lantern-harness 0.1.19 → 0.1.21

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 (111) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/builtin/session/lh-fs.mjs +41 -1
  3. package/cli/data-root.mjs +11 -6
  4. package/cli/seed-skip.mjs +72 -0
  5. package/cli/spaces.mjs +23 -9
  6. package/dist/500.html +4 -4
  7. package/dist/_astro/Base.NUwtco4a.css +1 -0
  8. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.BMvdPyIE.js → Base.astro_astro_type_script_index_0_lang.2J3Qrd4B.js} +1 -1
  9. package/dist/_astro/{CaseExecBoard.cBdsZU9e.js → CaseExecBoard.CwH1rd8R.js} +1 -1
  10. package/dist/_astro/CaseGenerateApp.CpL1po9n.js +9 -0
  11. package/dist/_astro/CasesLibrary.DAZMRzzt.js +19 -0
  12. package/dist/_astro/ChatApp.iDy6-iVA.js +212 -0
  13. package/dist/_astro/{DashboardBoard.BNuKH_zX.js → DashboardBoard.BDURPamv.js} +1 -1
  14. package/dist/_astro/ExcelFieldTags.CXif3Ilh.js +1 -0
  15. package/dist/_astro/{KnowledgeLibrary.D0r8ieOZ.js → KnowledgeLibrary.B_99kzox.js} +1 -1
  16. package/dist/_astro/{NavLibraries.D1J9BwYo.js → NavLibraries.RH3Sinuh.js} +1 -1
  17. package/dist/_astro/PluginsPage.B349vNQ7.js +1 -0
  18. package/dist/_astro/{PluginsPage.Du4g_yr4.js → PluginsPage.aQKIWMKz.js} +2 -2
  19. package/dist/_astro/{PmBugsBoard.BTtm1lki.js → PmBugsBoard.Catlw5fm.js} +1 -1
  20. package/dist/_astro/{PmIterationsBoard.Dm67iXe_.js → PmIterationsBoard.D4Bg969F.js} +1 -1
  21. package/dist/_astro/{PmProjectDetail.B7oWL7y-.js → PmProjectDetail.BYVt43oh.js} +1 -1
  22. package/dist/_astro/{PmProjectsBoard.8QI44RlE.js → PmProjectsBoard.D06_aCFK.js} +1 -1
  23. package/dist/_astro/PmRequirementsBoard.CyW9CfFH.js +1 -0
  24. package/dist/_astro/{PmRequirementsBoard.X98441HZ.js → PmRequirementsBoard.DuXUq0HB.js} +1 -1
  25. package/dist/_astro/PmShared.CwcLNMW2.js +1 -0
  26. package/dist/_astro/{PromptsLibrary.17cDZsjQ.js → PromptsLibrary.dMO4dOAT.js} +1 -1
  27. package/dist/_astro/{ReportsPage.BjcajHR6.js → ReportsPage.DOW1fswe.js} +1 -1
  28. package/dist/_astro/ReqAnalysisBoard.DQpPjNNr.js +29 -0
  29. package/dist/_astro/RequirementsLibrary.Dd2DRKxL.js +1 -0
  30. package/dist/_astro/SearchableSelect.DZb-mxqw.js +1 -0
  31. package/dist/_astro/{SettingsDialog.BMa8eGFr.js → SettingsDialog.BBYaIU0N.js} +1 -1
  32. package/dist/_astro/{SlideOverDrawer.HqVYaIjP.js → SlideOverDrawer.DMWJPD_W.js} +1 -1
  33. package/dist/_astro/{SpaceSwitcher.B8dzGxrR.js → SpaceSwitcher.DyzMNGfy.js} +2 -2
  34. package/dist/_astro/{TasksBoard.Bz_JL_uQ.js → TasksBoard.BODqpiYV.js} +1 -1
  35. package/dist/_astro/TemplatesLibrary.DDJLVEZk.js +1 -0
  36. package/dist/_astro/{TestStatsBoard.EIDxmU_8.js → TestStatsBoard.diX5s3sH.js} +1 -1
  37. package/dist/_astro/{TodosBoard.DV1VzVDe.js → TodosBoard.DQBEeiWU.js} +1 -1
  38. package/dist/_astro/{UiAutoBoard.BwKG4DcV.js → UiAutoBoard.3Xs5RjDq.js} +3 -3
  39. package/dist/_astro/app-version.BqfBCSsN.js +1 -0
  40. package/dist/_astro/case-fields.CtFiDM_d.js +1 -0
  41. package/dist/_astro/case-gen-run.BI_ld4oo.js +16 -0
  42. package/dist/_astro/case-review._K-6xl4v.js +3 -0
  43. package/dist/_astro/case-template.BGCVpSKI.js +5 -0
  44. package/dist/_astro/{i18n.B3BVhlok.js → i18n.CjqQGCAI.js} +1 -1
  45. package/dist/_astro/{index.astro_astro_type_script_index_0_lang.CM78W1qz.js → index.astro_astro_type_script_index_0_lang.DMnFoepS.js} +1 -1
  46. package/dist/_astro/{open-docs-in-session.B6uyOxPn.js → open-docs-in-session.Cj0J2-XT.js} +1 -1
  47. package/dist/_astro/{plugins.DYyAjBXb.js → plugins.CVM1IaoC.js} +1 -1
  48. package/dist/_astro/req-analysis.Dkbi-5A_.js +9 -0
  49. package/dist/_astro/{settings.BvxRxdqa.js → settings.B1yetppp.js} +2 -2
  50. package/dist/_astro/{spaces-client.Dy3tSPta.js → spaces-client.DnS6MgGy.js} +1 -1
  51. package/dist/_astro/story-review.DvCTzGfr.js +12 -0
  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 +45 -5
  57. package/dist/docs/install/index.html +4 -4
  58. package/dist/docs/manual/index.html +12 -9
  59. package/dist/index.html +1 -1
  60. package/dist/knowledge/index.html +5 -5
  61. package/dist/plugins/index.html +5 -5
  62. package/dist/pm/bugs/index.html +5 -5
  63. package/dist/pm/iterations/index.html +5 -5
  64. package/dist/pm/projects/detail/index.html +5 -5
  65. package/dist/pm/projects/index.html +5 -5
  66. package/dist/pm/requirements/index.html +5 -5
  67. package/dist/prompts/index.html +5 -5
  68. package/dist/reports/index.html +5 -5
  69. package/dist/requirement-analysis/index.html +5 -5
  70. package/dist/requirements/index.html +5 -5
  71. package/dist/tasks/index.html +5 -5
  72. package/dist/templates/index.html +5 -5
  73. package/dist/test-automation/index.html +5 -5
  74. package/dist/test-stats/index.html +5 -5
  75. package/dist/todos/index.html +5 -5
  76. package/dist/workbench/index.html +5 -5
  77. package/docs/lantern-harness.code-workspace +11 -0
  78. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +8 -5
  79. package/lh-plugins/case-review-prompt.mjs +16 -13
  80. package/lh-plugins/lh-case-review.mjs +2 -0
  81. package/lh-plugins/lh-project-docs.mjs +17 -0
  82. package/lh-plugins/lh-reports.mjs +28 -44
  83. package/package.json +1 -1
  84. package/dist/_astro/Base.VCz1UVxQ.css +0 -1
  85. package/dist/_astro/CaseGenerateApp.DLcUOrpS.js +0 -9
  86. package/dist/_astro/CasesLibrary.BERmgS2j.js +0 -19
  87. package/dist/_astro/ChatApp.azDLrlxw.js +0 -226
  88. package/dist/_astro/ExcelFieldTags.ytbpKt-Z.js +0 -5
  89. package/dist/_astro/PluginsPage.BNlpKMUM.js +0 -1
  90. package/dist/_astro/PmRequirementsBoard.DMJVLCqz.js +0 -1
  91. package/dist/_astro/PmShared.DbDseTcc.js +0 -1
  92. package/dist/_astro/ReqAnalysisBoard.CBgma-zG.js +0 -29
  93. package/dist/_astro/RequirementsLibrary.B5TE-2Ds.js +0 -1
  94. package/dist/_astro/SearchableSelect.mvcBwegf.js +0 -1
  95. package/dist/_astro/TemplatesLibrary.DazYm5Sh.js +0 -1
  96. package/dist/_astro/app-version.CdxtY1WM.js +0 -1
  97. package/dist/_astro/case-review.DYyZat83.js +0 -3
  98. package/dist/_astro/req-analysis.DGQa1vaH.js +0 -6
  99. package/dist/_astro/story-review.BjrulZG8.js +0 -10
  100. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +0 -851
  101. package/dist/raw/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203.md +0 -168
  102. package/dist/raw/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277.md +0 -58
  103. package/dist/raw/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277.md +0 -54
  104. package/dist/raw/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277.md +0 -35
  105. package/dist/raw/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277.md +0 -48
  106. package/dist/raw/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277.md +0 -30
  107. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +0 -710
  108. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +0 -690
  109. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +0 -652
  110. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +0 -679
  111. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +0 -654
