@lovelybunch/api 1.0.75-alpha.7 → 1.0.75-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/auth/auth-manager.d.ts +5 -0
- package/dist/lib/auth/auth-manager.js +9 -0
- package/dist/lib/terminal/terminal-manager.d.ts +1 -3
- package/dist/lib/terminal/terminal-manager.js +1 -52
- package/dist/middleware/auth.js +36 -0
- package/dist/routes/api/v1/ai/route.js +323 -2
- package/dist/routes/api/v1/chats/[id]/index.js +2 -1
- package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
- package/dist/routes/api/v1/chats/[id]/route.js +30 -1
- package/dist/routes/api/v1/context/index.js +0 -2
- package/dist/routes/api/v1/events/route.js +1 -1
- package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
- package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
- package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
- package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
- package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
- package/dist/routes/api/v1/knowledge/index.js +1 -0
- package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
- package/dist/routes/api/v1/knowledge/route.js +176 -0
- package/dist/routes/api/v1/mcp/index.js +78 -3
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
- package/dist/server-with-static.js +2 -0
- package/dist/server.js +2 -0
- package/package.json +4 -4
- package/static/assets/{ActivityPage-BsNcwPRH.js → ActivityPage-OxRci_V2.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-Dk-JIhny.js → ApiKeysSettingsPage-C0evI19e.js} +2 -2
- package/static/assets/{ArchitectureEditPage-Cq3jRBeK.js → ArchitectureEditPage-D7xcH6dY.js} +4 -4
- package/static/assets/{ArchitecturePage-DG4RrZCK.js → ArchitecturePage-pvnlX-NW.js} +1 -1
- package/static/assets/{AuthSettingsPage-C7a7q-Q2.js → AuthSettingsPage-Bu0CZ1rY.js} +2 -2
- package/static/assets/{CallbackPage-4mY02Tgr.js → CallbackPage-D0lkjxCT.js} +1 -1
- package/static/assets/CodePage-BJ4PC5nb.js +2 -0
- package/static/assets/{CollapsibleSection-BfOUBfzq.js → CollapsibleSection-Bt_ZLnJc.js} +1 -1
- package/static/assets/DashboardPage-BiffPdmj.js +41 -0
- package/static/assets/{GitPage-r3PCQC0B.js → GitPage-TrTxZ27J.js} +2 -2
- package/static/assets/{GitSettingsPage-fszzi8GW.js → GitSettingsPage-D7q5xQd_.js} +2 -2
- package/static/assets/{IdentityPage-BzVHjOMb.js → IdentityPage-CY0Ak2j0.js} +3 -3
- package/static/assets/{ImplementationStepsEditor-COEh2NTL.js → ImplementationStepsEditor-Ctx0CvbU.js} +2 -2
- package/static/assets/IntegrationsSettingsPage-C2wJVdM7.js +1 -0
- package/static/assets/{JobDetailPage-BIa9-NLI.js → JobDetailPage-Phx_IlKX.js} +1 -1
- package/static/assets/KnowledgeDetailPage-BdTUfWqj.js +1 -0
- package/static/assets/KnowledgeEditPage-D8XK4IUf.js +1 -0
- package/static/assets/KnowledgePage-Ci9G7Br-.js +8 -0
- package/static/assets/{LoginPage-C5GfXwon.js → LoginPage-Dqxd7cTa.js} +1 -1
- package/static/assets/McpSettingsPage-10n35zXi.js +1 -0
- package/static/assets/NewKnowledgePage-BlJzzuh7.js +9 -0
- package/static/assets/{NewProposalPage-BEqehTAn.js → NewProposalPage-BP7Ttoxk.js} +2 -2
- package/static/assets/{NewSkillPage-C4F8b-zZ.js → NewSkillPage-ByqN--mH.js} +1 -1
- package/static/assets/ProjectEditPage-DKJTY2uc.js +11 -0
- package/static/assets/{ProjectPage-WQwLaUBo.js → ProjectPage-2VblKCWz.js} +1 -1
- package/static/assets/PromptsSettingsPage-B4mOhXuo.js +1 -0
- package/static/assets/ProposalDetailPage-m3ysyzpj.js +1 -0
- package/static/assets/ProposalEditPage-3XVg_paW.js +1 -0
- package/static/assets/{ProposalsPage-DYoO3Zmv.js → ProposalsPage-B3u0aFFz.js} +3 -3
- package/static/assets/ResourceDetailPage-somBLUpC.js +1 -0
- package/static/assets/ResourcesPage-2BbjIWfF.js +41 -0
- package/static/assets/{RoleEditPage-BNKO37rN.js → RoleEditPage-CLzX7Xhi.js} +1 -1
- package/static/assets/{RolePage-B4Crd8sw.js → RolePage-qXWXZ2FZ.js} +1 -1
- package/static/assets/{RulesSettingsPage-C9JZf3Q-.js → RulesSettingsPage-BtM7p8F6.js} +3 -3
- package/static/assets/SchedulePage-4tFcIBSs.js +4 -0
- package/static/assets/{SkillDetailPage-CaVyuMJn.js → SkillDetailPage-CroSdaju.js} +1 -1
- package/static/assets/{SkillEditPage-BmzUm8ZL.js → SkillEditPage-Czlo8WWT.js} +1 -1
- package/static/assets/{SkillsPage-qw5UquV7.js → SkillsPage-CgULbcI-.js} +2 -2
- package/static/assets/{SkillsSettingsPage-DyomY5Jn.js → SkillsSettingsPage-DKtpy7qk.js} +1 -1
- package/static/assets/SourceInput-BITn1Y15.js +1 -0
- package/static/assets/{TagInput-CaHIGpWw.js → TagInput-BK91_M1N.js} +1 -1
- package/static/assets/TerminalPage-8fwvnOo2.js +1 -0
- package/static/assets/TerminalSessionPage-BhO5U48p.js +13 -0
- package/static/assets/UserPreferencesPage-DrgYEcxO.js +1 -0
- package/static/assets/UserSettingsPage-Dj6lKLi8.js +1 -0
- package/static/assets/UtilitiesPage-Djr4qT5L.js +1 -0
- package/static/assets/{alert-YHLFG4kD.js → alert-CsMvyYoX.js} +1 -1
- package/static/assets/{arrow-down-CVaEeC0E.js → arrow-down-BZnfbld8.js} +1 -1
- package/static/assets/{arrow-left-BpPEBvVt.js → arrow-left-WGBYWq3h.js} +1 -1
- package/static/assets/{arrow-up-BDiN-tgD.js → arrow-up-BByVUPE7.js} +1 -1
- package/static/assets/{badge-B59i_2WR.js → badge-AwLOflf5.js} +1 -1
- package/static/assets/{browser-modal-DZpkwK9n.js → browser-modal-BzGNFfTG.js} +2 -2
- package/static/assets/{card-B1BNEOKA.js → card-SN5gKnu7.js} +1 -1
- package/static/assets/{chevron-left-D13rHXtZ.js → chevron-left-C7uNq9l_.js} +1 -1
- package/static/assets/{plus-ChDS7MXp.js → chevron-up-CHdIiLxL.js} +2 -2
- package/static/assets/{chevrons-up-DrGM9h8F.js → chevrons-up-TXwQuoUN.js} +1 -1
- package/static/assets/{circle-alert-3FuqDs2g.js → circle-alert-37E5gU9K.js} +1 -1
- package/static/assets/{circle-check-Cq24IiHP.js → circle-check-D02pWDME.js} +1 -1
- package/static/assets/{circle-check-big-XKpfzr-Y.js → circle-check-big-nY4PntB5.js} +1 -1
- package/static/assets/{circle-play-CEPnc0z3.js → circle-play-7EXFLo4F.js} +1 -1
- package/static/assets/{circle-x-4bsQsvLG.js → circle-x-By4JoTHB.js} +1 -1
- package/static/assets/{clipboard-Xdr0FfgD.js → clipboard-BdymjxLO.js} +1 -1
- package/static/assets/{clock-BkRDj1VL.js → clock-HDu44KTo.js} +1 -1
- package/static/assets/{download-_PvO8olJ.js → download-Cv2G2Eg9.js} +1 -1
- package/static/assets/{droid-DqWsM2dp.js → droid-CPteN3f9.js} +1 -1
- package/static/assets/{external-link-C34deyLk.js → external-link-DwMXcCCj.js} +1 -1
- package/static/assets/{eye-CApn6EOn.js → eye-DYnjJzdb.js} +1 -1
- package/static/assets/{folder-git-2-B5Xz-Xdp.js → folder-git-2-COeWFPHS.js} +1 -1
- package/static/assets/index-9Tv-j_Ga.js +472 -0
- package/static/assets/index-GFQ5RqVh.css +2 -0
- package/static/assets/{info-BzNlGG-G.js → info-BmtuPMhv.js} +1 -1
- package/static/assets/{label-CdwSXdXm.js → label-TGqbNfMO.js} +1 -1
- package/static/assets/{markdown-editor-BfIQ27jO.js → markdown-editor-ls1JPK_e.js} +1 -1
- package/static/assets/{pause-FjNAOibm.js → pause-CAWbvTiL.js} +1 -1
- package/static/assets/{play-ps1v3QHM.js → play-DF_Qeu0H.js} +1 -1
- package/static/assets/{radio-group-xmkSGMqE.js → radio-group-DYTbywtK.js} +1 -1
- package/static/assets/{refresh-cw-DZmqHMC0.js → refresh-cw-BFZxHqbC.js} +1 -1
- package/static/assets/{search-1cnszOvc.js → search-Dr90tbch.js} +1 -1
- package/static/assets/select-Cs5qtMYV.js +1 -0
- package/static/assets/{switch-DIjerrYl.js → switch-4TDb6YiQ.js} +1 -1
- package/static/assets/{tabs-DHfBLbor.js → tabs-BrbEvF4V.js} +1 -1
- package/static/assets/{tag-CGdHqvLW.js → tag-DrQkepeD.js} +1 -1
- package/static/assets/{terminal-preview-DfhfOJmr.js → terminal-preview-uuKF9_x4.js} +1 -1
- package/static/assets/use-terminal-BG5UXuVE.js +1 -0
- package/static/assets/video-DYA2WfbA.js +36 -0
- package/static/assets/{zap-CN2EX1x-.js → zap-h9QOsasv.js} +1 -1
- package/static/index.html +2 -2
- package/static/assets/CodePage-DV9WWikT.js +0 -2
- package/static/assets/DashboardPage-dRge5Q81.js +0 -41
- package/static/assets/IntegrationsSettingsPage-D8jiPBI8.js +0 -1
- package/static/assets/KnowledgeDetailPage-BQxD9Lz3.js +0 -1
- package/static/assets/KnowledgeEditPage-kCUvyQ02.js +0 -1
- package/static/assets/KnowledgePage-CzjHNc32.js +0 -8
- package/static/assets/McpSettingsPage-CrXjyI7N.js +0 -1
- package/static/assets/NewKnowledgePage-DfSlEoq7.js +0 -9
- package/static/assets/ProjectEditPage-Dxj0T_OR.js +0 -11
- package/static/assets/PromptsSettingsPage-Bs1yLOnd.js +0 -1
- package/static/assets/ProposalDetailPage-Ox4VO8dP.js +0 -1
- package/static/assets/ProposalEditPage-RK0-VJcu.js +0 -1
- package/static/assets/ResourcesPage-DUSDibSA.js +0 -71
- package/static/assets/SchedulePage-BqPWdx_U.js +0 -4
- package/static/assets/SourceInput-D-9ARKki.js +0 -1
- package/static/assets/TerminalPage-Cidkdbnm.js +0 -1
- package/static/assets/TerminalSessionPage-COs2_qA8.js +0 -13
- package/static/assets/UserPreferencesPage-D868VFVd.js +0 -1
- package/static/assets/UserSettingsPage-DEFpDWXY.js +0 -1
- package/static/assets/UtilitiesPage-BBbNWbSM.js +0 -1
- package/static/assets/calendar-Ck6-s6Vl.js +0 -6
- package/static/assets/index-DLvo1sdI.js +0 -462
- package/static/assets/index-DVTgTsDa.css +0 -2
- package/static/assets/use-terminal-BZlVNW2z.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import{c as z,j as e,S as $,
|
|
1
|
+
import{c as z,j as e,S as $,_ as O,r as h,a as _,A as E,x as B,B as v,L as y,P as F,k as L,ah as U,ai as D}from"./index-9Tv-j_Ga.js";import{C as N,a as w,b as K,c as V}from"./card-SN5gKnu7.js";import{B as b}from"./badge-AwLOflf5.js";import{c as H}from"./clipboard-B9ndUJKl.js";import{R as Y,L as P}from"./browser-modal-BzGNFfTG.js";import{R as T,f as q}from"./registry-ANRa5WBi.js";import{T as G}from"./tag-DrQkepeD.js";import"./search-Dr90tbch.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
6
|
*/const J=[["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"}]],W=z("package",J),Q=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function k(t){if(t){if(Array.isArray(t)){const a=t.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return a.length>0?a:void 0}if(typeof t=="string"){const a=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);return a.length>0?a:void 0}}}function X(t,a){const i=[];if(t.content&&typeof t.content=="object")for(const d of Object.values(t.content))typeof d=="string"&&d.trim().length>0&&i.push(d.trim());const n=[];return n.push(`# ${a}`),t.description?.trim()&&n.push(t.description.trim()),[...n,...i].join(`
|
|
7
7
|
|
|
8
|
-
`).trim()}function
|
|
8
|
+
`).trim()}function I(t,a){const i=t.name||a.name,n=a.description||t.description||"",r={registryId:t.id,registryEndpoint:t.endpoint,registrySource:T,author:t.author};for(const o of Q){const m=a[o];if(m!==void 0)if(o==="tools"){const x=k(m);x&&(r.mcpServers=x)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const x=k(m);x&&(r[o]=x)}else r[o]=m}!r.version&&t.version&&(r.version=t.version),r.color||(r.color="blue"),!r.tags&&t.tags&&(r.tags=k(t.tags));for(const[o,m]of Object.entries(r))m==null&&delete r[o];let d;return a.archive&&(d=a.archive.startsWith("http")?a.archive:`${T}${a.archive}`),{name:i,description:n,content:X(a,i),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:d}}function M({open:t,onOpenChange:a,onImport:i}){return e.jsx(Y,{open:t,onOpenChange:a,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>q(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 d=I(n,r),o=d.metadata??{},m=typeof o.version=="string"?o.version:void 0,x=Array.isArray(n.tags)?n.tags:[],j=Array.isArray(o.mcpServers)?o.mcpServers.filter(c=>typeof c=="string"):[],f=Array.isArray(o.focusAreas)?o.focusAreas.filter(c=>typeof c=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx($,{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})]}),m&&e.jsxs(b,{variant:"outline",children:["v",m]})]}),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(b,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(W,{className:"h-3 w-3"}),"Includes companion files"]})]}),x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(c=>e.jsx(b,{variant:"secondary",children:c},c))}),j.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:"}),j.map(c=>e.jsx(b,{variant:"outline",children:c},c))]}),f.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:f.map(c=>e.jsx("li",{children:c},c))})]})]}),d.content?e.jsx(O,{className:"[&_.prose]:max-w-none",children:d.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 d=I(n,r);await i({summary:n,detail:r,payload:d})}})}const g={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 le(){const[t,a]=h.useState([]),[i,n]=h.useState(!0),[r,d]=h.useState({}),[o,m]=h.useState(!1),[x,j]=h.useState(!1),{toast:f}=_(),c=h.useCallback(async()=>{n(!0);try{const s=await fetch(`${E}/api/v1/skills`);if(!s.ok)throw new Error("Failed to load skills");const p=await s.json();a(Array.isArray(p.documents)?p.documents:[])}catch(s){console.error("Failed to load skills:",s),a([])}finally{n(!1)}},[]);h.useEffect(()=>{c()},[c]);const S=async s=>{const p=`.nut/skills/${s}/SKILL.md`;try{await H(p),d(l=>({...l,[s]:!0})),setTimeout(()=>{d(l=>({...l,[s]:!1}))},2e3),f({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(l){console.error("Failed to copy path:",l),f({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},C=h.useCallback(async({payload:s})=>{let p=!1;j(!0);try{const l=await fetch(`${E}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,description:s.description,content:s.content,metadata:s.metadata,...s.archiveUrl?{archiveUrl:s.archiveUrl}:{}})});let u=null;try{u=await l.json()}catch(A){console.error("Failed to parse registry import response:",A)}if(!(l.ok&&u?.success)){const R=(typeof u?.error=="string"?u.error:u?.error?.message)||l.statusText||"Failed to import skill from registry";throw f({title:"Failed to import skill",description:R,variant:"destructive"}),p=!0,new Error(R)}f({title:"Skill imported",description:`${s.name} is now available in Coconut`}),await c()}catch(l){if(!p){const u=l instanceof Error&&l.message?l.message:"Failed to import skill from registry";f({title:"Failed to import skill",description:u,variant:"destructive"})}throw l}finally{j(!1)}},[c,f]);return i?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(B,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):t.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(v,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:x,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(v,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(F,{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(L,{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(M,{open:o,onOpenChange:m,onImport:C})]}):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(v,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:x,children:[e.jsx(P,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(v,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(F,{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:t.map(s=>{const p=s.metadata?.color||"blue";return e.jsx(y,{to:`/skills/${s.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(K,{children:e.jsxs("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(V,{className:"text-lg",children:s.name}),e.jsx(v,{variant:"ghost",size:"sm",onClick:l=>{l.preventDefault(),S(s.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[s.id]?e.jsx(U,{className:"w-3 h-3 text-green-600"}):e.jsx(D,{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:l=>{l.preventDefault(),S(s.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",s.id,"/SKILL.md"]}),e.jsxs("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(G,{className:"w-3 h-3"}),p]}),s.allowedTools&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"w-3 h-3"}),s.allowedTools]})]})]}),e.jsx(b,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:g[p]?.bg||g.blue.bg,color:g[p]?.text||g.blue.text,borderColor:g[p]?.border||g.blue.border},children:p})]})}),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:s.description})})})})]})},s.id)})})]}),e.jsx(M,{open:o,onOpenChange:m,onImport:C})]})}export{le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,
|
|
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};
|
|
@@ -0,0 +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 +1 @@
|
|
|
1
|
-
import{r as p,j as t,I as d,B as m,X as x}from"./index-
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as U,a as J,r as i,j as e,B as r,T as S,p as K,X as L,x as H,a4 as G}from"./index-9Tv-j_Ga.js";import{C as f,a as W}from"./card-SN5gKnu7.js";import{u as X}from"./use-terminal-BG5UXuVE.js";import{T as _}from"./terminal-preview-uuKF9_x4.js";/* empty css */import{R as q}from"./refresh-cw-BFZxHqbC.js";import{C as Q,a as V}from"./chevrons-up-TXwQuoUN.js";import{C as Y}from"./chevron-up-CHdIiLxL.js";import{P as M}from"./play-DF_Qeu0H.js";import{C as Z}from"./circle-play-7EXFLo4F.js";import"./xterm-DTxiCjtJ.js";function he(){const m=U(),{sessions:p,loading:o,error:k,refreshSessions:h,createSession:j,destroySession:B}=X(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),O=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const C=Math.floor(b/60);return C<24?`${C}h ago`:`${Math.floor(C/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return p.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[p]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=p.filter(s=>!s.proposalId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[d,y]=i.useState(()=>{const s={};return p.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(G,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await B(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>d[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>d[s.id]);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:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:o,children:[e.jsx(q,{className:`h-4 w-4 sm:mr-2 ${o?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:o,children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),k&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:k})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),o?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):c.length===0?e.jsx(f,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(S,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(S,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.proposalId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",O(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":d[s.id]?"Hide preview":"Show preview",title:d[s.id]?"Hide preview":"Show preview",children:d[s.id]?e.jsx(Y,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.proposalId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(L,{className:"h-4 w-4"})})]})]}),d[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(_,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(f,{children:e.jsxs(W,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:o||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:o||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{he as default};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{c as Ve,j as e,B as v,a5 as Me,a6 as We,a7 as Le,a8 as Re,a9 as Be,aa as Xe,s as de,r as a,ab as Qe,E as et,v as tt,u as rt,z as st,a as at,l as ve,T as ye,X as je,P as we,k as Ne,m as nt,ac as ze,G as it,D as ct,b as ot,d as lt,f as dt,p as De,ad as Fe,ae as mt,A as me}from"./index-9Tv-j_Ga.js";import{C as ut,a as ht}from"./card-SN5gKnu7.js";import{B as Je}from"./badge-AwLOflf5.js";import{S as ke,a as Se,b as Ce,c as Ae,d as V}from"./select-Cs5qtMYV.js";import{R as xt,a as Te}from"./radio-group-DYTbywtK.js";import{C as gt}from"./CollapsibleSection-Bt_ZLnJc.js";import{L as ge}from"./label-TGqbNfMO.js";import{u as ft}from"./use-terminal-BG5UXuVE.js";import{x as pt,a as bt}from"./xterm-DTxiCjtJ.js";import{A as vt}from"./arrow-down-BZnfbld8.js";/* empty css */import{b as Ue,a as yt,c as jt,d as wt}from"./droid-CPteN3f9.js";import{R as Nt}from"./refresh-cw-BFZxHqbC.js";import{P as Ee}from"./play-DF_Qeu0H.js";import{E as kt}from"./eye-DYnjJzdb.js";import{Z as St}from"./zap-h9QOsasv.js";import"./chevron-up-CHdIiLxL.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 Ct=[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],At=Ve("book-marked",Ct);/**
|
|
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 Tt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Et=Ve("message-square",Tt);var Pe={exports:{}},Ge;function Pt(){return Ge||(Ge=1,(function(r,T){(function(P,C){r.exports=C()})(self,(()=>(()=>{var P={6:(d,o)=>{function f(m){try{const n=new URL(m),l=n.password&&n.username?`${n.protocol}//${n.username}:${n.password}@${n.host}`:n.username?`${n.protocol}//${n.username}@${n.host}`:`${n.protocol}//${n.host}`;return m.toLocaleLowerCase().startsWith(l.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(o,"__esModule",{value:!0}),o.LinkComputer=o.WebLinkProvider=void 0,o.WebLinkProvider=class{constructor(m,n,l,h={}){this._terminal=m,this._regex=n,this._handler=l,this._options=h}provideLinks(m,n){const l=_.computeLink(m,this._regex,this._terminal,this._handler);n(this._addCallbacks(l))}_addCallbacks(m){return m.map((n=>(n.leave=this._options.leave,n.hover=(l,h)=>{if(this._options.hover){const{range:x}=n;this._options.hover(l,h,x)}},n)))}};class _{static computeLink(n,l,h,x){const z=new RegExp(l.source,(l.flags||"")+"g"),[N,g]=_._getWindowedLineStrings(n-1,h),y=N.join("");let u;const E=[];for(;u=z.exec(y);){const p=u[0];if(!f(p))continue;const[O,j]=_._mapStrIdx(h,g,0,u.index),[Y,q]=_._mapStrIdx(h,O,j,p.length);if(O===-1||j===-1||Y===-1||q===-1)continue;const ee={start:{x:j+1,y:O+1},end:{x:q,y:Y+1}};E.push({range:ee,text:p,activate:x})}return E}static _getWindowedLineStrings(n,l){let h,x=n,z=n,N=0,g="";const y=[];if(h=l.buffer.active.getLine(n)){const u=h.translateToString(!0);if(h.isWrapped&&u[0]!==" "){for(N=0;(h=l.buffer.active.getLine(--x))&&N<2048&&(g=h.translateToString(!0),N+=g.length,y.push(g),h.isWrapped&&g.indexOf(" ")===-1););y.reverse()}for(y.push(u),N=0;(h=l.buffer.active.getLine(++z))&&h.isWrapped&&N<2048&&(g=h.translateToString(!0),N+=g.length,y.push(g),g.indexOf(" ")===-1););}return[y,x]}static _mapStrIdx(n,l,h,x){const z=n.buffer.active,N=z.getNullCell();let g=h;for(;x;){const y=z.getLine(l);if(!y)return[-1,-1];for(let u=g;u<y.length;++u){y.getCell(u,N);const E=N.getChars();if(N.getWidth()&&(x-=E.length||1,u===y.length-1&&E==="")){const p=z.getLine(l+1);p&&p.isWrapped&&(p.getCell(0,N),N.getWidth()===2&&(x+=1))}if(x<0)return[l,u]}l++,g=0}return[l,g]}}o.LinkComputer=_}},C={};function A(d){var o=C[d];if(o!==void 0)return o.exports;var f=C[d]={exports:{}};return P[d](f,f.exports,A),f.exports}var M={};return(()=>{var d=M;Object.defineProperty(d,"__esModule",{value:!0}),d.WebLinksAddon=void 0;const o=A(6),f=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function _(m,n){const l=window.open();if(l){try{l.opener=null}catch{}l.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}d.WebLinksAddon=class{constructor(m=_,n={}){this._handler=m,this._options=n}activate(m){this._terminal=m;const n=this._options,l=n.urlRegex||f;this._linkProvider=this._terminal.registerLinkProvider(new o.WebLinkProvider(this._terminal,l,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),M})()))})(Pe)),Pe.exports}var Mt=Pt();const Wt=[{label:"Save to knowledge base",command:"Save this to the knowledge base (.nut/knowledge/) using the following schema as reference .nut/.schema/knowledge.schema.md",description:"Save content to knowledge base with schema reference"},{label:"Update project document",command:"Update the project document (.nut/context/project.md) using the following schema as reference .nut/.schema/project.schema.md",description:"Update project.md using schema reference"},{label:"Update architecture document",command:"Update the architecture document (.nut/context/architecture.md) using the following schema as reference .nut/.schema/architecture.schema.md",description:"Update architecture.md using schema reference"}];function Lt({onJumpToBottom:r,onSnippet:T,onSendKey:P}){return e.jsxs("div",{className:"w-full border-t border-gray-700/50 bg-[#252525] px-4 py-2.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsxs(v,{variant:"outline",size:"sm",onClick:r,className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",title:"Jump to bottom and set focus",children:[e.jsx(vt,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Jump to Bottom"})]}),T&&e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-8 text-xs bg-[#2d2d2d] border-gray-600 hover:bg-[#3d3d3d] text-gray-200 hover:text-white transition-colors",children:[e.jsx(At,{className:"h-3.5 w-3.5 sm:mr-1.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Snippets"})]})}),e.jsxs(Le,{align:"start",className:"w-72",children:[e.jsx(Re,{children:"Command Snippets"}),e.jsx(Be,{}),Wt.map((C,A)=>e.jsxs(Xe,{onClick:()=>T(C.command),className:"cursor-pointer flex flex-col items-start py-2",children:[e.jsx("span",{className:"font-medium",children:C.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono mt-0.5",children:C.command})]},A))]})]})]}),P&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>P(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-red-900/40 hover:border-red-700 text-gray-200 hover:text-red-300 transition-colors",title:"Send Ctrl+C (interrupt)",children:[e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"C"})]}),e.jsxs("button",{onClick:()=>P(""),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Ctrl+Z (suspend)",children:[e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"⌃"}),e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Z"})]}),e.jsx("button",{onClick:()=>P("\x1B"),className:"h-8 px-2 flex items-center gap-1 rounded-md bg-[#2d2d2d] border border-gray-600 hover:bg-[#3d3d3d] hover:border-gray-500 text-gray-200 hover:text-white transition-colors",title:"Send Escape key",children:e.jsx(de,{className:"bg-gray-700/50 border-gray-600 text-gray-300",children:"Esc"})})]})]})}function Rt({sessionId:r,onResize:T,onDestroy:P,pendingCommand:C,onCommandExecuted:A,showToolbar:M=!0,onSnippet:d}){const o=a.useRef(null),f=a.useRef(null),_=a.useRef(null),m=a.useRef(null),[n,l]=a.useState(!1),[h,x]=a.useState(null),[z,N]=a.useState(!0),g=a.useRef(0),y=5,u=a.useRef(null),E=a.useRef(null),p=a.useRef(C??null),O=a.useRef(!1),j=a.useRef(null),Y=a.useRef(A),q=a.useRef(P),ee=a.useRef(T);a.useEffect(()=>{Y.current=A},[A]),a.useEffect(()=>{q.current=P},[P]),a.useEffect(()=>{ee.current=T},[T]);const te=a.useCallback(k=>{!p.current||O.current||(j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>{if(!p.current||O.current){j.current=null;return}m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:p.current+"\r"})),O.current=!0,Y.current?.()),j.current=null},k))},[]);a.useEffect(()=>{if(p.current=C??null,O.current=!1,!p.current){j.current!==null&&(window.clearTimeout(j.current),j.current=null);return}const k=m.current?.readyState===WebSocket.OPEN;return te(k?200:800),()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null)}},[C,r,te]),a.useEffect(()=>{l(!1),N(!0),x(null)},[r]),a.useEffect(()=>{if(!o.current||!r)return;const k=S=>{const b=S.getBoundingClientRect();return b.width>0&&b.height>0},W=new pt.Terminal({cursorBlink:!0,fontSize:14,fontFamily:"'IBM Plex Mono', 'Source Code Pro', 'Fira Code', ui-monospace, Menlo, Monaco, monospace",lineHeight:1.35,letterSpacing:.5,convertEol:!0,theme:{background:"#1a1b26",foreground:"#c0caf5",cursor:"#c0caf5",cursorAccent:"#1a1b26",selectionBackground:"#33467c",selectionForeground:"#c0caf5",black:"#15161e",red:"#f7768e",green:"#9ece6a",yellow:"#e0af68",blue:"#7aa2f7",magenta:"#bb9af7",cyan:"#7dcfff",white:"#a9b1d6",brightBlack:"#414868",brightRed:"#f7768e",brightGreen:"#9ece6a",brightYellow:"#e0af68",brightBlue:"#7aa2f7",brightMagenta:"#bb9af7",brightCyan:"#7dcfff",brightWhite:"#c0caf5"}}),B=new bt.FitAddon,K=new Mt.WebLinksAddon;W.loadAddon(B),W.loadAddon(K),W.open(o.current),f.current=W,_.current=B;let L=null,X=null;const R=()=>{if(!W||!W.element||!W.element.parentElement)return;const S=W.cols??0,b=W.rows??0;if(S>0&&b>0){m.current?.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:S,rows:b}));const I=ee.current;I&&I(S,b)}},H=()=>{const S=o.current;if(S&&k(S)&&!(!W||!W.element||!W.element.parentElement))try{const b=S.getBoundingClientRect();if(b.width<10||b.height<10)return;B.fit(),R()}catch(b){console.warn("xterm fit() failed, will retry if needed:",b)}},F=()=>{L&&cancelAnimationFrame(L),L=requestAnimationFrame(()=>{H()})},ce=()=>{if(!r)return;u.current&&(window.clearTimeout(u.current),u.current=null);const S=`${Qe}/ws/terminal/${r}`,b=new WebSocket(S);return m.current=b,b.onopen=()=>{l(!0),x(null),g.current=0,console.log("Terminal WebSocket connected"),E.current&&window.clearInterval(E.current),E.current=window.setInterval(()=>{b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"keepalive"}))},120*1e3),F(),setTimeout(()=>{N(!1),F(),setTimeout(()=>F(),50),setTimeout(()=>F(),150)},400),te(1200)},b.onmessage=I=>{try{const w=JSON.parse(I.data);switch(w.type){case"snapshot":if(typeof w.data=="string"&&w.data.length&&f.current){const J=f.current;J.write(w.data,()=>{J.scrollToBottom()})}break;case"data":if(f.current){const J=f.current,ae=J.buffer.active.viewportY+J.rows>=J.buffer.active.baseY+J.buffer.active.cursorY;J.write(w.data,()=>{ae&&J.scrollToBottom()})}break;case"exit":f.current&&f.current.write(`\r
|
|
12
|
+
\x1B[31mProcess exited with code ${w.exitCode}\x1B[0m\r
|
|
13
|
+
`),q.current?.();break}}catch(w){console.error("Error parsing WebSocket message:",w)}},b.onclose=I=>{if(l(!1),console.log("Terminal WebSocket disconnected",I.code,I.reason),E.current&&(window.clearInterval(E.current),E.current=null),I.code!==1e3&&g.current<y&&r){g.current++;const w=Math.min(1e3*Math.pow(2,g.current-1),1e4);console.log(`Attempting to reconnect (${g.current}/${y}) in ${w}ms`),u.current=window.setTimeout(()=>{ce()},w)}else g.current>=y&&x("Connection lost. Please refresh the page to reconnect.")},b.onerror=I=>{console.error("Terminal WebSocket error:",I),g.current===0&&x("WebSocket connection failed")},b};ce(),W.onData(S=>{m.current?.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:S}))});const $=()=>{F()},oe=new ResizeObserver($);o.current&&oe.observe(o.current),window.addEventListener("resize",$),window.addEventListener("orientationchange",$);const se=()=>{document.visibilityState==="visible"&&(X&&clearTimeout(X),X=window.setTimeout(()=>{F()},50))};document.addEventListener("visibilitychange",se);let he=0;const Oe=20,xe=()=>{const S=o.current;if(S){if(k(S)){H();return}he+=1,he<Oe?L=requestAnimationFrame(xe):X=window.setTimeout(()=>{H()},100)}};return L=requestAnimationFrame(xe),()=>{oe.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),document.removeEventListener("visibilitychange",se),L&&cancelAnimationFrame(L),X&&clearTimeout(X),u.current&&(window.clearTimeout(u.current),u.current=null),E.current&&(window.clearInterval(E.current),E.current=null),m.current?.readyState===WebSocket.OPEN&&m.current.close(),j.current!==null&&(window.clearTimeout(j.current),j.current=null),W.dispose()}},[r,te]);const re=a.useCallback(()=>{f.current&&(f.current.scrollToBottom(),f.current.focus())},[]),D=a.useCallback(k=>{m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:k})),f.current&&f.current.focus())},[]),ue=a.useCallback(k=>{m.current?.readyState===WebSocket.OPEN&&(m.current.send(JSON.stringify({type:"input",data:k})),f.current&&f.current.focus())},[]);return h?e.jsx("div",{className:"flex items-center justify-center h-full bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Terminal Connection Error"}),e.jsx("div",{className:"text-red-500 text-sm mt-1",children:h})]})}):e.jsxs("div",{className:"relative h-full flex flex-col bg-[#1a1b26] overflow-hidden",children:[!n&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1a1b26] bg-opacity-95 z-10 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 mt-2",children:"Connecting to terminal..."})]})}),n&&z&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[#1a1b26] bg-opacity-50 z-10 transition-opacity duration-300 backdrop-blur-sm",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-pulse rounded-full h-6 w-6 bg-blue-500 mx-auto"}),e.jsx("div",{className:"text-gray-300 text-sm mt-2",children:"Loading terminal..."})]})}),e.jsx("div",{ref:o,className:"flex-1 w-full overflow-hidden",style:{minHeight:"400px"}}),M&&e.jsx(Lt,{onJumpToBottom:re,onSnippet:d||D,onSendKey:ue})]})}const Bt=r=>r?Array.isArray(r)?r.filter(T=>typeof T=="string").map(T=>T.trim()).filter(Boolean):typeof r=="string"?r.split(",").map(T=>T.trim()).filter(Boolean):[]:[];function er(){const{proposalId:r}=et(),T=tt(),P=rt(),[C]=st(),{toast:A}=at(),M=r?.startsWith("session-"),d=a.useMemo(()=>!!r&&r.startsWith("cp-"),[r]),o=a.useMemo(()=>!!r&&r.startsWith("sk-"),[r]),f=C.get("reviewOnly")==="true",_=C.get("startOnly")==="true",m=d&&!_,n=!f,l=a.useMemo(()=>o&&r?r.replace("sk-",""):null,[o,r]),{sessions:h,loading:x,error:z,createSession:N,destroySession:g,refreshSessions:y}=ft(),[u,E]=a.useState([]),[p,O]=a.useState(null),[j,Y]=a.useState(null),[q,ee]=a.useState("claude"),[te,re]=a.useState(!1),[D,ue]=a.useState("claude"),[k,W]=a.useState([]),[B,K]=a.useState([]),[L,X]=a.useState([]),[R,H]=a.useState([]),[F,ce]=a.useState(!0),[$,oe]=a.useState(""),[se,he]=a.useState(!1),[Oe,xe]=a.useState({}),[S,b]=a.useState(null),I=a.useRef([]),[w,J]=a.useState("current"),[ae,qe]=a.useState("main"),Q=a.useMemo(()=>r?`terminal.cp.config.${r}`:null,[r]);a.useEffect(()=>{if(!(!d&&!o||!Q))try{const t=localStorage.getItem(Q);if(t){const s=JSON.parse(t);s.cliAgent&&ue(s.cliAgent),Array.isArray(s.selectedMcpServers)&&K(s.selectedMcpServers),Array.isArray(s.selectedSkillIds)&&H(s.selectedSkillIds),typeof s.automationEnabled=="boolean"&&ce(s.automationEnabled),typeof s.customInstruction=="string"&&oe(s.customInstruction),typeof s.createWorktree=="boolean"&&he(s.createWorktree),s.branchMode&&J(s.branchMode)}}catch{console.error("Failed to load config",Q)}},[d,o,Q]);const fe=a.useCallback(()=>{if(!Q)return;const t={cliAgent:D,selectedMcpServers:B,selectedSkillIds:R,automationEnabled:F,customInstruction:$,createWorktree:se,branchMode:w};try{localStorage.setItem(Q,JSON.stringify(t))}catch{console.error("Failed to persist config",Q)}},[Q,D,B,R,F,$,se,w]);a.useEffect(()=>{fe()},[$,fe]);const ne=t=>`feat/cp-${t.startsWith("cp-")?t.slice(3):t}`,He=async t=>{try{const s=ne(t),c=await(await fetch(`${me}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,from:ae})})).json();if(!c.success){const U=c.error?.message||"Unknown error";return A({title:"Branch creation failed",description:U,variant:"destructive"}),!1}return A({title:"Branch created",description:`Created branch: ${s}`}),!0}catch{return A({title:"Branch creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}},$e=async t=>{try{const s=ne(t),c=await(await fetch(`${me}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:s,from:ae})})).json();if(!c.success){const U=c.error?.message||"Unknown error";return A({title:"Worktree creation failed",description:U,variant:"destructive"}),!1}return A({title:"Worktree created",description:`Created branch: ${s}`}),!0}catch{return A({title:"Worktree creation failed",description:"Network error or invalid response",variant:"destructive"}),!1}};a.useEffect(()=>{(d||o)&&r&&(async()=>{try{const s=await fetch(`${me}/api/v1/git/status`);if(s.ok){const c=await s.json();c?.success&&c.data?.branch&&qe(c.data.branch)}const i=await fetch(`${me}/api/v1/mcp`);if(i.ok){const c=await i.json();c?.success&&Array.isArray(c.servers)&&(W(c.servers),K(U=>U.filter(G=>c.servers.includes(G))),c.mcpServers&&typeof c.mcpServers=="object"&&xe(c.mcpServers))}}catch(s){console.error("Failed to load MCP servers",s)}try{const s=await fetch(`${me}/api/v1/skills`);if(s.ok){const i=await s.json(),U=(Array.isArray(i?.documents)?i.documents:[]).map(G=>({id:G.id,name:G?.metadata?.name||G.id,mcpServers:Bt(G?.metadata?.metadata?.mcpServers)}));X(U),H(G=>{const le=G.filter(Z=>U.some(be=>be.id===Z));if(o&&l&&le.length===0){const Z=U.find(be=>be.id===l);if(Z)return[Z.id]}return le})}}catch(s){console.error("Failed to load skills",s)}})()},[d,o,r,l]),a.useEffect(()=>{const t=I.current,s=R.filter(i=>!t.includes(i));s.length>0&&K(i=>{const c=new Set(i),U=k.length>0?new Set(k):void 0;return s.forEach(G=>{const le=L.find(Z=>Z.id===G);le&&le.mcpServers.forEach(Z=>{(!U||U.has(Z))&&c.add(Z)})}),Array.from(c)}),I.current=R},[R,L,k]),a.useEffect(()=>{r&&y(r)},[r,y]),a.useEffect(()=>{if(!r)return;const s=h.filter(i=>i.proposalId===r).map(i=>i.id);E(s),!p&&s.length>0&&O(s[0]),p&&!s.includes(p)&&O(s.length>0?s[0]:null)},[h,r,p]);const ie=async t=>{if(!r)return;const s=t||void 0,i=await N(r,s);i&&(O(i),!s&&t&&Y(t),setTimeout(()=>y(r),100))},Ie=(t,s)=>{const c={proposalId:r,contextType:s??(d?"change-proposal":o?"skill":"general"),selectedMcpServers:B,selectedSkillIds:R,automationEnabled:F,customInstruction:$};switch(t){case"claude":return Ue(c);case"gemini":return wt(c);case"codex":return jt(c);case"droid":return yt(c);default:return Ue(c)}},pe=async()=>{d&&r&&(w==="new-branch"?await He(r)||console.warn("Branch creation failed, continuing with terminal creation"):w==="new-worktree"&&(await $e(r)||console.warn("Worktree creation failed, continuing with terminal creation"))),d&&se&&w==="current"&&r&&(await $e(r)||console.warn("Worktree creation failed, continuing with terminal creation"));const s=Ie(d||o?D:q);await ie(s)},Ze=async()=>{const s=Ie(D,"prepare-proposal");await ie(s)},_e=async t=>{if(await g(t)&&p===t){const i=u.filter(c=>c!==t);O(i.length>0?i[0]:null)}},Ye=t=>{_e(t)},Ke=async()=>{for(const t of u)await g(t);P("/agents")};return r?e.jsxs("div",{className:"flex flex-col h-full",children:[M&&u.length===0&&r&&e.jsx(Ot,{proposalId:r,onStart:ie,locationSearch:T.search}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-lg",children:d||o?e.jsx(ve,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(ye,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:M?"Terminal":"Agent Session"}),!M&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 font-mono",children:r}),M&&e.jsxs("span",{className:"text-sm text-gray-500 font-mono",children:["(",r,")"]})]})]})}),e.jsx("div",{className:"flex items-center gap-2 sm:gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>r&&y(r),disabled:x,className:"bg-white dark:bg-gray-800",children:[e.jsx(Nt,{className:`h-4 w-4 sm:mr-2 ${x?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),e.jsx(v,{size:"sm",variant:"destructive",onClick:Ke,title:"Close session","aria-label":"Close session",className:"h-9 w-9 p-0",children:e.jsx(je,{className:"h-4 w-4"})}),!M&&!d&&!o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ke,{value:q,onValueChange:ee,children:[e.jsx(Se,{className:"w-24",children:e.jsx(Ce,{})}),e.jsxs(Ae,{children:[e.jsx(V,{value:"claude",children:"Claude Code"}),e.jsx(V,{value:"gemini",children:"Google Gemini"}),e.jsx(V,{value:"codex",children:"OpenAI Codex"})]})]}),e.jsxs(v,{onClick:pe,disabled:x,size:"sm",variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Ee,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Start Agent"})]})]}),!d&&!o&&(!M||u.length===0)&&e.jsxs(v,{onClick:()=>ie(),disabled:x,size:"sm",children:[e.jsx(we,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})})]}),z&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-1.5 bg-red-100 dark:bg-red-900/40 rounded-lg flex-shrink-0",children:e.jsx(je,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),e.jsx("div",{className:"text-red-800 dark:text-red-200 text-sm font-medium",children:z})]})}),u.length>0&&e.jsx("div",{className:"flex items-center gap-1 border-b dark:border-gray-700",children:u.map(t=>{const s=h.find(c=>c.id===t),i=p===t;return e.jsxs("div",{className:`flex items-center gap-2 px-4 py-3 border-b-1 cursor-pointer rounded-t-lg transition-all duration-200 ${i?"border-gray-400 bg-white dark:bg-gray-800 dark:border-gray-500 shadow-sm":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800 hover:border-gray-300"}`,onClick:()=>O(t),children:[e.jsx("div",{className:`p-1.5 rounded-md ${i?"bg-gray-200 dark:bg-gray-700":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(ye,{className:`h-3.5 w-3.5 ${i?"text-gray-700 dark:text-gray-300":"text-gray-600 dark:text-gray-400"}`})}),e.jsxs("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["Terminal ",t.split("-").slice(-1)[0].substring(0,6)]}),e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?.connected?"bg-green-500":"bg-gray-400"}`}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-red-100 dark:hover:bg-red-900/30 rounded-md opacity-60 hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),_e(t)},children:e.jsx(je,{className:"h-3 w-3"})})]},t)})}),e.jsx("div",{className:"flex-1 min-h-0",children:u.length===0?e.jsx(ut,{className:"h-full",children:e.jsx(ht,{className:"flex items-center justify-center h-full p-8",children:e.jsxs("div",{className:"text-center w-full max-w-[33vw] min-w-[400px]",children:[e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-800 rounded-full w-fit mx-auto mb-2",children:d||o?e.jsx(Ne,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"}):e.jsx(ye,{className:"h-8 w-8 text-gray-600 dark:text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-3",children:"Prepare Agent"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6 leading-relaxed",children:M?"Create a new terminal session":e.jsxs(e.Fragment,{children:["Configure the agent to start working on ",r,"."]})}),e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[!M&&!d&&!o&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Choose your AI agent"}),e.jsxs(ke,{value:q,onValueChange:ee,children:[e.jsx(Se,{className:"w-full h-11 bg-white dark:bg-gray-800",children:e.jsx(Ce,{})}),e.jsxs(Ae,{children:[e.jsx(V,{value:"claude",children:"Claude Code (default)"}),e.jsx(V,{value:"gemini",children:"Google Gemini"}),e.jsx(V,{value:"codex",children:"OpenAI Codex"})]})]})]}),e.jsxs(v,{onClick:pe,disabled:x,className:"bg-green-600 hover:bg-green-700 w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(Ee,{className:"h-5 w-5 mr-2"}),"Start Agent"]}),e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"}),e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:"or"}),e.jsx("div",{className:"flex-1 h-px bg-gray-300 dark:bg-gray-600"})]}),e.jsxs(v,{onClick:()=>ie(),disabled:x,variant:"outline",className:"w-full h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(we,{className:"h-5 w-5 mr-2"}),"New Terminal"]})]}),!M&&(d||o)&&e.jsxs("div",{className:"flex flex-col items-center gap-4 p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:[m&&e.jsxs(v,{onClick:Ze,disabled:x,className:"w-full bg-blue-600 hover:bg-blue-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(kt,{className:"h-5 w-5 mr-2"}),"Review & Prepare"]}),e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsxs(v,{variant:"outline",onClick:()=>re(!0),className:"flex-1 h-11 bg-white dark:bg-gray-800",size:"lg",children:[e.jsx(nt,{className:"h-5 w-5 mr-2"}),"Configure"]}),n&&e.jsxs(v,{onClick:pe,disabled:x,className:"flex-1 bg-green-600 hover:bg-green-700 h-11 text-base font-medium",size:"lg",children:[e.jsx(Ee,{className:"h-5 w-5 mr-2"}),"Start Agent"]})]}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("div",{className:"text-xs uppercase font-semibold text-gray-500 dark:text-gray-400",children:"Agent Configuration"}),e.jsxs("div",{className:"text-left text-sm text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Agent:"}),e.jsx("span",{className:"font-mono text-sm",children:D==="claude"?"Claude Code":D.charAt(0).toUpperCase()+D.slice(1)})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Skills:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:R.length?R.map(t=>{const s=L.find(i=>i.id===t);return e.jsx(Je,{variant:"secondary",className:"font-mono text-xs",children:s?.name||t},t)}):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ze,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400 mt-0.5"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"MCP Servers:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:B.length?B.map(t=>e.jsx(Je,{variant:"secondary",className:"font-mono text-xs",children:t},t)):e.jsx("span",{className:"font-mono text-sm text-gray-500",children:"None"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(St,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Full Environment Access:"}),e.jsx("span",{className:"font-mono text-sm",children:F?"Enabled":"Disabled"})]}),d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(it,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-400",children:"Branch:"}),e.jsx("span",{className:"font-mono text-sm",children:w==="current"?`Current (${ae})`:w==="new-branch"?`New branch (${ne(r||"")})`:`New worktree (${ne(r||"")})`})]})]}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2 text-gray-700 dark:text-gray-300",children:[e.jsx(Et,{className:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"}),"Additional Instructions"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[$.length,"/500"]})]}),e.jsx("textarea",{className:"w-full min-h-[80px] rounded-md border p-3 text-sm bg-gray-50 dark:bg-gray-900/50 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 resize-none",placeholder:"Add specific instructions to guide the agent...",value:$,onChange:t=>oe(t.target.value),rows:3}),$.length>500&&e.jsx("div",{className:"text-xs text-red-600 mt-1",children:"Custom instruction is too long (max 500 characters)"})]})]})]}),M&&u.length===0&&e.jsx("div",{className:"p-6 border border-gray-200 dark:border-gray-700 rounded-xl shadow-sm bg-gradient-to-br from-white to-gray-50 dark:from-gray-800 dark:to-gray-900 w-full",children:e.jsxs(v,{onClick:()=>ie(),disabled:x,className:"w-full h-11 text-base font-medium",size:"lg",children:[e.jsx(we,{className:"h-5 w-5 mr-2"}),"New Terminal"]})})]})]})})}):p?e.jsx("div",{className:"h-full overflow-hidden rounded-b-lg",children:e.jsx(Rt,{sessionId:p,onDestroy:()=>Ye(p),pendingCommand:j,onCommandExecuted:()=>Y(null),showToolbar:!0})}):null}),e.jsx(ct,{open:te,onOpenChange:re,children:e.jsxs(ot,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(lt,{children:[e.jsx(dt,{children:"Configure Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Customize the agent's capabilities and configure it's environment."})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),"Agent"]}),e.jsxs(ke,{value:D,onValueChange:t=>ue(t),children:[e.jsx(Se,{className:"w-full",children:e.jsx(Ce,{placeholder:"Select agent"})}),e.jsxs(Ae,{children:[e.jsx(V,{value:"claude",children:"Claude Code"}),e.jsx(V,{value:"gemini",children:"Google Gemini"}),e.jsx(V,{value:"codex",children:"OpenAI Codex"}),e.jsx(V,{value:"droid",children:"Factory Droid"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[R.length," of ",L.length," selected"]})]}),e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:"w-full justify-between",children:[R.length===0?"Select skills...":R.length===L.length?"All skills selected":`${R.length} skill${R.length!==1?"s":""} selected`,e.jsx(De,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Le,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),H(L.map(s=>s.id))},children:"All"}),e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),H([])},children:"None"})]})]}),e.jsx(Be,{}),L.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):L.map(t=>e.jsx(Fe,{checked:R.includes(t.id),onCheckedChange:s=>{H(i=>s?i.includes(t.id)?i:[...i,t.id]:i.filter(c=>c!==t.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.name}),t.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",t.mcpServers.join(", ")]}),t.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},t.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ze,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[B.length," of ",k.length," selected"]})]}),e.jsxs(Me,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:"w-full justify-between",children:[B.length===0?"Select MCP servers...":B.length===k.length?"All servers selected":`${B.length} server${B.length!==1?"s":""} selected`,e.jsx(De,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Le,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),K(k)},children:"All"}),e.jsx(v,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:t=>{t.preventDefault(),K([])},children:"None"})]})]}),e.jsx(Be,{}),k.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):k.map(t=>e.jsx(Fe,{checked:B.includes(t),onCheckedChange:s=>{K(i=>s?i.includes(t)?i:[...i,t]:i.filter(c=>c!==t))},children:t},t))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 border rounded-md bg-amber-50/50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800",children:[e.jsx(mt,{id:"automation",checked:F,onCheckedChange:t=>ce(t===!0),className:"data-[state=checked]:bg-red-600 data-[state=checked]:border-red-600 data-[state=checked]:text-white border-red-400",disabled:D==="droid"}),e.jsx("label",{htmlFor:"automation",className:"text-sm font-medium text-red-600 dark:text-red-400 cursor-pointer",children:"Full environment access (recommended in secure environments only)"})]}),D==="droid"&&e.jsxs("p",{className:"text-xs text-muted-foreground px-1",children:[e.jsx("span",{className:"font-medium",children:"Droid:"})," Automation level is set in the REPL. Press ",e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:"shift+tab"})," to cycle through Off → Low → Medium → High."]})]}),d&&e.jsx(gt,{title:"Advanced Settings",description:"Configure branch and worktree options",defaultOpen:!1,children:e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(ge,{className:"text-sm font-medium mb-3 block",children:"Branch Management"}),e.jsxs(xt,{value:w,onValueChange:t=>J(t),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{value:"current",id:"branch-current"}),e.jsxs(ge,{htmlFor:"branch-current",className:"cursor-pointer font-normal",children:["Stay on current branch (",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ae}),")"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{value:"new-branch",id:"branch-new"}),e.jsxs(ge,{htmlFor:"branch-new",className:"cursor-pointer font-normal",children:["Create new branch: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ne(r||"")})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{value:"new-worktree",id:"branch-worktree"}),e.jsxs(ge,{htmlFor:"branch-worktree",className:"cursor-pointer font-normal",children:["Create new worktree: ",e.jsx("code",{className:"text-xs font-mono bg-muted px-1 py-0.5 rounded",children:ne(r||"")})]})]})]})]})})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(v,{variant:"outline",onClick:()=>re(!1),children:"Close"}),e.jsx(v,{onClick:()=>{if($.length>500){b("Please shorten the custom instruction to 500 characters.");return}b(null),fe(),re(!1)},children:"Save"})]}),S&&e.jsx("div",{className:"text-xs text-red-600 text-right",children:S})]})]})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-red-600 font-medium",children:"Invalid Proposal ID"}),e.jsx(v,{onClick:()=>P("/proposals"),className:"mt-4",children:"Back to Proposals"})]})})}function Ot({proposalId:r,onStart:T,locationSearch:P}){return a.useEffect(()=>{if(!r)return;const C=new URLSearchParams(P);if(!C.has("autostart"))return;const A=`terminal.autostart.${r}`;if(sessionStorage.getItem(A)==="done")return;sessionStorage.setItem(A,"done");const d=C.get("run")||void 0;T(d||void 0)},[r]),null}export{er as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as k,a$ as N,A as g,j as e,a2 as P,I as b,B as C}from"./index-9Tv-j_Ga.js";import{C as F,b as w,c as T,d as L,a as D}from"./card-SN5gKnu7.js";import{L as o}from"./label-TGqbNfMO.js";import{S as h,a as u,b as m,c as f,d as a}from"./select-Cs5qtMYV.js";import"./chevron-up-CHdIiLxL.js";const r={theme:"coconut",defaultEditor:"cursor",terminalShell:"bash",autoSaveInterval:60,notifications:{email:!1,desktop:!1,slack:!1}};function V(s){return{theme:s?.theme??r.theme,defaultEditor:s?.defaultEditor??r.defaultEditor,terminalShell:s?.terminalShell??r.terminalShell,autoSaveInterval:s?.autoSaveInterval??r.autoSaveInterval,notifications:{email:s?.notifications?.email??r.notifications.email,desktop:s?.notifications?.desktop??r.notifications.desktop,slack:s?.notifications?.slack??r.notifications.slack}}}function $(){const[s,v]=i.useState(r),[y,E]=i.useState(!0),[c,x]=i.useState(!1),{toast:d}=k(),{theme:j,setTheme:p}=N();i.useEffect(()=>{S()},[]),i.useEffect(()=>{s.theme!==j&&p(s.theme)},[s.theme,j,p]);const S=async()=>{try{const l=await(await fetch(`${g}/api/v1/user/settings`)).json();l.success&&v(V(l.data.preferences))}catch(t){console.error("Failed to load preferences:",t),d({title:"Error",description:"Failed to load user preferences",variant:"destructive"})}finally{E(!1)}},I=async()=>{x(!0);try{const l=await(await fetch(`${g}/api/v1/user/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:s})})).json();if(l.success)d({title:"Preferences saved",description:"Your personal preferences have been updated."});else throw new Error(l.error)}catch(t){console.error("Failed to save preferences:",t),d({title:"Error",description:"Failed to save preferences",variant:"destructive"})}finally{x(!1)}},n=t=>{v(l=>({...l,...t,notifications:{...l.notifications,...t.notifications}}))};return y?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"User Preferences"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure defaults for editors, shells, themes, and notifications."})]}),e.jsx(P,{}),e.jsxs(F,{children:[e.jsxs(w,{children:[e.jsx(T,{children:"Workspace Defaults"}),e.jsx(L,{children:"Set the defaults Coconut uses when creating sessions and surfaces."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"theme",children:"Theme"}),e.jsxs(h,{value:s.theme,onValueChange:t=>n({theme:t}),children:[e.jsx(u,{id:"theme",children:e.jsx(m,{placeholder:"Select theme"})}),e.jsxs(f,{children:[e.jsx(a,{value:"coconut",children:"Coconut"}),e.jsx(a,{value:"system",children:"System"}),e.jsx(a,{value:"light",children:"Light"}),e.jsx(a,{value:"dark",children:"Dark"})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"System follows your OS preference. Coconut is the default branded theme."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"defaultEditor",children:"Default Editor"}),e.jsxs(h,{value:s.defaultEditor,onValueChange:t=>n({defaultEditor:t}),children:[e.jsx(u,{id:"defaultEditor",children:e.jsx(m,{placeholder:"Select editor"})}),e.jsxs(f,{children:[e.jsx(a,{value:"cursor",children:"Cursor"}),e.jsx(a,{value:"vscode",children:"VS Code"}),e.jsx(a,{value:"vim",children:"Vim"}),e.jsx(a,{value:"emacs",children:"Emacs"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"terminalShell",children:"Preferred Shell"}),e.jsxs(h,{value:s.terminalShell,onValueChange:t=>n({terminalShell:t}),children:[e.jsx(u,{id:"terminalShell",children:e.jsx(m,{placeholder:"Select shell"})}),e.jsxs(f,{children:[e.jsx(a,{value:"bash",children:"Bash"}),e.jsx(a,{value:"zsh",children:"Zsh"}),e.jsx(a,{value:"fish",children:"Fish"}),e.jsx(a,{value:"sh",children:"sh"}),e.jsx(a,{value:"system",children:"System Default"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"autoSaveInterval",children:"Auto-save Interval (seconds)"}),e.jsx(b,{id:"autoSaveInterval",type:"number",min:10,max:600,value:s.autoSaveInterval,onChange:t=>n({autoSaveInterval:Number.parseInt(t.target.value,10)||r.autoSaveInterval})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how often Coconut persists draft work to disk."})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(C,{variant:"outline",onClick:S,disabled:c,children:"Reset"}),e.jsx(C,{onClick:I,disabled:c,children:c?"Saving...":"Save Preferences"})]})]})}export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,a as I,A as S,j as e,a2 as D,B as g,I as p,L as F}from"./index-9Tv-j_Ga.js";import{C as P,b as L,c as z,d as A,a as R}from"./card-SN5gKnu7.js";import{L as c}from"./label-TGqbNfMO.js";import{S as q,a as T,b as M,c as O,d as U}from"./select-Cs5qtMYV.js";import{C as B,a as Q}from"./clipboard-BdymjxLO.js";import"./chevron-up-CHdIiLxL.js";const m=[{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 W(){const[n,h]=a.useState({}),[r,d]=a.useState(null),[f,x]=a.useState(!1),[b,N]=a.useState(!0),[u,v]=a.useState(!1),{toast:o}=I();a.useEffect(()=>{j()},[]);const j=async()=>{try{try{const t=await fetch(`${S}/api/v1/config`),s=await t.json();if(t.ok&&s?.success){const i=s.data?.coconut||{};d(i.id??null),(i.firstName||i.lastName||i.email||i.role||i.roleDescription)&&h({firstName:i.firstName,lastName:i.lastName,email:i.email,role:i.role,roleDescription:i.roleDescription})}else d(null)}catch(t){console.error("Failed to load coconut config:",t),d(null)}}catch(t){console.error("Failed to load settings:",t),o({title:"Error",description:"Failed to load user settings",variant:"destructive"})}finally{N(!1)}},w=async()=>{v(!0);try{const s=await(await fetch(`${S}/api/v1/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconut:{...n,id:r||void 0}})})).json();if(s.success)window.dispatchEvent(new CustomEvent("config-updated")),o({title:"Success",description:"Settings saved successfully"});else throw new Error(s.error||"Failed to save settings")}catch(t){console.error("Failed to save settings:",t),o({title:"Error",description:"Failed to save settings",variant:"destructive"})}finally{v(!1)}},l=t=>{h(s=>{const i={...s,...t};if(t.role!==void 0){const C=m.find(k=>k.id===t.role);C?.description&&(i.roleDescription=C.description)}return i})},y=a.useMemo(()=>n.role&&m.find(s=>s.id===n.role)?.description||null,[n.role]),E=async()=>{if(r)try{await navigator.clipboard.writeText(r),x(!0),o({title:"Copied",description:"Coconut ID copied to clipboard."}),setTimeout(()=>x(!1),1500)}catch(t){console.error("Failed to copy coconut ID:",t),o({title:"Copy failed",description:"Unable to copy the Coconut ID to the clipboard.",variant:"destructive"})}};return b?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Coconut Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the Coconut's profile information."})]}),e.jsx(D,{}),e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/40 p-4",children:r?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID"}),e.jsx("p",{className:"mt-1 font-mono text-sm",children:r})]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:E,children:[f?e.jsx(B,{className:"h-4 w-4"}):e.jsx(Q,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2",children:f?"Copied":"Copy"})]})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"Coconut ID not configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an `id` under the `coconut` section in `.nut/config.json` to register this Coconut instance."})]})}),e.jsxs(P,{children:[e.jsxs(L,{children:[e.jsx(z,{children:"Coconut Profile"}),e.jsx(A,{children:"Update the Coconut's identifying details and role."})]}),e.jsxs(R,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"firstName",children:"First Name"}),e.jsx(p,{id:"firstName",value:n.firstName||"",onChange:t=>l({firstName:t.target.value}),placeholder:"Enter first name"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"lastName",children:"Last Name"}),e.jsx(p,{id:"lastName",value:n.lastName||"",onChange:t=>l({lastName:t.target.value}),placeholder:"Enter last name"})]})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"email",children:"Email"}),e.jsx(p,{id:"email",type:"email",value:n.email||"",onChange:t=>l({email:t.target.value}),placeholder:"Enter email address"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"role",children:"Role"}),e.jsxs(q,{value:n.role,onValueChange:t=>l({role:t}),children:[e.jsx(T,{children:e.jsx(M,{placeholder:"Select role"})}),e.jsx(O,{children:m.map(t=>e.jsx(U,{value:t.id,children:t.title},t.id))})]}),y&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:y})]})]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You can also manage the Coconut's identity to other agents on the"," ",e.jsx(F,{to:"/identity",className:"underline underline-offset-4 hover:text-primary",children:"Identity page"}),"."]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(g,{variant:"outline",onClick:j,disabled:u,children:"Cancel"}),e.jsx(g,{onClick:w,disabled:u,children:u?"Saving...":"Save Changes"})]})]})}export{W as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as k,a as w,r as n,j as e,B as g,af as b,L as C,A as S,a4 as I}from"./index-9Tv-j_Ga.js";import{C as R,a as B}from"./card-SN5gKnu7.js";import{u as Q}from"./use-terminal-BG5UXuVE.js";import{C as $}from"./circle-play-7EXFLo4F.js";import{P as O}from"./play-DF_Qeu0H.js";function L(){const o=k(),{loading:l,createSession:d,refreshSessions:j}=Q(),{toast:i}=w(),[m,u]=n.useState(!1),[x,h]=n.useState(!1),[,f]=n.useState([]),[c,y]=n.useState({});n.useEffect(()=>{try{const t=localStorage.getItem("terminal.commandHistory");t&&f(JSON.parse(t))}catch{}},[]),n.useEffect(()=>{(async()=>{try{const s=await fetch(`${S}/api/v1/context/architecture`);if(!s.ok)return;const a=await s.json();a?.success&&a?.document?.metadata?.commands&&y(a.document.metadata.commands)}catch{}})()},[]);const p=t=>{t&&f(s=>{const a=[t,...s.filter(r=>r!==t)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a})},N=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;u(!0);try{await d(a,s)?(p(s),i({title:"Session started",description:`${a}`}),o(`/terminal/${a}`)):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{u(!1)}},v=async t=>{const s=(t||"").trim();if(!s)return;const a=`session-${Date.now()}`;h(!0);try{await d(a,s)?(p(s),setTimeout(()=>j(),150),i({title:"Started in background",description:`${a}`,action:e.jsx(I,{altText:"Open session",onClick:()=>o(`/terminal/${a}`),children:"Open"})})):i({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{h(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Utilities"}),e.jsx("p",{className:"text-muted-foreground",children:"Quick commands and shortcuts"})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Quick Commands"}),e.jsx(R,{children:e.jsx(B,{className:"pt-6",children:c&&Object.keys(c).length>0?e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"rounded-md border divide-y",children:Object.entries(c).map(([t,s])=>e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 p-2",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t}),e.jsx("span",{className:"text-muted-foreground hidden sm:inline",children:":"}),e.jsx("span",{className:"truncate max-w-full",children:e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:s})})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[e.jsxs(g,{onClick:()=>v(s),variant:"secondary",size:"sm",disabled:l||x||m,title:"Run in background",children:[e.jsx($,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(g,{onClick:()=>N(s),size:"sm",disabled:l||m||x,title:"Run",children:[e.jsx(O,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]})]},t))})}):e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3 py-8",children:[e.jsx(b,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No quick commands configured"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md leading-relaxed",children:"Quick commands let you run common tasks with one click, like starting your development server or running build scripts."}),e.jsxs("p",{className:"text-sm text-muted-foreground max-w-md mt-2",children:["Set them up in the"," ",e.jsx(C,{to:"/context/architecture/edit",className:"text-primary hover:underline font-medium",children:"Quick Commands section"}),"."]})]})]})})})]})]})}export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as a,e as o}from"./index-
|
|
1
|
+
import{r,j as a,e as o}from"./index-9Tv-j_Ga.js";const v=r.forwardRef(({className:e,variant:t="default",...s},d)=>{const l="relative w-full rounded-lg border px-4 py-3 text-sm [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",i=t==="destructive"?"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive":"bg-background text-foreground";return a.jsx("div",{ref:d,role:"alert",className:o(l,i,e),...s})});v.displayName="Alert";const c=r.forwardRef(({className:e,...t},s)=>a.jsx("div",{ref:s,className:o("text-sm [&_p]:leading-relaxed",e),...t}));c.displayName="AlertDescription";export{v as A,c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o,e as n,
|
|
1
|
+
import{j as o,e as n,b3 as a}from"./index-9Tv-j_Ga.js";const s=a("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i({className:r,variant:e,...t}){return o.jsx("div",{className:n(s({variant:e}),r),...t})}export{i as B};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as z,r,j as e,D as G,b as J,d as K,f as Q,I as V,
|
|
1
|
+
import{c as z,r,j as e,D as G,b as J,d as K,f as Q,I as V,x as M,S as W,e as X,a1 as Y,B}from"./index-9Tv-j_Ga.js";import{B as v}from"./badge-AwLOflf5.js";import{a as Z}from"./registry-ANRa5WBi.js";import{S as O}from"./search-Dr90tbch.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 ee=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],ne=z("library",ee),te="Browse Registry",se="Import";function oe({open:f,categoryId:n,onOpenChange:x,title:F=te,confirmLabel:A=se,filterTags:o,onConfirm:I,getDetail:R,renderPreview:_}){const[c,y]=r.useState([]),[P,N]=r.useState(!1),[w,S]=r.useState(null),[l,b]=r.useState(null),[h,L]=r.useState({}),[T,g]=r.useState(!1),[E,j]=r.useState(null),[d,C]=r.useState(""),[p,k]=r.useState(!1);r.useEffect(()=>{if(!f)return;N(!0),S(null),b(null),j(null),g(!1),L({}),C("");const t=Array.isArray(n)?n:[n];Promise.all(t.map(s=>Z(s))).then(s=>{const a=s.flatMap(u=>u.elements??[]);y(a)}).catch(s=>{console.error("Failed to load registry category",s),y([]),S("Failed to load registry entries")}).finally(()=>N(!1))},[f,n]);const D=r.useMemo(()=>{let t=c;if(o&&o.length>0&&(t=t.filter(a=>{const u=a.tags??[];return o.some(
|
|
6
|
+
*/const ee=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],ne=z("library",ee),te="Browse Registry",se="Import";function oe({open:f,categoryId:n,onOpenChange:x,title:F=te,confirmLabel:A=se,filterTags:o,onConfirm:I,getDetail:R,renderPreview:_}){const[c,y]=r.useState([]),[P,N]=r.useState(!1),[w,S]=r.useState(null),[l,b]=r.useState(null),[h,L]=r.useState({}),[T,g]=r.useState(!1),[E,j]=r.useState(null),[d,C]=r.useState(""),[p,k]=r.useState(!1);r.useEffect(()=>{if(!f)return;N(!0),S(null),b(null),j(null),g(!1),L({}),C("");const t=Array.isArray(n)?n:[n];Promise.all(t.map(s=>Z(s))).then(s=>{const a=s.flatMap(u=>u.elements??[]);y(a)}).catch(s=>{console.error("Failed to load registry category",s),y([]),S("Failed to load registry entries")}).finally(()=>N(!1))},[f,n]);const D=r.useMemo(()=>{let t=c;if(o&&o.length>0&&(t=t.filter(a=>{const u=a.tags??[];return o.some(H=>u.some($=>$.toLowerCase()===H.toLowerCase()))})),!d.trim())return t;const s=d.trim().toLowerCase();return t.filter(a=>[a.name,a.description,a.preview,...a.tags??[]].filter(Boolean).join(" ").toLowerCase().includes(s))},[c,d,o]),i=r.useMemo(()=>l?c.find(t=>t.id===l)??null:null,[c,l]),m=r.useMemo(()=>l?h[l]?.detail??null:null,[l,h]),U=async t=>{if(b(t.id),j(null),!h?.[t.id]?.detail){g(!0);try{const s=await R(t);L(a=>({...a??{},[t.id]:{detail:s,fetchedAt:Date.now()}}))}catch(s){console.error("Failed to load registry element detail",s),j("Unable to load detail for this entry")}finally{g(!1)}}},q=async()=>{if(!(!i||!m)){k(!0);try{await I(i,m),x(!1)}catch(t){console.error("Failed to import registry element",t)}finally{k(!1)}}};return e.jsx(G,{open:f,onOpenChange:x,children:e.jsxs(J,{className:"max-w-5xl h-[80vh] flex flex-col",children:[e.jsx(K,{children:e.jsx(Q,{children:F})}),e.jsx("div",{className:"flex flex-col gap-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(O,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(V,{value:d,onChange:t=>C(t.target.value),placeholder:"Search registry entries",className:"pl-9"})]})}),e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[e.jsx("div",{className:"w-1/3 border-r pr-3",children:P?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(M,{className:"h-4 w-4 animate-spin mr-2"}),"Loading entries…"]}):w?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:w}):D.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No entries found"}):e.jsx(W,{className:"h-full",children:e.jsx("div",{className:"space-y-1 pb-4",children:D.map(t=>e.jsxs("button",{onClick:()=>U(t),className:X("w-full rounded-md border border-transparent p-3 text-left transition-colors hover:border-border hover:bg-muted/40",l===t.id&&"border-primary bg-muted"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:t.description||t.preview})]}),t.version&&e.jsxs(v,{variant:"outline",className:"text-[10px] font-medium uppercase",children:["v",t.version]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[t.tags.slice(0,4).map(s=>e.jsx(v,{variant:"secondary",className:"text-[10px] font-normal",children:s},s)),t.tags.length>4&&e.jsxs(v,{variant:"outline",className:"text-[10px] font-normal",children:["+",t.tags.length-4]})]})]},t.id))})})}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:T?e.jsxs("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5 animate-spin mr-2"}),"Loading detail…"]}):E?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:E}):i?e.jsx("div",{className:"h-full overflow-hidden",children:_(i,m)}):e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select an entry to preview"})})]}),e.jsxs(Y,{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:i?`Selected: ${i.name}`:"No entry selected"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{variant:"outline",onClick:()=>x(!1),disabled:p,children:"Cancel"}),e.jsx(B,{onClick:q,disabled:!i||!m||p,children:p?"Importing…":A})]})]})]})})}export{ne as L,oe as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as d,e as t}from"./index-
|
|
1
|
+
import{r,j as d,e as t}from"./index-9Tv-j_Ga.js";const o=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("rounded-xl border bg-card text-card-foreground shadow",a),...e}));o.displayName="Card";const c=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex flex-col space-y-1.5 p-6",a),...e}));c.displayName="CardHeader";const i=r.forwardRef(({className:a,...e},s)=>d.jsx("h3",{ref:s,className:t("font-semibold leading-none tracking-tight",a),...e}));i.displayName="CardTitle";const n=r.forwardRef(({className:a,...e},s)=>d.jsx("p",{ref:s,className:t("text-sm text-muted-foreground",a),...e}));n.displayName="CardDescription";const l=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("p-6 pt-0",a),...e}));l.displayName="CardContent";const f=r.forwardRef(({className:a,...e},s)=>d.jsx("div",{ref:s,className:t("flex items-center p-6 pt-0",a),...e}));f.displayName="CardFooter";export{o as C,l as a,c as b,i as c,n as d,f as e};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as o}from"./index-9Tv-j_Ga.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
|
|
6
|
+
*/const c=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],n=o("chevron-up",c);export{n as C};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const m="Use .nut/context/project.md and .nut/context/architecture.md for reference.";function c(e,t,n,s=!0){const o=[];return s&&(o.push(["## Task","","- Review and begin working on the following task proposal:",` .nut/proposals/${e}.md`,"- Retrieve your firstName, lastName, and email address from: .nut/config.json and use this identity to address yourself in any task updates, comments, git commits, etc."].join(`
|
|
2
2
|
`)),o.push(["## Task Lifecycle","",`- Before beginning any work: nut task update ${e} --status active`,`- Add appropriate steps with: nut task step ${e} "Step description" --author "firstName lastName"`,"",`- If you need human clarification or input: nut task update ${e} --status blocked. The clarification can be communicated as follows: nut task comment ${e} "Comments here" --author "firstName lastName". At this point please stop work.`,"",`- When implementation is complete and ready for approval: nut task update ${e} --status review`,`- Only mark the task complete once approval criteria are satisfied: nut task update ${e} --status done`].join(`
|
|
3
|
-
`)),o.push(["## Abilities","","- The following abilities are at your disposal and should be factored into the plan where appropriate (each command has its own --help):"," - Work with knowledge documents (used for the output of any research-centric tasks):",' - nut knowledge create "Quick Note" --content "# Quick Note\\n\\nSome content here"'," - nut knowledge list"," - nut knowledge get example-filename.md"," - Creating media such as images, audio, or video:"," - nut resource"," - Using available skills (specialized, reusable, and portable modules). There is also an official registry you can pull from:"," - nut skill list"," - nut skill registry list","- Similarly, the following are available: git, gh, node, python"].join(`
|
|
3
|
+
`)),o.push(["## Abilities","","- The following abilities are at your disposal and should be factored into the plan where appropriate (each command has its own --help):"," - Work with knowledge documents (used for the output of any research-centric tasks):",' - nut knowledge create "Quick Note" --content "# Quick Note\\n\\nSome content here"'," - nut knowledge list"," - nut knowledge get example-filename.md",' - nut knowledge update example-filename.md --content "# Quick Note\\n\\nSome content here"'," - Creating media such as images, audio, or video or adding existing files to the resource library:"," - nut resource ls"," - nut resource add ./screenshot.png",' - nut resource image "A serene morning in Tokyo" --save',' - nut resource audio "Welcome to the future" --save'," - Using available skills (specialized, reusable, and portable modules). There is also an official registry you can pull from:"," - nut skill list"," - nut skill registry list","- Similarly, the following are available: git, gh, node, python"].join(`
|
|
4
4
|
`)),o.push(["## Operational Rules","","- DO use the nut CLI to update task status as progress changes"," (nut --help or nut task --help for details)","- DO NOT edit files outside the scope of the approved proposal (unless instructed by the Additional Instructions below)"].join(`
|
|
5
5
|
`))),t.length>0&&o.push(["## Skills","","These skills are available to you if needed:",...t.map(i=>`- ${i}`)].join(`
|
|
6
6
|
`)),n&&n.trim()&&o.push(["## Additional Instructions","","DO strictly adhere to these additional instructions:",n.trim()].join(`
|