@runfusion/fusion 0.55.0 → 0.56.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.
Files changed (127) hide show
  1. package/dist/bin.js +5785 -1351
  2. package/dist/client/.vite/manifest.json +321 -321
  3. package/dist/client/assets/{AgentDetailView-B_VfFSlt.js → AgentDetailView-BPzzEIn1.js} +1 -1
  4. package/dist/client/assets/{AgentPermissionPolicyEditor-QZhz41AU.js → AgentPermissionPolicyEditor-CqlLF0pf.js} +1 -1
  5. package/dist/client/assets/{AgentsView-hkhJ8SUq.js → AgentsView-C4uCWzdt.js} +6 -6
  6. package/dist/client/assets/ChatView-BGV9F2K0.js +6 -0
  7. package/dist/client/assets/{CommandCenter-B3fAajUO.js → CommandCenter-BhIfVVjz.js} +1 -1
  8. package/dist/client/assets/{DevServerView-BR0ngFBw.js → DevServerView-Bd86MWUa.js} +1 -1
  9. package/dist/client/assets/DirectoryPicker-BDe9G84f.js +1 -0
  10. package/dist/client/assets/{DocumentsView-BnRvIUpa.js → DocumentsView-BkAHMt19.js} +1 -1
  11. package/dist/client/assets/{EvalsView-Bvx18QyC.js → EvalsView-BxxCVaJ8.js} +1 -1
  12. package/dist/client/assets/{ExperimentalAgentOnboardingModal-CKGJcfXI.js → ExperimentalAgentOnboardingModal-7-BD6W1v.js} +1 -1
  13. package/dist/client/assets/{GoalsView-Bj1yVIiv.js → GoalsView-B3KICwNu.js} +1 -1
  14. package/dist/client/assets/{InsightsView-DBX8DI60.js → InsightsView-DO8qefU1.js} +2 -2
  15. package/dist/client/assets/{MemoryView-CqkRH2fa.js → MemoryView-urkPdqTn.js} +1 -1
  16. package/dist/client/assets/{PiExtensionsManager-BMMmGWe2.js → PiExtensionsManager-BwVKjJIo.js} +2 -2
  17. package/dist/client/assets/{PluginManager-C1bdfN2W.js → PluginManager-C-OuqDLa.js} +1 -1
  18. package/dist/client/assets/{PullRequestView-D0CsXWLl.js → PullRequestView-B4q4X5WV.js} +1 -1
  19. package/dist/client/assets/{ResearchView-CVgmXAlj.js → ResearchView-DlW6z3sm.js} +1 -1
  20. package/dist/client/assets/{SecretsView-Bv_gw5Ix.js → SecretsView-C-3eC0KB.js} +1 -1
  21. package/dist/client/assets/SessionTerminal-DVfyVeS2.js +2 -0
  22. package/dist/client/assets/SettingsModal-BC_2Y56_.css +1 -0
  23. package/dist/client/assets/{SettingsModal-D7YgojbV.js → SettingsModal-BzXctrhu.js} +1 -1
  24. package/dist/client/assets/SettingsModal-qs8w3rov.js +21 -0
  25. package/dist/client/assets/SetupWizardModal-DDJ8PCkH.js +2 -0
  26. package/dist/client/assets/{ShadcnColorPicker-DM2fqGwl.js → ShadcnColorPicker-BcD5fZ_P.js} +1 -1
  27. package/dist/client/assets/{SkillsView-Bb-JTo99.js → SkillsView-DojlvxFh.js} +1 -1
  28. package/dist/client/assets/TodoView-BKZ07WxZ.js +6 -0
  29. package/dist/client/assets/WorkflowNodeEditor-BJNbi4_V.js +8 -0
  30. package/dist/client/assets/{agentSkills-DGFyuKuP.js → agentSkills-NbIIJy87.js} +1 -1
  31. package/dist/client/assets/app-0jcSCRQr.js +13 -0
  32. package/dist/client/assets/app-BPzPEE6G.js +13 -0
  33. package/dist/client/assets/app-BSZU5Uns.js +13 -0
  34. package/dist/client/assets/app-CEtD1B9K.js +13 -0
  35. package/dist/client/assets/app-CVyRSEUX.js +13 -0
  36. package/dist/client/assets/app-DoLz_4Dg.js +13 -0
  37. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DP7vOyXY.js → architectureDiagram-3BPJPVTR-CJu9RVXs.js} +1 -1
  38. package/dist/client/assets/{blockDiagram-GPEHLZMM-Di9v1pV8.js → blockDiagram-GPEHLZMM-crZsLLTq.js} +1 -1
  39. package/dist/client/assets/{c4Diagram-AAUBKEIU-Dvb8RSfr.js → c4Diagram-AAUBKEIU-D5mmJKvW.js} +1 -1
  40. package/dist/client/assets/channel-Zfk0yRN2.js +1 -0
  41. package/dist/client/assets/{chunk-2J33WTMH-gLcAuGjI.js → chunk-2J33WTMH-BZIDltTX.js} +1 -1
  42. package/dist/client/assets/{chunk-4BX2VUAB-B-B0wjkx.js → chunk-4BX2VUAB-ND_SzhUa.js} +1 -1
  43. package/dist/client/assets/{chunk-55IACEB6-XUDeC0Co.js → chunk-55IACEB6-C3n-Nisk.js} +1 -1
  44. package/dist/client/assets/{chunk-727SXJPM-1eebiGA2.js → chunk-727SXJPM-DfiPA7wv.js} +1 -1
  45. package/dist/client/assets/{chunk-AQP2D5EJ-D9VOB5QS.js → chunk-AQP2D5EJ-CDE0u57Z.js} +1 -1
  46. package/dist/client/assets/{chunk-FMBD7UC4-EFNFEaAz.js → chunk-FMBD7UC4-COR53PTE.js} +1 -1
  47. package/dist/client/assets/{chunk-ND2GUHAM-CbeQailD.js → chunk-ND2GUHAM-CbcTdl7C.js} +1 -1
  48. package/dist/client/assets/{chunk-QZHKN3VN-D55N6EBz.js → chunk-QZHKN3VN-DiB3PReK.js} +1 -1
  49. package/dist/client/assets/classDiagram-4FO5ZUOK-BehQ-wnv.js +1 -0
  50. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-BehQ-wnv.js +1 -0
  51. package/dist/client/assets/{cose-bilkent-S5V4N54A-B0zbhkX3.js → cose-bilkent-S5V4N54A-Dg3YVyLX.js} +1 -1
  52. package/dist/client/assets/{dagre-BM42HDAG-BL6peXwl.js → dagre-BM42HDAG-D2bK3gNb.js} +1 -1
  53. package/dist/client/assets/{dashboard-view-CS1H5SQN.js → dashboard-view-BcbTWSCe.js} +1 -1
  54. package/dist/client/assets/{dashboard-view-Db3n_W85.js → dashboard-view-t2UfQxck.js} +1 -1
  55. package/dist/client/assets/{diagram-2AECGRRQ-cYKwSHk7.js → diagram-2AECGRRQ-BWT8KaEl.js} +1 -1
  56. package/dist/client/assets/{diagram-5GNKFQAL-DHIwTGuM.js → diagram-5GNKFQAL-DWfJlASD.js} +1 -1
  57. package/dist/client/assets/{diagram-KO2AKTUF-DfHBJ4aX.js → diagram-KO2AKTUF-DE3hFbLT.js} +1 -1
  58. package/dist/client/assets/{diagram-LMA3HP47-pWhYmB6Z.js → diagram-LMA3HP47-CYCFeD4B.js} +1 -1
  59. package/dist/client/assets/{diagram-OG6HWLK6-GzWqbi_m.js → diagram-OG6HWLK6-C0C8lEGv.js} +1 -1
  60. package/dist/client/assets/{erDiagram-TEJ5UH35-CCVm5eiR.js → erDiagram-TEJ5UH35-kSo7RjKA.js} +1 -1
  61. package/dist/client/assets/{flowDiagram-I6XJVG4X-CUTdnU6S.js → flowDiagram-I6XJVG4X-DxRf1SVH.js} +1 -1
  62. package/dist/client/assets/{folder-open-DOCy9GVC.js → folder-open-DO1rnCxq.js} +1 -1
  63. package/dist/client/assets/{ganttDiagram-6RSMTGT7-CW4ENJaC.js → ganttDiagram-6RSMTGT7-CGtxSeWq.js} +1 -1
  64. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-QXXMfSzp.js → gitGraphDiagram-PVQCEYII-BNZv_DFY.js} +1 -1
  65. package/dist/client/assets/index-BCf32Sgx.css +1 -0
  66. package/dist/client/assets/index-D7eX7QJk.js +2511 -0
  67. package/dist/client/assets/{infoDiagram-5YYISTIA-CZyHbj0n.js → infoDiagram-5YYISTIA-DailohMo.js} +1 -1
  68. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Dea84lqZ.js → ishikawaDiagram-YF4QCWOH-Cy3shDZP.js} +1 -1
  69. package/dist/client/assets/{journeyDiagram-JHISSGLW-Db2iKGU5.js → journeyDiagram-JHISSGLW-B1rU18Qx.js} +1 -1
  70. package/dist/client/assets/{kanban-definition-UN3LZRKU-CB9loIqR.js → kanban-definition-UN3LZRKU-CRNUDgkO.js} +1 -1
  71. package/dist/client/assets/{mermaid.core-CoQ8aCb0.js → mermaid.core-Cg0po76i.js} +4 -4
  72. package/dist/client/assets/{mindmap-definition-RKZ34NQL-JPb2wF-K.js → mindmap-definition-RKZ34NQL-CEjwlhOe.js} +1 -1
  73. package/dist/client/assets/{pieDiagram-4H26LBE5-pdZzOreP.js → pieDiagram-4H26LBE5-70T-php2.js} +1 -1
  74. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-Dh9Ids90.js → quadrantDiagram-W4KKPZXB-ChcpRG7l.js} +1 -1
  75. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BVPOSvHU.js → requirementDiagram-4Y6WPE33-9Pzb_Cot.js} +1 -1
  76. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BqSMUpsx.js → sankeyDiagram-5OEKKPKP-Bx6DkeKq.js} +1 -1
  77. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-B8nepQ6X.js → sequenceDiagram-3UESZ5HK-emWPkPv7.js} +1 -1
  78. package/dist/client/assets/{shield-alert-CtSaIQNY.js → shield-alert-BdAjnDkU.js} +1 -1
  79. package/dist/client/assets/{stateDiagram-AJRCARHV-CQv9RdRp.js → stateDiagram-AJRCARHV-B_X2-VQy.js} +1 -1
  80. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-DvQssSEq.js +1 -0
  81. package/dist/client/assets/{timeline-definition-PNZ67QCA-CAjwM-Z5.js → timeline-definition-PNZ67QCA-CkyhunuI.js} +1 -1
  82. package/dist/client/assets/{upload-0_pT1euA.js → upload-D9-yuO2D.js} +1 -1
  83. package/dist/client/assets/{users--1B6mnm8.js → users-B4aebngl.js} +1 -1
  84. package/dist/client/assets/{vennDiagram-CIIHVFJN-BO3Um3rH.js → vennDiagram-CIIHVFJN-8OGD6Vb7.js} +1 -1
  85. package/dist/client/assets/{wardley-L42UT6IY-BzqJcqDA.js → wardley-L42UT6IY-MnRFGNPm.js} +1 -1
  86. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-Bctxc6_5.js → wardleyDiagram-YWT4CUSO-BAEzb08c.js} +1 -1
  87. package/dist/client/assets/{xychartDiagram-2RQKCTM6-CgDuiMFR.js → xychartDiagram-2RQKCTM6-DUxideKC.js} +1 -1
  88. package/dist/client/index.html +3 -3
  89. package/dist/client/version.json +1 -1
  90. package/dist/droid-cli/package.json +1 -1
  91. package/dist/extension.js +4668 -913
  92. package/dist/pi-claude-cli/package.json +1 -1
  93. package/dist/plugin-sdk/index.d.ts +47 -3
  94. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  95. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  96. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  97. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  98. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  99. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  100. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  101. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  102. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  103. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  104. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  105. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  106. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  107. package/package.json +1 -1
  108. package/dist/client/assets/ChatView-B4WnXLYA.js +0 -6
  109. package/dist/client/assets/DirectoryPicker-BiS41Hca.js +0 -1
  110. package/dist/client/assets/SessionTerminal-VLdVV3Ji.js +0 -2
  111. package/dist/client/assets/SettingsModal-4t8rV7rh.css +0 -1
  112. package/dist/client/assets/SettingsModal-gcrh5EOG.js +0 -21
  113. package/dist/client/assets/SetupWizardModal-DvmTlFP_.js +0 -2
  114. package/dist/client/assets/TodoView-bV-7deOh.js +0 -6
  115. package/dist/client/assets/WorkflowNodeEditor-Ui1q_fFI.js +0 -8
  116. package/dist/client/assets/app--OM-ul6R.js +0 -13
  117. package/dist/client/assets/app-BCvqf8qq.js +0 -13
  118. package/dist/client/assets/app-BZqqEiWR.js +0 -13
  119. package/dist/client/assets/app-DQeH1UDD.js +0 -13
  120. package/dist/client/assets/app-FiYwRatp.js +0 -13
  121. package/dist/client/assets/app-rGdYcsAA.js +0 -13
  122. package/dist/client/assets/channel-C5g9M3Sk.js +0 -1
  123. package/dist/client/assets/classDiagram-4FO5ZUOK-B-wdlvD6.js +0 -1
  124. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-B-wdlvD6.js +0 -1
  125. package/dist/client/assets/index-B6ttSchA.js +0 -1336
  126. package/dist/client/assets/index-CPE2Kwra.css +0 -1
  127. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BZ_mlvie.js +0 -1
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ExperimentalAgentOnboardingModal-7-BD6W1v.js","assets/vendor-react-SZ_qB27O.js","assets/index-D7eX7QJk.js","assets/vendor-i18n-GF3RlKbq.js","assets/vendor-reactflow-CnI7NMXG.js","assets/vendor-reactflow-C5ap-Sga.css","assets/vendor-codemirror-jBKmHyH0.js","assets/vendor-xterm-BNq00GSj.js","assets/vendor-xterm-LZoznX6r.css","assets/index-BCf32Sgx.css","assets/ExperimentalAgentOnboardingModal-3ZEFv8sr.css"])))=>i.map(i=>d[i]);
2
+ import{A as h,g as v,m as E,u as ie,d as ne,r as oe,a as le,b as de,e as ce,X as pe,L as C,C as ue,f as F,S as me,h as T,E as ge,_ as he}from"./index-D7eX7QJk.js";import{r as o,j as e}from"./vendor-react-SZ_qB27O.js";import{D as xe}from"./DirectoryPicker-BDe9G84f.js";import{s as z}from"./projectDetection-G3XuxD2X.js";import{u as je}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";import"./folder-open-DO1rnCxq.js";function P(p){const u=p.replace(/[^a-zA-Z]/g,"").toUpperCase();return u.length>=2&&u.length<=4?u:u.length>4?u.slice(0,4):"FN"}const fe=o.lazy(()=>he(()=>import("./ExperimentalAgentOnboardingModal-7-BD6W1v.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(p=>({default:p.ExperimentalAgentOnboardingModal})));function Ie({onProjectRegistered:p,onClose:u,agentOnboardingEnabled:I=!1,includeAgentStep:A=!0}){const{t:s}=je("app"),U="https://discord.gg/ksrfuy7WYR",f=o.useMemo(()=>v("ceo")??h[0],[]),[W,H]=o.useState(!0),[t,n]=o.useState(()=>({step:"manual",manualMode:"existing",manualPath:"",manualCloneUrl:"",manualName:"",manualIsolationMode:"in-process",manualNodeId:"",manualTaskPrefix:"",detectedRepos:[],workspaceMode:!1,isDetectingWorkspace:!1,registeredProject:null,selectedPresetId:f.id,agentDraft:E(f),isCreatingAgent:!1,isRegistering:!1,error:null,agentError:null,agentOutcome:null})),[D,L]=o.useState(!1),[R,w]=o.useState(!1),M=o.useRef(null),{nodes:S,loading:O}=ie(),_=S.find(a=>a.type==="local")?.id,N=o.useCallback(()=>{H(!1),u?.()},[u]),B=o.useCallback(()=>{if(t.registeredProject){p(t.registeredProject);return}N()},[N,p,t.registeredProject]);o.useEffect(()=>{t.agentError&&M.current?.focus()},[t.agentError]);const x=o.useRef(0),G=o.useCallback(a=>{if(n(r=>{const i={manualPath:a,detectedRepos:[],workspaceMode:!1,error:null};a&&(!r.manualName||r.manualName===z(r.manualPath))&&(i.manualName=z(a));const l=i.manualName??r.manualName;return l&&(!r.manualTaskPrefix||r.manualTaskPrefix===P(z(r.manualPath)))&&(i.manualTaskPrefix=P(l)),{...r,...i}}),t.manualMode==="existing"&&a.trim()&&a.trim()!=="/"){const r=++x.current;n(i=>({...i,isDetectingWorkspace:!0})),ne(a.trim()).then(i=>{r===x.current&&n(l=>({...l,isDetectingWorkspace:!1,detectedRepos:i.repos,workspaceMode:i.isWorkspace}))}).catch(()=>{r===x.current&&n(i=>({...i,isDetectingWorkspace:!1}))})}},[t.manualMode]),y=o.useCallback(a=>{n(r=>({...r,manualMode:a,manualCloneUrl:a==="clone"?r.manualCloneUrl:"",detectedRepos:a==="existing"?r.detectedRepos:[],workspaceMode:a==="existing"?r.workspaceMode:!1,isDetectingWorkspace:!1,error:null})),x.current+=1},[]),$=o.useCallback(async()=>{const a=t.manualPath.trim(),r=t.manualName.trim(),i=t.manualCloneUrl.trim();if(!(!a||!r)&&!(t.manualMode==="clone"&&!i)){n(l=>({...l,isRegistering:!0,error:null}));try{const l={name:r,path:a,isolationMode:t.manualIsolationMode,nodeId:t.manualNodeId||void 0,gitSetupMode:t.manualMode,cloneUrl:t.manualMode==="clone"?i:void 0,workspaceMode:t.manualMode==="existing"?t.workspaceMode:!1,taskPrefix:t.manualTaskPrefix.trim()||void 0},d=await oe(l);if(!A){n(g=>({...g,isRegistering:!1})),p(d);return}n(g=>({...g,step:"agent",registeredProject:d,isRegistering:!1}))}catch(l){n(d=>({...d,isRegistering:!1,error:l instanceof Error?l.message:"Failed to register project"}))}}},[A,p,t.manualPath,t.manualName,t.manualCloneUrl,t.manualMode,t.manualIsolationMode,t.manualNodeId,t.workspaceMode,t.manualTaskPrefix]),b=o.useCallback(a=>{const r=v(a);r&&n(i=>({...i,selectedPresetId:r.id,agentDraft:E(r),agentError:null}))},[]),Y=o.useCallback((a,r)=>{const i=h.findIndex(re=>re.id===r);if(i<0)return;const l=h.length-1;let d=null;if(a.key==="ArrowDown"||a.key==="ArrowRight"?d=i===l?0:i+1:a.key==="ArrowUp"||a.key==="ArrowLeft"?d=i===0?l:i-1:a.key==="Home"?d=0:a.key==="End"&&(d=l),d===null)return;a.preventDefault();const g=h[d];b(g.id),requestAnimationFrame(()=>{document.querySelector(`[data-agent-preset-id="${g.id}"]`)?.focus()})},[b]),q=o.useCallback(a=>{n(r=>({...r,selectedPresetId:"",agentDraft:le(a),agentError:null}))},[]),K=o.useCallback(async()=>{if(!(!t.registeredProject||!t.agentDraft.name.trim())){n(a=>({...a,isCreatingAgent:!0,agentError:null}));try{await de(ce(t.agentDraft),t.registeredProject.id),n(a=>({...a,step:"complete",isCreatingAgent:!1,agentOutcome:"created"}))}catch(a){if(a instanceof Error&&/already exists/i.test(a.message)){n(r=>({...r,step:"complete",isCreatingAgent:!1,agentOutcome:"created"}));return}n(r=>({...r,isCreatingAgent:!1,agentError:a instanceof Error?a.message:s("setup.firstAgentCreateError","Failed to create agent")}))}}},[t.agentDraft,t.registeredProject,s]),Z=o.useCallback(()=>{n(a=>({...a,step:"complete",agentError:null,agentOutcome:"skipped"}))},[]);if(!W)return null;const k=t.manualMode==="existing",m=t.manualMode==="init",c=t.manualMode==="clone",V=c?s("setup.cloneAndRegisterProject","Clone and Register Project"):m?s("setup.initializeAndRegisterProject","Initialize and Register Project"):s("setup.registerProject","Register Project"),X=t.manualPath.trim().length>0,J=t.manualName.trim().length>0,Q=t.manualCloneUrl.trim().length>0,ee=t.isRegistering||!X||!J||c&&!Q,te=t.selectedPresetId?v(t.selectedPresetId):void 0,j=t.isCreatingAgent,se=t.selectedPresetId||f.id,ae=`modal setup-wizard-modal${t.step==="agent"?" setup-wizard-modal--agent":""}`;return e.jsxs("div",{className:"modal-overlay open setup-wizard-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"wizard-title",children:[e.jsxs("div",{className:ae,children:[e.jsxs("div",{className:"setup-wizard-header",children:[e.jsxs("div",{className:"setup-wizard-heading",children:[e.jsxs("div",{className:"setup-wizard-brand","aria-label":s("setup.brandName","Fusion"),children:[e.jsxs("svg",{className:"setup-wizard-brand-logo",width:28,height:28,viewBox:"0 0 128 128",fill:"none","aria-label":s("setup.brandLogo","Fusion logo"),role:"img",children:[e.jsx("circle",{cx:"64",cy:"64",r:"52",stroke:"currentColor",strokeWidth:"8"}),e.jsx("path",{d:"M26 101C44 82 62 64 82 45C90 37 98 30 104 24C96 35 89 47 81 60C70 79 57 95 43 108C38 112 32 108 26 101Z",fill:"currentColor"})]}),e.jsx("span",{className:"setup-wizard-brand-name",children:s("setup.brandName","Fusion")})]}),e.jsxs("h2",{id:"wizard-title",className:"setup-wizard-title",children:[t.step==="manual"&&s("setup.welcomeToFusion","Welcome to Fusion"),t.step==="agent"&&s("setup.firstAgentTitle","Create your first agent"),t.step==="complete"&&s("setup.setupCompleteTitle","Setup Complete!")]})]}),t.step!=="complete"&&t.step!=="agent"&&e.jsx("button",{className:"modal-close",onClick:N,"aria-label":s("setup.closeWizard","Close wizard"),children:e.jsx(pe,{size:20})})]}),e.jsxs("div",{className:"setup-wizard-content",children:[t.step==="manual"&&e.jsxs("div",{className:"setup-wizard-manual",children:[e.jsxs("section",{className:"setup-wizard-repository-section","aria-labelledby":"setup-repository-mode-title",children:[e.jsxs("div",{className:"setup-wizard-section-heading",children:[e.jsx("h3",{id:"setup-repository-mode-title",children:s("setup.repositorySetupTitle","Repository setup")}),e.jsx("p",{children:s("setup.repositorySetupDescription","Choose how Fusion should prepare the project directory before registration.")})]}),e.jsxs("fieldset",{className:"setup-wizard-mode-switch","aria-label":s("setup.projectSetupModeAriaLabel","Project setup mode"),children:[e.jsx("legend",{children:s("setup.setupMode","Setup Mode")}),e.jsxs("label",{className:`setup-wizard-mode-option${k?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"existing","aria-label":s("setup.useExistingDirectory","Use Existing Directory"),checked:k,onChange:()=>y("existing")}),e.jsxs("span",{className:"setup-wizard-mode-option-copy",children:[e.jsx("strong",{children:s("setup.useExistingDirectory","Use Existing Directory")}),e.jsx("span",{children:s("setup.useExistingDirectoryHint","Register a folder that is already a git repository or workspace root.")})]})]}),e.jsxs("label",{className:`setup-wizard-mode-option${m?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"init","aria-label":s("setup.initializeNewRepository","Initialize New Repository"),checked:m,onChange:()=>y("init")}),e.jsxs("span",{className:"setup-wizard-mode-option-copy",children:[e.jsx("strong",{children:s("setup.initializeNewRepository","Initialize New Repository")}),e.jsx("span",{children:s("setup.initializeNewRepositoryHint","Register a selected non-git folder and let Fusion run git init on the server.")})]})]}),e.jsxs("label",{className:`setup-wizard-mode-option${c?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"setup-mode",value:"clone","aria-label":s("setup.cloneGitRepository","Clone Git Repository"),checked:c,onChange:()=>y("clone")}),e.jsxs("span",{className:"setup-wizard-mode-option-copy",children:[e.jsx("strong",{children:s("setup.cloneGitRepository","Clone Git Repository")}),e.jsx("span",{children:s("setup.cloneGitRepositoryHint","Clone a remote repository into an empty or absent destination folder.")})]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-path",children:c?s("setup.destinationDirectory","Destination Directory"):m?s("setup.newRepositoryDirectory","New Repository Directory"):s("setup.projectDirectory","Project Directory")}),e.jsx(xe,{value:t.manualPath,onChange:G,nodeId:t.manualNodeId||void 0,localNodeId:_,selectCreatedDirectory:!0,placeholder:c?s("setup.clonePathPlaceholder","/path/for/new-clone"):m?s("setup.initPathPlaceholder","/path/to/new-project"):s("setup.projectPathPlaceholder","/path/to/your/project")}),e.jsx("p",{className:"form-hint",children:c?s("setup.clonePathHint","Select or type an absolute destination path. Fusion will clone into this directory. The destination must be empty or absent."):m?s("setup.initPathHint","Select or type an absolute path to an empty or non-git folder. Fusion will run git init during registration."):s("setup.projectPathHint","Select or type the absolute path to an existing git repository or workspace root.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-name",children:s("setup.projectName","Project Name")}),e.jsx("input",{id:"project-name",type:"text",value:t.manualName,onChange:a=>n(r=>({...r,manualName:a.target.value})),placeholder:s("setup.projectNamePlaceholder","my-project")}),e.jsx("p",{className:"form-hint",children:c?s("setup.projectNameHintClone","By default this follows the destination folder name unless you edit it."):m?s("setup.projectNameHintInit","By default this follows the folder name Fusion will initialize unless you edit it."):s("setup.projectNameHintExisting","By default this follows the selected directory name unless you edit it.")})]}),c&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"project-clone-url",children:s("setup.repositoryUrl","Repository URL")}),e.jsx("input",{id:"project-clone-url",type:"text",value:t.manualCloneUrl,onChange:a=>n(r=>({...r,manualCloneUrl:a.target.value,error:null})),placeholder:s("setup.repositoryUrlPlaceholder","https://github.com/owner/repo.git")}),e.jsx("p",{className:"form-hint",children:s("setup.cloneGitHint","Fusion will run git clone into the destination directory, then register that cloned folder.")})]}),k&&t.manualPath.trim()&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"workspace-mode",className:"checkbox-label",children:[e.jsx("input",{id:"workspace-mode",type:"checkbox",checked:t.workspaceMode,onChange:a=>n(r=>({...r,workspaceMode:a.target.checked}))}),s("setup.workspaceMode","Workspace mode (multi-repo)")]}),t.isDetectingWorkspace&&e.jsxs("p",{className:"form-hint",children:[e.jsx(C,{size:12,className:"animate-spin setup-wizard-inline-spinner"}),s("setup.detectingWorkspace","Detecting sub-repositories...")]}),!t.isDetectingWorkspace&&t.detectedRepos.length>0&&e.jsxs("p",{className:"form-hint",children:[s("setup.detectedRepos","Found {{count}} repositories:",{count:t.detectedRepos.length})," ",t.detectedRepos.join(", ")]}),!t.isDetectingWorkspace&&t.detectedRepos.length===0&&t.workspaceMode===!1&&t.manualPath.trim()&&e.jsx("p",{className:"form-hint",children:s("setup.noSubReposDetected","No sub-repositories detected. Enable if this is a multi-repo workspace.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"task-prefix",children:s("setup.taskPrefix","Task Prefix")}),e.jsx("input",{id:"task-prefix",type:"text",value:t.manualTaskPrefix,onChange:a=>n(r=>({...r,manualTaskPrefix:a.target.value.toUpperCase()})),placeholder:P(t.manualName||"FN"),maxLength:5}),e.jsx("p",{className:"form-hint",children:s("setup.taskPrefixHint",'Used for task IDs (e.g. "{{prefix}}-1"). Derived from project name.',{prefix:t.manualTaskPrefix||"FN"})})]}),e.jsxs("div",{className:"setup-wizard-advanced",children:[e.jsxs("button",{type:"button",className:"setup-wizard-advanced-toggle","aria-expanded":D,onClick:()=>L(a=>!a),children:[e.jsx(ue,{size:16,className:"setup-wizard-advanced-chevron"}),e.jsx("span",{children:s("setup.advancedSettings","Advanced settings")})]}),D&&e.jsxs("div",{className:"setup-wizard-advanced-panel",children:[e.jsx("div",{className:"form-group",children:e.jsxs("div",{className:"project-node-selector",children:[e.jsx("span",{className:"project-node-selector__label",children:s("setup.runtimeNode","Runtime Node")}),e.jsxs("select",{value:t.manualNodeId,onChange:a=>n(r=>({...r,manualNodeId:a.target.value})),disabled:O||t.isRegistering,children:[e.jsx("option",{value:"",children:s("setup.localNode","Local node")}),S.map(a=>e.jsxs("option",{value:a.id,children:[a.name," (",a.type,")"]},a.id))]})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("setup.isolationMode","Isolation Mode")}),e.jsxs("div",{className:"setup-wizard-isolation-options",children:[e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="in-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"in-process",checked:t.manualIsolationMode==="in-process",onChange:()=>n(a=>({...a,manualIsolationMode:"in-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.inProcess","In-Process")}),e.jsx("span",{children:s("setup.inProcessDesc","Lower overhead, shared memory. Best for most projects.")}),e.jsx("span",{className:"wizard-option-recommended",children:s("setup.recommended","Recommended")})]})]}),e.jsxs("label",{className:`setup-wizard-isolation-option${t.manualIsolationMode==="child-process"?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"isolation-mode",value:"child-process",checked:t.manualIsolationMode==="child-process",onChange:()=>n(a=>({...a,manualIsolationMode:"child-process"}))}),e.jsxs("div",{className:"setup-wizard-isolation-option-content",children:[e.jsx("strong",{children:s("setup.childProcess","Child-Process")}),e.jsx("span",{children:s("setup.childProcessDesc","Isolated execution with crash containment.")})]})]})]})]})]})]}),t.error&&e.jsx("div",{className:"wizard-error",role:"alert",children:t.error})]}),t.step==="agent"&&e.jsxs("div",{className:"setup-wizard-agent-step",children:[e.jsx("p",{className:"setup-wizard-agent-intro",children:s("setup.firstAgentIntro","Agents are optional. Fusion can build tasks without one by starting temporary agents for planning, coding, review, and merge. Create an agent only if you want help coordinating tasks and direction.")}),e.jsxs("div",{className:"setup-wizard-agent-layout",children:[e.jsxs("section",{className:"setup-wizard-agent-presets","aria-labelledby":"setup-first-agent-presets-heading",children:[e.jsx("div",{className:"setup-wizard-agent-section-heading",id:"setup-first-agent-presets-heading",children:s("setup.firstAgentTemplates","Templates")}),e.jsx("div",{className:"setup-wizard-agent-preset-list",role:"radiogroup","aria-label":s("setup.firstAgentTemplates","Templates"),children:h.map(a=>{const r=t.selectedPresetId===a.id;return e.jsxs("button",{type:"button",className:`setup-wizard-agent-preset${r?" selected":""}`,role:"radio","aria-checked":r,"aria-label":r?s("setup.selectedAgentTemplate","{{name}} selected",{name:a.name}):a.name,tabIndex:a.id===se?0:-1,"data-agent-preset-id":a.id,disabled:j,onClick:()=>b(a.id),onKeyDown:i=>Y(i,a.id),children:[e.jsx(F,{agent:{id:a.id,icon:a.icon,name:a.name},size:28}),e.jsxs("span",{className:"setup-wizard-agent-preset-copy",children:[e.jsxs("span",{className:"setup-wizard-agent-preset-name",children:[a.name,a.id==="ceo"&&e.jsx("span",{className:"wizard-option-recommended",children:s("setup.recommended","Recommended")})]}),e.jsx("span",{className:"setup-wizard-agent-preset-description",children:a.description})]})]},a.id)})})]}),e.jsxs("section",{className:"setup-wizard-agent-preview","aria-labelledby":"setup-first-agent-preview-heading",children:[e.jsx("div",{className:"setup-wizard-agent-section-heading",id:"setup-first-agent-preview-heading",children:s("setup.firstAgentPreview","Preview")}),e.jsxs("div",{className:"setup-wizard-agent-preview-card",children:[e.jsxs("div",{className:"setup-wizard-agent-preview-title-row",children:[e.jsx(F,{agent:{id:t.selectedPresetId||"draft",icon:t.agentDraft.icon,name:t.agentDraft.name},size:36}),e.jsxs("div",{children:[e.jsx("h3",{children:t.agentDraft.name||s("setup.firstAgentDraftName","Draft agent")}),e.jsx("p",{children:t.agentDraft.title||te?.title||s("setup.firstAgentCustomDraft","Custom agent draft")})]})]}),e.jsxs("dl",{className:"setup-wizard-agent-preview-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:s("agents.fieldRole","Role")}),e.jsx("dd",{children:t.agentDraft.role})]}),e.jsxs("div",{children:[e.jsx("dt",{children:s("agents.fieldInstructionsText","Inline Instructions")}),e.jsx("dd",{children:t.agentDraft.instructionsText||s("setup.firstAgentNoInstructions","No inline instructions yet")})]})]}),I&&e.jsxs("button",{type:"button",className:"btn setup-wizard-agent-ai-btn",onClick:()=>w(!0),disabled:j,children:[e.jsx(me,{size:16}),e.jsx("span",{children:s("agents.aiInterview","AI Interview")})]})]})]})]}),t.agentError&&e.jsx("div",{className:"wizard-error",role:"alert",tabIndex:-1,ref:M,children:t.agentError})]}),t.step==="complete"&&e.jsxs("div",{className:"setup-wizard-complete",children:[e.jsxs("div",{className:"setup-wizard-success-streak","aria-hidden":"true",children:[e.jsx("div",{className:"setup-wizard-success-streak-core"}),e.jsx("div",{className:"setup-wizard-success-streak-glow"})]}),e.jsx(T,{size:64,className:"success-icon"}),e.jsx("h3",{children:s("setup.allSet","All Set!")}),e.jsx("p",{children:t.agentOutcome==="created"?s("setup.firstAgentCreatedSuccess","Your project is registered and your first agent is ready."):s("setup.projectRegisteredSuccess","Your project has been registered successfully.")}),e.jsx("p",{children:t.agentOutcome==="skipped"?s("setup.firstAgentSkippedHint","You can create agents later from the Agents view."):s("setup.addMoreProjectsHint","You can add more projects anytime from the project overview.")})]})]}),e.jsxs("div",{className:"setup-wizard-footer",children:[e.jsx("a",{className:"btn setup-wizard-help-link",href:U,target:"_blank",rel:"noopener noreferrer",children:s("setup.needHelp","Need help?")}),t.step==="manual"&&e.jsx("button",{className:"btn btn-primary",onClick:$,disabled:ee,children:t.isRegistering?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:16,className:"animate-spin"}),e.jsx("span",{children:s("setup.registering","Registering...")})]}):e.jsx("span",{children:V})}),t.step==="agent"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:Z,disabled:j,children:s("setup.skipFirstAgent","Skip for now")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void K(),disabled:j||!t.agentDraft.name.trim(),"aria-busy":t.isCreatingAgent,children:t.isCreatingAgent?e.jsxs(e.Fragment,{children:[e.jsx(C,{size:16,className:"animate-spin"}),e.jsx("span",{children:s("setup.creatingFirstAgent","Creating agent...")})]}):e.jsx("span",{children:s("setup.createFirstAgent","Create Agent")})})]}),t.step==="complete"&&e.jsxs("button",{className:"btn btn-primary",onClick:B,children:[e.jsx(T,{size:16}),e.jsx("span",{children:s("setup.getStarted","Get Started")})]})]})]}),I&&R&&e.jsx(ge,{level:"modal",fallback:e.jsxs("div",{className:"wizard-error setup-wizard-agent-interview-error",role:"alert",children:[e.jsx("span",{children:s("setup.firstAgentInterviewLoadError","AI interview could not load. You can still create an agent from a template or skip this step.")}),e.jsx("button",{type:"button",className:"btn",onClick:()=>w(!1),children:s("setup.firstAgentContinueWithTemplates","Continue with templates")})]}),children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"wizard-error setup-wizard-agent-interview-error",role:"status",children:s("setup.firstAgentInterviewLoading","Loading AI Interview...")}),children:e.jsx(fe,{isOpen:R,onClose:()=>w(!1),onUseDraft:q,projectId:t.registeredProject?.id,existingAgents:[],mode:"create"})})})]})}export{Ie as SetupWizardModal};
@@ -1,4 +1,4 @@
1
- import{c as N,c3 as k,c4 as v,ad as y,o as S,c5 as x,c6 as f}from"./index-B6ttSchA.js";import{r,j as a}from"./vendor-react-SZ_qB27O.js";import{u as C}from"./vendor-i18n-GF3RlKbq.js";/**
1
+ import{c as N,c4 as k,c5 as v,ae as y,o as S,c6 as x,c7 as f}from"./index-D7eX7QJk.js";import{r,j as a}from"./vendor-react-SZ_qB27O.js";import{u as C}from"./vendor-i18n-GF3RlKbq.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as a,j as s}from"./vendor-react-SZ_qB27O.js";import{i as ms,j as us,t as vs,k as hs,l as gs,n as bs,V as ws,Z as xs,X as q,R as fs,o as js,C as ps,L as A,p as H,q as G,M as J}from"./index-B6ttSchA.js";import{u as Ns}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const Ss=new Set([".md",".markdown",".mdx"]);function Cs(r){const d=r.toLowerCase(),j=d.lastIndexOf(".");return j<0?!1:Ss.has(d.slice(j))}function zs({projectId:r,addToast:d,onClose:j}){const{t:e}=Ns("app"),[k,p]=a.useState([]),[F,T]=a.useState(!0),[Y,V]=a.useState(!1),[I,D]=a.useState(null),[_,ss]=a.useState([]),[g,ls]=a.useState(""),[M,B]=a.useState(null),[c,N]=a.useState(null),[b,S]=a.useState(null),[es,K]=a.useState(!1),[Q,C]=a.useState(null),[y,w]=a.useState(null),[u,v]=a.useState(null),[is,z]=a.useState(!1),[$,h]=a.useState(null),m=a.useRef(null),[P,as]=a.useState(""),O=g.trim()?k.filter(l=>l.name.toLowerCase().includes(g.toLowerCase())||l.relativePath.toLowerCase().includes(g.toLowerCase())):k,x=a.useCallback(async()=>{T(!0);try{const l=await ms(r);p(l)}catch(l){const t=l instanceof Error?l.message:e("skills.loadDiscoveredError","Failed to load discovered skills");d(t,"error")}finally{T(!1)}},[r,d]),f=a.useCallback(async l=>{const t=i=>{if(!i||typeof i!="object")return!1;const n=i;if(typeof n.status=="number"&&n.status>=500)return!0;if(n.details&&typeof n.details=="object"){const L=n.details;if(typeof L.code=="string"&&L.code.startsWith("upstream_"))return!0}const o=i;return typeof o.error=="string"&&typeof o.code=="string"};V(!0),D(null);try{const i=await us(l,20,r);ss(i.entries)}catch(i){if(t(i))D(e("skills.catalogUnavailable","Catalog is temporarily unavailable. Please try again later."));else{const n=i instanceof Error?i.message:e("skills.loadCatalogError","Failed to load catalog");D(n)}}finally{V(!1)}},[r]);a.useEffect(()=>{x(),f("")},[x,f]);const ts=a.useCallback(l=>{ls(l),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{as(l),m.current=null},300)},[]);a.useEffect(()=>()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),a.useEffect(()=>{f(P)},[P,f]);const ns=a.useCallback(async(l,t)=>{const i=!t;p(n=>n.map(o=>o.id===l?{...o,toggling:!0}:o));try{await vs(l,i,r),p(n=>n.map(o=>o.id===l?{...o,enabled:i,toggling:!1}:o)),d(e(`skills.${i?"enabled":"disabled"}`,i?"Skill enabled":"Skill disabled"),"success")}catch(n){p(L=>L.map(R=>R.id===l?{...R,toggling:!1}:R));const o=n instanceof Error?n.message:e("skills.toggleError","Failed to toggle skill");d(e("skills.toggleFailed","Failed to toggle skill: {{message}}",{message:o}),"error")}},[r,d]),cs=a.useCallback(async l=>{const t=l.repo?.trim();if(!(!t||M===l.id)){B(l.id);try{await hs(t,l.slug||l.name,r),d(e("skills.installSuccess","Installed {{name}}",{name:l.name}),"success"),await x()}catch(i){const n=i instanceof Error?i.message:e("skills.installError","Failed to install skill");d(e("skills.installFailed","Failed to install {{name}}: {{message}}",{name:l.name,message:n}),"error")}finally{B(i=>i===l.id?null:i)}}},[d,M,x,r]),E=a.useCallback(async l=>{K(!0),C(null),S(null),w(null),v(null),h(null);try{const t=await gs(l,r);S(t)}catch(t){const i=t instanceof Error?t.message:e("skills.loadContentError","Failed to load skill content");C(i)}finally{K(!1)}},[r]),U=a.useCallback((l,t)=>{if(!(t&&t.target.closest(".skills-view-item-toggle"))){if(c===l){N(null),S(null),C(null),w(null),v(null),h(null);return}N(l),E(l)}},[c,E]),os=a.useCallback(l=>{c!==l&&N(l),E(l)},[E,c]),W=a.useCallback(async(l,t)=>{w(t),v(null),h(null),z(!0);try{const i=await bs(l,t,r);v(i)}catch(i){const n=i instanceof Error?i.message:e("skills.loadFileError","Failed to load file");h(n)}finally{z(!1)}},[r]),rs=a.useCallback(()=>{w(null),v(null),h(null),z(!1)},[]),X=a.useCallback(()=>{N(null),S(null),C(null),w(null),v(null),h(null)},[]),ds=a.useMemo(()=>k.find(l=>l.id===c)??null,[k,c]),Z=()=>!b||b.files.length===0?null:s.jsxs("div",{className:"skills-view-detail-files","data-testid":"skill-files",children:[s.jsxs("span",{className:"skills-view-detail-files-label",children:[e("skills.filesLabel","Files"),":"]}),b.files.map(l=>{if(l.type==="directory")return s.jsxs("span",{className:"badge badge--sm skills-view-detail-file--dir",children:[l.name,"/"]},l.relativePath);const t=y===l.relativePath;return s.jsx("button",{type:"button","data-testid":"skill-file-item",className:`badge badge--sm skills-view-detail-file${t?" skills-view-detail-file--active":""}`,onClick:()=>c&&void W(c,l.relativePath),"aria-pressed":t,"aria-label":e("skills.viewFile","View {{name}}",{name:l.name}),children:l.name},l.relativePath)})]}),ks=()=>c?es?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingContent","Loading skill content...")]}):Q?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:Q}),s.jsx("button",{className:"btn btn-sm",onClick:()=>os(c),children:e("common.retry","Retry")})]}):b?y!==null?s.jsxs("div",{className:"skills-view-file-viewer","data-testid":"skill-file-viewer",children:[s.jsxs("div",{className:"skills-view-file-viewer-bar",children:[s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-file-back",onClick:rs,"data-testid":"skill-file-back","aria-label":e("skills.backToSkillMd","Back to SKILL.md"),children:[s.jsx(H,{size:14}),e("skills.backToSkillMd","Back to SKILL.md")]}),s.jsx("span",{className:"skills-view-file-viewer-name",children:y})]}),is?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingFile","Loading file...")]}):$?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:$}),s.jsx("button",{className:"btn btn-sm",onClick:()=>c&&void W(c,y),children:e("common.retry","Retry")})]}):u&&!u.isText?s.jsx("div",{className:"skills-view-detail-empty",children:e("skills.fileNotPreviewable","This file cannot be previewed.")}):u?Cs(u.relativePath)?s.jsx(J,{content:u.content||e("skills.emptyFile","(Empty file)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}):s.jsx("pre",{className:"skills-view-detail-content",children:u.content||e("skills.emptyFile","(Empty file)")}):null,Z()]}):s.jsxs(s.Fragment,{children:[s.jsx(J,{content:b.skillMd||e("skills.noSkillMd","(No SKILL.md found)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}),Z()]}):null:s.jsx("div",{className:"skills-view-detail-placeholder","data-testid":"skills-detail-empty",children:e("skills.selectASkill","Select a skill to view its details")});return s.jsxs("div",{className:"skills-view","data-testid":"skills-view","data-selected":c?"true":"false",children:[s.jsx(ws,{icon:xs,title:e("skills.title","Skills"),actions:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"skills-view-count","aria-label":e("skills.discoveredCount","{{count}} discovered skills",{count:k.length}),children:[k.length," ",e("skills.discovered","discovered")]}),s.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:j,"aria-label":e("skills.closeView","Close skills view"),children:s.jsx(q,{size:16})}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>void x(),disabled:F,children:[s.jsx(fs,{size:14,className:F?"spin":""}),e("common.refresh","Refresh")]})]})}),s.jsxs("div",{className:"skills-view-body",children:[s.jsx("div",{className:"skills-view__list","data-testid":"skills-list",children:s.jsxs("div",{className:"skills-view-content",children:[s.jsx("div",{className:"skills-view-search",children:s.jsx("input",{type:"text",className:"form-input",placeholder:e("skills.searchPlaceholder","Search skills..."),value:g,onChange:l=>ts(l.target.value),"aria-label":e("skills.searchLabel","Search skills")})}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[s.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:e("skills.discoveredSection","Discovered Skills")}),F?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingDiscovered","Loading discovered skills...")]}):k.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noDiscovered","No skills discovered in this project.")})}):O.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noMatchingDiscovered","No discovered skills match your search.")})}):s.jsx("div",{className:"skills-view-list",children:O.map(l=>{const t=c===l.id;return s.jsx("div",{children:s.jsxs("div",{className:`skills-view-item${t?" skills-view-item--selected":""}`,onClick:i=>U(l.id,i),role:"button",tabIndex:0,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),U(l.id))},"aria-expanded":t,"aria-label":e("skills.viewDetails","View details for {{name}}",{name:l.name}),children:[s.jsxs("div",{className:"skills-view-item-info",children:[s.jsxs("span",{className:"skills-view-item-name",children:[t?s.jsx(js,{size:14}):s.jsx(ps,{size:14}),s.jsx("span",{className:"skills-view-item-name-text",children:l.name})]}),s.jsx("span",{className:"skills-view-item-path",children:l.relativePath}),s.jsx("span",{className:"skills-view-item-source",children:l.metadata.source})]}),s.jsxs("label",{className:"skills-view-item-toggle",onClick:i=>i.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:l.enabled,disabled:l.toggling,onChange:()=>void ns(l.id,l.enabled),"aria-label":e(`skills.${l.enabled?"disable":"enable"}Skill`,l.enabled?"Disable {{name}}":"Enable {{name}}",{name:l.name})}),s.jsx("span",{className:"skills-view-toggle-slider"})]})]})},l.id)})})]}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[s.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:e("skills.catalogSection","Skills Catalog")}),I?s.jsxs("div",{className:"skills-view-error",children:[s.jsx("p",{children:I}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void f(P),children:e("common.tryAgain","Try Again")})]}):Y?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingCatalog","Loading catalog...")]}):_.length===0?s.jsx("div",{className:"skills-view-empty",children:g?s.jsx("p",{children:e("skills.noMatchingSearch","No skills match your search.")}):s.jsx("p",{children:e("skills.noCatalogAvailable","No skills available in the catalog.")})}):s.jsx("div",{className:"skills-view-grid",children:_.map(l=>{const i=!!l.repo?.trim(),n=M===l.id;return s.jsxs("div",{className:"skills-view-card",children:[s.jsxs("div",{className:"skills-view-card-header",children:[s.jsx("h4",{className:"skills-view-card-title",children:l.name}),i?s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-card-install",onClick:()=>void cs(l),disabled:n,"aria-label":e("skills.installSkill","Install {{name}}",{name:l.name}),children:[n?s.jsx(A,{size:14,className:"spin"}):null,n?e("skills.installing","Installing…"):e("skills.install","Install")]}):null]}),l.description&&s.jsx("p",{className:"skills-view-card-description",children:l.description}),l.tags&&l.tags.length>0&&s.jsx("div",{className:"skills-view-card-tags",children:l.tags.map(o=>s.jsx("span",{className:"badge badge--sm",children:o},o))}),l.installs!==void 0&&s.jsx("span",{className:"skills-view-card-installs",children:e("skills.installsCount","{{value}} installs",{value:l.installs.toLocaleString()})})]},l.id)})})]})]})}),s.jsxs("div",{className:"skills-view__detail","data-testid":"skill-detail",children:[s.jsxs("div",{className:"skills-view-detail-header",children:[s.jsx("button",{type:"button",className:"btn btn-sm btn-icon skills-view-detail-back",onClick:X,"aria-label":e("skills.backToList","Back to skills"),title:e("skills.backToList","Back to skills"),"data-testid":"skills-detail-back",children:s.jsx(H,{size:14})}),s.jsx("span",{className:"skills-view-detail-title",children:ds?.name??e("skills.detailTitle","Skill")}),s.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:X,disabled:!c,"aria-label":e("skills.closeDetail","Close skill detail"),children:[s.jsx(q,{size:14}),e("common.close","Close")]})]}),s.jsx("div",{className:"skills-view-detail-body",children:ks()})]})]})]})}export{zs as SkillsView};
1
+ import{r as a,j as s}from"./vendor-react-SZ_qB27O.js";import{i as ms,j as us,t as vs,k as hs,l as gs,n as bs,V as ws,Z as xs,X as q,R as fs,o as js,C as ps,L as A,p as H,q as G,M as J}from"./index-D7eX7QJk.js";import{u as Ns}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const Ss=new Set([".md",".markdown",".mdx"]);function Cs(r){const d=r.toLowerCase(),j=d.lastIndexOf(".");return j<0?!1:Ss.has(d.slice(j))}function zs({projectId:r,addToast:d,onClose:j}){const{t:e}=Ns("app"),[k,p]=a.useState([]),[F,T]=a.useState(!0),[Y,V]=a.useState(!1),[I,D]=a.useState(null),[_,ss]=a.useState([]),[g,ls]=a.useState(""),[M,B]=a.useState(null),[c,N]=a.useState(null),[b,S]=a.useState(null),[es,K]=a.useState(!1),[Q,C]=a.useState(null),[y,w]=a.useState(null),[u,v]=a.useState(null),[is,z]=a.useState(!1),[$,h]=a.useState(null),m=a.useRef(null),[P,as]=a.useState(""),O=g.trim()?k.filter(l=>l.name.toLowerCase().includes(g.toLowerCase())||l.relativePath.toLowerCase().includes(g.toLowerCase())):k,x=a.useCallback(async()=>{T(!0);try{const l=await ms(r);p(l)}catch(l){const t=l instanceof Error?l.message:e("skills.loadDiscoveredError","Failed to load discovered skills");d(t,"error")}finally{T(!1)}},[r,d]),f=a.useCallback(async l=>{const t=i=>{if(!i||typeof i!="object")return!1;const n=i;if(typeof n.status=="number"&&n.status>=500)return!0;if(n.details&&typeof n.details=="object"){const L=n.details;if(typeof L.code=="string"&&L.code.startsWith("upstream_"))return!0}const o=i;return typeof o.error=="string"&&typeof o.code=="string"};V(!0),D(null);try{const i=await us(l,20,r);ss(i.entries)}catch(i){if(t(i))D(e("skills.catalogUnavailable","Catalog is temporarily unavailable. Please try again later."));else{const n=i instanceof Error?i.message:e("skills.loadCatalogError","Failed to load catalog");D(n)}}finally{V(!1)}},[r]);a.useEffect(()=>{x(),f("")},[x,f]);const ts=a.useCallback(l=>{ls(l),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{as(l),m.current=null},300)},[]);a.useEffect(()=>()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),a.useEffect(()=>{f(P)},[P,f]);const ns=a.useCallback(async(l,t)=>{const i=!t;p(n=>n.map(o=>o.id===l?{...o,toggling:!0}:o));try{await vs(l,i,r),p(n=>n.map(o=>o.id===l?{...o,enabled:i,toggling:!1}:o)),d(e(`skills.${i?"enabled":"disabled"}`,i?"Skill enabled":"Skill disabled"),"success")}catch(n){p(L=>L.map(R=>R.id===l?{...R,toggling:!1}:R));const o=n instanceof Error?n.message:e("skills.toggleError","Failed to toggle skill");d(e("skills.toggleFailed","Failed to toggle skill: {{message}}",{message:o}),"error")}},[r,d]),cs=a.useCallback(async l=>{const t=l.repo?.trim();if(!(!t||M===l.id)){B(l.id);try{await hs(t,l.slug||l.name,r),d(e("skills.installSuccess","Installed {{name}}",{name:l.name}),"success"),await x()}catch(i){const n=i instanceof Error?i.message:e("skills.installError","Failed to install skill");d(e("skills.installFailed","Failed to install {{name}}: {{message}}",{name:l.name,message:n}),"error")}finally{B(i=>i===l.id?null:i)}}},[d,M,x,r]),E=a.useCallback(async l=>{K(!0),C(null),S(null),w(null),v(null),h(null);try{const t=await gs(l,r);S(t)}catch(t){const i=t instanceof Error?t.message:e("skills.loadContentError","Failed to load skill content");C(i)}finally{K(!1)}},[r]),U=a.useCallback((l,t)=>{if(!(t&&t.target.closest(".skills-view-item-toggle"))){if(c===l){N(null),S(null),C(null),w(null),v(null),h(null);return}N(l),E(l)}},[c,E]),os=a.useCallback(l=>{c!==l&&N(l),E(l)},[E,c]),W=a.useCallback(async(l,t)=>{w(t),v(null),h(null),z(!0);try{const i=await bs(l,t,r);v(i)}catch(i){const n=i instanceof Error?i.message:e("skills.loadFileError","Failed to load file");h(n)}finally{z(!1)}},[r]),rs=a.useCallback(()=>{w(null),v(null),h(null),z(!1)},[]),X=a.useCallback(()=>{N(null),S(null),C(null),w(null),v(null),h(null)},[]),ds=a.useMemo(()=>k.find(l=>l.id===c)??null,[k,c]),Z=()=>!b||b.files.length===0?null:s.jsxs("div",{className:"skills-view-detail-files","data-testid":"skill-files",children:[s.jsxs("span",{className:"skills-view-detail-files-label",children:[e("skills.filesLabel","Files"),":"]}),b.files.map(l=>{if(l.type==="directory")return s.jsxs("span",{className:"badge badge--sm skills-view-detail-file--dir",children:[l.name,"/"]},l.relativePath);const t=y===l.relativePath;return s.jsx("button",{type:"button","data-testid":"skill-file-item",className:`badge badge--sm skills-view-detail-file${t?" skills-view-detail-file--active":""}`,onClick:()=>c&&void W(c,l.relativePath),"aria-pressed":t,"aria-label":e("skills.viewFile","View {{name}}",{name:l.name}),children:l.name},l.relativePath)})]}),ks=()=>c?es?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingContent","Loading skill content...")]}):Q?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:Q}),s.jsx("button",{className:"btn btn-sm",onClick:()=>os(c),children:e("common.retry","Retry")})]}):b?y!==null?s.jsxs("div",{className:"skills-view-file-viewer","data-testid":"skill-file-viewer",children:[s.jsxs("div",{className:"skills-view-file-viewer-bar",children:[s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-file-back",onClick:rs,"data-testid":"skill-file-back","aria-label":e("skills.backToSkillMd","Back to SKILL.md"),children:[s.jsx(H,{size:14}),e("skills.backToSkillMd","Back to SKILL.md")]}),s.jsx("span",{className:"skills-view-file-viewer-name",children:y})]}),is?s.jsxs("div",{className:"skills-view-detail-loading",children:[s.jsx(A,{size:16,className:"spin"}),e("skills.loadingFile","Loading file...")]}):$?s.jsxs("div",{className:"skills-view-detail-error",children:[s.jsx(G,{size:14}),s.jsx("span",{children:$}),s.jsx("button",{className:"btn btn-sm",onClick:()=>c&&void W(c,y),children:e("common.retry","Retry")})]}):u&&!u.isText?s.jsx("div",{className:"skills-view-detail-empty",children:e("skills.fileNotPreviewable","This file cannot be previewed.")}):u?Cs(u.relativePath)?s.jsx(J,{content:u.content||e("skills.emptyFile","(Empty file)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}):s.jsx("pre",{className:"skills-view-detail-content",children:u.content||e("skills.emptyFile","(Empty file)")}):null,Z()]}):s.jsxs(s.Fragment,{children:[s.jsx(J,{content:b.skillMd||e("skills.noSkillMd","(No SKILL.md found)"),className:"skills-view-detail-markdown",testId:"skills-view-detail-markdown"}),Z()]}):null:s.jsx("div",{className:"skills-view-detail-placeholder","data-testid":"skills-detail-empty",children:e("skills.selectASkill","Select a skill to view its details")});return s.jsxs("div",{className:"skills-view","data-testid":"skills-view","data-selected":c?"true":"false",children:[s.jsx(ws,{icon:xs,title:e("skills.title","Skills"),actions:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"skills-view-count","aria-label":e("skills.discoveredCount","{{count}} discovered skills",{count:k.length}),children:[k.length," ",e("skills.discovered","discovered")]}),s.jsx("button",{className:"btn-icon skills-view-close touch-target",onClick:j,"aria-label":e("skills.closeView","Close skills view"),children:s.jsx(q,{size:16})}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>void x(),disabled:F,children:[s.jsx(fs,{size:14,className:F?"spin":""}),e("common.refresh","Refresh")]})]})}),s.jsxs("div",{className:"skills-view-body",children:[s.jsx("div",{className:"skills-view__list","data-testid":"skills-list",children:s.jsxs("div",{className:"skills-view-content",children:[s.jsx("div",{className:"skills-view-search",children:s.jsx("input",{type:"text",className:"form-input",placeholder:e("skills.searchPlaceholder","Search skills..."),value:g,onChange:l=>ts(l.target.value),"aria-label":e("skills.searchLabel","Search skills")})}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"discovered-skills-title",children:[s.jsx("h3",{id:"discovered-skills-title",className:"skills-view-section-title",children:e("skills.discoveredSection","Discovered Skills")}),F?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingDiscovered","Loading discovered skills...")]}):k.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noDiscovered","No skills discovered in this project.")})}):O.length===0?s.jsx("div",{className:"skills-view-empty",children:s.jsx("p",{children:e("skills.noMatchingDiscovered","No discovered skills match your search.")})}):s.jsx("div",{className:"skills-view-list",children:O.map(l=>{const t=c===l.id;return s.jsx("div",{children:s.jsxs("div",{className:`skills-view-item${t?" skills-view-item--selected":""}`,onClick:i=>U(l.id,i),role:"button",tabIndex:0,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),U(l.id))},"aria-expanded":t,"aria-label":e("skills.viewDetails","View details for {{name}}",{name:l.name}),children:[s.jsxs("div",{className:"skills-view-item-info",children:[s.jsxs("span",{className:"skills-view-item-name",children:[t?s.jsx(js,{size:14}):s.jsx(ps,{size:14}),s.jsx("span",{className:"skills-view-item-name-text",children:l.name})]}),s.jsx("span",{className:"skills-view-item-path",children:l.relativePath}),s.jsx("span",{className:"skills-view-item-source",children:l.metadata.source})]}),s.jsxs("label",{className:"skills-view-item-toggle",onClick:i=>i.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:l.enabled,disabled:l.toggling,onChange:()=>void ns(l.id,l.enabled),"aria-label":e(`skills.${l.enabled?"disable":"enable"}Skill`,l.enabled?"Disable {{name}}":"Enable {{name}}",{name:l.name})}),s.jsx("span",{className:"skills-view-toggle-slider"})]})]})},l.id)})})]}),s.jsxs("section",{className:"skills-view-section","aria-labelledby":"catalog-title",children:[s.jsx("h3",{id:"catalog-title",className:"skills-view-section-title",children:e("skills.catalogSection","Skills Catalog")}),I?s.jsxs("div",{className:"skills-view-error",children:[s.jsx("p",{children:I}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void f(P),children:e("common.tryAgain","Try Again")})]}):Y?s.jsxs("div",{className:"skills-view-loading",children:[s.jsx("span",{className:"spinner"}),e("skills.loadingCatalog","Loading catalog...")]}):_.length===0?s.jsx("div",{className:"skills-view-empty",children:g?s.jsx("p",{children:e("skills.noMatchingSearch","No skills match your search.")}):s.jsx("p",{children:e("skills.noCatalogAvailable","No skills available in the catalog.")})}):s.jsx("div",{className:"skills-view-grid",children:_.map(l=>{const i=!!l.repo?.trim(),n=M===l.id;return s.jsxs("div",{className:"skills-view-card",children:[s.jsxs("div",{className:"skills-view-card-header",children:[s.jsx("h4",{className:"skills-view-card-title",children:l.name}),i?s.jsxs("button",{type:"button",className:"btn btn-sm skills-view-card-install",onClick:()=>void cs(l),disabled:n,"aria-label":e("skills.installSkill","Install {{name}}",{name:l.name}),children:[n?s.jsx(A,{size:14,className:"spin"}):null,n?e("skills.installing","Installing…"):e("skills.install","Install")]}):null]}),l.description&&s.jsx("p",{className:"skills-view-card-description",children:l.description}),l.tags&&l.tags.length>0&&s.jsx("div",{className:"skills-view-card-tags",children:l.tags.map(o=>s.jsx("span",{className:"badge badge--sm",children:o},o))}),l.installs!==void 0&&s.jsx("span",{className:"skills-view-card-installs",children:e("skills.installsCount","{{value}} installs",{value:l.installs.toLocaleString()})})]},l.id)})})]})]})}),s.jsxs("div",{className:"skills-view__detail","data-testid":"skill-detail",children:[s.jsxs("div",{className:"skills-view-detail-header",children:[s.jsx("button",{type:"button",className:"btn btn-sm btn-icon skills-view-detail-back",onClick:X,"aria-label":e("skills.backToList","Back to skills"),title:e("skills.backToList","Back to skills"),"data-testid":"skills-detail-back",children:s.jsx(H,{size:14})}),s.jsx("span",{className:"skills-view-detail-title",children:ds?.name??e("skills.detailTitle","Skill")}),s.jsxs("button",{className:"btn btn-sm skills-view-detail-close",onClick:X,disabled:!c,"aria-label":e("skills.closeDetail","Close skill detail"),children:[s.jsx(q,{size:14}),e("common.close","Close")]})]}),s.jsx("div",{className:"skills-view-detail-body",children:ks()})]})]})]})}export{zs as SkillsView};
@@ -0,0 +1,6 @@
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Rt,az as ft,aA as ht,aB as Ot,bi as _t,bj as Pt,bk as Ut,bl as Kt,bm as Bt,bn as Vt,bo as Xt,bp as zt,aE as Gt,af as Wt,bq as qt,br as Z,bs as xt,L as Ht,P as gt,G as tt,X as et,bt as vt,I as Lt,J as yt,bu as Jt,ae as Yt,o as Qt,bv as Zt,bw as jt,am as te}from"./index-D7eX7QJk.js";import{u as kt}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ee=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],se=Rt("circle-plus",ee);function oe(C){const{items:r,...f}=C;return f}function It(C){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${C}-${crypto.randomUUID()}`:`${C}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ae(C={}){const{t:r}=kt("app"),{projectId:f,addToast:L}=C,o=`${Ot.TODO_LISTS_PREFIX}${f??"global"}`,[w,I]=l.useState(()=>{const s=ft(o,{maxAgeMs:ht});return Array.isArray(s)?s:[]}),[N,k]=l.useState([]),[T,O]=l.useState(()=>w.length===0),[q,y]=l.useState(null),[F,$]=l.useState(null),[j,g]=l.useState([]),S=l.useRef(F);S.current=F,l.useEffect(()=>{let s=!1;const c=ft(o,{maxAgeMs:ht}),u=Array.isArray(c)&&c.length>0;u?(I(c),O(!1)):(I([]),O(!0));async function b(){u||O(!0),y(null);try{const n=await zt(f);if(s)return;g(n);const a=n.map(oe);I(a),Gt(o,a,{maxBytes:5e5});const i=S.current&&n.some(d=>d.id===S.current)?S.current:n[0]?.id??null;$(i),k(i?n.find(d=>d.id===i)?.items??[]:[])}catch(n){if(s)return;g([]),I([]),k([]),$(null),y(n instanceof Error?n.message:r("todo.failedLoadLists","Failed to load todo lists"))}finally{s||O(!1)}}return b(),()=>{s=!0}},[o,f]),l.useEffect(()=>{if(!F){k([]);return}const s=j.find(c=>c.id===F);k(s?.items??[])},[j,F]);const H=l.useCallback(async s=>{const c=w,u=j,b=new Date().toISOString(),n={id:It("temp-list"),projectId:f??"",title:s,createdAt:b,updatedAt:b};y(null),I(a=>[...a,n]),g(a=>[...a,{...n,items:[]}]);try{const a=await _t(s,f);I(i=>i.map(d=>d.id===n.id?a:d)),g(i=>i.map(d=>d.id===n.id?{...a,items:[]}:d)),S.current||$(a.id)}catch(a){I(c),g(u),y(a instanceof Error?a.message:r("todo.failedCreateList","Failed to create list")),L?.(r("todo.failedCreateListToast","Failed to create todo list"),"error")}},[L,j,w,f,r]),P=l.useCallback(async(s,c)=>{const u=w,b=j;y(null),I(n=>n.map(a=>a.id===s?{...a,title:c}:a)),g(n=>n.map(a=>a.id===s?{...a,title:c}:a));try{const n=await Pt(s,c,f);I(a=>a.map(i=>i.id===s?n:i)),g(a=>a.map(i=>i.id===s?{...n,items:i.items}:i))}catch(n){I(u),g(b),y(n instanceof Error?n.message:r("todo.failedRenameList","Failed to rename list")),L?.(r("todo.failedRenameListToast","Failed to rename todo list"),"error")}},[L,j,w,f,r]),D=l.useCallback(async s=>{const c=w,u=j,b=S.current,n=b===s?w.find(a=>a.id!==s)?.id??null:b;y(null),I(a=>a.filter(i=>i.id!==s)),g(a=>a.filter(i=>i.id!==s)),b===s&&$(n);try{await Ut(s,f)}catch(a){I(c),g(u),$(b),y(a instanceof Error?a.message:r("todo.failedDeleteList","Failed to delete list")),L?.(r("todo.failedDeleteListToast","Failed to delete todo list"),"error")}},[L,j,w,f,r]),X=l.useCallback(async s=>{const c=S.current;if(!c)return;const u=N,b=j,n=new Date().toISOString(),a=N.reduce((d,p)=>Math.max(d,p.sortOrder),-1),i={id:It("temp-item"),listId:c,text:s,completed:!1,completedAt:null,createdAt:n,updatedAt:n,sortOrder:a+1};y(null),k(d=>[...d,i]),g(d=>d.map(p=>p.id===c?{...p,items:[...p.items,i]}:p));try{const d=await Kt(c,s,f);k(p=>p.map(v=>v.id===i.id?d:v)),g(p=>p.map(v=>v.id===c?{...v,items:v.items.map(R=>R.id===i.id?d:R)}:v))}catch(d){k(u),g(b),y(d instanceof Error?d.message:r("todo.failedCreateItem","Failed to create item")),L?.(r("todo.failedCreateItemToast","Failed to create todo item"),"error")}},[L,N,j,f,r]),A=l.useCallback(async(s,c)=>{const u=N.find(d=>d.id===s);if(!u)return;const b=N,n=j,a=c.completed??u.completed,i={...u,...c,completed:a,completedAt:a?u.completedAt??new Date().toISOString():null,updatedAt:new Date().toISOString()};y(null),k(d=>d.map(p=>p.id===s?i:p)),g(d=>d.map(p=>p.id===i.listId?{...p,items:p.items.map(v=>v.id===s?i:v)}:p));try{const d=await Bt(s,c,f);k(p=>p.map(v=>v.id===s?d:v)),g(p=>p.map(v=>v.id===d.listId?{...v,items:v.items.map(R=>R.id===s?d:R)}:v))}catch(d){k(b),g(n),y(d instanceof Error?d.message:r("todo.failedUpdateItem","Failed to update item")),L?.(r("todo.failedUpdateItemToast","Failed to update todo item"),"error")}},[L,N,j,f,r]),U=l.useCallback(async s=>{const c=N.find(u=>u.id===s);c&&await A(s,{completed:!c.completed})},[N,A]),M=l.useCallback(async s=>{const c=N,u=j;y(null),k(b=>b.filter(n=>n.id!==s)),g(b=>b.map(n=>({...n,items:n.items.filter(a=>a.id!==s)})));try{await Vt(s,f)}catch(b){k(c),g(u),y(b instanceof Error?b.message:r("todo.failedDeleteItem","Failed to delete item")),L?.(r("todo.failedDeleteItemToast","Failed to delete todo item"),"error")}},[L,N,j,f,r]),z=l.useCallback(async s=>{const c=S.current;if(!c)return;const u=N,b=j,n=new Map(N.map(i=>[i.id,i])),a=s.map((i,d)=>{const p=n.get(i);return p?{...p,sortOrder:d}:null}).filter(i=>i!==null);y(null),k(a),g(i=>i.map(d=>d.id===c?{...d,items:a}:d));try{await Xt(c,s,f)}catch(i){k(u),g(b),y(i instanceof Error?i.message:r("todo.failedReorderItems","Failed to reorder items")),L?.(r("todo.failedReorderItemsToast","Failed to reorder todo items"),"error")}},[L,N,j,f,r]);return{lists:w,items:N,loading:T,error:q,selectedListId:F,setSelectedListId:$,createList:H,renameList:P,deleteList:D,createItem:X,updateItem:A,toggleItem:U,deleteItem:M,reorderItems:z}}function ne(C){return[...C].sort((r,f)=>r.sortOrder-f.sortOrder)}function ue({projectId:C,addToast:r,onPlanningMode:f,onTaskCreated:L}){const{t:o}=kt("app"),{lists:w,items:I,loading:N,error:k,selectedListId:T,setSelectedListId:O,createList:q,renameList:y,deleteList:F,createItem:$,updateItem:j,toggleItem:g,deleteItem:S,reorderItems:H}=ae({projectId:C,addToast:(t,m)=>{if(m==="success"||m==="error"||m==="info"||m===void 0){r(t,m);return}r(t,"info")}}),[P,D]=l.useState(null),[X,A]=l.useState(""),[U,M]=l.useState(null),[z,s]=l.useState(""),[c,u]=l.useState(""),[b,n]=l.useState(!1),[a,i]=l.useState(""),[d,p]=l.useState([]),[v,R]=l.useState(!1),[J,K]=l.useState(!1),[st,B]=l.useState(null),Y=l.useRef(null),{confirm:Ct}=Wt(),[wt,ot]=l.useState("list"),G=l.useMemo(()=>w.find(t=>t.id===T)??null,[w,T]),_=l.useMemo(()=>ne(I.filter(t=>t.listId===T)),[I,T]),at=l.useMemo(()=>{const t=new Map;for(const m of w)t.set(m.id,{total:0,completed:0});for(const m of I){const h=t.get(m.listId)??{total:0,completed:0};h.total+=1,m.completed&&(h.completed+=1),t.set(m.listId,h)}return t},[I,w]),Q=G?at.get(G.id)??{total:_.length,completed:_.filter(t=>t.completed).length}:null;function nt(){D(null),A(""),u(""),n(!1)}function W(){M(null),s(""),i("")}function Nt(t){nt(),W(),O(t),ot("detail")}function At(){ot("list")}const St=l.useCallback(async()=>{R(!0);try{const t=await qt(void 0,C);p(t),K(!0)}catch(t){r(o("todo.failedToLoadAgents","Failed to load agents: {{error}}",{error:Z(t)}),"error"),K(!1),B(null)}finally{R(!1)}},[C,r,o]);l.useEffect(()=>{D(null),A(""),u(""),n(!1),M(null),s(""),i(""),K(!1),B(null)},[T]),l.useEffect(()=>{if(!J)return;const t=m=>{Y.current&&!Y.current.contains(m.target)&&(K(!1),B(null))};return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[J]);function Et(t){W(),D(t.id),A(t.title),n(!1)}async function it(){if(!P)return;const t=X.trim();if(!t){D(null),A("");return}await y(P,t),D(null),A("")}function dt(){D(null),A("")}function lt(t){nt(),M(t.id),s(t.text)}async function rt(){if(!U)return;const t=z.trim();if(!t){M(null),s("");return}await j(U,{text:t}),M(null),s("")}function ct(){M(null),s("")}async function mt(){const t=c.trim();t&&(await q(t),u(""),n(!1))}async function ut(){if(!T)return;const t=a.trim();t&&(await $(t),i(""))}async function Tt(t){await Ct({title:o("todo.deleteListTitle","Delete List"),message:o("todo.deleteListConfirm","Delete this list and all its items?"),danger:!0})&&await F(t)}async function Dt(t){await S(t)}async function bt(t,m){const h=_.map(V=>V.id),x=h.findIndex(V=>V===t);if(x<0)return;const E=m==="up"?x-1:x+1;E<0||E>=h.length||([h[x],h[E]]=[h[E],h[x]],await H(h))}const Ft=l.useCallback(async t=>{try{const m={description:t.text,source:{sourceType:"dashboard_ui"}},h=await xt(m,C);L?.(h),r(o("todo.taskCreatedFromTodo","Created {{id}} from todo",{id:h.id}),"success")}catch(m){r(o("todo.failedToCreateTask","Failed to create task: {{error}}",{error:Z(m)}),"error")}},[C,r,L,o]),$t=l.useCallback(async(t,m)=>{try{const h={description:t.text,assignedAgentId:m,source:{sourceType:"dashboard_ui"}},x=await xt(h,C);L?.(x);const V=d.find(Mt=>Mt.id===m)?.name??m;r(o("todo.taskCreatedAndAssigned","Created {{id}} and assigned to {{agent}}",{id:x.id,agent:V}),"success"),K(!1),B(null)}catch(h){r(o("todo.failedToCreateAndAssign","Failed to create and assign task: {{error}}",{error:Z(h)}),"error")}},[C,r,d,L,o]),pt=null;return N?e.jsxs("div",{className:"todo-view","data-testid":"todo-view-root",children:[pt,e.jsxs("div",{className:"todo-loading",children:[e.jsx(Ht,{className:"todo-loading-icon","aria-hidden":"true"}),e.jsx("p",{children:o("todo.loading","Loading todos...")})]})]}):e.jsxs("div",{className:"todo-view","data-testid":"todo-view-root",children:[pt,e.jsxs("div",{className:"todo-view-layout","data-mobile-stack-view":wt,children:[e.jsxs("aside",{className:"todo-view-sidebar","aria-label":o("todo.listsLabel","Todo lists sidebar"),children:[e.jsxs("div",{className:"todo-sidebar-header",children:[e.jsx("h3",{className:"todo-sidebar-title",children:o("todo.lists","Lists")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-add-list-btn",onClick:()=>{W(),n(!0),D(null)},"aria-label":o("todo.addList","Add list"),"data-testid":"add-list-button",children:e.jsx(gt,{})})]}),b&&e.jsxs("div",{className:"todo-list-item",children:[e.jsx("input",{className:"input todo-inline-edit-input",placeholder:o("todo.newListTitle","New list title"),value:c,onChange:t=>u(t.target.value),onKeyDown:t=>{t.key==="Enter"&&mt(),t.key==="Escape"&&(u(""),n(!1))},autoFocus:!0,"data-testid":"new-list-input"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{mt()},"aria-label":o("todo.saveList","Save list"),children:e.jsx(tt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{u(""),n(!1)},"aria-label":o("todo.cancelList","Cancel list"),children:e.jsx(et,{})})]}),w.length===0&&!b?e.jsxs("div",{className:"todo-empty-state",children:[e.jsx(vt,{"aria-hidden":"true"}),e.jsx("p",{children:o("todo.noListsEmpty","No todo lists yet. Create one to get started.")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>{W(),n(!0)},children:o("todo.createList","Create List")})]}):e.jsx("div",{className:"todo-list-items",role:"list","aria-label":o("todo.todoListsLabel","Todo lists"),children:w.map(t=>{const m=t.id===T,h=t.id===P,x=at.get(t.id)??{total:0,completed:0};return e.jsx("div",{className:`todo-list-item${m?" todo-list-item--active":""}`,role:"listitem",children:h?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"input todo-inline-edit-input",value:X,onChange:E=>A(E.target.value),onKeyDown:E=>{E.key==="Enter"&&it(),E.key==="Escape"&&dt()},autoFocus:!0,"data-testid":`rename-list-input-${t.id}`}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{it()},"aria-label":o("todo.saveListRename","Save list rename"),children:e.jsx(tt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:dt,"aria-label":o("todo.cancelListRename","Cancel list rename"),children:e.jsx(et,{})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"todo-list-select-btn",onClick:()=>Nt(t.id),"aria-label":o("todo.selectList","Select list {{title}}",{title:t.title}),"aria-current":m?"true":void 0,"data-testid":`todo-list-${t.id}`,children:[e.jsx("span",{className:"todo-list-item-name",children:t.title}),e.jsxs("span",{className:"todo-list-item-count",children:[x.completed,"/",x.total]})]}),e.jsxs("div",{className:"todo-list-item-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{Et(t)},"aria-label":o("todo.renameList","Rename {{title}}",{title:t.title}),"data-testid":`rename-list-button-${t.id}`,children:e.jsx(Lt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{Tt(t.id)},"aria-label":o("todo.deleteList","Delete {{title}}",{title:t.title}),"data-testid":`delete-list-button-${t.id}`,children:e.jsx(yt,{})})]})]})},t.id)})})]}),e.jsxs("section",{className:"todo-view-main","aria-label":o("todo.itemsLabel","Todo items"),children:[k&&e.jsxs("div",{className:"todo-error-banner",role:"alert",children:[e.jsx("span",{className:"todo-error-message",children:k}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>window.location.reload(),children:o("actions.retry","Retry")})]}),G?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"todo-items-header",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn todo-mobile-back-btn",onClick:At,"aria-label":o("todo.backToLists","Back to lists"),"data-testid":"todo-mobile-back-button",children:e.jsx(Jt,{})}),e.jsxs("div",{className:"todo-items-heading",children:[e.jsx("h3",{children:G.title}),Q&&e.jsx("span",{className:"todo-items-progress",children:o("todo.completedCount","{{completed}}/{{total}} complete",{completed:Q.completed,total:Q.total})})]})]}),e.jsxs("div",{className:"todo-add-item-row",children:[e.jsx("input",{className:"input",placeholder:o("todo.addItemPlaceholder","Add a todo item"),value:a,onChange:t=>i(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ut(),t.key==="Escape"&&i("")},"data-testid":"new-item-input"}),e.jsxs("button",{type:"button",className:"btn btn-primary",onClick:()=>{ut()},children:[e.jsx(gt,{size:14}),o("actions.add","Add")]})]}),_.length===0?e.jsx("div",{className:"todo-empty-state",children:e.jsx("p",{children:o("todo.noItemsEmpty","No items in this list. Add one above.")})}):e.jsx("div",{className:"todo-items-list",children:_.map((t,m)=>{const h=t.id===U;return e.jsxs("div",{className:"todo-item","data-testid":`todo-item-${t.id}`,children:[e.jsxs("div",{className:"todo-item-main-row",children:[e.jsx("input",{type:"checkbox",checked:t.completed,onChange:()=>{g(t.id)},className:"todo-item-checkbox","aria-label":`Toggle ${t.text}`,"data-testid":`toggle-item-${t.id}`}),h?e.jsx("input",{className:"input todo-inline-edit-input",value:z,onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&rt(),x.key==="Escape"&&ct()},autoFocus:!0,"data-testid":`edit-item-input-${t.id}`}):e.jsx("button",{type:"button",className:`todo-item-text${t.completed?" todo-item-text--completed":""}`,onClick:()=>lt(t),children:t.text})]}),e.jsx("div",{className:"todo-item-actions","data-testid":`todo-item-actions-${t.id}`,children:h?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{rt()},"aria-label":o("todo.saveItemEdit","Save item edit"),children:e.jsx(tt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:ct,"aria-label":o("todo.cancelItemEdit","Cancel item edit"),children:e.jsx(et,{})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"todo-item-reorder-btns",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{bt(t.id,"up")},disabled:m===0,"aria-label":o("todo.moveItemUp","Move {{text}} up",{text:t.text}),"data-testid":`move-up-${t.id}`,children:e.jsx(Yt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-item-reorder-btn",onClick:()=>{bt(t.id,"down")},disabled:m===_.length-1,"aria-label":o("todo.moveItemDown","Move {{text}} down",{text:t.text}),"data-testid":`move-down-${t.id}`,children:e.jsx(Qt,{})})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{f?.(t.text)},"aria-label":o("todo.startPlanning","Start planning from {{text}}",{text:t.text}),"data-testid":`planning-from-${t.id}`,children:e.jsx(Zt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{Ft(t)},"aria-label":o("todo.createTaskFrom","Create task from {{text}}",{text:t.text}),"data-testid":`create-task-from-${t.id}`,children:e.jsx(se,{})}),e.jsxs("div",{className:"todo-agent-picker-trigger",ref:st===t.id?Y:void 0,children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>{B(t.id),St()},"aria-label":o("todo.assignAgent","Assign {{text}} to agent",{text:t.text}),"data-testid":`assign-agent-for-${t.id}`,children:e.jsx(jt,{})}),J&&st===t.id&&e.jsx("div",{className:"todo-agent-picker-dropdown",onMouseDown:x=>{x.preventDefault()},children:v?e.jsx("div",{className:"todo-agent-picker-loading",children:e.jsx(te,{label:o("todo.loadingAgents","Loading agents...")})}):d.length>0?d.map(x=>e.jsxs("button",{type:"button",className:"todo-agent-picker-item",onClick:()=>{$t(t,x.id)},children:[e.jsx(jt,{}),e.jsx("span",{children:x.name}),e.jsx("span",{className:"todo-agent-picker-role",children:x.role})]},x.id)):e.jsx("div",{className:"todo-agent-picker-empty",children:o("todo.noAgentsAvailable","No agents available")})})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon todo-icon-btn",onClick:()=>lt(t),"aria-label":o("todo.editItem","Edit {{text}}",{text:t.text}),"data-testid":`edit-item-${t.id}`,children:e.jsx(Lt,{})}),e.jsx("button",{type:"button",className:"btn btn-sm btn-icon btn-danger todo-icon-btn",onClick:()=>{Dt(t.id)},"aria-label":o("todo.deleteItem","Delete {{text}}",{text:t.text}),"data-testid":`delete-item-${t.id}`,children:e.jsx(yt,{})})]})})]},t.id)})})]}):e.jsxs("div",{className:"todo-empty-state",children:[e.jsx(vt,{"aria-hidden":"true"}),e.jsx("p",{children:o("todo.selectListEmpty","Select a list from the sidebar")})]})]})]})]})}export{ue as TodoView};