@lovelybunch/api 1.0.75-alpha.9 → 1.0.75

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 (163) hide show
  1. package/dist/lib/jobs/job-runner.js +10 -2
  2. package/dist/lib/jobs/job-scheduler.js +21 -0
  3. package/dist/lib/mail/mail-runner.d.ts +51 -0
  4. package/dist/lib/mail/mail-runner.js +342 -0
  5. package/dist/lib/slack/slack-service.d.ts +2 -0
  6. package/dist/lib/slack/slack-service.js +3 -0
  7. package/dist/lib/storage/file-storage.d.ts +16 -16
  8. package/dist/lib/storage/file-storage.js +59 -64
  9. package/dist/lib/terminal/terminal-manager.d.ts +3 -3
  10. package/dist/lib/terminal/terminal-manager.js +10 -10
  11. package/dist/routes/api/v1/ai/route.js +39 -19
  12. package/dist/routes/api/v1/git/index.js +23 -0
  13. package/dist/routes/api/v1/mail/index.d.ts +3 -0
  14. package/dist/routes/api/v1/mail/index.js +23 -0
  15. package/dist/routes/api/v1/mail/route.d.ts +294 -0
  16. package/dist/routes/api/v1/mail/route.js +344 -0
  17. package/dist/routes/api/v1/mcp/index.js +32 -32
  18. package/dist/routes/api/v1/slack/index.d.ts +3 -0
  19. package/dist/routes/api/v1/slack/index.js +15 -0
  20. package/dist/routes/api/v1/slack/route.d.ts +124 -0
  21. package/dist/routes/api/v1/slack/route.js +192 -0
  22. package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
  23. package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
  24. package/dist/routes/api/v1/tasks/index.d.ts +3 -0
  25. package/dist/routes/api/v1/tasks/index.js +10 -0
  26. package/dist/routes/api/v1/tasks/route.d.ts +96 -0
  27. package/dist/routes/api/v1/tasks/route.js +136 -0
  28. package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
  29. package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
  30. package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
  31. package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
  32. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
  33. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
  34. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
  35. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
  36. package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
  37. package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
  38. package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
  39. package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
  40. package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
  41. package/dist/server-with-static.js +12 -8
  42. package/dist/server.js +12 -8
  43. package/package.json +4 -4
  44. package/static/assets/{ActivityPage-OxRci_V2.js → ActivityPage-k4I7Q53O.js} +1 -1
  45. package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
  46. package/static/assets/{ArchitectureEditPage-D7xcH6dY.js → ArchitectureEditPage-CpowsIx2.js} +4 -4
  47. package/static/assets/{ArchitecturePage-pvnlX-NW.js → ArchitecturePage-DYxC_aMR.js} +1 -1
  48. package/static/assets/{AuthSettingsPage-Bu0CZ1rY.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
  49. package/static/assets/{CallbackPage-D0lkjxCT.js → CallbackPage-bROCGapx.js} +1 -1
  50. package/static/assets/CodePage-CPCj64rX.js +2 -0
  51. package/static/assets/{CollapsibleSection-Bt_ZLnJc.js → CollapsibleSection-M5cXbl92.js} +1 -1
  52. package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
  53. package/static/assets/{GitPage-TrTxZ27J.js → GitPage-BiDtdSK1.js} +2 -2
  54. package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
  55. package/static/assets/IdentityPage-BC16skg6.js +6 -0
  56. package/static/assets/{ImplementationStepsEditor-Ctx0CvbU.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
  57. package/static/assets/{IntegrationsSettingsPage-C2wJVdM7.js → IntegrationsSettingsPage-CC_VKIQa.js} +1 -1
  58. package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
  59. package/static/assets/{KnowledgeDetailPage-BdTUfWqj.js → KnowledgeDetailPage-DzHXBS7Q.js} +1 -1
  60. package/static/assets/{KnowledgeEditPage-D8XK4IUf.js → KnowledgeEditPage-BwGnUH_m.js} +1 -1
  61. package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
  62. package/static/assets/{LoginPage-Dqxd7cTa.js → LoginPage-VQ3lcfLV.js} +1 -1
  63. package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
  64. package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
  65. package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
  66. package/static/assets/MailSentPage-C_5yFly_.js +1 -0
  67. package/static/assets/{McpSettingsPage-10n35zXi.js → McpSettingsPage-i9YHcu1s.js} +1 -1
  68. package/static/assets/{NewKnowledgePage-BlJzzuh7.js → NewKnowledgePage-BnVY7WUD.js} +1 -1
  69. package/static/assets/{NewSkillPage-ByqN--mH.js → NewSkillPage-DwniHD6D.js} +1 -1
  70. package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
  71. package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
  72. package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
  73. package/static/assets/{ProjectEditPage-DKJTY2uc.js → ProjectEditPage-DUUlIEqI.js} +1 -1
  74. package/static/assets/{ProjectPage-2VblKCWz.js → ProjectPage-Unz9PQpA.js} +1 -1
  75. package/static/assets/{PromptsSettingsPage-B4mOhXuo.js → PromptsSettingsPage-DVpIuRKI.js} +1 -1
  76. package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
  77. package/static/assets/{ResourcesPage-2BbjIWfF.js → ResourcesPage-BP5tuAi-.js} +1 -1
  78. package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
  79. package/static/assets/{RolePage-qXWXZ2FZ.js → RolePage-Fed52Ov5.js} +1 -1
  80. package/static/assets/{RulesSettingsPage-BtM7p8F6.js → RulesSettingsPage-BQ2O0u66.js} +3 -3
  81. package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
  82. package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
  83. package/static/assets/{SkillEditPage-Czlo8WWT.js → SkillEditPage-urF4snjo.js} +1 -1
  84. package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
  85. package/static/assets/{SkillsSettingsPage-DKtpy7qk.js → SkillsSettingsPage-BViFgckG.js} +1 -1
  86. package/static/assets/{SourceInput-BITn1Y15.js → SourceInput-CAFKTHw-.js} +1 -1
  87. package/static/assets/{TagInput-BK91_M1N.js → TagInput-C6lI-ePr.js} +1 -1
  88. package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
  89. package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
  90. package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
  91. package/static/assets/TerminalPage-BG_wlccr.js +1 -0
  92. package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
  93. package/static/assets/{UserPreferencesPage-DrgYEcxO.js → UserPreferencesPage-CWUq3efu.js} +1 -1
  94. package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
  95. package/static/assets/{UtilitiesPage-Djr4qT5L.js → UtilitiesPage-BAxokhLh.js} +1 -1
  96. package/static/assets/{alert-CsMvyYoX.js → alert-BXsc6_qu.js} +1 -1
  97. package/static/assets/{arrow-down-BZnfbld8.js → arrow-down-DmW_3gE8.js} +1 -1
  98. package/static/assets/{arrow-left-WGBYWq3h.js → arrow-left-1S-835kP.js} +1 -1
  99. package/static/assets/{arrow-up-BByVUPE7.js → arrow-up-BYism_o1.js} +1 -1
  100. package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
  101. package/static/assets/{badge-AwLOflf5.js → badge-BUEY53dV.js} +1 -1
  102. package/static/assets/{browser-modal-BzGNFfTG.js → browser-modal-DCNdI4NT.js} +2 -2
  103. package/static/assets/{card-SN5gKnu7.js → card-BcPlIAH5.js} +1 -1
  104. package/static/assets/{chevron-left-C7uNq9l_.js → chevron-left-FMmNe7yP.js} +1 -1
  105. package/static/assets/{chevron-up-CHdIiLxL.js → chevron-up-CqM3won3.js} +1 -1
  106. package/static/assets/{chevrons-up-TXwQuoUN.js → chevrons-up-DTvCkIHc.js} +1 -1
  107. package/static/assets/{circle-alert-37E5gU9K.js → circle-alert-dseM-Ib7.js} +1 -1
  108. package/static/assets/{circle-check-big-nY4PntB5.js → circle-check-big-jKg34xC-.js} +1 -1
  109. package/static/assets/{circle-check-D02pWDME.js → circle-check-eyo6pBP1.js} +1 -1
  110. package/static/assets/{circle-play-7EXFLo4F.js → circle-play-BrY_lNiH.js} +1 -1
  111. package/static/assets/{circle-x-By4JoTHB.js → circle-x-uqmzEce1.js} +1 -1
  112. package/static/assets/{clipboard-BdymjxLO.js → clipboard-tzPFoieb.js} +1 -1
  113. package/static/assets/{clock-HDu44KTo.js → clock-Bjc06QBM.js} +1 -1
  114. package/static/assets/code-DrYqPukx.js +6 -0
  115. package/static/assets/{download-Cv2G2Eg9.js → download-Bg__QCLT.js} +1 -1
  116. package/static/assets/{external-link-DwMXcCCj.js → external-link-CNDy2UUo.js} +1 -1
  117. package/static/assets/{eye-DYnjJzdb.js → eye-DLFBnC8t.js} +1 -1
  118. package/static/assets/{folder-git-2-COeWFPHS.js → folder-git-2-DUqd0WRi.js} +1 -1
  119. package/static/assets/index-CHdBxVyk.css +2 -0
  120. package/static/assets/{index-9Tv-j_Ga.js → index-DFcWlnzl.js} +118 -103
  121. package/static/assets/{info-BmtuPMhv.js → info-D6jxZC5X.js} +1 -1
  122. package/static/assets/kiro-CX1mOsRO.js +17 -0
  123. package/static/assets/{label-TGqbNfMO.js → label-DBuh-ke5.js} +1 -1
  124. package/static/assets/{markdown-editor-ls1JPK_e.js → markdown-editor-B4YNQFT2.js} +1 -1
  125. package/static/assets/message-square-B5RWz_ff.js +6 -0
  126. package/static/assets/paperclip-4A_3MaPx.js +6 -0
  127. package/static/assets/{pause-CAWbvTiL.js → pause-BzhKXHtR.js} +1 -1
  128. package/static/assets/{play-DF_Qeu0H.js → play-CHIf-Rcz.js} +1 -1
  129. package/static/assets/{radio-group-DYTbywtK.js → radio-group-C1ct-VsJ.js} +1 -1
  130. package/static/assets/{refresh-cw-BFZxHqbC.js → refresh-cw-B3OwrDUf.js} +1 -1
  131. package/static/assets/{search-Dr90tbch.js → search-Cq1ksEdp.js} +1 -1
  132. package/static/assets/{select-Cs5qtMYV.js → select-44mcS2_G.js} +1 -1
  133. package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
  134. package/static/assets/{switch-4TDb6YiQ.js → switch-CIwjYvCt.js} +1 -1
  135. package/static/assets/{tabs-BrbEvF4V.js → tabs-DTV6Su-h.js} +1 -1
  136. package/static/assets/{tag-DrQkepeD.js → tag-p6yeowCW.js} +1 -1
  137. package/static/assets/{terminal-preview-uuKF9_x4.js → terminal-preview-DN38x9Jm.js} +1 -1
  138. package/static/assets/use-terminal-BXJqOeJe.js +1 -0
  139. package/static/assets/{video-DYA2WfbA.js → video-BH5ChaoS.js} +1 -1
  140. package/static/index.html +2 -2
  141. package/static/assets/ApiKeysSettingsPage-C0evI19e.js +0 -2
  142. package/static/assets/CodePage-BJ4PC5nb.js +0 -2
  143. package/static/assets/DashboardPage-BiffPdmj.js +0 -41
  144. package/static/assets/GitSettingsPage-D7q5xQd_.js +0 -6
  145. package/static/assets/IdentityPage-CY0Ak2j0.js +0 -11
  146. package/static/assets/JobDetailPage-Phx_IlKX.js +0 -1
  147. package/static/assets/KnowledgePage-Ci9G7Br-.js +0 -8
  148. package/static/assets/NewProposalPage-BP7Ttoxk.js +0 -90
  149. package/static/assets/ProposalDetailPage-m3ysyzpj.js +0 -1
  150. package/static/assets/ProposalEditPage-3XVg_paW.js +0 -1
  151. package/static/assets/ProposalsPage-B3u0aFFz.js +0 -17
  152. package/static/assets/ResourceDetailPage-somBLUpC.js +0 -1
  153. package/static/assets/RoleEditPage-CLzX7Xhi.js +0 -13
  154. package/static/assets/SchedulePage-4tFcIBSs.js +0 -4
  155. package/static/assets/SkillDetailPage-CroSdaju.js +0 -1
  156. package/static/assets/SkillsPage-CgULbcI-.js +0 -8
  157. package/static/assets/TerminalPage-8fwvnOo2.js +0 -1
  158. package/static/assets/TerminalSessionPage-BhO5U48p.js +0 -13
  159. package/static/assets/UserSettingsPage-Dj6lKLi8.js +0 -1
  160. package/static/assets/droid-CPteN3f9.js +0 -17
  161. package/static/assets/index-GFQ5RqVh.css +0 -2
  162. package/static/assets/use-terminal-BG5UXuVE.js +0 -1
  163. package/static/assets/zap-h9QOsasv.js +0 -6
@@ -1 +1 @@
1
- import{a as w,r,A as y,j as e,x as C,F as b,B as n,M as P,ax as E,L as k,H as L,au as z}from"./index-9Tv-j_Ga.js";import{C as c,a as i,b as x,c as F}from"./card-SN5gKnu7.js";import{B as p}from"./badge-AwLOflf5.js";import{c as B}from"./clipboard-B9ndUJKl.js";import{E as D}from"./external-link-DwMXcCCj.js";function I(){const{toast:d}=w(),[o,h]=r.useState(null),[j,u]=r.useState(!0),[f,l]=r.useState(!1);r.useEffect(()=>{fetch(`${y}/api/v1/context/project`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(h(s.document),l(!0)):l(!1)}).catch(()=>{l(!1)}).finally(()=>{u(!1)})},[]);const v=async()=>{const s=".nut/context/project.md";try{await B(s),d({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(m){console.error("Failed to copy path:",m),d({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},N=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"project-md",filename:"project.md",name:"project.md",path:".nut/context/project.md"}});window.dispatchEvent(s)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading Project Overview..."})]})})})});if(!f||!o)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(b,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Project Overview Found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Run ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded",children:"coconut init"})," to create the project overview."]})]})})})});const t=o.metadata,a=t.project?.website||t.project?.repository,g=a?(s=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).host.replace(/^www\./,"")}catch{return s.replace(/^https?:\/\//,"")}})(a):null;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Core project information and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(n,{variant:"outline",size:"sm",onClick:v,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(n,{size:"sm",asChild:!0,children:e.jsxs(k,{to:"/context/project/edit",children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),t&&e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsxs(c,{children:[e.jsx(x,{className:"pb-3",children:e.jsx(F,{className:"text-lg font-semibold",children:"Project Info"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.project?.name||"Unnamed Project"}),t.project?.description&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.project.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(D,{className:"w-3 h-3 mr-2"}),g||"Website"]})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[t.project?.version&&e.jsxs(p,{variant:"secondary",children:["v",t.project.version]}),t.project?.stage&&e.jsx(p,{variant:t.project.stage==="mvp"?"default":"secondary",children:t.project.stage})]})]})]})]})}),e.jsxs(c,{children:[e.jsx(x,{}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(z,{children:o.content||"No content available"})})})]})]})}export{I as default};
1
+ import{a as w,r,A as y,j as e,t as C,F as b,B as n,M as P,au as E,L as k,Y as L,ar as z}from"./index-DFcWlnzl.js";import{C as c,a as i,b as p,c as F}from"./card-BcPlIAH5.js";import{B as x}from"./badge-BUEY53dV.js";import{c as B}from"./clipboard-B9ndUJKl.js";import{E as D}from"./external-link-CNDy2UUo.js";function I(){const{toast:d}=w(),[o,h]=r.useState(null),[j,u]=r.useState(!0),[f,l]=r.useState(!1);r.useEffect(()=>{fetch(`${y}/api/v1/context/project`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(h(s.document),l(!0)):l(!1)}).catch(()=>{l(!1)}).finally(()=>{u(!1)})},[]);const v=async()=>{const s=".nut/context/project.md";try{await B(s),d({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(m){console.error("Failed to copy path:",m),d({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},N=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"project-md",filename:"project.md",name:"project.md",path:".nut/context/project.md"}});window.dispatchEvent(s)};if(j)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading Project Overview..."})]})})})});if(!f||!o)return e.jsx("div",{className:"space-y-6",children:e.jsx(c,{children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(b,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Project Overview Found"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["Run ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded",children:"coconut init"})," to create the project overview."]})]})})})});const t=o.metadata,a=t.project?.website||t.project?.repository,g=a?(s=>{try{return new URL(s.startsWith("http")?s:`https://${s}`).host.replace(/^www\./,"")}catch{return s.replace(/^https?:\/\//,"")}})(a):null;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Project Overview"}),e.jsx("p",{className:"text-muted-foreground",children:"Core project information and configuration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(n,{variant:"outline",size:"sm",onClick:v,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(n,{size:"sm",asChild:!0,children:e.jsxs(k,{to:"/context/project/edit",children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),t&&e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsxs(c,{children:[e.jsx(p,{className:"pb-3",children:e.jsx(F,{className:"text-lg font-semibold",children:"Project Info"})}),e.jsxs(i,{className:"space-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.project?.name||"Unnamed Project"}),t.project?.description&&e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.project.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(D,{className:"w-3 h-3 mr-2"}),g||"Website"]})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[t.project?.version&&e.jsxs(x,{variant:"secondary",children:["v",t.project.version]}),t.project?.stage&&e.jsx(x,{variant:t.project.stage==="mvp"?"default":"secondary",children:t.project.stage})]})]})]})]})}),e.jsxs(c,{children:[e.jsx(p,{}),e.jsx(i,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(z,{children:o.content||"No content available"})})})]})]})}export{I as default};
@@ -1 +1 @@
1
- import{j as e,a2 as p,B as r,P as h,H as j,ai as u,O as g,I as l}from"./index-9Tv-j_Ga.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-SN5gKnu7.js";import{L as a}from"./label-TGqbNfMO.js";import{S as f,a as v,b as N,c as y,d as b}from"./select-Cs5qtMYV.js";import{B as o}from"./badge-AwLOflf5.js";import{E as w}from"./eye-DYnjJzdb.js";import{D as C}from"./download-Cv2G2Eg9.js";import"./chevron-up-CHdIiLxL.js";function U(){const m=[{id:"1",name:"Code Review Assistant",description:"Prompt for AI agents to perform thorough code reviews",category:"Code Review",usage:"cursor-cli, claude-code",lastUpdated:"2 days ago",active:!0},{id:"2",name:"Architecture Advisor",description:"System prompt for architectural decision guidance",category:"Architecture",usage:"gemini-cli, claude-code",lastUpdated:"1 week ago",active:!0},{id:"3",name:"Bug Analysis Expert",description:"Specialized prompt for debugging and error analysis",category:"Debugging",usage:"cursor-cli",lastUpdated:"3 days ago",active:!1},{id:"4",name:"Documentation Generator",description:"Prompt for generating comprehensive code documentation",category:"Documentation",usage:"github-copilot, claude-code",lastUpdated:"5 days ago",active:!0}],x=["Code Review","Architecture","Debugging","Documentation","Testing","Refactoring","Security","Performance"];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"System Prompts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage system prompts used by AI agents and integrations for consistent behavior."})]}),e.jsx(p,{}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Prompt Library"}),e.jsx(c,{children:"Pre-configured prompts for different AI agents and use cases."})]}),e.jsxs(r,{size:"sm",children:[e.jsx(h,{className:"h-4 w-4 mr-2"}),"New Prompt"]})]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),e.jsx(o,{variant:s.active?"default":"secondary",children:s.active?"Active":"Inactive"}),e.jsx(o,{variant:"outline",children:s.category})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used by: ",s.usage]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated: ",s.lastUpdated]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(w,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(g,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Create New Prompt"}),e.jsx(c,{children:"Design a new system prompt for your AI agents and integrations."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptName",children:"Prompt Name"}),e.jsx(l,{id:"promptName",placeholder:"Enter prompt name"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptCategory",children:"Category"}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(N,{placeholder:"Select category"})}),e.jsx(y,{children:x.map(s=>e.jsx(b,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptDescription",children:"Description"}),e.jsx(l,{id:"promptDescription",placeholder:"Brief description of the prompt's purpose"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"targetIntegrations",children:"Target Integrations"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["cursor-cli","claude-code","gemini-cli","github-copilot"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptContent",children:"Prompt Content"}),e.jsx("textarea",{id:"promptContent",className:"w-full min-h-[200px] p-3 border rounded-md font-mono text-sm",placeholder:"You are an expert code reviewer. Your task is to..."})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptVariables",children:"Variables (JSON format)"}),e.jsx("textarea",{id:"promptVariables",className:"w-full min-h-[100px] p-3 border rounded-md font-mono text-sm",placeholder:'{"language": "typescript", "framework": "react", "style": "functional"}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(r,{variant:"outline",children:"Preview"}),e.jsx(r,{variant:"outline",children:"Save as Draft"}),e.jsx(r,{children:"Save & Activate"})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Prompt Templates"}),e.jsx(c,{children:"Import and export prompt templates for sharing across teams."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(r,{variant:"outline",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Import Template"]}),e.jsx(r,{variant:"outline",size:"sm",children:"Export All Prompts"}),e.jsx(r,{variant:"outline",size:"sm",children:"Export Selected"})]}),e.jsx("div",{className:"p-4 border-2 border-dashed rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop prompt template files here, or click to browse"})})]})]})]})}export{U as default};
1
+ import{j as e,a$ as p,B as r,P as h,Y as j,af as u,E as g,I as l}from"./index-DFcWlnzl.js";import{C as t,b as i,c as n,d as c,a as d}from"./card-BcPlIAH5.js";import{L as a}from"./label-DBuh-ke5.js";import{S as f,a as v,b as N,c as y,d as b}from"./select-44mcS2_G.js";import{B as o}from"./badge-BUEY53dV.js";import{E as w}from"./eye-DLFBnC8t.js";import{D as C}from"./download-Bg__QCLT.js";import"./chevron-up-CqM3won3.js";function U(){const m=[{id:"1",name:"Code Review Assistant",description:"Prompt for AI agents to perform thorough code reviews",category:"Code Review",usage:"cursor-cli, claude-code",lastUpdated:"2 days ago",active:!0},{id:"2",name:"Architecture Advisor",description:"System prompt for architectural decision guidance",category:"Architecture",usage:"gemini-cli, claude-code",lastUpdated:"1 week ago",active:!0},{id:"3",name:"Bug Analysis Expert",description:"Specialized prompt for debugging and error analysis",category:"Debugging",usage:"cursor-cli",lastUpdated:"3 days ago",active:!1},{id:"4",name:"Documentation Generator",description:"Prompt for generating comprehensive code documentation",category:"Documentation",usage:"github-copilot, claude-code",lastUpdated:"5 days ago",active:!0}],x=["Code Review","Architecture","Debugging","Documentation","Testing","Refactoring","Security","Performance"];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"System Prompts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage system prompts used by AI agents and integrations for consistent behavior."})]}),e.jsx(p,{}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(n,{children:"Prompt Library"}),e.jsx(c,{children:"Pre-configured prompts for different AI agents and use cases."})]}),e.jsxs(r,{size:"sm",children:[e.jsx(h,{className:"h-4 w-4 mr-2"}),"New Prompt"]})]})}),e.jsx(d,{children:e.jsx("div",{className:"space-y-4",children:m.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h4",{className:"font-medium",children:s.name}),e.jsx(o,{variant:s.active?"default":"secondary",children:s.active?"Active":"Inactive"}),e.jsx(o,{variant:"outline",children:s.category})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used by: ",s.usage]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Updated: ",s.lastUpdated]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(w,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(j,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(u,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",children:e.jsx(g,{className:"h-4 w-4"})})]})]},s.id))})})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Create New Prompt"}),e.jsx(c,{children:"Design a new system prompt for your AI agents and integrations."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptName",children:"Prompt Name"}),e.jsx(l,{id:"promptName",placeholder:"Enter prompt name"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptCategory",children:"Category"}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(N,{placeholder:"Select category"})}),e.jsx(y,{children:x.map(s=>e.jsx(b,{value:s.toLowerCase(),children:s},s))})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptDescription",children:"Description"}),e.jsx(l,{id:"promptDescription",placeholder:"Brief description of the prompt's purpose"})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"targetIntegrations",children:"Target Integrations"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:["cursor-cli","claude-code","gemini-cli","github-copilot"].map(s=>e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",className:"rounded"}),e.jsx("span",{className:"text-sm",children:s})]},s))})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptContent",children:"Prompt Content"}),e.jsx("textarea",{id:"promptContent",className:"w-full min-h-[200px] p-3 border rounded-md font-mono text-sm",placeholder:"You are an expert code reviewer. Your task is to..."})]}),e.jsxs("div",{children:[e.jsx(a,{htmlFor:"promptVariables",children:"Variables (JSON format)"}),e.jsx("textarea",{id:"promptVariables",className:"w-full min-h-[100px] p-3 border rounded-md font-mono text-sm",placeholder:'{"language": "typescript", "framework": "react", "style": "functional"}'})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(r,{variant:"outline",children:"Preview"}),e.jsx(r,{variant:"outline",children:"Save as Draft"}),e.jsx(r,{children:"Save & Activate"})]})]})]}),e.jsxs(t,{children:[e.jsxs(i,{children:[e.jsx(n,{children:"Prompt Templates"}),e.jsx(c,{children:"Import and export prompt templates for sharing across teams."})]}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(r,{variant:"outline",size:"sm",children:[e.jsx(C,{className:"h-4 w-4 mr-2"}),"Import Template"]}),e.jsx(r,{variant:"outline",size:"sm",children:"Export All Prompts"}),e.jsx(r,{variant:"outline",size:"sm",children:"Export Selected"})]}),e.jsx("div",{className:"p-4 border-2 border-dashed rounded-lg text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop prompt template files here, or click to browse"})})]})]})]})}export{U as default};
@@ -0,0 +1 @@
1
+ import{x as Z,u as ee,a as se,r as a,A as u,j as e,B as i,ae as te,af as A,m as ae,F as M,X as ie,aq as re,ar as le,as as ne,at as oe}from"./index-DFcWlnzl.js";import{B as ce}from"./badge-BUEY53dV.js";import{c as W}from"./clipboard-B9ndUJKl.js";import{A as B}from"./arrow-left-1S-835kP.js";import{L as de,H as me,I as ue,V as xe,M as R,F as he,a as I}from"./video-BH5ChaoS.js";import{D as U}from"./download-Bg__QCLT.js";import{T as fe}from"./tag-p6yeowCW.js";function ke(){const{id:x}=Z(),b=ee(),{toast:o}=se(),[s,p]=a.useState(null),[G,C]=a.useState(!0),[L,h]=a.useState(null),[r,j]=a.useState(null),[f,F]=a.useState(!1),[g,c]=a.useState(!1),[V,E]=a.useState(!1),[S,T]=a.useState(!1);a.useEffect(()=>{x&&(C(!0),h(null),fetch(`${u}/api/v1/resources/${x}`).then(t=>{if(!t.ok)throw new Error(`Resource not found (${t.status})`);if(t.headers.get("content-type")?.includes("application/json"))return t.json();throw new Error("NEED_METADATA")}).then(t=>{if(t.success&&t.data)p(t.data);else if(t.id)p(t);else throw new Error("Invalid response")}).catch(async t=>{if(t.message==="NEED_METADATA")try{const d=await(await fetch(`${u}/api/v1/resources`)).json();if(d.success&&d.data){const m=d.data.find(Q=>Q.id===x);if(m){p(m);return}}h("Resource not found")}catch{h("Failed to load resource")}else h(t.message||"Failed to load resource")}).finally(()=>C(!1)))},[x]),a.useEffect(()=>{T(!1)},[s?.id]);const l=s?`${u}/api/v1/resources/${s.id}`:"",w=s?.thumbnailPath?`${u}/api/v1/resources/${s.id}/thumbnail`:"",D=s?.type.startsWith("image/")??!1,P=s?s.type==="image/svg+xml"||s.name.toLowerCase().endsWith(".svg"):!1,_=s?s.type==="application/pdf"||s.name.toLowerCase().endsWith(".pdf"):!1,H=s?.type.startsWith("video/")??!1,J=s?.type.startsWith("audio/")??!1,v=s?s.type.startsWith("text/")||s.type==="application/json"||s.type.includes("javascript")||s.type.includes("typescript")||s.type.includes("xml")||s.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,N=s?s.name.toLowerCase().endsWith(".md")||s.name.toLowerCase().endsWith(".markdown"):!1,y=s?s.type==="application/json"||s.name.toLowerCase().endsWith(".json"):!1,k=s?s.type==="text/html"||s.name.toLowerCase().endsWith(".html"):!1;a.useEffect(()=>{s&&(v||N||y||k)?(F(!0),fetch(l).then(t=>{if(t.ok)return t.text();throw new Error("Failed to load file")}).then(t=>j(t)).catch(t=>{console.error("Failed to load text content:",t),j(null)}).finally(()=>F(!1))):j(null)},[s?.id,v,N,y,k,l]),a.useEffect(()=>{const t=n=>{n.key==="Escape"&&g&&c(!1)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g]);const O=t=>{if(t===0)return"0 B";const n=1024,d=["B","KB","MB","GB"],m=Math.floor(Math.log(t)/Math.log(n));return parseFloat((t/Math.pow(n,m)).toFixed(2))+" "+d[m]},K=t=>new Date(t).toLocaleString(),z=t=>t.startsWith("image/")?e.jsx(ue,{className:"h-6 w-6"}):t.startsWith("video/")?e.jsx(xe,{className:"h-6 w-6"}):t.startsWith("audio/")?e.jsx(R,{className:"h-6 w-6"}):t.includes("text")||t.includes("document")||t.includes("code")?e.jsx(M,{className:"h-6 w-6"}):t.includes("json")||t.includes("javascript")||t.includes("typescript")?e.jsx(he,{className:"h-6 w-6"}):e.jsx(re,{className:"h-6 w-6"}),$=()=>{s&&window.open(`${u}/api/v1/resources/${s.id}?download=true`)},Y=async()=>{if(s)try{const t=`.nut/resources/files/${s.path}`;await W(t),o({title:"Path copied!",description:`Copied ${t} to clipboard`})}catch{o({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},q=async()=>{if(s)try{const t=`${window.location.origin}/resources/${s.id}`;await W(t),E(!0),o({title:"Link copied!",description:"Share link copied to clipboard"}),setTimeout(()=>E(!1),2e3)}catch{o({title:"Failed to copy",description:"Unable to copy link to clipboard",variant:"destructive"})}},X=()=>{if(!s)return null;if(P)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:l,alt:s.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(i,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:e.jsx(I,{className:"h-4 w-4"})})]});if(_)return e.jsx("iframe",{src:l,className:"w-full h-full min-h-[600px] rounded-lg border",title:s.name});if(H)return e.jsx("video",{src:l,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(J)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(R,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:l,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(N&&r!==null)return f?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(le,{remarkPlugins:[oe],rehypePlugins:[ne],children:r})});if(k&&r!==null)return f?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:r,className:"w-full h-full min-h-[600px] rounded-lg border",title:s.name,sandbox:"allow-same-origin"});if(y&&r!==null){if(f)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let t=r;try{const n=JSON.parse(r);t=JSON.stringify(n,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:t})})})}return v&&r!==null?f?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:r})})}):D?e.jsxs(e.Fragment,{children:[w&&!S&&e.jsx("img",{src:w,alt:s.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg blur-[2px] scale-[1.01]"}),e.jsx("img",{src:l,alt:s.name,className:`max-w-full max-h-full object-contain rounded-lg shadow-lg ${w&&!S?"absolute inset-0 m-auto opacity-0":""}`,onLoad:()=>T(!0)}),e.jsx(i,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>c(!0),children:e.jsx(I,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[z(s.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(i,{variant:"outline",onClick:$,children:[e.jsx(U,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return G?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading resource..."})}):L||!s?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:L||"Resource not found"}),e.jsxs(i,{variant:"outline",onClick:()=>b("/resources"),children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),"Back to Resources"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-6 py-4 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>b("/resources"),title:"Back to Resources",children:e.jsx(B,{className:"h-4 w-4"})}),z(s.type),e.jsxs("div",{className:"min-w-0 flex items-baseline gap-3",children:[e.jsx("h1",{className:"text-xl font-semibold truncate",children:s.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:s.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:q,title:"Copy share link",children:V?e.jsx(te,{className:"h-4 w-4"}):e.jsx(de,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:Y,title:"Copy path to clipboard",children:e.jsx(A,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:$,title:"Download",children:e.jsx(U,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden border rounded-lg",children:X()}),e.jsx("div",{className:"p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 md:grid-cols-2 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:O(s.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:K(s.uploadedAt)})]})]}),e.jsx("div",{className:"space-y-2",children:s.metadata.tags&&s.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(t=>e.jsx(ce,{variant:"secondary",className:"text-xs",children:t},t))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"truncate flex-1",title:s.metadata.description,children:s.metadata.description})]}):e.jsx("div",{className:"flex-1"}),s.metadata.generationPrompt&&e.jsxs(i,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(s.metadata.generationPrompt||""),o({title:"Prompt copied!",description:"Generation prompt copied to clipboard"})},children:[e.jsx(A,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]}),g&&(D||P)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>c(!1),children:[e.jsx(i,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>c(!1),children:e.jsx(ie,{className:"h-6 w-6"})}),e.jsx("img",{src:l,alt:s.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:t=>t.stopPropagation()})]})]})}export{ke as default};
@@ -1,4 +1,4 @@
1
- import{c as xe,r as t,j as e,D as pe,b as ge,d as ve,f as je,x as le,S as os,B as F,ah as Xe,h as Ee,a as $e,A as ae,q as be,ae as Ve,s as ue,aj as ca,ak as da,al as ua,am as we,an as Fe,ao as _e,ap as ma,aq as Bs,ar as ha,as as xa,e as fa,I as We,ai as Ze,X as cs,C as $s,n as pa,F as Ne,at as es,au as ga,av as va,aw as ja,a5 as ba,a6 as wa,p as Na,a7 as ya,aa as Je,P as ds,g as us,O as ms,ax as _a}from"./index-9Tv-j_Ga.js";import{C as Ye,b as hs,a as Qe,c as Sa,d as Ca}from"./card-SN5gKnu7.js";import{L as C}from"./label-TGqbNfMO.js";import{B as Me}from"./badge-AwLOflf5.js";import{c as ka}from"./clipboard-B9ndUJKl.js";import{S as B,a as $,b as U,c as z,d as K}from"./select-Cs5qtMYV.js";import{R as Us}from"./registry-ANRa5WBi.js";import{I as ye,M as fe,V as Be,L as Pa,H as Ea,F as ss,a as xs}from"./video-DYA2WfbA.js";import{D as as}from"./download-Cv2G2Eg9.js";import{C as zs}from"./chevron-left-C7uNq9l_.js";import{T as Ma}from"./tag-DrQkepeD.js";import{S as Fa}from"./search-Dr90tbch.js";import"./chevron-up-CHdIiLxL.js";/**
1
+ import{c as xe,r as t,j as e,D as pe,b as ge,d as ve,f as je,t as le,S as os,B as F,ae as Xe,h as Ee,a as $e,A as ae,o as be,ab as Ve,p as ue,ag as ca,ah as da,ai as ua,aj as we,ak as Fe,al as _e,am as ma,an as Bs,ao as ha,ap as xa,e as fa,I as We,af as Ze,X as cs,C as $s,m as pa,F as Ne,aq as es,ar as ga,as as va,at as ja,a2 as ba,a3 as wa,n as Na,a4 as ya,a7 as Je,P as ds,g as us,E as ms,au as _a}from"./index-DFcWlnzl.js";import{C as Ye,b as hs,a as Qe,c as Sa,d as Ca}from"./card-BcPlIAH5.js";import{L as C}from"./label-DBuh-ke5.js";import{B as Me}from"./badge-BUEY53dV.js";import{c as ka}from"./clipboard-B9ndUJKl.js";import{S as B,a as $,b as U,c as z,d as K}from"./select-44mcS2_G.js";import{R as Us}from"./registry-ANRa5WBi.js";import{I as ye,M as fe,V as Be,L as Pa,H as Ea,F as ss,a as xs}from"./video-BH5ChaoS.js";import{D as as}from"./download-Bg__QCLT.js";import{C as zs}from"./chevron-left-FMmNe7yP.js";import{T as Ma}from"./tag-p6yeowCW.js";import{S as Fa}from"./search-Cq1ksEdp.js";import"./chevron-up-CqM3won3.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,13 @@
1
+ import{u as N,a as E,r as s,A as o,j as e,B as v,L as R,a0 as D}from"./index-DFcWlnzl.js";import{C as y,a as S,b as A,c as L}from"./card-BcPlIAH5.js";import{L as P}from"./label-DBuh-ke5.js";import{S as z,a as I,b as q,c as T,d as M}from"./select-44mcS2_G.js";import{M as O}from"./markdown-editor-B4YNQFT2.js";import{A as B}from"./arrow-left-1S-835kP.js";import{C as F}from"./circle-check-big-jKg34xC-.js";import"./chevron-up-CqM3won3.js";const d=[{id:"software-engineer",title:"Software Engineer",description:"Builds, refactors, and reviews high-quality code across stacks. Excellent at translating specs into implementation and optimizing system performance. Strong at debugging, architecture patterns, and accelerating development velocity."},{id:"product-strategist",title:"Product Strategist",description:"Defines product direction, clarifies requirements, and aligns work with user and business goals. Skilled in roadmap planning, prioritization, and transforming ambiguous ideas into actionable plans."},{id:"researcher",title:"Researcher",description:"Investigates topics deeply, synthesizes information, and produces evidence-based insights. Strong at literature review, competitive analysis, and generating clear summaries to inform decisions."},{id:"designer",title:"Designer",description:"Creates intuitive interfaces, user flows, and visual assets. Focused on usability, accessibility, and crafting polished experiences. Strong at wireframing and turning requirements into elegant solutions."},{id:"qa-engineer",title:"QA Engineer",description:"Identifies bugs, edge cases, and reliability gaps. Produces test plans, automated tests, and reproducible reports. Strong at ensuring product quality and preventing regressions."},{id:"devops-engineer",title:"DevOps Engineer",description:"Manages infrastructure, deployments, and operational reliability. Skilled with CI/CD, observability, automation, and environment provisioning. Ensures systems are scalable and fault-tolerant."},{id:"data-analyst",title:"Data Analyst",description:"Analyzes data, defines metrics, and generates actionable insights. Strong in SQL, visualization, experimentation, and turning raw data into strategic recommendations."},{id:"marketer",title:"Marketer",description:"Creates campaigns, messaging, and positioning to reach target audiences. Skilled in content, funnels, and brand strategy. Strong at synthesizing market needs and shaping demand."},{id:"sales-partnerships-agent",title:"Sales & Partnerships Agent",description:"Identifies prospects, crafts outreach, and develops strategic relationships. Strong at value articulation, objection handling, and mapping product capabilities to customer needs."},{id:"growth-operator",title:"Growth Operator",description:"Optimizes acquisition, activation, and retention through experimentation. Skilled in funnel analysis, rapid testing, and leveraging data for compounding growth."},{id:"customer-success-specialist",title:"Customer Success Specialist",description:"Ensures users succeed by providing onboarding, guidance, and proactive support. Strong at diagnosing user challenges and improving long-term satisfaction and retention."},{id:"orchestration-engineer",title:"Orchestration Engineer",description:"Coordinates multi-agent workflows, dependencies, and handoffs. Strong at breaking large tasks into sequenced steps and ensuring agents operate cohesively and efficiently."},{id:"context-curator",title:"Context Curator",description:"Maintains clean, accurate project context by organizing files, logs, and knowledge. Strong at eliminating ambiguity, ensuring agents have the right information at the right time."},{id:"documentation-writer",title:"Documentation Writer",description:"Produces clear technical docs, guides, READMEs, and CP summaries. Strong at structuring complex information and keeping knowledge bases up to date and accessible."}];function H(){const j=N(),{toast:a}=E(),[l,c]=s.useState(""),[r,g]=s.useState(""),[b,u]=s.useState(!0),[p,m]=s.useState(!1),h=s.useRef(!1),w=t=>{if(g(t),!h.current)return;const i=d.find(n=>n.id===t);i?.description&&c(i.description)};s.useEffect(()=>{Promise.all([fetch(`${o}/api/v1/context/role`).then(t=>t.json()),fetch(`${o}/api/v1/config`).then(t=>t.json())]).then(([t,i])=>{if(t.success&&c(t.document.content.trim()),i?.success){const n=i.data?.coconut?.role;n&&g(n)}h.current=!0,u(!1)}).catch(t=>{console.error("Failed to load context:",t),a({title:"Error",description:"Failed to load role definition",variant:"destructive"}),u(!1)})},[a]);const C=async()=>{m(!0);try{const t=r?d.find(k=>k.id===r)?.description:void 0,[i,n]=await Promise.all([fetch(`${o}/api/v1/context/role`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l,metadata:{}})}),fetch(`${o}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconut:{role:r||void 0,roleDescription:t}})})]),f=await i.json(),x=await n.json();if(f.success&&x.success)a({title:"Success",description:"Role definition saved successfully",action:e.jsx(F,{className:"h-4 w-4"})}),j("/context/role");else throw new Error(f.error||x.error||"Failed to save")}catch(t){console.error("Save error:",t),a({title:"Error",description:"Failed to save role definition",variant:"destructive"})}finally{m(!1)}};return b?e.jsx("div",{className:"space-y-6",children:e.jsx(y,{children:e.jsx(S,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Role Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define your role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(v,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(R,{to:"/context/role",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(B,{className:"w-4 h-4"})})}),e.jsxs(v,{onClick:C,disabled:p,size:"sm",children:[e.jsx(D,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save"})]})]})]}),e.jsxs(y,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(L,{children:"Role Documentation"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{className:"text-sm text-muted-foreground",children:"Role:"}),e.jsxs(z,{value:r,onValueChange:w,children:[e.jsx(I,{className:"w-48",children:e.jsx(q,{placeholder:"Select role"})}),e.jsx(T,{children:d.map(t=>e.jsx(M,{value:t.id,children:t.title},t.id))})]})]})]})}),e.jsx(S,{children:e.jsx(O,{value:l,onChange:t=>c(t||""),placeholder:`Write your role definition in markdown...
2
+
3
+ ## Your Role
4
+
5
+ Describe your role and primary responsibilities.
6
+
7
+ ## Guidelines
8
+
9
+ Key guidelines and principles to follow.
10
+
11
+ ## Constraints
12
+
13
+ Any constraints or boundaries to be aware of.`,height:800})})]})]})}export{H as default};
@@ -1 +1 @@
1
- import{a as N,r as t,A as v,j as e,x as C,F as g,B as a,L as c,H as d,M as w,ax as y,au as b}from"./index-9Tv-j_Ga.js";import{C as i,a as r,b as E}from"./card-SN5gKnu7.js";import{c as k}from"./clipboard-B9ndUJKl.js";function L(){const{toast:l}=N(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/role`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/role.md";try{await k(s),l({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),l({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"role-md",filename:"role.md",name:"role.md",path:".nut/context/role.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading role definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(g,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Role Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Role definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Role Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Role"}),e.jsx("p",{className:"text-muted-foreground",children:"This Coconut's responsibilities and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:o.content||"No content available"})})})]})]})}export{L as default};
1
+ import{a as N,r as t,A as v,j as e,t as C,F as g,B as a,L as c,Y as d,M as w,au as y,ar as b}from"./index-DFcWlnzl.js";import{C as i,a as r,b as E}from"./card-BcPlIAH5.js";import{c as k}from"./clipboard-B9ndUJKl.js";function L(){const{toast:l}=N(),[o,m]=t.useState(null),[x,h]=t.useState(!0),[u,n]=t.useState(!1);t.useEffect(()=>{fetch(`${v}/api/v1/context/role`).then(s=>{if(s.ok)return s.json();throw new Error("Not found")}).then(s=>{s.success?(m(s.document),n(!0)):n(!1)}).catch(()=>{n(!1)}).finally(()=>{h(!1)})},[]);const p=async()=>{const s=".nut/context/role.md";try{await k(s),l({title:"Copied!",description:`Path ${s} copied to clipboard`})}catch(f){console.error("Failed to copy path:",f),l({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},j=()=>{const s=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"role-md",filename:"role.md",name:"role.md",path:".nut/context/role.md"}});window.dispatchEvent(s)};return x?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(C,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading role definition..."})]})})})}):!u||!o?e.jsx("div",{className:"space-y-6",children:e.jsx(i,{children:e.jsx(r,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(g,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Role Definition Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Role definition will appear here once created."}),e.jsx(a,{className:"mt-4",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 mr-2"}),"Create Role Definition"]})})]})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Role"}),e.jsx("p",{className:"text-muted-foreground",children:"This Coconut's responsibilities and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:p,children:[e.jsx(y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(a,{size:"sm",asChild:!0,children:e.jsxs(c,{to:"/context/role/edit",children:[e.jsx(d,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),e.jsxs(i,{children:[e.jsx(E,{className:"pb-0"}),e.jsx(r,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(b,{children:o.content||"No content available"})})})]})]})}export{L as default};
@@ -1,9 +1,9 @@
1
- import{c as f,r,A as p,j as e,a2 as F,B as l,P as L,I as c,O as T}from"./index-9Tv-j_Ga.js";import{C as I,b as z,a as _}from"./card-SN5gKnu7.js";import{L as n}from"./label-TGqbNfMO.js";import{B as D}from"./badge-AwLOflf5.js";/**
1
+ import{c as f,r,A as p,j as e,a$ as F,B as l,P as L,I as c,E as T}from"./index-DFcWlnzl.js";import{C as I,b as z,a as _}from"./card-BcPlIAH5.js";import{L as n}from"./label-DBuh-ke5.js";import{B as D}from"./badge-BUEY53dV.js";/**
2
2
  * @license lucide-react v0.542.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 O=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],q=f("link",O);/**
6
+ */const q=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],O=f("link",q);/**
7
7
  * @license lucide-react v0.542.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{c as f,r,A as p,j as e,a2 as F,B as l,P as L,I as c,O as T}from"./index-9
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const R=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],w=f("unlink",R);function G(){const[v,C]=r.useState([]),[y,k]=r.useState(!1),[o,h]=r.useState(null),[u,j]=r.useState(!1),[g,N]=r.useState(null),[a,d]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1}),[i,m]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});r.useEffect(()=>{x()},[]);const x=async()=>{try{const s=await(await fetch(`${p}/api/v1/symlinks`)).json();s.success&&C(s.symlinks)}catch(t){console.error("Error fetching symlinks:",t)}},S=async t=>{h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error toggling symlink")}catch(s){console.error("Error toggling symlink:",s)}finally{h(null)}},A=async t=>{if(confirm("Are you sure you want to delete this symlink configuration?")){h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error deleting symlink")}catch(s){console.error("Error deleting symlink:",s)}finally{h(null)}}},E=async()=>{if(!a.name||!a.linkPath||!a.targetPath){alert("Please fill in all required fields");return}k(!0);try{const t=await fetch(`${p}/api/v1/symlinks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(t.ok)await x(),j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});else{const s=await t.json();alert(s.error?.message||"Error creating symlink")}}catch(t){console.error("Error adding symlink:",t),alert("Failed to create symlink")}finally{k(!1)}},b=t=>{N(t.id),m({name:t.name,description:t.description||"",linkPath:t.linkPath,targetPath:t.targetPath,isActive:t.isActive})},P=()=>{N(null),m({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},$=async()=>{if(g){if(!i.name||!i.linkPath||!i.targetPath){alert("Please fill in all required fields");return}h(g);try{const t=await fetch(`${p}/api/v1/symlinks/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(t.ok)await x(),P();else{const s=await t.json();alert(s.error?.message||"Error updating symlink")}}catch(t){console.error("Error updating symlink:",t),alert("Failed to update symlink")}finally{h(null)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Symlinks Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage symlinks for easy access to project rules and configurations."})]}),e.jsx(F,{}),e.jsxs(I,{children:[e.jsx(z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>j(!u),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),u?"Cancel":"Add Symlink"]})})}),e.jsxs(_,{children:[u&&e.jsxs("div",{className:"mb-6 p-4 border rounded-lg bg-muted/50",children:[e.jsx("h4",{className:"font-medium mb-4",children:"New Symlink Configuration"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-name",children:"Name *"}),e.jsx(c,{id:"new-name",placeholder:"e.g., Claude Rules",value:a.name,onChange:t=>d({...a,name:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-description",children:"Description"}),e.jsx(c,{id:"new-description",placeholder:"e.g., Project-specific rules for Claude AI",value:a.description,onChange:t=>d({...a,description:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-link-path",children:"Link Path * (relative to project root)"}),e.jsx(c,{id:"new-link-path",placeholder:"e.g., CLAUDE.md or docs/README.md",value:a.linkPath,onChange:t=>d({...a,linkPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Where the symlink will be created in your project"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-target-path",children:"Target Path * (relative to project root)"}),e.jsx(c,{id:"new-target-path",placeholder:"e.g., .nut/rules/CLAUDE.md",value:a.targetPath,onChange:t=>d({...a,targetPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"The actual file that the symlink will point to"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-active",checked:a.isActive,onChange:t=>d({...a,isActive:t.target.checked}),className:"rounded"}),e.jsx(n,{htmlFor:"new-active",children:"Activate immediately"})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:()=>{j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},children:"Cancel"}),e.jsx(l,{onClick:E,disabled:y,children:y?"Creating...":"Create Symlink"})]})]})]}),v.length===0&&!u?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(w,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No symlinks configured"}),e.jsx("p",{className:"text-sm mt-2",children:'Click "Add Symlink" to create your first symlink configuration.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(t=>e.jsx("div",{className:"border rounded-lg",children:g===t.id?e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-name-${t.id}`,children:"Name *"}),e.jsx(c,{id:`edit-name-${t.id}`,value:i.name,onChange:s=>m({...i,name:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-desc-${t.id}`,children:"Description"}),e.jsx(c,{id:`edit-desc-${t.id}`,value:i.description,onChange:s=>m({...i,description:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-link-${t.id}`,children:"Link Path *"}),e.jsx(c,{id:`edit-link-${t.id}`,value:i.linkPath,onChange:s=>m({...i,linkPath:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-target-${t.id}`,children:"Target Path *"}),e.jsx(c,{id:`edit-target-${t.id}`,value:i.targetPath,onChange:s=>m({...i,targetPath:s.target.value})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",size:"sm",onClick:P,children:"Cancel"}),e.jsx(l,{size:"sm",onClick:$,disabled:o===t.id,children:o===t.id?"Saving...":"Save"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.isActive?e.jsx(q,{className:"h-4 w-4 text-green-600 flex-shrink-0"}):e.jsx(w,{className:"h-4 w-4 text-gray-400 flex-shrink-0"}),e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:t.name})]}),e.jsx(D,{variant:t.isActive?"default":"secondary",className:"text-xs",children:t.isActive?"Active":"Inactive"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-2 font-mono break-all",children:[e.jsx("span",{className:"text-foreground/70",children:t.linkPath}),e.jsx("span",{className:"mx-1",children:"→"}),e.jsx("span",{children:t.targetPath})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsx(l,{onClick:()=>S(t.id),disabled:o===t.id,variant:t.isActive?"outline":"default",size:"sm",children:o===t.id?"...":e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:t.isActive?"Disable":"Enable"}),e.jsx("span",{className:"sm:hidden",children:t.isActive?"Off":"On"})]})}),e.jsx(l,{onClick:()=>b(t),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{onClick:()=>A(t.id),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(T,{className:"h-4 w-4"})})]})]})})},t.id))})]})]})]})}export{G as default};
16
+ */const R=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],w=f("unlink",R);function G(){const[v,C]=r.useState([]),[y,k]=r.useState(!1),[o,h]=r.useState(null),[u,j]=r.useState(!1),[g,N]=r.useState(null),[a,d]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1}),[i,m]=r.useState({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});r.useEffect(()=>{x()},[]);const x=async()=>{try{const s=await(await fetch(`${p}/api/v1/symlinks`)).json();s.success&&C(s.symlinks)}catch(t){console.error("Error fetching symlinks:",t)}},S=async t=>{h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error toggling symlink")}catch(s){console.error("Error toggling symlink:",s)}finally{h(null)}},A=async t=>{if(confirm("Are you sure you want to delete this symlink configuration?")){h(t);try{(await fetch(`${p}/api/v1/symlinks/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok?await x():console.error("Error deleting symlink")}catch(s){console.error("Error deleting symlink:",s)}finally{h(null)}}},E=async()=>{if(!a.name||!a.linkPath||!a.targetPath){alert("Please fill in all required fields");return}k(!0);try{const t=await fetch(`${p}/api/v1/symlinks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(t.ok)await x(),j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1});else{const s=await t.json();alert(s.error?.message||"Error creating symlink")}}catch(t){console.error("Error adding symlink:",t),alert("Failed to create symlink")}finally{k(!1)}},b=t=>{N(t.id),m({name:t.name,description:t.description||"",linkPath:t.linkPath,targetPath:t.targetPath,isActive:t.isActive})},P=()=>{N(null),m({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},$=async()=>{if(g){if(!i.name||!i.linkPath||!i.targetPath){alert("Please fill in all required fields");return}h(g);try{const t=await fetch(`${p}/api/v1/symlinks/${g}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(t.ok)await x(),P();else{const s=await t.json();alert(s.error?.message||"Error updating symlink")}}catch(t){console.error("Error updating symlink:",t),alert("Failed to update symlink")}finally{h(null)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Symlinks Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage symlinks for easy access to project rules and configurations."})]}),e.jsx(F,{}),e.jsxs(I,{children:[e.jsx(z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>j(!u),children:[e.jsx(L,{className:"h-4 w-4 mr-2"}),u?"Cancel":"Add Symlink"]})})}),e.jsxs(_,{children:[u&&e.jsxs("div",{className:"mb-6 p-4 border rounded-lg bg-muted/50",children:[e.jsx("h4",{className:"font-medium mb-4",children:"New Symlink Configuration"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-name",children:"Name *"}),e.jsx(c,{id:"new-name",placeholder:"e.g., Claude Rules",value:a.name,onChange:t=>d({...a,name:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-description",children:"Description"}),e.jsx(c,{id:"new-description",placeholder:"e.g., Project-specific rules for Claude AI",value:a.description,onChange:t=>d({...a,description:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-link-path",children:"Link Path * (relative to project root)"}),e.jsx(c,{id:"new-link-path",placeholder:"e.g., CLAUDE.md or docs/README.md",value:a.linkPath,onChange:t=>d({...a,linkPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Where the symlink will be created in your project"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"new-target-path",children:"Target Path * (relative to project root)"}),e.jsx(c,{id:"new-target-path",placeholder:"e.g., .nut/rules/CLAUDE.md",value:a.targetPath,onChange:t=>d({...a,targetPath:t.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"The actual file that the symlink will point to"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"new-active",checked:a.isActive,onChange:t=>d({...a,isActive:t.target.checked}),className:"rounded"}),e.jsx(n,{htmlFor:"new-active",children:"Activate immediately"})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",onClick:()=>{j(!1),d({name:"",description:"",linkPath:"",targetPath:"",isActive:!1})},children:"Cancel"}),e.jsx(l,{onClick:E,disabled:y,children:y?"Creating...":"Create Symlink"})]})]})]}),v.length===0&&!u?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(w,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No symlinks configured"}),e.jsx("p",{className:"text-sm mt-2",children:'Click "Add Symlink" to create your first symlink configuration.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(t=>e.jsx("div",{className:"border rounded-lg",children:g===t.id?e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-name-${t.id}`,children:"Name *"}),e.jsx(c,{id:`edit-name-${t.id}`,value:i.name,onChange:s=>m({...i,name:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-desc-${t.id}`,children:"Description"}),e.jsx(c,{id:`edit-desc-${t.id}`,value:i.description,onChange:s=>m({...i,description:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-link-${t.id}`,children:"Link Path *"}),e.jsx(c,{id:`edit-link-${t.id}`,value:i.linkPath,onChange:s=>m({...i,linkPath:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:`edit-target-${t.id}`,children:"Target Path *"}),e.jsx(c,{id:`edit-target-${t.id}`,value:i.targetPath,onChange:s=>m({...i,targetPath:s.target.value})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(l,{variant:"outline",size:"sm",onClick:P,children:"Cancel"}),e.jsx(l,{size:"sm",onClick:$,disabled:o===t.id,children:o===t.id?"Saving...":"Save"})]})]}):e.jsx("div",{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[t.isActive?e.jsx(O,{className:"h-4 w-4 text-green-600 flex-shrink-0"}):e.jsx(w,{className:"h-4 w-4 text-gray-400 flex-shrink-0"}),e.jsx("h4",{className:"font-medium text-sm sm:text-base",children:t.name})]}),e.jsx(D,{variant:t.isActive?"default":"secondary",className:"text-xs",children:t.isActive?"Active":"Inactive"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-2 font-mono break-all",children:[e.jsx("span",{className:"text-foreground/70",children:t.linkPath}),e.jsx("span",{className:"mx-1",children:"→"}),e.jsx("span",{children:t.targetPath})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsx(l,{onClick:()=>S(t.id),disabled:o===t.id,variant:t.isActive?"outline":"default",size:"sm",children:o===t.id?"...":e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:t.isActive?"Disable":"Enable"}),e.jsx("span",{className:"sm:hidden",children:t.isActive?"Off":"On"})]})}),e.jsx(l,{onClick:()=>b(t),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{onClick:()=>A(t.id),variant:"outline",size:"icon",className:"h-8 w-8",disabled:o===t.id,children:e.jsx(T,{className:"h-4 w-4"})})]})]})})},t.id))})]})]})]})}export{G as default};
@@ -0,0 +1,4 @@
1
+ import{a as Xe,ad as Ze,r as m,j as e,B as u,t as J,P as pe,bs as ge,y as q,z as fe,E as ve,H as V,J as Y,N as G,O as K,Q,R as X,U as Z,L as je,k as ee,a9 as Ne,bt as es,C as ss,n as se,D as be,b as ye,d as we,f as Se,g as Ce,I as te,a2 as ke,a3 as Ae,a4 as De,a5 as Ie,a6 as Te,aa as Fe,o as ts,ab as as,W as Pe,A as j}from"./index-DFcWlnzl.js";import{C as O,a as ae,c as re,b as $e}from"./card-BcPlIAH5.js";import{B as F}from"./badge-BUEY53dV.js";import{S as rs,a as ns,b as is,c as ls,d as ds}from"./select-44mcS2_G.js";import{L as v}from"./label-DBuh-ke5.js";import{S as cs}from"./switch-CIwjYvCt.js";import{T as os,a as ms,b as ne,c as ie}from"./tabs-DTV6Su-h.js";import{R as us}from"./refresh-cw-B3OwrDUf.js";import{P as Me}from"./play-CHIf-Rcz.js";import{P as hs}from"./pause-BzhKXHtR.js";import{C as xs}from"./clock-Bjc06QBM.js";import{C as ps}from"./chevron-up-CqM3won3.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"},{id:"kiro",label:"Kiro"}],gs=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],Ee=["monday","tuesday","wednesday","thursday","friday"],Je=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Je(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const T=Math.round(N/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},fs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},vs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set(Ee),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},js=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Ps(){const{toast:a}=Xe(),{refresh:o}=Ze(),[x,f]=m.useState([]),[N,T]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,$]=m.useState(null),[Oe,M]=m.useState(!1),[R,He]=m.useState([]),[W,Le]=m.useState([]),[ze,We]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&$(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:js(h?.metadata?.tools)}));if(He(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(I=>!d.find(_=>_.id===I));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(I=>({...I,agentIds:I.agentIds.filter(_=>d.find(Qe=>Qe.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(Le(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},Be=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=R.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Ue=(s,t)=>{if(!t&&R.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},_e=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},qe=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ee.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{We(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{$(s),M(!0)},he=()=>{C(null),E(),y(!0)},Ve=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),p(Re(s)),y(!0)},Ye=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}oe(!0);const t=!!c;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const I=await D.json().catch(()=>({}));throw new Error(I?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ge=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await k(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},Ke=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await k(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(M(!1),$(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Jobs"}),e.jsx("p",{className:"text-md text-muted-foreground",children:"Automate recurring agent runs"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(us,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx(pe,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(O,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(J,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(O,{className:"border-dashed",children:e.jsxs(ae,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(ge,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks by scheduling an agent to run on your behalf. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the agent can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx(pe,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(O,{className:"border-destructive/50 bg-destructive/5",children:e.jsx($e,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(q,{children:[e.jsx(fe,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(ve,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(O,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx($e,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(je,{to:`/schedule/${s.id}`,className:"hover:underline",children:e.jsx(re,{className:"text-lg truncate",children:s.name})}),e.jsx(F,{variant:le(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(u,{size:"sm",variant:"default",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx(je,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ve(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ke(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(hs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(fe,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(ve,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(xs,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:fs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:vs(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(ee,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(Ne,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(es,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(ss,{className:"ml-1 h-3 w-3"})]})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,1).map(t=>{const r=ze.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ps,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(be,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(ye,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(we,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(Se,{className:"text-xl flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(Ce,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ye,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(os,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(ms,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(rs,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(ns,{id:"job-model",className:"h-11",children:e.jsx(is,{placeholder:"Select a model"})}),e.jsx(ls,{children:ce.map(s=>e.jsx(ds,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(ke,{children:[e.jsx(Ae,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(De,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ie,{children:"Available Agents"}),e.jsx(Te,{}),R.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):R.map(s=>e.jsx(Fe,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Be(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Ne,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(ke,{children:[e.jsx(Ae,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(De,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(Ie,{children:"Available MCP Servers"}),e.jsx(Te,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Fe,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Ue(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ts,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
2
+ Example: Focus on performance optimizations`:`Example:
3
+ Run the following command and append the output to .nut/knowledge/runs.md:
4
+ pnpm docs:publish`,rows:6,value:n.prompt,onChange:s=>A({prompt:s.target.value}),className:"resize-none font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"⚠"}),e.jsx("span",{children:n.agentIds.length>0?"These custom instructions will be combined with the selected agents' predefined instructions. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(ie,{value:"schedule",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1.2fr_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:gs.map(s=>e.jsxs("label",{className:"flex items-center gap-2.5 text-sm rounded-md border border-input px-3.5 py-2.5 cursor-pointer hover:bg-accent/50 transition-colors",children:[e.jsx(as,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>qe(s.value,t)}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which days the job should run"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>A({hours:Number(s.target.value)||1}),className:"h-11 pr-16"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"hours"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the job runs on selected days"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-anchor",className:"text-sm font-medium flex items-center gap-1.5",children:["Start Hour",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>A({anchorHour:s.target.value}),className:"h-11"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"0-23"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preferred starting hour in 24h format"})]})]})]})}),e.jsx(ie,{value:"advanced",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"flex items-start gap-4 rounded-lg border border-border bg-accent/20 p-4",children:[e.jsx(cs,{id:"job-status",checked:n.status,onCheckedChange:s=>A({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(v,{htmlFor:"job-status",className:"text-base font-semibold cursor-pointer",children:n.status?"Start Active":"Start Paused"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.status?"Job will begin running on the configured schedule immediately after creation.":"Job will be created in a paused state. You can activate it later from the schedule page."})]})]})})]})]}),e.jsxs(Pe,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>y(!1),disabled:z,className:"min-w-24",children:"Cancel"}),e.jsx(u,{type:"submit",disabled:z||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:z?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:c?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(be,{open:Oe,onOpenChange:s=>{M(s),s||$(null)},children:e.jsxs(ye,{className:"max-w-3xl",children:[e.jsxs(we,{children:[e.jsxs(Se,{children:["Run history — ",g?.name]}),e.jsxs(Ce,{children:[g?.runs?.length??0," recorded runs. Logs stored in ",e.jsxs("code",{children:[".nut/jobs/",g?.id,".md"]})," and ",e.jsxs("code",{children:[".nut/jobs/logs/",g?.id]}),"."]})]}),e.jsxs("div",{className:"max-h-[420px] space-y-3 overflow-y-auto pr-2",children:[g?.runs.map(s=>e.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-3 text-xs bg-card/50",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(F,{variant:le(s.status),className:"capitalize text-[10px] h-5",children:s.status}),e.jsxs("span",{className:"text-muted-foreground",children:[s.trigger," • ",Je(s.startedAt)]}),s.finishedAt&&e.jsxs("span",{className:"text-muted-foreground",children:["• completed ",H(s.finishedAt)]})]}),s.error&&e.jsx("p",{className:"text-destructive font-medium mb-2",children:s.error}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px] text-muted-foreground",children:[s.outputPath&&e.jsxs("span",{children:["log: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.outputPath})]}),s.cliCommand&&e.jsxs("span",{children:["cmd: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.cliCommand})]})]})]}),s.summary&&e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap",children:s.summary})})]},s.id)),g&&g.runs.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No recorded runs yet."})]}),e.jsx(Pe,{children:e.jsx(u,{variant:"outline",onClick:()=>M(!1),children:"Close"})})]})}),e.jsx(q,{open:B.open,onOpenChange:s=>{s||U({open:!1,serverToRemove:null})},children:e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Remove MCP Server?"}),e.jsxs(K,{children:["One or more selected agents require the ",e.jsx("strong",{children:B.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:"Cancel"}),e.jsx(Z,{onClick:_e,children:"OK"})]})]})})]})}export{Ps as default};
@@ -0,0 +1 @@
1
+ import{x as C,u as S,r as h,j as e,B as a,L as c,Y as E,E as T,k as A,A as N}from"./index-DFcWlnzl.js";import{C as l,b as d,a as o,c as f,d as z}from"./card-BcPlIAH5.js";import{B as v}from"./badge-BUEY53dV.js";import{A as p}from"./arrow-left-1S-835kP.js";function B(n){return n.replace(/[-_]/g," ").replace(/\b\w/g,u=>u.toUpperCase())}const i={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function U(){const n=C(),u=S(),[s,w]=h.useState(null),[k,g]=h.useState(!0),[b,m]=h.useState(null);h.useEffect(()=>{async function r(){try{g(!0);const j=await(await fetch(`${N}/api/v1/skills/${n.id}`)).json();j.success?w(j.document):m(j.error||"Failed to fetch skill")}catch(t){m(t instanceof Error?t.message:"Unknown error")}finally{g(!1)}}n.id&&r()},[n.id]);const y=async()=>{if(!(!s||!confirm("Are you sure you want to delete this skill?")))try{const t=await(await fetch(`${N}/api/v1/skills/${s.id}`,{method:"DELETE"})).json();t.success?u("/skills"):m(t.error?.message||"Failed to delete skill")}catch(r){m(r instanceof Error?r.message:"Unknown error")}};if(k)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-64 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 animate-pulse mt-2"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsxs(d,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-64 animate-pulse"})]})})]});if(b||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Skill Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The requested skill could not be found"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsx(o,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-destructive",children:b||"Skill not found"})})})})]});const x=s.metadata?.color||"blue";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"space-y-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:B(s.name)}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(c,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(p,{className:"h-4 w-4"})})}),e.jsx(a,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(c,{to:`/skills/${s.id}/edit`,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(a,{variant:"destructive",size:"sm",onClick:y,children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Description"})}),e.jsx(o,{children:e.jsx("p",{children:s.description})})]}),s.content&&e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(f,{children:"Instructions"}),e.jsx(z,{children:"System prompt and behavior instructions for this skill"})]}),e.jsx(o,{children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-muted p-4 rounded-md",children:s.content})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Actions"})}),e.jsx(o,{className:"space-y-2",children:e.jsx(a,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(c,{to:`/terminal/sk-${s.id}`,children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Use Skill"]})})})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(f,{children:"Information"})}),e.jsxs(o,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Color"}),e.jsx(v,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:i[x]?.bg||i.blue.bg,color:i[x]?.text||i.blue.text,borderColor:i[x]?.border||i.blue.border},children:x})]}),s.allowedTools&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Allowed Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.allowedTools})]}),s.metadata?.mcpServers&&s.metadata.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:s.metadata.mcpServers.map(r=>e.jsx(v,{variant:"secondary",children:r},r))})]}),!s.allowedTools&&!(s.metadata?.mcpServers&&s.metadata.mcpServers.length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No specific tools configured - inherits all tools"})]})]})]})]})]})]})}export{U as default};
@@ -1 +1 @@
1
- import{E as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,q as Y,ae as Z,A as y}from"./index-9Tv-j_Ga.js";import{C as N,a as C,b as O,c as ee}from"./card-SN5gKnu7.js";import{L as l}from"./label-TGqbNfMO.js";import{B as se}from"./badge-AwLOflf5.js";import{c as te}from"./clipboard-B9ndUJKl.js";import{A as D}from"./arrow-left-WGBYWq3h.js";import{C as re,a as ae}from"./clipboard-BdymjxLO.js";function me(){const{id:n}=Q(),q=V(),{toast:S}=W(),[U,k]=i.useState(!0),[o,w]=i.useState(!1),[d,c]=i.useState(null),[f,E]=i.useState(""),[x,P]=i.useState(""),[m,M]=i.useState("blue"),[h,F]=i.useState([]),[p,L]=i.useState(""),[$,g]=i.useState([]),[z,A]=i.useState(!0),[R,I]=i.useState(!1),_=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],H={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};i.useEffect(()=>{async function s(){try{k(!0);const r=await(await fetch(`${y}/api/v1/skills/${n}`)).json();if(!r.success)throw new Error(r.error||"Failed to load skill");const t=r.document;E(t.name||""),P(t.description||""),M(t.metadata?.color||"blue"),L(t.content||""),F(Array.isArray(t.metadata?.mcpServers)?t.metadata.mcpServers:[])}catch(a){const r=a instanceof Error?a.message:"Failed to load skill";c(r)}finally{k(!1)}}n&&s()},[n]),i.useEffect(()=>{let s=!0;return(async()=>{A(!0);try{const r=await fetch(`${y}/api/v1/mcp`);if(!r.ok)throw new Error("Failed to fetch MCP servers");const t=await r.json();if(!t?.success||!Array.isArray(t.servers)){s&&g([]);return}const b=t.mcpServers&&typeof t.mcpServers=="object"?t.mcpServers:{},K=t.servers.map(T=>{const j=b[T]??{};return{name:T,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});s&&g(K)}catch(r){console.error("Failed to load MCP servers",r),s&&g([])}finally{s&&A(!1)}})(),()=>{s=!1}},[]);const J=async()=>{const s=".nut/config.json";try{await te(s),I(!0),S({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>I(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),S({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},G=async s=>{if(s.preventDefault(),!f.trim()||!x.trim()||!p.trim()){c("Name, description, and skill instructions are required");return}try{w(!0),c(null);const a={name:f.trim(),description:x.trim(),content:p.trim(),metadata:{color:m,mcpServers:h.length?h:void 0}},t=await(await fetch(`${y}/api/v1/skills/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!t.success)throw new Error(t.error||"Failed to update skill");const b=t.document?.id||n;q(`/skills/${b}`)}catch(a){const r=a instanceof Error?a.message:"Failed to update skill";c(r)}finally{w(!1)}};return U?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading skill..."})})}):d&&!f?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load skill"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsxs("p",{className:"text-muted-foreground",children:["Skill ID: ",n]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsxs(N,{children:[e.jsx(O,{children:e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(B,{id:"name",value:f,onChange:s=>E(s.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(B,{id:"description",value:x,onChange:s=>P(s.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(s=>{const a=H[s];return e.jsx("button",{type:"button",onClick:()=>M(s),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${m===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:m===s?a.border:"hsl(var(--border))",...m===s&&{"--tw-ring-color":a.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:R?e.jsx(re,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ae,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(Y,{id:"content",value:p,onChange:s=>L(s.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:z?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):$.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):$.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Z,{checked:h.includes(s.name),onCheckedChange:a=>{F(r=>a===!0?r.includes(s.name)?r:[...r,s.name]:r.filter(t=>t!==s.name))},disabled:o||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(se,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(u,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/skills/${n}`,children:"Cancel"})}),e.jsx(u,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{me as default};
1
+ import{x as Q,u as V,a as W,r as i,j as e,B as u,L as v,k as X,I as B,o as Y,ab as Z,A as y}from"./index-DFcWlnzl.js";import{C as N,a as C,b as O,c as ee}from"./card-BcPlIAH5.js";import{L as l}from"./label-DBuh-ke5.js";import{B as se}from"./badge-BUEY53dV.js";import{c as te}from"./clipboard-B9ndUJKl.js";import{A as D}from"./arrow-left-1S-835kP.js";import{C as re,a as ae}from"./clipboard-tzPFoieb.js";function me(){const{id:n}=Q(),q=V(),{toast:S}=W(),[U,k]=i.useState(!0),[o,w]=i.useState(!1),[d,c]=i.useState(null),[f,E]=i.useState(""),[x,P]=i.useState(""),[m,M]=i.useState("blue"),[h,F]=i.useState([]),[p,L]=i.useState(""),[$,g]=i.useState([]),[z,A]=i.useState(!0),[R,I]=i.useState(!1),_=["blue","green","red","emerald","purple","orange","yellow","teal","indigo","pink","cyan","slate","gray"],H={blue:{bg:"#3b82f6",border:"#1e40af",text:"#ffffff"},green:{bg:"#22c55e",border:"#15803d",text:"#ffffff"},red:{bg:"#ef4444",border:"#b91c1c",text:"#ffffff"},emerald:{bg:"#10b981",border:"#047857",text:"#ffffff"},purple:{bg:"#a855f7",border:"#7e22ce",text:"#ffffff"},orange:{bg:"#f97316",border:"#c2410c",text:"#ffffff"},yellow:{bg:"#eab308",border:"#a16207",text:"#ffffff"},teal:{bg:"#14b8a6",border:"#0f766e",text:"#ffffff"},indigo:{bg:"#6366f1",border:"#4338ca",text:"#ffffff"},pink:{bg:"#ec4899",border:"#be185d",text:"#ffffff"},cyan:{bg:"#06b6d4",border:"#0e7490",text:"#ffffff"},slate:{bg:"#64748b",border:"#475569",text:"#ffffff"},gray:{bg:"#6b7280",border:"#4b5563",text:"#ffffff"}};i.useEffect(()=>{async function s(){try{k(!0);const r=await(await fetch(`${y}/api/v1/skills/${n}`)).json();if(!r.success)throw new Error(r.error||"Failed to load skill");const t=r.document;E(t.name||""),P(t.description||""),M(t.metadata?.color||"blue"),L(t.content||""),F(Array.isArray(t.metadata?.mcpServers)?t.metadata.mcpServers:[])}catch(a){const r=a instanceof Error?a.message:"Failed to load skill";c(r)}finally{k(!1)}}n&&s()},[n]),i.useEffect(()=>{let s=!0;return(async()=>{A(!0);try{const r=await fetch(`${y}/api/v1/mcp`);if(!r.ok)throw new Error("Failed to fetch MCP servers");const t=await r.json();if(!t?.success||!Array.isArray(t.servers)){s&&g([]);return}const b=t.mcpServers&&typeof t.mcpServers=="object"?t.mcpServers:{},K=t.servers.map(T=>{const j=b[T]??{};return{name:T,enabled:j?.enabled!==!1,description:typeof j?.description=="string"?j.description:void 0}});s&&g(K)}catch(r){console.error("Failed to load MCP servers",r),s&&g([])}finally{s&&A(!1)}})(),()=>{s=!1}},[]);const J=async()=>{const s=".nut/config.json";try{await te(s),I(!0),S({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>I(!1),2e3)}catch(a){console.error("Failed to copy config path:",a),S({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},G=async s=>{if(s.preventDefault(),!f.trim()||!x.trim()||!p.trim()){c("Name, description, and skill instructions are required");return}try{w(!0),c(null);const a={name:f.trim(),description:x.trim(),content:p.trim(),metadata:{color:m,mcpServers:h.length?h:void 0}},t=await(await fetch(`${y}/api/v1/skills/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!t.success)throw new Error(t.error||"Failed to update skill");const b=t.document?.id||n;q(`/skills/${b}`)}catch(a){const r=a instanceof Error?a.message:"Failed to update skill";c(r)}finally{w(!1)}};return U?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:"Loading skill..."})})}):d&&!f?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsx("p",{className:"text-muted-foreground",children:"Unable to load skill"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsx(N,{children:e.jsx(C,{className:"pt-6",children:e.jsx("div",{className:"text-destructive",children:d})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Edit Skill"}),e.jsxs("p",{className:"text-muted-foreground",children:["Skill ID: ",n]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(v,{to:`/skills/${n}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})})]}),e.jsxs(N,{children:[e.jsx(O,{children:e.jsxs(ee,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Skill Configuration"]})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:G,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:"Name *"}),e.jsx(B,{id:"name",value:f,onChange:s=>E(s.target.value),disabled:o})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:"Description *"}),e.jsx(B,{id:"description",value:x,onChange:s=>P(s.target.value),disabled:o})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(s=>{const a=H[s];return e.jsx("button",{type:"button",onClick:()=>M(s),disabled:o,className:`w-10 h-10 rounded-md border-2 transition-all ${m===s?"ring-2 ring-offset-2 shadow-md":"hover:scale-110 hover:shadow-sm"}`,style:{backgroundColor:a.bg,borderColor:m===s?a.border:"hsl(var(--border))",...m===s&&{"--tw-ring-color":a.border}},title:s,children:e.jsx("span",{className:"sr-only",children:s})},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"content",children:"Skill Instructions *"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["System prompt or instructions for this skill's behavior."," ","Insert ",e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:".nut/config.json"})," ",e.jsx("button",{type:"button",onClick:J,className:"inline-flex items-center align-middle text-muted-foreground hover:text-foreground transition-colors",title:"Copy .nut/config.json to clipboard",children:R?e.jsx(re,{className:"h-3.5 w-3.5 ml-0.5"}):e.jsx(ae,{className:"h-3.5 w-3.5 ml-0.5"})})," ","if you want the skill to be able to access its name, role, or email address."]}),e.jsx(Y,{id:"content",value:p,onChange:s=>L(s.target.value),rows:8,disabled:o,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"MCP Servers (Optional)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which MCP servers this skill requires. Leave empty to inherit all available servers."}),e.jsx("div",{className:"space-y-2",children:z?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading MCP servers..."}):$.length===0?e.jsx("div",{className:"text-sm text-muted-foreground border border-dashed rounded-md p-3",children:"No MCP servers configured yet. Configure servers in Settings → MCP."}):$.map(s=>e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-transparent bg-muted/30 px-3 py-2 hover:border-muted transition-colors",children:[e.jsx(Z,{checked:h.includes(s.name),onCheckedChange:a=>{F(r=>a===!0?r.includes(s.name)?r:[...r,s.name]:r.filter(t=>t!==s.name))},disabled:o||!s.enabled}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s.name,!s.enabled&&e.jsx(se,{variant:"secondary",className:"ml-2 text-xs",children:"Disabled"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.enabled?s.description||"Enabled MCP server":"Enable this server in Settings to use it"})]})]},s.name))})]}),d&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 p-3 rounded-md",children:d}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(u,{type:"button",variant:"outline",asChild:!0,disabled:o,children:e.jsx(v,{to:`/skills/${n}`,children:"Cancel"})}),e.jsx(u,{type:"submit",disabled:o,children:o?"Saving...":"Save Changes"})]})]})})]})]})}export{me as default};
@@ -0,0 +1,8 @@
1
+ import{c as M,j as e,S as z,_,r as f,a as $,A as R,t as O,B as j,L as y,P as E,k as F,ae as B,af as U}from"./index-DFcWlnzl.js";import{C as N,a as w,b as D,c as K}from"./card-BcPlIAH5.js";import{c as V}from"./clipboard-B9ndUJKl.js";import{R as H,L}from"./browser-modal-DCNdI4NT.js";import{R as P,f as Y}from"./registry-ANRa5WBi.js";import{B as v}from"./badge-BUEY53dV.js";import"./search-Cq1ksEdp.js";/**
2
+ * @license lucide-react v0.542.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 q=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],G=M("package",q),J=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function k(s){if(s){if(Array.isArray(s)){const i=s.map(a=>{if(typeof a=="string")return a.trim();if(typeof a=="number")return`${a}`}).filter(a=>typeof a=="string"&&a.length>0);return i.length>0?i:void 0}if(typeof s=="string"){const i=s.split(",").map(a=>a.trim()).filter(a=>a.length>0);return i.length>0?i:void 0}}}function W(s,i){const a=[];if(s.content&&typeof s.content=="object")for(const c of Object.values(s.content))typeof c=="string"&&c.trim().length>0&&a.push(c.trim());const n=[];return n.push(`# ${i}`),s.description?.trim()&&n.push(s.description.trim()),[...n,...a].join(`
7
+
8
+ `).trim()}function T(s,i){const a=s.name||i.name,n=i.description||s.description||"",r={registryId:s.id,registryEndpoint:s.endpoint,registrySource:P,author:s.author};for(const o of J){const d=i[o];if(d!==void 0)if(o==="tools"){const h=k(d);h&&(r.mcpServers=h)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const h=k(d);h&&(r[o]=h)}else r[o]=d}!r.version&&s.version&&(r.version=s.version),r.color||(r.color="blue"),!r.tags&&s.tags&&(r.tags=k(s.tags));for(const[o,d]of Object.entries(r))d==null&&delete r[o];let c;return i.archive&&(c=i.archive.startsWith("http")?i.archive:`${P}${i.archive}`),{name:a,description:n,content:W(i,a),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:c}}function I({open:s,onOpenChange:i,onImport:a}){return e.jsx(H,{open:s,onOpenChange:i,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>Y(n.endpoint),renderPreview:(n,r)=>{if(!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a skill to preview"});const c=T(n,r),o=c.metadata??{},d=typeof o.version=="string"?o.version:void 0,h=Array.isArray(n.tags)?n.tags:[],g=Array.isArray(o.mcpServers)?o.mcpServers.filter(l=>typeof l=="string"):[],x=Array.isArray(o.focusAreas)?o.focusAreas.filter(l=>typeof l=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx(z,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]}),d&&e.jsxs(v,{variant:"outline",children:["v",d]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:n.id})]}),r.archive&&e.jsxs(v,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(G,{className:"h-3 w-3"}),"Includes companion files"]})]}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(l=>e.jsx(v,{variant:"secondary",children:l},l))}),g.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"MCP Servers:"}),g.map(l=>e.jsx(v,{variant:"outline",children:l},l))]}),x.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:x.map(l=>e.jsx("li",{children:l},l))})]})]}),c.content?e.jsx(_,{className:"[&_.prose]:max-w-none",children:c.content}):r.archive?e.jsx("div",{className:"rounded-md bg-muted/50 p-4 text-sm text-muted-foreground",children:e.jsx("p",{children:"Full skill content and companion files will be downloaded during import."})}):null]})})})},onConfirm:async(n,r)=>{const c=T(n,r);await a({summary:n,detail:r,payload:c})}})}function Q(s){return s.replace(/[-_]/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function ne(){const[s,i]=f.useState([]),[a,n]=f.useState(!0),[r,c]=f.useState({}),[o,d]=f.useState(!1),[h,g]=f.useState(!1),{toast:x}=$(),l=f.useCallback(async()=>{n(!0);try{const t=await fetch(`${R}/api/v1/skills`);if(!t.ok)throw new Error("Failed to load skills");const p=await t.json();i(Array.isArray(p.documents)?p.documents:[])}catch(t){console.error("Failed to load skills:",t),i([])}finally{n(!1)}},[]);f.useEffect(()=>{l()},[l]);const b=async t=>{const p=`.nut/skills/${t}/SKILL.md`;try{await V(p),c(m=>({...m,[t]:!0})),setTimeout(()=>{c(m=>({...m,[t]:!1}))},2e3),x({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(m){console.error("Failed to copy path:",m),x({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},S=f.useCallback(async({payload:t})=>{let p=!1;g(!0);try{const m=await fetch(`${R}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t.name,description:t.description,content:t.content,metadata:t.metadata,...t.archiveUrl?{archiveUrl:t.archiveUrl}:{}})});let u=null;try{u=await m.json()}catch(C){console.error("Failed to parse registry import response:",C)}if(!(m.ok&&u?.success)){const A=(typeof u?.error=="string"?u.error:u?.error?.message)||m.statusText||"Failed to import skill from registry";throw x({title:"Failed to import skill",description:A,variant:"destructive"}),p=!0,new Error(A)}x({title:"Skill imported",description:`${t.name} is now available in Coconut`}),await l()}catch(m){if(!p){const u=m instanceof Error&&m.message?m.message:"Failed to import skill from registry";x({title:"Failed to import skill",description:u,variant:"destructive"})}throw m}finally{g(!1)}},[l,x]);return a?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(O,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):s.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Skills Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized skills help you automate your development and business workflows."})]})})})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>d(!0),disabled:h,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(j,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:s.map(t=>e.jsx(y,{to:`/skills/${t.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(D,{children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"text-lg",children:Q(t.name)}),e.jsx(j,{variant:"ghost",size:"sm",onClick:p=>{p.preventDefault(),b(t.id)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:r[t.id]?e.jsx(B,{className:"w-3 h-3 text-green-600"}):e.jsx(U,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:p=>{p.preventDefault(),b(t.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",t.id,"/SKILL.md"]}),t.allowedTools&&e.jsx("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),t.allowedTools]})})]})})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:t.description})})})})]})},t.id))})]}),e.jsx(I,{open:o,onOpenChange:d,onImport:S})]})}export{ne as default};
@@ -1 +1 @@
1
- import{j as s,a2 as e,B as a,L as t}from"./index-9Tv-j_Ga.js";import{C as i,b as l,c as r,d as n,a as d}from"./card-SN5gKnu7.js";import{E as o}from"./external-link-DwMXcCCj.js";function h(){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium",children:"Skills Management"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI skills that automate various development tasks."})]}),s.jsx(e,{}),s.jsxs(i,{children:[s.jsxs(l,{children:[s.jsx(r,{children:"Skills"}),s.jsx(n,{children:"Skills are managed from the Skills page. Visit the skills page to create, edit, and manage your AI skills."})]}),s.jsx(d,{children:s.jsx(a,{asChild:!0,children:s.jsxs(t,{to:"/skills",children:[s.jsx(o,{className:"h-4 w-4 mr-2"}),"Go to Skills"]})})})]})]})}export{h as default};
1
+ import{j as s,a$ as e,B as a,L as t}from"./index-DFcWlnzl.js";import{C as i,b as l,c as r,d as n,a as d}from"./card-BcPlIAH5.js";import{E as o}from"./external-link-CNDy2UUo.js";function h(){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-medium",children:"Skills Management"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure and manage AI skills that automate various development tasks."})]}),s.jsx(e,{}),s.jsxs(i,{children:[s.jsxs(l,{children:[s.jsx(r,{children:"Skills"}),s.jsx(n,{children:"Skills are managed from the Skills page. Visit the skills page to create, edit, and manage your AI skills."})]}),s.jsx(d,{children:s.jsx(a,{asChild:!0,children:s.jsxs(t,{to:"/skills",children:[s.jsx(o,{className:"h-4 w-4 mr-2"}),"Go to Skills"]})})})]})]})}export{h as default};
@@ -1 +1 @@
1
- import{r as h,j as t,I as x,B as d,P as j,X as N}from"./index-9Tv-j_Ga.js";import{E as v}from"./external-link-DwMXcCCj.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function S(n){return n?n.map(g):[]}function k({sources:n,onChange:i,disabled:a}){const[l,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...n,r]),m(""),c("")},f=e=>{i(n.filter((s,r)=>r!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!l.trim(),className:"shrink-0",children:[t.jsx(j,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{k as S,S as n};
1
+ import{r as h,j as t,I as x,B as d,P as j,X as N}from"./index-DFcWlnzl.js";import{E as v}from"./external-link-CNDy2UUo.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function S(n){return n?n.map(g):[]}function k({sources:n,onChange:i,disabled:a}){const[l,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=l.trim();if(!e)return;const s=o.trim()||void 0,r={title:e,url:s};i([...n,r]),m(""),c("")},f=e=>{i(n.filter((s,r)=>r!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:l,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!l.trim(),className:"shrink-0",children:[t.jsx(j,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(N,{className:"h-3 w-3"})})]},s))})]})}export{k as S,S as n};
@@ -1 +1 @@
1
- import{r as p,j as t,I as d,B as m,X as x}from"./index-9Tv-j_Ga.js";import{B as f}from"./badge-AwLOflf5.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
1
+ import{r as p,j as t,I as d,B as m,X as x}from"./index-DFcWlnzl.js";import{B as f}from"./badge-BUEY53dV.js";function j({tags:a,onChange:r,disabled:n,placeholder:o}){const[l,s]=p.useState(""),c=()=>{const e=l.trim();if(e){if(a.includes(e)){s("");return}r([...a,e]),s("")}},i=e=>{r(a.filter(u=>u!==e))};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(d,{placeholder:o||"Add a tag",value:l,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),c())},disabled:n}),t.jsx(m,{type:"button",variant:"outline",onClick:c,disabled:n,children:"Add"})]}),a.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(e=>t.jsxs(f,{variant:"secondary",className:"flex items-center gap-1",children:[e,t.jsx("button",{type:"button",onClick:()=>i(e),className:"ml-1 hover:text-destructive",disabled:n,"aria-label":`Remove tag ${e}`,children:t.jsx(x,{className:"h-3 w-3"})})]},e))})]})}export{j as T};
@@ -0,0 +1,16 @@
1
+ import{c as T,x as xe,u as ue,r as i,a as pe,j as e,B as n,L as c,y as je,z as fe,E as ge,H as Ne,J as ye,N as ve,O as be,Q as we,R as Ce,U as ke,D as H,V,b as B,d as q,f as J,g as K,W as G,Y as Se,_ as Q,$ as De,m as Te,o as Ae,A as u}from"./index-DFcWlnzl.js";import{c as $e}from"./clipboard-B9ndUJKl.js";import{C as m,b as k,a as h,c as W,d as Pe}from"./card-BcPlIAH5.js";import{B as g}from"./badge-BUEY53dV.js";import{L as Y}from"./label-DBuh-ke5.js";import{S as X,a as Z,b as ee,c as se,d as te}from"./select-44mcS2_G.js";import{T as Ue,a as ae,g as Ee}from"./status-utils-CDkPeVfP.js";import{A as S}from"./arrow-left-1S-835kP.js";import{C as Ie,a as Oe}from"./clipboard-tzPFoieb.js";import{A as Fe}from"./arrow-up-down-Dw3J0a4i.js";import{I as ze}from"./info-D6jxZC5X.js";import{P as Le}from"./play-CHIf-Rcz.js";import{C as Me}from"./clock-Bjc06QBM.js";import{M as _e}from"./message-square-B5RWz_ff.js";import"./chevron-up-CqM3won3.js";/**
2
+ * @license lucide-react v0.542.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 Re=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],re=T("circle-dot",Re);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const He=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],Ve=T("flag",He);/**
12
+ * @license lucide-react v0.542.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Be=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qe=T("gauge",Be);function Je(a){return a>=80?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300":a>=60?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300":a>=40?"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-300":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300"}function Ke(a){switch(a){case"high":case"critical":return"destructive";case"medium":return"secondary";default:return"outline"}}const Ge=["low","medium","high","critical"];function ne(a){return a?a.charAt(0).toUpperCase()+a.slice(1):"None"}function D(a){const N=Date.now(),s=new Date(a).getTime(),d=N-s,y=Math.floor(d/1e3),o=Math.floor(y/60),l=Math.floor(o/60),x=Math.floor(l/24);return x>0?`${x}d ago`:l>0?`${l}h ago`:o>0?`${o}m ago`:"just now"}function os(){const{id:a}=xe(),N=ue(),[s,d]=i.useState(null),[y,o]=i.useState(!0),[l,x]=i.useState(null),[A,$]=i.useState(!1),[P,U]=i.useState(!1),[E,I]=i.useState(!1),[O,F]=i.useState(!1),[p,z]=i.useState(""),[ie,v]=i.useState(!1),[le,b]=i.useState(!1),[j,L]=i.useState("draft"),[w,M]=i.useState("medium"),[ce,_]=i.useState(!1),{toast:R}=pe();i.useEffect(()=>{async function t(){if(a)try{o(!0);const f=await(await fetch(`${u}/api/v1/tasks/${a}`)).json();f.success?d(f.data):x(f.error?.message||"Failed to fetch task")}catch(r){x(r instanceof Error?r.message:"Unknown error")}finally{o(!1)}}t()},[a]);const de=async()=>{if(a){$(!0);try{const r=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"DELETE"})).json();r.success?N("/tasks"):alert(r.error?.message||"Failed to delete task")}catch(t){alert(`Error deleting task: ${t instanceof Error?t.message:"Unknown error"}`)}finally{$(!1)}}},oe=async()=>{if(!(!s||!a||j===s.status)){U(!0);try{const r=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:j})})).json();r.success?(d(r.data),v(!1)):alert(r.error?.message||"Failed to update status")}catch(t){alert(`Error updating status: ${t instanceof Error?t.message:"Unknown error"}`)}finally{U(!1)}}},me=async()=>{if(!(!s||!a)){I(!0);try{const r=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:{...s.metadata,priority:w}})})).json();r.success?(d(r.data),b(!1)):alert(r.error?.message||"Failed to update priority")}catch(t){alert(`Error updating priority: ${t instanceof Error?t.message:"Unknown error"}`)}finally{I(!1)}}},he=async()=>{if(!(!s||!a||!p.trim())){F(!0);try{const t={id:`comment-${Date.now()}`,content:p,author:"current-user",createdAt:new Date().toISOString()},r=[...s.comments||[],t],C=await(await fetch(`${u}/api/v1/tasks/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comments:r})})).json();C.success?(d(C.data),z("")):alert(C.error?.message||"Failed to add comment")}catch(t){alert(`Error adding comment: ${t instanceof Error?t.message:"Unknown error"}`)}finally{F(!1)}}};return y?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsxs(m,{children:[e.jsx(k,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(h,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]}):l||!s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:l||"Task not found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(c,{to:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})})})]}),e.jsx(m,{children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:l||"Task not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The task with ID "',a,'" could not be found.']}),e.jsx(n,{asChild:!0,className:"mt-4",children:e.jsx(c,{to:"/tasks",children:"Back to Tasks"})})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:s.title||s.intent}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(n,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(c,{to:"/tasks",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"h-4 w-4"})})}),e.jsxs(je,{children:[e.jsx(fe,{asChild:!0,children:e.jsxs(n,{variant:"destructive",size:"sm",disabled:A,children:[e.jsx(ge,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:A?"Deleting...":"Delete"})]})}),e.jsxs(Ne,{children:[e.jsxs(ye,{children:[e.jsx(ve,{children:"Are you absolutely sure?"}),e.jsxs(be,{children:["This action cannot be undone. This will permanently delete the task",e.jsxs("span",{className:"font-semibold",children:[' "',s.title||s.intent,'"']})," and remove it from the system."]})]}),e.jsxs(we,{children:[e.jsx(Ce,{children:"Cancel"}),e.jsx(ke,{onClick:de,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Task"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const t=`.nut/tasks/${s.id}.md`;try{await $e(t),_(!0),R({title:"Copied!",description:`${t} copied to clipboard`}),setTimeout(()=>_(!1),2e3)}catch(r){console.error("Failed to copy path:",r),R({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/tasks/${s.id}.md`}),ce?e.jsx(Ie,{className:"h-3.5 w-3.5"}):e.jsx(Oe,{className:"h-3.5 w-3.5"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(H,{open:ie,onOpenChange:v,children:[e.jsx(V,{asChild:!0,children:e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>L(s?.status||"draft"),children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Update Status"]})}),e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:"Change Task Status"}),e.jsx(K,{children:"Update the status of this task."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(Y,{htmlFor:"status",children:"Status"}),e.jsxs(X,{value:j,onValueChange:t=>L(t),children:[e.jsx(Z,{children:e.jsx(ee,{placeholder:"Select status"})}),e.jsx(se,{children:Ue.map(t=>e.jsx(te,{value:t,children:ae(t)},t))})]})]})}),e.jsxs(G,{children:[e.jsx(n,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsx(n,{onClick:oe,disabled:P||j===s?.status,children:P?"Updating...":"Update Status"})]})]})]}),e.jsxs(H,{open:le,onOpenChange:b,children:[e.jsx(V,{asChild:!0,children:e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>M(s?.metadata.priority||"medium"),children:[e.jsx(re,{className:"h-4 w-4 mr-2"}),"Update Priority"]})}),e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:"Change Task Priority"}),e.jsx(K,{children:"Update the priority of this task."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(Y,{htmlFor:"priority",children:"Priority"}),e.jsxs(X,{value:w,onValueChange:M,children:[e.jsx(Z,{children:e.jsx(ee,{placeholder:"Select priority"})}),e.jsx(se,{children:Ge.map(t=>e.jsx(te,{value:t,children:ne(t)},t))})]})]})}),e.jsxs(G,{children:[e.jsx(n,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(n,{onClick:me,disabled:E||w===s?.metadata.priority,children:E?"Updating...":"Update Priority"})]})]})]}),e.jsx(n,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(c,{to:`/tasks/${a}/edit`,children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Edit"]})}),e.jsx("div",{className:"border-l h-6 mx-1"}),e.jsx(n,{variant:"default",size:"sm",className:"bg-blue-600 hover:bg-blue-700",asChild:!0,children:e.jsxs(c,{to:`/terminal/${a}?reviewOnly=true`,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Review Task"]})}),e.jsx(n,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700",asChild:!0,children:e.jsxs(c,{to:`/terminal/${a}?startOnly=true`,children:[e.jsx(Le,{className:"h-4 w-4 mr-2"}),"Start Task"]})})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(m,{children:e.jsx(h,{className:"pt-6 space-y-4",children:s.content?e.jsx(Q,{children:s.content}):e.jsx("p",{className:"text-muted-foreground",children:"No detailed content available for this task."})})}),s.planSteps&&s.planSteps.length>0&&e.jsxs(m,{children:[e.jsxs(k,{children:[e.jsx(W,{children:"Implementation Steps"}),e.jsxs(Pe,{children:[s.planSteps.length," step",s.planSteps.length!==1?"s":""," planned"]})]}),e.jsx(h,{children:e.jsx("div",{className:"space-y-3",children:s.planSteps.map((t,r)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium",children:r+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:t.description}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:e.jsx(g,{variant:"outline",className:"text-xs",children:t.status})})]})]},t.id))})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(m,{children:e.jsx(h,{className:"pt-6",children:e.jsxs("div",{children:[s.metadata.readiness!=null&&e.jsxs("div",{className:"flex items-center justify-between py-2 first:pt-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(qe,{className:"h-4 w-4"}),e.jsx("span",{children:"Readiness"})]}),e.jsxs("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold ${Je(s.metadata.readiness)}`,children:[s.metadata.readiness,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 first:pt-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx("span",{children:"Status"})]}),e.jsx(g,{variant:Ee(s.status),children:ae(s.status)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx("span",{children:"Priority"})]}),e.jsx(g,{variant:Ke(s.metadata.priority),children:ne(s.metadata.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{children:"Author"})]}),e.jsx("span",{className:"text-sm font-medium",children:s.author.name})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{children:"Created"})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:D(s.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Me,{className:"h-4 w-4"}),e.jsx("span",{children:"Updated"})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:D(s.metadata.updatedAt)})]})]})})}),e.jsxs(m,{children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-5 w-5"}),e.jsx(W,{children:"Comments"}),s.comments&&s.comments.length>0&&e.jsx(g,{variant:"secondary",className:"rounded-full px-2 py-0.5 text-xs",children:s.comments.length})]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ae,{placeholder:"Add a comment...",value:p,onChange:t=>z(t.target.value),rows:3}),e.jsx(n,{className:"w-full",onClick:he,disabled:O||!p.trim(),children:O?"Adding...":"Add Comment"})]}),s.comments&&s.comments.length>0&&e.jsx("div",{className:"space-y-3",children:[...s.comments].reverse().map((t,r)=>e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsxs("div",{className:"mb-1",children:[e.jsx("span",{className:"text-sm font-semibold",children:t.author}),e.jsx("p",{className:"text-xs text-muted-foreground",children:D(t.createdAt)})]}),e.jsx(Q,{className:"prose-sm prose-p:mb-0 prose-ul:my-1 prose-ol:my-1 text-sm",children:t.content})]},t.id||r))})]})]})]})]})]})}export{os as default};
@@ -0,0 +1 @@
1
+ import{x as R,u as U,a as H,r as c,A,j as e,B as h,L as p,I as O,X as V,a0 as _}from"./index-DFcWlnzl.js";import{L as j}from"./label-DBuh-ke5.js";import{S as D,a as L,b as F,c as I,d as r}from"./select-44mcS2_G.js";import{C as f,b as $,a as v,c as q,d as J}from"./card-BcPlIAH5.js";import{M as K}from"./markdown-editor-B4YNQFT2.js";import{C as W}from"./CollapsibleSection-M5cXbl92.js";import{I as X,L as G}from"./ImplementationStepsEditor-HliLQav5.js";import{T as Q}from"./TagInput-C6lI-ePr.js";import{A as N}from"./arrow-left-1S-835kP.js";import"./chevron-up-CqM3won3.js";import"./badge-BUEY53dV.js";function de(){const{id:i}=R(),P=U(),{toast:y}=H(),[z,S]=c.useState(!0),[u,k]=c.useState(!1),[C,w]=c.useState(null),[n,o]=c.useState({title:"",description:"",priority:"medium",status:"draft",author:{id:"current-user",name:"Current User",email:"user@example.com"}}),[m,b]=c.useState([]),[T,E]=c.useState([]);c.useEffect(()=>{i&&B()},[i]);const B=async()=>{try{S(!0);const t=await fetch(`${A}/api/v1/tasks/${i}`),s=await t.json();if(s.success||s.data||t.ok){const a=s.data||s;o({title:a.title||a.intent||"",description:a.content||"",priority:a.metadata?.priority||"medium",status:a.status||"draft",author:{id:a.author?.id||"current-user",name:a.author?.name||"Current User",email:a.author?.email||"user@example.com"}});const g=Array.isArray(a.planSteps)?a.planSteps:[];b(g.map((d,x)=>({id:d.id||`step-${x+1}`,description:d.description||"",status:d.status||"pending"}))),E(a.metadata?.tags||[])}else w(s.error?.message||"Failed to fetch task")}catch(t){w(t instanceof Error?t.message:"An error occurred")}finally{S(!1)}},M=async t=>{t.preventDefault(),k(!0);try{const s=m.map(l=>({id:l.id,description:l.description.trim(),status:l.status})).filter(l=>l.description.length>0),a=T.map(l=>l.trim()).filter(l=>l.length>0),g={title:n.title,status:n.status,planSteps:s,metadata:{priority:n.priority,tags:a},content:n.description},d=await fetch(`${A}/api/v1/tasks/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),x=await d.json();if(x.success||d.ok)y({title:"Success",description:"Task updated successfully."}),P(`/tasks/${i}`);else throw new Error(x.error?.message||"Failed to update task")}catch(s){y({title:"Error",description:`Failed to update task: ${s instanceof Error?s.message:"An error occurred"}`,variant:"destructive"})}finally{k(!1)}};return z?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading task data..."})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsxs(f,{children:[e.jsx($,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-1/2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-3/4 animate-pulse"})]})}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-64 bg-muted rounded animate-pulse"})]})})]})]}):C?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(p,{to:"/tasks",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx(f,{children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:"Error"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:C})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Edit Task"}),e.jsxs("p",{className:"text-muted-foreground",children:["Editing ",i]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(p,{to:`/tasks/${i}`,className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(N,{className:"h-4 w-4"})})})})]}),e.jsx("form",{onSubmit:M,children:e.jsxs(f,{children:[e.jsxs($,{children:[e.jsx(q,{children:"Task Details"}),e.jsx(J,{children:"Update the information for your task"})]}),e.jsxs(v,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"title",children:"Title *"}),e.jsx(O,{id:"title",placeholder:"Brief description of what you want to change",value:n.title,onChange:t=>o(s=>({...s,title:t.target.value})),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"description",children:"Description"}),e.jsx(K,{value:n.description,onChange:t=>o(s=>({...s,description:t||""})),placeholder:"Write your task description in markdown...",height:400})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"status",children:"Status"}),e.jsxs(D,{value:n.status,onValueChange:t=>o(s=>({...s,status:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select status"})}),e.jsxs(I,{children:[e.jsx(r,{value:"draft",children:"Draft"}),e.jsx(r,{value:"proposed",children:"Proposed"}),e.jsx(r,{value:"in-review",children:"In Review"}),e.jsx(r,{value:"approved",children:"Approved"}),e.jsx(r,{value:"code-complete",children:"Code Complete"}),e.jsx(r,{value:"rejected",children:"Rejected"}),e.jsx(r,{value:"merged",children:"Merged"})]})]})]}),e.jsx(W,{defaultOpen:!0,icon:e.jsx(G,{className:"h-4 w-4"}),title:"Optional Implementation Detail",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"priority",children:"Priority"}),e.jsxs(D,{value:n.priority,onValueChange:t=>o(s=>({...s,priority:t})),children:[e.jsx(L,{children:e.jsx(F,{placeholder:"Select priority"})}),e.jsxs(I,{children:[e.jsx(r,{value:"low",children:"Low"}),e.jsx(r,{value:"medium",children:"Medium"}),e.jsx(r,{value:"high",children:"High"}),e.jsx(r,{value:"critical",children:"Critical"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Implementation Steps"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep the implementation plan accurate as work progresses."})]}),m.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.length," step",m.length===1?"":"s"]})]}),e.jsx(X,{steps:m,onChange:b,disabled:u})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Tags"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tags power filtering and discovery across the task list."}),e.jsx(Q,{tags:T,onChange:E,disabled:u,placeholder:"Add a tag (e.g. backend, rollout)"})]})]})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(h,{type:"button",variant:"outline",asChild:!0,children:e.jsxs(p,{to:`/tasks/${i}`,children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Cancel"]})}),e.jsx(h,{type:"submit",disabled:u||!n.title,children:u?e.jsx(e.Fragment,{children:"Saving..."}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})]})]})]})})]})}export{de as TaskEditPage};