@@ -1,5 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{a as r,i,n as a,o,r as s,t as c}from"./export.joBT53eb.js";import{t as l}from"./jszip.min.Bh2Mgo40.js";var u=e(l(),1);function d(e){return e.some(e=>String(e??``).trim().length>0)}function f(e){let t=i(e,{type:`base64`}),n=t.SheetNames[0]??`Sheet1`,a=t.Sheets[n];if(!a)return{headers:[...c],body:``};let o=r.sheet_to_json(a,{header:1,defval:``,raw:!1}),s=(o.find(d)??[]).map(e=>String(e??``).trim()).filter(Boolean);if(!s.length)return{headers:[...c],body:`(模板工作表「${n}」无表头)`};let l=o.filter(d).slice(1,4),u=[`工作表:${n}`,`字段(必须原样作为 JSON 对象键,顺序一致):${s.join(`、`)}`,``,`样例行(风格与粒度请对齐,勿照抄业务内容):`];for(let e of l){let t={};s.forEach((n,r)=>{t[n]=String(e[r]??``).trim()}),u.push(JSON.stringify(t,null,2))}return{headers:s,body:u.join(`
2
- `)}}function p(e){let t=(e.split(/\r?\n/).find(e=>e.trim())??``).split(`,`).map(e=>e.replace(/^"|"$/g,``).trim()).filter(Boolean);return t.length?{headers:t,body:`字段(必须原样作为 JSON 对象键):${t.join(`、`)}\n\n${e.slice(0,4e3)}`}:{headers:[...c],body:e.slice(0,4e3)}}function m(e){let t=e.match(/^\|(.+)\|\s*$/m);if(t?.[1]){let n=t[1].split(`|`).map(e=>e.trim()).filter(e=>e&&!/^[-:]+$/.test(e));if(n.length)return{headers:n,body:`字段(必须原样作为 JSON 对象键):${n.join(`、`)}\n\n${e.slice(0,4e3)}`}}return{headers:[...c],body:e.slice(0,4e3)}}function h(e,t){let n=t.length?t:[...c];return e.map(e=>{let t=e??{},r={};for(let e of n){let n=t[e],i=typeof n==`string`?n:n==null?``:String(n);r[e]=a(e)?s(i):i}return r})}async function g(e){let t=await u.default.loadAsync(e,{base64:!0}),n=`xl/styles.xml`,r=t.file(n);if(r){let e=await r.async(`string`);e.includes(`wrapText`)||(/<cellXfs[^>]*count="1"[^>]*>\s*<xf[^/]*\/>\s*<\/cellXfs>/.test(e)?e=e.replace(/<cellXfs([^>]*)count="1"([^>]*)>\s*<xf([^/]*)\/>\s*<\/cellXfs>/,`<cellXfs$1count="2"$2><xf$3/><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment wrapText="1" vertical="top"/></xf></cellXfs>`):e.includes(`</cellXfs>`)&&(e=e.replace(/<cellXfs([^>]*)count="(\d+)"/,(e,t,n)=>`<cellXfs${t}count="${Number(n)+1}"`).replace(`</cellXfs>`,`<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment wrapText="1" vertical="top"/></xf></cellXfs>`)),t.file(n,e))}let i=Object.keys(t.files).filter(e=>/^xl\/worksheets\/sheet\d+\.xml$/.test(e));for(let e of i){let n=t.file(e);if(!n)continue;let r=await n.async(`string`);r=r.replace(/<c\b([^>]*)>/g,(e,t)=>!/\bt="str"/.test(t)||/\bs="\d+"/.test(t)?e:`<c s="1"${t.startsWith(` `)?t:` ${t}`}>`),r=r.replace(/<row r="(\d+)"([^>]*)>/g,(e,t,n)=>Number(t)===1||/\bht=/.test(n)?`<row r="${t}"${n}>`:`<row r="${t}" ht="60" customHeight="1"${n}>`),t.file(e,r)}return t.generateAsync({type:`base64`,compression:`DEFLATE`})}function _(e){return/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function v(e){return e.replace(/\|/g,`\\|`).replace(/\n+/g,`<br>`)}function y(e,t,n){let r=n.length?n:[...c],i=[`# ${t}`,``,`| ${r.join(` | `)} |`,`|${r.map(()=>`---`).join(`|`)}|`];for(let t of e)i.push(`| ${r.map(e=>v(t[e]??``)).join(` | `)} |`);return i.join(`
3
- `)+`
4
- `}function b(e,t){let n=t.length?t:[...c];return``+[n.join(`,`),...e.map(e=>n.map(t=>_(e[t]??``)).join(`,`))].join(`
5
- `)}async function x(e,t,n=`测试用例`){let i=t.length?t:[...c],l=e.map(e=>{let t={};for(let n of i){let r=e[n]??``;t[n]=a(n)?s(r):r}return t}),u=r.json_to_sheet(l,{header:[...i]}),d=u[`!ref`]?r.decode_range(u[`!ref`]):null;if(d)for(let e=d.s.r;e<=d.e.r;e++)for(let t=d.s.c;t<=d.e.c;t++){let n=u[r.encode_cell({r:e,c:t})];if(!n||typeof n.v!=`string`||e===0)continue;let i=String(u[r.encode_cell({r:0,c:t})]?.v??``);a(i)&&(n.v=s(n.v),n.w!=null&&(n.w=n.v))}u[`!cols`]=i.map(e=>({wch:a(e)?48:Math.min(28,Math.max(12,e.length+4))}));let f=r.book_new();r.book_append_sheet(f,u,n.slice(0,31));let p=o(f,{bookType:`xlsx`,type:`base64`});try{return await g(p)}catch{return p}}var S=e(t(),1),C=n();function w({fields:e,sheetNames:t}){let n=(0,S.useRef)(null),r=(0,S.useRef)(null),i=(0,S.useRef)(null),[a,o]=(0,S.useState)(e.length),[s,c]=(0,S.useState)(!1),l=(0,S.useCallback)(()=>{let t=n.current,a=r.current;if(!t||!a||e.length===0)return;let s=t.clientWidth;if(s<=0)return;let c=Array.from(a.querySelectorAll(`[data-chip]`)).map(e=>e.offsetWidth),l=i.current?.offsetWidth??36,u=0;for(let e=0;e<c.length;e++)u+=c[e]+(e>0?4:0);if(u<=s){o(e.length);return}let d=0,f=0;for(let e=0;e<c.length;e++){let t=d+(f>0?4:0)+c[e];if(t+4+l<=s||e===c.length-1&&t<=s)d=t,f=e+1;else break}o(Math.max(1,Math.min(f,e.length-1)))},[e.length]);if((0,S.useLayoutEffect)(()=>{c(!1),l()},[e.join(`\0`),l]),(0,S.useEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{s||l()});return t.observe(e),()=>t.disconnect()},[s,e.join(`\0`),l]),!e.length)return null;let u=s?e:e.slice(0,a),d=s?0:Math.max(0,e.length-a);return(0,C.jsxs)(`div`,{ref:n,className:`mt-1.5 relative w-full min-w-0`,children:[t&&t.length>1&&(0,C.jsxs)(`p`,{className:`mb-1.5 text-xs text-stone-400 truncate`,"data-hint":t.join(` | `),children:[`工作表:`,t.join(` | `)]}),(0,C.jsxs)(`div`,{ref:r,className:`pointer-events-none absolute inset-x-0 top-0 -z-10 flex w-full gap-1 overflow-hidden opacity-0 whitespace-nowrap`,"aria-hidden":!0,children:[e.map(e=>(0,C.jsx)(`span`,{"data-chip":!0,className:`text-[11px] px-1.5 py-0.5 rounded border border-stone-200 max-w-36 shrink-0 truncate`,children:e},`m-${e}`)),(0,C.jsx)(`button`,{ref:i,type:`button`,tabIndex:-1,className:`text-[11px] px-1.5 py-0.5 shrink-0`,children:`+99`})]}),(0,C.jsxs)(`div`,{className:`flex gap-1 items-center w-full min-w-0 ${s?`flex-wrap`:`flex-nowrap overflow-hidden`}`,children:[u.map(e=>(0,C.jsx)(`span`,{className:`text-[11px] px-1.5 py-0.5 rounded border border-stone-200 text-stone-500 max-w-36 truncate shrink-0`,"data-hint":e,children:e},e)),d>0&&(0,C.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`text-[11px] text-stone-400 hover:text-amber-700 cursor-pointer shrink-0`,children:[`+`,d]}),s&&e.length>a&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`text-[11px] text-stone-400 hover:text-amber-700 cursor-pointer shrink-0`,children:`收起`})]})]})}export{f as a,x as c,m as i,h as n,b as o,p as r,y as s,w as t};
@@ -1 +0,0 @@
1
- export{t as default}from"./PluginsPage.Du4g_yr4.js";
@@ -1 +0,0 @@
1
- export{t as default}from"./PmRequirementsBoard.X98441HZ.js";
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i}from"./plugins.DYyAjBXb.js";import{a,n as o,o as s,r as c}from"./view-prefs.D1snIG5o.js";import{t as l}from"./react-dom.DLW9pGCF.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./SelectDropdown.Cb-QtC-D.js";import{t as f}from"./SlideOverDrawer.HqVYaIjP.js";import{_ as p,v as m,y as h}from"./pm.CagBA-ht.js";var g=e(t(),1),_=e(l(),1),v=u(),y=8e3;function b(e,t,n){let[r,i]=(0,g.useState)(()=>o(e,t,n));return[r,(0,g.useCallback)(t=>{i(t),a(e,t)},[e])]}function x(e,t=``){let[n,r]=(0,g.useState)(()=>c(e)||t);return[n,(0,g.useCallback)(n=>{r(n),s(e,n===t?``:n)},[e,t])]}function S(e){let[t,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(()=>r(e));return(0,g.useEffect)(()=>{let t=!0,o=i(()=>s(r(e)));return n().then(()=>{t&&(s(r(e)),a(!0))}),()=>{t=!1,o()}},[e]),{ready:t,on:o}}var C=(0,g.createContext)(null);function w(e){let[t,n]=(0,g.useState)(p),[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!0),[s,c]=(0,g.useState)(``),l=(0,g.useRef)(!0),u=(0,g.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await h();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]);return(0,g.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{let e=await m();l.current&&(e?(i(!0),await u(),t=window.setInterval(()=>void u(!0),y)):(i(!1),o(!1)))})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u}}function T({children:e}){let t=w(!0);return(0,v.jsx)(C.Provider,{value:t,children:e})}function E(){let e=(0,g.useContext)(C),t=w(e===null);return e??t}var D={gray:`bg-stone-100 text-stone-600`,blue:`bg-[#e1eaff] text-[#1f4ec2]`,amber:`bg-[#fff1e3] text-[#a85b00]`,yellow:`bg-[#fff7d6] text-[#8a6100]`,red:`bg-[#fee4e3] text-[#c02a26]`,purple:`bg-[#efe7ff] text-[#5b32b4]`,green:`bg-[#d9f5d2] text-[#1d7a12]`,muted:`bg-stone-100 text-stone-400`},O={planning:`blue`,in_progress:`amber`,archived:`gray`},k={planning:`blue`,in_progress:`amber`,done:`green`},A={urgent:`red`,high:`amber`,medium:`yellow`,low:`gray`},j={pending:`gray`,todo:`blue`,in_progress:`blue`,testing:`purple`,done:`green`,cancelled:`muted`},M={critical:`red`,major:`amber`,minor:`yellow`,trivial:`gray`},N={pending:`gray`,todo:`blue`,fixed:`amber`,verifying:`purple`,passed:`green`,cancelled:`muted`},P={gray:`#a8a29e`,blue:`#3370ff`,amber:`#f59e0b`,yellow:`#eab308`,red:`#ef4444`,purple:`#8b5cf6`,green:`#22c55e`,muted:`#d6d3d1`};function F({tone:e}){return(0,v.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:P[e]}})}function I({tone:e,children:t}){return(0,v.jsx)(`span`,{className:`inline-flex h-6 shrink-0 items-center rounded-md px-2 text-xs font-medium ${D[e]}`,children:t})}var L={plus:[`M12 5v14`,`M5 12h14`],more:[],chevronRight:[`m9 5 7 7-7 7`],chevronDown:[`m5 9 7 7 7-7`],arrowLeft:[`M19 12H5`,`m11 18-6-6 6-6`],pencil:[`M12 20h9`,`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`],trash:[`M3 6h18`,`M8 6V4h8v2`,`M19 6l-1 14H6L5 6`,`M10 11v6`,`M14 11v6`],copy:[`M9 9.5A1.5 1.5 0 0 1 10.5 8h7A1.5 1.5 0 0 1 19 9.5v7A1.5 1.5 0 0 1 17.5 18h-7A1.5 1.5 0 0 1 9 16.5Z`,`M5 15V5.5A1.5 1.5 0 0 1 6.5 4H15`],check:[`m4.5 12.5 5 5 10-11`],play:[`M8 5.5v13l11-6.5Z`],search:[`M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14Z`,`m20 20-3.6-3.6`],folder:[`M3 7.5A2.5 2.5 0 0 1 5.5 5h3.2l2 2h7.8A2.5 2.5 0 0 1 21 9.5v7A2.5 2.5 0 0 1 18.5 19h-13A2.5 2.5 0 0 1 3 16.5Z`],calendar:[`M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z`,`M8 3v4`,`M16 3v4`,`M4 10h16`],file:[`M7 3.5h6.5L18 8v12.5H7Z`,`M13.5 3.5V8H18`,`M10 12.5h5`,`M10 16h5`],bug:[`M8.5 9.5h7V14a3.5 3.5 0 0 1-7 0Z`,`M9.5 6.2 12 8l2.5-1.8`,`M4.5 13H8.5`,`M15.5 13h4`,`M6 18.5l2-2`,`M18 18.5l-2-2`]};function R({name:e,size:t=16,className:n=``}){return e===`more`?(0,v.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,className:n,children:[(0,v.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.6`}),(0,v.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1.6`})]}):(0,v.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:n,children:L[e].map(e=>(0,v.jsx)(`path`,{d:e},e))})}function z({tabs:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-tabs`,role:`tablist`,"aria-label":r,children:e.map(e=>(0,v.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:`tw-pm-tab`,children:[e.label,typeof e.count==`number`?(0,v.jsx)(`span`,{className:`tw-pm-tab-count`,children:e.count}):null]},e.value))})}function B({options:e,value:t,onChange:n,ariaLabel:r}){return(0,v.jsx)(`div`,{className:`tw-pm-pills`,role:`group`,"aria-label":r,children:e.map(e=>(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t===e.value,onClick:()=>n(e.value),children:e.label},e.value))})}function V({icon:e,title:t,hint:n,action:r}){return(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-4 py-20 text-center`,children:[(0,v.jsx)(`span`,{className:`tw-pm-tile mb-4 flex h-16 w-16 items-center justify-center rounded-2xl`,children:(0,v.jsx)(R,{name:e,size:30})}),(0,v.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:t}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:n}),r?(0,v.jsx)(`div`,{className:`mt-4`,children:r}):null]})}function H(e){return`/pm/projects/detail/?id=${encodeURIComponent(e)}`}var U=`h-9 w-full rounded-md border border-transparent bg-transparent px-2 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`,W=`min-h-[72px] w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`;function G(e){return(0,v.jsx)(d,{flat:!0,menuMatchTrigger:!0,ariaLabel:e.ariaLabel,options:e.options,value:e.value,onChange:e.onChange,disabled:e.disabled,renderOptionPrefix:e.renderOptionPrefix})}function K({page:e,totalPages:t,busy:n=!1,onPage:r}){let i=`h-7 shrink-0 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-40`;return(0,v.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 pt-3`,children:[(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e<=1,onClick:()=>r(e-1),children:`上一页`}),(0,v.jsxs)(`span`,{className:`px-2 text-xs tabular-nums text-stone-400`,children:[e,` / `,t]}),(0,v.jsx)(`button`,{type:`button`,className:i,disabled:n||e>=t,onClick:()=>r(e+1),children:`下一页`})]})}function q({label:e}){return(0,v.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}function J({children:e}){return(0,v.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:e})}function Y({children:e}){return(0,v.jsx)(`div`,{className:`px-4 py-16 text-center text-sm text-stone-400`,children:e})}function X({open:e,title:t,busy:n,submitLabel:r,onClose:i,onSubmit:a,children:o}){return(0,v.jsx)(f,{open:e,onClose:i,title:t,footer:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-stone-100 px-2 py-3`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 hover:bg-stone-100`,children:`取消`}),(0,v.jsx)(`button`,{type:`button`,disabled:n,onClick:a,className:`h-8 rounded-lg bg-[#3370ff] px-3 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:r})]}),children:o})}function Z({label:e,required:t,children:n}){return(0,v.jsxs)(`div`,{className:`flex items-start gap-3 px-2 py-2`,children:[(0,v.jsx)(`div`,{className:`flex h-9 w-[88px] shrink-0 items-center text-sm text-stone-600`,children:(0,v.jsxs)(`span`,{className:`truncate`,children:[e,t?(0,v.jsx)(`span`,{className:`ml-0.5 text-red-500`,children:`*`}):null]})}),(0,v.jsx)(`div`,{className:`min-w-0 flex-1 [&>div]:mt-0`,children:n})]})}function Q({file:e,onClose:t}){return e?(0,_.createPortal)((0,v.jsxs)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center bg-stone-900/70 p-6 sm:p-10`,role:`dialog`,"aria-modal":`true`,"aria-label":e.name,onClick:t,children:[(0,v.jsx)(`img`,{src:e.url,alt:e.name,className:`max-h-full max-w-full rounded-lg bg-white object-contain shadow-2xl`,onClick:e=>e.stopPropagation()}),(0,v.jsx)(`button`,{type:`button`,"aria-label":`关闭预览`,onClick:t,className:`absolute right-4 top-4 flex h-9 w-9 items-center justify-center rounded-full bg-white/90 text-lg text-stone-600 shadow-md transition-colors hover:bg-white hover:text-stone-900`,children:`✕`})]}),document.body):null}function $({message:e,onClose:t}){return(0,v.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,v.jsx)(`span`,{className:`min-w-0 flex-1`,children:e}),(0,v.jsx)(`button`,{type:`button`,onClick:t,"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:`✕`})]})}export{A as C,x as D,b as E,S as O,I as S,H as T,J as _,W as a,T as b,X as c,$ as d,Z as f,q as g,Q as h,U as i,E as k,Y as l,R as m,N as n,O as o,B as p,k as r,F as s,M as t,V as u,K as v,j as w,z as x,G as y};
@@ -1,29 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.DYyAjBXb.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as ee}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as p}from"./Toast.BO2NFckG.js";import{s as te}from"./llm.BZEzE0x2.js";import{o as ne}from"./project-docs.DAw9bzgk.js";import{f as re,l as ie,p as m}from"./settings.BvxRxdqa.js";import{C as ae,D as h,E as oe,S as se,T as ce,_ as le,a as ue,b as de,c as fe,d as pe,f as me,g as he,h as ge,i as _e,l as ve,m as g,n as ye,o as _,p as be,r as xe,s as Se,t as v,u as Ce,v as we,x as Te,y as Ee}from"./req-analysis.DGQa1vaH.js";import{_ as De,a as Oe,c as ke,d as Ae,f as je,g as Me,h as Ne,i as Pe,l as y,m as Fe,n as Ie,o as Le,p as Re,r as ze,s as Be,u as b}from"./story-review.BjrulZG8.js";import{t as Ve}from"./hydrate-cache.CmC22o_H.js";import{O as He,S as x,_ as Ue,g as We,m as S,u as Ge}from"./PmShared.DbDseTcc.js";var C=e(t(),1),Ke=`可用工具(只调用这些,不要自己编工具名):
2
- - req_set_outline:提交本批「需求条目」,返回每个条目的 id。
3
- - req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
4
- - req_save_check:提交体检结果(缺口清单 + 结论)。
5
- - req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
6
-
7
- 提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,qe=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function Je(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function w(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function T(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function Ye(e){let t=w(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function E(e){let t=w(e,40);return qe.includes(t)?t:`other`}var D=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function O(e){let t=w(e,40);if(D.includes(t))return t;let n=w(e,20);return D.find(e=>Be[e]===n)??`functional`}function k(e){let t=w(e,4).toUpperCase();return b.includes(t)?t:`P1`}function A(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=w(n.title,200);if(!r)return null;let i=w(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:O(n.dimension),priority:k(n.priority),title:r,precondition:w(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>w(e,500)).filter(Boolean).slice(0,20):[],expected:w(n.expected,1e3)}}var Xe=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:qe},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:D,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:b},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function Ze(e,t,n){let r=Je(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>T(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=w(e.title,200)||w(e.quote,200);if(!r||a.has(T(r)))continue;a.add(T(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:w(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=we(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=fe(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[T(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=w(n.title,200);if(!r)continue;let i=w(n.storyId,20),o=a.has(i)&&i||t.get(T(w(n.storyTitle,200)))||``,c=E(n.type);s.push({id:g(c,o,r),storyId:o,type:c,severity:Ye(n.severity),title:r,detail:w(n.detail,1e3),suggestion:w(n.suggestion,1e3),origin:`model`,selected:!1})}let c=le(e.gaps,s),l=w(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>A(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:w(r.summary,2e3),points:a})).testPoints?.points??a,s=D.map(e=>({dimension:Be[e],count:o.filter(t=>t.dimension===e).length})),c=b.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function j(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function Qe(e){let t=j(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}function $e(e,t=[]){let n=new Set(t),r=j(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>A(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?w(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var M=u(),N=`text-xs font-semibold tracking-wide text-stone-500`,P=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,et=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function tt({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,M.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始审查`})]});let c=Oe(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Ie(e.gaps),ee=new Map(t.map(e=>[e.id,e.title]));return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:N,children:`需求条目覆盖率`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,M.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,M.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,M.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,M.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,M.jsxs)(`div`,{className:`text-right`,children:[(0,M.jsx)(`p`,{className:N,children:`缺口`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,M.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,M.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsx)(`p`,{className:N,children:`维度覆盖`}),(0,M.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,M.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,M.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,M.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,M.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:et,onClick:s,children:`导出 Markdown`}),(0,M.jsx)(`button`,{type:`button`,className:et,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,M.jsx)(`button`,{type:`button`,className:P,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,M.jsx)(F,{gap:e,storyTitle:ee.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,M.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function F({gap:e,storyTitle:t,onToggle:n}){return(0,M.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(x,{tone:ye[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:xe[e.type]}),e.storyId?(0,M.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,M.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var I=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,L=`text-xs font-semibold tracking-wide text-stone-500`;function R({point:e}){return(0,M.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function z({doc:e}){let t=Me(e.testPoints);return(0,M.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,M.jsxs)(`div`,{className:`min-w-[860px]`,children:[(0,M.jsx)(`div`,{className:`flex justify-center`,children:(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5 text-center shadow-sm`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title||`未命名分析`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`测试点 `,e.testPoints?.points.length??0,` 条 · 五维覆盖`]})]})}),(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 right-[10%] left-[10%] h-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsx)(`div`,{className:`grid grid-cols-5 gap-3`,children:t.map(e=>{let t=ke[e.key];return(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:t.label})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,M.jsx)(`div`,{className:`space-y-1.5 px-2 py-2`,children:e.points.length?e.points.map(e=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority}),(0,M.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-stone-700`,children:e.title})]}),(0,M.jsx)(f,{text:`${e.storyId||`全局`}${e.expected?` · ${e.expected}`:``}`,className:`mt-1 block truncate text-[10px] text-stone-400`})]},e.id)):(0,M.jsx)(`p`,{className:`py-2 text-center text-[11px] text-stone-300`,children:`无`})})]})]},e.key)})})]}),(0,M.jsx)(`p`,{className:`mt-3 text-center text-[11px] text-stone-400`,children:`分支 = 五个维度,叶子 = 测试点;左侧标签为优先级。需要完整结构可导出 XMind。`})]})})}function nt({doc:e}){let t=Me(e.testPoints);return(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-stone-100 px-3.5 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${ke[e.key].accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-stone-700`,children:e.label}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.points.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`details`,{className:`group px-3.5 py-2`,children:[(0,M.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority})}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`font-mono`,children:e.storyId||`全局`}),(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,M.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,M.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,M.jsx)(R,{point:e})})]})},e.id))}):(0,M.jsx)(`p`,{className:`px-3.5 py-3 text-xs text-stone-400`,children:`本维度没有测试点。`})]},e.key))})}function rt({doc:e,generating:t,busy:n,promptReady:r,onGenerate:i,onExportXmind:a,onExportMarkdown:o}){let[s,c]=(0,C.useState)(`map`),l=e.testPoints,u=je(l);if(!l){let n=e.stories.length?r?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`基于拆好的用户故事,按功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度拆测试点,每条标 P0–P3;结果可看导图、可下载 XMind。`}),n?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:n}):null,(0,M.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:t?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:u.total}),` 条`]}),(0,M.jsx)(`span`,{className:`flex items-center gap-1`,children:b.map(e=>(0,M.jsxs)(x,{tone:y[e].tone,children:[e,` `,u.byPriority[e]]},e))}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,u.coveredDimensions,`/5`]}),(0,M.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,M.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${s===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>c(e.id),children:e.label},e.id))}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:i,children:t?`生成中…`:`重新生成`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:a,children:`导出 XMind`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:o,children:`导出 Markdown`})]})]}),s===`map`?(0,M.jsx)(z,{doc:e}):(0,M.jsx)(nt,{doc:e}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:L,children:`生成说明`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:l.at})]}),(0,M.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-stone-600`,children:l.summary||`(模型没有给整体结论)`})]})]})}var it=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],B=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,at=`w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,V=`text-xs font-semibold tracking-wide text-stone-500`,ot=`text-[11px] font-medium tracking-wide text-stone-400`,st={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function H({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,M.jsx)(`p`,{className:`${ot} pt-0.5`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function ct(e){return e.split(`
8
- `).map(e=>e.trim()).filter(Boolean)}function U({label:e,value:t,placeholder:n,onChange:r}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsxs)(`span`,{className:V,children:[e,`(一行一条)`]}),(0,M.jsx)(`textarea`,{className:`${at} mt-1 min-h-[64px]`,value:t.join(`
9
- `),placeholder:n,onChange:e=>r(ct(e.target.value))})]})}function lt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`主流程(一行一步:动作 -> 结果)`}),(0,M.jsx)(`textarea`,{className:`${at} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
10
- `),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(ct(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{action:e}:{action:e.slice(0,t).trim(),result:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function ut({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
11
- `)).join(`
12
-
13
- `);return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,M.jsx)(`textarea`,{className:`${at} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
14
- 1. 提交后进入人工队列
15
- 2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
16
- `).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function dt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`异常场景(一行一条:场景 -> 预期)`}),(0,M.jsx)(`textarea`,{className:`${at} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
17
- `),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(ct(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{scenario:e,expected:``}:{scenario:e.slice(0,t).trim(),expected:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function ft({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`验收标准(一行一条:Given | When | Then)`}),(0,M.jsx)(`textarea`,{className:`${at} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
18
- `),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(ct(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function pt({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(!1),[p,te]=(0,C.useState)(e),[ne,re]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(l||d){re(!0);return}let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},[l,d]);let ie=()=>{te({...e}),f(!0),u(!0)},m=e=>te(t=>({...t,...e})),ae=r.filter(e=>e.severity===`high`).length;return(0,M.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,M.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${st[e.priority]}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,M.jsx)(x,{tone:_[e.priority],children:e.priority}),(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,M.jsxs)(x,{tone:ae?`red`:`amber`,children:[r.length,` 个缺口`,ae?` · 高 ${ae}`:``]}):null]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`}),l?null:(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):ie(),children:(0,M.jsx)(S,{name:`pencil`,size:14})}),(0,M.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,M.jsx)(S,{name:`trash`,size:14})}),(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,M.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,M.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[ne&&d?(0,M.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`标题`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.title,onChange:e=>m({title:e.target.value})})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`角色`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.role,onChange:e=>m({role:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`优先级`}),(0,M.jsx)(`div`,{className:`mt-1`,children:(0,M.jsx)(ee,{options:it,value:p.priority,onChange:e=>m({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`目标`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.goal,onChange:e=>m({goal:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:V,children:`价值 / 备注`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.value,onChange:e=>m({value:e.target.value})})]}),(0,M.jsx)(U,{label:`前置条件`,value:p.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>m({preconditions:e})}),(0,M.jsx)(lt,{value:p.mainFlow,onChange:e=>m({mainFlow:e})}),(0,M.jsx)(ut,{value:p.altFlows,onChange:e=>m({altFlows:e})}),(0,M.jsx)(dt,{value:p.exceptions,onChange:e=>m({exceptions:e})}),(0,M.jsx)(U,{label:`后置条件`,value:p.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>m({postconditions:e})}),(0,M.jsx)(ft,{value:p.acceptance,onChange:e=>m({acceptance:e})}),(0,M.jsx)(U,{label:`覆盖维度`,value:p.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>m({dimensions:e})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>f(!1),children:`取消`}),(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!p.title.trim(),onClick:()=>{a(p),f(!1)},children:`保存`})]})]})]}):null,ne&&!d?(0,M.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,M.jsx)(H,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,M.jsx)(H,{label:`前置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,M.jsx)(H,{label:`主流程`,children:(0,M.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.actor?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,M.jsx)(H,{label:`替代流程`,children:(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,M.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,M.jsx)(H,{label:`异常场景`,children:(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.scenario,e.expected?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,M.jsx)(H,{label:`后置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,M.jsx)(H,{label:`验收标准`,children:(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,M.jsx)(`span`,{children:e.given||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,M.jsx)(`span`,{children:e.when||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,M.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,M.jsx)(H,{label:`覆盖维度`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,M.jsx)(H,{label:`来源条目`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,M.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,M.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,M.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,M.jsx)(x,{tone:ye[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`text-stone-500`,children:xe[e.type]}),(0,M.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var mt=`reqanalysis.doc`,ht=`reqanalysis.listmode`,gt=`reqanalysis.view`,_t=`reqanalysis.tab`,vt=`reqanalysis.storykeyword`,yt=[`list`,`work`],bt=[`stories`,`check`,`outline`,`points`],xt=`reqanalysis.activity`,St=[`info`,`tool`,`done`,`error`];function Ct(e){return`${xt}.${e}`}function wt(e){if(!e)return[];let t=l(Ct(e),[]);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.text==`string`&&typeof t.at==`string`&&St.includes(t.kind)}).slice(-200):[]}var Tt=/\.[a-z0-9]+$/i,Et={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},Dt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md bg-[#3370ff] px-3.5 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Ot=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-stone-200 bg-white px-3 text-sm text-stone-700 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,kt=`text-xs font-semibold tracking-wide text-stone-500`;function At(e){return e.split(`/`).pop()||e}function jt(e){return e.replace(Tt,``)}function Mt(e){return(e.format||At(e.path).split(`.`).pop()||``).toLowerCase()}function Nt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`),r=`${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;return t.getFullYear()===new Date().getFullYear()?r:`${t.getFullYear()}/${r}`}function Pt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Ft({name:e,ready:t}){return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function It(){let e=He(`reqAnalysis`),t=He(`storyReview`),l=He(`testPoints`),[u,le]=(0,C.useState)(null),[g,ye]=(0,C.useState)([]),[_,xe]=(0,C.useState)(``),[v,Oe]=(0,C.useState)(null),[ke,je]=(0,C.useState)([]),[Me,y]=(0,C.useState)(``),[Ie,Be]=(0,C.useState)(``),[b,qe]=(0,C.useState)(null),[Je,w]=(0,C.useState)(null),[T,Ye]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(null),[N,P]=(0,C.useState)([]),[et,F]=(0,C.useState)(``),[I,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(()=>o(_t,bt,`stories`));(0,C.useEffect)(()=>{i(_t,R)},[R]);let[nt,it]=(0,C.useState)(`list`),B=(0,C.useRef)(o(gt,yt,`list`)),[at,V]=(0,C.useState)(()=>B.current===`work`),[ot,st]=(0,C.useState)(()=>o(ht,[`doc`,`story`],`doc`)),[H,ct]=(0,C.useState)(()=>c(vt,``));(0,C.useEffect)(()=>{s(vt,H)},[H]);let[U,lt]=(0,C.useState)(null),[ut,dt]=(0,C.useState)([]),ft=(0,C.useRef)(``),[xt,St]=(0,C.useState)(``),[Tt,It]=(0,C.useState)(!1),[Lt,Rt]=(0,C.useState)(!1),W=(0,C.useRef)(null),G=(0,C.useRef)(null),zt=(0,C.useRef)(0),Bt=(0,C.useRef)(null),Vt=(0,C.useRef)(null),Ht=(0,C.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?Se[e]:Se.decomposed,[t.on]),Ut=(0,C.useMemo)(()=>{let e=e=>+!e.supported;return[...ke].filter(e=>!ne(e.name)).sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=Mt(e),n=Et[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[ke]),K=(0,C.useCallback)(e=>{W.current=e,Oe(e),ye(t=>Pt(t.map(t=>t.id===e.id?e:t)))},[]),q=(0,C.useCallback)((e,t=`info`)=>{zt.current+=1,P(n=>[...n,{id:zt.current,kind:t,text:e,at:new Date().toISOString()}])},[]),Wt=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!_){Wt.current=!0,P([]);return}let e=wt(_);zt.current=e.reduce((e,t)=>Math.max(e,t.id),0),Wt.current=!0,P(e)},[_]),(0,C.useEffect)(()=>{Wt.current?Wt.current=!1:_&&a(Ct(_),N.slice(-200))},[N,_]);let J=(0,C.useCallback)(e=>{W.current=e,Oe(e),xe(e?.id??``),s(mt,e?.id??``),e?.sourcePath&&y(e.sourcePath)},[]),Y=(0,C.useCallback)(e=>{it(e),i(gt,e)},[]),X=(0,C.useCallback)((e,t=`stories`)=>{J(e),z(t),Y(`work`),Ve(`req-analysis`)},[Y,J]),Gt=(0,C.useCallback)((e,t)=>{ft.current=t,X(e,`stories`)},[X]);(0,C.useEffect)(()=>{if(nt!==`work`||!ft.current)return;let e=ft.current;ft.current=``;let t=0,n=requestAnimationFrame(()=>{let n=document.getElementById(`req-story-${e}`);n&&(n.scrollIntoView({block:`center`,behavior:`smooth`}),n.classList.add(`tw-req-story-focus`),t=window.setTimeout(()=>n.classList.remove(`tw-req-story-focus`),1600))});return()=>{cancelAnimationFrame(n),t&&window.clearTimeout(t)}},[nt,v?.id]);let Kt=(0,C.useMemo)(()=>g.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[g]),qt=Kt.length,Jt=(0,C.useMemo)(()=>{let e=H.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?Kt.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(e.title)):Kt,r=[],i=new Map;for(let e of n){let t=i.get(e.doc.id);t===void 0?(i.set(e.doc.id,r.length),r.push({doc:e.doc,rows:[e]})):r[t].rows.push(e)}return r.sort((e,t)=>t.doc.updatedAt.localeCompare(e.doc.updatedAt))},[Kt,H]),Yt=(0,C.useMemo)(()=>new Set(U?.ids??[]),[U]),Xt=(0,C.useCallback)((e,t)=>{lt(n=>{if(!n||n.docId!==e)return{docId:e,ids:[t]};let r=n.ids.includes(t)?n.ids.filter(e=>e!==t):[...n.ids,t];return r.length?{docId:e,ids:r}:null})},[]),Zt=(0,C.useCallback)((e,t)=>{lt(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Qt=(0,C.useCallback)(e=>{st(e),i(ht,e)},[]);(0,C.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;qe(ie());let t=await me();if(e&&(le(t),t))try{let[t,n,r,i]=await Promise.all([ge(),be(),Pe(),Ne()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await ce(!0).catch(()=>void 0),a=await be()),!e)return;w(a);let o=r;if((!r.exists||!r.review.trim())&&(await Le(!0).catch(()=>void 0),o=await Pe()),!e)return;o.exists&&Ye(o),i.exists&&D(i);let s=Pt(t);ye(s);let l=c(mt,``),u=s.find(e=>e.id===l)??s[0]??null;J(u);let d=B.current;B.current=`list`,d===`work`&&u&&l&&u.id===l&&(Y(`work`),Ve(`req-analysis`)),V(!1)}catch(t){e&&(V(!1),L(t instanceof Error?t.message:String(t)))}})();let t=re(()=>qe(ie()));return()=>{e=!1,t()}},[Y,J]),(0,C.useEffect)(()=>{if(!t.ready)return;if(!t.on){Ye(null),z(e=>e===`check`?`stories`:e);return}if(!u||T!==null)return;let e=!0;return(async()=>{let t=await Pe();(!t.exists||!t.review.trim())&&(await Le(!0).catch(()=>void 0),t=await Pe()),e&&Ye(t)})(),()=>{e=!1}},[t.ready,t.on,u,T]),(0,C.useEffect)(()=>{if(!l.ready)return;if(!l.on){D(null),z(e=>e===`points`?`stories`:e);return}if(!u||E!==null)return;let e=!0;return(async()=>{let t=await Ne();(!t.exists||!t.generate.trim())&&(await De(!0).catch(()=>void 0),t=await Ne()),e&&D(t)})(),()=>{e=!1}},[l.ready,l.on,u,E]),(0,C.useEffect)(()=>{if(!u)return;let e=!0;return he().then(t=>{e&&je(t)}).catch(t=>{e&&Be(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[u]),(0,C.useEffect)(()=>{let e=v?.sourcePath;if(!e){St(``);return}let t=!0;return de(e).then(e=>{t&&St(se(e))}).catch(()=>{t&&St(``)}),()=>{t=!1}},[v?.sourcePath,v?.sourceHash]),(0,C.useEffect)(()=>{let e=Bt.current;e&&(e.scrollTop=e.scrollHeight)},[N]);let $t=!!(v?.sourceHash&&xt&&v.sourceHash!==xt),en=(0,C.useMemo)(()=>new Set((v?.stories??[]).flatMap(e=>e.sourceRefs)),[v?.stories]),tn=Je??null,nn=!!tn?.decompose.trim(),rn=(0,C.useMemo)(()=>(v?.check?.gaps??[]).filter(e=>e.selected).length,[v?.check]),Z=(0,C.useCallback)(async(e,t)=>{let n=t??W.current;if(!n)throw Error(`还没有分析文档`);let r=await h(n.id,e);return K(r),r},[K]),an=(0,C.useCallback)(()=>{Vt.current&&window.clearTimeout(Vt.current),Vt.current=window.setTimeout(()=>{let e=W.current;e?.check&&h(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),on=(0,C.useCallback)(async e=>{if(!e)return null;let t=g.find(t=>t.sourcePath===e);if(t)return X(t,`stories`),t;try{let t=await de(e),n=At(e),r=await ve({sourcePath:e,sourceTitle:n,sourceHash:se(t),title:jt(n)});return ye(e=>Pt([r,...e])),X(r,`stories`),q(`新建分析:${r.title}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),p(t,`error`),y(W.current?.sourcePath??``),null}},[g,X,q]),sn=!!(b?.baseURL&&b.apiKey&&b.model),cn=(0,C.useCallback)(()=>!sn||!b?(p(`请先在设置里配置模型`,`error`),m(`model`),null):b,[sn,b]),Q=(0,C.useCallback)((e,t)=>({getDoc:()=>W.current,batch:t,saveOutline:async t=>{let n=await h(e.id,{outline:t});return K(n),n.outline},saveStories:async t=>{let n=await h(e.id,{stories:t});return K(n),q(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=W.current?.check,r={...t,gaps:Ee(n?.gaps??[],t.gaps)},i=await h(e.id,{check:r,status:`checked`});return K(i),i},saveTestPoints:async t=>{let n=await h(e.id,{testPoints:t});return K(n),n}}),[K,q]),ln=(0,C.useCallback)(async()=>{let e=W.current,n=cn();if(!e||!n)return;let r=tn?.decompose.trim()??``;if(!r){p(`没有读到「${ue}」的「## 拆解」段落`,`error`);return}L(``),F(``),P([]),k(`decompose`),j({label:`拆解`,done:0,total:0,message:`正在读取来源文档`});let i=new AbortController;G.current=i;try{let a=await h(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:0,message:`正在读取来源文档`,at:new Date().toISOString()}});K(a);let o=await de(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=ae(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);j({label:`拆解`,done:0,total:s.length,message:`共 ${s.length} 批,准备拆第 1 批`}),q(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await h(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:se(o)});K(c);for(let t of s){if(i.signal.aborted)break;let a=W.current?.stories.length??0,o=[r,``,Ke,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(W.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
19
- `)||`(本批还没有条目,先调用 req_set_outline)`].join(`
20
- `),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
21
- `);await Z({progress:{stage:`stories`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},W.current).catch(()=>void 0),j({label:`拆解`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`});let l=``;for await(let r of te(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Xe,maxToolRounds:20,runTool:(n,r)=>Ze(n,r,Q(e,t.index))}))r.type===`content`?(l+=r.delta,F(e=>e+r.delta)):r.type===`tool`&&r.status===`running`&&q(`调用 ${r.name}`,`tool`);if((W.current?.stories.length??0)===a){let n=Qe(l);if(n.length){let t=we(W.current?.stories??[],n),r=await h(e.id,{stories:t});K(r),q(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else q(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}j({label:`拆解`,done:t.index+1,total:s.length,message:`第 ${t.index+1}/${s.length} 批已写入`})}if(i.signal.aborted){q(`已中断:已经写入的故事保留`,`info`);return}let l=await h(e.id,{status:`decomposed`,progress:{stage:`done`,done:s.length,total:s.length,message:`拆解完成`,at:new Date().toISOString()}});K(l),q(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),z(`stories`),t.on&&!i.signal.aborted?(p(`拆解完成,接着做用户故事审查`,`success`),await dn.current?.(!0)):p(`拆解完成`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?q(`已中断:已经写入的故事保留`,`info`):(L(t),q(`拆解失败:${t}`,`error`))}finally{k(null),j(null),G.current=null}},[Q,K,q,tn,cn,t.on,Z]),un=(0,C.useCallback)(async(e=!1)=>{let t=W.current;if(!t)return;if(!t.stories.length){e||p(`还没有用户故事,先做一次拆解`,`info`);return}L(``),e||(F(``),P([])),k(`audit`),j({label:`审查用户故事`,done:0,total:2,message:`正在跑规则体检`});let n=new AbortController;G.current=n;try{let e=fe(t),r=await h(t.id,{check:{...e,gaps:Ee(t.check?.gaps??[],e.gaps)},status:`checked`,progress:{stage:`audit`,done:0,total:1,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});K(r),q(`规则体检:覆盖率 ${Math.round(e.coverage.rate*100)}%,${e.gaps.length} 个缺口`),j({label:`审查用户故事`,done:1,total:2,message:`规则体检完成,等待模型评审`});let i=T?.review.trim()??``,a=sn?b:null;if(!a||!i){q(a?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),z(`check`);return}let o=!1,s=Q(t,90),c=s.saveCheck;s.saveCheck=async e=>{o=!0;let t=await c(e);return q(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let l=W.current??r,u=await Te(l.sourcePath);u.text||q(`没有读到原始需求,只能依据需求条目摘句审查`,`info`);let d=[`## 原始需求`,u.text?u.truncated?`${u.text}\n\n(原文共 ${u.total} 字,以上为前 ${u.text.length} 字,没看到的部分不要猜)`:u.text:`(未读到原始需求,只能依据下面的需求条目摘句判断)`,``,`## 需求条目`,l.outline.length?l.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
22
- `):`(无)`,``,`## 用户故事(${l.stories.length} 条)`,"```json",JSON.stringify(l.stories,null,2),"```"].join(`
23
- `);for await(let e of te(a,[{role:`system`,content:`${i}\n\n${Ke}`},{role:`user`,content:d}],n.signal,{tools:Xe.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Ze(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&q(`调用 ${e.name}`,`tool`);o||(q(`模型没有提交体检结果,当前只保留规则结果`,`error`),p(`模型没有提交体检结果,只保留了规则检查`,`error`)),j({label:`审查用户故事`,done:2,total:2,message:o?`模型评审完成`:`已保留规则结果`}),z(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?q(`已中断:规则体检结果已保留`,`info`):(L(t),q(`体检失败:${t}`,`error`))}finally{k(null),j(null),G.current=null}},[Q,sn,K,q,T,b]),dn=(0,C.useRef)(null);dn.current=un;let fn=(0,C.useCallback)(async()=>{let e=W.current,t=cn();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){p(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=T?.fix.trim()??``;if(!r){p(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}L(``),F(``),P([]),k(`fix`);let i=new AbortController;G.current=i;try{q(`按 ${n.length} 个勾选缺口补写`,`info`);let a=new Map(e.stories.map(e=>[e.id,e.title])),o=await Te(e.sourcePath),s=[`## 原始需求`,o.text?o.truncated?`${o.text}\n\n(原文共 ${o.total} 字,以上为前 ${o.text.length} 字,没看到的部分不要猜)`:o.text:`(未读到原始需求,只能依据需求条目与当前故事集判断)`,``,`## 需求条目(新增故事的 sourceRefs 只能引用这里的 id)`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
24
- `):`(无)`,``,`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${a.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
25
- `)}).join(`
26
- `)].join(`
27
- `),c=Q(e,90),l=!1,u=c.saveStories;c.saveStories=async e=>(l=!0,u(e));for await(let e of te(t,[{role:`system`,content:`${r}\n\n${Ke}`},{role:`user`,content:s}],i.signal,{tools:Xe.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Ze(e,t,c)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&q(`调用 ${e.name}`,`tool`);if(!l){q(`模型没有提交补写结果,故事集保持不变`,`error`),p(`模型没有提交补写结果`,`error`);return}let d=W.current;if(d){let e=fe(d),t=await h(d.id,{check:e,status:`decomposed`});K(t)}q(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`),z(`check`),p(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?q(`已中断:已经写入的改动保留`,`info`):(L(t),q(`补写失败:${t}`,`error`))}finally{k(null),G.current=null}},[Q,K,q,cn,T]),pn=(0,C.useCallback)(async()=>{let e=W.current,t=cn();if(!e||!t)return;if(!e.stories.length){p(`还没有用户故事,先做一次拆解`,`info`);return}let n=E?.generate.trim()??``;if(!n){p(`没有读到「${Ae}」的「## 生成」段落`,`error`);return}L(``),F(``),P([]),k(`testpoints`),z(`points`),j({label:`生成测试点`,done:0,total:2,message:`正在整理用户故事,等待模型生成`}),await Z({progress:{stage:`points`,done:0,total:2,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0),q(`开始生成测试点(五维覆盖,P0–P3)`,`info`);let r=new AbortController;G.current=r;try{let i=Q(e,90),a=!1,o=i.saveTestPoints;i.saveTestPoints=async e=>{a=!0,j({label:`生成测试点`,done:1,total:2,message:`正在写入测试点`});let t=await o(e);return q(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let s=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
28
- `):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
29
- `),c=``;for await(let e of te(t,[{role:`system`,content:`${n}\n\n${Ke}`},{role:`user`,content:s}],r.signal,{tools:Xe.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>Ze(e,t,i)}))e.type===`content`?(c+=e.delta,F(t=>t+e.delta)):e.type===`tool`&&e.status===`running`&&q(`调用 ${e.name}`,`tool`);if(!a){let t=$e(c,e.stories.map(e=>e.id));t&&(await i.saveTestPoints(t),a=!0,q(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!a)q(`模型没有提交测试点,原结果保持不变`,`error`),p(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=W.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;q(`测试点完成:${e.length} 条(P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)})`,`done`),j({label:`生成测试点`,done:2,total:2,message:`已生成 ${e.length} 条`}),await Z({progress:{stage:`done`,done:2,total:2,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},W.current).catch(()=>void 0),p(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);r.signal.aborted?q(`已中断:已经生成的测试点保留`,`info`):(L(t),q(`生成测试点失败:${t}`,`error`))}finally{k(null),j(null),G.current=null}},[Q,q,cn,Z,E]),mn=(0,C.useCallback)(async()=>{let e=W.current;if(!e?.testPoints)p(`还没有测试点可导出`,`info`);else try{let t=await Fe(e);q(`已导出 ${t}`,`done`)}catch(e){p(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[q]),hn=(0,C.useCallback)(()=>{let e=W.current;if(!e?.testPoints){p(`还没有测试点可导出`,`info`);return}let t=Re(e);q(`已导出 ${t}`,`done`)},[q]),$=(0,C.useCallback)(async e=>{let t=W.current;if(t)try{await Z({stories:e},t)}catch(e){p(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Z]),gn=(0,C.useCallback)((e,t)=>{let n=W.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);$(r)},[$]),_n=(0,C.useCallback)(e=>{let t=W.current;t&&$(t.stories.filter((t,n)=>n!==e))},[$]),vn=(0,C.useCallback)((e,t)=>{let n=W.current;if(!n)return;let r=e+t;if(r<0||r>=n.stories.length)return;let i=[...n.stories],a=i[e],o=i[r];a&&o&&(i[e]=o,i[r]=a,$(i))},[$]),yn=(0,C.useCallback)((e,t)=>{let n=W.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};K(r),an()},[K,an]),bn=(0,C.useCallback)(e=>{let t=W.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};K(n),an()},[K,an]),xn=(0,C.useCallback)(e=>{let t=W.current,n=e.trim();t&&n&&n!==t.title&&Z({title:n},t).catch(()=>void 0)},[Z]),Sn=(0,C.useCallback)(async()=>{let e=W.current;if(e)try{await Ce(e.id);let t=g.filter(t=>t.id!==e.id);ye(t),J(t[0]??null),Y(`list`),p(`已删除分析记录`,`success`)}catch(e){p(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{It(!1)}},[Y,g,J]),Cn=(0,C.useCallback)(()=>{let e=W.current;if(!e)return;let t=new Blob([oe(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=pe(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),p(`已导出 Markdown`,`success`)},[]),wn=(0,C.useCallback)(()=>{let e=W.current;if(!e?.check)return;let t=ze(e,e.check);p(`已导出 ${t}`,`success`)},[]),Tn=(0,C.useCallback)(()=>{G.current?.abort()},[]);if(!e.ready)return(0,M.jsx)(We,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(Ue,{children:r(`reqAnalysis`)});if(u===null)return(0,M.jsx)(We,{label:`正在连接需求分析服务`});if(!u)return(0,M.jsx)(Ue,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(at)return(0,M.jsx)(We,{label:`正在回到上次的分析`});let En=v?.outline.filter(e=>en.has(e.id)).length??0,Dn=v?.check?.gaps??[],On=(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,M.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,M.jsx)(`p`,{className:kt,children:`新建分析`}),(0,M.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,M.jsx)(ee,{options:Ut,value:Me,onChange:e=>{y(e),e&&on(e)},triggerTitle:Me||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,M.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,g.length,` 份分析`]})]}),Ie?(0,M.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Ie,(0,M.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,_e,` 之外的内容目录没有被移动。`]}):null]}),I?(0,M.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>Qt(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${ot===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Qt(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${ot===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),ot===`story`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(S,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:H,onChange:e=>ct(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[qt,` 个故事`,U?` · 已选 ${U.ids.length}`:``]}),(0,M.jsx)(`button`,{type:`button`,disabled:!U,onClick:()=>{if(!U)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:U.docId,stories:U.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${Dt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,M.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[g.length,` 份分析 · `,qt,` 个故事`]})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:ot===`doc`?g.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:g.map(e=>{let t=Ht(e.status);return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>X(e,`stories`),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),(0,M.jsx)(x,{tone:t.tone,children:t.label})]}),(0,M.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,M.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,M.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,M.jsx)(`span`,{children:Nt(e.updatedAt)})]})]})}),(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>X(e,`stories`),children:[`用户故事`,(0,M.jsx)(S,{name:`chevronRight`,size:13})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{J(e),It(!0)},children:(0,M.jsx)(S,{name:`trash`,size:14})})]},e.id)})}):(0,M.jsx)(Ge,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):Jt.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:Jt.map(({doc:e,rows:t})=>{let n=ut.includes(e.id),r=t.map(e=>e.story.id),i=U?.docId===e.id&&r.length>0&&r.every(e=>Yt.has(e));return(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${e.title} 的全部故事`,checked:i,onChange:()=>Zt(e.id,r)}),(0,M.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>dt(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,M.jsx)(S,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:e.title}),(0,M.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,Nt(e.updatedAt)]})]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>X(e,`stories`),children:`打开拆解`})]}),n?null:(0,M.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:Yt.has(t.id)&&U?.docId===e.id,onChange:()=>Xt(e.id,t.id)}),(0,M.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>Gt(e,t.id),children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,M.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,M.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,M.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,M.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,M.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,M.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,M.jsx)(Ge,{icon:`file`,title:H?`没有匹配的用户故事`:`还没有用户故事`,hint:H?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[nt===`list`?On:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{y(``),L(``),Y(`list`)},children:[(0,M.jsx)(S,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:v?.title?`用户故事 · ${v.title}`:`用户故事`})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,M.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,M.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:kt,children:`分析记录`}),(0,M.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:g.length})]}),(0,M.jsx)(`div`,{className:`px-2 py-2`,children:g.length?(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:g.map(e=>{let t=e.id===_,n=Ht(e.status);return(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>J(e),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(f,{text:e.title,matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,M.jsx)(x,{tone:n.tone,children:n.label}),(0,M.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,M.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:kt,children:`提示词`})}),(0,M.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(Ft,{name:ue,ready:nn}),(0,M.jsx)(Ft,{name:T?.file??`用户故事审查提示词.md`,ready:t.on&&!!T?.review.trim()&&!!T?.fix.trim()}),(0,M.jsx)(Ft,{name:Ae,ready:l.on&&!!E?.generate.trim()})]}),(0,M.jsx)(`p`,{className:`mt-2 text-[11px] ${sn?`text-stone-400`:`text-amber-700`}`,children:sn?`模型:${b?.model}`:`还没配置模型`})]})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:kt,children:`动作`})}),(0,M.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,M.jsx)(`button`,{type:`button`,className:`${Dt} w-full`,disabled:!v||!!O||!v.sourcePath,onClick:()=>{v?.stories.length?Rt(!0):ln()},children:O===`decompose`?`拆解中…`:v?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,M.jsx)(`button`,{type:`button`,className:`${Ot} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void un(),children:O===`audit`?`审查中…`:v?.check?`重新审查用户故事`:`用户故事审查`}):null,l.on?(0,M.jsx)(`button`,{type:`button`,className:`${Ot} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void pn(),children:O===`testpoints`?`生成中…`:v?.testPoints?`重新生成测试点`:`生成测试点`}):null,O?(0,M.jsx)(`button`,{type:`button`,className:`${Ot} w-full`,onClick:Tn,children:`中断`}):(0,M.jsx)(`button`,{type:`button`,className:`${Ot} w-full`,disabled:!v,onClick:Cn,children:`导出 Markdown`}),v&&!O?(0,M.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>It(!0),children:`删除这份分析`}):null]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:kt,children:`活动日志`}),N.length?(0,M.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>P([]),children:`清空`}):null]}),(0,M.jsx)(`div`,{ref:Bt,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:N.length?N.map(e=>(0,M.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:`text-stone-500`,children:e.text})]},e.id)):(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[I?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,v?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{className:`min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-[15px] font-semibold text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,defaultValue:v.title,"aria-label":`分析标题`,onBlur:e=>xn(e.target.value)},v.id),O?(0,M.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),A?A.message:O===`decompose`?`拆解中`:O===`audit`?`审查中`:O===`testpoints`?`生成测试点中`:O===`fix`?`补写中`:`处理中`,A&&A.total>0?(0,M.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(A.done,A.total)/A.total*100),`%`]}):null]}):null,(0,M.jsx)(x,{tone:Ht(v.status).tone,children:Ht(v.status).label})]}),O?(0,M.jsx)(`div`,{className:`mt-2`,children:(0,M.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${A?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A&&A.total>0?Math.round(Math.min(A.done,A.total)/A.total*100):void 0,children:(0,M.jsx)(`div`,{className:A&&A.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:A&&A.total>0?{width:`${Math.round(Math.min(A.done,A.total)/A.total*100)}%`}:void 0})})}):null,(0,M.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.stories.length})]}),(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,M.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[En,`/`,v.outline.length]}),` `,`覆盖`]}),t.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:Dn.length}),rn?` · 已选 ${rn}`:``]}),v.check?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.check.coverage.total?`${Math.round(v.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,l.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.testPoints?.points.length??0})]})]}):null,(0,M.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,v.sourcePath]}),$t?(0,M.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,M.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:v.stories.length},{id:`check`,label:`审查结果`,count:Dn.length},{id:`outline`,label:`需求条目`,count:v.outline.length},{id:`points`,label:`测试点`,count:v.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||l.on)).map(e=>{let t=R===e.id;return(0,M.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>z(e.id),children:[e.label,(0,M.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[R===`stories`?v.stories.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.stories.map((e,t)=>(0,M.jsx)(pt,{story:e,index:t,total:v.stories.length,gaps:Dn.filter(t=>t.storyId===e.id),busy:!!O,onSave:e=>gn(t,e),onDelete:()=>_n(t),onMove:e=>vn(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,R===`check`&&t.on?(0,M.jsx)(tt,{check:v.check,stories:v.stories,busy:!!O,onToggleGap:yn,onToggleAll:bn,onFix:()=>void fn(),onReview:()=>void un(),onExport:wn}):null,R===`points`&&l.on?(0,M.jsx)(rt,{doc:v,generating:O===`testpoints`,busy:!!O,promptReady:!!E?.generate.trim(),onGenerate:()=>void pn(),onExportXmind:()=>void mn(),onExportMarkdown:hn}):null,R===`outline`?v.outline.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.outline.map(e=>{let t=en.has(e.id);return(0,M.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,M.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,M.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),et?(0,M.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,M.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:et})]}):null]}):(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,M.jsx)(d,{open:Tt,title:`删除分析记录`,message:`确认删除「${v?.title??``}」?故事、需求条目、体检报告与测试点都会一起删掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>It(!1),onConfirm:()=>void Sn()}),(0,M.jsx)(d,{open:Lt,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${v?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>Rt(!1),onConfirm:()=>{Rt(!1),ln()}})]})}export{It as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.v4kQH163.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as u,c as d,d as te,g as ne,h as re,i as ie,l as ae,m as oe,n as se,p as ce,r as f,s as p,t as le,u as ue}from"./project-docs.DAw9bzgk.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.BoerpmsB.js";import{t as m}from"./NamePromptDialog.CS1pTTVl.js";var h=e(t(),1),g=o(),pe=5;function _({className:e=`w-4 h-4`,open:t=!1}){return(0,g.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,g.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,g.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function v({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,g.jsx)(`path`,{d:`m15 5 4 4`})]})}function y({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M3 6h18`}),(0,g.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,g.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,g.jsx)(`path`,{d:`M10 11v6`}),(0,g.jsx)(`path`,{d:`M14 11v6`})]})}function b({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,g.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(_,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,g.jsx)(b,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function x(){let[e,t]=(0,h.useState)(()=>r(`requirements`)),[o,x]=(0,h.useState)(!1),[S,he]=(0,h.useState)(null),[C,ge]=(0,h.useState)([]),[_e,ve]=(0,h.useState)(0),[w,T]=(0,h.useState)(`.`),[E,D]=(0,h.useState)([]),[ye,O]=(0,h.useState)({}),[k,be]=(0,h.useState)(!0),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[xe,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(null),[Se,V]=(0,h.useState)(1),[H,Ce]=c(pe),[we,U]=(0,h.useState)(null),W=(0,h.useRef)(null),{cls:Te,play:G}=fe(),K=(0,h.useCallback)(async()=>{let e=await ie(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,h.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([d(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,h.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),x(!0)}),e},[]),(0,h.useEffect)(()=>{o&&e&&(async()=>{let e=await f(`requirements`);if(he(e),e)try{let[e]=await Promise.all([d(`requirements`,`.`),K()]);D(e.entries),T(e.path)}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Ee(){be(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await d(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function De(e){I(!1),N(!0),j(null);try{await ae(`requirements`,w,e),await q(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function Oe(e){if(e.type===`file`){N(!0),j(null);try{await ue(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ne(`requirements`,w,t);await q(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),W.current&&(W.current.value=``)}}}function Ae(e){let t=u(C,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function je(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function Me(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await se(`requirements`,e.path),P&&p(P.path,e.path)&&F(null);let t=p(w,e.path)?te(e.path):w;await q(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Ne(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await re(`requirements`,t.path,e);await q(oe(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Pe=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Fe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){N(!0),j(null);try{let t=await ce(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!o)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,g.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(`requirements`)});if(S===null)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!S)return(0,g.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:`需求文档库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(Se,Q),Ie=X.slice(($-1)*H,$*H);function Le(e){G(),Ce(e),V(1)}return(0,g.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,g.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Ee()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,g.jsx)(_,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:C.map(e=>(0,g.jsx)(b,{node:e,depth:0,activePath:w,expanded:ye,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,g.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,g.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),w===`.`?``:w]}),(0,g.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,g.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,g.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,g.jsx)(_,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,g.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,g.jsx)(`ul`,{className:`${Te}space-y-1`,children:Ie.map(e=>{let t=we===e.path;return(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Fe(e)},onDoubleClick:t=>{t.preventDefault(),Oe(e)},children:[(0,g.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,g.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,g.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,g.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,g.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,g.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Le}):null]}),(0,g.jsx)(m,{open:xe,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void De(e)}),(0,g.jsx)(m,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Ne(e)}),(0,g.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Pe,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Me()})]})}export{x as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.CF1xVPmo.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.Cb-QtC-D.js";import{i as o}from"./case-types.DS1EQ5yP.js";var s=`/__tb_case_sessions`,c=`tw.case.sessions.v1`,l=!1;function u(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function d(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return o().some(e=>e.id===t),t}return o()[0]?.id??`functional`}function f(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:d(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 p(){try{let e=localStorage.getItem(n(c));return e?f(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function m(e){try{localStorage.setItem(n(c),JSON.stringify(e))}catch{}}async function h(){try{let e=await fetch(s,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();l=!0;let n=f(t.store);return m(n),n}}catch{}return l=!1,p()}function g(){return p()}async function _(e){if(m(e),l)try{await fetch(s,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function v(e){m(e),_(e)}function y(e){let t=Date.now(),n={id:u(),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 v({sessions:[n,...p().sessions],activeId:n.id}),n}function b(e,t){let n=p(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return v(i),i}var x=e(t(),1),S=r();function C({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:a=!1}){let[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!o)return;function e(e){c.current?.contains(e.target)||s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let l=e.filter(e=>t.includes(e.value)).map(e=>e.label),u=a||l.length===0?r:l.length<=2?l.join(`、`):`已选 ${l.length} 项`;function d(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,S.jsxs)(`div`,{className:`relative mt-1`,ref:c,children:[(0,S.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>s(e=>!e),className:a?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,S.jsx)(i,{text:u,className:`min-w-0 flex-1 truncate ${a||l.length?``:`text-stone-400`}`}),(0,S.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,S.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),o?(0,S.jsx)(`div`,{className:`tw-select-menu tw-dsh-scroll tw-popover-anim absolute z-80 mt-1 max-h-72 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,S.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>d(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,S.jsx)(i,{text:e.label,className:`min-w-0 flex-1 truncate`})]},e.value)})}):null]})}function w({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:o=!1,allowEmpty:s=!0,emptyLabel:c=`不选择`}){let l=(0,x.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return s?[{value:``,label:c,muted:!0},...t]:t},[e,s,c]),u=t?l.find(e=>e.value===t):void 0;return(0,S.jsx)(a,{options:l,value:t,onChange:n,disabled:o,searchable:!0,searchPlaceholder:r,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>u?(0,S.jsx)(`span`,{className:`min-w-0 flex-1 ${t?`text-stone-400`:``}`,children:(0,S.jsx)(i,{text:u.label,className:`block truncate`})}):(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-stone-400`,children:r})})}export{g as a,h as i,C as n,v as o,y as r,b as s,w as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.v4kQH163.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as u,i as d,r as f,t as te}from"./ExcelFieldTags.ytbpKt-Z.js";import{a as ne,c as p,d as re,f as m,g as ie,h as ae,i as oe,l as se,m as ce,n as le,p as h,r as ue,s as de,t as fe,u as pe}from"./project-docs.DAw9bzgk.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.BoerpmsB.js";import{t as g}from"./NamePromptDialog.CS1pTTVl.js";var _=e(t(),1),v=o(),ge=5;async function _e(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await m(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return u(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await h(`templates`,e.path);return f(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await h(`templates`,e.path);return d(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,v.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,v.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,v.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,v.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M3 6h18`}),(0,v.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,v.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,v.jsx)(`path`,{d:`M10 11v6`}),(0,v.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,v.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,v.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function ve(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,_.useState)(()=>r(`templates`)),[o,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(null),[m,h]=(0,_.useState)([]),[C,ye]=(0,_.useState)(0),[w,T]=(0,_.useState)(`.`),[E,D]=(0,_.useState)([]),[be,xe]=(0,_.useState)({}),[Se,O]=(0,_.useState)({}),[k,Ce]=(0,_.useState)(!0),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1),[we,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(null),[Te,z]=(0,_.useState)(1),[B,Ee]=c(ge),[De,V]=(0,_.useState)(null),H=(0,_.useRef)(null),{cls:Oe,play:U}=he(),W=(0,_.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await _e(e);n.length&&(t[e.path]=n)})),xe(t)},[]),G=(0,_.useCallback)(async()=>{let e=await oe(`templates`);h(e.tree),ye(e.totalFiles)},[]),K=(0,_.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([p(`templates`,e),G()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await W(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,W,G]);(0,_.useEffect)(()=>{let e=i(e=>t(!!e.templates));return n().then(()=>{t(r(`templates`)),u(!0)}),e},[]),(0,_.useEffect)(()=>{o&&e&&(async()=>{let e=await ue(`templates`);if(f(e),e)try{let[e]=await Promise.all([p(`templates`,`.`),G()]);D(e.entries),T(e.path),await W(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,W,G]);function ke(){Ce(e=>!e),O({})}async function q(e){U(),T(e),z(1),V(null),j(null);try{let t=await p(`templates`,e);D(t.entries),await W(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Ae(e){P(!1),N(!0),j(null);try{await se(`templates`,w,e),await K(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function je(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await K(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),H.current&&(H.current.value=``)}}}async function Me(e){if(e.type===`file`){N(!0),j(null);try{await pe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function Ne(e){let t=ne(m,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Pe(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await le(`templates`,e.path);let t=de(w,e.path)?re(e.path):w;await K(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Fe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await ae(`templates`,t.path,e);await K(ce(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Ie=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,v.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(`templates`)});if(d===null)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!d)return(0,v.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:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/B)),$=Math.min(Te,Q),Le=X.slice(($-1)*B,$*B);function Re(e){U(),Ee(e),z(1)}return(0,v.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,v.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),ke()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:m.map(e=>(0,v.jsx)(S,{node:e,depth:0,activePath:w,expanded:Se,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,v.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,v.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,v.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,v.jsx)(`input`,{ref:H,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void je(e.target.files)}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>H.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,v.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,v.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,v.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ne({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,v.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,v.jsx)(`ul`,{className:`${Oe}space-y-1`,children:Le.map(e=>{let t=be[e.path]??[],n=De===e.path;return(0,v.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>V(e.path),onDoubleClick:()=>void Me(e),children:[(0,v.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,v.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:ve(e.size)}),t.length>0?(0,v.jsx)(te,{fields:t}):null]}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded shrink-0 mt-0.5`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,v.jsx)(ee,{page:$,totalPages:Q,pageSize:B,busy:M,onPage:e=>{U(),z(e)},onPageSize:Re}):null]}),(0,v.jsx)(g,{open:we,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Ae(e)}),(0,v.jsx)(g,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Fe(e)}),(0,v.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Ie,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Pe()})]})}export{C as default};
@@ -1 +0,0 @@
1
- var e=`0.1.19`;export{e as t};
@@ -1,3 +0,0 @@
1
- import{t as e}from"./export.joBT53eb.js";var t={no:`用例编号`,title:`用例标题`,precondition:`前置条件`,steps:`测试步骤`,expected:`预期结果`,priority:`优先级`,type:`用例类型`,module:`所属模块`,requirement:`需求编号`},n={no:[`用例编号`,`测试用例编号`,`案例编号`,`用例号`,`用例id`,`编号`,`no`,`caseid`,`tc编号`],title:[`用例标题`,`用例名称`,`测试用例标题`,`测试分项目`,`测试项目`,`测试点`,`检查点`,`测试内容`,`用例描述`,`用例说明`,`标题`,`名称`,`摘要`,`title`,`casename`],precondition:[`前置条件`,`预置条件`,`前提条件`,`准备条件`,`初始条件`,`前置`,`precondition`],steps:[`测试步骤`,`操作步骤`,`执行步骤`,`用例步骤`,`测试过程`,`操作过程`,`步骤`,`steps`,`step`],expected:[`预期结果`,`期望结果`,`预期内容`,`期望内容标准`,`预期效果`,`期望结果标准`,`验收标准`,`检查结果`,`预期`,`expected`],priority:[`优先级`,`优先级别`,`重要级别`,`重要程度`,`级别`,`priority`],type:[`用例类型`,`测试类型`,`用例种类`,`类型`,`类别`,`type`],module:[`所属模块`,`测试模块`,`功能模块`,`所属功能`,`所属子系统`,`模块`,`测试项目`,`module`],requirement:[`需求编号`,`关联需求`,`需求id`,`需求`,`requirement`]};function r(e){return String(e??``).replace(/[((][^))]*[))]/g,``).replace(/[\s**・·::]/g,``).toLowerCase().trim()}function i(e){let t=e.map(e=>({raw:String(e??``),norm:r(e)})).filter(e=>e.norm&&e.raw),i={},a=new Set,o=Object.keys(n);for(let e of o)for(let o of n[e].map(r)){let n=t.find(e=>!a.has(e.raw)&&e.norm===o);if(n){i[e]=n.raw,a.add(n.raw);break}}for(let e of o)if(!i[e])for(let o of n[e].map(r)){if(o.length<3)continue;let n=t.find(e=>!a.has(e.raw)&&Math.abs(e.norm.length-o.length)<=2&&(e.norm.startsWith(o)||o.startsWith(e.norm)));if(n){i[e]=n.raw,a.add(n.raw);break}}return i}function a(e){let t=[];for(let n of e)for(let e of Object.keys(n))t.includes(e)||t.push(e);return t}function o(e){if(!e.length)return[...e];let n=i(a(e));return e.map(e=>{let r={...e};for(let e of Object.keys(t)){let i=n[e];i&&(String(r[t[e]]??``).trim()||(r[t[e]]=r[i]??``))}return r})}function s(e){let n=[];for(let r of Object.keys(t)){let i=e[r];if(!i)continue;let a=t[r];n.push(i===a?a:`${a}(表头:${i})`)}return n.join(` / `)}var c=`/__tb_casereview`,l=`/__tb_caseblindspot`,u=`用例质量评审提示词.md`,d=`场景遗漏补全提示词.md`,f=[`coverage`,`steps`,`expected`,`data`,`convention`],p={coverage:{label:`需求覆盖`,weight:25,hint:`对应需求点是否明确、主流程与关键分支是否走到`,tone:`blue`},steps:{label:`步骤可执行`,weight:25,hint:`一步一个动作、有编号、照着能点`,tone:`purple`},expected:{label:`预期可判定`,weight:20,hint:`状态 / 文案 / 数值写清楚,第三方能判对错`,tone:`green`},data:{label:`数据与边界`,weight:15,hint:`前置数据与角色齐备,覆盖空值 / 上下限 / 重复`,tone:`amber`},convention:{label:`规范完整`,weight:15,hint:`编号、标题、优先级、类型与模板一致`,tone:`gray`}},m=[`usable`,`revise`,`invalid`],h={usable:{label:`可用`,tone:`green`,hint:`照着能执行,预期能判定`,badge:`bg-emerald-50 text-emerald-700 border-emerald-200`},revise:{label:`待修改`,tone:`amber`,hint:`能看懂但执行会卡住或结论扯皮`,badge:`bg-amber-50 text-amber-800 border-amber-200`},invalid:{label:`错误无效`,tone:`red`,hint:`存在硬伤,不能用`,badge:`bg-red-50 text-red-700 border-red-200`}},g=[`nonfunctional`,`security`,`compatibility`,`business`],_={nonfunctional:{label:`非功能`,hint:`响应时间、并发、大数量、断网与重试`,tone:`purple`,mark:`非功能`},security:{label:`安全边界与容错`,hint:`越权、注入、重复提交、竞态与篡改`,tone:`amber`,mark:`安全`},compatibility:{label:`兼容性`,hint:`分辨率、浏览器 / 端、深浅色、时区与格式`,tone:`blue`,mark:`兼容`},business:{label:`隐藏业务规则`,hint:`金额精度、状态互斥、唯一性、跨模块联动`,tone:`green`,mark:`业务`}},v={high:{label:`高`,tone:`red`},medium:{label:`中`,tone:`amber`},low:{label:`低`,tone:`gray`}},y={usable:85,revise:60},b=/^(正常|正确|成功|符合预期|无异常|没问题|ok|okay|通过|显示正常)的?$/i,x=/(提示|跳转|弹窗|状态|变为|变成|显示|返回|报错|错误码|http\s*\d|\d+%|金额|数量|\d+\s*(ms|s|秒|条|元|位|个|行|次))|「[^」]+」|"[^"]+"/i,S=/^(验证|测试|检查)[^,。]{0,4}(功能|流程|是否正确)?$/;function C(e){let t=String(e??``).replace(/<br\s*\/?>/gi,`
2
- `).split(/\r?\n/).map(e=>e.trim()),n=[];for(let e of t){if(!e)continue;let t=e.split(/(?=(?:^|[;;])\s*\d+\s*[、..))])/).map(e=>e.replace(/^[;;\s]+/,``).trim()).filter(Boolean);n.push(...t.length?t:[e])}return n.filter(e=>e.length>0)}function w(e){let t=String(e??``).trim();return!t||b.test(t)?!1:x.test(t)&&t.length>=6}function T(e){let t=`${e.用例类型??``} ${e.用例标题??``} ${e.测试步骤??``}`;return/(边界|异常|失败|为空|超时|越界|并发|重复|非法|错误)/.test(t)}function E(e){let t=e=>String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``);return`${t(e.用例标题??``)}|${t(e.测试步骤??``)}`}function D(e,t=80){let n=String(e??``).replace(/```[\s\S]*?```/g,` `).replace(/[#>*_`]/g,` `).split(/[\n。;;!!??,,、|]+/),r=[];for(let e of n){let n=e.replace(/^[\s\-*\d.、))]+/,``).trim();if(!(n.length<3||n.length>24)&&!r.includes(n)&&(r.push(n),r.length>=t))break}return r}function O(t,n=``){let r=o(t),i=r.length,a=D(n),s=r.map(e=>{let t=String(e.用例编号??``).trim(),n=String(e.用例标题??``).trim(),r=C(e.测试步骤??``),i=String(e.预期结果??``).trim(),o=String(e.前置条件??``).trim(),s=String(e.优先级??``).trim().toUpperCase(),c=String(e.用例类型??``).trim(),l=String(e.所属模块??``).trim(),u=`${n} ${r.join(` `)} ${i}`,d=[];n||d.push(`用例标题为空`),r.length||d.push(`测试步骤为空`),i||d.push(`预期结果为空`),/^(同上|同前|同上一条|略)$/.test(i)&&d.push(`预期结果只有占位文字`);let f={coverage:(()=>{let e=l?60:25;if(a.length){let t=a.some(e=>u.includes(e));e+=t?40:0}else e+=30;return k(e)})(),steps:(()=>{if(!r.length)return 0;let e=r.length>=3?100:r.length===2?80:50;return r.some(e=>S.test(e))&&(e-=25),r.length===1&&r[0].length>80&&(e-=15),k(e)})(),expected:i?b.test(i)?45:w(i)?i.length>=12?100:90:65:0,data:(()=>{let t=o?60:20;return T(e)?t+=40:t+=15,k(t)})(),convention:(()=>{let e=100;return t||(e-=25),(n.length<6||n.length>60)&&(e-=20),[`P0`,`P1`,`P2`,`P3`].includes(s)||(e-=20),c||(e-=20),k(e)})()},p=[];n||p.push({dimension:`convention`,points:15,reason:`用例标题为空,无法从列表里认出这条用例测什么`,suggestion:`补一句「动词 + 对象 + 条件」的标题,例如「未登录用户提交订单时提示先登录」`}),r.length||p.push({dimension:`steps`,points:25,reason:`测试步骤为空,无法执行`,suggestion:`按「一步一个动作」补步骤,从进入路径写到触发动作`}),i?w(i)||p.push({dimension:`expected`,points:8,reason:`预期结果不够可判定:「${i.slice(0,30)}」`,suggestion:`写成具体状态或文案,例如「提示『手机号格式不正确』,输入框标红且不提交」`}):p.push({dimension:`expected`,points:20,reason:`预期结果为空,无法判定是否通过`,suggestion:`补可判定的结果:页面 / 状态 / 文案 / 数值`}),o||p.push({dimension:`data`,points:6,reason:`没有前置条件,执行者不知道该用什么账号 / 数据 / 状态`,suggestion:`补上需要的角色、数据量与初始状态(如「已登录普通用户,购物车有 1 件商品」)`}),T(e)||p.push({dimension:`data`,points:5,reason:`这条用例没有体现边界或异常路径`,suggestion:`确认是否需要补一条空值 / 上下限 / 失败路径的用例`}),t||p.push({dimension:`convention`,points:5,reason:`缺少用例编号,无法在报告或缺陷里互相引用`,suggestion:`按项目规则补编号(如 TC-模块-001)`});let m=A(f);return{no:t,title:n,verdict:d.length?`invalid`:m>=y.usable?`usable`:m>=y.revise?`revise`:`invalid`,score:m,dimensions:f,deductions:p,hard:d.join(`;`)}}),c={usable:0,revise:0,invalid:0};for(let e of s)c[e.verdict]+=1;let l=new Map;for(let e of r){let t=E(e);t!==`|`&&l.set(t,(l.get(t)??0)+1)}let u=[...l.values()].reduce((e,t)=>e+(t>1?t:0),0),d=j(s),f=A(d),p=e.filter(e=>r.some(t=>e in t)),m=M(r,p);return{metrics:[{key:`total`,label:`用例总数`,value:i,text:`${i}`,hint:`本文件里的用例条数`},{key:`fieldComplete`,label:`字段完整率`,value:i?m/i:0,text:N(i?m/i:0),hint:`文件里的 ${p.length} 个字段是否都有内容`},{key:`stepExecutable`,label:`步骤可执行率`,value:i?r.filter(e=>C(e.测试步骤??``).length>=2).length/i:0,text:N(i?r.filter(e=>C(e.测试步骤??``).length>=2).length/i:0),hint:`有编号且至少两步`},{key:`expectedTestable`,label:`预期可判定率`,value:i?r.filter(e=>w(e.预期结果??``)).length/i:0,text:N(i?r.filter(e=>w(e.预期结果??``)).length/i:0),hint:`排除「正常 / 符合预期」这类模糊表述`},{key:`coverage`,label:`需求覆盖率`,value:a.length?Math.min(1,d.coverage/100):-1,text:a.length?N(Math.min(1,d.coverage/100)):`—`,hint:a.length?`与对照需求的关键点做匹配`:`未挂对照需求,不计算`},{key:`duplicate`,label:`重复用例率`,value:i?u/i:0,text:N(i?u/i:0),hint:`标题 + 步骤完全相同`},{key:`priority`,label:`优先级合规率`,value:i?r.filter(e=>[`P0`,`P1`,`P2`,`P3`].includes(String(e.优先级??``).toUpperCase())).length/i:0,text:N(i?r.filter(e=>[`P0`,`P1`,`P2`,`P3`].includes(String(e.优先级??``).toUpperCase())).length/i:0),hint:`优先级为 P0–P3 之一`},{key:`hard`,label:`硬伤用例`,value:s.filter(e=>e.hard).length,text:`${s.filter(e=>e.hard).length}`,hint:`标题 / 步骤 / 预期为空或冲突,直接判无效`}],cases:s,dimensions:d,score:f,counts:c}}function k(e){return Math.min(100,Math.max(0,Math.round(e)))}function A(e){let t=0;for(let n of f)t+=e[n]*(p[n].weight/100);return k(t)}function j(e){let t={};for(let n of f)t[n]=e.length?k(e.reduce((e,t)=>e+(t.dimensions[n]??0),0)/e.length):0;return t}function M(t,n){let r=n.length?n:e;return t.filter(e=>r.every(t=>String(e[t]??``).trim())).length}function N(e){return Number.isFinite(e)?`${Math.round(Math.max(0,Math.min(1,e))*100)}%`:`—`}function P(e,t=12){let n=[],r=new Set;for(let i of e.deductions??[]){let e=String(i?.suggestion||i?.reason||``).trim();if(!e)continue;let a=e.replace(/\s+/g,` `).toLowerCase();if(!r.has(a)&&(r.add(a),n.push(e.length>240?`${e.slice(0,238)}…`:e),n.length>=t))break}return n}function F(e){return f.map(t=>({key:t,label:p[t].label,score:k(e[t]??0),weight:p[t].weight}))}function I(e,t,n){let r=new Map;for(let e of t){let t=String(e.no??``).trim()||String(e.title??``).trim();t&&r.set(t,e)}let i=0,a=e.cases.map(e=>{let t=r.get(e.no)??r.get(e.title);if(!t)return e;i+=1;let n={...e.dimensions};for(let e of f){let r=t.dimensions?.[e];typeof r==`number`&&Number.isFinite(r)&&(n[e]=k(r))}let a=Array.isArray(t.deductions)?t.deductions.filter(e=>e&&e.reason).map(e=>({dimension:f.includes(e.dimension)?e.dimension:`expected`,points:k(Number(e.points)||0),reason:String(e.reason??``).slice(0,1e3),suggestion:String(e.suggestion??``).slice(0,1e3)})):[],o=A(n),s=e.hard||String(t.hard??``).trim()||void 0,c=s?`invalid`:o>=y.usable?`usable`:o>=y.revise?`revise`:`invalid`,l={...e,verdict:c,score:o,dimensions:n,deductions:a.length?a:e.deductions};return s&&(l.hard=s),l}),o={usable:0,revise:0,invalid:0};for(let e of a)o[e.verdict]+=1;let s=j(a);return{at:new Date().toISOString(),score:A(s),counts:o,dimensions:F(s),metrics:e.metrics,cases:a,summary:n.trim(),modeled:!0,modelCovered:i}}function L(e,n){let r=new Map;if(n?.length)for(let e of o(n)){let n=String(e[t.no]??``).trim(),i=String(e[t.title]??``).trim();n&&i&&r.set(n,i)}let i=!1,a=e.cases.map(e=>{let t=e.title||r.get(String(e.no??``).trim())||``,n=e.hard?`invalid`:e.score>=y.usable?`usable`:e.score>=y.revise?`revise`:`invalid`;return t===e.title&&n===e.verdict?e:(i=!0,{...e,title:t,verdict:n})});if(!i)return e;let s={usable:0,revise:0,invalid:0};for(let e of a)s[e.verdict]+=1;return{...e,cases:a,counts:s}}function R(e,t=``){return{at:new Date().toISOString(),score:e.score,counts:e.counts,dimensions:F(e.dimensions),metrics:e.metrics,cases:e.cases,summary:t||`规则判定:可用 ${e.counts.usable} · 待修改 ${e.counts.revise} · 错误无效 ${e.counts.invalid}。未接入模型,语义类问题(与需求冲突、预期与步骤无关)未计入。`,modeled:!1}}function z(e){return g.map(t=>({key:t,items:e.filter(e=>e.category===t)})).filter(e=>e.items.length>0)}function B(e,t,n){let r=[];if(r.push(`# 用例质量评审报告 · ${e}`),r.push(``),t){r.push(`- 评审时间:${t.at}`),r.push(`- 总分:${t.score}`),r.push(`- 三档:可用 ${t.counts.usable} · 待修改 ${t.counts.revise} · 错误无效 ${t.counts.invalid}`),r.push(`- 来源:${t.modeled?`规则 + 模型`:`仅规则`}`),r.push(``),r.push(`## 五维得分`),r.push(``);for(let e of t.dimensions)r.push(`- ${e.label}(权重 ${e.weight}):${e.score}`);r.push(``),r.push(`## 量化指标`),r.push(``);for(let e of t.metrics)r.push(`- ${e.label}:${e.text}`);t.summary&&(r.push(``),r.push(`## 结论`),r.push(``),r.push(t.summary)),r.push(``),r.push(`## 逐条明细`),r.push(``);for(let e of t.cases){r.push(`### ${e.no||`(无编号)`} ${e.title||`(无标题)`} · ${h[e.verdict].label} ${e.score}`),e.hard&&r.push(`- 硬伤:${e.hard}`);for(let t of e.deductions)r.push(`- [${p[t.dimension]?.label??t.dimension} −${t.points}] ${t.reason}`),t.suggestion&&r.push(` - 建议:${t.suggestion}`);r.push(``)}}else r.push(`- 还没有质量评审结果。`),r.push(``);if(n?.items.length){r.push(`## 场景补全`),r.push(``),r.push(`- 探测时间:${n.at}`),n.context.reqTitle&&r.push(`- 对照需求:${n.context.reqTitle}`),r.push(``);for(let e of z(n.items)){let t=_[e.key];r.push(`### ${t.label}(${e.items.length})`),r.push(``);for(let t of e.items)r.push(`- **[${v[t.severity].label}] ${t.title}**${t.added?`(已补全 ${t.caseNo})`:``}`),t.why&&r.push(` - 为什么容易漏:${t.why}`),t.precondition&&r.push(` - 前置条件:${t.precondition}`),t.steps.length&&r.push(` - 步骤:${t.steps.join(` → `)}`),t.expected&&r.push(` - 预期:${t.expected}`);r.push(``)}}return`${r.join(`
3
- `).trimEnd()}\n`}function V(e,t,n){let r=`${e.replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}-用例评审-${new Date().toISOString().slice(0,10)}.md`,i=new Blob([B(e,t,n)],{type:`text/markdown;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);return o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a),r}async function H(e,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 U(e){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}function W(){return U(c)}function G(){return U(l)}async function K(){try{let e=await H(c,`/prompt`);return{file:e.file||`用例质量评审提示词.md`,exists:e.exists===!0,review:e.review??``}}catch(e){return{file:u,exists:!1,review:``,error:e instanceof Error?e.message:String(e)}}}async function q(){try{let e=await H(l,`/prompt`);return{file:e.file||`场景遗漏补全提示词.md`,exists:e.exists===!0,detect:e.detect??``,complete:e.complete??``}}catch(e){return{file:d,exists:!1,detect:``,complete:``,error:e instanceof Error?e.message:String(e)}}}function J(e){return H(c,`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}function Y(e){return H(l,`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}async function X(){return(await H(`/__tb_casereview`,`/summaries`)).files??[]}async function Z(e){let t=await H(c,`/report?path=${encodeURIComponent(e)}`);return{entry:t.entry??null,stale:t.stale===!0}}async function Q(e,t){return(await H(c,`/report`,{method:`PUT`,body:JSON.stringify({path:e,...t})})).entry}export{s as A,R as C,t as D,J as E,o as O,L as S,Y as T,W as _,p as a,z as b,h as c,O as d,P as f,Z as g,q as h,u as i,i as k,m as l,G as m,g as n,f as o,V as p,d as r,v as s,_ as t,y as u,K as v,Q as w,I as x,X as y};
@@ -1,6 +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":`条目未覆盖`,"missing-field":`字段缺失`,"missing-scenario":`场景遗漏`,"missing-dimension":`维度缺失`,"untestable-acceptance":`验收不可测`,conflict:`与原文冲突`,"over-split":`过度拆分`,other:`其它`},o={high:`高`,medium:`中`,low:`低`},s={high:`red`,medium:`amber`,low:`gray`},c=[{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:`补充跨时区时间展示、多语言文案与本地化格式。`}],l=/创建|新增|新建|保存|提交|删除|编辑|修改|更新|上传|导入|导出|发布|审批|撤回|绑定|解绑|发送|支付|下单|配置|启停|启用|停用/;async function u(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 d(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function f(){return(await u(`/list`)).docs??[]}async function p(e){return(await u(`/create`,{method:`POST`,body:JSON.stringify(e)})).doc}async function m(e,t){return(await u(`/`,{method:`PUT`,body:JSON.stringify({id:e,...t})})).doc}async function h(e){await u(`/delete`,{method:`POST`,body:JSON.stringify({id:e})})}async function g(){try{let e=await u(`/prompt`);return{file:e.file||`需求分析提示词.md`,exists:e.exists===!0,decompose:e.decompose??``,audit:e.audit??``,fix:e.fix??``}}catch(e){return{file:t,exists:!1,decompose:``,audit:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function _(e){return await u(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}async function v(e){return(await x(e)).content}async function y(e,t=2e4){try{let n=(await v(e)).trim();return{text:n.slice(0,t),total:n.length,truncated:n.length>t}}catch{return{text:``,total:0,truncated:!1}}}async function b(){return(await u(`/sources`)).files??[]}async function x(e){return u(`/source?path=${encodeURIComponent(e)}`)}var S=/[\s\p{P}\p{S}]+/gu;function C(e){return String(e??``).toLowerCase().replace(S,``)}function w(e){return Array.from(new Set(e.map(e=>String(e??``).trim()).filter(Boolean)))}function T(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function E(e,t=30,n=500){return Array.isArray(e)?e.map(e=>T(e,n)).filter(Boolean).slice(0,t):[]}function D(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 O(e){return D(String(e??``))}function k(e,t,n){return`g_${D(`${e}|${t}|${n}`)}`}function A(e){let t=e&&typeof e==`object`?e:{},n=T(t.priority,4);return{id:T(t.id,20),title:T(t.title,200),role:T(t.role,120),goal:T(t.goal,500),value:T(t.value,500),sourceRefs:E(t.sourceRefs,20,40),priority:n===`P0`||n===`P1`||n===`P2`?n:`P1`,preconditions:E(t.preconditions),mainFlow:(Array.isArray(t.mainFlow)?t.mainFlow:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{actor:T(t.actor,80),action:T(t.action,500),result:T(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(t.name,120)||`替代流程`,trigger:T(t.trigger,500),steps:E(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(t.scenario,500),expected:T(t.expected,500)}}).filter(e=>e.scenario).slice(0,30),postconditions:E(t.postconditions),acceptance:(Array.isArray(t.acceptance)?t.acceptance:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{given:T(t.given,500),when:T(t.when,500),then:T(t.then,500)}}).filter(e=>e.given||e.when||e.then).slice(0,30),dimensions:E(t.dimensions,12,40)}}function j(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 M(e){let t=e.mainFlow?.[0];return`${C(e.title)}|${t?C(`${t.action}${t.result??``}`):``}`}function N(e,t){let n=e.map(j),r=new Map(n.filter(e=>e.id).map(e=>[e.id,e])),i=new Map(n.map(e=>[M(e),e]));for(let e of t){let t=A(e);if(!t.title)continue;let a=t.id&&r.get(t.id)||i.get(M(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=w([...a.sourceRefs,...t.sourceRefs]),a.dimensions=w([...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(M(e),e)}}return n}function P(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 F(e){return e.mainFlow.some(e=>l.test(e.action))}function I(e,t,n,r,i,a){return{id:k(e,t,n),storyId:t,type:e,severity:a,title:n,detail:r,suggestion:i,origin:`rule`,selected:!1}}var L=new Set([`缺少角色`,`缺少目标`,`缺少前置条件`,`缺少主流程`,`没有异常场景`,`写操作缺少异常分支`,`缺少验收标准`,`验收标准缺 then`,`没有关联需求条目`,`只写了主流程`]);function R(e){let t=e.outline??[],n=e.stories??[],r=[],i=new Set(n.flatMap(e=>e.sourceRefs));for(let e of t)i.has(e.id)||r.push(I(`uncovered-outline`,``,`需求条目未覆盖:${e.title}`,`条目 ${e.id}「${e.title}」没有任何用户故事引用。`,`补一条覆盖该条目的用户故事,或在已有故事的 sourceRefs 里加上 ${e.id}。`,`high`));for(let e of n){let t=`${e.id} ${e.title}`;e.role||r.push(I(`missing-field`,e.id,`缺少角色`,`${t} 没有写清谁在用这个功能。`,`补一个来自原文的角色;原文没写就标注「推断」。`,`medium`)),e.goal||r.push(I(`missing-field`,e.id,`缺少目标`,`${t} 没有写用户要达成什么。`,`补一句用户目标(想要什么结果)。`,`medium`)),e.preconditions.length||r.push(I(`missing-field`,e.id,`缺少前置条件`,`${t} 没有前置条件。`,`补进入这条流程前必须成立的状态。`,`low`)),e.mainFlow.length||r.push(I(`missing-field`,e.id,`缺少主流程`,`${t} 没有主流程步骤。`,`按「动作 + 结果」补主流程。`,`high`)),e.sourceRefs.length||r.push(I(`missing-field`,e.id,`没有关联需求条目`,`${t} 的 sourceRefs 为空,覆盖率无法统计。`,`把这条故事挂到对应的需求条目 id 上。`,`low`)),e.exceptions.length?F(e)&&e.exceptions.length<2&&r.push(I(`missing-scenario`,e.id,`写操作缺少异常分支`,`${t} 包含写操作,但只写了 ${e.exceptions.length} 条异常。`,`补重复提交 / 并发修改 / 保存失败时的表现与回滚。`,`medium`)):r.push(I(`missing-scenario`,e.id,`没有异常场景`,`${t} 只写了顺利路径,没有异常分支。`,`至少补 3 条:输入非法、权限不足、依赖失败 / 超时。`,`high`)),!e.altFlows.length&&F(e)&&r.push(I(`missing-scenario`,e.id,`只写了主流程`,`${t} 没有替代流程:分支条件、可跳过步骤、不同入口都没覆盖。`,`按触发条件补至少一条替代路径。`,`low`)),e.acceptance.length?e.acceptance.some(e=>!e.then)&&r.push(I(`untestable-acceptance`,e.id,`验收标准缺 then`,`${t} 有 ${e.acceptance.filter(e=>!e.then).length} 条验收没有写 then。`,`补上「应该看到什么 / 查到什么」,不要停在操作步骤。`,`high`)):r.push(I(`untestable-acceptance`,e.id,`缺少验收标准`,`${t} 没有 Given / When / Then。`,`每条验收写成 Given / When / Then,then 必须可判定。`,`high`))}let a=c.map(e=>{let t=n.filter(t=>{let n=P(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}});for(let e of a){if(e.covered)continue;let t=c.find(t=>t.key===e.key)?.hint??``;r.push(I(`missing-dimension`,``,`维度缺失:${e.label}`,`所有用户故事都没有覆盖「${e.label}」相关场景。`,t,`medium`))}let o=t.filter(e=>i.has(e.id)).length,s={total:t.length,covered:o,rate:t.length?o/t.length:0};return{at:new Date().toISOString(),summary:`规则检查:${n.length} 个故事、${t.length} 条需求条目,覆盖率 ${t.length?Math.round(s.rate*100):0}%,发现 ${r.length} 个问题。`,coverage:s,dimensions:a,gaps:r}}function z(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?L.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):C(a.title)!==C(e.title)&&(n.push({...e}),i.add(e.id)):(n.push({...e}),r.set(t,e),i.add(e.id))}return n}function B(e,t){let n=new Set(e.filter(e=>e.selected).map(e=>e.id));return n.size?t.map(e=>n.has(e.id)?{...e,selected:!0}:e):t}function V(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 H(e,t=12e3){let n=String(e??``).replace(/\r\n/g,`
2
- `).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(`
3
- `).trim();e&&i.push({title:a,text:e}),o=[]};for(let e of n.split(`
4
- `)){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?V(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 U(e,t){return t?`- **${e}**:${t}`:``}function W(e){return e.filter(Boolean).map(e=>`- ${e}`)}function G(e){let t=[];t.push(`### ${e.id} ${e.title}`),t.push(``);let n=[U(`角色`,e.role),U(`目标`,e.goal),U(`价值`,e.value),U(`优先级`,e.priority),U(`来源条目`,e.sourceRefs.join(`、`))].filter(Boolean);if(t.push(...n),n.length&&t.push(``),e.preconditions.length&&(t.push(`**前置条件**`),t.push(...W(e.preconditions)),t.push(``)),e.mainFlow.length&&(t.push(`**主流程**`),e.mainFlow.forEach((e,n)=>{let r=e.actor?`${e.actor}:`:``;t.push(`${n+1}. ${r}${e.action}${e.result?` → ${e.result}`:``}`)}),t.push(``)),e.altFlows.length){t.push(`**替代流程**`);for(let n of e.altFlows)t.push(`- **${n.name}**${n.trigger?`(触发:${n.trigger})`:``}`),n.steps.forEach((e,n)=>t.push(` ${n+1}. ${e}`));t.push(``)}if(e.exceptions.length){t.push(`**异常场景**`);for(let n of e.exceptions)t.push(`- ${n.scenario}${n.expected?` → ${n.expected}`:``}`);t.push(``)}if(e.postconditions.length&&(t.push(`**后置条件**`),t.push(...W(e.postconditions)),t.push(``)),e.acceptance.length){t.push(`**验收标准**`);for(let n of e.acceptance)t.push(`- Given ${n.given||`(未写)`};When ${n.when||`(未写)`};Then ${n.then||`(未写)`}`);t.push(``)}return e.dimensions.length&&(t.push(`**覆盖维度**:${e.dimensions.join(`、`)}`),t.push(``)),t[t.length-1]!==``&&t.push(``),t}function K(e,t){let n=new Set((t??[]).filter(Boolean)),i=n.size?e.stories.filter(e=>n.has(e.id)):e.stories,a=[];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(``),e.outline.forEach((e,t)=>{a.push(`${t+1}. **${e.id}** ${e.title}`)}),a.push(``)),a.push(`## 用户故事`),a.push(``),i.length||(a.push(`- (暂无)`),a.push(``));for(let e of i)a.push(...G(e));return a.join(`
5
- `)}function q(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(`- (暂无)`),e.outline.forEach((e,n)=>{t.push(`${n+1}. **${e.id}** ${e.title}`),e.quote&&t.push(` > ${e.quote.replace(/\n+/g,` `)}`)}),t.push(``),t.push(`## 用户故事`),t.push(``),e.stories.length||t.push(`- (暂无)`);for(let n of e.stories)t.push(...G(n));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(`- **[${o[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(`
6
- `)}function J(e){return`${(e.title||e.sourcePath.split(`/`).pop()||`需求分析`).replace(/\.(md|markdown|txt)$/i,``).replace(/[\\/:*?"<>|]/g,` `).trim()||`需求分析`}-用户故事.md`}export{H as C,m as D,q as E,O as S,_ as T,z as _,t as a,v as b,R as c,J as d,d as f,b as g,f as h,n as i,p as l,k as m,s as n,i as o,g as p,a as r,r as s,o as t,h as u,N as v,K as w,y as x,B as y};
@@ -1,10 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/jszip.min.Bh2Mgo40.js","_astro/react.Blvh0GOs.js"])))=>i.map(i=>d[i]);
2
- import{s as e}from"./react.Blvh0GOs.js";import{y as t}from"./settings.BvxRxdqa.js";import{r as n,s as r,t as i}from"./req-analysis.DGQa1vaH.js";import{t as a}from"./app-version.CdxtY1WM.js";var o=`/__tb_testpoints`,s=`测试点生成提示词.md`,c=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`],l=[`P0`,`P1`,`P2`,`P3`],u={functional:{label:`功能`,hint:`主流程 / 替代流程 / 每个功能点`,tone:`blue`,accent:`bg-[#3370ff]`},boundary:{label:`边界值`,hint:`为空 / 上下限 / 刚好越界`,tone:`purple`,accent:`bg-[#7b5bd6]`},exception:{label:`异常`,hint:`失败路径 / 非法输入 / 并发`,tone:`red`,accent:`bg-[#e5484d]`},business:{label:`业务规则`,hint:`状态流转 / 权限 / 唯一性`,tone:`amber`,accent:`bg-[#d9820b]`},nonfunctional:{label:`非功能`,hint:`性能 / 安全 / 兼容 / 时区`,tone:`green`,accent:`bg-[#2f9e44]`}},d={P0:{label:`P0`,tone:`red`,markerId:`priority-1`},P1:{label:`P1`,tone:`amber`,markerId:`priority-2`},P2:{label:`P2`,tone:`blue`,markerId:`priority-3`},P3:{label:`P3`,tone:`gray`,markerId:`priority-4`}},f=Object.fromEntries(c.map(e=>[e,u[e].label]));async function p(e,t){let n=await fetch(`${o}${e}`,{...t,headers:t?.body===void 0?void 0:{"Content-Type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function m(){try{let e=await p(`/prompt`);return{file:s,exists:e.exists===!0,generate:e.generate??``}}catch(e){return{file:s,exists:!1,generate:``,error:e instanceof Error?e.message:String(e)}}}async function h(e){return p(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}var g={P0:0,P1:1,P2:2,P3:3};function _(e){let t=e?.points??[];return c.map(e=>({key:e,label:u[e].label,hint:u[e].hint,points:t.filter(t=>t.dimension===e).sort((e,t)=>g[e.priority]-g[t.priority]||e.title.localeCompare(t.title,`zh`))}))}function v(e){let t=e?.points??[],n={P0:0,P1:0,P2:0,P3:0};for(let e of t)e.priority in n&&(n[e.priority]+=1);return{total:t.length,byPriority:n,coveredDimensions:c.filter(e=>t.some(t=>t.dimension===e)).length}}function y(e){return[...e].sort((e,t)=>c.indexOf(e.dimension)-c.indexOf(t.dimension)||g[e.priority]-g[t.priority]||e.title.localeCompare(t.title,`zh`))}function b(e){let t=y(e);if(!t.length)return``;let n=[];for(let e of c){let r=t.filter(t=>t.dimension===e);if(r.length){n.push(`#### ${u[e].label}`);for(let e of r)n.push(`- **[${e.priority}]** ${e.title}(${e.id})`),e.storyId&&n.push(` - 来源故事:${e.storyId}`),e.precondition&&n.push(` - 前置:${e.precondition}`),e.steps.length&&n.push(` - 步骤:${e.steps.join(`;`)}`),e.expected&&n.push(` - 预期:${e.expected}`)}}return n.join(`
3
- `)}function x(e){return(e||`需求分析`).replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}function S(e){let t=[];return e.precondition&&t.push(`前置条件:${e.precondition}`),e.steps.length&&(t.push(`步骤:`),e.steps.forEach((e,n)=>t.push(`${n+1}. ${e}`))),e.expected&&t.push(`预期:${e.expected}`),t.join(`
4
- `)}function C(e,t){let n=t.replace(/[^A-Za-z0-9_-]/g,``);return n?`${e}-${n}`:`${e}-${Math.random().toString(36).slice(2,8)}`}function w(e){return{id:C(`tp`,e.id),title:`[${e.priority}] ${e.title}`,labels:[u[e.dimension].label,e.priority],markers:[{markerId:d[e.priority].markerId}],notes:{plain:{content:S(e)}}}}function T(e){let t=e.testPoints?.points??[],n=e.stories.map(e=>e.id),r=new Map(e.stories.map(e=>[e.id,e.title])),i=new Map;for(let e of t){let t=e.storyId||``,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[...n,...[...i.keys()].filter(e=>e&&!n.includes(e)).sort(),``],o=[];for(let e of a){let t=i.get(e);if(!t?.length)continue;let n=e?r.get(e):``;o.push({key:e||`global`,label:e?`${e} ${n??``}`.trim():`全局测试点`,points:[...t].sort((e,t)=>g[e.priority]-g[t.priority]||c.indexOf(e.dimension)-c.indexOf(t.dimension)||e.title.localeCompare(t.title,`zh`))})}return o}function E(e){let t=e.testPoints,n=T(e).map(e=>{let t=c.map(t=>e.points.filter(e=>e.dimension===t).length),n=t.filter(e=>e>0).length;return{id:C(`fn`,e.key),title:`${e.label}(${e.points.length})`,notes:{plain:{content:`测试点 ${e.points.length} 条 · 维度覆盖 ${n}/5\n${c.map((e,n)=>`${u[e].label} ${t[n]}`).join(` · `)}`}},children:{attached:e.points.map(w)}}}),r={id:`root-topic`,title:`测试点 · ${e.title||`未命名分析`}`,structureClass:`org.xmind.ui.logic.right`,notes:{plain:{content:t?.summary?t.summary:`按功能 / 用户故事归组的测试点,叶子标注优先级与所属维度。`}},children:{attached:n}};return[{id:`sheet-1`,class:`sheet`,title:e.title||`测试点`,rootTopic:r}]}async function D(n){let r=E(n),{default:i}=await t(async()=>{let{default:t}=await import(`./jszip.min.Bh2Mgo40.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1])),o=new i;return o.file(`content.json`,JSON.stringify(r)),o.file(`metadata.json`,JSON.stringify({creator:{name:`Lantern Harness`,version:a},activeSheetId:`sheet-1`})),o.file(`manifest.json`,JSON.stringify({"file-entries":{"content.json":{},"metadata.json":{}}})),o.generateAsync({type:`blob`,compression:`DEFLATE`})}async function O(e){let t=new Date().toISOString().slice(0,10),n=`${x(e.title)}-测试点-${t}.xmind`,r=await D(e),i=URL.createObjectURL(r),a=document.createElement(`a`);return a.href=i,a.download=n,a.click(),URL.revokeObjectURL(i),n}function k(e){let t=e.testPoints,n=[];if(n.push(`# 测试点 · ${e.title||`未命名分析`}`),n.push(``),n.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 故事 ${e.stories.length} 条`),n.push(``),!t)return n.push(`- 还没有生成测试点。`),`${n.join(`
5
- `)}\n`;let r=v(t);n.push(`- 生成时间:${t.at}`),n.push(`- 共 ${r.total} 条(P0 ${r.byPriority.P0} / P1 ${r.byPriority.P1} / P2 ${r.byPriority.P2} / P3 ${r.byPriority.P3})`),n.push(`- 维度覆盖:${r.coveredDimensions}/5`),t.summary&&(n.push(``),n.push(t.summary)),n.push(``);let i=T(e);if(!i.length)return n.push(`- 还没有生成测试点。`),`${n.join(`
6
- `).trimEnd()}\n`;for(let e of i){n.push(`## ${e.label}(${e.points.length})`),n.push(``);for(let t of e.points)n.push(`- **[${t.priority}]** ${t.title} · ${u[t.dimension].label}`),t.precondition&&n.push(` - 前置:${t.precondition}`),t.steps.length&&n.push(` - 步骤:${t.steps.join(`;`)}`),t.expected&&n.push(` - 预期:${t.expected}`);n.push(``)}return`${n.join(`
7
- `).trimEnd()}\n`}function A(e){let t=new Date().toISOString().slice(0,10),n=`${x(e.title)}-测试点-${t}.md`,r=new Blob([k(e)],{type:`text/markdown;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);return a.href=i,a.download=n,a.click(),URL.revokeObjectURL(i),n}var j=`/__tb_storyreview`,M=`用户故事审查提示词.md`;async function N(e,t){let n=await fetch(`${j}${e}`,{...t,headers:t?.body===void 0?void 0:{"Content-Type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function P(){try{let e=await N(`/prompt`);return{file:M,exists:e.exists===!0,review:e.review??``,fix:e.fix??``}}catch(e){return{file:M,exists:!1,review:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function F(e){return N(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}var I={high:0,medium:1,low:2};function L(e){let t={scenario:[],dimension:[],other:[]};for(let n of e)n.type===`missing-scenario`?t.scenario.push(n):n.type===`missing-dimension`?t.dimension.push(n):t.other.push(n);let n=e=>[...e].sort((e,t)=>I[e.severity]-I[t.severity]||e.title.localeCompare(t.title,`zh`));return[{key:`scenario`,label:`场景遗漏`,hint:`角色 / 分支 / 失败路径没写到`,gaps:n(t.scenario)},{key:`dimension`,label:`维度缺失`,hint:`六个维度里该覆盖却没提`,gaps:n(t.dimension)},{key:`other`,label:`其它问题`,hint:`验收不可测 / 冲突 / 过度拆分等`,gaps:n(t.other)}].filter(e=>e.gaps.length>0)}function R(e){return{high:e.filter(e=>e.severity===`high`).length,medium:e.filter(e=>e.severity===`medium`).length,low:e.filter(e=>e.severity===`low`).length}}function z(e,t){let a=[];if(a.push(`# 用户故事审查报告 · ${e.title||`未命名分析`}`),a.push(``),a.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 故事 ${e.stories.length} 条`),a.push(``),!t)return a.push(`- 还没有审查结果。`),`${a.join(`
8
- `)}\n`;let o=t.coverage.total?Math.round(t.coverage.rate*100):0;a.push(`## 结论`),a.push(``),a.push(`- 状态:${r[e.status]?.label??e.status}`),a.push(`- 审查时间:${t.at}`),a.push(`- 需求条目覆盖率:${t.coverage.covered}/${t.coverage.total}(${o}%)`),a.push(`- 维度覆盖:${t.dimensions.map(e=>`${e.label}${e.covered?` ✓`:` ✗`}`).join(` · `)||`(无)`}`);let s=R(t.gaps);a.push(`- 缺口:${t.gaps.length} 条(高 ${s.high} / 中 ${s.medium} / 低 ${s.low})`),t.summary&&(a.push(``),a.push(t.summary)),a.push(``);let c=new Map(e.stories.map(e=>[e.id,e.title])),l=L(t.gaps);if(!l.length)return a.push(`## 缺口清单`),a.push(``),a.push(`- 没有发现缺口。`),`${a.join(`
9
- `)}\n`;for(let e of l){a.push(`## ${e.label}(${e.gaps.length})`),a.push(``);for(let t of e.gaps){let e=t.storyId?`${t.storyId}${c.get(t.storyId)?` ${c.get(t.storyId)}`:``}`:`全局`;a.push(`- **[${i[t.severity]}] ${n[t.type]}** · ${e} · ${t.title}`),t.detail&&a.push(` - 原因:${t.detail}`),t.suggestion&&a.push(` - 建议:${t.suggestion}`)}a.push(``)}return`${a.join(`
10
- `).trimEnd()}\n`}function B(e,t){let n=`${(e.title||`需求分析`).replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}-审查报告-${new Date().toISOString().slice(0,10)}.md`,r=new Blob([z(e,t)],{type:`text/markdown;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);return a.href=i,a.download=n,a.click(),URL.revokeObjectURL(i),n}export{h as _,L as a,u as c,s as d,v as f,_ as g,m as h,P as i,d as l,O as m,R as n,F as o,A as p,B as r,f as s,M as t,l as u,b as v};