lantern-harness 0.1.29 → 0.1.32

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 (105) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/{Base.BbqRC8BF.css → Base.9LLJ6KVG.css} +1 -1
  4. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.4j--gBo-.js +2 -0
  5. package/dist/_astro/CaseExecBoard.CTuf_Nom.js +1 -0
  6. package/dist/_astro/CaseGenerateApp.18SE0dLJ.js +10 -0
  7. package/dist/_astro/CasesLibrary.C-T3VrPa.js +24 -0
  8. package/dist/_astro/ChatApp.BpFXgd8K.js +226 -0
  9. package/dist/_astro/{DashboardBoard.DAUPgVh3.js → DashboardBoard.B5Qo5Y3e.js} +2 -2
  10. package/dist/_astro/DocsFileBrowser.DnxVsmed.js +1 -0
  11. package/dist/_astro/DocsPager.CnXEnQqa.js +1 -0
  12. package/dist/_astro/{KnowledgeLibrary.DKci9jN8.js → KnowledgeLibrary.DARUegK8.js} +1 -1
  13. package/dist/_astro/{NavLibraries.BybmHnXn.js → NavLibraries.FAj9zUuq.js} +1 -1
  14. package/dist/_astro/PluginsPage.DKPA2zw8.js +1 -0
  15. package/dist/_astro/{PluginsPage.CYqe0xYq.js → PluginsPage.F0oMYJri.js} +2 -2
  16. package/dist/_astro/{PmBugsBoard.DVhrHxD2.js → PmBugsBoard.uNPzbw-N.js} +1 -1
  17. package/dist/_astro/{PmIterationsBoard.BQPHdbpp.js → PmIterationsBoard.CjR8L71i.js} +1 -1
  18. package/dist/_astro/{PmProjectDetail.DZmqbZLO.js → PmProjectDetail.Cpug99Lt.js} +1 -1
  19. package/dist/_astro/{PmProjectsBoard.tk8cI-lO.js → PmProjectsBoard.VLqrwucj.js} +1 -1
  20. package/dist/_astro/PmRequirementsBoard.B5ypu68O.js +1 -0
  21. package/dist/_astro/PmRequirementsBoard.CdP4gEzq.js +1 -0
  22. package/dist/_astro/{PmShared.DRYCFoRc.js → PmShared.ChKKU3Ww.js} +1 -1
  23. package/dist/_astro/PromptsLibrary.BlWPVm1Z.js +1 -0
  24. package/dist/_astro/{ReportsPage.B7MOskzc.js → ReportsPage.iSM5TWMq.js} +1 -1
  25. package/dist/_astro/ReqAnalysisBoard.CeQbq7Qh.js +39 -0
  26. package/dist/_astro/{RequirementsLibrary._OviMClB.js → RequirementsLibrary.X89V8-QF.js} +1 -1
  27. package/dist/_astro/{SettingsDialog.F2HdD5v4.js → SettingsDialog.BlokCWBn.js} +1 -1
  28. package/dist/_astro/{SpaceSwitcher.DQOG363O.js → SpaceSwitcher.MmSkP3wb.js} +1 -1
  29. package/dist/_astro/TagSelect.UUXgkMqJ.js +1 -0
  30. package/dist/_astro/TasksBoard.Z8rBCO1F.js +1 -0
  31. package/dist/_astro/{TemplatesLibrary.CEVQPDDz.js → TemplatesLibrary.DBHSAPQ0.js} +1 -1
  32. package/dist/_astro/TestStatsBoard.BtqoPuLc.js +1 -0
  33. package/dist/_astro/TodosBoard.ETI63YgA.js +1 -0
  34. package/dist/_astro/{UiAutoBoard.DegcBc_3.js → UiAutoBoard.DxrlgvI7.js} +1 -1
  35. package/dist/_astro/app-config.Bg6v8zQQ.js +1 -0
  36. package/dist/_astro/app-version.CLOjRiPN.js +1 -0
  37. package/dist/_astro/{bash-tools.D4DBYc9k.js → bash-tools.cciCC33C.js} +1 -1
  38. package/dist/_astro/case-exec.BLqTXR7U.js +1 -0
  39. package/dist/_astro/case-gen-run.BNNfA12U.js +22 -0
  40. package/dist/_astro/{case-review.DlCarphW.js → case-review.s1w_mD4l.js} +1 -1
  41. package/dist/_astro/{case-types.B6MLX3iE.js → case-types.CJ5PHz59.js} +1 -1
  42. package/dist/_astro/{hydrate-cache.C0F0L04c.js → hydrate-cache.B7--LFB_.js} +1 -1
  43. package/dist/_astro/{i18n.ele1lM9e.js → i18n.CH6ZNsHf.js} +1 -1
  44. package/dist/_astro/{open-docs-in-session.D608wzlx.js → open-docs-in-session.DQ2_5fkC.js} +1 -1
  45. package/dist/_astro/plugins.SqANn3ZB.js +1 -0
  46. package/dist/_astro/req-analysis.Dbe_gqPz.js +24 -0
  47. package/dist/_astro/{settings.DbhUT6Ao.js → settings.Cu00if4D.js} +2 -2
  48. package/dist/_astro/spaces-client.Czm-VPh5.js +1 -0
  49. package/dist/_astro/{story-review.SqNsPiZE.js → story-review.CNZnYMvW.js} +2 -2
  50. package/dist/_astro/test-stats.Cf3_L4wu.js +1 -0
  51. package/dist/_astro/{view-prefs.DkS1ldnh.js → view-prefs.SdItxolG.js} +1 -1
  52. package/dist/case-exec/index.html +5 -5
  53. package/dist/cases/generate/index.html +5 -5
  54. package/dist/cases/library/index.html +5 -5
  55. package/dist/dashboard/index.html +5 -5
  56. package/dist/docs/changelog/index.html +88 -35
  57. package/dist/docs/install/index.html +4 -4
  58. package/dist/docs/manual/index.html +44 -16
  59. package/dist/knowledge/index.html +5 -5
  60. package/dist/plugins/index.html +5 -5
  61. package/dist/pm/bugs/index.html +5 -5
  62. package/dist/pm/iterations/index.html +5 -5
  63. package/dist/pm/projects/detail/index.html +5 -5
  64. package/dist/pm/projects/index.html +5 -5
  65. package/dist/pm/requirements/index.html +5 -5
  66. package/dist/prompts/index.html +5 -5
  67. package/dist/reports/index.html +5 -5
  68. package/dist/requirement-analysis/index.html +5 -5
  69. package/dist/requirements/index.html +5 -5
  70. package/dist/tasks/index.html +5 -5
  71. package/dist/templates/index.html +5 -5
  72. package/dist/test-automation/index.html +5 -5
  73. package/dist/test-stats/index.html +5 -5
  74. package/dist/todos/index.html +5 -5
  75. package/dist/workbench/index.html +5 -5
  76. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +36 -12
  77. package/lh-plugins/lh-case-review.mjs +159 -0
  78. package/lh-plugins/lh-config.mjs +9 -0
  79. package/lh-plugins/lh-req-analysis.mjs +66 -6
  80. package/lh-plugins/lh-stats.mjs +308 -16
  81. package/package.json +1 -1
  82. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.C_hJAznE.js +0 -2
  83. package/dist/_astro/CaseExecBoard.cl2Od7av.js +0 -1
  84. package/dist/_astro/CaseGenerateApp.nE3RR7bV.js +0 -10
  85. package/dist/_astro/CasesLibrary.BkQY421S.js +0 -21
  86. package/dist/_astro/ChatApp.BULN48Ml.js +0 -226
  87. package/dist/_astro/DocsFileBrowser.BdpWp8zQ.js +0 -1
  88. package/dist/_astro/DocsPager.D55FTK9d.js +0 -1
  89. package/dist/_astro/PluginsPage.DiPg_D8e.js +0 -1
  90. package/dist/_astro/PmRequirementsBoard.BjC9CEFr.js +0 -1
  91. package/dist/_astro/PmRequirementsBoard.CtuavIey.js +0 -1
  92. package/dist/_astro/PromptsLibrary.fKp4NWWW.js +0 -1
  93. package/dist/_astro/ReqAnalysisBoard.CcRTrBPY.js +0 -39
  94. package/dist/_astro/TagSelect.B9W63KWq.js +0 -1
  95. package/dist/_astro/TasksBoard.Uj4XWtWz.js +0 -1
  96. package/dist/_astro/TestStatsBoard.CO4JMh4N.js +0 -1
  97. package/dist/_astro/TodosBoard.BkszTn-p.js +0 -1
  98. package/dist/_astro/app-config.DAIyT--R.js +0 -1
  99. package/dist/_astro/app-version.p8P81lR6.js +0 -1
  100. package/dist/_astro/case-exec.BipZCK6G.js +0 -1
  101. package/dist/_astro/case-gen-run.Byxy6M5X.js +0 -22
  102. package/dist/_astro/plugins.Di6uuouN.js +0 -1
  103. package/dist/_astro/req-analysis.CIZ_cIJQ.js +0 -23
  104. package/dist/_astro/spaces-client.OuJPy3GP.js +0 -1
  105. package/dist/_astro/test-stats.MEm3K2rB.js +0 -1
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DAIyT--R.js";import{i as r,o as i,s as a}from"./plugins.Di6uuouN.js";import{n as o,o as s,r as c,s as ee}from"./view-prefs.DkS1ldnh.js";import{i as te,n as ne,r as l,t as re}from"./dialog.DZHZCe_T.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.D5qXeML0.js";import{a as f,c as p,d as m,i as ie,l as ae,n as h,o as oe,r as g,s as se,t as _}from"./ColumnResize.BgYkV9Iy.js";import{n as ce,t as v}from"./DatePicker.Bkl71M49.js";import{t as le}from"./OverflowHint.pvo2Xc8R.js";import{t as y}from"./SelectDropdown.apWlFGbA.js";import{showToast as b}from"./Toast.BO2NFckG.js";import{A as ue,C as x,D as S,E as C,F as w,M as de,N as fe,O as pe,P as me,S as he,T as ge,_ as _e,b as T,f as ve,g as ye,j as E,n as D,u as be,v as O,w as xe,x as Se,y as k}from"./tasks.jfnSAEmg.js";import{a as Ce,c as A,i as we,l as j,n as M,o as N,r as Te,s as P,t as Ee}from"./DrawerField.C0MkN-LW.js";var F=e(t(),1),I=u(),De=8e3,Oe=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],ke=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Ae={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},je={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},L={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Me={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Ne={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},R={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Pe=[`status`,`priority`,`none`],Fe=`todos.group-by`,Ie=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Le=k.map(e=>({value:e,label:T[e]})),Re=[{value:``,label:`未设置`},..._e.map(e=>({value:e,label:O[e]}))],ze=Object.keys(R).map(e=>({value:e,label:R[e]})),Be=[{value:`all`,label:`全部紧急程度`},..._e.map(e=>({value:e,label:O[e]}))],Ve=Be.map(e=>e.value),He=`todos.priority-filter`,Ue=`todos.search`,We=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ge(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,I.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${We} ${r&&!t?`text-stone-300`:``}`})}function Ke(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,F.useState)(!1);return a?(0,I.jsx)(Ge,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,I.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,I.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function qe(e){return(0,I.jsx)(v,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Je(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,F.useState)({title:``}),[u,d]=(0,F.useState)(``),[f,p]=(0,F.useState)(!1),[m,ie]=(0,F.useState)(!0);(0,F.useEffect)(()=>{t&&(d(``),p(!1),ie(!0),ee(n?{title:n.title,status:n.status,statusManual:n.statusManual,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:(()=>{let e=E(),t=E(),n=C(e,t)??`in_progress`;return{title:``,status:r?.status??n,statusManual:!!r?.status,priority:r?.priority??``,startDate:e,dueDate:t}})()))},[t,n,r]);let ae=[{value:``,label:`不关联`},...ve(i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId)).map(e=>({value:e.id,label:e.title}))];function h(e){ee(t=>{let n={...t,...e};if(`status`in e&&!(`startDate`in e||`dueDate`in e))n.statusManual=!0;else if((`startDate`in e||`dueDate`in e)&&!n.statusManual&&!S(n.status??`pending`)){let e=C(n.startDate??``,n.dueDate??``);e&&(n.status=e)}return n})}let oe=de({startDate:c.startDate??``,dueDate:c.dueDate??``}),g=me({dueDate:c.dueDate??``}),se=S(c.status??`pending`),_=se?ce((n&&S(n.status)?n.taskEndDate:``)||E()):``,ue=g===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:g<0?`逾期 ${Math.abs(g)} 天`:g===0?`今天截止`:`${g} 天`;async function x(){let e=(c.title??``).trim();if(!e)d(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)d(`截止日期不能早于开始日期`);else{p(!0),d(``);try{let t={...c,title:e};n?await w(n.id,t):await Se([t],{mode:`manual`}),await s(),b(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);d(t),b(`保存待办失败:${t}`,`error`)}finally{p(!1)}}}return(0,I.jsxs)(l,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,I.jsx)(re,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,I.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,I.jsxs)(te,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,I.jsx)(ne,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,I.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,I.jsx)(M,{icon:(0,I.jsx)(j,{}),label:`待办名称`,children:(0,I.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())},placeholder:`请输入内容`,className:Ee})}),(0,I.jsx)(M,{icon:(0,I.jsx)(P,{}),label:`待办状态`,children:(0,I.jsx)(Te,{ariaLabel:`待办状态`,menuMinWidth:140,options:Le,value:c.status??`pending`,onChange:e=>h({status:e}),label:T[c.status??`pending`],optionDotClassName:e=>Me[e]})}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>ie(e=>!e),"aria-expanded":m,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,I.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,I.jsx)(A,{})}),(0,I.jsx)(`span`,{children:`任务详情`}),(0,I.jsx)(`span`,{className:`text-stone-400`,children:(0,I.jsx)(we,{open:m})})]}),m?(0,I.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,I.jsx)(M,{icon:(0,I.jsx)(A,{}),label:`所属任务`,children:a?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(y,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ae,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);h({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,I.jsx)(le,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,I.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,I.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,I.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,I.jsx)(M,{icon:(0,I.jsx)(P,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,I.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?D[e.priority]:`任务未设置`}),(0,I.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,I.jsx)(Te,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Re,value:c.priority??``,onChange:e=>h({priority:e}),label:c.priority?O[c.priority]:`未设置`,optionDotClassName:e=>Ne[e]})})()}),(0,I.jsx)(M,{icon:(0,I.jsx)(Ce,{}),label:`结束日期`,children:(0,I.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[_?(0,I.jsx)(`span`,{className:`text-stone-800`,children:_}):(0,I.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,I.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:se?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,I.jsx)(M,{icon:(0,I.jsx)(Ce,{}),label:`开始日期`,children:(0,I.jsx)(v,{value:c.startDate??``,onChange:e=>h({startDate:e}),className:`${Ee} tabular-nums`})}),(0,I.jsx)(M,{icon:(0,I.jsx)(Ce,{}),label:`截止日期`,children:(0,I.jsx)(v,{value:c.dueDate??``,onChange:e=>h({dueDate:e}),className:`${Ee} tabular-nums`})}),(0,I.jsx)(M,{icon:(0,I.jsx)(N,{}),label:`待办周期`,children:(0,I.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:oe===null?`—`:`${oe} 天`})}),(0,I.jsx)(M,{icon:(0,I.jsx)(N,{}),label:`剩余天数`,children:(0,I.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ue||`—`})}),(0,I.jsx)(M,{icon:(0,I.jsx)(j,{}),label:`备注`,children:(0,I.jsx)(`textarea`,{value:c.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),u?(0,I.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:u}):null]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:o,disabled:f,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>void x(),disabled:f,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:f?`保存中…`:n?`保存`:`新建`})]})]})})]})}function z(){let[e,t]=(0,F.useState)(!1),[te,ne]=(0,F.useState)(!0),[l,re]=(0,F.useState)(null),[u,D]=(0,F.useState)([]),[k,Ce]=(0,F.useState)([]),[A,we]=(0,F.useState)(!1),[j,M]=(0,F.useState)(null),[N,Te]=(0,F.useState)(!1),[P,Ee]=(0,F.useState)(()=>c(Ue)),[R,We]=(0,F.useState)(()=>o(He,Ve,`all`)),[z,Ye]=(0,F.useState)(()=>o(Fe,Pe,`status`)),[Xe,Ze]=(0,F.useState)({}),[B,Qe]=(0,F.useState)({});function $e(e){s(Fe,e),Ye(e)}function et(e){s(He,e),We(e)}function tt(e){ee(Ue,e),Ee(e)}let[nt,rt]=(0,F.useState)({}),[V,H]=(0,F.useState)(null),[U,W]=(0,F.useState)(null),[it,at]=(0,F.useState)(!1),[ot,st]=(0,F.useState)(null),G=(0,F.useRef)(!0),ct=(0,F.useRef)(!1),K=(0,F.useRef)(!1),q=ae(`lh:todos:cols:v1`,Oe),lt=m(`todos`),ut=V!==null,dt=(0,F.useRef)(V);dt.current=V;let ft=(0,F.useRef)(!1),pt=(0,F.useRef)(async()=>{});pt.current=xt,(0,F.useEffect)(()=>(G.current=!0,()=>{G.current=!1}),[]),(0,F.useEffect)(()=>{if(!ut)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=dt.current;if(!n)return;if(n.title.trim()){pt.current();return}let r=E();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&H(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[ut]);let J=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([pe(),A?be().catch(()=>[]):Promise.resolve([])]);if(!G.current)return;let n=t;if(!ct.current&&A){ct.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ye(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}D(e),Ce(n),M(null)}catch(e){if(!G.current)return;M(e instanceof Error?e.message:String(e))}},[A]);(0,F.useEffect)(()=>{let e=i(e=>{ne(!!e.todos),we(!!e.tasks)});return n().then(()=>{ne(r(`todos`)),we(r(`tasks`)),t(!0)}),e},[]),(0,F.useEffect)(()=>{e&&te&&(async()=>{let e=await xe();G.current&&(e?(await J(),G.current&&re(!0)):re(!1))})()},[e,te,J]),(0,F.useEffect)(()=>{if(l!==!0)return;let e=window.setInterval(()=>{K.current||J()},De),t=()=>{K.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[l,J]),(0,F.useEffect)(()=>{if(!A||l!==!0||k.length===0)return;let e=u.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=k.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await w(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&D(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[A,l,u,k]);function mt(e,t,n){rt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){rt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let ht=(0,F.useMemo)(()=>[{value:``,label:`不关联`},...ve(k.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[k]);function gt(e){return e.taskId?k.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function _t(e){return e.taskId?k.find(t=>t.id===e.taskId):void 0}function vt(e){let t=_t(e);return t?t.priority:e.priority}async function X(e,t){let n=u.find(t=>t.id===e),r={...t};if(t.status!==void 0&&t.startDate===void 0&&t.dueDate===void 0)r.statusManual=!0;else if(n&&!n.statusManual&&!S(n.status)&&(t.startDate!==void 0||t.dueDate!==void 0)&&t.status===void 0){let e=C(t.startDate??n.startDate,t.dueDate??n.dueDate);e&&(r.status=e)}D(t=>t.map(t=>t.id===e?{...t,...r,updatedAt:new Date().toISOString()}:t));try{let t=await w(e,r);if(!G.current)return;D(n=>n.map(n=>n.id===e?t:n)),M(null),r.taskId&&await J()}catch(e){M(e instanceof Error?e.message:String(e)),await J()}}async function yt(e){let t=nt[e],n=u.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of ke){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())M(`待办名称不能为空`),Y(e);else try{let t=await w(e,r);if(!G.current)return;D(n=>n.map(n=>n.id===e?t:n)),rt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),M(null)}catch(t){M(t instanceof Error?t.message:String(t)),Y(e)}}function bt(e){let t=E(),n=E(),r=!!e.newStatus,i=C(t,n)??`in_progress`,a=e.newStatus??i,o=e.newPriority??``;H({groupKey:e.key,title:``,status:a,statusManual:r,priority:o,taskId:``,startDate:t,dueDate:n,note:``,baseStatus:a,basePriority:o}),Ze(t=>({...t,[e.key]:!1}))}async function xt(){let e=dt.current;if(!e||ft.current)return;let t=e.title.trim();if(t){ft.current=!0,at(!0);try{let n=k.find(t=>t.id===e.taskId);await Se([{title:t,status:e.status,statusManual:e.statusManual,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),dt.current===e&&H(null),M(null),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{ft.current=!1,G.current&&at(!1)}}}async function St(){let e=U;if(e){W(null),Te(!0),M(null);try{await he(e.map(e=>e.id)),Qe({}),await J(),b(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),b(`删除待办失败:${t}`,`error`)}finally{G.current&&Te(!1)}}}let Z=E(),Ct=(0,F.useMemo)(()=>u.map(e=>{let t=e.taskId?k.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[u,k]),wt=(0,F.useMemo)(()=>ge(Ct,{status:`all`,priority:R,keyword:P,today:Z}),[Ct,R,P,Z]),Q=(0,F.useMemo)(()=>ue(wt),[wt]),Tt=(0,F.useMemo)(()=>z===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:z===`priority`?[..._e,``].map(e=>({key:`priority:${e||`none`}`,label:e?O[e]:`未设置`,pill:e?L[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Ie.map(e=>({key:`status:${e}`,label:T[e],pill:Ae[e],items:Q.filter(t=>x(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[z,Q,Z]).filter(e=>e.items.length>0||V?.groupKey===e.key&&!!V),Et=Object.keys(B).filter(e=>B[e]),$=(0,F.useMemo)(()=>{let e={total:u.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of u){let n=x(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[u,Z]);return e?te?l===null?(0,I.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,I.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):l?(0,I.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,I.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,I.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`input`,{value:P,onChange:e=>tt(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,I.jsx)(y,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:ze,value:z,onChange:e=>$e(e)}),(0,I.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Be,value:R,onChange:e=>et(e)}),(0,I.jsx)(`button`,{type:`button`,disabled:N||Et.length===0,onClick:()=>W(u.filter(e=>B[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,I.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>st({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),j?(0,I.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,I.jsx)(`span`,{className:`min-w-0 flex-1`,children:j}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>M(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,I.jsx)(`div`,{ref:lt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{K.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{K.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,I.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,I.jsx)(`colgroup`,{children:Oe.map(e=>(0,I.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,I.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:f,children:(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>B[e.id]),onChange:e=>{let t=e.target.checked;Qe(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,I.jsx)(`th`,{className:se,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,I.jsxs)(`th`,{className:oe,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,I.jsx)(_,{...q.resizeProps(`title`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,I.jsx)(_,{...q.resizeProps(`status`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,I.jsx)(_,{...q.resizeProps(`task`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,I.jsx)(_,{...q.resizeProps(`priority`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,I.jsx)(_,{...q.resizeProps(`start`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,I.jsx)(_,{...q.resizeProps(`due`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,I.jsx)(_,{...q.resizeProps(`end`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,I.jsx)(_,{...q.resizeProps(`cycle`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,I.jsx)(_,{...q.resizeProps(`remain`)})]}),(0,I.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,I.jsx)(_,{...q.resizeProps(`note`)})]}),(0,I.jsx)(`th`,{"aria-hidden":`true`}),(0,I.jsx)(`th`,{className:p,children:`操作`})]})}),Tt.map(e=>{let t=Xe[e.key]===!0;return(0,I.jsxs)(`tbody`,{children:[(0,I.jsx)(`tr`,{className:`bg-white`,children:(0,I.jsx)(`td`,{colSpan:14,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>Ze(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,I.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,I.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,I.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=nt[e.id]??{},r={...e,...n},i=x(r,Z),a=de(r),o=me(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,I.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,I.jsx)(`td`,{className:h,children:(0,I.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!B[e.id],onChange:t=>Qe(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,I.jsx)(`td`,{className:`${g} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,I.jsx)(`td`,{className:h,style:{"--tw-sticky-left":`68px`},children:(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,I.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,I.jsx)(Ge,{value:r.title,placeholder:`输入待办名称`,onChange:t=>mt(e.id,`title`,t),onCommit:()=>void yt(e.id),onCancel:()=>Y(e.id)})]})}),(0,I.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,I.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Le,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${je[i]}`,renderTrigger:()=>(0,I.jsx)(`span`,{className:`truncate`,children:T[i]}),renderOptionPrefix:e=>(0,I.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Me[e.value]}`})})}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:A?(0,I.jsx)(y,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ht,value:r.taskId,onChange:t=>{let n=k.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,I.jsx)(le,{text:gt(r)||`未关联`,className:`min-w-0 truncate ${gt(r)?`text-stone-800`:`text-stone-300`}`})}):(0,I.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:gt(r)?`${gt(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,I.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:_t(r)?(0,I.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${L[vt(r)]??`text-stone-300`}`,children:vt(r)?O[vt(r)]:`未设置`}):(0,I.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Re,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${L[e.priority]}`,renderTrigger:()=>(0,I.jsx)(`span`,{className:`truncate`,children:e.priority?O[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,I.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ne[e.value]}`})})}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,I.jsx)(qe,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,I.jsx)(qe,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:fe(r)?(0,I.jsx)(`span`,{className:`text-stone-500`,children:ce(fe(r))}):(0,I.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,I.jsx)(Ke,{value:r.note,onChange:t=>mt(e.id,`note`,t),onCommit:()=>void yt(e.id),onCancel:()=>Y(e.id)})}),(0,I.jsx)(`td`,{"aria-hidden":`true`}),(0,I.jsx)(`td`,{className:ie,children:(0,I.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>st({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M14 4h6v6`}),(0,I.jsx)(`path`,{d:`M20 4 13 11`}),(0,I.jsx)(`path`,{d:`M10 20H4v-6`}),(0,I.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,I.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>W([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M3 6h18`}),(0,I.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,I.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,I.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:V?.groupKey===e.key?(0,I.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,I.jsx)(`td`,{className:g,children:(0,I.jsx)(`input`,{autoFocus:!0,value:V.title,disabled:it,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>H(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),xt()):e.key===`Escape`&&(e.preventDefault(),H(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,I.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,I.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Le,value:V.status,onChange:e=>H(t=>t&&{...t,status:e,statusManual:!0}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${je[V.status]}`,renderTrigger:()=>(0,I.jsx)(`span`,{className:`truncate`,children:T[V.status]})})}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:A?(0,I.jsx)(y,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ht,value:V.taskId,onChange:e=>H(t=>{if(!t)return t;let n=k.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=k.find(e=>e.id===V.taskId);return(0,I.jsx)(le,{text:e?.title||`未关联`,className:`min-w-0 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,I.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,I.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=k.find(e=>e.id===V.taskId);return e?(0,I.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${L[e.priority]??`text-stone-300`}`,children:e.priority?O[e.priority]:`未设置`}):(0,I.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Re,value:V.priority,onChange:e=>H(t=>t&&{...t,priority:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${L[V.priority]}`,renderTrigger:()=>(0,I.jsx)(`span`,{className:`truncate`,children:V.priority?O[V.priority]:`未设置`})})})()}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,I.jsx)(v,{value:V.startDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,startDate:n};if(!t.statusManual&&!S(t.status)){let e=C(n,t.dueDate);e&&(r.status=e)}return r}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,I.jsx)(v,{value:V.dueDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,dueDate:n};if(!t.statusManual&&!S(t.status)){let e=C(t.startDate,n);e&&(r.status=e)}return r}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:S(V.status)?(0,I.jsx)(`span`,{className:`text-stone-500`,children:ce(E())}):(0,I.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,I.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,I.jsx)(`input`,{value:V.note,disabled:it,placeholder:`—`,onChange:e=>H(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,I.jsx)(`td`,{"aria-hidden":`true`}),(0,I.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{className:`px-2 py-0.5`}),(0,I.jsx)(`td`,{className:`px-1 py-0.5`}),(0,I.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:12,children:(0,I.jsxs)(`button`,{type:`button`,disabled:it,onClick:()=>bt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,I.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),Tt.length===0?(0,I.jsx)(`tbody`,{children:(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:14,className:`px-3 py-16 text-center text-sm text-stone-400`,children:u.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,I.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,I.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,Et.length?` · 已选 ${Et.length}`:``]}),(0,I.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,I.jsx)(Je,{open:ot!==null,item:ot?.item??null,preset:ot?.preset,tasks:k,tasksOn:A,onClose:()=>st(null),onSaved:J}),(0,I.jsx)(d,{open:U!=null,title:U&&U.length>1?`批量删除`:`删除待办`,message:U&&U.length>1?`确认删除已选中的 ${U.length} 条待办?此操作不可恢复。`:`删除「${U?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>W(null),onConfirm:()=>void St()})]}):(0,I.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,I.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,I.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,I.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,I.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{z as default};
@@ -1 +0,0 @@
1
- var e=[{id:`functional`,label:`功能测试`,casesFolder:`功能测试`,templateFolder:`功能测试用例`},{id:`api`,label:`接口测试`,casesFolder:`接口测试`,templateFolder:`接口测试用例`},{id:`performance`,label:`性能测试`,casesFolder:`性能测试`,templateFolder:`性能测试用例`},{id:`automation`,label:`自动化测试`,casesFolder:`自动化测试`,templateFolder:`自动化测试用例`}];function t(){return`ct_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function n(e){let t=e.trim()||`未命名类型`;return{casesFolder:t,templateFolder:`${t}用例`}}function r(e){if(!e||typeof e!=`object`)return null;let r=e,i=String(r.label??``).trim();if(!i)return null;let a=String(r.id??``).trim()||t(),o=n(i);return{id:a,label:i,casesFolder:typeof r.casesFolder==`string`&&r.casesFolder.trim()?r.casesFolder.trim():o.casesFolder,templateFolder:typeof r.templateFolder==`string`&&r.templateFolder.trim()?r.templateFolder.trim():o.templateFolder,...typeof r.promptPath==`string`&&r.promptPath.trim()?{promptPath:r.promptPath.trim()}:{}}}function i(t){if(!Array.isArray(t))return e.map(e=>({...e}));let n=[],i=new Set;for(let e of t){let t=r(e);t&&!i.has(t.id)&&(i.add(t.id),n.push(t))}return n.length?n:e.map(e=>({...e}))}function a(){return t()}var o=[`测试规范`,`方法论`,`环境约定`];function s(e){if(!Array.isArray(e))return[...o];let t=[],n=new Set;for(let r of e){let e=String(r??``).trim();!e||e.length>40||n.has(e)||(n.add(e),t.push(e))}return t.length?t:[...o]}var c=[{id:`case`,label:`用例生成提示词`,hint:`用于编写「用例生成」提示词:指导模型按需求与模板输出可入库用例;须约束 JSON 结构、字段对齐模板、步骤换行与覆盖策略,不要限定固定用例条数。`},{id:`general`,label:`通用提示词`,hint:`用于编写通用测试/工作台提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}];function l(){return`pk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function u(e){return`生成「${e.trim()||`自定义`}」类提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}function d(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.label??``).trim();if(!n)return null;let r=String(t.id??``).trim()||l(),i=typeof t.hint==`string`&&t.hint.trim()?t.hint.trim():u(n);return r===`case`&&i.includes(`「测试用例生成」`)&&(i=c[0].hint),{id:r,label:n,hint:i}}function f(e){if(!Array.isArray(e))return c.map(e=>({...e}));let t=[],n=new Set;for(let r of e){let e=d(r);e&&!n.has(e.id)&&(n.add(e.id),t.push(e))}return t.length?t:c.map(e=>({...e}))}function ee(){return l()}var p=[{id:`dashboard`,href:`dashboard/`,i18n:`nav.dashboard`,plugin:`dashboard`,match:`dashboard`},{id:`tasks`,href:`tasks/`,i18n:`nav.tasks`,plugin:`tasks`,match:`tasks`},{id:`todos`,href:`todos/`,i18n:`nav.todos`,plugin:`todos`,match:`todos`},{id:`projects`,href:`pm/projects/`,i18n:`nav.projects`,plugin:`projects`,match:`pm/projects`},{id:`iterations`,href:`pm/iterations/`,i18n:`nav.iterations`,plugin:`iterations`,match:`pm/iterations`},{id:`pmRequirements`,href:`pm/requirements/`,i18n:`nav.requirementsMgmt`,plugin:`pmRequirements`,match:`pm/requirements`},{id:`bugs`,href:`pm/bugs/`,i18n:`nav.bugs`,plugin:`bugs`,match:`pm/bugs`},{id:`reports`,href:`reports/`,i18n:`nav.reports`,plugin:`reports`,match:`reports`},{id:`testStats`,href:`test-stats/`,i18n:`nav.testStats`,plugin:`testStats`,match:`test-stats`},{id:`caseExec`,href:`case-exec/`,i18n:`nav.caseExec`,plugin:`caseExec`,match:`case-exec`},{id:`uiAuto`,href:`test-automation/`,i18n:`nav.uiAuto`,plugin:`uiAuto`,match:`test-automation`},{id:`reqAnalysis`,href:`requirement-analysis/`,i18n:`nav.reqAnalysis`,plugin:`reqAnalysis`,match:`requirement-analysis`},{id:`cases`,href:`cases/library/`,i18n:`nav.caseManage`,plugin:`cases`,match:`cases`},{id:`prompts`,href:`prompts/`,i18n:`nav.prompts`,plugin:`prompts`,match:`prompts`},{id:`knowledgeLib`,href:`knowledge/`,i18n:`nav.knowledge`,plugin:`knowledgeLib`,match:`knowledge`},{id:`requirements`,href:`requirements/`,i18n:`nav.requirements`,plugin:`requirements`,match:`requirements`},{id:`templates`,href:`templates/`,i18n:`nav.templates`,plugin:`templates`,match:`templates`}],m=[],te=[`prompts`];function h(e){return te.includes(e)}var g=`check.pencil.book.fileText.layers.list.folder.star.database.target.code.flask.home.clipboard.bug.calendar.chart.globe.link.users.terminal.tag.flag.zap.dashboard.search.settings.bell.clock.mail.message.image.video.download.upload.plus.trash.lock.shield.key.cloud.box.filter.grid.pin.sparkle.rocket.eye.bookmark.archive.refresh.play.map.activity.cpu.briefcase.presentation.copy.save`.split(`.`),_={dashboard:`dashboard`,tasks:`clipboard`,todos:`list`,projects:`folder`,iterations:`calendar`,pmRequirements:`fileText`,bugs:`bug`,reports:`fileText`,testStats:`chart`,caseExec:`target`,uiAuto:`terminal`,reqAnalysis:`fileText`,cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`};function ne(e){return typeof e==`string`&&g.includes(e)}function v(e){let t={..._};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of p){let r=e[n.id];ne(r)&&(t[n.id]=r)}return t}var y=new Set(p.map(e=>e.id));function b(e){return typeof e==`string`&&y.has(e)}function re(e){return p.find(t=>t.id===e)}function ie(e,t=`/`){let n=t.replace(/\/$/,``),r=(n&&e.startsWith(n)?e.slice(n.length):e).replace(/^\/+/,``);return r?p.filter(e=>r===e.match||r.startsWith(`${e.match}/`)).sort((e,t)=>t.match.length-e.match.length)[0]??null:null}function x(e){return`item:${e}`}function S(e){return`group:${e}`}function C(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function w(){return m.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function T(e,t=!0){if(e==null||!Array.isArray(e))return t?w():[];let n=new Set,r=[],i=new Set;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,a=String(e.name??``).trim();if(!a)continue;let o=String(e.id??``).trim()||C();i.has(o)&&(o=C());let s=[];if(Array.isArray(e.items))for(let t of e.items)b(t)&&!n.has(t)&&(n.add(t),s.push(t));let c=String(e.parentId??``).trim()||void 0;i.add(o),r.push({id:o,name:a,items:s,parentId:c})}let a=new Set(r.map(e=>e.id)),o=r.map(e=>{let t=e.parentId;return(!t||t===e.id||!a.has(t))&&(t=void 0),t?{...e,parentId:t}:{id:e.id,name:e.name,items:e.items}}),s=new Map(o.map(e=>[e.id,e])),c=o.map(e=>{if(!e.parentId)return e;let t=s.get(e.parentId);if(t?.parentId){let n=t.parentId;return n&&n!==e.id&&a.has(n)?{...e,parentId:n}:{id:e.id,name:e.name,items:e.items}}return e}),l=new Set(c.map(e=>e.parentId).filter(e=>!!e));return c.filter(e=>e.items.length>0||l.has(e.id))}function E(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>b(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||C(),a=e.find(e=>e.id===i),o=t.parentId===void 0?a?.parentId:t.parentId.trim()||void 0;if(o===i&&(o=void 0),o){let t=e.find(e=>e.id===o);t?t.parentId&&(o=t.parentId):o=void 0}let s=new Set(r),c=e.filter(e=>e.id!==i).map(e=>({...e,items:e.items.filter(e=>!s.has(e))}));return c.push(o?{id:i,name:n,items:r,parentId:o}:{id:i,name:n,items:r}),{groups:T(c),id:i}}function ae(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function D(e,t){return e.filter(e=>e.parentId===t)}function oe(e,t){let n=e.find(e=>e.id===t);if(!n)return e;let r=e.filter(e=>e.id!==t);return n.parentId?r.map(e=>e.id===n.parentId?{...e,items:[...e.items,...n.items]}:e.parentId===t?{...e,parentId:n.parentId}:e):r.map(e=>e.parentId===t?{id:e.id,name:e.name,items:e.items}:e)}function se(e,t,n){let r=e.find(e=>e.id===t);return!r||!b(n)||r.items.includes(n)?e:E(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function ce(e,t){let n=e.find(e=>e.items.includes(t))??null;return n?{groups:e.map(e=>e.id===n.id?{...e,items:e.items.filter(e=>e!==t)}:e).filter(e=>e.items.length>0),owner:n}:{groups:e,owner:null}}function le(e,t,n,r){let i=x(t),a=S(n.id),o=r.some(e=>e.id===n.id),s=e.indexOf(a),c=e.filter(e=>e!==i&&(o||e!==a)),l=s<0?c.length:o?s+1:s;return c.splice(l,0,i),k(c,r)}function ue(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.parentId?t.get(r.parentId)??r:r;for(let t of r.items)n.set(t,e)}let r=new Set,i=[];for(let e of p){let t=n.get(e.id);if(t){if(r.has(t.id))continue;r.add(t.id),i.push({type:`group`,group:t})}else i.push({type:`item`,id:e.id})}return i}function O(e){let t=new Map;for(let n of e){if(!n.parentId)continue;let e=t.get(n.parentId);e?e.push(n):t.set(n.parentId,[n])}let n=[],r=new Set,i=e=>{if(!r.has(e.id)){r.add(e.id),n.push(S(e.id));for(let n of t.get(e.id)??[])i(n)}};for(let t of ue(e))t.type===`item`?n.push(x(t.id)):i(t.group);for(let t of e)i(t);return n}function de(e){let t=new Set,n=new Set;for(let r of e){n.add(S(r.id));for(let e of r.items)t.add(e)}for(let e of p)t.has(e.id)||n.add(x(e.id));return n}function k(e,t){let n=de(t),r=[],i=new Set;if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.has(t)&&!i.has(t)&&(i.add(t),r.push(t));for(let e of O(t))i.has(e)||r.push(e);return r}function fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=k(t,e),a=[];for(let e of i)if(e.startsWith(`group:`)){let t=n.get(e.slice(6));t&&!t.parentId&&a.push({type:`group`,group:t})}else if(e.startsWith(`item:`)){let t=e.slice(5);b(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function pe(e,t,n){let r=t.find(e=>e.id===n);if(!r)return k(e,t);let i=new Set(r.items.map(e=>x(e))),a=S(n);if(r.parentId){let n=e.filter(e=>e!==a),i=S(r.parentId),o=n.indexOf(i),s=[...n];return o<0?s.push(a):s.splice(o+1,0,a),k(s,t)}let o=[...e],s=o.length;for(let e=0;e<o.length;e++){let t=o[e];if(t===a||i.has(t)){s=o.slice(0,e).filter(e=>e!==a&&!i.has(e)).length;break}}let c=o.filter(e=>e!==a&&!i.has(e));return c.splice(s,0,a),k(c,t)}function me(e,t,n){let r=D(e,t);if(!n?.length||r.length<2)return r;let i=new Map;return n.forEach((e,t)=>{i.has(e)||i.set(e,t)}),r.map((e,t)=>({group:e,i:t,at:i.get(S(e.id))})).sort((e,t)=>{let n=e.at??1/0,r=t.at??1/0;return n===r?e.i-t.i:n-r}).map(e=>e.group)}function he(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=r.filter(e=>i.get(e)?.parentId===n),o=new Set(a.map(S)),s=e.filter(e=>!o.has(e)),c=S(n),l=s.indexOf(c),u=a.map(S),d=[...s];return l<0?d.push(...u):d.splice(l+1,0,...u),k(d,t)}function ge(e,t){if(!e.startsWith(`group:`))return!1;let n=e.slice(6);return t.some(e=>e.id===n&&!!e.parentId)}function _e(e,t,n,r=[]){if(t.parentId)return k(e,n);let i=S(t.id),a=[...r.map(e=>S(e)),...t.items.map(e=>x(e))],o=e.filter(e=>e!==i);return o.push(...a),k(o,n)}function ve(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return[...e];let a=[...e],[o]=a.splice(r,1);return o===void 0?[...e]:(a.splice(i,0,o),a)}var A=`tw.space.active-id`,ye=`tw.spaces.list.v1`;function j(e,t){try{return(e===`local`?localStorage:sessionStorage).getItem(t)?.trim()||``}catch{return``}}function M(e,t,n){try{(e===`local`?localStorage:sessionStorage).setItem(t,n)}catch{}}function N(e){let t=String(e||``).trim();t&&(M(`session`,A,t),M(`local`,A,t))}function P(){let e=j(`session`,A);if(e)return e;let t=j(`local`,A);if(t)return t;try{let e=sessionStorage.getItem(ye);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function F(e){let t=P();return t?`${e}::${t}`:e}var I=`/__tb_config`,L=`tw.app.config.v1`,R=`tw.app.apikey.v1`,z=`tw.app.model.v1`,B=!1,V=null,H=``,U=!1,be={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``,allowPrivateWebFetch:!1};function W(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function xe(e){if(!e||typeof e!=`object`)return null;let t=String(e.name??``).trim()||`未命名提供商`,n=String(e.baseURL??``).trim(),r=String(e.model??``).trim(),i=String(e.id??``).trim()||W(),a=typeof e.contextWindow==`number`&&Number.isFinite(e.contextWindow)&&e.contextWindow>0?Math.floor(e.contextWindow):void 0;return{id:i,name:t,baseURL:n,model:r,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0,contextWindow:a,supportsTools:e.supportsTools!==!1,supportsVision:e.supportsVision===!0}}function Se(e){let t=typeof e.baseURL==`string`?e.baseURL.trim():``,n=typeof e.model==`string`?e.model.trim():``;return!t&&!n&&!e.apiKey?[]:[{id:W(),name:`默认`,baseURL:t||`https://api.deepseek.com/v1`,model:n,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}]}function G(e){let t=e?.reasoningEffort===`low`||e?.reasoningEffort===`high`||e?.reasoningEffort===`max`?e.reasoningEffort:`high`,n=[];Array.isArray(e?.providers)&&e.providers.length?n=e.providers.map(e=>xe(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=Se(e));let r=typeof e?.activeId==`string`?e.activeId:``;return n.length&&!n.some(e=>e.id===r)&&(r=n[0].id),n.length||(r=``),{activeId:r,reasoningEffort:t,providers:n}}function K(){return{version:1,model:{activeId:``,reasoningEffort:`high`,providers:[]},access:`readonly`,general:{...be},plugins:{cases:!1,caseGen:!1,prompts:!0,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,knowledge:!1,memory:!1,pluginDev:!1,todos:!1,tasks:!1,projects:!1,iterations:!1,pmRequirements:!1,bugs:!1,reports:!1,testStats:!1,caseExec:!1,dashboard:!1},caseTypes:e.map(e=>({...e})),promptKinds:c.map(e=>({...e})),knowledgeCategories:[...o],navGroups:m.map(e=>({...e,items:[...e.items]})),navIcons:{..._},navOrder:O(m)}}function q(e){let t=K();if(!e||typeof e!=`object`)return t;let n=e.general&&typeof e.general==`object`?e.general:{},r={...t.plugins,...e.plugins??{}},a=T(e.navGroups);return{version:typeof e.version==`number`?e.version:1,model:G(e.model),access:e.access===`readwrite`||e.access===`full`||e.access===`readonly`?e.access:`readonly`,general:{language:n.language===`en`?`en`:`zh-CN`,appearance:n.appearance===`light`||n.appearance===`dark`||n.appearance===`system`?n.appearance:`system`,sessionFontSize:typeof n.sessionFontSize==`number`&&n.sessionFontSize>=12&&n.sessionFontSize<=22?Math.round(n.sessionFontSize):14,toolStepDetail:n.toolStepDetail===`concise`||n.toolStepDetail===`standard`||n.toolStepDetail===`detailed`||n.toolStepDetail===`full`?n.toolStepDetail:`standard`,busySendBehavior:n.busySendBehavior===`interrupt`?`interrupt`:`queue`,subagentModel:typeof n.subagentModel==`string`?n.subagentModel.trim():``,allowPrivateWebFetch:n.allowPrivateWebFetch===!0},plugins:r,caseTypes:i(e.caseTypes),promptKinds:f(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:v(e.navIcons),navOrder:k(e.navOrder,a)}}function Ce(){try{let e=localStorage.getItem(z);if(e)return G(JSON.parse(e))}catch{}try{let e=localStorage.getItem(F(L));if(e){let t=JSON.parse(e);if(t?.model)return G(t.model)}}catch{}return null}function we(e){try{localStorage.setItem(z,JSON.stringify(e))}catch{}}function J(){try{let e=localStorage.getItem(F(L)),t=Ce();if(!e)return t?q({...K(),model:t}):null;let n=q(JSON.parse(e));return t&&(n.model=t),n}catch{return null}}function Y(e){try{let{model:t,...n}=e;localStorage.setItem(F(L),JSON.stringify(n)),we(t)}catch{}}function Te(){try{return localStorage.getItem(R)?.trim()||localStorage.getItem(F(R))?.trim()||``}catch{return``}}function Ee(e){try{e?localStorage.setItem(R,e):localStorage.removeItem(R),localStorage.removeItem(F(R))}catch{}}function De(){try{let e=K(),t=!1,n=localStorage.getItem(`tw-llm-settings`);if(n){let r=JSON.parse(n);e.model=G({providers:[{id:W(),name:r.name||`默认`,baseURL:r.baseURL||``,model:r.model||``,apiKey:r.apiKey,availableModels:r.availableModels}],reasoningEffort:r.reasoningEffort}),e.model.providers[0]&&(e.model.activeId=e.model.providers[0].id),t=!0}let r=localStorage.getItem(`tw-access-level`);(r===`readonly`||r===`readwrite`||r===`full`)&&(e.access=r,t=!0);let i=localStorage.getItem(`tw.general.prefs.v1`);i&&(e.general=q({general:JSON.parse(i)}).general,t=!0);let a=localStorage.getItem(`tw.plugins.enabled.v1`);if(a){let n=JSON.parse(a);e.plugins={...e.plugins,...n},t=!0}return t?e:null}catch{return null}}function X(e){let t=e.model.providers;return t.length?t.find(t=>t.id===e.model.activeId)??t[0]??null:null}function Oe(){return B}function ke(){return V||Z(),V??K()}function Z(){if(!U&&(U=!0,typeof window<`u`))try{let e=J();e&&(V=e)}catch{}}function Ae(){return H}function je(){return[...V?.model.providers??[]]}async function Me(){try{let e=await fetch(I,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();V=q(t.config);let n=X(V),r=String(t.apiKey??``).trim();return H=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(H=r),B=!0,Y(V),V}}catch{}B=!1;let e=J();return e||=De()??K(),V=e,H=X(e)?.apiKey?.trim()||Te(),Y(V),V}var Q=null;async function $(e){if(Y(e),B)try{await fetch(I,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e}),keepalive:!0})}catch{}}function Ne(e){let t=V??K(),n=q({...t,...e,model:e.model?{...t.model,...e.model,providers:e.model.providers??t.model.providers}:t.model,general:{...t.general,...e.general??{}},plugins:{...t.plugins,...e.plugins??{}},caseTypes:e.caseTypes??t.caseTypes,promptKinds:e.promptKinds??t.promptKinds,knowledgeCategories:e.knowledgeCategories??t.knowledgeCategories,navGroups:e.navGroups??t.navGroups,navIcons:e.navIcons??t.navIcons,navOrder:e.navOrder??t.navOrder});return V=n,H=X(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Pe(){return Q&&=(clearTimeout(Q),null),$(V??K())}function Fe(e){if(H=e.trim(),B||Ee(H),!V)return;let t=V.model.providers.map(e=>e.id===V.model.activeId?{...e,apiKey:H||void 0}:e);V=q({...V,model:{...V.model,providers:t}})}function Ie(){let e=V;if(!e)return null;let t=X(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||H).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function Le(){return W()}export{he as A,u as B,h as C,T as D,ie as E,ce as F,e as G,f as H,oe as I,i as J,n as K,ve as L,_e as M,pe as N,v as O,me as P,E as R,ge as S,D as T,o as U,ee as V,s as W,se as _,Oe as a,re as b,Fe as c,P as d,N as f,g,p as h,Me as i,le as j,k,Ie as l,_ as m,Ae as n,je as o,F as p,a as q,ke as r,Le as s,Pe as t,Ne as u,fe as v,x as w,S as x,ae as y,c as z};
@@ -1 +0,0 @@
1
- var e=`0.1.29`;export{e as t};
@@ -1 +0,0 @@
1
- var e=`/__tb_case_exec`,t=/^\d{4}-\d{2}-\d{2}$/;function n(e,t=120){return typeof e==`string`?e.trim().slice(0,t):``}function r(e){let r=n(e,10);return t.test(r)?r:``}function i(e){let t=typeof e==`number`?e:Number(String(e??``).trim());return!Number.isFinite(t)||t<=0?0:Math.min(9999999,Math.round(t))}function a(e=new Date){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function o(e){if(!e||typeof e!=`object`)return null;let t=e,o=n(t.project),s=!o;if(s&&t.draft!==!0)return null;let c=new Date().toISOString();return{id:n(t.id,64)||`ce_${Math.random().toString(16).slice(2,10)}`,date:r(t.date)||a(),project:o,startDate:r(t.startDate),endDate:r(t.endDate),total:i(t.total),pending:i(t.pending),executed:i(t.executed),draft:s,source:t.source===`ai`?`ai`:`manual`,sessionId:n(t.sessionId,120),createdAt:n(t.createdAt,40)||c,updatedAt:n(t.updatedAt,40)||c}}async function s(t,n){let r=await fetch(e,{method:t,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error||`HTTP ${r.status}`);return i}async function c(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function l(){let e=await s(`GET`),t=Array.isArray(e.items)?e.items:[],r=Array.isArray(e.projects)?e.projects.map(e=>n(e)).filter(Boolean):[];return{items:t.map(o).filter(e=>!!e),projects:r}}async function u(e,t){let r=await s(`POST`,{items:e,...t}),i=Array.isArray(r.items)?r.items:[],a=Array.isArray(r.projects)?r.projects.map(e=>n(e)).filter(Boolean):[];return{items:i.map(o).filter(e=>!!e),projects:a}}async function d(e,t){let r=await s(`PUT`,{id:e,...t}),i=o(r.item);if(!i)throw Error(`更新用例执行统计失败`);return{item:i,projects:Array.isArray(r.projects)?r.projects.map(e=>n(e)).filter(Boolean):[]}}async function f(e){let t=await s(`DELETE`,{ids:e});return Number(t.removed??0)}function p(e){return Math.max(e.total-e.executed,0)}function m(e){return e.total<=0?0:Math.min(100,Math.max(0,e.executed/e.total*100))}function h(e){return`${m(e).toFixed(2)}%`}function g(e){return[...e].sort((e,t)=>e.date===t.date?e.createdAt<t.createdAt?1:-1:e.date<t.date?1:-1)}function _(e,t={}){let n=(t.keyword??``).trim().toLowerCase();return n?e.filter(e=>`${e.date} ${e.project} ${e.startDate} ${e.endDate}`.toLowerCase().includes(n)):e}function v(e){let t=new Set(e.map(e=>e.project).filter(Boolean)),n=e.reduce((e,t)=>e+t.total,0),r=e.reduce((e,t)=>e+t.executed,0);return{records:e.length,projects:t.size,total:n,executed:r,percent:n>0?Math.min(100,r/n*100):0}}export{f as a,h as c,i as d,a as f,u as i,l,m as n,c as o,d as p,p as r,_ as s,v as t,g as u};
@@ -1,22 +0,0 @@
1
- import{p as e}from"./app-config.DAIyT--R.js";import{i as t,s as n}from"./plugins.Di6uuouN.js";import{i as r,r as i}from"./case-types.B6MLX3iE.js";import{t as a}from"./export.joBT53eb.js";import{a as o,o as s,s as c,t as l}from"./case-template.F1Nv08GV.js";import{r as u,t as d}from"./case-fields.Dqkws1iX.js";import{h as f}from"./req-analysis.CIZ_cIJQ.js";import{_ as p,v as m}from"./project-docs.DAw9bzgk.js";var h=`/__tb_case_sessions`,g=`tw.case.sessions.v1`,_=!1;function v(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function y(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return r().some(e=>e.id===t),t}return r()[0]?.id??`functional`}function b(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:y(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function x(){try{let t=localStorage.getItem(e(g));return t?b(JSON.parse(t)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function S(t){try{localStorage.setItem(e(g),JSON.stringify(t))}catch{}}async function ee(){try{let e=await fetch(h,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();_=!0;let n=b(t.store);return S(n),n}}catch{}return _=!1,x()}function te(){return x()}async function C(e){if(S(e),_)try{await fetch(h,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function w(e){S(e),C(e)}function T(e){let t=Date.now(),n={id:v(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return w({sessions:[n,...x().sessions],activeId:n.id}),n}function E(e,t){let n=x(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return w(i),i}function D(e){return e.reqSource?e.reqSource:e.reqPath?{kind:`doc`,path:e.reqPath}:void 0}function ne(e){let t=[e.templateTitle||e.templateId?.split(`/`).pop()||`默认模板`,e.outputFormat.toUpperCase()],n=D(e);return n?.kind===`stories`?t.push(`${e.docTitle||`用户故事`} · ${n.storyIds.length} 条故事`):n?.kind===`doc`&&t.push(n.path.split(`/`).pop()||n.path),e.testPointIds?.length&&t.push(`${e.testPointIds.length} 条测试点`),t.join(` · `)}function O(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e,coverageRate:null,uncovered:[],writeNote:``};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title,i=typeof r==`string`?r.trim():``,a=t.覆盖需求率??t.coverageRate??t.coverage,o=null;if(typeof a==`number`&&Number.isFinite(a))o=Math.max(0,Math.min(100,Math.round(a)));else if(typeof a==`string`&&a.trim()){let e=parseInt(a.replace(/%/g,``),10);Number.isFinite(e)&&(o=Math.max(0,Math.min(100,e)))}let s=t.未覆盖说明??t.uncovered??t.omissions,c=Array.isArray(s)?s.map(e=>String(e).trim()).filter(Boolean):typeof s==`string`&&s.trim()?[s.trim()]:[],l=t.编写说明??t.note??t.summary,u=typeof l==`string`?l.trim():``;return{docTitle:i,cases:n,coverageRate:o,uncovered:c,writeNote:u}}}catch{return null}return null}function k(e){return e.replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`-`).slice(0,64)||`cases`}function A(e){let t=String(e??``).trim().split(/[/\\]/).pop()?.trim()||``;t=t.replace(/\.(xlsx|xls|docx|doc|md|txt|csv)$/i,``),t=t.replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).trim(),t=t.replace(/_\d{8}-\d{6}$/,``);for(let e of r()){let n=`_${e.label}用例`;if(t.endsWith(n)){t=t.slice(0,-n.length);break}}return/迭代版本$/u.test(t)?k(t):/v?\d+(?:\.\d+)*版本$/iu.test(t)?k(t.replace(/版本$/u,`迭代版本`)):/v\d+(?:\.\d+)+$/i.test(t)?k(`${t}迭代版本`):k(t)}function j(e){let t=A(e).replace(/迭代版本$/u,``).replace(/版本$/u,``).trim();return t=t.replace(/[\s_\-—·()()[\]【】]/g,``).toLowerCase(),t}function M(e,t){let n=j(e),r=j(t);return n.length<4||r.length<4?!1:n===r||n.includes(r)||r.includes(n)}function N(e=new Date){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function P(e,t,n=new Date){let r=`_${i(t).label}用例`;return`${A(e)||`cases`}${r}_${N(n)}`}function F(e,t){let n=String(e||``).match(RegExp(`${t}-\\d+`,`i`));return n?n[0].toUpperCase():``}function I(e,t){if(e===t)return 0;if(!e)return 1;if(!t)return-1;let n=e.match(/^(.*?)(\d+)$/),r=t.match(/^(.*?)(\d+)$/);return n&&r&&n[1]===r[1]?Number(n[2])-Number(r[2]):e.localeCompare(t,`zh`)}function re(e){return f(e??``)}function L(e,t,n){if(!t.length)return 0;let r=t.length+1,i=-1,a=!1,o=[n.submodule&&e[n.submodule],n.module&&e[n.module],n.title&&e[n.title]];for(let e of o){let n=String(e??``).trim();if(n)for(let e=0;e<t.length;e++){let o=t[e];o&&(n===o||n.includes(o))&&o.length>i&&(i=o.length,r=e,a=!0)}}return a?r:t.length+1}function R(e,t,n){if(e.length<=1)return e;let r=u(t),i=r.requirement||d.requirement,a=r.no||d.no,o=r.title||d.title,s=n?.idealOrder??[],c={submodule:r.submodule,module:r.module,title:o},l=new Map((n?.storyIds??[]).map((e,t)=>[e.toUpperCase(),t])),f=new Map((n?.testPointIds??[]).map((e,t)=>[e.toUpperCase(),t]));return[...e].map((e,t)=>({row:e,index:t})).sort((e,t)=>{if(s.length){let n=L(e.row,s,c),r=L(t.row,s,c);if(n!==r)return n-r;if(n<s.length)return e.index-t.index}let n=F(e.row[i]??``,`US`)||F(e.row[o]??``,`US`),r=F(t.row[i]??``,`US`)||F(t.row[o]??``,`US`);if(l.size){let e=n?l.get(n)??l.size+1:l.size+2,t=r?l.get(r)??l.size+1:l.size+2;if(e!==t)return e-t}let u=I(n,r);if(u)return u;let d=F(e.row[o]??``,`TP`)||F(e.row[a]??``,`TP`),p=F(t.row[o]??``,`TP`)||F(t.row[a]??``,`TP`);if(f.size&&(d||p)){let e=d?f.get(d)??f.size+1:f.size+2,t=p?f.get(p)??f.size+1:f.size+2;if(e!==t)return e-t}return I(d,p)||I(String(e.row[a]??``),String(t.row[a]??``))||e.index-t.index}).map(e=>e.row)}function z(e,t){let n=[];for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}return n}function B(e,t=``,n){let r=i(e.caseType).label,o=e.templateHeaders.length>0?e.templateHeaders:[...a],s=e.outputFormat===`md`?`最终结果将保存为 Markdown 表格文件`:e.outputFormat===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,c=e.promptBody.trim();if(!c)throw Error(`请先在生成测试用例插件中选择提示词`);let l=e.templateBody?`\n\n### 用例模板:${e.templateTitle||e.templateId||``}\n${e.templateBody}`:`\n\n### 模板字段:${o.join(`、`)}`,d=e.reqBlock?`\n\n${e.reqBlock}`:``,f=e.testPointIds?.length??0,p=!!(n&&n.total>1),m=e.testPointBlock?`\n\n### 测试点(逐条覆盖,别合并成一条用例;${p?`本批 ${f||n.pointCount} 条,第 ${n.index}/${n.total} 批`:`共 ${f||`全部`} 条,下文为完整清单`})\n${e.testPointBlock}`:``,h=e.testPointBlock?p?`- 本批是第 ${n.index}/${n.total} 批,下文仅列出本批 ${f||n.pointCount} 条测试点:须逐条落到用例里;不要编写未列出的测试点;测试点的前置 / 步骤 / 预期分别对应用例的对应字段\n- 「覆盖需求率」「编写说明」只概括本批;系统会合并各批后再入库\n- 「未覆盖说明」只列本批清单里确实没写成用例的真实缺口(如缺规则、材料不足);本批已全部落成时必须输出空数组 \`[]\`;禁止写「本批仅覆盖 / 由其他批次负责 / 均已落成 / 不计入本批缺口」等分批说明(那不是缺口)\n`:`- 已选测试点共 ${f||`全部`} 条,正文已完整注入,须逐条落到用例里;测试点的前置 / 步骤 / 预期分别对应用例的对应字段。不要声称「材料未提供后半段测试点」\n`:``,g=K(o.includes(`备注`)?o:[...o,`备注`]),_=u(g),v=_.module,y=_.submodule,b=[];v&&b.push(`「${v}」对齐需求大模块 / 章节(Ideal 表填大模块原文;普通文档填对应章节名)`),y&&b.push(`「${y}」对齐需求小模块 / 小节原文,不要自造更细的名称`);let x=b.length>0?`- 字段对齐:${b.join(`;`)};用例数组严格按需求文档章节 / Ideal 小模块出现顺序输出\n`:`- 用例数组严格按需求文档章节 / 段落 / Ideal 小模块出现顺序输出(系统入库还会按此序重排)
2
- `;return`${c}
3
- ${l}${d}${m}
4
-
5
- 【运行时约束 · 生成测试用例插件已启用】
6
- - 本轮以「生成测试用例」插件所选提示词为准,不要再遵循工作台闲聊/系统提示词风格
7
- - 用例类型:${r}
8
- - ${s}
9
- ${h}- 需求名称默认可用「${t||`未命名需求`}」
10
- - 「用例」数组必须按上文材料的需求顺序输出(Ideal 小模块行序 / 需求章节 / 文档段落 / 用户故事 / 测试点清单),不要按自造模块名、优先级或维度重排
11
- ${x}- 「用例」对象键必须与当前模板字段完全一致(另可多写「备注」「引用需求点」列):${g.join(`、`)}
12
- - 仅输出一个 JSON 对象(可无代码围栏),结构为:
13
- {"需求名称":"...","覆盖需求率":0-100,"未覆盖说明":["..."],"编写说明":"...","用例":[...]}
14
- - 「引用需求点」必填:只填材料「需求条目」里真实的 \`RO-…\` id,格式为「RO-id 标题或原文摘录」(编号在前);不要填 \`US-…\`、测试点 id(\`TP-…\`)、\`全局测试点:…\`;只有用户故事时填该故事的「来源条目」RO,仍不要只写 US id
15
- - 补充扩展场景:同一「引用需求点」,并在「备注」写「补充:…」;同点内正式用例在前、补充在后
16
- - 「待业务确认 / 待确认」类不确定项也要写成用例,不要只丢进「未覆盖说明」:步骤写可执行操作,预期写「记录实际行为,规则待业务确认后回填判定口径」,并在「备注」写「待业务确认:…」(可与「补充:」并存)
17
- - 「未覆盖说明」只写确实没写成用例的缺口;已用备注标过待业务确认的不要再重复列进「未覆盖说明」;某个需求点一条引用都没有时须在未覆盖说明点名
18
- - 不要输出 JSON 以外的解释性正文;界面只会展示执行摘要,用例由系统静默入库`}function V(e,t=100){return Math.min(95,Math.max(1,Math.round(95*(1-Math.exp(-Math.max(0,e)/t)))))}function H(e=0,t){let n=Math.max(0,Math.floor(e)),r=!!(t&&t.total>1),i;if(r&&t){let e=V(n,80)/100;i=Math.min(95,Math.max(1,Math.round((t.index-1+e)/t.total*95)))}else i=V(n);return`正在编写用例…\n\n${r?`第 ${t.index}/${t.total} 批${t.label?` · ${t.label}`:``}\n`:``}进度约 ${i}% · 已用 ${n}s\n${r?`系统自动分批生成,全部完成后合并入库并给出覆盖率。`:`大文档可能需要数分钟;完成后将给出覆盖率与入库结果。`}`}function U(e){if(!e.ok)return[`**执行失败**`,``,e.error||`未知错误`,``,`可调整插件中的需求 / 模板 / 提示词后重试。`].join(`
19
- `);let t=[`**执行成功**`,``,`- 需求名称:${e.title||`—`}`,`- 共编写:${e.count??0} 条用例`,`- 覆盖需求率:${e.coverageRate==null?`未给出(已按用例入库)`:`${e.coverageRate}%`}`];e.path&&t.push(`- 入库文件:用例管理/${e.path}`),e.writeNote&&t.push(``,`**编写说明**`,e.writeNote);let n=e.uncovered??[];if(t.push(``,`**未覆盖 / 未编写原因**`),n.length)for(let e of n)t.push(`- ${e}`);else t.push(`- 无(模型未声明未覆盖项;待业务确认项已写入用例「备注」)`);let r=e.fieldGaps??[];if(r.length){t.push(``,`**字段完整性检测**`);for(let e of r)t.push(`- ${e}`)}return t.join(`
20
- `)}async function W(e){if(!t(`cases`))throw Error(n(`cases`));let r=i(e.caseType),l=`${P(e.title,e.caseType)}${e.outputFormat===`md`?`.md`:e.outputFormat===`csv`?`.csv`:`.xlsx`}`,u=e.headers.length?e.headers:[...a];return e.outputFormat===`md`?await m(`cases`,l,s(e.cases,e.title,u)):e.outputFormat===`csv`?await m(`cases`,l,o(e.cases,u)):await p(`cases`,l,await c(e.cases,u,r.label)),l}function G(e){return e.some(e=>/备注/.test(e))?e:[...e,`备注`]}function K(e){return e.some(e=>/引用需求点|需求点/.test(e)&&!/需求编号/.test(e))?e:[...e,`引用需求点`]}var q=/\bRO-[A-Za-z0-9_-]+\b/gi,J=/\bUS-\d+\b/gi;function Y(e,t=``){let n=String(e??``).trim(),r=String(t??``).replace(/\s+/g,` `).trim();return n?r?r===n||r.toUpperCase().startsWith(n.toUpperCase()+` `)||RegExp(`^${n}\\b`,`i`).test(r)?r:`${n} ${r}`:n:r}function X(e,t){let n=[],r=new Set;for(let i of String(e??``).matchAll(t)){let e=/^US-/i.test(i[0])?i[0].toUpperCase():i[0].replace(/^ro-/i,`RO-`),t=e.toUpperCase();r.has(t)||(r.add(t),n.push(e))}return n}function ie(e,t){let n=String(e??``).trim();if(!n)return``;n=n.replace(/全局测试点\s*[::]\s*/g,``).replace(/来源故事\s*[::]\s*/gi,``).replace(/\s+/g,` `).trim();let r=X(n,q),i=X(n,J),a=t?.outlineById,o=t?.storySourceRefs,s=e=>{let t=a?.get(e)??a?.get(e.toUpperCase());if(!t&&a){for(let[n,r]of a)if(n.toUpperCase()===e.toUpperCase()){t=r;break}}return Y(e,(t?.quote||t?.title||``).replace(/\s+/g,` `).trim())};if(r.length)return r.map(s).join(`;`);if(i.length&&o){let e=[],t=new Set;for(let n of i){let r=o.get(n)??o.get(n.toUpperCase())??[];for(let n of r){let r=n.toUpperCase();t.has(r)||(t.add(r),e.push(s(n)))}}if(e.length)return e.join(`;`)}if(i.length&&!r.length){let e=n;for(let t of i)e=e.replace(new RegExp(t,`ig`),` `);return e=e.replace(/[/||,,;;]+/g,` `).replace(/\s+/g,` `).trim(),e||n}return n}function ae(e){let t=new Map,n=String(e??``).split(/\n/);for(let e=0;e<n.length;e++){let r=n[e]??``,i=r.match(/\*\*(RO-[A-Za-z0-9_-]+)\*\*\s*(.+)?$/)||r.match(/\b(RO-[A-Za-z0-9_-]+)\b\s+(.+)$/);if(!i)continue;let a=i[1],o=(i[2]??``).replace(/\*\*/g,``).trim(),s=``,c=(n[e+1]??``).match(/^\s*>\s*(.+)$/);c&&(s=c[1].trim()),!o&&s&&(o=s.slice(0,80)),t.has(a)||t.set(a,{title:o,quote:s||void 0})}return t}function oe(e){let t=new Map,n=String(e??``).split(/^###\s+/m).slice(1);for(let e of n){let n=e.match(/^(US-\d+)\b/);if(!n)continue;let r=n[1],i=e.match(/\*\*来源条目\*\*[::]\s*(.+)/);if(!i)continue;let a=X(i[1],q);a.length&&t.set(r,a)}return t}function se(e,t,n){let r=u(t).reqCite||t.find(e=>/引用需求点|需求点/.test(e)&&!/需求编号/.test(e));return r?e.map(e=>{let t=e[r];if(t==null||!String(t).trim())return e;let i=ie(String(t),n);return i===String(t).trim()?e:{...e,[r]:i}}):e}var ce=/待业务确|待确认|业务确认/;function Z(e){return e.find(e=>/备注/.test(e))??`备注`}function Q(e){return e.find(e=>/用例标题|测试分项目|用例名称|标题/.test(e))??e.find(e=>e.includes(`标题`))??`用例标题`}function le(e){for(let t of[`备注`,`备注说明`,`说明`,`remark`,`note`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return``}function ue(e,t,n){let r=Z(n),i=Q(n),a=[],o=[];for(let e of t){let t=String(e??``).trim();if(!t||!ce.test(t)){t&&a.push(t);continue}let s=t.replace(/^[-*·\s]+/,``).split(/[。;;\n]/)[0]?.trim()||t,c=(s.length>48?`${s.slice(0,48)}…`:s).replace(/^待业务确认[::]\s*/u,``),l={};for(let e of n)l[e]=``;l[i]=c||`待业务确认项`,n.includes(`优先级`)&&(l.优先级=`P2`),n.includes(`用例类型`)&&(l.用例类型=`功能测试`);let u=n.find(e=>/步骤/.test(e)),d=n.find(e=>/预期|期望|结果标准/.test(e));u&&(l[u]=`1、按需求描述完成相关操作
21
- 2、记录系统实际行为与提示文案`),d&&(l[d]=`记录实际行为;业务规则确认前不做通过/失败判定,确认后回填判定口径`),l[r]=t.startsWith(`待业务确认`)?t:`待业务确认:${t}`,o.push(l)}return{cases:[...e,...o],uncovered:a}}function de(e,t){let n=Z(t);return e.map(e=>{if(!e||typeof e!=`object`)return e;let t={...e};if(!String(t[n]??``).trim()){let e=le(t);e&&(t[n]=e)}return t})}function fe(e){let t=String(e||``).trim();return!t||/本批仅覆盖|本批只覆盖|本批只负责|本批仅负责/.test(t)||/由其他批次|其他批次负责|其余批次|后续批次/.test(t)||/不计入本批缺口|不算本批缺口|非本批缺口/.test(t)||/均已落成用例|均已写成用例|本批.*全部落成|本批测试点.*均已/.test(t)||/指定的\s*\d+\s*条测试点/.test(t)}function pe(e){if(!e.length)return null;let t=[],n=[],r=new Set,i=[],a=0,o=0,s=``;for(let c of e){!s&&c.docTitle&&(s=c.docTitle),Array.isArray(c.cases)&&t.push(...c.cases);for(let e of c.uncovered){let t=e.trim();!t||r.has(t)||fe(t)||(r.add(t),n.push(t))}if(c.writeNote.trim()&&i.push(c.writeNote.trim()),c.coverageRate!=null&&Number.isFinite(c.coverageRate)){let e=Math.max(1,c.cases.length||1);a+=c.coverageRate*e,o+=e}}return t.length?{docTitle:s,cases:t,coverageRate:o>0?Math.round(a/o):null,uncovered:n,writeNote:i.length?i.length===1?i[0]:i.map((e,t)=>`(第 ${t+1} 批)${e}`).join(`
22
- `):``}:null}async function $(e,t,n,r){let o=K(G(t.templateHeaders.length>0?t.templateHeaders:[...a])),s=ue(e.cases,e.uncovered,o),c=de(s.cases,o),f=D(t),p=f?.kind===`stories`?f.storyIds:void 0,m=re(t.reqBlock),h=ae(t.reqBlock??``),g=oe(t.reqBlock??``),_=R(se(l(c,o),o,{outlineById:h,storySourceRefs:g}),o,{storyIds:p,testPointIds:t.testPointIds,idealOrder:m});if(r?.renumber||m.length){let e=u(o).no||d.no;o.includes(e)&&_.forEach((t,n)=>{t[e]=String(n+1)})}let v=(n||t.docTitle||``).trim()||e.docTitle||i(t.caseType).label,y=z(_,o);try{let n=await W({cases:_,headers:o,caseType:t.caseType,outputFormat:t.outputFormat,title:v}),r=U({ok:!0,title:v,path:n,count:_.length,coverageRate:e.coverageRate,uncovered:s.uncovered,writeNote:e.writeNote,fieldGaps:y});return{ok:!0,path:n,count:_.length,title:v,coverageRate:e.coverageRate,uncovered:s.uncovered,writeNote:e.writeNote,fieldGaps:y,summary:r}}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,error:t,summary:U({ok:!1,error:t})}}}async function me(e,t,n){let r=O(e);if(!r){let e=`未能解析出用例结果,未写入文件`;return{ok:!1,error:e,summary:U({ok:!1,error:e})}}return $(r,t,n)}async function he(e,t,n){let r=[];for(let t of e){let e=O(t.raw);if(!e){let e=`第 ${t.index}/${t.total} 批未能解析出用例结果,未写入文件`;return{ok:!1,error:e,summary:U({ok:!1,error:e})}}r.push(e)}let i=pe(r);if(!i){let e=`各批均未解析出用例,未写入文件`;return{ok:!1,error:e,summary:U({ok:!1,error:e})}}return $(i,t,n,{renumber:!0})}export{H as a,ne as c,te as d,w as f,j as i,T as l,M as n,me as o,E as p,P as r,he as s,B as t,ee as u};
@@ -1 +0,0 @@
1
- import{r as e,t,u as n}from"./app-config.DAIyT--R.js";var r=[`内置插件`,`测试技能`,`需求管理`,`生成能力`,`记忆与检索`,`待办与效率`,`项目管理`,`仪表盘`,`开发工具`],i=[{id:`cases`,category:`测试技能`,name:`用例管理`,description:`侧栏进入用例库:浏览、搜索、打开与删除用例。关闭后入口隐藏,「生成测试用例」一并关闭;磁盘文件仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`caseGen`,category:`测试技能`,name:`生成测试用例`,description:`在工作台用「/」打开配置:选类型、模板与提示词后生成用例并写入用例库。需同时开启「用例管理」。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0,requires:`cases`},{id:`prompts`,category:`内置插件`,name:`提示词管理`,description:`侧栏进入提示词库:浏览、搜索、打开与删除提示词,并维护当前空间的「默认提示词」。每个空间都需要,属于内置能力,常开且没有开关。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!0,alwaysOn:!0},{id:`promptGen`,category:`内置插件`,name:`生成提示词`,description:`用「/」打开配置后对话生成提示词;质检通过后写入提示词库。属于内置能力,默认常开、没有开关。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!0,alwaysOn:!0,hasPanel:!0,requires:`prompts`},{id:`knowledgeLib`,category:`测试技能`,name:`知识库管理`,description:`侧栏进入知识库:浏览、搜索、打开与删除文档。关闭后入口隐藏,「生成知识库」一并关闭;磁盘文件仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`knowledgeGen`,category:`测试技能`,name:`生成知识库`,description:`用「/」打开配置后对话生成规范、方法论或环境约定;质检通过后写入知识库。需同时开启「知识库管理」。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0,requires:`knowledgeLib`},{id:`requirements`,category:`需求管理`,name:`需求文档库`,description:`侧栏进入需求文档库:浏览、搜索、上传与整理需求文档。关闭后入口隐藏;磁盘文件仍保留,生成用例时也不再引用。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`templates`,category:`测试技能`,name:`测试模板库`,description:`侧栏进入测试模板库:浏览、上传与整理用例 / 报告模板。关闭后入口隐藏;磁盘文件仍保留,生成用例时不再选用模板。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`knowledge`,category:`记忆与检索`,name:`知识库检索`,description:`工作台输入「@」引用知识库与模板文档;发送后由模型按需读取。关闭后 @ 只列工作区文件。`,version:`1.4.0`,requiresDev:!1,defaultEnabled:!1},{id:`memory`,category:`记忆与检索`,name:`会话记忆`,description:`五轨记忆(用户档案 / 全局事实 / 项目关键 / 项目日志 / 每日):待确认、归档与便签,在工作台「记忆」Tab 管理。`,version:`2.0.0`,requiresDev:!0,defaultEnabled:!1},{id:`todos`,category:`待办与效率`,name:`待办事项`,description:`侧栏进入待办事项:按状态 / 紧急程度筛选、行内改状态与手动维护;工作台会话也能通过工具直接记录与更新同一份待办。关闭后入口隐藏,磁盘数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`tasks`,category:`待办与效率`,name:`任务管理`,description:`侧栏进入任务列表:按任务池 / 进行中 / 已完成 / 已关闭 / 已取消跟踪任务,并汇总每个任务下关联待办的数量与完成进度。关闭后入口隐藏,磁盘数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`reports`,category:`待办与效率`,name:`工作汇报`,description:`打开后在工作台注入「工作汇报提示词」,并把这份提示词写进提示词管理,方便随时修改;关闭时只停用,提示词文件保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`projects`,category:`项目管理`,name:`项目列表`,description:`侧栏进入项目列表:进度 / 规划 / 归档三种状态的项目卡片,汇总每个项目下的迭代、需求与缺陷数量;支持搜索、归档与删除。关闭后入口隐藏,数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`iterations`,category:`项目管理`,name:`迭代管理`,description:`侧栏进入迭代管理:按项目维护迭代的开始 / 截止日期与状态,按日期流逝算进度并标出逾期。需同时开启「项目列表」。关闭后入口隐藏,数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,requires:`projects`},{id:`pmRequirements`,category:`项目管理`,name:`需求管理`,description:`侧栏进入需求管理:按项目 / 迭代维护需求编号、优先级、状态与验收标准;需求挂在项目下,可关联迭代。需同时开启「项目列表」。关闭后入口隐藏,数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,requires:`projects`},{id:`bugs`,category:`项目管理`,name:`缺陷管理`,description:`侧栏进入缺陷管理:按项目 / 迭代 / 需求记录缺陷,含严重程度、状态、重现步骤、期望与实际结果;关闭后入口隐藏,数据仍保留。需同时开启「项目列表」。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,requires:`projects`},{id:`testStats`,category:`测试技能`,name:`测试统计`,description:`侧栏进入测试统计:按当前日期与测试统计维度(功能用例 / 自动化用例 / 接口用例 / 测试报告 / 缺陷统计等)记录统计数量,维度可搜索或直接创建。打开开关即在当前空间生成 测试统计/测试统计.json。关闭后入口隐藏,磁盘数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`caseExec`,category:`测试技能`,name:`用例执行统计`,description:`侧栏进入用例执行统计:按项目记录用例总数、待执行与已执行数量,自动计算当前剩余用例与执行比例;项目名称可搜索或直接创建。打开开关即在当前空间生成 用例执行统计/用例执行统计.json。关闭后入口隐藏,磁盘数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`uiAuto`,category:`测试技能`,name:`自动化测试`,description:`侧栏进入自动化测试:把已有的 Playwright / pytest / Selenium 项目挂进来(系统原生选目录,自动识别框架),一键运行 / 停止用例(先跑全量),实时看日志,查看 HTML 报告与结构化结果。执行的是目标项目自己的测试命令,不会自动安装依赖或联网。打开开关时在「提示词管理」生成「Playwright提示词.md」(已存在不覆盖,生成页优先用它,插件开启期间不可删除)。关闭后入口隐藏,项目记录与报告仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`reqAnalysis`,category:`需求管理`,name:`需求分析`,description:`侧栏进入需求分析:选「需求文档库」里的原始需求,用当前模型拆成结构化用户故事(角色 / 前置 / 主流程 / 替代 / 异常 / 后置 / 验收),可编辑、可导出 Markdown;打开时默认一并开启「用户故事审查」,拆完可做体检。打开开关时在「提示词管理」生成「需求分析提示词.md」(只有「拆解」一段,已存在不覆盖,插件开启期间不可删除)。关闭后入口隐藏,已保存的分析仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`storyReview`,category:`需求管理`,name:`用户故事审查`,description:`打开后不新增侧栏入口:在「需求分析」页里多出「用户故事审查」按钮与「审查结果」Tab,对拆好的用户故事做系统性体检——先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失,缺口按类型分组、可勾选补写、可导出 Markdown。开启「需求分析」时默认一并打开,也可单独关掉。打开开关时在「提示词管理」生成「用户故事审查提示词.md」(已存在不覆盖,插件开启期间不可删除)。关闭后这些入口隐藏,审查结果仍保留在分析里。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!0,requires:`reqAnalysis`,autoEnableWith:`reqAnalysis`},{id:`testPoints`,category:`需求管理`,name:`生成测试点`,description:`打开后不新增侧栏入口:在「需求分析」页里多出「生成测试点」按钮与「测试点」Tab,基于拆好的用户故事按功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度拆测试点,每条标注 P0–P3 优先级;界面与导出按 Ideal「一行一条」需求标题 → 五维 → 测试点归组(列表 / 左右导图 / XMind 向右逻辑图 / Markdown),可下载。开启「需求分析」时默认一并打开,也可单独关掉。打开开关时在「提示词管理」生成「测试点生成提示词.md」(已存在不覆盖,插件开启期间不可删除)。关闭后这些入口隐藏,已生成的测试点仍保留在分析里。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!0,requires:`reqAnalysis`,autoEnableWith:`reqAnalysis`},{id:`caseReview`,category:`测试技能`,name:`用例质量评审`,description:`打开后不新增侧栏入口:在「用例管理」文件行上多出「评审」按钮与评审列,打开抽屉对整份用例做分级质检——逐条判定可用 / 待修改 / 错误无效,五维打分(需求覆盖 / 步骤可执行 / 预期可判定 / 数据与边界 / 规范完整),另给七项量化指标与逐条扣分原因、改进建议;报告可导出 Markdown。开启「用例管理」时默认一并打开,也可单独关掉。打开开关时在「提示词管理」生成「用例质量评审提示词.md」(已存在不覆盖,插件开启期间不可删除)。关闭后入口隐藏,评审结果仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,requires:`cases`,autoEnableWith:`cases`},{id:`caseBlindspot`,category:`测试技能`,name:`场景遗漏补全`,description:`打开后不新增侧栏入口:在「用例管理」的评审抽屉里多出「场景补全」Tab,专挖人工最容易漏的场景——非功能 / 安全边界与容错 / 兼容性 / 隐藏业务规则,逐条给出为什么容易漏与建议用例;勾选后跳到这条用例绑定的工作台会话,由模型按文件表头补进原用例文件(写前自动备份)。可根据文件名自动挂上对照需求。开启「用例管理」时默认一并打开,也可单独关掉。打开开关时在「提示词管理」生成「场景遗漏补全提示词.md」(已存在不覆盖,插件开启期间不可删除)。关闭后入口隐藏,探测结果仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,requires:`cases`,autoEnableWith:`cases`},{id:`dashboard`,category:`仪表盘`,name:`仪表盘`,description:`侧栏进入仪表盘:把当前空间的待办、任务、项目与测试统计聚合成一页(指标卡、倒计时、今日待办、进行中任务、测试统计柱状图、飞书式待办日历)。首次打开是空白画布,需在「编辑组件」里自行添加卡片;待办 / 任务为表格 + 分页。卡片摆在 12 列自由画布上,按住顶部圆点手柄拖位置、拖右下角把手改宽高,挡住相邻卡片时松手把它们挤开或让位;布局按空间记在浏览器本地。关闭后入口隐藏,数据仍保留。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1},{id:`pluginDev`,category:`开发工具`,name:`插件开发`,description:`用固定提示词开发扩展插件:先评估形态与范围并用选项确认,确认后才改代码,完成后并入「扩展插件」。需要读写项目源码。`,version:`0.1.0`,requiresDev:!0,defaultEnabled:!1,hasPanel:!0}];function a(e=i){return r.map(t=>({category:t,items:e.filter(e=>e.category===t)})).filter(e=>e.items.length>0)}var o=`tw-plugins-changed`;function s(){let e={};for(let t of i)e[t.id]=t.defaultEnabled;return e}function c(e,t){let n={...e};if(t&&!m(t.id)?.alwaysOn){if(n[t.id]=t.enabled,t.enabled){let e=m(t.id)?.requires;e&&(n[e]=!0);for(let e of i)e.autoEnableWith===t.id&&(n[e.id]=!0)}else for(let e of i)e.requires===t.id&&(n[e.id]=!1)}for(let e of i)e.alwaysOn&&(n[e.id]=!0);for(let e of i)e.requires&&!n[e.requires]&&(n[e.id]=!1);return n}function l(){let t=s(),n=e().plugins??{};for(let e of i)typeof n[e.id]==`boolean`&&(t[e.id]=n[e.id]);return c(t)}function u(e){return l()[e]}function d(e){let t=s();for(let n of i)typeof e[n.id]==`boolean`&&(t[n.id]=e[n.id]);return c(t)}function f(e,r){if(m(e)?.alwaysOn)return l();let i=c(l(),{id:e,enabled:r});return n({plugins:i}),t(),typeof window<`u`&&window.dispatchEvent(new CustomEvent(o,{detail:i})),i}function p(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail;e(n??l())};return window.addEventListener(o,t),()=>{window.removeEventListener(o,t)}}function m(e){return i.find(t=>t.id===e)}function h(e){let t=m(e),n=t?.name??e;return t?.requires&&!u(t.requires)?`请先在「我的插件」中启用「${m(t.requires)?.name??t.requires}」`:`请先在「我的插件」中启用「${n}」`}export{l as a,d as c,u as i,f as l,m as n,p as o,a as r,h as s,i as t};
@@ -1,23 +0,0 @@
1
- var e=`/__tb_reqanalysis`,t=`需求分析提示词.md`,n=`需求分析`,r={draft:{label:`待拆解`,tone:`gray`},decomposed:{label:`已拆解`,tone:`blue`},checked:{label:`已审查`,tone:`amber`},accepted:{label:`已验收`,tone:`green`}},i={P0:`red`,P1:`amber`,P2:`gray`},a={"uncovered-outline":`待确认·未覆盖`,"pending-confirm":`待确认`,"missing-field":`字段缺失`,"missing-scenario":`场景遗漏`,"missing-dimension":`维度缺失`,"untestable-acceptance":`验收不可测`,conflict:`与原文冲突`,"over-split":`过度拆分`,other:`其它`},o=new Set([`uncovered-outline`,`pending-confirm`,`conflict`,`other`]);function s(e){return o.has(e.type)}function c(e){return e.filter(s)}var l={high:`高`,medium:`中`,low:`低`},u={high:`red`,medium:`amber`,low:`gray`},d=[{key:`permission`,label:`权限与角色`,keywords:[`权限`,`角色`,`授权`,`越权`,`未登录`,`登录`,`管理员`,`普通用户`],hint:`补充不同角色 / 未登录 / 越权访问时这条流程的行为。`},{key:`boundary`,label:`边界值`,keywords:[`边界`,`上限`,`下限`,`最大`,`最小`,`长度`,`超长`,`字数`,`为空`,`空值`],hint:`补充字段长度、数量上限、刚好等于阈值时的表现。`},{key:`concurrency`,label:`并发与幂等`,keywords:[`并发`,`重复`,`幂等`,`同时`,`加锁`,`冲突`,`重复提交`],hint:`补充重复提交、多人同时操作同一数据时的结果。`},{key:`empty`,label:`空数据`,keywords:[`空数据`,`无数据`,`没有数据`,`空列表`,`暂无`,`空态`],hint:`补充列表为空、首次使用、数据被清空时的空态。`},{key:`failure`,label:`超时与失败`,keywords:[`超时`,`失败`,`异常`,`错误`,`重试`,`断网`,`不可用`,`降级`,`回滚`],hint:`补充依赖超时、接口失败、网络中断时的提示与回滚。`},{key:`i18n`,label:`国际化与时区`,keywords:[`国际化`,`时区`,`多语言`,`语言`,`翻译`,`utc`,`夏令时`],hint:`补充跨时区时间展示、多语言文案与本地化格式。`}],f=/创建|新增|新建|保存|提交|删除|编辑|修改|更新|上传|导入|导出|发布|审批|撤回|绑定|解绑|发送|支付|下单|配置|启停|启用|停用/;async function p(t,n){let r=await fetch(`${e}${t}`,{...n,headers:n?.body===void 0?void 0:{"Content-Type":`application/json`,...n?.headers}}),i=await r.json().catch(()=>({}));if(!r.ok||i.ok===!1)throw Error(i.error||`HTTP ${r.status}`);return i}async function ee(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function te(){return(await p(`/list`)).docs??[]}async function ne(e){return(await p(`/create`,{method:`POST`,body:JSON.stringify(e)})).doc}async function re(e,t){return(await p(`/`,{method:`PUT`,body:JSON.stringify({id:e,...t})})).doc}async function ie(e){await p(`/delete`,{method:`POST`,body:JSON.stringify({id:e})})}async function ae(){try{let e=await p(`/prompt`),t=e.decompose??``,n=e.stories??``;return{file:e.file||`需求分析提示词.md`,exists:e.exists===!0,decompose:t,stories:n||t,audit:e.audit??``,fix:e.fix??``}}catch(e){return{file:t,exists:!1,decompose:``,stories:``,audit:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function oe(e){return await p(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}async function m(e){return(await le(e)).content}async function se(e,t=2e4){try{let n=(await m(e)).trim();return{text:n.slice(0,t),total:n.length,truncated:n.length>t}}catch{return{text:``,total:0,truncated:!1}}}async function ce(){return(await p(`/sources`)).files??[]}async function le(e){return p(`/source?path=${encodeURIComponent(e)}`)}var ue=/[\s\p{P}\p{S}]+/gu;function h(e){return String(e??``).toLowerCase().replace(ue,``)}function g(e){return Array.from(new Set(e.map(e=>String(e??``).trim()).filter(Boolean)))}function _(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function v(e,t=30,n=500){return Array.isArray(e)?e.map(e=>_(e,n)).filter(Boolean).slice(0,t):[]}function y(e){let t=2166136261,n=String(e??``);for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function de(e){return y(String(e??``))}function b(e,t=80){return String(e??``).replace(/\s+/g,` `).trim().slice(0,t)}function fe(e){let t=String(e.sourceTitle||e.sourcePath||``).trim();if(t){let e=t.split(/[/\\]/).pop()?.trim();if(e)return e}return String(e.title||``).trim()||`未命名文档`}function pe(e){return b((String(e??``).split(/[/\\]/).pop()?.replace(/\.[^.]+$/,``).trim()||``).replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).trim())||`未命名需求`}function x(e){return String(e.sourceTitle||e.title||``).trim()||pe(e.sourcePath)}function me(e){let t=String(e??``).split(/[/\\]/).pop()?.trim()||``;return t=t.replace(/\.(xlsx|xls|docx|doc|md|txt|csv)$/i,``),t.replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).replace(/迭代版本$/u,``).replace(/版本$/u,``).trim()}function S(e){let t=me(e);return t=t.replace(/v?\d+(?:\.\d+)*/gi,``),t.replace(/[\s_\-—·()()[\]【】]+/gu,``).toLowerCase()}function C(e){let t=me(e),n=/v(\d+(?:\.\d+)*)/i.exec(t)||/(\d+(?:\.\d+)+)/.exec(t);return n?.[1]?n[1].split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0}):null}function w(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]??0,i=t[r]??0;if(n!==i)return n-i}return 0}function he(e,t){let n=x(e),r=S(n),i=C(n);return!r||!i?[]:t.filter(t=>{if(t.id===e.id)return!1;let n=x(t);if(S(n)!==r)return!1;let a=C(n);return a?w(a,i)<0:!1}).sort((e,t)=>w(C(x(e))??[],C(x(t))??[]))}function ge(e){let t=[];for(let n of e){let e=x(n);for(let r of A(n.outline))t.push({docId:n.id,docLabel:e,point:r})}return t}function T(e){let t=String(e??``).toLowerCase().replace(/\s+/g,` `).trim();if(!t)return[];let n=[];for(let e of t.matchAll(/[a-z0-9_]{2,}|[\u4e00-\u9fff]{2}/gu))n.push(e[0]);let r=t.replace(/[^\u4e00-\u9fff]/g,``);for(let e=0;e<r.length-1;e++)n.push(r.slice(e,e+2));return[...new Set(n)].slice(0,80)}var _e=40,ve=7e3;function ye(e,t,n){if(!t.length)return[];let r=Math.max(1,n?.maxItems??_e),i=Math.max(200,n?.maxChars??ve),a=T(e),o=String(e??``).toLowerCase();if(!a.length&&!o.trim())return[];let s=[];for(let e of t){let t=e.point.title||``,n=(e.point.quote||e.point.body||``).slice(0,200);`${t} ${n}`.toLowerCase();let r=0;t&&o.includes(t.toLowerCase())&&(r+=8),n&&n.length>=4&&o.includes(n.toLowerCase().slice(0,40))&&(r+=5);let i=T(`${t} ${n}`);for(let e of i)a.includes(e)&&(r+=e.length>=3?2:1);r<=0||s.push({...e,score:r})}s.sort((e,t)=>t.score-e.score||e.docLabel.localeCompare(t.docLabel,`zh`)||e.point.id.localeCompare(t.point.id));let c=[],l=0;for(let e of s){if(c.length>=r)break;let t=E(e);if(c.length>0&&l+t.length+1>i)break;c.push(e),l+=t.length+1}return c}function E(e){let t=e.point.kind===`query`?`查询`:e.point.kind===`mutate`?`修改`:`子点`,n=(e.point.quote||e.point.body||``).replace(/\s+/g,` `).trim().slice(0,120);return`- [${e.docLabel}] ${e.point.id} [${t}] ${e.point.title}${n?`(${n})`:``}`}function be(e){return e.length?[`## 历史迭代需求条目(检索参考,勿当作本版文档条目 id)`,`来源版本:${[...new Set(e.map(e=>e.docLabel))].join(`、`)}。下列 id 属于历史分析,禁止写入本版 sourceRefs;仅作能力对照与延伸参考。`,...e.map(E)].join(`
2
- `):``}function xe(e,t){if(!e?.length)return[];let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t);e&&A(e.outline).length&&r.push(e)}return r}function D(e){let t=String(e??``).trim();return t?!!(/^"+,{2,}/.test(t)||/^,{2,}/.test(t)&&/(待开发|已开发|需求\s*,\s*高|v\d+\.\d+)/.test(t)||!/【/.test(t)&&!/^\d+[、.]/.test(t)&&/,/.test(t)&&/(待开发|已关闭|已完成|需求\s*,\s*[高低中]|v\d+\.\d+|^\d{4}年\d{1,2}月)/.test(t)):!1}function Se(e){let t=String(e??``);if(!t)return``;if(t.startsWith(`"`)){let e=1,n=``;for(;e<t.length;){let r=t[e];if(r===`"`){if(t[e+1]===`"`){n+=`"`,e+=2;continue}return n}n+=r,e+=1}return n}let n=t.search(/,{2,}|(?:,\s*(?:待开发|需求\s*,|v\d+))/);return(n>=0?t.slice(0,n):t).trim()}function Ce(e){let t=String(e??``),n=t.search(/"\s*,{2,}/);n>=0&&(t=t.slice(0,n));let r=t.split(`
3
- `),i=[];for(let e of r){if(D(e))break;let t=e.search(/"\s*,{2,}/);if(t>=0){i.push(e.slice(0,t));break}i.push(e)}return i.join(`
4
- `).replace(/^"/,``).replace(/"$/,``).trim()}function we(e){let t=Ce(e.body).slice(0,4e3),n=b(t.match(/【([^】\n]{1,40})】/)?.[1]||e.title||e.small);return{...e,title:n||e.small,body:t||`【${n||e.small}】`}}function O(e){let t=String(e??``).replace(/\r\n/g,`
5
- `).trim();if(!t||!t.split(`
6
- `).find(e=>/大模块/.test(e)&&/小模块/.test(e)))return[];let n=[],r=new Set,i=null,a=()=>{i&&=(n.push(we(i)),null)};for(let e of t.split(`
7
- `)){if(/^#{1,3}\s/.test(e)){a();continue}if(/^大模块/.test(e))continue;let t=e.match(/^"?([^,"\n]{1,40})"?,"?([^,"\n]{1,40})"?,([\s\S]*)$/);if(t){let e=t[1].trim(),n=t[2].trim();if(!n||n===`小模块`||e===`大模块`||/[。;;]/.test(n)||n.length>30||(a(),r.has(n)))continue;r.add(n),i={big:e,small:n,title:n,body:Se(t[3]||``)}}else if(i){if(D(e)){a();continue}let t=e.search(/"\s*,{2,}/);if(t>=0){let n=e.slice(0,t);i={...i,body:i.body?`${i.body}\n${n}`:n},a();continue}i={...i,body:i.body?`${i.body}\n${e}`:e}}}return a(),n}function Te(e){let t=O(e);if(t.length)return t.map(e=>({title:e.small||e.title,body:e.body||`【${e.title}】`,quote:(e.body||e.title).replace(/\s+/g,` `).slice(0,80)}));let n=String(e??``).replace(/\r\n/g,`
8
- `).trim();if(!n)return[];let r=[],i=/^(概述|简介|目录|修订|附录|背景|术语|参考)/,a=n.split(/(?=^#{2,3}\s+)/m).filter(e=>e.trim());if(a.length>1||/^#{2,3}\s+/m.test(n)){for(let e of a){let t=e.match(/^#{2,3}\s+(.+?)\s*$/m);if(!t)continue;let n=b(t[1]??``);if(!n||n.length>40||i.test(n))continue;let a=e.replace(/^#{2,3}\s+.+?\s*\n?/,``).trim().slice(0,4e3);(a||!r.some(e=>e.title===n))&&r.push({title:n,body:a||n,quote:(a||n).replace(/\s+/g,` `).slice(0,80)})}if(r.length)return k(r)}return k(Z(e).map(e=>({title:e,body:e,quote:e.slice(0,80)})))}function k(e){let t=new Set,n=[];for(let r of e){let e=r.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``);e&&!t.has(e)&&(t.add(e),n.push(r))}return n}function Ee(e,t=[]){let n=Te(e);if(!n.length)return t.filter(e=>!e.kind);let r=new Map(t.filter(e=>!e.kind&&!e.parentId).map(e=>[e.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``),e])),i=new Set(t.map(e=>e.id)),a=[];n.forEach((e,t)=>{let n=e.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``),o=r.get(n);if(o){a.push({...o,title:e.title,quote:e.quote||o.quote,body:e.body||o.body,kind:void 0,parentId:void 0});return}let s=`RO-E-${t+1}`,c=1;for(;i.has(s);)s=`RO-E-${t+1}-${c++}`;i.add(s),a.push({id:s,title:e.title,quote:e.quote,body:e.body})});let o=new Set(a.map(e=>e.id)),s=t.filter(e=>e.parentId&&o.has(e.parentId));return[...a,...s]}function A(e){let t=e.filter(e=>e.kind&&e.parentId);return t.length?t:e.filter(e=>!e.parentId)}function De(e,t){let n=new Set(t.flatMap(e=>e.sourceRefs));return A(e).filter(e=>!n.has(e.id))}function Oe(e,t=12){let n=Math.max(1,Math.floor(t)||12),r=A(e);if(!r.length)return[];let i=e.filter(e=>!e.parentId&&!e.kind),a=new Map(i.map(e=>[e.id,e])),o=new Map,s=[];for(let e of r){let t=e.parentId||``;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=[],l=(e,t)=>{for(let r=0;r<t.length;r+=n)c.push({parent:e,mustCover:t.slice(r,r+n)})};for(let e of i){let t=o.get(e.id);t?.length&&l(e,t)}return s.length&&l(null,s),c}function ke(e,t){let n=String(e??``);if(!n)return 2**53-1;let r=q(t,n);return r>=0?r:2**53-1}function j(e,t){if(t.length<=1)return[...t];let n=e.body||e.quote||``;return[...t].map((e,t)=>({p:e,index:t,rank:ke(n,e)})).sort((e,t)=>e.rank===t.rank?e.index-t.index:e.rank-t.rank).map(e=>e.p)}function M(e,t){return`${e}-${t}`}function N(e,t){return e.filter(e=>e.parentId===t)}function P(e,t,n){let r=new Map,i=n.map((e,n)=>{let i=M(t,n+1),a=e.id;a&&!a.startsWith(`__new_`)&&a!==i&&r.set(a,i);let o={id:i,title:e.title,quote:e.quote,kind:e.kind,parentId:t};return e.body&&(o.body=e.body),o}),a=e.filter(e=>e.parentId!==t),o=a.findIndex(e=>e.id===t);return{outline:o<0?[...a,...i]:[...a.slice(0,o+1),...i,...a.slice(o+1)],idMap:r}}function F(e,t){let n=N(e,t.id);if(!n.length)return{outline:[...e],idMap:new Map};let r=j(t,n);return P(e,t.id,r)}function Ae(e){let t=[...e],n=new Map,r=t.filter(e=>!e.parentId&&!e.kind);for(let e of r){let r=F(t,e);t=r.outline;for(let[e,t]of r.idMap)n.set(e,t)}return{outline:t,idMap:n}}function I(e,t){let n=e.find(e=>e.id===t);if(!n?.parentId||!n.kind)return{outline:[...e],pointId:t,idMap:new Map,parentId:``,error:`必须是已有的查询/修改子点`};let r=e.find(e=>e.id===n.parentId&&!e.parentId&&!e.kind);if(!r)return{outline:[...e],pointId:t,idMap:new Map,parentId:n.parentId,error:`找不到所属需求条目`};if(N(e,r.id).every(e=>e.id.startsWith(`${r.id}-`)))return{outline:[...e],pointId:t,idMap:new Map,parentId:r.id};let i=F(e,r),a=i.idMap.get(t)??t;return{outline:i.outline,pointId:a,idMap:i.idMap,parentId:r.id}}function L(e,t){let n=new Map;for(let[r,i]of e)n.set(r,t.get(i)??i);for(let[e,r]of t)n.has(e)||n.set(e,r);return n}function je(e,t,n){let r=I(e,t);if(r.error)return{outline:[...e],idMap:new Map,addedIds:[],error:r.error.includes(`必须是`)?`afterId 必须是已有的查询/修改子点`:r.error};if(!n.length)return{outline:r.outline,idMap:r.idMap,addedIds:[]};let i=r.parentId,a=N(r.outline,i),o=a.findIndex(e=>e.id===r.pointId);if(o<0)return{outline:r.outline,idMap:r.idMap,addedIds:[],error:`找不到锚点子点`};let s=n.map((e,t)=>{let n={id:`__new_${t}`,title:e.title,quote:e.quote,kind:e.kind,parentId:i};return e.body&&(n.body=e.body),n}),c=[...a.slice(0,o+1),...s,...a.slice(o+1)],l=P(r.outline,i,c),u=n.map((e,t)=>M(i,o+2+t));return{outline:l.outline,idMap:L(r.idMap,l.idMap),addedIds:u}}function Me(e,t){let n=I(e,t);if(n.error)return{outline:[...e],idMap:new Map,removedId:t,removedIds:new Set([t]),error:n.error.includes(`必须是`)?`只能删除查询/修改子点`:n.error};let r=n.parentId,i=n.pointId,a=new Set([t,i]);for(let[e,t]of n.idMap)(t===i||e===i)&&a.add(e);let o=N(n.outline,r).filter(e=>e.id!==i),s=P(n.outline,r,o),c=new Map([...n.idMap].filter(([e,t])=>!a.has(e)&&!a.has(t)));return{outline:s.outline,idMap:L(c,s.idMap),removedId:i,removedIds:a}}function Ne(e,t,n){let r=e.findIndex(e=>e.id===t);if(r<0)return{outline:[...e],error:`找不到需求点`};let i=e[r];if(!i.parentId||!i.kind)return{outline:[...e],error:`只能修改查询/修改子点的原文`};if(n.kind&&n.kind!==`query`&&n.kind!==`mutate`)return{outline:[...e],error:`kind 只能是 query 或 mutate`};let a=[...e],o={...i,quote:n.quote};return n.title!==void 0&&n.title.trim()&&(o.title=n.title.trim()),n.kind&&(o.kind=n.kind),n.body!==void 0&&(n.body?o.body=n.body:delete o.body),a[r]=o,{outline:a}}function Pe(e,t,n=new Set){if(!t.size&&!n.size)return e;let r=e=>n.has(e)?null:t.get(e)??e,i=e=>g(e.map(r).filter(e=>!!e)),a=e.stories.map(e=>({...e,sourceRefs:i(e.sourceRefs)})),o=e=>{if(!e.outlineId)return e;let t=r(e.outlineId);return t===e.outlineId?e:t==null?{...e,outlineId:void 0}:{...e,outlineId:t}},s=e.check?{...e.check,gaps:e.check.gaps.map(o)}:e.check,c=e.ignoredGaps?.map(o);return{...e,stories:a,check:s,ignoredGaps:c}}function R(e,t=[]){let n=e.filter(e=>!e.parentId&&!e.kind),r=e.filter(e=>e.kind&&!e.parentId),i=new Set(t.flatMap(e=>e.sourceRefs)),a=new Map;for(let t of e){if(!t.parentId)continue;let e=a.get(t.parentId)??[];e.push(t),a.set(t.parentId,e)}let o=n.map(e=>{let n=a.get(e.id)??[],r=n.length>0&&n.every(t=>t.id.startsWith(`${e.id}-`))?n:j(e,n),o=r.length?r:[e],s=o.filter(e=>i.has(e.id)).length,c=t.filter(t=>t.sourceRefs.some(t=>t===e.id||r.some(e=>e.id===t)));return{parent:e,points:r,coveredCount:s,totalPoints:o.length,coveringStories:c}});if(r.length&&!n.length)for(let n of e)o.push({parent:n,points:n.kind?[n]:[],coveredCount:+!!i.has(n.id),totalPoints:1,coveringStories:t.filter(e=>e.sourceRefs.includes(n.id))});else r.length&&o.push({parent:{id:`__orphan__`,title:`其它需求点`,quote:``,body:``},points:r,coveredCount:r.filter(e=>i.has(e.id)).length,totalPoints:r.length,coveringStories:t.filter(e=>r.some(t=>e.sourceRefs.includes(t.id)))});return o}function Fe(e){let t=new Map,n=0;for(let r of R(e)){t.has(r.parent.id)||t.set(r.parent.id,n++);for(let e of r.points)t.has(e.id)||t.set(e.id,n++)}return t}var Ie=500,Le=12e3;function Re(e,t){if(!e.length)return`(无需求点)`;let n=Math.max(40,t?.excerptMax??Ie),r=Math.max(40,t?.blockMax??Le),i=R(e);if(!i.length)return`(无需求点)`;let a=[];for(let e of i){let t=e.parent.id===`__orphan__`?`- ${e.parent.title}`:`- ${e.parent.id} ${e.parent.title}`;if(a.push({kind:`parent`,text:t,shrinkable:!1}),!e.points.length)a.push({kind:`empty`,text:` (尚无查/改子点)`,shrinkable:!1});else for(let t of e.points){let e=t.kind===`query`?`查询`:t.kind===`mutate`?`修改`:`子点`;a.push({kind:`point`,text:` - ${t.id} [${e}] ${t.title}`,shrinkable:!1});let r=(t.body||t.quote||``).replace(/\s+/g,` `).trim();if(r){let e=r.length>n?`${r.slice(0,n).trimEnd()}…`:r;a.push({kind:`excerpt`,text:` 原文:${e}`,shrinkable:!0})}}}let o=e=>e.map(e=>e.text).join(`
9
- `),s=e=>e.length<=r?e:e.slice(0,r),c=o(a);if(c.length<=r)return c;let l=a.map(e=>({...e}));for(let e=0;e<3&&o(l).length>r;e++){let t=Math.max(40,Math.floor(n/(e+2)));for(let e=0;e<l.length;e++){let n=l[e];if(!n.shrinkable||n.kind!==`excerpt`)continue;let r=n.text.replace(/^ {4}原文:/,``);r.length<=t||(l[e]={...n,text:` 原文:${r.slice(0,t).trimEnd()}…`})}}return c=o(l),c.length<=r?c:s(o(l.filter(e=>!e.shrinkable)))}function z(e,t){if(e.length<=1)return[...e];let n=Fe(t),r=e=>{if(!e.sourceRefs.length)return 2**53-1;let t=2**53-1;for(let r of e.sourceRefs){let e=n.get(r);e!=null&&e<t&&(t=e)}return t};return[...e].map((e,t)=>({s:e,index:t,r:r(e)})).sort((e,t)=>e.r===t.r?e.index-t.index:e.r-t.r).map(e=>e.s)}function B(e){let t=new Map;for(let n of e){let e=n.kind===`query`?`查询`:n.kind===`mutate`?`修改`:``;t.set(n.id,e?`${n.title}(${e})`:n.title)}return t}function V(e){let t=B(e),n=new Map;for(let r of e){let e=t.get(r.id)||r.title;n.set(r.id,`${r.id} ${e}`.trim())}return n}function ze(e,t){if(!e.length)return``;let n=V(t);return e.map(e=>n.get(e)||e).join(`;`)}var Be=2e3,H=800;function U(e,t){let n=0;for(let r=0;r<e.length;r++)if(!/\s/.test(e[r])){if(n===t)return r;n+=1}return-1}function W(e,t,n){if(!n||n.length<4)return-1;let r=t.indexOf(n);return r<0||t.indexOf(n,r+n.length)>=0?-1:U(e,r)}function G(e,t){let n=String(e??``).trim(),r=String(t??``);if(!n||!r)return-1;let i=r.indexOf(n),a=n.replace(/\s+/g,``),o=r.replace(/\s+/g,``);if(i<0&&a&&(i=W(r,o,a)),i<0){let e=Math.min(4,a.length);for(let t of[64,48,32,24,16,12,8,4]){if(t<e)continue;let s=t<=8;if(n.length>=t){let e=n.slice(0,t),a=s?K(r,e):r.indexOf(e);if(a>=0){i=a;break}}let c=a.slice(0,Math.min(t,a.length));if(c.length<e)continue;let l=s?W(r,o,c):(()=>{let e=o.indexOf(c);return e>=0?U(r,e):-1})();if(l>=0){i=l;break}}}if(i<0){let e=/^(【[^】]{2,30}】)/u.exec(n);e&&n.slice(e[0].length).replace(/\s+/g,``).length<4&&(i=r.indexOf(e[1]))}if(i<0)return-1;let s=r.slice(Math.max(0,i-80),i),c=s.lastIndexOf(`
10
- `);return c>=0&&(i-=s.length-c-1),i}function K(e,t){if(!t||t.length<4)return-1;let n=e.indexOf(t);return n<0||e.indexOf(t,n+t.length)>=0?-1:n}function Ve(e){let t=String(e??``).replace(/[((]?(查询|修改)[))]?$/u,``).replace(/^(政企通页面管理|政企通)/,``).trim();if(!t)return[];let n=[t,...t.split(/[与、及]/u).map(e=>e.trim()).filter(e=>e.length>=4)];t.length>12&&n.push(t.slice(-12));let r=new Set,i=[];for(let e of n)r.has(e)||e.length<4||(r.add(e),i.push(e));return i.sort((e,t)=>t.length-e.length),i}function q(e,t){let n=G(e.quote||e.body||``,t);if(n>=0)return n;for(let n of Ve(e.title??``)){let e=K(t,n);if(e>=0)return e}return-1}function J(e,t,n){let r=/^\d+[、.]/.test(e.slice(t,Math.min(e.length,t+24)).trimStart()),i=t;for(;i<n;){let t=e.indexOf(`
11
- `,i);if(t<0||t>=n)return n;let a=t+1;for(;a<n&&(e[a]===`
12
- `||e[a]===`\r`||e[a]===` `);)a+=1;if(a>=n)return t;let o=e.slice(a,Math.min(n,a+40));if(/^【|^#{2,3}\s|^-{3,}/.test(o)||r&&/^\d+[、.]/.test(o)||a>t+1&&!/^\d+[、.]/.test(o))return t;i=t+1}return n}function Y(e,t,n){if(n<=t||n>=e.length)return!1;let r=e.slice(t,n),i=e.slice(n,Math.min(e.length,n+48)).trimStart();if(!/^\d+[、.]/.test(i)||/^\d+[、.]/.test(r.trimStart()))return!1;if(/\d+[、.]/.test(r))return!0;let a=r.trimEnd().split(/\n/).pop()?.trim()??``;return/下面分|如下|包括|分别为|计有|默认字段/u.test(a)||/[::))]\s*$/u.test(a)}function He(e,t,n=Be,r){let i=String(t??``),a=G(e,i);if(a<0)return``;let o=Math.min(i.length,a+n),s=r?.endBefore!=null&&r.endBefore>a?r.endBefore:void 0;if(s!=null&&!Y(i,a,s)){let e=J(i,a,Math.min(o,s));return i.slice(a,Math.min(o,s,e)).trim()}let c=J(i,a,o);return i.slice(a,Math.max(c,a+1)).trim()}function Ue(e,t,n){let r=Math.min(e.length,t+H),i=n==null?r:Math.min(r,n);return i=n!=null&&Y(e,t,n)?J(e,t,r):J(e,t,i),e.slice(t,i).trim()}function We(e,t,n,r,i){if(!e||i<0||!r.length)return e;let a=r.filter(e=>e.id!==t.id&&e.start>i).sort((e,t)=>e.start-t.start)[0]?.id;if(!a)return e;let o=n.find(e=>e.id===a);if(!o)return e;let s=[(o.quote||``).trim(),(o.body||``).trim().split(/\n/)[0]?.trim()||``].filter(e=>e.length>=4);for(let t of s){let n=e.indexOf(t);if(n>0)return e.slice(0,n).trim();let r=t.split(/\n/)[0]?.trim()||``;if(r.length>=4&&r!==t){let t=e.indexOf(r);if(t>0)return e.slice(0,t).trim()}}return e}function Ge(e,t,n){let r=(e.body||``).trim(),i=(e.quote||``).trim(),a=(t?.body||t?.quote||``).trim();if(!a)return{text:r||i||`(无原文切片)`,fromParent:!1};let o=n&&n.length?j(t??{id:``,title:``,quote:``},n):[],s=o.map(e=>({id:e.id,start:q(e,a)})),c=i?G(i,a):-1,l=r?G(r,a):-1,u=c>=0?c:l>=0?l:q(e,a),d;if(u>=0&&s.length){let t=s.filter(t=>t.id!==e.id&&t.start>u).sort((e,t)=>e.start-t.start);t[0]&&(d=t[0].start)}let f=u>=0&&s.some(t=>t.id!==e.id&&t.start===u);if(r)return{text:o.length?We(r,e,o,s,u):r,fromParent:!1};if(o.length&&u>=0&&!f&&d!=null){let e=Ue(a,u,d);if(e)return{text:e,fromParent:!1}}if(i){if(f)return{text:i,fromParent:!1};if(i.length<400||i.length<a.length*.35){let e=He(i,a,H,{endBefore:d});if(e&&(e.length>i.length||d!=null))return{text:e,fromParent:!1}}return{text:i,fromParent:!1}}if(u>=0&&!f){let e=Ue(a,u,d);if(e)return{text:e,fromParent:!1}}return{text:`(未定位到该需求点对应原文)`,fromParent:!1}}function Ke(e){let t=h(e.title??``);return`${e.type}|${e.storyId||``}|${e.outlineId||``}|${t}`}function X(e,t){if(Ke(e)===Ke(t))return!0;if(e.type!==t.type||(e.storyId||``)!==(t.storyId||``))return!1;let n=h(e.title??``),r=h(t.title??``);if(!n||!r)return!1;if(n===r)return!0;let i=n.length<=r.length?n:r,a=n.length<=r.length?r:n;return i.length>=8&&a.includes(i)}function qe(e,t){return t?.length?e.filter(e=>!t.some(t=>X(e,t))):[...e]}function Je(e,t,n,r){let i=r?.allowNew!==!1,a=qe(t,n),o=new Set,s=[],c=0,l=e=>i?!0:e.type===`uncovered-outline`;for(let t of a){let n=e.length?e.find(e=>e.id===t.id&&!o.has(e.id))||e.find(e=>!o.has(e.id)&&X(e,t)):void 0;if(n)o.add(n.id),s.push({...t,id:n.id,title:n.title,selected:n.selected||t.selected,conclusion:t.conclusion?.trim()||n.conclusion});else{if(!l(t)){c+=1;continue}s.push({...t})}}if(!i)for(let t of e)o.has(t.id)||t.type!==`uncovered-outline`&&(n?.some(e=>X(t,e))||s.push({...t}));return{gaps:s,suppressed:c}}function Ye(e){let t=e.pending??[],n=e.ignored??[];if(!t.length&&!n.length)return``;let r=[];if(t.length){r.push(`## 上轮待确认(复审底稿:只更新/收敛,禁止新开条;问题仍在则沿用原 title)`);for(let e of t)r.push(`- id=${e.id} type=${e.type} storyId=${e.storyId||`-`} outlineId=${e.outlineId||`-`}`),r.push(` title: ${e.title}`),e.detail?.trim()&&r.push(` detail: ${e.detail.trim()}`),e.conclusion?.trim()&&r.push(` conclusion: ${e.conclusion.trim()}(已有结论待补写,勿另开一条)`);r.push(``)}if(n.length){r.push(`## 已忽略(禁止再报同类,不要求标题字面一致)`);for(let e of n)r.push(`- type=${e.type} storyId=${e.storyId||`-`} outlineId=${e.outlineId||`-`} title: ${e.title}`)}return r.join(`
13
- `).trim()}function Xe(e){let t=[];return e.role||t.push({key:`role`,label:`缺角色`}),e.goal||t.push({key:`goal`,label:`缺目标`}),e.preconditions.length||t.push({key:`preconditions`,label:`缺前置条件`}),e.mainFlow.length||t.push({key:`mainFlow`,label:`缺主流程`}),e.sourceRefs.length||t.push({key:`sourceRefs`,label:`未挂需求点`}),e.exceptions.length?ft(e)&&e.exceptions.length<2&&t.push({key:`write-exceptions`,label:`写操作异常不足`}):t.push({key:`exceptions`,label:`缺异常场景`}),!e.altFlows.length&&ft(e)&&t.push({key:`altFlows`,label:`缺替代流程`}),e.acceptance.length?e.acceptance.some(e=>!e.then)&&t.push({key:`acceptance-then`,label:`验收缺 then`}):t.push({key:`acceptance`,label:`缺验收标准`}),t}function Ze(e){return O(e).map(e=>e.small)}function Qe(e){let t=O(e);if(!t.length)return``;let n=e=>/[,"\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,r=[`Ideal 小模块行序(用例「子模块 / 小模块」填下列原文;最终文件按此序排列,优先于用户故事 US 编号):`,`大模块,小模块,优化/问题内容`];for(let e of t)r.push(`${n(e.big)},${n(e.small)},【${e.title}】`);return r.join(`
14
- `)}var $e=`需求章节顺序`;function et(e){let t=String(e??``).replace(/\r\n/g,`
15
- `).trim();if(!t)return[];let n=[],r=new Set,i=/^(概述|简介|目录|修订|附录|背景|术语|参考)/;for(let e of t.matchAll(/^#{2,3}\s+(.+?)\s*$/gm)){let t=b(e[1]??``);!t||t.length>40||i.test(t)||r.has(t)||(r.add(t),n.push(t))}return n}function tt(e){let t=String(e??``).replace(/\r\n/g,`
16
- `),n=t.indexOf($e);if(n<0)return[];let r=t.slice(n,n+4e3),i=[],a=new Set;for(let e of r.matchAll(/^\s*\d+[.)、]\s*(.+?)\s*$/gm)){let t=b(e[1]??``);!t||t.length>40||a.has(t)||(a.add(t),i.push(t))}return i}function Z(e){let t=Ze(e);if(t.length)return t;let n=tt(e);if(n.length)return n;let r=rt(e);return r.length?r:et(e)}function nt(e){let t=Qe(e);if(t)return t;let n=Z(e);return n.length<2?``:[`${$e}(用例「模块 / 子模块 / 标题」应对齐下列原文;最终文件按此序排列,优先于用户故事 US 编号):`,...n.map((e,t)=>`${t+1}. ${e}`)].join(`
17
- `)}function rt(e){let t=O(e);if(t.length)return t.map(e=>e.title);let n=String(e??``).replace(/\r\n/g,`
18
- `).trim(),r=[],i=new Set;for(let e of n.matchAll(/【([^】\n]{1,40})】/g)){let t=b(e[1]??``);!t||t.length>24||i.has(t)||(i.add(t),r.push(t))}return r}function it(e,t,n){return`g_${y(`${e}|${t}|${n}`)}`}function at(e){let t=e&&typeof e==`object`?e:{},n=_(t.priority,4);return{id:_(t.id,20),title:_(t.title,200),role:_(t.role,120),goal:_(t.goal,500),value:_(t.value,500),sourceRefs:v(t.sourceRefs,20,40),priority:n===`P0`||n===`P1`||n===`P2`?n:`P1`,preconditions:v(t.preconditions),mainFlow:(Array.isArray(t.mainFlow)?t.mainFlow:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{actor:_(t.actor,80),action:_(t.action,500),result:_(t.result,500)}}).filter(e=>e.action).slice(0,40),altFlows:(Array.isArray(t.altFlows)?t.altFlows:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{name:_(t.name,120)||`替代流程`,trigger:_(t.trigger,500),steps:v(t.steps,20)}}).slice(0,20),exceptions:(Array.isArray(t.exceptions)?t.exceptions:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{scenario:_(t.scenario,500),expected:_(t.expected,500)}}).filter(e=>e.scenario).slice(0,30),postconditions:v(t.postconditions),acceptance:(Array.isArray(t.acceptance)?t.acceptance:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{given:_(t.given,500),when:_(t.when,500),then:_(t.then,500)}}).filter(e=>e.given||e.when||e.then).slice(0,30),dimensions:v(t.dimensions,12,40)}}function ot(e){return{...e,sourceRefs:[...e.sourceRefs],preconditions:[...e.preconditions],mainFlow:e.mainFlow.map(e=>({...e})),altFlows:e.altFlows.map(e=>({...e,steps:[...e.steps]})),exceptions:e.exceptions.map(e=>({...e})),postconditions:[...e.postconditions],acceptance:e.acceptance.map(e=>({...e})),dimensions:[...e.dimensions]}}function Q(e){let t=e.mainFlow?.[0];return`${h(e.title)}|${t?h(`${t.action}${t.result??``}`):``}`}function st(e,t){let n=e.map(ot),r=new Map(n.filter(e=>e.id).map(e=>[e.id,e])),i=new Map(n.map(e=>[Q(e),e]));for(let e of t){let t=at(e);if(!t.title)continue;let a=t.id&&r.get(t.id)||i.get(Q(t));if(a)!a.role&&t.role&&(a.role=t.role),!a.goal&&t.goal&&(a.goal=t.goal),!a.value&&t.value&&(a.value=t.value),a.sourceRefs=g([...a.sourceRefs,...t.sourceRefs]),a.dimensions=g([...a.dimensions,...t.dimensions]),a.preconditions.length||(a.preconditions=[...t.preconditions]),a.mainFlow.length||(a.mainFlow=t.mainFlow.map(e=>({...e}))),a.altFlows.length||(a.altFlows=t.altFlows.map(e=>({...e}))),a.exceptions.length||(a.exceptions=t.exceptions.map(e=>({...e}))),a.postconditions.length||(a.postconditions=[...t.postconditions]),a.acceptance.length||(a.acceptance=t.acceptance.map(e=>({...e}))),t.priority===`P0`&&a.priority!==`P0`?a.priority=`P0`:t.priority===`P1`&&a.priority===`P2`&&(a.priority=`P1`);else{let e={...t,id:``};n.push(e),i.set(Q(e),e)}}return n}function ct(e,t){let n=h(e),r=h(t);if(!n||!r)return 0;if(n===r)return 1e3;if(n.includes(r)||r.includes(n))return 800+Math.min(n.length,r.length);let i=n.length<=r.length?n:r,a=n.length<=r.length?r:n,o=0;for(let e=0;e<i.length-1;e++)a.includes(i.slice(e,e+2))&&(o+=1);let s=Math.max(1,i.length-1);return o+Math.round(o/s*10)}var lt=4;function ut(e,t){let n=e.map(ot);if(!t.length)return{stories:n,filled:0};let r=new Set(t.filter(e=>e.parentId).map(e=>e.parentId)),i=[...t.filter(e=>e.kind===`query`||e.kind===`mutate`),...t.filter(e=>!e.kind&&!e.parentId&&!r.has(e.id))];if(!i.length)return{stories:n,filled:0};let a=new Set(n.flatMap(e=>e.sourceRefs).filter(e=>i.some(t=>t.id===e))),o=0;for(let e of n){if(e.sourceRefs.length)continue;let t=null,n=0;for(let r of i){if(a.has(r.id))continue;let i=ct(e.title,r.title);i>n&&(n=i,t=r)}!t||n<lt||(e.sourceRefs=[t.id],a.add(t.id),o+=1)}return{stories:n,filled:o}}function dt(e){return[e.title,e.role,e.goal,e.value,...e.dimensions,...e.preconditions,...e.postconditions,...e.mainFlow.map(e=>`${e.actor??``} ${e.action} ${e.result??``}`),...e.altFlows.map(e=>`${e.name} ${e.trigger} ${e.steps.join(` `)}`),...e.exceptions.map(e=>`${e.scenario} ${e.expected}`),...e.acceptance.map(e=>`${e.given} ${e.when} ${e.then}`)].join(` `)}function ft(e){return e.mainFlow.some(e=>f.test(e.action))}function pt(e,t,n,r,i,a,o=``){return{id:it(e,t||o,n),storyId:t,outlineId:o||void 0,type:e,severity:a,title:n,detail:r,suggestion:i,origin:`rule`,selected:!1}}var mt=new Set([`缺少角色`,`缺少目标`,`缺少前置条件`,`缺少主流程`,`没有异常场景`,`写操作缺少异常分支`,`缺少验收标准`,`验收标准缺 then`,`没有关联需求条目`,`只写了主流程`]);function ht(e){let t=e.outline??[],n=e.stories??[],r=[],i=A(t),a=new Set(n.flatMap(e=>e.sourceRefs));for(let e of i){if(a.has(e.id))continue;let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``,n=t?`${e.title}(${t})`:e.title;r.push(pt(`uncovered-outline`,``,`${n}:还没有用户故事挂上`,`需求点「${n}」在文档里有,但目前没有任何故事引用它。可能是漏拆了,也可能这块其实不用测。`,`跟业务确认要不要覆盖:要的话补一条故事(或在已有故事里挂上这个点);不要的话直接忽略。`,`high`,e.id))}let o=d.map(e=>{let t=n.filter(t=>{let n=dt(t).toLowerCase();return e.keywords.some(e=>n.includes(e.toLowerCase()))}).map(e=>e.id);return{key:e.key,label:e.label,covered:t.length>0,stories:t}}),s=i.filter(e=>a.has(e.id)).length,c={total:i.length,covered:s,rate:i.length?s/i.length:0};return{at:new Date().toISOString(),summary:`规则检查:${n.length} 个故事、${i.length} 个需求点,覆盖率 ${i.length?Math.round(c.rate*100):0}%,${r.length} 项待确认未覆盖。`,coverage:c,dimensions:o,gaps:r}}function gt(e,t){let n=e.map(e=>({...e})),r=new Map(n.map(e=>[`${e.storyId}|${e.type}`,e])),i=new Set(n.map(e=>e.id));for(let e of t){if(i.has(e.id))continue;let t=`${e.storyId}|${e.type}`,a=r.get(t);a?mt.has(a.title)?(a.title=e.title,a.detail=[a.detail,e.detail].filter(Boolean).join(` / `),a.suggestion=e.suggestion||a.suggestion,a.severity=e.severity):h(a.title)!==h(e.title)&&(n.push({...e}),i.add(e.id)):(n.push({...e}),r.set(t,e),i.add(e.id))}return n}function _t(e,t){let n=[],r=``;for(let i of e.split(/\n{2,}/)){let e=r?`${r}\n\n${i}`:i;if(e.length<=t)r=e;else if(r&&n.push(r),i.length<=t)r=i;else{for(let e=0;e<i.length;e+=t)n.push(i.slice(e,e+t));r=``}}return r&&n.push(r),n}function vt(e,t=12e3){let n=String(e??``).replace(/\r\n/g,`
19
- `).trim();if(!n)return[];let r=Math.max(2e3,Math.floor(t));if(n.length<=r)return[{index:0,title:``,text:n}];let i=[],a=``,o=[],s=()=>{let e=o.join(`
20
- `).trim();e&&i.push({title:a,text:e}),o=[]};for(let e of n.split(`
21
- `)){let t=/^#{2,6}\s+(.+?)\s*$/.exec(e);t&&(s(),a=t[1]),o.push(e)}if(s(),!i.length)return[{index:0,title:``,text:n}];let c=[],l=``,u=``,d=()=>{let e=l.trim();if(e){for(let t of e.length>r?_t(e,r):[e])c.push({index:c.length,title:u,text:t});l=``}};for(let e of i){let t=l?`${l}\n\n${e.text}`:e.text;t.length<=r?(l||(u=e.title),l=t):(d(),u=e.title,l=e.text,l.length>r&&d())}return d(),c.length?c:[{index:0,title:``,text:n}]}function $(e,t){return t?`- **${e}**:${t}`:``}function yt(e){return e.filter(Boolean).map(e=>`- ${e}`)}function bt(e,t=[]){let n=[];n.push(`### ${e.id} ${e.title}`),n.push(``);let r=t.length?ze(e.sourceRefs,t):e.sourceRefs.join(`、`),i=[$(`角色`,e.role),$(`目标`,e.goal),$(`价值`,e.value),$(`优先级`,e.priority),$(`来源条目`,r)].filter(Boolean);if(n.push(...i),i.length&&n.push(``),e.preconditions.length&&(n.push(`**前置条件**`),n.push(...yt(e.preconditions)),n.push(``)),e.mainFlow.length&&(n.push(`**主流程**`),e.mainFlow.forEach((e,t)=>{let r=e.actor?`${e.actor}:`:``;n.push(`${t+1}. ${r}${e.action}${e.result?` → ${e.result}`:``}`)}),n.push(``)),e.altFlows.length){n.push(`**替代流程**`);for(let t of e.altFlows)n.push(`- **${t.name}**${t.trigger?`(触发:${t.trigger})`:``}`),t.steps.forEach((e,t)=>n.push(` ${t+1}. ${e}`));n.push(``)}if(e.exceptions.length){n.push(`**异常场景**`);for(let t of e.exceptions)n.push(`- ${t.scenario}${t.expected?` → ${t.expected}`:``}`);n.push(``)}if(e.postconditions.length&&(n.push(`**后置条件**`),n.push(...yt(e.postconditions)),n.push(``)),e.acceptance.length){n.push(`**验收标准**`);for(let t of e.acceptance)n.push(`- Given ${t.given||`(未写)`};When ${t.when||`(未写)`};Then ${t.then||`(未写)`}`);n.push(``)}return e.dimensions.length&&(n.push(`**覆盖维度**:${e.dimensions.join(`、`)}`),n.push(``)),n[n.length-1]!==``&&n.push(``),n}function xt(e,t){let n=new Set((t??[]).filter(Boolean)),i=n.size?e.stories.filter(e=>n.has(e.id)):e.stories,a=[];if(a.push(`# ${e.title||`需求分析`} · 用户故事`),a.push(``),a.push(`> 来源需求文档:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),a.push(``),e.outline.length){a.push(`## 需求条目`),a.push(``),a.push(`> 「引用需求点」请填下列真实 RO id,格式「RO-id 标题」;不要填 US-…。`),a.push(``);for(let t of R(e.outline,i)){if(a.push(`### ${t.parent.id} ${t.parent.title}`),t.parent.quote||t.parent.body){let e=(t.parent.quote||t.parent.body||``).replace(/\s+/g,` `).slice(0,200);a.push(`> ${e}`)}if(t.points.length)for(let e of t.points){let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``;a.push(`- **${e.id}** ${e.title}${t?`(${t})`:``}`),e.quote&&a.push(` > ${e.quote.replace(/\n+/g,` `)}`)}a.push(``)}}a.push(`## 用户故事`),a.push(``),i.length||(a.push(`- (暂无)`),a.push(``));let o=z(i,e.outline);for(let t of o)a.push(...bt(t,e.outline));return a.join(`
22
- `)}function St(e){let t=[];t.push(`# ${e.title||`需求分析`}`),t.push(``),t.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),t.push(``),t.push(`## 需求条目`),t.push(``),e.outline.length||t.push(`- (暂无)`);for(let n of R(e.outline,e.stories)){t.push(`- **${n.parent.id}** ${n.parent.title}`),n.parent.quote&&t.push(` > ${n.parent.quote.replace(/\n+/g,` `)}`);for(let e of n.points){let n=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``;t.push(` - **${e.id}** ${e.title}${n?`(${n})`:``}`),e.quote&&t.push(` > ${e.quote.replace(/\n+/g,` `)}`)}}t.push(``),t.push(`## 用户故事`),t.push(``),e.stories.length||t.push(`- (暂无)`);for(let n of z(e.stories,e.outline))t.push(...bt(n,e.outline));if(t.push(`## 审查摘要`),t.push(``),!e.check)t.push(`- 还没有跑过审查。`);else{let n=e.check.coverage.total?Math.round(e.check.coverage.rate*100):0;t.push(`- 覆盖率:${e.check.coverage.covered}/${e.check.coverage.total}(${n}%)`),t.push(`- 维度覆盖:${e.check.dimensions.map(e=>`${e.label}${e.covered?` ✓`:` ✗`}`).join(` · `)||`(无)`}`),e.check.summary&&(t.push(``),t.push(e.check.summary)),t.push(``),t.push(`### 缺口清单`),t.push(``),e.check.gaps.length||t.push(`- 没有发现缺口。`);let r=[...e.check.gaps].sort((e,t)=>{let n={high:0,medium:1,low:2};return n[e.severity]-n[t.severity]});for(let e of r){let n=e.storyId?`${e.storyId} `:``;t.push(`- **[${l[e.severity]}] ${a[e.type]}** · ${n}${e.title}`),e.detail&&t.push(` - 原因:${e.detail}`),e.suggestion&&t.push(` - 建议:${e.suggestion}`)}}return t.push(``),t.join(`
23
- `)}function Ct(e){return`${(e.title||e.sourcePath.split(`/`).pop()||`需求分析`).replace(/\.(md|markdown|txt)$/i,``).replace(/[\\/:*?"<>|]/g,` `).trim()||`需求分析`}-用户故事.md`}export{oe as $,ce as A,Je as B,be as C,je as D,R as E,V as F,xe as G,Me as H,Ge as I,z as J,ye as K,B as L,st as M,Ae as N,he as O,A as P,Xe as Q,m as R,Re as S,it as T,x as U,Pe as V,fe as W,vt as X,de as Y,xt as Z,ae as _,t as a,c as b,ht as c,ne as d,St as et,ie as f,ee as g,Z as h,n as i,gt as j,te as k,Oe as l,rt as m,u as n,Ne as nt,i as o,Ct as p,Ee as q,a as r,re as rt,r as s,l as t,De as tt,ge as u,ut as v,nt as w,Ye as x,qe as y,se as z};
@@ -1 +0,0 @@
1
- import{f as e}from"./app-config.DAIyT--R.js";import{n as t}from"./i18n.ele1lM9e.js";var n=`/__tb_spaces`;async function r(e,t){try{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json();return n.ok?r:{ok:!1,error:r?.error||`请求失败(HTTP ${n.status})`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function i(e){try{return(await fetch(n,{signal:e??AbortSignal.timeout(2e3)})).ok}catch{return!1}}async function a(t){try{let r=t?.stats?`${n}?stats=1`:n,i=await fetch(r);if(!i.ok)return null;let a=await i.json();return a?.activeId&&e(a.activeId),a}catch{return null}}async function o(t){let i=await r(`${n}/switch`,{id:t});return i.ok&&e(t),i}function s(e,t){return r(`${n}/create`,{name:e,managedParent:t?.managedParent,switch:t?.switch===!0,systemPrompt:t?.systemPrompt,promptBrief:t?.promptBrief})}function c(e){let t=e instanceof Error?e.message:String(e??``);return!t.trim()||/^not found$/i.test(t.trim())?`本地服务版本较旧,还没有空间编辑接口;请重启本地服务后再试`:t}async function l(e){try{let t=await fetch(`${n}/detail?id=${encodeURIComponent(e)}`),r=await t.json();return t.ok?r:{ok:!1,error:c(r?.error??`HTTP ${t.status}`)}}catch(e){return{ok:!1,error:c(e)}}}async function u(e,t){let i=await r(`${n}/update`,{id:e,...t});return i.ok?i:{...i,error:c(i.error)}}function d(e,t){return r(`${n}/copy`,{id:e,name:t})}function f(e,t){return r(`${n}/delete`,{id:e,purge:t,confirm:t===!0})}function p(e,t=`full`){return`${n}/export?id=${encodeURIComponent(e)}${t===`content`?`&scope=content`:``}`}function m(e){return r(`${n}/discover`,Array.isArray(e)&&e.length?{adopt:e}:{})}async function h(e,t){let i=await e.arrayBuffer(),a=new Uint8Array(i),o=``,s=32768;for(let e=0;e<a.length;e+=s)o+=String.fromCharCode(...a.subarray(e,e+s));let c=btoa(o);return r(`${n}/import`,{zipBase64:c,name:t})}function g(e){return e.isPublic?t(`space.publicName`):e.name}function _(e,t){let n=e.includes(`\\`)?`\\`:`/`,r=t.replace(/[/\\]+$/,``),i=`${r}${n}空间池`;if(e===i)return r;let a=`${i}${n}`;return e.startsWith(a)?`${r}${n}${e.slice(a.length)}`:e}function v(e){if(!e||e<=0)return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return`${r<10&&n>0?r.toFixed(1):Math.round(r)} ${t[n]}`}export{g as a,l as c,a as d,i as f,m as i,v as l,u as m,s as n,_ as o,o as p,f as r,p as s,d as t,h as u};
@@ -1 +0,0 @@
1
- var e=`/__tb_test_stats`,t=[`功能测试用例`,`自动化测试用例`,`接口测试用例`,`测试报告`,`缺陷统计`,`自动化缺陷统计`,`测试计划`],n=/^\d{4}-\d{2}-\d{2}$/,r=9999999;function i(e,t=80){return typeof e==`string`?e.trim().slice(0,t):``}function a(e){let t=i(e,10);return n.test(t)?t:``}function o(e){let t=typeof e==`number`?e:Number(String(e??``).trim());return!Number.isFinite(t)||t<=0?0:Math.min(r,Math.round(t))}function s(e,t=20){if(!Array.isArray(e))return[];let n=[];for(let r of e){let e=i(r,40);if(e&&!n.includes(e)&&(n.push(e),n.length>=t))break}return n}function c(e=new Date){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function l(e){if(!e||typeof e!=`object`)return null;let t=e,n=s(t.dimensions).slice(0,1),r=!n.length;if(r&&t.draft!==!0)return null;let l=new Date().toISOString();return{id:i(t.id,64)||`ts_${Math.random().toString(16).slice(2,10)}`,date:a(t.date)||c(),dimensions:n,count:o(t.count),draft:r,source:t.source===`ai`?`ai`:`manual`,sessionId:i(t.sessionId,120),createdAt:i(t.createdAt,40)||l,updatedAt:i(t.updatedAt,40)||l}}async function u(t,n){let r=await fetch(e,{method:t,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error(i.error||`HTTP ${r.status}`);return i}async function d(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function f(){let e=await u(`GET`),n=Array.isArray(e.items)?e.items:[],r=s(e.dimensions);return{items:n.map(l).filter(e=>!!e),dimensions:r.length?r:[...t]}}async function p(e,t){let n=await u(`POST`,{items:e,...t});return{items:(Array.isArray(n.items)?n.items:[]).map(l).filter(e=>!!e),dimensions:s(n.dimensions)}}async function m(e,t){let n=await u(`PUT`,{id:e,...t}),r=l(n.item);if(!r)throw Error(`更新测试统计失败`);return{item:r,dimensions:s(n.dimensions)}}async function h(e){let t=await u(`DELETE`,{ids:e});return Number(t.removed??0)}function g(e){return[...e].sort((e,t)=>e.date===t.date?e.createdAt<t.createdAt?1:-1:e.date<t.date?1:-1)}function _(e,t={}){let n=(t.keyword??``).trim().toLowerCase();return n?e.filter(e=>`${e.date} ${e.dimensions.join(` `)} ${e.count}`.toLowerCase().includes(n)):e}function v(e){let t=new Set,n=0;for(let r of e){n+=r.count;for(let e of r.dimensions)t.add(e)}return{records:e.length,dimensions:t.size,total:n}}export{f as a,o as c,_ as i,c as l,h as n,g as o,d as r,v as s,p as t,m as u};