@winspan/claude-forge 3.6.27 → 3.6.43

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.
Files changed (239) hide show
  1. package/dist/autopilot/issue-tracker.js +1 -1
  2. package/dist/autopilot/issue-tracker.js.map +1 -1
  3. package/dist/autopilot/quality-gate.d.ts +20 -2
  4. package/dist/autopilot/quality-gate.d.ts.map +1 -1
  5. package/dist/autopilot/quality-gate.js +20 -2
  6. package/dist/autopilot/quality-gate.js.map +1 -1
  7. package/dist/cli/commands/logs.js +1 -1
  8. package/dist/cli/commands/logs.js.map +1 -1
  9. package/dist/config/defaults.d.ts.map +1 -1
  10. package/dist/config/defaults.js +5 -0
  11. package/dist/config/defaults.js.map +1 -1
  12. package/dist/config/schema.d.ts +9 -1
  13. package/dist/config/schema.d.ts.map +1 -1
  14. package/dist/config/schema.js +5 -0
  15. package/dist/config/schema.js.map +1 -1
  16. package/dist/convention/convention-loader.d.ts.map +1 -1
  17. package/dist/convention/convention-loader.js +3 -0
  18. package/dist/convention/convention-loader.js.map +1 -1
  19. package/dist/convention/types.d.ts +15 -5
  20. package/dist/convention/types.d.ts.map +1 -1
  21. package/dist/daemon/engine-registry.d.ts.map +1 -1
  22. package/dist/daemon/engine-registry.js +6 -0
  23. package/dist/daemon/engine-registry.js.map +1 -1
  24. package/dist/daemon/handler-context.d.ts +5 -1
  25. package/dist/daemon/handler-context.d.ts.map +1 -1
  26. package/dist/daemon/handlers/post-tool-use-handler.d.ts.map +1 -1
  27. package/dist/daemon/handlers/post-tool-use-handler.js +59 -2
  28. package/dist/daemon/handlers/post-tool-use-handler.js.map +1 -1
  29. package/dist/daemon/handlers/pre-tool-use-handler.d.ts.map +1 -1
  30. package/dist/daemon/handlers/pre-tool-use-handler.js +25 -2
  31. package/dist/daemon/handlers/pre-tool-use-handler.js.map +1 -1
  32. package/dist/daemon/handlers/session-cleanup.d.ts +2 -0
  33. package/dist/daemon/handlers/session-cleanup.d.ts.map +1 -1
  34. package/dist/daemon/handlers/session-cleanup.js +20 -0
  35. package/dist/daemon/handlers/session-cleanup.js.map +1 -1
  36. package/dist/daemon/handlers/stages/07-pipeline-reply.d.ts.map +1 -1
  37. package/dist/daemon/handlers/stages/07-pipeline-reply.js +3 -0
  38. package/dist/daemon/handlers/stages/07-pipeline-reply.js.map +1 -1
  39. package/dist/daemon/handlers/stages/18-complex-task.d.ts.map +1 -1
  40. package/dist/daemon/handlers/stages/18-complex-task.js +3 -0
  41. package/dist/daemon/handlers/stages/18-complex-task.js.map +1 -1
  42. package/dist/daemon/handlers/stages/19-moderate-task.d.ts.map +1 -1
  43. package/dist/daemon/handlers/stages/19-moderate-task.js +3 -0
  44. package/dist/daemon/handlers/stages/19-moderate-task.js.map +1 -1
  45. package/dist/daemon/handlers/stop-handler.d.ts.map +1 -1
  46. package/dist/daemon/handlers/stop-handler.js +1 -0
  47. package/dist/daemon/handlers/stop-handler.js.map +1 -1
  48. package/dist/daemon/index.d.ts.map +1 -1
  49. package/dist/daemon/index.js +80 -0
  50. package/dist/daemon/index.js.map +1 -1
  51. package/dist/pipeline/completion-gate.d.ts +1 -0
  52. package/dist/pipeline/completion-gate.d.ts.map +1 -1
  53. package/dist/pipeline/completion-gate.js +43 -3
  54. package/dist/pipeline/completion-gate.js.map +1 -1
  55. package/dist/pipeline/completion-verifier.d.ts +75 -0
  56. package/dist/pipeline/completion-verifier.d.ts.map +1 -0
  57. package/dist/pipeline/completion-verifier.js +217 -0
  58. package/dist/pipeline/completion-verifier.js.map +1 -0
  59. package/dist/pipeline/diagnosis-service.d.ts +43 -0
  60. package/dist/pipeline/diagnosis-service.d.ts.map +1 -0
  61. package/dist/pipeline/diagnosis-service.js +136 -0
  62. package/dist/pipeline/diagnosis-service.js.map +1 -0
  63. package/dist/pipeline/dynamic-node-types.d.ts +2 -0
  64. package/dist/pipeline/dynamic-node-types.d.ts.map +1 -1
  65. package/dist/pipeline/execution-engine.d.ts +79 -0
  66. package/dist/pipeline/execution-engine.d.ts.map +1 -0
  67. package/dist/pipeline/execution-engine.js +227 -0
  68. package/dist/pipeline/execution-engine.js.map +1 -0
  69. package/dist/pipeline/index.d.ts +27 -1
  70. package/dist/pipeline/index.d.ts.map +1 -1
  71. package/dist/pipeline/index.js +87 -72
  72. package/dist/pipeline/index.js.map +1 -1
  73. package/dist/pipeline/node-type-sync.d.ts.map +1 -1
  74. package/dist/pipeline/node-type-sync.js +25 -22
  75. package/dist/pipeline/node-type-sync.js.map +1 -1
  76. package/dist/pipeline/pipeline-state-machine.d.ts +19 -0
  77. package/dist/pipeline/pipeline-state-machine.d.ts.map +1 -0
  78. package/dist/pipeline/pipeline-state-machine.js +53 -0
  79. package/dist/pipeline/pipeline-state-machine.js.map +1 -0
  80. package/dist/pipeline/plan-service.d.ts +58 -0
  81. package/dist/pipeline/plan-service.d.ts.map +1 -0
  82. package/dist/pipeline/plan-service.js +382 -0
  83. package/dist/pipeline/plan-service.js.map +1 -0
  84. package/dist/pipeline/strategy-selector.d.ts +41 -0
  85. package/dist/pipeline/strategy-selector.d.ts.map +1 -0
  86. package/dist/pipeline/strategy-selector.js +112 -0
  87. package/dist/pipeline/strategy-selector.js.map +1 -0
  88. package/dist/pipeline/template-evolver.d.ts +45 -0
  89. package/dist/pipeline/template-evolver.d.ts.map +1 -0
  90. package/dist/pipeline/template-evolver.js +223 -0
  91. package/dist/pipeline/template-evolver.js.map +1 -0
  92. package/dist/pipeline/template-registry.d.ts.map +1 -1
  93. package/dist/pipeline/template-registry.js +4 -1
  94. package/dist/pipeline/template-registry.js.map +1 -1
  95. package/dist/storage/repositories/base-repository.d.ts +2 -0
  96. package/dist/storage/repositories/base-repository.d.ts.map +1 -1
  97. package/dist/storage/repositories/base-repository.js +12 -0
  98. package/dist/storage/repositories/base-repository.js.map +1 -1
  99. package/dist/storage/repositories/dynamic-pipeline-repository.d.ts +2 -2
  100. package/dist/storage/repositories/dynamic-pipeline-repository.d.ts.map +1 -1
  101. package/dist/storage/repositories/dynamic-pipeline-repository.js +28 -3
  102. package/dist/storage/repositories/dynamic-pipeline-repository.js.map +1 -1
  103. package/dist/storage/repositories/dynamic-pipeline-template-repository.d.ts +13 -0
  104. package/dist/storage/repositories/dynamic-pipeline-template-repository.d.ts.map +1 -0
  105. package/dist/storage/repositories/dynamic-pipeline-template-repository.js +117 -0
  106. package/dist/storage/repositories/dynamic-pipeline-template-repository.js.map +1 -0
  107. package/dist/storage/repositories/event-repository.d.ts.map +1 -1
  108. package/dist/storage/repositories/event-repository.js +1 -1
  109. package/dist/storage/repositories/event-repository.js.map +1 -1
  110. package/dist/storage/repositories/latency-repository.js +1 -1
  111. package/dist/storage/repositories/latency-repository.js.map +1 -1
  112. package/dist/storage/repositories/node-attempt-repository.d.ts +29 -0
  113. package/dist/storage/repositories/node-attempt-repository.d.ts.map +1 -0
  114. package/dist/storage/repositories/node-attempt-repository.js +57 -0
  115. package/dist/storage/repositories/node-attempt-repository.js.map +1 -0
  116. package/dist/storage/repositories/pipeline-plan-repository.d.ts +75 -0
  117. package/dist/storage/repositories/pipeline-plan-repository.d.ts.map +1 -0
  118. package/dist/storage/repositories/pipeline-plan-repository.js +123 -0
  119. package/dist/storage/repositories/pipeline-plan-repository.js.map +1 -0
  120. package/dist/storage/repositories/quality-repository.d.ts +16 -0
  121. package/dist/storage/repositories/quality-repository.d.ts.map +1 -0
  122. package/dist/storage/repositories/quality-repository.js +36 -0
  123. package/dist/storage/repositories/quality-repository.js.map +1 -0
  124. package/dist/storage/repositories/session-repository.d.ts +7 -0
  125. package/dist/storage/repositories/session-repository.d.ts.map +1 -1
  126. package/dist/storage/repositories/session-repository.js +33 -0
  127. package/dist/storage/repositories/session-repository.js.map +1 -1
  128. package/dist/storage/repositories/template-evolution-repository.d.ts +39 -0
  129. package/dist/storage/repositories/template-evolution-repository.d.ts.map +1 -0
  130. package/dist/storage/repositories/template-evolution-repository.js +83 -0
  131. package/dist/storage/repositories/template-evolution-repository.js.map +1 -0
  132. package/dist/storage/schema/migration-manager.d.ts +1 -1
  133. package/dist/storage/schema/migration-manager.d.ts.map +1 -1
  134. package/dist/storage/schema/migration-manager.js +27 -1
  135. package/dist/storage/schema/migration-manager.js.map +1 -1
  136. package/dist/storage/sqlite.d.ts +21 -0
  137. package/dist/storage/sqlite.d.ts.map +1 -1
  138. package/dist/storage/sqlite.js +105 -31
  139. package/dist/storage/sqlite.js.map +1 -1
  140. package/dist/types/session.d.ts +3 -0
  141. package/dist/types/session.d.ts.map +1 -1
  142. package/dist/utils/logger.d.ts +4 -4
  143. package/dist/utils/logger.d.ts.map +1 -1
  144. package/dist/utils/logger.js +24 -10
  145. package/dist/utils/logger.js.map +1 -1
  146. package/dist/web/routes/config.d.ts +2 -0
  147. package/dist/web/routes/config.d.ts.map +1 -1
  148. package/dist/web/routes/config.js +58 -3
  149. package/dist/web/routes/config.js.map +1 -1
  150. package/dist/web/routes/evolution.d.ts +4 -0
  151. package/dist/web/routes/evolution.d.ts.map +1 -0
  152. package/dist/web/routes/evolution.js +61 -0
  153. package/dist/web/routes/evolution.js.map +1 -0
  154. package/dist/web/routes/knowledge.d.ts.map +1 -1
  155. package/dist/web/routes/knowledge.js +44 -16
  156. package/dist/web/routes/knowledge.js.map +1 -1
  157. package/dist/web/routes/pipelines.d.ts.map +1 -1
  158. package/dist/web/routes/pipelines.js +72 -0
  159. package/dist/web/routes/pipelines.js.map +1 -1
  160. package/dist/web/routes/plans.d.ts +5 -0
  161. package/dist/web/routes/plans.d.ts.map +1 -0
  162. package/dist/web/routes/plans.js +163 -0
  163. package/dist/web/routes/plans.js.map +1 -0
  164. package/dist/web/routes/quality.d.ts.map +1 -1
  165. package/dist/web/routes/quality.js +6 -44
  166. package/dist/web/routes/quality.js.map +1 -1
  167. package/dist/web/routes/sessions.d.ts.map +1 -1
  168. package/dist/web/routes/sessions.js +27 -15
  169. package/dist/web/routes/sessions.js.map +1 -1
  170. package/dist/web/routes/skills.d.ts.map +1 -1
  171. package/dist/web/routes/skills.js +13 -6
  172. package/dist/web/routes/skills.js.map +1 -1
  173. package/dist/web/routes/stats.d.ts.map +1 -1
  174. package/dist/web/routes/stats.js +53 -2
  175. package/dist/web/routes/stats.js.map +1 -1
  176. package/dist/web/routes/templates.d.ts +4 -0
  177. package/dist/web/routes/templates.d.ts.map +1 -0
  178. package/dist/web/routes/templates.js +117 -0
  179. package/dist/web/routes/templates.js.map +1 -0
  180. package/dist/web/server.d.ts.map +1 -1
  181. package/dist/web/server.js +119 -26
  182. package/dist/web/server.js.map +1 -1
  183. package/dist/web/sse-broadcaster.d.ts +23 -0
  184. package/dist/web/sse-broadcaster.d.ts.map +1 -0
  185. package/dist/web/sse-broadcaster.js +73 -0
  186. package/dist/web/sse-broadcaster.js.map +1 -0
  187. package/dist/web/utils/error-response.d.ts +23 -0
  188. package/dist/web/utils/error-response.d.ts.map +1 -0
  189. package/dist/web/utils/error-response.js +26 -0
  190. package/dist/web/utils/error-response.js.map +1 -0
  191. package/dist/web/utils/validation.d.ts +10 -0
  192. package/dist/web/utils/validation.d.ts.map +1 -1
  193. package/dist/web/utils/validation.js +15 -0
  194. package/dist/web/utils/validation.js.map +1 -1
  195. package/dist/web-static/assets/Analytics-Bo74j97W.js +1 -0
  196. package/dist/web-static/assets/BatchProgress-BQ533tSf.js +1 -0
  197. package/dist/web-static/assets/Breadcrumb-DtfwnOx6.js +1 -0
  198. package/dist/web-static/assets/Config-DhfQsbT1.js +1 -0
  199. package/dist/web-static/assets/ConfirmDialog-CVzB7X5y.js +1 -0
  200. package/dist/web-static/assets/Conventions-BobuQiOk.js +1 -0
  201. package/dist/web-static/assets/Dashboard-Bj28rnDe.js +1 -0
  202. package/dist/web-static/assets/ErrorState-DXHA8lr8.js +1 -0
  203. package/dist/web-static/assets/Events-C0y7WcDP.js +1 -0
  204. package/dist/web-static/assets/Evolution-DimZAXFS.js +1 -0
  205. package/dist/web-static/assets/Knowledge-Y1lX6vor.js +2 -0
  206. package/dist/web-static/assets/NodeTypes-DyrDqhBp.js +1 -0
  207. package/dist/web-static/assets/Pagination-lp8b_3NR.js +1 -0
  208. package/dist/web-static/assets/PipelineDetail-DGKz18zu.js +4 -0
  209. package/dist/web-static/assets/PipelineTemplates-D4zvL6I1.js +1 -0
  210. package/dist/web-static/assets/Pipelines-CR9oD3Xy.js +2 -0
  211. package/dist/web-static/assets/ProjectDetail-RfdtEvTT.js +1 -0
  212. package/dist/web-static/assets/Projects-RGIPdiJn.js +1 -0
  213. package/dist/web-static/assets/Quality-BdvL1VQn.js +3 -0
  214. package/dist/web-static/assets/SessionDetail-BNDIfmmq.js +1 -0
  215. package/dist/web-static/assets/Sessions-CorfQV78.js +2 -0
  216. package/dist/web-static/assets/Skeleton-B7PVDJJ_.js +1 -0
  217. package/dist/web-static/assets/Skills-BJt0OrKj.js +1 -0
  218. package/dist/web-static/assets/TemplateDetail-DOfBYdQ3.js +1 -0
  219. package/dist/web-static/assets/Templates-Cp3yC5tv.js +1 -0
  220. package/dist/web-static/assets/client-BhcjNvkG.js +1 -0
  221. package/dist/web-static/assets/exportCsv-CSExJI8h.js +3 -0
  222. package/dist/web-static/assets/index-CqwJts5v.css +2 -0
  223. package/dist/web-static/assets/index-DdmJVOxm.js +2 -0
  224. package/dist/web-static/assets/rolldown-runtime-COnpUsM8.js +1 -0
  225. package/dist/web-static/assets/ui-CDL3BZ13.js +1 -0
  226. package/dist/web-static/assets/useDebounce-DNfPs3Tv.js +1 -0
  227. package/dist/web-static/assets/useSmartPolling-DYAVOihL.js +1 -0
  228. package/dist/web-static/assets/vendor-DRGPi8ui.js +9 -0
  229. package/dist/web-static/assets/vendor-charts-9eVsQvUV.js +36 -0
  230. package/dist/web-static/assets/vendor-editor-B1NX2ipj.js +11 -0
  231. package/dist/web-static/assets/vendor-flow-CHpVij2M.css +1 -0
  232. package/dist/web-static/assets/vendor-flow-srkes8If.js +7 -0
  233. package/dist/web-static/assets/vendor-motion-CQmdgnI8.js +9 -0
  234. package/dist/web-static/assets/vendor-query-DqPOMnuX.js +4 -0
  235. package/dist/web-static/assets/vendor-react-DJI9oneq.js +11 -0
  236. package/dist/web-static/index.html +13 -2
  237. package/package.json +2 -1
  238. package/dist/web-static/assets/index-BCgOtcuH.js +0 -91
  239. package/dist/web-static/assets/index-DwWCJY_u.css +0 -1
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,Cn as n,Ut as r,gr as i}from"./vendor-DRGPi8ui.js";import{c as a}from"./vendor-flow-srkes8If.js";import{a as o,n as s}from"./ui-CDL3BZ13.js";var c=e(i(),1),l=a();function u({open:e,title:i,description:a,confirmText:u=`确认`,cancelText:d=`取消`,variant:f=`default`,loading:p=!1,count:m,onConfirm:h,onCancel:g}){let[_,v]=(0,c.useState)(``),y=m!==void 0&&m>=5&&m<=20,b=m!==void 0&&m>20,x=y||b,S=b?`DELETE`:String(m),C=!x||_===S;if((0,c.useEffect)(()=>{if(!e){v(``);return}let t=e=>{e.key===`Escape`&&g(),e.key===`Enter`&&C&&h()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,h,g,C]),!e)return null;let w=f===`danger`?r:f===`warning`?t:n,T=f===`danger`?`text-red-500`:f===`warning`?`text-amber-500`:`text-blue-500`;return(0,l.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm`,onClick:g,children:(0,l.jsxs)(`div`,{className:`bg-white rounded-xl shadow-xl w-full max-w-md mx-4 p-6`,onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,l.jsx)(`div`,{className:o(`flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center`,f===`danger`?`bg-red-50`:f===`warning`?`bg-amber-50`:`bg-blue-50`),children:(0,l.jsx)(w,{className:o(`h-5 w-5`,T)})}),(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:i}),(0,l.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 leading-relaxed`,children:a})]})]}),x&&(0,l.jsxs)(`div`,{className:`mt-4`,children:[(0,l.jsx)(`p`,{className:`text-sm text-gray-600 mb-2`,children:b?(0,l.jsxs)(l.Fragment,{children:[`请输入 `,(0,l.jsx)(`code`,{className:`px-1 py-0.5 bg-gray-100 rounded text-red-600 font-mono text-xs`,children:`DELETE`}),` 以确认操作`]}):(0,l.jsxs)(l.Fragment,{children:[`请输入数量 `,(0,l.jsx)(`code`,{className:`px-1 py-0.5 bg-gray-100 rounded text-gray-800 font-mono text-xs`,children:m}),` 以确认操作`]})}),(0,l.jsx)(`input`,{autoFocus:!0,type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:S,className:o(`w-full px-3 py-2 border rounded-lg text-sm focus:outline-none focus:ring-2`,_&&!C?`border-red-300 focus:ring-red-400`:`border-gray-200 focus:ring-blue-500`)})]}),(0,l.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,l.jsx)(s,{variant:`secondary`,size:`sm`,onClick:g,disabled:p,children:d}),(0,l.jsx)(s,{variant:f===`danger`?`danger`:`primary`,size:`sm`,onClick:h,loading:p,disabled:!C,children:u})]})]})})}export{u as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Gn as t,It as n,Mn as r,Rn as i,Ut as a,Vt as o,Yn as s,cr as c,en as l,gr as u,rn as d,tn as f}from"./vendor-DRGPi8ui.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{$ as _,Ft as v,G as y,Jt as b,K as x,Q as S,S as C,W as w,Zt as T,d as E,un as D}from"./client-BhcjNvkG.js";import{t as O}from"./ConfirmDialog-CVzB7X5y.js";import{t as k}from"./vendor-editor-B1NX2ipj.js";var A=e(u(),1),j=g();function M(){let[e,t]=(0,A.useState)(`library`),[o,s]=(0,A.useState)(`all`),[u,f]=(0,A.useState)(``),[g,b]=(0,A.useState)(new Set),[x,S]=(0,A.useState)(null),[w,k]=(0,A.useState)(``),[M,I]=(0,A.useState)(!1),[L,R]=(0,A.useState)(null),z=p(),{data:B,isLoading:V}=h({queryKey:[`global-conventions`],queryFn:()=>_().then(e=>e.data),refetchInterval:6e4}),{data:H}=h({queryKey:[`convention-usage-stats`],queryFn:()=>y().then(e=>e.data),enabled:e===`usage`}),U=m({mutationFn:()=>T().then(e=>e.data),onSuccess:e=>{D(e.added.length+e.updated.length>0?`同步完成:新增 ${e.added.length},更新 ${e.updated.length}`:`已是最新`,`success`),z.invalidateQueries({queryKey:[`global-conventions`]})}}),W=m({mutationFn:e=>v(e).then(e=>e.data),onSuccess:e=>{D(`已安装:${e.convention.name}`,`success`),k(``),I(!1),z.invalidateQueries({queryKey:[`global-conventions`]})}}),G=m({mutationFn:e=>C(e).then(e=>e.data),onSuccess:(e,t)=>{D(`规范已删除`,`success`),R(null),z.invalidateQueries({queryKey:[`global-conventions`]})}}),K=m({mutationFn:e=>E(e.length>0?e:void 0).then(e=>e.data),onSuccess:e=>{D(`进化完成:${e.results.success.length} 个规范已更新`,`success`),z.invalidateQueries({queryKey:[`global-conventions`]})}}),q=(B?.items||[]).filter(e=>!(o!==`all`&&e.source!==o||u&&!e.name.toLowerCase().includes(u.toLowerCase()))),J=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Y=q.length>0&&g.size===q.length,X=()=>b(Y?new Set:new Set(q.map(e=>e.id))),Z={official:`bg-amber-50 text-amber-700`,user:`bg-blue-50 text-blue-700`,community:`bg-purple-50 text-purple-700`},Q={official:`官方`,user:`用户`,community:`社区`};return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`规范管理`}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`管理全局规范模板,绑定到项目,追踪使用情况`})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`button`,{onClick:()=>U.mutate(),disabled:U.isPending,className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-amber-50 text-amber-700 hover:bg-amber-100 rounded-lg transition-colors`,children:[(0,j.jsx)(d,{className:`h-4 w-4 ${U.isPending?`animate-spin`:``}`}),`同步官方规范`]}),(0,j.jsxs)(`button`,{onClick:()=>I(!M),className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-blue-600 text-white hover:bg-blue-700 rounded-lg transition-colors`,children:[(0,j.jsx)(i,{className:`h-4 w-4`}),`从 URL 安装`]})]})]}),M&&(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-3`,children:[(0,j.jsx)(`input`,{type:`text`,placeholder:`规范 YAML 文件 URL...`,value:w,onChange:e=>k(e.target.value),onKeyDown:e=>e.key===`Enter`&&w.trim()&&W.mutate(w.trim()),className:`flex-1 px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`}),(0,j.jsx)(`button`,{onClick:()=>W.mutate(w.trim()),disabled:!w.trim()||W.isPending,className:`px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors`,children:W.isPending?`安装中...`:`安装`}),(0,j.jsx)(`button`,{onClick:()=>I(!1),className:`p-2 text-gray-400 hover:text-gray-600 rounded-lg`,children:(0,j.jsx)(n,{className:`h-4 w-4`})})]})}),(0,j.jsx)(`div`,{className:`border-b border-gray-200`,children:(0,j.jsx)(`nav`,{className:`flex gap-1`,children:[{key:`library`,label:`规范库`},{key:`usage`,label:`使用统计`},{key:`evolution`,label:`进化历史`}].map(n=>(0,j.jsx)(`button`,{onClick:()=>t(n.key),className:`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===`library`&&(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4 flex items-center gap-3 flex-wrap`,children:[(0,j.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`official`,`user`,`community`].map(e=>(0,j.jsx)(`button`,{onClick:()=>s(e),className:`px-3 py-1.5 text-xs rounded-lg transition-colors ${o===e?`bg-blue-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`}`,children:{all:`全部`,official:`官方`,user:`用户`,community:`社区`}[e]},e))}),(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(l,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400`}),(0,j.jsx)(`input`,{type:`text`,placeholder:`搜索规范名称...`,value:u,onChange:e=>f(e.target.value),className:`pl-8 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 w-48`})]}),(0,j.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[q.length,` 个规范`]}),g.size>0&&(0,j.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[`已选 `,g.size,` 个`]}),(0,j.jsxs)(`button`,{onClick:()=>K.mutate(Array.from(g)),disabled:K.isPending,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-green-50 text-green-600 hover:bg-green-100 rounded-lg transition-colors`,children:[(0,j.jsx)(d,{className:`h-3.5 w-3.5 ${K.isPending?`animate-spin`:``}`}),`批量进化`]})]})]}),V?(0,j.jsx)(`div`,{className:`flex items-center justify-center h-48 bg-white rounded-xl border border-gray-200`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500`})}):(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:[(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`w-10 px-4 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:X,className:`rounded`})}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`规范名称`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`版本`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`角色数`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`质量标准`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:q.map(e=>(0,j.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:g.has(e.id),onChange:()=>J(e.id),className:`rounded`})}),(0,j.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,j.jsx)(`button`,{onClick:()=>S(e.id),className:`font-medium text-blue-600 hover:text-blue-700 text-left`,children:e.name}),(0,j.jsx)(`div`,{className:`text-xs text-gray-500 truncate max-w-xs mt-0.5`,children:e.description})]}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full font-medium ${Z[e.source]||`bg-gray-100 text-gray-600`}`,children:Q[e.source]||e.source})}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.version||`—`}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.roles?Object.keys(e.roles).length:0}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.quality_standards?.length||0}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`button`,{onClick:()=>S(e.id),className:`p-1.5 text-gray-400 hover:text-blue-500 rounded transition-colors`,title:`查看/编辑`,children:(0,j.jsx)(r,{className:`h-4 w-4`})}),e.source!==`official`&&(0,j.jsx)(`button`,{onClick:()=>R(e),className:`p-1.5 text-gray-400 hover:text-red-500 rounded transition-colors`,title:`删除`,children:(0,j.jsx)(a,{className:`h-4 w-4`})})]})})]},e.id))})]}),q.length===0&&(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(c,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无规范`}),(0,j.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:`点击「同步官方规范」获取内置规范`})]})]})]}),e===`usage`&&(0,j.jsx)(N,{data:H?.items||[]}),e===`evolution`&&(0,j.jsx)(P,{conventions:B?.items||[]}),x&&(0,j.jsx)(F,{id:x,onClose:()=>S(null)}),L&&(0,j.jsx)(O,{open:!!L,title:`删除规范`,description:`确定要删除规范「${L.name}」吗?此操作不可撤销。`,variant:`danger`,onConfirm:()=>G.mutate(L.id),onCancel:()=>R(null)})]})}function N({data:e}){let[t,n]=(0,A.useState)(null);return(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 overflow-hidden`,children:e.length===0?(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(o,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无使用数据`})]}):(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`bg-gray-50 border-b border-gray-200`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`规范名称`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`来源`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`使用项目数`}),(0,j.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-gray-600`,children:`操作`})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-gray-100`,children:e.map(e=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(`tr`,{className:`hover:bg-gray-50 transition-colors`,children:[(0,j.jsx)(`td`,{className:`px-4 py-3 font-medium text-gray-900`,children:e.name}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.source}),(0,j.jsx)(`td`,{className:`px-4 py-3 text-gray-600`,children:e.projectCount}),(0,j.jsx)(`td`,{className:`px-4 py-3`,children:(0,j.jsx)(`button`,{onClick:()=>n(t===e.id?null:e.id),className:`text-xs text-blue-600 hover:text-blue-700`,children:t===e.id?`收起`:`查看项目`})})]}),t===e.id&&(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:4,className:`px-4 py-3 bg-gray-50`,children:(0,j.jsx)(`div`,{className:`text-xs text-gray-600 space-y-1`,children:e.projects.map((e,t)=>(0,j.jsx)(`div`,{className:`font-mono`,children:e},t))})})})]},e.id))})]})})}function P({conventions:e}){let[n,r]=(0,A.useState)(null),{data:i,isLoading:a}=h({queryKey:[`convention-evolution`,n],queryFn:()=>n?w(n).then(e=>e.data):null,enabled:!!n});return(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-4`,children:[(0,j.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-2`,children:`选择规范`}),(0,j.jsxs)(`select`,{value:n||``,onChange:e=>r(e.target.value||null),className:`w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,j.jsx)(`option`,{value:``,children:`— 请选择 —`}),e.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,` (v`,e.version,`)`]},e.id))]})]}),n&&(0,j.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:a?(0,j.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500`})}):!i||i.history.length===0?(0,j.jsxs)(`div`,{className:`text-center py-12`,children:[(0,j.jsx)(t,{className:`h-10 w-10 text-gray-300 mx-auto mb-3`}),(0,j.jsx)(`p`,{className:`text-gray-500`,children:`暂无进化记录`})]}):(0,j.jsx)(`div`,{className:`space-y-4`,children:i.history.map((e,t)=>(0,j.jsxs)(`div`,{className:`border-l-2 border-blue-200 pl-4 pb-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,j.jsx)(s,{className:`h-4 w-4 text-green-500`}),(0,j.jsxs)(`span`,{className:`text-sm font-medium text-gray-900`,children:[e.previousVersion,` → `,e.newVersion]}),(0,j.jsx)(`span`,{className:`text-xs text-gray-500`,children:new Date(e.timestamp).toLocaleString(`zh-CN`)})]}),e.changes.length>0&&(0,j.jsx)(`ul`,{className:`text-sm text-gray-600 space-y-1 ml-6`,children:e.changes.map((e,t)=>(0,j.jsx)(`li`,{className:`list-disc`,children:e},t))})]},t))})})]})}function F({id:e,onClose:t}){let[i,a]=(0,A.useState)(``),[o,s]=(0,A.useState)(!1),c=p(),{data:l,isLoading:u}=h({queryKey:[`global-convention`,e],queryFn:()=>S(e).then(e=>e.data)}),{data:g}=h({queryKey:[`convention-yaml`,e],queryFn:()=>x(e).then(e=>e.data),enabled:o});(0,A.useEffect)(()=>{g?.yaml!==void 0&&a(g.yaml)},[g]);let _=m({mutationFn:t=>b(e,t).then(e=>e.data),onSuccess:()=>{D(`保存成功`,`success`),s(!1),c.invalidateQueries({queryKey:[`global-convention`,e]}),c.invalidateQueries({queryKey:[`global-conventions`]})},onError:()=>{D(`保存失败`,`error`)}}),v=m({mutationFn:()=>E([e]).then(e=>e.data),onSuccess:t=>{t.results.success.length>0?(D(`规范已进化更新`,`success`),c.invalidateQueries({queryKey:[`global-convention`,e]}),c.invalidateQueries({queryKey:[`global-conventions`]})):D(`进化失败:`+(t.results.failed[0]?.error||`未知错误`),`error`)},onError:()=>{D(`进化失败`,`error`)}});if(u)return(0,j.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,j.jsx)(`div`,{className:`bg-white rounded-xl p-8`,children:(0,j.jsx)(d,{className:`h-8 w-8 animate-spin text-blue-500 mx-auto`})})});if(!l)return null;let y=l.source===`official`;return(0,j.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,j.jsxs)(`div`,{className:`bg-white rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between p-6 border-b border-gray-200`,children:[(0,j.jsxs)(`div`,{className:`flex-1`,children:[(0,j.jsx)(`h2`,{className:`text-xl font-bold text-gray-900`,children:l.name}),(0,j.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:l.description})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,j.jsxs)(`button`,{onClick:()=>v.mutate(),disabled:v.isPending,className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-green-50 text-green-600 hover:bg-green-100 rounded-lg transition-colors disabled:opacity-50`,title:`AI 进化优化`,children:[(0,j.jsx)(d,{className:`h-4 w-4 ${v.isPending?`animate-spin`:``}`}),v.isPending?`进化中...`:`手动进化`]}),(0,j.jsx)(`button`,{onClick:t,className:`p-2 text-gray-400 hover:text-gray-600 rounded-lg transition-colors`,children:(0,j.jsx)(n,{className:`h-5 w-5`})})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 text-sm`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`版本`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.version})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`来源`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.source===`official`?`官方`:l.source===`user`?`用户`:`社区`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-gray-500`,children:`角色数`}),(0,j.jsx)(`div`,{className:`font-medium text-gray-900 mt-1`,children:l.roles?Object.keys(l.roles).length:0})]})]}),o?(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`label`,{className:`text-sm font-medium text-gray-700`,children:`YAML 内容`}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(`button`,{onClick:()=>_.mutate(i),disabled:_.isPending,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 disabled:opacity-50 transition-colors`,children:[(0,j.jsx)(f,{className:`h-3.5 w-3.5`}),_.isPending?`保存中...`:`保存`]}),(0,j.jsx)(`button`,{onClick:()=>s(!1),className:`px-3 py-1.5 text-sm bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors`,children:`取消`})]})]}),(0,j.jsx)(`div`,{className:`border border-gray-200 rounded-lg overflow-hidden`,children:(0,j.jsx)(k,{height:`500px`,language:`yaml`,value:i,onChange:e=>a(e||``),theme:`vs-light`,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0}})})]}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[l.principles&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`核心原则`}),(0,j.jsx)(`pre`,{className:`text-sm text-gray-600 bg-gray-50 p-3 rounded-lg overflow-x-auto whitespace-pre-wrap`,children:l.principles})]}),l.roles&&Object.keys(l.roles).length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`角色定义`}),(0,j.jsx)(`div`,{className:`space-y-2`,children:Object.entries(l.roles).map(([e,t])=>(0,j.jsxs)(`div`,{className:`bg-gray-50 p-3 rounded-lg`,children:[(0,j.jsx)(`div`,{className:`font-medium text-gray-900 text-sm`,children:t.name||e}),t.responsibilities&&(0,j.jsxs)(`div`,{className:`text-xs text-gray-600 mt-1`,children:[`职责:`,t.responsibilities]}),t.constraints&&(0,j.jsxs)(`div`,{className:`text-xs text-gray-500 mt-1`,children:[`约束:`,t.constraints]})]},e))})]}),l.quality_standards&&l.quality_standards.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`质量标准`}),(0,j.jsx)(`div`,{className:`space-y-1.5`,children:l.quality_standards.map((e,t)=>(0,j.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`px-1.5 py-0.5 text-xs rounded font-medium ${e.severity===`must`?`bg-red-50 text-red-600`:e.severity===`should`?`bg-amber-50 text-amber-600`:`bg-blue-50 text-blue-600`}`,children:e.severity===`must`?`必须`:e.severity===`should`?`应该`:`可以`}),(0,j.jsxs)(`span`,{className:`text-gray-500`,children:[`[`,e.category,`]`]}),(0,j.jsx)(`span`,{className:`text-gray-700 flex-1`,children:e.rule})]},t))})]}),l.active_prompt&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`Active Prompt`}),(0,j.jsx)(`pre`,{className:`text-xs text-gray-600 bg-gray-50 p-3 rounded-lg overflow-x-auto whitespace-pre-wrap`,children:l.active_prompt})]}),!y&&(0,j.jsxs)(`button`,{onClick:()=>s(!0),className:`flex items-center gap-1.5 px-3 py-2 text-sm bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-lg transition-colors`,children:[(0,j.jsx)(r,{className:`h-4 w-4`}),`编辑 YAML`]})]})]})]})})}export{M as default};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Bt as t,Dn as n,Fn as r,Ft as i,Gn as ee,It as te,Qt as a,Ut as o,Vn as ne,ar as s,gr as c,in as l,ln as u,on as d,pr as f,rn as p,s as m,tr as h,ur as g}from"./vendor-DRGPi8ui.js";import{S as _,d as re,f as ie,g as ae,m as oe,s as se,y as ce}from"./vendor-charts-9eVsQvUV.js";import{c as le}from"./vendor-react-DJI9oneq.js";import{a as ue,n as v,r as y}from"./vendor-query-DqPOMnuX.js";import{c as b}from"./vendor-flow-srkes8If.js";import{Ht as de,I as fe,St as pe,Wt as me,Y as x,_ as S,at as C,g as w,it as T,q as E,ut as D}from"./client-BhcjNvkG.js";import{a as O,i as k,l as A,n as j,r as M,s as N,t as P}from"./ui-CDL3BZ13.js";import{t as F}from"./vendor-motion-CQmdgnI8.js";import{t as I}from"./ConfirmDialog-CVzB7X5y.js";import{t as he}from"./useSmartPolling-DYAVOihL.js";var L=e(c(),1),R=b(),ge={PreToolUse:`#3b82f6`,PostToolUse:`#10b981`,UserPromptSubmit:`#f59e0b`,Stop:`#ef4444`,Notification:`#8b5cf6`};function z(){let e=le(),c=ue(),[b,z]=(0,L.useState)(!1),B=(0,L.useRef)(null),[V,H]=(0,L.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:U}=y({queryKey:[`pipelines-active`],queryFn:()=>fe().then(e=>e.data)}),W=(U?.total||0)>0,G=he(W),{data:K}=y({queryKey:[`daemon-status`],queryFn:()=>E().then(e=>e.data),refetchInterval:G}),{data:q}=y({queryKey:[`overview`],queryFn:()=>D().then(e=>e.data),refetchInterval:G}),{data:J}=y({queryKey:[`roi-stats`],queryFn:()=>pe().then(e=>e.data),refetchInterval:6e4}),{data:Y,refetch:_e}=y({queryKey:[`events-live`],queryFn:()=>x({limit:100}).then(e=>e.data),refetchInterval:b?!1:G}),{data:X}=y({queryKey:[`memory-process-dash`],queryFn:()=>C().then(e=>e.data),refetchInterval:G}),{data:Z}=y({queryKey:[`memory-caches-dash`],queryFn:()=>T().then(e=>e.data),refetchInterval:G}),Q=v({mutationFn:e=>S(e),onSuccess:()=>c.invalidateQueries({queryKey:[`pipelines-active`]})}),ve=v({mutationFn:()=>w(),onSuccess:()=>c.invalidateQueries({queryKey:[`pipelines-active`]})}),ye=v({mutationFn:()=>de(),onSuccess:()=>c.invalidateQueries({queryKey:[`overview`]})}),be=v({mutationFn:()=>me()});(0,L.useEffect)(()=>{!b&&B.current&&B.current.scrollIntoView({behavior:`smooth`})},[Y,b]);let $=q?.recommendations?.find(e=>e.action===`/quality`);return(0,R.jsxs)(`div`,{className:`space-y-6`,children:[(0,R.jsx)(M,{className:`!p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-4 text-sm flex-wrap`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`div`,{className:O(`w-2 h-2 rounded-full`,K?.running?`bg-green-500 animate-pulse`:`bg-red-500`)}),(0,R.jsx)(`span`,{className:`font-medium`,children:K?.running?`Daemon PID:${K.pid}`:`Daemon 离线`})]}),K?.uptime&&(0,R.jsxs)(`span`,{className:`text-gray-400`,children:[`运行 `,K.uptime.formatted]}),K?.memory&&(0,R.jsxs)(`span`,{className:`text-gray-400`,children:[`内存 `,K.memory.rss,`MB`]}),W&&(0,R.jsx)(P,{variant:`info`,children:`Pipeline 运行中`}),$&&(0,R.jsx)(P,{variant:`warning`,children:$.title})]}),(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:l,onClick:()=>{H({open:!0,title:`重启 Daemon`,description:`确认重启 daemon?这将中断当前所有会话。`,onConfirm:()=>{be.mutate(),H(e=>({...e,open:!1}))}})},children:`重启`})]})}),X&&(0,R.jsx)(M,{className:`!p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(ne,{className:`h-4 w-4 text-purple-500`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:`内存`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-4 text-sm flex-wrap`,children:[(0,R.jsxs)(`span`,{className:`text-gray-500`,children:[`RSS `,(0,R.jsxs)(`span`,{className:`font-mono text-gray-800`,children:[X.rssMB,` MB`]})]}),(0,R.jsxs)(`span`,{className:`text-gray-500`,children:[`堆 `,(0,R.jsxs)(`span`,{className:`font-mono text-gray-800`,children:[X.heapUsedMB,`/`,X.heapTotalMB,` MB`]})]}),Z&&(0,R.jsxs)(`span`,{className:`text-gray-500`,children:[`缓存 `,(0,R.jsxs)(`span`,{className:`font-mono text-gray-800`,children:[Z.caches.reduce((e,t)=>e+t.size,0),`/`,Z.caches.reduce((e,t)=>e+t.maxSize,0)]}),` 条`]}),(0,R.jsx)(`button`,{onClick:()=>e(`/config?section=memory_mgmt`),className:`text-xs text-blue-600 hover:underline`,children:`管理`})]})]})}),W&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-gray-500 uppercase tracking-wider mb-3`,children:`当前运行中`}),(0,R.jsx)(`div`,{className:`space-y-3`,children:U?.items.map((t,i)=>(0,R.jsx)(F.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,R.jsx)(M,{className:`border-l-4 border-l-blue-500 !p-4`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,R.jsx)(n,{className:`h-5 w-5 text-blue-500`}),t.type===`dynamic`&&(0,R.jsx)(P,{variant:`primary`,size:`sm`,children:`动态编排`}),(0,R.jsx)(P,{variant:`info`,children:t.phaseLabel}),(0,R.jsx)(`span`,{className:`text-sm text-gray-500`,children:t.projectPath?t.projectPath.split(`/`).pop():``})]}),(0,R.jsx)(`p`,{className:`text-sm text-gray-700 line-clamp-2`,children:t.requirement?.slice(0,150)}),(0,R.jsxs)(`p`,{className:`text-xs text-gray-400 mt-2`,children:[`创建于 `,t.updatedAt?m(A(t.updatedAt),`HH:mm:ss`):``]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2 ml-4`,children:[(0,R.jsx)(j,{variant:`secondary`,size:`sm`,icon:r,onClick:()=>e(`/pipelines/${t.id}`),children:`查看`}),(0,R.jsx)(j,{variant:`danger`,size:`sm`,icon:te,onClick:()=>{H({open:!0,title:`关闭 Pipeline`,description:`确认关闭此 Pipeline?`,onConfirm:()=>{Q.mutate(t.id),H(e=>({...e,open:!1}))}})},children:`关闭`})]})]})})},t.id))})]}),q?.recommendations&&q.recommendations.length>0&&(0,R.jsx)(`div`,{className:`space-y-2`,children:q.recommendations.map((n,r)=>(0,R.jsxs)(F.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:O(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all hover:shadow-sm`,n.type===`warning`?`bg-amber-50 border-amber-200`:`bg-blue-50 border-blue-200`),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 flex-1`,onClick:()=>e(n.action),children:[(0,R.jsx)(t,{className:O(`h-4 w-4`,n.type===`warning`?`text-amber-500`:`text-blue-500`)}),(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:n.title})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[n.action===`/quality`&&(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:h,onClick:e=>{e.stopPropagation(),ye.mutate()},children:`修复`}),n.action===`/pipelines`&&(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:o,onClick:e=>{e.stopPropagation(),ve.mutate()},children:`清理`}),(0,R.jsx)(g,{className:`h-4 w-4 text-gray-300`})]})]},r))}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/sessions`),children:(0,R.jsx)(k,{title:`本周节省`,value:`${J?.week.timeSavedHours||0}h`,icon:ee,color:`blue`})}),(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/analytics`),children:(0,R.jsx)(k,{title:`Token 用量`,value:N(J?.week.tokensTotal||0),icon:i,color:`green`})}),(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/quality`),children:(0,R.jsx)(k,{title:`质量拦截`,value:J?.week.qualityBlocked||0,icon:a,color:`purple`})}),(0,R.jsx)(`div`,{className:`cursor-pointer`,onClick:()=>e(`/knowledge`),children:(0,R.jsx)(k,{title:`知识沉淀`,value:J?.totals.knowledgeNodes||0,icon:s,color:`orange`})})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,R.jsx)(M,{title:`7 天活动趋势`,children:(0,R.jsx)(_,{width:`100%`,height:180,children:(0,R.jsxs)(se,{data:J?.dailyTrend||[],children:[(0,R.jsx)(`defs`,{children:(0,R.jsxs)(`linearGradient`,{id:`gradE`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,R.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.3}),(0,R.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]})}),(0,R.jsx)(ae,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,R.jsx)(ie,{dataKey:`date`,stroke:`#6b7280`}),(0,R.jsx)(re,{stroke:`#6b7280`}),(0,R.jsx)(ce,{contentStyle:{borderRadius:`8px`,border:`1px solid #e5e7eb`}}),(0,R.jsx)(oe,{type:`monotone`,dataKey:`events`,stroke:`#3b82f6`,fill:`url(#gradE)`,name:`事件`})]})})}),(0,R.jsx)(M,{title:`实时事件流`,action:(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[b&&(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:p,onClick:()=>void _e(),children:`刷新`}),(0,R.jsx)(j,{variant:`ghost`,size:`sm`,icon:b?d:u,onClick:()=>z(!b),children:b?`继续`:`暂停`})]}),children:(0,R.jsxs)(`div`,{className:`h-[180px] overflow-y-auto text-xs font-mono space-y-1`,children:[Y?.items.map((t,n)=>{let r=t.tool_input,i=r?.file_path?String(r.file_path).split(`/`).slice(-2).join(`/`):r?.command?String(r.command).slice(0,60):r?.pattern?String(r.pattern):t.hook_type===`UserPromptSubmit`?`用户输入`:``;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 py-1 hover:bg-gray-50 rounded px-1 cursor-pointer`,onClick:()=>e(`/events`),children:[(0,R.jsx)(`span`,{className:`text-gray-400 w-14 flex-shrink-0`,children:m(A(t.timestamp),`HH:mm:ss`)}),(0,R.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0`,style:{backgroundColor:ge[t.hook_type]||`#6b7280`}}),(0,R.jsx)(`span`,{className:`text-gray-700 font-medium w-16 flex-shrink-0 truncate`,children:t.tool_name||t.hook_type}),(0,R.jsx)(`span`,{className:`text-gray-400 truncate flex-1`,children:i})]},`${t.id}-${n}`)}),(0,R.jsx)(`div`,{ref:B})]})})]}),(0,R.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:[{label:`会话管理`,icon:f,path:`/sessions`,count:J?.week.sessions},{label:`流水线`,icon:n,path:`/pipelines`,count:U?.total},{label:`质量门禁`,icon:a,path:`/quality`,count:q?.recommendations?.find(e=>e.action===`/quality`)?`!`:`0`},{label:`知识图谱`,icon:s,path:`/knowledge`,count:J?.totals.knowledgeNodes}].map(t=>(0,R.jsx)(F.div,{whileHover:{scale:1.02},whileTap:{scale:.98},className:`bg-white rounded-xl p-4 border border-gray-100 cursor-pointer hover:border-blue-200 hover:shadow-sm transition-all`,onClick:()=>e(t.path),children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(t.icon,{className:`h-5 w-5 text-gray-500`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:t.label})]}),(0,R.jsx)(`span`,{className:`text-sm font-bold text-gray-900`,children:t.count??`-`})]})},t.path))}),(0,R.jsx)(I,{open:V.open,title:V.title,description:V.description,variant:`warning`,onConfirm:V.onConfirm,onCancel:()=>H(e=>({...e,open:!1}))})]})}export{z as default};
@@ -0,0 +1 @@
1
+ import{Xn as e,rn as t}from"./vendor-DRGPi8ui.js";import{c as n}from"./vendor-flow-srkes8If.js";import{n as r}from"./ui-CDL3BZ13.js";var i=n();function a({message:n=`加载失败,请重试`,onRetry:a}){return(0,i.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-96 text-center px-4`,children:[(0,i.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-full bg-red-50 mb-4`,children:(0,i.jsx)(e,{className:`h-8 w-8 text-red-500`})}),(0,i.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-2`,children:`出错了`}),(0,i.jsx)(`p`,{className:`text-sm text-gray-500 mb-6 max-w-md`,children:n}),a&&(0,i.jsx)(r,{variant:`primary`,size:`sm`,icon:t,onClick:a,children:`重试`})]})}export{a as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Gt as t,Pn as n,Qn as ee,Rn as r,Ut as i,en as a,er as te,gr as o,ir as s,o as c,pn as ne,rn as re,s as l,sr as ie}from"./vendor-DRGPi8ui.js";import{a as u,n as d,r as f,t as p}from"./vendor-query-DqPOMnuX.js";import{c as m}from"./vendor-flow-srkes8If.js";import{Rt as ae,Y as oe}from"./client-BhcjNvkG.js";import{a as h,l as g,n as _,r as v,t as y}from"./ui-CDL3BZ13.js";import{n as b,t as x}from"./vendor-motion-CQmdgnI8.js";import{t as se}from"./useDebounce-DNfPs3Tv.js";import{t as ce}from"./ErrorState-DXHA8lr8.js";import{t as le}from"./exportCsv-CSExJI8h.js";import{t as ue}from"./ConfirmDialog-CVzB7X5y.js";var S=e(o(),1),C=m(),de={PreToolUse:`bg-blue-100 text-blue-700`,PostToolUse:`bg-green-100 text-green-700`,UserPromptSubmit:`bg-amber-100 text-amber-700`,Stop:`bg-red-100 text-red-700`,Notification:`bg-purple-100 text-purple-700`};function w(e){if(!e)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function T(e){if(e.hook_type===`UserPromptSubmit`){let t=e.user_prompt;return{title:`用户输入`,subtitle:t?t.slice(0,80):`用户提交了新请求`}}if(e.tool_name){let t=e.tool_input;return t?.file_path?{title:`${e.tool_name} 文件`,subtitle:String(t.file_path).split(`/`).slice(-2).join(`/`)}:t?.command?{title:`${e.tool_name} 命令`,subtitle:String(t.command).slice(0,100)}:t?.pattern?{title:`${e.tool_name} 搜索`,subtitle:String(t.pattern)}:{title:e.tool_name,subtitle:e.hook_type}}return{title:e.hook_type,subtitle:e.project_path.split(`/`).pop()||``}}function E(){let e=u(),[o,m]=(0,S.useState)(50),[E,D]=(0,S.useState)(``),[O,k]=(0,S.useState)(``),[A,j]=(0,S.useState)(``),[M,N]=(0,S.useState)(null),[P,F]=(0,S.useState)(``),I=se(P),[L,R]=(0,S.useState)(``),[z,B]=(0,S.useState)(``),[V,H]=(0,S.useState)(`all`),[U,fe]=(0,S.useState)(30),[W,G]=(0,S.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),K=(0,S.useRef)(null),q=V===`all`?void 0:l(c(new Date,V===`1d`?1:V===`7d`?7:30),`yyyy-MM-dd'T'HH:mm:ss`),{data:J,isLoading:pe,isError:Y,refetch:X}=f({queryKey:[`events`,{limit:o,tool_name:E||void 0,start_time:q,search:L||void 0}],queryFn:()=>oe({limit:o,tool_name:E||void 0,start_time:q,search:L||void 0}).then(e=>e.data)}),Z=d({mutationFn:e=>ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`events`]})}}),Q=J?.items.filter(e=>!(O&&e.hook_type!==O||A&&e.project_path.split(`/`).pop()!==A||I&&![e.tool_name,w(e.tool_input),w(e.tool_output)].join(` `).toLowerCase().includes(I.toLowerCase())))||[],$=p({count:Q.length,getScrollElement:()=>K.current,estimateSize:()=>120,overscan:5});if(pe)return(0,C.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,C.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});if(Y)return(0,C.jsx)(ce,{message:`事件数据加载失败`,onRetry:()=>X()});let me=Array.from(new Set(J?.items.map(e=>e.project_path.split(`/`).pop()||``).filter(Boolean)||[])),he=Q.reduce((e,t)=>{let n=t.tool_name||`N/A`;return e[n]=(e[n]||0)+1,e},{}),ge=Object.entries(he).sort((e,t)=>t[1]-e[1]).slice(0,10),_e=Array.from(new Set(J?.items.map(e=>e.hook_type)||[]));return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(v,{children:(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center flex-1`,children:[(0,C.jsxs)(`div`,{className:`relative flex-1 min-w-[240px] max-w-sm`,children:[(0,C.jsx)(a,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,C.jsx)(`input`,{type:`text`,placeholder:`实时过滤:工具名、文件名...`,value:P,onChange:e=>{F(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,C.jsx)(`div`,{className:`relative min-w-[200px] max-w-xs`,children:(0,C.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),R(z)},children:[(0,C.jsx)(`input`,{type:`text`,placeholder:`全文搜索内容(回车提交)...`,value:z,onChange:e=>B(e.target.value),className:h(`w-full pl-3 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm`,L?`border-blue-400 bg-blue-50`:`border-gray-200`)}),L&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>{R(``),B(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 text-xs`,children:`✕`})]})}),(0,C.jsxs)(`select`,{value:O,onChange:e=>{k(e.target.value)},className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:``,children:`全部类型`}),_e.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))]}),(0,C.jsxs)(`select`,{value:A,onChange:e=>{j(e.target.value)},className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:``,children:`全部项目`}),me.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1 border border-gray-200 rounded-lg overflow-hidden text-sm`,children:[(0,C.jsx)(s,{className:`h-3.5 w-3.5 text-gray-400 ml-2`}),[`all`,`1d`,`7d`,`30d`].map(e=>(0,C.jsx)(`button`,{onClick:()=>{H(e)},className:h(`px-2.5 py-2 transition-colors`,V===e?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`),children:e===`all`?`全部`:e},e))]}),(0,C.jsxs)(`select`,{value:o,onChange:e=>m(Number(e.target.value)),className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:20,children:`20 条`}),(0,C.jsx)(`option`,{value:50,children:`50 条`}),(0,C.jsx)(`option`,{value:100,children:`100 条`})]})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,C.jsxs)(`select`,{value:U,onChange:e=>fe(Number(e.target.value)),className:`px-2 py-1.5 border border-gray-200 rounded-lg text-sm`,children:[(0,C.jsx)(`option`,{value:7,children:`7天`}),(0,C.jsx)(`option`,{value:30,children:`30天`}),(0,C.jsx)(`option`,{value:90,children:`90天`})]}),(0,C.jsx)(_,{variant:`secondary`,size:`sm`,icon:r,onClick:()=>{let e=[`时间`,`类型`,`工具`,`项目`,`会话ID`,`摘要`],t=Q.map(e=>{let t=T(e);return[e.timestamp,e.hook_type,e.tool_name||``,e.project_path.split(`/`).pop()||``,e.session_id.slice(0,12),t.subtitle]});le(`events-${l(new Date,`yyyyMMdd-HHmmss`)}.csv`,e,t)},children:`导出`}),(0,C.jsx)(_,{variant:`secondary`,size:`sm`,icon:i,onClick:()=>{G({open:!0,title:`清理历史事件`,description:`确认清理 ${U} 天前的已蒸馏事件?此操作不可撤销。`,onConfirm:()=>{Z.mutate(U),G({...W,open:!1})}})},loading:Z.isPending,children:`清理历史`}),(0,C.jsx)(_,{variant:`secondary`,size:`sm`,icon:re,onClick:()=>X(),children:`刷新`})]})]})}),(0,C.jsx)(v,{title:`工具使用频率`,children:(0,C.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ge.map(([e,t])=>(0,C.jsxs)(`button`,{onClick:()=>{D(E===e?``:e)},className:h(`px-3 py-1.5 rounded-full text-sm transition-all`,E===e?`bg-blue-100 text-blue-700 border-2 border-blue-300`:`bg-gray-100 text-gray-700 hover:bg-gray-200 border-2 border-transparent`),children:[(0,C.jsx)(`span`,{className:`font-medium`,children:e}),(0,C.jsx)(`span`,{className:`ml-1 text-xs opacity-70`,children:t})]},e))})}),(0,C.jsx)(v,{title:`执行轨迹 (${Q.length})`,children:(0,C.jsx)(`div`,{ref:K,className:`h-[600px] overflow-auto`,style:{contain:`strict`},children:(0,C.jsx)(`div`,{style:{height:`${$.getTotalSize()}px`,width:`100%`,position:`relative`},children:$.getVirtualItems().map(e=>{let r=Q[e.index],i=T(r),a=M===r.event_id;return(0,C.jsx)(`div`,{"data-index":e.index,ref:$.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},className:`pb-2`,children:(0,C.jsxs)(`div`,{className:`border border-gray-100 rounded-lg overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between p-3 hover:bg-gray-50 cursor-pointer`,onClick:()=>N(a?null:r.event_id),children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,C.jsx)(`button`,{className:`text-gray-400`,children:a?(0,C.jsx)(te,{className:`h-4 w-4`}):(0,C.jsx)(ee,{className:`h-4 w-4`})}),(0,C.jsx)(y,{size:`sm`,className:de[r.hook_type]||`bg-gray-100 text-gray-700`,children:r.hook_type}),r.tool_name&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-sm text-gray-700 flex-shrink-0`,children:[r.tool_name===`Bash`?(0,C.jsx)(t,{className:`h-4 w-4`}):(0,C.jsx)(n,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`font-mono`,children:r.tool_name})]}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-gray-900 truncate`,children:i.title}),(0,C.jsx)(`div`,{className:`text-xs text-gray-500 truncate`,children:i.subtitle})]})]}),(0,C.jsx)(`div`,{className:`text-xs text-gray-400 font-mono ml-3`,children:l(g(r.timestamp),`HH:mm:ss`)})]}),(0,C.jsx)(b,{children:a&&(0,C.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`border-t border-gray-100 bg-gray-50`,children:(0,C.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,C.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 text-xs`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`会话`}),(0,C.jsxs)(`div`,{className:`font-mono text-gray-700`,children:[r.session_id.slice(0,12),`...`]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`项目`}),(0,C.jsx)(`div`,{className:`text-gray-700`,children:r.project_path.split(`/`).pop()})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`时间`}),(0,C.jsx)(`div`,{className:`font-mono text-gray-700`,children:r.timestamp})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-gray-400 mb-1`,children:`类型`}),(0,C.jsx)(`div`,{className:`text-gray-700`,children:r.hook_type})]})]}),r.tool_input&&(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-gray-500 mb-2 uppercase tracking-wider`,children:[(0,C.jsx)(ne,{className:`h-3 w-3`}),` 输入`]}),(0,C.jsx)(`pre`,{className:`bg-white p-3 rounded-lg text-xs font-mono overflow-x-auto border border-gray-200 text-gray-700 whitespace-pre-wrap break-all`,children:w(r.tool_input)})]}),r.tool_output&&(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-gray-500 mb-2 uppercase tracking-wider`,children:[(0,C.jsx)(ie,{className:`h-3 w-3`}),` 输出`]}),(0,C.jsx)(`pre`,{className:`bg-white p-3 rounded-lg text-xs font-mono overflow-x-auto border border-gray-200 text-gray-700 whitespace-pre-wrap break-all max-h-64 overflow-y-auto`,children:w(r.tool_output)})]})]})})})]})},r.event_id)})})})}),(0,C.jsx)(ue,{open:W.open,title:W.title,description:W.description,variant:`danger`,onConfirm:W.onConfirm,onCancel:()=>G({...W,open:!1})})]})}export{E as default};
@@ -0,0 +1 @@
1
+ import{Dn as e,Ft as t,Vt as n,pr as r,s as i}from"./vendor-DRGPi8ui.js";import{c as a}from"./vendor-react-DJI9oneq.js";import{r as o}from"./vendor-query-DqPOMnuX.js";import{c as s}from"./vendor-flow-srkes8If.js";import{X as c,Z as l}from"./client-BhcjNvkG.js";import{l as u,r as d}from"./ui-CDL3BZ13.js";import{t as f}from"./vendor-motion-CQmdgnI8.js";import{t as p}from"./Skeleton-B7PVDJJ_.js";var m=s(),h={multi_retry_pass:`多次重试通过`,strategy_reliable:`策略可靠`,strategy_ineffective:`策略无效`,backtrack_failure:`回溯失败`,diagnosis_pattern:`诊断模式`},g={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 _(){let s=a(),{data:_,isLoading:v}=o({queryKey:[`evolution-stats`],queryFn:()=>l().then(e=>e.data)}),{data:y,isLoading:b}=o({queryKey:[`evolution-events-all`],queryFn:()=>c({limit:100}).then(e=>e.data)});if(v||b)return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(p,{rows:2}),(0,m.jsx)(p,{rows:5})]});let x=y?.items||[];return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`模板进化`}),(0,m.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:`系统根据执行结果自动优化流水线模板`})]}),_&&(0,m.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,m.jsx)(d,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`div`,{className:`p-2 bg-blue-100 rounded-lg`,children:(0,m.jsx)(r,{className:`h-5 w-5 text-blue-600`})}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:_.total_events}),(0,m.jsx)(`div`,{className:`text-sm text-gray-500`,children:`总进化事件`})]})]})}),(0,m.jsx)(d,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`div`,{className:`p-2 bg-green-100 rounded-lg`,children:(0,m.jsx)(e,{className:`h-5 w-5 text-green-600`})}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:_.total_evolved_templates}),(0,m.jsx)(`div`,{className:`text-sm text-gray-500`,children:`已进化模板数`})]})]})}),(0,m.jsx)(d,{children:(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`div`,{className:`p-2 bg-purple-100 rounded-lg`,children:(0,m.jsx)(n,{className:`h-5 w-5 text-purple-600`})}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`text-2xl font-bold text-gray-900`,children:_.signal_breakdown.length}),(0,m.jsx)(`div`,{className:`text-sm text-gray-500`,children:`信号类型`})]})]})})]}),(0,m.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[_&&_.signal_breakdown.length>0&&(0,m.jsxs)(d,{children:[(0,m.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,m.jsx)(t,{className:`h-5 w-5`}),`信号分布`]}),(0,m.jsx)(`div`,{className:`space-y-3`,children:_.signal_breakdown.map((e,t)=>{let n=_.signal_breakdown.reduce((e,t)=>e+t.count,0),r=n>0?e.count/n*100:0;return(0,m.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,m.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs font-medium w-28 text-center ${g[e.signal_type]||`bg-gray-100 text-gray-700`}`,children:h[e.signal_type]||e.signal_type}),(0,m.jsx)(`div`,{className:`flex-1 h-2 bg-gray-200 rounded-full overflow-hidden`,children:(0,m.jsx)(`div`,{className:`h-full bg-blue-500 transition-all`,style:{width:`${r}%`}})}),(0,m.jsx)(`span`,{className:`text-sm text-gray-700 w-8 text-right`,children:e.count})]},t)})})]}),_&&_.recent_evolutions.length>0&&(0,m.jsxs)(d,{children:[(0,m.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,m.jsx)(e,{className:`h-5 w-5`}),`最近进化的模板`]}),(0,m.jsx)(`div`,{className:`space-y-3`,children:_.recent_evolutions.map((e,t)=>(0,m.jsxs)(f.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`flex items-center justify-between p-3 border border-gray-200 rounded-lg hover:bg-gray-50 cursor-pointer transition-colors`,onClick:()=>s(`/templates/${e.template_id}`),children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`div`,{className:`font-medium text-gray-900`,children:e.template_name||e.template_id}),(0,m.jsx)(`div`,{className:`text-xs text-gray-500 mt-0.5`,children:i(u(e.last_evolved_at),`yyyy-MM-dd HH:mm`)})]}),(0,m.jsxs)(`span`,{className:`text-sm text-gray-600 bg-gray-100 px-2 py-1 rounded`,children:[e.evolution_count,` 次进化`]})]},e.template_id))})]})]}),(0,m.jsxs)(d,{children:[(0,m.jsxs)(`h3`,{className:`text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2`,children:[(0,m.jsx)(r,{className:`h-5 w-5`}),`最近进化事件`]}),x.length===0?(0,m.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:`暂无进化事件。系统将在 Pipeline 执行完成后自动分析并触发进化。`}):(0,m.jsx)(`div`,{className:`space-y-2`,children:x.map((e,t)=>(0,m.jsxs)(f.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:t*.03},className:`flex items-start gap-3 p-3 border border-gray-100 rounded-lg hover:bg-gray-50 cursor-pointer transition-colors`,onClick:()=>s(`/templates/${e.template_id}`),children:[(0,m.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs font-medium flex-shrink-0 ${g[e.signal_type]||`bg-gray-100 text-gray-700`}`,children:h[e.signal_type]||e.signal_type}),(0,m.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,m.jsx)(`p`,{className:`text-sm text-gray-700 truncate`,children:e.action}),(0,m.jsx)(`p`,{className:`text-xs text-gray-400 mt-0.5`,children:i(u(e.created_at),`MM-dd HH:mm`)})]})]},e.event_id))})]})]})}export{_ as default};
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Dn as t,Jt as n,Mn as r,Rn as i,Ut as a,Wn as o,Yn as s,an as c,ar as l,bn as u,dn as d,en as ee,gr as f,s as p,zt as te}from"./vendor-DRGPi8ui.js";import{S as ne,_ as re,c as ie,v as ae,y as oe}from"./vendor-charts-9eVsQvUV.js";import{a as se,n as m,r as h}from"./vendor-query-DqPOMnuX.js";import{a as g,c as _,i as v,n as y,o as b,r as x,s as S,t as ce}from"./vendor-flow-srkes8If.js";import{C as le,Mt as ue,Yt as C,nn as de,nt as fe,rt as pe,s as me,tt as he,un as w,v as ge,y as _e}from"./client-BhcjNvkG.js";import{n as T,r as E,t as D}from"./ui-CDL3BZ13.js";import{t as ve}from"./vendor-motion-CQmdgnI8.js";import{t as ye}from"./exportCsv-CSExJI8h.js";import{t as be}from"./ConfirmDialog-CVzB7X5y.js";import{t as xe}from"./Pagination-lp8b_3NR.js";var O=e(f(),1);function Se(e,t){let[n,r]=(0,O.useState)(e);return(0,O.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var k=_();function Ce({open:e,count:t,itemLabel:n=`项`,loading:r=!1,onConfirm:i,onCancel:o}){let[s,c]=(0,O.useState)(``);if((0,O.useEffect)(()=>{e||c(``)},[e]),(0,O.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,o]),!e)return null;let l=t<5?`simple`:t<=20?`count`:`keyword`,u=`DELETE`,d=l===`simple`||l===`count`&&s===String(t)||l===`keyword`&&s===u;return(0,k.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm`,onClick:o,children:(0,k.jsxs)(`div`,{className:`bg-white rounded-xl shadow-xl w-full max-w-md mx-4 p-6`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,k.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center bg-red-50`,children:(0,k.jsx)(a,{className:`h-5 w-5 text-red-500`})}),(0,k.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,k.jsxs)(`h3`,{className:`text-base font-semibold text-gray-900`,children:[`删除 `,t,` 个`,n]}),(0,k.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 leading-relaxed`,children:`此操作不可撤销,关联数据也会被删除。`}),l===`count`&&(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsxs)(`label`,{className:`block text-xs text-gray-500 mb-1`,children:[`请输入数量 `,(0,k.jsx)(`span`,{className:`font-mono font-bold text-gray-800`,children:t}),` 以确认:`]}),(0,k.jsx)(`input`,{autoFocus:!0,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d&&i()},placeholder:String(t),className:`w-full px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-400 font-mono`})]}),l===`keyword`&&(0,k.jsxs)(`div`,{className:`mt-3`,children:[(0,k.jsxs)(`label`,{className:`block text-xs text-gray-500 mb-1`,children:[`请输入 `,(0,k.jsx)(`span`,{className:`font-mono font-bold text-red-600`,children:u}),` 以确认:`]}),(0,k.jsx)(`input`,{autoFocus:!0,type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d&&i()},placeholder:u,className:`w-full px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-400 font-mono`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-3 mt-6`,children:[(0,k.jsx)(T,{variant:`secondary`,size:`sm`,onClick:o,disabled:r,children:`取消`}),(0,k.jsx)(T,{variant:`danger`,size:`sm`,onClick:i,loading:r,disabled:!d,children:`确认删除`})]})]})})}var A={requirement:`#3b82f6`,decision:`#8b5cf6`,code_change:`#10b981`,outcome:`#f59e0b`};function we({nodes:e,edges:t,onNodeClick:n}){let r=(0,O.useMemo)(()=>e.map((e,t)=>({id:e.id,type:`default`,data:{label:(0,k.jsxs)(`div`,{className:`text-xs`,children:[(0,k.jsx)(`div`,{className:`font-semibold truncate max-w-[120px]`,children:e.title}),(0,k.jsx)(`div`,{className:`text-gray-500 text-[10px]`,children:e.node_type})]})},position:{x:t%5*200+Math.sin(t)*30,y:Math.floor(t/5)*150+Math.cos(t)*20},style:{background:A[e.node_type]||`#6b7280`,color:`#fff`,border:`none`,borderRadius:`8px`,padding:`8px 12px`,minWidth:`140px`}})),[e]),i=(0,O.useMemo)(()=>t.map(e=>({id:e.id,source:e.from_node_id,target:e.to_node_id,label:e.edge_type,labelStyle:{fontSize:10,fill:`#6b7280`},style:{stroke:`#d1d5db`,strokeWidth:Math.max(1,e.weight)},markerEnd:{type:S.ArrowClosed,color:`#d1d5db`}})),[t]),[a,,o]=b(r),[s,,c]=g(i),l=(0,O.useCallback)((e,t)=>{n?.(t.id)},[n]);return e.length===0?(0,k.jsx)(`div`,{className:`flex items-center justify-center h-full text-gray-400 text-sm`,children:`暂无知识节点`}):(0,k.jsxs)(v,{nodes:a,edges:s,onNodesChange:o,onEdgesChange:c,onNodeClick:l,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[(0,k.jsx)(ce,{color:`#f3f4f6`,gap:20}),(0,k.jsx)(y,{}),(0,k.jsx)(x,{nodeColor:t=>A[e.find(e=>e.id===t.id)?.node_type||``]||`#6b7280`,style:{background:`#f9fafb`}})]})}var j={requirement:r,decision:u,code_change:o,outcome:s},M={requirement:`#3b82f6`,decision:`#8b5cf6`,code_change:`#10b981`,outcome:`#f59e0b`},N={requirement:`需求`,decision:`决策`,code_change:`代码变更`,outcome:`结果`},P=[`#3b82f6`,`#8b5cf6`,`#10b981`,`#f59e0b`,`#ef4444`,`#06b6d4`];function F(){let e=se(),[r,o]=(0,O.useState)(``),s=Se(r,300),[u,f]=(0,O.useState)(``),[g,_]=(0,O.useState)(null),[v,y]=(0,O.useState)(new Set),[b,x]=(0,O.useState)(1),[S,ce]=(0,O.useState)(20),[A,F]=(0,O.useState)(!1),[Te,I]=(0,O.useState)(!1),[Ee,L]=(0,O.useState)(!1),[R,De]=(0,O.useState)(null),[z,Oe]=(0,O.useState)(``),[B,ke]=(0,O.useState)(`list`),[V,H]=(0,O.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),[Ae,U]=(0,O.useState)(!1),{data:W}=h({queryKey:[`knowledge-overview`],queryFn:()=>pe().then(e=>e.data)}),{data:je}=h({queryKey:[`knowledge-search`,s,u,z],queryFn:()=>C(s,z||void 0,u||void 0).then(e=>e.data),enabled:s.length>0}),{data:G}=h({queryKey:[`knowledge-all`],queryFn:()=>C(``,void 0,void 0,500).then(e=>e.data)}),{data:Me}=h({queryKey:[`knowledge-filtered`,u,z],queryFn:()=>C(``,z||void 0,u||void 0,500).then(e=>e.data),enabled:r.length===0&&(!!u||!!z)}),{data:K}=h({queryKey:[`knowledge-neighbors`,g],queryFn:()=>fe(g).then(e=>e.data),enabled:!!g}),{data:q}=h({queryKey:[`knowledge-graph`,z,u],queryFn:()=>he(z||void 0,u||void 0).then(e=>e.data),enabled:B===`graph`}),Ne=m({mutationFn:_e,onSuccess:()=>{e.invalidateQueries({queryKey:[`knowledge-all`]}),e.invalidateQueries({queryKey:[`knowledge-filtered`]}),e.invalidateQueries({queryKey:[`knowledge-search`]}),e.invalidateQueries({queryKey:[`knowledge-overview`]}),F(!1)}}),Pe=m({mutationFn:({id:e,data:t})=>de(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`knowledge-all`]}),e.invalidateQueries({queryKey:[`knowledge-filtered`]}),e.invalidateQueries({queryKey:[`knowledge-search`]}),I(!1),De(null)}}),Fe=m({mutationFn:le,onSuccess:()=>{e.invalidateQueries({queryKey:[`knowledge-all`]}),e.invalidateQueries({queryKey:[`knowledge-filtered`]}),e.invalidateQueries({queryKey:[`knowledge-search`]}),e.invalidateQueries({queryKey:[`knowledge-overview`]}),_(null)}}),J=m({mutationFn:e=>me(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`knowledge-all`]}),e.invalidateQueries({queryKey:[`knowledge-filtered`]}),e.invalidateQueries({queryKey:[`knowledge-search`]}),e.invalidateQueries({queryKey:[`knowledge-overview`]}),y(new Set),_(null)}}),Y=m({mutationFn:ge,onSuccess:()=>{e.invalidateQueries({queryKey:[`knowledge-neighbors`]}),e.invalidateQueries({queryKey:[`knowledge-graph`]}),L(!1)}}),X=s?je?.items:u||z?Me?.items:G?.items,Ie=Array.from(new Set(G?.items.map(e=>e.node_type)||[])),Le=Array.from(new Set(G?.items.map(e=>e.project_path||``).filter(Boolean)||[])),Z=W?.byType?Object.entries(W.byType).map(([e,t])=>({name:e,value:t})):[],Re=Math.ceil((X?.length||0)/S),Q=X?.slice((b-1)*S,b*S),ze=e=>{e.preventDefault();let t=new FormData(e.currentTarget);Ne.mutate({title:t.get(`title`),content:t.get(`content`),node_type:t.get(`node_type`),project_path:t.get(`project_path`),tags:t.get(`tags`)})},Be=e=>{if(e.preventDefault(),!R)return;let t=new FormData(e.currentTarget);Pe.mutate({id:R.id,data:{title:t.get(`title`),content:t.get(`content`),tags:t.get(`tags`)}})},Ve=e=>{H({open:!0,title:`删除知识节点`,description:`确认删除此知识节点?关联的边也会被删除。`,onConfirm:()=>{Fe.mutate(e),H(e=>({...e,open:!1}))}})},He=()=>{U(!0)},Ue=()=>{if(!X||X.length===0)return;let e=[`ID`,`标题`,`类型`,`内容`,`标签`,`项目路径`],t=X.map(e=>[e.id,e.title,e.node_type,e.content,e.tags||``,e.project_path||``]);ye(`knowledge-nodes-${p(new Date,`yyyyMMdd-HHmmss`)}.csv`,e,t)},We=()=>{if(!X||X.length===0)return;let e=new Blob([JSON.stringify(X,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`knowledge-nodes-${p(new Date,`yyyyMMdd-HHmmss`)}.json`,n.click(),URL.revokeObjectURL(t)},$=m({mutationFn:e=>ue(e).then(e=>e.data),onSuccess:t=>{w(t.message,`success`),e.invalidateQueries({queryKey:[`knowledge-all`]}),e.invalidateQueries({queryKey:[`knowledge-overview`]})},onError:()=>w(`导入失败`,`error`)});return(0,k.jsxs)(`div`,{className:`space-y-6`,children:[(0,k.jsx)(E,{children:(0,k.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(ee,{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:`搜索知识节点(需求、决策、代码变更、结果)...`,value:r,onChange:e=>{o(e.target.value),x(1)},className:`w-full pl-10 pr-4 py-3 border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 text-lg`})]}),(0,k.jsxs)(`select`,{value:u,onChange:e=>{f(e.target.value),x(1)},className:`px-3 py-3 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,k.jsx)(`option`,{value:``,children:`全部类型`}),Ie.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]}),(0,k.jsxs)(`select`,{value:z,onChange:e=>{Oe(e.target.value),x(1)},className:`px-3 py-3 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,k.jsx)(`option`,{value:``,children:`全部项目`}),Le.map(e=>(0,k.jsx)(`option`,{value:e,children:e.split(`/`).pop()},e))]}),(0,k.jsx)(T,{variant:`primary`,size:`sm`,icon:c,onClick:()=>F(!0),children:`创建节点`}),v.size>0&&(0,k.jsxs)(T,{variant:`danger`,size:`sm`,icon:a,onClick:He,loading:J.isPending,children:[`删除 (`,v.size,`)`]}),(0,k.jsxs)(`div`,{className:`flex border border-gray-200 rounded-lg overflow-hidden`,children:[(0,k.jsx)(`button`,{onClick:()=>ke(`list`),className:`px-3 py-2 text-sm transition-colors ${B===`list`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`}`,children:`列表`}),(0,k.jsxs)(`button`,{onClick:()=>ke(`graph`),className:`px-3 py-2 text-sm transition-colors flex items-center gap-1 ${B===`graph`?`bg-blue-50 text-blue-700 font-medium`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,k.jsx)(d,{className:`h-4 w-4`}),`图谱`]})]})]})}),(0,k.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,k.jsxs)(E,{title:`知识图谱概览`,children:[(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mb-4`,children:[(0,k.jsxs)(`button`,{className:`text-center p-4 bg-blue-50 rounded-xl hover:bg-blue-100 transition-colors cursor-pointer`,onClick:()=>{f(``),Oe(``),x(1)},title:`点击查看全部节点`,children:[(0,k.jsx)(l,{className:`h-8 w-8 text-blue-500 mx-auto mb-2`}),(0,k.jsx)(`div`,{className:`text-3xl font-bold text-blue-600`,children:W?.totalNodes||0}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600`,children:`知识节点`})]}),(0,k.jsxs)(`div`,{className:`text-center p-4 bg-purple-50 rounded-xl`,children:[(0,k.jsx)(t,{className:`h-8 w-8 text-purple-500 mx-auto mb-2`}),(0,k.jsx)(`div`,{className:`text-3xl font-bold text-purple-600`,children:Z.length}),(0,k.jsx)(`div`,{className:`text-sm text-gray-600`,children:`节点类型`})]})]}),Z.length>0&&(0,k.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Z.map((e,t)=>(0,k.jsxs)(`button`,{onClick:()=>{f(u===e.name?``:e.name),x(1)},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${u===e.name?`text-white`:`bg-gray-100 text-gray-700 hover:bg-gray-200`}`,style:u===e.name?{backgroundColor:P[t%P.length]}:{},children:[(0,k.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0`,style:{backgroundColor:P[t%P.length]}}),N[e.name]||e.name,(0,k.jsxs)(`span`,{className:`opacity-70`,children:[`(`,e.value,`)`]})]},e.name))})]}),(0,k.jsx)(E,{title:`节点类型分布`,children:Z.length>0?(0,k.jsx)(ne,{width:`100%`,height:220,children:(0,k.jsxs)(ie,{margin:{top:20,right:20,bottom:20,left:20},children:[(0,k.jsx)(re,{data:Z,cx:`50%`,cy:`50%`,innerRadius:50,outerRadius:80,dataKey:`value`,label:({name:e,percent:t})=>t>=.05?`${N[e]||e} ${(t*100).toFixed(0)}%`:``,labelLine:({percent:e})=>e>=.05,onClick:e=>{f(u===e.name?``:e.name),x(1)},style:{cursor:`pointer`},children:Z.map((e,t)=>(0,k.jsx)(ae,{fill:P[t%P.length],opacity:u&&u!==e.name?.4:1},t))}),(0,k.jsx)(oe,{formatter:(e,t)=>[e,N[t]||t]})]})}):(0,k.jsx)(`div`,{className:`flex items-center justify-center h-48 text-gray-400`,children:`暂无数据`})})]}),B===`graph`&&(0,k.jsx)(E,{title:`知识图谱`,children:(0,k.jsx)(`div`,{className:`h-[600px] border border-gray-200 rounded-lg overflow-hidden`,children:q?(0,k.jsx)(we,{nodes:q.nodes,edges:q.edges,onNodeClick:_}):(0,k.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,k.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})})})}),B===`list`&&(0,k.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-6`,children:[(0,k.jsx)(`div`,{className:`lg:col-span-2`,children:(0,k.jsxs)(E,{title:`知识节点 (${X?.length||0})`,action:(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[X&&X.length>0&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(T,{variant:`secondary`,size:`sm`,icon:i,onClick:Ue,children:`导出 CSV`}),(0,k.jsx)(T,{variant:`secondary`,size:`sm`,icon:i,onClick:We,children:`导出 JSON`})]}),(0,k.jsxs)(`label`,{className:`cursor-pointer`,children:[(0,k.jsx)(`input`,{type:`file`,accept:`.json,.csv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=e=>{try{let n=e.target?.result,r=[];if(t.name.endsWith(`.json`)){let e=JSON.parse(n);r=Array.isArray(e)?e:e.nodes||e.items||[]}else if(t.name.endsWith(`.csv`)){let e=n.split(`
2
+ `).filter(e=>e.trim()),t=e[0].split(`,`).map(e=>e.trim().replace(/^"|"$/g,``));r=e.slice(1).map(e=>{let n=e.split(`,`).map(e=>e.trim().replace(/^"|"$/g,``)),r={};return t.forEach((e,t)=>{r[e]=n[t]||``}),{title:r.title||r.标题||``,content:r.content||r.内容||``,node_type:r.node_type||r.类型||`requirement`,project_path:r.project_path||r.项目路径||``,tags:r.tags||r.标签?(r.tags||r.标签).split(`;`).filter(Boolean):[]}})}if(r.length===0){w(`未解析到有效节点,请检查文件格式`,`error`);return}$.mutate(r)}catch{w(`文件解析失败,请检查格式`,`error`)}},n.readAsText(t),e.target.value=``}}),(0,k.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg border border-gray-200 bg-white hover:bg-gray-50 transition-colors ${$.isPending?`opacity-50 pointer-events-none`:``}`,children:[(0,k.jsx)(te,{className:`h-4 w-4`}),$.isPending?`导入中...`:`导入`]})]}),Q&&Q.length>0&&(0,k.jsx)(`button`,{onClick:()=>{v.size===Q.length?y(new Set):y(new Set(Q.map(e=>e.id)))},className:`text-xs text-blue-600 hover:underline`,children:v.size===Q.length?`取消全选`:`全选当前页`})]}),children:[(0,k.jsxs)(`div`,{className:`space-y-2`,children:[Q?.map((e,t)=>{let r=j[e.node_type]||l,i=M[e.node_type]||`#6b7280`;return(0,k.jsx)(ve.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:t*.03},className:`p-4 rounded-lg border cursor-pointer transition-all group ${v.has(e.id)?`border-blue-300 bg-blue-50`:g===e.id?`border-blue-300 bg-blue-50 shadow-sm`:`border-gray-100 hover:border-gray-200 hover:bg-gray-50`}`,onClick:()=>_(e.id),children:(0,k.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:v.has(e.id),onChange:t=>{t.stopPropagation(),y(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 cursor-pointer flex-shrink-0 mt-1`}),(0,k.jsx)(`div`,{className:`p-2 rounded-lg`,style:{backgroundColor:`${i}15`},children:(0,k.jsx)(r,{className:`h-5 w-5`,style:{color:i}})}),(0,k.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`font-semibold text-gray-900 truncate`,children:e.title}),(0,k.jsx)(D,{size:`sm`,variant:e.node_type===`outcome`?`success`:e.node_type===`decision`?`info`:`default`,children:N[e.node_type]||e.node_type})]}),(0,k.jsx)(`p`,{className:`text-sm text-gray-600 mt-1 line-clamp-2`,children:e.content}),e.tags&&e.tags.trim()&&(0,k.jsx)(`div`,{className:`flex gap-1 mt-2`,children:e.tags.split(`,`).filter(e=>e.trim()).slice(0,3).map(e=>(0,k.jsx)(`span`,{className:`text-xs px-2 py-0.5 bg-gray-100 rounded-full text-gray-600`,children:e.trim()},e))})]}),(0,k.jsxs)(`div`,{className:`flex gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,k.jsx)(`button`,{onClick:t=>{t.stopPropagation(),De({id:e.id,title:e.title,content:e.content,tags:e.tags||``}),I(!0)},className:`p-1.5 rounded hover:bg-gray-200 text-gray-400 hover:text-gray-600`,children:(0,k.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ve(e.id)},className:`p-1.5 rounded hover:bg-red-100 text-gray-400 hover:text-red-600`,children:(0,k.jsx)(a,{className:`h-3.5 w-3.5`})})]})]})},e.id)}),(!Q||Q.length===0)&&(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-gray-400`,children:[(0,k.jsx)(l,{className:`h-12 w-12 mb-4`}),(0,k.jsx)(`p`,{children:`暂无知识节点`}),(0,k.jsx)(`p`,{className:`text-sm mt-1`,children:`使用 Claude Code 进行开发后,知识会自动沉淀`})]})]}),X&&X.length>0&&(0,k.jsx)(`div`,{className:`mt-4`,children:(0,k.jsx)(xe,{currentPage:b,totalPages:Re,onPageChange:x,pageSize:S,onPageSizeChange:e=>{ce(e),x(1)},totalItems:X.length})})]})}),(0,k.jsx)(`div`,{children:(0,k.jsx)(E,{title:`节点详情`,children:g&&X?(()=>{let e=X.find(e=>e.id===g);if(!e)return(0,k.jsx)(`div`,{className:`text-gray-400 text-center py-8`,children:`节点未找到`});let n=j[e.node_type]||l,r=M[e.node_type]||`#6b7280`;return(0,k.jsxs)(`div`,{className:`space-y-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`p-3 rounded-xl`,style:{backgroundColor:`${r}15`},children:(0,k.jsx)(n,{className:`h-6 w-6`,style:{color:r}})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`font-bold text-gray-900`,children:e.title}),(0,k.jsx)(D,{size:`sm`,children:N[e.node_type]||e.node_type})]})]}),(0,k.jsx)(`div`,{className:`p-3 bg-gray-50 rounded-lg text-sm text-gray-700 whitespace-pre-wrap`,children:e.content}),e.tags&&e.tags.trim()&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-xs font-semibold text-gray-500 mb-2`,children:`标签`}),(0,k.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.tags.split(`,`).filter(e=>e.trim()).map(e=>(0,k.jsx)(`span`,{className:`text-xs px-2 py-1 bg-blue-50 text-blue-600 rounded-full`,children:e.trim()},e))})]}),K&&K.items.length>0&&(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`text-xs font-semibold text-gray-500 mb-2`,children:[`关联节点 (`,K.total,`)`]}),(0,k.jsx)(`div`,{className:`space-y-2`,children:K.items.map((e,t)=>(0,k.jsxs)(`div`,{className:`p-2 bg-gray-50 rounded-lg text-sm cursor-pointer hover:bg-gray-100`,onClick:()=>_(e.id),children:[(0,k.jsx)(`div`,{className:`font-medium`,children:e.title}),(0,k.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[e.edge_type,` · `,e.node_type]})]},t))})]}),(0,k.jsx)(T,{variant:`ghost`,size:`sm`,icon:t,onClick:()=>L(!0),children:`添加关系`})]})})():(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-gray-400`,children:[(0,k.jsx)(ee,{className:`h-8 w-8 mb-3`}),(0,k.jsx)(`p`,{className:`text-sm`,children:`点击左侧节点查看详情`})]})})})]}),A&&(0,k.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:()=>F(!1),children:(0,k.jsxs)(`div`,{className:`bg-white rounded-xl p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h3`,{className:`text-xl font-bold mb-4`,children:`创建知识节点`}),(0,k.jsxs)(`form`,{onSubmit:ze,className:`space-y-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`标题 *`}),(0,k.jsx)(`input`,{type:`text`,name:`title`,required:!0,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`内容 *`}),(0,k.jsx)(`textarea`,{name:`content`,required:!0,rows:6,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`类型 *`}),(0,k.jsxs)(`select`,{name:`node_type`,required:!0,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,k.jsx)(`option`,{value:`requirement`,children:`需求 (requirement)`}),(0,k.jsx)(`option`,{value:`decision`,children:`决策 (decision)`}),(0,k.jsx)(`option`,{value:`code_change`,children:`代码变更 (code_change)`}),(0,k.jsx)(`option`,{value:`outcome`,children:`结果 (outcome)`})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`项目路径 *`}),(0,k.jsx)(`input`,{type:`text`,name:`project_path`,required:!0,placeholder:`/path/to/project`,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`标签(逗号分隔)`}),(0,k.jsx)(`input`,{type:`text`,name:`tags`,placeholder:`tag1, tag2, tag3`,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2 justify-end pt-2`,children:[(0,k.jsx)(T,{type:`button`,variant:`secondary`,onClick:()=>F(!1),children:`取消`}),(0,k.jsx)(T,{type:`submit`,variant:`primary`,loading:Ne.isPending,children:`创建`})]})]})]})}),Te&&R&&(0,k.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:()=>I(!1),children:(0,k.jsxs)(`div`,{className:`bg-white rounded-xl p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h3`,{className:`text-xl font-bold mb-4`,children:`编辑知识节点`}),(0,k.jsxs)(`form`,{onSubmit:Be,className:`space-y-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`标题`}),(0,k.jsx)(`input`,{type:`text`,name:`title`,defaultValue:R.title,required:!0,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`内容`}),(0,k.jsx)(`textarea`,{name:`content`,defaultValue:R.content,required:!0,rows:6,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`标签(逗号分隔)`}),(0,k.jsx)(`input`,{type:`text`,name:`tags`,defaultValue:R.tags,placeholder:`tag1, tag2, tag3`,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),(0,k.jsxs)(`div`,{className:`flex gap-2 justify-end pt-2`,children:[(0,k.jsx)(T,{type:`button`,variant:`secondary`,onClick:()=>I(!1),children:`取消`}),(0,k.jsx)(T,{type:`submit`,variant:`primary`,loading:Pe.isPending,children:`保存`})]})]})]})}),Ee&&g&&(0,k.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:()=>L(!1),children:(0,k.jsxs)(`div`,{className:`bg-white rounded-xl p-6 w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h3`,{className:`text-xl font-bold mb-4`,children:`添加关系`}),(0,k.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget),n=t.get(`to_node_id`),r=t.get(`edge_type`);n&&r&&Y.mutate({from_node_id:g,to_node_id:n,edge_type:r})},className:`space-y-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`目标节点 *`}),(0,k.jsxs)(`select`,{name:`to_node_id`,required:!0,className:`w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,k.jsx)(`option`,{value:``,children:`选择节点`}),G?.items.filter(e=>e.id!==g).map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.title,` (`,N[e.node_type]||e.node_type,`)`]},e.id))]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-1`,children:`关系类型 *`}),(0,k.jsxs)(`select`,{name:`edge_type`,required:!0,className:`w-full px-3 py-2 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:`depends_on`,children:`依赖于`}),(0,k.jsx)(`option`,{value:`implements`,children:`实现`}),(0,k.jsx)(`option`,{value:`relates_to`,children:`关联到`}),(0,k.jsx)(`option`,{value:`causes`,children:`导致`}),(0,k.jsx)(`option`,{value:`resolves`,children:`解决`})]})]}),(0,k.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>L(!1),className:`px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-lg transition-colors`,children:`取消`}),(0,k.jsx)(`button`,{type:`submit`,disabled:Y.isPending,className:`px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50`,children:Y.isPending?`创建中...`:`创建`})]})]})]})}),(0,k.jsx)(be,{open:V.open,title:V.title,description:V.description,variant:`danger`,onConfirm:V.onConfirm,onCancel:()=>H({...V,open:!1})}),(0,k.jsx)(Ce,{open:Ae,count:v.size,itemLabel:`知识节点`,loading:J.isPending,onConfirm:()=>{J.mutate(Array.from(v)),U(!1),y(new Set)},onCancel:()=>U(!1)})]})}export{F as default};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Ft as t,It as n,Mn as r,Ut as i,Yn as a,Zn as o,_n as s,an as c,er as l,gr as u,or as d,sn as f,tn as p}from"./vendor-DRGPi8ui.js";import{a as m,n as h,r as g}from"./vendor-query-DqPOMnuX.js";import{c as _}from"./vendor-flow-srkes8If.js";import{b as v,ct as y,rn as b,st as x,w as S,yt as C}from"./client-BhcjNvkG.js";var w=e(u(),1),T=_(),E=[`analyze`,`design`,`code`,`test`,`review`,`deploy`],D=[`read_heavy`,`write_heavy`,`balanced`],O=[`document`,`code`,`test`,`config`];function k({artifacts:e,onChange:t}){let r=e||[],i=()=>t([...r,{type:`document`,description:``,required:!0,minCount:1}]),a=e=>t(r.filter((t,n)=>n!==e)),o=(e,n,i)=>{t(r.map((t,r)=>r===e?{...t,[n]:i}:t))};return(0,T.jsxs)(`div`,{className:`space-y-2`,children:[r.map((e,t)=>(0,T.jsxs)(`div`,{className:`border border-gray-200 rounded p-3 space-y-2 text-sm`,children:[(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsx)(`select`,{value:e.type,onChange:e=>o(t,`type`,e.target.value),className:`border rounded px-2 py-1 text-xs`,children:O.map(e=>(0,T.jsx)(`option`,{children:e},e))}),(0,T.jsx)(`input`,{value:e.description,onChange:e=>o(t,`description`,e.target.value),placeholder:`描述`,className:`flex-1 border rounded px-2 py-1 text-xs`}),(0,T.jsx)(`button`,{onClick:()=>a(t),className:`text-red-400 hover:text-red-600`,children:(0,T.jsx)(n,{className:`h-4 w-4`})})]}),(0,T.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,T.jsx)(`input`,{value:e.pathPattern||``,onChange:e=>o(t,`pathPattern`,e.target.value),placeholder:`路径模式 (如 docs/**/*.md)`,className:`flex-1 border rounded px-2 py-1 text-xs`}),(0,T.jsxs)(`label`,{className:`flex items-center gap-1 text-xs text-gray-600`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.required!==!1,onChange:e=>o(t,`required`,e.target.checked)}),`必须`]}),(0,T.jsx)(`input`,{type:`number`,value:e.minCount||1,min:1,onChange:e=>o(t,`minCount`,parseInt(e.target.value)),className:`w-16 border rounded px-2 py-1 text-xs`})]})]},t)),(0,T.jsxs)(`button`,{onClick:i,className:`flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800`,children:[(0,T.jsx)(c,{className:`h-3 w-3`}),` 添加产物约束`]})]})}function A({initial:e,onSave:t,onCancel:r}){let[i,a]=(0,w.useState)({id:e?.id||``,name:e?.name||``,description:e?.description||``,semanticCategory:e?.semanticCategory||`code`,defaultSkills:e?.defaultSkills||[],minToolCalls:e?.minToolCalls||20,stagnationStrategy:e?.stagnationStrategy||`balanced`,expectedArtifacts:e?.expectedArtifacts||[],instructionSuffix:e?.instructionSuffix||``}),o=(e,t)=>a(n=>({...n,[e]:t}));return(0,T.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`ID(唯一标识)`}),(0,T.jsx)(`input`,{value:i.id,onChange:e=>o(`id`,e.target.value),disabled:!!e?.id,className:`w-full border rounded px-2 py-1 text-xs disabled:bg-gray-50`})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`名称`}),(0,T.jsx)(`input`,{value:i.name,onChange:e=>o(`name`,e.target.value),className:`w-full border rounded px-2 py-1 text-xs`})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`描述`}),(0,T.jsx)(`input`,{value:i.description,onChange:e=>o(`description`,e.target.value),className:`w-full border rounded px-2 py-1 text-xs`})]}),(0,T.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`语义类别`}),(0,T.jsx)(`select`,{value:i.semanticCategory,onChange:e=>o(`semanticCategory`,e.target.value),className:`w-full border rounded px-2 py-1 text-xs`,children:E.map(e=>(0,T.jsx)(`option`,{children:e},e))})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`最小工具调用`}),(0,T.jsx)(`input`,{type:`number`,value:i.minToolCalls,min:1,onChange:e=>o(`minToolCalls`,parseInt(e.target.value)),className:`w-full border rounded px-2 py-1 text-xs`})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`停滞策略`}),(0,T.jsx)(`select`,{value:i.stagnationStrategy,onChange:e=>o(`stagnationStrategy`,e.target.value),className:`w-full border rounded px-2 py-1 text-xs`,children:D.map(e=>(0,T.jsx)(`option`,{children:e},e))})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`预期产物`}),(0,T.jsx)(k,{artifacts:i.expectedArtifacts,onChange:e=>o(`expectedArtifacts`,e)})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{className:`block text-xs text-gray-600 mb-1`,children:`执行提示(可选)`}),(0,T.jsx)(`textarea`,{value:i.instructionSuffix||``,onChange:e=>o(`instructionSuffix`,e.target.value),rows:2,className:`w-full border rounded px-2 py-1 text-xs`})]}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,T.jsxs)(`button`,{onClick:()=>t(i),className:`flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white text-xs rounded hover:bg-blue-700`,children:[(0,T.jsx)(p,{className:`h-3 w-3`}),` 保存`]}),(0,T.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 px-3 py-1.5 border text-xs rounded hover:bg-gray-50`,children:[(0,T.jsx)(n,{className:`h-3 w-3`}),` 取消`]})]})]})}function j(){let[e,n]=(0,w.useState)(null),[u,p]=(0,w.useState)(!1),[_,E]=(0,w.useState)(void 0),[D,O]=(0,w.useState)(`view`),k=m(),{data:j}=g({queryKey:[`projects`],queryFn:()=>C().then(e=>e.data)});(0,w.useEffect)(()=>{j?.items?.[0]?.projectPath&&E(j.items[0].projectPath)},[j]);let{data:M,isLoading:N}=g({queryKey:[`node-types`,_],queryFn:()=>y(_),enabled:!!_}),{data:P,isLoading:F}=g({queryKey:[`node-type`,e],queryFn:()=>x(e),enabled:!!e&&D===`view`}),I=()=>{k.invalidateQueries({queryKey:[`node-types`]}),k.invalidateQueries({queryKey:[`node-type`,e]})},L=h({mutationFn:e=>v(e),onSuccess:()=>{I(),O(`view`)}}),R=h({mutationFn:e=>b(e.id,e),onSuccess:()=>{I(),O(`view`)}}),z=h({mutationFn:e=>S(e),onSuccess:()=>{n(null),O(`view`),I()}}),B=M?.data.items||[],V=P?.data,H=e=>({analyze:`bg-blue-100 text-blue-700`,design:`bg-purple-100 text-purple-700`,code:`bg-green-100 text-green-700`,test:`bg-orange-100 text-orange-700`,review:`bg-red-100 text-red-700`,deploy:`bg-indigo-100 text-indigo-700`})[e]||`bg-gray-100 text-gray-700`;return(0,T.jsxs)(`div`,{className:`p-6 max-w-7xl mx-auto`,children:[(0,T.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`流水线节点类型管理`}),(0,T.jsx)(`p`,{className:`text-sm text-gray-600 mt-1`,children:`浏览所有可用的节点类型,点击查看详细配置`})]}),(0,T.jsxs)(`button`,{onClick:()=>{n(null),O(`create`)},className:`flex items-center gap-1 px-3 py-2 bg-blue-600 text-white text-sm rounded hover:bg-blue-700`,children:[(0,T.jsx)(c,{className:`h-4 w-4`}),` 新建节点类型`]})]}),N?(0,T.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,T.jsx)(s,{className:`h-6 w-6 animate-spin text-gray-400`})}):(0,T.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,T.jsx)(`div`,{className:`space-y-3`,children:B.map(i=>(0,T.jsxs)(`div`,{onClick:()=>{n(i.id),O(`view`),p(!1)},className:`p-4 border rounded-lg cursor-pointer transition-all ${e===i.id?`border-blue-500 bg-blue-50 shadow-sm`:`border-gray-200 hover:border-gray-300 hover:shadow-sm`}`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(d,{className:`h-5 w-5 text-gray-600`}),(0,T.jsx)(`h3`,{className:`font-semibold text-gray-900`,children:i.name})]}),(0,T.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full ${H(i.semanticCategory)}`,children:i.semanticCategory})]}),(0,T.jsx)(`p`,{className:`text-sm text-gray-600 mt-2`,children:i.description}),(0,T.jsxs)(`div`,{className:`flex items-center gap-4 mt-3 text-xs text-gray-500`,children:[i.isBuiltin&&(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(a,{className:`h-3 w-3`}),`内置`]}),!i.isBuiltin&&(0,T.jsx)(`span`,{className:`flex items-center gap-1 text-blue-600`,children:`自定义`}),i.defaultSkills.length>0&&(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(t,{className:`h-3 w-3`}),i.defaultSkills.length,` 个默认技能`]}),(i.expectedArtifacts?.length||0)>0&&(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(r,{className:`h-3 w-3`}),i.expectedArtifacts.length,` 个产物约束`]}),i.usageCount!==void 0&&(0,T.jsxs)(`span`,{className:`flex items-center gap-1 text-purple-600 font-medium`,children:[`使用 `,i.usageCount,` 次`]})]})]},i.id))}),(0,T.jsx)(`div`,{className:`lg:sticky lg:top-6 lg:self-start`,children:D===`create`?(0,T.jsxs)(`div`,{className:`border border-gray-200 rounded-lg p-6`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-bold text-gray-900 mb-4`,children:`新建节点类型`}),(0,T.jsx)(A,{onSave:e=>L.mutate(e),onCancel:()=>O(`view`)})]}):D===`edit`&&V?(0,T.jsxs)(`div`,{className:`border border-gray-200 rounded-lg p-6`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-bold text-gray-900 mb-4`,children:`编辑节点类型`}),(0,T.jsx)(A,{initial:{...V,minToolCalls:V.activityThreshold.minToolCalls,stagnationStrategy:V.activityThreshold.stagnationStrategy},onSave:e=>R.mutate(e),onCancel:()=>O(`view`)})]}):e?F?(0,T.jsx)(`div`,{className:`border border-gray-200 rounded-lg p-8 flex items-center justify-center`,children:(0,T.jsx)(s,{className:`h-6 w-6 animate-spin text-gray-400`})}):V?(0,T.jsxs)(`div`,{className:`border border-gray-200 rounded-lg p-6 space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,T.jsx)(`h2`,{className:`text-xl font-bold text-gray-900`,children:V.name}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`px-2 py-1 text-xs rounded-full ${H(V.semanticCategory)}`,children:V.semanticCategory}),!V.isBuiltin&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`button`,{onClick:()=>O(`edit`),className:`p-1 text-gray-400 hover:text-blue-600`,children:(0,T.jsx)(f,{className:`h-4 w-4`})}),(0,T.jsx)(`button`,{onClick:()=>{confirm(`确认删除?`)&&z.mutate(V.id)},className:`p-1 text-gray-400 hover:text-red-600`,children:(0,T.jsx)(i,{className:`h-4 w-4`})})]})]})]}),(0,T.jsx)(`p`,{className:`text-sm text-gray-600`,children:V.description}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 text-xs text-gray-500`,children:[(0,T.jsx)(`code`,{className:`bg-gray-100 px-2 py-0.5 rounded`,children:V.id}),V.isBuiltin&&(0,T.jsxs)(`span`,{className:`flex items-center gap-1 text-green-600`,children:[(0,T.jsx)(a,{className:`h-3 w-3`}),`内置节点`]})]})]}),V.expectedArtifacts&&V.expectedArtifacts.length>0&&(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-2 flex items-center gap-1`,children:[(0,T.jsx)(r,{className:`h-4 w-4`}),`预期产物`]}),(0,T.jsx)(`div`,{className:`space-y-2`,children:V.expectedArtifacts.map((e,t)=>(0,T.jsxs)(`div`,{className:`flex items-start gap-2 text-xs bg-gray-50 rounded p-2`,children:[(0,T.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs font-medium ${e.type===`code`?`bg-green-100 text-green-700`:e.type===`test`?`bg-orange-100 text-orange-700`:`bg-blue-100 text-blue-700`}`,children:e.type}),(0,T.jsxs)(`div`,{className:`flex-1`,children:[(0,T.jsx)(`div`,{className:`text-gray-700`,children:e.description}),e.pathPattern&&(0,T.jsx)(`code`,{className:`text-gray-500`,children:e.pathPattern})]}),e.required&&(0,T.jsx)(`span`,{className:`text-red-500 text-xs`,children:`必须`})]},t))})]}),V.defaultSkills.length>0&&(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-2 flex items-center gap-1`,children:[(0,T.jsx)(t,{className:`h-4 w-4`}),`默认技能`]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.defaultSkills.map(e=>(0,T.jsx)(`span`,{className:`px-2 py-1 bg-blue-50 text-blue-700 text-xs rounded`,children:e},e))})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-2 flex items-center gap-1`,children:[(0,T.jsx)(a,{className:`h-4 w-4`}),`完成条件`]}),(0,T.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[V.completion.explicitSignal&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-gray-600`,children:`显式信号:`}),(0,T.jsx)(`code`,{className:`ml-2 bg-gray-100 px-2 py-0.5 rounded text-xs`,children:V.completion.explicitSignal})]}),V.completion.keywords.length>0&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-gray-600`,children:`关键词:`}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:V.completion.keywords.map((e,t)=>(0,T.jsx)(`code`,{className:`bg-gray-100 px-2 py-0.5 rounded text-xs`,children:e},t))})]})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-2`,children:`活跃度阈值`}),(0,T.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[V.activityThreshold.minToolCalls!==void 0&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-gray-600`,children:`最小工具调用:`}),(0,T.jsx)(`span`,{className:`ml-2`,children:V.activityThreshold.minToolCalls})]}),V.activityThreshold.stagnationStrategy&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-gray-600`,children:`停滞策略:`}),(0,T.jsx)(`code`,{className:`ml-2 bg-gray-100 px-2 py-0.5 rounded text-xs`,children:V.activityThreshold.stagnationStrategy})]})]})]}),V.instructionSuffix&&(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-gray-700 mb-2`,children:`执行提示`}),(0,T.jsx)(`p`,{className:`text-xs text-gray-600 bg-gray-50 rounded p-2`,children:V.instructionSuffix})]}),V.heuristic&&(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`button`,{onClick:()=>p(!u),className:`flex items-center gap-2 text-sm font-semibold text-gray-700 hover:text-gray-900`,children:[u?(0,T.jsx)(o,{className:`h-4 w-4`}):(0,T.jsx)(l,{className:`h-4 w-4`}),`原始配置(JSON)`]}),u&&(0,T.jsx)(`pre`,{className:`mt-2 p-3 bg-gray-50 rounded text-xs overflow-auto max-h-64`,children:JSON.stringify(V.heuristic,null,2)})]})]}):null:(0,T.jsxs)(`div`,{className:`border border-gray-200 rounded-lg p-8 text-center text-gray-500`,children:[(0,T.jsx)(d,{className:`h-12 w-12 mx-auto mb-3 text-gray-300`}),(0,T.jsx)(`p`,{children:`选择左侧节点类型查看详细信息`})]})})]})]})}export{j as default};
@@ -0,0 +1 @@
1
+ import{$n as e,Qn as t}from"./vendor-DRGPi8ui.js";import{c as n}from"./vendor-flow-srkes8If.js";import{n as r}from"./ui-CDL3BZ13.js";var i=n();function a({currentPage:n,totalPages:a,onPageChange:o,pageSize:s,onPageSizeChange:c,totalItems:l}){return(0,i.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t border-gray-200`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,i.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[`显示 `,(n-1)*s+1,`-`,Math.min(n*s,l),` / 共 `,l,` 条`]}),(0,i.jsxs)(`select`,{value:s,onChange:e=>c(Number(e.target.value)),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,i.jsx)(`option`,{value:10,children:`10 条/页`}),(0,i.jsx)(`option`,{value:20,children:`20 条/页`}),(0,i.jsx)(`option`,{value:50,children:`50 条/页`}),(0,i.jsx)(`option`,{value:100,children:`100 条/页`})]})]}),(0,i.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(r,{variant:`ghost`,size:`sm`,icon:e,onClick:()=>o(n-1),disabled:n===1,children:`上一页`}),(0,i.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:Math.min(a,7)},(e,t)=>{let r;return r=a<=7||n<=4?t+1:n>=a-3?a-6+t:n-3+t,(0,i.jsx)(`button`,{onClick:()=>o(r),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${n===r?`bg-blue-600 text-white`:`text-gray-600 hover:bg-gray-100`}`,children:r},r)})}),(0,i.jsx)(r,{variant:`ghost`,size:`sm`,icon:t,onClick:()=>o(n+1),disabled:n===a,children:`下一页`})]})]})}export{a as t};
@@ -0,0 +1,4 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{$t as t,Bn as n,Bt as r,Ft as i,Gn as a,It as o,Kn as s,Mn as c,Pn as l,Qt as u,Rt as d,Wn as f,Wt as p,Xn as m,Yn as h,Zn as g,dr as _,er as v,gr as y,jn as b,nn as x,pr as S,qn as C,rn as w,s as T,wn as E}from"./vendor-DRGPi8ui.js";import{c as D,l as ee,s as te}from"./vendor-react-DJI9oneq.js";import{a as ne,n as O,r as k}from"./vendor-query-DqPOMnuX.js";import{c as A}from"./vendor-flow-srkes8If.js";import{Kt as j,Ut as M,_ as N,dt as P,j as F,n as re,un as I,zt as ie}from"./client-BhcjNvkG.js";import{a as L,l as R,n as z,r as B,t as V}from"./ui-CDL3BZ13.js";import{t as H}from"./vendor-motion-CQmdgnI8.js";import{t as U}from"./ConfirmDialog-CVzB7X5y.js";import{t as W}from"./Breadcrumb-DtfwnOx6.js";var G=e(y(),1),K=A(),q={pending:s,running:a,validating:x,passed:h,failed:C,need_human:m},J={pending:`text-gray-400`,running:`text-blue-500`,validating:`text-yellow-500`,passed:`text-green-500`,failed:`text-red-500`,need_human:`text-orange-500`},Y={pending:`待执行`,running:`执行中`,validating:`验证中`,passed:`已完成`,failed:`失败`,need_human:`需人工介入`};function ae({steps:e,currentStepId:t}){return!e||e.length===0?null:(0,K.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[`步骤进度 (`,e.filter(e=>e.status===`passed`).length,`/`,e.length,`)`]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:e.map((e,n)=>{let r=q[e.status],i=e.id===t;return(0,K.jsxs)(`div`,{className:L(`flex items-start gap-3 p-3 rounded-lg border transition-colors`,i?`bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800`:`bg-gray-50 dark:bg-gray-800/50 border-gray-200 dark:border-gray-700`),children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-6 h-6 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center text-xs font-medium`,children:n+1}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(r,{className:L(`w-4 h-4`,J[e.status])}),(0,K.jsx)(`span`,{className:`font-medium text-sm text-gray-900 dark:text-gray-100`,children:e.stepName}),(0,K.jsx)(V,{variant:e.status===`passed`?`success`:e.status===`failed`?`error`:`default`,children:Y[e.status]}),i&&(0,K.jsx)(V,{variant:`info`,children:`当前`})]}),e.attempts>0&&(0,K.jsxs)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[`重试次数:`,e.attempts]}),e.failureReason&&(0,K.jsxs)(`div`,{className:`text-xs text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 p-2 rounded mt-1`,children:[`失败原因:`,e.failureReason]}),e.outputs&&Object.keys(e.outputs).length>0&&(0,K.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,K.jsx)(`div`,{className:`text-gray-600 dark:text-gray-400 mb-1`,children:`输出产物:`}),(0,K.jsx)(`div`,{className:`space-y-1`,children:Object.entries(e.outputs).map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-700 dark:text-gray-300`,children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e,`:`]}),(0,K.jsx)(`a`,{href:`file://${t}`,className:`text-blue-600 dark:text-blue-400 hover:underline truncate`,title:t,children:t})]},e))})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 text-xs text-gray-500 dark:text-gray-400`,children:[e.startedAt&&(0,K.jsxs)(`span`,{children:[`开始:`,T(new Date(e.startedAt),`HH:mm:ss`)]}),e.completedAt&&(0,K.jsxs)(`span`,{children:[`完成:`,T(new Date(e.completedAt),`HH:mm:ss`)]})]})]})]},e.id)})})]})}var oe={document:c,code:f,test:p,config:t,diagram:E,data:n,other:b},X={analyze:{name:`需求分析`,description:`分析需求,明确目标和范围`},design:{name:`架构设计`,description:`设计系统架构和技术方案`},profile:{name:`性能分析`,description:`分析性能瓶颈,制定优化方案`},code:{name:`编码实现`,description:`编写代码,实现功能`},test:{name:`测试验证`,description:`编写测试,验证功能正确性`},review:{name:`代码审查`,description:`审查代码质量和规范`}},se={analy:`#3b82f6`,design:`#8b5cf6`,architect:`#8b5cf6`,profile:`#06b6d4`,code:`#10b981`,implement:`#10b981`,test:`#f59e0b`,verif:`#f59e0b`,review:`#ef4444`,deploy:`#06b6d4`};function Z(e){let t=e.toLowerCase();for(let[e,n]of Object.entries(se))if(t.includes(e))return n;return`#6b7280`}function Q(e){let t=X[e];return t?t.name:e.split(/[_\-.]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function ce(e){return X[e]?.description||null}function le(e){let t=new Set,n=[],r=new Map(e.map(e=>[e.id,e]));function i(e){if(t.has(e))return;t.add(e);let a=r.get(e);a&&((a.dependencies||[]).forEach(e=>i(e)),n.push(a))}return e.forEach(e=>i(e.id)),n}function $(e,t){if(!e)return null;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now(),i=Math.floor((r-n)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function ue({pipeline:e,onRetryNode:t}){let[n,r]=(0,G.useState)(new Set),o=(0,G.useMemo)(()=>le(e.nodes),[e.nodes]),s=o.filter(e=>e.status===`completed`||e.status===`skipped`).length,c=o.length>0&&o.every(e=>e.status===`completed`||e.status===`skipped`||e.status===`failed`),l=c?-1:o.findIndex(t=>t.id===e.currentNodeId),u=e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return o.length===0?(0,K.jsx)(B,{children:(0,K.jsx)(`div`,{className:`text-center py-8 text-gray-400`,children:`暂无节点`})}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(B,{className:`!p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium text-gray-700`,children:[`编排阶段 · `,s,`/`,o.length,` 已完成`]}),(0,K.jsx)(`span`,{className:`text-xs text-gray-400`,children:c||e.status===`completed`?`✅ 全部完成`:e.status===`failed`?`❌ 已失败`:l>=0?`当前:第 ${l+1} 阶段`:`准备中`})]}),(0,K.jsx)(`div`,{className:`flex items-start gap-0 overflow-x-auto pb-1`,children:o.map((t,n)=>{let r=t.id===e.currentNodeId,i=t.status===`completed`,a=t.status===`failed`,s=t.status===`skipped`,c=Z(t.nodeTypeId),l=a?`#ef4444`:s?`#9ca3af`:i||r?c:void 0;return(0,K.jsxs)(`div`,{className:`flex items-center flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:L(`w-9 h-9 rounded-full flex items-center justify-center text-xs font-bold transition-all`,l?`text-white`:`bg-gray-100 text-gray-400`,r&&`ring-4 ring-offset-2`),style:l?{backgroundColor:l,...r?{ringColor:`${c}40`}:{}}:{},children:i?`✓`:a?`✗`:s?`—`:n+1}),(0,K.jsx)(`span`,{className:L(`text-xs mt-1 max-w-[72px] text-center leading-tight break-words`,r?`font-bold text-gray-900`:`text-gray-500`),children:Q(t.nodeTypeId)})]}),n<o.length-1&&(0,K.jsx)(`div`,{className:L(`h-0.5 w-6 mx-0.5 mb-5 flex-shrink-0 transition-colors`,i?`bg-green-400`:`bg-gray-200`)})]},t.id)})})]}),(0,K.jsx)(`div`,{className:`space-y-3`,children:o.map((r,s)=>{let c=r.id===e.currentNodeId,l=Z(r.nodeTypeId),d=Q(r.nodeTypeId),f=ce(r.nodeTypeId),p=$(r.startedAt,r.completedAt),m=n.has(r.id),h=null,_=null;if(r.output)try{let e=JSON.parse(r.output);e.artifacts&&e.validation?h=e:_=r.output}catch{_=r.output}let y=_?_.trim().split(`
2
+ `):[],S=y.length>10,C=(r.dependencies||[]).map(e=>{let t=o.find(t=>t.id===e);return t?Q(t.nodeTypeId):e.slice(0,8)});return(0,K.jsxs)(B,{className:L(`!p-0 overflow-hidden transition-all`,c?`ring-2 ring-blue-400 ring-offset-1`:``),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-4`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center text-white font-bold text-sm flex-shrink-0`,style:{backgroundColor:r.status===`pending`?`#d1d5db`:r.status===`failed`?`#ef4444`:r.status===`skipped`?`#9ca3af`:l},children:r.status===`completed`?`✓`:r.status===`failed`?`✗`:r.status===`skipped`?`—`:s+1}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-900`,children:d}),c&&(0,K.jsx)(V,{variant:`info`,size:`sm`,children:`当前阶段`}),(0,K.jsx)(V,{size:`sm`,variant:r.status===`completed`?`success`:r.status===`in_progress`?`info`:r.status===`failed`?`danger`:r.status===`skipped`?`warning`:`default`,children:r.status===`completed`?`已完成`:r.status===`in_progress`?`执行中`:r.status===`failed`?`失败`:r.status===`skipped`?`已跳过`:`等待中`}),p&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-gray-400`,children:[(0,K.jsx)(a,{className:`w-3 h-3`}),p]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5 mt-1`,children:[f&&(0,K.jsx)(`span`,{className:`text-xs text-gray-500`,children:f}),r.boundSkillName&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600`,children:[(0,K.jsx)(i,{className:`w-3 h-3`}),r.boundSkillName]}),C.length>0&&(0,K.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`依赖:`,C.join(`, `)]}),r.completedAt&&(0,K.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`完成于 `,T(new Date(r.completedAt),`HH:mm:ss`)]})]})]}),r.status===`failed`&&t&&(0,K.jsx)(z,{variant:`outline`,size:`sm`,icon:x,onClick:()=>t(r.id),className:`flex-shrink-0`,children:`重试`})]}),h&&(0,K.jsxs)(`div`,{className:`border-t border-gray-100 bg-gray-50 px-4 pt-3 pb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:`阶段产出`}),!h.validation.passed&&(0,K.jsx)(V,{variant:`danger`,size:`sm`,children:`验证失败`})]}),h.summary&&(0,K.jsx)(`div`,{className:`text-sm text-gray-700 mb-3`,children:h.summary}),h.artifacts.length>0&&(0,K.jsx)(`div`,{className:`space-y-2`,children:h.artifacts.map((e,t)=>(0,K.jsx)(`div`,{className:`bg-white rounded-lg border border-gray-200 p-3`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(oe[e.type]||b,{className:`w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-mono text-sm text-gray-900 break-all`,children:e.path}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-xs text-gray-500`,children:[(0,K.jsx)(`span`,{className:`capitalize`,children:e.type}),e.size_bytes&&(0,K.jsxs)(`span`,{children:[`· `,(e.size_bytes/1024).toFixed(1),` KB`]}),(0,K.jsxs)(`span`,{children:[`· `,T(new Date(e.created_at),`HH:mm:ss`)]})]})]})]})},t))}),h.validation.errors&&h.validation.errors.length>0&&(0,K.jsx)(`div`,{className:`mt-3 p-2 bg-red-50 border border-red-200 rounded text-xs text-red-700`,children:h.validation.errors.map((e,t)=>(0,K.jsxs)(`div`,{children:[`• `,e]},t))})]}),!h&&y.length>0&&(0,K.jsxs)(`div`,{className:`border-t border-gray-100 bg-gray-50 px-4 pt-3 pb-4`,children:[(0,K.jsx)(`span`,{className:`text-xs font-semibold text-gray-500 uppercase tracking-wider`,children:`阶段产出`}),(0,K.jsx)(`div`,{className:L(`mt-2 text-sm text-gray-800 whitespace-pre-wrap font-mono bg-white rounded-lg border border-gray-100 p-3 leading-relaxed`,!m&&S?`max-h-52 overflow-hidden`:``),children:!m&&S?y.slice(0,10).join(`
3
+ `)+`
4
+ …`:_}),S&&(0,K.jsx)(`button`,{onClick:()=>u(r.id),className:`mt-2 text-xs text-blue-600 hover:underline flex items-center gap-1`,children:m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(g,{className:`w-3 h-3`}),`收起`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(v,{className:`w-3 h-3`}),`展开全部(`,y.length,` 行)`]})})]}),r.stepExecutions&&r.stepExecutions.length>0&&(0,K.jsx)(`div`,{className:`border-t border-gray-100 bg-white px-4 py-3`,children:(0,K.jsx)(ae,{steps:r.stepExecutions,currentStepId:r.currentStepId})}),r.status===`in_progress`&&y.length===0&&(0,K.jsxs)(`div`,{className:`border-t border-blue-100 bg-blue-50 px-4 py-3 flex items-center gap-2 text-sm text-blue-600`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-blue-500 animate-pulse`}),`正在执行,等待产出…`]})]},r.id)})})]})}var de={PreToolUse:`#3b82f6`,PostToolUse:`#10b981`,UserPromptSubmit:`#f59e0b`,Stop:`#ef4444`};function fe(){let{id:e}=ee(),t=D(),n=te(),i=ne(),[a,s]=(0,G.useState)(`tasks`),[c,f]=(0,G.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),p=n.state?.from||`/pipelines`,{data:m,isLoading:g,isError:v,error:y}=k({queryKey:[`pipeline`,e],queryFn:()=>P(e).then(e=>e.data),enabled:!!e,refetchInterval:5e3}),b=O({mutationFn:()=>N(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`pipeline`,e]}),t(p)},onError:e=>I(e.message||`关闭失败`,`error`)}),x=O({mutationFn:()=>ie(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`pipeline`,e]}),I(`Pipeline 已重新激活`,`success`)},onError:e=>I(e.message||`重新激活失败`,`error`)}),C=O({mutationFn:()=>j(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`pipeline`,e]}),I(`已添加到执行队列,下次工具调用时自动注入提示`,`success`)},onError:e=>I(e.message||`恢复失败`,`error`)}),E=O({mutationFn:t=>re(e),onSuccess:t=>{i.invalidateQueries({queryKey:[`pipeline`,e]}),I(t.data.message||`节点已重置,等待重新执行`,`success`)},onError:e=>I(e.message||`重试失败`,`error`)}),A=O({mutationFn:e=>M(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`pipeline`,e]}),I(`问题已标记为已解决`,`success`)},onError:e=>I(e.message||`操作失败`,`error`)}),q=O({mutationFn:e=>F(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`pipeline`,e]}),I(`问题已忽略`,`success`)},onError:e=>I(e.message||`操作失败`,`error`)});if(v)return(0,K.jsxs)(`div`,{className:`flex items-center justify-center h-96 text-red-500`,children:[`加载失败:`,y?.message||`未知错误`]});if(g||!m)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600`})});let J=m,Y=J.status!==`completed`&&J.status!==`failed`;return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsx)(W,{items:[{label:`Pipeline 列表`,path:`/pipelines`},{label:m.id.slice(0,12)+`...`}]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(z,{variant:`ghost`,size:`sm`,icon:_,onClick:()=>t(p),children:`返回`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-bold text-gray-900`,children:`Pipeline 执行轨迹`}),(0,K.jsxs)(V,{variant:`primary`,size:`sm`,children:[(0,K.jsx)(d,{className:`w-3 h-3 mr-1`}),` 动态编排`]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-500`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:m.id.slice(0,12)}),m.sessionId&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`mx-2`,children:`·`}),(0,K.jsxs)(`span`,{className:`text-blue-600 cursor-pointer hover:underline`,onClick:()=>t(`/sessions/${m.sessionId}`),children:[`会话 `,m.sessionId.slice(0,8)]})]})]})]}),(0,K.jsx)(V,{variant:Y?`info`:`success`,children:J.status===`completed`?`已完成`:J.status===`failed`?`已失败`:`执行中`}),(0,K.jsx)(V,{variant:m.complexity===`complex`?`danger`:m.complexity===`moderate`?`warning`:`default`,children:m.complexity})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[m.sessionId&&(0,K.jsx)(z,{variant:`secondary`,size:`sm`,icon:S,onClick:()=>t(`/sessions/${m.sessionId}`),children:`查看会话`}),Y&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z,{variant:`primary`,size:`sm`,onClick:()=>C.mutate(),loading:C.isPending,children:`继续执行`}),(0,K.jsx)(z,{variant:`danger`,size:`sm`,icon:o,onClick:()=>{f({open:!0,title:`关闭 Pipeline`,description:`确认关闭此 Pipeline?`,onConfirm:()=>{b.mutate(),f(e=>({...e,open:!1}))}})},children:`关闭`})]}),!Y&&(0,K.jsx)(z,{variant:`secondary`,size:`sm`,icon:w,onClick:()=>{f({open:!0,title:`重新激活 Pipeline`,description:`确认重新激活此 Pipeline?状态将重置为活跃。`,onConfirm:()=>{x.mutate(),f(e=>({...e,open:!1}))}})},loading:x.isPending,children:`重新激活`})]})]}),(0,K.jsx)(B,{className:`!p-4`,children:(0,K.jsx)(`p`,{className:`text-sm text-gray-700 line-clamp-3`,children:m.requirement})}),J.executionPlan&&(0,K.jsx)(B,{title:`编排计划`,className:`!p-4`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[J.reasoning&&(0,K.jsxs)(`div`,{className:`text-sm text-gray-600 bg-blue-50 p-3 rounded-lg border border-blue-100`,children:[(0,K.jsx)(`div`,{className:`font-medium text-blue-900 mb-1`,children:`规划依据`}),(0,K.jsx)(`p`,{className:`text-blue-800`,children:J.reasoning})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:J.executionPlan.stages.map((e,t)=>{let n=J.nodes.find(t=>t.nodeTypeId===e.nodeTypeId),r=n?.status===`completed`,i=n?.status===`in_progress`,a=!n||n.status===`pending`;return(0,K.jsxs)(`div`,{className:L(`flex items-start gap-3 p-3 rounded-lg border`,r&&`bg-green-50 border-green-200`,i&&`bg-blue-50 border-blue-200`,a&&`bg-gray-50 border-gray-200`),children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold`,style:{backgroundColor:r?`#10b981`:i?`#3b82f6`:`#9ca3af`,color:`white`},children:t+1}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`font-medium text-gray-900`,children:e.name}),(0,K.jsx)(V,{size:`sm`,variant:r?`success`:i?`info`:`default`,children:r?`已完成`:i?`进行中`:`待执行`}),e.phase&&(0,K.jsx)(V,{size:`sm`,children:e.phase})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 mt-1`,children:e.description}),e.expectedArtifacts&&e.expectedArtifacts.length>0&&(0,K.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:`预期产物:`}),e.expectedArtifacts.map((e,t)=>(0,K.jsxs)(`span`,{className:`ml-1 font-mono bg-gray-100 px-1.5 py-0.5 rounded`,children:[e.pattern,e.required&&(0,K.jsx)(`span`,{className:`text-red-500`,children:`*`})]},t))]})]})]},t)})})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-5 gap-3`,children:[(0,K.jsxs)(B,{className:`text-center !p-3`,children:[(0,K.jsx)(`div`,{className:`text-xl font-bold text-blue-600`,children:m.stats.totalEvents}),(0,K.jsx)(`div`,{className:`text-xs text-gray-500`,children:`事件`})]}),(0,K.jsxs)(B,{className:`text-center !p-3`,children:[(0,K.jsx)(`div`,{className:`text-xl font-bold text-green-600`,children:`${J.stats.completedNodes}/${J.stats.totalNodes}`}),(0,K.jsx)(`div`,{className:`text-xs text-gray-500`,children:`节点`})]}),(0,K.jsxs)(B,{className:`text-center !p-3`,children:[(0,K.jsx)(`div`,{className:`text-xl font-bold text-purple-600`,children:m.stats.totalArtifacts}),(0,K.jsx)(`div`,{className:`text-xs text-gray-500`,children:`产物`})]}),(0,K.jsxs)(B,{className:`text-center !p-3`,children:[(0,K.jsx)(`div`,{className:`text-xl font-bold text-orange-600`,children:m.stats.totalQualityIssues}),(0,K.jsx)(`div`,{className:`text-xs text-gray-500`,children:`质量问题`})]}),(0,K.jsxs)(B,{className:`text-center !p-3`,children:[(0,K.jsx)(`div`,{className:`text-xl font-bold text-red-600`,children:m.stats.unresolvedQuality}),(0,K.jsx)(`div`,{className:`text-xs text-gray-500`,children:`未解决`})]})]}),(0,K.jsx)(`div`,{className:`flex gap-1 bg-gray-100 p-1 rounded-lg w-fit`,children:[`tasks`,`events`,`artifacts`,`quality`].map(e=>(0,K.jsx)(`button`,{onClick:()=>s(e),className:L(`px-4 py-2 rounded-md text-sm font-medium transition-colors`,a===e?`bg-white text-gray-900 shadow-sm`:`text-gray-600 hover:text-gray-900`),children:{tasks:`编排图 (${J.stats.totalNodes})`,events:`事件 (${m.stats.totalEvents})`,artifacts:`产物 (${m.stats.totalArtifacts})`,quality:`质量 (${m.stats.totalQualityIssues})`}[e]},e))}),a===`tasks`&&(0,K.jsx)(`div`,{className:`space-y-4`,children:(0,K.jsx)(ue,{pipeline:J,onRetryNode:e=>{f({open:!0,title:`重试失败节点`,description:`确定要重试此节点吗?节点状态将重置为等待中,下次工具调用时自动重新执行。`,onConfirm:()=>{E.mutate(e),f(e=>({...e,open:!1}))}})}})}),a===`events`&&(0,K.jsx)(B,{title:`工具调用时间线`,children:(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[600px] overflow-y-auto`,children:[m.events.map((e,t)=>(0,K.jsxs)(H.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},transition:{delay:t*.01},className:`flex items-center gap-3 py-1.5 px-2 rounded hover:bg-gray-50 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-400 font-mono w-16 flex-shrink-0`,children:T(R(e.time),`HH:mm:ss`)}),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0`,style:{backgroundColor:de[e.hookType]||`#6b7280`}}),(0,K.jsx)(`span`,{className:`font-mono text-gray-700 w-20 flex-shrink-0`,children:e.toolName||e.hookType}),(0,K.jsx)(`span`,{className:`text-gray-500 truncate`,children:e.detail||``})]},t)),m.events.length===0&&(0,K.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:`暂无事件`})]})}),a===`artifacts`&&(0,K.jsx)(B,{title:`产物文件`,children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[m.artifacts.map((e,t)=>(0,K.jsx)(H.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{delay:t*.03},className:`flex items-center justify-between p-3 rounded-lg border border-gray-100 hover:border-green-200 hover:bg-green-50/50`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(l,{className:`h-5 w-5 text-green-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-mono text-sm text-gray-900`,children:e.filePath.split(`/`).slice(-2).join(`/`)}),(0,K.jsxs)(`div`,{className:`text-xs text-gray-400`,children:[e.tool,` · `,T(R(e.time),`HH:mm:ss`)]})]})]})},t)),m.artifacts.length===0&&(0,K.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:`暂无产物`})]})}),a===`quality`&&(0,K.jsx)(B,{title:`质量问题`,children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[m.qualityIssues.map((e,t)=>(0,K.jsxs)(H.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},transition:{delay:t*.03},className:`flex items-start justify-between p-3 rounded-lg border border-gray-100`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 flex-1`,children:[e.resolved?(0,K.jsx)(h,{className:`h-5 w-5 text-green-500 mt-0.5`}):(0,K.jsx)(r,{className:`h-5 w-5 text-amber-500 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(V,{size:`sm`,variant:e.level===`error`?`danger`:e.level===`warn`?`warning`:`info`,children:e.level}),(0,K.jsx)(V,{size:`sm`,children:e.category})]}),(0,K.jsx)(`p`,{className:`text-sm text-gray-700 mt-1`,children:e.message}),(0,K.jsx)(`p`,{className:`text-xs text-gray-400 mt-1`,children:T(R(e.createdAt),`MM-dd HH:mm`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(V,{size:`sm`,variant:e.resolved?`success`:`warning`,children:e.resolved?`已解决`:`未解决`}),!e.resolved&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z,{variant:`secondary`,size:`sm`,onClick:()=>A.mutate(e.id),loading:A.isPending,children:`解决`}),(0,K.jsx)(z,{variant:`ghost`,size:`sm`,onClick:()=>q.mutate(e.id),loading:q.isPending,children:`忽略`})]})]})]},t)),m.qualityIssues.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 text-green-300`}),`暂无质量问题`]})]})}),(0,K.jsx)(U,{open:c.open,title:c.title,description:c.description,variant:`danger`,onConfirm:c.onConfirm,onCancel:()=>f({...c,open:!1})})]})}export{fe as default};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{gr as t}from"./vendor-DRGPi8ui.js";import{a as n,n as r,r as i}from"./vendor-query-DqPOMnuX.js";import{c as a}from"./vendor-flow-srkes8If.js";import{E as o,in as s,mt as c,pt as l,un as u,x as d}from"./client-BhcjNvkG.js";var f=e(t(),1),p=a();function m(){let e=n(),[t,a]=(0,f.useState)(`all`),[s,d]=(0,f.useState)(null),[m,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(!1),{data:b,isLoading:x}=i({queryKey:[`pipeline-templates`,t],queryFn:()=>c(t===`all`?void 0:{source:t})}),{data:S}=i({queryKey:[`pipeline-template`,s],queryFn:()=>l(s),enabled:!!s}),C=r({mutationFn:o,onSuccess:()=>{e.invalidateQueries({queryKey:[`pipeline-templates`]}),d(null),u(`模板已删除`,`success`)}}),w=b?.data.items||[],T=S?.data;return(0,p.jsxs)(`div`,{className:`p-6`,children:[(0,p.jsxs)(`div`,{className:`flex justify-between items-center mb-6`,children:[(0,p.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Pipeline 模板管理`}),(0,p.jsx)(`button`,{onClick:()=>_(!0),className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`创建模板`})]}),(0,p.jsx)(`div`,{className:`flex gap-2 mb-4`,children:[`all`,`builtin`,`user`,`convention`].map(e=>(0,p.jsx)(`button`,{onClick:()=>a(e),className:`px-3 py-1 rounded text-sm ${t===e?`bg-blue-600 text-white`:`bg-gray-100 text-gray-700 hover:bg-gray-200`}`,children:e===`all`?`全部`:e===`builtin`?`内置`:e===`user`?`用户`:`规范`},e))}),(0,p.jsxs)(`div`,{className:`flex gap-4`,children:[(0,p.jsx)(`div`,{className:`w-1/3 border rounded-lg overflow-hidden`,children:x?(0,p.jsx)(`div`,{className:`p-4 text-gray-500`,children:`加载中...`}):w.length===0?(0,p.jsx)(`div`,{className:`p-8 text-center text-gray-400`,children:`暂无模板`}):(0,p.jsx)(`ul`,{children:w.map(e=>(0,p.jsxs)(`li`,{onClick:()=>d(e.id),className:`p-3 cursor-pointer border-b hover:bg-gray-50 ${s===e.id?`bg-blue-50 border-l-2 border-l-blue-500`:``}`,children:[(0,p.jsx)(`div`,{className:`font-medium text-sm`,children:e.name}),(0,p.jsx)(`div`,{className:`text-xs text-gray-500 mt-1 truncate`,children:e.description}),(0,p.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,p.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.source===`builtin`?`bg-purple-100 text-purple-700`:e.source===`convention`?`bg-green-100 text-green-700`:`bg-blue-100 text-blue-700`}`,children:e.source===`builtin`?`内置`:e.source===`convention`?`规范`:`用户`}),e.version&&(0,p.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`v`,e.version]})]})]},e.id))})}),(0,p.jsx)(`div`,{className:`flex-1 border rounded-lg p-4`,children:T?(0,p.jsx)(h,{template:T,onEdit:()=>y(!0),onDelete:()=>{confirm(`确认删除模板「${T.name}」?`)&&C.mutate(T.id)}}):(0,p.jsx)(`div`,{className:`text-center text-gray-400 mt-8`,children:`选择一个模板查看详情`})})]}),m&&(0,p.jsx)(g,{onClose:()=>_(!1),onSaved:t=>{e.invalidateQueries({queryKey:[`pipeline-templates`]}),d(t),_(!1)}}),v&&T&&(0,p.jsx)(g,{template:T,onClose:()=>y(!1),onSaved:()=>{e.invalidateQueries({queryKey:[`pipeline-templates`]}),e.invalidateQueries({queryKey:[`pipeline-template`,s]}),y(!1)}})]})}function h({template:e,onEdit:t,onDelete:n}){return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex justify-between items-start mb-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.name}),(0,p.jsx)(`p`,{className:`text-sm text-gray-500 mt-1`,children:e.description})]}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(`button`,{onClick:t,className:`px-3 py-1 text-sm border rounded hover:bg-gray-50`,children:`编辑`}),e.source===`user`&&(0,p.jsx)(`button`,{onClick:n,className:`px-3 py-1 text-sm border border-red-300 text-red-600 rounded hover:bg-red-50`,children:`删除`})]})]}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm mb-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`text-gray-500`,children:`来源:`}),e.source]}),e.version&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`text-gray-500`,children:`版本:`}),`v`,e.version]}),e.conventionName&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`text-gray-500`,children:`规范:`}),e.conventionName]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`text-gray-500`,children:`节点数:`}),Array.isArray(e.nodes)?e.nodes.length:`-`]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`text-gray-500`,children:`创建时间:`}),new Date(e.createdAt).toLocaleString()]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`text-gray-500`,children:`更新时间:`}),new Date(e.updatedAt).toLocaleString()]})]}),(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-gray-700 mb-1`,children:`触发条件`}),(0,p.jsx)(`pre`,{className:`text-xs bg-gray-50 p-3 rounded overflow-auto max-h-32`,children:JSON.stringify(e.trigger,null,2)})]}),(0,p.jsxs)(`div`,{className:`mb-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-gray-700 mb-1`,children:`节点配置`}),(0,p.jsx)(`pre`,{className:`text-xs bg-gray-50 p-3 rounded overflow-auto max-h-48`,children:JSON.stringify(e.nodes,null,2)})]}),e.qualityStandards&&(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`div`,{className:`text-sm font-medium text-gray-700 mb-1`,children:`质量标准`}),(0,p.jsx)(`pre`,{className:`text-xs bg-gray-50 p-3 rounded overflow-auto max-h-32`,children:JSON.stringify(e.qualityStandards,null,2)})]})]})}function g({template:e,onClose:t,onSaved:n}){let[i,a]=(0,f.useState)(e?.name||``),[o,c]=(0,f.useState)(e?.description||``),[l,u]=(0,f.useState)(e?.version||``),[m,h]=(0,f.useState)(e?JSON.stringify(e.nodes,null,2):`[]`),[g,_]=(0,f.useState)(e?JSON.stringify(e.trigger,null,2):`{}`),[v,y]=(0,f.useState)(``),b=r({mutationFn:d,onSuccess:e=>n(e.data.id)}),x=r({mutationFn:({id:e,data:t})=>s(e,t),onSuccess:()=>n(e.id)}),S=()=>{if(y(``),!i.trim()||!o.trim()){y(`名称和描述必填`);return}let t,n;try{t=JSON.parse(m)}catch{y(`节点配置 JSON 格式错误`);return}try{n=JSON.parse(g)}catch{y(`触发条件 JSON 格式错误`);return}e?x.mutate({id:e.id,data:{name:i,description:o,version:l||void 0,nodes:t,trigger:n}}):b.mutate({name:i,description:o,source:`user`,trigger:n,nodes:t,version:l||void 0})},C=b.isPending||x.isPending;return(0,p.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,p.jsxs)(`div`,{className:`bg-white rounded-lg p-6 w-[600px] max-h-[80vh] overflow-y-auto`,children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:e?`编辑模板`:`创建模板`}),(0,p.jsxs)(`div`,{className:`space-y-3`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium mb-1`,children:`名称 *`}),(0,p.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),className:`w-full border rounded px-3 py-2 text-sm`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium mb-1`,children:`描述 *`}),(0,p.jsx)(`textarea`,{value:o,onChange:e=>c(e.target.value),rows:2,className:`w-full border rounded px-3 py-2 text-sm`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium mb-1`,children:`版本`}),(0,p.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`1.0.0`,className:`w-full border rounded px-3 py-2 text-sm`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium mb-1`,children:`触发条件(JSON)*`}),(0,p.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),rows:4,className:`w-full border rounded px-3 py-2 text-xs font-mono`})]}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-sm font-medium mb-1`,children:`节点配置(JSON)*`}),(0,p.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),rows:6,className:`w-full border rounded px-3 py-2 text-xs font-mono`})]})]}),v&&(0,p.jsx)(`p`,{className:`text-red-500 text-sm mt-2`,children:v}),(0,p.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,p.jsx)(`button`,{onClick:t,className:`px-4 py-2 text-sm border rounded hover:bg-gray-50`,children:`取消`}),(0,p.jsx)(`button`,{onClick:S,disabled:C,className:`px-4 py-2 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50`,children:C?`保存中...`:`保存`})]})]})})}export{m as default};
@@ -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 ee}from"./vendor-react-DJI9oneq.js";import{a as _,n as v,r as y}from"./vendor-query-DqPOMnuX.js";import{c as b}from"./vendor-flow-srkes8If.js";import{_ as te,ft as x,g as ne,ht as S,i as re,o as ie,ot as C,t as ae}from"./client-BhcjNvkG.js";import{a as w,l as T,n as E,r as D,t as O}from"./ui-CDL3BZ13.js";import{n as k,t as A}from"./vendor-motion-CQmdgnI8.js";import{t as oe}from"./useDebounce-DNfPs3Tv.js";import{t as se}from"./ErrorState-DXHA8lr8.js";import{t as ce}from"./exportCsv-CSExJI8h.js";import{t as j}from"./ConfirmDialog-CVzB7X5y.js";import{t as le}from"./useSmartPolling-DYAVOihL.js";import{n as ue,t as de}from"./Skeleton-B7PVDJJ_.js";import{t as fe}from"./Pagination-lp8b_3NR.js";import{t as pe}from"./BatchProgress-BQ533tSf.js";var M=e(p(),1),N=b(),P={pending:{label:`待执行`,color:`text-gray-400`,icon:(0,N.jsx)(i,{className:`w-4 h-4`})},in_progress:{label:`执行中`,color:`text-blue-500`,icon:(0,N.jsx)(f,{className:`w-4 h-4 animate-spin`})},retrying:{label:`重试中`,color:`text-yellow-500`,icon:(0,N.jsx)(h,{className:`w-4 h-4 animate-spin`})},blocked:{label:`已阻塞`,color:`text-red-500`,icon:(0,N.jsx)(m,{className:`w-4 h-4`})},done:{label:`已完成`,color:`text-green-500`,icon:(0,N.jsx)(l,{className:`w-4 h-4`})},failed:{label:`失败`,color:`text-red-500`,icon:(0,N.jsx)(m,{className:`w-4 h-4`})},skipped:{label:`已跳过`,color:`text-gray-400`,icon:(0,N.jsx)(t,{className:`w-4 h-4`})}};function F({node:e}){let[t,n]=(0,M.useState)(!1),r=P[e.status],{data:i,isLoading:a}=y({queryKey:[`node-attempts`,e.node_id],queryFn:()=>C(e.node_id).then(e=>e.data),enabled:t});return(0,N.jsxs)(`div`,{className:`border border-gray-700 rounded-lg overflow-hidden`,children:[(0,N.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,N.jsx)(`span`,{className:w(`flex-shrink-0`,r.color),children:r.icon}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`text-sm font-medium text-gray-100 truncate`,children:e.title}),(0,N.jsx)(O,{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,N.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[e.attempt_count,` 次尝试`]})]}),(0,N.jsxs)(`div`,{className:`text-xs text-gray-500 mt-0.5`,children:[`阶段: `,e.phase,` · 超时: `,e.timeout_sec,`s`]})]}),(0,N.jsx)(`span`,{className:`text-gray-500 flex-shrink-0`,children:t?(0,N.jsx)(d,{className:`w-4 h-4`}):(0,N.jsx)(o,{className:`w-4 h-4`})})]}),(0,N.jsx)(k,{children:t&&(0,N.jsx)(A.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:`overflow-hidden`,children:(0,N.jsx)(`div`,{className:`px-4 pb-4 pt-2 border-t border-gray-700 bg-gray-900/50`,children:a?(0,N.jsx)(`div`,{className:`text-sm text-gray-500 py-2`,children:`加载执行记录...`}):i?.items.length===0?(0,N.jsx)(`div`,{className:`text-sm text-gray-500 py-2`,children:`暂无执行记录`}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-400 mb-2`,children:`执行记录`}),i?.items.map(e=>(0,N.jsxs)(`div`,{className:w(`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,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`span`,{className:`font-medium text-gray-300`,children:[`第 `,e.attempt_number,` 次 · 策略: `,e.strategy_id]}),(0,N.jsx)(`span`,{className:w(`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,N.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,N.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,N.jsx)(`div`,{className:`text-gray-400`,children:e.verification_result.diagnostics}),e.verification_result.missing_items.length>0&&(0,N.jsx)(`ul`,{className:`text-red-400 space-y-0.5 pl-3`,children:e.verification_result.missing_items.map((e,t)=>(0,N.jsxs)(`li`,{children:[`· `,e]},t))})]})]},e.attempt_id))]})})})})]})}function I({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,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,N.jsxs)(`span`,{className:`text-gray-400`,children:[`进度: `,n,`/`,t,` 节点完成`]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[i>0&&(0,N.jsxs)(`span`,{className:`text-yellow-400`,children:[i,` 重试中`]}),r>0&&(0,N.jsxs)(`span`,{className:`text-red-400`,children:[r,` 已阻塞`]}),(0,N.jsxs)(`span`,{className:`text-gray-400`,children:[a,`%`]})]})]}),(0,N.jsx)(`div`,{className:`h-2 bg-gray-700 rounded-full overflow-hidden`,children:(0,N.jsx)(`div`,{className:w(`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 me({projectPath:e}){let{data:t,isLoading:n,isError:r}=y({queryKey:[`plan`,`by-project`,e],queryFn:()=>x(e).then(e=>e.data),refetchInterval:5e3});if(n)return(0,N.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,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,N.jsx)(`span`,{className:`text-sm font-medium text-gray-200 truncate`,children:t.goal}),(0,N.jsx)(O,{variant:i.color,children:i.label})]}),(0,N.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[`模板: `,t.template_id,` · 创建: `,g(new Date(t.created_at),`MM-dd HH:mm`)]})]})}),(0,N.jsx)(I,{nodes:t.nodes}),(0,N.jsx)(`div`,{className:`space-y-2`,children:t.nodes.map(e=>(0,N.jsx)(F,{node:e},e.node_id))})]})}function he({open:e,planId:r,templateName:o,goal:s,nodes:c,onApprove:u,onReject:d,onClose:f,loading:p=!1}){let[m,h]=(0,M.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,N.jsx)(k,{children:(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,N.jsxs)(A.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,N.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-gray-200`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900`,children:`确认执行计划`}),(0,N.jsxs)(`p`,{className:`text-sm text-gray-500 mt-1`,children:[`模板:`,o]})]}),(0,N.jsx)(`button`,{onClick:f,className:`text-gray-400 hover:text-gray-600 transition-colors`,children:(0,N.jsx)(a,{className:`h-5 w-5`})})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 mb-2`,children:`目标`}),(0,N.jsx)(`p`,{className:`text-gray-900`,children:s})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`h3`,{className:`text-sm font-medium text-gray-700 mb-3`,children:[`执行节点(共 `,c.length,` 个)`]}),(0,N.jsx)(`div`,{className:`space-y-2`,children:c.map((e,r)=>(0,N.jsxs)(`div`,{className:`border border-gray-200 rounded-lg overflow-hidden`,children:[(0,N.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,N.jsxs)(`div`,{className:`flex items-center gap-3 flex-1`,children:[(0,N.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,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`div`,{className:`font-medium text-gray-900`,children:e.title}),(0,N.jsxs)(`div`,{className:`text-sm text-gray-500 flex items-center gap-2 mt-1`,children:[(0,N.jsx)(`span`,{className:`px-2 py-0.5 bg-gray-100 rounded text-xs`,children:e.phase}),(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(l,{className:`h-3 w-3`}),e.completion_rules.length,` 条完成规则`]}),e.dependencies&&e.dependencies.length>0&&(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(n,{className:`h-3 w-3`}),`依赖 `,e.dependencies.length,` 个节点`]})]})]})]}),(0,N.jsx)(A.div,{animate:{rotate:m.has(e.node_id)?180:0},transition:{duration:.2},children:(0,N.jsx)(`svg`,{className:`h-5 w-5 text-gray-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,N.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})})]}),(0,N.jsx)(k,{children:m.has(e.node_id)&&(0,N.jsx)(A.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,N.jsx)(`div`,{className:`p-4 space-y-3`,children:(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h4`,{className:`text-xs font-medium text-gray-700 mb-2`,children:`完成条件`}),(0,N.jsx)(`div`,{className:`space-y-1.5`,children:e.completion_rules.map((e,n)=>(0,N.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[e.required?(0,N.jsx)(t,{className:`h-4 w-4 text-orange-500 flex-shrink-0 mt-0.5`}):(0,N.jsx)(i,{className:`h-4 w-4 text-gray-400 flex-shrink-0 mt-0.5`}),(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`span`,{className:`text-gray-700`,children:e.description}),(0,N.jsxs)(`span`,{className:`ml-2 text-xs text-gray-500`,children:[`(`,e.type===`artifact`?`文件检查`:e.type===`command`?`命令执行`:`人工确认`,`)`]})]})]},n))})]})})})})]},e.node_id))})]}),(0,N.jsxs)(`div`,{className:`flex items-start gap-3 p-4 bg-yellow-50 border border-yellow-200 rounded-lg`,children:[(0,N.jsx)(t,{className:`h-5 w-5 text-yellow-600 flex-shrink-0 mt-0.5`}),(0,N.jsxs)(`div`,{className:`text-sm text-yellow-800`,children:[(0,N.jsx)(`p`,{className:`font-medium mb-1`,children:`确认后将开始执行`}),(0,N.jsx)(`p`,{children:`系统将按照节点顺序自动执行,每个节点完成后会自动推进到下一个节点。`})]})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-3 p-6 border-t border-gray-200 bg-gray-50`,children:[(0,N.jsx)(E,{variant:`secondary`,onClick:d,disabled:p,children:`拒绝`}),(0,N.jsx)(E,{variant:`primary`,onClick:u,loading:p,icon:l,children:`确认执行`})]})]})})}):null}function L(){let e=_(),t=ee(),[o,l]=(0,M.useState)(``),d=oe(o),[f,p]=(0,M.useState)(``),[m,b]=(0,M.useState)(`all`),[x,C]=(0,M.useState)(1),[w,k]=(0,M.useState)(20),[P,F]=(0,M.useState)(new Set),[I,L]=(0,M.useState)(``),[R,z]=(0,M.useState)(null),[B,V]=(0,M.useState)({open:!1,title:``,description:``,onConfirm:()=>{}}),{data:H,isLoading:ge,isError:_e,refetch:U}=y({queryKey:[`pipelines`,`active`],queryFn:()=>S({status:`active`,page_size:100}).then(e=>e.data),refetchInterval:le((H?.total??0)>0)}),{data:W,refetch:ve}=y({queryKey:[`pipelines`,`completed`,d,f,x,w],queryFn:()=>S({status:`completed`,search:d||void 0,complexity:f||void 0,page:x,page_size:w}).then(e=>e.data)}),G=v({mutationFn:e=>te(e),onSuccess:()=>e.invalidateQueries({queryKey:[`pipelines`]})}),K=v({mutationFn:()=>ne(),onSuccess:()=>e.invalidateQueries({queryKey:[`pipelines`]})}),q=v({mutationFn:e=>ie(e),onSuccess:t=>{e.invalidateQueries({queryKey:[`pipelines`]}),F(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=v({mutationFn:e=>re(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`pipelines`]}),z(null)}}),Y=v({mutationFn:e=>ae(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`pipelines`]}),z(null)}});if(ge)return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsx)(de,{rows:2}),(0,N.jsx)(ue,{count:5})]});if(_e)return(0,N.jsx)(se,{message:`Pipeline 数据加载失败`,onRetry:()=>U()});let X=H?.items||[],Z=W?.items||[],Q=W?.total||0,$=X.filter(e=>!I||e.requirement.toLowerCase().includes(I.toLowerCase())||e.project.toLowerCase().includes(I.toLowerCase())),ye=m===`all`||m===`active`,be=m===`all`||m===`completed`,xe=Math.ceil(Q/w);return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,N.jsxs)(`span`,{className:`text-sm text-gray-500`,children:[X.length,` 个活跃 · `,Q,` 个已完成`,P.size>0&&` · 已选 ${P.size} 个`]}),(0,N.jsxs)(`select`,{value:m,onChange:e=>{b(e.target.value),C(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,N.jsx)(`option`,{value:`all`,children:`全部状态`}),(0,N.jsx)(`option`,{value:`active`,children:`仅活跃`}),(0,N.jsx)(`option`,{value:`completed`,children:`仅已完成`})]})]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[$.length>0&&P.size>0&&(0,N.jsxs)(E,{variant:`danger`,size:`sm`,icon:a,onClick:()=>{P.size!==0&&V({open:!0,title:`批量关闭 Pipeline`,description:`确认关闭选中的 ${P.size} 个 Pipeline?`,count:P.size,onConfirm:()=>{q.mutate(Array.from(P)),V(e=>({...e,open:!1}))}})},loading:q.isPending,children:[`批量关闭 (`,P.size,`)`]}),$.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(E,{variant:`secondary`,size:`sm`,onClick:()=>{P.size===$.length?F(new Set):F(new Set($.map(e=>e.id)))},children:P.size===$.length?`取消全选`:`全选`}),(0,N.jsx)(E,{variant:`danger`,size:`sm`,icon:c,onClick:()=>{V({open:!0,title:`清理过期 Pipeline`,description:`确认关闭所有过期 Pipeline?`,onConfirm:()=>{K.mutate(),V(e=>({...e,open:!1}))}})},loading:K.isPending,children:`清理过期`})]}),(0,N.jsx)(E,{variant:`secondary`,size:`sm`,icon:h,onClick:()=>U(),children:`刷新`}),(0,N.jsx)(E,{variant:`secondary`,size:`sm`,icon:s,onClick:()=>{let e=[...X,...Z];ce(`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,N.jsx)(pe,{total:P.size,done:0,label:`批量关闭中`}),ye&&X.length>0&&(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,N.jsxs)(`h3`,{className:`text-sm font-semibold text-gray-500 uppercase tracking-wider`,children:[`活跃中 (`,$.length,`/`,X.length,`)`]}),(0,N.jsxs)(`div`,{className:`relative w-64`,children:[(0,N.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,N.jsx)(`input`,{type:`text`,placeholder:`搜索活跃 Pipeline...`,value:I,onChange:e=>L(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,N.jsx)(`div`,{className:`space-y-3`,children:$.map((e,r)=>(0,N.jsx)(A.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.05},children:(0,N.jsxs)(D,{className:`!p-0 overflow-hidden cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>t(`/pipelines/${e.id}`),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between p-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:P.has(e.id),onChange:t=>{t.stopPropagation(),F(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,N.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg`,style:{backgroundColor:`#10b98120`},children:(0,N.jsx)(n,{className:`h-5 w-5`,style:{color:`#10b981`}})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{className:`font-medium text-gray-900 truncate`,children:e.requirement}),(0,N.jsxs)(`div`,{className:`text-sm text-gray-500 flex items-center gap-3 mt-1`,children:[(0,N.jsx)(O,{variant:`primary`,size:`sm`,children:`动态`}),(0,N.jsx)(`span`,{children:e.project}),(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(i,{className:`h-3 w-3`}),g(T(e.createdAt),`MM-dd HH:mm`)]})]}),e.type===`dynamic`&&e.nodeConfig&&(0,N.jsxs)(`div`,{className:`mt-2 flex items-center gap-3 text-xs text-gray-600`,children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(n,{className:`h-3 w-3`}),e.nodeConfig.totalNodes,` 个节点`]}),e.nodeConfig.boundSkills.length>0&&(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`⚡ `,e.nodeConfig.boundSkills.length,` 个技能`]}),(0,N.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,N.jsx)(E,{variant:`danger`,size:`sm`,icon:a,onClick:t=>{t.stopPropagation(),V({open:!0,title:`关闭 Pipeline`,description:`确认关闭此 Pipeline?`,onConfirm:()=>{G.mutate(e.id),V(e=>({...e,open:!1}))}})},loading:G.isPending,children:`关闭`})]}),(0,N.jsx)(`div`,{className:`border-t border-gray-100`,children:(0,N.jsx)(me,{projectPath:e.project})})]})},e.id))})]}),be&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold text-gray-500 uppercase tracking-wider mb-3`,children:`历史记录`}),(0,N.jsxs)(D,{children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center mb-4 pb-4 border-b border-gray-100`,children:[(0,N.jsxs)(`div`,{className:`relative flex-1 min-w-[240px] max-w-sm`,children:[(0,N.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,N.jsx)(`input`,{type:`text`,placeholder:`搜索需求描述...`,value:o,onChange:e=>{l(e.target.value),C(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,N.jsxs)(`select`,{value:f,onChange:e=>{p(e.target.value),C(1)},className:`px-3 py-2 border border-gray-200 rounded-lg text-sm`,children:[(0,N.jsx)(`option`,{value:``,children:`全部复杂度`}),(0,N.jsx)(`option`,{value:`simple`,children:`简单`}),(0,N.jsx)(`option`,{value:`moderate`,children:`中等`}),(0,N.jsx)(`option`,{value:`complex`,children:`复杂`})]})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto`,children:(0,N.jsxs)(`table`,{className:`w-full`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`text-left text-sm text-gray-600`,children:[(0,N.jsx)(`th`,{className:`pb-3 font-medium`,children:`需求`}),(0,N.jsx)(`th`,{className:`pb-3 font-medium`,children:`项目`}),(0,N.jsx)(`th`,{className:`pb-3 font-medium`,children:`类型`}),(0,N.jsx)(`th`,{className:`pb-3 font-medium`,children:`复杂度`}),(0,N.jsx)(`th`,{className:`pb-3 font-medium`,children:`时间`}),(0,N.jsx)(`th`,{className:`pb-3 font-medium`,children:`操作`})]})}),(0,N.jsx)(`tbody`,{className:`text-sm`,children:Z.map(e=>(0,N.jsxs)(`tr`,{className:`border-t border-gray-50 hover:bg-gray-50 cursor-pointer`,onClick:()=>t(`/pipelines/${e.id}`),children:[(0,N.jsx)(`td`,{className:`py-3 max-w-xs truncate`,children:e.requirement}),(0,N.jsx)(`td`,{className:`py-3`,children:e.project}),(0,N.jsx)(`td`,{className:`py-3`,children:(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(O,{size:`sm`,variant:`primary`,children:`动态编排`}),e.nodeConfig&&(0,N.jsxs)(`div`,{className:`text-xs text-gray-500 space-y-0.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(n,{className:`h-3 w-3`}),e.nodeConfig.totalNodes,` 节点`,e.nodeConfig.boundSkills.length>0&&(0,N.jsxs)(`span`,{className:`ml-1`,children:[`· ⚡ `,e.nodeConfig.boundSkills.length,` 技能`]})]}),(0,N.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,N.jsx)(`td`,{className:`py-3`,children:(0,N.jsx)(O,{size:`sm`,variant:e.complexity===`complex`?`danger`:e.complexity===`moderate`?`warning`:`default`,children:e.complexity||`-`})}),(0,N.jsx)(`td`,{className:`py-3 text-gray-500`,children:g(T(e.createdAt),`MM-dd HH:mm`)}),(0,N.jsx)(`td`,{className:`py-3`,children:(0,N.jsx)(E,{variant:`ghost`,size:`sm`,icon:r,onClick:n=>{n.stopPropagation(),t(`/pipelines/${e.id}`)},children:`查看`})})]},e.id))})]})}),Q===0&&(0,N.jsx)(`div`,{className:`text-center py-12 text-gray-400`,children:`暂无历史记录`}),Q>0&&(0,N.jsx)(fe,{currentPage:x,totalPages:xe,onPageChange:C,pageSize:w,onPageSizeChange:e=>{k(e),C(1)},totalItems:Q})]})]}),R&&(0,N.jsx)(he,{open:!0,planId:R,templateName:`待确认计划`,goal:`执行计划`,nodes:[],onApprove:()=>J.mutate(R),onReject:()=>Y.mutate(R),onClose:()=>z(null),loading:J.isPending||Y.isPending}),(0,N.jsx)(j,{open:B.open,title:B.title,description:B.description,count:B.count,variant:`danger`,onConfirm:B.onConfirm,onCancel:()=>V({...B,open:!1})})]})}export{L 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,un as P,vt as F,z as _e}from"./client-BhcjNvkG.js";import{a as ve,c as ye,l as I,n as L,r as R,t as z}from"./ui-CDL3BZ13.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)(z,{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)(z,{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),[F,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),P(`上下文已复制,请粘贴到 Claude Code 进行修复`,`success`),setTimeout(()=>U(null),3e3)}catch{P(`复制失败`,`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=>P(e.message||`删除失败`,`error`)}),je=T({mutationFn:e=>he(W,e),onSuccess:()=>{f.invalidateQueries({queryKey:[`claudemd`,e]}),D(!1)},onError:e=>P(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)(L,{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)(L,{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)(R,{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)(L,{variant:`ghost`,size:`sm`,onClick:()=>{g(!1),S(``)},children:`取消`}),(0,V.jsx)(L,{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)(R,{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)(R,{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)(R,{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)(R,{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)(R,{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)(R,{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/F),(0,V.jsxs)(V.Fragment,{children:[e.slice((M-1)*F,M*F).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)(z,{size:`sm`,className:ye(e.status),children:e.status})}),(0,V.jsx)(`td`,{className:`py-3 text-gray-500`,children:x(I(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/F);return e.length>F?(0,V.jsx)(`div`,{className:`mt-4`,children:(0,V.jsx)(be,{currentPage:M,totalPages:t,onPageChange:N,pageSize:F,onPageSizeChange:e=>{Se(e),N(1)},totalItems:e.length})}):null})()]}),p===`pipelines`&&(0,V.jsx)(R,{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)(z,{size:`sm`,children:e.phase})}),(0,V.jsx)(`td`,{className:`py-3 text-gray-500`,children:x(I(e.updated_at),`MM-dd HH:mm`)})]},e.id))})]})})}),p===`quality`&&(0,V.jsxs)(R,{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)(z,{size:`sm`,variant:e.resolved?`success`:`default`,children:e.resolved?`已解决`:`未解决`})}),(0,V.jsx)(`td`,{className:`py-3 text-gray-500`,children:x(I(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)(R,{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)(z,{size:`sm`,children:e.node_type}),(0,V.jsxs)(`span`,{children:[`更新于 `,x(I(e.updated_at),`MM-dd HH:mm`)]})]})]})]})},e.id))})}),p===`rules`&&(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(R,{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)(z,{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)(R,{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)(z,{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)(R,{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)(L,{variant:`ghost`,size:`sm`,icon:ie,onClick:()=>f.invalidateQueries({queryKey:[`claudemd`,e]}),children:`刷新`}),K?.exists&&(0,V.jsx)(L,{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)(L,{size:`sm`,icon:te,onClick:()=>{k(K.content||``),D(!0)},children:`编辑`})]})]})}),A&&(0,V.jsx)(R,{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)(L,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>j(null)})]})}),w&&(0,V.jsxs)(R,{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)(L,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>D(!1),children:`取消`}),(0,V.jsx)(L,{size:`sm`,icon:C,onClick:()=>je.mutate(O),children:`保存`})]})]}),!w&&K?.exists&&(0,V.jsx)(R,{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)(R,{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)(z,{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)(R,{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)(L,{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)(L,{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)(L,{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)(R,{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)(L,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>Z(null)})]})}),Q&&(0,V.jsx)(R,{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)(L,{variant:`ghost`,size:`sm`,icon:s,onClick:()=>$(null)})]})}),J&&!(`error`in J)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(R,{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)(R,{title:`检测到的语言`,children:(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:J.languages.map((e,t)=>(0,V.jsxs)(z,{size:`sm`,children:[e.name,e.version?` ${e.version}`:``]},t))})}),J.frameworks.length>0&&(0,V.jsx)(R,{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)(R,{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)(R,{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)(R,{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:()=>F(e).then(e=>e.data),enabled:l}),h=T({mutationFn:t=>N(e,t).then(e=>e.data),onSuccess:t=>{P(`已绑定:${t.convention.name}`,`success`),a(!1),d.invalidateQueries({queryKey:[`project-conventions`,e]})}}),re=T({mutationFn:t=>k(e,t).then(e=>e.data),onSuccess:()=>{P(`已解绑`,`success`),d.invalidateQueries({queryKey:[`project-conventions`,e]})}}),g=T({mutationFn:()=>A(e).then(e=>e.data),onSuccess:t=>{P(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:()=>{P(`保存成功`,`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 se,r as m}from"./vendor-query-DqPOMnuX.js";import{c as h}from"./vendor-flow-srkes8If.js";import{D as g,r as _,un as v,yt as ce}from"./client-BhcjNvkG.js";import{a as y,l as b,r as x,t as S}from"./ui-CDL3BZ13.js";import{t as C}from"./vendor-motion-CQmdgnI8.js";import{t as w}from"./exportCsv-CSExJI8h.js";import{t as T}from"./Pagination-lp8b_3NR.js";var E=e(u(),1),D=h();function O(){let e=p(),u=oe(),[h,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}=m({queryKey:[`project-meta-all`],queryFn:()=>_.get(`/projects/meta/all`).then(e=>e.data),staleTime:3e4}),X=fe||{},Z=se({mutationFn:({projectPath:e,meta:t})=>_.put(`/projects/${encodeURIComponent(e)}/meta`,t),onSuccess:()=>{u.invalidateQueries({queryKey:[`project-meta-all`]})},onError:e=>v(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}})}v(`已归档 ${U.size} 个项目`,`success`),W(new Set)},_e=async()=>{Y(!0);let e=0;for(let t of U)try{await g(encodeURIComponent(t)),e++}catch{}Y(!1),G(!1),q(``),W(new Set),u.invalidateQueries({queryKey:[`projects`]}),v(`已删除 ${e} 个项目`,`success`)},{data:ve,isLoading:ye}=m({queryKey:[`projects`],queryFn:()=>ce({limit:1e3}).then(e=>e.data),refetchInterval:3e4});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(!h)return!0;let t=h.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)(S,{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)(S,{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)(x,{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:h,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)(C.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:o*.03},children:(0,D.jsx)(x,{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(b(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 ae,nr as oe,qn as d,s as f,tr as p,vn as se}from"./vendor-DRGPi8ui.js";import{a as ce,n as m,r as h}from"./vendor-query-DqPOMnuX.js";import{c as g}from"./vendor-flow-srkes8If.js";import{Ht as le,Ut as ue,bt as de,f as fe,j as pe,jt as me,u as he,un as _,xt as v}from"./client-BhcjNvkG.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 ge}from"./useDebounce-DNfPs3Tv.js";import{t as _e}from"./ErrorState-DXHA8lr8.js";import{t as ve}from"./exportCsv-CSExJI8h.js";import{t as ye}from"./ConfirmDialog-CVzB7X5y.js";import{t as be}from"./Pagination-lp8b_3NR.js";var E=e(ae(),1),D=g(),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:d,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=ce(),[n,r]=(0,E.useState)(``),o=ge(n),[s,ne]=(0,E.useState)(``),[l,ae]=(0,E.useState)(``),[d,g]=(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}=h({queryKey:[`quality-unresolved`],queryFn:()=>me().then(e=>e.data),refetchInterval:1e4}),{data:ke}=h({queryKey:[`quality-history`,s,l,d,M,o],queryFn:()=>v({limit:500,level:s||void 0,category:l||void 0,resolved:d===`resolved`?!0:d===`unresolved`?!1:void 0,project_path:M||void 0,search:o||void 0}).then(e=>e.data)}),{data:q}=h({queryKey:[`quality-history`,`all`],queryFn:()=>v({limit:500}).then(e=>e.data)}),J=m({mutationFn:e=>ue(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]})}}),Y=m({mutationFn:e=>pe(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]})}}),Ae=m({mutationFn:()=>le(),onSuccess:()=>{e.invalidateQueries({queryKey:[`quality-unresolved`]}),e.invalidateQueries({queryKey:[`quality-history`]})}}),je=m({mutationFn:e=>he(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=m({mutationFn:e=>fe(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 de(e);await navigator.clipboard.writeText(t.data.context),B(e),_(`上下文已复制,请粘贴到 Claude Code 进行修复`,`success`),setTimeout(()=>B(null),3e3)}catch{_(`复制失败`,`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,d,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?f(b(e.created_at),`yyyy-MM-dd HH:mm:ss`):``]);ve(`quality-issues-${f(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:p,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:p,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)(se,{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=>{ae(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:d,onChange:e=>{g(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?f(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?f(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:f(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)?oe:i,onClick:t=>{t.stopPropagation(),Ne(String(e.id))},children:z===String(e.id)?`已复制`:`复制上下文`}),(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:p,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?f(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?f(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:f(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)?oe:i,onClick:t=>{t.stopPropagation(),Ne(String(e.id))},children:z===String(e.id)?`已复制`:`复制上下文`}),(0,D.jsx)(x,{variant:`ghost`,size:`sm`,icon:p,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};
@@ -0,0 +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-BhcjNvkG.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};