@runfusion/fusion 0.71.0 → 0.72.0
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/dist/bin.js +2251 -2176
- package/dist/child-process-worker.js +1545 -1485
- package/dist/client/.vite/manifest.json +244 -244
- package/dist/client/assets/{AgentDetailView-BvY24zNh.js → AgentDetailView-Bq6qfKGR.js} +5 -5
- package/dist/client/assets/{AgentPermissionPolicyEditor-CYvJw48-.js → AgentPermissionPolicyEditor-Dah1P8IX.js} +2 -2
- package/dist/client/assets/{AgentsView-BWkWEfNs.js → AgentsView-Bu8h0vGY.js} +4 -4
- package/dist/client/assets/{ChatView-BhlVq9Re.js → ChatView-BTE8fIib.js} +1 -1
- package/dist/client/assets/{CommandCenter-DingokjC.js → CommandCenter-l4no66mI.js} +1 -1
- package/dist/client/assets/{DevServerView-kfNJk83M.js → DevServerView-Cuxhgjdv.js} +1 -1
- package/dist/client/assets/DirectoryPicker-tm1SS2jF.js +1 -0
- package/dist/client/assets/{DocumentsView-Bwc5HSg7.js → DocumentsView-Dg8lFF7X.js} +2 -2
- package/dist/client/assets/{EvalsView-BEr_MhJ4.js → EvalsView-TccfkTNy.js} +1 -1
- package/dist/client/assets/{ExperimentalAgentOnboardingModal-CZK-KtFP.js → ExperimentalAgentOnboardingModal-2qAtocIG.js} +1 -1
- package/dist/client/assets/{GoalsView-B_Qrm8po.js → GoalsView-Du_jIEn2.js} +1 -1
- package/dist/client/assets/{InsightsView-BfbclBHM.js → InsightsView-BxJ327Tj.js} +2 -2
- package/dist/client/assets/{MemoryView-V9Y08BtR.js → MemoryView-Blv0YUWC.js} +2 -2
- package/dist/client/assets/{PiExtensionsManager-B7fl5l3O.js → PiExtensionsManager-BUS_ZKwO.js} +2 -2
- package/dist/client/assets/{PluginManager-H32X557C.js → PluginManager-DM5-rNen.js} +1 -1
- package/dist/client/assets/{PullRequestView-Dhz86tnJ.js → PullRequestView-D7ozwDrc.js} +2 -2
- package/dist/client/assets/{ResearchView-DEObk9J2.js → ResearchView-CRGaOkBH.js} +1 -1
- package/dist/client/assets/{SecretsView-DFEWUbXI.js → SecretsView-Nwc-7xGn.js} +1 -1
- package/dist/client/assets/{SessionTerminal-CwfTrmor.js → SessionTerminal-gC7X57E6.js} +1 -1
- package/dist/client/assets/{SettingsModal-H1TNebmF.js → SettingsModal-CuEXiFb_.js} +4 -4
- package/dist/client/assets/{SettingsModal-2mlwjfVZ.js → SettingsModal-q_D1o7T-.js} +1 -1
- package/dist/client/assets/{SettingsTextareaRow-ByeSU4Pi.js → SettingsTextareaRow-DnsWtbkh.js} +1 -1
- package/dist/client/assets/SetupWizardModal-3-mXX0VJ.js +2 -0
- package/dist/client/assets/{SkillsView-DScNdDRz.js → SkillsView-Dw8m0G-9.js} +1 -1
- package/dist/client/assets/{ThemeDropdown-BKl0kouU.js → ThemeDropdown-C7qybW7w.js} +1 -1
- package/dist/client/assets/{TodoView-_HojIE_Y.js → TodoView-r_qHhO28.js} +2 -2
- package/dist/client/assets/{WorkflowNodeEditor-CoQYdUYX.js → WorkflowNodeEditor-B0TGhu5B.js} +1 -1
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-vIoH_tGm.js → architectureDiagram-3BPJPVTR-9REjGWnr.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-BqjSE9AM.js → blockDiagram-GPEHLZMM-OATfTc06.js} +1 -1
- package/dist/client/assets/{c4Diagram-AAUBKEIU-TWEWVE4T.js → c4Diagram-AAUBKEIU-B-nq1avj.js} +1 -1
- package/dist/client/assets/channel-BW-0I-xJ.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-CJM3p9Fh.js → chunk-2J33WTMH-Dds2A4Un.js} +1 -1
- package/dist/client/assets/{chunk-4BX2VUAB-Bf_1wJ7O.js → chunk-4BX2VUAB-Dc-jRxxZ.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-CI4ThikJ.js → chunk-55IACEB6-CKtwSOvQ.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-C2TasaKk.js → chunk-727SXJPM-DbRZhQCr.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-BqKUxt3g.js → chunk-AQP2D5EJ-Dq_cSIeh.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-CdK77AxG.js → chunk-FMBD7UC4-BmnvYNOo.js} +1 -1
- package/dist/client/assets/{chunk-ND2GUHAM-TE8zbIZ3.js → chunk-ND2GUHAM-D6nyZn0C.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-7lgttGIx.js → chunk-QZHKN3VN-FFojVCmd.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-DfBIljo4.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DfBIljo4.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-DsK8EBeo.js → cose-bilkent-S5V4N54A-DysS3-yZ.js} +1 -1
- package/dist/client/assets/{dagre-BM42HDAG-COza1ss6.js → dagre-BM42HDAG-DgL7uNq4.js} +1 -1
- package/dist/client/assets/{dashboard-view-ILJ_vnYK.js → dashboard-view-Bu_nB-cd.js} +1 -1
- package/dist/client/assets/{dashboard-view-D_etacMS.js → dashboard-view-DlxD_dta.js} +1 -1
- package/dist/client/assets/{dashboard-view-JEFD-Zgw.js → dashboard-view-ln6_a3ZY.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-Co_F0-vp.js → diagram-2AECGRRQ-DTACb17z.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-BD_n7vU0.js → diagram-5GNKFQAL-DqdKDR_d.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-SFnuzet_.js → diagram-KO2AKTUF-CCKa3iUW.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-CFYeR0mH.js → diagram-LMA3HP47-C2SLmXdM.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-DOVfqKgw.js → diagram-OG6HWLK6-Dz9wXgRN.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-DkeW3bDN.js → erDiagram-TEJ5UH35-GGHapzlB.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-CVaNMQl_.js → flowDiagram-I6XJVG4X-B3SLxAlP.js} +1 -1
- package/dist/client/assets/{folder-open-BY1Gp9Wf.js → folder-open-BWBZSyO2.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-BQJ0x5Hq.js → ganttDiagram-6RSMTGT7-DYveq-32.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CIt0P2Lg.js → gitGraphDiagram-PVQCEYII-Bxh-7IFt.js} +1 -1
- package/dist/client/assets/{index-GJLKrqhe.css → index-CiqkhNwQ.css} +1 -1
- package/dist/client/assets/{index-ClPjlOHJ.js → index-D8sgsB8q.js} +268 -268
- package/dist/client/assets/{infoDiagram-5YYISTIA-B1KKCn80.js → infoDiagram-5YYISTIA-B3_g2TQW.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-CzG1cEeg.js → ishikawaDiagram-YF4QCWOH-CExRn4qZ.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-CNB7oM4Q.js → journeyDiagram-JHISSGLW-Dgck68vd.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-D8vXTzfs.js → kanban-definition-UN3LZRKU-B258_39Z.js} +1 -1
- package/dist/client/assets/{mermaid.core-BUhJJv1M.js → mermaid.core-uCT9za93.js} +4 -4
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-y_XyU0Us.js → mindmap-definition-RKZ34NQL-DHevd0he.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-MB9aZtTc.js → pieDiagram-4H26LBE5-rTbXqg0x.js} +1 -1
- package/dist/client/assets/{puzzle-CE00Ce2g.js → puzzle-D7NHfczg.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-hF7q33gK.js → quadrantDiagram-W4KKPZXB-C-N3JbLv.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-BIOIzbEd.js → requirementDiagram-4Y6WPE33-DNINb6LP.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BpLzUxJ8.js → sankeyDiagram-5OEKKPKP-UI7SyvRN.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-CLXamQhZ.js → sequenceDiagram-3UESZ5HK-pc1RDjwM.js} +1 -1
- package/dist/client/assets/{shield-alert-BhLVV0rp.js → shield-alert-c_--H0ce.js} +1 -1
- package/dist/client/assets/{standing-instructions-template-96KSNan7.js → standing-instructions-template-aTeHy5lT.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-CPRWhQtZ.js → stateDiagram-AJRCARHV-CEiZfKWc.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-8GvpOVMc.js → stateDiagram-v2-BHNVJYJU-B7aNz5OD.js} +1 -1
- package/dist/client/assets/{timeline-definition-PNZ67QCA-BAAldJMW.js → timeline-definition-PNZ67QCA-DyE71jn0.js} +1 -1
- package/dist/client/assets/{upload-DbKZcYCW.js → upload-YGrA50-5.js} +1 -1
- package/dist/client/assets/{users-ccVe3aKQ.js → users-fxiLvP6C.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-DGSAcrfx.js → vennDiagram-CIIHVFJN-DX-6Y82D.js} +1 -1
- package/dist/client/assets/{wardley-L42UT6IY-CLGvNiAx.js → wardley-L42UT6IY-ew7KQxeH.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-BhU8FLGx.js → wardleyDiagram-YWT4CUSO-DqSCrJdO.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-BQ6AzTfE.js → xychartDiagram-2RQKCTM6-CEtZEj45.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/version.json +1 -1
- package/dist/extension.js +1767 -1707
- package/package.json +1 -1
- package/dist/client/assets/DirectoryPicker-Cluyep4u.js +0 -1
- package/dist/client/assets/SetupWizardModal-BFZnVJX1.js +0 -2
- package/dist/client/assets/channel-hhQEu5zM.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-C2Thhy7D.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C2Thhy7D.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{aD as F,aE as L,aF as D,aG as J,aH as Y,aI as H,aJ as Q,aK as Z,V as O,T as K,N as ee,R as se,a8 as ae,a6 as te}from"./index-D8sgsB8q.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const re=300,ne=15e3;function B(r){if(!r.trim())return;const s=Number(r);return Number.isFinite(s)?s:void 0}function w(...r){for(const s of r)if(Array.isArray(s))return s;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function X(r){const s=f(r),m=f(s.taskSnapshot);return{id:String(s.id??s.evalId??""),runId:String(s.runId??s.batchId??""),taskId:String(s.taskId??m.taskId??""),taskTitle:String(m.title??s.taskTitle??s.title??"Untitled task"),createdAt:String(s.createdAt??s.timestamp??s.updatedAt??new Date(0).toISOString()),overallScore:typeof s.overallScore=="number"?s.overallScore:null,maxScore:typeof s.maxScore=="number"?s.maxScore:null,categoryScores:w(s.categoryScores,f(s.scores).categories)}}function ce(r){const s=f(r);return{...X(s),rationale:String(s.rationale??s.summary??""),evidence:w(s.evidence,f(s.details).evidence),followUps:w(s.followUps,f(s.recommendations).followUps)}}function ie(r){const s=r?.projectId,m=s??"",t=`${D.EVALS_RUNS_PREFIX}${m}`,h=`${D.EVALS_RESULTS_PREFIX}${m}`,p=F(t,{maxAgeMs:L}),v=F(h,{maxAgeMs:L}),S=l.useRef(Array.isArray(p)&&p.length>0||Array.isArray(v)&&v.length>0),[i,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[A,k]=l.useState(()=>Array.isArray(p)?p:[]),[o,M]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[P,b]=l.useState(null),[a,d]=l.useState(0),[y,j]=l.useState(!S.current),[G,q]=l.useState(null),C=l.useRef(0),z=l.useRef(s),_=l.useRef(u);_.current=u;const I=l.useCallback(async()=>{const n=++C.current;S.current||j(!0),q(null);try{const[c,x]=await Promise.all([J({q:i.q||void 0,runId:i.runId||void 0,scoreMin:B(i.scoreMin),scoreMax:B(i.scoreMax),limit:100,offset:0},s),Y(s)]);if(n!==C.current)return;const E=w(c.results,c.evals,c.items).map(X);M(E),H(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),d(typeof c.count=="number"?c.count:E.length);const V=w(x.runs,x.items).map(U=>{const N=f(U),$=f(N.counts);return{id:String(N.id??""),createdAt:String(N.createdAt??""),completedAt:typeof N.completedAt=="string"?N.completedAt:void 0,status:String(N.status??"pending"),evaluatedTaskCount:typeof $.totalTasks=="number"?$.totalTasks:0}});k(V),H(t,V,{maxBytes:5e5}),S.current=!0,_.current&&!E.some(U=>U.id===_.current)&&(R(null),b(null))}catch(c){if(n!==C.current)return;q(c instanceof Error?c.message:"Failed to load evals")}finally{n===C.current&&j(!1)}},[i.q,i.runId,i.scoreMax,i.scoreMin,s,h,t]),T=l.useCallback(async n=>{const c=await Q(n,s),x=c.result??c;b(ce(x))},[s]);l.useEffect(()=>{if(z.current===s)return;z.current=s;const n=F(t,{maxAgeMs:L}),c=F(h,{maxAgeMs:L}),x=Array.isArray(n)&&n.length>0||Array.isArray(c)&&c.length>0;k(Array.isArray(n)?n:[]),M(Array.isArray(c)?c:[]),j(!x),S.current=x},[s,h,t]),l.useEffect(()=>{const n=window.setTimeout(()=>{I()},re);return()=>window.clearTimeout(n)},[I]),l.useEffect(()=>{if(!u){b(null);return}T(u)},[T,u]),l.useEffect(()=>{const n=window.setInterval(()=>{I(),u&&T(u)},ne);return()=>window.clearInterval(n)},[T,I,u]);const W=l.useCallback(n=>{_.current=n,R(n)},[]);return{loading:y,error:G,results:o,count:a,runs:A,filters:i,setFilters:g,refresh:I,selectedEvalId:u,setSelectedEvalId:W,selectedEval:P}}function xe({projectId:r,onOpenSettings:s,onOpenTaskDetail:m}){const{t}=le("app"),{loading:h,error:p,results:v,runs:S,filters:i,setFilters:g,selectedEvalId:A,setSelectedEvalId:k,selectedEval:o,refresh:M}=ie({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let a=!1;return Z(r).then(d=>{if(a)return;const y=d.evalSettings?.enabled;R(y??!1)}).catch(()=>{a||R(!1)}),()=>{a=!0}},[r]);const P=v.length>0,b=l.useMemo(()=>v.find(a=>a.id===A)??null,[v,A]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(O,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__body",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:t("evals.searchPlaceholder","Search task or rationale"),value:i.q,onChange:a=>g(d=>({...d,q:a.target.value}))}),e.jsxs("select",{className:"select",value:i.runId,onChange:a=>g(d=>({...d,runId:a.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:i.scoreMin,onChange:a=>g(d=>({...d,scoreMin:a.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:i.scoreMax,onChange:a=>g(d=>({...d,scoreMax:a.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void M(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(se,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(ae,{label:t("evals.loading","Loading evals…")})}),p&&e.jsx("p",{className:"evals-state evals-state--error",children:p}),!h&&!p&&!P&&e.jsx("p",{className:"evals-state",children:t("evals.empty","No evals yet. Scheduled evals review tasks completed since the last run.")}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:v.map(a=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${a.id===A?"evals-result--active":""}`,type:"button",onClick:()=>k(a.id),children:[e.jsx("span",{className:"evals-result-title",children:a.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[a.taskId," · ",a.runId," · ",a.overallScore??t("evals.naPlaceholder","n/a")]})]})},a.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!o&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),o&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:b?.taskTitle??o.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[o.taskId," · ",o.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:o.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:o.categoryScores.map(a=>e.jsxs("li",{children:[a.category,": ",a.finalScore]},a.category))}),e.jsx("p",{className:"evals-rationale",children:o.rationale||t("evals.noRationale","No rationale recorded.")}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.evidenceHeading","Evidence")}),e.jsx("ul",{className:"evals-links",children:o.evidence.map((a,d)=>{const y=typeof a.metadata?.taskId=="string"?a.metadata.taskId:void 0,j=typeof a.metadata?.url=="string"?a.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:a.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[a.ref,e.jsx(te,{size:14})]}):e.jsx("span",{children:a.ref})},`${a.ref}-${d}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[o.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),o.followUps.map(a=>e.jsxs("li",{children:[e.jsx("strong",{children:a.title}),e.jsx("p",{children:a.rationale})]},a.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(O,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__empty",children:[e.jsx("h2",{className:"evals-title",children:t("evals.disabledTitle","Scheduled evals are disabled")}),e.jsx("p",{className:"evals-empty-copy",children:t("evals.enablePrompt","Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations.")}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>s?.("scheduled-evals"),children:[e.jsx(ee,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{xe as EvalsView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as n}from"./vendor-react-SZ_qB27O.js";import{v as F,w as V,x as W,y as z,z as B,B as G}from"./index-
|
|
1
|
+
import{r as s,j as n}from"./vendor-react-SZ_qB27O.js";import{v as F,w as V,x as W,y as z,z as B,B as G}from"./index-D8sgsB8q.js";import{u as U}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";function en({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:_="create",existingAgentConfig:L}){const{t:e}=U("app"),[m,d]=s.useState("initial"),[f,S]=s.useState(""),[c,k]=s.useState(null),[C,w]=s.useState(""),[I,A]=s.useState("answer"),[v,p]=s.useState(""),[t,T]=s.useState(null),[H,g]=s.useState(null),[E,y]=s.useState([]),b=_==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),S(""),k(null),w(""),A("answer"),p(""),T(null),g(null),y([])},[]),q=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=V(c,x,{onThinking:i=>{o.current&&y($=>{const h=[...$],j=h[h.length-1];return j&&!j.question?(h[h.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${i}`},h):[...h,{response:{},thinkingOutput:i}]})},onQuestion:i=>{o.current&&(w(i.question),A(i.id),d("question"))},onSummary:i=>{o.current&&(T(i),d("summary"))},onError:i=>{o.current&&(g(i),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const u=async()=>{o.current=!1;try{c&&await z(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const r=a=>a==null||a===""?n.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:e("agents.onboarding.notSet","Not set")}):n.jsx("span",{children:a}),D=async()=>{d("loading"),g(null);try{const a=await B(f,{mode:_,existingAgentConfig:L,existingAgents:P.map(i=>({id:i.id,name:i.name,role:i.role})),templates:q},x);if(!o.current)return;k(a.sessionId)}catch(a){if(!o.current)return;g(a.message),d("error")}},Q=async()=>{if(c){d("loading"),g(null);try{const a={[I]:v};if(y(i=>[...i,{question:{id:I,type:"text",question:C},response:a}]),await G(c,a,x),!o.current)return;p("")}catch(a){if(!o.current)return;g(a.message),d("error")}}},O=async()=>{t&&(M(t),await u())};return n.jsx("div",{className:"modal-overlay open",role:"presentation",children:n.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":e("agents.onboarding.dialogLabel","AI Interview"),children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{children:e("agents.onboarding.title","AI Interview")}),n.jsx("button",{className:"modal-close",onClick:()=>void u(),"aria-label":e("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&n.jsx(W,{entries:E}),m==="initial"&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?e("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):e("agents.onboarding.intentLabelCreate","What should this new agent own?")}),n.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>S(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void D(),children:b?e("agents.onboarding.startInterview","Start interview"):e("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(m==="loading"||m==="question")&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||e("agents.onboarding.thinking","Thinking...")}),n.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:v,onChange:a=>p(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:m==="loading"||!v.trim(),onClick:()=>void Q(),children:e("agents.onboarding.continue","Continue")})]})]}),m==="summary"&&t&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{children:b?e("agents.onboarding.updatedDraftReady","Updated draft ready for review"):e("agents.onboarding.draftReady","Draft ready for review")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:e("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionIdentity","Identity")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldName","Name")}),n.jsx("dd",{children:r(t.name)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRole","Role")}),n.jsx("dd",{children:r(t.role)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTitle","Title")}),n.jsx("dd",{children:r(t.title)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldIcon","Icon")}),n.jsx("dd",{children:r(t.icon)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldReportsTo","Reports To")}),n.jsx("dd",{children:r(t.reportsTo)})]})]})]}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionConfiguration","Configuration")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.instructionsText)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSoul","Soul")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.soul)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldAgentMemory","Agent Memory")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.memory)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSkills","Skills")}),n.jsx("dd",{children:r(t.skills?.join(", "))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldThinkingLevel","Thinking Level")}),n.jsx("dd",{children:r(t.thinkingLevel)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldMaxTurns","Max Turns")}),n.jsx("dd",{children:r(t.maxTurns)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTemplate","Template")}),n.jsx("dd",{children:r(t.templateId)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldPatternAgent","Pattern Agent")}),n.jsx("dd",{children:r(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),n.jsx("dd",{children:r(t.heartbeatProcedurePath)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),n.jsx("dd",{children:r(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),n.jsx("dd",{children:r(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?e("agents.onboarding.yes","yes"):e("agents.onboarding.no","no"))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldModelHint","Model Hint")}),n.jsx("dd",{children:r(t.modelHint)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),n.jsx("dd",{children:r(t.runtimeHint)})]})]})]}),t.rationale&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRationale","Rationale")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",onClick:()=>void O(),children:b?e("agents.onboarding.applyDraftSettings","Apply draft to settings form"):e("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),m==="error"&&H&&n.jsxs("div",{className:"form-group",children:[n.jsx("div",{className:"form-error",children:H}),n.jsx("div",{className:"modal-actions",children:n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.close","Close")})})]})]})})}export{en as ExperimentalAgentOnboardingModal};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,S as Es,h as Ss,r as $s,j as Ms,X as Cs,k as Ts,l as As}from"./index-
|
|
1
|
+
import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,S as Es,h as Ss,r as $s,j as Ms,X as Cs,k as Ts,l as As}from"./index-D8sgsB8q.js";import{u as Gs}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const Ls=5,Ds=3,Ps=280;function h(r,m){if(!m)return r;const d=r.includes("?")?"&":"?";return`${r}${d}projectId=${encodeURIComponent(m)}`}function is(r){return!!(r&&typeof r=="object"&&"code"in r&&r.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function qs({initialGoals:r,anchorGoalId:m,projectId:d,onNavigateToMission:as}){const{t:a}=Gs("app"),[c,k]=n.useState(()=>r??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(r===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[y,F]=n.useState(""),[U,N]=n.useState(""),[R,u]=n.useState(null),[O,_]=n.useState(!1),[v,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,W]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,z]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(r!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",d));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[r,d]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",d));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[d,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,d));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Ds&&G<=Ls;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=y.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Ts(s,d);N(e)}catch(e){u(As(e))}finally{E(!1)}}async function fs(){const s=y.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",d),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:U})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{W(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,d),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{W(!1)}}function ks(s){return s.length>Ps||s.includes(`
|
|
2
2
|
`)}function ys(s){rs(e=>{const i=new Set(e);return i.has(s)?i.delete(s):i.add(s),i})}function Z(s){const e=new Set((x[s]??[]).map(i=>i.id));return ds.filter(i=>!e.has(i.id))}async function ss(s){const e=await J(s);C(i=>({...i,[s]:e})),z(i=>({...i,[s]:""}))}async function vs(s){const e=T[s];if(e)try{K(s),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,d),{method:"POST"});if(!i.ok)throw new Error(`Failed to link mission (${i.status})`);await ss(s)}catch{l(a("goals.linkMissionError","Unable to link mission right now. Please try again."))}finally{K(null)}}async function xs(s,e){try{X(`${s}:${e}`),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,d),{method:"DELETE"});if(!i.ok)throw new Error(`Failed to unlink mission (${i.status})`);await ss(s)}catch{l(a("goals.unlinkMissionError","Unable to unlink mission right now. Please try again."))}finally{X(null)}}async function ts(s){const e=s.status==="active"?`/api/goals/${s.id}/archive`:`/api/goals/${s.id}/unarchive`;try{l(null);const i=await fetch(h(e,d),{method:"POST"});if(i.ok){const g=await i.json();k(b=>b.map(es=>es.id===g.id?g:es));return}let o=null;try{o=await i.json()}catch{o=null}if(i.status===409&&is(o)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}l(a("goals.updateError","Unable to update goal status right now. Please try again."))}catch{l(a("goals.updateError","Unable to update goal status right now. Please try again."))}}return t.jsxs("section",{className:"goals-view","data-testid":"goals-view",children:[t.jsx(js,{icon:ws,title:a("goals.title","Goals"),actions:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"goals-count","data-testid":"goals-active-count",children:a("goals.activeCount","{{count}} active goals",{count:G})}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-add-button",onClick:ms,"data-testid":"goals-add-button",children:[t.jsx(Ns,{size:18,"aria-hidden":"true"}),a("goals.addGoal","Add Goal")]})]})}),t.jsxs("div",{className:"goals-view__content",children:[os?t.jsxs("div",{className:"card goals-form","data-testid":"goals-form",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-title",children:a("goals.labelTitle","Title")}),t.jsx("input",{id:"goals-form-title",className:"input",type:"text",value:y,maxLength:200,onChange:s=>F(s.target.value),"data-testid":"goals-form-title"}),t.jsxs("div",{className:"goals-form-label-row",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-description",children:a("goals.labelDescription","Description")}),t.jsxs("button",{type:"button",className:"btn goals-form-draft-button",onClick:()=>void ps(),disabled:!y.trim()||v,"data-testid":"goals-form-draft-ai",children:[t.jsx(Es,{"aria-hidden":"true"}),v?a("goals.drafting","Drafting…"):a("goals.draftWithAi","Draft with AI")]})]}),t.jsx("textarea",{id:"goals-form-description",className:"input",value:U,maxLength:5e3,onChange:s=>N(s.target.value),"data-testid":"goals-form-description"}),R?t.jsx("p",{className:"form-error goals-error",role:"alert",children:R}):null,t.jsxs("div",{className:"goals-form-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void fs(),disabled:O||v,"data-testid":"goals-form-submit",children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Y,disabled:O||v,"data-testid":"goals-form-cancel",children:a("actions.cancel","Cancel")})]})]}):null,gs?t.jsx("p",{className:"goals-warning",role:"status",children:a("goals.capWarning","Approaching the 5-active goal cap. Keep active goals focused.")}):null,D?t.jsx("p",{className:"form-error goals-error",role:"alert","data-testid":"goals-error",children:D}):null,w?t.jsx("p",{className:"goals-loading",role:"status","data-testid":"goals-loading",children:a("goals.loading","Loading goals…")}):null,!w&&c.length===0?t.jsx("div",{className:"goals-empty card","data-testid":"goals-empty-state",children:a("goals.emptyState","No goals yet. Add one to begin tracking strategic outcomes.")}):null,!w&&c.length>0?t.jsx("div",{className:"goals-list","data-testid":"goals-list",children:c.map(s=>t.jsxs("article",{id:`goal-card-${s.id}`,className:`card goals-card ${s.status==="archived"?"goals-card-archived":""} ${ns===s.id?"goals-card--anchored":""}`.trim(),"data-testid":`goal-card-${s.id}`,children:[S===s.id?t.jsxs("div",{className:"goals-card-main goals-card-edit",children:[t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-title-${s.id}`,children:a("goals.labelTitle","Title")}),t.jsx("input",{id:`goal-edit-title-${s.id}`,className:"input",type:"text",value:q,maxLength:200,onChange:e=>$(e.target.value),"data-testid":`goal-edit-title-${s.id}`}),t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-description-${s.id}`,children:a("goals.labelDescription","Description")}),t.jsx("textarea",{id:`goal-edit-description-${s.id}`,className:"input",value:B,maxLength:5e3,onChange:e=>M(e.target.value),"data-testid":`goal-edit-description-${s.id}`}),H?t.jsx("p",{className:"form-error goals-error",role:"alert",children:H}):null,t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void bs(),disabled:I,"data-testid":`goal-edit-save-${s.id}`,children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Q,disabled:I,"data-testid":`goal-edit-cancel-${s.id}`,children:a("actions.cancel","Cancel")})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"goals-card-main",children:[t.jsx("h3",{className:"goals-card-title",children:s.title}),s.description?(()=>{const e=ks(s.description),i=ls.has(s.id);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`markdown-body goals-card-description ${e&&!i?"goals-card-description-collapsed":""}`.trim(),children:t.jsx(Ss,{remarkPlugins:[$s],children:s.description})}),e?t.jsx("button",{type:"button",className:"btn goals-card-description-toggle","aria-expanded":i,"data-testid":`goal-description-toggle-${s.id}`,onClick:()=>ys(s.id),children:i?a("actions.showLess","Show less"):a("actions.showMore","Show more")}):null]})})():null,t.jsxs("p",{className:"goals-card-status",children:[a("goals.status","Status"),": ",s.status]})]}),t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn",onClick:()=>hs(s),"data-testid":`goal-edit-${s.id}`,children:a("actions.edit","Edit")}),s.status==="active"?t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-archive-${s.id}`,children:a("goals.archive","Archive")}):t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-unarchive-${s.id}`,children:a("goals.unarchive","Unarchive")})]})]}),t.jsxs("section",{className:"goals-linked-missions","aria-label":a("goals.linkedMissions","Linked missions"),children:[t.jsxs("div",{className:"goals-linked-missions-header",children:[t.jsx("h4",{className:"goals-linked-missions-title",children:a("goals.linkedMissionsTitle","Linked Missions")}),t.jsx("span",{className:"goals-linked-missions-count",children:a("goals.linkedMissionsCount",{count:x[s.id]?.length??0,defaultValue_one:"{{count}} linked",defaultValue_other:"{{count}} linked"})})]}),t.jsxs("div",{className:"goals-linked-missions-controls",children:[t.jsxs("select",{className:"input goals-linked-missions-picker","data-testid":`goal-mission-picker-${s.id}`,value:T[s.id]??"",onChange:e=>z(i=>({...i,[s.id]:e.target.value})),"aria-label":a("goals.missionPicker","Mission to link"),disabled:A===s.id||Z(s.id).length===0,children:[t.jsx("option",{value:"",children:a("goals.selectMission","Select a mission")}),Z(s.id).map(e=>t.jsx("option",{value:e.id,children:e.title},e.id))]}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-linked-missions-link-button","data-testid":`goal-mission-link-button-${s.id}`,disabled:!T[s.id]||A===s.id,onClick:()=>void vs(s.id),children:[t.jsx(Ms,{size:16,"aria-hidden":"true"}),A===s.id?a("goals.linkingMission","Linking…"):a("goals.linkMission","Link mission")]})]}),(x[s.id]?.length??0)>0?t.jsx("div",{className:"goals-linked-missions-list",children:(x[s.id]??[]).map(e=>t.jsxs("div",{className:"goals-linked-mission-chip","data-testid":`goal-linked-mission-chip-${e.id}`,children:[t.jsx("button",{type:"button",className:"btn goals-linked-mission-link",onClick:()=>as?.(e.id),children:e.title}),t.jsx("span",{className:"goals-linked-mission-status",children:e.status}),t.jsx("button",{type:"button",className:"btn-icon goals-linked-mission-unlink","data-testid":`goal-linked-mission-unlink-${e.id}`,"aria-label":a("goals.unlinkMission","Unlink mission"),disabled:us===`${s.id}:${e.id}`,onClick:()=>void xs(s.id,e.id),children:t.jsx(Cs,{size:16,"aria-hidden":"true"})})]},e.id))}):t.jsx("p",{className:"goals-linked-missions-empty",children:a("goals.noLinkedMissions","No linked missions.")})]})]},s.id))}):null]})]})}export{qs as GoalsView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,
|
|
1
|
+
import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,aD as ce,aE as we,aF as Ce,bk as je,bl as Ye,aI as Ie,bm as Qe,bn as Je,bo as Ze,bp as es,bq as ss,br as ts,bs as Me,bt as is,bu as ns,bv as Ae,V as as,S as A,bw as rs,X as Ne,bx as fe,R as N,N as cs,by as ls,aB as _e,g as le,bz as Ee,bh as os,P as De,a6 as hs,aQ as Pe,bA as gs}from"./index-D8sgsB8q.js";import{u as $e}from"./vendor-i18n-GF3RlKbq.js";import{U as Fe}from"./users-fxiLvP6C.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,aB as ce,aC
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const ms=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],fs=ze("chart-line",ms),me=["architecture","quality","workflow","performance","reliability","security","ux","testability","documentation","dependency","features","competitive_analysis","research","trends","other"],Re={quality:"Quality",performance:"Performance",architecture:"Architecture",security:"Security",reliability:"Reliability",ux:"User Experience",testability:"Testability",documentation:"Documentation",dependency:"Dependencies",workflow:"Workflow",other:"Other",features:"Features",competitive_analysis:"Competitive Analysis",research:"Research",trends:"Trends"};function vs(d){const{t:g}=$e("app"),$=d??"",k=`${Ce.INSIGHTS_PREFIX}${$}`,S=`${Ce.INSIGHT_LATEST_RUN_PREFIX}${$}`,s=ce(k,{maxAgeMs:we}),V=ce(S,{maxAgeMs:je}),E=c.useRef(Array.isArray(s)&&s.length>0),G=c.useCallback(a=>g(`insights.category.${a}`,Re[a]??a),[g]),[v,x]=c.useState(()=>Array.isArray(s)?s:[]),[T,W]=c.useState(()=>me.map(a=>({category:a,label:Re[a]??a,items:[],isLoading:!1,error:null}))),[K,L]=c.useState(!(Array.isArray(s)&&s.length>0)),[Y,U]=c.useState(null),[Q,z]=c.useState(V??null),[J,B]=c.useState(!1),[Z,F]=c.useState(null),[ee,_]=c.useState(new Map),[se,C]=c.useState(new Map),[u,w]=c.useState(new Map),[m,D]=c.useState(new Map),[H,j]=c.useState(!1),R=c.useCallback(async()=>{E.current||L(!0),U(null);try{const t=(await Ye({status:void 0,limit:1e3},d)).insights.filter(l=>l.status!=="dismissed");x(t),Ie(k,t.length>500?t.slice(0,500):t,{maxBytes:5e5});const r=await Qe(d);r.runs.length>0&&(z(r.runs[0]),Ie(S,r.runs[0],{maxBytes:5e5})),E.current=!0}catch(a){const t=a instanceof Error?a.message:"Failed to fetch insights";U(t)}finally{L(!1)}},[k,S,d]),y=c.useCallback(()=>{j(a=>!a)},[]),te=c.useCallback(async(a,t,r)=>{B(!0),F(null);try{const l=await Je("manual",void 0,d,a,t,r);z(l),l.status==="completed"?await R():l.status==="failed"&&l.error&&F(l.error)}catch(l){if(l instanceof Ze&&l.status===409&&l.details?.code==="ACTIVE_RUN_CONFLICT"){const ie=typeof l.details.activeRunId=="string"?l.details.activeRunId:null;if(ie)try{const de=await es(ie,d);z(de)}catch{}throw F("Insight generation is already running"),l}const f=l instanceof Error?l.message:"Failed to generate insights";throw F(f),l}finally{B(!1)}},[d,R]),O=c.useCallback(async a=>{_(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{await ss(a,d),x(t=>t.filter(r=>r.id!==a)),_(t=>{const r=new Map(t);return r.set(a,{running:!1,error:null}),r})}catch(t){const r=t instanceof Error?t.message:"Failed to dismiss insight";throw _(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]),oe=c.useCallback(async a=>{C(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{const t=await ts(a,d);return await Me(a,d),x(r=>r.map(l=>l.id===a?{...l,status:"archived",updatedAt:new Date().toISOString()}:l)),C(r=>{const l=new Map(r);return l.set(a,{running:!1,error:null}),l}),{title:t.suggestedTitle,description:t.suggestedDescription}}catch(t){const r=t instanceof Error?t.message:"Failed to create task";throw C(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]);c.useEffect(()=>{const a=new Map;for(const t of me)a.set(t,[]);for(const t of v){if(!H&&t.status==="archived")continue;const r=a.get(t.category)??[];a.set(t.category,[...r,t])}W(me.map(t=>({category:t,label:G(t),items:a.get(t)??[],isLoading:!1,error:null})))},[v,H,G]);const he=c.useCallback(async a=>{w(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{await Me(a,d),x(t=>t.map(r=>r.id===a?{...r,status:"archived",updatedAt:new Date().toISOString()}:r)),w(t=>{const r=new Map(t);return r.set(a,{running:!1,error:null}),r})}catch(t){const r=t instanceof Error?t.message:"Failed to archive insight";throw w(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]),ge=c.useCallback(async a=>{D(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{await is(a,d),x(t=>t.map(r=>r.id===a?{...r,status:"confirmed",updatedAt:new Date().toISOString()}:r)),D(t=>{const r=new Map(t);return r.set(a,{running:!1,error:null}),r})}catch(t){const r=t instanceof Error?t.message:"Failed to unarchive insight";throw D(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]),b=c.useMemo(()=>T.reduce((a,t)=>a+t.items.length,0),[T]),X=c.useMemo(()=>0,[]),p=c.useMemo(()=>v.filter(a=>a.status==="archived").length,[v]);return c.useEffect(()=>{const a=ce(k,{maxAgeMs:we}),t=ce(S,{maxAgeMs:je}),r=Array.isArray(a)&&a.length>0;x(Array.isArray(a)?a:[]),z(t??null),L(!r),E.current=r},[k,S]),c.useEffect(()=>{R()},[R]),{sections:T,loading:K,error:Y,latestRun:Q,isRunInFlight:J,runError:Z,refresh:R,runInsights:te,dismiss:O,createTask:oe,archive:he,unarchive:ge,toggleShowArchived:y,dismissStates:ee,createTaskStates:se,archiveStates:u,unarchiveStates:m,totalCount:b,dismissedCount:X,archivedCount:p,showArchived:H}}const Ge=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Te(d){return Ge.some(g=>d.title.startsWith(g))}const Le={architecture:us,quality:_e,workflow:Pe,performance:Ee,reliability:N,security:le,ux:Fe,testability:fe,documentation:hs,dependency:De,features:os,competitive_analysis:Fe,research:fs,trends:Ee,other:A};function Cs({projectId:d,addToast:g,onClose:$,onCreateTask:k,models:S}){const{t:s}=$e("app"),{sections:V,loading:E,error:G,latestRun:v,isRunInFlight:x,runError:T,refresh:W,runInsights:K,dismiss:L,createTask:Y,archive:U=async()=>{},unarchive:Q=async()=>{},toggleShowArchived:z=()=>{},dismissStates:J,createTaskStates:B,archiveStates:Z=new Map,unarchiveStates:F=new Map,totalCount:ee,archivedCount:_=0,showArchived:se=!1}=vs(d),[C,u]=c.useState(null),[w,m]=c.useState("info"),[D,H]=c.useState(!1),[j,R]=c.useState(!1),[y,te]=c.useState(()=>localStorage.getItem("fusion-insight-model")??""),[O,oe]=c.useState(()=>localStorage.getItem("fusion-insight-thinking")??""),[he,ge]=c.useState([]),[b,X]=c.useState([]),[p,a]=c.useState([]),[t,r]=c.useState();c.useEffect(()=>{S||ns().then(i=>{ge(i.models),X(i.favoriteProviders),a(i.favoriteModels),r(i.resolvedPlanningProvider);const n=localStorage.getItem("fusion-insight-model");n&&(i.models.some(h=>`${h.provider}/${h.id}`===n)||(localStorage.removeItem("fusion-insight-model"),te("")))}).catch(()=>{})},[S]);const l=S??he,f=c.useMemo(()=>b.length>0?b:t?[t]:[],[b,t]),ie=c.useCallback(async i=>{const o=b.includes(i)?b.filter(h=>h!==i):[i,...b];X(o);try{await Ae({favoriteProviders:o,favoriteModels:p})}catch{X(b)}},[b,p]),de=c.useCallback(async i=>{const o=p.includes(i)?p.filter(h=>h!==i):[i,...p];a(o);try{await Ae({favoriteProviders:b,favoriteModels:o})}catch{a(p)}},[p,b]),Ue=c.useCallback(i=>{te(i),i?localStorage.setItem("fusion-insight-model",i):localStorage.removeItem("fusion-insight-model")},[]),Be=c.useCallback(i=>{oe(i),i?localStorage.setItem("fusion-insight-thinking",i):localStorage.removeItem("fusion-insight-thinking")},[]),q=c.useMemo(()=>V.filter(i=>i.items.length>0),[V]),ve=c.useMemo(()=>q.reduce((i,n)=>i+n.items.filter(Te).length,0),[q]),I=c.useMemo(()=>j?q.map(i=>({...i,items:i.items.filter(Te)})).filter(i=>i.items.length>0):q,[q,j]),[P,ue]=c.useState(null);c.useEffect(()=>{if(I.length===0){P!==null&&ue(null);return}P&&I.some(n=>n.category===P&&n.items.length>0)||ue(I[0].category)},[I,P]);const M=c.useMemo(()=>I.find(i=>i.category===P)??I[0],[I,P]);c.useEffect(()=>{if(C){const i=setTimeout(()=>u(null),5e3);return()=>clearTimeout(i)}},[C]);const be=c.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),m("info");let i,n;if(y){const o=y.indexOf("/");if(o!==-1){const h=y.slice(0,o),ne=y.slice(o+1);h&&ne&&(i=h,n=ne)}}await K(i,n,O||void 0),u(s("insights.generationStarted","Insight generation started")),m("success"),g(s("insights.generationStarted","Insight generation started"),"success")}catch(i){const n=i instanceof Error?i.message:s("insights.failedToStart","Failed to start generation");if(n==="Insight generation is already running"){u(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),m("info"),g(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(n),m("error"),g(n,"error")}},[K,g,y,O,s]),He=c.useCallback(async(i,n)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:n})),m("info"),await L(i),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:n})),m("success"),g(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:n}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToDismiss","Failed to dismiss insight");u(h),m("error"),g(h,"error")}},[L,g,s]),Oe=c.useCallback(async(i,n)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:n})),m("info"),await U(i),u(s("insights.archived",'Archived "{{title}}"',{title:n})),m("success"),g(s("insights.archivedMsg","Insight archived: {{title}}",{title:n}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToArchive","Failed to archive insight");u(h),m("error"),g(h,"error")}},[U,g,s]),Xe=c.useCallback(async(i,n)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:n})),m("info"),await Q(i),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:n})),m("success"),g(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:n}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(h),m("error"),g(h,"error")}},[Q,g,s]),qe=c.useCallback(async(i,n)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:n})),m("info"),!k)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const o=await Y(i);if(!o)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await k({insightId:i,title:o.title,description:o.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:n})),m("success"),g(s("insights.taskCreatedMsg","Task created: {{title}}",{title:o.title}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToCreateTask","Failed to create task");u(h),m("error"),g(h,"error")}},[Y,k,g,s]),Ve=i=>{const n=Le[i.category]??A,o=M?.category===i.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${o?" insights-category-item--active":""}`,onClick:()=>ue(i.category),"aria-current":o?"true":void 0,"data-testid":`insights-category-${i.category}`,children:[e.jsx(n,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:i.label}),e.jsx("span",{className:"insights-category-count",children:i.items.length})]})},i.category)},We=()=>{if(!M)return null;const i=Le[M.category]??A;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${M.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(i,{size:18,className:"insights-section-icon"}),e.jsx("h3",{children:M.label}),e.jsx("span",{className:"insights-section-count",children:M.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:M.items.map(n=>{const o=J.get(n.id),h=B.get(n.id),ne=Z.get(n.id),Ke=F.get(n.id),ye=o?.running??!1,xe=h?.running??!1,pe=ne?.running??!1,ke=Ke?.running??!1,Se=n.status==="archived",ae=M.items.some(re=>J.get(re.id)?.running||B.get(re.id)?.running||Z.get(re.id)?.running||F.get(re.id)?.running);return e.jsxs("li",{className:`insight-item${Se?" insight-item--archived":""}`,"data-insight-id":n.id,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:n.title}),e.jsxs("div",{className:"insight-item-actions",children:[Se?e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Xe(n.id,n.title),disabled:ke||ae,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${n.id}`,children:ke?e.jsx(N,{size:16,className:"spin"}):e.jsx(gs,{size:16})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void qe(n.id,n.title),disabled:xe||ae,title:s("insights.createTaskTitle","Create task from this insight"),"aria-label":s("insights.createTaskLabel","Create task from this insight"),"data-testid":`create-task-${n.id}`,children:xe?e.jsx(N,{size:16,className:"spin"}):e.jsx(De,{size:16})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Oe(n.id,n.title),disabled:pe||ae,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${n.id}`,children:pe?e.jsx(N,{size:16,className:"spin"}):e.jsx(fe,{size:16})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void He(n.id,n.title),disabled:ye||ae,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${n.id}`,children:ye?e.jsx(N,{size:16,className:"spin"}):e.jsx(Ne,{size:16})})]})]}),n.content&&e.jsx("p",{className:"insight-item-content",children:n.content}),e.jsxs("div",{className:"insight-item-meta",children:[e.jsx("span",{className:`insight-item-status insight-item-status--${n.status}`,children:n.status}),n.createdAt&&e.jsxs("span",{className:"insight-item-date",children:[e.jsx(Pe,{size:12}),new Date(n.createdAt).toLocaleDateString()]})]})]},n.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(as,{icon:A,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[ee," ",s("common.total","total")]}),ve>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${j?" btn-icon--active":""}`,onClick:()=>R(i=>!i),"aria-pressed":j,"aria-label":j?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:Ge.join(", "),children:[e.jsx(rs,{size:14}),j?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",ve,")"]})]}),$&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:$,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ne,{size:16})}),_>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:z,"aria-label":se?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(fe,{size:14}),se?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:_})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void W(),disabled:E,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(N,{size:14,className:E?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>H(i=>!i),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":D,"data-testid":"toggle-model-config",title:y?s("insights.modelConfigured","Model: {{model}}",{model:y}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(cs,{size:14}),y&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void be(),disabled:x,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),D&&e.jsxs("div",{className:"insights-model-config","data-testid":"model-config",children:[e.jsx("label",{htmlFor:"insight-model-select",className:"insights-model-label",children:s("insights.model","Model")}),e.jsx(ls,{models:l,value:y,onChange:Ue,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:x,id:"insight-model-select",favoriteProviders:f,favoriteModels:p,onToggleFavorite:ie,onToggleModelFavorite:de,showThinkingLevel:!0,thinkingLevel:O,onThinkingLevelChange:Be,defaultThinkingLevel:"off"})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:C&&e.jsxs("div",{className:`insights-status-message insights-status-message--${w}`,role:w==="error"?"alert":void 0,children:[w==="success"&&e.jsx(_e,{size:16}),w==="error"&&e.jsx(le,{size:16}),w==="info"&&e.jsx(A,{size:16}),e.jsx("span",{children:C})]})}),T&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(le,{size:16}),e.jsx("span",{children:T})]}),v&&e.jsx("div",{className:"insights-run-info","data-testid":"latest-run",children:e.jsxs("span",{className:"insights-run-status",children:[s("insights.latestRun","Latest run:")," ",v.status,v.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:v.insightsCreated,updated:v.insightsUpdated})]}),v.status==="failed"&&v.error&&e.jsxs(e.Fragment,{children:[" — ",v.error]})]})}),E?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(N,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):G?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(le,{size:24}),e.jsx("p",{children:G}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void W(),children:s("actions.retry","Retry")})]}):ee===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(A,{size:48}),e.jsx("h3",{children:s("insights.noInsightsYet","No insights yet")}),e.jsx("p",{children:s("insights.generateDescription","Generate insights to get AI-powered recommendations for your project.")}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void be(),children:[e.jsx(A,{size:14}),s("insights.generateFirst","Generate First Insights")]})]}):e.jsxs("div",{className:"insights-body",children:[e.jsx("aside",{className:"insights-sidebar","aria-label":s("insights.categoriesLabel","Insight categories"),children:e.jsx("ul",{className:"insights-category-list",children:I.map(Ve)})}),e.jsx("div",{className:"insights-detail",children:We()})]})]})}export{Cs as InsightsView};
|
|
11
|
+
*/const ms=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],fs=ze("chart-line",ms),me=["architecture","quality","workflow","performance","reliability","security","ux","testability","documentation","dependency","features","competitive_analysis","research","trends","other"],Re={quality:"Quality",performance:"Performance",architecture:"Architecture",security:"Security",reliability:"Reliability",ux:"User Experience",testability:"Testability",documentation:"Documentation",dependency:"Dependencies",workflow:"Workflow",other:"Other",features:"Features",competitive_analysis:"Competitive Analysis",research:"Research",trends:"Trends"};function vs(d){const{t:g}=$e("app"),$=d??"",k=`${Ce.INSIGHTS_PREFIX}${$}`,S=`${Ce.INSIGHT_LATEST_RUN_PREFIX}${$}`,s=ce(k,{maxAgeMs:we}),V=ce(S,{maxAgeMs:je}),E=c.useRef(Array.isArray(s)&&s.length>0),U=c.useCallback(a=>g(`insights.category.${a}`,Re[a]??a),[g]),[v,x]=c.useState(()=>Array.isArray(s)?s:[]),[T,W]=c.useState(()=>me.map(a=>({category:a,label:Re[a]??a,items:[],isLoading:!1,error:null}))),[K,L]=c.useState(!(Array.isArray(s)&&s.length>0)),[Y,G]=c.useState(null),[Q,z]=c.useState(V??null),[J,B]=c.useState(!1),[Z,F]=c.useState(null),[ee,_]=c.useState(new Map),[se,C]=c.useState(new Map),[u,w]=c.useState(new Map),[m,D]=c.useState(new Map),[H,j]=c.useState(!1),R=c.useCallback(async()=>{E.current||L(!0),G(null);try{const t=(await Ye({status:void 0,limit:1e3},d)).insights.filter(l=>l.status!=="dismissed");x(t),Ie(k,t.length>500?t.slice(0,500):t,{maxBytes:5e5});const r=await Qe(d);r.runs.length>0&&(z(r.runs[0]),Ie(S,r.runs[0],{maxBytes:5e5})),E.current=!0}catch(a){const t=a instanceof Error?a.message:"Failed to fetch insights";G(t)}finally{L(!1)}},[k,S,d]),y=c.useCallback(()=>{j(a=>!a)},[]),te=c.useCallback(async(a,t,r)=>{B(!0),F(null);try{const l=await Je("manual",void 0,d,a,t,r);z(l),l.status==="completed"?await R():l.status==="failed"&&l.error&&F(l.error)}catch(l){if(l instanceof Ze&&l.status===409&&l.details?.code==="ACTIVE_RUN_CONFLICT"){const ie=typeof l.details.activeRunId=="string"?l.details.activeRunId:null;if(ie)try{const de=await es(ie,d);z(de)}catch{}throw F("Insight generation is already running"),l}const f=l instanceof Error?l.message:"Failed to generate insights";throw F(f),l}finally{B(!1)}},[d,R]),O=c.useCallback(async a=>{_(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{await ss(a,d),x(t=>t.filter(r=>r.id!==a)),_(t=>{const r=new Map(t);return r.set(a,{running:!1,error:null}),r})}catch(t){const r=t instanceof Error?t.message:"Failed to dismiss insight";throw _(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]),oe=c.useCallback(async a=>{C(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{const t=await ts(a,d);return await Me(a,d),x(r=>r.map(l=>l.id===a?{...l,status:"archived",updatedAt:new Date().toISOString()}:l)),C(r=>{const l=new Map(r);return l.set(a,{running:!1,error:null}),l}),{title:t.suggestedTitle,description:t.suggestedDescription}}catch(t){const r=t instanceof Error?t.message:"Failed to create task";throw C(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]);c.useEffect(()=>{const a=new Map;for(const t of me)a.set(t,[]);for(const t of v){if(!H&&t.status==="archived")continue;const r=a.get(t.category)??[];a.set(t.category,[...r,t])}W(me.map(t=>({category:t,label:U(t),items:a.get(t)??[],isLoading:!1,error:null})))},[v,H,U]);const he=c.useCallback(async a=>{w(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{await Me(a,d),x(t=>t.map(r=>r.id===a?{...r,status:"archived",updatedAt:new Date().toISOString()}:r)),w(t=>{const r=new Map(t);return r.set(a,{running:!1,error:null}),r})}catch(t){const r=t instanceof Error?t.message:"Failed to archive insight";throw w(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]),ge=c.useCallback(async a=>{D(t=>{const r=new Map(t);return r.set(a,{running:!0,error:null}),r});try{await is(a,d),x(t=>t.map(r=>r.id===a?{...r,status:"confirmed",updatedAt:new Date().toISOString()}:r)),D(t=>{const r=new Map(t);return r.set(a,{running:!1,error:null}),r})}catch(t){const r=t instanceof Error?t.message:"Failed to unarchive insight";throw D(l=>{const f=new Map(l);return f.set(a,{running:!1,error:r}),f}),t}},[d]),b=c.useMemo(()=>T.reduce((a,t)=>a+t.items.length,0),[T]),X=c.useMemo(()=>0,[]),p=c.useMemo(()=>v.filter(a=>a.status==="archived").length,[v]);return c.useEffect(()=>{const a=ce(k,{maxAgeMs:we}),t=ce(S,{maxAgeMs:je}),r=Array.isArray(a)&&a.length>0;x(Array.isArray(a)?a:[]),z(t??null),L(!r),E.current=r},[k,S]),c.useEffect(()=>{R()},[R]),{sections:T,loading:K,error:Y,latestRun:Q,isRunInFlight:J,runError:Z,refresh:R,runInsights:te,dismiss:O,createTask:oe,archive:he,unarchive:ge,toggleShowArchived:y,dismissStates:ee,createTaskStates:se,archiveStates:u,unarchiveStates:m,totalCount:b,dismissedCount:X,archivedCount:p,showArchived:H}}const Ue=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Te(d){return Ue.some(g=>d.title.startsWith(g))}const Le={architecture:us,quality:_e,workflow:Pe,performance:Ee,reliability:N,security:le,ux:Fe,testability:fe,documentation:hs,dependency:De,features:os,competitive_analysis:Fe,research:fs,trends:Ee,other:A};function Cs({projectId:d,addToast:g,onClose:$,onCreateTask:k,models:S}){const{t:s}=$e("app"),{sections:V,loading:E,error:U,latestRun:v,isRunInFlight:x,runError:T,refresh:W,runInsights:K,dismiss:L,createTask:Y,archive:G=async()=>{},unarchive:Q=async()=>{},toggleShowArchived:z=()=>{},dismissStates:J,createTaskStates:B,archiveStates:Z=new Map,unarchiveStates:F=new Map,totalCount:ee,archivedCount:_=0,showArchived:se=!1}=vs(d),[C,u]=c.useState(null),[w,m]=c.useState("info"),[D,H]=c.useState(!1),[j,R]=c.useState(!1),[y,te]=c.useState(()=>localStorage.getItem("fusion-insight-model")??""),[O,oe]=c.useState(()=>localStorage.getItem("fusion-insight-thinking")??""),[he,ge]=c.useState([]),[b,X]=c.useState([]),[p,a]=c.useState([]),[t,r]=c.useState();c.useEffect(()=>{S||ns().then(i=>{ge(i.models),X(i.favoriteProviders),a(i.favoriteModels),r(i.resolvedPlanningProvider);const n=localStorage.getItem("fusion-insight-model");n&&(i.models.some(h=>`${h.provider}/${h.id}`===n)||(localStorage.removeItem("fusion-insight-model"),te("")))}).catch(()=>{})},[S]);const l=S??he,f=c.useMemo(()=>b.length>0?b:t?[t]:[],[b,t]),ie=c.useCallback(async i=>{const o=b.includes(i)?b.filter(h=>h!==i):[i,...b];X(o);try{await Ae({favoriteProviders:o,favoriteModels:p})}catch{X(b)}},[b,p]),de=c.useCallback(async i=>{const o=p.includes(i)?p.filter(h=>h!==i):[i,...p];a(o);try{await Ae({favoriteProviders:b,favoriteModels:o})}catch{a(p)}},[p,b]),Ge=c.useCallback(i=>{te(i),i?localStorage.setItem("fusion-insight-model",i):localStorage.removeItem("fusion-insight-model")},[]),Be=c.useCallback(i=>{oe(i),i?localStorage.setItem("fusion-insight-thinking",i):localStorage.removeItem("fusion-insight-thinking")},[]),q=c.useMemo(()=>V.filter(i=>i.items.length>0),[V]),ve=c.useMemo(()=>q.reduce((i,n)=>i+n.items.filter(Te).length,0),[q]),I=c.useMemo(()=>j?q.map(i=>({...i,items:i.items.filter(Te)})).filter(i=>i.items.length>0):q,[q,j]),[P,ue]=c.useState(null);c.useEffect(()=>{if(I.length===0){P!==null&&ue(null);return}P&&I.some(n=>n.category===P&&n.items.length>0)||ue(I[0].category)},[I,P]);const M=c.useMemo(()=>I.find(i=>i.category===P)??I[0],[I,P]);c.useEffect(()=>{if(C){const i=setTimeout(()=>u(null),5e3);return()=>clearTimeout(i)}},[C]);const be=c.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),m("info");let i,n;if(y){const o=y.indexOf("/");if(o!==-1){const h=y.slice(0,o),ne=y.slice(o+1);h&&ne&&(i=h,n=ne)}}await K(i,n,O||void 0),u(s("insights.generationStarted","Insight generation started")),m("success"),g(s("insights.generationStarted","Insight generation started"),"success")}catch(i){const n=i instanceof Error?i.message:s("insights.failedToStart","Failed to start generation");if(n==="Insight generation is already running"){u(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),m("info"),g(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(n),m("error"),g(n,"error")}},[K,g,y,O,s]),He=c.useCallback(async(i,n)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:n})),m("info"),await L(i),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:n})),m("success"),g(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:n}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToDismiss","Failed to dismiss insight");u(h),m("error"),g(h,"error")}},[L,g,s]),Oe=c.useCallback(async(i,n)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:n})),m("info"),await G(i),u(s("insights.archived",'Archived "{{title}}"',{title:n})),m("success"),g(s("insights.archivedMsg","Insight archived: {{title}}",{title:n}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToArchive","Failed to archive insight");u(h),m("error"),g(h,"error")}},[G,g,s]),Xe=c.useCallback(async(i,n)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:n})),m("info"),await Q(i),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:n})),m("success"),g(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:n}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(h),m("error"),g(h,"error")}},[Q,g,s]),qe=c.useCallback(async(i,n)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:n})),m("info"),!k)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const o=await Y(i);if(!o)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await k({insightId:i,title:o.title,description:o.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:n})),m("success"),g(s("insights.taskCreatedMsg","Task created: {{title}}",{title:o.title}),"success")}catch(o){const h=o instanceof Error?o.message:s("insights.failedToCreateTask","Failed to create task");u(h),m("error"),g(h,"error")}},[Y,k,g,s]),Ve=i=>{const n=Le[i.category]??A,o=M?.category===i.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${o?" insights-category-item--active":""}`,onClick:()=>ue(i.category),"aria-current":o?"true":void 0,"data-testid":`insights-category-${i.category}`,children:[e.jsx(n,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:i.label}),e.jsx("span",{className:"insights-category-count",children:i.items.length})]})},i.category)},We=()=>{if(!M)return null;const i=Le[M.category]??A;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${M.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(i,{size:18,className:"insights-section-icon"}),e.jsx("h3",{children:M.label}),e.jsx("span",{className:"insights-section-count",children:M.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:M.items.map(n=>{const o=J.get(n.id),h=B.get(n.id),ne=Z.get(n.id),Ke=F.get(n.id),ye=o?.running??!1,xe=h?.running??!1,pe=ne?.running??!1,ke=Ke?.running??!1,Se=n.status==="archived",ae=M.items.some(re=>J.get(re.id)?.running||B.get(re.id)?.running||Z.get(re.id)?.running||F.get(re.id)?.running);return e.jsxs("li",{className:`insight-item${Se?" insight-item--archived":""}`,"data-insight-id":n.id,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:n.title}),e.jsxs("div",{className:"insight-item-actions",children:[Se?e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Xe(n.id,n.title),disabled:ke||ae,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${n.id}`,children:ke?e.jsx(N,{size:16,className:"spin"}):e.jsx(gs,{size:16})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void qe(n.id,n.title),disabled:xe||ae,title:s("insights.createTaskTitle","Create task from this insight"),"aria-label":s("insights.createTaskLabel","Create task from this insight"),"data-testid":`create-task-${n.id}`,children:xe?e.jsx(N,{size:16,className:"spin"}):e.jsx(De,{size:16})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Oe(n.id,n.title),disabled:pe||ae,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${n.id}`,children:pe?e.jsx(N,{size:16,className:"spin"}):e.jsx(fe,{size:16})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void He(n.id,n.title),disabled:ye||ae,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${n.id}`,children:ye?e.jsx(N,{size:16,className:"spin"}):e.jsx(Ne,{size:16})})]})]}),n.content&&e.jsx("p",{className:"insight-item-content",children:n.content}),e.jsxs("div",{className:"insight-item-meta",children:[e.jsx("span",{className:`insight-item-status insight-item-status--${n.status}`,children:n.status}),n.createdAt&&e.jsxs("span",{className:"insight-item-date",children:[e.jsx(Pe,{size:12}),new Date(n.createdAt).toLocaleDateString()]})]})]},n.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(as,{icon:A,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[ee," ",s("common.total","total")]}),ve>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${j?" btn-icon--active":""}`,onClick:()=>R(i=>!i),"aria-pressed":j,"aria-label":j?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:Ue.join(", "),children:[e.jsx(rs,{size:14}),j?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",ve,")"]})]}),$&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:$,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ne,{size:16})}),_>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:z,"aria-label":se?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(fe,{size:14}),se?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:_})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void W(),disabled:E,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(N,{size:14,className:E?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>H(i=>!i),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":D,"data-testid":"toggle-model-config",title:y?s("insights.modelConfigured","Model: {{model}}",{model:y}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(cs,{size:14}),y&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void be(),disabled:x,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),D&&e.jsxs("div",{className:"insights-model-config","data-testid":"model-config",children:[e.jsx("label",{htmlFor:"insight-model-select",className:"insights-model-label",children:s("insights.model","Model")}),e.jsx(ls,{models:l,value:y,onChange:Ge,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:x,id:"insight-model-select",favoriteProviders:f,favoriteModels:p,onToggleFavorite:ie,onToggleModelFavorite:de,showThinkingLevel:!0,thinkingLevel:O,onThinkingLevelChange:Be,defaultThinkingLevel:"off"})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:C&&e.jsxs("div",{className:`insights-status-message insights-status-message--${w}`,role:w==="error"?"alert":void 0,children:[w==="success"&&e.jsx(_e,{size:16}),w==="error"&&e.jsx(le,{size:16}),w==="info"&&e.jsx(A,{size:16}),e.jsx("span",{children:C})]})}),T&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(le,{size:16}),e.jsx("span",{children:T})]}),v&&e.jsx("div",{className:"insights-run-info","data-testid":"latest-run",children:e.jsxs("span",{className:"insights-run-status",children:[s("insights.latestRun","Latest run:")," ",v.status,v.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:v.insightsCreated,updated:v.insightsUpdated})]}),v.status==="failed"&&v.error&&e.jsxs(e.Fragment,{children:[" — ",v.error]})]})}),E?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(N,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):U?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(le,{size:24}),e.jsx("p",{children:U}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void W(),children:s("actions.retry","Retry")})]}):ee===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(A,{size:48}),e.jsx("h3",{children:s("insights.noInsightsYet","No insights yet")}),e.jsx("p",{children:s("insights.generateDescription","Generate insights to get AI-powered recommendations for your project.")}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void be(),children:[e.jsx(A,{size:14}),s("insights.generateFirst","Generate First Insights")]})]}):e.jsxs("div",{className:"insights-body",children:[e.jsx("aside",{className:"insights-sidebar","aria-label":s("insights.categoriesLabel","Insight categories"),children:e.jsx("ul",{className:"insights-category-list",children:I.map(Ve)})}),e.jsx("div",{className:"insights-detail",children:We()})]})]})}export{Cs as InsightsView};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as
|
|
1
|
+
import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Ie,f as fe,a as Se,s as Re,i as qe,t as Te,b as je,c as ve,d as Pe,e as He,g as _e,h as Oe}from"./SettingsModal-q_D1o7T-.js";import{aL as Ue,aK as $e,V as Qe,aM as Be,L as D,aN as Ne}from"./index-D8sgsB8q.js";import{u as We}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const O=".fusion/memory/MEMORY.md",Ve=5e4,Ye="0 3 * * *",Ge="0 4 * * *";function de(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ve,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Ye,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ge}}function Ce(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===O)?.path??i[0]?.path??O}function Ke(i={}){const{projectId:t}=i,[h,s]=r.useState(null),[d,v]=r.useState(!0),[I,z]=r.useState(!1),[L,S]=r.useState(()=>de({})),[x,j]=r.useState(!0),[n,k]=r.useState(!1),[U,$]=r.useState([]),[X,R]=r.useState(!0),[y,M]=r.useState(O),[N,w]=r.useState(""),[ye,Q]=r.useState(!1),[l,u]=r.useState(!1),[J,B]=r.useState(!1),[g,W]=r.useState(!1),[ee,q]=r.useState(!1),[c,P]=r.useState(null),[he,V]=r.useState(!0),[se,Y]=r.useState(!1),[te,G]=r.useState(!1),{status:K,loading:ue,refresh:A}=Ie({projectId:t}),Z=r.useCallback(m=>{w(m),u(!0)},[]),H=r.useCallback(async m=>{Q(!0);try{const{content:o}=await fe(m,t);M(m),w(o),u(!1)}finally{Q(!1)}},[t]),C=r.useCallback(async()=>{R(!0);try{const{files:m}=await Se(t);if($(m),m.length===0){M(O),w(""),u(!1);return}const o=Ce(m,y);o!==y&&await H(o)}finally{R(!1)}},[t,y,H]);r.useEffect(()=>{let m=!1;async function o(){try{const p=await ve(t);m||(s(p.content),z(p.exists),v(!1))}catch{m||(s(null),z(!1),v(!1))}}return o(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function o(){j(!0);try{const p=await $e(t);m||S(de(p))}catch{m||S(de({}))}finally{m||j(!1)}}return o(),()=>{m=!0}},[t]);const ae=r.useRef(y);r.useEffect(()=>{ae.current=y},[y]),r.useEffect(()=>{let m=!1;async function o(){R(!0);try{const{files:p}=await Se(t);if(m)return;if($(p),p.length===0){M(O),w(""),u(!1);return}const oe=Ce(p,ae.current),{content:xe}=await fe(oe,t);if(m)return;M(oe),w(xe),u(!1)}catch{m||($([]),M(O),w(""),u(!1))}finally{m||R(!1)}}return o(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function o(){try{const p=await je(t);m||(P(p),V(!1))}catch{m||(P(null),V(!1))}}return o(),()=>{m=!0}},[t]);const re=r.useCallback(async m=>{k(!0);try{const o=await Ue(m,t);S(de(o))}finally{k(!1)}},[t]),me=r.useCallback(async m=>{await H(m)},[H]),ne=r.useCallback(async()=>{if(l){B(!0);try{await Re(y,N,t),u(!1),await C()}finally{B(!1)}}},[N,l,y,t,C]),ie=r.useCallback(async()=>{G(!0);try{const m=await qe(t);return await A(),m}finally{G(!1)}},[t,A]),le=r.useCallback(async m=>Te(m,t),[t]),_=r.useCallback(async()=>{try{const m=await je(t);P(m)}catch{P(null)}},[t]),F=r.useCallback(async()=>{try{const m=await ve(t);s(m.content),z(m.exists)}catch{s(null),z(!1)}},[t]),f=r.useCallback(async m=>{await Pe(m,t),await F()},[t,F]),ge=r.useCallback(async()=>{W(!0);try{const m=await He(t);return await Promise.all([F(),_()]),{success:m.success,summary:m.summary}}finally{W(!1)}},[t,F,_]),T=r.useCallback(async()=>{q(!0);try{return await _e(t)}finally{q(!1)}},[t]),be=r.useCallback(async m=>{Y(!0);try{const o=await Oe(m,t),p=o.path??m;M(p),w(o.content),u(!1),await C()}finally{Y(!1)}},[t,C]);return{insightsContent:h,insightsLoading:d,insightsExists:I,refreshInsights:F,saveInsights:f,memorySettings:L,settingsLoading:x,savingMemorySettings:n,saveMemorySettings:re,memoryFiles:U,memoryFilesLoading:X,selectedFilePath:y,selectedFileContent:N,selectedFileLoading:ye,selectedFileDirty:l,setSelectedFileContent:Z,selectFile:me,saveSelectedFile:ne,savingSelectedFile:J,reloadMemoryFiles:C,backendStatus:K,backendLoading:ue,extractInsights:ge,extracting:g,triggerDreamNow:T,dreamRunning:ee,auditReport:c,auditLoading:he,refreshAudit:_,compactMemory:be,compacting:se,installQmdAction:ie,installingQmd:te,testRetrieval:le}}const Ze={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},Xe=72;function Je(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),d=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-d)}`}function es(i){const t=`${i.label} — ${i.path}`;return Je(t,Xe)}function ss(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const d=s.trim();if(!d)continue;const v=d.match(/^##\s+(.+?)(\n|$)/);if(v){const I=v[1].trim(),z=Ze[I]??I.toLowerCase(),L=d.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),S=L.split(`
|
|
2
2
|
`).reduce((x,j)=>{const n=j.trim();return/^[-*]\s+/.test(j)?x.push(n.replace(/^[-*]\s+/,"")):n.length>0&&x.length>0&&(x[x.length-1]=`${x[x.length-1]}
|
|
3
|
-
${j.trimEnd()}`),x},[]);(S.length>0||I.length>0)&&t.push({name:L,key:z,items:S.length>0?S:I.length>0?[I]:[],expanded:!0})}}return t}function ts(i){if(!i)return null;const t=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return t?t[1]:null}function as(i){return i.reduce((t,h)=>t+h.items.length,0)}function ds({projectId:i,addToast:t,onSendSelectionToTask:h}){const{t:s}=We("app"),[d,v]=r.useState("working"),[L,z]=r.useState(new Set),[I,S]=r.useState(!1),[x,j]=r.useState(null),[n,k]=r.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[U,$]=r.useState(""),[J,R]=r.useState(!1),[y,M]=r.useState(null),{insightsContent:N,insightsLoading:w,insightsExists:ye,saveInsights:Q,memorySettings:l,settingsLoading:u,saveMemorySettings:X,savingMemorySettings:B,backendStatus:g,backendLoading:W,extractInsights:ee,extracting:q,auditReport:c,auditLoading:P,refreshAudit:he,compactMemory:V,compacting:se,installQmdAction:Y,installingQmd:te,testRetrieval:G,memoryFiles:K,memoryFilesLoading:ue,selectedFilePath:A,selectedFileContent:Z,selectedFileLoading:H,selectedFileDirty:C,setSelectedFileContent:ae,selectFile:re,saveSelectedFile:me,savingSelectedFile:ne,reloadMemoryFiles:ie,triggerDreamNow:le,dreamRunning:_}=Ke({projectId:i});r.useEffect(()=>{k(l)},[l]);const F=r.useMemo(()=>n.memoryEnabled!==l.memoryEnabled||n.memoryAutoSummarizeEnabled!==l.memoryAutoSummarizeEnabled||n.memoryAutoSummarizeThresholdChars!==l.memoryAutoSummarizeThresholdChars||n.memoryAutoSummarizeSchedule!==l.memoryAutoSummarizeSchedule||n.memoryDreamsEnabled!==l.memoryDreamsEnabled||n.memoryDreamsSchedule!==l.memoryDreamsSchedule,[n,l]),f=r.useMemo(()=>K.find(a=>a.path===A),[K,A]),ge=f?f.layer==="long-term"?s("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):f.layer==="daily"?s("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):s("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):s("memory.editorDefaultDescription","Edits the selected memory file."),T=r.useMemo(()=>ss(N),[N]),be=r.useMemo(()=>as(T),[T]),m=r.useMemo(()=>ts(N),[N]),o=r.useCallback(a=>{z(b=>{const E=new Set(b);return E.has(a)?E.delete(a):E.add(a),E})},[]),p=r.useCallback(async a=>{try{await re(a)}catch{t(s("memory.loadFileFailed","Failed to load memory file"),"error")}},[re,t]),oe=r.useCallback(async()=>{try{await me(),t(s("memory.memorySaved","Memory saved"),"success")}catch{t(s("memory.saveMemoryFailed","Failed to save memory"),"error")}},[me,t]),xe=r.useCallback(async()=>{if(!F)return;const a={};n.memoryEnabled!==l.memoryEnabled&&(a.memoryEnabled=n.memoryEnabled),n.memoryAutoSummarizeEnabled!==l.memoryAutoSummarizeEnabled&&(a.memoryAutoSummarizeEnabled=n.memoryAutoSummarizeEnabled),n.memoryAutoSummarizeThresholdChars!==l.memoryAutoSummarizeThresholdChars&&(a.memoryAutoSummarizeThresholdChars=n.memoryAutoSummarizeThresholdChars),n.memoryAutoSummarizeSchedule!==l.memoryAutoSummarizeSchedule&&(a.memoryAutoSummarizeSchedule=n.memoryAutoSummarizeSchedule),n.memoryDreamsEnabled!==l.memoryDreamsEnabled&&(a.memoryDreamsEnabled=n.memoryDreamsEnabled),n.memoryDreamsSchedule!==l.memoryDreamsSchedule&&(a.memoryDreamsSchedule=n.memoryDreamsSchedule);try{await X(a),t(s("memory.settingsSaved","Memory settings saved"),"success")}catch{t(s("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[F,n,l,X,t]),Ee=r.useCallback(async()=>{try{const a=await Y();t(a.qmdAvailable?s("memory.qmdInstallSuccess","qmd installed successfully"):s("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),a.qmdAvailable?"success":"info")}catch{t(s("memory.installQmdFailed","Failed to install qmd"),"error")}},[Y,t]),ke=r.useCallback(async()=>{R(!0),M(null);try{const a=await G(U);M(a),t(a.qmdAvailable?s("memory.retrievalTestComplete","Memory retrieval test complete"):s("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),a.qmdAvailable?"success":"info")}catch{t(s("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{R(!1)}},[U,G,t]),Me=r.useCallback(async()=>{try{await le(),t(s("memory.dreamProcessingComplete","Dream processing completed"),"success"),await ie()}catch(a){t(a instanceof Error?a.message:s("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[le,ie,t]),we=r.useCallback(async()=>{try{await V(A),t(s("memory.fileCompacted","Memory file compacted"),"success")}catch{t(s("memory.compactFailed","Failed to compact memory"),"error")}},[V,A,t]),pe=r.useCallback(async()=>{try{const a=await ee();t(a.summary,"success")}catch(a){t(a instanceof Error?a.message:s("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[ee,t]),Ae=r.useCallback(async()=>{if(x!==null)try{await Q(x),S(!1),j(null),t(s("memory.insightsSaved","Insights saved"),"success")}catch{t(s("memory.saveInsightsFailed","Failed to save insights"),"error")}},[x,Q,t]),Fe=r.useCallback(()=>{j(N??""),S(!0)},[N]),De=r.useCallback(()=>{S(!1),j(null)},[]),ze=!W&&g!==null,ce=g?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Qe,{icon:Be,title:s("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":d==="working",className:`memory-view-tab${d==="working"?" memory-view-tab--active":""}`,onClick:()=>v("working"),"data-testid":"memory-tab-working",children:s("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":d==="insights",className:`memory-view-tab${d==="insights"?" memory-view-tab--active":""}`,onClick:()=>v("insights"),"data-testid":"memory-tab-insights",children:s("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":d==="engines",className:`memory-view-tab${d==="engines"?" memory-view-tab--active":""}`,onClick:()=>v("engines"),"data-testid":"memory-tab-engines",children:s("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[d==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[ze&&!ce&&e.jsx("div",{className:"memory-readonly-banner",children:s("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),ue||H?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingFile","Loading memory file…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:s("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:A,onChange:a=>{p(a.target.value)},disabled:C,children:K.map(a=>e.jsx("option",{value:a.path,title:`${a.label} — ${a.path}`,children:es(a)},a.path))}),e.jsx("small",{children:C?s("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):s("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),f&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:f.layer==="long-term"?s("memory.layerLongTerm","Long-term"):f.layer==="daily"?s("memory.layerDaily","Daily"):s("memory.layerDreams","Dreams")}),e.jsx("strong",{children:f.path}),e.jsx("small",{children:s("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:f.size.toLocaleString(),updatedAt:new Date(f.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:f?.label||s("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:ge}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ne,{content:Z,onChange:ae,readOnly:!ce,filePath:A,forceToolbarActionsVisible:!0,onSendSelectionToTask:h})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:s("memory.charCount","{{count}} characters",{count:Z.length})}),e.jsx("div",{className:"memory-flex-spacer"}),ce&&Z.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:we,disabled:se||C,children:se?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.compacting","Compacting…")]}):s("memory.compactSelectedFile","Compact Selected File")}),C&&ce&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:oe,disabled:ne,children:ne?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.save","Save")})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",title:s("memory.dreamsEnabledTooltip","Daily notes are distilled into DREAMS.md and reusable lessons are promoted into MEMORY.md."),children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:n.memoryDreamsEnabled,onChange:a=>{k(b=>({...b,memoryDreamsEnabled:a.target.checked}))},disabled:!n.memoryEnabled||u}),s("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:s("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),n.memoryEnabled&&n.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:s("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:n.memoryDreamsSchedule,onChange:a=>{k(b=>({...b,memoryDreamsSchedule:a.target.value}))},placeholder:"0 4 * * *",disabled:u}),e.jsx("small",{children:s("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Me,disabled:_||!n.memoryDreamsEnabled,children:_?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.dreaming","Dreaming…")]}):s("memory.dreamNow","Dream Now")}),e.jsx("small",{children:s("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:n.memoryAutoSummarizeEnabled,onChange:a=>{k(b=>({...b,memoryAutoSummarizeEnabled:a.target.checked}))},disabled:!n.memoryEnabled||u}),s("memory.autoSummarizeLabel","Auto-summarize memory")]}),e.jsx("small",{children:s("memory.autoSummarizeHint","Automatically compacts memory when it exceeds the threshold on a schedule.")})]}),n.memoryEnabled&&n.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:s("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:n.memoryAutoSummarizeThresholdChars,onChange:a=>{k(b=>({...b,memoryAutoSummarizeThresholdChars:parseInt(a.target.value,10)||5e4}))},min:1e3,disabled:u}),e.jsx("small",{children:s("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:s("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:n.memoryAutoSummarizeSchedule,onChange:a=>{k(b=>({...b,memoryAutoSummarizeSchedule:a.target.value}))},placeholder:"0 3 * * *",disabled:u}),e.jsx("small",{children:s("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!n.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:s("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),F&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:xe,disabled:B||u,children:B?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.saveSettings","Save Settings")})})]})]})]}),d==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:w?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingInsights","Loading insights…")})]}):I?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ne,{content:x??"",onChange:j,readOnly:!1,filePath:".fusion/memory/memory-insights.md",forceToolbarActionsVisible:!0,onSendSelectionToTask:h})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:De,children:s("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ae,children:s("memory.saveInsights","Save Insights")})]})]}):!ye||T.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:s("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:s("memory.noInsightsHint",'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.')}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:pe,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:be}),e.jsx("div",{className:"memory-stat-label",children:s("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:T.length}),e.jsx("div",{className:"memory-stat-label",children:s("memory.categories","Categories")})]}),m&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:m}),e.jsx("div",{className:"memory-stat-label",children:s("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:pe,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Fe,children:s("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:T.map(a=>{const b=!L.has(a.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>o(a.key),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),o(a.key))},children:[e.jsx("h4",{children:a.name}),e.jsx("span",{className:"memory-category-count",children:a.items.length})]}),b&&e.jsx("div",{className:"memory-category-items",children:a.items.map((E,Ie)=>e.jsx("div",{className:"memory-insight-item",children:E.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Ie))})]},a.key)})})]})}),d==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:W||P?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:s("memory.qmdIntegrationTitle","QMD Integration")}),g?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:s("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):g?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[s("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:g.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ee,disabled:te,children:te?s("memory.installing","Installing…"):s("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:s("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdCheckingAvailability","Checking qmd availability…")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:s("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:U,onChange:a=>$(a.target.value),placeholder:s("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ke,disabled:J,children:J?s("memory.testing","Testing…"):s("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:s("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),y&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:s("memory.testResultCount",'{{count}} result for "{{query}}"',{count:y.results.length,query:y.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:s("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:y.qmdAvailable?s("memory.qmdStatusAvailable","available"):s("memory.qmdStatusMissing","missing"),fallbackStatus:y.usedFallback?s("memory.localFallbackUsed","local fallback used"):s("memory.qmdPathUsed","qmd path used")})}),y.results.length>0?e.jsx("ul",{children:y.results.map((a,b)=>e.jsxs("li",{children:[e.jsxs("span",{children:[a.path,":",a.lineStart]}),e.jsx("p",{children:a.snippet})]},`${a.path}-${a.lineStart}-${b}`))}):e.jsx("small",{children:s("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:g?.currentBackend==="file"?s("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):g?.currentBackend==="readonly"?s("memory.backendReadonly","Read-Only"):g?.currentBackend==="qmd"?s("memory.backendQmd","QMD (Quantized Memory Distillation)"):g?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[g?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),g?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),g?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),g?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),c&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:s("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${c.health}`,children:c.health==="healthy"?s("memory.healthHealthy","Healthy"):c.health==="warning"?s("memory.healthWarning","Warning"):s("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.sectionCount","{{count}} sections",{count:c.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.insightCount","{{count}} insights",{count:c.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:c.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:s("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:s("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:c.extraction.summary||s("memory.insightsExtracted","{{count}} insights extracted",{count:c.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:c.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:s("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:s("memory.pruningNotNeeded","Not needed")})}),c.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:c.pruning.reason})]})]}),c&&c.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:c.checks.map(a=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:a.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:a.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:a.name}),e.jsx("div",{className:"memory-health-detail",children:a.details})]})]},a.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>he(),children:s("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:s("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{t(s("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:s("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{ds as MemoryView};
|
|
3
|
+
${j.trimEnd()}`),x},[]);(S.length>0||L.length>0)&&t.push({name:I,key:z,items:S.length>0?S:L.length>0?[L]:[],expanded:!0})}}return t}function ts(i){if(!i)return null;const t=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return t?t[1]:null}function as(i){return i.reduce((t,h)=>t+h.items.length,0)}function ds({projectId:i,addToast:t,onSendSelectionToTask:h}){const{t:s}=We("app"),[d,v]=r.useState("working"),[I,z]=r.useState(new Set),[L,S]=r.useState(!1),[x,j]=r.useState(null),[n,k]=r.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[U,$]=r.useState(""),[X,R]=r.useState(!1),[y,M]=r.useState(null),{insightsContent:N,insightsLoading:w,insightsExists:ye,saveInsights:Q,memorySettings:l,settingsLoading:u,saveMemorySettings:J,savingMemorySettings:B,backendStatus:g,backendLoading:W,extractInsights:ee,extracting:q,auditReport:c,auditLoading:P,refreshAudit:he,compactMemory:V,compacting:se,installQmdAction:Y,installingQmd:te,testRetrieval:G,memoryFiles:K,memoryFilesLoading:ue,selectedFilePath:A,selectedFileContent:Z,selectedFileLoading:H,selectedFileDirty:C,setSelectedFileContent:ae,selectFile:re,saveSelectedFile:me,savingSelectedFile:ne,reloadMemoryFiles:ie,triggerDreamNow:le,dreamRunning:_}=Ke({projectId:i});r.useEffect(()=>{k(l)},[l]);const F=r.useMemo(()=>n.memoryEnabled!==l.memoryEnabled||n.memoryAutoSummarizeEnabled!==l.memoryAutoSummarizeEnabled||n.memoryAutoSummarizeThresholdChars!==l.memoryAutoSummarizeThresholdChars||n.memoryAutoSummarizeSchedule!==l.memoryAutoSummarizeSchedule||n.memoryDreamsEnabled!==l.memoryDreamsEnabled||n.memoryDreamsSchedule!==l.memoryDreamsSchedule,[n,l]),f=r.useMemo(()=>K.find(a=>a.path===A),[K,A]),ge=f?f.layer==="long-term"?s("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):f.layer==="daily"?s("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):s("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):s("memory.editorDefaultDescription","Edits the selected memory file."),T=r.useMemo(()=>ss(N),[N]),be=r.useMemo(()=>as(T),[T]),m=r.useMemo(()=>ts(N),[N]),o=r.useCallback(a=>{z(b=>{const E=new Set(b);return E.has(a)?E.delete(a):E.add(a),E})},[]),p=r.useCallback(async a=>{try{await re(a)}catch{t(s("memory.loadFileFailed","Failed to load memory file"),"error")}},[re,t]),oe=r.useCallback(async()=>{try{await me(),t(s("memory.memorySaved","Memory saved"),"success")}catch{t(s("memory.saveMemoryFailed","Failed to save memory"),"error")}},[me,t]),xe=r.useCallback(async()=>{if(!F)return;const a={};n.memoryEnabled!==l.memoryEnabled&&(a.memoryEnabled=n.memoryEnabled),n.memoryAutoSummarizeEnabled!==l.memoryAutoSummarizeEnabled&&(a.memoryAutoSummarizeEnabled=n.memoryAutoSummarizeEnabled),n.memoryAutoSummarizeThresholdChars!==l.memoryAutoSummarizeThresholdChars&&(a.memoryAutoSummarizeThresholdChars=n.memoryAutoSummarizeThresholdChars),n.memoryAutoSummarizeSchedule!==l.memoryAutoSummarizeSchedule&&(a.memoryAutoSummarizeSchedule=n.memoryAutoSummarizeSchedule),n.memoryDreamsEnabled!==l.memoryDreamsEnabled&&(a.memoryDreamsEnabled=n.memoryDreamsEnabled),n.memoryDreamsSchedule!==l.memoryDreamsSchedule&&(a.memoryDreamsSchedule=n.memoryDreamsSchedule);try{await J(a),t(s("memory.settingsSaved","Memory settings saved"),"success")}catch{t(s("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[F,n,l,J,t]),Ee=r.useCallback(async()=>{try{const a=await Y();t(a.qmdAvailable?s("memory.qmdInstallSuccess","qmd installed successfully"):s("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),a.qmdAvailable?"success":"info")}catch{t(s("memory.installQmdFailed","Failed to install qmd"),"error")}},[Y,t]),ke=r.useCallback(async()=>{R(!0),M(null);try{const a=await G(U);M(a),t(a.qmdAvailable?s("memory.retrievalTestComplete","Memory retrieval test complete"):s("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),a.qmdAvailable?"success":"info")}catch{t(s("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{R(!1)}},[U,G,t]),Me=r.useCallback(async()=>{try{await le(),t(s("memory.dreamProcessingComplete","Dream processing completed"),"success"),await ie()}catch(a){t(a instanceof Error?a.message:s("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[le,ie,t]),we=r.useCallback(async()=>{try{await V(A),t(s("memory.fileCompacted","Memory file compacted"),"success")}catch{t(s("memory.compactFailed","Failed to compact memory"),"error")}},[V,A,t]),pe=r.useCallback(async()=>{try{const a=await ee();t(a.summary,"success")}catch(a){t(a instanceof Error?a.message:s("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[ee,t]),Ae=r.useCallback(async()=>{if(x!==null)try{await Q(x),S(!1),j(null),t(s("memory.insightsSaved","Insights saved"),"success")}catch{t(s("memory.saveInsightsFailed","Failed to save insights"),"error")}},[x,Q,t]),Fe=r.useCallback(()=>{j(N??""),S(!0)},[N]),De=r.useCallback(()=>{S(!1),j(null)},[]),ze=!W&&g!==null,ce=g?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Qe,{icon:Be,title:s("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":d==="working",className:`memory-view-tab${d==="working"?" memory-view-tab--active":""}`,onClick:()=>v("working"),"data-testid":"memory-tab-working",children:s("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":d==="insights",className:`memory-view-tab${d==="insights"?" memory-view-tab--active":""}`,onClick:()=>v("insights"),"data-testid":"memory-tab-insights",children:s("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":d==="engines",className:`memory-view-tab${d==="engines"?" memory-view-tab--active":""}`,onClick:()=>v("engines"),"data-testid":"memory-tab-engines",children:s("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[d==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[ze&&!ce&&e.jsx("div",{className:"memory-readonly-banner",children:s("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),ue||H?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingFile","Loading memory file…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:s("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:A,onChange:a=>{p(a.target.value)},disabled:C,children:K.map(a=>e.jsx("option",{value:a.path,title:`${a.label} — ${a.path}`,children:es(a)},a.path))}),e.jsx("small",{children:C?s("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):s("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),f&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:f.layer==="long-term"?s("memory.layerLongTerm","Long-term"):f.layer==="daily"?s("memory.layerDaily","Daily"):s("memory.layerDreams","Dreams")}),e.jsx("strong",{children:f.path}),e.jsx("small",{children:s("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:f.size.toLocaleString(),updatedAt:new Date(f.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:f?.label||s("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:ge}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ne,{content:Z,onChange:ae,readOnly:!ce,filePath:A,forceToolbarActionsVisible:!0,onSendSelectionToTask:h})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:s("memory.charCount","{{count}} characters",{count:Z.length})}),e.jsx("div",{className:"memory-flex-spacer"}),ce&&Z.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:we,disabled:se||C,children:se?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.compacting","Compacting…")]}):s("memory.compactSelectedFile","Compact Selected File")}),C&&ce&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:oe,disabled:ne,children:ne?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.save","Save")})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",title:s("memory.dreamsEnabledTooltip","Daily notes are distilled into DREAMS.md and reusable lessons are promoted into MEMORY.md."),children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:n.memoryDreamsEnabled,onChange:a=>{k(b=>({...b,memoryDreamsEnabled:a.target.checked}))},disabled:!n.memoryEnabled||u}),s("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:s("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),n.memoryEnabled&&n.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:s("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:n.memoryDreamsSchedule,onChange:a=>{k(b=>({...b,memoryDreamsSchedule:a.target.value}))},placeholder:"0 4 * * *",disabled:u}),e.jsx("small",{children:s("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Me,disabled:_||!n.memoryDreamsEnabled,children:_?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.dreaming","Dreaming…")]}):s("memory.dreamNow","Dream Now")}),e.jsx("small",{children:s("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:n.memoryAutoSummarizeEnabled,onChange:a=>{k(b=>({...b,memoryAutoSummarizeEnabled:a.target.checked}))},disabled:!n.memoryEnabled||u}),s("memory.autoSummarizeLabel","Auto-summarize memory")]}),e.jsx("small",{children:s("memory.autoSummarizeHint","Automatically compacts memory when it exceeds the threshold on a schedule.")})]}),n.memoryEnabled&&n.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:s("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:n.memoryAutoSummarizeThresholdChars,onChange:a=>{k(b=>({...b,memoryAutoSummarizeThresholdChars:parseInt(a.target.value,10)||5e4}))},min:1e3,disabled:u}),e.jsx("small",{children:s("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:s("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:n.memoryAutoSummarizeSchedule,onChange:a=>{k(b=>({...b,memoryAutoSummarizeSchedule:a.target.value}))},placeholder:"0 3 * * *",disabled:u}),e.jsx("small",{children:s("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!n.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:s("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),F&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:xe,disabled:B||u,children:B?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.saveSettings","Save Settings")})})]})]})]}),d==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:w?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingInsights","Loading insights…")})]}):L?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ne,{content:x??"",onChange:j,readOnly:!1,filePath:".fusion/memory/memory-insights.md",forceToolbarActionsVisible:!0,onSendSelectionToTask:h})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:De,children:s("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ae,children:s("memory.saveInsights","Save Insights")})]})]}):!ye||T.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:s("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:s("memory.noInsightsHint",'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.')}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:pe,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:be}),e.jsx("div",{className:"memory-stat-label",children:s("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:T.length}),e.jsx("div",{className:"memory-stat-label",children:s("memory.categories","Categories")})]}),m&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:m}),e.jsx("div",{className:"memory-stat-label",children:s("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:pe,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Fe,children:s("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:T.map(a=>{const b=!I.has(a.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>o(a.key),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),o(a.key))},children:[e.jsx("h4",{children:a.name}),e.jsx("span",{className:"memory-category-count",children:a.items.length})]}),b&&e.jsx("div",{className:"memory-category-items",children:a.items.map((E,Le)=>e.jsx("div",{className:"memory-insight-item",children:E.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Le))})]},a.key)})})]})}),d==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:W||P?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:s("memory.qmdIntegrationTitle","QMD Integration")}),g?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:s("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):g?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[s("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:g.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ee,disabled:te,children:te?s("memory.installing","Installing…"):s("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:s("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdCheckingAvailability","Checking qmd availability…")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:s("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:U,onChange:a=>$(a.target.value),placeholder:s("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ke,disabled:X,children:X?s("memory.testing","Testing…"):s("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:s("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),y&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:s("memory.testResultCount",'{{count}} result for "{{query}}"',{count:y.results.length,query:y.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:s("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:y.qmdAvailable?s("memory.qmdStatusAvailable","available"):s("memory.qmdStatusMissing","missing"),fallbackStatus:y.usedFallback?s("memory.localFallbackUsed","local fallback used"):s("memory.qmdPathUsed","qmd path used")})}),y.results.length>0?e.jsx("ul",{children:y.results.map((a,b)=>e.jsxs("li",{children:[e.jsxs("span",{children:[a.path,":",a.lineStart]}),e.jsx("p",{children:a.snippet})]},`${a.path}-${a.lineStart}-${b}`))}):e.jsx("small",{children:s("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:g?.currentBackend==="file"?s("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):g?.currentBackend==="readonly"?s("memory.backendReadonly","Read-Only"):g?.currentBackend==="qmd"?s("memory.backendQmd","QMD (Quantized Memory Distillation)"):g?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[g?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),g?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),g?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),g?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),c&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:s("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${c.health}`,children:c.health==="healthy"?s("memory.healthHealthy","Healthy"):c.health==="warning"?s("memory.healthWarning","Warning"):s("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.sectionCount","{{count}} sections",{count:c.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.insightCount","{{count}} insights",{count:c.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:c.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:s("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:s("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:c.extraction.summary||s("memory.insightsExtracted","{{count}} insights extracted",{count:c.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:c.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:s("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:s("memory.pruningNotNeeded","Not needed")})}),c.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:c.pruning.reason})]})]}),c&&c.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:c.checks.map(a=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:a.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:a.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:a.name}),e.jsx("div",{className:"memory-health-detail",children:a.details})]})]},a.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>he(),children:s("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:s("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{t(s("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:s("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{ds as MemoryView};
|
package/dist/client/assets/{PiExtensionsManager-B7fl5l3O.js → PiExtensionsManager-BUS_ZKwO.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as J,
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as J,aY as Q,aZ as V,a_ as T,R as L,a8 as D,aa as P,P as ee,C as se,e as ae,s as ie,a$ as B,b0 as ne,b1 as te,b2 as $,X as re}from"./index-D8sgsB8q.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{P as _}from"./puzzle-D7NHfczg.js";import{B as A}from"./AgentPermissionPolicyEditor-Dah1P8IX.js";import"./vendor-reactflow-9C3XTE7_.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],A=J("palette",ce);function oe(n){return n.replace(/-/g,"-")}function de(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function pe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function xe(n){return n.replace(/^(npm:|git:)/,"")}function be({addToast:n,projectId:x}){const{t:a}=le("app"),[c,G]=l.useState(null),[N,y]=l.useState(!0),[v,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[H,I]=l.useState(new Set),[m,O]=l.useState([]),[b,R]=l.useState(!0),[X,C]=l.useState(!1),o=l.useCallback(async()=>{try{y(!0);const s=await Q();G(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{y(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await V(x);O(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),q=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const K=s=>{I(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},U=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Y=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await $({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},Z=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await $({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>Z(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:v}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:v||!h.trim(),children:[e.jsx(ee,{size:14}),v?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:U,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=pe(i),f=xe(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=H.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>K(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Y(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(W,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(_,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),W,"extensions"),u(a("piManager.sectionSkills","Skills"),_,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),A,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:b,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:b?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),b?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${oe(s.source)}`,children:de(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void q(s),disabled:X,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{be as PiExtensionsManager};
|
|
6
|
+
*/const ce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],G=J("palette",ce);function oe(n){return n.replace(/-/g,"-")}function de(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function pe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function xe(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,H]=l.useState(null),[N,y]=l.useState(!0),[b,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[I,O]=l.useState(new Set),[m,W]=l.useState([]),[v,R]=l.useState(!0),[q,C]=l.useState(!1),o=l.useCallback(async()=>{try{y(!0);const s=await Q();H(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{y(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await V(x);W(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),K=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const U=s=>{O(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},X=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Y=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await $({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},Z=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await $({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>Z(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:b}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:b||!h.trim(),children:[e.jsx(ee,{size:14}),b?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:X,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=pe(i),f=xe(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=I.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>U(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Y(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(_,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(G,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),_,"extensions"),u(a("piManager.sectionSkills","Skills"),A,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),G,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:v,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:v?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),v?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${oe(s.source)}`,children:de(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void K(s),disabled:q,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};
|