@mcp-graph-workflow/mcp-graph 5.6.0 → 5.7.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/README.md +2 -2
- package/dist/api/routes/code-graph.d.ts.map +1 -1
- package/dist/api/routes/code-graph.js +4 -1
- package/dist/api/routes/code-graph.js.map +1 -1
- package/dist/core/code/code-indexer.d.ts.map +1 -1
- package/dist/core/code/code-indexer.js +17 -2
- package/dist/core/code/code-indexer.js.map +1 -1
- package/dist/core/code/code-types.d.ts +1 -0
- package/dist/core/code/code-types.d.ts.map +1 -1
- package/dist/core/code/code-types.js.map +1 -1
- package/dist/core/code/ts-analyzer.d.ts +6 -0
- package/dist/core/code/ts-analyzer.d.ts.map +1 -1
- package/dist/core/code/ts-analyzer.js +9 -0
- package/dist/core/code/ts-analyzer.js.map +1 -1
- package/dist/core/importer/import-graph.d.ts +23 -0
- package/dist/core/importer/import-graph.d.ts.map +1 -0
- package/dist/core/importer/import-graph.js +127 -0
- package/dist/core/importer/import-graph.js.map +1 -0
- package/dist/core/rag/benchmark-indexer.d.ts +32 -0
- package/dist/core/rag/benchmark-indexer.d.ts.map +1 -0
- package/dist/core/rag/benchmark-indexer.js +85 -0
- package/dist/core/rag/benchmark-indexer.js.map +1 -0
- package/dist/core/rag/citation-mapper.d.ts +32 -0
- package/dist/core/rag/citation-mapper.d.ts.map +1 -0
- package/dist/core/rag/citation-mapper.js +45 -0
- package/dist/core/rag/citation-mapper.js.map +1 -0
- package/dist/core/rag/enrichment-pipeline.d.ts +48 -0
- package/dist/core/rag/enrichment-pipeline.d.ts.map +1 -0
- package/dist/core/rag/enrichment-pipeline.js +127 -0
- package/dist/core/rag/enrichment-pipeline.js.map +1 -0
- package/dist/core/rag/post-retrieval.d.ts +40 -0
- package/dist/core/rag/post-retrieval.d.ts.map +1 -0
- package/dist/core/rag/post-retrieval.js +119 -0
- package/dist/core/rag/post-retrieval.js.map +1 -0
- package/dist/core/rag/query-cache.d.ts +54 -0
- package/dist/core/rag/query-cache.d.ts.map +1 -0
- package/dist/core/rag/query-cache.js +104 -0
- package/dist/core/rag/query-cache.js.map +1 -0
- package/dist/core/rag/query-understanding.d.ts +37 -0
- package/dist/core/rag/query-understanding.d.ts.map +1 -0
- package/dist/core/rag/query-understanding.js +123 -0
- package/dist/core/rag/query-understanding.js.map +1 -0
- package/dist/core/rag/rag-trace.d.ts +67 -0
- package/dist/core/rag/rag-trace.d.ts.map +1 -0
- package/dist/core/rag/rag-trace.js +82 -0
- package/dist/core/rag/rag-trace.js.map +1 -0
- package/dist/core/rag/source-contribution.d.ts +37 -0
- package/dist/core/rag/source-contribution.d.ts.map +1 -0
- package/dist/core/rag/source-contribution.js +54 -0
- package/dist/core/rag/source-contribution.js.map +1 -0
- package/dist/core/store/sqlite-store.d.ts +9 -0
- package/dist/core/store/sqlite-store.d.ts.map +1 -1
- package/dist/core/store/sqlite-store.js +42 -0
- package/dist/core/store/sqlite-store.js.map +1 -1
- package/dist/mcp/tools/import-graph.d.ts +4 -0
- package/dist/mcp/tools/import-graph.d.ts.map +1 -0
- package/dist/mcp/tools/import-graph.js +81 -0
- package/dist/mcp/tools/import-graph.js.map +1 -0
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js +2 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/schemas/knowledge.schema.d.ts +2 -0
- package/dist/schemas/knowledge.schema.d.ts.map +1 -1
- package/dist/schemas/knowledge.schema.js +1 -0
- package/dist/schemas/knowledge.schema.js.map +1 -1
- package/dist/web/dashboard/dist/assets/{benchmark-tab-WCcv55oB.js → benchmark-tab-BoMsoQjO.js} +1 -1
- package/dist/web/dashboard/dist/assets/{context-tab-CYnMjkHN.js → context-tab-BLT4qQ77.js} +1 -1
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-Dj0DERUy.js → gitnexus-tab-DDw7DUED.js} +4 -4
- package/dist/web/dashboard/dist/assets/{graph-tab-tI93ZxxW.js → graph-tab-DG9Q6nko.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-DeQEwmsr.js → graph-utils-BpYHKE87.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-DKvjo_C5.css → index-Cu23WCcu.css} +1 -1
- package/dist/web/dashboard/dist/assets/{index-B1PLsGu1.js → index-DtkPX5ZZ.js} +2 -2
- package/dist/web/dashboard/dist/assets/{index-NmopQGmQ.js → index-F9dY4AG_.js} +1 -1
- package/dist/web/dashboard/dist/assets/{insights-tab-X7u4J-xv.js → insights-tab-YN7G6mjm.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-Cpz6_3mB.js → journey-tab-BcweuR82.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-QB__4Xdl.js → logs-tab-BjdAURdy.js} +1 -1
- package/dist/web/dashboard/dist/assets/{memories-tab-Dry9wz7q.js → memories-tab-CQ2xM2aw.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-OXTksZKv.js → prd-backlog-tab-CIeCpE1a.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-x7OCuCmb.js → siebel-tab-bj5CT4-Z.js} +1 -1
- package/dist/web/dashboard/dist/assets/{skills-tab-DeUEKmpZ.js → skills-tab-Bgk72mKO.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-C-e8BTyP.js → style-Da3qWU01.js} +1 -1
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +13 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,a as f,j as t}from"./index-
|
|
1
|
+
import{r,a as f,j as t}from"./index-DtkPX5ZZ.js";function w(){const[l,o]=r.useState([]),[n,v]=r.useState(!0),d=r.useRef(0),p=r.useCallback(async()=>{try{const{logs:c}=await f.getLogs();o(c),c.length>0&&(d.current=c[c.length-1].id)}finally{v(!1)}},[]),u=r.useCallback(async()=>{await f.clearLogs(),o([]),d.current=0},[]);return r.useEffect(()=>{p()},[p]),r.useEffect(()=>{const c=new EventSource("/api/v1/events"),i=b=>{try{const s=JSON.parse(b.data),a={id:s.payload.id,level:s.payload.level,message:s.payload.message,context:s.payload.context,timestamp:s.timestamp};a.id>d.current&&(d.current=a.id,o(h=>[...h,a]))}catch{}};return c.addEventListener("log:entry",i),c.onerror=()=>{c.close(),setTimeout(()=>{},5e3)},()=>c.close()},[]),{logs:l,loading:n,clearLogs:u,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 y(l){return new Date(l).toLocaleTimeString("en-US",{hour12:!1})}function L(l){return!l||Object.keys(l).length===0?"":Object.entries(l).map(([o,n])=>`${o}="${String(n)}"`).join(" ")}function j(l){return l.map(o=>{const n=L(o.context);return`[${y(o.timestamp)}] [${o.level.toUpperCase()}] ${o.message}${n?" "+n:""}`}).join(`
|
|
2
2
|
`)}function O(){const{logs:l,loading:o,clearLogs:n,refresh:v}=w(),[d,p]=r.useState("all"),[u,c]=r.useState(""),[i,b]=r.useState(!0),s=r.useRef(null),a=r.useMemo(()=>{let e=l;if(d!=="all"&&(e=e.filter(x=>x.level===d)),u.trim()){const x=u.toLowerCase();e=e.filter(g=>g.message.toLowerCase().includes(x))}return e},[l,d,u]);r.useEffect(()=>{i&&s.current&&(s.current.scrollTop=s.current.scrollHeight)},[a,i]);const h=r.useCallback(()=>{if(!s.current)return;const{scrollTop:e,scrollHeight:x,clientHeight:g}=s.current,m=x-e-g<40;b(m)},[]),C=r.useCallback(async()=>{const e=j(a);await navigator.clipboard.writeText(e)},[a]),N=r.useCallback(()=>{const e=j(a),x=new Blob([e],{type:"text/plain"}),g=URL.createObjectURL(x),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]),S=r.useCallback(async()=>{await n()},[n]);return o?t.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-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-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[t.jsxs("select",{value:d,onChange:e=>p(e.target.value),className:"px-2 py-1 text-sm rounded border border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-text)]","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:u,onChange:e=>c(e.target.value),placeholder:"Search logs...",className:"flex-1 px-2 py-1 text-sm rounded border border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-text)] placeholder:text-[var(--color-text-muted)]","data-testid":"log-search"}),t.jsx("button",{onClick:()=>b(!i),className:`px-2 py-1 text-xs rounded border ${i?"border-[var(--color-accent)] text-[var(--color-accent)]":"border-[var(--color-border)] text-[var(--color-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-[var(--color-border)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",title:"Copy all visible logs",children:"Copy"}),t.jsx("button",{onClick:N,className:"px-2 py-1 text-xs rounded border border-[var(--color-border)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",title:"Download logs as .txt",children:"Download"}),t.jsx("button",{onClick:S,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 v(),className:"px-2 py-1 text-xs rounded border border-[var(--color-border)] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",title:"Refresh logs",children:"Refresh"}),t.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[a.length," entries"]})]}),t.jsx("div",{ref:s,onScroll:h,className:"flex-1 overflow-y-auto font-mono text-xs p-2","data-testid":"log-list",children:a.length===0?t.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"No logs to display"}):a.map(e=>t.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-[var(--color-bg-secondary)]",children:[t.jsx("span",{className:"text-[var(--color-text-muted)] shrink-0",children:y(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-[var(--color-text)]",children:e.message}),e.context&&Object.keys(e.context).length>0&&t.jsx("span",{className:"text-[var(--color-text-muted)]",children:L(e.context)})]},e.id))})]})}export{O as LogsTab};
|
package/dist/web/dashboard/dist/assets/{memories-tab-Dry9wz7q.js → memories-tab-CQ2xM2aw.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,a as b,j as e}from"./index-
|
|
1
|
+
import{r as i,a as b,j as e}from"./index-DtkPX5ZZ.js";function j(t){const c=[];for(const l of t){const o=l.name.split("/");let a=c;for(let n=0;n<o.length;n++){const r=o[n],x=o.slice(0,n+1).join("/"),d=n===o.length-1;let s=a.find(f=>f.name===r);s||(s={name:r,path:x,children:[]},d&&(s.memory=l),a.push(s)),d&&!s.memory&&(s.memory=l),a=s.children}}return c}function S(){const[t,c]=i.useState([]),[l,o]=i.useState(null),[a,n]=i.useState(null),[r,x]=i.useState(!0),d=i.useCallback(async()=>{try{x(!0);const s=await b.getMemories().catch(()=>[]);c(s)}catch(s){n(s instanceof Error?s.message:"Failed to load")}finally{x(!1)}},[]);return i.useEffect(()=>{d()},[d]),r?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading Memories..."}):a?e.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load: ",a]}):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-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Memories"}),e.jsx(g,{label:"Memories",active:t.length>0}),e.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[t.length," memories"]})]}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(N,{memories:t,selectedMemory:l,onSelect:o}),e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(y,{selectedMemory:l})})]})]})}function g({label:t,active:c}){const l=c?"var(--color-success)":"var(--color-text-muted)",o=c?"Active":"No data";return e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full",style:{background:`${l}20`,color:l},children:[t,": ",o]})}function N({memories:t,selectedMemory:c,onSelect:l}){const[o,a]=i.useState(""),[n,r]=i.useState(!1),[x,d]=i.useState(new Set),s=i.useMemo(()=>{if(!o.trim())return t;const m=o.toLowerCase();return t.filter(p=>p.name.toLowerCase().includes(m))},[t,o]),f=i.useMemo(()=>j(s),[s]),v=i.useCallback(m=>{d(p=>{const u=new Set(p);return u.has(m)?u.delete(m):u.add(m),u})},[]);return n?e.jsx("div",{className:"w-8 border-r border-[var(--color-border)] bg-[var(--color-bg-secondary)] flex flex-col items-center pt-2",children:e.jsx("button",{onClick:()=>r(!1),className:"text-[10px] text-[var(--color-text-muted)] hover:text-[var(--color-text)] rotate-90",title:"Expand file explorer",children:"Files"})}):e.jsxs("div",{className:"w-64 border-r border-[var(--color-border)] bg-[var(--color-bg-secondary)] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-[var(--color-border)]",children:[e.jsx("span",{className:"text-[10px] font-semibold text-[var(--color-text-muted)] uppercase tracking-wider",children:"Files"}),e.jsx("button",{onClick:()=>r(!0),className:"text-[10px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",title:"Collapse",children:"✕"})]}),e.jsx("div",{className:"px-2 py-1.5 border-b border-[var(--color-border)]",children:e.jsx("input",{type:"text",value:o,onChange:m=>a(m.target.value),placeholder:"Search files...",className:"w-full text-[11px] px-2 py-1 rounded bg-[var(--color-bg)] border border-[var(--color-border)] focus:outline-none focus:border-[var(--color-accent)]"})}),e.jsx("div",{className:"flex-1 overflow-y-auto text-[11px]",children:t.length===0?e.jsx("div",{className:"px-2 py-4 text-center text-[var(--color-text-muted)]",children:"No memories"}):e.jsx(h,{nodes:f,depth:0,expandedPaths:x,onToggle:v,selectedMemory:c,onSelect:l})})]})}function h({nodes:t,depth:c,expandedPaths:l,onToggle:o,selectedMemory:a,onSelect:n}){return e.jsx(e.Fragment,{children:t.map(r=>{const x=r.children.length>0,d=l.has(r.path),s=r.memory!=null&&(a==null?void 0:a.name)===r.memory.name;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>{x&&o(r.path),r.memory&&n(r.memory)},className:`w-full text-left px-2 py-0.5 flex items-center gap-1 hover:bg-[var(--color-bg-tertiary)] transition-colors ${s?"bg-[var(--color-accent)]15 text-[var(--color-accent)]":"text-[var(--color-text)]"}`,style:{paddingLeft:`${c*12+8}px`},children:[x?e.jsx("span",{className:"w-3 text-[9px] text-[var(--color-text-muted)]",children:d?"▾":"▸"}):e.jsx("span",{className:"w-3 text-[9px] text-[var(--color-text-muted)]",children:"·"}),e.jsx("span",{className:"truncate",children:r.name})]}),x&&d&&e.jsx(h,{nodes:r.children,depth:c+1,expandedPaths:l,onToggle:o,selectedMemory:a,onSelect:n})]},r.path)})})}function y({selectedMemory:t}){return t?e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3 pb-2 border-b border-[var(--color-border)]",children:e.jsx("span",{className:"text-sm font-semibold",children:t.name})}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap text-[var(--color-text-muted)] font-mono leading-relaxed",children:t.content})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-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",children:"Project memories appear as navigable files"})]})})}export{S as MemoriesTab};
|
package/dist/web/dashboard/dist/assets/{prd-backlog-tab-OXTksZKv.js → prd-backlog-tab-CIeCpE1a.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as e}from"./index-
|
|
1
|
+
import{r as a,j as e}from"./index-DtkPX5ZZ.js";import{R as _,u as M,a as E,b as P,i as T,B,C as D}from"./style-Da3qWU01.js";import{S as y}from"./constants-z0QkAiYv.js";import{b as R,g as F,t as $,c as z,d as I,W as L,e as A,N as O}from"./graph-utils-BpYHKE87.js";import"./index-F9dY4AG_.js";const V=a.memo(function({graph:c,onNodeClick:N}){const{groups:w,nextTask:h,nodeMap:g}=a.useMemo(()=>{const d=c.nodes.filter(s=>s.type==="task"||s.type==="subtask"),x=new Map(c.nodes.map(s=>[s.id,s])),m=new Set(c.nodes.filter(s=>s.status==="done").map(s=>s.id)),f=d.filter(s=>s.status!=="backlog"&&s.status!=="ready"||s.blocked?!1:c.edges.filter(r=>r.from===s.id&&r.relationType==="depends_on").every(r=>m.has(r.to)));f.sort((s,t)=>s.priority-t.priority);const i=new Map;for(const s of d){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,r)=>t.priority-r.priority);return{groups:i,nextTask:f[0]||null,nodeMap:x}},[c]);return c.nodes.filter(d=>d.type==="task"||d.type==="subtask").length===0?e.jsx("div",{className:"p-4 text-center text-[var(--color-text-muted)]",children:"No tasks in backlog."}):e.jsxs("div",{className:"p-2",children:[h&&e.jsxs("div",{className:"mb-3 px-3 py-2 bg-[var(--color-accent)]10 border border-[var(--color-accent)] rounded-lg",children:[e.jsx("span",{className:"text-xs font-medium text-[var(--color-accent)]",children:"Next:"})," ",e.jsx("span",{className:"text-sm font-semibold",children:h.title})]}),Array.from(w.entries()).map(([d,x])=>{const m=d!=="__root__"?g.get(d):null,f=m?m.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:f}),e.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[i,"/",x.length]})]}),e.jsx("div",{className:"h-1 mx-2 mb-1 bg-[var(--color-bg-tertiary)] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${s}%`,background:y.done}})}),x.map(t=>{const r=(h==null?void 0:h.id)===t.id,v=y[t.status]||"#9e9e9e",j=c.edges.filter(n=>n.from===t.id&&n.relationType==="depends_on").map(n=>{var l;return((l=g.get(n.to))==null?void 0:l.title)||n.to});return e.jsxs("div",{onClick:()=>N(t),className:`mx-1 mb-1 px-2 py-1.5 rounded cursor-pointer hover:bg-[var(--color-bg-tertiary)] transition-colors ${r?"ring-1 ring-[var(--color-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-[var(--color-text-muted)]",children:["P",t.priority]}),t.xpSize&&e.jsx("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:t.xpSize})]}),j.length>0&&e.jsxs("div",{className:"text-[10px] text-[var(--color-text-muted)] mt-0.5 truncate pl-1",children:["Depends on: ",j.join(", ")]})]},t.id)})]},d)})]})}),W={workflowNode:A},U={workflowEdge:L},Z={hideAttribution:!0};function G({graph:o}){const[c,N,w]=M([]),[h,g,d]=E([]),[x,m]=a.useState(null),[f,i]=a.useState(new Set),s=a.useRef(!0),{fitView:t}=P(),r=a.useMemo(()=>R(o.nodes,o.edges),[o.nodes,o.edges]),v=a.useCallback(l=>{i(u=>{const p=new Set(u);return p.has(l)?p.delete(l):p.add(l),p})},[]);a.useEffect(()=>{const l=F(o.nodes,f,r),u=$(l,void 0,r,f,v),p=new Set(u.map(S=>S.id)),k=z(o.edges,p),b=I(u,k,"TB");N(b.nodes),g(b.edges),s.current?s.current=!1:setTimeout(()=>t({duration:300}),50)},[o,N,g,f,r,v,t]);const C=a.useCallback((l,u)=>{m(u.data.sourceNode)},[]),j=a.useCallback(l=>{m(l)},[]),n=a.useMemo(()=>{const l=o.nodes.length,u=o.nodes.filter(b=>b.status==="done").length,p=o.nodes.filter(b=>b.status==="in_progress").length,k=o.nodes.filter(b=>b.status==="blocked").length;return{total:l,done:u,inProgress:p,blocked:k,pctDone:l?Math.round(u/l*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-[var(--color-bg-secondary)] border-b border-[var(--color-border)] flex items-center gap-2 text-xs relative z-10",children:e.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["Showing ",c.length," of ",o.nodes.length," nodes — click ▶ to expand"]})}),o.nodes.length>0?e.jsxs(T,{nodes:c,edges:h,onNodesChange:w,onEdgesChange:d,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-[var(--color-text-muted)]",children:"Import a PRD to see the workflow"})]}),e.jsxs("div",{className:"w-96 border-l border-[var(--color-border)] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsxs("span",{children:[n.done,"/",n.total," done (",n.pctDone,"%)"]}),e.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[n.inProgress," in progress, ",n.blocked," blocked"]})]}),e.jsxs("div",{className:"h-2 bg-[var(--color-bg-tertiary)] rounded-full overflow-hidden flex",children:[e.jsx("div",{className:"h-full transition-all",style:{width:`${n.pctDone}%`,background:y.done}}),e.jsx("div",{className:"h-full transition-all",style:{width:`${n.total?Math.round(n.inProgress/n.total*100):0}%`,background:y.in_progress}})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx(V,{graph:o,onNodeClick:j})})]}),x&&e.jsx(O,{node:x,onClose:()=>m(null)})]})}function X({graph:o}){return e.jsx(_,{children:e.jsx(G,{graph:o})})}export{X as PrdBacklogTab};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r,a as d,j as e}from"./index-
|
|
1
|
+
import{r,a as d,j as e}from"./index-DtkPX5ZZ.js";function z(){const[h,C]=r.useState([]),[k,L]=r.useState([]),[P,N]=r.useState(!0),[w,I]=r.useState(null),[f,i]=r.useState(null),v=r.useRef(null),g=r.useRef(null),[c,T]=r.useState(""),[x,D]=r.useState(["business_component"]),[j,F]=r.useState(""),[m,S]=r.useState(null),[u,G]=r.useState(""),[a,y]=r.useState(null),[b,p]=r.useState(!1),n=r.useCallback(async()=>{try{N(!0);const[t,s]=await Promise.all([d.siebelGetObjects({limit:100}).catch(()=>({objects:[],total:0})),d.siebelGetTemplates().catch(()=>({templates:[]}))]);C(t.objects),L(s.templates)}catch(t){I(t instanceof Error?t.message:"Failed to load")}finally{N(!1)}},[]);r.useEffect(()=>{n()},[n]);const E=r.useCallback(async t=>{var l;const s=(l=t.target.files)==null?void 0:l[0];if(s){try{i("Importing SIF...");const o=await s.text();await d.siebelImportSif(o,s.name,!0),i(`SIF imported: ${s.name}`),n()}catch(o){i(`Error: ${o instanceof Error?o.message:String(o)}`)}v.current&&(v.current.value="")}},[n]),R=r.useCallback(async t=>{var l;const s=(l=t.target.files)==null?void 0:l[0];if(s){try{i("Uploading documentation...");const o=await d.siebelUploadDocs(s);i(`Indexed: ${o.fileName} (${o.chunksIndexed} chunks)`),n()}catch(o){i(`Error: ${o instanceof Error?o.message:String(o)}`)}g.current&&(g.current.value="")}},[n]),$=r.useCallback(async()=>{if(c.trim()){p(!0),y(null);try{const t=await d.siebelPrepareGeneration({description:c,objectTypes:x,basedOnProject:j||void 0});S(t.prompt)}catch(t){S(`Error: ${t instanceof Error?t.message:String(t)}`)}finally{p(!1)}}},[c,x,j]),U=r.useCallback(async()=>{if(u.trim()){p(!0);try{const t=await d.siebelFinalizeGeneration({generatedXml:u,description:c,objectTypes:x});y(t),n()}catch(t){y({sifContent:"",objects:[],validation:{status:"invalid",messages:[{level:"error",message:t instanceof Error?t.message:String(t)}],score:0},metadata:{generatedAt:new Date().toISOString(),requestDescription:c,objectCount:0}})}finally{p(!1)}}},[u,c,x,n]),O=r.useCallback(()=>{if(!(a!=null&&a.sifContent))return;const t=new Blob([a.sifContent],{type:"application/xml"}),s=URL.createObjectURL(t),l=document.createElement("a");l.href=s,l.download="generated.sif",l.click(),URL.revokeObjectURL(s)},[a]),M=r.useCallback(t=>{D(s=>s.includes(t)?s.filter(l=>l!==t):[...s,t])},[]);return P?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading Siebel..."}):w?e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:w}):e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"p-4 space-y-6 max-w-6xl mx-auto",children:[e.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-[var(--color-border)]",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Upload & Context"}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:"Upload SIF files and documentation to build RAG context for generation"})]}),e.jsxs("div",{className:"p-4 grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"SIF File (.sif)"}),e.jsx("input",{ref:v,type:"file",accept:".sif,.xml",onChange:E,className:"block w-full text-xs file:mr-2 file:py-1.5 file:px-3 file:rounded-md file:border-0 file:text-xs file:font-medium file:bg-[var(--color-accent)] file:text-white hover:file:opacity-90 cursor-pointer"}),e.jsx("p",{className:"text-[10px] text-[var(--color-text-muted)] mt-1",children:"Imports Siebel objects into the graph + knowledge store"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1.5",children:"Documentation (PDF, HTML, DOC, DOCX, TXT, MD)"}),e.jsx("input",{ref:g,type:"file",accept:".pdf,.html,.htm,.txt,.md,.doc,.docx",onChange:R,className:"block w-full text-xs file:mr-2 file:py-1.5 file:px-3 file:rounded-md file:border-0 file:text-xs file:font-medium file:bg-[var(--color-accent)] file:text-white hover:file:opacity-90 cursor-pointer"}),e.jsx("p",{className:"text-[10px] text-[var(--color-text-muted)] mt-1",children:"Indexes documentation as context for SIF generation"})]})]}),f&&e.jsx("div",{className:`px-4 py-2 text-xs border-t border-[var(--color-border)] ${f.startsWith("Error")?"text-red-500":"text-green-500"}`,children:f})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[e.jsx("div",{className:"px-4 py-3 border-b border-[var(--color-border)]",children:e.jsxs("h3",{className:"text-sm font-semibold",children:["Indexed Siebel Objects",e.jsxs("span",{className:"ml-2 text-xs font-normal text-[var(--color-text-muted)]",children:[h.length," objects"]})]})}),h.length===0?e.jsx("div",{className:"p-4 text-xs text-[var(--color-text-muted)]",children:"No Siebel objects indexed yet. Upload a .sif file above."}):e.jsx("div",{className:"max-h-64 overflow-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-[var(--color-bg-secondary)]",children:e.jsxs("tr",{className:"border-b border-[var(--color-border)]",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:h.map((t,s)=>e.jsxs("tr",{className:"border-b border-[var(--color-border)] hover:bg-[var(--color-bg-primary)]",children:[e.jsx("td",{className:"px-4 py-1.5 font-mono",children:t.title}),e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] bg-[var(--color-accent)]/10 text-[var(--color-accent)]",children:t.siebelType??t.sourceType})}),e.jsx("td",{className:"px-4 py-1.5 text-[var(--color-text-muted)]",children:t.siebelProject??"-"}),e.jsx("td",{className:"px-4 py-1.5 text-[var(--color-text-muted)] truncate max-w-xs",children:t.contentPreview})]},s))})]})})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--color-bg-secondary)]",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-[var(--color-border)]",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"SIF Generation"}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:"Describe what you need, generate context for the LLM, then validate the output"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:"Description"}),e.jsx("textarea",{value:c,onChange:t=>T(t.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-[var(--color-border)] bg-[var(--color-bg-primary)] text-[var(--color-text)] placeholder:text-[var(--color-text-muted)] focus:outline-none focus:ring-1 focus:ring-[var(--color-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:k.map(t=>e.jsx("button",{onClick:()=>M(t.type),className:`px-2 py-1 text-[10px] rounded-md border transition-colors ${x.includes(t.type)?"bg-[var(--color-accent)] text-white border-[var(--color-accent)]":"bg-transparent text-[var(--color-text-muted)] border-[var(--color-border)] hover:border-[var(--color-accent)]"}`,children:t.type.replace(/_/g," ")},t.type))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:"Base Project (optional)"}),e.jsx("input",{value:j,onChange:t=>F(t.target.value),placeholder:"e.g., Account (SSE)",className:"w-full px-3 py-1.5 text-xs rounded-md border border-[var(--color-border)] bg-[var(--color-bg-primary)] text-[var(--color-text)] placeholder:text-[var(--color-text-muted)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent)]"})]}),e.jsx("button",{onClick:$,disabled:!c.trim()||b,className:"px-4 py-1.5 text-xs font-medium rounded-md bg-[var(--color-accent)] text-white hover:opacity-90 disabled:opacity-50 transition-opacity",children:b?"Generating Context...":"Generate Context & Prompt"}),m&&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(m),className:"text-[10px] px-2 py-0.5 rounded bg-[var(--color-bg-primary)] text-[var(--color-text-muted)] hover:text-[var(--color-text)] border border-[var(--color-border)]",children:"Copy"})]}),e.jsxs("pre",{className:"text-[10px] p-3 rounded-md bg-[var(--color-bg-primary)] border border-[var(--color-border)] max-h-48 overflow-auto whitespace-pre-wrap text-[var(--color-text-muted)]",children:[m.slice(0,3e3),m.length>3e3&&`
|
|
2
2
|
|
|
3
3
|
... (truncated for display)`]})]}),m&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium mb-1",children:"Paste LLM-generated SIF XML"}),e.jsx("textarea",{value:u,onChange:t=>G(t.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-[var(--color-border)] bg-[var(--color-bg-primary)] text-[var(--color-text)] placeholder:text-[var(--color-text-muted)] focus:outline-none focus:ring-1 focus:ring-[var(--color-accent)]"}),e.jsx("button",{onClick:U,disabled:!u.trim()||b,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",children:b?"Validating...":"Validate & Finalize"})]}),a&&e.jsxs("div",{className:`rounded-md border p-4 space-y-2 ${a.validation.status==="valid"?"border-green-500/30 bg-green-500/5":a.validation.status==="warnings"?"border-yellow-500/30 bg-yellow-500/5":"border-red-500/30 bg-red-500/5"}`,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 ${a.validation.status==="valid"?"text-green-500":a.validation.status==="warnings"?"text-yellow-500":"text-red-500"}`,children:a.validation.status==="valid"?"Valid":a.validation.status==="warnings"?"Warnings":"Invalid"}),e.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:["Score: ",a.validation.score,"/100"]}),e.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[a.metadata.objectCount," objects"]})]}),a.validation.status!=="invalid"&&e.jsx("button",{onClick:O,className:"px-3 py-1 text-xs font-medium rounded-md bg-[var(--color-accent)] text-white hover:opacity-90",children:"Download SIF"})]}),a.objects.length>0&&e.jsxs("div",{className:"text-xs text-[var(--color-text-muted)]",children:["Objects: ",a.objects.map(t=>`${t.type}:${t.name}`).join(", ")]}),a.validation.messages.length>0&&e.jsx("ul",{className:"space-y-0.5",children:a.validation.messages.map((t,s)=>e.jsxs("li",{className:`text-[10px] ${t.level==="error"?"text-red-500":t.level==="warning"?"text-yellow-600":"text-[var(--color-text-muted)]"}`,children:["[",t.level,"] ",t.message,t.objectName&&` (${t.objectName})`]},s))})]})]})]})]})})}export{z as SiebelTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,a as k,j as e}from"./index-B1PLsGu1.js";import{P,L as O}from"./constants-z0QkAiYv.js";function D(){const[t,s]=a.useState([]),[x,l]=a.useState([]),[i,n]=a.useState(0),[m,h]=a.useState(!0),[b,v]=a.useState(null),d=a.useCallback(async()=>{h(!0),v(null);try{const[o,u]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(o.skills),n(o.totalTokens),l(u.recommendations)}catch(o){v(o instanceof Error?o.message:"Failed to load skills")}finally{h(!1)}},[]);a.useEffect(()=>{d()},[d]);const j=a.useCallback(async(o,u)=>{s(C=>C.map(N=>N.name===o?{...N,enabled:u}:N));try{await k.toggleSkill(o,u)}catch{d()}},[d]),p=a.useCallback(async o=>{await k.createCustomSkill(o),d()},[d]),y=a.useCallback(async(o,u)=>{await k.updateCustomSkill(o,u),d()},[d]),f=a.useCallback(async o=>{await k.deleteCustomSkill(o),d()},[d]),g=t.filter(o=>o.enabled).reduce((o,u)=>o+u.estimatedTokens,0);return{skills:t,recommendations:x,totalTokens:i,activeTokens:g,loading:m,error:b,refresh:d,toggleSkill:j,createSkill:p,updateSkill:y,deleteSkill:f}}function A({skill:t,onClose:s,onToggle:x,onDelete:l,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:n=>{n.target===n.currentTarget&&s()},children:e.jsxs("div",{className:"bg-[var(--color-bg)] 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-[var(--color-text-muted)] hover:text-[var(--color-text)] text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-[var(--color-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-[var(--color-border)] text-[var(--color-text-muted)]",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-[var(--color-border)] text-[var(--color-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(n=>{const m=P[n]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${m}20`,color:m},children:n},n)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>x(t.name,n.target.checked),className:"w-4 h-4 accent-[var(--color-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-[var(--color-border)] rounded hover:bg-[var(--color-bg-tertiary)]",children:"Edit"}),l&&t.id&&e.jsx("button",{onClick:()=>l(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 F=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function z({open:t,onClose:s,onSubmit:x,editSkill:l}){const[i,n]=a.useState(""),[m,h]=a.useState(""),[b,v]=a.useState("know-me"),[d,j]=a.useState(["IMPLEMENT"]),[p,y]=a.useState(""),[f,g]=a.useState(!1),[o,u]=a.useState(null);a.useEffect(()=>{l?(n(l.name),h(l.description),v(l.category),j(l.phases??["IMPLEMENT"]),y("")):(n(""),h(""),v("know-me"),j(["IMPLEMENT"]),y("")),u(null)},[l,t]);const C=a.useCallback(r=>{j(S=>S.includes(r)?S.filter(T=>T!==r):[...S,r])},[]),N=a.useCallback(async()=>{if(!i.trim()||!m.trim()||!p.trim()||d.length===0){u("All fields are required and at least one phase must be selected.");return}g(!0),u(null);try{await x({name:i.trim(),description:m.trim(),category:b,phases:d,instructions:p.trim()}),s()}catch(r){u(r instanceof Error?r.message:"Failed to save skill")}finally{g(!1)}},[i,m,b,d,p,x,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:r=>{r.target===r.currentTarget&&s()},children:e.jsxs("div",{className:"bg-[var(--color-bg)] 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:l?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] 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-[var(--color-text-muted)] mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:r=>n(r.target.value),placeholder:"my-workflow",disabled:!!l,className:"w-full px-3 py-2 text-sm rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Description"}),e.jsx("input",{type:"text",value:m,onChange:r=>h(r.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Category"}),e.jsx("select",{value:b,onChange:r=>v(r.target.value),className:"w-full px-3 py-2 text-sm rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:F.map(r=>e.jsx("option",{value:r,children:r},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:O.map(r=>e.jsx("button",{type:"button",onClick:()=>C(r),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(r)?"bg-[var(--color-accent)]/10 border-[var(--color-accent)] text-[var(--color-accent)]":"border-[var(--color-border)] text-[var(--color-text-muted)] hover:border-[var(--color-text)]"}`,children:r},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:r=>y(r.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-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] resize-y"})]}),o&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:o}),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-[var(--color-border)] rounded hover:bg-[var(--color-bg-tertiary)]",children:"Cancel"}),e.jsx("button",{onClick:N,disabled:f,className:"px-3 py-1.5 text-sm bg-[var(--color-accent)] text-white rounded hover:opacity-90 disabled:opacity-50",children:f?"Saving...":l?"Update":"Create"})]})]})]})}):null}const I=4e3;function w({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase",children:s})]})}function _({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-[var(--color-accent)]/10 text-[var(--color-accent)]",filesystem:"bg-[var(--color-text-muted)]/10 text-[var(--color-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:x}){return e.jsxs("div",{className:`p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] cursor-pointer hover:border-[var(--color-accent)]/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>x(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:l=>{l.stopPropagation(),s(t.name,l.target.checked)},onClick:l=>l.stopPropagation(),className:"w-3.5 h-3.5 accent-[var(--color-accent)]"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)] line-clamp-2",children:t.description})]})}function B({phase:t,skills:s,onToggle:x,onSkillClick:l}){const[i,n]=a.useState(!0),m=P[t]??"#6b7280",h=s.filter(b=>b.enabled).length;return e.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-[var(--color-bg-tertiary)] 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:m}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-[var(--color-border)] text-[10px]",children:[h,"/",s.length]})]}),e.jsx("span",{className:"text-[var(--color-text-muted)]",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(b=>e.jsx(H,{skill:b,onToggle:x,onClick:l},b.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-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(_,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const x=Math.min(s/I,1),l=Math.min(t/I,1),i=Math.round(x*100),n=x>.8?"#ef4444":x>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-[var(--color-border)] relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(l*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:n}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:x,activeTokens:l,loading:i,error:n,refresh:m,toggleSkill:h,createSkill:b,updateSkill:v,deleteSkill:d}=D(),[j,p]=a.useState(null),[y,f]=a.useState(!1),[g,o]=a.useState(null),u=a.useCallback(async c=>{await d(c),p(null)},[d]),C=a.useCallback(c=>{p(null),o(c),f(!0)},[]),N=a.useCallback(async c=>{g!=null&&g.id?await v(g.id,c):await b(c),o(null)},[g,b,v]);if(n)return e.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load skills: ",n]});if(i)return e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading skills..."});const r=t.filter(c=>c.source==="built-in").length,S=t.filter(c=>c.source==="custom").length,T=t.filter(c=>c.enabled).length,M=new Map;for(const c of O){const E=t.filter($=>{var R;return(R=$.phases)==null?void 0:R.includes(c)});E.length>0&&M.set(c,E)}const L=t.filter(c=>!c.phases||c.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:()=>{o(null),f(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[var(--color-accent)]/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void m(),className:"text-xs px-3 py-1.5 rounded-lg bg-[var(--color-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(w,{value:t.length,label:"Total Skills"}),e.jsx(w,{value:r,label:"Built-in"}),e.jsx(w,{value:S,label:"Custom"}),e.jsx(w,{value:T,label:"Enabled"}),e.jsx(w,{value:l.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:x,activeTokens:l}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(c=>e.jsx(U,{rec:c},c.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([c,E])=>e.jsx(B,{phase:c,skills:E,onToggle:h,onSkillClick:p},c)),L.length>0&&e.jsx(B,{phase:"Other",skills:L,onToggle:h,onSkillClick:p})]}),e.jsx(A,{skill:j,onClose:()=>p(null),onToggle:h,onDelete:u,onEdit:C}),e.jsx(z,{open:y,onClose:()=>{f(!1),o(null)},onSubmit:N,editSkill:g})]})}export{Y as SkillsTab};
|
|
1
|
+
import{r as a,a as k,j as e}from"./index-DtkPX5ZZ.js";import{P,L as O}from"./constants-z0QkAiYv.js";function D(){const[t,s]=a.useState([]),[x,l]=a.useState([]),[i,n]=a.useState(0),[m,h]=a.useState(!0),[b,v]=a.useState(null),d=a.useCallback(async()=>{h(!0),v(null);try{const[o,u]=await Promise.all([k.getSkills(),k.getRecommendations().catch(()=>({recommendations:[]}))]);s(o.skills),n(o.totalTokens),l(u.recommendations)}catch(o){v(o instanceof Error?o.message:"Failed to load skills")}finally{h(!1)}},[]);a.useEffect(()=>{d()},[d]);const j=a.useCallback(async(o,u)=>{s(C=>C.map(N=>N.name===o?{...N,enabled:u}:N));try{await k.toggleSkill(o,u)}catch{d()}},[d]),p=a.useCallback(async o=>{await k.createCustomSkill(o),d()},[d]),y=a.useCallback(async(o,u)=>{await k.updateCustomSkill(o,u),d()},[d]),f=a.useCallback(async o=>{await k.deleteCustomSkill(o),d()},[d]),g=t.filter(o=>o.enabled).reduce((o,u)=>o+u.estimatedTokens,0);return{skills:t,recommendations:x,totalTokens:i,activeTokens:g,loading:m,error:b,refresh:d,toggleSkill:j,createSkill:p,updateSkill:y,deleteSkill:f}}function A({skill:t,onClose:s,onToggle:x,onDelete:l,onEdit:i}){return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:n=>{n.target===n.currentTarget&&s()},children:e.jsxs("div",{className:"bg-[var(--color-bg)] 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-[var(--color-text-muted)] hover:text-[var(--color-text)] text-xl",children:"×"})]}),e.jsx("p",{className:"text-sm text-[var(--color-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-[var(--color-border)] text-[var(--color-text-muted)]",children:t.category}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium bg-[var(--color-border)] text-[var(--color-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(n=>{const m=P[n]??"#6b7280";return e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium",style:{background:`${m}20`,color:m},children:n},n)})}),e.jsx("div",{className:"flex items-center gap-3 mb-4 p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:n=>x(t.name,n.target.checked),className:"w-4 h-4 accent-[var(--color-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-[var(--color-border)] rounded hover:bg-[var(--color-bg-tertiary)]",children:"Edit"}),l&&t.id&&e.jsx("button",{onClick:()=>l(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 F=["know-me","software-design","security","testing","cost-reducer","research","ddd","frontend-design","other"];function z({open:t,onClose:s,onSubmit:x,editSkill:l}){const[i,n]=a.useState(""),[m,h]=a.useState(""),[b,v]=a.useState("know-me"),[d,j]=a.useState(["IMPLEMENT"]),[p,y]=a.useState(""),[f,g]=a.useState(!1),[o,u]=a.useState(null);a.useEffect(()=>{l?(n(l.name),h(l.description),v(l.category),j(l.phases??["IMPLEMENT"]),y("")):(n(""),h(""),v("know-me"),j(["IMPLEMENT"]),y("")),u(null)},[l,t]);const C=a.useCallback(r=>{j(S=>S.includes(r)?S.filter(T=>T!==r):[...S,r])},[]),N=a.useCallback(async()=>{if(!i.trim()||!m.trim()||!p.trim()||d.length===0){u("All fields are required and at least one phase must be selected.");return}g(!0),u(null);try{await x({name:i.trim(),description:m.trim(),category:b,phases:d,instructions:p.trim()}),s()}catch(r){u(r instanceof Error?r.message:"Failed to save skill")}finally{g(!1)}},[i,m,b,d,p,x,s]);return t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:r=>{r.target===r.currentTarget&&s()},children:e.jsxs("div",{className:"bg-[var(--color-bg)] 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:l?"Edit Skill":"Create Custom Skill"}),e.jsx("button",{onClick:s,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] 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-[var(--color-text-muted)] mb-1",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:r=>n(r.target.value),placeholder:"my-workflow",disabled:!!l,className:"w-full px-3 py-2 text-sm rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Description"}),e.jsx("input",{type:"text",value:m,onChange:r=>h(r.target.value),placeholder:"What does this skill do?",className:"w-full px-3 py-2 text-sm rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Category"}),e.jsx("select",{value:b,onChange:r=>v(r.target.value),className:"w-full px-3 py-2 text-sm rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:F.map(r=>e.jsx("option",{value:r,children:r},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Phases"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:O.map(r=>e.jsx("button",{type:"button",onClick:()=>C(r),className:`px-2 py-1 text-[10px] font-medium rounded-full border transition-colors ${d.includes(r)?"bg-[var(--color-accent)]/10 border-[var(--color-accent)] text-[var(--color-accent)]":"border-[var(--color-border)] text-[var(--color-text-muted)] hover:border-[var(--color-text)]"}`,children:r},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--color-text-muted)] mb-1",children:"Instructions"}),e.jsx("textarea",{value:p,onChange:r=>y(r.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-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] resize-y"})]}),o&&e.jsx("div",{className:"text-sm p-2 rounded bg-red-500/10 text-red-500",children:o}),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-[var(--color-border)] rounded hover:bg-[var(--color-bg-tertiary)]",children:"Cancel"}),e.jsx("button",{onClick:N,disabled:f,className:"px-3 py-1.5 text-sm bg-[var(--color-accent)] text-white rounded hover:opacity-90 disabled:opacity-50",children:f?"Saving...":l?"Update":"Create"})]})]})]})}):null}const I=4e3;function w({value:t,label:s}){return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:t}),e.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase",children:s})]})}function _({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-[var(--color-accent)]/10 text-[var(--color-accent)]",filesystem:"bg-[var(--color-text-muted)]/10 text-[var(--color-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:x}){return e.jsxs("div",{className:`p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] cursor-pointer hover:border-[var(--color-accent)]/50 transition-all ${t.enabled?"":"opacity-50"}`,onClick:()=>x(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:l=>{l.stopPropagation(),s(t.name,l.target.checked)},onClick:l=>l.stopPropagation(),className:"w-3.5 h-3.5 accent-[var(--color-accent)]"}),e.jsx(G,{source:t.source}),e.jsxs("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[t.estimatedTokens.toLocaleString()," tok"]})]})]}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)] line-clamp-2",children:t.description})]})}function B({phase:t,skills:s,onToggle:x,onSkillClick:l}){const[i,n]=a.useState(!0),m=P[t]??"#6b7280",h=s.filter(b=>b.enabled).length;return e.jsxs("div",{className:"rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(!i),className:"w-full flex items-center justify-between px-3 py-2 text-xs font-medium hover:bg-[var(--color-bg-tertiary)] 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:m}}),t,e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-[var(--color-border)] text-[10px]",children:[h,"/",s.length]})]}),e.jsx("span",{className:"text-[var(--color-text-muted)]",children:i?"▲":"▼"})]}),i&&e.jsx("div",{className:"px-3 pb-3 space-y-2",children:s.map(b=>e.jsx(H,{skill:b,onToggle:x,onClick:l},b.name))})]})}function U({rec:t}){return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-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(_,{phase:t.phase})]}),e.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:t.reason})]})}function q({totalTokens:t,activeTokens:s}){const x=Math.min(s/I,1),l=Math.min(t/I,1),i=Math.round(x*100),n=x>.8?"#ef4444":x>.5?"#f59e0b":"#10b981";return e.jsxs("div",{"data-testid":"token-budget-bar",className:"p-4 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[s.toLocaleString()," active / ",t.toLocaleString()," total (",i,"%)"]})]}),e.jsxs("div",{className:"w-full h-2 rounded-full bg-[var(--color-border)] relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-30",style:{width:`${Math.round(l*100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${i}%`,background:n}})]})]})}function Y(){const{skills:t,recommendations:s,totalTokens:x,activeTokens:l,loading:i,error:n,refresh:m,toggleSkill:h,createSkill:b,updateSkill:v,deleteSkill:d}=D(),[j,p]=a.useState(null),[y,f]=a.useState(!1),[g,o]=a.useState(null),u=a.useCallback(async c=>{await d(c),p(null)},[d]),C=a.useCallback(c=>{p(null),o(c),f(!0)},[]),N=a.useCallback(async c=>{g!=null&&g.id?await v(g.id,c):await b(c),o(null)},[g,b,v]);if(n)return e.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load skills: ",n]});if(i)return e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading skills..."});const r=t.filter(c=>c.source==="built-in").length,S=t.filter(c=>c.source==="custom").length,T=t.filter(c=>c.enabled).length,M=new Map;for(const c of O){const E=t.filter($=>{var R;return(R=$.phases)==null?void 0:R.includes(c)});E.length>0&&M.set(c,E)}const L=t.filter(c=>!c.phases||c.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:()=>{o(null),f(!0)},className:"text-xs px-3 py-1.5 rounded-lg border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[var(--color-accent)]/10 transition-colors",children:"+ Custom Skill"}),e.jsx("button",{onClick:()=>void m(),className:"text-xs px-3 py-1.5 rounded-lg bg-[var(--color-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(w,{value:t.length,label:"Total Skills"}),e.jsx(w,{value:r,label:"Built-in"}),e.jsx(w,{value:S,label:"Custom"}),e.jsx(w,{value:T,label:"Enabled"}),e.jsx(w,{value:l.toLocaleString(),label:"Active Tokens"})]}),e.jsx(q,{totalTokens:x,activeTokens:l}),s.length>0&&e.jsxs("div",{"data-testid":"recommendations-section",className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase",children:["Recommendations (",s.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2",children:s.map(c=>e.jsx(U,{rec:c},c.skill))})]}),e.jsxs("div",{"data-testid":"skills-by-phase",className:"space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-[var(--color-text-muted)] uppercase",children:"Skills by Lifecycle Phase"}),[...M.entries()].map(([c,E])=>e.jsx(B,{phase:c,skills:E,onToggle:h,onSkillClick:p},c)),L.length>0&&e.jsx(B,{phase:"Other",skills:L,onToggle:h,onSkillClick:p})]}),e.jsx(A,{skill:j,onClose:()=>p(null),onToggle:h,onDelete:u,onEdit:C}),e.jsx(z,{open:y,onClose:()=>{f(!1),o(null)},onSubmit:N,editSkill:g})]})}export{Y as SkillsTab};
|