@mcp-graph-workflow/mcp-graph 5.30.0 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +2 -0
- package/dist/api/router.js.map +1 -1
- package/dist/api/routes/dream.d.ts +5 -0
- package/dist/api/routes/dream.d.ts.map +1 -0
- package/dist/api/routes/dream.js +142 -0
- package/dist/api/routes/dream.js.map +1 -0
- package/dist/core/dream/dream-engine.d.ts +40 -0
- package/dist/core/dream/dream-engine.d.ts.map +1 -0
- package/dist/core/dream/dream-engine.js +192 -0
- package/dist/core/dream/dream-engine.js.map +1 -0
- package/dist/core/dream/dream-store.d.ts +19 -0
- package/dist/core/dream/dream-store.d.ts.map +1 -0
- package/dist/core/dream/dream-store.js +86 -0
- package/dist/core/dream/dream-store.js.map +1 -0
- package/dist/core/dream/dream-types.d.ts +128 -0
- package/dist/core/dream/dream-types.d.ts.map +1 -0
- package/dist/core/dream/dream-types.js +99 -0
- package/dist/core/dream/dream-types.js.map +1 -0
- package/dist/core/dream/phases/nrem-phase.d.ts +21 -0
- package/dist/core/dream/phases/nrem-phase.d.ts.map +1 -0
- package/dist/core/dream/phases/nrem-phase.js +98 -0
- package/dist/core/dream/phases/nrem-phase.js.map +1 -0
- package/dist/core/dream/phases/rem-phase.d.ts +22 -0
- package/dist/core/dream/phases/rem-phase.d.ts.map +1 -0
- package/dist/core/dream/phases/rem-phase.js +87 -0
- package/dist/core/dream/phases/rem-phase.js.map +1 -0
- package/dist/core/dream/phases/wake-ready-phase.d.ts +24 -0
- package/dist/core/dream/phases/wake-ready-phase.d.ts.map +1 -0
- package/dist/core/dream/phases/wake-ready-phase.js +63 -0
- package/dist/core/dream/phases/wake-ready-phase.js.map +1 -0
- package/dist/core/events/event-types.d.ts +39 -1
- package/dist/core/events/event-types.d.ts.map +1 -1
- package/dist/core/store/migrations.d.ts.map +1 -1
- package/dist/core/store/migrations.js +30 -0
- package/dist/core/store/migrations.js.map +1 -1
- package/dist/docs-manifest.json +36 -1
- package/dist/schemas/entity.schema.d.ts +2 -2
- package/dist/web/dashboard/dist/assets/{benchmark-tab-Dx9G7cqf.js → benchmark-tab-BD02uofm.js} +1 -1
- package/dist/web/dashboard/dist/assets/{circle-alert-B17sfIdw.js → circle-alert-RxlCxXj1.js} +1 -1
- package/dist/web/dashboard/dist/assets/context-tab-DTPFGxle.js +1 -0
- package/dist/web/dashboard/dist/assets/{docs-tab-sxC7Gxc7.js → docs-tab-2uo7-Ybt.js} +1 -1
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-DEcNhLvY.js → gitnexus-tab-CiiNOf3e.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-CsHifp70.js → graph-section-DKMay1zv.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-D8ZSUyGR.js → graph-tab-BYRVanTv.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-D10A5HwE.js → graph-utils-1O2cEKuy.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-07Y4UWP1.js → index-B5DzSMGg.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-BxDGbcbB.css +1 -0
- package/dist/web/dashboard/dist/assets/{index-Dbaws8C6.js → index-CIhDR5rf.js} +26 -26
- package/dist/web/dashboard/dist/assets/{index-CVRN6scU.js → index-CSeiGgX8.js} +1 -1
- package/dist/web/dashboard/dist/assets/{insights-tab-DJAtypOr.js → insights-tab-DdI7TLP7.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-CXtDFeGm.js → journey-tab-CDuvIW6V.js} +1 -1
- package/dist/web/dashboard/dist/assets/{languages-tab-03j3C58E.js → languages-tab-CrbP4u3b.js} +1 -1
- package/dist/web/dashboard/dist/assets/{loader-circle-BNEIXs1s.js → loader-circle-Bl0DpM5P.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-D3BE923P.js → logs-tab-QYKxeHna.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-cac4ysh4.js → lsp-tab-CLO4RFMh.js} +1 -1
- package/dist/web/dashboard/dist/assets/{memories-tab-BPJTM45d.js → memories-tab-BT7A7YOy.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-5PCpKm0j.js → prd-backlog-tab-M1j0tAm2.js} +1 -1
- package/dist/web/dashboard/dist/assets/{refresh-cw-CI2U4FGa.js → refresh-cw-0ApsgAym.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-BuhOpZO3.js → siebel-tab-CsZz2y2b.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-BHWwOBtm.js → skills-tab-BrkrK7AC.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-BPgBTbDw.js → style-UgkJJqFQ.js} +1 -1
- package/dist/web/dashboard/dist/assets/{triangle-alert-aqoYdsgW.js → triangle-alert-BcgxNLLr.js} +1 -1
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +2 -2
- package/dist/web/dashboard/dist/assets/context-tab-BX2hlI9H.js +0 -1
- package/dist/web/dashboard/dist/assets/index-DVIgWBT4.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,a as k,j as e}from"./index-Dbaws8C6.js";import{u as F,a as P,i as H,B as z,C as R,M as V,H as J,P as O}from"./style-BPgBTbDw.js";import"./index-07Y4UWP1.js";const M={landing:"#2196f3",form:"#ff9800",selection:"#4caf50",listing:"#9c27b0",comparison:"#e91e63",detail:"#00bcd4",map:"#009688",calculator:"#ffc107",confirmation:"#3f51b5",success:"#4caf50",dashboard:"#607d8b",page:"#757575"},W={navigation:"#6c757d",form_submit:"#2196f3",redirect:"#ff9800",back:"#9e9e9e"},D=280,X=220,Y=c.memo(function({data:o}){const{screen:a,screenshotUrl:s,onSelect:n}=o,r=M[a.screenType]??"#757575";return e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"target",position:O.Top,className:"!w-2 !h-2"}),e.jsxs("div",{className:"bg-surface border-2 rounded-lg shadow-md hover:shadow-lg transition-shadow cursor-pointer overflow-hidden",style:{borderColor:r,width:D},onClick:()=>n(a),children:[e.jsxs("div",{className:"relative w-full bg-surface-elevated",style:{height:140},children:[s?e.jsx("img",{src:s,alt:a.title,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"No screenshot"}),e.jsx("span",{className:"absolute top-1.5 left-1.5 text-[9px] font-bold uppercase px-1.5 py-0.5 rounded text-white",style:{background:r},children:a.screenType})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-sm font-semibold leading-tight line-clamp-1",children:a.title}),a.url&&e.jsx("div",{className:"text-[10px] text-muted truncate mt-0.5",children:a.url}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.fields&&a.fields.length>0&&e.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-surface-elevated text-muted",children:[a.fields.length," fields"]}),a.ctas&&a.ctas.length>0&&e.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-surface-elevated text-muted",children:[a.ctas.length," CTAs"]})]})]})]}),e.jsx(J,{type:"source",position:O.Bottom,className:"!w-2 !h-2"})]})}),B={journeyScreen:Y};function G(t,o){var d;const a=new Map,s=new Map;for(const l of t)a.set(l.id,[]),s.set(l.id,0);for(const l of o)(d=a.get(l.from))==null||d.push(l.to),s.set(l.to,(s.get(l.to)??0)+1);const n=[],r=[],f=new Set;for(const l of t)(s.get(l.id)??0)===0&&r.push(l.id);for(;r.length>0;){const l=[...r];n.push(l),r.length=0;for(const i of l){f.add(i);for(const x of a.get(i)??[])if(!f.has(x)){const b=(s.get(x)??1)-1;s.set(x,b),b<=0&&!f.has(x)&&r.push(x)}}}for(const l of t)f.has(l.id)||(n.length===0&&n.push([]),n[n.length-1].push(l.id));const j=new Map(t.map(l=>[l.id,l])),u=D+60,v=X+80,y=[];for(let l=0;l<n.length;l++){const i=n[l],b=-(i.length*u)/2+u/2;for(let N=0;N<i.length;N++){const m=j.get(i[N]);m&&y.push({id:m.id,type:"journeyScreen",position:{x:m.positionX!==0?m.positionX:b+N*u,y:m.positionY!==0?m.positionY:l*v},data:{screen:m,screenshotUrl:m.screenshot?`/api/v1/journey/screenshots/_/${m.screenshot}`:void 0,onSelect:()=>{}}})}}return y}function L(t){return t.map(o=>({id:o.id,source:o.from,target:o.to,label:o.label??"",type:"smoothstep",animated:o.type==="form_submit",style:{stroke:W[o.type]??"#6c757d",strokeWidth:2},labelStyle:{fontSize:10,fill:"var(--color-text-muted)"},labelBgStyle:{fill:"var(--color-bg)",fillOpacity:.8}}))}function $({screen:t,onClose:o}){const a=M[t.screenType]??"#757575";return e.jsxs("div",{className:"w-80 h-full border-l border-edge bg-surface overflow-y-auto p-4 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold uppercase px-2 py-0.5 rounded text-white",style:{background:a},children:t.screenType}),e.jsx("button",{onClick:o,className:"text-muted hover:text-foreground",children:"X"})]}),e.jsx("h3",{className:"text-lg font-semibold",children:t.title}),t.url&&e.jsx("div",{className:"text-xs text-muted break-all",children:t.url}),t.description&&e.jsx("p",{className:"text-sm text-muted",children:t.description}),t.screenshot&&e.jsx("div",{className:"rounded-lg overflow-hidden border border-edge",children:e.jsx("img",{src:`/api/v1/journey/screenshots/_/${t.screenshot}`,alt:t.title,className:"w-full"})}),t.fields&&t.fields.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:["Form Fields (",t.fields.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:t.fields.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-surface-alt rounded px-2 py-1",children:[e.jsx("span",{className:"font-mono text-xs text-accent",children:s.type}),e.jsx("span",{children:s.label??s.name}),s.required&&e.jsx("span",{className:"text-[9px] text-red-400 font-bold",children:"*"})]},s.name))})]}),t.ctas&&t.ctas.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:["CTAs (",t.ctas.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.ctas.map(s=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-accent text-white",children:s},s))})]}),t.metadata&&Object.keys(t.metadata).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:"Metadata"}),e.jsx("pre",{className:"text-[10px] bg-surface-alt rounded p-2 overflow-x-auto",children:JSON.stringify(t.metadata,null,2)})]})]})}function T({maps:t,selectedId:o,onSelect:a,onImport:s,loading:n}){return n?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-7 flex-1 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-7 w-20 rounded bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 bg-surface-alt animate-pulse rounded-lg m-4"})]}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-muted",children:[e.jsx("div",{className:"text-5xl",children:"🗺"}),e.jsx("p",{className:"text-sm font-medium",children:"No journey maps yet"}),e.jsx("p",{className:"text-xs text-center max-w-xs",children:"Import a journey map JSON file or capture website screens to create a journey flow visualization."}),e.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg bg-accent text-white text-sm hover:opacity-90 transition-opacity",children:"Import Journey Map"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge bg-surface-alt",children:[e.jsx("label",{className:"text-xs font-medium text-muted",children:"Journey:"}),e.jsx("select",{value:o??"",onChange:r=>a(r.target.value),className:"text-sm bg-surface border border-edge rounded px-2 py-1 flex-1",children:t.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))}),e.jsx("button",{onClick:s,className:"text-xs px-2 py-1 rounded bg-surface-elevated hover:bg-edge text-muted",children:"+ Import"})]})}function U({variants:t,activeVariant:o,onSelect:a}){return t.length===0?null:e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge",children:[e.jsx("label",{className:"text-xs font-medium text-muted",children:"Variant:"}),e.jsx("button",{onClick:()=>a(null),className:`text-xs px-2 py-1 rounded ${o===null?"bg-accent text-white":"bg-surface-elevated text-muted"}`,children:"All"}),t.map(s=>e.jsx("button",{onClick:()=>a(s.id),className:`text-xs px-2 py-1 rounded ${o===s.id?"bg-accent text-white":"bg-surface-elevated text-muted"}`,title:s.description,children:s.name},s.id))]})}function _({open:t,onClose:o,onImported:a}){const[s,n]=c.useState(""),[r,f]=c.useState(null),[j,u]=c.useState(!1);if(!t)return null;const v=async()=>{f(null),u(!0);try{const d=JSON.parse(s);await k.importJourneyMap(d),a(),o(),n("")}catch(d){f(d instanceof Error?d.message:"Import failed")}finally{u(!1)}},y=d=>{var x;const l=(x=d.target.files)==null?void 0:x[0];if(!l)return;const i=new FileReader;i.onload=()=>n(i.result),i.readAsText(l)};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Import Journey Map"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Upload JSON file"}),e.jsx("input",{type:"file",accept:".json",onChange:y,className:"text-sm"})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Or paste JSON"}),e.jsx("textarea",{value:s,onChange:d=>n(d.target.value),rows:10,className:"w-full text-xs font-mono bg-surface-alt border border-edge rounded p-2",placeholder:'{"journey": {"name": "..."}, "screens": [...], "edges": [...]}'})]}),r&&e.jsx("div",{className:"text-sm text-danger mb-3",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"px-3 py-1.5 text-sm rounded-lg border border-edge hover:bg-surface-alt",children:"Cancel"}),e.jsx("button",{onClick:v,disabled:!s.trim()||j,className:"px-3 py-1.5 text-sm rounded-lg bg-accent text-white hover:opacity-90 disabled:opacity-50",children:j?"Importing...":"Import"})]})]})})}const q={hideAttribution:!0};function ee(){const[t,o]=c.useState([]),[a,s]=c.useState(null),[n,r]=c.useState(null),[f,j]=c.useState(null),[u,v]=c.useState(null),[y,d]=c.useState(!1),[l,i]=c.useState(!0),[x,b,N]=F([]),[m,C,A]=P([]),S=c.useCallback(async()=>{try{const p=await k.getJourneyMaps();o(p.maps),p.maps.length>0&&!a&&s(p.maps[0].id)}catch{o([])}finally{i(!1)}},[a]),E=c.useCallback(async p=>{try{const h=await k.getJourneyMap(p);r(h)}catch{r(null)}},[]);c.useEffect(()=>{S()},[S]),c.useEffect(()=>{a&&E(a)},[a,E]);const w=c.useMemo(()=>{if(!n)return null;if(!u)return n;const p=n.variants.find(g=>g.id===u);if(!p)return n;const h=new Set(p.path);return{...n,screens:n.screens.filter(g=>h.has(g.id)),edges:n.edges.filter(g=>h.has(g.from)&&h.has(g.to))}},[n,u]);c.useEffect(()=>{if(!w){b([]),C([]);return}const h=G(w.screens,w.edges).map(g=>({...g,data:{...g.data,onSelect:j}}));b(h),C(L(w.edges))},[w,b,C]);const I=c.useCallback(()=>{i(!0),S()},[S]);return l||t.length===0?e.jsxs(e.Fragment,{children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>d(!0),loading:l}),e.jsx(_,{open:y,onClose:()=>d(!1),onImported:I})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>d(!0),loading:!1}),n&&e.jsx(U,{variants:n.variants,activeVariant:u,onSelect:v}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx("div",{className:"flex-1",children:e.jsxs(H,{nodes:x,edges:m,onNodesChange:N,onEdgesChange:A,nodeTypes:B,proOptions:q,fitView:!0,minZoom:.1,maxZoom:3,defaultViewport:{x:0,y:0,zoom:.7},children:[e.jsx(z,{color:"var(--color-border)",gap:20}),e.jsx(R,{position:"bottom-left"}),e.jsx(V,{nodeColor:p=>{const h=p.data;return M[h.screen.screenType]??"#757575"},maskColor:"rgba(0,0,0,0.1)",position:"bottom-right"})]})}),f&&e.jsx($,{screen:f,onClose:()=>j(null)})]}),e.jsx(_,{open:y,onClose:()=>d(!1),onImported:I})]})}export{ee as JourneyTab};
|
|
1
|
+
import{r as c,a as k,j as e}from"./index-CIhDR5rf.js";import{u as F,a as P,i as H,B as z,C as R,M as V,H as J,P as O}from"./style-UgkJJqFQ.js";import"./index-B5DzSMGg.js";const M={landing:"#2196f3",form:"#ff9800",selection:"#4caf50",listing:"#9c27b0",comparison:"#e91e63",detail:"#00bcd4",map:"#009688",calculator:"#ffc107",confirmation:"#3f51b5",success:"#4caf50",dashboard:"#607d8b",page:"#757575"},W={navigation:"#6c757d",form_submit:"#2196f3",redirect:"#ff9800",back:"#9e9e9e"},D=280,X=220,Y=c.memo(function({data:o}){const{screen:a,screenshotUrl:s,onSelect:n}=o,r=M[a.screenType]??"#757575";return e.jsxs(e.Fragment,{children:[e.jsx(J,{type:"target",position:O.Top,className:"!w-2 !h-2"}),e.jsxs("div",{className:"bg-surface border-2 rounded-lg shadow-md hover:shadow-lg transition-shadow cursor-pointer overflow-hidden",style:{borderColor:r,width:D},onClick:()=>n(a),children:[e.jsxs("div",{className:"relative w-full bg-surface-elevated",style:{height:140},children:[s?e.jsx("img",{src:s,alt:a.title,className:"w-full h-full object-cover",loading:"lazy"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"No screenshot"}),e.jsx("span",{className:"absolute top-1.5 left-1.5 text-[9px] font-bold uppercase px-1.5 py-0.5 rounded text-white",style:{background:r},children:a.screenType})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-sm font-semibold leading-tight line-clamp-1",children:a.title}),a.url&&e.jsx("div",{className:"text-[10px] text-muted truncate mt-0.5",children:a.url}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.fields&&a.fields.length>0&&e.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-surface-elevated text-muted",children:[a.fields.length," fields"]}),a.ctas&&a.ctas.length>0&&e.jsxs("span",{className:"text-[9px] px-1 py-0.5 rounded bg-surface-elevated text-muted",children:[a.ctas.length," CTAs"]})]})]})]}),e.jsx(J,{type:"source",position:O.Bottom,className:"!w-2 !h-2"})]})}),B={journeyScreen:Y};function G(t,o){var d;const a=new Map,s=new Map;for(const l of t)a.set(l.id,[]),s.set(l.id,0);for(const l of o)(d=a.get(l.from))==null||d.push(l.to),s.set(l.to,(s.get(l.to)??0)+1);const n=[],r=[],f=new Set;for(const l of t)(s.get(l.id)??0)===0&&r.push(l.id);for(;r.length>0;){const l=[...r];n.push(l),r.length=0;for(const i of l){f.add(i);for(const x of a.get(i)??[])if(!f.has(x)){const b=(s.get(x)??1)-1;s.set(x,b),b<=0&&!f.has(x)&&r.push(x)}}}for(const l of t)f.has(l.id)||(n.length===0&&n.push([]),n[n.length-1].push(l.id));const j=new Map(t.map(l=>[l.id,l])),u=D+60,v=X+80,y=[];for(let l=0;l<n.length;l++){const i=n[l],b=-(i.length*u)/2+u/2;for(let N=0;N<i.length;N++){const m=j.get(i[N]);m&&y.push({id:m.id,type:"journeyScreen",position:{x:m.positionX!==0?m.positionX:b+N*u,y:m.positionY!==0?m.positionY:l*v},data:{screen:m,screenshotUrl:m.screenshot?`/api/v1/journey/screenshots/_/${m.screenshot}`:void 0,onSelect:()=>{}}})}}return y}function L(t){return t.map(o=>({id:o.id,source:o.from,target:o.to,label:o.label??"",type:"smoothstep",animated:o.type==="form_submit",style:{stroke:W[o.type]??"#6c757d",strokeWidth:2},labelStyle:{fontSize:10,fill:"var(--color-text-muted)"},labelBgStyle:{fill:"var(--color-bg)",fillOpacity:.8}}))}function $({screen:t,onClose:o}){const a=M[t.screenType]??"#757575";return e.jsxs("div",{className:"w-80 h-full border-l border-edge bg-surface overflow-y-auto p-4 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold uppercase px-2 py-0.5 rounded text-white",style:{background:a},children:t.screenType}),e.jsx("button",{onClick:o,className:"text-muted hover:text-foreground",children:"X"})]}),e.jsx("h3",{className:"text-lg font-semibold",children:t.title}),t.url&&e.jsx("div",{className:"text-xs text-muted break-all",children:t.url}),t.description&&e.jsx("p",{className:"text-sm text-muted",children:t.description}),t.screenshot&&e.jsx("div",{className:"rounded-lg overflow-hidden border border-edge",children:e.jsx("img",{src:`/api/v1/journey/screenshots/_/${t.screenshot}`,alt:t.title,className:"w-full"})}),t.fields&&t.fields.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:["Form Fields (",t.fields.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:t.fields.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-surface-alt rounded px-2 py-1",children:[e.jsx("span",{className:"font-mono text-xs text-accent",children:s.type}),e.jsx("span",{children:s.label??s.name}),s.required&&e.jsx("span",{className:"text-[9px] text-red-400 font-bold",children:"*"})]},s.name))})]}),t.ctas&&t.ctas.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:["CTAs (",t.ctas.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.ctas.map(s=>e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-accent text-white",children:s},s))})]}),t.metadata&&Object.keys(t.metadata).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase text-muted mb-1.5",children:"Metadata"}),e.jsx("pre",{className:"text-[10px] bg-surface-alt rounded p-2 overflow-x-auto",children:JSON.stringify(t.metadata,null,2)})]})]})}function T({maps:t,selectedId:o,onSelect:a,onImport:s,loading:n}){return n?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-7 flex-1 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-7 w-20 rounded bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 bg-surface-alt animate-pulse rounded-lg m-4"})]}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-muted",children:[e.jsx("div",{className:"text-5xl",children:"🗺"}),e.jsx("p",{className:"text-sm font-medium",children:"No journey maps yet"}),e.jsx("p",{className:"text-xs text-center max-w-xs",children:"Import a journey map JSON file or capture website screens to create a journey flow visualization."}),e.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg bg-accent text-white text-sm hover:opacity-90 transition-opacity",children:"Import Journey Map"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge bg-surface-alt",children:[e.jsx("label",{className:"text-xs font-medium text-muted",children:"Journey:"}),e.jsx("select",{value:o??"",onChange:r=>a(r.target.value),className:"text-sm bg-surface border border-edge rounded px-2 py-1 flex-1",children:t.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))}),e.jsx("button",{onClick:s,className:"text-xs px-2 py-1 rounded bg-surface-elevated hover:bg-edge text-muted",children:"+ Import"})]})}function U({variants:t,activeVariant:o,onSelect:a}){return t.length===0?null:e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-edge",children:[e.jsx("label",{className:"text-xs font-medium text-muted",children:"Variant:"}),e.jsx("button",{onClick:()=>a(null),className:`text-xs px-2 py-1 rounded ${o===null?"bg-accent text-white":"bg-surface-elevated text-muted"}`,children:"All"}),t.map(s=>e.jsx("button",{onClick:()=>a(s.id),className:`text-xs px-2 py-1 rounded ${o===s.id?"bg-accent text-white":"bg-surface-elevated text-muted"}`,title:s.description,children:s.name},s.id))]})}function _({open:t,onClose:o,onImported:a}){const[s,n]=c.useState(""),[r,f]=c.useState(null),[j,u]=c.useState(!1);if(!t)return null;const v=async()=>{f(null),u(!0);try{const d=JSON.parse(s);await k.importJourneyMap(d),a(),o(),n("")}catch(d){f(d instanceof Error?d.message:"Import failed")}finally{u(!1)}},y=d=>{var x;const l=(x=d.target.files)==null?void 0:x[0];if(!l)return;const i=new FileReader;i.onload=()=>n(i.result),i.readAsText(l)};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Import Journey Map"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Upload JSON file"}),e.jsx("input",{type:"file",accept:".json",onChange:y,className:"text-sm"})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Or paste JSON"}),e.jsx("textarea",{value:s,onChange:d=>n(d.target.value),rows:10,className:"w-full text-xs font-mono bg-surface-alt border border-edge rounded p-2",placeholder:'{"journey": {"name": "..."}, "screens": [...], "edges": [...]}'})]}),r&&e.jsx("div",{className:"text-sm text-danger mb-3",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:o,className:"px-3 py-1.5 text-sm rounded-lg border border-edge hover:bg-surface-alt",children:"Cancel"}),e.jsx("button",{onClick:v,disabled:!s.trim()||j,className:"px-3 py-1.5 text-sm rounded-lg bg-accent text-white hover:opacity-90 disabled:opacity-50",children:j?"Importing...":"Import"})]})]})})}const q={hideAttribution:!0};function ee(){const[t,o]=c.useState([]),[a,s]=c.useState(null),[n,r]=c.useState(null),[f,j]=c.useState(null),[u,v]=c.useState(null),[y,d]=c.useState(!1),[l,i]=c.useState(!0),[x,b,N]=F([]),[m,C,A]=P([]),S=c.useCallback(async()=>{try{const p=await k.getJourneyMaps();o(p.maps),p.maps.length>0&&!a&&s(p.maps[0].id)}catch{o([])}finally{i(!1)}},[a]),E=c.useCallback(async p=>{try{const h=await k.getJourneyMap(p);r(h)}catch{r(null)}},[]);c.useEffect(()=>{S()},[S]),c.useEffect(()=>{a&&E(a)},[a,E]);const w=c.useMemo(()=>{if(!n)return null;if(!u)return n;const p=n.variants.find(g=>g.id===u);if(!p)return n;const h=new Set(p.path);return{...n,screens:n.screens.filter(g=>h.has(g.id)),edges:n.edges.filter(g=>h.has(g.from)&&h.has(g.to))}},[n,u]);c.useEffect(()=>{if(!w){b([]),C([]);return}const h=G(w.screens,w.edges).map(g=>({...g,data:{...g.data,onSelect:j}}));b(h),C(L(w.edges))},[w,b,C]);const I=c.useCallback(()=>{i(!0),S()},[S]);return l||t.length===0?e.jsxs(e.Fragment,{children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>d(!0),loading:l}),e.jsx(_,{open:y,onClose:()=>d(!1),onImported:I})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(T,{maps:t,selectedId:a,onSelect:s,onImport:()=>d(!0),loading:!1}),n&&e.jsx(U,{variants:n.variants,activeVariant:u,onSelect:v}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx("div",{className:"flex-1",children:e.jsxs(H,{nodes:x,edges:m,onNodesChange:N,onEdgesChange:A,nodeTypes:B,proOptions:q,fitView:!0,minZoom:.1,maxZoom:3,defaultViewport:{x:0,y:0,zoom:.7},children:[e.jsx(z,{color:"var(--color-border)",gap:20}),e.jsx(R,{position:"bottom-left"}),e.jsx(V,{nodeColor:p=>{const h=p.data;return M[h.screen.screenType]??"#757575"},maskColor:"rgba(0,0,0,0.1)",position:"bottom-right"})]})}),f&&e.jsx($,{screen:f,onClose:()=>j(null)})]}),e.jsx(_,{open:y,onClose:()=>d(!1),onImported:I})]})}export{ee as JourneyTab};
|
package/dist/web/dashboard/dist/assets/{languages-tab-03j3C58E.js → languages-tab-CrbP4u3b.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as N,r as m,a as w,j as e,
|
|
1
|
+
import{c as N,r as m,a as w,j as e,e as H,B as G,u as de,L as ie,G as B}from"./index-CIhDR5rf.js";import{i as xe,B as ue,C as me}from"./style-UgkJJqFQ.js";import{d as X}from"./index-CSeiGgX8.js";import{L as $}from"./loader-circle-Bl0DpM5P.js";import{T as J,C as q,a as K,S as ae,F as re}from"./triangle-alert-BcgxNLLr.js";import{R as V}from"./refresh-cw-0ApsgAym.js";import"./index-B5DzSMGg.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,a as v,j as t}from"./index-
|
|
1
|
+
import{r as s,a as v,j as t}from"./index-CIhDR5rf.js";function S(){const[r,l]=s.useState([]),[c,h]=s.useState(!0),d=s.useRef(0),p=s.useCallback(async()=>{try{const{logs:n}=await v.getLogs();l(n),n.length>0&&(d.current=n[n.length-1].id)}finally{h(!1)}},[]),x=s.useCallback(async()=>{await v.clearLogs(),l([]),d.current=0},[]);return s.useEffect(()=>{p()},[p]),s.useEffect(()=>{const n=new EventSource("/api/v1/events"),i=f=>{try{const o=JSON.parse(f.data),a={id:o.payload.id,level:o.payload.level,message:o.payload.message,context:o.payload.context,timestamp:o.timestamp};a.id>d.current&&(d.current=a.id,l(b=>[...b,a]))}catch{}};return n.addEventListener("log:entry",i),n.onerror=()=>{n.close(),setTimeout(()=>{},5e3)},()=>n.close()},[]),{logs:r,loading:c,clearLogs:x,refresh:p}}const k={info:"bg-blue-500/20 text-blue-400",warn:"bg-yellow-500/20 text-yellow-400",error:"bg-red-500/20 text-red-400",success:"bg-green-500/20 text-green-400",debug:"bg-gray-500/20 text-gray-400"},E=["info","warn","error","success","debug"];function L(r){return new Date(r).toLocaleTimeString("en-US",{hour12:!1})}function y(r){return!r||Object.keys(r).length===0?"":Object.entries(r).map(([l,c])=>`${l}="${String(c)}"`).join(" ")}function j(r){return r.map(l=>{const c=y(l.context);return`[${L(l.timestamp)}] [${l.level.toUpperCase()}] ${l.message}${c?" "+c:""}`}).join(`
|
|
2
2
|
`)}function O(){const{logs:r,loading:l,clearLogs:c,refresh:h}=S(),[d,p]=s.useState("all"),[x,n]=s.useState(""),[i,f]=s.useState(!0),o=s.useRef(null),a=s.useMemo(()=>{let e=r;if(d!=="all"&&(e=e.filter(u=>u.level===d)),x.trim()){const u=x.toLowerCase();e=e.filter(g=>g.message.toLowerCase().includes(u))}return e},[r,d,x]);s.useEffect(()=>{i&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[a,i]);const b=s.useCallback(()=>{if(!o.current)return;const{scrollTop:e,scrollHeight:u,clientHeight:g}=o.current,m=u-e-g<40;f(m)},[]),C=s.useCallback(async()=>{const e=j(a);await navigator.clipboard.writeText(e)},[a]),N=s.useCallback(()=>{const e=j(a),u=new Blob([e],{type:"text/plain"}),g=URL.createObjectURL(u),m=document.createElement("a");m.href=g,m.download=`mcp-graph-logs-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.txt`,m.click(),URL.revokeObjectURL(g)},[a]),w=s.useCallback(async()=>{await c()},[c]);return l?t.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading logs..."}):t.jsxs("div",{className:"flex flex-col h-full","data-testid":"logs-tab",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-edge bg-surface-alt",children:[t.jsxs("select",{value:d,onChange:e=>p(e.target.value),className:"px-2 py-1 text-sm rounded border border-edge bg-surface text-foreground","data-testid":"log-level-filter",children:[t.jsx("option",{value:"all",children:"All Levels"}),E.map(e=>t.jsx("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),t.jsx("input",{type:"text",value:x,onChange:e=>n(e.target.value),placeholder:"Search logs...",className:"flex-1 px-2 py-1 text-sm rounded border border-edge bg-surface text-foreground placeholder:text-muted","data-testid":"log-search"}),t.jsx("button",{onClick:()=>f(!i),className:`px-2 py-1 text-xs rounded border ${i?"border-accent text-accent":"border-edge text-muted"}`,title:i?"Auto-scroll enabled":"Auto-scroll paused",children:i?"Auto-scroll ON":"Auto-scroll OFF"}),t.jsx("button",{onClick:C,className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Copy all visible logs",children:"Copy"}),t.jsx("button",{onClick:N,className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Download logs as .txt",children:"Download"}),t.jsx("button",{onClick:w,className:"px-2 py-1 text-xs rounded border border-red-500/30 text-red-400 hover:bg-red-500/10",title:"Clear all logs",children:"Clear"}),t.jsx("button",{onClick:()=>void h(),className:"px-2 py-1 text-xs rounded border border-edge text-muted hover:text-foreground",title:"Refresh logs",children:"Refresh"}),t.jsxs("span",{className:"text-xs text-muted",children:[a.length," entries"]})]}),t.jsx("div",{ref:o,onScroll:b,className:"flex-1 overflow-y-auto font-mono text-xs p-2","data-testid":"log-list",children:a.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted",children:[t.jsx("p",{className:"text-xs",children:"No logs to display"}),t.jsx("p",{className:"text-[10px] text-muted/60",children:"Logs appear when mcp-graph tools are executed"})]}):a.map(e=>t.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-surface-alt",children:[t.jsx("span",{className:"text-muted shrink-0",children:L(e.timestamp)}),t.jsx("span",{className:`px-1.5 py-0 rounded text-[10px] font-semibold uppercase shrink-0 ${k[e.level]}`,children:e.level}),t.jsx("span",{className:"text-foreground",children:e.message}),e.context&&Object.keys(e.context).length>0&&t.jsx("span",{className:"text-muted",children:y(e.context)})]},e.id))})]})}export{O as LogsTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as I,r as n,a as L,j as e,C as X}from"./index-
|
|
1
|
+
import{c as I,r as n,a as L,j as e,C as X}from"./index-CIhDR5rf.js";import{C as Z}from"./circle-alert-RxlCxXj1.js";import{R as z}from"./refresh-cw-0ApsgAym.js";import{S as K,T as A,F as ee,C as me,a as ue}from"./triangle-alert-BcgxNLLr.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dist/web/dashboard/dist/assets/{memories-tab-BPJTM45d.js → memories-tab-BT7A7YOy.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,a as b,j as e}from"./index-Dbaws8C6.js";function z(l){const m=[];for(const r of l){const i=r.name.split("/");let o=m;for(let x=0;x<i.length;x++){const n=i[x],d=i.slice(0,x+1).join("/"),a=x===i.length-1;let c=o.find(h=>h.name===n);c||(c={name:n,path:d,children:[]},a&&(c.memory=r),o.push(c)),a&&!c.memory&&(c.memory=r),o=c.children}}return m}function C(){const[l,m]=t.useState([]),[r,i]=t.useState(null),[o,x]=t.useState(""),[n,d]=t.useState(null),[a,c]=t.useState(!0),[h,g]=t.useState(null),p=t.useCallback(async()=>{try{c(!0);const[s,N]=await Promise.all([b.knowledgeList(50),b.knowledgeGetStats()]);m(s.documents),i(N)}catch(s){g(s instanceof Error?s.message:"Failed to load")}finally{c(!1)}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async()=>{if(!o.trim()){d(null);return}try{const s=await b.knowledgeSearch(o,20);d(s.results)}catch{d([])}},[o]),u=t.useCallback(async s=>{if(confirm("Delete this knowledge document?"))try{await b.knowledgeDelete(s),await p()}catch{}},[p]),f=n??l;return a?e.jsx("div",{className:"text-zinc-400 p-4",children:"Loading knowledge store..."}):h?e.jsxs("div",{className:"text-red-400 p-4",children:["Error: ",h]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs("div",{className:"bg-zinc-800 rounded-lg px-4 py-2 border border-zinc-700",children:[e.jsx("span",{className:"text-lg font-bold text-zinc-100",children:r.total}),e.jsx("span",{className:"text-xs text-zinc-500 ml-2",children:"total docs"})]}),Object.entries(r.bySource).map(([s,N])=>e.jsxs("div",{className:"bg-zinc-800 rounded-lg px-3 py-2 border border-zinc-700",children:[e.jsx("span",{className:"text-sm font-medium text-zinc-200",children:N}),e.jsx("span",{className:"text-xs text-zinc-500 ml-1",children:s})]},s))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Search knowledge store...",value:o,onChange:s=>x(s.target.value),onKeyDown:s=>s.key==="Enter"&&j(),className:"flex-1 px-3 py-2 bg-zinc-800 border border-zinc-600 rounded-md text-zinc-200 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("button",{onClick:j,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-500 text-sm",children:"Search"}),n&&e.jsx("button",{onClick:()=>{d(null),x("")},className:"px-3 py-2 bg-zinc-700 text-zinc-300 rounded-md hover:bg-zinc-600 text-sm",children:"Clear"})]}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[f.length," documents",n?" (search results)":""]}),e.jsxs("div",{className:"space-y-1",children:[f.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md hover:bg-zinc-800/50 group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-zinc-200 truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[s.sourceType,s.createdAt?` - ${new Date(s.createdAt).toLocaleDateString()}`:""]})]}),e.jsx("button",{onClick:()=>u(s.id),className:"text-xs text-red-400 opacity-0 group-hover:opacity-100 transition-opacity px-2 py-1 rounded hover:bg-red-900/30",children:"Delete"})]},s.id)),f.length===0&&e.jsx("div",{className:"text-zinc-500 text-sm p-4 text-center",children:"No documents found"})]})]})}function E(){const[l,m]=t.useState(!1),[r,i]=t.useState(!1),[o,x]=t.useState(null),[n,d]=t.useState(null),[a,c]=t.useState(null),[h,g]=t.useState(null),p=t.useCallback(async()=>{try{m(!0),g(null);const s=await b.knowledgeExport(),N=new Blob([JSON.stringify(s.package,null,2)],{type:"application/json"}),v=URL.createObjectURL(N),y=document.createElement("a");y.href=v,y.download=`knowledge-export-${new Date().toISOString().slice(0,10)}.json`,y.click(),URL.revokeObjectURL(v)}catch(s){g(s instanceof Error?s.message:"Export failed")}finally{m(!1)}},[]),j=t.useCallback(async s=>{var v;const N=(v=s.target.files)==null?void 0:v[0];if(N)try{g(null),d(null);const y=await N.text(),w=JSON.parse(y);c(w);const S=await b.knowledgePreview(w);x(S.preview)}catch(y){g(y instanceof Error?y.message:"Invalid package file"),c(null),x(null)}},[]),u=t.useCallback(async()=>{if(a)try{i(!0),g(null);const s=await b.knowledgeImport(a);d(s.result),x(null),c(null)}catch(s){g(s instanceof Error?s.message:"Import failed")}finally{i(!1)}},[a]),f=t.useCallback(()=>{c(null),x(null),d(null)},[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-2",children:"Export Knowledge Package"}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:"Download all knowledge documents, memories, and relations as a portable JSON package."}),e.jsx("button",{onClick:p,disabled:l,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-500 text-sm disabled:opacity-50",children:l?"Exporting...":"Export Package"})]}),e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-2",children:"Import Knowledge Package"}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:"Upload a knowledge package JSON to import documents and memories."}),e.jsx("input",{type:"file",accept:".json",onChange:j,className:"block w-full text-sm text-zinc-400 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:bg-zinc-700 file:text-zinc-200 hover:file:bg-zinc-600"}),o&&e.jsxs("div",{className:"mt-4 p-3 bg-zinc-900 rounded-md border border-zinc-600",children:[e.jsx("h4",{className:"text-xs font-semibold text-zinc-300 mb-2",children:"Import Preview"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-green-400",children:o.newDocuments})," new documents"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-yellow-400",children:o.existingDocuments})," existing (skip)"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-green-400",children:o.newMemories})," new memories"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-yellow-400",children:o.existingMemories})," existing (skip)"]})]}),e.jsxs("div",{className:"text-xs text-zinc-500 mt-2",children:["Sources: ",o.sourceTypes.join(", ")]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:u,disabled:r,className:"px-3 py-1.5 bg-green-600 text-white rounded-md hover:bg-green-500 text-xs disabled:opacity-50",children:r?"Importing...":"Confirm Import"}),e.jsx("button",{onClick:f,className:"px-3 py-1.5 bg-zinc-700 text-zinc-300 rounded-md hover:bg-zinc-600 text-xs",children:"Cancel"})]})]}),n&&e.jsxs("div",{className:"mt-4 p-3 bg-green-900/20 rounded-md border border-green-700/50",children:[e.jsx("h4",{className:"text-xs font-semibold text-green-400 mb-1",children:"Import Complete"}),e.jsxs("div",{className:"text-xs text-zinc-300",children:[n.documentsImported," docs imported, ",n.documentsSkipped," skipped, ",n.memoriesImported," memories imported"]})]})]}),h&&e.jsx("div",{className:"text-red-400 text-sm p-2",children:h})]})}function L(){const[l,m]=t.useState([]),[r,i]=t.useState(!0),[o,x]=t.useState({}),n=t.useCallback(async()=>{try{i(!0);const a=await b.knowledgeList(30);m(a.documents)}finally{i(!1)}},[]);t.useEffect(()=>{n()},[n]);const d=t.useCallback(async(a,c)=>{try{await b.knowledgeFeedback(a,c),x(h=>({...h,[a]:c}))}catch{}},[]);return r?e.jsx("div",{className:"text-zinc-400 p-4",children:"Loading..."}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-3",children:"Rate knowledge documents to improve RAG quality. Your feedback adjusts quality scores."}),l.map(a=>{const c=o[a.id];return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md hover:bg-zinc-800/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-zinc-200 truncate",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[e.jsx("span",{children:a.sourceType}),a.qualityScore!==void 0&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded ${a.qualityScore>.7?"bg-green-900/30 text-green-400":a.qualityScore>.3?"bg-yellow-900/30 text-yellow-400":"bg-red-900/30 text-red-400"}`,children:["q:",(a.qualityScore*100).toFixed(0),"%"]})]})]}),e.jsx("div",{className:"flex gap-1",children:c?e.jsx("span",{className:`text-xs px-2 py-1 rounded ${c==="helpful"?"bg-green-900/30 text-green-400":c==="unhelpful"?"bg-red-900/30 text-red-400":"bg-yellow-900/30 text-yellow-400"}`,children:c}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>d(a.id,"helpful"),className:"text-xs px-2 py-1 rounded bg-green-900/20 text-green-400 hover:bg-green-900/40",children:"Helpful"}),e.jsx("button",{onClick:()=>d(a.id,"unhelpful"),className:"text-xs px-2 py-1 rounded bg-red-900/20 text-red-400 hover:bg-red-900/40",children:"Unhelpful"}),e.jsx("button",{onClick:()=>d(a.id,"outdated"),className:"text-xs px-2 py-1 rounded bg-yellow-900/20 text-yellow-400 hover:bg-yellow-900/40",children:"Outdated"})]})})]},a.id)}),l.length===0&&e.jsx("div",{className:"text-zinc-500 text-sm p-4 text-center",children:"No knowledge documents yet"})]})}function R(){const[l,m]=t.useState("memories");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex gap-1 p-2 border-b border-zinc-700 shrink-0",children:[{id:"memories",label:"Memories"},{id:"knowledge",label:"Knowledge Store"},{id:"export",label:"Export / Import"}].map(r=>e.jsx("button",{onClick:()=>m(r.id),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${l===r.id?"bg-blue-600/20 text-blue-400":"text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"}`,children:r.label},r.id))}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[l==="knowledge"&&e.jsx("div",{className:"p-4",children:e.jsx(C,{})}),l==="export"&&e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(E,{}),e.jsxs("div",{className:"border-t border-zinc-700 pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-3",children:"Knowledge Feedback"}),e.jsx(L,{})]})]}),l==="memories"&&e.jsx(D,{})]})]})}function D(){const[l,m]=t.useState([]),[r,i]=t.useState(null),[o,x]=t.useState(null),[n,d]=t.useState(!0),[a,c]=t.useState(!1),[h,g]=t.useState(new Map),p=t.useCallback(async()=>{try{d(!0);const u=await b.getMemories().catch(()=>[]);m(u)}catch(u){x(u instanceof Error?u.message:"Failed to load")}finally{d(!1)}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async u=>{i(u);const f=h.get(u.name);if(f!==void 0){i({...u,content:f});return}try{c(!0);const s=await b.readMemory(u.name);g(N=>{const v=new Map(N);return v.set(u.name,s.content),v}),i({...u,content:s.content})}catch{i({...u,content:"[Failed to load content]"})}finally{c(!1)}},[h]);return n?e.jsxs("div",{className:"h-full flex",children:[e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt p-2 space-y-2",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-6 w-full rounded bg-surface animate-pulse"}),Array.from({length:6}).map((u,f)=>e.jsx("div",{className:"h-4 rounded bg-surface animate-pulse",style:{width:`${50+Math.random()*40}%`,marginLeft:`${f%3*12}px`}},f))]}),e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Loading memories..."})]}):o?e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",o]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Memories"}),e.jsx(F,{label:"Memories",active:l.length>0}),e.jsxs("span",{className:"text-[10px] text-muted",children:[l.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(P,{memories:l,selectedMemory:r,onSelect:j}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(M,{selectedMemory:r,contentLoading:a})})]})]})}function F({label:l,active:m}){const r=m?"var(--color-success)":"var(--color-text-muted)",i=m?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${r}20`,color:r},children:[l,": ",i]})}function P({memories:l,selectedMemory:m,onSelect:r}){const[i,o]=t.useState(""),[x,n]=t.useState(!1),[d,a]=t.useState(new Set),c=t.useMemo(()=>{if(!i.trim())return l;const p=i.toLowerCase();return l.filter(j=>j.name.toLowerCase().includes(p))},[l,i]),h=t.useMemo(()=>z(c),[c]),g=t.useCallback(p=>{a(j=>{const u=new Set(j);return u.has(p)?u.delete(p):u.add(p),u})},[]);return x?e.jsx("div",{className:"w-8 border-r border-edge bg-surface-alt flex flex-col items-center pt-2",children:e.jsx("button",{onClick:()=>n(!1),className:"text-[10px] text-muted hover:text-foreground rotate-90",title:"Expand file explorer",children:"Files"})}):e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-edge",children:[e.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Files"}),e.jsx("button",{onClick:()=>n(!0),className:"text-[10px] text-muted hover:text-foreground",title:"Collapse",children:"✕"})]}),e.jsx("div",{className:"px-2 py-1.5 border-b border-edge",children:e.jsx("input",{type:"text",value:i,onChange:p=>o(p.target.value),placeholder:"Search files...",className:"w-full text-[11px] px-2 py-1 rounded bg-surface border border-edge focus:outline-none focus:border-accent"})}),e.jsx("div",{className:"flex-1 overflow-y-auto text-[11px]",children:l.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-muted",children:"No memories"}):e.jsx(k,{nodes:h,depth:0,expandedPaths:d,onToggle:g,selectedMemory:m,onSelect:r})})]})}function k({nodes:l,depth:m,expandedPaths:r,onToggle:i,selectedMemory:o,onSelect:x}){return e.jsx(e.Fragment,{children:l.map(n=>{const d=n.children.length>0,a=r.has(n.path),c=n.memory!=null&&(o==null?void 0:o.name)===n.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{d&&i(n.path),n.memory&&x(n.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-surface-elevated transition-colors cursor-pointer ${c?"bg-accent15 text-accent":"text-foreground"}`,style:{paddingLeft:`${m*12+8}px`},children:[d?e.jsx("span",{className:"w-3 text-[9px] text-muted",children:a?"▾":"▸"}):e.jsx("span",{className:"w-3 text-[9px] text-muted",children:"·"}),e.jsx("span",{className:"truncate",children:n.name})]}),d&&a&&e.jsx(k,{nodes:n.children,depth:m+1,expandedPaths:r,onToggle:i,selectedMemory:o,onSelect:x})]},n.path)})})}function M({selectedMemory:l,contentLoading:m}){const[r,i]=t.useState(!1);if(!l)return e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm mb-1",children:"Select a memory from the explorer"}),e.jsx("p",{className:"text-xs text-muted/60",children:"Project memories appear as navigable files"})]})});const o=()=>{navigator.clipboard.writeText(l.content),i(!0),setTimeout(()=>i(!1),2e3)},x=l.name.split("/");return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px] text-muted",children:[e.jsx("span",{children:"memories"}),x.map((n,d)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"/"}),e.jsx("span",{className:d===x.length-1?"text-foreground font-medium":"",children:n})]},d))]}),e.jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b border-edge",children:[e.jsx("span",{className:"text-sm font-semibold",children:x[x.length-1]}),e.jsx("button",{onClick:o,disabled:m,className:`text-[10px] px-2 py-0.5 rounded border transition-all cursor-pointer ${r?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:r?"Copied!":"Copy"})]}),m?e.jsx("div",{className:"space-y-2",children:Array.from({length:8}).map((n,d)=>e.jsx("div",{className:"h-3 rounded bg-surface animate-pulse",style:{width:`${40+Math.random()*50}%`}},d))}):e.jsx("pre",{className:"text-xs whitespace-pre-wrap text-muted font-mono leading-relaxed",children:l.content})]})}export{R as MemoriesTab};
|
|
1
|
+
import{r as t,a as b,j as e}from"./index-CIhDR5rf.js";function z(l){const m=[];for(const r of l){const i=r.name.split("/");let o=m;for(let x=0;x<i.length;x++){const n=i[x],d=i.slice(0,x+1).join("/"),a=x===i.length-1;let c=o.find(h=>h.name===n);c||(c={name:n,path:d,children:[]},a&&(c.memory=r),o.push(c)),a&&!c.memory&&(c.memory=r),o=c.children}}return m}function C(){const[l,m]=t.useState([]),[r,i]=t.useState(null),[o,x]=t.useState(""),[n,d]=t.useState(null),[a,c]=t.useState(!0),[h,g]=t.useState(null),p=t.useCallback(async()=>{try{c(!0);const[s,N]=await Promise.all([b.knowledgeList(50),b.knowledgeGetStats()]);m(s.documents),i(N)}catch(s){g(s instanceof Error?s.message:"Failed to load")}finally{c(!1)}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async()=>{if(!o.trim()){d(null);return}try{const s=await b.knowledgeSearch(o,20);d(s.results)}catch{d([])}},[o]),u=t.useCallback(async s=>{if(confirm("Delete this knowledge document?"))try{await b.knowledgeDelete(s),await p()}catch{}},[p]),f=n??l;return a?e.jsx("div",{className:"text-zinc-400 p-4",children:"Loading knowledge store..."}):h?e.jsxs("div",{className:"text-red-400 p-4",children:["Error: ",h]}):e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs("div",{className:"bg-zinc-800 rounded-lg px-4 py-2 border border-zinc-700",children:[e.jsx("span",{className:"text-lg font-bold text-zinc-100",children:r.total}),e.jsx("span",{className:"text-xs text-zinc-500 ml-2",children:"total docs"})]}),Object.entries(r.bySource).map(([s,N])=>e.jsxs("div",{className:"bg-zinc-800 rounded-lg px-3 py-2 border border-zinc-700",children:[e.jsx("span",{className:"text-sm font-medium text-zinc-200",children:N}),e.jsx("span",{className:"text-xs text-zinc-500 ml-1",children:s})]},s))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Search knowledge store...",value:o,onChange:s=>x(s.target.value),onKeyDown:s=>s.key==="Enter"&&j(),className:"flex-1 px-3 py-2 bg-zinc-800 border border-zinc-600 rounded-md text-zinc-200 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("button",{onClick:j,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-500 text-sm",children:"Search"}),n&&e.jsx("button",{onClick:()=>{d(null),x("")},className:"px-3 py-2 bg-zinc-700 text-zinc-300 rounded-md hover:bg-zinc-600 text-sm",children:"Clear"})]}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[f.length," documents",n?" (search results)":""]}),e.jsxs("div",{className:"space-y-1",children:[f.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md hover:bg-zinc-800/50 group",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-zinc-200 truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-zinc-500",children:[s.sourceType,s.createdAt?` - ${new Date(s.createdAt).toLocaleDateString()}`:""]})]}),e.jsx("button",{onClick:()=>u(s.id),className:"text-xs text-red-400 opacity-0 group-hover:opacity-100 transition-opacity px-2 py-1 rounded hover:bg-red-900/30",children:"Delete"})]},s.id)),f.length===0&&e.jsx("div",{className:"text-zinc-500 text-sm p-4 text-center",children:"No documents found"})]})]})}function E(){const[l,m]=t.useState(!1),[r,i]=t.useState(!1),[o,x]=t.useState(null),[n,d]=t.useState(null),[a,c]=t.useState(null),[h,g]=t.useState(null),p=t.useCallback(async()=>{try{m(!0),g(null);const s=await b.knowledgeExport(),N=new Blob([JSON.stringify(s.package,null,2)],{type:"application/json"}),v=URL.createObjectURL(N),y=document.createElement("a");y.href=v,y.download=`knowledge-export-${new Date().toISOString().slice(0,10)}.json`,y.click(),URL.revokeObjectURL(v)}catch(s){g(s instanceof Error?s.message:"Export failed")}finally{m(!1)}},[]),j=t.useCallback(async s=>{var v;const N=(v=s.target.files)==null?void 0:v[0];if(N)try{g(null),d(null);const y=await N.text(),w=JSON.parse(y);c(w);const S=await b.knowledgePreview(w);x(S.preview)}catch(y){g(y instanceof Error?y.message:"Invalid package file"),c(null),x(null)}},[]),u=t.useCallback(async()=>{if(a)try{i(!0),g(null);const s=await b.knowledgeImport(a);d(s.result),x(null),c(null)}catch(s){g(s instanceof Error?s.message:"Import failed")}finally{i(!1)}},[a]),f=t.useCallback(()=>{c(null),x(null),d(null)},[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-2",children:"Export Knowledge Package"}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:"Download all knowledge documents, memories, and relations as a portable JSON package."}),e.jsx("button",{onClick:p,disabled:l,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-500 text-sm disabled:opacity-50",children:l?"Exporting...":"Export Package"})]}),e.jsxs("div",{className:"bg-zinc-800 rounded-lg p-4 border border-zinc-700",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-2",children:"Import Knowledge Package"}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:"Upload a knowledge package JSON to import documents and memories."}),e.jsx("input",{type:"file",accept:".json",onChange:j,className:"block w-full text-sm text-zinc-400 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:bg-zinc-700 file:text-zinc-200 hover:file:bg-zinc-600"}),o&&e.jsxs("div",{className:"mt-4 p-3 bg-zinc-900 rounded-md border border-zinc-600",children:[e.jsx("h4",{className:"text-xs font-semibold text-zinc-300 mb-2",children:"Import Preview"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-green-400",children:o.newDocuments})," new documents"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-yellow-400",children:o.existingDocuments})," existing (skip)"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-green-400",children:o.newMemories})," new memories"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-yellow-400",children:o.existingMemories})," existing (skip)"]})]}),e.jsxs("div",{className:"text-xs text-zinc-500 mt-2",children:["Sources: ",o.sourceTypes.join(", ")]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:u,disabled:r,className:"px-3 py-1.5 bg-green-600 text-white rounded-md hover:bg-green-500 text-xs disabled:opacity-50",children:r?"Importing...":"Confirm Import"}),e.jsx("button",{onClick:f,className:"px-3 py-1.5 bg-zinc-700 text-zinc-300 rounded-md hover:bg-zinc-600 text-xs",children:"Cancel"})]})]}),n&&e.jsxs("div",{className:"mt-4 p-3 bg-green-900/20 rounded-md border border-green-700/50",children:[e.jsx("h4",{className:"text-xs font-semibold text-green-400 mb-1",children:"Import Complete"}),e.jsxs("div",{className:"text-xs text-zinc-300",children:[n.documentsImported," docs imported, ",n.documentsSkipped," skipped, ",n.memoriesImported," memories imported"]})]})]}),h&&e.jsx("div",{className:"text-red-400 text-sm p-2",children:h})]})}function L(){const[l,m]=t.useState([]),[r,i]=t.useState(!0),[o,x]=t.useState({}),n=t.useCallback(async()=>{try{i(!0);const a=await b.knowledgeList(30);m(a.documents)}finally{i(!1)}},[]);t.useEffect(()=>{n()},[n]);const d=t.useCallback(async(a,c)=>{try{await b.knowledgeFeedback(a,c),x(h=>({...h,[a]:c}))}catch{}},[]);return r?e.jsx("div",{className:"text-zinc-400 p-4",children:"Loading..."}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-zinc-500 mb-3",children:"Rate knowledge documents to improve RAG quality. Your feedback adjusts quality scores."}),l.map(a=>{const c=o[a.id];return e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md hover:bg-zinc-800/50",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-zinc-200 truncate",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[e.jsx("span",{children:a.sourceType}),a.qualityScore!==void 0&&e.jsxs("span",{className:`px-1.5 py-0.5 rounded ${a.qualityScore>.7?"bg-green-900/30 text-green-400":a.qualityScore>.3?"bg-yellow-900/30 text-yellow-400":"bg-red-900/30 text-red-400"}`,children:["q:",(a.qualityScore*100).toFixed(0),"%"]})]})]}),e.jsx("div",{className:"flex gap-1",children:c?e.jsx("span",{className:`text-xs px-2 py-1 rounded ${c==="helpful"?"bg-green-900/30 text-green-400":c==="unhelpful"?"bg-red-900/30 text-red-400":"bg-yellow-900/30 text-yellow-400"}`,children:c}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>d(a.id,"helpful"),className:"text-xs px-2 py-1 rounded bg-green-900/20 text-green-400 hover:bg-green-900/40",children:"Helpful"}),e.jsx("button",{onClick:()=>d(a.id,"unhelpful"),className:"text-xs px-2 py-1 rounded bg-red-900/20 text-red-400 hover:bg-red-900/40",children:"Unhelpful"}),e.jsx("button",{onClick:()=>d(a.id,"outdated"),className:"text-xs px-2 py-1 rounded bg-yellow-900/20 text-yellow-400 hover:bg-yellow-900/40",children:"Outdated"})]})})]},a.id)}),l.length===0&&e.jsx("div",{className:"text-zinc-500 text-sm p-4 text-center",children:"No knowledge documents yet"})]})}function R(){const[l,m]=t.useState("memories");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex gap-1 p-2 border-b border-zinc-700 shrink-0",children:[{id:"memories",label:"Memories"},{id:"knowledge",label:"Knowledge Store"},{id:"export",label:"Export / Import"}].map(r=>e.jsx("button",{onClick:()=>m(r.id),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${l===r.id?"bg-blue-600/20 text-blue-400":"text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200"}`,children:r.label},r.id))}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[l==="knowledge"&&e.jsx("div",{className:"p-4",children:e.jsx(C,{})}),l==="export"&&e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(E,{}),e.jsxs("div",{className:"border-t border-zinc-700 pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-zinc-200 mb-3",children:"Knowledge Feedback"}),e.jsx(L,{})]})]}),l==="memories"&&e.jsx(D,{})]})]})}function D(){const[l,m]=t.useState([]),[r,i]=t.useState(null),[o,x]=t.useState(null),[n,d]=t.useState(!0),[a,c]=t.useState(!1),[h,g]=t.useState(new Map),p=t.useCallback(async()=>{try{d(!0);const u=await b.getMemories().catch(()=>[]);m(u)}catch(u){x(u instanceof Error?u.message:"Failed to load")}finally{d(!1)}},[]);t.useEffect(()=>{p()},[p]);const j=t.useCallback(async u=>{i(u);const f=h.get(u.name);if(f!==void 0){i({...u,content:f});return}try{c(!0);const s=await b.readMemory(u.name);g(N=>{const v=new Map(N);return v.set(u.name,s.content),v}),i({...u,content:s.content})}catch{i({...u,content:"[Failed to load content]"})}finally{c(!1)}},[h]);return n?e.jsxs("div",{className:"h-full flex",children:[e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt p-2 space-y-2",children:[e.jsx("div",{className:"h-4 w-16 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-6 w-full rounded bg-surface animate-pulse"}),Array.from({length:6}).map((u,f)=>e.jsx("div",{className:"h-4 rounded bg-surface animate-pulse",style:{width:`${50+Math.random()*40}%`,marginLeft:`${f%3*12}px`}},f))]}),e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Loading memories..."})]}):o?e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",o]}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Memories"}),e.jsx(F,{label:"Memories",active:l.length>0}),e.jsxs("span",{className:"text-[10px] text-muted",children:[l.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(P,{memories:l,selectedMemory:r,onSelect:j}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(M,{selectedMemory:r,contentLoading:a})})]})]})}function F({label:l,active:m}){const r=m?"var(--color-success)":"var(--color-text-muted)",i=m?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${r}20`,color:r},children:[l,": ",i]})}function P({memories:l,selectedMemory:m,onSelect:r}){const[i,o]=t.useState(""),[x,n]=t.useState(!1),[d,a]=t.useState(new Set),c=t.useMemo(()=>{if(!i.trim())return l;const p=i.toLowerCase();return l.filter(j=>j.name.toLowerCase().includes(p))},[l,i]),h=t.useMemo(()=>z(c),[c]),g=t.useCallback(p=>{a(j=>{const u=new Set(j);return u.has(p)?u.delete(p):u.add(p),u})},[]);return x?e.jsx("div",{className:"w-8 border-r border-edge bg-surface-alt flex flex-col items-center pt-2",children:e.jsx("button",{onClick:()=>n(!1),className:"text-[10px] text-muted hover:text-foreground rotate-90",title:"Expand file explorer",children:"Files"})}):e.jsxs("div",{className:"w-64 border-r border-edge bg-surface-alt flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-edge",children:[e.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Files"}),e.jsx("button",{onClick:()=>n(!0),className:"text-[10px] text-muted hover:text-foreground",title:"Collapse",children:"✕"})]}),e.jsx("div",{className:"px-2 py-1.5 border-b border-edge",children:e.jsx("input",{type:"text",value:i,onChange:p=>o(p.target.value),placeholder:"Search files...",className:"w-full text-[11px] px-2 py-1 rounded bg-surface border border-edge focus:outline-none focus:border-accent"})}),e.jsx("div",{className:"flex-1 overflow-y-auto text-[11px]",children:l.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-muted",children:"No memories"}):e.jsx(k,{nodes:h,depth:0,expandedPaths:d,onToggle:g,selectedMemory:m,onSelect:r})})]})}function k({nodes:l,depth:m,expandedPaths:r,onToggle:i,selectedMemory:o,onSelect:x}){return e.jsx(e.Fragment,{children:l.map(n=>{const d=n.children.length>0,a=r.has(n.path),c=n.memory!=null&&(o==null?void 0:o.name)===n.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{d&&i(n.path),n.memory&&x(n.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-surface-elevated transition-colors cursor-pointer ${c?"bg-accent15 text-accent":"text-foreground"}`,style:{paddingLeft:`${m*12+8}px`},children:[d?e.jsx("span",{className:"w-3 text-[9px] text-muted",children:a?"▾":"▸"}):e.jsx("span",{className:"w-3 text-[9px] text-muted",children:"·"}),e.jsx("span",{className:"truncate",children:n.name})]}),d&&a&&e.jsx(k,{nodes:n.children,depth:m+1,expandedPaths:r,onToggle:i,selectedMemory:o,onSelect:x})]},n.path)})})}function M({selectedMemory:l,contentLoading:m}){const[r,i]=t.useState(!1);if(!l)return e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm mb-1",children:"Select a memory from the explorer"}),e.jsx("p",{className:"text-xs text-muted/60",children:"Project memories appear as navigable files"})]})});const o=()=>{navigator.clipboard.writeText(l.content),i(!0),setTimeout(()=>i(!1),2e3)},x=l.name.split("/");return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 text-[10px] text-muted",children:[e.jsx("span",{children:"memories"}),x.map((n,d)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"/"}),e.jsx("span",{className:d===x.length-1?"text-foreground font-medium":"",children:n})]},d))]}),e.jsxs("div",{className:"flex items-center justify-between mb-3 pb-2 border-b border-edge",children:[e.jsx("span",{className:"text-sm font-semibold",children:x[x.length-1]}),e.jsx("button",{onClick:o,disabled:m,className:`text-[10px] px-2 py-0.5 rounded border transition-all cursor-pointer ${r?"border-green-500/30 text-green-500 bg-green-500/5":"border-edge text-muted hover:text-foreground"}`,children:r?"Copied!":"Copy"})]}),m?e.jsx("div",{className:"space-y-2",children:Array.from({length:8}).map((n,d)=>e.jsx("div",{className:"h-3 rounded bg-surface animate-pulse",style:{width:`${40+Math.random()*50}%`}},d))}):e.jsx("pre",{className:"text-xs whitespace-pre-wrap text-muted font-mono leading-relaxed",children:l.content})]})}export{R as MemoriesTab};
|
package/dist/web/dashboard/dist/assets/{prd-backlog-tab-5PCpKm0j.js → prd-backlog-tab-M1j0tAm2.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./index-
|
|
1
|
+
import{r as c,j as e}from"./index-CIhDR5rf.js";import{R as _,u as M,a as E,b as P,i as T,B,C as D}from"./style-UgkJJqFQ.js";import{S as w}from"./constants-Dd6A34aQ.js";import{b as R,g as F,t as $,c as z,d as A,W as I,e as L,N as O}from"./graph-utils-1O2cEKuy.js";import"./index-B5DzSMGg.js";import"./index-CSeiGgX8.js";const V=c.memo(function({graph:d,onNodeClick:N}){const{groups:m,nextTask:f,nodeMap:j}=c.useMemo(()=>{const r=d.nodes.filter(s=>s.type==="task"||s.type==="subtask"),x=new Map(d.nodes.map(s=>[s.id,s])),p=new Set(d.nodes.filter(s=>s.status==="done").map(s=>s.id)),h=r.filter(s=>s.status!=="backlog"&&s.status!=="ready"||s.blocked?!1:d.edges.filter(a=>a.from===s.id&&a.relationType==="depends_on").every(a=>p.has(a.to)));h.sort((s,t)=>s.priority-t.priority);const i=new Map;for(const s of r){const t=s.parentId||"__root__";i.has(t)||i.set(t,[]),i.get(t).push(s)}for(const s of i.values())s.sort((t,a)=>t.priority-a.priority);return{groups:i,nextTask:h[0]||null,nodeMap:x}},[d]);return d.nodes.filter(r=>r.type==="task"||r.type==="subtask").length===0?e.jsx("div",{className:"p-4 text-center text-muted",children:"No tasks in backlog."}):e.jsxs("div",{className:"p-2",children:[f&&e.jsxs("div",{className:"mb-3 px-3 py-2 bg-accent10 border border-accent rounded-lg",children:[e.jsx("span",{className:"text-xs font-medium text-accent",children:"Next:"})," ",e.jsx("span",{className:"text-sm font-semibold",children:f.title})]}),Array.from(m.entries()).map(([r,x])=>{const p=r!=="__root__"?j.get(r):null,h=p?p.title:"Ungrouped Tasks",i=x.filter(t=>t.status==="done").length,s=Math.round(i/x.length*100);return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[e.jsx("h4",{className:"text-xs font-semibold truncate",children:h}),e.jsxs("span",{className:"text-[10px] text-muted",children:[i,"/",x.length]})]}),e.jsx("div",{className:"h-1 mx-2 mb-1 bg-surface-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${s}%`,background:w.done}})}),x.map(t=>{const a=(f==null?void 0:f.id)===t.id,v=w[t.status]||"#9e9e9e",y=d.edges.filter(l=>l.from===t.id&&l.relationType==="depends_on").map(l=>{var n;return((n=j.get(l.to))==null?void 0:n.title)||l.to});return e.jsxs("div",{onClick:()=>N(t),className:`mx-1 mb-1 px-2 py-1.5 rounded cursor-pointer hover:bg-surface-elevated transition-colors ${a?"ring-1 ring-accent":""}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded font-medium shrink-0",style:{background:`${v}20`,color:v},children:t.status.replace("_"," ")}),e.jsx("span",{className:"text-xs truncate flex-1",children:t.title}),e.jsxs("span",{className:"text-[10px] text-muted",children:["P",t.priority]}),t.xpSize&&e.jsx("span",{className:"text-[10px] text-muted",children:t.xpSize})]}),y.length>0&&e.jsxs("div",{className:"text-[10px] text-muted mt-0.5 truncate pl-1",children:["Depends on: ",y.join(", ")]})]},t.id)})]},r)})]})}),W={workflowNode:L},U={workflowEdge:I},Z={hideAttribution:!0};function G({graph:o}){const[d,N,m]=M([]),[f,j,r]=E([]),[x,p]=c.useState(null),[h,i]=c.useState(new Set),s=c.useRef(!0),{fitView:t}=P(),a=c.useMemo(()=>R(o.nodes,o.edges),[o.nodes,o.edges]),v=c.useCallback(n=>{i(u=>{const b=new Set(u);return b.has(n)?b.delete(n):b.add(n),b})},[]);c.useEffect(()=>{const n=F(o.nodes,h,a),u=$(n,void 0,a,h,v),b=new Set(u.map(S=>S.id)),k=z(o.edges,b),g=A(u,k,"TB");N(g.nodes),j(g.edges),s.current?s.current=!1:setTimeout(()=>t({duration:300}),50)},[o,N,j,h,a,v,t]);const C=c.useCallback((n,u)=>{p(u.data.sourceNode)},[]),y=c.useCallback(n=>{p(n)},[]),l=c.useMemo(()=>{const n=o.nodes.length,u=o.nodes.filter(g=>g.status==="done").length,b=o.nodes.filter(g=>g.status==="in_progress").length,k=o.nodes.filter(g=>g.status==="blocked").length;return{total:n,done:u,inProgress:b,blocked:k,pctDone:n?Math.round(u/n*100):0}},[o.nodes]);return e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-3 py-1.5 bg-surface-alt border-b border-edge flex items-center gap-2 text-xs relative z-10",children:e.jsxs("span",{className:"text-muted",children:["Showing ",d.length," of ",o.nodes.length," nodes — click ▶ to expand"]})}),o.nodes.length>0?e.jsxs(T,{nodes:d,edges:f,onNodesChange:m,onEdgesChange:r,onNodeClick:C,nodeTypes:W,edgeTypes:U,nodesDraggable:!1,nodesConnectable:!1,fitView:!0,minZoom:.1,maxZoom:2,proOptions:Z,children:[e.jsx(B,{gap:16,size:1}),e.jsx(D,{showInteractive:!1})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Import a PRD to see the workflow"})]}),e.jsxs("div",{className:"w-96 border-l border-edge flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge bg-surface-alt",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{children:[l.done,"/",l.total," done (",l.pctDone,"%)"]}),e.jsxs("span",{className:"text-muted",children:[l.inProgress," in progress, ",l.blocked," blocked"]})]}),e.jsxs("div",{className:"h-2 bg-surface-elevated rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full transition-all",style:{width:`${l.pctDone}%`,background:w.done}}),e.jsx("div",{className:"h-full transition-all",style:{width:`${l.total?Math.round(l.inProgress/l.total*100):0}%`,background:w.in_progress}})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(V,{graph:o,onNodeClick:y})})]}),x&&e.jsx(O,{node:x,onClose:()=>p(null)})]})}function Y({graph:o,loading:d,error:N,onRetry:m}){return d||!o?e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-3 py-1.5 bg-surface-alt border-b border-edge",children:e.jsx("div",{className:"h-3 w-48 rounded bg-surface animate-pulse"})}),e.jsx("div",{className:"flex-1 bg-surface-alt animate-pulse"})]}),e.jsxs("div",{className:"w-96 border-l border-edge flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge bg-surface-alt space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{className:"h-4 w-28 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"h-4 w-40 rounded bg-surface animate-pulse"})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface animate-pulse"})]}),e.jsx("div",{className:"flex-1 p-3 space-y-3",children:Array.from({length:6}).map((f,j)=>e.jsx("div",{className:"h-14 rounded-lg border border-edge bg-surface-alt animate-pulse"},j))})]})]}):N?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Failed to load PRD & Backlog"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:N})]}),m&&e.jsx("button",{type:"button",onClick:m,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-md border border-edge text-muted hover:text-foreground transition-colors cursor-pointer",children:"Retry"})]}):o?e.jsx(_,{children:e.jsx(G,{graph:o})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted",children:[e.jsx("p",{className:"text-xs",children:"No graph data available"}),m&&e.jsx("button",{type:"button",onClick:m,className:"text-xs px-3 py-1.5 rounded border border-edge hover:text-foreground transition-colors cursor-pointer",children:"Retry"})]})}export{Y as PrdBacklogTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-
|
|
2
|
-
import{r as s,j as e,a as S,_ as L}from"./index-Dbaws8C6.js";import{e as k}from"./constants-Dd6A34aQ.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/graph-section-DKMay1zv.js","assets/index-CIhDR5rf.js","assets/index-BxDGbcbB.css","assets/style-UgkJJqFQ.js","assets/index-B5DzSMGg.js","assets/style-BZV40eAE.css","assets/constants-Dd6A34aQ.js","assets/index-CSeiGgX8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,j as e,a as S,_ as L}from"./index-CIhDR5rf.js";import{e as k}from"./constants-Dd6A34aQ.js";const D=[{id:"upload",label:"Upload",icon:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"},{id:"objects",label:"Objects",icon:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 010 3.75H5.625a1.875 1.875 0 010-3.75z"},{id:"graph",label:"Graph",icon:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"},{id:"generation",label:"Generation",icon:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"}],T=s.memo(function({activeSection:t,onSectionChange:a,objectCount:d}){return e.jsxs("nav",{className:"w-48 flex-shrink-0 border-r border-edge bg-surface-alt flex flex-col","aria-label":"Siebel sections",children:[e.jsx("div",{className:"px-3 py-3 border-b border-edge",children:e.jsx("h2",{className:"text-xs font-semibold uppercase text-muted tracking-wider",children:"Siebel"})}),e.jsx("div",{className:"flex-1 py-1",children:D.map(u=>e.jsxs("button",{onClick:()=>a(u.id),"aria-label":`Navigate to ${u.label}`,className:`w-full flex items-center gap-2.5 px-3 py-2 text-xs font-medium transition-colors cursor-pointer ${t===u.id?"bg-accent/10 text-accent border-r-2 border-accent":"text-muted hover:text-foreground hover:bg-surface"}`,children:[e.jsx("svg",{className:"w-4 h-4 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:u.icon})}),e.jsx("span",{children:u.label}),u.id==="objects"&&d>0&&e.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded-full bg-surface text-muted",children:d})]},u.id))})]})});function E(){const[o,t]=s.useState([]),[a,d]=s.useState([]),[u,x]=s.useState(!0),[b,h]=s.useState(null),c=s.useCallback(async()=>{try{x(!0),h(null);const[m,l]=await Promise.all([S.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),S.siebelGetTemplates().catch(()=>({templates:[]}))]);t(m.objects),d(l.templates)}catch(m){h(m instanceof Error?m.message:"Failed to load Siebel data")}finally{x(!1)}},[]);return s.useEffect(()=>{c()},[c]),{objects:o,templates:a,loading:u,error:b,refresh:c}}function P(o){const[t,a]=s.useState(""),[d,u]=s.useState(["business_component"]),[x,b]=s.useState(""),[h,c]=s.useState(null),[m,l]=s.useState(""),[n,i]=s.useState(null),[g,v]=s.useState(!1),N=s.useCallback(f=>{u(y=>y.includes(f)?y.filter(w=>w!==f):[...y,f])},[]),j=s.useCallback(async()=>{if(t.trim()){v(!0),i(null);try{const f=await S.siebelPrepareGeneration({description:t,objectTypes:d,basedOnProject:x||void 0});c(f.prompt)}catch(f){c(`Error: ${f instanceof Error?f.message:String(f)}`)}finally{v(!1)}}},[t,d,x]),r=s.useCallback(async()=>{if(m.trim()){v(!0);try{const f=await S.siebelFinalizeGeneration({generatedXml:m,description:t,objectTypes:d});i(f),o==null||o()}catch(f){i({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:f instanceof Error?f.message:String(f)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:t,objectCount:0}})}finally{v(!1)}}},[m,t,d,o]),p=s.useCallback(()=>{if(!(n!=null&&n.sifContent))return;const f=new Blob([n.sifContent],{type:"application/xml"}),y=URL.createObjectURL(f),w=document.createElement("a");w.href=y,w.download="generated.sif",w.click(),URL.revokeObjectURL(y)},[n]);return{description:t,setDescription:a,selectedTypes:d,toggleType:N,project:x,setProject:b,prompt:h,xml:m,setXml:l,result:n,loading:g,prepare:j,finalize:r,download:p}}function I(){const[o,t]=s.useState(null),[a,d]=s.useState(0),[u,x]=s.useState("idle"),[b,h]=s.useState(null),c=s.useRef(null);s.useEffect(()=>()=>{var n;(n=c.current)==null||n.terminate()},[]);const m=s.useCallback(n=>{t(null),h(null),d(0),x("reading"),n.text().then(i=>{var v;d(10),x("parsing"),(v=c.current)==null||v.terminate();const g=new Worker(new URL("/assets/sif-parse.worker-DZrybOHz.js",import.meta.url),{type:"module"});c.current=g,g.onmessage=N=>{const j=N.data;j.type==="progress"?(d(j.progress),x(j.status)):j.type==="result"?(t(j.data),x("done"),d(100),g.terminate(),c.current=null):j.type==="error"&&(h(j.message),x("error"),g.terminate(),c.current=null)},g.onerror=N=>{h(N.message||"Worker error"),x("error"),g.terminate(),c.current=null},g.postMessage({type:"parse",content:i,fileName:n.name})}).catch(i=>{h(i instanceof Error?i.message:"Failed to read file"),x("error")})},[]),l=s.useCallback(()=>{var n;(n=c.current)==null||n.terminate(),c.current=null,t(null),d(0),x("idle"),h(null)},[]);return{parse:m,result:o,progress:a,status:u,error:b,reset:l}}const F={idle:"",reading:"Reading file...",parsing:"Parsing XML...",extracting:"Extracting objects...",inferring:"Inferring dependencies...",done:"Done!",error:"Error"},R=s.memo(function({status:t,progress:a,error:d}){if(t==="idle")return null;const u=t==="error",x=t==="done";return e.jsxs("div",{className:"space-y-1.5",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:u?"text-red-500":x?"text-green-500":"text-muted",children:u?d:F[t]}),!u&&e.jsxs("span",{className:"text-[10px] text-muted",children:[a,"%"]})]}),!u&&e.jsx("div",{className:"h-1.5 rounded-full bg-surface overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-300 ${x?"bg-green-500":"bg-accent"}`,style:{width:`${a}%`}})})]})});function $({onUploaded:o}){const[t,a]=s.useState(null),[d,u]=s.useState(!1),[x,b]=s.useState(!1),h=s.useRef(null),c=s.useRef(null),m=I();s.useEffect(()=>{if(m.status!=="done"||!m.result)return;const r=m.result.metadata.fileName;(async()=>{try{l.current&&(await S.siebelImportSif(l.current,r,!0),l.current=null,o())}catch{}})()},[m.status,m.result,o]);const l=s.useRef(null),n=s.useCallback(r=>{r.text().then(p=>{l.current=p,m.parse(r)}).catch(()=>{(async()=>{try{const p=await r.text();await S.siebelImportSif(p,r.name,!0),o()}catch{}})()})},[m,o]),i=s.useCallback(async r=>{try{a("Uploading documentation...");const p=await S.siebelUploadDocs(r);a(`Indexed: ${p.fileName} (${p.chunksIndexed} chunks)`),o()}catch(p){a(`Error: ${p instanceof Error?p.message:String(p)}`)}},[o]),g=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&n(p),h.current&&(h.current.value="")},[n]),v=s.useCallback(r=>{var f;const p=(f=r.target.files)==null?void 0:f[0];p&&i(p),c.current&&(c.current.value="")},[i]),N=s.useCallback((r,p,f)=>{r.preventDefault(),f(!1);const y=r.dataTransfer.files[0];y&&p(y)},[]),j=s.useCallback(r=>{r.preventDefault(),r.stopPropagation()},[]);return e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-muted",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${d?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),u(!0)},onDragOver:r=>{j(r),u(!0)},onDragLeave:r=>{j(r),u(!1)},onDrop:r=>N(r,n,u),onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=h.current)==null||p.click())},"aria-label":"Upload SIF file",children:[e.jsx("input",{ref:h,type:"file",accept:".sif,.xml",onChange:g,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m6.75 12l-3-3m0 0l-3 3m3-3v6m-1.5-15H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),e.jsx("p",{className:"text-xs font-medium",children:"SIF File (.sif, .xml)"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"Drop here or click to browse"})]}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors cursor-pointer ${x?"border-accent bg-accent/5":"border-edge hover:border-accent/50"}`,onDragEnter:r=>{j(r),b(!0)},onDragOver:r=>{j(r),b(!0)},onDragLeave:r=>{j(r),b(!1)},onDrop:r=>N(r,i,b),onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},role:"button",tabIndex:0,onKeyDown:r=>{var p;(r.key==="Enter"||r.key===" ")&&((p=c.current)==null||p.click())},"aria-label":"Upload documentation file",children:[e.jsx("input",{ref:c,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:v,className:"hidden",tabIndex:-1}),e.jsx("svg",{className:"w-8 h-8 mx-auto mb-2 text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-xs font-medium",children:"Documentation"}),e.jsx("p",{className:"text-[10px] text-muted mt-1",children:"PDF, HTML, DOC, DOCX, TXT, MD"})]})]}),m.status!=="idle"&&e.jsx(R,{status:m.status,progress:m.progress,error:m.error}),t&&e.jsx("div",{className:`px-3 py-2 rounded-md text-xs ${t.startsWith("Error")?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-500"}`,role:"status","aria-live":"polite",children:t})]})}const C=36;function M({objects:o}){const[t,a]=s.useState(""),[d,u]=s.useState(new Set),x=s.useDeferredValue(t),b=s.useDeferredValue(d),h=s.useMemo(()=>{const l=new Set;for(const n of o)n.siebelType&&l.add(n.siebelType);return[...l].sort()},[o]),c=s.useMemo(()=>{let l=o;if(x){const n=x.toLowerCase();l=l.filter(i=>{var g;return i.title.toLowerCase().includes(n)||((g=i.siebelProject)==null?void 0:g.toLowerCase().includes(n))||i.contentPreview.toLowerCase().includes(n)})}return b.size>0&&(l=l.filter(n=>n.siebelType&&b.has(n.siebelType))),l},[o,x,b]),m=l=>{u(n=>{const i=new Set(n);return i.has(l)?i.delete(l):i.add(l),i})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"p-4 space-y-3 border-b border-edge",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-muted",children:[c.length,c.length!==o.length?` / ${o.length}`:""," objects"]})]})}),e.jsx("input",{type:"text",value:t,onChange:l=>a(l.target.value),placeholder:"Search objects...","aria-label":"Search Siebel objects",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),h.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:h.map(l=>{const n=k[l]||"#6b7280",i=d.has(l);return e.jsx("button",{onClick:()=>m(l),"aria-label":`Filter by ${l}`,"aria-pressed":i,className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:i?n:"var(--color-border)",backgroundColor:i?`${n}15`:"transparent",color:i?n:"var(--color-text-muted)"},children:l.replace(/_/g," ")},l)})})]}),c.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-muted",children:o.length===0?"No Siebel objects indexed yet. Upload a .sif file.":"No objects match the current filters."}):e.jsx("div",{className:"flex-1 overflow-auto",style:{contentVisibility:"auto",containIntrinsicSize:`0 ${c.length*C}px`},children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-alt z-10",children:e.jsxs("tr",{className:"border-b border-edge",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Project"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Preview"})]})}),e.jsx("tbody",{children:c.map((l,n)=>{const i=k[l.siebelType??""]||"#6b7280";return e.jsxs("tr",{className:"border-b border-edge hover:bg-surface transition-colors",style:{height:C},children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:l.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px]",style:{backgroundColor:`${i}15`,color:i},children:l.siebelType??l.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-muted",children:l.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-muted truncate max-w-xs",children:l.contentPreview})]},n)})})]})})]})}function O({templates:o,gen:t}){return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-muted",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-description",children:"Description"}),e.jsx("textarea",{id:"gen-description",value:t.description,onChange:a=>t.setDescription(a.target.value),placeholder:"e.g., Create a Business Component for Service Requests with fields: SR Number, Status, Priority",rows:3,className:"w-full px-3 py-2 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Object Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.map(a=>e.jsx("button",{onClick:()=>t.toggleType(a.type),"aria-label":`Toggle ${a.type}`,"aria-pressed":t.selectedTypes.includes(a.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors cursor-pointer ${t.selectedTypes.includes(a.type)?"bg-accent text-white border-accent":"bg-transparent text-muted border-edge hover:border-accent"}`,children:a.type.replace(/_/g," ")},a.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-project",children:"Base Project (optional)"}),e.jsx("input",{id:"gen-project",value:t.project,onChange:a=>t.setProject(a.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"})]}),e.jsx("button",{onClick:t.prepare,disabled:!t.description.trim()||t.loading,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading&&!t.prompt?"Generating Context...":"Generate Context & Prompt"}),t.prompt&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-xs font-medium",children:"Generated Prompt (copy to LLM)"}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(t.prompt??""),"aria-label":"Copy prompt to clipboard",className:"text-[10px] px-2 py-0.5 rounded bg-surface text-muted hover:text-foreground border border-edge cursor-pointer transition-colors",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-surface border border-edge max-h-48 overflow-auto whitespace-pre-wrap text-muted",children:[t.prompt.slice(0,3e3),t.prompt.length>3e3&&`
|
|
3
3
|
|
|
4
|
-
... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-
|
|
4
|
+
... (truncated for display)`]})]}),t.prompt&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",htmlFor:"gen-xml",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{id:"gen-xml",value:t.xml,onChange:a=>t.setXml(a.target.value),placeholder:'Paste the XML output from the LLM here (starting with <?xml version="1.0"...)',rows:8,className:"w-full px-3 py-2 text-xs font-mono rounded-md border border-edge bg-surface text-foreground placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-accent"}),e.jsx("button",{onClick:t.finalize,disabled:!t.xml.trim()||t.loading,className:"mt-2 px-4 py-1.5 text-xs font-medium rounded-md bg-green-600 text-white hover:opacity-90 disabled:opacity-50 transition-opacity cursor-pointer disabled:cursor-not-allowed",children:t.loading?"Validating...":"Validate & Finalize"})]}),t.result&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${t.result.validation.status==="valid"?"border-green-500/30 bg-green-500/5":t.result.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,role:"status",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-bold ${t.result.validation.status==="valid"?"text-green-500":t.result.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:t.result.validation.status==="valid"?"Valid":t.result.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-muted",children:["Score: ",t.result.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-muted",children:[t.result.metadata.objectCount," objects"]})]}),t.result.validation.status!=="invalid"&&e.jsx("button",{onClick:t.download,"aria-label":"Download generated SIF file",className:"px-3 py-1 text-xs font-medium rounded-md bg-accent text-white hover:opacity-90 cursor-pointer transition-opacity",children:"Download SIF"})]}),t.result.objects.length>0&&e.jsxs("div",{className:"text-xs text-muted",children:["Objects: ",t.result.objects.map(a=>`${a.type}:${a.name}`).join(", ")]}),t.result.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:t.result.validation.messages.map((a,d)=>e.jsxs("li",{className:`text-[10px] ${a.level==="error"?"text-red-500":a.level==="warning"?"text-yellow-600":"text-muted"}`,children:["[",a.level,"] ",a.message,a.objectName&&` (${a.objectName})`]},d))})]})]})})}const G=s.lazy(()=>L(()=>import("./graph-section-DKMay1zv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(o=>({default:o.GraphSection})));function A(){return e.jsx("div",{className:"flex items-center justify-center h-full text-muted text-xs",children:"Loading..."})}function U(){const[o,t]=s.useState("upload"),{objects:a,templates:d,loading:u,error:x,refresh:b}=E(),h=P(b),[c,m]=s.useState([]),[l,n]=s.useState([]),i=s.useCallback(async()=>{try{const v=await S.siebelGetGraph();m(v.objects),n(v.dependencies)}catch{}},[]);s.useEffect(()=>{i()},[i]);const g=s.useCallback(()=>{b(),i()},[b,i]);return u?e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading Siebel..."}):x?e.jsx("div",{className:"flex items-center justify-center h-full text-danger",children:x}):e.jsxs("div",{className:"h-full flex",children:[e.jsx(T,{activeSection:o,onSectionChange:t,objectCount:a.length}),e.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden",children:[o==="upload"&&e.jsx($,{onUploaded:g}),o==="objects"&&e.jsx(M,{objects:a}),o==="graph"&&e.jsx(s.Suspense,{fallback:e.jsx(A,{}),children:e.jsx(G,{objects:c,dependencies:l})}),o==="generation"&&e.jsx(O,{templates:d,gen:h})]})]})}export{U as SiebelTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,a as k,j as e}from"./index-Dbaws8C6.js";import{P,L as B}from"./constants-Dd6A34aQ.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};
|
|
1
|
+
import{r as l,a as k,j as e}from"./index-CIhDR5rf.js";import{P,L as B}from"./constants-Dd6A34aQ.js";function $(){const[t,s]=l.useState([]),[u,n]=l.useState([]),[i,c]=l.useState(0),[x,b]=l.useState(!0),[h,f]=l.useState(null),d=l.useCallback(async()=>{b(!0),f(null);try{const[r,m]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(r.skills),c(r.totalTokens),n(m.recommendations)}catch(r){f(r instanceof Error?r.message:"Failed to load skills")}finally{b(!1)}},[]);l.useEffect(()=>{d()},[d]);const N=l.useCallback(async(r,m)=>{s(C=>C.map(w=>w.name===r?{...w,enabled:m}:w));try{await k.toggleSkill(r,m)}catch{d()}},[d]),p=l.useCallback(async r=>{await k.createCustomSkill(r),d()},[d]),y=l.useCallback(async(r,m)=>{await k.updateCustomSkill(r,m),d()},[d]),j=l.useCallback(async r=>{await k.deleteCustomSkill(r),d()},[d]),g=t.filter(r=>r.enabled).reduce((r,m)=>r+m.estimatedTokens,0);return{skills:t,recommendations:u,totalTokens:i,activeTokens:g,loading:x,error:h,refresh:d,toggleSkill:N,createSkill:p,updateSkill:y,deleteSkill:j}}function D({skill:t,onClose:s,onToggle:u,onDelete:n,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:c=>{c.target===c.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold truncate",children:t.name}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-muted mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${t.source==="built-in"?"bg-blue-500/10 text-blue-500":t.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-gray-500/10 text-gray-500"}`,children:t.source}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-edge text-muted",children:[t.estimatedTokens.toLocaleString()," tokens"]})]}),t.phases&&t.phases.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:t.phases.map(c=>{const x=P[c]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${x}20`,color:x},children:c},c)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:c=>u(t.name,c.target.checked),className:"w-4 h-4 accent-accent"}),t.enabled?"Enabled":"Disabled"]})}),t.source==="custom"&&e.jsxs("div",{className:"flex gap-2",children:[i&&e.jsx("button",{onClick:()=>i(t),className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Edit"}),n&&t.id&&e.jsx("button",{onClick:()=>n(t.id),className:"px-3 py-1.5 text-sm text-red-500 border border-red-500/30 rounded hover:bg-red-500/10",children:"Delete"})]})]})}):null}const _=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function F({open:t,onClose:s,onSubmit:u,editSkill:n}){const[i,c]=l.useState(""),[x,b]=l.useState(""),[h,f]=l.useState("know-me"),[d,N]=l.useState(["IMPLEMENT"]),[p,y]=l.useState(""),[j,g]=l.useState(!1),[r,m]=l.useState(null);l.useEffect(()=>{n?(c(n.name),b(n.description),f(n.category),N(n.phases??["IMPLEMENT"]),y("")):(c(""),b(""),f("know-me"),N(["IMPLEMENT"]),y("")),m(null)},[n,t]);const C=l.useCallback(a=>{N(S=>S.includes(a)?S.filter(T=>T!==a):[...S,a])},[]),w=l.useCallback(async()=>{if(!i.trim()||!x.trim()||!p.trim()||d.length===0){m("All fields are required and at least one phase must be selected.");return}g(!0),m(null);try{await u({name:i.trim(),description:x.trim(),category:h,phases:d,instructions:p.trim()}),s()}catch(a){m(a instanceof Error?a.message:"Failed to save skill")}finally{g(!1)}},[i,x,h,d,p,u,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{className:"bg-surface rounded-lg shadow-xl w-full max-w-lg p-6 max-h-[85vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:n?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-muted hover:text-foreground text-xl",children:"×"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:a=>c(a.target.value),placeholder:"my-workflow",disabled:!!n,className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Description"}),e.jsx("input",{type:"text",value:x,onChange:a=>b(a.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Category"}),e.jsx("select",{value:h,onChange:a=>f(a.target.value),className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(a=>e.jsx("button",{type:"button",onClick:()=>C(a),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(a)?"bg-accent/10 border-accent text-accent":"border-edge text-muted hover:border-foreground"}`,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:a=>y(a.target.value),rows:6,placeholder:"Instructions for the AI agent when this skill is active...",className:"w-full px-3 py-2 text-sm rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt resize-y"})]}),r&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:r}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm border border-edge rounded hover:bg-surface-elevated",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:j,className:"px-3 py-1.5 text-sm bg-accent text-white rounded hover:opacity-90 disabled:opacity-50",children:j?"Saving...":n?"Update":"Create"})]})]})]})}):null}const I=4e3;function E({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:s})]})}function z({phase:t}){const s=P[t]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${s}20`,color:s},children:t})}function G({source:t}){const s={"built-in":"bg-accent/10 text-accent",filesystem:"bg-muted/10 text-muted",custom:"bg-purple-500/10 text-purple-500"};return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${s[t]}`,children:t})}function H({skill:t,onToggle:s,onClick:u}){return e.jsxs("div",{className:`p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt cursor-pointer hover:border-accent/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>u(t),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:t.name}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>{n.stopPropagation(),s(t.name,n.target.checked)},onClick:n=>n.stopPropagation(),className:"w-3.5 h-3.5 accent-accent"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-muted",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-muted line-clamp-2",children:t.description})]})}function A({phase:t,skills:s,onToggle:u,onSkillClick:n}){const[i,c]=l.useState(!0),x=P[t]??"#6b7280",b=s.filter(h=>h.enabled).length;return e.jsxs("div",{className:"rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:x}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-edge text-[10px]",children:[b,"/",s.length]})]}),e.jsx("span",{className:"text-muted",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(h=>e.jsx(H,{skill:h,onToggle:u,onClick:n},h.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-surface-alt border border-accent/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:t.skill}),e.jsx(z,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-muted",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const u=Math.min(s/I,1),n=Math.min(t/I,1),i=Math.round(u*100),c=u>.8?"#ef4444":u>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(n*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:c}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:u,activeTokens:n,loading:i,error:c,refresh:x,toggleSkill:b,createSkill:h,updateSkill:f,deleteSkill:d}=$(),[N,p]=l.useState(null),[y,j]=l.useState(!1),[g,r]=l.useState(null),m=l.useCallback(async o=>{await d(o),p(null)},[d]),C=l.useCallback(o=>{p(null),r(o),j(!0)},[]),w=l.useCallback(async o=>{g!=null&&g.id?await f(g.id,o):await h(o),r(null)},[g,h,f]);if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load skills: ",c]});if(i)return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[e.jsx("div",{className:"h-5 w-32 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:Array.from({length:5}).map((o,v)=>e.jsx("div",{className:"h-20 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))}),e.jsx("div",{className:"h-8 rounded bg-surface animate-pulse"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((o,v)=>e.jsx("div",{className:"h-16 rounded-xl border border-edge bg-surface-alt animate-pulse"},v))})]});const a=t.filter(o=>o.source==="built-in").length,S=t.filter(o=>o.source==="custom").length,T=t.filter(o=>o.enabled).length,M=new Map;for(const o of B){const v=t.filter(O=>{var R;return(R=O.phases)==null?void 0:R.includes(o)});v.length>0&&M.set(o,v)}const L=t.filter(o=>!o.phases||o.phases.length===0);return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Skills"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{r(null),j(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-accent text-accent hover:bg-accent/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void x(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3","data-testid":"skills-stats",children:[e.jsx(E,{value:t.length,label:"Total Skills"}),e.jsx(E,{value:a,label:"Built-in"}),e.jsx(E,{value:S,label:"Custom"}),e.jsx(E,{value:T,label:"Enabled"}),e.jsx(E,{value:n.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:u,activeTokens:n}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(o=>e.jsx(U,{rec:o},o.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([o,v])=>e.jsx(A,{phase:o,skills:v,onToggle:b,onSkillClick:p},o)),L.length>0&&e.jsx(A,{phase:"Other",skills:L,onToggle:b,onSkillClick:p})]}),e.jsx(D,{skill:N,onClose:()=>p(null),onToggle:b,onDelete:m,onEdit:C}),e.jsx(F,{open:y,onClose:()=>{j(!1),r(null)},onSubmit:w,editSkill:g})]})}export{Y as SkillsTab};
|