@winspan/claude-forge 3.6.47 → 3.6.51
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/prompts/pipeline-decompose.md +2 -2
- package/dist/web-static/assets/{Analytics-Bo74j97W.js → Analytics-txva5ugO.js} +1 -1
- package/dist/web-static/assets/Config-1QvdGyY8.js +1 -0
- package/dist/web-static/assets/Conventions-E_2yAYoB.js +1 -0
- package/dist/web-static/assets/Dashboard-Dskgf0jG.js +1 -0
- package/dist/web-static/assets/{Events-C0y7WcDP.js → Events-CAY9kU9T.js} +1 -1
- package/dist/web-static/assets/{Evolution-DimZAXFS.js → Evolution-Ck_BqRpt.js} +1 -1
- package/dist/web-static/assets/Knowledge-BHLyFp2U.js +2 -0
- package/dist/web-static/assets/{NodeTypes-DyrDqhBp.js → NodeTypes-B6wc7VnR.js} +1 -1
- package/dist/web-static/assets/PipelineDetail-DGoURh1I.js +4 -0
- package/dist/web-static/assets/PipelineTemplates-sSL-9oRh.js +1 -0
- package/dist/web-static/assets/Pipelines-Drat9IqZ.js +2 -0
- package/dist/web-static/assets/ProjectDetail-Cx8VZp8O.js +1 -0
- package/dist/web-static/assets/Projects-qDolX6Y6.js +1 -0
- package/dist/web-static/assets/Quality-Bm7oRSun.js +3 -0
- package/dist/web-static/assets/{SessionDetail-BNDIfmmq.js → SessionDetail-BMrqH8_W.js} +1 -1
- package/dist/web-static/assets/Sessions-C0BmdDPK.js +2 -0
- package/dist/web-static/assets/Skills-B3c1_uFt.js +1 -0
- package/dist/web-static/assets/{TemplateDetail-DOfBYdQ3.js → TemplateDetail-ep5h3Cu5.js} +1 -1
- package/dist/web-static/assets/{Templates-Cp3yC5tv.js → Templates-Dho__f4l.js} +1 -1
- package/dist/web-static/assets/Toast-BbB3oD2a.js +1 -0
- package/dist/web-static/assets/client-BvVpIixG.js +1 -0
- package/dist/web-static/assets/index-BoxlVgIs.js +2 -0
- package/dist/web-static/index.html +3 -2
- package/package.json +1 -1
- package/dist/web-static/assets/Config-DhfQsbT1.js +0 -1
- package/dist/web-static/assets/Conventions-BobuQiOk.js +0 -1
- package/dist/web-static/assets/Dashboard-Bj28rnDe.js +0 -1
- package/dist/web-static/assets/Knowledge-Y1lX6vor.js +0 -2
- package/dist/web-static/assets/PipelineDetail-DGKz18zu.js +0 -4
- package/dist/web-static/assets/PipelineTemplates-D4zvL6I1.js +0 -1
- package/dist/web-static/assets/Pipelines-CR9oD3Xy.js +0 -2
- package/dist/web-static/assets/ProjectDetail-RfdtEvTT.js +0 -1
- package/dist/web-static/assets/Projects-RGIPdiJn.js +0 -1
- package/dist/web-static/assets/Quality-BdvL1VQn.js +0 -3
- package/dist/web-static/assets/Sessions-CorfQV78.js +0 -2
- package/dist/web-static/assets/Skills-BJt0OrKj.js +0 -1
- package/dist/web-static/assets/client-BhcjNvkG.js +0 -1
- package/dist/web-static/assets/index-D8kSmB5h.js +0 -2
- package/dist/web-static/assets/useSmartPolling-DYAVOihL.js +0 -1
- /package/dist/web-static/assets/{ConfirmDialog-CVzB7X5y.js → ConfirmDialog-BKfwMp04.js} +0 -0
- /package/dist/web-static/assets/{ErrorState-DXHA8lr8.js → ErrorState-BOInXmfg.js} +0 -0
- /package/dist/web-static/assets/{exportCsv-CSExJI8h.js → exportCsv-Dm5Y5M_E.js} +0 -0
- /package/dist/web-static/assets/{vendor-editor-B1NX2ipj.js → vendor-editor-CYLOGES5.js} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,Dn as n,Fn as r,Gn as i,It as a,Qn as o,Rn as s,Ut as c,Yn as l,en as u,er as d,gn as f,gr as p,qn as m,rn as h,s as g}from"./vendor-DRGPi8ui.js";import{c as _}from"./vendor-react-DJI9oneq.js";import{a as v,n as y,r as b}from"./vendor-query-DqPOMnuX.js";import{c as x}from"./vendor-flow-srkes8If.js";import{_ as ee,ft as S,g as te,ht as C,i as ne,o as re,ot as w,t as ie}from"./client-BvVpIixG.js";import{a as T,l as E,n as D,r as O,t as k}from"./ui-CDL3BZ13.js";import{n as A,t as j}from"./vendor-motion-CQmdgnI8.js";import{t as ae}from"./useDebounce-DNfPs3Tv.js";import{t as oe}from"./ErrorState-BOInXmfg.js";import{t as se}from"./exportCsv-Dm5Y5M_E.js";import{t as M}from"./ConfirmDialog-BKfwMp04.js";import{n as ce,t as le}from"./Skeleton-B7PVDJJ_.js";import{t as ue}from"./Pagination-lp8b_3NR.js";import{t as de}from"./BatchProgress-BQ533tSf.js";var N=e(p(),1),P=x(),F={pending:{label:`待执行`,color:`text-gray-400`,icon:(0,P.jsx)(i,{className:`w-4 h-4`})},in_progress:{label:`执行中`,color:`text-blue-500`,icon:(0,P.jsx)(f,{className:`w-4 h-4 animate-spin`})},retrying:{label:`重试中`,color:`text-yellow-500`,icon:(0,P.jsx)(h,{className:`w-4 h-4 animate-spin`})},blocked:{label:`已阻塞`,color:`text-red-500`,icon:(0,P.jsx)(m,{className:`w-4 h-4`})},done:{label:`已完成`,color:`text-green-500`,icon:(0,P.jsx)(l,{className:`w-4 h-4`})},failed:{label:`失败`,color:`text-red-500`,icon:(0,P.jsx)(m,{className:`w-4 h-4`})},skipped:{label:`已跳过`,color:`text-gray-400`,icon:(0,P.jsx)(t,{className:`w-4 h-4`})}};function I({node:e}){let[t,n]=(0,N.useState)(!1),r=F[e.status],{data:i,isLoading:a}=b({queryKey:[`node-attempts`,e.node_id],queryFn:()=>w(e.node_id).then(e=>e.data),enabled:t});return(0,P.jsxs)(`div`,{className:`border border-gray-700 rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`button`,{className:`w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-800/50 transition-colors text-left`,onClick:()=>n(e=>!e),children:[(0,P.jsx)(`span`,{className:T(`flex-shrink-0`,r.color),children:r.icon}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-100 truncate`,children:e.title}),(0,P.jsx)(k,{variant:e.status===`done`?`success`:e.status===`blocked`||e.status===`failed`?`error`:e.status===`in_progress`||e.status===`retrying`?`warning`:`default`,children:r.label}),e.attempt_count>0&&(0,P.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[e.attempt_count,` 次尝试`]})]}),(0,P.jsxs)(`div`,{className:`text-xs text-gray-500 mt-0.5`,children:[`阶段: `,e.phase,` · 超时: `,e.timeout_sec,`s`]})]}),(0,P.jsx)(`span`,{className:`text-gray-500 flex-shrink-0`,children:t?(0,P.jsx)(d,{className:`w-4 h-4`}):(0,P.jsx)(o,{className:`w-4 h-4`})})]}),(0,P.jsx)(A,{children:t&&(0,P.jsx)(j.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,P.jsx)(`div`,{className:`px-4 pb-4 pt-2 border-t border-gray-700 bg-gray-900/50`,children:a?(0,P.jsx)(`div`,{className:`text-sm text-gray-500 py-2`,children:`加载执行记录...`}):i?.items.length===0?(0,P.jsx)(`div`,{className:`text-sm text-gray-500 py-2`,children:`暂无执行记录`}):(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-400 mb-2`,children:`执行记录`}),i?.items.map(e=>(0,P.jsxs)(`div`,{className:T(`rounded p-3 text-xs space-y-1`,e.status===`passed`?`bg-green-900/20 border border-green-800/30`:e.status===`failed`?`bg-red-900/20 border border-red-800/30`:`bg-gray-800/50 border border-gray-700`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`span`,{className:`font-medium text-gray-300`,children:[`第 `,e.attempt_number,` 次 · 策略: `,e.strategy_id]}),(0,P.jsx)(`span`,{className:T(`font-medium`,e.status===`passed`?`text-green-400`:e.status===`failed`?`text-red-400`:`text-blue-400`),children:e.status===`passed`?`通过`:e.status===`failed`?`失败`:`执行中`})]}),e.started_at&&(0,P.jsxs)(`div`,{className:`text-gray-500`,children:[g(new Date(e.started_at),`HH:mm:ss`),e.ended_at&&` → ${g(new Date(e.ended_at),`HH:mm:ss`)}`]}),e.verification_result&&!e.verification_result.passed&&(0,P.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,P.jsx)(`div`,{className:`text-gray-400`,children:e.verification_result.diagnostics}),e.verification_result.missing_items.length>0&&(0,P.jsx)(`ul`,{className:`text-red-400 space-y-0.5 pl-3`,children:e.verification_result.missing_items.map((e,t)=>(0,P.jsxs)(`li`,{children:[`· `,e]},t))})]})]},e.attempt_id))]})})})})]})}function L({nodes:e}){let t=e.length,n=e.filter(e=>e.status===`done`).length,r=e.filter(e=>e.status===`blocked`||e.status===`failed`).length,i=e.filter(e=>e.status===`retrying`).length,a=t>0?Math.round(n/t*100):0;return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,P.jsxs)(`span`,{className:`text-gray-400`,children:[`进度: `,n,`/`,t,` 节点完成`]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[i>0&&(0,P.jsxs)(`span`,{className:`text-yellow-400`,children:[i,` 重试中`]}),r>0&&(0,P.jsxs)(`span`,{className:`text-red-400`,children:[r,` 已阻塞`]}),(0,P.jsxs)(`span`,{className:`text-gray-400`,children:[a,`%`]})]})]}),(0,P.jsx)(`div`,{className:`h-2 bg-gray-700 rounded-full overflow-hidden`,children:(0,P.jsx)(`div`,{className:T(`h-full rounded-full transition-all duration-500`,r>0?`bg-red-500`:a===100?`bg-green-500`:`bg-blue-500`),style:{width:`${a}%`}})})]})}function fe({projectPath:e}){let{data:t,isLoading:n,isError:r}=b({queryKey:[`plan`,`by-project`,e],queryFn:()=>S(e).then(e=>e.data)});if(n)return(0,P.jsx)(`div`,{className:`text-sm text-gray-500 py-4 text-center`,children:`加载执行计划...`});if(r||!t)return null;let i={draft:{label:`草稿`,color:`default`},approved:{label:`已确认`,color:`default`},running:{label:`执行中`,color:`warning`},completed:{label:`已完成`,color:`success`},failed:{label:`失败`,color:`error`},aborted:{label:`已中止`,color:`error`}}[t.status];return(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-200 truncate`,children:t.goal}),(0,P.jsx)(k,{variant:i.color,children:i.label})]}),(0,P.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[`模板: `,t.template_id,` · 创建: `,g(new Date(t.created_at),`MM-dd HH:mm`)]})]})}),(0,P.jsx)(L,{nodes:t.nodes}),(0,P.jsx)(`div`,{className:`space-y-2`,children:t.nodes.map(e=>(0,P.jsx)(I,{node:e},e.node_id))})]})}function pe({open:e,planId:r,templateName:o,goal:s,nodes:c,onApprove:u,onReject:d,onClose:f,loading:p=!1}){let[m,h]=(0,N.useState)(new Set),g=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return e?(0,P.jsx)(A,{children:(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,P.jsxs)(j.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`bg-white rounded-lg shadow-xl max-w-3xl w-full max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-gray-200`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900`,children:`确认执行计划`}),(0,P.jsxs)(`p`,{className:`text-sm text-gray-500 mt-1`,children:[`模板:`,o]})]}),(0,P.jsx)(`button`,{onClick:f,className:`text-gray-400 hover:text-gray-600 transition-colors`,children:(0,P.jsx)(a,{className:`h-5 w-5`})})]}),(0,P.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`目标`}),(0,P.jsx)(`p`,{className:`text-gray-900`,children:s})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h3`,{className:`text-sm font-medium text-gray-700 mb-3`,children:[`执行节点(共 `,c.length,` 个)`]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:c.map((e,r)=>(0,P.jsxs)(`div`,{className:`border border-gray-200 rounded-lg overflow-hidden`,children:[(0,P.jsxs)(`button`,{onClick:()=>g(e.node_id),className:`w-full flex items-center justify-between p-4 hover:bg-gray-50 transition-colors text-left`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 flex-1`,children:[(0,P.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-full bg-blue-100 text-blue-600 text-sm font-medium`,children:r+1}),(0,P.jsxs)(`div`,{className:`flex-1`,children:[(0,P.jsx)(`div`,{className:`font-medium text-gray-900`,children:e.title}),(0,P.jsxs)(`div`,{className:`text-sm text-gray-500 flex items-center gap-2 mt-1`,children:[(0,P.jsx)(`span`,{className:`px-2 py-0.5 bg-gray-100 rounded text-xs`,children:e.phase}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(l,{className:`h-3 w-3`}),e.completion_rules.length,` 条完成规则`]}),e.dependencies&&e.dependencies.length>0&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(n,{className:`h-3 w-3`}),`依赖 `,e.dependencies.length,` 个节点`]})]})]})]}),(0,P.jsx)(j.div,{animate:{rotate:m.has(e.node_id)?180:0},transition:{duration:.2},children:(0,P.jsx)(`svg`,{className:`h-5 w-5 text-gray-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,P.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),(0,P.jsx)(A,{children:m.has(e.node_id)&&(0,P.jsx)(j.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`border-t border-gray-200 bg-gray-50`,children:(0,P.jsx)(`div`,{className:`p-4 space-y-3`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h4`,{className:`text-xs font-medium text-gray-700 mb-2`,children:`完成条件`}),(0,P.jsx)(`div`,{className:`space-y-1.5`,children:e.completion_rules.map((e,n)=>(0,P.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.required?(0,P.jsx)(t,{className:`h-4 w-4 text-orange-500 flex-shrink-0 mt-0.5`}):(0,P.jsx)(i,{className:`h-4 w-4 text-gray-400 flex-shrink-0 mt-0.5`}),(0,P.jsxs)(`div`,{className:`flex-1`,children:[(0,P.jsx)(`span`,{className:`text-gray-700`,children:e.description}),(0,P.jsxs)(`span`,{className:`ml-2 text-xs text-gray-500`,children:[`(`,e.type===`artifact`?`文件检查`:e.type===`command`?`命令执行`:`人工确认`,`)`]})]})]},n))})]})})})})]},e.node_id))})]}),(0,P.jsxs)(`div`,{className:`flex items-start gap-3 p-4 bg-yellow-50 border border-yellow-200 rounded-lg`,children:[(0,P.jsx)(t,{className:`h-5 w-5 text-yellow-600 flex-shrink-0 mt-0.5`}),(0,P.jsxs)(`div`,{className:`text-sm text-yellow-800`,children:[(0,P.jsx)(`p`,{className:`font-medium mb-1`,children:`确认后将开始执行`}),(0,P.jsx)(`p`,{children:`系统将按照节点顺序自动执行,每个节点完成后会自动推进到下一个节点。`})]})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-3 p-6 border-t border-gray-200 bg-gray-50`,children:[(0,P.jsx)(D,{variant:`secondary`,onClick:d,disabled:p,children:`拒绝`}),(0,P.jsx)(D,{variant:`primary`,onClick:u,loading:p,icon:l,children:`确认执行`})]})]})})}):null}function R(){let e=v(),t=_(),[o,l]=(0,N.useState)(``),d=ae(o),[f,p]=(0,N.useState)(``),[m,x]=(0,N.useState)(`all`),[S,w]=(0,N.useState)(1),[T,A]=(0,N.useState)(20),[F,I]=(0,N.useState)(new Set),[L,R]=(0,N.useState)(``),[z,B]=(0,N.useState)(null),[V,H]=(0,N.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:me,isLoading:he,isError:ge,refetch:U}=b({queryKey:[`pipelines`,`active`],queryFn:()=>C({status:`active`,page_size:100}).then(e=>e.data)}),{data:W,refetch:_e}=b({queryKey:[`pipelines`,`completed`,d,f,S,T],queryFn:()=>C({status:`completed`,search:d||void 0,complexity:f||void 0,page:S,page_size:T}).then(e=>e.data)}),G=y({mutationFn:e=>ee(e),onSuccess:()=>e.invalidateQueries({queryKey:[`pipelines`]})}),K=y({mutationFn:()=>te(),onSuccess:()=>e.invalidateQueries({queryKey:[`pipelines`]})}),q=y({mutationFn:e=>re(e),onSuccess:t=>{e.invalidateQueries({queryKey:[`pipelines`]}),I(new Set),t.failed.length>0&&alert(`关闭完成:成功 ${t.success.length} 个,失败 ${t.failed.length} 个\n失败原因:\n${t.errors.map(e=>`${e.id}: ${e.reason}`).join(`
|
|
2
|
+
`)}`)}}),J=y({mutationFn:e=>ne(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`pipelines`]}),B(null)}}),Y=y({mutationFn:e=>ie(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`pipelines`]}),B(null)}});if(he)return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(le,{rows:2}),(0,P.jsx)(ce,{count:5})]});if(ge)return(0,P.jsx)(oe,{message:`Pipeline 数据加载失败`,onRetry:()=>U()});let X=me?.items||[],Z=W?.items||[],Q=W?.total||0,$=X.filter(e=>!L||e.requirement.toLowerCase().includes(L.toLowerCase())||e.project.toLowerCase().includes(L.toLowerCase())),ve=m===`all`||m===`active`,ye=m===`all`||m===`completed`,be=Math.ceil(Q/T);return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,P.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[X.length,` 个活跃 · `,Q,` 个已完成`,F.size>0&&` · 已选 ${F.size} 个`]}),(0,P.jsxs)(`select`,{value:m,onChange:e=>{x(e.target.value),w(1)},className:`px-3 py-1.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,P.jsx)(`option`,{value:`all`,children:`全部状态`}),(0,P.jsx)(`option`,{value:`active`,children:`仅活跃`}),(0,P.jsx)(`option`,{value:`completed`,children:`仅已完成`})]})]}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[$.length>0&&F.size>0&&(0,P.jsxs)(D,{variant:`danger`,size:`sm`,icon:a,onClick:()=>{F.size!==0&&H({open:!0,title:`批量关闭 Pipeline`,description:`确认关闭选中的 ${F.size} 个 Pipeline?`,count:F.size,onConfirm:()=>{q.mutate(Array.from(F)),H(e=>({...e,open:!1}))}})},loading:q.isPending,children:[`批量关闭 (`,F.size,`)`]}),$.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(D,{variant:`secondary`,size:`sm`,onClick:()=>{F.size===$.length?I(new Set):I(new Set($.map(e=>e.id)))},children:F.size===$.length?`取消全选`:`全选`}),(0,P.jsx)(D,{variant:`danger`,size:`sm`,icon:c,onClick:()=>{H({open:!0,title:`清理过期 Pipeline`,description:`确认关闭所有过期 Pipeline?`,onConfirm:()=>{K.mutate(),H(e=>({...e,open:!1}))}})},loading:K.isPending,children:`清理过期`})]}),(0,P.jsx)(D,{variant:`secondary`,size:`sm`,icon:h,onClick:()=>U(),children:`刷新`}),(0,P.jsx)(D,{variant:`secondary`,size:`sm`,icon:s,onClick:()=>{let e=[...X,...Z];se(`pipelines-${g(new Date,`yyyyMMdd-HHmmss`)}.csv`,[`ID`,`需求`,`复杂度`,`状态`,`项目`,`创建时间`],e.map(e=>[e.id,e.requirement,e.complexity,e.status,e.project,e.createdAt]))},children:`导出 CSV`})]})]}),q.isPending&&(0,P.jsx)(de,{total:F.size,done:0,label:`批量关闭中`}),ve&&X.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,P.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-500 uppercase tracking-wider`,children:[`活跃中 (`,$.length,`/`,X.length,`)`]}),(0,P.jsxs)(`div`,{className:`relative w-64`,children:[(0,P.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,P.jsx)(`input`,{type:`text`,placeholder:`搜索活跃 Pipeline...`,value:L,onChange:e=>R(e.target.value),className:`w-full pl-10 pr-4 py-1.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`})]})]}),(0,P.jsx)(`div`,{className:`space-y-3`,children:$.map((e,r)=>(0,P.jsx)(j.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.05},children:(0,P.jsxs)(O,{className:`!p-0 overflow-hidden cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>t(`/pipelines/${e.id}`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between p-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:F.has(e.id),onChange:t=>{t.stopPropagation(),I(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})},onClick:e=>e.stopPropagation(),className:`h-4 w-4 rounded border-gray-300 text-blue-600 flex-shrink-0`}),(0,P.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg`,style:{backgroundColor:`#10b98120`},children:(0,P.jsx)(n,{className:`h-5 w-5`,style:{color:`#10b981`}})}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`font-medium text-gray-900 truncate`,children:e.requirement}),(0,P.jsxs)(`div`,{className:`text-sm text-gray-500 flex items-center gap-3 mt-1`,children:[(0,P.jsx)(k,{variant:`primary`,size:`sm`,children:`动态`}),(0,P.jsx)(`span`,{children:e.project}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(i,{className:`h-3 w-3`}),g(E(e.createdAt),`MM-dd HH:mm`)]})]}),e.type===`dynamic`&&e.nodeConfig&&(0,P.jsxs)(`div`,{className:`mt-2 flex items-center gap-3 text-xs text-gray-600`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(n,{className:`h-3 w-3`}),e.nodeConfig.totalNodes,` 个节点`]}),e.nodeConfig.boundSkills.length>0&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`⚡ `,e.nodeConfig.boundSkills.length,` 个技能`]}),(0,P.jsxs)(`span`,{className:`text-gray-400`,children:[`节点类型:`,e.nodeConfig.nodeTypes.map(e=>e.split(/[_\-.]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)).join(` → `)]})]})]})]}),(0,P.jsx)(D,{variant:`danger`,size:`sm`,icon:a,onClick:t=>{t.stopPropagation(),H({open:!0,title:`关闭 Pipeline`,description:`确认关闭此 Pipeline?`,onConfirm:()=>{G.mutate(e.id),H(e=>({...e,open:!1}))}})},loading:G.isPending,children:`关闭`})]}),(0,P.jsx)(`div`,{className:`border-t border-gray-100`,children:(0,P.jsx)(fe,{projectPath:e.project})})]})},e.id))})]}),ye&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold text-gray-500 uppercase tracking-wider mb-3`,children:`历史记录`}),(0,P.jsxs)(O,{children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center mb-4 pb-4 border-b border-gray-100`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1 min-w-[240px] max-w-sm`,children:[(0,P.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,P.jsx)(`input`,{type:`text`,placeholder:`搜索需求描述...`,value:o,onChange:e=>{l(e.target.value),w(1)},className:`w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`})]}),(0,P.jsxs)(`select`,{value:f,onChange:e=>{p(e.target.value),w(1)},className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,P.jsx)(`option`,{value:``,children:`全部复杂度`}),(0,P.jsx)(`option`,{value:`simple`,children:`简单`}),(0,P.jsx)(`option`,{value:`moderate`,children:`中等`}),(0,P.jsx)(`option`,{value:`complex`,children:`复杂`})]})]}),(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`text-left text-sm text-gray-600`,children:[(0,P.jsx)(`th`,{className:`pb-3 font-medium`,children:`需求`}),(0,P.jsx)(`th`,{className:`pb-3 font-medium`,children:`项目`}),(0,P.jsx)(`th`,{className:`pb-3 font-medium`,children:`类型`}),(0,P.jsx)(`th`,{className:`pb-3 font-medium`,children:`复杂度`}),(0,P.jsx)(`th`,{className:`pb-3 font-medium`,children:`时间`}),(0,P.jsx)(`th`,{className:`pb-3 font-medium`,children:`操作`})]})}),(0,P.jsx)(`tbody`,{className:`text-sm`,children:Z.map(e=>(0,P.jsxs)(`tr`,{className:`border-t border-gray-50 hover:bg-gray-50 cursor-pointer`,onClick:()=>t(`/pipelines/${e.id}`),children:[(0,P.jsx)(`td`,{className:`py-3 max-w-xs truncate`,children:e.requirement}),(0,P.jsx)(`td`,{className:`py-3`,children:e.project}),(0,P.jsx)(`td`,{className:`py-3`,children:(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(k,{size:`sm`,variant:`primary`,children:`动态编排`}),e.nodeConfig&&(0,P.jsxs)(`div`,{className:`text-xs text-gray-500 space-y-0.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(n,{className:`h-3 w-3`}),e.nodeConfig.totalNodes,` 节点`,e.nodeConfig.boundSkills.length>0&&(0,P.jsxs)(`span`,{className:`ml-1`,children:[`· ⚡ `,e.nodeConfig.boundSkills.length,` 技能`]})]}),(0,P.jsx)(`div`,{className:`text-gray-400 max-w-[200px] truncate`,children:e.nodeConfig.nodeTypes.map(e=>e.split(/[_\-.]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)).join(` → `)})]})]})}),(0,P.jsx)(`td`,{className:`py-3`,children:(0,P.jsx)(k,{size:`sm`,variant:e.complexity===`complex`?`danger`:e.complexity===`moderate`?`warning`:`default`,children:e.complexity||`-`})}),(0,P.jsx)(`td`,{className:`py-3 text-gray-500`,children:g(E(e.createdAt),`MM-dd HH:mm`)}),(0,P.jsx)(`td`,{className:`py-3`,children:(0,P.jsx)(D,{variant:`ghost`,size:`sm`,icon:r,onClick:n=>{n.stopPropagation(),t(`/pipelines/${e.id}`)},children:`查看`})})]},e.id))})]})}),Q===0&&(0,P.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:`暂无历史记录`}),Q>0&&(0,P.jsx)(ue,{currentPage:S,totalPages:be,onPageChange:w,pageSize:T,onPageSizeChange:e=>{A(e),w(1)},totalItems:Q})]})]}),z&&(0,P.jsx)(pe,{open:!0,planId:z,templateName:`待确认计划`,goal:`执行计划`,nodes:[],onApprove:()=>J.mutate(z),onReject:()=>Y.mutate(z),onClose:()=>B(null),loading:J.isPending||Y.isPending}),(0,P.jsx)(M,{open:V.open,title:V.title,description:V.description,count:V.count,variant:`danger`,onConfirm:V.onConfirm,onCancel:()=>H({...V,open:!1})})]})}export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{$t as t,Bt as n,Dn as r,Ft as i,Gt as a,Hn as o,It as s,Mn as c,Pn as l,Qt as u,Ut as d,Vt as ee,Wt as f,Yn as p,Zt as m,ar as h,cn as te,cr as ne,dr as re,gr as g,kn as _,nr as v,pr as y,qn as b,rn as ie,s as x,tn as S,tr as C,yn as w}from"./vendor-DRGPi8ui.js";import{c as ae,l as oe}from"./vendor-react-DJI9oneq.js";import{a as se,n as T,r as E}from"./vendor-query-DqPOMnuX.js";import{c as D}from"./vendor-flow-srkes8If.js";import{$ as O,$t as k,B as ce,D as le,M as ue,N as A,Nt as de,Pt as fe,V as pe,_t as j,an as M,bt as me,en as he,gt as ge,p as N,vt as P,z as _e}from"./client-BvVpIixG.js";import{a as ve,c as ye,l as F,n as I,r as L,t as R}from"./ui-CDL3BZ13.js";import{n as z}from"./Toast-BbB3oD2a.js";import{t as be}from"./Pagination-lp8b_3NR.js";import{t as xe}from"./Breadcrumb-DtfwnOx6.js";var B=e(g(),1),V=D(),Se={spec:{label:`规格`,icon:c,color:`text-blue-600`,bg:`bg-blue-50`,border:`border-blue-200`},security:{label:`安全`,icon:m,color:`text-red-600`,bg:`bg-red-50`,border:`border-red-200`},quality:{label:`质量`,icon:l,color:`text-purple-600`,bg:`bg-purple-50`,border:`border-purple-200`},test:{label:`测试`,icon:f,color:`text-green-600`,bg:`bg-green-50`,border:`border-green-200`},performance:{label:`性能`,icon:i,color:`text-orange-600`,bg:`bg-orange-50`,border:`border-orange-200`}},H={fail:{label:`失败`,icon:b,color:`text-red-600`,bg:`bg-red-50`,border:`border-red-300`},warn:{label:`警告`,icon:n,color:`text-yellow-600`,bg:`bg-yellow-50`,border:`border-yellow-300`},pass:{label:`通过`,icon:p,color:`text-green-600`,bg:`bg-green-50`,border:`border-green-300`}};function Ce({level:e}){let t=H[e];if(!t)return(0,V.jsx)(R,{size:`sm`,children:e});let n=t.icon;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border ${t.bg} ${t.color} ${t.border}`,children:[(0,V.jsx)(n,{className:`h-3 w-3`}),t.label]})}function we({category:e}){let t=Se[e];if(!t)return(0,V.jsx)(R,{size:`sm`,children:e});let n=t.icon;return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border ${t.bg} ${t.color} ${t.border}`,children:[(0,V.jsx)(n,{className:`h-3 w-3`}),t.label]})}function U(){let{encodedPath:e}=oe(),l=ae(),f=se(),[p,m]=(0,B.useState)(`sessions`),[ne,g]=(0,B.useState)(!1),[b,S]=(0,B.useState)(``),[w,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(``),[A,j]=(0,B.useState)(null),[M,N]=(0,B.useState)(1),[P,Se]=(0,B.useState)(20),[H,U]=(0,B.useState)(null),Ee=async e=>{try{let t=await me(e);await navigator.clipboard.writeText(t.data.context),U(e),z(`上下文已复制,请粘贴到 Claude Code 进行修复`,`success`),setTimeout(()=>U(null),3e3)}catch{z(`复制失败`,`error`)}},W=e?encodeURIComponent(e):``,{data:G,isLoading:De,isError:Oe,error:ke}=E({queryKey:[`project`,e],queryFn:()=>ge(W).then(e=>e.data),enabled:!!e}),{data:K}=E({queryKey:[`claudemd`,e],queryFn:()=>_e(W).then(e=>e.data),enabled:!!e&&p===`claudemd`}),{data:q}=E({queryKey:[`claudemd-modules`,e],queryFn:()=>ce(W).then(e=>e.data),enabled:!!e&&p===`claudemd`}),Ae=T({mutationFn:()=>le(W),onSuccess:()=>{f.invalidateQueries({queryKey:[`projects`]}),l(`/projects`)},onError:e=>z(e.message||`删除失败`,`error`)}),je=T({mutationFn:e=>he(W,e),onSuccess:()=>{f.invalidateQueries({queryKey:[`claudemd`,e]}),D(!1)},onError:e=>z(e.message||`保存失败`,`error`)}),Me=T({mutationFn:()=>ue(W),onSuccess:t=>{f.invalidateQueries({queryKey:[`claudemd`,e]}),j({success:!0,message:t.data.distilled?`蒸馏完成,压缩 ${t.data.reduction}%(${t.data.before} → ${t.data.after} 字符):${t.data.summary}`:t.data.message??`无需蒸馏`})},onError:e=>{j({success:!1,message:e.message})}}),[J,Y]=(0,B.useState)(null),[Ne,Pe]=(0,B.useState)(!1),[Fe,Ie]=(0,B.useState)(!1),[X,Z]=(0,B.useState)(null),[Le,Re]=(0,B.useState)(!1),[Q,$]=(0,B.useState)(null);return Oe?(0,V.jsxs)(`div`,{className:`flex items-center justify-center h-96 text-red-500`,children:[`加载失败:`,ke?.message||`未知错误`]}):De||!G?(0,V.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})}):(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(xe,{items:[{label:`项目列表`,path:`/projects`},{label:G.projectName}]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,V.jsx)(I,{variant:`ghost`,size:`sm`,icon:re,onClick:()=>l(`/projects`),children:`返回`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-blue-50`,children:(0,V.jsx)(_,{className:`h-5 w-5 text-blue-600`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xl font-bold text-gray-900`,children:G.projectName}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:G.projectPath})]})]})]}),(0,V.jsx)(I,{variant:`danger`,size:`sm`,icon:d,onClick:()=>g(!0),children:`删除项目`})]}),ne&&(0,V.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,V.jsxs)(L,{className:`max-w-md`,children:[(0,V.jsxs)(`h3`,{className:`text-lg font-bold text-red-600 mb-3 flex items-center gap-2`,children:[(0,V.jsx)(n,{className:`h-5 w-5`}),`危险操作:删除项目`]}),(0,V.jsxs)(`div`,{className:`bg-red-50 border border-red-200 rounded-lg p-3 mb-4`,children:[(0,V.jsxs)(`p`,{className:`text-sm text-red-800 font-medium mb-2`,children:[`⚠️ 此操作将永久删除项目 `,(0,V.jsx)(`strong`,{children:G.projectName}),` 的所有监控数据:`]}),(0,V.jsxs)(`ul`,{className:`text-xs text-red-700 space-y-1 ml-4 list-disc`,children:[(0,V.jsx)(`li`,{children:`所有会话记录`}),(0,V.jsx)(`li`,{children:`所有 Pipeline 历史`}),(0,V.jsx)(`li`,{children:`所有质量问题记录`}),(0,V.jsx)(`li`,{children:`所有事件日志`}),(0,V.jsx)(`li`,{children:`所有知识节点`})]}),(0,V.jsx)(`p`,{className:`text-xs text-red-800 font-bold mt-2`,children:`此操作无法撤销,无法恢复!`})]}),(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 mb-2`,children:[`请输入项目名称 `,(0,V.jsx)(`code`,{className:`px-1.5 py-0.5 bg-gray-100 rounded text-red-600`,children:G.projectName}),` 以确认删除:`]}),(0,V.jsx)(`input`,{type:`text`,value:b,onChange:e=>S(e.target.value),placeholder:`输入项目名称`,className:`w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-red-500`,autoFocus:!0})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>{g(!1),S(``)},children:`取消`}),(0,V.jsx)(I,{variant:`danger`,size:`sm`,disabled:b!==G.projectName,onClick:()=>{b===G.projectName&&(Ae.mutate(),g(!1),S(``))},children:`确认删除`})]})]})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-5 gap-4`,children:[(0,V.jsx)(L,{className:`!p-4 cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>m(`sessions`),children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(y,{className:`h-8 w-8 text-blue-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-2xl font-bold text-gray-900`,children:G.sessions.total}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`会话`})]})]})}),(0,V.jsx)(L,{className:`!p-4 cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>m(`pipelines`),children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(r,{className:`h-8 w-8 text-green-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-2xl font-bold text-gray-900`,children:G.pipelines.total}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Pipeline`})]})]})}),(0,V.jsx)(L,{className:`!p-4 cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>m(`api`),children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(a,{className:`h-8 w-8 text-purple-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-2xl font-bold text-gray-900`,children:G.events.total}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`事件`})]})]})}),(0,V.jsx)(L,{className:`!p-4 cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>m(`quality`),children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(u,{className:`h-8 w-8 text-orange-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-2xl font-bold text-gray-900`,children:G.quality.total}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`质量`})]})]})}),(0,V.jsx)(L,{className:`!p-4 cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>m(`knowledge`),children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(h,{className:`h-8 w-8 text-pink-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-2xl font-bold text-gray-900`,children:G.knowledge.total}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`知识`})]})]})})]}),(0,V.jsx)(`div`,{className:`flex gap-1 bg-gray-100 p-1 rounded-lg w-fit flex-wrap`,children:[{key:`sessions`,label:`会话`},{key:`pipelines`,label:`Pipeline`},{key:`quality`,label:`质量问题`},{key:`knowledge`,label:`知识文档`},{key:`rules`,label:`规则管理`},{key:`convention`,label:`自定义规范`},{key:`claudemd`,label:`CLAUDE.md`},{key:`environment`,label:`环境初始化`}].map(e=>(0,V.jsx)(`button`,{onClick:()=>m(e.key),className:`px-4 py-2 rounded-md text-sm font-medium transition-colors ${p===e.key?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`}`,children:e.label},e.key))}),p===`sessions`&&(0,V.jsxs)(L,{children:[(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`w-full`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsxs)(`tr`,{className:`text-left text-sm text-gray-600`,children:[(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`会话 ID`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`首条对话`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`状态`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`开始时间`})]})}),(0,V.jsx)(`tbody`,{className:`text-sm`,children:(()=>{let e=G.sessions.items;return Math.ceil(e.length/P),(0,V.jsxs)(V.Fragment,{children:[e.slice((M-1)*P,M*P).map(e=>(0,V.jsxs)(`tr`,{onClick:()=>l(`/sessions/${e.session_id}`,{state:{from:`/projects/${W}`}}),className:`border-t border-gray-50 hover:bg-blue-50 cursor-pointer transition-colors`,children:[(0,V.jsx)(`td`,{className:`py-3 font-mono text-xs`,children:e.session_id.slice(0,12)}),(0,V.jsx)(`td`,{className:`py-3 text-gray-700 max-w-md truncate`,title:e.first_requirement,children:e.first_requirement?e.first_requirement:`(无对话记录)`}),(0,V.jsx)(`td`,{className:`py-3`,children:(0,V.jsx)(R,{size:`sm`,className:ye(e.status),children:e.status})}),(0,V.jsx)(`td`,{className:`py-3 text-gray-500`,children:x(F(e.start_time),`MM-dd HH:mm`)})]},e.session_id)),e.length===0&&(0,V.jsx)(`tr`,{children:(0,V.jsx)(`td`,{colSpan:4,className:`py-8 text-center text-gray-400`,children:`暂无会话记录`})})]})})()})]})}),(()=>{let e=G.sessions.items,t=Math.ceil(e.length/P);return e.length>P?(0,V.jsx)(`div`,{className:`mt-4`,children:(0,V.jsx)(be,{currentPage:M,totalPages:t,onPageChange:N,pageSize:P,onPageSizeChange:e=>{Se(e),N(1)},totalItems:e.length})}):null})()]}),p===`pipelines`&&(0,V.jsx)(L,{children:(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`w-full`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsxs)(`tr`,{className:`text-left text-sm text-gray-600`,children:[(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`需求`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`阶段`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`时间`})]})}),(0,V.jsx)(`tbody`,{className:`text-sm`,children:G.pipelines.items.map(e=>(0,V.jsxs)(`tr`,{onClick:()=>l(`/pipelines/${e.id}`,{state:{from:`/projects/${W}`}}),className:`border-t border-gray-50 hover:bg-blue-50 cursor-pointer transition-colors`,children:[(0,V.jsx)(`td`,{className:`py-3 max-w-xs truncate`,children:e.requirement}),(0,V.jsx)(`td`,{className:`py-3`,children:(0,V.jsx)(R,{size:`sm`,children:e.phase})}),(0,V.jsx)(`td`,{className:`py-3 text-gray-500`,children:x(F(e.updated_at),`MM-dd HH:mm`)})]},e.id))})]})})}),p===`quality`&&(0,V.jsxs)(L,{children:[(0,V.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,V.jsxs)(`p`,{className:`text-sm text-gray-600`,children:[`共 `,G.quality.total,` 个质量问题`]})}),(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`w-full`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsxs)(`tr`,{className:`text-left text-sm text-gray-600`,children:[(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`问题`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`级别`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`分类`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`状态`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`,children:`时间`}),(0,V.jsx)(`th`,{className:`pb-3 font-medium`})]})}),(0,V.jsx)(`tbody`,{className:`text-sm`,children:G.quality.items.map(e=>(0,V.jsxs)(`tr`,{className:`border-t border-gray-50 hover:bg-blue-50 transition-colors`,children:[(0,V.jsx)(`td`,{className:`py-3 max-w-xs truncate`,children:e.message}),(0,V.jsx)(`td`,{className:`py-3`,children:(0,V.jsx)(Ce,{level:e.level})}),(0,V.jsx)(`td`,{className:`py-3`,children:(0,V.jsx)(we,{category:e.category})}),(0,V.jsx)(`td`,{className:`py-3`,children:(0,V.jsx)(R,{size:`sm`,variant:e.resolved?`success`:`default`,children:e.resolved?`已解决`:`未解决`})}),(0,V.jsx)(`td`,{className:`py-3 text-gray-500`,children:x(F(e.created_at),`MM-dd HH:mm`)}),(0,V.jsx)(`td`,{className:`py-3`,children:!e.resolved&&(0,V.jsxs)(`button`,{onClick:()=>Ee(e.id),className:`flex items-center gap-1 px-2 py-1 text-xs text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors`,title:`复制上下文到剪贴板`,children:[H===e.id?(0,V.jsx)(v,{className:`h-3.5 w-3.5 text-green-500`}):(0,V.jsx)(o,{className:`h-3.5 w-3.5`}),H===e.id?`已复制`:`复制`]})})]},e.id))})]})})]}),p===`knowledge`&&(0,V.jsx)(L,{children:(0,V.jsx)(`div`,{className:`space-y-3`,children:G.knowledge.items.map(e=>(0,V.jsx)(`div`,{className:`p-4 border border-gray-100 rounded-lg hover:bg-blue-50 cursor-pointer transition-colors`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsx)(c,{className:`h-5 w-5 text-blue-500 flex-shrink-0 mt-0.5`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 mb-1`,children:e.title}),(0,V.jsxs)(`p`,{className:`text-sm text-gray-600 line-clamp-2`,children:[e.content?.substring(0,150),`...`]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-gray-400`,children:[(0,V.jsx)(R,{size:`sm`,children:e.node_type}),(0,V.jsxs)(`span`,{children:[`更新于 `,x(F(e.updated_at),`MM-dd HH:mm`)]})]})]})]})},e.id))})}),p===`rules`&&(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(L,{title:`意图识别规则`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:G.rules.intentRules.slice(0,10).map(e=>(0,V.jsx)(`div`,{className:`flex items-center justify-between p-3 border border-gray-100 rounded-lg`,children:(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(R,{size:`sm`,children:e.rule_type}),(0,V.jsx)(`code`,{className:`text-xs text-gray-600`,children:e.pattern})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-xs text-gray-400`,children:[(0,V.jsxs)(`span`,{children:[`命中 `,e.hit_count,` 次`]}),(0,V.jsxs)(`span`,{children:[`置信度 `,(e.confidence*100).toFixed(0),`%`]})]})]})},e.id))})}),(0,V.jsx)(L,{title:`任务模式`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:G.rules.taskPatterns.slice(0,10).map(e=>(0,V.jsxs)(`div`,{className:`p-3 border border-gray-100 rounded-lg`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,V.jsx)(R,{size:`sm`,children:e.task_type}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[(0,V.jsx)(ee,{className:`h-3 w-3`}),(0,V.jsxs)(`span`,{children:[`效果 `,(e.effectiveness_score*100).toFixed(0),`%`]})]})]}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 mb-1`,children:e.failure_pattern}),(0,V.jsxs)(`p`,{className:`text-xs text-gray-500`,children:[`策略:`,e.prevention_strategy]})]},e.id))})})]}),p===`convention`&&e&&(0,V.jsx)(Te,{encodedPath:W}),p===`claudemd`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(L,{children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(c,{className:`h-5 w-5 text-blue-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:`CLAUDE.md`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:K?.exists?`${(K.size/1024).toFixed(1)} KB · ${K.hasAutoSection?`含自动区块`:`纯用户内容`}`:`文件不存在`})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(I,{variant:`ghost`,size:`sm`,icon:ie,onClick:()=>f.invalidateQueries({queryKey:[`claudemd`,e]}),children:`刷新`}),K?.exists&&(0,V.jsx)(I,{variant:`secondary`,size:`sm`,icon:i,onClick:()=>{j(null),Me.mutate()},disabled:Me.isPending,title:`AI 蒸馏:压缩冗余内容,保留核心规范`,children:Me.isPending?`蒸馏中...`:`蒸馏`}),K?.exists&&!w&&(0,V.jsx)(I,{size:`sm`,icon:te,onClick:()=>{k(K.content||``),D(!0)},children:`编辑`})]})]})}),A&&(0,V.jsx)(L,{children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsx)(`p`,{className:`text-sm ${A.success?`text-gray-900`:`text-red-600`}`,children:A.message}),(0,V.jsx)(I,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>j(null)})]})}),w&&(0,V.jsxs)(L,{children:[(0,V.jsx)(`textarea`,{className:`w-full px-3 py-2 text-sm border border-gray-200 rounded-md font-mono h-96 resize-y`,value:O,onChange:e=>k(e.target.value)}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end mt-3`,children:[(0,V.jsx)(I,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>D(!1),children:`取消`}),(0,V.jsx)(I,{size:`sm`,icon:C,onClick:()=>je.mutate(O),children:`保存`})]})]}),!w&&K?.exists&&(0,V.jsx)(L,{title:`内容预览`,children:(0,V.jsx)(`pre`,{className:`text-xs text-gray-700 bg-gray-50 p-4 rounded-md overflow-auto max-h-96 whitespace-pre-wrap font-mono`,children:K.content})}),(0,V.jsx)(L,{title:`子模块 (${q?.total??0})`,children:q?.items.length===0?(0,V.jsx)(`p`,{className:`text-sm text-gray-400`,children:`未检测到子模块`}):(0,V.jsx)(`div`,{className:`space-y-2`,children:q?.items.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-3 border border-gray-100 rounded-lg`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(_,{className:`h-4 w-4 text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900`,children:e.name}),(0,V.jsx)(`p`,{className:`text-xs text-gray-400`,children:e.relativePath})]})]}),(0,V.jsx)(R,{size:`sm`,variant:e.hasClaudeMd?`success`:`default`,children:e.hasClaudeMd?`已有 CLAUDE.md`:`未生成`})]},e.path))})})]}),p===`environment`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(L,{children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`font-medium text-gray-900 mb-1`,children:`环境检测 & 项目初始化`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`检测项目技术栈、创建 .claude-forge 目录、自动生成 CLAUDE.md(如不存在)`})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,V.jsx)(I,{variant:`secondary`,size:`sm`,icon:t,onClick:async()=>{Pe(!0),Y(null);try{Y((await pe(W)).data.profile)}catch(e){Y({error:String(e)})}finally{Pe(!1)}},disabled:Ne,children:Ne?`检测中...`:`环境检测`}),(0,V.jsx)(I,{size:`sm`,icon:i,onClick:async()=>{Ie(!0),Z(null);try{let t=await fe(W);Z({success:t.data.success,message:t.data.message,claudeMdGenerated:t.data.claudeMdGenerated}),Y(t.data.profile),f.invalidateQueries({queryKey:[`claudemd`,e]}),f.invalidateQueries({queryKey:[`project`,e]})}catch(e){Z({success:!1,message:String(e)})}finally{Ie(!1)}},disabled:Fe,children:Fe?`初始化中...`:`一键初始化`}),(0,V.jsx)(I,{size:`sm`,icon:c,onClick:async()=>{Re(!0),$(null);try{let t=await de(W);$({success:t.data.success,message:t.data.message}),t.data.skipped||(f.invalidateQueries({queryKey:[`conventions`,e]}),f.invalidateQueries({queryKey:[`claudemd`,e]}))}catch(e){$({success:!1,message:String(e)})}finally{Re(!1)}},disabled:Le,children:Le?`生成中...`:`初始化规范`})]})]})}),X&&(0,V.jsx)(L,{children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[X.success?(0,V.jsx)(C,{className:`h-4 w-4 text-green-500 mt-0.5 flex-shrink-0`}):(0,V.jsx)(s,{className:`h-4 w-4 text-red-500 mt-0.5 flex-shrink-0`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium ${X.success?`text-gray-900`:`text-red-600`}`,children:X.message}),X.claudeMdGenerated&&(0,V.jsx)(`p`,{className:`text-xs text-green-600 mt-0.5`,children:`CLAUDE.md 已自动生成`})]})]}),(0,V.jsx)(I,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>Z(null)})]})}),Q&&(0,V.jsx)(L,{children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[Q.success?(0,V.jsx)(C,{className:`h-4 w-4 text-green-500 mt-0.5 flex-shrink-0`}):(0,V.jsx)(s,{className:`h-4 w-4 text-red-500 mt-0.5 flex-shrink-0`}),(0,V.jsx)(`p`,{className:ve(`text-sm font-medium`,Q.success?`text-gray-900`:`text-red-600`),children:Q.message})]}),(0,V.jsx)(I,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>$(null)})]})}),J&&!(`error`in J)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(L,{title:`技术栈`,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mb-1`,children:`项目名称`}),(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:J.projectName})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mb-1`,children:`包管理器`}),(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:J.packageManager||`未检测到`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mb-1`,children:`测试框架`}),(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:J.testFramework||`未检测到`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mb-1`,children:`构建工具`}),(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:J.buildTool||`未检测到`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mb-1`,children:`Linter`}),(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:J.linter||`未检测到`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mb-1`,children:`Formatter`}),(0,V.jsx)(`p`,{className:`font-medium text-gray-900`,children:J.formatter||`未检测到`})]})]})}),J.languages.length>0&&(0,V.jsx)(L,{title:`检测到的语言`,children:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:J.languages.map((e,t)=>(0,V.jsxs)(R,{size:`sm`,children:[e.name,e.version?` ${e.version}`:``]},t))})}),J.frameworks.length>0&&(0,V.jsx)(L,{title:`检测到的框架`,children:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:J.frameworks.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 bg-blue-50 rounded-md`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-blue-700`,children:e.name}),(0,V.jsx)(`span`,{className:`text-xs text-blue-400`,children:e.category})]},t))})}),Object.keys(J.scripts).length>0&&(0,V.jsx)(L,{title:`常用脚本`,children:(0,V.jsx)(`div`,{className:`space-y-1`,children:Object.entries(J.scripts).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 text-sm py-1 border-b border-gray-50 last:border-0`,children:[(0,V.jsx)(`span`,{className:`font-mono text-blue-600 flex-shrink-0 w-24`,children:e}),(0,V.jsx)(`span`,{className:`text-gray-600 font-mono text-xs break-all`,children:t})]},e))})}),J.keyDirectories.length>0&&(0,V.jsx)(L,{title:`关键目录`,children:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:J.keyDirectories.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 bg-gray-50 rounded-md`,children:[(0,V.jsx)(_,{className:`h-3.5 w-3.5 text-gray-400`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-700 font-mono`,children:e})]},t))})})]}),J&&`error`in J&&(0,V.jsx)(L,{children:(0,V.jsxs)(`p`,{className:`text-sm text-red-600`,children:[`检测失败:`,J.error]})})]})]})}function Te({encodedPath:e}){let[t,n]=(0,B.useState)(`bindings`),[r,a]=(0,B.useState)(!1),[o,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(!1),d=se(),{data:ee,isLoading:f}=E({queryKey:[`project-conventions`,e],queryFn:()=>j(e).then(e=>e.data)}),{data:p}=E({queryKey:[`global-conventions`],queryFn:()=>O().then(e=>e.data),enabled:r}),{data:m}=E({queryKey:[`project-custom-yaml`,e],queryFn:()=>P(e).then(e=>e.data),enabled:l}),h=T({mutationFn:t=>N(e,t).then(e=>e.data),onSuccess:t=>{z(`已绑定:${t.convention.name}`,`success`),a(!1),d.invalidateQueries({queryKey:[`project-conventions`,e]})}}),re=T({mutationFn:t=>k(e,t).then(e=>e.data),onSuccess:()=>{z(`已解绑`,`success`),d.invalidateQueries({queryKey:[`project-conventions`,e]})}}),g=T({mutationFn:()=>A(e).then(e=>e.data),onSuccess:t=>{z(t.isIncremental?`增量蒸馏完成,版本 ${t.convention.version}`:`蒸馏完成,生成 ${t.convention.name}`,`success`),d.invalidateQueries({queryKey:[`project-conventions`,e]}),n(`custom`)}}),_=T({mutationFn:t=>M(e,t).then(e=>e.data),onSuccess:()=>{z(`保存成功`,`success`),u(!1),d.invalidateQueries({queryKey:[`project-conventions`,e]})}}),v=ee?.bindings||[],y=ee?.custom,b=(p?.items||[]).filter(e=>!v.some(t=>t.id===e.id)),x={official:`bg-amber-50 text-amber-700`,user:`bg-blue-50 text-blue-700`,community:`bg-purple-50 text-purple-700`},C={official:`官方`,user:`用户`,community:`社区`};return f?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,V.jsx)(ie,{className:`h-6 w-6 animate-spin text-blue-500`})}):(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`div`,{className:`flex gap-1 bg-gray-100 rounded-lg p-1`,children:[`bindings`,`custom`].map(e=>(0,V.jsx)(`button`,{onClick:()=>n(e),className:`px-4 py-1.5 text-sm font-medium rounded-md transition-colors flex items-center gap-1.5 ${t===e?`bg-white text-gray-900 shadow-sm`:`text-gray-500 hover:text-gray-700`}`,children:e===`bindings`?`绑定的规范 (${v.length})`:(0,V.jsxs)(V.Fragment,{children:[`蒸馏规范`,y&&(0,V.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700`,children:`实际生效`})]})},e))}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[t===`bindings`&&(0,V.jsxs)(`button`,{onClick:()=>a(!r),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:[(0,V.jsx)(w,{className:`h-3.5 w-3.5`}),`绑定规范`]}),t===`custom`&&(0,V.jsxs)(`button`,{onClick:()=>g.mutate(),disabled:g.isPending||v.length===0,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 transition-colors`,title:v.length===0?`请先绑定至少一个规范`:``,children:[(0,V.jsx)(i,{className:`h-3.5 w-3.5 ${g.isPending?`animate-pulse`:``}`}),g.isPending?`蒸馏中...`:y?`重新蒸馏`:`生成蒸馏规范`]})]})]}),r&&(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-blue-200 p-4 space-y-3`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-700`,children:`从全局规范库选择绑定`}),b.length===0?(0,V.jsx)(`p`,{className:`text-sm text-gray-400`,children:`所有全局规范已全部绑定`}):(0,V.jsx)(`div`,{className:`grid gap-2`,children:b.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 rounded-lg`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-900`,children:e.name}),(0,V.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs rounded-full ${x[e.source]||`bg-gray-100 text-gray-600`}`,children:C[e.source]||e.source}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`v`,e.version]})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:e.description})]}),(0,V.jsx)(`button`,{onClick:()=>h.mutate(e.id),disabled:h.isPending,className:`px-3 py-1.5 text-xs bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:`绑定`})]},e.id))}),(0,V.jsx)(`button`,{onClick:()=>a(!1),className:`text-xs text-gray-400 hover:text-gray-600`,children:`关闭`})]}),t===`bindings`&&(0,V.jsx)(`div`,{className:`space-y-3`,children:v.length===0?(0,V.jsxs)(`div`,{className:`text-center py-12 bg-white rounded-xl border border-gray-200`,children:[(0,V.jsx)(ne,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500 text-sm`,children:`尚未绑定任何规范`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:`点击「绑定规范」从全局规范库选择`})]}):v.map(e=>(0,V.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,V.jsx)(`span`,{className:`font-medium text-gray-900`,children:e.name}),(0,V.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs rounded-full font-medium ${x[e.source]||`bg-gray-100 text-gray-600`}`,children:C[e.source]||e.source}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`v`,e.version]})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.description}),(0,V.jsxs)(`div`,{className:`flex gap-3 mt-2 text-xs text-gray-400`,children:[(0,V.jsxs)(`span`,{children:[e.roles?Object.keys(e.roles).length:0,` 个角色`]}),(0,V.jsxs)(`span`,{children:[e.quality_standards?.length||0,` 条质量标准`]})]})]}),(0,V.jsx)(`button`,{onClick:()=>re.mutate(e.id),disabled:re.isPending,className:`ml-4 p-1.5 text-gray-400 hover:text-red-500 rounded transition-colors`,title:`解绑`,children:(0,V.jsx)(s,{className:`h-4 w-4`})})]})},e.id))}),t===`custom`&&(0,V.jsx)(`div`,{className:`space-y-4`,children:y?(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-gray-100`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`font-semibold text-gray-900`,children:y.name}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`v`,y.version]}),(0,V.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700 border border-green-200`,children:`项目真实规范`})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:y.description})]}),!l&&(0,V.jsxs)(`button`,{onClick:()=>{c(m?.yaml||``),u(!0)},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-100 text-gray-700 hover:bg-gray-200 rounded-lg transition-colors`,children:[(0,V.jsx)(te,{className:`h-3.5 w-3.5`}),`编辑 YAML`]})]}),(0,V.jsx)(`div`,{className:`p-5`,children:l?(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`textarea`,{value:o||m?.yaml||``,onChange:e=>c(e.target.value),rows:24,className:`w-full px-3 py-2 text-xs border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(`button`,{onClick:()=>_.mutate(o),disabled:_.isPending,className:`flex items-center gap-1.5 px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:[(0,V.jsx)(S,{className:`h-3.5 w-3.5`}),_.isPending?`保存中...`:`保存`]}),(0,V.jsx)(`button`,{onClick:()=>u(!1),className:`px-4 py-2 text-sm bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors`,children:`取消`})]})]}):(0,V.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[y.principles&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500 uppercase tracking-wide mb-2`,children:`核心原则`}),(0,V.jsx)(`pre`,{className:`text-xs text-gray-700 bg-gray-50 rounded-lg p-3 whitespace-pre-wrap border border-gray-100 max-h-48 overflow-y-auto`,children:typeof y.principles==`string`?y.principles:JSON.stringify(y.principles,null,2)})]}),y.quality_standards&&y.quality_standards.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 uppercase tracking-wide mb-2`,children:[`质量标准 (`,y.quality_standards.length,`)`]}),(0,V.jsxs)(`div`,{className:`space-y-1`,children:[y.quality_standards.slice(0,5).map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-gray-600`,children:[(0,V.jsx)(`span`,{className:`mt-0.5 px-1.5 py-0.5 rounded text-xs font-medium ${e.severity===`must`?`bg-red-50 text-red-600`:e.severity===`should`?`bg-yellow-50 text-yellow-600`:`bg-gray-100 text-gray-500`}`,children:e.severity||`rule`}),(0,V.jsx)(`span`,{children:e.rule||String(e)})]},t)),y.quality_standards.length>5&&(0,V.jsxs)(`p`,{className:`text-xs text-gray-400`,children:[`...还有 `,y.quality_standards.length-5,` 条`]})]})]})]})})]}):(0,V.jsxs)(`div`,{className:`text-center py-12 bg-white rounded-xl border border-gray-200`,children:[(0,V.jsx)(i,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500 text-sm`,children:`尚未生成蒸馏规范`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:v.length>0?`点击「生成蒸馏规范」将绑定的规范融合为项目专属规范`:`请先绑定至少一个规范,再生成蒸馏规范`})]})})]})}export{U as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{$t as t,Dn as n,Gn as r,It as i,Kt as a,Qt as ee,Rn as o,Ut as s,Yt as te,ar as ne,en as c,fr as l,gr as u,kn as d,lr as re,pr as ie,qt as ae,s as f}from"./vendor-DRGPi8ui.js";import{c as p}from"./vendor-react-DJI9oneq.js";import{a as oe,n as m,r as h}from"./vendor-query-DqPOMnuX.js";import{c as g}from"./vendor-flow-srkes8If.js";import{D as _,r as v,yt as se}from"./client-BvVpIixG.js";import{a as y,l as ce,r as b,t as x}from"./ui-CDL3BZ13.js";import{t as S}from"./vendor-motion-CQmdgnI8.js";import{n as C}from"./Toast-BbB3oD2a.js";import{t as w}from"./exportCsv-Dm5Y5M_E.js";import{t as T}from"./Pagination-lp8b_3NR.js";var E=e(u(),1),D=g();function O(){let e=p(),u=oe(),[g,O]=(0,E.useState)(``),[k,A]=(0,E.useState)(1),[j,le]=(0,E.useState)(12),[M,ue]=(0,E.useState)(`lastActivity`),[N,P]=(0,E.useState)(!1),[F,I]=(0,E.useState)(!1),[L,R]=(0,E.useState)(null),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)(``),[U,W]=(0,E.useState)(new Set),[de,G]=(0,E.useState)(!1),[K,q]=(0,E.useState)(``),[J,Y]=(0,E.useState)(!1),{data:fe}=h({queryKey:[`project-meta-all`],queryFn:()=>v.get(`/projects/meta/all`).then(e=>e.data),staleTime:3e4}),X=fe||{},Z=m({mutationFn:({projectPath:e,meta:t})=>v.put(`/projects/${encodeURIComponent(e)}/meta`,t),onSuccess:()=>{u.invalidateQueries({queryKey:[`project-meta-all`]})},onError:e=>C(e.message||`操作失败`,`error`)}),Q=(e,t)=>{t.stopPropagation();let n=X[e]||{notes:``,tags:[],archived:!1};B(n.notes),H(n.tags.join(`, `)),R(e)},pe=()=>{if(!L)return;let e=X[L]||{notes:``,tags:[],archived:!1};Z.mutate({projectPath:L,meta:{notes:z.trim(),tags:V.split(`,`).map(e=>e.trim()).filter(Boolean),archived:e.archived}}),R(null)},me=(e,t)=>{t.stopPropagation();let n=X[e]||{notes:``,tags:[],archived:!1};Z.mutate({projectPath:e,meta:{...n,archived:!n.archived}})},he=(e,t)=>{t.stopPropagation(),W(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ge=()=>{for(let e of U){let t=X[e]||{notes:``,tags:[],archived:!1};Z.mutate({projectPath:e,meta:{...t,archived:!0}})}C(`已归档 ${U.size} 个项目`,`success`),W(new Set)},_e=async()=>{Y(!0);let e=0;for(let t of U)try{await _(encodeURIComponent(t)),e++}catch{}Y(!1),G(!1),q(``),W(new Set),u.invalidateQueries({queryKey:[`projects`]}),C(`已删除 ${e} 个项目`,`success`)},{data:ve,isLoading:ye}=h({queryKey:[`projects`],queryFn:()=>se({limit:1e3}).then(e=>e.data)});if(ye)return(0,D.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,D.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});let be=ve?.items||[],xe=e=>{M===e?P(e=>!e):(ue(e),P(!1)),A(1)},$=be.filter(e=>{if(X[e.projectPath]?.archived&&!F)return!1;if(!g)return!0;let t=g.toLowerCase();return e.projectName.toLowerCase().includes(t)||e.projectPath.toLowerCase().includes(t)}).sort((e,t)=>{let n=0;return M===`name`?n=e.projectName.localeCompare(t.projectName):M===`lastActivity`?n=(e.lastActivity||``).localeCompare(t.lastActivity||``):M===`sessionCount`?n=e.sessionCount-t.sessionCount:M===`totalEvents`&&(n=e.totalEvents-t.totalEvents),N?n:-n}),Se=Math.ceil($.length/j),Ce=$.slice((k-1)*j,k*j);return(0,D.jsxs)(`div`,{className:`space-y-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`项目管理`}),(0,D.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`查看所有被 Forge 管理的项目`})]}),(0,D.jsx)(`div`,{className:`flex items-center gap-3`,children:U.size>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(x,{variant:`info`,children:[U.size,` 个已选`]}),(0,D.jsxs)(`button`,{onClick:ge,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:[(0,D.jsx)(l,{className:`h-4 w-4`}),`批量归档`]}),(0,D.jsxs)(`button`,{onClick:()=>G(!0),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors`,children:[(0,D.jsx)(s,{className:`h-4 w-4`}),`批量删除`]}),(0,D.jsxs)(`button`,{onClick:()=>W(new Set),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 hover:bg-gray-50 rounded-lg transition-colors`,children:[(0,D.jsx)(i,{className:`h-4 w-4`}),`取消选择`]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(x,{variant:`info`,children:[$.length,` 个项目`]}),(0,D.jsxs)(`button`,{onClick:()=>I(!F),className:y(`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg transition-colors`,F?`bg-blue-50 text-blue-600`:`text-gray-600 hover:bg-gray-50`),children:[(0,D.jsx)(l,{className:`h-4 w-4`}),F?`隐藏归档`:`显示归档`]}),(0,D.jsxs)(`button`,{onClick:()=>{let e=[`项目名称`,`项目路径`,`会话数`,`Pipeline 数`,`质量问题数`,`总事件数`,`最近活动`],t=$.map(e=>[e.projectName,e.projectPath,e.sessionCount,e.pipelineCount,e.qualityIssueCount,e.totalEvents,e.lastActivity||``]);w(`projects-${new Date().toISOString().slice(0,10)}.csv`,e,t)},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-gray-600 hover:bg-gray-50 rounded-lg transition-colors`,children:[(0,D.jsx)(o,{className:`h-4 w-4`}),`导出 CSV`]})]})})]}),(0,D.jsx)(b,{children:(0,D.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1`,children:[(0,D.jsx)(c,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,D.jsx)(`input`,{type:`text`,placeholder:`搜索项目名称或路径...`,value:g,onChange:e=>{O(e.target.value),A(1)},className:`w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,D.jsx)(`span`,{className:`text-gray-500`,children:`排序:`}),[{key:`name`,label:`名称`},{key:`lastActivity`,label:`活动时间`},{key:`sessionCount`,label:`会话数`},{key:`totalEvents`,label:`事件数`}].map(({key:e,label:t})=>(0,D.jsxs)(`button`,{onClick:()=>xe(e),className:y(`px-3 py-1.5 rounded-lg transition-colors flex items-center gap-1`,M===e?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`),children:[t,M===e&&(0,D.jsx)(re,{className:y(`h-3 w-3`,N&&`rotate-180`)})]},e))]})]})}),(0,D.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Ce.map((i,o)=>{let s=i.projectPath,c=X[s]||{notes:``,tags:[],archived:!1};return(0,D.jsx)(S.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:o*.03},children:(0,D.jsx)(b,{className:y(`!p-0 overflow-hidden cursor-pointer hover:shadow-md transition-shadow h-full flex flex-col`,c.archived&&`opacity-60`),onClick:()=>e(`/projects/${encodeURIComponent(s)}`),children:(0,D.jsxs)(`div`,{className:`p-4 flex-1 flex flex-col`,children:[(0,D.jsxs)(`div`,{className:`flex items-start gap-3 mb-3`,children:[(0,D.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-blue-50 flex-shrink-0`,children:(0,D.jsx)(d,{className:`h-5 w-5 text-blue-600`})}),(0,D.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`h3`,{className:`font-semibold text-gray-900 truncate`,children:i.projectName}),c.archived&&(0,D.jsx)(l,{className:`h-3.5 w-3.5 text-gray-400 flex-shrink-0`})]}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500 truncate`,children:s}),c.tags.length>0&&(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:c.tags.map(e=>(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 bg-blue-50 text-blue-600 text-xs rounded`,children:[(0,D.jsx)(a,{className:`h-2.5 w-2.5`}),e]},e))}),c.notes&&(0,D.jsx)(`p`,{className:`text-xs text-gray-400 mt-1 truncate`,children:c.notes})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,D.jsx)(`button`,{onClick:e=>he(s,e),className:y(`p-1 rounded transition-colors`,U.has(s)?`text-blue-600`:`text-gray-300 hover:text-gray-500`),title:`选择`,children:U.has(s)?(0,D.jsx)(te,{className:`h-3.5 w-3.5`}):(0,D.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,D.jsx)(`button`,{onClick:e=>me(s,e),className:`p-1 text-gray-400 hover:text-gray-600 rounded`,title:c.archived?`取消归档`:`归档`,children:(0,D.jsx)(l,{className:`h-3.5 w-3.5`})}),(0,D.jsx)(`button`,{onClick:e=>Q(s,e),className:`p-1 text-gray-400 hover:text-gray-600 rounded`,title:`项目设置`,children:(0,D.jsx)(t,{className:`h-3.5 w-3.5`})})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-sm flex-1`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-600`,children:[(0,D.jsx)(ie,{className:`h-4 w-4 flex-shrink-0`}),(0,D.jsxs)(`span`,{children:[i.sessionCount,` 会话`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-600`,children:[(0,D.jsx)(n,{className:`h-4 w-4 flex-shrink-0`}),(0,D.jsxs)(`span`,{children:[i.pipelineCount,` Pipeline`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-600`,children:[(0,D.jsx)(ee,{className:`h-4 w-4 flex-shrink-0`}),(0,D.jsxs)(`span`,{children:[i.qualityIssueCount,` 质量`]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-600`,children:[(0,D.jsx)(ne,{className:`h-4 w-4 flex-shrink-0`}),(0,D.jsxs)(`span`,{children:[i.totalEvents,` 事件`]})]})]}),i.lastActivity&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-gray-400 mt-3 pt-3 border-t border-gray-100`,children:[(0,D.jsx)(r,{className:`h-3 w-3 flex-shrink-0`}),(0,D.jsxs)(`span`,{children:[`最近活动:`,f(ce(i.lastActivity),`MM-dd HH:mm`)]})]})]})})},s)})}),$.length===0&&(0,D.jsxs)(`div`,{className:`text-center py-12`,children:[(0,D.jsx)(d,{className:`h-12 w-12 text-gray-300 mx-auto mb-3`}),(0,D.jsx)(`p`,{className:`text-gray-500`,children:`暂无项目`}),(0,D.jsx)(`p`,{className:`text-sm text-gray-400 mt-1`,children:`在任意目录使用 Claude Code 后,项目将自动出现在这里`})]}),$.length>0&&(0,D.jsx)(T,{currentPage:k,totalPages:Se,onPageChange:A,pageSize:j,onPageSizeChange:e=>{le(e),A(1)},totalItems:$.length}),de&&(0,D.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:()=>{G(!1),q(``)},children:(0,D.jsxs)(`div`,{className:`bg-white rounded-xl shadow-xl w-full max-w-md p-6`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`h3`,{className:`text-lg font-bold text-red-600 mb-3 flex items-center gap-2`,children:[(0,D.jsx)(s,{className:`h-5 w-5`}),`危险操作:批量删除项目`]}),(0,D.jsxs)(`div`,{className:`bg-red-50 border border-red-200 rounded-lg p-3 mb-4`,children:[(0,D.jsxs)(`p`,{className:`text-sm text-red-800 font-medium mb-2`,children:[`⚠️ 此操作将永久删除 `,(0,D.jsxs)(`strong`,{children:[U.size,` 个项目`]}),` 的所有监控数据:`]}),(0,D.jsxs)(`ul`,{className:`text-xs text-red-700 space-y-1 ml-4 list-disc`,children:[(0,D.jsx)(`li`,{children:`所有会话记录`}),(0,D.jsx)(`li`,{children:`所有 Pipeline 历史`}),(0,D.jsx)(`li`,{children:`所有质量问题记录`}),(0,D.jsx)(`li`,{children:`所有事件日志`}),(0,D.jsx)(`li`,{children:`所有知识节点`})]}),(0,D.jsx)(`p`,{className:`text-xs text-red-800 font-bold mt-2`,children:`此操作无法撤销,无法恢复!`})]}),(0,D.jsxs)(`div`,{className:`mb-4`,children:[(0,D.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 mb-2`,children:[`请输入 `,(0,D.jsx)(`code`,{className:`px-1.5 py-0.5 bg-gray-100 rounded text-red-600`,children:`删除`}),` 以确认批量删除:`]}),(0,D.jsx)(`input`,{type:`text`,value:K,onChange:e=>q(e.target.value),placeholder:`输入「删除」二字`,className:`w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-red-500`,autoFocus:!0})]}),(0,D.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,D.jsx)(`button`,{onClick:()=>{G(!1),q(``)},className:`px-4 py-2 text-sm text-gray-600 hover:bg-gray-50 rounded-lg`,children:`取消`}),(0,D.jsx)(`button`,{disabled:K!==`删除`||J,onClick:_e,className:`px-4 py-2 text-sm bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed`,children:J?`删除中...`:`确认删除`})]})]})}),L&&(0,D.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:()=>R(null),children:(0,D.jsxs)(`div`,{className:`bg-white rounded-xl shadow-xl w-full max-w-md p-6`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,D.jsx)(`h3`,{className:`font-semibold text-gray-900`,children:`项目设置`}),(0,D.jsx)(`button`,{onClick:()=>R(null),className:`text-gray-400 hover:text-gray-600`,children:(0,D.jsx)(i,{className:`h-5 w-5`})})]}),(0,D.jsx)(`p`,{className:`text-xs text-gray-500 mb-4 truncate`,children:L}),(0,D.jsxs)(`div`,{className:`space-y-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`标签(逗号分隔)`}),(0,D.jsx)(`input`,{type:`text`,value:V,onChange:e=>H(e.target.value),placeholder:`前端, 工具, 实验...`,className:`w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`备注`}),(0,D.jsx)(`textarea`,{value:z,onChange:e=>B(e.target.value),rows:3,placeholder:`项目说明、注意事项...`,className:`w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none`})]})]}),(0,D.jsxs)(`div`,{className:`flex justify-end gap-2 mt-5`,children:[(0,D.jsx)(`button`,{onClick:()=>R(null),className:`px-4 py-2 text-sm text-gray-600 hover:bg-gray-50 rounded-lg`,children:`取消`}),(0,D.jsx)(`button`,{onClick:pe,className:`px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700`,children:`保存`})]})]})})]})}export{O as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{An as t,Bt as n,Ft as r,Hn as i,It as a,Mn as o,On as ee,Pn as s,Qn as c,Rn as te,Wt as ne,Yn as re,Zt as l,en as ie,er as u,gr as d,nr as ae,qn as f,s as p,tr as m,vn as oe}from"./vendor-DRGPi8ui.js";import{a as se,n as h,r as g}from"./vendor-query-DqPOMnuX.js";import{c as _}from"./vendor-flow-srkes8If.js";import{Ht as ce,Ut as le,bt as ue,f as de,j as fe,jt as pe,u as me,xt as v}from"./client-BvVpIixG.js";import{a as y,l as b,n as x,r as S,t as C}from"./ui-CDL3BZ13.js";import{n as w,t as T}from"./vendor-motion-CQmdgnI8.js";import{t as he}from"./useDebounce-DNfPs3Tv.js";import{n as ge}from"./Toast-BbB3oD2a.js";import{t as _e}from"./ErrorState-BOInXmfg.js";import{t as ve}from"./exportCsv-Dm5Y5M_E.js";import{t as ye}from"./ConfirmDialog-BKfwMp04.js";import{t as be}from"./Pagination-lp8b_3NR.js";var E=e(d(),1),D=_(),O={spec:{label:`规格`,icon:o,color:`text-blue-600`,bg:`bg-blue-50`,border:`border-blue-200`},security:{label:`安全`,icon:l,color:`text-red-600`,bg:`bg-red-50`,border:`border-red-200`},quality:{label:`质量`,icon:s,color:`text-purple-600`,bg:`bg-purple-50`,border:`border-purple-200`},test:{label:`测试`,icon:ne,color:`text-green-600`,bg:`bg-green-50`,border:`border-green-200`},performance:{label:`性能`,icon:r,color:`text-orange-600`,bg:`bg-orange-50`,border:`border-orange-200`}},k={fail:{label:`失败`,icon:f,color:`text-red-600`,bg:`bg-red-50`,border:`border-red-300`},warn:{label:`警告`,icon:n,color:`text-yellow-600`,bg:`bg-yellow-50`,border:`border-yellow-300`},pass:{label:`通过`,icon:re,color:`text-green-600`,bg:`bg-green-50`,border:`border-green-300`}};function A({level:e}){let t=k[e];if(!t)return(0,D.jsx)(C,{size:`sm`,children:e});let n=t.icon;return(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border ${t.bg} ${t.color} ${t.border}`,children:[(0,D.jsx)(n,{className:`h-3 w-3`}),t.label]})}function j({category:e}){let t=O[e];if(!t)return(0,D.jsx)(C,{size:`sm`,children:e});let n=t.icon;return(0,D.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border ${t.bg} ${t.color} ${t.border}`,children:[(0,D.jsx)(n,{className:`h-3 w-3`}),t.label]})}function M(){let e=se(),[n,r]=(0,E.useState)(``),o=he(n),[s,ne]=(0,E.useState)(``),[l,d]=(0,E.useState)(``),[f,_]=(0,E.useState)(``),[M,xe]=(0,E.useState)(``),[N,Se]=(0,E.useState)(!1),[P,F]=(0,E.useState)(1),[I,Ce]=(0,E.useState)(20),[L,R]=(0,E.useState)(null),[z,B]=(0,E.useState)(null),[V,H]=(0,E.useState)(new Set),[U,W]=(0,E.useState)(`list`),[we,Te]=(0,E.useState)(new Set),[G,K]=(0,E.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:Ee,isError:De,refetch:Oe}=g({queryKey:[`quality-unresolved`],queryFn:()=>pe().then(e=>e.data)}),{data:ke}=g({queryKey:[`quality-history`,s,l,f,M,o],queryFn:()=>v({limit:500,level:s||void 0,category:l||void 0,resolved:f===`resolved`?!0:f===`unresolved`?!1:void 0,project_path:M||void 0,search:o||void 0}).then(e=>e.data)}),{data:q}=g({queryKey:[`quality-history`,`all`],queryFn:()=>v({limit:500}).then(e=>e.data)}),J=h({mutationFn:e=>le(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]})}}),Y=h({mutationFn:e=>fe(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]})}}),Ae=h({mutationFn:()=>ce(),onSuccess:()=>{e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]})}}),je=h({mutationFn:e=>me(e),onSuccess:t=>{H(new Set),e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]}),t.failed.length>0&&alert(`忽略完成:成功 ${t.success.length} 个,失败 ${t.failed.length} 个\n失败原因:\n${t.errors.map(e=>`${e.id}: ${e.reason}`).join(`
|
|
2
|
+
`)}`)}}),Me=h({mutationFn:e=>de(e),onSuccess:t=>{H(new Set),e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]}),t.failed.length>0&&alert(`解决完成:成功 ${t.success.length} 个,失败 ${t.failed.length} 个\n失败原因:\n${t.errors.map(e=>`${e.id}: ${e.reason}`).join(`
|
|
3
|
+
`)}`)}}),Ne=async e=>{try{let t=await ue(e);await navigator.clipboard.writeText(t.data.context),B(e),ge(`上下文已复制,请粘贴到 Claude Code 进行修复`,`success`),setTimeout(()=>B(null),3e3)}catch{ge(`复制失败`,`error`)}},X=ke?.items||[],Pe=X.reduce((e,t)=>{let n=t.project_path?.split(`/`).pop()||`未知项目`;return e[n]||(e[n]=[]),e[n].push(t),e},{}),Fe=Math.ceil(X.length/I),Z=X.slice((P-1)*I,P*I),Ie=q?.total||0,Q=Ee?.total||0,Le=X.filter(e=>e.level===`fail`).length,Re=X.filter(e=>e.level===`warn`).length,ze=Array.from(new Set(q?.items.map(e=>e.level)||[])),Be=Array.from(new Set(q?.items.map(e=>e.category)||[])),Ve=Array.from(new Set(q?.items.map(e=>e.project_path?.split(`/`).pop()||``).filter(Boolean)||[])),$=[s,l,f,M].filter(Boolean).length,He=()=>{let e=[`级别`,`类别`,`消息`,`项目`,`状态`,`创建时间`],t=X.map(e=>[e.level,e.category,e.message,e.project_path?.split(`/`).pop()||``,e.resolved?`已解决`:`未解决`,e.created_at?p(b(e.created_at),`yyyy-MM-dd HH:mm:ss`):``]);ve(`quality-issues-${p(new Date,`yyyyMMdd-HHmmss`)}.csv`,e,t)};return De?(0,D.jsx)(_e,{message:`质量数据加载失败`,onRetry:()=>Oe()}):(0,D.jsxs)(`div`,{className:`space-y-6`,children:[(0,D.jsx)(S,{children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1`,children:[(0,D.jsx)(ie,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,D.jsx)(`input`,{type:`text`,placeholder:`搜索问题描述...`,value:n,onChange:e=>{r(e.target.value),F(1)},className:`w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,D.jsxs)(`button`,{onClick:()=>Se(e=>!e),className:y(`flex items-center gap-1.5 px-3 py-2 text-sm rounded-lg border transition-colors`,N||$>0?`border-blue-300 bg-blue-50 text-blue-700`:`border-gray-200 text-gray-600 hover:bg-gray-50`),children:[(0,D.jsx)(ee,{className:`h-4 w-4`}),`筛选`,$>0&&(0,D.jsx)(`span`,{className:`ml-1 px-1.5 py-0.5 bg-blue-600 text-white text-xs rounded-full`,children:$}),(0,D.jsx)(u,{className:y(`h-3.5 w-3.5 transition-transform`,N&&`rotate-180`)})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[V.size>0&&(0,D.jsxs)(x,{variant:`secondary`,size:`sm`,icon:m,onClick:()=>K({open:!0,title:`批量解决问题`,description:`确认将选中的 ${V.size} 个问题标记为已解决?`,count:V.size,onConfirm:()=>{Me.mutate(Array.from(V)),K(e=>({...e,open:!1}))}}),loading:Me.isPending,children:[`解决 (`,V.size,`)`]}),V.size>0&&(0,D.jsxs)(x,{variant:`secondary`,size:`sm`,icon:a,onClick:()=>K({open:!0,title:`批量忽略问题`,description:`确认忽略选中的 ${V.size} 个问题?`,count:V.size,onConfirm:()=>{je.mutate(Array.from(V)),K(e=>({...e,open:!1}))}}),loading:je.isPending,children:[`忽略 (`,V.size,`)`]}),Q>0&&(0,D.jsx)(x,{variant:`primary`,size:`sm`,icon:m,onClick:()=>K({open:!0,title:`全部标记已修复`,description:`确认将 ${Q} 个问题全部标记为已修复?`,onConfirm:()=>{Ae.mutate(),K(e=>({...e,open:!1}))}}),loading:Ae.isPending,children:`全部已修复`}),(0,D.jsx)(x,{variant:`secondary`,size:`sm`,icon:te,onClick:()=>X.length>0&&He(),children:`导出`}),(0,D.jsxs)(`div`,{className:`flex border border-gray-200 rounded-lg overflow-hidden`,children:[(0,D.jsx)(`button`,{onClick:()=>W(`list`),className:y(`px-2.5 py-1.5 text-sm transition-colors flex items-center gap-1`,U===`list`?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`),title:`列表视图`,children:(0,D.jsx)(oe,{className:`h-4 w-4`})}),(0,D.jsx)(`button`,{onClick:()=>W(`group`),className:y(`px-2.5 py-1.5 text-sm transition-colors flex items-center gap-1`,U===`group`?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`),title:`按项目分组`,children:(0,D.jsx)(t,{className:`h-4 w-4`})})]})]})]}),N&&(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-3 pt-2 border-t border-gray-100`,children:[(0,D.jsxs)(`select`,{value:s,onChange:e=>{ne(e.target.value),F(1)},className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,D.jsx)(`option`,{value:``,children:`全部级别`}),ze.map(e=>(0,D.jsx)(`option`,{value:e,children:k[e]?.label||e},e))]}),(0,D.jsxs)(`select`,{value:l,onChange:e=>{d(e.target.value),F(1)},className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,D.jsx)(`option`,{value:``,children:`全部类别`}),Be.map(e=>(0,D.jsx)(`option`,{value:e,children:O[e]?.label||e},e))]}),(0,D.jsxs)(`select`,{value:f,onChange:e=>{_(e.target.value),F(1)},className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,D.jsx)(`option`,{value:``,children:`全部状态`}),(0,D.jsx)(`option`,{value:`resolved`,children:`已解决`}),(0,D.jsx)(`option`,{value:`unresolved`,children:`未解决`})]}),(0,D.jsxs)(`select`,{value:M,onChange:e=>{xe(e.target.value),F(1)},className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,D.jsx)(`option`,{value:``,children:`全部项目`}),Ve.map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))]})]})]})}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[(0,D.jsxs)(S,{className:`text-center`,children:[(0,D.jsx)(`div`,{className:`text-3xl font-bold text-red-600`,children:Le}),(0,D.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`失败`})]}),(0,D.jsxs)(S,{className:`text-center`,children:[(0,D.jsx)(`div`,{className:`text-3xl font-bold text-amber-600`,children:Re}),(0,D.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`警告`})]}),(0,D.jsxs)(S,{className:`text-center`,children:[(0,D.jsx)(`div`,{className:`text-3xl font-bold text-orange-600`,children:Q}),(0,D.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`未解决`})]}),(0,D.jsxs)(S,{className:`text-center`,children:[(0,D.jsx)(`div`,{className:`text-3xl font-bold text-blue-600`,children:Ie}),(0,D.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`总检查`})]})]}),(0,D.jsxs)(S,{title:`问题列表 (${X.length})`,action:X.length>0?(0,D.jsx)(`button`,{onClick:()=>{let e=U===`list`?Z.filter(e=>!e.resolved).map(e=>String(e.id)):X.filter(e=>!e.resolved).map(e=>String(e.id));V.size===e.length&&e.length>0?H(new Set):H(new Set(e))},className:`text-xs text-blue-600 hover:underline`,children:V.size>0?`取消全选`:U===`list`?`全选当前页未解决`:`全选所有未解决`}):void 0,children:[U===`list`?(0,D.jsx)(`div`,{className:`space-y-2`,children:Z.map((e,t)=>{let n=L===String(e.id||t);return(0,D.jsxs)(`div`,{className:`rounded-lg border border-gray-100 overflow-hidden`,children:[(0,D.jsxs)(T.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.02},className:y(`flex items-center gap-3 p-4 cursor-pointer transition-all`,V.has(String(e.id))?`bg-blue-50`:`hover:bg-gray-50`),onClick:()=>R(n?null:String(e.id||t)),children:[e.resolved?(0,D.jsx)(`div`,{className:`h-4 w-4 flex-shrink-0`}):(0,D.jsx)(`input`,{type:`checkbox`,checked:V.has(String(e.id)),onChange:t=>{t.stopPropagation(),H(t=>{let n=new Set(t);return n.has(String(e.id))?n.delete(String(e.id)):n.add(String(e.id)),n})},onClick:e=>e.stopPropagation(),className:`h-4 w-4 rounded border-gray-300 text-blue-600 cursor-pointer flex-shrink-0`}),(0,D.jsxs)(`div`,{className:`flex-1 grid grid-cols-1 md:grid-cols-5 gap-3 items-center min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,D.jsx)(A,{level:e.level}),(0,D.jsx)(j,{category:e.category})]}),(0,D.jsx)(`div`,{className:`md:col-span-2 min-w-0`,children:(0,D.jsx)(`p`,{className:`text-sm text-gray-700 truncate`,children:e.message})}),(0,D.jsx)(`div`,{className:`text-sm text-gray-500 truncate`,children:e.project_path?.split(`/`).pop()||`-`}),(0,D.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,D.jsx)(C,{size:`sm`,variant:e.resolved?`success`:`warning`,children:e.resolved?`已解决`:`未解决`}),(0,D.jsx)(`span`,{className:`text-xs text-gray-400 flex-shrink-0`,children:e.created_at?p(b(e.created_at),`MM-dd HH:mm`):``}),n?(0,D.jsx)(u,{className:`h-4 w-4 text-gray-400 flex-shrink-0`}):(0,D.jsx)(c,{className:`h-4 w-4 text-gray-400 flex-shrink-0`})]})]})]}),(0,D.jsx)(w,{children:n&&(0,D.jsx)(T.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,D.jsxs)(`div`,{className:`border-t border-gray-100 bg-gray-50 p-4 space-y-2 text-sm`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`完整消息:`}),(0,D.jsx)(`p`,{className:`text-gray-700 mt-1 break-words`,children:e.message})]}),e.project_path&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`项目路径:`}),(0,D.jsx)(`span`,{className:`text-gray-700 ml-1 font-mono text-xs break-all`,children:e.project_path})]}),(0,D.jsxs)(`div`,{className:`flex gap-6`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`创建时间:`}),(0,D.jsx)(`span`,{className:`text-gray-700 ml-1`,children:e.created_at?p(b(e.created_at),`yyyy-MM-dd HH:mm:ss`):`-`})]}),e.resolved_at&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`解决时间:`}),(0,D.jsx)(`span`,{className:`text-gray-700 ml-1`,children:p(b(e.resolved_at),`yyyy-MM-dd HH:mm:ss`)})]})]}),!e.resolved&&(0,D.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:z===String(e.id)?ae:i,onClick:t=>{t.stopPropagation(),Ne(String(e.id))},children:z===String(e.id)?`已复制`:`复制上下文`}),(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:m,onClick:t=>{t.stopPropagation(),J.mutate(String(e.id))},loading:J.isPending,children:`标记已修复`}),(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:a,onClick:t=>{t.stopPropagation(),Y.mutate(String(e.id))},loading:Y.isPending,children:`忽略`})]})]})})})]},e.id||t)})}):(0,D.jsx)(`div`,{className:`space-y-3`,children:Object.entries(Pe).map(([e,t])=>{let n=we.has(e),r=t.filter(e=>!e.resolved).length;return(0,D.jsxs)(`div`,{className:`border border-gray-200 rounded-lg overflow-hidden`,children:[(0,D.jsx)(`div`,{className:`flex items-center justify-between p-3 bg-gray-50 cursor-pointer hover:bg-gray-100 transition-colors`,onClick:()=>Te(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,D.jsx)(u,{className:`h-4 w-4 text-gray-500`}):(0,D.jsx)(c,{className:`h-4 w-4 text-gray-500`}),(0,D.jsx)(`span`,{className:`font-medium text-gray-900`,children:e}),(0,D.jsxs)(C,{size:`sm`,children:[t.length,` 个问题`]}),r>0&&(0,D.jsxs)(C,{size:`sm`,variant:`warning`,children:[r,` 未解决`]})]})}),(0,D.jsx)(w,{children:n&&(0,D.jsx)(T.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,D.jsx)(`div`,{className:`divide-y divide-gray-100`,children:t.map((e,t)=>{let n=L===String(e.id||t);return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(T.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:t*.01},className:y(`flex items-center gap-3 p-3 cursor-pointer transition-all`,V.has(String(e.id))?`bg-blue-50`:`hover:bg-gray-50`),onClick:()=>R(n?null:String(e.id||t)),children:[e.resolved?(0,D.jsx)(`div`,{className:`h-4 w-4 flex-shrink-0`}):(0,D.jsx)(`input`,{type:`checkbox`,checked:V.has(String(e.id)),onChange:t=>{t.stopPropagation(),H(t=>{let n=new Set(t);return n.has(String(e.id))?n.delete(String(e.id)):n.add(String(e.id)),n})},onClick:e=>e.stopPropagation(),className:`h-4 w-4 rounded border-gray-300 text-blue-600 cursor-pointer flex-shrink-0`}),(0,D.jsxs)(`div`,{className:`flex-1 grid grid-cols-1 md:grid-cols-4 gap-3 items-center min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,D.jsx)(A,{level:e.level}),(0,D.jsx)(j,{category:e.category})]}),(0,D.jsx)(`div`,{className:`md:col-span-2 min-w-0`,children:(0,D.jsx)(`p`,{className:`text-sm text-gray-700 truncate`,children:e.message})}),(0,D.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,D.jsx)(C,{size:`sm`,variant:e.resolved?`success`:`warning`,children:e.resolved?`已解决`:`未解决`}),(0,D.jsx)(`span`,{className:`text-xs text-gray-400 flex-shrink-0`,children:e.created_at?p(b(e.created_at),`MM-dd HH:mm`):``}),n?(0,D.jsx)(u,{className:`h-4 w-4 text-gray-400 flex-shrink-0`}):(0,D.jsx)(c,{className:`h-4 w-4 text-gray-400 flex-shrink-0`})]})]})]}),(0,D.jsx)(w,{children:n&&(0,D.jsx)(T.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,D.jsxs)(`div`,{className:`border-t border-gray-100 bg-gray-50 p-4 space-y-2 text-sm`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`完整消息:`}),(0,D.jsx)(`p`,{className:`text-gray-700 mt-1 break-words`,children:e.message})]}),e.project_path&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`项目路径:`}),(0,D.jsx)(`span`,{className:`text-gray-700 ml-1 font-mono text-xs break-all`,children:e.project_path})]}),(0,D.jsxs)(`div`,{className:`flex gap-6`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`创建时间:`}),(0,D.jsx)(`span`,{className:`text-gray-700 ml-1`,children:e.created_at?p(b(e.created_at),`yyyy-MM-dd HH:mm:ss`):`-`})]}),e.resolved_at&&(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-gray-500 font-medium`,children:`解决时间:`}),(0,D.jsx)(`span`,{className:`text-gray-700 ml-1`,children:p(b(e.resolved_at),`yyyy-MM-dd HH:mm:ss`)})]})]}),!e.resolved&&(0,D.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:z===String(e.id)?ae:i,onClick:t=>{t.stopPropagation(),Ne(String(e.id))},children:z===String(e.id)?`已复制`:`复制上下文`}),(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:m,onClick:t=>{t.stopPropagation(),J.mutate(String(e.id))},loading:J.isPending,children:`标记已修复`}),(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:a,onClick:t=>{t.stopPropagation(),Y.mutate(String(e.id))},loading:Y.isPending,children:`忽略`})]})]})})})]},e.id||t)})})})})]},e)})}),X.length===0&&(0,D.jsxs)(`div`,{className:`text-center py-12 text-gray-400`,children:[(0,D.jsx)(re,{className:`h-12 w-12 mx-auto mb-3 text-green-300`}),`没有符合条件的记录`]}),X.length>0&&U===`list`&&(0,D.jsx)(be,{currentPage:P,totalPages:Fe,onPageChange:F,pageSize:I,onPageSizeChange:e=>{Ce(e),F(1)},totalItems:X.length})]}),(0,D.jsx)(ye,{open:G.open,title:G.title,description:G.description,count:G.count,variant:`warning`,onConfirm:G.onConfirm,onCancel:()=>K({...G,open:!1})})]})}export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Gn as t,Gt as n,Lt as r,Nn as i,Qn as a,dr as o,en as s,er as c,gr as l,s as u}from"./vendor-DRGPi8ui.js";import{S as d,d as f,f as p,g as m,l as h,m as g,p as _,s as v,y}from"./vendor-charts-9eVsQvUV.js";import{c as b,l as x,s as S}from"./vendor-react-DJI9oneq.js";import{r as C}from"./vendor-query-DqPOMnuX.js";import{c as w}from"./vendor-flow-srkes8If.js";import{Ct as T}from"./client-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Gn as t,Gt as n,Lt as r,Nn as i,Qn as a,dr as o,en as s,er as c,gr as l,s as u}from"./vendor-DRGPi8ui.js";import{S as d,d as f,f as p,g as m,l as h,m as g,p as _,s as v,y}from"./vendor-charts-9eVsQvUV.js";import{c as b,l as x,s as S}from"./vendor-react-DJI9oneq.js";import{r as C}from"./vendor-query-DqPOMnuX.js";import{c as w}from"./vendor-flow-srkes8If.js";import{Ct as T}from"./client-BvVpIixG.js";import{a as E,l as D,n as O,o as k,r as A,t as j}from"./ui-CDL3BZ13.js";import{t as M}from"./vendor-motion-CQmdgnI8.js";import{t as N}from"./Breadcrumb-DtfwnOx6.js";var P=e(l(),1),F=w();function I(){let{id:e}=x(),l=b(),w=S(),[I,L]=(0,P.useState)(null),[R,z]=(0,P.useState)(`phases`),B=w.state?.from||`/sessions`,{data:V,isLoading:H,isError:U,error:W}=C({queryKey:[`session`,e],queryFn:()=>T(e).then(e=>e.data),enabled:!!e});if(U)return(0,F.jsxs)(`div`,{className:`flex items-center justify-center h-96 text-red-500`,children:[`加载失败:`,W?.message||`未知错误`]});if(H||!V)return(0,F.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,F.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});let{session:G,phases:K,dataFlow:q,timeline:J,stats:Y}=V,X=Object.entries(Y.toolUsage).sort((e,t)=>t[1]-e[1]).slice(0,12).map(([e,t])=>({name:e,value:t}));return(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsx)(N,{items:[{label:`会话列表`,path:`/sessions`},{label:G.session_id.slice(0,8)+`...`}]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,F.jsx)(O,{variant:`ghost`,size:`sm`,icon:o,onClick:()=>l(B),children:`返回`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-xl font-bold text-gray-900`,children:`会话详情`}),(0,F.jsx)(`p`,{className:`text-sm text-gray-500 font-mono`,children:G.session_id})]}),(0,F.jsx)(j,{variant:G.status===`active`?`success`:`info`,children:G.status})]}),V.pipeline&&(0,F.jsx)(O,{variant:`secondary`,size:`sm`,onClick:()=>l(`/pipelines/${V.pipeline.id}`,{state:{from:B}}),children:`查看关联 Pipeline`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-5 gap-4`,children:[(0,F.jsxs)(A,{className:`text-center !p-4`,children:[(0,F.jsx)(t,{className:`h-5 w-5 text-blue-500 mx-auto mb-2`}),(0,F.jsx)(`div`,{className:`text-xl font-bold`,children:k(Y.duration)}),(0,F.jsx)(`div`,{className:`text-xs text-gray-500`,children:`持续时间`})]}),(0,F.jsxs)(A,{className:`text-center !p-4`,children:[(0,F.jsx)(r,{className:`h-5 w-5 text-green-500 mx-auto mb-2`}),(0,F.jsx)(`div`,{className:`text-xl font-bold`,children:Y.totalEvents}),(0,F.jsx)(`div`,{className:`text-xs text-gray-500`,children:`总事件数`})]}),(0,F.jsxs)(A,{className:`text-center !p-4`,children:[(0,F.jsx)(i,{className:`h-5 w-5 text-purple-500 mx-auto mb-2`}),(0,F.jsx)(`div`,{className:`text-xl font-bold`,children:Y.writeOps}),(0,F.jsx)(`div`,{className:`text-xs text-gray-500`,children:`写入操作`})]}),(0,F.jsxs)(A,{className:`text-center !p-4`,children:[(0,F.jsx)(s,{className:`h-5 w-5 text-orange-500 mx-auto mb-2`}),(0,F.jsx)(`div`,{className:`text-xl font-bold`,children:Y.readOps}),(0,F.jsx)(`div`,{className:`text-xs text-gray-500`,children:`读取操作`})]}),(0,F.jsxs)(A,{className:`text-center !p-4`,children:[(0,F.jsx)(n,{className:`h-5 w-5 text-red-500 mx-auto mb-2`}),(0,F.jsx)(`div`,{className:`text-xl font-bold`,children:K.length}),(0,F.jsx)(`div`,{className:`text-xs text-gray-500`,children:`交互轮次`})]})]}),(0,F.jsx)(A,{title:`事件密度时间线`,children:(0,F.jsx)(d,{width:`100%`,height:120,children:(0,F.jsxs)(v,{data:J,children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`timelineGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.4}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]})}),(0,F.jsx)(m,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,F.jsx)(p,{dataKey:`time`,tick:!1}),(0,F.jsx)(f,{hide:!0}),(0,F.jsx)(y,{formatter:e=>[`${e} 事件`,`数量`]}),(0,F.jsx)(g,{type:`monotone`,dataKey:`count`,stroke:`#3b82f6`,fill:`url(#timelineGrad)`})]})})}),(0,F.jsx)(`div`,{className:`flex gap-1 bg-gray-100 p-1 rounded-lg w-fit`,children:[`phases`,`flow`,`events`].map(e=>(0,F.jsx)(`button`,{onClick:()=>z(e),className:E(`px-4 py-2 rounded-md text-sm font-medium transition-colors`,R===e?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`),children:{phases:`阶段视图`,flow:`数据流图`,events:`事件列表`}[e]},e))}),R===`phases`&&(0,F.jsx)(`div`,{className:`space-y-3`,children:K.map((e,t)=>(0,F.jsx)(M.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.05},children:(0,F.jsxs)(A,{className:`!p-0 overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-4 cursor-pointer hover:bg-gray-50 transition-colors`,onClick:()=>L(I===t?null:t),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 text-white font-bold text-sm`,children:t+1}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-semibold text-gray-900`,children:e.name}),(0,F.jsxs)(`div`,{className:`text-sm text-gray-500`,children:[e.toolCalls,` 工具调用 · `,e.writeOps,` 写入 · `,e.artifacts.length,` 产物`]})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[e.duration&&(0,F.jsx)(`span`,{className:`text-sm text-gray-500`,children:k(e.duration)}),(0,F.jsxs)(`div`,{className:`flex gap-1`,children:[e.artifacts.slice(0,3).map((e,t)=>(0,F.jsx)(j,{variant:`success`,size:`sm`,children:e},t)),e.artifacts.length>3&&(0,F.jsxs)(j,{variant:`default`,size:`sm`,children:[`+`,e.artifacts.length-3]})]}),I===t?(0,F.jsx)(c,{className:`h-5 w-5 text-gray-400`}):(0,F.jsx)(a,{className:`h-5 w-5 text-gray-400`})]})]}),I===t&&(0,F.jsx)(M.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`border-t border-gray-100`,children:(0,F.jsx)(`div`,{className:`p-4 max-h-96 overflow-y-auto space-y-2`,children:e.events.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,F.jsx)(`div`,{className:`text-gray-400 font-mono w-20 flex-shrink-0`,children:u(D(e.time),`HH:mm:ss`)}),(0,F.jsx)(j,{size:`sm`,variant:e.hookType===`PostToolUse`?`success`:e.hookType===`PreToolUse`?`info`:e.hookType===`UserPromptSubmit`?`warning`:`default`,children:e.hookType}),e.toolName&&(0,F.jsx)(`span`,{className:`font-mono text-gray-700 font-medium`,children:e.toolName}),e.input&&(0,F.jsx)(`span`,{className:`text-gray-500 truncate max-w-md`,children:e.input})]},t))})})]})},t))}),R===`flow`&&(0,F.jsx)(A,{title:`数据流图 (${q.nodes.length} 节点)`,children:(0,F.jsx)(`div`,{className:`space-y-1 max-h-[600px] overflow-y-auto`,children:q.nodes.map((e,t)=>(0,F.jsxs)(M.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:t*.02},className:`flex items-center gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-col items-center w-8`,children:[t>0&&(0,F.jsx)(`div`,{className:`w-0.5 h-3 bg-gray-300`}),(0,F.jsx)(`div`,{className:E(`w-3 h-3 rounded-full border-2`,e.type===`intent`?`bg-blue-500 border-blue-500`:e.type===`artifact`?`bg-green-500 border-green-500`:e.type===`quality`?`bg-yellow-500 border-yellow-500`:`bg-gray-400 border-gray-400`)}),t<q.nodes.length-1&&(0,F.jsx)(`div`,{className:`w-0.5 h-3 bg-gray-300`})]}),(0,F.jsxs)(`div`,{className:E(`flex-1 flex items-center gap-3 p-2 rounded-lg text-sm`,e.type===`intent`?`bg-blue-50`:e.type===`artifact`?`bg-green-50`:e.type===`quality`?`bg-yellow-50`:`bg-gray-50`),children:[(0,F.jsx)(`span`,{className:`font-mono text-xs text-gray-400`,children:u(D(e.time),`HH:mm:ss`)}),(0,F.jsx)(j,{size:`sm`,variant:e.type===`intent`?`info`:e.type===`artifact`?`success`:e.type===`quality`?`warning`:`default`,children:e.label}),e.detail&&(0,F.jsx)(`span`,{className:`text-gray-600 truncate`,children:e.detail})]})]},e.id))})}),R===`events`&&(0,F.jsx)(A,{title:`全部事件 (${V.events.length})`,children:(0,F.jsx)(`div`,{className:`overflow-x-auto`,children:(0,F.jsxs)(`table`,{className:`w-full`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-left text-sm text-gray-600`,children:[(0,F.jsx)(`th`,{className:`pb-3 font-medium`,children:`时间`}),(0,F.jsx)(`th`,{className:`pb-3 font-medium`,children:`类型`}),(0,F.jsx)(`th`,{className:`pb-3 font-medium`,children:`工具`}),(0,F.jsx)(`th`,{className:`pb-3 font-medium`,children:`详情`})]})}),(0,F.jsx)(`tbody`,{className:`text-sm`,children:V.events.map(e=>(0,F.jsxs)(`tr`,{className:`border-t border-gray-50 hover:bg-gray-50`,children:[(0,F.jsx)(`td`,{className:`py-2 font-mono text-gray-500`,children:u(D(e.timestamp),`HH:mm:ss`)}),(0,F.jsx)(`td`,{className:`py-2`,children:(0,F.jsx)(j,{size:`sm`,variant:e.hook_type===`PostToolUse`?`success`:e.hook_type===`UserPromptSubmit`?`warning`:`default`,children:e.hook_type})}),(0,F.jsx)(`td`,{className:`py-2 font-mono`,children:e.tool_name||`-`}),(0,F.jsx)(`td`,{className:`py-2 text-gray-500 truncate max-w-md`,children:typeof e.tool_input==`string`?e.tool_input.slice(0,80):``})]},e.id))})]})})}),(0,F.jsx)(A,{title:`工具使用分布`,children:(0,F.jsx)(d,{width:`100%`,height:250,children:(0,F.jsxs)(h,{data:X,layout:`vertical`,children:[(0,F.jsx)(m,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,F.jsx)(p,{type:`number`}),(0,F.jsx)(f,{dataKey:`name`,type:`category`,width:80,tick:{fontSize:12}}),(0,F.jsx)(y,{}),(0,F.jsx)(_,{dataKey:`value`,fill:`#3b82f6`,radius:[0,4,4,0]})]})})})]})}export{I as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Fn as t,Gn as n,On as r,Rn as i,Ut as a,en as o,er as ee,fr as s,gr as c,ir as te,lr as ne,o as l,pr as u,s as d}from"./vendor-DRGPi8ui.js";import{c as f}from"./vendor-react-DJI9oneq.js";import{a as p,n as m,r as h,t as re}from"./vendor-query-DqPOMnuX.js";import{c as g}from"./vendor-flow-srkes8If.js";import{O as ie,c as _,on as v,wt as y}from"./client-BvVpIixG.js";import{a as b,l as x,n as S,r as C,t as w}from"./ui-CDL3BZ13.js";import{t as T}from"./ErrorState-BOInXmfg.js";import{t as E}from"./exportCsv-Dm5Y5M_E.js";import{t as D}from"./ConfirmDialog-BKfwMp04.js";import{n as ae,r as oe}from"./Skeleton-B7PVDJJ_.js";import{t as se}from"./BatchProgress-BQ533tSf.js";var O=e(c(),1),k=g();function A(e,t){let n=t.getTime()-e.getTime();if(n<0)return`-`;let r=Math.floor(n/6e4),i=Math.floor(r/60);return i>0?`${i}h ${r%60}m`:r>0?`${r}m`:`${Math.floor(n/1e3)}s`}function j(){let e=p(),[c,g]=(0,O.useState)(``),[j,M]=(0,O.useState)(``),[N,P]=(0,O.useState)(``),[F,I]=(0,O.useState)(`all`),[L,R]=(0,O.useState)(new Set),[z,B]=(0,O.useState)(`start_time`),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(!1),[G,K]=(0,O.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),ce=f(),q=(0,O.useRef)(null),{data:J,isLoading:le,isError:ue,refetch:Y}=h({queryKey:[`sessions`,{limit:100,status:j||void 0}],queryFn:()=>y({limit:100,status:j||void 0}).then(e=>e.data)}),X=m({mutationFn:e=>ie(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`sessions`]})}}),Z=m({mutationFn:e=>_(e),onSuccess:t=>{R(new Set),e.invalidateQueries({queryKey:[`sessions`]}),t.failed.length>0&&alert(`删除完成:成功 ${t.success.length} 个,失败 ${t.failed.length} 个\n失败原因:\n${t.errors.map(e=>`${e.id}: ${e.reason}`).join(`
|
|
2
|
+
`)}`)}}),de=m({mutationFn:({id:e,meta:t})=>v(e,t),onSuccess:()=>e.invalidateQueries({queryKey:[`sessions`]})}),Q=(J?.items.filter(e=>{let t=e.session_id.toLowerCase().includes(c.toLowerCase())||e.project_path.toLowerCase().includes(c.toLowerCase()),n=!N||e.project_path.split(`/`).pop()===N,r=F===`all`||new Date(e.start_time)>=l(new Date,F===`1d`?1:F===`7d`?7:30);return t&&n&&r})||[]).sort((e,t)=>{let n=0;return z===`start_time`?n=e.start_time.localeCompare(t.start_time):z===`event_count`?n=e.event_count-t.event_count:z===`duration`&&(n=(e.end_time?new Date(e.end_time).getTime()-new Date(e.start_time).getTime():1/0)-(t.end_time?new Date(t.end_time).getTime()-new Date(t.start_time).getTime():1/0)),V?n:-n}),fe=Array.from(new Set(J?.items.map(e=>e.project_path.split(`/`).pop()||``).filter(Boolean)||[])),pe=e=>{z===e?H(e=>!e):(B(e),H(!1))},$=re({count:Q.length,getScrollElement:()=>q.current,estimateSize:()=>72,overscan:10}),me=()=>{let e=[`Session ID`,`项目`,`状态`,`开始时间`,`结束时间`,`事件数`],t=Q.map(e=>[e.session_id,e.project_path,e.status,e.start_time,e.end_time||``,e.event_count]);E(`sessions-${d(new Date,`yyyyMMdd-HHmmss`)}.csv`,e,t)};return le?(0,k.jsxs)(`div`,{className:`space-y-6`,children:[(0,k.jsx)(oe,{count:4}),(0,k.jsx)(ae,{count:6})]}):ue?(0,k.jsx)(T,{message:`会话数据加载失败`,onRetry:()=>Y()}):(0,k.jsxs)(`div`,{className:`space-y-6`,children:[(0,k.jsx)(C,{children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(o,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`搜索会话 ID 或项目...`,value:c,onChange:e=>g(e.target.value),className:`w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`button`,{onClick:()=>W(e=>!e),className:b(`flex items-center gap-1.5 px-3 py-2 text-sm rounded-lg border transition-colors`,U||j||N||F!==`all`?`border-blue-300 bg-blue-50 text-blue-700`:`border-gray-200 text-gray-600 hover:bg-gray-50`),children:[(0,k.jsx)(r,{className:`h-4 w-4`}),`筛选`,(j||N||F!==`all`)&&(0,k.jsx)(`span`,{className:`ml-1 px-1.5 py-0.5 bg-blue-600 text-white text-xs rounded-full`,children:[j,N,F===`all`?``:F].filter(Boolean).length}),(0,k.jsx)(ee,{className:b(`h-3.5 w-3.5 transition-transform`,U&&`rotate-180`)})]}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[L.size>0&&(0,k.jsxs)(S,{variant:`danger`,size:`sm`,icon:a,onClick:()=>{K({open:!0,title:`批量删除会话`,description:`确定删除选中的 ${L.size} 个会话吗?此操作不可撤销。`,count:L.size,onConfirm:()=>{Z.mutate(Array.from(L)),K(e=>({...e,open:!1}))}})},loading:Z.isPending,children:[`删除 (`,L.size,`)`]}),(0,k.jsx)(S,{variant:`secondary`,size:`sm`,icon:i,onClick:()=>Q.length>0&&me(),children:`导出`}),(0,k.jsx)(S,{variant:`primary`,size:`sm`,onClick:()=>Y(),children:`刷新`})]})]}),Z.isPending&&(0,k.jsx)(`div`,{className:`mt-2`,children:(0,k.jsx)(se,{total:L.size,done:0,label:`批量删除中`})}),U&&(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-3 pt-2 border-t border-gray-100`,children:[(0,k.jsxs)(`select`,{value:j,onChange:e=>M(e.target.value),className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,k.jsx)(`option`,{value:``,children:`全部状态`}),(0,k.jsx)(`option`,{value:`active`,children:`活跃`}),(0,k.jsx)(`option`,{value:`completed`,children:`已完成`}),(0,k.jsx)(`option`,{value:`interrupted`,children:`中断`})]}),(0,k.jsxs)(`select`,{value:N,onChange:e=>P(e.target.value),className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,k.jsx)(`option`,{value:``,children:`全部项目`}),fe.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 border border-gray-200 rounded-lg overflow-hidden text-sm`,children:[(0,k.jsx)(te,{className:`h-3.5 w-3.5 text-gray-400 ml-2`}),[`all`,`1d`,`7d`,`30d`].map(e=>(0,k.jsx)(`button`,{onClick:()=>I(e),className:b(`px-2.5 py-1.5 transition-colors`,F===e?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`),children:e===`all`?`全部`:e},e))]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,k.jsx)(`span`,{className:`text-gray-500 text-xs`,children:`排序:`}),[{key:`start_time`,label:`时间`},{key:`event_count`,label:`事件数`},{key:`duration`,label:`时长`}].map(({key:e,label:t})=>(0,k.jsxs)(`button`,{onClick:()=>pe(e),className:b(`px-2.5 py-1.5 rounded-lg transition-colors flex items-center gap-1`,z===e?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`),children:[t,z===e&&(0,k.jsx)(ne,{className:b(`h-3 w-3`,V&&`rotate-180`)})]},e))]})]})]})}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[(0,k.jsxs)(C,{className:`text-center`,children:[(0,k.jsx)(`div`,{className:`text-3xl font-bold text-blue-600`,children:J?.total||0}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`总会话数`})]}),(0,k.jsxs)(C,{className:`text-center`,children:[(0,k.jsx)(`div`,{className:`text-3xl font-bold text-green-600`,children:J?.items.filter(e=>e.status===`active`).length||0}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`活跃会话`})]}),(0,k.jsxs)(C,{className:`text-center`,children:[(0,k.jsx)(`div`,{className:`text-3xl font-bold text-purple-600`,children:J?.items.filter(e=>e.status===`completed`).length||0}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`已完成`})]}),(0,k.jsxs)(C,{className:`text-center`,children:[(0,k.jsx)(`div`,{className:`text-3xl font-bold text-orange-600`,children:Math.round((J?.items.reduce((e,t)=>e+t.event_count,0)||0)/(J?.items.length||1))}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600 mt-1`,children:`平均事件数`})]})]}),(0,k.jsx)(C,{title:`会话列表 (${Q.length})`,action:Q.length>0?(0,k.jsx)(`button`,{onClick:()=>{L.size===Q.length?R(new Set):R(new Set(Q.map(e=>e.session_id)))},className:`text-xs text-blue-600 hover:underline`,children:L.size===Q.length?`取消全选`:`全选`}):void 0,children:Q.length===0?(0,k.jsxs)(`div`,{className:`text-center py-12 text-gray-400`,children:[(0,k.jsx)(u,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,k.jsx)(`p`,{children:`暂无会话记录`}),(0,k.jsx)(`p`,{className:`text-sm mt-1`,children:`使用 Claude Code 开始一个会话后,记录将自动出现在这里`})]}):(0,k.jsx)(`div`,{ref:q,className:`h-[600px] overflow-auto`,children:(0,k.jsx)(`div`,{style:{height:`${$.getTotalSize()}px`,position:`relative`},children:$.getVirtualItems().map(e=>{let r=Q[e.index];return(0,k.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},children:(0,k.jsxs)(`div`,{className:b(`flex items-center gap-3 p-4 rounded-lg border transition-all cursor-pointer mb-2`,L.has(r.session_id)?`border-blue-300 bg-blue-50`:`border-gray-100 hover:border-blue-200 hover:bg-blue-50/50`),onClick:()=>ce(`/sessions/${r.session_id}`),children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:L.has(r.session_id),onChange:e=>{e.stopPropagation(),R(e=>{let t=new Set(e);return t.has(r.session_id)?t.delete(r.session_id):t.add(r.session_id),t})},onClick:e=>e.stopPropagation(),className:`h-4 w-4 rounded border-gray-300 text-blue-600 cursor-pointer flex-shrink-0`}),(0,k.jsxs)(`div`,{className:`flex-1 grid grid-cols-1 md:grid-cols-6 gap-4 items-center`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`font-mono text-sm font-medium text-gray-900`,children:[r.session_id.slice(0,12),`...`]}),(0,k.jsx)(`div`,{className:`text-xs text-gray-500 mt-1`,children:r.project_path.split(`/`).slice(-2).join(`/`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(w,{variant:r.status===`active`?`success`:r.status===`completed`?`info`:`warning`,children:r.status}),r.archived&&(0,k.jsx)(w,{variant:`default`,children:`已归档`})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,k.jsx)(u,{className:`h-4 w-4`}),r.event_count,` 事件`]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,k.jsx)(n,{className:`h-4 w-4`}),d(x(r.start_time),`MM-dd HH:mm`)]}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600`,children:r.end_time?A(x(r.start_time),x(r.end_time)):A(x(r.start_time),new Date)}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,k.jsx)(S,{variant:`ghost`,size:`sm`,icon:t,children:`查看详情`}),(0,k.jsx)(S,{variant:`ghost`,size:`sm`,icon:s,onClick:e=>{e.stopPropagation(),de.mutate({id:r.session_id,meta:{archived:!r.archived}})},title:r.archived?`取消归档`:`归档`}),(0,k.jsx)(S,{variant:`ghost`,size:`sm`,icon:a,onClick:e=>{e.stopPropagation(),K({open:!0,title:`删除会话`,description:`确认删除此会话及其所有数据?此操作不可撤销。`,onConfirm:()=>{X.mutate(r.session_id),K(e=>({...e,open:!1}))}})},loading:X.isPending&&X.variables===r.session_id})]})]})]})},r.session_id)})})})}),(0,k.jsx)(D,{open:G.open,title:G.title,description:G.description,count:G.count,variant:`danger`,onConfirm:G.onConfirm,onCancel:()=>K({...G,open:!1})})]})}export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{It as t,Jn as n,Kt as r,Ln as i,Lt as a,Mn as o,On as s,Rn as c,Ut as l,Vt as u,Xt as d,_n as f,an as p,cn as m,en as h,er as g,gr as _,rn as v,tn as y,un as b}from"./vendor-DRGPi8ui.js";import{a as x,n as S,r as C}from"./vendor-query-DqPOMnuX.js";import{c as w}from"./vendor-flow-srkes8If.js";import{Dt as T,Et as ee,F as E,It as te,P as ne,T as D,Tt as O,Vt as k,Xt as A,cn as j,k as M,l as N,lt as P,r as F,sn as I}from"./client-BvVpIixG.js";import{a as L}from"./ui-CDL3BZ13.js";import{n as R}from"./Toast-BbB3oD2a.js";import{t as z}from"./ConfirmDialog-BKfwMp04.js";var B=e(_(),1),V=w(),H={local:`bg-blue-50 text-blue-700`,remote:`bg-purple-50 text-purple-700`,generated:`bg-green-50 text-green-700`,official:`bg-amber-50 text-amber-700`,user:`bg-pink-50 text-pink-700`},U={local:`本地`,remote:`远程`,generated:`AI生成`,official:`官方`,user:`用户`};function W(){let[e,t]=(0,B.useState)(`list`),[i,a]=(0,B.useState)(``),[o,c]=(0,B.useState)(``),[d,p]=(0,B.useState)(new Set),[m,h]=(0,B.useState)(``),[_,v]=(0,B.useState)(null),[y,w]=(0,B.useState)(!1),[D,O]=(0,B.useState)(null),[j,P]=(0,B.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),F=x(),{data:I,isLoading:W}=C({queryKey:[`skills`,i,o],queryFn:()=>T({source:i||void 0,tag:o||void 0}).then(e=>e.data)}),{data:G}=C({queryKey:[`skills-status`],queryFn:()=>ee().then(e=>e.data)}),K=S({mutationFn:e=>A(e).then(e=>e.data),onSuccess:e=>{v(e),R(`找到 ${e.github.length+e.npm.length} 个结果`,`success`)}}),q=S({mutationFn:e=>te(e).then(e=>e.data),onSuccess:e=>{R(`已安装: ${e.skill.name}`,`success`),F.invalidateQueries({queryKey:[`skills`]}),F.invalidateQueries({queryKey:[`skills-status`]})}}),J=S({mutationFn:e=>M(e).then(e=>e.data),onSuccess:(e,t)=>{R(`已删除: ${t}`,`success`),p(e=>{let n=new Set(e);return n.delete(t),n}),F.invalidateQueries({queryKey:[`skills`]}),F.invalidateQueries({queryKey:[`skills-status`]})}}),Y=S({mutationFn:e=>N(e).then(e=>e.data),onSuccess:e=>{R(`已删除 ${e.success.length} 个技能`,`success`),p(new Set),F.invalidateQueries({queryKey:[`skills`]}),F.invalidateQueries({queryKey:[`skills-status`]})}}),X=S({mutationFn:()=>E().then(e=>e.data),onSuccess:e=>{R(`进化完成:${e.repaired.length+e.retired.length+e.optimized.length+e.generated.length} 项变更`,`success`),F.invalidateQueries({queryKey:[`skills`]}),F.invalidateQueries({queryKey:[`skills-status`]})}}),Z=S({mutationFn:()=>ne().then(e=>e.data),onSuccess:e=>{R(`蒸馏完成:新增 ${e.distilled.length} 个技能`,`success`),F.invalidateQueries({queryKey:[`skills`]}),F.invalidateQueries({queryKey:[`skills-status`]})}}),Q=S({mutationFn:()=>k().then(e=>e.data),onSuccess:e=>{R(`修复完成:${e.repaired.length} 个技能已修复`,`success`),F.invalidateQueries({queryKey:[`skills`]})}}),$=I?.items||[],se=$.length>0&&d.size===$.length,ce=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`技能管理`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`管理 Claude Code 技能库,搜索安装、进化优化`})]}),G&&(0,V.jsx)(`div`,{className:`flex items-center gap-3`,children:[{label:`全部`,value:G.total,color:`text-gray-700`},{label:`官方`,value:G.official,color:`text-amber-600`},{label:`本地`,value:G.local,color:`text-blue-600`},{label:`AI生成`,value:G.generated,color:`text-green-600`}].map(({label:e,value:t,color:n})=>(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:L(`text-xl font-bold`,n),children:t}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500`,children:e})]},e))})]}),(0,V.jsx)(`div`,{className:`border-b border-gray-200`,children:(0,V.jsx)(`nav`,{className:`flex gap-1`,children:[{key:`list`,label:`技能列表`},{key:`search`,label:`搜索安装`},{key:`evolve`,label:`进化管理`},{key:`sources`,label:`技能源`}].map(n=>(0,V.jsx)(`button`,{onClick:()=>t(n.key),className:L(`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors`,e===n.key?`border-blue-600 text-blue-600`:`border-transparent text-gray-500 hover:text-gray-700`),children:n.label},n.key))})}),e===`list`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(`button`,{onClick:()=>w(!y),className:L(`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg transition-colors`,y?`bg-blue-50 text-blue-600`:`text-gray-600 hover:bg-gray-50`),children:[(0,V.jsx)(s,{className:`h-4 w-4`}),`筛选`,(0,V.jsx)(g,{className:L(`h-3.5 w-3.5 transition-transform`,y&&`rotate-180`)})]}),(0,V.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[$.length,` 个技能`]}),d.size>0&&(0,V.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[`已选 `,d.size,` 个`]}),(0,V.jsxs)(`button`,{onClick:()=>{P({open:!0,title:`批量删除技能`,description:`确定要删除选中的 ${d.size} 个技能吗?此操作不可恢复。`,count:d.size,onConfirm:()=>{Y.mutate(Array.from(d)),P(e=>({...e,open:!1}))}})},disabled:Y.isPending,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-50 text-red-600 hover:bg-red-100 rounded-lg transition-colors`,children:[(0,V.jsx)(l,{className:`h-3.5 w-3.5`}),`批量删除`]})]})]}),y&&(0,V.jsxs)(`div`,{className:`flex gap-3 mt-3 pt-3 border-t border-gray-100`,children:[(0,V.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,V.jsx)(`option`,{value:``,children:`全部来源`}),(0,V.jsx)(`option`,{value:`local`,children:`本地`}),(0,V.jsx)(`option`,{value:`official`,children:`官方`}),(0,V.jsx)(`option`,{value:`remote`,children:`远程`}),(0,V.jsx)(`option`,{value:`generated`,children:`AI生成`}),(0,V.jsx)(`option`,{value:`user`,children:`用户`})]}),(0,V.jsx)(`input`,{type:`text`,placeholder:`按标签筛选...`,value:o,onChange:e=>c(e.target.value),className:`px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]})]}),W?(0,V.jsx)(`div`,{className:`flex items-center justify-center h-48`,children:(0,V.jsx)(f,{className:`h-8 w-8 animate-spin text-blue-500`})}):(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:[(0,V.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`w-10 px-4 py-3`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:se,onChange:()=>{p(se?new Set:new Set($.map(e=>e.name)))},className:`rounded`})}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`技能名称`}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`版本`}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`调用次数`}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`成功率`}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`最近使用`}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,V.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:$.map(e=>(0,V.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,V.jsx)(`td`,{className:`px-4 py-3`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:d.has(e.name),onChange:()=>ce(e.name),className:`rounded`})}),(0,V.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,V.jsx)(`button`,{onClick:()=>O(e.name),className:`font-medium text-blue-600 hover:text-blue-700 cursor-pointer`,children:e.name}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 truncate max-w-xs`,children:e.description}),e.tags&&e.tags.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.tags.map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 bg-gray-100 text-gray-600 text-xs rounded`,children:[(0,V.jsx)(r,{className:`h-2.5 w-2.5`}),e]},e))})]}),(0,V.jsx)(`td`,{className:`px-4 py-3`,children:(0,V.jsx)(`span`,{className:L(`px-2 py-0.5 text-xs rounded-full font-medium`,H[e.source]||`bg-gray-100 text-gray-600`),children:U[e.source]||e.source})}),(0,V.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.version}),(0,V.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.stats.callCount}),(0,V.jsx)(`td`,{className:`px-4 py-3`,children:e.stats.callCount>0?(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`div`,{className:`w-16 h-1.5 bg-gray-200 rounded-full overflow-hidden`,children:(0,V.jsx)(`div`,{className:L(`h-full rounded-full`,e.stats.successRate>=.8?`bg-green-500`:e.stats.successRate>=.5?`bg-yellow-500`:`bg-red-500`),style:{width:`${e.stats.successRate*100}%`}})}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-600`,children:[(e.stats.successRate*100).toFixed(0),`%`]})]}):(0,V.jsx)(`span`,{className:`text-xs text-gray-400`,children:`未使用`})}),(0,V.jsx)(`td`,{className:`px-4 py-3 text-xs text-gray-500`,children:e.stats.lastUsed?new Date(e.stats.lastUsed).toLocaleDateString(`zh-CN`):`—`}),(0,V.jsx)(`td`,{className:`px-4 py-3`,children:(0,V.jsx)(`button`,{onClick:()=>{P({open:!0,title:`删除技能`,description:`确定要删除技能 "${e.name}" 吗?此操作不可恢复。`,onConfirm:()=>{J.mutate(e.name),P(e=>({...e,open:!1}))}})},disabled:J.isPending,className:`p-1.5 text-gray-400 hover:text-red-500 rounded transition-colors`,title:`删除`,children:(0,V.jsx)(l,{className:`h-4 w-4`})})})]},e.name))})]}),$.length===0&&(0,V.jsxs)(`div`,{className:`text-center py-12`,children:[(0,V.jsx)(b,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500`,children:`暂无技能`})]})]}),G&&(G.topUsed.length>0||G.topRated.length>0)&&(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[G.topUsed.length>0&&(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:[(0,V.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-3 flex items-center gap-2`,children:[(0,V.jsx)(u,{className:`h-4 w-4 text-blue-500`}),`最常用技能`]}),(0,V.jsx)(`div`,{className:`space-y-2`,children:G.topUsed.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-gray-400 w-4`,children:t+1}),(0,V.jsx)(`span`,{className:`text-gray-700`,children:e.name})]}),(0,V.jsxs)(`span`,{className:`text-gray-500`,children:[e.calls,` 次`]})]},e.name))})]}),G.topRated.length>0&&(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:[(0,V.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-3 flex items-center gap-2`,children:[(0,V.jsx)(n,{className:`h-4 w-4 text-green-500`}),`评分最高技能`]}),(0,V.jsx)(`div`,{className:`space-y-2`,children:G.topRated.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-gray-400 w-4`,children:t+1}),(0,V.jsx)(`span`,{className:`text-gray-700`,children:e.name})]}),(0,V.jsxs)(`span`,{className:`text-gray-500`,children:[(e.rating*100).toFixed(0),`%`]})]},e.name))})]})]})]}),e===`search`&&(0,V.jsx)(ie,{searchQuery:m,setSearchQuery:h,searchResults:_,onSearch:()=>K.mutate(m),onInstall:e=>q.mutate(e),isSearching:K.isPending,isInstalling:q.isPending}),e===`evolve`&&(0,V.jsx)(ae,{onEvolve:()=>X.mutate(),onDistill:()=>Z.mutate(),onRepair:()=>Q.mutate(),isEvolving:X.isPending,isDistilling:Z.isPending,isRepairing:Q.isPending,evolveResult:X.data,distillResult:Z.data,repairResult:Q.data}),e===`sources`&&(0,V.jsx)(oe,{}),D&&(0,V.jsx)(re,{name:D,onClose:()=>O(null)}),(0,V.jsx)(z,{open:j.open,title:j.title,description:j.description,count:j.count,onConfirm:j.onConfirm,onCancel:()=>P(e=>({...e,open:!1}))})]})}function re({name:e,onClose:n}){let[a,s]=(0,B.useState)(`content`),[c,u]=(0,B.useState)(!1),[d,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(``),v=x(),{data:w,isLoading:T}=C({queryKey:[`skill-detail`,e],queryFn:()=>O(e).then(e=>e.data)}),{data:ee}=C({queryKey:[`orchestration-mappings`],queryFn:()=>P().then(e=>e.data),enabled:a===`orchestration`}),E=ee?.items.find(t=>t.skill===e),[te,ne]=(0,B.useState)([]),k=E?.keywords??[],A=S({mutationFn:t=>I(e,t),onSuccess:()=>{R(`技能内容已保存`,`success`),u(!1),v.invalidateQueries({queryKey:[`skill-detail`,e]})},onError:()=>R(`保存失败`,`error`)}),M=S({mutationFn:t=>j(e,t),onSuccess:()=>{R(`编排映射已保存`,`success`),v.invalidateQueries({queryKey:[`orchestration-mappings`]})},onError:()=>R(`保存失败`,`error`)}),N=S({mutationFn:()=>D(e),onSuccess:()=>{R(`编排映射已删除`,`success`),v.invalidateQueries({queryKey:[`orchestration-mappings`]})}}),[F,L]=(0,B.useState)(null),z=F??k;return(0,V.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40`,onClick:n,children:(0,V.jsxs)(`div`,{className:`bg-white rounded-2xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-gray-100`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(b,{className:`h-5 w-5 text-blue-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900`,children:e}),w&&(0,V.jsx)(`p`,{className:`text-xs text-gray-500 mt-0.5`,children:w.description})]})]}),(0,V.jsx)(`button`,{onClick:n,className:`p-1.5 text-gray-400 hover:text-gray-600 rounded-lg transition-colors`,children:(0,V.jsx)(t,{className:`h-5 w-5`})})]}),(0,V.jsx)(`div`,{className:`flex gap-1 px-6 pt-3 border-b border-gray-100`,children:[`content`,`stats`,`orchestration`].map(e=>(0,V.jsx)(`button`,{onClick:()=>s(e),className:`px-3 py-1.5 text-sm font-medium border-b-2 transition-colors ${a===e?`border-blue-600 text-blue-600`:`border-transparent text-gray-500 hover:text-gray-700`}`,children:e===`content`?`技能内容`:e===`stats`?`使用情况`:`编排映射`},e))}),(0,V.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5`,children:T?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,V.jsx)(f,{className:`h-6 w-6 animate-spin text-blue-500`})}):w?a===`content`?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,V.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full font-medium ${H[w.source]||`bg-gray-100 text-gray-600`}`,children:U[w.source]||w.source}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`v`,w.version]}),w.requires?.bins&&w.requires.bins.length>0&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`需要:`,w.requires.bins.join(`, `)]}),w.filePath&&(0,V.jsx)(`span`,{className:`text-xs text-gray-400 font-mono truncate max-w-xs`,children:w.filePath})]}),w.tags&&w.tags.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:w.tags.map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-blue-50 text-blue-700 text-xs rounded-full`,children:[(0,V.jsx)(r,{className:`h-2.5 w-2.5`}),e]},e))}),w.content||w.filePath?(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`text-xs text-gray-500 mb-2 flex items-center justify-between`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(o,{className:`h-3.5 w-3.5`}),`技能文件内容`]}),w.filePath&&!c&&(0,V.jsxs)(`button`,{onClick:()=>{h(w.content||``),u(!0)},className:`flex items-center gap-1 text-blue-600 hover:underline`,children:[(0,V.jsx)(m,{className:`h-3 w-3`}),`编辑`]}),c&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`button`,{onClick:()=>u(!1),className:`text-gray-500 hover:text-gray-700 text-xs`,children:`取消`}),(0,V.jsxs)(`button`,{onClick:()=>A.mutate(d),disabled:A.isPending,className:`flex items-center gap-1 text-green-600 hover:underline text-xs`,children:[(0,V.jsx)(y,{className:`h-3 w-3`}),A.isPending?`保存中...`:`保存`]})]})]}),c?(0,V.jsx)(`textarea`,{value:d,onChange:e=>h(e.target.value),className:`w-full text-xs text-gray-800 bg-gray-50 rounded-lg p-4 border border-blue-300 focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono leading-relaxed resize-y`,style:{minHeight:`40vh`,maxHeight:`60vh`}}):(0,V.jsx)(`pre`,{className:`text-xs text-gray-800 bg-gray-50 rounded-lg p-4 overflow-auto whitespace-pre-wrap border border-gray-200 max-h-[50vh] leading-relaxed`,children:w.content||`(空文件)`})]}):(0,V.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`暂无文件内容`}),w.sourceUrl&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,V.jsx)(i,{className:`h-3.5 w-3.5 text-gray-400`}),(0,V.jsx)(`a`,{href:w.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 hover:underline truncate`,children:w.sourceUrl})]})]}):a===`stats`?(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,V.jsxs)(`div`,{className:`bg-blue-50 rounded-xl p-4 text-center`,children:[(0,V.jsx)(`div`,{className:`text-2xl font-bold text-blue-700`,children:w.stats.callCount}),(0,V.jsx)(`div`,{className:`text-xs text-blue-600 mt-1`,children:`总调用次数`})]}),(0,V.jsxs)(`div`,{className:`bg-green-50 rounded-xl p-4 text-center`,children:[(0,V.jsx)(`div`,{className:`text-2xl font-bold text-green-700`,children:w.stats.callCount>0?`${(w.stats.successRate*100).toFixed(0)}%`:`—`}),(0,V.jsx)(`div`,{className:`text-xs text-green-600 mt-1`,children:`成功率`})]}),(0,V.jsxs)(`div`,{className:`bg-purple-50 rounded-xl p-4 text-center`,children:[(0,V.jsx)(`div`,{className:`text-2xl font-bold text-purple-700`,children:w.stats.userFeedback.positive+w.stats.userFeedback.negative>0?`${w.stats.userFeedback.positive} / ${w.stats.userFeedback.negative}`:`—`}),(0,V.jsx)(`div`,{className:`text-xs text-purple-600 mt-1`,children:`用户反馈(正向/负向)`})]})]}),w.stats.callCount>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex justify-between text-xs text-gray-500 mb-1.5`,children:[(0,V.jsx)(`span`,{children:`成功率`}),(0,V.jsxs)(`span`,{children:[(w.stats.successRate*100).toFixed(1),`%`]})]}),(0,V.jsx)(`div`,{className:`w-full h-2 bg-gray-200 rounded-full overflow-hidden`,children:(0,V.jsx)(`div`,{className:`h-full rounded-full transition-all ${w.stats.successRate>=.8?`bg-green-500`:w.stats.successRate>=.5?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${w.stats.successRate*100}%`}})})]}),(0,V.jsxs)(`div`,{className:`bg-gray-50 rounded-xl p-4`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-500 mb-1`,children:`最近使用时间`}),(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:w.stats.lastUsed?new Date(w.stats.lastUsed).toLocaleString(`zh-CN`):`从未使用`})]}),w.stats.callCount===0&&(0,V.jsx)(`div`,{className:`text-center py-8 text-gray-400 text-sm`,children:`该技能尚未被调用过`})]}):(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:`配置触发该技能的关键词,当用户输入包含这些关键词时,编排引擎会自动调用此技能。`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500 uppercase tracking-wide mb-2`,children:`触发关键词`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2 min-h-[40px] p-3 bg-gray-50 rounded-lg border border-gray-200`,children:z.length===0?(0,V.jsx)(`span`,{className:`text-xs text-gray-400`,children:`暂无关键词,添加后可触发自动编排`}):z.map((e,n)=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-blue-100 text-blue-700 text-xs rounded-full`,children:[e,(0,V.jsx)(`button`,{onClick:()=>L(z.filter((e,t)=>t!==n)),className:`hover:text-red-500 transition-colors`,children:(0,V.jsx)(t,{className:`h-3 w-3`})})]},n))})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&g.trim()){let e=g.trim();z.includes(e)||L([...z,e]),_(``)}},placeholder:`输入关键词,回车添加`,className:`flex-1 px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,V.jsx)(`button`,{onClick:()=>{let e=g.trim();e&&!z.includes(e)&&L([...z,e]),_(``)},disabled:!g.trim(),className:`px-3 py-1.5 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:(0,V.jsx)(p,{className:`h-4 w-4`})})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,V.jsxs)(`button`,{onClick:()=>M.mutate(z),disabled:M.isPending||F===null,className:`flex items-center gap-1.5 px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:[(0,V.jsx)(y,{className:`h-3.5 w-3.5`}),M.isPending?`保存中...`:`保存映射`]}),E&&(0,V.jsxs)(`button`,{onClick:()=>N.mutate(),disabled:N.isPending,className:`flex items-center gap-1.5 px-4 py-2 text-sm bg-red-50 text-red-600 rounded-lg hover:bg-red-100 disabled:opacity-50 transition-colors`,children:[(0,V.jsx)(l,{className:`h-3.5 w-3.5`}),`删除映射`]})]})]}):(0,V.jsx)(`div`,{className:`text-center py-16 text-gray-500`,children:`技能不存在`})})]})})}function ie({searchQuery:e,setSearchQuery:t,searchResults:n,onSearch:r,onInstall:a,isSearching:o,isInstalling:s}){return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:(0,V.jsxs)(`div`,{className:`flex gap-3`,children:[(0,V.jsx)(`input`,{type:`text`,placeholder:`搜索技能(GitHub / npm)...`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&r(),className:`flex-1 px-4 py-2.5 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,V.jsxs)(`button`,{onClick:r,disabled:o||!e.trim(),className:`flex items-center gap-2 px-6 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[o?(0,V.jsx)(f,{className:`h-4 w-4 animate-spin`}):(0,V.jsx)(h,{className:`h-4 w-4`}),`搜索`]})]})}),n&&(0,V.jsxs)(`div`,{className:`space-y-6`,children:[n.github.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-3`,children:[`GitHub 结果 (`,n.github.length,`)`]}),(0,V.jsx)(`div`,{className:`grid gap-3`,children:n.github.map((e,t)=>(0,V.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4 hover:border-blue-300 transition-colors`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,V.jsx)(`h4`,{className:`font-semibold text-gray-900`,children:e.skill.name}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`v`,e.skill.version]})]}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 mb-2`,children:e.skill.description}),(0,V.jsxs)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-blue-600 hover:underline`,children:[(0,V.jsx)(i,{className:`h-3 w-3`}),e.sourceUrl]})]}),(0,V.jsxs)(`button`,{onClick:()=>a(e.sourceUrl),disabled:s,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-lg transition-colors`,children:[(0,V.jsx)(c,{className:`h-3.5 w-3.5`}),`安装`]})]})},t))})]}),n.npm.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-3`,children:[`npm 结果 (`,n.npm.length,`)`]}),(0,V.jsx)(`div`,{className:`grid gap-3`,children:n.npm.map((e,t)=>(0,V.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4 hover:border-purple-300 transition-colors`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,V.jsx)(`h4`,{className:`font-semibold text-gray-900`,children:e.skill.name}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`v`,e.skill.version]})]}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 mb-2`,children:e.skill.description}),e.installCommand&&(0,V.jsx)(`code`,{className:`text-xs bg-gray-100 px-2 py-1 rounded`,children:e.installCommand})]}),(0,V.jsxs)(`button`,{onClick:()=>a(e.sourceUrl),disabled:s,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-purple-50 text-purple-600 hover:bg-purple-100 rounded-lg transition-colors`,children:[(0,V.jsx)(c,{className:`h-3.5 w-3.5`}),`安装`]})]})},t))})]}),n.github.length===0&&n.npm.length===0&&(0,V.jsxs)(`div`,{className:`text-center py-12 bg-white rounded-xl border border-gray-200`,children:[(0,V.jsx)(h,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500`,children:`未找到匹配的技能`})]})]})]})}function ae({onEvolve:e,onDistill:t,onRepair:n,isEvolving:r,isDistilling:i,isRepairing:o,evolveResult:s,distillResult:l,repairResult:u}){return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,V.jsx)(`div`,{className:`p-2 bg-blue-50 rounded-lg`,children:(0,V.jsx)(d,{className:`h-5 w-5 text-blue-600`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`font-semibold text-gray-900`,children:`技能进化`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:`淘汰、优化、生成`})]})]}),(0,V.jsxs)(`button`,{onClick:e,disabled:r,className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:[r?(0,V.jsx)(f,{className:`h-4 w-4 animate-spin`}):(0,V.jsx)(v,{className:`h-4 w-4`}),r?`进化中...`:`开始进化`]}),s&&(0,V.jsxs)(`div`,{className:`mt-4 space-y-2 text-sm`,children:[s.repaired?.length>0&&(0,V.jsxs)(`div`,{className:`text-green-600`,children:[`✔ 修复 `,s.repaired.length,` 个`]}),s.retired?.length>0&&(0,V.jsxs)(`div`,{className:`text-red-600`,children:[`- 淘汰 `,s.retired.length,` 个`]}),s.optimized?.length>0&&(0,V.jsxs)(`div`,{className:`text-blue-600`,children:[`↑ 优化 `,s.optimized.length,` 个`]}),s.generated?.length>0&&(0,V.jsxs)(`div`,{className:`text-green-600`,children:[`+ 生成 `,s.generated.length,` 个`]})]})]}),(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,V.jsx)(`div`,{className:`p-2 bg-purple-50 rounded-lg`,children:(0,V.jsx)(c,{className:`h-5 w-5 text-purple-600`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`font-semibold text-gray-900`,children:`社区蒸馏`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:`从精选源采集`})]})]}),(0,V.jsxs)(`button`,{onClick:t,disabled:i,className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 transition-colors`,children:[i?(0,V.jsx)(f,{className:`h-4 w-4 animate-spin`}):(0,V.jsx)(c,{className:`h-4 w-4`}),i?`蒸馏中...`:`开始蒸馏`]}),l&&l.distilled?.length>0&&(0,V.jsxs)(`div`,{className:`mt-4 text-sm text-purple-600`,children:[`✦ 新增 `,l.distilled.length,` 个技能`]})]}),(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,V.jsx)(`div`,{className:`p-2 bg-amber-50 rounded-lg`,children:(0,V.jsx)(a,{className:`h-5 w-5 text-amber-600`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`font-semibold text-gray-900`,children:`修复残缺`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500`,children:`AI 修复低质量技能`})]})]}),(0,V.jsxs)(`button`,{onClick:n,disabled:o,className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-amber-600 text-white rounded-lg hover:bg-amber-700 disabled:opacity-50 transition-colors`,children:[o?(0,V.jsx)(f,{className:`h-4 w-4 animate-spin`}):(0,V.jsx)(a,{className:`h-4 w-4`}),o?`修复中...`:`开始修复`]}),u&&u.repaired?.length>0&&(0,V.jsxs)(`div`,{className:`mt-4 text-sm text-amber-600`,children:[`✔ 修复 `,u.repaired.length,` 个技能`]})]})]}),(0,V.jsxs)(`div`,{className:`bg-blue-50 rounded-xl border border-blue-200 p-4`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-semibold text-blue-900 mb-2`,children:`进化机制说明`}),(0,V.jsxs)(`ul`,{className:`text-sm text-blue-700 space-y-1`,children:[(0,V.jsxs)(`li`,{children:[`• `,(0,V.jsx)(`strong`,{children:`技能进化`}),`:根据使用统计自动淘汰低效技能、优化高频技能、生成新技能`]}),(0,V.jsxs)(`li`,{children:[`• `,(0,V.jsx)(`strong`,{children:`社区蒸馏`}),`:从 GitHub 精选仓库采集优质技能并蒸馏为官方技能`]}),(0,V.jsxs)(`li`,{children:[`• `,(0,V.jsx)(`strong`,{children:`修复残缺`}),`:检测并修复缺少描述、版本号或格式错误的技能文件`]})]})]})]})}function oe(){let e=x(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)({repo:``,dir:``,branch:`main`,format:`command-md`,description:``}),{data:a}=C({queryKey:[`skill-sources`],queryFn:()=>F.get(`/skills/sources`).then(e=>e.data)}),o=S({mutationFn:e=>F.post(`/skills/sources`,e).then(e=>e.data),onSuccess:()=>{R(`技能源已添加`,`success`),n(!1),i({repo:``,dir:``,branch:`main`,format:`command-md`,description:``}),e.invalidateQueries({queryKey:[`skill-sources`]})}}),s=S({mutationFn:e=>F.delete(`/skills/sources/${encodeURIComponent(e)}`).then(e=>e.data),onSuccess:()=>{R(`技能源已删除`,`success`),e.invalidateQueries({queryKey:[`skill-sources`]})}}),u=a?.builtIn||[],d=a?.user||[];return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:[(0,V.jsx)(c,{className:`h-4 w-4`}),`添加技能源`]})}),t&&(0,V.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,V.jsx)(`h3`,{className:`font-semibold text-gray-900 mb-4`,children:`添加自定义技能源`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsx)(`input`,{type:`text`,placeholder:`仓库 (owner/repo)`,value:r.repo,onChange:e=>i({...r,repo:e.target.value}),className:`px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,V.jsx)(`input`,{type:`text`,placeholder:`目录路径`,value:r.dir,onChange:e=>i({...r,dir:e.target.value}),className:`px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,V.jsx)(`input`,{type:`text`,placeholder:`分支 (默认 main)`,value:r.branch,onChange:e=>i({...r,branch:e.target.value}),className:`px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,V.jsxs)(`select`,{value:r.format,onChange:e=>i({...r,format:e.target.value}),className:`px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,V.jsx)(`option`,{value:`command-md`,children:`command-md`}),(0,V.jsx)(`option`,{value:`skill-md`,children:`skill-md`})]}),(0,V.jsx)(`input`,{type:`text`,placeholder:`描述`,value:r.description,onChange:e=>i({...r,description:e.target.value}),className:`col-span-2 px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 mt-4`,children:[(0,V.jsx)(`button`,{onClick:()=>o.mutate(r),disabled:!r.repo||!r.dir||o.isPending,className:`px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:o.isPending?`添加中...`:`确认添加`}),(0,V.jsx)(`button`,{onClick:()=>n(!1),className:`px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors`,children:`取消`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-3`,children:`内置技能源`}),(0,V.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 divide-y divide-gray-100`,children:u.map((e,t)=>(0,V.jsxs)(`div`,{className:`p-4 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`font-medium text-gray-900`,children:[e.repo,`/`,e.dir]}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500`,children:e.description})]}),(0,V.jsx)(`span`,{className:`px-2 py-1 bg-gray-100 text-gray-600 text-xs rounded`,children:`内置`})]},t))})]}),d.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-3`,children:`用户自定义源`}),(0,V.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 divide-y divide-gray-100`,children:d.map((e,t)=>(0,V.jsxs)(`div`,{className:`p-4 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`font-medium text-gray-900`,children:[e.repo,`/`,e.dir]}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500`,children:e.description})]}),(0,V.jsx)(`button`,{onClick:()=>s.mutate(e.repo),disabled:s.isPending,className:`p-1.5 text-gray-400 hover:text-red-500 rounded transition-colors`,children:(0,V.jsx)(l,{className:`h-4 w-4`})})]},t))})]})]})}export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Dn as t,Gn as n,Vt as r,Yn as i,dr as a,gr as o,nn as s,pr as c,qn as l,s as u}from"./vendor-DRGPi8ui.js";import{c as d,l as f}from"./vendor-react-DJI9oneq.js";import{a as p,n as m,r as h}from"./vendor-query-DqPOMnuX.js";import{c as g}from"./vendor-flow-srkes8If.js";import{At as _,Ot as v,X as y,kt as b,qt as x}from"./client-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Dn as t,Gn as n,Vt as r,Yn as i,dr as a,gr as o,nn as s,pr as c,qn as l,s as u}from"./vendor-DRGPi8ui.js";import{c as d,l as f}from"./vendor-react-DJI9oneq.js";import{a as p,n as m,r as h}from"./vendor-query-DqPOMnuX.js";import{c as g}from"./vendor-flow-srkes8If.js";import{At as _,Ot as v,X as y,kt as b,qt as x}from"./client-BvVpIixG.js";import{l as S,n as C,r as w,t as T}from"./ui-CDL3BZ13.js";import{t as E}from"./vendor-motion-CQmdgnI8.js";import{t as D}from"./ErrorState-BOInXmfg.js";import{t as O}from"./ConfirmDialog-BKfwMp04.js";import{t as k}from"./Skeleton-B7PVDJJ_.js";var A=e(o(),1),j=g(),M={multi_retry_pass:`多次重试通过`,strategy_reliable:`策略可靠`,strategy_ineffective:`策略无效`,backtrack_failure:`回溯失败`,diagnosis_pattern:`诊断模式`},N={multi_retry_pass:`bg-yellow-100 text-yellow-700`,strategy_reliable:`bg-green-100 text-green-700`,strategy_ineffective:`bg-red-100 text-red-700`,backtrack_failure:`bg-orange-100 text-orange-700`,diagnosis_pattern:`bg-purple-100 text-purple-700`};function P(){let{id:e}=f(),o=d(),g=p(),[P,F]=(0,A.useState)({open:!1,versionId:``,version:``}),{data:I}=h({queryKey:[`templates`],queryFn:()=>_().then(e=>e.data)}),{data:L,isLoading:R}=h({queryKey:[`template-versions`,e],queryFn:()=>b(e).then(e=>e.data),enabled:!!e}),{data:z,isLoading:B}=h({queryKey:[`template-stats`,e],queryFn:()=>v(e).then(e=>e.data),enabled:!!e}),{data:V,isLoading:H}=h({queryKey:[`evolution-events`,e],queryFn:()=>y({template_id:e,limit:50}).then(e=>e.data),enabled:!!e}),U=m({mutationFn:({versionId:t})=>x(e,t),onSuccess:()=>{g.invalidateQueries({queryKey:[`templates`]}),g.invalidateQueries({queryKey:[`template-versions`,e]}),F({open:!1,versionId:``,version:``})}});if(!e)return(0,j.jsx)(D,{message:`模板 ID 缺失`});let W=(I?.items)?.find(t=>t.id===e),G=L?.items||[],K=V?.items||[];if(!W)return(0,j.jsx)(k,{rows:5});let q=R||B||H;return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,j.jsx)(C,{variant:`ghost`,size:`sm`,icon:a,onClick:()=>o(`/templates`),children:`返回`}),(0,j.jsxs)(`div`,{className:`flex-1`,children:[(0,j.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:W.name}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:W.description})]}),(0,j.jsx)(T,{size:`sm`,className:W.source===`builtin`?`bg-blue-100 text-blue-700`:`bg-green-100 text-green-700`,children:W.source===`builtin`?`内置`:W.source===`convention`?`规范`:`自定义`})]}),z&&(0,j.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[(0,j.jsx)(w,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`p-2 bg-blue-100 rounded-lg`,children:(0,j.jsx)(c,{className:`h-5 w-5 text-blue-600`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:z.total_plans}),(0,j.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总执行次数`})]})]})}),(0,j.jsx)(w,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`p-2 bg-green-100 rounded-lg`,children:(0,j.jsx)(i,{className:`h-5 w-5 text-green-600`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:z.status_breakdown.find(e=>e.status===`completed`)?.count||0}),(0,j.jsx)(`div`,{className:`text-sm text-gray-500`,children:`成功次数`})]})]})}),(0,j.jsx)(w,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`p-2 bg-red-100 rounded-lg`,children:(0,j.jsx)(l,{className:`h-5 w-5 text-red-600`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:z.status_breakdown.find(e=>e.status===`failed`)?.count||0}),(0,j.jsx)(`div`,{className:`text-sm text-gray-500`,children:`失败次数`})]})]})}),(0,j.jsx)(w,{children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`p-2 bg-purple-100 rounded-lg`,children:(0,j.jsx)(n,{className:`h-5 w-5 text-purple-600`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:z.avg_duration_sec?`${Math.round(z.avg_duration_sec/60)}m`:`-`}),(0,j.jsx)(`div`,{className:`text-sm text-gray-500`,children:`平均耗时`})]})]})})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,j.jsxs)(w,{children:[(0,j.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,j.jsx)(t,{className:`h-5 w-5`}),`版本历史`]}),q?(0,j.jsx)(`div`,{className:`text-center py-8 text-gray-400`,children:`加载中...`}):G.length===0?(0,j.jsx)(`div`,{className:`text-center py-8 text-gray-400`,children:`暂无版本历史`}):(0,j.jsx)(`div`,{className:`space-y-3`,children:G.map((e,t)=>(0,j.jsxs)(E.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:t*.05},className:`flex items-start justify-between p-3 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`font-medium text-gray-900`,children:[`v`,e.version]}),t===0&&(0,j.jsx)(T,{size:`sm`,className:`bg-green-100 text-green-700`,children:`当前`})]}),e.evolution_reason&&(0,j.jsx)(`p`,{className:`text-sm text-gray-600 mt-1 line-clamp-2`,children:e.evolution_reason}),(0,j.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:u(S(e.created_at),`yyyy-MM-dd HH:mm`)})]}),t>0&&(0,j.jsx)(C,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>F({open:!0,versionId:e.version_id,version:e.version}),children:`回滚`})]},e.version_id))})]}),(0,j.jsxs)(w,{children:[(0,j.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,j.jsx)(r,{className:`h-5 w-5`}),`进化事件`]}),q?(0,j.jsx)(`div`,{className:`text-center py-8 text-gray-400`,children:`加载中...`}):K.length===0?(0,j.jsx)(`div`,{className:`text-center py-8 text-gray-400`,children:`暂无进化事件`}):(0,j.jsx)(`div`,{className:`space-y-3 max-h-[500px] overflow-y-auto`,children:K.map((e,t)=>(0,j.jsx)(E.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:t*.05},className:`p-3 border border-gray-200 rounded-lg`,children:(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(T,{size:`sm`,className:N[e.signal_type]||`bg-gray-100 text-gray-700`,children:M[e.signal_type]||e.signal_type}),(0,j.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,j.jsx)(`p`,{className:`text-sm text-gray-700`,children:e.action}),(0,j.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:u(S(e.created_at),`yyyy-MM-dd HH:mm`)})]})]})},e.event_id))})]})]}),z&&z.node_stats.length>0&&(0,j.jsxs)(w,{children:[(0,j.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4`,children:`节点成功率`}),(0,j.jsx)(`div`,{className:`space-y-3`,children:z.node_stats.map((e,t)=>(0,j.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,j.jsx)(`div`,{className:`w-32 text-sm text-gray-700 truncate`,children:e.phase}),(0,j.jsxs)(`div`,{className:`flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`div`,{className:`flex-1 h-2 bg-gray-200 rounded-full overflow-hidden`,children:(0,j.jsx)(`div`,{className:`h-full bg-green-500 transition-all`,style:{width:`${e.success_rate*100}%`}})}),(0,j.jsxs)(`span`,{className:`text-sm font-medium text-gray-900 w-12 text-right`,children:[Math.round(e.success_rate*100),`%`]})]}),(0,j.jsxs)(`p`,{className:`text-xs text-gray-500 mt-1`,children:[e.total_attempts,` 次尝试`]})]})]},t))})]}),(0,j.jsx)(O,{open:P.open,title:`确认回滚`,description:`确认将模板回滚到版本 ${P.version}?此操作将覆盖当前版本。`,variant:`warning`,onConfirm:()=>U.mutate({versionId:P.versionId}),onCancel:()=>F({open:!1,versionId:``,version:``})})]})}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Dn as t,Fn as n,Jt as r,Sn as i,an as a,en as o,gr as s,s as c}from"./vendor-DRGPi8ui.js";import{c as l}from"./vendor-react-DJI9oneq.js";import{r as u}from"./vendor-query-DqPOMnuX.js";import{c as d}from"./vendor-flow-srkes8If.js";import{At as f}from"./client-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Dn as t,Fn as n,Jt as r,Sn as i,an as a,en as o,gr as s,s as c}from"./vendor-DRGPi8ui.js";import{c as l}from"./vendor-react-DJI9oneq.js";import{r as u}from"./vendor-query-DqPOMnuX.js";import{c as d}from"./vendor-flow-srkes8If.js";import{At as f}from"./client-BvVpIixG.js";import{l as p,n as m,r as h,t as g}from"./ui-CDL3BZ13.js";import{t as _}from"./vendor-motion-CQmdgnI8.js";import{t as v}from"./ErrorState-BOInXmfg.js";import{n as y}from"./Skeleton-B7PVDJJ_.js";var b=e(s(),1),x=d();function S(){let e=l(),[s,d]=(0,b.useState)(``),[S,C]=(0,b.useState)(`all`),{data:w,isLoading:T,isError:E,refetch:D}=u({queryKey:[`templates`],queryFn:()=>f().then(e=>e.data)});if(T)return(0,x.jsx)(y,{count:5});if(E)return(0,x.jsx)(v,{message:`模板数据加载失败`,onRetry:()=>D()});let O=w?.items||[],k=O.filter(e=>{let t=!s||e.name.toLowerCase().includes(s.toLowerCase())||e.description.toLowerCase().includes(s.toLowerCase()),n=S===`all`||e.source===S;return t&&n}),A={builtin:`bg-blue-100 text-blue-700`,convention:`bg-purple-100 text-purple-700`,user:`bg-green-100 text-green-700`},j={builtin:`内置`,convention:`规范`,user:`自定义`};return(0,x.jsxs)(`div`,{className:`space-y-6`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`流水线模板`}),(0,x.jsxs)(`p`,{className:`text-sm text-gray-500 mt-1`,children:[`管理和查看流水线模板,共 `,O.length,` 个模板`]})]}),(0,x.jsx)(m,{variant:`primary`,icon:a,onClick:()=>e(`/templates/new`),children:`新建模板`})]}),(0,x.jsx)(h,{children:(0,x.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,x.jsxs)(`div`,{className:`relative flex-1 min-w-[240px] max-w-sm`,children:[(0,x.jsx)(o,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,x.jsx)(`input`,{type:`text`,placeholder:`搜索模板名称或描述...`,value:s,onChange:e=>d(e.target.value),className:`w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`})]}),(0,x.jsxs)(`select`,{value:S,onChange:e=>C(e.target.value),className:`px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,x.jsx)(`option`,{value:`all`,children:`全部来源`}),(0,x.jsx)(`option`,{value:`builtin`,children:`内置模板`}),(0,x.jsx)(`option`,{value:`convention`,children:`规范模板`}),(0,x.jsx)(`option`,{value:`user`,children:`自定义模板`})]})]})}),(0,x.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:k.map((a,o)=>(0,x.jsx)(_.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:o*.05},children:(0,x.jsx)(h,{className:`h-full hover:shadow-md transition-shadow cursor-pointer`,onClick:()=>e(`/templates/${a.id}`),children:(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`h3`,{className:`font-semibold text-gray-900 truncate`,children:a.name}),(0,x.jsx)(`p`,{className:`text-sm text-gray-500 mt-1 line-clamp-2`,children:a.description})]}),(0,x.jsx)(g,{size:`sm`,className:A[a.source],children:j[a.source]})]}),a.conventionName&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-600`,children:[(0,x.jsx)(i,{className:`h-3 w-3`}),(0,x.jsx)(`span`,{children:a.conventionName})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,x.jsx)(t,{className:`h-4 w-4`}),(0,x.jsxs)(`span`,{children:[a.nodes.length,` 个节点`]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[a.trigger.keywords.length>0&&(0,x.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[a.trigger.keywords.slice(0,3).map((e,t)=>(0,x.jsx)(`span`,{className:`px-2 py-0.5 bg-gray-100 text-gray-600 rounded text-xs`,children:e},t)),a.trigger.keywords.length>3&&(0,x.jsxs)(`span`,{className:`px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs`,children:[`+`,a.trigger.keywords.length-3]})]}),a.trigger.complexity.length>0&&(0,x.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[`适用复杂度:`,a.trigger.complexity.join(`, `)]})]}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-gray-100`,children:[(0,x.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[a.version&&`v${a.version}`,a.updatedAt&&` · ${c(p(a.updatedAt),`yyyy-MM-dd`)}`]}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(m,{variant:`ghost`,size:`sm`,icon:n,onClick:t=>{t.stopPropagation(),e(`/templates/${a.id}`)},children:`查看`}),a.source===`user`&&(0,x.jsx)(m,{variant:`ghost`,size:`sm`,icon:r,onClick:t=>{t.stopPropagation(),e(`/templates/${a.id}/edit`)},children:`编辑`})]})]})]})})},a.id))}),k.length===0&&(0,x.jsx)(h,{children:(0,x.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:s||S!==`all`?`没有找到匹配的模板`:`暂无模板`})})]})}export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,It as n,Yn as r,gr as i,qn as a}from"./vendor-DRGPi8ui.js";import{C as o}from"./vendor-charts-9eVsQvUV.js";import{c as s}from"./vendor-flow-srkes8If.js";var c=e(i(),1),l=e(o(),1),u=s(),d=(0,c.createContext)({toast:()=>{}}),f=()=>{};function p(e,t=`error`){f(e,t)}function m({children:e}){let[i,o]=(0,c.useState)([]),s={current:0},p=(0,c.useCallback)((e,t=`error`)=>{let n=++s.current;o(r=>[...r,{id:n,type:t,message:e}]),setTimeout(()=>o(e=>e.filter(e=>e.id!==n)),4e3)},[]);(0,c.useEffect)(()=>{f=p;let e=e=>p(e.detail,`error`);return window.addEventListener(`api:error`,e),()=>window.removeEventListener(`api:error`,e)},[p]);let m={success:r,error:a,warning:t},h={success:`bg-green-50 border-green-200 text-green-800`,error:`bg-red-50 border-red-200 text-red-800`,warning:`bg-yellow-50 border-yellow-200 text-yellow-800`},g={success:`text-green-500`,error:`text-red-500`,warning:`text-yellow-500`};return(0,u.jsxs)(d.Provider,{value:{toast:p},children:[e,(0,l.createPortal)((0,u.jsx)(`div`,{className:`fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 max-w-sm`,children:i.map(e=>{let t=m[e.type];return(0,u.jsxs)(`div`,{className:`flex items-start gap-3 px-4 py-3 rounded-lg border shadow-lg text-sm ${h[e.type]}`,children:[(0,u.jsx)(t,{className:`h-4 w-4 mt-0.5 flex-shrink-0 ${g[e.type]}`}),(0,u.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,u.jsx)(`button`,{onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),children:(0,u.jsx)(n,{className:`h-3.5 w-3.5 opacity-60 hover:opacity-100`})})]},e.id)})}),document.body)]})}export{p as n,m as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mr as e}from"./vendor-DRGPi8ui.js";var t=e.create({baseURL:`/api`,timeout:3e4});t.interceptors.request.use(e=>{let t=window.__AUTH_TOKEN__;return t&&(e.headers.Authorization=`Bearer ${t}`),e}),t.interceptors.response.use(e=>e,e=>{let t=e.response?.data?.error||e.response?.data?.message||e.message||`请求失败`;return window.dispatchEvent(new CustomEvent(`api:error`,{detail:t})),Promise.reject(e)});var n=()=>t.get(`/health`),r=()=>t.get(`/config`),i=e=>t.put(`/config`,e),ee=()=>t.get(`/config/history`),te=e=>t.get(`/sessions`,{params:e}),a=e=>t.get(`/sessions/${e}`),o=e=>t.delete(`/sessions/${e}`),s=(e,n)=>t.patch(`/sessions/${e}/meta`,n),c=e=>t.delete(`/sessions`,{data:{ids:e}}),l=e=>t.get(`/events`,{params:e}),u=e=>t.get(`/events/stats`,{params:{project_path:e}}),d=e=>t.get(`/pipelines`,{params:e}),f=e=>t.get(`/pipelines/${e}`),p=e=>t.get(`/quality/history`,{params:e}),m=e=>t.get(`/quality/unresolved`,{params:{project_path:e}}),h=()=>t.get(`/stats/roi`),g=()=>t.get(`/stats/overview`),_=(e,n,r,i)=>t.get(`/knowledge/search`,{params:{q:e,project_path:n,node_type:r,limit:i}}),v=e=>t.get(`/knowledge/overview`,{params:{project_path:e}}),y=(e,n)=>t.get(`/knowledge/neighbors`,{params:{node_id:e,project_path:n}}),b=(e,n)=>t.get(`/knowledge/graph`,{params:{project_path:e,node_type:n}}),x=e=>t.post(`/knowledge/nodes`,e),S=(e,n)=>t.put(`/knowledge/nodes/${e}`,n),C=e=>t.delete(`/knowledge/nodes/${e}`),w=e=>t.delete(`/knowledge/batch`,{data:{ids:e}}),T=e=>t.post(`/knowledge/import`,{nodes:e}),E=e=>t.post(`/knowledge/edges`,e),D=e=>t.post(`/pipelines/${e}/close`),O=e=>t.post(`/pipelines/${e}/reactivate`),k=e=>t.post(`/pipelines/batch-close`,{ids:e}),A=()=>t.post(`/pipelines/close-expired`),j=()=>t.get(`/pipelines/active`),M=e=>t.post(`/pipelines/${e}/resume`),N=e=>t.post(`/pipelines/${e}/advance`),P=e=>t.get(`/pipeline-templates`,{params:e}),F=e=>t.get(`/pipeline-templates/${e}`),I=e=>t.post(`/pipeline-templates`,e),L=(e,n)=>t.put(`/pipeline-templates/${e}`,n),R=e=>t.delete(`/pipeline-templates/${e}`),z=e=>t.get(`/projects`,{params:e}),B=e=>t.get(`/projects/${e}`),V=e=>t.delete(`/projects/${e}`),H=e=>t.post(`/convention/init`,{path:e},{timeout:18e4}),U=e=>t.get(`/projects/${e}/conventions`),W=(e,n)=>t.post(`/projects/${e}/conventions/bind`,{conventionId:n}),G=(e,n)=>t.delete(`/projects/${e}/conventions/${encodeURIComponent(n)}`),K=e=>t.get(`/projects/${e}/conventions/custom/yaml`),q=(e,n)=>t.put(`/projects/${e}/conventions/custom`,{yaml:n}),J=e=>t.post(`/projects/${e}/conventions/distill`,{},{timeout:12e4}),Y=e=>t.get(`/claudemd/${e}`),X=(e,n)=>t.put(`/claudemd/${e}`,{content:n}),Z=e=>t.get(`/claudemd/${e}/profile`),Q=e=>t.get(`/claudemd/${e}/modules`),ne=e=>t.post(`/claudemd/${e}/distill`,void 0,{timeout:18e4}),re=e=>t.post(`/claudemd/${e}/init`,void 0,{timeout:18e4}),ie=e=>t.post(`/quality/${e}/resolve`),ae=e=>t.post(`/quality/${e}/dismiss`),oe=e=>t.post(`/quality/batch-dismiss`,{ids:e}),se=e=>t.post(`/quality/batch-resolve`,{ids:e}),ce=()=>t.post(`/quality/resolve-all`),le=e=>t.get(`/quality/${e}/context`),ue=()=>t.get(`/daemon/status`),de=()=>t.post(`/daemon/restart`),fe=()=>t.get(`/daemon/diagnose`),pe=()=>t.post(`/daemon/repair`),me=e=>t.post(`/config/backup`,e||{}),he=()=>t.get(`/config/backups`),ge=e=>`/api/config/backups/${encodeURIComponent(e)}`,_e=(e,n)=>t.post(`/config/restore`,{filename:e,password:n}),ve=e=>t.post(`/events/purge`,{retentionDays:e}),ye=()=>t.get(`/memory/caches`),be=()=>t.get(`/memory/process`),xe=e=>t.post(`/memory/caches/${encodeURIComponent(e)}/clear`),Se=()=>t.post(`/memory/caches/clear-all`),Ce=()=>t.post(`/memory/gc`),we=e=>t.get(`/stats/api-usage`,{params:{days:e}}),Te=e=>t.get(`/skills`,{params:e}),Ee=()=>t.get(`/skills/status`),De=e=>t.get(`/skills/${encodeURIComponent(e)}`),Oe=(e,n)=>t.put(`/skills/${encodeURIComponent(e)}/content`,{content:n}),ke=(e,n)=>t.post(`/skills/search`,{query:e,...n},{timeout:3e4}),Ae=e=>t.post(`/skills/install`,{url:e},{timeout:6e4}),je=e=>t.delete(`/skills/${encodeURIComponent(e)}`),Me=e=>t.post(`/skills/batch-delete`,{names:e}),Ne=()=>t.post(`/skills/evolve`,{},{timeout:12e4}),Pe=()=>t.post(`/skills/distill`,{},{timeout:12e4}),Fe=()=>t.post(`/skills/repair`,{},{timeout:6e4}),Ie=()=>t.get(`/skills/orchestration`),Le=(e,n)=>t.put(`/skills/orchestration`,{skill:e,keywords:n}),Re=e=>t.delete(`/skills/orchestration/${encodeURIComponent(e)}`),ze=()=>t.get(`/conventions`),Be=e=>t.get(`/conventions/${encodeURIComponent(e)}`),Ve=()=>t.post(`/conventions/sync-official`),He=e=>t.post(`/conventions/install`,{url:e},{timeout:3e4}),Ue=e=>t.delete(`/conventions/${encodeURIComponent(e)}`),We=()=>t.get(`/conventions/usage-stats`),Ge=e=>t.get(`/conventions/${encodeURIComponent(e)}/evolution-history`),Ke=e=>t.post(`/conventions/batch-evolve`,{conventionIds:e},{timeout:12e4}),qe=e=>t.get(`/conventions/${encodeURIComponent(e)}/yaml`),Je=(e,n)=>t.put(`/conventions/${encodeURIComponent(e)}/yaml`,{yaml:n}),$=e=>t.get(`/node-types`,{params:e?{projectPath:e}:void 0}),Ye=e=>t.get(`/node-types/${encodeURIComponent(e)}`),Xe=e=>t.post(`/node-types`,e),Ze=(e,n)=>t.put(`/node-types/${encodeURIComponent(e)}`,n),Qe=e=>t.delete(`/node-types/${encodeURIComponent(e)}`),$e=e=>t.get(`/plans/by-project/${encodeURIComponent(e)}`),et=e=>t.get(`/plans/nodes/${e}/attempts`),tt=e=>t.post(`/plans/${e}/approve`),nt=e=>t.post(`/plans/${e}/abort`),rt=()=>t.get(`/templates`),it=e=>t.get(`/templates/${e}/versions`),at=(e,n)=>t.post(`/templates/${e}/rollback`,{version_id:n}),ot=e=>t.get(`/templates/${e}/stats`),st=e=>t.get(`/evolution/events`,{params:e}),ct=()=>t.get(`/evolution/stats`);export{ze as $,G as $t,fe as A,rt as At,Q as B,pe as Bt,C,a as Ct,V as D,Te as Dt,R as E,Ee as Et,Ne as F,He as Ft,We as G,_e as Gt,r as H,ce as Ht,j as I,Ae as It,u as J,Je as Jt,qe as K,M as Kt,we as L,he as Lt,ne as M,T as Mt,J as N,H as Nt,o as O,ot as Ot,Pe as P,re as Pt,Be as Q,Ce as Qt,ge as R,ve as Rt,Ue as S,h as St,Re as T,De as Tt,ee as U,ie as Ut,Z as V,Fe as Vt,Ge as W,de as Wt,st as X,ke as Xt,l as Y,_ as Yt,ct as Z,Ve as Zt,D as _,U as _t,me as a,q as an,be as at,Xe as b,le as bt,c,Le as cn,$ as ct,Ke as d,f as dt,X as en,n as et,se as f,$e as ft,A as g,B as gt,xe as h,d as ht,tt as i,L as in,ye as it,ae as j,m as jt,je as k,it as kt,Me as l,Ie as lt,Se as m,P as mt,N as n,S as nn,y as nt,k as o,s as on,et as ot,W as p,F as pt,ue as q,at as qt,t as r,Ze as rn,v as rt,w as s,Oe as sn,Ye as st,nt as t,i as tn,b as tt,oe as u,g as ut,E as v,K as vt,Qe as w,te as wt,I as x,p as xt,x as y,z as yt,Y as z,O as zt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Dskgf0jG.js","assets/rolldown-runtime-COnpUsM8.js","assets/vendor-react-DJI9oneq.js","assets/vendor-DRGPi8ui.js","assets/vendor-charts-9eVsQvUV.js","assets/vendor-query-DqPOMnuX.js","assets/vendor-flow-srkes8If.js","assets/vendor-flow-CHpVij2M.css","assets/vendor-motion-CQmdgnI8.js","assets/client-BvVpIixG.js","assets/ConfirmDialog-BKfwMp04.js","assets/ui-CDL3BZ13.js","assets/Sessions-C0BmdDPK.js","assets/BatchProgress-BQ533tSf.js","assets/ErrorState-BOInXmfg.js","assets/Skeleton-B7PVDJJ_.js","assets/exportCsv-Dm5Y5M_E.js","assets/SessionDetail-BMrqH8_W.js","assets/Breadcrumb-DtfwnOx6.js","assets/Events-CAY9kU9T.js","assets/useDebounce-DNfPs3Tv.js","assets/Pipelines-Drat9IqZ.js","assets/Pagination-lp8b_3NR.js","assets/PipelineDetail-DGoURh1I.js","assets/Toast-BbB3oD2a.js","assets/Quality-Bm7oRSun.js","assets/Config-1QvdGyY8.js","assets/Analytics-txva5ugO.js","assets/Knowledge-BHLyFp2U.js","assets/Projects-qDolX6Y6.js","assets/ProjectDetail-Cx8VZp8O.js","assets/Skills-B3c1_uFt.js","assets/Conventions-E_2yAYoB.js","assets/vendor-editor-CYLOGES5.js","assets/NodeTypes-B6wc7VnR.js","assets/PipelineTemplates-sSL-9oRh.js","assets/Templates-Dho__f4l.js","assets/TemplateDetail-ep5h3Cu5.js","assets/Evolution-Ck_BqRpt.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{$n as t,$t as n,Bt as r,Dn as i,En as a,Ft as o,Mn as s,Qt as c,Un as l,Vt as u,_n as d,ar as f,cr as p,en as ee,gr as m,ir as h,kn as g,mn as _,or as v,pr as y,rn as b,rr as x,un as S,xn as C}from"./vendor-DRGPi8ui.js";import{a as w,c as T,d as E,i as D,o as O,r as k,s as A,t as j,u as M}from"./vendor-react-DJI9oneq.js";import{a as N,i as P,o as F,r as I}from"./vendor-query-DqPOMnuX.js";import{c as te}from"./vendor-flow-srkes8If.js";import{Dt as L,Yt as R,et as z,ht as B,wt as V}from"./client-BvVpIixG.js";import{a as H,n as U}from"./ui-CDL3BZ13.js";import{n as W,t as G}from"./vendor-motion-CQmdgnI8.js";import{t as K}from"./useDebounce-DNfPs3Tv.js";import{t as q}from"./Toast-BbB3oD2a.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var J=e(E(),1),Y=e(m(),1),X=te(),Z=[{path:`/dashboard`,label:`仪表盘`,icon:C},{path:`/projects`,label:`项目管理`,icon:g},{path:`/sessions`,label:`会话管理`,icon:y},{path:`/events`,label:`事件流`,icon:h},{path:`/pipelines`,label:`流水线`,icon:i},{path:`/quality`,label:`质量门禁`,icon:c},{path:`/knowledge`,label:`知识图谱`,icon:f},{path:`/skills`,label:`技能管理`,icon:S},{path:`/conventions`,label:`规范管理`,icon:p},{path:`/node-types`,label:`节点类型`,icon:v},{path:`/pipeline-templates`,label:`模板管理`,icon:s},{path:`/templates`,label:`执行模板`,icon:i},{path:`/evolution`,label:`模板进化`,icon:u},{path:`/analytics`,label:`数据分析`,icon:x},{path:`/config`,label:`系统配置`,icon:n}];function Q({children:e}){let[n,r]=(0,Y.useState)(()=>localStorage.getItem(`sidebar-collapsed`)===`true`),i=A();(0,Y.useEffect)(()=>{localStorage.setItem(`sidebar-collapsed`,String(n))},[n]);let{data:a}=I({queryKey:[`health`],queryFn:()=>z().then(e=>e.data)}),s=Z.find(e=>i.pathname.startsWith(e.path));return(0,X.jsxs)(`div`,{className:`flex min-h-screen bg-gray-50`,children:[(0,X.jsxs)(`aside`,{className:H(`fixed top-0 left-0 bottom-0 z-50 flex flex-col transition-all duration-300`,`bg-gradient-to-b from-slate-900 to-slate-800`,n?`w-16`:`w-60`),children:[(0,X.jsxs)(`div`,{className:H(`flex items-center border-b border-white/10 h-16`,n?`justify-center px-2`:`justify-between px-5`),children:[!n&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-gradient-to-br from-blue-500 to-purple-600`,children:(0,X.jsx)(o,{className:`h-5 w-5 text-white`})}),(0,X.jsx)(`span`,{className:`text-white font-bold text-lg tracking-tight`,children:`Forge`})]}),(0,X.jsx)(`button`,{onClick:()=>r(!n),className:`p-1.5 rounded-lg text-white/60 hover:text-white hover:bg-white/10 transition-colors`,children:n?(0,X.jsx)(_,{className:`h-5 w-5`}):(0,X.jsx)(t,{className:`h-5 w-5`})})]}),(0,X.jsx)(`nav`,{className:`flex-1 py-4 space-y-1 px-2`,children:Z.map(e=>(0,X.jsxs)(k,{to:e.path,className:({isActive:e})=>H(`flex items-center gap-3 rounded-lg transition-all duration-200`,n?`justify-center p-3`:`px-3 py-2.5`,e?`bg-blue-600/20 text-blue-400`:`text-white/60 hover:text-white hover:bg-white/5`),children:[(0,X.jsx)(e.icon,{className:`h-5 w-5 flex-shrink-0`}),!n&&(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:e.label})]},e.path))}),(0,X.jsx)(`div`,{className:H(`border-t border-white/10 py-4`,n?`px-2`:`px-5`),children:(0,X.jsxs)(`div`,{className:H(`flex items-center gap-2`,n?`justify-center`:``),children:[(0,X.jsx)(`div`,{className:H(`w-2 h-2 rounded-full`,a?.status===`ok`?`bg-green-400 animate-pulse`:`bg-red-400`)}),!n&&(0,X.jsx)(`span`,{className:`text-xs text-white/40`,children:a?.status===`ok`?`Daemon 运行中`:`连接断开`})]})})]}),(0,X.jsxs)(`main`,{className:H(`flex-1 transition-all duration-300`,n?`ml-16`:`ml-60`),children:[(0,X.jsxs)(`header`,{className:`sticky top-0 z-40 bg-white/80 backdrop-blur-md border-b border-gray-200/50 h-16 flex items-center justify-between px-8`,children:[(0,X.jsx)(`h1`,{className:`text-xl font-semibold text-gray-900`,children:s?.label||`Claude Forge`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsxs)(`button`,{className:`hidden sm:flex items-center gap-2 px-3 py-1.5 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors`,onClick:()=>{let e=new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0});window.dispatchEvent(e)},children:[(0,X.jsx)(l,{className:`h-4 w-4`}),(0,X.jsx)(`span`,{children:`命令面板`}),(0,X.jsx)(`kbd`,{className:`px-2 py-0.5 text-xs bg-gray-100 rounded border border-gray-200`,children:`⌘K`})]}),(0,X.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[`v`,`3.6.51`]}),(0,X.jsxs)(`div`,{className:H(`flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-semibold`,a?.status===`ok`?`bg-green-50 text-green-700 border border-green-200`:`bg-red-50 text-red-700 border border-red-200`),children:[(0,X.jsx)(`div`,{className:H(`w-1.5 h-1.5 rounded-full`,a?.status===`ok`?`bg-green-500`:`bg-red-500`)}),a?.status===`ok`?`在线`:`离线`]})]})]}),(0,X.jsx)(`div`,{className:`p-8 overflow-x-hidden`,children:e})]})]})}var ne=e=>[{id:`nav-dashboard`,label:`仪表盘`,description:`查看效率指标和趋势`,icon:C,action:()=>e(`/dashboard`),category:`导航`},{id:`nav-sessions`,label:`会话管理`,description:`查看和管理会话`,icon:y,action:()=>e(`/sessions`),category:`导航`},{id:`nav-events`,label:`事件流`,description:`查看实时事件`,icon:h,action:()=>e(`/events`),category:`导航`},{id:`nav-pipelines`,label:`流水线`,description:`查看编排流水线`,icon:i,action:()=>e(`/pipelines`),category:`导航`},{id:`nav-quality`,label:`质量门禁`,description:`查看质量问题`,icon:c,action:()=>e(`/quality`),category:`导航`},{id:`nav-knowledge`,label:`知识图谱`,description:`浏览知识节点`,icon:f,action:()=>e(`/knowledge`),category:`导航`},{id:`nav-analytics`,label:`数据分析`,description:`查看统计报表`,icon:x,action:()=>e(`/analytics`),category:`导航`},{id:`nav-config`,label:`系统配置`,description:`管理配置项`,icon:n,action:()=>e(`/config`),category:`导航`}];function re(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(``),[i,s]=(0,Y.useState)(0),c=(0,Y.useRef)(null),u=T(),p=K(n,300),m=p.trim().length>=2,{data:h,isFetching:g}=I({queryKey:[`cmd-pipelines`,p],queryFn:()=>B({search:p,page_size:5}).then(e=>e.data),enabled:m&&e,staleTime:1e4}),{data:_,isFetching:v}=I({queryKey:[`cmd-sessions`,p],queryFn:()=>V({limit:5}).then(e=>e.data),enabled:m&&e,staleTime:1e4}),{data:b,isFetching:x}=I({queryKey:[`cmd-knowledge`,p],queryFn:()=>R(p,void 0,void 0,5).then(e=>e.data),enabled:m&&e,staleTime:1e4}),{data:S,isFetching:C}=I({queryKey:[`cmd-skills`,p],queryFn:()=>L({limit:5}).then(e=>e.data),enabled:m&&e,staleTime:1e4}),w=g||v||x||C,E=[];if(m){let e=p.toLowerCase();(h?.items||[]).forEach(t=>{let n=String(t.requirement||``);(n.toLowerCase().includes(e)||!e)&&E.push({id:`pipeline-${t.id}`,label:n.slice(0,60)||String(t.id),description:`流水线 · ${t.project||``}`,icon:a,action:()=>u(`/pipelines/${t.id}`),category:`流水线`})}),(_?.items||[]).filter(t=>String(t.title||t.id||``).toLowerCase().includes(e)).forEach(e=>{E.push({id:`session-${e.id}`,label:String(e.title||e.id||``).slice(0,60),description:`会话 · ${String(e.project_path||``).split(`/`).pop()||``}`,icon:y,action:()=>u(`/sessions/${e.id}`),category:`会话`})}),(b?.items||[]).forEach(e=>{E.push({id:`knowledge-${e.id}`,label:String(e.title||``).slice(0,60),description:`知识节点 · ${e.node_type||``}`,icon:f,action:()=>u(`/knowledge`),category:`知识图谱`})}),(S?.items||[]).filter(t=>String(t.name||``).toLowerCase().includes(e)).forEach(e=>{E.push({id:`skill-${e.name}`,label:String(e.name||``).slice(0,60),description:`技能 · ${e.description?String(e.description).slice(0,40):``}`,icon:o,action:()=>u(`/skills`),category:`技能`})})}let D=ne(u),O=n?D.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())||(e.description||``).toLowerCase().includes(n.toLowerCase())):D,k=m?[...E,...O]:O;(0,Y.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),t(e=>!e),r(``),s(0)),e.key===`Escape`&&t(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Y.useEffect)(()=>{e&&setTimeout(()=>c.current?.focus(),100)},[e]),(0,Y.useEffect)(()=>{s(0)},[p]);let A=e=>{e.key===`ArrowDown`?(e.preventDefault(),s(e=>Math.min(e+1,k.length-1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(e-1,0))):e.key===`Enter`&&k[i]&&(k[i].action(),t(!1))},j=Array.from(new Set(k.map(e=>e.category)));return(0,X.jsx)(W,{children:e&&(0,X.jsx)(G.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`fixed inset-0 z-[200] bg-black/50 backdrop-blur-sm flex items-start justify-center pt-[20vh]`,onClick:()=>t(!1),children:(0,X.jsxs)(G.div,{initial:{scale:.95,opacity:0,y:-20},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:-20},transition:{duration:.15},className:`bg-white rounded-xl shadow-2xl w-full max-w-lg overflow-hidden border border-gray-200`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-gray-100`,children:[w?(0,X.jsx)(d,{className:`h-5 w-5 text-blue-400 flex-shrink-0 animate-spin`}):(0,X.jsx)(ee,{className:`h-5 w-5 text-gray-400 flex-shrink-0`}),(0,X.jsx)(`input`,{ref:c,type:`text`,placeholder:`输入命令或搜索(≥2字符跨模块搜索)...`,value:n,onChange:e=>{r(e.target.value),s(0)},onKeyDown:A,className:`flex-1 text-sm outline-none placeholder:text-gray-400`}),(0,X.jsx)(`kbd`,{className:`hidden sm:inline-flex items-center gap-1 px-2 py-0.5 text-xs text-gray-400 bg-gray-100 rounded`,children:`ESC`})]}),(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto py-2`,children:k.length===0&&!w?(0,X.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-gray-400`,children:m?`没有找到相关内容`:`没有匹配的命令`}):j.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`px-4 py-1.5 text-xs font-semibold text-gray-400 uppercase tracking-wider`,children:e}),k.filter(t=>t.category===e).map(e=>{let n=k.indexOf(e);return(0,X.jsxs)(`button`,{className:H(`w-full flex items-center gap-3 px-4 py-2.5 text-left transition-colors`,n===i?`bg-blue-50 text-blue-700`:`text-gray-700 hover:bg-gray-50`),onClick:()=>{e.action(),t(!1)},onMouseEnter:()=>s(n),children:[(0,X.jsx)(e.icon,{className:`h-4 w-4 flex-shrink-0`}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.label}),e.description&&(0,X.jsx)(`div`,{className:`text-xs text-gray-400 truncate`,children:e.description})]})]},e.id)})]},e))}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-gray-100 text-xs text-gray-400`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-gray-100 rounded`,children:`↑↓`}),`导航`]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`kbd`,{className:`px-1.5 py-0.5 bg-gray-100 rounded`,children:`↵`}),`执行`]})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(l,{className:`h-3 w-3`}),`K 打开`]})]})]})})})}var $=class extends Y.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught:`,e,t)}render(){return this.state.hasError?(0,X.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 px-4`,children:(0,X.jsxs)(`div`,{className:`max-w-md w-full bg-white rounded-xl shadow-lg p-8 text-center`,children:[(0,X.jsx)(r,{className:`h-16 w-16 text-red-500 mx-auto mb-4`}),(0,X.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 mb-2`,children:`出错了`}),(0,X.jsx)(`p`,{className:`text-gray-600 mb-6`,children:`页面加载时遇到错误,请刷新页面重试`}),this.state.error&&(0,X.jsxs)(`details`,{className:`text-left mb-6 p-4 bg-gray-50 rounded-lg`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-gray-700 mb-2`,children:`错误详情`}),(0,X.jsx)(`pre`,{className:`text-xs text-red-600 overflow-auto`,children:this.state.error.toString()})]}),(0,X.jsx)(U,{variant:`primary`,icon:b,onClick:()=>window.location.reload(),children:`刷新页面`})]})}):this.props.children}},ie=3e3;function ae(){let e=window.__AUTH_TOKEN__;return e?`/api/events/stream?token=${encodeURIComponent(e)}`:`/api/events/stream`}function oe(){let e=N(),t=(0,Y.useRef)(null),n=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let r=!1;function i(){if(r)return;let a=new EventSource(ae());t.current=a;let o=t=>{for(let n of t)e.invalidateQueries({queryKey:n})};a.addEventListener(`pipeline:status`,()=>{o([[`pipelines-active`],[`pipelines`,`active`],[`pipelines`],[`overview`],[`plan`,`by-project`]])}),a.addEventListener(`pipeline:node`,()=>{o([[`pipelines-active`],[`pipelines`,`active`],[`pipelines`],[`pipeline`]])}),a.addEventListener(`quality:issue`,()=>{o([[`quality-history`],[`quality-unresolved`],[`overview`]])}),a.addEventListener(`session:event`,()=>{o([[`events-live`],[`sessions`],[`overview`]])}),a.addEventListener(`session:status`,()=>{o([[`sessions`],[`overview`]])}),a.addEventListener(`daemon:status`,()=>{o([[`daemon-status`],[`health`]])}),a.onerror=()=>{a.close(),t.current=null,r||(n.current=setTimeout(i,ie))}}return i(),()=>{r=!0,n.current&&clearTimeout(n.current),t.current?.close(),t.current=null}},[e])}var se=(0,Y.lazy)(()=>M(()=>import(`./Dashboard-Dskgf0jG.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),ce=(0,Y.lazy)(()=>M(()=>import(`./Sessions-C0BmdDPK.js`),__vite__mapDeps([12,1,2,3,4,5,6,7,9,13,10,11,8,14,15,16]))),le=(0,Y.lazy)(()=>M(()=>import(`./SessionDetail-BMrqH8_W.js`),__vite__mapDeps([17,1,2,3,4,5,6,7,8,9,18,11]))),ue=(0,Y.lazy)(()=>M(()=>import(`./Events-CAY9kU9T.js`),__vite__mapDeps([19,1,3,5,6,4,7,8,9,10,11,14,20,16]))),de=(0,Y.lazy)(()=>M(()=>import(`./Pipelines-Drat9IqZ.js`),__vite__mapDeps([21,1,2,3,4,5,6,7,8,9,13,10,11,14,22,15,20,16]))),fe=(0,Y.lazy)(()=>M(()=>import(`./PipelineDetail-DGoURh1I.js`),__vite__mapDeps([23,1,2,3,4,5,6,7,8,9,18,10,11,24]))),pe=(0,Y.lazy)(()=>M(()=>import(`./Quality-Bm7oRSun.js`),__vite__mapDeps([25,1,3,5,6,4,7,8,9,10,11,14,22,24,20,16]))),me=(0,Y.lazy)(()=>M(()=>import(`./Config-1QvdGyY8.js`),__vite__mapDeps([26,1,3,5,6,4,7,8,9,10,11,24]))),he=(0,Y.lazy)(()=>M(()=>import(`./Analytics-txva5ugO.js`),__vite__mapDeps([27,1,3,5,6,4,7,9,14,11,8,16]))),ge=(0,Y.lazy)(()=>M(()=>import(`./Knowledge-BHLyFp2U.js`),__vite__mapDeps([28,1,3,5,6,4,7,8,9,10,11,22,24,16]))),_e=(0,Y.lazy)(()=>M(()=>import(`./Projects-qDolX6Y6.js`),__vite__mapDeps([29,1,2,3,4,5,6,7,8,9,22,11,24,16]))),ve=(0,Y.lazy)(()=>M(()=>import(`./ProjectDetail-Cx8VZp8O.js`),__vite__mapDeps([30,1,2,3,4,5,6,7,9,18,22,11,8,24]))),ye=(0,Y.lazy)(()=>M(()=>import(`./Skills-B3c1_uFt.js`),__vite__mapDeps([31,1,3,5,6,4,7,9,10,11,8,24]))),be=(0,Y.lazy)(()=>M(()=>import(`./Conventions-E_2yAYoB.js`),__vite__mapDeps([32,1,33,3,5,6,4,7,9,10,11,8,24]))),xe=(0,Y.lazy)(()=>M(()=>import(`./NodeTypes-B6wc7VnR.js`),__vite__mapDeps([34,1,3,5,6,4,7,9]))),Se=(0,Y.lazy)(()=>M(()=>import(`./PipelineTemplates-sSL-9oRh.js`),__vite__mapDeps([35,1,3,5,6,4,7,9,24]))),Ce=(0,Y.lazy)(()=>M(()=>import(`./Templates-Dho__f4l.js`),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,14,11,15]))),we=(0,Y.lazy)(()=>M(()=>import(`./TemplateDetail-ep5h3Cu5.js`),__vite__mapDeps([37,1,2,3,4,5,6,7,8,9,10,11,14,15]))),Te=(0,Y.lazy)(()=>M(()=>import(`./Evolution-Ck_BqRpt.js`),__vite__mapDeps([38,2,1,3,4,5,6,7,8,9,15,11])));function Ee(){return oe(),(0,X.jsx)($,{children:(0,X.jsxs)(q,{children:[(0,X.jsx)(re,{}),(0,X.jsx)(Q,{children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full text-gray-400`,children:`加载中...`}),children:(0,X.jsxs)(O,{children:[(0,X.jsx)(w,{path:`/`,element:(0,X.jsx)(D,{to:`/dashboard`,replace:!0})}),(0,X.jsx)(w,{path:`/dashboard`,element:(0,X.jsx)(se,{})}),(0,X.jsx)(w,{path:`/sessions`,element:(0,X.jsx)(ce,{})}),(0,X.jsx)(w,{path:`/sessions/:id`,element:(0,X.jsx)(le,{})}),(0,X.jsx)(w,{path:`/events`,element:(0,X.jsx)(ue,{})}),(0,X.jsx)(w,{path:`/pipelines`,element:(0,X.jsx)(de,{})}),(0,X.jsx)(w,{path:`/pipelines/:id`,element:(0,X.jsx)(fe,{})}),(0,X.jsx)(w,{path:`/projects`,element:(0,X.jsx)(_e,{})}),(0,X.jsx)(w,{path:`/projects/:encodedPath`,element:(0,X.jsx)(ve,{})}),(0,X.jsx)(w,{path:`/quality`,element:(0,X.jsx)(pe,{})}),(0,X.jsx)(w,{path:`/analytics`,element:(0,X.jsx)(he,{})}),(0,X.jsx)(w,{path:`/knowledge`,element:(0,X.jsx)(ge,{})}),(0,X.jsx)(w,{path:`/skills`,element:(0,X.jsx)(ye,{})}),(0,X.jsx)(w,{path:`/conventions`,element:(0,X.jsx)(be,{})}),(0,X.jsx)(w,{path:`/node-types`,element:(0,X.jsx)(xe,{})}),(0,X.jsx)(w,{path:`/pipeline-templates`,element:(0,X.jsx)(Se,{})}),(0,X.jsx)(w,{path:`/templates`,element:(0,X.jsx)(Ce,{})}),(0,X.jsx)(w,{path:`/templates/:id`,element:(0,X.jsx)(we,{})}),(0,X.jsx)(w,{path:`/evolution`,element:(0,X.jsx)(Te,{})}),(0,X.jsx)(w,{path:`/config`,element:(0,X.jsx)(me,{})})]})})})]})})}var De=new F({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,staleTime:3e4}}});J.createRoot(document.getElementById(`root`)).render((0,X.jsx)(Y.StrictMode,{children:(0,X.jsx)(P,{client:De,children:(0,X.jsx)(j,{children:(0,X.jsx)(Ee,{})})})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Claude Forge - 管理后台</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BoxlVgIs.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-COnpUsM8.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-DRGPi8ui.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-charts-9eVsQvUV.js">
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/vendor-flow-srkes8If.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/vendor-query-DqPOMnuX.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/vendor-motion-CQmdgnI8.js">
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/client-
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/client-BvVpIixG.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/Toast-BbB3oD2a.js">
|
|
16
17
|
<link rel="modulepreload" crossorigin href="/assets/ui-CDL3BZ13.js">
|
|
17
18
|
<link rel="modulepreload" crossorigin href="/assets/useDebounce-DNfPs3Tv.js">
|
|
18
19
|
<link rel="stylesheet" crossorigin href="/assets/vendor-flow-CHpVij2M.css">
|