@mcp-graph-workflow/mcp-graph 5.25.0 → 5.26.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/translation-project.d.ts +8 -0
- package/dist/api/routes/translation-project.d.ts.map +1 -0
- package/dist/api/routes/translation-project.js +338 -0
- package/dist/api/routes/translation-project.js.map +1 -0
- package/dist/api/routes/translation.d.ts.map +1 -1
- package/dist/api/routes/translation.js +102 -0
- package/dist/api/routes/translation.js.map +1 -1
- package/dist/core/code/code-indexer.d.ts +2 -0
- package/dist/core/code/code-indexer.d.ts.map +1 -1
- package/dist/core/code/code-indexer.js +9 -3
- package/dist/core/code/code-indexer.js.map +1 -1
- package/dist/core/code/code-types.d.ts +4 -0
- package/dist/core/code/code-types.d.ts.map +1 -1
- package/dist/core/code/code-types.js +1 -0
- package/dist/core/code/code-types.js.map +1 -1
- package/dist/core/code/ts-analyzer.d.ts.map +1 -1
- package/dist/core/code/ts-analyzer.js +77 -6
- package/dist/core/code/ts-analyzer.js.map +1 -1
- package/dist/core/store/migrations.d.ts.map +1 -1
- package/dist/core/store/migrations.js +41 -0
- package/dist/core/store/migrations.js.map +1 -1
- package/dist/core/translation/project-translation-orchestrator.d.ts +65 -0
- package/dist/core/translation/project-translation-orchestrator.d.ts.map +1 -0
- package/dist/core/translation/project-translation-orchestrator.js +336 -0
- package/dist/core/translation/project-translation-orchestrator.js.map +1 -0
- package/dist/core/translation/translation-project-store.d.ts +40 -0
- package/dist/core/translation/translation-project-store.d.ts.map +1 -0
- package/dist/core/translation/translation-project-store.js +195 -0
- package/dist/core/translation/translation-project-store.js.map +1 -0
- package/dist/core/translation/translation-project-types.d.ts +98 -0
- package/dist/core/translation/translation-project-types.d.ts.map +1 -0
- package/dist/core/translation/translation-project-types.js +84 -0
- package/dist/core/translation/translation-project-types.js.map +1 -0
- package/dist/core/translation/zip-extractor.d.ts +4 -0
- package/dist/core/translation/zip-extractor.d.ts.map +1 -0
- package/dist/core/translation/zip-extractor.js +194 -0
- package/dist/core/translation/zip-extractor.js.map +1 -0
- package/dist/mcp/tools/reindex-knowledge.js +1 -1
- package/dist/mcp/tools/reindex-knowledge.js.map +1 -1
- package/dist/web/dashboard/dist/assets/{benchmark-tab-sjsZBd-4.js → benchmark-tab-BAfHRc8R.js} +1 -1
- package/dist/web/dashboard/dist/assets/{circle-alert-DcTbCUEa.js → circle-alert-Xp4yHA83.js} +1 -1
- package/dist/web/dashboard/dist/assets/{context-tab-DNMJ2Pv-.js → context-tab-WZWpYE4Q.js} +1 -1
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-CZ9LJbwz.js → gitnexus-tab-BL3gMYaZ.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-BdcXKKoS.js → graph-section-B-cObR6x.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-CFzux3kf.js → graph-tab-DC5Iama3.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-_8jpWA5z.js → graph-utils-CdV9peLO.js} +1 -1
- package/dist/web/dashboard/dist/assets/index-CTdsOcRa.css +1 -0
- package/dist/web/dashboard/dist/assets/{index-CITYTuX5.js → index-DfEJaZLA.js} +46 -46
- package/dist/web/dashboard/dist/assets/{index-DSI2SYWO.js → index-iWhfMJa8.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-Bny20bel.js → index-z9HSPrpH.js} +1 -1
- package/dist/web/dashboard/dist/assets/{insights-tab-DUA76KUY.js → insights-tab-Cu1cH-bN.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-FTd6jBta.js → journey-tab-BtqgC4Wj.js} +1 -1
- package/dist/web/dashboard/dist/assets/languages-tab-BeJF5wPH.js +128 -0
- package/dist/web/dashboard/dist/assets/{loader-circle-D1DpGd2u.js → loader-circle-MkZSJbxU.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-CzL36_Qy.js → logs-tab-CA2dPs0v.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-DdHhJq_H.js → lsp-tab-DuF6UV_3.js} +9 -19
- package/dist/web/dashboard/dist/assets/{memories-tab-CzgCahnV.js → memories-tab-blOtravG.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-C8Cl7swI.js → prd-backlog-tab-DtwzxFyr.js} +1 -1
- package/dist/web/dashboard/dist/assets/{refresh-cw-DSYiHmbh.js → refresh-cw-VhHh0g7N.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-B4XOaUGz.js → siebel-tab-DP6xoWD8.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-CkpnwPJY.js → skills-tab-Tspln3N1.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-BOQDk6qp.js → style-CsU39IOg.js} +1 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-ZnXg11jO.js +26 -0
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +4 -2
- package/dist/web/dashboard/dist/assets/index-CvAguK65.css +0 -1
- package/dist/web/dashboard/dist/assets/languages-tab-B_nhFL2q.js +0 -70
- package/dist/web/dashboard/dist/assets/triangle-alert-Bf6Ly19h.js +0 -16
|
@@ -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-CITYTuX5.js";import{e as k}from"./constants-lq4BIQN3.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-B-cObR6x.js","assets/index-DfEJaZLA.js","assets/index-CTdsOcRa.css","assets/style-CsU39IOg.js","assets/index-iWhfMJa8.js","assets/style-BZV40eAE.css","assets/constants-lq4BIQN3.js","assets/index-z9HSPrpH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,j as e,a as S,_ as L}from"./index-DfEJaZLA.js";import{e as k}from"./constants-lq4BIQN3.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-B-cObR6x.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-CITYTuX5.js";import{P,L as B}from"./constants-lq4BIQN3.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-DfEJaZLA.js";import{P,L as B}from"./constants-lq4BIQN3.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};
|