lantern-harness 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/500.html +3 -3
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.Cd3ccDN-.js → Base.astro_astro_type_script_index_0_lang.4j--gBo-.js} +1 -1
- package/dist/_astro/CaseGenerateApp.18SE0dLJ.js +10 -0
- package/dist/_astro/CasesLibrary.C-T3VrPa.js +24 -0
- package/dist/_astro/ChatApp.BpFXgd8K.js +226 -0
- package/dist/_astro/PluginsPage.DKPA2zw8.js +1 -0
- package/dist/_astro/{PluginsPage.CRBtbpx-.js → PluginsPage.F0oMYJri.js} +2 -2
- package/dist/_astro/PromptsLibrary.BlWPVm1Z.js +1 -0
- package/dist/_astro/ReqAnalysisBoard.CeQbq7Qh.js +39 -0
- package/dist/_astro/{SettingsDialog.FHQTm21D.js → SettingsDialog.BlokCWBn.js} +1 -1
- package/dist/_astro/app-version.CLOjRiPN.js +1 -0
- package/dist/_astro/case-gen-run.BNNfA12U.js +22 -0
- package/dist/_astro/{case-review.DlCarphW.js → case-review.s1w_mD4l.js} +1 -1
- package/dist/_astro/req-analysis.Dbe_gqPz.js +24 -0
- package/dist/_astro/{story-review.BzBFIFt-.js → story-review.CNZnYMvW.js} +2 -2
- package/dist/case-exec/index.html +3 -3
- package/dist/cases/generate/index.html +4 -4
- package/dist/cases/library/index.html +4 -4
- package/dist/dashboard/index.html +3 -3
- package/dist/docs/changelog/index.html +56 -36
- package/dist/docs/install/index.html +3 -3
- package/dist/docs/manual/index.html +13 -5
- package/dist/knowledge/index.html +3 -3
- package/dist/plugins/index.html +4 -4
- package/dist/pm/bugs/index.html +3 -3
- package/dist/pm/iterations/index.html +3 -3
- package/dist/pm/projects/detail/index.html +3 -3
- package/dist/pm/projects/index.html +3 -3
- package/dist/pm/requirements/index.html +3 -3
- package/dist/prompts/index.html +4 -4
- package/dist/reports/index.html +3 -3
- package/dist/requirement-analysis/index.html +4 -4
- package/dist/requirements/index.html +3 -3
- package/dist/tasks/index.html +3 -3
- package/dist/templates/index.html +3 -3
- package/dist/test-automation/index.html +3 -3
- package/dist/test-stats/index.html +3 -3
- package/dist/todos/index.html +3 -3
- package/dist/workbench/index.html +4 -4
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +10 -2
- package/lh-plugins/lh-case-review.mjs +159 -0
- package/lh-plugins/lh-req-analysis.mjs +66 -6
- package/package.json +1 -1
- package/dist/_astro/CaseGenerateApp.CHQnkY5R.js +0 -10
- package/dist/_astro/CasesLibrary.B7wyxL0p.js +0 -21
- package/dist/_astro/ChatApp.OW9jzZNM.js +0 -226
- package/dist/_astro/PluginsPage.Bof7KzU6.js +0 -1
- package/dist/_astro/PromptsLibrary.CK6nLgdD.js +0 -1
- package/dist/_astro/ReqAnalysisBoard.D94a1NoW.js +0 -39
- package/dist/_astro/app-version.C6rzHe1M.js +0 -1
- package/dist/_astro/case-gen-run.CKShZ1Ha.js +0 -22
- package/dist/_astro/req-analysis.CIZ_cIJQ.js +0 -23
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PluginsPage.CRBtbpx-.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.Bg6v8zQQ.js";import{a as i,i as a,n as o,o as ee,s as te}from"./plugins.SqANn3ZB.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as ne}from"./ConfirmDialog.D5qXeML0.js";import{showToast as c}from"./Toast.BO2NFckG.js";import{i as re}from"./case-types.CJ5PHz59.js";import{$ as ie,a as ae}from"./req-analysis.CIZ_cIJQ.js";import{c as l,d as u,h as oe,n as d,p as se,r as ce,u as le,v as ue}from"./project-docs.DAw9bzgk.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{a as f,c as p,d as fe,i as m,l as h,o as g,s as _,u as v}from"./prompts-meta.C_MeYq8G.js";import{i as pe,n as me,r as he,t as ge}from"./DocsFileBrowser.DnxVsmed.js";import{d as _e,t as ve}from"./open-docs-in-session.DQ2_5fkC.js";import{F as ye,P as be,i as xe,r as Se}from"./case-review.DlCarphW.js";import{t as y}from"./NamePromptDialog.Csfnh5eM.js";import{m as b}from"./PmShared.ChKKU3Ww.js";import{r as Ce}from"./report-prompt.CAfZ6RIo.js";import{g as we,s as Te}from"./ui-auto.BmC9JJ_X.js";import{f as Ee,s as De,t as Oe,y as ke}from"./story-review.BzBFIFt-.js";var x=e(t(),1),S=`tw.prompts.mounted.v1`;function Ae(){try{let e=sessionStorage.getItem(r(S));if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t))typeof e==`string`&&typeof r==`string`&&(n[e]=r);return n}catch{return{}}}function je(e){try{sessionStorage.setItem(r(S),JSON.stringify(e))}catch{}}var C=s(),Me=10;async function w(e=`.`){let{entries:t}=await l(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await w(e.path));return n}function Ne({path:e,enabled:t,mounted:n}){let r=v(e,n);if(!r)return(0,C.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,C.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,ee=g(e,n);return(0,C.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,C.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),ee&&a?(0,C.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function T(){let e=he(`prompts`),[t,r]=(0,x.useState)(!1),[s,l]=(0,x.useState)(!0),[g,S]=(0,x.useState)(e?!0:null),[T,Pe]=(0,x.useState)(()=>e??[]),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)({}),[M,N]=(0,x.useState)(null),[P,F]=(0,x.useState)(()=>i()),[I,Fe]=(0,x.useState)(()=>Ae()),[L,R]=(0,x.useState)(null),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)(``),U=me(T,Me,`prompts`),W=(0,x.useRef)(!1),G=(0,x.useRef)(!1),K=(0,x.useRef)(!1),q=(0,x.useRef)(!1),J=(0,x.useRef)(!1),Y=(0,x.useCallback)(async()=>{D(null);try{let e=await w(`.`);Pe(e),pe(`prompts`,e)}catch(e){D(e instanceof Error?e.message:String(e))}},[]);(0,x.useEffect)(()=>{g&&P.reqAnalysis===!0&&!W.current&&(T.some(e=>e.name===`需求分析提示词.md`)||(W.current=!0,ie(!0).then(()=>Y()).catch(()=>void 0)))},[g,P.reqAnalysis,T,Y]),(0,x.useEffect)(()=>{g&&P.storyReview===!0&&!G.current&&(T.some(e=>e.name===`用户故事审查提示词.md`)||(G.current=!0,De(!0).then(()=>Y()).catch(()=>void 0)))},[g,P.storyReview,T,Y]),(0,x.useEffect)(()=>{g&&P.testPoints===!0&&!K.current&&(T.some(e=>e.name===`测试点生成提示词.md`)||(K.current=!0,ke(!0).then(()=>Y()).catch(()=>void 0)))},[g,P.testPoints,T,Y]),(0,x.useEffect)(()=>{g&&P.caseReview===!0&&!q.current&&(T.some(e=>e.name===`用例质量评审提示词.md`)||(q.current=!0,ye(!0).then(()=>Y()).catch(()=>void 0)))},[g,P.caseReview,T,Y]),(0,x.useEffect)(()=>{g&&P.caseBlindspot===!0&&!J.current&&(T.some(e=>e.name===`场景遗漏补全提示词.md`)||(J.current=!0,be(!0).then(()=>Y()).catch(()=>void 0)))},[g,P.caseBlindspot,T,Y]),(0,x.useEffect)(()=>{let e=ee(e=>{l(!!e.prompts),F(e)});return n().then(()=>{l(a(`prompts`)),F(i()),r(!0)}),e},[]),(0,x.useEffect)(()=>{t&&s&&(async()=>{await ce(`prompts`)?(await _e().catch(()=>null),await Y(),S(!0)):S(!1)})()},[t,s,Y]);let X=(0,x.useCallback)(async()=>{let e=await Te(),t=a(`reports`),n=t?await Ce().catch(()=>null):null;Fe(r=>{let i={};if(e)for(let t of e)i[p(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[p(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(P.reqAnalysis&&(i[p(ae)]=`reqAnalysis`),P.storyReview&&(i[p(Oe)]=`storyReview`),P.testPoints&&(i[p(Ee)]=`testPoints`),P.caseReview&&(i[p(xe)]=`caseReview`),P.caseBlindspot&&(i[p(Se)]=`caseBlindspot`),P.caseGen)for(let e of re()){let t=(e.promptPath??``).trim();t&&(i[p(t)]=`caseGen`)}return je(i),i})},[P.reqAnalysis,P.storyReview,P.testPoints,P.caseReview,P.caseBlindspot,P.caseGen]);(0,x.useEffect)(()=>{if(!t||!s)return;X();let e=()=>{document.visibilityState===`visible`&&X()};document.addEventListener(`visibilitychange`,e);let n=we(()=>void X());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,s,P.uiAuto,P.reports,P.reqAnalysis,P.storyReview,P.testPoints,P.caseReview,P.caseBlindspot,P.caseGen,X]);let Z=(0,x.useMemo)(()=>Object.keys(A).filter(e=>A[e]),[A]),Q=(0,x.useCallback)(e=>{let t=v(e,I);return!t||t===`system`||fe(e)?``:P[t]===!0?t:``},[I,P]);async function Ie(e){k(!0),D(null);try{await le(`prompts`,e.path)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(!1)}}async function Le(e){k(!0),D(null);try{await ve(`prompts`,e)}catch(e){D(e instanceof Error?e.message:String(e)),k(!1)}}function Re(e){if(_(e.path)){D(`默认提示词不可删除`);return}if(m(e.path,P)){D(h(e.path,P));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;D(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else N({kind:`one`,entry:e})}function ze(e){if(_(e.path)){D(`默认提示词不可改名`);return}if(m(e.path,P)){D(h(e.path,P));return}let t=Q(e.path);if(t){let e=o(t)?.name??t;D(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else R(e),H(``)}function Be(e){B(e),H(``)}async function Ve(){let e=M;if(e){N(null),k(!0),D(null);try{if(e.kind===`one`)await d(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)_(n)||m(n,P)||Q(n)?t+=1:await d(`prompts`,n);t&&D(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),j({})}await Y(),c(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);D(t),c(`删除失败:${t}`,`error`)}finally{k(!1)}}}function He(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:D(te(`promptGen`))}let $=(0,x.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=T.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[T]);async function Ue(e){let t=L;if(!t)return;let n=e.trim();if(!n||n===t.name){R(null),H(``);return}let r=$(u(t.path),n,t.path);if(r)H(`已存在同名文件「${r}」,换个名字再试`);else{k(!0),H(``);try{await oe(`prompts`,t.path,n),R(null),await Y(),c(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);H(t),c(`重命名失败:${t}`,`error`)}finally{k(!1)}}}async function We(e){let t=z;if(!t)return;let n=e.trim();if(!n)return;let r=$(u(t.path),n);if(r)H(`已存在同名文件「${r}」,换个名字再试`);else{k(!0),H(``);try{let{content:e}=await se(`prompts`,t.path);await ue(`prompts`,u(t.path)===`.`?n:`${u(t.path)}/${n}`,e),B(null),await Y(),c(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);H(t),c(`复制失败:${t}`,`error`)}finally{k(!1)}}}let Ge=M?.kind===`one`?`删除「${M.entry.name}」?将从 ${de(`prompts`)} 中移除。`:M?.kind===`batch`?`确认删除已选中的 ${M.paths.length} 个提示词?此操作不可恢复。`:``;return t?s?g===null?(0,C.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,C.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,C.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):g?(0,C.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,C.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,C.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[U.query.trim()?(0,C.jsxs)(C.Fragment,{children:[`匹配 `,(0,C.jsx)(`span`,{className:`font-medium text-stone-800`,children:U.filtered.length}),` 个`,(0,C.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,T.length]})]}):(0,C.jsxs)(C.Fragment,{children:[`共 `,(0,C.jsx)(`span`,{className:`font-medium text-stone-800`,children:T.length}),` 个提示词`]}),Z.length>0?(0,C.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Z.length]}):null]}),(0,C.jsx)(`button`,{type:`button`,disabled:O||Z.length===0,onClick:()=>N({kind:`batch`,paths:Z}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,C.jsx)(`button`,{type:`button`,disabled:O,onClick:He,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:`生成提示词`})]}),E?(0,C.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:E}):null,(0,C.jsx)(ge,{resizeKey:`docs:prompts:cols:v1`,files:T,filtered:U.filtered,pageFiles:U.pageFiles,query:U.query,onQuery:U.setQuery,sortBy:U.sortBy,onSortBy:U.setSortBy,page:U.page,totalPages:U.totalPages,pageSize:U.pageSize,onPage:U.setPage,onPageSize:U.setPageSize,busy:O,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!f(e.path,P)&&!Q(e.path),selected:A,onToggleRow:e=>j(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>j(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Ie(e),extraColumn:{header:`关联插件`,render:e=>(0,C.jsx)(Ne,{path:e.path,enabled:P,mounted:I})},renderNameAction:e=>(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`button`,{type:`button`,disabled:O,"aria-label":`重命名 ${e.name}`,onClick:()=>ze(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,C.jsx)(b,{name:`pencil`,size:12})}),(0,C.jsx)(`button`,{type:`button`,disabled:O,"aria-label":`复制 ${e.name}`,onClick:()=>Be(e),className:`inline-flex h-6 w-6 items-center justify-center rounded text-stone-400 transition-colors hover:bg-[#e8f0fe] hover:text-[#4176e6] disabled:opacity-40`,children:(0,C.jsx)(b,{name:`copy`,size:12})})]}),renderActions:e=>{let t=f(e.path,P)||!!Q(e.path);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void Le(e),className:`inline-flex h-6 items-center whitespace-nowrap rounded bg-[#4176e6] px-2 text-xs text-white hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,C.jsx)(`button`,{type:`button`,disabled:O||t,"aria-label":`删除 ${e.name}`,onClick:()=>Re(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,C.jsx)(b,{name:`trash`,size:12})})]})}}),(0,C.jsx)(y,{open:L!=null,title:`重命名提示词`,label:`文件名称`,initialValue:L?.name??``,lockExtension:!0,confirmLabel:`保存`,error:V,onClose:()=>{R(null),H(``)},onConfirm:e=>void Ue(e)}),(0,C.jsx)(y,{open:z!=null,title:`复制提示词`,label:`新文件名称`,initialValue:z?z.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:V,onClose:()=>{B(null),H(``)},onConfirm:e=>void We(e)}),(0,C.jsx)(ne,{open:M!=null,title:M?.kind===`batch`?`批量删除`:`删除提示词`,message:Ge,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>N(null),onConfirm:()=>void Ve()})]}):(0,C.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:`提示词管理需要本地文档服务,当前未就绪。`}):(0,C.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:te(`prompts`)}):(0,C.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,C.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,C.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{T as default};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{s as r}from"./plugins.SqANn3ZB.js";import{a as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./view-prefs.SdItxolG.js";import{i as d,n as f,r as p,t as m}from"./dialog.DZHZCe_T.js";import{t as h}from"./jsx-runtime.DUg_B_vD.js";import{t as g}from"./ConfirmDialog.D5qXeML0.js";import{t as _}from"./OverflowHint.pvo2Xc8R.js";import{t as ee}from"./SelectDropdown.apWlFGbA.js";import{showToast as v}from"./Toast.BO2NFckG.js";import{$ as te,A as ne,B as re,C as y,D as b,E as ie,F as ae,G as oe,H as se,I as ce,J as le,K as ue,L as de,M as fe,N as pe,O as me,P as he,Q as ge,R as _e,S as ve,T as x,U as ye,V as be,W as S,X as xe,Y as Se,_ as Ce,a as we,b as Te,c as Ee,d as De,et as Oe,f as ke,g as Ae,i as je,j as Me,k as Ne,l as Pe,m as Fe,n as C,nt as Ie,o as Le,p as Re,q as ze,r as w,rt as T,s as Be,t as Ve,tt as He,u as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./req-analysis.CIZ_cIJQ.js";import{o as Ye}from"./project-docs.DAw9bzgk.js";import{s as Xe}from"./llm.DyweO-KK.js";import{m as Ze,p as Qe,u as $e}from"./settings.Cu00if4D.js";import{t as et}from"./MultiSelectDropdown.BHxW9XLR.js";import{S as E,_ as tt,g as nt,k as rt,m as D,u as it}from"./PmShared.ChKKU3Ww.js";import{_ as at,a as ot,c as st,d as ct,f as lt,g as ut,h as dt,i as ft,l as pt,m as mt,n as ht,o as gt,p as O,r as _t,s as vt,u as yt,y as bt}from"./story-review.BzBFIFt-.js";import{t as xt}from"./hydrate-cache.B7--LFB_.js";var k=e(t(),1),St=`可用工具(只调用这些,不要自己编工具名):
|
|
2
|
-
- req_set_outline:在已播种的文档条目下提交查询/修改子点(带 parentId、kind),返回 id 供 sourceRefs 引用。不要另造文档里没有的条目标题。同一 parentId 下按能力点拆多条子点(可多个 query、多个 mutate),勿把多个能力点合并成一条。
|
|
3
|
-
- req_insert_outline_after:在指定已有子点下方插入新的查询/修改子点(用户补充需求内容时用);afterId 固定为消息里给出的锚点;插入后同父级子点 id 按序号顺延。
|
|
4
|
-
- req_update_outline_point:按 id 更新已有查询/修改子点的标题 / 类型 / 原文(id 不变);用户变更当前点内容时用。
|
|
5
|
-
- req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
|
|
6
|
-
- req_save_check:提交待确认缺口(原文不清、需业务拍板等),不要报故事字段缺失类质检。
|
|
7
|
-
- req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3);补充点标 supplemental。
|
|
8
|
-
|
|
9
|
-
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`;async function Ct(e,t,n,r=new Set){let i=await e.saveOutline(t);if(!n.size&&!r.size)return i;let a=e.getDoc();if(!a)return i;let o=be({stories:a.stories,check:a.check,ignoredGaps:a.ignoredGaps},n,r);return JSON.stringify(o.stories)!==JSON.stringify(a.stories)&&await e.saveStories(o.stories),o.check&&JSON.stringify(o.check)!==JSON.stringify(a.check)&&await e.saveCheck(o.check),JSON.stringify(o.ignoredGaps??[])!==JSON.stringify(a.ignoredGaps??[])&&await e.saveIgnoredGaps(o.ignoredGaps??[]),e.getDoc()?.outline??i}var wt=[`pending-confirm`,`uncovered-outline`,`conflict`,`other`,`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`over-split`];function Tt(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function A(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function Et(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function Dt(e){let t=A(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function j(e){let t=A(e,40);return wt.includes(t)?t:`other`}var Ot=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function M(e){let t=A(e,40);if(Ot.includes(t))return t;let n=A(e,20);return Ot.find(e=>st[e]===n)??`functional`}function N(e){let t=A(e,4).toUpperCase();return ct.includes(t)?t:`P1`}function kt(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=A(n.title,200);if(!r)return null;let i=A(n.storyId,20),a={id:``,storyId:t.has(i)?i:``,dimension:M(n.dimension),priority:N(n.priority),title:r,precondition:A(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>A(e,500)).filter(Boolean).slice(0,20):[],expected:A(n.expected,1e3)};return n.supplemental===!0&&(a.supplemental=!0),a}var At=[{type:`function`,function:{name:`req_set_outline`,description:`在已播种的文档需求条目下提交查询/修改子点。一个可独立验收的能力点交一条;同一 parentId 可有多条 query/mutate,勿合并。title 写清该能力(可贴近父级标题加短后缀);必须带 parentId 与 kind(query|mutate)。禁止另造文档没有的条目。每条 quote/body 只支撑本能力点,勿把连续多条编号或整段粘贴塞进同一子点。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`贴近文档的条目标题,可带查询/修改后缀`},quote:{type:`string`,description:`从父级原文摘出支撑本子点的相关段落,尽量 verbatim;本能力点对应的编号项/字段即可,勿把后续其它编号项一并塞入;可至约 2000 字`},body:{type:`string`,description:`可选;与 quote 同段的更完整原文切片(仍限本能力点),可至约 4000 字`},kind:{type:`string`,enum:[`query`,`mutate`],description:`query=查询类能力;mutate=修改/写入类能力`},parentId:{type:`string`,description:`所属文档条目 id(消息里「需求条目」已列出的父级 id)`}},required:[`title`,`kind`,`parentId`,`quote`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_insert_outline_after`,description:`在指定查询/修改子点下方插入新子点(用户补充的需求内容拆出来的能力点)。afterId 必须是消息里给出的锚点子点;新点继承其 parentId;写入后同父级子点 id 按序号顺延为 parentId-1..n。每条 quote/body 只支撑本能力点,勿把连续多条编号或用户整段粘贴塞进同一子点。`,parameters:{type:`object`,properties:{afterId:{type:`string`,description:`锚点子点 id;新点插在它下方`},items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`能力点标题`},quote:{type:`string`,description:`支撑本子点的需求原文摘录,尽量 verbatim;只含本能力点,勿塞入后续编号项`},body:{type:`string`,description:`可选;更完整原文切片(仍限本能力点)`},kind:{type:`string`,enum:[`query`,`mutate`],description:`query=查询类;mutate=修改/写入类`}},required:[`title`,`kind`,`quote`]}}},required:[`afterId`,`items`]}}},{type:`function`,function:{name:`req_update_outline_point`,description:`按 id 更新已有查询/修改子点的标题、类型与原文摘录(id 与 parentId 不变)。用户变更当前需求点内容时用;若还要拆出额外能力点,另调 req_insert_outline_after。`,parameters:{type:`object`,properties:{id:{type:`string`,description:`要更新的子点 id(消息里给出的锚点)`},title:{type:`string`,description:`能力点标题`},quote:{type:`string`,description:`支撑本子点的需求原文摘录,尽量 verbatim`},body:{type:`string`,description:`可选;更完整原文切片`},kind:{type:`string`,enum:[`query`,`mutate`],description:`query=查询类;mutate=修改/写入类`}},required:[`id`,`quote`]}}},{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`},minItems:1,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`,`sourceRefs`,`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:[`pending-confirm`,`uncovered-outline`,`conflict`,`other`],description:`待确认类`},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`需要确认什么 + 原文依据`},suggestion:{type:`string`,description:`建议如何确认或补故事`},outlineId:{type:`string`,description:`相关需求点 id,可选`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:五维全覆盖,每条标 P0–P3。正式点优先;扩展场景标 supplemental=true。一次提交全部。`,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:Ot,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:ct},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有数值写具体数值`},supplemental:{type:`boolean`,description:`true=补充扩展点;落到用例备注「补充:」`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function jt(e,t,n){let r=Tt(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,kind:n,parentId:r})=>({id:e,title:t,kind:n??null,parentId:r??null})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.filter(e=>!e.parentId&&!e.kind).map(e=>e.id)),o=(e,t,n)=>`${n}|${t}|${Et(e)}`,s=new Set(t.map(e=>o(e.title,e.kind??``,e.parentId??``))),c=new Set(t.map(e=>e.id)),l=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=A(e.title,200)||A(e.quote,200),i=A(e.kind,16),u=i===`query`||i===`mutate`?i:void 0,d=A(e.parentId,32);if(!r||!u||!d||!a.has(d))continue;let f=o(r,u,d);if(s.has(f))continue;s.add(f);let p=`RO-${n.batch+1}-${l.length+1}`,m=p,h=1;for(;c.has(m);)m=`${p}-${h++}`;c.add(m);let g=A(e.quote,2e3),_=A(e.body,4e3),ee={id:m,title:r,quote:g,kind:u,parentId:d};_&&(ee.body=_),l.push(ee)}let u=[...t,...l],d=pe(u),f=await Ct(n,d.outline,d.idMap);return JSON.stringify({ok:!0,added:l.length,total:f.length,items:f.map(({id:e,title:t,kind:n,parentId:r})=>({id:e,title:t,kind:n??null,parentId:r??null})),note:l.length>0?`子点已保存并按父级原文序顺延编号(parentId-n)。接下来用 req_set_stories 提交故事,sourceRefs 只能引用返回的 id(优先挂查询/修改子点)。`:`这些子点已存在或 parentId/kind 无效,没有写入;请对照消息里的文档条目父级 id。`})}if(e===`req_insert_outline_after`){let e=A(r.afterId,64),t=Array.isArray(r.items)?r.items:[];if(!e)return JSON.stringify({ok:!1,error:`缺少 afterId`});let a=[];for(let e of t){let t=e&&typeof e==`object`?e:{},n=A(t.title,200)||A(t.quote,200),r=A(t.kind,16),i=r===`query`||r===`mutate`?r:``,o=A(t.quote,2e3);if(!n||!i||!o)continue;let s={title:n,kind:i,quote:o},c=A(t.body,4e3);c&&(s.body=c),a.push(s)}if(!a.length)return JSON.stringify({ok:!1,error:`没有有效的子点(需要 title、kind、quote)`});let o=b(i.outline,e,a);if(o.error)return JSON.stringify({ok:!1,error:o.error});let s=await Ct(n,o.outline,o.idMap);return JSON.stringify({ok:!0,added:o.addedIds.length,addedIds:o.addedIds,idMap:Object.fromEntries(o.idMap),total:s.length,items:s.filter(e=>e.parentId&&e.kind).map(({id:e,title:t,kind:n,parentId:r})=>({id:e,title:t,kind:n??null,parentId:r??null})),note:`已在 ${e} 下方插入 ${o.addedIds.length} 条子点,同父级序号已顺延。`})}if(e===`req_update_outline_point`){let e=A(r.id,64),t=A(r.quote,2e3);if(!e)return JSON.stringify({ok:!1,error:`缺少 id`});if(!t)return JSON.stringify({ok:!1,error:`缺少 quote`});let a=A(r.kind,16),o=a===`query`||a===`mutate`?a:void 0,s=A(r.title,200),c=A(r.body,4e3),l={quote:t};s&&(l.title=s),o&&(l.kind=o),r.body!==void 0&&(l.body=c);let u=Ie(i.outline,e,l);if(u.error)return JSON.stringify({ok:!1,error:u.error});let d=(await n.saveOutline(u.outline)).find(t=>t.id===e);return JSON.stringify({ok:!0,id:e,item:d?{id:d.id,title:d.title,kind:d.kind??null,parentId:d.parentId??null}:null,note:`已更新需求点 ${e}(id 未变)。若还要拆出额外子点,用 req_insert_outline_after,afterId 仍为 ${e}。`})}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=fe(i.stories,e),{stories:o,filled:s}=We(a,i.outline),c=await n.saveStories(o),l=new Set(i.outline.map(e=>e.id)),u=c.stories.flatMap(e=>e.sourceRefs).filter(e=>!l.has(e)),d=c.stories.filter(e=>!e.sourceRefs.length).length;return JSON.stringify({ok:!0,added:Math.max(0,c.stories.length-t),total:c.stories.length,stories:c.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),autoLinked:s,danglingSourceRefs:Array.from(new Set(u)).slice(0,10),note:u.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:d>0?`故事已保存;仍有 ${d} 条未挂上需求点,请对照条目 id 补上。`:s>0?`故事已保存(自动补挂了 ${s} 条需求点)。`:`故事已保存。`})}if(e===`req_save_check`){let e=Ee(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[Et(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=A(n.title,200);if(!r)continue;let i=A(n.storyId,20),o=a.has(i)&&i||t.get(Et(A(n.storyTitle,200)))||``,c=j(n.type);(c===`missing-scenario`||c===`missing-dimension`||c===`untestable-acceptance`||c===`over-split`||c===`missing-field`)&&(c=`pending-confirm`);let l=A(n.outlineId,32);s.push({id:x(c,o||l,r),storyId:o,outlineId:l||void 0,type:c,severity:Dt(n.severity),title:r,detail:A(n.detail,1e3),suggestion:A(n.suggestion,1e3),origin:`model`,selected:!1})}let c=Te(Me(e.gaps,s)),l=A(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=>kt(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:A(r.summary,2e3),points:a})).testPoints?.points??a,s=Ot.map(e=>({dimension:st[e],count:o.filter(t=>t.dimension===e).length})),c=ct.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 P(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 Mt(e){let t=P(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 Nt(e,t=[]){let n=new Set(t),r=P(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=>kt(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?A(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var F=h(),Pt=`text-xs font-semibold tracking-wide text-stone-500`,Ft=`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`,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=[`pending`,`ignored`],It=`reqanalysis.reviewListTab`;function R(e){let t=e?.parentElement??null;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return null}function Lt({check:e,stories:t,outlineTitles:n,ignoredGaps:r=[],busy:i,onToggleGap:a,onToggleAll:c,onFix:l,onReview:u,onFullScan:h,onExport:g,onExportPending:ee,onIgnoreGap:v,onIgnoreSelected:te,onSaveGapConclusion:ne,onRestoreIgnored:re,onPromoteIgnored:y}){let[b,ie]=(0,k.useState)(()=>o(It,L,`pending`)),[ae,oe]=(0,k.useState)(null),[se,ce]=(0,k.useState)(``),le=(0,k.useRef)(null),ue=(0,k.useRef)(null),de=(0,k.useRef)(null),fe=(0,k.useRef)(!1);(0,k.useEffect)(()=>{s(It,b)},[b]),(0,k.useEffect)(()=>{if(!ae)return;ce(ae.conclusion?.trim()||``);let e=window.setTimeout(()=>{le.current?.focus(),le.current?.select()},50);return()=>window.clearTimeout(e)},[ae]),(0,k.useLayoutEffect)(()=>{let e=ue.current,t=de.current,n=R(e);if(!e||!t||!n)return;let r=Math.max(0,n.clientHeight-e.offsetHeight-16);if(t.style.minHeight=`${r}px`,!fe.current)return;fe.current=!1;let i=e.getBoundingClientRect().top-n.getBoundingClientRect().top;Math.abs(i)>.5&&(n.scrollTop+=i)},[b,e?.gaps.length,r.length]);let pe=e=>{if(e===b)return;let t=ue.current,n=R(t);t&&n?fe.current=t.getBoundingClientRect().top<=n.getBoundingClientRect().top+1:fe.current=!1,ie(e)};if(!e)return(0,F.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,F.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,F.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会核对需求点覆盖,并标出需要业务确认的点(不是需求文档缺什么的质检单)。`}),(0,F.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:i||!t.length,onClick:u,children:`开始审查`})]});let me=gt(e.gaps),he=e.gaps.filter(e=>e.selected).length,ge=e.coverage.total?Math.round(e.coverage.rate*100):0,_e=ht(e.gaps),ve=new Map(t.map(e=>[e.id,e.title])),x=[{id:`pending`,label:`待确认清单`,count:e.gaps.length},{id:`ignored`,label:`忽略`,count:r.length}];return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:Pt,children:`需求点覆盖率`}),(0,F.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,F.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,F.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[ge,`%`]})]})]}),(0,F.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,F.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all ${ge>=90?`bg-emerald-500`:ge>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(ge,e.coverage.total?2:0)}%`}})}),(0,F.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的需求点算覆盖;未覆盖会进待确认清单`:`还没有需求条目,先做一次拆解`})]}),(0,F.jsxs)(`div`,{className:`text-right`,children:[(0,F.jsx)(`p`,{className:Pt,children:`待确认`}),(0,F.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,F.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,_e.high,` · 中 `,_e.medium,` · 低 `,_e.low]})]})]})]}),e.summary?(0,F.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null,h?(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-2 border-t border-stone-100 pt-2`,children:[(0,F.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`复审只刷新上轮清单;需要再挖新问题用全量扫描(已忽略仍不回潮)`}),(0,F.jsx)(`button`,{type:`button`,className:I,disabled:i||!t.length,onClick:h,children:`重新全量扫描`})]}):null]}),(0,F.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,F.jsx)(`p`,{className:Pt,children:`维度覆盖(仅供参考,无原文依据不进待确认)`}),(0,F.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,F.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,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,F.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,F.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,F.jsx)(_,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,F.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,F.jsx)(`div`,{ref:ue,className:`sticky top-0 z-10 -mx-0.5 rounded-xl border border-stone-200 bg-white px-2 shadow-sm sm:px-3`,children:(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-0.5`,role:`tablist`,"aria-label":`审查清单`,children:x.map(e=>{let t=b===e.id;return(0,F.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.5 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>pe(e.id),children:[e.label,(0,F.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)})}),b===`pending`?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1.5 sm:px-0`,children:[(0,F.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,he,` 条`]}),(0,F.jsx)(`button`,{type:`button`,className:I,onClick:g,children:`导出 Markdown`}),ee?(0,F.jsx)(`button`,{type:`button`,className:I,onClick:ee,children:`导出待确认`}):null,(0,F.jsx)(`button`,{type:`button`,className:I,onClick:()=>c(he!==e.gaps.length),children:he===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),te?(0,F.jsx)(`button`,{type:`button`,className:I,disabled:i||!he,onClick:te,children:`批量忽略`}):null,(0,F.jsx)(`button`,{type:`button`,className:Ft,disabled:i||!he,onClick:l,children:`补写选中缺口`})]}):(0,F.jsx)(`span`,{className:`px-1 py-1.5 text-xs text-stone-400 sm:px-0`,children:`忽略项可恢复或落成用户故事`})]})}),(0,F.jsx)(`div`,{ref:de,className:`rounded-xl border border-stone-200 bg-white`,children:b===`pending`?me.length?(0,F.jsx)(`div`,{className:`divide-y divide-stone-100`,children:me.map(e=>(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,F.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,F.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,F.jsx)(z,{gap:e,storyTitle:ve.get(e.storyId)??``,outlineLabel:e.outlineId?n?.get(e.outlineId)??e.outlineId:``,onToggle:a,onIgnore:v,onFillConclusion:ne?e=>oe(e):void 0,busy:i},e.id))})]},e.key))}):(0,F.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有待确认项。需求点覆盖与待确认都过了,可再人工过一遍故事。`}):r.length?(0,F.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:r.map(e=>(0,F.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:w[e.type]}),e.outlineId?(0,F.jsx)(`span`,{className:`rounded bg-[#eaf1ff] px-1.5 py-0.5 text-[11px] text-[#3370ff]`,children:n?.get(e.outlineId)??e.outlineId}):null,(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.ignoredAt.slice(0,16).replace(`T`,` `)})]}),(0,F.jsx)(`p`,{className:`mt-1 text-sm text-stone-800`,children:e.title}),e.detail?(0,F.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-xs text-stone-500`,children:e.detail}):null,e.conclusion?.trim()?(0,F.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs text-emerald-700`,children:[`结论:`,e.conclusion.trim()]}):null,(0,F.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap justify-end gap-2`,children:[re?(0,F.jsx)(`button`,{type:`button`,className:I,disabled:i,onClick:()=>re(e.id),children:`恢复`}):null,y?(0,F.jsx)(`button`,{type:`button`,className:Ft,disabled:i,onClick:()=>y(e.id),children:`落成用户故事`}):null]})]},e.id))}):(0,F.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`忽略后不进用户故事,可随时恢复或落成。`})}),(0,F.jsxs)(p,{open:!!ae,onClose:()=>oe(null),className:`relative z-110`,children:[(0,F.jsx)(m,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,F.jsxs)(d,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-md rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,F.jsx)(f,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:`填写结论`}),ae?(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-stone-400 line-clamp-2`,children:ae.title}):null,(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-stone-400`,children:`把产品/项目确认的结论写在这里;勾选后点「补写选中缺口」时会带给模型。`}),(0,F.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[`结论`,(0,F.jsx)(`textarea`,{ref:le,value:se,onChange:e=>ce(e.target.value),rows:3,placeholder:`例如:倒计时是提交后 3 秒关页,时间到自动关,不能取消…`,className:`mt-1.5 block w-full resize-y rounded-lg border border-stone-200 px-3 py-2 text-sm leading-relaxed text-stone-800 outline-none transition-colors focus:border-[#4176e6] focus:ring-2 focus:ring-[#4176e6]/30`})]}),(0,F.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,className:`tw-confirm-cancel h-8 rounded-lg px-3 text-sm text-stone-600 transition-colors hover:bg-stone-100`,onClick:()=>oe(null),children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`h-8 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white transition-colors hover:bg-[#3565c7] disabled:opacity-40`,disabled:i||!se.trim(),onClick:()=>{if(!ae||!ne||!se.trim())return;let e=ae,t=se.trim();oe(null),ne(e,t)},children:`保存结论`})]})]})})]})]})}function z({gap:e,storyTitle:t,outlineLabel:n,onToggle:r,onIgnore:i,onFillConclusion:a,busy:o}){return(0,F.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>r(e.id,t.target.checked)}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,F.jsx)(E,{tone:C[e.severity],children:Ve[e.severity]}),(0,F.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:w[e.type]}),n?(0,F.jsx)(`span`,{className:`rounded bg-[#eaf1ff] px-1.5 py-0.5 text-[11px] text-[#3370ff]`,children:n}):null,e.storyId?(0,F.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,F.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,F.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500 whitespace-pre-wrap`,children:e.detail}):null,e.suggestion?(0,F.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null,e.conclusion?.trim()?(0,F.jsxs)(`p`,{className:`mt-1 line-clamp-3 text-xs text-emerald-700`,children:[`结论:`,e.conclusion.trim()]}):null,a||i?(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2`,children:[a?(0,F.jsx)(`button`,{type:`button`,className:I,disabled:o,onClick:()=>a(e),children:`填结论`}):null,i?(0,F.jsx)(`button`,{type:`button`,className:I,disabled:o,onClick:()=>i(e.id),children:`忽略`}):null]}):null]})]})}var B=`reqanalysis.testPointsView`,Rt=[`map`,`list`],zt=`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 Bt({point:e}){return(0,F.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,F.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,F.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,F.jsxs)(`p`,{children:[(0,F.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function Vt({req:e,onJumpToRequirement:t}){return(0,F.jsxs)(`div`,{className:`flex items-stretch gap-0`,children:[(0,F.jsxs)(`div`,{className:`flex w-36 shrink-0 flex-col justify-center rounded-l-xl border border-r-0 border-[#c9d8ff] bg-[#f5f8ff] px-3 py-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] text-[#5b7fd6]`,children:`需求`}),t?(0,F.jsx)(`button`,{type:`button`,className:`text-left text-sm font-semibold leading-snug text-[#1f4fd8] hover:underline`,onClick:()=>t(e.title,e.storyIds),children:e.title}):(0,F.jsx)(`p`,{className:`text-sm font-semibold leading-snug text-stone-800`,children:e.title}),(0,F.jsxs)(`p`,{className:`mt-1 text-[11px] tabular-nums text-stone-400`,children:[e.points.length,` 条`]})]}),(0,F.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-hidden rounded-r-xl border border-stone-200 bg-white`,children:e.dimensions.map((n,r)=>{let i=pt[n.key];return(0,F.jsxs)(`div`,{className:`flex w-[9.5rem] shrink-0 flex-col ${r>0?`border-l border-stone-100`:``}`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2 py-1.5`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${i.accent}`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`truncate text-[11px] font-medium text-stone-700`,children:i.label})]}),(0,F.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:n.points.length})]}),(0,F.jsx)(`div`,{className:`max-h-52 space-y-1.5 overflow-y-auto px-1.5 py-1.5`,children:n.points.length?n.points.map(n=>(0,F.jsx)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/70 px-1.5 py-1`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,F.jsx)(E,{tone:yt[n.priority].tone,children:n.priority}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`p`,{className:`break-words text-[11px] leading-snug text-stone-700`,children:n.title}),t?(0,F.jsxs)(`button`,{type:`button`,className:`mt-0.5 text-left text-[10px] text-[#3370ff] hover:underline`,onClick:()=>t(e.title,e.storyIds),children:[`所属需求:`,e.title]}):(0,F.jsxs)(`p`,{className:`mt-0.5 text-[10px] text-[#3370ff]`,children:[`所属需求:`,e.title]})]})]})},n.id)):(0,F.jsx)(`p`,{className:`py-3 text-center text-[11px] text-stone-300`,children:`无`})})]},n.key)})})]})}function Ht({doc:e,idealTitles:t,onJumpToRequirement:n}){let r=(0,k.useMemo)(()=>at(e,t),[e,t]);return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,F.jsx)(`div`,{className:`min-w-[62rem] space-y-3`,children:r.length?r.map(e=>(0,F.jsx)(Vt,{req:e,onJumpToRequirement:n},e.key)):(0,F.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`还没有测试点。`})})}),(0,F.jsx)(`p`,{className:`text-center text-[11px] text-stone-400`,children:`每条需求横向展开五个维度;列过窄时整行左右滑动。导出 XMind 为同结构的向右逻辑图。`})]})}function Ut({doc:e,idealTitles:t,onJumpToRequirement:n}){let r=(0,k.useMemo)(()=>at(e,t),[e,t]);return(0,F.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,F.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`border-b border-stone-100 bg-[#f8fafc] px-3.5 py-2.5`,children:[(0,F.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`需求`}),n?(0,F.jsx)(`button`,{type:`button`,className:`text-left text-sm font-semibold text-[#1f4fd8] hover:underline`,onClick:()=>n(e.title,e.storyIds),children:e.title}):(0,F.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title}),(0,F.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[e.points.length,` 条`]})]}),(0,F.jsx)(`div`,{className:`divide-y divide-stone-100`,children:e.dimensions.map(t=>(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${pt[t.key].accent}`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:t.label}),(0,F.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:t.hint})]}),(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:t.points.length})]}),t.points.length?(0,F.jsx)(`ul`,{className:`border-t border-stone-50`,children:t.points.map(t=>(0,F.jsx)(`li`,{className:`border-t border-stone-50 first:border-t-0`,children:(0,F.jsxs)(`details`,{className:`group px-3.5 py-2 pl-8`,children:[(0,F.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,F.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,F.jsx)(E,{tone:yt[t.priority].tone,children:t.priority})}),(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:`block text-sm text-stone-800`,children:t.title}),n?(0,F.jsxs)(`button`,{type:`button`,className:`mt-0.5 block text-left text-xs text-[#3370ff] hover:underline`,onClick:t=>{t.preventDefault(),n(e.title,e.storyIds)},children:[`所属需求:`,e.title]}):(0,F.jsxs)(`span`,{className:`mt-0.5 block text-xs text-[#3370ff]`,children:[`所属需求:`,e.title]}),(0,F.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-xs text-stone-400`,children:[(0,F.jsxs)(`span`,{children:[t.steps.length,` 步`]}),t.supplemental?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,F.jsx)(`span`,{className:`text-amber-600`,children:`补充`})]}):null,t.expected?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,F.jsx)(_,{text:t.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,F.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,F.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,F.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,F.jsx)(Bt,{point:t})})]})},t.id))}):(0,F.jsx)(`p`,{className:`px-3.5 py-2 pl-8 text-[11px] text-stone-300`,children:`本维度没有测试点。`})]},t.key))})]},e.key))})}function Wt({doc:e,idealTitles:t=[],generating:n,busy:r,promptReady:i,onExportXmind:a,onExportMarkdown:c,onJumpToRequirement:l}){let[u,d]=(0,k.useState)(()=>o(B,Rt,`map`)),f=e.testPoints,p=O(f),m=!!e.sourcePath&&t.length===0,h=(0,k.useMemo)(()=>m?0:at(e,t).length,[e,t,m]),g=e=>{d(e),s(B,e)};if(!f){let t=e.stories.length?i?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,F.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,F.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,F.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`按需求文档每一行整理标题,再按功能 / 边界值 / 异常 / 业务规则 / 非功能拆测试点;导图左右展开,可导出 XMind(向右逻辑图)与 Markdown。`}),t?(0,F.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:t}):null,(0,F.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:n?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.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,F.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`需求 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-700`,children:h}),` · 测试点`,` `,(0,F.jsx)(`span`,{className:`font-medium text-stone-700`,children:p.total})]}),(0,F.jsx)(`span`,{className:`flex items-center gap-1`,children:ct.map(e=>(0,F.jsxs)(E,{tone:yt[e].tone,children:[e,` `,p.byPriority[e]]},e))}),(0,F.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,p.coveredDimensions,`/5`]}),(0,F.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,F.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${u===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>g(e.id),children:e.label},e.id))}),(0,F.jsx)(`button`,{type:`button`,className:zt,disabled:r,onClick:a,children:`导出 XMind`}),(0,F.jsx)(`button`,{type:`button`,className:zt,disabled:r,onClick:c,children:`导出 Markdown`})]})]}),m?(0,F.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-xl border border-dashed border-stone-200 py-16 text-xs text-stone-400`,"aria-busy":`true`,children:[(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),`正在按需求文档行整理…`]}):u===`map`?(0,F.jsx)(Ht,{doc:e,idealTitles:t,onJumpToRequirement:l}):(0,F.jsx)(Ut,{doc:e,idealTitles:t,onJumpToRequirement:l}),f.summary?(0,F.jsxs)(`details`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-stone-600`,children:`生成说明`}),(0,F.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed whitespace-pre-wrap text-stone-500`,children:f.summary})]}):null]})}var Gt=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],V=`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`,Kt=`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`,H=`text-xs font-semibold tracking-wide text-stone-500`,qt=`text-[11px] font-medium tracking-wide text-stone-400`,Jt={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function Yt({label:e,children:t}){return(0,F.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,F.jsx)(`p`,{className:`${qt} pt-0.5`,children:e}),(0,F.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function Xt(e){return e.split(`
|
|
10
|
-
`).map(e=>e.trim()).filter(Boolean)}function Zt({label:e,value:t,placeholder:n,onChange:r}){return(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsxs)(`span`,{className:H,children:[e,`(一行一条)`]}),(0,F.jsx)(`textarea`,{className:`${Kt} mt-1 min-h-[64px]`,value:t.join(`
|
|
11
|
-
`),placeholder:n,onChange:e=>r(Xt(e.target.value))})]})}function Qt({value:e,onChange:t}){return(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`主流程(一行一步:动作 -> 结果)`}),(0,F.jsx)(`textarea`,{className:`${Kt} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
|
|
12
|
-
`),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(Xt(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 $t({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
13
|
-
`)).join(`
|
|
14
|
-
|
|
15
|
-
`);return(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,F.jsx)(`textarea`,{className:`${Kt} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
|
|
16
|
-
1. 提交后进入人工队列
|
|
17
|
-
2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
|
|
18
|
-
`).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 en({value:e,onChange:t}){return(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`异常场景(一行一条:场景 -> 预期)`}),(0,F.jsx)(`textarea`,{className:`${Kt} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
|
|
19
|
-
`),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(Xt(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 tn({value:e,onChange:t}){return(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`验收标准(一行一条:Given | When | Then)`}),(0,F.jsx)(`textarea`,{className:`${Kt} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
|
|
20
|
-
`),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(Xt(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function nn({story:e,index:t,total:n,gaps:r,outlineTitles:i,outlineOptions:a,completenessHints:o,busy:s,onSave:c,onDelete:l,onMove:u,onJumpOutline:d,domId:f}){let[p,m]=(0,k.useState)(!1),[h,g]=(0,k.useState)(!1),[_,v]=(0,k.useState)(e),[te,ne]=(0,k.useState)(!1);(0,k.useEffect)(()=>{if(p||h){ne(!0);return}let e=window.setTimeout(()=>ne(!1),200);return()=>window.clearTimeout(e)},[p,h]);let re=()=>{v({...e}),g(!0),m(!0)},y=e=>v(t=>({...t,...e})),b=r.filter(e=>e.severity===`high`).length;return(0,F.jsxs)(`li`,{id:f,className:`overflow-hidden rounded-xl border bg-white transition-colors ${p||h?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,F.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":p,"aria-label":p?`收起 ${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:()=>m(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m(e=>!e))},children:[(0,F.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${Jt[e.priority]}`,"aria-hidden":`true`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,F.jsx)(E,{tone:Le[e.priority],children:e.priority}),(0,F.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,F.jsxs)(E,{tone:b?`red`:`amber`,children:[r.length,` 个待确认`,b?` · 高 ${b}`:``]}):null,o?.length?(0,F.jsxs)(E,{tone:`gray`,children:[`待补全 `,o.length]}):null]}),e.sourceRefs.length?(0,F.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.sourceRefs.map(e=>{let t=i?.get(e)??e;return(0,F.jsx)(`button`,{type:`button`,className:`rounded bg-[#eaf1ff] px-1.5 py-0.5 text-[11px] text-[#3370ff] hover:opacity-80`,onClick:t=>{t.stopPropagation(),d?.(e)},children:t},e)})}):null,(0,F.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(` · `)||`还没有写角色与目标`}),o?.length?(0,F.jsxs)(`p`,{className:`mt-1 text-[11px] text-amber-700`,children:[`待补全:`,o.map(e=>e.label).join(`、`)]}):null,p?null:(0,F.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,F.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:s||t===0,onClick:()=>u(-1),children:(0,F.jsx)(D,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,F.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:s||t>=n-1,onClick:()=>u(1),children:(0,F.jsx)(D,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,F.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":h?`取消编辑`:`编辑`,onClick:()=>h?g(!1):re(),children:(0,F.jsx)(D,{name:`pencil`,size:14})}),(0,F.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:s,onClick:l,children:(0,F.jsx)(D,{name:`trash`,size:14})}),(0,F.jsx)(D,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${p||h?`rotate-90`:``}`})]})]}),(0,F.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${p||h?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,F.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[te&&h?(0,F.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`标题`}),(0,F.jsx)(`input`,{className:`${V} mt-1`,value:_.title,onChange:e=>y({title:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`角色`}),(0,F.jsx)(`input`,{className:`${V} mt-1`,value:_.role,onChange:e=>y({role:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`优先级`}),(0,F.jsx)(`div`,{className:`mt-1`,children:(0,F.jsx)(ee,{options:Gt,value:_.priority,onChange:e=>y({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`目标`}),(0,F.jsx)(`input`,{className:`${V} mt-1`,value:_.goal,onChange:e=>y({goal:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`block`,children:[(0,F.jsx)(`span`,{className:H,children:`价值 / 备注`}),(0,F.jsx)(`input`,{className:`${V} mt-1`,value:_.value,onChange:e=>y({value:e.target.value})})]}),(0,F.jsx)(Zt,{label:`前置条件`,value:_.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>y({preconditions:e})}),(0,F.jsx)(Qt,{value:_.mainFlow,onChange:e=>y({mainFlow:e})}),(0,F.jsx)($t,{value:_.altFlows,onChange:e=>y({altFlows:e})}),(0,F.jsx)(en,{value:_.exceptions,onChange:e=>y({exceptions:e})}),(0,F.jsx)(Zt,{label:`后置条件`,value:_.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>y({postconditions:e})}),(0,F.jsx)(tn,{value:_.acceptance,onChange:e=>y({acceptance:e})}),(0,F.jsx)(Zt,{label:`覆盖维度`,value:_.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>y({dimensions:e})}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-stone-600`,children:`关联需求点`}),a?.length?(0,F.jsx)(`div`,{className:`flex max-h-40 flex-wrap gap-1.5 overflow-y-auto rounded-lg border border-stone-100 bg-white p-2`,children:a.filter(e=>e.kind||!a.some(t=>t.parentId===e.id)).map(e=>{let t=_.sourceRefs.includes(e.id),n=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``,r=i?.get(e.id)??e.title;return(0,F.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] ${t?`border-[#3370ff] bg-[#eaf1ff] text-[#3370ff]`:`border-stone-200 text-stone-600 hover:bg-stone-50`}`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`sr-only`,checked:t,onChange:()=>{let n=t?_.sourceRefs.filter(t=>t!==e.id):[..._.sourceRefs,e.id];y({sourceRefs:n})}}),n?(0,F.jsx)(`span`,{className:`opacity-70`,children:n}):null,(0,F.jsx)(`span`,{children:r})]},e.id)})}):(0,F.jsxs)(`p`,{className:`text-xs text-stone-400`,children:[`来源条目:`,_.sourceRefs.join(`、`)||`(未关联)`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,F.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:()=>g(!1),children:`取消`}),(0,F.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:s||!_.title.trim(),onClick:()=>{c(_),g(!1)},children:`保存`})]})]}):null,te&&!h?(0,F.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,F.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,F.jsx)(Yt,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,F.jsx)(Yt,{label:`前置条件`,children:(0,F.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,F.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,F.jsx)(Yt,{label:`主流程`,children:(0,F.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,F.jsxs)(`li`,{children:[e.actor?(0,F.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,F.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,F.jsx)(Yt,{label:`替代流程`,children:(0,F.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,F.jsxs)(`li`,{children:[(0,F.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,F.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,F.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,F.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,F.jsx)(Yt,{label:`异常场景`,children:(0,F.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,F.jsxs)(`li`,{children:[e.scenario,e.expected?(0,F.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,F.jsx)(Yt,{label:`后置条件`,children:(0,F.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,F.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,F.jsx)(Yt,{label:`验收标准`,children:(0,F.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,F.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,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,F.jsx)(`span`,{children:e.given||`—`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,F.jsx)(`span`,{children:e.when||`—`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,F.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,F.jsx)(Yt,{label:`覆盖维度`,children:(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,F.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,F.jsx)(Yt,{label:`来源条目`,children:(0,F.jsx)(`div`,{className:`space-y-1.5`,children:e.sourceRefs.length?e.sourceRefs.map(e=>{let t=a?.find(t=>t.id===e),n=i?.get(e)??e,r=(t?.quote||t?.body||``).trim();return(0,F.jsxs)(`div`,{className:`rounded-md bg-white px-2 py-1.5 ring-1 ring-stone-100`,children:[(0,F.jsx)(`button`,{type:`button`,className:`text-left text-[11px] text-[#3370ff] hover:opacity-80`,onClick:()=>d?.(e),children:n}),r?(0,F.jsx)(`p`,{className:`mt-0.5 line-clamp-3 text-[11px] leading-relaxed text-stone-500`,children:r}):null]},e)}):(0,F.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,F.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,F.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,F.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,F.jsx)(E,{tone:C[e.severity],children:Ve[e.severity]}),(0,F.jsx)(`span`,{className:`text-stone-500`,children:w[e.type]}),(0,F.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}function rn(e){if(!e.length)return`(尚未播种文档条目)`;let t=e.filter(e=>!e.parentId&&!e.kind),n=e.filter(e=>e.parentId);if(!t.length)return e.map(e=>{let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:`条目`;return`- ${e.id} [${t}] ${e.title}${e.quote?`(原文:${e.quote})`:``}`}).join(`
|
|
21
|
-
`);let r=[];for(let e of t){r.push(`- ${e.id} [文档条目] ${e.title}`),e.body?r.push(` 原文:${e.body.replace(/\s+/g,` `).slice(0,1500)}`):e.quote&&r.push(` 原文:${e.quote}`);let t=n.filter(t=>t.parentId===e.id);for(let e of t){let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:`子点`;r.push(` - ${e.id} [${t}] ${e.title}`)}t.length||r.push(` (尚无查询/修改子点:按原文能力点逐条用 req_set_outline 提交,同一父级可有多条 query/mutate,勿合并)`)}return r.join(`
|
|
22
|
-
`)}function an(e){return e.length?e.map(e=>{let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:`条目`,n=(e.quote||e.body||``).replace(/\s+/g,` `).trim().slice(0,400);return`- ${e.id} [${t}] ${e.title}${n?`\n 原文:${n}`:``}`}).join(`
|
|
23
|
-
`):`(无)`}var on=`reqanalysis.doc`,sn=`reqanalysis.listmode`,cn=`reqanalysis.view`,ln=`reqanalysis.tab`,un=`reqanalysis.promptCardOpen`,dn=`reqanalysis.storykeyword`,fn=[`list`,`work`],pn=[`outline`,`stories`,`check`,`points`],mn=`reqanalysis.activity`,hn=[`info`,`tool`,`done`,`error`,`stage`];function gn(e){return`${mn}.${e}`}function _n(e){if(!e)return[];let t=u(gn(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`&&typeof(t.detail??``)==`string`&&hn.includes(t.kind)}).slice(-200):[]}var vn=`reqanalysis.run`,yn=[`decompose`,`stories`,`audit`,`fix`,`testpoints`,`change-point`],U=null,bn={current:null},xn=new Set;function Sn(e){return`${vn}.${e}`}function Cn(e){let t=e?.docId??U?.docId;U=e,t&&i(Sn(t),e);for(let t of xn)t(e)}function wn(e){return xn.add(e),()=>{xn.delete(e)}}function W(e,t){if(!U||U.status!==`running`)return;let n=Math.max(0,Math.min(100,Math.round(e)));(n!==U.done||t!==void 0&&t!==U.message)&&Cn({...U,total:100,done:n,...t===void 0?{}:{message:t}})}var Tn=96;function G(e,t=1){if(!U||U.status!==`running`)return;let n=Math.max(1,Math.min(Tn,Math.round(e))),r=U.done;if(r>=n)return;let i=n-r,a=i>28?Math.min(Math.max(1,t),i):1;Cn({...U,total:100,done:Math.min(n,r+a)})}function En(e,t=1200){let n=0,r=window.setInterval(()=>{if(!U||U.status!==`running`)return;let t=Math.max(1,Math.min(Tn,Math.round(e)))-U.done;t<=0||(n+=1,n%(t>40?1:t>24?2:t>12?3:t>5?5:8)==0&&G(e,1))},t);return()=>window.clearInterval(r)}function Dn(e){if(!e)return null;let t=u(Sn(e),null);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.label!=`string`||typeof n.message!=`string`||!yn.includes(n.kind))return null;let r=n.status===`done`||n.status===`error`?n.status:`stopped`;return{docId:e,kind:n.kind,label:n.label,done:Math.max(0,Number(n.done)||0),total:Math.max(0,Number(n.total)||0),message:n.message,startedAt:Number(n.startedAt)||0,status:r,finishedAt:Number(n.finishedAt)||void 0}}var On={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},kn=`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`,An=`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`,jn=`text-xs font-semibold tracking-wide text-stone-500`;function Mn(e){return e.split(`/`).pop()||e}function Nn(e){return(e.format||Mn(e.path).split(`.`).pop()||``).toLowerCase()}function Pn(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 Fn(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function K(e,t=160){if(e==null)return``;let n=``;try{n=typeof e==`string`?e:JSON.stringify(e)}catch{return``}return n?n.length>t?`${n.slice(0,t)}…`:n:``}function In(e){let t=Math.max(0,(Date.now()-e)/1e3);return t<10?`${t.toFixed(1)}s`:`${Math.round(t)}s`}function Ln(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Rn({name:e,ready:t}){return(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(_,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function zn(){let e=rt(`reqAnalysis`),t=rt(`storyReview`),h=rt(`testPoints`),[b,pe]=(0,k.useState)(null),[x,Me]=(0,k.useState)([]),[C,Le]=(0,k.useState)(``),[w,Ve]=(0,k.useState)(null),[at,st]=(0,k.useState)([]),[ct,pt]=(0,k.useState)(``),[ht,gt]=(0,k.useState)(``),[O,yt]=(0,k.useState)(null),[Ct,wt]=(0,k.useState)(null),[Tt,A]=(0,k.useState)(null),[Et,Dt]=(0,k.useState)(null),[j,Ot]=(0,k.useState)(()=>U);(0,k.useEffect)(()=>(Ot(U),wn(Ot)),[]);let M=j?.status===`running`?j.kind:null,N=j?.status===`running`&&j.docId===C?{label:j.label,done:j.done,total:j.total,message:j.message}:null,kt=(0,k.useRef)(Date.now()),P=j&&j.docId===C&&j.status!==`running`&&(j.finishedAt??0)<kt.current?j:null,[Pt,Ft]=(0,k.useState)([]),[I,L]=(0,k.useState)(``),[It,R]=(0,k.useState)(``),[z,B]=(0,k.useState)(()=>o(ln,pn,`outline`));(0,k.useEffect)(()=>{s(ln,z)},[z]);let[Rt,zt]=(0,k.useState)(`list`),Bt=(0,k.useRef)(o(cn,fn,`list`)),[Vt,Ht]=(0,k.useState)(!0),[Ut,Gt]=(0,k.useState)(()=>o(sn,[`doc`,`story`],`doc`)),[V,Kt]=(0,k.useState)(()=>c(dn,``));(0,k.useEffect)(()=>{l(dn,V)},[V]);let[H,qt]=(0,k.useState)(null),[Jt,Yt]=(0,k.useState)([]),Xt=(0,k.useRef)(``),[Zt,Qt]=(0,k.useState)(``),[$t,en]=(0,k.useState)([]),tn=(0,k.useRef)([]),[mn,hn]=(0,k.useState)(!1),[vn,yn]=(0,k.useState)(!1),[xn,Tn]=(0,k.useState)(!1),[zn,Bn]=(0,k.useState)(!1),[Vn,Hn]=(0,k.useState)(()=>c(un,`1`)!==`0`),[Un,Wn]=(0,k.useState)(null),[Gn,Kn]=(0,k.useState)(``),[qn,Jn]=(0,k.useState)(null),q=(0,k.useRef)(null),Yn=(0,k.useRef)(0),Xn=(0,k.useRef)(null),Zn=(0,k.useRef)(null),Qn=(0,k.useRef)(``),$n=(0,k.useRef)(!0),er=(0,k.useRef)(0),tr=(0,k.useRef)([]),nr=(0,k.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?Be[e]:Be.decomposed,[t.on]),rr=(0,k.useMemo)(()=>{let e=e=>+!e.supported,t=e=>e.ctime||e.mtime||0;return[...at].filter(e=>!Ye(e.name)).sort((n,r)=>e(n)-e(r)||t(r)-t(n)||n.path.localeCompare(r.path,`zh`)).map(e=>{let t=Nn(e),n=On[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[at]),J=(0,k.useCallback)(e=>{q.current=e,Ve(e),Me(t=>Ln(t.map(t=>t.id===e.id?e:t)))},[]),Y=(0,k.useCallback)((e,t=`info`,n)=>{Yn.current+=1,Ft(r=>[...r,{id:Yn.current,kind:t,text:e,detail:n?.trim()||void 0,at:new Date().toISOString()}])},[]),X=(0,k.useCallback)((e,t,n,r)=>{Cn({docId:q.current?.id??``,kind:e,label:t,done:0,total:100,message:r,startedAt:Date.now(),status:`running`})},[]),ir=(0,k.useCallback)(e=>{if(!U||U.status!==`running`)return;let t=e.done==null?U.done:Math.max(0,Math.min(100,Math.round(e.done)));Cn({...U,...e,total:100,done:t})},[]),Z=(0,k.useCallback)((e,t,n)=>{U?.kind===e&&(bn.current=null,Cn({...U,status:t,done:t===`done`?100:U.done,total:100,message:n??U.message,finishedAt:Date.now()}))},[]);(0,k.useEffect)(()=>{C&&Ot(U??Dn(C))},[C]);let ar=(0,k.useCallback)(()=>{C&&i(Sn(C),null),Cn(null)},[C]),or=(0,k.useRef)(!1);(0,k.useEffect)(()=>{if(!C){or.current=!0,Ft([]);return}let e=_n(C);Yn.current=e.reduce((e,t)=>Math.max(e,t.id),0),or.current=!0,Ft(e)},[C]),(0,k.useEffect)(()=>{or.current?or.current=!1:C&&i(gn(C),Pt.slice(-200))},[Pt,C]);let sr=(0,k.useCallback)((e,t)=>{let n=tn.current,r=n.length===t.length&&n.every((e,n)=>e===t[n]);tn.current=t,r||en(t),e&&i(`reqanalysis.idealTitles.${e}`,t)},[]),cr=(0,k.useCallback)(e=>{if(q.current=e,Ve(e),Le(e?.id??``),l(on,e?.id??``),e?.sourcePath&&pt(e.sourcePath),e?.id){let t=u(`reqanalysis.idealTitles.${e.id}`,[]),n=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];tn.current=n,en(n)}else tn.current=[],en([])},[]);(0,k.useEffect)(()=>{let e=w;if(!e?.id||Qn.current===e.id)return;if(!e.outline.length||!e.stories.some(e=>!e.sourceRefs.length)){Qn.current=e.id;return}let{stories:t,filled:n}=We(e.stories,e.outline);if(Qn.current=e.id,!n)return;let r=!1;return T(e.id,{stories:t}).then(e=>{r||(J(e),v(`已自动挂上 ${n} 条需求点`,`success`))}).catch(()=>void 0),()=>{r=!0}},[w,J]),(0,k.useEffect)(()=>{let e=w;if(!e?.id||e.priorMemoryDocIds!==void 0||!x.length)return;let t=me(e,x).map(e=>e.id),n=!1;return T(e.id,{priorMemoryDocIds:t}).then(e=>{n||J(e)}).catch(()=>void 0),()=>{n=!0}},[w,x,J]);let lr=(0,k.useMemo)(()=>w?me(w,x):[],[w,x]),ur=(0,k.useMemo)(()=>lr.map(e=>({value:e.id,label:ye(e)})),[lr]),dr=(0,k.useCallback)(e=>{let t=q.current;if(!t?.priorMemoryDocIds?.length)return``;let n=oe(t.priorMemoryDocIds,x);if(!n.length)return``;let r=ue(e,Ue(n));if(!r.length)return``;let i=new Set(r.map(e=>e.docId)).size;return Y(`历史记忆命中 ${r.length} 条(来自 ${i} 版)`),y(r)},[x,Y]),fr=(0,k.useCallback)(e=>{zt(e),s(cn,e)},[]),pr=(0,k.useCallback)(async e=>{if(!e?.sourcePath)return sr(``,[]),[];try{let t=await _e(e.sourcePath),n=Fe(t);return sr(e.id,n),n}catch{return sr(e.id,tn.current),tn.current}},[sr]),mr=(0,k.useCallback)(async e=>{try{let t=await _e(e.sourcePath),n=Fe(t);return sr(e.id,n),e}catch{return e}},[sr]),hr=(0,k.useCallback)((e,t=`outline`)=>{cr(e),B(t),fr(`work`),xt(`req-analysis`),mr(e)},[fr,cr,mr]),gr=(0,k.useCallback)((e,t)=>{Xt.current=t,hr(e,`stories`)},[hr]);(0,k.useEffect)(()=>{if(Rt!==`work`||!Xt.current)return;let e=Xt.current;Xt.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)}},[Rt,w?.id]);let _r=(0,k.useMemo)(()=>x.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[x]),vr=_r.length,yr=(0,k.useMemo)(()=>{let e=V.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?_r.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(S(e))||t(e.title)):_r,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))},[_r,V]),br=(0,k.useMemo)(()=>new Set(H?.ids??[]),[H]),xr=(0,k.useCallback)((e,t)=>{qt(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})},[]),Sr=(0,k.useCallback)((e,t)=>{qt(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Cr=(0,k.useCallback)(e=>{Gt(e),s(sn,e)},[]);(0,k.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;yt($e());let t=await Ae();if(e){if(pe(t),!t)Ht(!1);else try{let[t,n,r,i]=await Promise.all([Ne(),Ce(),ot(),ut()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await te(!0).catch(()=>void 0),a=await Ce()),!e)return;wt(a);let o=r;if((!r.exists||!r.review.trim())&&(await vt(!0).catch(()=>void 0),o=await ot()),!e)return;o.exists&&A(o),i.exists&&Dt(i);let s=Ln(t);Me(s);let l=c(on,``),u=s.find(e=>e.id===l)??s[0]??null;cr(u);let d=Bt.current;if(Bt.current=`list`,d===`work`&&u&&l&&u.id===l&&(fr(`work`),xt(`req-analysis`)),u&&await mr(u),!e)return;Ht(!1)}catch(t){e&&(Ht(!1),R(t instanceof Error?t.message:String(t)))}}})();let t=Qe(()=>yt($e()));return()=>{e=!1,t()}},[fr,cr,mr]),(0,k.useEffect)(()=>{if(!t.ready)return;if(!t.on){A(null),B(e=>e===`check`?`stories`:e);return}if(!b||Tt!==null)return;let e=!0;return(async()=>{let t=await ot();(!t.exists||!t.review.trim())&&(await vt(!0).catch(()=>void 0),t=await ot()),e&&A(t)})(),()=>{e=!1}},[t.ready,t.on,b,Tt]),(0,k.useEffect)(()=>{z===`points`&&w?.sourcePath&&(tn.current.length||pr(w))},[z,w,pr]),(0,k.useEffect)(()=>{if(!h.ready)return;if(!h.on){Dt(null),B(e=>e===`points`?`stories`:e);return}if(!b||Et!==null)return;let e=!0;return(async()=>{let t=await ut();(!t.exists||!t.generate.trim())&&(await bt(!0).catch(()=>void 0),t=await ut()),e&&Dt(t)})(),()=>{e=!1}},[h.ready,h.on,b,Et]),(0,k.useEffect)(()=>{if(!b)return;let e=!0;return ne().then(t=>{e&&st(t)}).catch(t=>{e&>(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[b]),(0,k.useEffect)(()=>{let e=w?.sourcePath;if(!e){Qt(``);return}let t=!0;return _e(e).then(e=>{t&&Qt(Se(e))}).catch(()=>{t&&Qt(``)}),()=>{t=!1}},[w?.sourcePath,w?.sourceHash]),(0,k.useEffect)(()=>{let e=Xn.current;e&&(e.scrollTop=e.scrollHeight)},[Pt]);let wr=!!(w?.sourceHash&&Zt&&w.sourceHash!==Zt),Tr=(0,k.useMemo)(()=>new Set((w?.stories??[]).flatMap(e=>e.sourceRefs)),[w?.stories]),Er=Ct??null,Dr=!!Er?.decompose.trim(),Or=!!(Er?.stories||Er?.decompose||``).trim(),kr=Dr||Or,Ar=(0,k.useMemo)(()=>(w?.check?.gaps??[]).filter(e=>e.selected).length,[w?.check]),jr=(0,k.useMemo)(()=>qe(Te(w?.check?.gaps??[]),w?.ignoredGaps),[w?.check?.gaps,w?.ignoredGaps]),Mr=(0,k.useMemo)(()=>de(w?.outline??[]),[w?.outline]),Nr=(0,k.useMemo)(()=>ae(w?.outline??[]),[w?.outline]),Pr=(0,k.useMemo)(()=>w?ie(w.outline,w.stories):[],[w]),Fr=(0,k.useMemo)(()=>w?le(w.stories,w.outline):[],[w]),[Ir,Lr]=(0,k.useState)({}),[Rr,zr]=(0,k.useState)({}),Br=w?.ignoredGaps??[],Vr=(0,k.useCallback)(e=>{let t=q.current;if(!t)return;let n=t.outline.find(t=>t.id===e),r=n?.parentId||e,i=n?.parentId?e:``;B(`outline`),Lr(e=>({...e,[r]:!0})),i&&zr(e=>({...e,[i]:!0})),requestAnimationFrame(()=>{(i&&document.getElementById(`req-outline-point-${i}`)||document.getElementById(`req-outline-${r}`))?.scrollIntoView({behavior:`smooth`,block:`nearest`})})},[]),Hr=(0,k.useCallback)((e,t=[])=>{let n=q.current;if(!n||!e.trim())return;let r=e.trim(),i=new Set(n.stories.filter(e=>t.includes(e.id)).flatMap(e=>e.sourceRefs)),a=n.outline.find(e=>e.parentId&&e.kind&&i.has(e.id));if(a){Vr(a.id);return}let o=n.outline.find(e=>!e.parentId&&!e.kind&&(e.title===r||e.title.includes(r)||r.includes(e.title)))??n.outline.find(e=>e.parentId&&e.kind&&(e.title===r||e.title.includes(r)||r.includes(e.title)));o?Vr(o.id):(B(`outline`),v(`需求条目里没找到对应项`,`info`))},[Vr]),Ur=(0,k.useCallback)(async e=>{let t=q.current;if(!t?.check||!e.length)return;let n=t.check.gaps.filter(t=>e.includes(t.id));if(!n.length)return;let r=new Date().toISOString(),i=[...t.ignoredGaps??[],...n.map(e=>({...e,selected:!1,ignoredAt:r}))],a=t.check.gaps.filter(t=>!e.includes(t.id)),o=await T(t.id,{check:{...t.check,gaps:a},ignoredGaps:i});J(o),v(`已忽略 ${n.length} 项`,`success`)},[J]),Wr=(0,k.useCallback)(async e=>{let t=q.current;if(!t)return;let n=(t.ignoredGaps??[]).find(t=>t.id===e);if(!n)return;let{ignoredAt:r,...i}=n,a=(t.ignoredGaps??[]).filter(t=>t.id!==e),o=[...t.check?.gaps??[],{...i,selected:!1}],s=await T(t.id,{check:t.check?{...t.check,gaps:o}:{at:new Date().toISOString(),summary:``,coverage:{total:0,covered:0,rate:0},dimensions:[],gaps:o},ignoredGaps:a});J(s),v(`已恢复到待确认清单`,`success`)},[J]),Gr=(0,k.useCallback)(async e=>{let t=q.current;if(!t)return;let n=(t.ignoredGaps??[]).find(t=>t.id===e);if(!n)return;let r=window.prompt(`落成用户故事:请输入故事标题`,n.title.replace(/^待确认[::]/,``))||``;if(!r.trim())return;let i={id:``,title:r.trim(),role:`待确认`,goal:n.suggestion||n.detail||r.trim(),value:`由忽略项落成,请补全字段`,sourceRefs:n.outlineId?[n.outlineId]:[],priority:`P1`,preconditions:[],mainFlow:[{action:`按待确认项补齐主流程`,result:`可验收`}],altFlows:[],exceptions:[],postconditions:[],acceptance:[{given:`前置就绪`,when:`执行操作`,then:`结果可判定`}],dimensions:[]},a=fe(t.stories,[i]),o=(t.ignoredGaps??[]).filter(t=>t.id!==e),s=await T(t.id,{stories:a,ignoredGaps:o,status:t.status===`draft`?`decomposed`:t.status});J(s),B(`stories`),v(`已落成用户故事`,`success`)},[J]),Kr=(0,k.useCallback)(async(e,t)=>{let n=q.current;if(!n?.check)return;let r=t.trim();if(!r)return;let i=n.check.gaps.map(t=>t.id===e.id?{...t,conclusion:r}:t),a=await T(n.id,{check:{...n.check,gaps:i}});J(a),v(`结论已保存`,`success`)},[J]),Q=(0,k.useCallback)(async(e,t)=>{let n=t??q.current;if(!n)throw Error(`还没有分析文档`);let r=await T(n.id,e);return J(r),r},[J]),qr=(0,k.useCallback)(()=>{Zn.current&&window.clearTimeout(Zn.current),Zn.current=window.setTimeout(()=>{let e=q.current;e?.check&&T(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),Jr=(0,k.useCallback)(async e=>{if(!e)return null;let t=x.find(t=>t.sourcePath===e);if(t)return hr(t,`outline`),t;try{let t=await _e(e),n=Mn(e),r=await De({sourcePath:e,sourceTitle:n,sourceHash:Se(t),title:n});return Me(e=>Ln([r,...e])),hr(r,`outline`),Y(`新建分析:${S(r)}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return R(t),v(t,`error`),pt(q.current?.sourcePath??``),null}},[x,hr,Y]),Yr=!!(O?.baseURL&&O.apiKey&&O.model),Xr=(0,k.useCallback)(()=>!Yr||!O?(v(`请先在设置里配置模型`,`error`),Ze(`model`),null):O,[Yr,O]),$=(0,k.useCallback)((e,t)=>({getDoc:()=>q.current,batch:t,saveOutline:async t=>{let n=await T(e.id,{outline:t});return J(n),n.outline},saveStories:async t=>{let n=await T(e.id,{stories:t});return J(n),Y(`已写入 ${n.stories.length} 个用户故事`),n},saveIgnoredGaps:async t=>{let n=await T(e.id,{ignoredGaps:t});return J(n),n},saveCheck:async t=>{let n=q.current,r=tr.current.length>0?tr.current:n?.check?.gaps??[],i=re(r,t.gaps,n?.ignoredGaps,{allowNew:$n.current});er.current+=i.suppressed;let a={...t,gaps:i.gaps},o=await T(e.id,{check:a});return J(o),o},saveTestPoints:async t=>{let n=await T(e.id,{testPoints:t});return J(n),n}}),[J,Y]),Zr=(0,k.useCallback)(async()=>{let e=q.current,t=Xr();if(!e||!t)return;let n=Er?.decompose.trim()??``;if(!n){v(`没有读到「${we}」的「## 拆解需求」段落`,`error`);return}R(``),L(``),Y(`开始拆解需求`,`stage`),X(`decompose`,`拆解需求`,100,`正在读取来源文档`);let r=new AbortController;bn.current=r;let i=`done`;try{let i=await T(e.id,{status:`draft`,progress:{stage:`outline`,done:0,total:100,message:`正在读取来源文档`,at:new Date().toISOString()}});J(i);let a=await _e(e.sourcePath);if(!a.trim())throw Error(`来源文档是空的`);let o=xe(a);if(!o.length)throw Error(`来源文档没有可拆解的内容`);W(5,`共 ${o.length} 批,准备整理需求条目`),Y(o.length>1?`来源 ${a.length} 字,已分 ${o.length} 批整理条目`:`来源 ${a.length} 字,单批整理条目`);let s=ze(a,[]),c=await T(e.id,{replaceStories:!0,stories:[],outline:s,check:null,ignoredGaps:[],testPoints:null,status:`draft`,sourceHash:Se(a)});J(c),Y(s.length?`已按文档结构播种 ${s.length} 条需求条目`:`未能从文档结构抽出条目,将仅按原文整理`);let l=Ge(a);B(`outline`);for(let i of o){if(r.signal.aborted)break;let a=q.current?.outline.length??0,s=rn(q.current?.outline??[]),c=dr(i.text),u=[n,``,St,c?`\n${c}`:``,``,`## 需求条目(文档结构已播种;只用 req_set_outline 按能力点补查询/修改子点,同一父级可多条 query/mutate,本步不要写用户故事)`,s].filter(Boolean).join(`
|
|
24
|
-
`),d=[`这一批是原始需求的第 ${i.index+1}/${o.length} 段${i.title?`(章节:${i.title})`:``}。只整理这一段的查/改子点:一个可独立验收的能力点交一条,勿把多个能力点捆进同一 title;不要另造文档没有的条目标题;不要写用户故事。`,``,l?`${l}\n`:``,`## 原始需求`,``,i.text].filter(Boolean).join(`
|
|
25
|
-
`),f=5+Math.floor(i.index/o.length*85),p=5+Math.floor((i.index+1)/o.length*85),m=i.index===o.length-1,h=Math.max(f+1,m?Math.min(90,p):Math.min(p-2,88));await Q({progress:{stage:`outline`,done:f,total:100,message:`正在整理第 ${i.index+1}/${o.length} 批条目`,at:new Date().toISOString()}},q.current).catch(()=>void 0);let g=Date.now();Y(`第 ${i.index+1}/${o.length} 批开始(拆解需求)`,`info`,[i.title?`章节:${i.title}`:``,`${i.text.length} 字`].filter(Boolean).join(` · `)),W(f,`正在整理第 ${i.index+1}/${o.length} 批条目`);let _=En(h);try{for await(let n of Xe(t,[{role:`system`,content:u},{role:`user`,content:d}],r.signal,{tools:At.filter(e=>e.function.name===`req_set_outline`),maxToolRounds:20,runTool:(t,n)=>jt(t,n,$(e,i.index))}))n.type===`content`?(L(e=>e+n.delta),G(h,1)):n.type===`tool`&&n.status===`running`?(Y(`调用 ${n.name}`,`tool`,K(n.args)),G(h,1)):n.type===`tool`&&n.status===`done`&&(Y(`${n.name} 返回`,`tool`,K(n.result,120)),G(h,2))}finally{_()}W(Math.min(90,Math.max(h+2,p-2)),`第 ${i.index+1}/${o.length} 批返回,正在写入`);let ee=Math.max(0,(q.current?.outline.length??0)-a);Y(`第 ${i.index+1}/${o.length} 批完成`,`done`,`条目变化 +${ee} · 耗时 ${In(g)}`),W(p,`第 ${i.index+1}/${o.length} 批已写入`)}if(r.signal.aborted){Y(`已中断:已经写入的需求条目保留`,`info`);return}W(92,`正在保存需求条目`);let u=await T(e.id,{status:`decomposed`,progress:{stage:`done`,done:100,total:100,message:`需求条目已整理`,at:new Date().toISOString()}});J(u),Y(`拆解需求完成:${u.outline.length} 条需求条目`,`done`),B(`outline`),W(100,`需求条目已整理`),v(`需求条目已整理,可继续生成用户故事`,`success`)}catch(t){let n=t instanceof Error?t.message:String(t);r.signal.aborted?(i=`stopped`,Y(`已中断:已经写入的需求条目保留`,`info`)):(i=`error`,R(n),Y(`拆解需求失败:${n}`,`error`),await T(e.id,{status:`draft`}).then(e=>J(e)).catch(()=>void 0))}finally{r.signal.aborted&&(i=`stopped`),Z(`decompose`,i,i===`done`?`需求条目已整理`:i===`stopped`?`已中断:已经写入的需求条目保留`:`拆解需求失败,详见活动日志`)}},[X,dr,Z,$,J,Y,Er,Xr,Q]),Qr=(0,k.useCallback)((e,t)=>{if(!e.parentId||!e.kind)return;Wn({pointId:e.id,parentId:t.id});let n=ce(e,t,[]);Kn(e.body||e.quote||n.text||``)},[]),$r=(0,k.useCallback)(async(e,t,n,r=new Set)=>{let i=be({stories:e.stories,check:e.check,ignoredGaps:e.ignoredGaps},n,r),a=await T(e.id,{outline:t,stories:i.stories,check:i.check,ignoredGaps:i.ignoredGaps});return J(a),a},[J]),ei=(0,k.useCallback)(async()=>{let e=q.current,t=qn;if(!e||!t)return;let n=se(e.outline,t);n.error?(v(n.error,`error`),Jn(null)):(await $r(e,n.outline,n.idMap,n.removedIds),Y(`已删除需求点 ${t},同父级序号已顺延`,`done`),Jn(null),Wn(null),v(`需求点已删除`,`success`))},[qn,$r,Y]),ti=(0,k.useCallback)(async()=>{let e=q.current,t=Xr();if(!e||!t||!Un)return;let n=Gn.trim();if(!n){v(`请填写需求内容`,`error`);return}let r=Er?.decompose.trim()??``;if(!r){v(`没有读到「${we}」的「## 拆解需求」段落`,`error`);return}let i=e.outline.find(e=>e.id===Un.pointId),a=e.outline.find(e=>e.id===Un.parentId);if(!i?.parentId||!a){v(`找不到锚点需求点`,`error`);return}let o=Un.pointId,s=Ie(e.outline,o,{quote:n.slice(0,2e3),body:n});if(s.error){v(s.error,`error`);return}let c=await T(e.id,{outline:s.outline});J(c),Wn(null),Kn(``),R(``),L(``),Y(`已写入需求点原文 ${o}`,`done`),Y(`变更需求点 ${o}(模型整理)`,`stage`),X(`change-point`,`变更需求点`,100,`正在根据需求内容整理子点`);let l=new AbortController;bn.current=l;let u=`done`;try{let e=rn(c.outline),s=[r,``,St,``,`## 本轮任务`,`锚点 ${o} 的原文已按用户内容写入。请继续:`,`- 若标题或类型(查询/修改)需随内容调整:调用 req_update_outline_point(id 固定为 ${o});原文 quote/body 以用户内容为准,不要擅自删减用户已写的条目;`,`- 若用户内容里还含有其它独立能力点:调用 req_insert_outline_after,afterId 固定为 ${o},插到锚点下方;`,`- 若只需保留当前锚点、无需新增:可以不调工具,直接简短说明即可。`,`不要改其它无关子点,不要写用户故事,不要调用 req_set_outline。`,``,`## 需求条目`,e].join(`
|
|
26
|
-
`),u=[`锚点子点:${o} ${i.title}(${i.kind===`mutate`?`修改`:`查询`})`,`已写入原文:${n.slice(0,2e3)}`,`所属条目:${a.id} ${a.title}`,a.body||a.quote?`\n## 条目原文(参考)\n\n${(a.body||a.quote).slice(0,4e3)}`:``,``,`## 用户需求内容`,``,n].filter(Boolean).join(`
|
|
27
|
-
`);W(10,`正在整理需求点`);for await(let e of Xe(t,[{role:`system`,content:s},{role:`user`,content:u}],l.signal,{tools:At.filter(e=>e.function.name===`req_insert_outline_after`||e.function.name===`req_update_outline_point`),maxToolRounds:8,runTool:(e,t)=>jt(e,t,$(c,0))}))e.type===`content`?(L(t=>t+e.delta),G(90,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),G(90,1)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),G(90,2));if(l.signal.aborted){Y(`已中断:已写入的需求点保留`,`info`);return}W(100,`需求点已更新`),Y(`已变更需求点 ${o}`,`done`),v(`需求点已更新`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);l.signal.aborted?(u=`stopped`,Y(`已中断:已写入的需求点保留`,`info`)):(u=`error`,R(t),Y(`变更需求点失败:${t}`,`error`))}finally{l.signal.aborted&&(u=`stopped`),Z(`change-point`,u,u===`done`?`需求点已更新`:u===`stopped`?`已中断:已写入的需求点保留`:`变更需求点失败`)}},[X,Gn,Un,Z,$,J,Y,Er,Xr]),ni=(0,k.useCallback)(async()=>{let e=q.current,t=Xr();if(!e||!t)return;if(!e.outline.length){v(`还没有需求条目,请先点「拆解需求」`,`info`);return}if(e.status===`draft`){v(`请先成功拆解需求,再生成用户故事`,`info`);return}let n=(Er?.stories||Er?.decompose||``).trim();if(!n){v(`没有读到「${we}」的「## 生成用户故事」段落`,`error`);return}if(!he(e.outline).length){v(`还没有可挂故事的需求点,请先拆解出查询/修改子点`,`info`);return}R(``),L(``),Y(`开始生成用户故事`,`stage`),X(`stories`,`生成用户故事`,100,`正在按需求点生成`);let r=new AbortController;bn.current=r;let i=`done`,a=async i=>{let a=q.current?.stories.length??0,o=rn(q.current?.outline??[]),s=dr(i.user),c=[n,``,St,s?`\n${s}`:``,``,`## 需求条目(sourceRefs 只能引用这些 id;本步只用 req_set_stories,不要改条目)`,o].filter(Boolean).join(`
|
|
28
|
-
`);W(Math.min(i.softCap,Math.max(5,i.softCap-8)),i.progressMsg);let l=En(i.softCap),u=``;try{for await(let n of Xe(t,[{role:`system`,content:c},{role:`user`,content:i.user}],r.signal,{tools:At.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:20,runTool:(t,n)=>jt(t,n,$(e,i.batchIndex))}))n.type===`content`?(u+=n.delta,L(e=>e+n.delta),G(i.softCap,1)):n.type===`tool`&&n.status===`running`?(Y(`调用 ${n.name}`,`tool`,K(n.args)),G(i.softCap,1)):n.type===`tool`&&n.status===`done`&&(Y(`${n.name} 返回`,`tool`,K(n.result,120)),G(i.softCap,2))}finally{l()}if((q.current?.stories.length??0)===a){let t=Mt(u);if(t.length){let n=fe(q.current?.stories??[],t),r=await T(e.id,{stories:n});J(r),Y(`模型没调工具,已从回答里兜底解析 ${t.length} 个故事`,`info`)}else Y(`${i.label}没有拿到结构化故事`,`error`)}return Math.max(0,(q.current?.stories.length??0)-a)};try{let t=await T(e.id,{progress:{stage:`stories`,done:0,total:100,message:`正在按需求点生成用户故事`,at:new Date().toISOString()}});J(t);let n=await _e(e.sourcePath);if(!n.trim())throw Error(`来源文档是空的`);let i=await T(e.id,{replaceStories:!0,stories:[],check:null,ignoredGaps:[],testPoints:null,status:`decomposed`});J(i);let o=Pe(i.outline,12);Y(`按需求点生成:${he(i.outline).length} 个覆盖目标 · ${o.length} 批`),B(`stories`),W(5,`共 ${o.length} 批,按需求点生成`);for(let e=0;e<o.length&&!r.signal.aborted;e++){let t=o[e],n=5+Math.floor(e/Math.max(1,o.length)*70),r=5+Math.floor((e+1)/Math.max(1,o.length)*70),i=Math.max(n+1,Math.min(r-1,74)),s=t.parent?`${t.parent.id} ${t.parent.title}`:`其它需求点`,c=t.mustCover.map(e=>e.id).join(`、`);await Q({progress:{stage:`stories`,done:n,total:100,message:`正在生成第 ${e+1}/${o.length} 批(${s})`,at:new Date().toISOString()}},q.current).catch(()=>void 0);let l=Date.now();Y(`第 ${e+1}/${o.length} 批开始`,`info`,`${s} · 须挂 ${t.mustCover.length} 个点`);let u=(t.parent?.body||t.parent?.quote||``).trim(),d=[`按需求点生成用户故事:第 ${e+1}/${o.length} 批。`,`所属条目:${s}`,``,`## 本批必须挂上的需求点(每个 id 至少出现在一条故事的 sourceRefs 里;可多点并一条故事,不得漏 id)`,an(t.mustCover),``,`必须覆盖的 id:${c}`,u?`\n## 条目原文(依据)\n\n${u.slice(0,6e3)}`:``].filter(Boolean).join(`
|
|
29
|
-
`),f=await a({label:`第 ${e+1} 批`,user:d,batchIndex:e,softCap:i,progressMsg:`正在生成第 ${e+1}/${o.length} 批故事`});Y(`第 ${e+1}/${o.length} 批完成`,`done`,`故事变化 +${f} · 耗时 ${In(l)}`),W(r,`第 ${e+1}/${o.length} 批已写入`)}if(r.signal.aborted){Y(`已中断:已经写入的故事保留`,`info`);return}let s=He(q.current?.outline??[],q.current?.stories??[]);s.length&&(Y(`补挂未覆盖需求点 ${s.length} 个`,`stage`),W(76,`正在补挂 ${s.length} 个未覆盖需求点`),await a({label:`补挂未覆盖`,user:[`以下查改子点尚未被任何故事的 sourceRefs 引用。请用 req_set_stories 为每个 id 新建故事或并入已有故事(补写带原 id),不得漏 id;不要改需求条目。`,``,`## 未挂上的需求点`,an(s),``,`必须覆盖的 id:${s.map(e=>e.id).join(`、`)}`].join(`
|
|
30
|
-
`),batchIndex:90,softCap:84,progressMsg:`正在补挂未覆盖需求点`}),s=He(q.current?.outline??[],q.current?.stories??[]));let c=xe(n),l=c.length?c:[{index:0,title:``,text:n}];Y(`二次卡控:对照原始需求查漏`,`stage`);for(let e=0;e<l.length&&!r.signal.aborted;e++){let t=l[e],r=85+Math.floor(e/Math.max(1,l.length)*10),i=Math.min(94,r+3),o=(q.current?.stories??[]).map(e=>`- ${e.id||`(新)`} ${e.title} · refs=${e.sourceRefs.join(`、`)||`无`}`).join(`
|
|
31
|
-
`);W(r,`原文卡控 ${e+1}/${l.length}${t.title?`(${t.title})`:``}`),Y(`原文卡控第 ${e+1}/${l.length} 段`,`info`,t.title||`${t.text.length} 字`),await a({label:`原文卡控 ${e+1}`,user:[`二次卡控:对照本段原始需求,找出原文里有、但当前故事尚未覆盖的能力。`,`有则用 req_set_stories 补故事或并入已有故事的 sourceRefs(能对上的挂真实子点 id);对不上条目的写进回答「待确认」,不要调用 req_set_outline、不要另造条目标题。`,``,`## 当前用户故事(摘要)`,o||`(尚无故事)`,``,Ge(n)?`${Ge(n)}\n`:``,`## 原始需求(第 ${t.index+1}/${l.length} 段${t.title?` · ${t.title}`:``})`,``,t.text].filter(Boolean).join(`
|
|
32
|
-
`),batchIndex:91+e,softCap:i,progressMsg:`原文卡控 ${e+1}/${l.length}`})}if(r.signal.aborted){Y(`已中断:已经写入的故事保留`,`info`);return}s=He(q.current?.outline??[],q.current?.stories??[]),W(96,`正在保存用户故事`);let u=await T(e.id,{status:`decomposed`,progress:{stage:`done`,done:100,total:100,message:`用户故事已生成`,at:new Date().toISOString()}});J(u);let d=he(u.outline).length-s.length,f=he(u.outline).length;if(Y(`生成用户故事完成:${u.stories.length} 个故事 · 需求点 ${d}/${f} 已挂`,`done`),B(`stories`),W(100,`用户故事已生成`),s.length){let e=s.map(e=>e.id).join(`、`);Y(`仍有 ${s.length} 个需求点未挂:${e}`,`info`),v(`用户故事已生成,仍有 ${s.length} 个需求点未挂`,`info`)}else v(`用户故事已生成,需求点已挂全`,`success`)}catch(t){let n=t instanceof Error?t.message:String(t);r.signal.aborted?(i=`stopped`,Y(`已中断:已经写入的故事保留`,`info`)):(i=`error`,R(n),Y(`生成用户故事失败:${n}`,`error`),await T(e.id,{replaceStories:!0,stories:[],check:null,ignoredGaps:[],testPoints:null,status:`decomposed`}).then(e=>J(e)).catch(()=>void 0))}finally{r.signal.aborted&&(i=`stopped`),Z(`stories`,i,i===`done`?`用户故事已生成`:i===`stopped`?`已中断:已经写入的故事保留`:`生成用户故事失败,详见活动日志`)}},[X,dr,Z,$,J,Y,Er,Xr,Q]),ri=(0,k.useCallback)(async(e=!1)=>{let t=typeof e==`boolean`?e:!!e.auto,n=typeof e==`object`&&!!e.fullScan,r=q.current;if(!r)return;if(!r.stories.length||r.status===`draft`){t||v(`请先成功生成用户故事,再审查`,`info`);return}let i=(r.check?.gaps?.length??0)>0||(r.ignoredGaps?.length??0)>0,a=n||!i;$n.current=a,er.current=0;let o=Te(r.check?.gaps??[]);tr.current=o,R(``),t||L(``),Y(t?`继续审查用户故事`:n?`开始全量扫描用户故事`:a?`开始审查用户故事`:`开始复审用户故事`,`stage`,t?`拆解完成后自动接续`:a?`全量检查,可发现新待确认`:`只刷新上轮清单,不新增待确认`),X(`audit`,a?`审查用户故事`:`复审用户故事`,100,`正在跑规则体检`);let s=new AbortController;bn.current=s;let c={status:`done`,message:`审查完成`};try{let e=Date.now();W(8,`正在跑规则体检`);let t=Ee(r),i=re(o.filter(e=>e.type===`uncovered-outline`),Te(t.gaps),r.ignoredGaps,{allowNew:!0}),l=[...o.filter(e=>e.type!==`uncovered-outline`),...i.gaps],u=await T(r.id,{check:{...t,gaps:l},progress:{stage:`audit`,done:18,total:100,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});J(u),Y(`规则体检:覆盖率 ${Math.round(t.coverage.rate*100)}%,${l.length} 项待确认`,`info`,`${r.outline.length} 条需求条目 · ${r.stories.length} 个故事 · 耗时 ${In(e)}`),W(18,`规则体检完成,等待模型评审`);let d=Tt?.review.trim()??``,f=Yr?O:null;if(!f||!d){Y(f?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),c.message=`没有配置模型,只保留规则结果`,await T(r.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:c.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),B(`check`);return}let p=!1,m=$(r,90),h=m.saveCheck;m.saveCheck=async e=>{p=!0,W(96,`正在写入审查结果`);let t={...e,gaps:Te(e.gaps)},n=await h(t);return Y(`模型体检:${n.check?.gaps.length??0} 项待确认`,`done`),n};let g=q.current??u,_=await Je(g.sourcePath);_.text||Y(`没有读到原始需求,只能依据需求条目摘句审查`,`info`),Y(`提交模型审查`,`tool`,`模型 ${f.model} · ${g.stories.length} 个故事 · 原文 ${_.text.length} 字`),W(22,`正在提交模型审查`);let ee=Ke({pending:qe(o,g.ignoredGaps),ignored:g.ignoredGaps??[]}),te=[`## 原始需求`,_.text?_.truncated?`${_.text}\n\n(原文共 ${_.total} 字,以上为前 ${_.text.length} 字,没看到的部分不要猜)`:_.text:`(未读到原始需求,只能依据下面的需求条目摘句判断)`,``,`## 需求条目`,g.outline.length?g.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
33
|
-
`):`(无)`,``,`## 用户故事(${g.stories.length} 条)`,"```json",JSON.stringify(g.stories,null,2),"```",...ee?[``,ee]:[]].join(`
|
|
34
|
-
`),ne=En(90);try{for await(let e of Xe(f,[{role:`system`,content:`${d}\n\n${St}`},{role:`user`,content:te}],s.signal,{tools:At.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>jt(e,t,m)}))e.type===`content`?(L(t=>t+e.delta),G(90,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(94,`模型正在提交审查结果`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(97,`审查结果已返回`))}finally{ne()}p||(Y(`模型没有提交体检结果,当前只保留规则结果`,`error`),v(`模型没有提交体检结果,只保留了规则检查`,`error`)),W(100,p?`模型评审完成`:`已保留规则结果`);let y=q.current?.check?.gaps.length??0,b=q.current?.ignoredGaps?.length??0,ie=er.current;p?(a?(c.message=n?`全量扫描完成,待确认 ${y}`:`全量审查完成,待确认 ${y}`,v(c.message,`success`)):(c.message=ie>0?`复审未新增;待确认 ${y} · 已忽略 ${b}(已抑制 ${ie} 条新报)`:`复审未新增;待确认 ${y} · 已忽略 ${b}`,v(c.message,`success`)),Y(c.message,`done`)):c.message=`模型没提交结果,已保留规则结果`,await T(r.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:c.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),B(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);s.signal.aborted?(c.status=`stopped`,Y(`已中断:规则体检结果已保留`,`info`)):(c.status=`error`,R(t),Y(`体检失败:${t}`,`error`))}finally{s.signal.aborted&&(c.status=`stopped`),Z(`audit`,c.status,c.status===`error`?`审查失败,详见活动日志`:c.message)}},[X,Z,$,Yr,J,Y,ir,Tt,O]),ii=(0,k.useCallback)(async()=>{let e=q.current,t=Xr();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){v(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=Tt?.fix.trim()??``;if(!r){v(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}R(``),L(``),Y(`开始补写选中条目`,`stage`,`勾选 ${n.length} 个缺口`),X(`fix`,`补写选中条目`,100,`正在按 ${n.length} 个勾选缺口补写`);let i=Date.now(),a=new AbortController;bn.current=a;let o={status:`done`,message:`补写完成`};try{W(5,`正在按 ${n.length} 个勾选缺口补写`),Y(`按 ${n.length} 个勾选缺口补写`,`info`,n.map(e=>`[${e.severity}] ${e.storyId||`全局`}|${e.title}`).join(`;`));let s=new Map(e.stories.map(e=>[e.id,e.title])),c=await Je(e.sourcePath),l=[`## 原始需求`,c.text?c.truncated?`${c.text}\n\n(原文共 ${c.total} 字,以上为前 ${c.text.length} 字,没看到的部分不要猜)`:c.text:`(未读到原始需求,只能依据需求条目与当前故事集判断)`,``,`## 需求条目(新增故事的 sourceRefs 只能引用这里的 id)`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
35
|
-
`):`(无)`,``,`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${s.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 疑问:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``,e.conclusion?.trim()?` 结论:${e.conclusion.trim()}`:``,e.outlineId?` 需求点:${e.outlineId}`:``].filter(Boolean).join(`
|
|
36
|
-
`)}).join(`
|
|
37
|
-
`),``,`说明:若某条带了「结论」,优先按结论改故事;结论与原文冲突时以原文为准并在回答里说明。`].join(`
|
|
38
|
-
`),u=$(e,90),d=!1,f=u.saveStories;u.saveStories=async e=>(d=!0,W(90,`正在写入补写结果`),f(e)),W(12,`正在提交模型补写`);let p=En(88);try{for await(let e of Xe(t,[{role:`system`,content:`${r}\n\n${St}`},{role:`user`,content:l}],a.signal,{tools:At.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>jt(e,t,u)}))e.type===`content`?(L(t=>t+e.delta),G(88,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(90,`模型正在提交补写`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(94,`补写结果已返回`))}finally{p()}if(!d){o.status=`error`,o.message=`模型没有提交补写结果,故事集保持不变`,Y(`模型没有提交补写结果,故事集保持不变`,`error`),v(`模型没有提交补写结果`,`error`);return}W(94,`已写入补写结果,正在重算覆盖率`);let m=q.current;if(m){let e=Ee(m),t=await T(m.id,{check:e,status:`decomposed`});J(t)}let h=Math.round((q.current?.check?.coverage.rate??0)*100);Y(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`,`覆盖率 ${h}% · 耗时 ${In(i)}`),await Q({progress:{stage:`done`,done:100,total:100,message:`补写完成`,at:new Date().toISOString()}},q.current).catch(()=>void 0),B(`check`),v(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);a.signal.aborted?(o.status=`stopped`,Y(`已中断:已经写入的改动保留`,`info`)):(o.status=`error`,o.message=t,R(t),Y(`补写失败:${t}`,`error`))}finally{a.signal.aborted&&(o.status=`stopped`),Z(`fix`,o.status,o.status===`error`?`补写失败:${o.message}`:o.message)}},[X,Z,$,J,Y,ir,Xr,Tt,Q]),ai=(0,k.useCallback)(async()=>{let e=q.current,t=Xr();if(!e||!t)return;if(!e.stories.length||e.status===`draft`){v(`请先成功生成用户故事,再生成测试点`,`info`);return}let n=Et?.generate.trim()??``;if(!n){v(`没有读到「${lt}」的「## 生成」段落`,`error`);return}R(``),L(``),Y(`开始生成测试点`,`stage`,`基于 ${e.stories.length} 个用户故事,五维覆盖 P0–P3`),X(`testpoints`,`生成测试点`,100,`正在整理用户故事,等待模型生成`),B(`points`),await Q({progress:{stage:`points`,done:5,total:100,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0);let r=Date.now();W(8,`正在整理用户故事`),Y(`整理用户故事,提交模型生成`,`info`,`${e.outline.length} 条需求条目 · ${e.stories.length} 个故事 · 模型 ${t.model}`);let i=new AbortController;bn.current=i;let a={status:`done`,message:`测试点已生成`};try{let o=$(e,90),s=!1,c=o.saveTestPoints;o.saveTestPoints=async e=>{s=!0,W(90,`正在写入测试点`);let t=await c(e);return Y(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let l=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求点(按条目;未挂故事的子点也需覆盖)`,ve(e.outline),``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
|
|
39
|
-
`);W(15,`正在提交模型生成`);let u=``,d=En(88);try{for await(let e of Xe(t,[{role:`system`,content:`${n}\n\n${St}`},{role:`user`,content:l}],i.signal,{tools:At.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>jt(e,t,o)}))e.type===`content`?(u+=e.delta,L(t=>t+e.delta),G(88,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(90,`模型正在提交测试点`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(94,`测试点已返回`))}finally{d()}if(!s){let t=Nt(u,e.stories.map(e=>e.id));t&&(await o.saveTestPoints(t),s=!0,Y(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!s)a.status=`error`,a.message=`模型没有提交测试点,原结果保持不变`,Y(`模型没有提交测试点,原结果保持不变`,`error`),v(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=q.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;Y(`测试点完成:${e.length} 条`,`done`,`P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)} · 耗时 ${In(r)}`),W(100,`已生成 ${e.length} 条`),a.message=`测试点已生成 ${e.length} 条`,await Q({progress:{stage:`done`,done:100,total:100,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},q.current).catch(()=>void 0),v(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a.status=`stopped`,Y(`已中断:已经生成的测试点保留`,`info`)):(a.status=`error`,a.message=t,R(t),Y(`生成测试点失败:${t}`,`error`))}finally{i.signal.aborted&&(a.status=`stopped`),Z(`testpoints`,a.status,a.status===`error`?`生成测试点失败:${a.message}`:a.message)}},[X,Z,$,Y,ir,Xr,Q,Et]),oi=(0,k.useCallback)(async()=>{let e=q.current;if(!e?.testPoints)v(`还没有测试点可导出`,`info`);else try{let t=tn.current;t.length||(t=await pr(e));let n=await dt(e,t);Y(`已导出 ${n}`,`done`)}catch(e){v(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Y,pr]),si=(0,k.useCallback)(async()=>{let e=q.current;if(!e?.testPoints){v(`还没有测试点可导出`,`info`);return}let t=tn.current;t.length||(t=await pr(e));let n=mt(e,t);Y(`已导出 ${n}`,`done`)},[Y,pr]),ci=(0,k.useCallback)(async e=>{let t=q.current;if(t)try{await Q({stories:e},t)}catch(e){v(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Q]),li=(0,k.useCallback)((e,t)=>{let n=q.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);ci(r)},[ci]),ui=(0,k.useCallback)(e=>{let t=q.current;t&&ci(t.stories.filter((t,n)=>n!==e))},[ci]),di=(0,k.useCallback)((e,t)=>{let n=q.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,ci(i))},[ci]),fi=(0,k.useCallback)((e,t)=>{let n=q.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};J(r),qr()},[J,qr]),pi=(0,k.useCallback)(e=>{let t=q.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};J(n),qr()},[J,qr]),mi=(0,k.useCallback)(async()=>{let e=q.current;if(e)try{await ke(e.id),a(gn(e.id)),a(Sn(e.id)),a(`reqanalysis.idealTitles.${e.id}`),Qn.current===e.id&&(Qn.current=``);let t=x.filter(t=>t.id!==e.id);Me(t),cr(t[0]??null),fr(`list`),v(`已删除分析记录`,`success`)}catch(e){v(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{hn(!1)}},[fr,x,cr]),hi=(0,k.useCallback)(()=>{let e=q.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=Re(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),v(`已导出 Markdown`,`success`)},[]),gi=(0,k.useCallback)(()=>{let e=q.current;if(!e?.check)return;let t=ft(e,e.check);v(`已导出 ${t}`,`success`)},[]),_i=(0,k.useCallback)(()=>{let e=q.current;if(!e?.check)return;let t=e.check.gaps.filter(e=>e.selected).map(e=>e.id),n=new Map(e.outline.map(e=>[e.id,(e.body||e.quote||e.title||``).trim()])),r=_t(e,e.check,{gapIds:t.length?t:void 0,outlineBodies:n,outlineTitles:Mr});v(`已导出 ${r}`,`success`)},[Mr]),vi=(0,k.useCallback)(()=>{bn.current?.abort()},[]);if(!e.ready)return(0,F.jsx)(nt,{label:`正在读取插件开关`});if(!e.on)return(0,F.jsx)(tt,{children:r(`reqAnalysis`)});if(b===null)return(0,F.jsx)(nt,{label:`正在连接需求分析服务`});if(!b)return(0,F.jsx)(tt,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(Vt)return(0,F.jsx)(nt,{label:`正在回到上次的分析`});let yi=w?.outline.filter(e=>Tr.has(e.id)).length??0,bi=(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,F.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,F.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,F.jsx)(`p`,{className:jn,children:`新建分析`}),(0,F.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,F.jsx)(ee,{options:rr,value:ct,onChange:e=>{pt(e),e&&Jr(e)},triggerTitle:ct||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,F.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,x.length,` 份分析`]})]}),ht?(0,F.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,ht,(0,F.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,je,` 之外的内容目录没有被移动。`]}):null]}),It?(0,F.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,F.jsx)(`span`,{className:`break-all`,children:It}),(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>R(``),children:`✕`})]}):null,(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,F.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>Cr(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${Ut===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>Cr(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${Ut===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),Ut===`story`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`label`,{className:`relative block`,children:[(0,F.jsx)(D,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,F.jsx)(`input`,{value:V,onChange:e=>Kt(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,F.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[vr,` 个故事`,H?` · 已选 ${H.ids.length}`:``]}),(0,F.jsx)(`button`,{type:`button`,disabled:!H,onClick:()=>{if(!H)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:H.docId,stories:H.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${kn} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,F.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[x.length,` 份分析 · `,vr,` 个故事`]})]}),(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:Ut===`doc`?x.length?(0,F.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:x.map(e=>{let t=nr(e.status);return(0,F.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,F.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>hr(e,`stories`),children:(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:S(e)}),(0,F.jsx)(E,{tone:t.tone,children:t.label})]}),(0,F.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,F.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,F.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,F.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,F.jsx)(`span`,{children:Pn(e.updatedAt)})]})]})}),(0,F.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:()=>hr(e,`stories`),children:[`用户故事`,(0,F.jsx)(D,{name:`chevronRight`,size:13})]}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`删除 ${S(e)}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{cr(e),hn(!0)},children:(0,F.jsx)(D,{name:`trash`,size:14})})]},e.id)})}):(0,F.jsx)(it,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析;先拆解需求条目,再生成用户故事。`}):yr.length?(0,F.jsx)(`div`,{className:`divide-y divide-stone-100`,children:yr.map(({doc:e,rows:t})=>{let n=Jt.includes(e.id),r=t.map(e=>e.story.id),i=H?.docId===e.id&&r.length>0&&r.every(e=>br.has(e));return(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${S(e)} 的全部故事`,checked:i,onChange:()=>Sr(e.id,r)}),(0,F.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>Yt(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,F.jsx)(D,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,F.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:S(e)}),(0,F.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,Pn(e.updatedAt)]})]}),(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>hr(e,`stories`),children:`打开分析`})]}),n?null:(0,F.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,F.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:br.has(t.id)&&H?.docId===e.id,onChange:()=>xr(e.id,t.id)}),(0,F.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>gr(e,t.id),children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,F.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,F.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,F.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,F.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,F.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,F.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,F.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,F.jsx)(it,{icon:`file`,title:V?`没有匹配的用户故事`:`还没有用户故事`,hint:V?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,F.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[Rt===`list`?bi:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,F.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:()=>{pt(``),R(``),fr(`list`)},children:[(0,F.jsx)(D,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,F.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:w?`用户故事 · ${S(w)}`:`用户故事`})]}),(0,F.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,F.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,F.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,F.jsx)(`p`,{className:jn,children:`分析记录`}),(0,F.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:x.length})]}),(0,F.jsx)(`div`,{className:`px-2 py-2`,children:x.length?(0,F.jsx)(`ul`,{className:`space-y-0.5`,children:x.map(e=>{let t=e.id===C,n=nr(e.status);return(0,F.jsx)(`li`,{children:(0,F.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:()=>cr(e),children:(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(_,{text:S(e),matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,F.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,F.jsx)(E,{tone:n.tone,children:n.label}),(0,F.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,F.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,F.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between border-b border-stone-100 px-3.5 py-2.5 text-left hover:bg-stone-50/80`,onClick:()=>{Hn(e=>{let t=!e;return l(un,t?`1`:`0`),t})},children:[(0,F.jsx)(`p`,{className:jn,children:`提示词`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:Vn?`收起`:`展开`})]}),Vn?(0,F.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(Rn,{name:we,ready:kr}),(0,F.jsx)(Rn,{name:Tt?.file??`用户故事审查提示词.md`,ready:t.on&&!!Tt?.review.trim()&&!!Tt?.fix.trim()}),(0,F.jsx)(Rn,{name:lt,ready:h.on&&!!Et?.generate.trim()})]}),(0,F.jsx)(`p`,{className:`mt-2 text-[11px] ${Yr?`text-stone-400`:`text-amber-700`}`,children:Yr?`模型:${O?.model}`:`还没配置模型`})]}):null]}),(0,F.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,F.jsx)(`p`,{className:jn,children:`动作`})}),(0,F.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,F.jsx)(et,{options:ur,values:w?.priorMemoryDocIds??[],placeholder:w?ur.length===0?`暂无同产品历史分析`:`选择历史分析`:`请先打开分析`,disabled:!w||ur.length===0||!!M,chips:!0,searchable:!0,searchPlaceholder:`搜索历史版本…`,onChange:e=>{w&&T(w.id,{priorMemoryDocIds:e}).then(e=>J(e)).catch(e=>{let t=e instanceof Error?e.message:String(e);v(t,`error`)})}}),(0,F.jsx)(`button`,{type:`button`,className:`${kn} w-full`,disabled:!w||!!M||!w.sourcePath||!Dr,onClick:()=>{(w?.outline??[]).some(e=>e.kind)||(w?.stories.length??0)>0?yn(!0):Zr()},children:M===`decompose`?`拆解需求中…`:(w?.outline??[]).some(e=>e.kind)||(w?.stories.length??0)>0?`重新拆解需求`:`拆解需求`}),(0,F.jsx)(`button`,{type:`button`,className:`${An} w-full`,disabled:!w||!!M||!w.sourcePath||!w.outline.length||w.status===`draft`||!Or,onClick:()=>{w?.stories.length?Tn(!0):ni()},children:M===`stories`?`生成故事中…`:w?.stories.length?`重新生成用户故事`:`生成用户故事`}),t.on?(0,F.jsx)(`button`,{type:`button`,className:`${An} w-full`,disabled:!w||!!M||!w.stories.length||w.status===`draft`,onClick:()=>void ri(),children:M===`audit`?`审查中…`:w?.check||(w?.ignoredGaps?.length??0)>0?`复审用户故事`:`用户故事审查`}):null,h.on?(0,F.jsx)(`button`,{type:`button`,className:`${An} w-full`,disabled:!w||!!M||!w.stories.length||w.status===`draft`,onClick:()=>{w?.testPoints?.points.length?Bn(!0):ai()},children:M===`testpoints`?`生成中…`:w?.testPoints?`重新生成测试点`:`生成测试点`}):null,M?(0,F.jsx)(`button`,{type:`button`,className:`${An} w-full`,onClick:vi,children:`中断`}):(0,F.jsx)(`button`,{type:`button`,className:`${An} w-full`,disabled:!w,onClick:hi,children:`导出 Markdown`}),w&&!M?(0,F.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:()=>hn(!0),children:`删除这份分析`}):null]})]}),(0,F.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,F.jsx)(`p`,{className:jn,children:`活动日志`}),Pt.length?(0,F.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>Ft([]),children:`清空`}):null]}),(0,F.jsx)(`div`,{ref:Xn,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:Pt.length?Pt.map(e=>e.kind===`stage`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2 pt-1.5 first:pt-0`,children:[(0,F.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium text-stone-500`,children:e.text}),(0,F.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-300`,children:Fn(e.at)}),(0,F.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`})]},e.id):(0,F.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,F.jsx)(`span`,{className:`mt-px shrink-0 text-[10px] tabular-nums text-stone-300`,children:Fn(e.at)}),(0,F.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,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:e.kind===`done`?`text-stone-700`:`text-stone-500`,children:e.text}),e.detail?(0,F.jsx)(`span`,{className:`mt-0.5 block break-all text-[10px] leading-relaxed text-stone-400`,children:e.detail}):null]})]},e.id)):(0,F.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,F.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[It?(0,F.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,F.jsx)(`span`,{className:`break-all`,children:It}),(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>R(``),children:`✕`})]}):null,P&&!M?(0,F.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border px-3 py-2 text-xs ${P.status===`done`?`border-emerald-200 bg-emerald-50 text-emerald-700`:P.status===`error`?`border-red-200 bg-red-50 text-red-700`:`border-amber-200 bg-amber-50 text-amber-700`}`,children:[(0,F.jsxs)(`span`,{className:`break-all`,children:[(0,F.jsxs)(`span`,{className:`font-medium`,children:[P.label,P.status===`done`?`已完成`:P.status===`error`?`失败`:`已中断`]}),(0,F.jsx)(`span`,{className:`ml-1.5 opacity-80`,children:P.message}),P.finishedAt?(0,F.jsxs)(`span`,{className:`ml-1.5 opacity-60`,children:[`· `,Pn(new Date(P.finishedAt).toISOString())]}):null]}),(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-60 transition-opacity hover:opacity-100`,"aria-label":`关闭上次任务提示`,onClick:ar,children:`✕`})]}):null,w?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(_,{text:S(w),matchAnchorWidth:!0,className:`min-w-0 flex-1 truncate px-1 py-0.5 text-[15px] font-semibold text-stone-800`}),M?(0,F.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),N?N.message:M===`decompose`?`拆解需求中`:M===`stories`?`生成故事中`:M===`audit`?`审查中`:M===`testpoints`?`生成测试点中`:M===`fix`?`补写中`:`处理中`,N&&N.total>0?(0,F.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(N.done,N.total)/N.total*100),`%`]}):null]}):null,(0,F.jsx)(E,{tone:nr(w.status).tone,children:nr(w.status).label})]}),M?(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${N?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N&&N.total>0?Math.round(Math.min(N.done,N.total)/N.total*100):void 0,children:(0,F.jsx)(`div`,{className:N&&N.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:N&&N.total>0?{width:`${Math.round(Math.min(N.done,N.total)/N.total*100)}%`}:void 0})})}):null,(0,F.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,F.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,F.jsx)(`span`,{className:`font-medium text-stone-600`,children:w.stories.length})]}),(0,F.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,F.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[yi,`/`,w.outline.length]}),` `,`覆盖`]}),t.on?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,F.jsx)(`span`,{className:`font-medium text-stone-600`,children:jr.length}),Ar?` · 已选 ${Ar}`:``]}),w.check?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,F.jsx)(`span`,{className:`font-medium text-stone-600`,children:w.check.coverage.total?`${Math.round(w.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,h.on?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,F.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,F.jsx)(`span`,{className:`font-medium text-stone-600`,children:w.testPoints?.points.length??0})]})]}):null,(0,F.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,w.sourcePath]}),wr?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,F.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`outline`,label:`需求条目`,count:Pr.length||w.outline.length},{id:`stories`,label:`用户故事`,count:w.stories.length},{id:`check`,label:`审查结果`,count:jr.length+Br.length},{id:`points`,label:`测试点`,count:w.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||h.on)).map(e=>{let t=z===e.id;return(0,F.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:()=>B(e.id),children:[e.label,(0,F.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,F.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[z===`stories`?Fr.length?(0,F.jsx)(`ul`,{className:`space-y-2`,children:Fr.map(e=>{let t=w.stories.findIndex(t=>t.id===e.id),n=t>=0?t:0;return(0,F.jsx)(nn,{story:e,index:n,total:w.stories.length,gaps:jr.filter(t=>t.storyId===e.id),outlineTitles:Nr,outlineOptions:w.outline,completenessHints:ge(e),busy:!!M,onSave:e=>li(n,e),onDelete:()=>ui(n),onMove:e=>di(n,e),onJumpOutline:Vr,domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${n}`)})}):(0,F.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,F.jsx)(it,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「拆解需求」整理条目,再点「生成用户故事」。`})}):null,z===`check`&&t.on?(0,F.jsx)(Lt,{check:w.check?{...w.check,gaps:jr}:null,stories:w.stories,outlineTitles:Mr,ignoredGaps:Br,busy:!!M,onToggleGap:fi,onToggleAll:pi,onFix:()=>void ii(),onReview:()=>void ri(),onFullScan:()=>void ri({fullScan:!0}),onExport:gi,onExportPending:_i,onIgnoreGap:e=>void Ur([e]),onIgnoreSelected:()=>{let e=jr.filter(e=>e.selected).map(e=>e.id);Ur(e)},onSaveGapConclusion:(e,t)=>void Kr(e,t),onRestoreIgnored:e=>void Wr(e),onPromoteIgnored:e=>void Gr(e)}):null,z===`points`&&h.on?(0,F.jsx)(Wt,{doc:w,idealTitles:$t,generating:M===`testpoints`,busy:!!M,promptReady:!!Et?.generate.trim(),onExportXmind:()=>void oi(),onExportMarkdown:()=>void si(),onJumpToRequirement:Hr}):null,z===`outline`?Pr.length?(0,F.jsx)(`ul`,{className:`space-y-2`,children:Pr.map(e=>{let t=!!Ir[e.parent.id],n=e.totalPoints>0&&e.coveredCount===e.totalPoints;return(0,F.jsxs)(`li`,{id:`req-outline-${e.parent.id}`,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-2 px-4 py-2.5 text-left`,onClick:()=>Lr(t=>({...t,[e.parent.id]:!t[e.parent.id]})),children:[(0,F.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${n?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,F.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.parent.id}),e.parent.title]}),(0,F.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`已整理需求点 `,e.coveredCount,`/`,e.totalPoints,` 已覆盖`,e.coveringStories.length?` · ${e.coveringStories.length} 个故事`:``]})]}),(0,F.jsx)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:t?`收起`:`展开`})]}),t?(0,F.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold text-stone-500`,children:[`已整理的需求点(`,e.points.length,`)`]}),e.points.length?(0,F.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:e.points.map(t=>{let n=Tr.has(t.id),r=t.kind===`query`?`查询`:t.kind===`mutate`?`修改`:``,i=!!Rr[t.id],a=ce(t,e.parent,e.points);return(0,F.jsxs)(`li`,{id:`req-outline-point-${t.id}`,className:`rounded-md border border-transparent text-xs text-stone-700`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1 text-left hover:bg-stone-50`,onClick:()=>zr(e=>({...e,[t.id]:!e[t.id]})),children:[(0,F.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${n?`bg-emerald-500`:`bg-amber-400`}`}),(0,F.jsx)(`span`,{className:`font-mono text-[10px] text-stone-400`,children:t.id}),r?(0,F.jsx)(`span`,{className:`rounded bg-stone-100 px-1 text-[10px] text-stone-500`,children:r}):null,(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),(0,F.jsx)(`span`,{className:n?`shrink-0 text-emerald-600`:`shrink-0 text-amber-600`,children:n?`已覆盖`:`未覆盖`})]}),(0,F.jsx)(`button`,{type:`button`,disabled:!!M,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] text-stone-500 hover:bg-stone-100 hover:text-[#3370ff] disabled:cursor-not-allowed disabled:opacity-40`,onClick:n=>{n.stopPropagation(),Qr(t,e.parent)},children:`变更需求点`}),(0,F.jsx)(`button`,{type:`button`,disabled:!!M,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] text-stone-500 hover:bg-stone-100 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-40`,onClick:e=>{e.stopPropagation(),Jn(t.id)},children:`删除`}),(0,F.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md px-1.5 py-1 text-[10px] text-stone-400 hover:bg-stone-100 hover:text-stone-600`,onClick:()=>zr(e=>({...e,[t.id]:!e[t.id]})),children:i?`收起`:`原文`})]}),i?(0,F.jsx)(`div`,{className:`mb-1 ml-4 mt-0.5`,children:(0,F.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-md bg-stone-50 px-2 py-1.5 text-[11px] leading-relaxed text-stone-600`,children:a.text||`(无原文切片)`})}):null]},t.id)})}):(0,F.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`尚无查询/修改子点;拆解时会按原文能力补上。`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold text-stone-500`,children:`需求文档条目内容`}),(0,F.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto whitespace-pre-wrap rounded-lg bg-stone-50 px-3 py-2 text-xs leading-relaxed text-stone-600`,children:e.parent.body||e.parent.quote||`(无原文切片)`})]}),e.coveringStories.length?(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold text-stone-500`,children:`覆盖故事`}),(0,F.jsx)(`ul`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:e.coveringStories.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`rounded-md border border-stone-200 bg-white px-2 py-0.5 text-[11px] text-stone-600 hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>{B(`stories`),requestAnimationFrame(()=>{document.getElementById(`req-story-${e.id}`)?.scrollIntoView({behavior:`smooth`,block:`nearest`})})},children:[e.id,` `,e.title]},e.id))})]}):null]}):null]},e.parent.id)})}):(0,F.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,F.jsx)(it,{icon:`file`,title:`还没有需求条目`,hint:`拆解时会按需求文档结构播种条目,再整理查询/修改需求点。`})}):null]}),I?(0,F.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,F.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,F.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:I})]}):null]}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,F.jsx)(it,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,F.jsxs)(p,{open:!!Un,onClose:()=>{M!==`change-point`&&(Wn(null),Kn(``))},className:`relative z-110`,children:[(0,F.jsx)(m,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,F.jsxs)(d,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[85vh] w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{Wn(null),Kn(``)},className:`absolute top-3.5 right-3.5 flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,"aria-label":`关闭`,children:`✕`}),(0,F.jsxs)(f,{className:`pr-8 text-base font-semibold text-stone-900`,children:[`变更需求点`,Un?(0,F.jsx)(`span`,{className:`ml-2 font-mono text-xs font-normal text-stone-400`,children:Un.pointId}):null]}),(0,F.jsx)(`p`,{className:`mt-3 text-[11px] text-stone-400`,children:`编辑或补充需求内容后点确认,由模型更新当前点,必要时在下方新增子点。保存后除非重新拆解,否则审查与生成故事不会改回原文。`}),(0,F.jsx)(`textarea`,{value:Gn,onChange:e=>Kn(e.target.value),spellCheck:!1,placeholder:`需求内容(可多行)`,className:`mt-2 min-h-[200px] w-full resize-y overflow-y-auto rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2.5 text-[12.5px] leading-relaxed text-stone-700 outline-none focus:border-[#4176e6]/40 focus:bg-white`}),(0,F.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{Wn(null),Kn(``)},className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-100`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,disabled:!Gn.trim()||!!M,onClick:()=>void ti(),className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-sm text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:bg-stone-300`,children:`确认`})]})]})})]}),(0,F.jsx)(g,{open:!!qn,title:`删除需求点`,message:`确认删除需求点「${qn?`${qn} ${w?.outline.find(e=>e.id===qn)?.title??``}`.trim():``}」?同父级后续子点序号会顺延;引用它的故事会去掉该引用。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Jn(null),onConfirm:()=>void ei()}),(0,F.jsx)(g,{open:mn,title:`删除分析记录`,message:`确认删除「${w?S(w):``}」?故事、需求条目、体检报告与测试点都会一起清掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>hn(!1),onConfirm:()=>void mi()}),(0,F.jsx)(g,{open:vn,title:`重新拆解需求`,message:`将按文档结构重新播种需求条目并整理查/改子点。当前 ${w?.stories.length??0} 个用户故事、审查结果与测试点会一并清空(条目 id 可能变化)。`,confirmLabel:`重新拆解需求`,onClose:()=>yn(!1),onConfirm:()=>{yn(!1),Zr()}}),(0,F.jsx)(g,{open:xn,title:`重新生成用户故事`,message:`将覆盖当前 ${w?.stories.length??0} 个用户故事,并清空审查结果与测试点;需求条目保留。`,confirmLabel:`重新生成用户故事`,onClose:()=>Tn(!1),onConfirm:()=>{Tn(!1),ni()}}),(0,F.jsx)(g,{open:zn,title:`重新生成测试点`,message:`将覆盖当前 ${w?.testPoints?.points.length??0} 条测试点,按现有用户故事重新生成。`,confirmLabel:`重新生成`,onClose:()=>Bn(!1),onConfirm:()=>{Bn(!1),ai()}})]})}export{zn as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=`0.1.31`;export{e as t};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{p as e}from"./app-config.Bg6v8zQQ.js";import{i as t,s as n}from"./plugins.SqANn3ZB.js";import{i as r,r as i}from"./case-types.CJ5PHz59.js";import{t as a}from"./export.joBT53eb.js";import{a as o,o as s,s as c,t as l}from"./case-template.F1Nv08GV.js";import{r as u,t as d}from"./case-fields.Dqkws1iX.js";import{h as f}from"./req-analysis.CIZ_cIJQ.js";import{_ as p,v as m}from"./project-docs.DAw9bzgk.js";var h=`/__tb_case_sessions`,g=`tw.case.sessions.v1`,_=!1;function v(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function y(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return r().some(e=>e.id===t),t}return r()[0]?.id??`functional`}function b(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:y(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function x(){try{let t=localStorage.getItem(e(g));return t?b(JSON.parse(t)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function S(t){try{localStorage.setItem(e(g),JSON.stringify(t))}catch{}}async function ee(){try{let e=await fetch(h,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();_=!0;let n=b(t.store);return S(n),n}}catch{}return _=!1,x()}function te(){return x()}async function C(e){if(S(e),_)try{await fetch(h,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function w(e){S(e),C(e)}function T(e){let t=Date.now(),n={id:v(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return w({sessions:[n,...x().sessions],activeId:n.id}),n}function E(e,t){let n=x(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return w(i),i}function D(e){return e.reqSource?e.reqSource:e.reqPath?{kind:`doc`,path:e.reqPath}:void 0}function ne(e){let t=[e.templateTitle||e.templateId?.split(`/`).pop()||`默认模板`,e.outputFormat.toUpperCase()],n=D(e);return n?.kind===`stories`?t.push(`${e.docTitle||`用户故事`} · ${n.storyIds.length} 条故事`):n?.kind===`doc`&&t.push(n.path.split(`/`).pop()||n.path),e.testPointIds?.length&&t.push(`${e.testPointIds.length} 条测试点`),t.join(` · `)}function O(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e,coverageRate:null,uncovered:[],writeNote:``};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title,i=typeof r==`string`?r.trim():``,a=t.覆盖需求率??t.coverageRate??t.coverage,o=null;if(typeof a==`number`&&Number.isFinite(a))o=Math.max(0,Math.min(100,Math.round(a)));else if(typeof a==`string`&&a.trim()){let e=parseInt(a.replace(/%/g,``),10);Number.isFinite(e)&&(o=Math.max(0,Math.min(100,e)))}let s=t.未覆盖说明??t.uncovered??t.omissions,c=Array.isArray(s)?s.map(e=>String(e).trim()).filter(Boolean):typeof s==`string`&&s.trim()?[s.trim()]:[],l=t.编写说明??t.note??t.summary,u=typeof l==`string`?l.trim():``;return{docTitle:i,cases:n,coverageRate:o,uncovered:c,writeNote:u}}}catch{return null}return null}function k(e){return e.replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`-`).slice(0,64)||`cases`}function A(e){let t=String(e??``).trim().split(/[/\\]/).pop()?.trim()||``;t=t.replace(/\.(xlsx|xls|docx|doc|md|txt|csv)$/i,``),t=t.replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).trim(),t=t.replace(/_\d{8}-\d{6}$/,``);for(let e of r()){let n=`_${e.label}用例`;if(t.endsWith(n)){t=t.slice(0,-n.length);break}}return/迭代版本$/u.test(t)?k(t):/v?\d+(?:\.\d+)*版本$/iu.test(t)?k(t.replace(/版本$/u,`迭代版本`)):/v\d+(?:\.\d+)+$/i.test(t)?k(`${t}迭代版本`):k(t)}function j(e){let t=A(e).replace(/迭代版本$/u,``).replace(/版本$/u,``).trim();return t=t.replace(/[\s_\-—·()()[\]【】]/g,``).toLowerCase(),t}function M(e,t){let n=j(e),r=j(t);return n.length<4||r.length<4?!1:n===r||n.includes(r)||r.includes(n)}function N(e=new Date){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}function P(e,t,n=new Date){let r=`_${i(t).label}用例`;return`${A(e)||`cases`}${r}_${N(n)}`}function F(e,t){let n=String(e||``).match(RegExp(`${t}-\\d+`,`i`));return n?n[0].toUpperCase():``}function I(e,t){if(e===t)return 0;if(!e)return 1;if(!t)return-1;let n=e.match(/^(.*?)(\d+)$/),r=t.match(/^(.*?)(\d+)$/);return n&&r&&n[1]===r[1]?Number(n[2])-Number(r[2]):e.localeCompare(t,`zh`)}function re(e){return f(e??``)}function L(e,t,n){if(!t.length)return 0;let r=t.length+1,i=-1,a=!1,o=[n.submodule&&e[n.submodule],n.module&&e[n.module],n.title&&e[n.title]];for(let e of o){let n=String(e??``).trim();if(n)for(let e=0;e<t.length;e++){let o=t[e];o&&(n===o||n.includes(o))&&o.length>i&&(i=o.length,r=e,a=!0)}}return a?r:t.length+1}function R(e,t,n){if(e.length<=1)return e;let r=u(t),i=r.requirement||d.requirement,a=r.no||d.no,o=r.title||d.title,s=n?.idealOrder??[],c={submodule:r.submodule,module:r.module,title:o},l=new Map((n?.storyIds??[]).map((e,t)=>[e.toUpperCase(),t])),f=new Map((n?.testPointIds??[]).map((e,t)=>[e.toUpperCase(),t]));return[...e].map((e,t)=>({row:e,index:t})).sort((e,t)=>{if(s.length){let n=L(e.row,s,c),r=L(t.row,s,c);if(n!==r)return n-r;if(n<s.length)return e.index-t.index}let n=F(e.row[i]??``,`US`)||F(e.row[o]??``,`US`),r=F(t.row[i]??``,`US`)||F(t.row[o]??``,`US`);if(l.size){let e=n?l.get(n)??l.size+1:l.size+2,t=r?l.get(r)??l.size+1:l.size+2;if(e!==t)return e-t}let u=I(n,r);if(u)return u;let d=F(e.row[o]??``,`TP`)||F(e.row[a]??``,`TP`),p=F(t.row[o]??``,`TP`)||F(t.row[a]??``,`TP`);if(f.size&&(d||p)){let e=d?f.get(d)??f.size+1:f.size+2,t=p?f.get(p)??f.size+1:f.size+2;if(e!==t)return e-t}return I(d,p)||I(String(e.row[a]??``),String(t.row[a]??``))||e.index-t.index}).map(e=>e.row)}function z(e,t){let n=[];for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}return n}function B(e,t=``,n){let r=i(e.caseType).label,o=e.templateHeaders.length>0?e.templateHeaders:[...a],s=e.outputFormat===`md`?`最终结果将保存为 Markdown 表格文件`:e.outputFormat===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,c=e.promptBody.trim();if(!c)throw Error(`请先在生成测试用例插件中选择提示词`);let l=e.templateBody?`\n\n### 用例模板:${e.templateTitle||e.templateId||``}\n${e.templateBody}`:`\n\n### 模板字段:${o.join(`、`)}`,d=e.reqBlock?`\n\n${e.reqBlock}`:``,f=e.testPointIds?.length??0,p=!!(n&&n.total>1),m=e.testPointBlock?`\n\n### 测试点(逐条覆盖,别合并成一条用例;${p?`本批 ${f||n.pointCount} 条,第 ${n.index}/${n.total} 批`:`共 ${f||`全部`} 条,下文为完整清单`})\n${e.testPointBlock}`:``,h=e.testPointBlock?p?`- 本批是第 ${n.index}/${n.total} 批,下文仅列出本批 ${f||n.pointCount} 条测试点:须逐条落到用例里;不要编写未列出的测试点;测试点的前置 / 步骤 / 预期分别对应用例的对应字段\n- 「覆盖需求率」「编写说明」只概括本批;系统会合并各批后再入库\n- 「未覆盖说明」只列本批清单里确实没写成用例的真实缺口(如缺规则、材料不足);本批已全部落成时必须输出空数组 \`[]\`;禁止写「本批仅覆盖 / 由其他批次负责 / 均已落成 / 不计入本批缺口」等分批说明(那不是缺口)\n`:`- 已选测试点共 ${f||`全部`} 条,正文已完整注入,须逐条落到用例里;测试点的前置 / 步骤 / 预期分别对应用例的对应字段。不要声称「材料未提供后半段测试点」\n`:``,g=K(o.includes(`备注`)?o:[...o,`备注`]),_=u(g),v=_.module,y=_.submodule,b=[];v&&b.push(`「${v}」对齐需求大模块 / 章节(Ideal 表填大模块原文;普通文档填对应章节名)`),y&&b.push(`「${y}」对齐需求小模块 / 小节原文,不要自造更细的名称`);let x=b.length>0?`- 字段对齐:${b.join(`;`)};用例数组严格按需求文档章节 / Ideal 小模块出现顺序输出\n`:`- 用例数组严格按需求文档章节 / 段落 / Ideal 小模块出现顺序输出(系统入库还会按此序重排)
|
|
2
|
-
`;return`${c}
|
|
3
|
-
${l}${d}${m}
|
|
4
|
-
|
|
5
|
-
【运行时约束 · 生成测试用例插件已启用】
|
|
6
|
-
- 本轮以「生成测试用例」插件所选提示词为准,不要再遵循工作台闲聊/系统提示词风格
|
|
7
|
-
- 用例类型:${r}
|
|
8
|
-
- ${s}
|
|
9
|
-
${h}- 需求名称默认可用「${t||`未命名需求`}」
|
|
10
|
-
- 「用例」数组必须按上文材料的需求顺序输出(Ideal 小模块行序 / 需求章节 / 文档段落 / 用户故事 / 测试点清单),不要按自造模块名、优先级或维度重排
|
|
11
|
-
${x}- 「用例」对象键必须与当前模板字段完全一致(另可多写「备注」「引用需求点」列):${g.join(`、`)}
|
|
12
|
-
- 仅输出一个 JSON 对象(可无代码围栏),结构为:
|
|
13
|
-
{"需求名称":"...","覆盖需求率":0-100,"未覆盖说明":["..."],"编写说明":"...","用例":[...]}
|
|
14
|
-
- 「引用需求点」必填:只填材料「需求条目」里真实的 \`RO-…\` id,格式为「RO-id 标题或原文摘录」(编号在前);不要填 \`US-…\`、测试点 id(\`TP-…\`)、\`全局测试点:…\`;只有用户故事时填该故事的「来源条目」RO,仍不要只写 US id
|
|
15
|
-
- 补充扩展场景:同一「引用需求点」,并在「备注」写「补充:…」;同点内正式用例在前、补充在后
|
|
16
|
-
- 「待业务确认 / 待确认」类不确定项也要写成用例,不要只丢进「未覆盖说明」:步骤写可执行操作,预期写「记录实际行为,规则待业务确认后回填判定口径」,并在「备注」写「待业务确认:…」(可与「补充:」并存)
|
|
17
|
-
- 「未覆盖说明」只写确实没写成用例的缺口;已用备注标过待业务确认的不要再重复列进「未覆盖说明」;某个需求点一条引用都没有时须在未覆盖说明点名
|
|
18
|
-
- 不要输出 JSON 以外的解释性正文;界面只会展示执行摘要,用例由系统静默入库`}function V(e,t=100){return Math.min(95,Math.max(1,Math.round(95*(1-Math.exp(-Math.max(0,e)/t)))))}function H(e=0,t){let n=Math.max(0,Math.floor(e)),r=!!(t&&t.total>1),i;if(r&&t){let e=V(n,80)/100;i=Math.min(95,Math.max(1,Math.round((t.index-1+e)/t.total*95)))}else i=V(n);return`正在编写用例…\n\n${r?`第 ${t.index}/${t.total} 批${t.label?` · ${t.label}`:``}\n`:``}进度约 ${i}% · 已用 ${n}s\n${r?`系统自动分批生成,全部完成后合并入库并给出覆盖率。`:`大文档可能需要数分钟;完成后将给出覆盖率与入库结果。`}`}function U(e){if(!e.ok)return[`**执行失败**`,``,e.error||`未知错误`,``,`可调整插件中的需求 / 模板 / 提示词后重试。`].join(`
|
|
19
|
-
`);let t=[`**执行成功**`,``,`- 需求名称:${e.title||`—`}`,`- 共编写:${e.count??0} 条用例`,`- 覆盖需求率:${e.coverageRate==null?`未给出(已按用例入库)`:`${e.coverageRate}%`}`];e.path&&t.push(`- 入库文件:用例管理/${e.path}`),e.writeNote&&t.push(``,`**编写说明**`,e.writeNote);let n=e.uncovered??[];if(t.push(``,`**未覆盖 / 未编写原因**`),n.length)for(let e of n)t.push(`- ${e}`);else t.push(`- 无(模型未声明未覆盖项;待业务确认项已写入用例「备注」)`);let r=e.fieldGaps??[];if(r.length){t.push(``,`**字段完整性检测**`);for(let e of r)t.push(`- ${e}`)}return t.join(`
|
|
20
|
-
`)}async function W(e){if(!t(`cases`))throw Error(n(`cases`));let r=i(e.caseType),l=`${P(e.title,e.caseType)}${e.outputFormat===`md`?`.md`:e.outputFormat===`csv`?`.csv`:`.xlsx`}`,u=e.headers.length?e.headers:[...a];return e.outputFormat===`md`?await m(`cases`,l,s(e.cases,e.title,u)):e.outputFormat===`csv`?await m(`cases`,l,o(e.cases,u)):await p(`cases`,l,await c(e.cases,u,r.label)),l}function G(e){return e.some(e=>/备注/.test(e))?e:[...e,`备注`]}function K(e){return e.some(e=>/引用需求点|需求点/.test(e)&&!/需求编号/.test(e))?e:[...e,`引用需求点`]}var q=/\bRO-[A-Za-z0-9_-]+\b/gi,J=/\bUS-\d+\b/gi;function Y(e,t=``){let n=String(e??``).trim(),r=String(t??``).replace(/\s+/g,` `).trim();return n?r?r===n||r.toUpperCase().startsWith(n.toUpperCase()+` `)||RegExp(`^${n}\\b`,`i`).test(r)?r:`${n} ${r}`:n:r}function X(e,t){let n=[],r=new Set;for(let i of String(e??``).matchAll(t)){let e=/^US-/i.test(i[0])?i[0].toUpperCase():i[0].replace(/^ro-/i,`RO-`),t=e.toUpperCase();r.has(t)||(r.add(t),n.push(e))}return n}function ie(e,t){let n=String(e??``).trim();if(!n)return``;n=n.replace(/全局测试点\s*[::]\s*/g,``).replace(/来源故事\s*[::]\s*/gi,``).replace(/\s+/g,` `).trim();let r=X(n,q),i=X(n,J),a=t?.outlineById,o=t?.storySourceRefs,s=e=>{let t=a?.get(e)??a?.get(e.toUpperCase());if(!t&&a){for(let[n,r]of a)if(n.toUpperCase()===e.toUpperCase()){t=r;break}}return Y(e,(t?.quote||t?.title||``).replace(/\s+/g,` `).trim())};if(r.length)return r.map(s).join(`;`);if(i.length&&o){let e=[],t=new Set;for(let n of i){let r=o.get(n)??o.get(n.toUpperCase())??[];for(let n of r){let r=n.toUpperCase();t.has(r)||(t.add(r),e.push(s(n)))}}if(e.length)return e.join(`;`)}if(i.length&&!r.length){let e=n;for(let t of i)e=e.replace(new RegExp(t,`ig`),` `);return e=e.replace(/[/||,,;;]+/g,` `).replace(/\s+/g,` `).trim(),e||n}return n}function ae(e){let t=new Map,n=String(e??``).split(/\n/);for(let e=0;e<n.length;e++){let r=n[e]??``,i=r.match(/\*\*(RO-[A-Za-z0-9_-]+)\*\*\s*(.+)?$/)||r.match(/\b(RO-[A-Za-z0-9_-]+)\b\s+(.+)$/);if(!i)continue;let a=i[1],o=(i[2]??``).replace(/\*\*/g,``).trim(),s=``,c=(n[e+1]??``).match(/^\s*>\s*(.+)$/);c&&(s=c[1].trim()),!o&&s&&(o=s.slice(0,80)),t.has(a)||t.set(a,{title:o,quote:s||void 0})}return t}function oe(e){let t=new Map,n=String(e??``).split(/^###\s+/m).slice(1);for(let e of n){let n=e.match(/^(US-\d+)\b/);if(!n)continue;let r=n[1],i=e.match(/\*\*来源条目\*\*[::]\s*(.+)/);if(!i)continue;let a=X(i[1],q);a.length&&t.set(r,a)}return t}function se(e,t,n){let r=u(t).reqCite||t.find(e=>/引用需求点|需求点/.test(e)&&!/需求编号/.test(e));return r?e.map(e=>{let t=e[r];if(t==null||!String(t).trim())return e;let i=ie(String(t),n);return i===String(t).trim()?e:{...e,[r]:i}}):e}var ce=/待业务确|待确认|业务确认/;function Z(e){return e.find(e=>/备注/.test(e))??`备注`}function Q(e){return e.find(e=>/用例标题|测试分项目|用例名称|标题/.test(e))??e.find(e=>e.includes(`标题`))??`用例标题`}function le(e){for(let t of[`备注`,`备注说明`,`说明`,`remark`,`note`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return``}function ue(e,t,n){let r=Z(n),i=Q(n),a=[],o=[];for(let e of t){let t=String(e??``).trim();if(!t||!ce.test(t)){t&&a.push(t);continue}let s=t.replace(/^[-*·\s]+/,``).split(/[。;;\n]/)[0]?.trim()||t,c=(s.length>48?`${s.slice(0,48)}…`:s).replace(/^待业务确认[::]\s*/u,``),l={};for(let e of n)l[e]=``;l[i]=c||`待业务确认项`,n.includes(`优先级`)&&(l.优先级=`P2`),n.includes(`用例类型`)&&(l.用例类型=`功能测试`);let u=n.find(e=>/步骤/.test(e)),d=n.find(e=>/预期|期望|结果标准/.test(e));u&&(l[u]=`1、按需求描述完成相关操作
|
|
21
|
-
2、记录系统实际行为与提示文案`),d&&(l[d]=`记录实际行为;业务规则确认前不做通过/失败判定,确认后回填判定口径`),l[r]=t.startsWith(`待业务确认`)?t:`待业务确认:${t}`,o.push(l)}return{cases:[...e,...o],uncovered:a}}function de(e,t){let n=Z(t);return e.map(e=>{if(!e||typeof e!=`object`)return e;let t={...e};if(!String(t[n]??``).trim()){let e=le(t);e&&(t[n]=e)}return t})}function fe(e){let t=String(e||``).trim();return!t||/本批仅覆盖|本批只覆盖|本批只负责|本批仅负责/.test(t)||/由其他批次|其他批次负责|其余批次|后续批次/.test(t)||/不计入本批缺口|不算本批缺口|非本批缺口/.test(t)||/均已落成用例|均已写成用例|本批.*全部落成|本批测试点.*均已/.test(t)||/指定的\s*\d+\s*条测试点/.test(t)}function pe(e){if(!e.length)return null;let t=[],n=[],r=new Set,i=[],a=0,o=0,s=``;for(let c of e){!s&&c.docTitle&&(s=c.docTitle),Array.isArray(c.cases)&&t.push(...c.cases);for(let e of c.uncovered){let t=e.trim();!t||r.has(t)||fe(t)||(r.add(t),n.push(t))}if(c.writeNote.trim()&&i.push(c.writeNote.trim()),c.coverageRate!=null&&Number.isFinite(c.coverageRate)){let e=Math.max(1,c.cases.length||1);a+=c.coverageRate*e,o+=e}}return t.length?{docTitle:s,cases:t,coverageRate:o>0?Math.round(a/o):null,uncovered:n,writeNote:i.length?i.length===1?i[0]:i.map((e,t)=>`(第 ${t+1} 批)${e}`).join(`
|
|
22
|
-
`):``}:null}async function $(e,t,n,r){let o=K(G(t.templateHeaders.length>0?t.templateHeaders:[...a])),s=ue(e.cases,e.uncovered,o),c=de(s.cases,o),f=D(t),p=f?.kind===`stories`?f.storyIds:void 0,m=re(t.reqBlock),h=ae(t.reqBlock??``),g=oe(t.reqBlock??``),_=R(se(l(c,o),o,{outlineById:h,storySourceRefs:g}),o,{storyIds:p,testPointIds:t.testPointIds,idealOrder:m});if(r?.renumber||m.length){let e=u(o).no||d.no;o.includes(e)&&_.forEach((t,n)=>{t[e]=String(n+1)})}let v=(n||t.docTitle||``).trim()||e.docTitle||i(t.caseType).label,y=z(_,o);try{let n=await W({cases:_,headers:o,caseType:t.caseType,outputFormat:t.outputFormat,title:v}),r=U({ok:!0,title:v,path:n,count:_.length,coverageRate:e.coverageRate,uncovered:s.uncovered,writeNote:e.writeNote,fieldGaps:y});return{ok:!0,path:n,count:_.length,title:v,coverageRate:e.coverageRate,uncovered:s.uncovered,writeNote:e.writeNote,fieldGaps:y,summary:r}}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,error:t,summary:U({ok:!1,error:t})}}}async function me(e,t,n){let r=O(e);if(!r){let e=`未能解析出用例结果,未写入文件`;return{ok:!1,error:e,summary:U({ok:!1,error:e})}}return $(r,t,n)}async function he(e,t,n){let r=[];for(let t of e){let e=O(t.raw);if(!e){let e=`第 ${t.index}/${t.total} 批未能解析出用例结果,未写入文件`;return{ok:!1,error:e,summary:U({ok:!1,error:e})}}r.push(e)}let i=pe(r);if(!i){let e=`各批均未解析出用例,未写入文件`;return{ok:!1,error:e,summary:U({ok:!1,error:e})}}return $(i,t,n,{renumber:!0})}export{H as a,ne as c,te as d,w as f,j as i,T as l,M as n,me as o,E as p,P as r,he as s,B as t,ee as u};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var e=`/__tb_reqanalysis`,t=`需求分析提示词.md`,n=`需求分析`,r={draft:{label:`待拆解`,tone:`gray`},decomposed:{label:`已拆解`,tone:`blue`},checked:{label:`已审查`,tone:`amber`},accepted:{label:`已验收`,tone:`green`}},i={P0:`red`,P1:`amber`,P2:`gray`},a={"uncovered-outline":`待确认·未覆盖`,"pending-confirm":`待确认`,"missing-field":`字段缺失`,"missing-scenario":`场景遗漏`,"missing-dimension":`维度缺失`,"untestable-acceptance":`验收不可测`,conflict:`与原文冲突`,"over-split":`过度拆分`,other:`其它`},o=new Set([`uncovered-outline`,`pending-confirm`,`conflict`,`other`]);function s(e){return o.has(e.type)}function c(e){return e.filter(s)}var l={high:`高`,medium:`中`,low:`低`},u={high:`red`,medium:`amber`,low:`gray`},d=[{key:`permission`,label:`权限与角色`,keywords:[`权限`,`角色`,`授权`,`越权`,`未登录`,`登录`,`管理员`,`普通用户`],hint:`补充不同角色 / 未登录 / 越权访问时这条流程的行为。`},{key:`boundary`,label:`边界值`,keywords:[`边界`,`上限`,`下限`,`最大`,`最小`,`长度`,`超长`,`字数`,`为空`,`空值`],hint:`补充字段长度、数量上限、刚好等于阈值时的表现。`},{key:`concurrency`,label:`并发与幂等`,keywords:[`并发`,`重复`,`幂等`,`同时`,`加锁`,`冲突`,`重复提交`],hint:`补充重复提交、多人同时操作同一数据时的结果。`},{key:`empty`,label:`空数据`,keywords:[`空数据`,`无数据`,`没有数据`,`空列表`,`暂无`,`空态`],hint:`补充列表为空、首次使用、数据被清空时的空态。`},{key:`failure`,label:`超时与失败`,keywords:[`超时`,`失败`,`异常`,`错误`,`重试`,`断网`,`不可用`,`降级`,`回滚`],hint:`补充依赖超时、接口失败、网络中断时的提示与回滚。`},{key:`i18n`,label:`国际化与时区`,keywords:[`国际化`,`时区`,`多语言`,`语言`,`翻译`,`utc`,`夏令时`],hint:`补充跨时区时间展示、多语言文案与本地化格式。`}],f=/创建|新增|新建|保存|提交|删除|编辑|修改|更新|上传|导入|导出|发布|审批|撤回|绑定|解绑|发送|支付|下单|配置|启停|启用|停用/;async function p(t,n){let r=await fetch(`${e}${t}`,{...n,headers:n?.body===void 0?void 0:{"Content-Type":`application/json`,...n?.headers}}),i=await r.json().catch(()=>({}));if(!r.ok||i.ok===!1)throw Error(i.error||`HTTP ${r.status}`);return i}async function ee(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function te(){return(await p(`/list`)).docs??[]}async function ne(e){return(await p(`/create`,{method:`POST`,body:JSON.stringify(e)})).doc}async function re(e,t){return(await p(`/`,{method:`PUT`,body:JSON.stringify({id:e,...t})})).doc}async function ie(e){await p(`/delete`,{method:`POST`,body:JSON.stringify({id:e})})}async function ae(){try{let e=await p(`/prompt`),t=e.decompose??``,n=e.stories??``;return{file:e.file||`需求分析提示词.md`,exists:e.exists===!0,decompose:t,stories:n||t,audit:e.audit??``,fix:e.fix??``}}catch(e){return{file:t,exists:!1,decompose:``,stories:``,audit:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function oe(e){return await p(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}async function m(e){return(await le(e)).content}async function se(e,t=2e4){try{let n=(await m(e)).trim();return{text:n.slice(0,t),total:n.length,truncated:n.length>t}}catch{return{text:``,total:0,truncated:!1}}}async function ce(){return(await p(`/sources`)).files??[]}async function le(e){return p(`/source?path=${encodeURIComponent(e)}`)}var ue=/[\s\p{P}\p{S}]+/gu;function h(e){return String(e??``).toLowerCase().replace(ue,``)}function g(e){return Array.from(new Set(e.map(e=>String(e??``).trim()).filter(Boolean)))}function _(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function v(e,t=30,n=500){return Array.isArray(e)?e.map(e=>_(e,n)).filter(Boolean).slice(0,t):[]}function y(e){let t=2166136261,n=String(e??``);for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function de(e){return y(String(e??``))}function b(e,t=80){return String(e??``).replace(/\s+/g,` `).trim().slice(0,t)}function fe(e){let t=String(e.sourceTitle||e.sourcePath||``).trim();if(t){let e=t.split(/[/\\]/).pop()?.trim();if(e)return e}return String(e.title||``).trim()||`未命名文档`}function pe(e){return b((String(e??``).split(/[/\\]/).pop()?.replace(/\.[^.]+$/,``).trim()||``).replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).trim())||`未命名需求`}function x(e){return String(e.sourceTitle||e.title||``).trim()||pe(e.sourcePath)}function me(e){let t=String(e??``).split(/[/\\]/).pop()?.trim()||``;return t=t.replace(/\.(xlsx|xls|docx|doc|md|txt|csv)$/i,``),t.replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).replace(/迭代版本$/u,``).replace(/版本$/u,``).trim()}function S(e){let t=me(e);return t=t.replace(/v?\d+(?:\.\d+)*/gi,``),t.replace(/[\s_\-—·()()[\]【】]+/gu,``).toLowerCase()}function C(e){let t=me(e),n=/v(\d+(?:\.\d+)*)/i.exec(t)||/(\d+(?:\.\d+)+)/.exec(t);return n?.[1]?n[1].split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0}):null}function w(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]??0,i=t[r]??0;if(n!==i)return n-i}return 0}function he(e,t){let n=x(e),r=S(n),i=C(n);return!r||!i?[]:t.filter(t=>{if(t.id===e.id)return!1;let n=x(t);if(S(n)!==r)return!1;let a=C(n);return a?w(a,i)<0:!1}).sort((e,t)=>w(C(x(e))??[],C(x(t))??[]))}function ge(e){let t=[];for(let n of e){let e=x(n);for(let r of A(n.outline))t.push({docId:n.id,docLabel:e,point:r})}return t}function T(e){let t=String(e??``).toLowerCase().replace(/\s+/g,` `).trim();if(!t)return[];let n=[];for(let e of t.matchAll(/[a-z0-9_]{2,}|[\u4e00-\u9fff]{2}/gu))n.push(e[0]);let r=t.replace(/[^\u4e00-\u9fff]/g,``);for(let e=0;e<r.length-1;e++)n.push(r.slice(e,e+2));return[...new Set(n)].slice(0,80)}var _e=40,ve=7e3;function ye(e,t,n){if(!t.length)return[];let r=Math.max(1,n?.maxItems??_e),i=Math.max(200,n?.maxChars??ve),a=T(e),o=String(e??``).toLowerCase();if(!a.length&&!o.trim())return[];let s=[];for(let e of t){let t=e.point.title||``,n=(e.point.quote||e.point.body||``).slice(0,200);`${t} ${n}`.toLowerCase();let r=0;t&&o.includes(t.toLowerCase())&&(r+=8),n&&n.length>=4&&o.includes(n.toLowerCase().slice(0,40))&&(r+=5);let i=T(`${t} ${n}`);for(let e of i)a.includes(e)&&(r+=e.length>=3?2:1);r<=0||s.push({...e,score:r})}s.sort((e,t)=>t.score-e.score||e.docLabel.localeCompare(t.docLabel,`zh`)||e.point.id.localeCompare(t.point.id));let c=[],l=0;for(let e of s){if(c.length>=r)break;let t=E(e);if(c.length>0&&l+t.length+1>i)break;c.push(e),l+=t.length+1}return c}function E(e){let t=e.point.kind===`query`?`查询`:e.point.kind===`mutate`?`修改`:`子点`,n=(e.point.quote||e.point.body||``).replace(/\s+/g,` `).trim().slice(0,120);return`- [${e.docLabel}] ${e.point.id} [${t}] ${e.point.title}${n?`(${n})`:``}`}function be(e){return e.length?[`## 历史迭代需求条目(检索参考,勿当作本版文档条目 id)`,`来源版本:${[...new Set(e.map(e=>e.docLabel))].join(`、`)}。下列 id 属于历史分析,禁止写入本版 sourceRefs;仅作能力对照与延伸参考。`,...e.map(E)].join(`
|
|
2
|
-
`):``}function xe(e,t){if(!e?.length)return[];let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t);e&&A(e.outline).length&&r.push(e)}return r}function D(e){let t=String(e??``).trim();return t?!!(/^"+,{2,}/.test(t)||/^,{2,}/.test(t)&&/(待开发|已开发|需求\s*,\s*高|v\d+\.\d+)/.test(t)||!/【/.test(t)&&!/^\d+[、.]/.test(t)&&/,/.test(t)&&/(待开发|已关闭|已完成|需求\s*,\s*[高低中]|v\d+\.\d+|^\d{4}年\d{1,2}月)/.test(t)):!1}function Se(e){let t=String(e??``);if(!t)return``;if(t.startsWith(`"`)){let e=1,n=``;for(;e<t.length;){let r=t[e];if(r===`"`){if(t[e+1]===`"`){n+=`"`,e+=2;continue}return n}n+=r,e+=1}return n}let n=t.search(/,{2,}|(?:,\s*(?:待开发|需求\s*,|v\d+))/);return(n>=0?t.slice(0,n):t).trim()}function Ce(e){let t=String(e??``),n=t.search(/"\s*,{2,}/);n>=0&&(t=t.slice(0,n));let r=t.split(`
|
|
3
|
-
`),i=[];for(let e of r){if(D(e))break;let t=e.search(/"\s*,{2,}/);if(t>=0){i.push(e.slice(0,t));break}i.push(e)}return i.join(`
|
|
4
|
-
`).replace(/^"/,``).replace(/"$/,``).trim()}function we(e){let t=Ce(e.body).slice(0,4e3),n=b(t.match(/【([^】\n]{1,40})】/)?.[1]||e.title||e.small);return{...e,title:n||e.small,body:t||`【${n||e.small}】`}}function O(e){let t=String(e??``).replace(/\r\n/g,`
|
|
5
|
-
`).trim();if(!t||!t.split(`
|
|
6
|
-
`).find(e=>/大模块/.test(e)&&/小模块/.test(e)))return[];let n=[],r=new Set,i=null,a=()=>{i&&=(n.push(we(i)),null)};for(let e of t.split(`
|
|
7
|
-
`)){if(/^#{1,3}\s/.test(e)){a();continue}if(/^大模块/.test(e))continue;let t=e.match(/^"?([^,"\n]{1,40})"?,"?([^,"\n]{1,40})"?,([\s\S]*)$/);if(t){let e=t[1].trim(),n=t[2].trim();if(!n||n===`小模块`||e===`大模块`||/[。;;]/.test(n)||n.length>30||(a(),r.has(n)))continue;r.add(n),i={big:e,small:n,title:n,body:Se(t[3]||``)}}else if(i){if(D(e)){a();continue}let t=e.search(/"\s*,{2,}/);if(t>=0){let n=e.slice(0,t);i={...i,body:i.body?`${i.body}\n${n}`:n},a();continue}i={...i,body:i.body?`${i.body}\n${e}`:e}}}return a(),n}function Te(e){let t=O(e);if(t.length)return t.map(e=>({title:e.small||e.title,body:e.body||`【${e.title}】`,quote:(e.body||e.title).replace(/\s+/g,` `).slice(0,80)}));let n=String(e??``).replace(/\r\n/g,`
|
|
8
|
-
`).trim();if(!n)return[];let r=[],i=/^(概述|简介|目录|修订|附录|背景|术语|参考)/,a=n.split(/(?=^#{2,3}\s+)/m).filter(e=>e.trim());if(a.length>1||/^#{2,3}\s+/m.test(n)){for(let e of a){let t=e.match(/^#{2,3}\s+(.+?)\s*$/m);if(!t)continue;let n=b(t[1]??``);if(!n||n.length>40||i.test(n))continue;let a=e.replace(/^#{2,3}\s+.+?\s*\n?/,``).trim().slice(0,4e3);(a||!r.some(e=>e.title===n))&&r.push({title:n,body:a||n,quote:(a||n).replace(/\s+/g,` `).slice(0,80)})}if(r.length)return k(r)}return k(Z(e).map(e=>({title:e,body:e,quote:e.slice(0,80)})))}function k(e){let t=new Set,n=[];for(let r of e){let e=r.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``);e&&!t.has(e)&&(t.add(e),n.push(r))}return n}function Ee(e,t=[]){let n=Te(e);if(!n.length)return t.filter(e=>!e.kind);let r=new Map(t.filter(e=>!e.kind&&!e.parentId).map(e=>[e.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``),e])),i=new Set(t.map(e=>e.id)),a=[];n.forEach((e,t)=>{let n=e.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``),o=r.get(n);if(o){a.push({...o,title:e.title,quote:e.quote||o.quote,body:e.body||o.body,kind:void 0,parentId:void 0});return}let s=`RO-E-${t+1}`,c=1;for(;i.has(s);)s=`RO-E-${t+1}-${c++}`;i.add(s),a.push({id:s,title:e.title,quote:e.quote,body:e.body})});let o=new Set(a.map(e=>e.id)),s=t.filter(e=>e.parentId&&o.has(e.parentId));return[...a,...s]}function A(e){let t=e.filter(e=>e.kind&&e.parentId);return t.length?t:e.filter(e=>!e.parentId)}function De(e,t){let n=new Set(t.flatMap(e=>e.sourceRefs));return A(e).filter(e=>!n.has(e.id))}function Oe(e,t=12){let n=Math.max(1,Math.floor(t)||12),r=A(e);if(!r.length)return[];let i=e.filter(e=>!e.parentId&&!e.kind),a=new Map(i.map(e=>[e.id,e])),o=new Map,s=[];for(let e of r){let t=e.parentId||``;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=[],l=(e,t)=>{for(let r=0;r<t.length;r+=n)c.push({parent:e,mustCover:t.slice(r,r+n)})};for(let e of i){let t=o.get(e.id);t?.length&&l(e,t)}return s.length&&l(null,s),c}function ke(e,t){let n=String(e??``);if(!n)return 2**53-1;let r=q(t,n);return r>=0?r:2**53-1}function j(e,t){if(t.length<=1)return[...t];let n=e.body||e.quote||``;return[...t].map((e,t)=>({p:e,index:t,rank:ke(n,e)})).sort((e,t)=>e.rank===t.rank?e.index-t.index:e.rank-t.rank).map(e=>e.p)}function M(e,t){return`${e}-${t}`}function N(e,t){return e.filter(e=>e.parentId===t)}function P(e,t,n){let r=new Map,i=n.map((e,n)=>{let i=M(t,n+1),a=e.id;a&&!a.startsWith(`__new_`)&&a!==i&&r.set(a,i);let o={id:i,title:e.title,quote:e.quote,kind:e.kind,parentId:t};return e.body&&(o.body=e.body),o}),a=e.filter(e=>e.parentId!==t),o=a.findIndex(e=>e.id===t);return{outline:o<0?[...a,...i]:[...a.slice(0,o+1),...i,...a.slice(o+1)],idMap:r}}function F(e,t){let n=N(e,t.id);if(!n.length)return{outline:[...e],idMap:new Map};let r=j(t,n);return P(e,t.id,r)}function Ae(e){let t=[...e],n=new Map,r=t.filter(e=>!e.parentId&&!e.kind);for(let e of r){let r=F(t,e);t=r.outline;for(let[e,t]of r.idMap)n.set(e,t)}return{outline:t,idMap:n}}function I(e,t){let n=e.find(e=>e.id===t);if(!n?.parentId||!n.kind)return{outline:[...e],pointId:t,idMap:new Map,parentId:``,error:`必须是已有的查询/修改子点`};let r=e.find(e=>e.id===n.parentId&&!e.parentId&&!e.kind);if(!r)return{outline:[...e],pointId:t,idMap:new Map,parentId:n.parentId,error:`找不到所属需求条目`};if(N(e,r.id).every(e=>e.id.startsWith(`${r.id}-`)))return{outline:[...e],pointId:t,idMap:new Map,parentId:r.id};let i=F(e,r),a=i.idMap.get(t)??t;return{outline:i.outline,pointId:a,idMap:i.idMap,parentId:r.id}}function L(e,t){let n=new Map;for(let[r,i]of e)n.set(r,t.get(i)??i);for(let[e,r]of t)n.has(e)||n.set(e,r);return n}function je(e,t,n){let r=I(e,t);if(r.error)return{outline:[...e],idMap:new Map,addedIds:[],error:r.error.includes(`必须是`)?`afterId 必须是已有的查询/修改子点`:r.error};if(!n.length)return{outline:r.outline,idMap:r.idMap,addedIds:[]};let i=r.parentId,a=N(r.outline,i),o=a.findIndex(e=>e.id===r.pointId);if(o<0)return{outline:r.outline,idMap:r.idMap,addedIds:[],error:`找不到锚点子点`};let s=n.map((e,t)=>{let n={id:`__new_${t}`,title:e.title,quote:e.quote,kind:e.kind,parentId:i};return e.body&&(n.body=e.body),n}),c=[...a.slice(0,o+1),...s,...a.slice(o+1)],l=P(r.outline,i,c),u=n.map((e,t)=>M(i,o+2+t));return{outline:l.outline,idMap:L(r.idMap,l.idMap),addedIds:u}}function Me(e,t){let n=I(e,t);if(n.error)return{outline:[...e],idMap:new Map,removedId:t,removedIds:new Set([t]),error:n.error.includes(`必须是`)?`只能删除查询/修改子点`:n.error};let r=n.parentId,i=n.pointId,a=new Set([t,i]);for(let[e,t]of n.idMap)(t===i||e===i)&&a.add(e);let o=N(n.outline,r).filter(e=>e.id!==i),s=P(n.outline,r,o),c=new Map([...n.idMap].filter(([e,t])=>!a.has(e)&&!a.has(t)));return{outline:s.outline,idMap:L(c,s.idMap),removedId:i,removedIds:a}}function Ne(e,t,n){let r=e.findIndex(e=>e.id===t);if(r<0)return{outline:[...e],error:`找不到需求点`};let i=e[r];if(!i.parentId||!i.kind)return{outline:[...e],error:`只能修改查询/修改子点的原文`};if(n.kind&&n.kind!==`query`&&n.kind!==`mutate`)return{outline:[...e],error:`kind 只能是 query 或 mutate`};let a=[...e],o={...i,quote:n.quote};return n.title!==void 0&&n.title.trim()&&(o.title=n.title.trim()),n.kind&&(o.kind=n.kind),n.body!==void 0&&(n.body?o.body=n.body:delete o.body),a[r]=o,{outline:a}}function Pe(e,t,n=new Set){if(!t.size&&!n.size)return e;let r=e=>n.has(e)?null:t.get(e)??e,i=e=>g(e.map(r).filter(e=>!!e)),a=e.stories.map(e=>({...e,sourceRefs:i(e.sourceRefs)})),o=e=>{if(!e.outlineId)return e;let t=r(e.outlineId);return t===e.outlineId?e:t==null?{...e,outlineId:void 0}:{...e,outlineId:t}},s=e.check?{...e.check,gaps:e.check.gaps.map(o)}:e.check,c=e.ignoredGaps?.map(o);return{...e,stories:a,check:s,ignoredGaps:c}}function R(e,t=[]){let n=e.filter(e=>!e.parentId&&!e.kind),r=e.filter(e=>e.kind&&!e.parentId),i=new Set(t.flatMap(e=>e.sourceRefs)),a=new Map;for(let t of e){if(!t.parentId)continue;let e=a.get(t.parentId)??[];e.push(t),a.set(t.parentId,e)}let o=n.map(e=>{let n=a.get(e.id)??[],r=n.length>0&&n.every(t=>t.id.startsWith(`${e.id}-`))?n:j(e,n),o=r.length?r:[e],s=o.filter(e=>i.has(e.id)).length,c=t.filter(t=>t.sourceRefs.some(t=>t===e.id||r.some(e=>e.id===t)));return{parent:e,points:r,coveredCount:s,totalPoints:o.length,coveringStories:c}});if(r.length&&!n.length)for(let n of e)o.push({parent:n,points:n.kind?[n]:[],coveredCount:+!!i.has(n.id),totalPoints:1,coveringStories:t.filter(e=>e.sourceRefs.includes(n.id))});else r.length&&o.push({parent:{id:`__orphan__`,title:`其它需求点`,quote:``,body:``},points:r,coveredCount:r.filter(e=>i.has(e.id)).length,totalPoints:r.length,coveringStories:t.filter(e=>r.some(t=>e.sourceRefs.includes(t.id)))});return o}function Fe(e){let t=new Map,n=0;for(let r of R(e)){t.has(r.parent.id)||t.set(r.parent.id,n++);for(let e of r.points)t.has(e.id)||t.set(e.id,n++)}return t}var Ie=500,Le=12e3;function Re(e,t){if(!e.length)return`(无需求点)`;let n=Math.max(40,t?.excerptMax??Ie),r=Math.max(40,t?.blockMax??Le),i=R(e);if(!i.length)return`(无需求点)`;let a=[];for(let e of i){let t=e.parent.id===`__orphan__`?`- ${e.parent.title}`:`- ${e.parent.id} ${e.parent.title}`;if(a.push({kind:`parent`,text:t,shrinkable:!1}),!e.points.length)a.push({kind:`empty`,text:` (尚无查/改子点)`,shrinkable:!1});else for(let t of e.points){let e=t.kind===`query`?`查询`:t.kind===`mutate`?`修改`:`子点`;a.push({kind:`point`,text:` - ${t.id} [${e}] ${t.title}`,shrinkable:!1});let r=(t.body||t.quote||``).replace(/\s+/g,` `).trim();if(r){let e=r.length>n?`${r.slice(0,n).trimEnd()}…`:r;a.push({kind:`excerpt`,text:` 原文:${e}`,shrinkable:!0})}}}let o=e=>e.map(e=>e.text).join(`
|
|
9
|
-
`),s=e=>e.length<=r?e:e.slice(0,r),c=o(a);if(c.length<=r)return c;let l=a.map(e=>({...e}));for(let e=0;e<3&&o(l).length>r;e++){let t=Math.max(40,Math.floor(n/(e+2)));for(let e=0;e<l.length;e++){let n=l[e];if(!n.shrinkable||n.kind!==`excerpt`)continue;let r=n.text.replace(/^ {4}原文:/,``);r.length<=t||(l[e]={...n,text:` 原文:${r.slice(0,t).trimEnd()}…`})}}return c=o(l),c.length<=r?c:s(o(l.filter(e=>!e.shrinkable)))}function z(e,t){if(e.length<=1)return[...e];let n=Fe(t),r=e=>{if(!e.sourceRefs.length)return 2**53-1;let t=2**53-1;for(let r of e.sourceRefs){let e=n.get(r);e!=null&&e<t&&(t=e)}return t};return[...e].map((e,t)=>({s:e,index:t,r:r(e)})).sort((e,t)=>e.r===t.r?e.index-t.index:e.r-t.r).map(e=>e.s)}function B(e){let t=new Map;for(let n of e){let e=n.kind===`query`?`查询`:n.kind===`mutate`?`修改`:``;t.set(n.id,e?`${n.title}(${e})`:n.title)}return t}function V(e){let t=B(e),n=new Map;for(let r of e){let e=t.get(r.id)||r.title;n.set(r.id,`${r.id} ${e}`.trim())}return n}function ze(e,t){if(!e.length)return``;let n=V(t);return e.map(e=>n.get(e)||e).join(`;`)}var Be=2e3,H=800;function U(e,t){let n=0;for(let r=0;r<e.length;r++)if(!/\s/.test(e[r])){if(n===t)return r;n+=1}return-1}function W(e,t,n){if(!n||n.length<4)return-1;let r=t.indexOf(n);return r<0||t.indexOf(n,r+n.length)>=0?-1:U(e,r)}function G(e,t){let n=String(e??``).trim(),r=String(t??``);if(!n||!r)return-1;let i=r.indexOf(n),a=n.replace(/\s+/g,``),o=r.replace(/\s+/g,``);if(i<0&&a&&(i=W(r,o,a)),i<0){let e=Math.min(4,a.length);for(let t of[64,48,32,24,16,12,8,4]){if(t<e)continue;let s=t<=8;if(n.length>=t){let e=n.slice(0,t),a=s?K(r,e):r.indexOf(e);if(a>=0){i=a;break}}let c=a.slice(0,Math.min(t,a.length));if(c.length<e)continue;let l=s?W(r,o,c):(()=>{let e=o.indexOf(c);return e>=0?U(r,e):-1})();if(l>=0){i=l;break}}}if(i<0){let e=/^(【[^】]{2,30}】)/u.exec(n);e&&n.slice(e[0].length).replace(/\s+/g,``).length<4&&(i=r.indexOf(e[1]))}if(i<0)return-1;let s=r.slice(Math.max(0,i-80),i),c=s.lastIndexOf(`
|
|
10
|
-
`);return c>=0&&(i-=s.length-c-1),i}function K(e,t){if(!t||t.length<4)return-1;let n=e.indexOf(t);return n<0||e.indexOf(t,n+t.length)>=0?-1:n}function Ve(e){let t=String(e??``).replace(/[((]?(查询|修改)[))]?$/u,``).replace(/^(政企通页面管理|政企通)/,``).trim();if(!t)return[];let n=[t,...t.split(/[与、及]/u).map(e=>e.trim()).filter(e=>e.length>=4)];t.length>12&&n.push(t.slice(-12));let r=new Set,i=[];for(let e of n)r.has(e)||e.length<4||(r.add(e),i.push(e));return i.sort((e,t)=>t.length-e.length),i}function q(e,t){let n=G(e.quote||e.body||``,t);if(n>=0)return n;for(let n of Ve(e.title??``)){let e=K(t,n);if(e>=0)return e}return-1}function J(e,t,n){let r=/^\d+[、.]/.test(e.slice(t,Math.min(e.length,t+24)).trimStart()),i=t;for(;i<n;){let t=e.indexOf(`
|
|
11
|
-
`,i);if(t<0||t>=n)return n;let a=t+1;for(;a<n&&(e[a]===`
|
|
12
|
-
`||e[a]===`\r`||e[a]===` `);)a+=1;if(a>=n)return t;let o=e.slice(a,Math.min(n,a+40));if(/^【|^#{2,3}\s|^-{3,}/.test(o)||r&&/^\d+[、.]/.test(o)||a>t+1&&!/^\d+[、.]/.test(o))return t;i=t+1}return n}function Y(e,t,n){if(n<=t||n>=e.length)return!1;let r=e.slice(t,n),i=e.slice(n,Math.min(e.length,n+48)).trimStart();if(!/^\d+[、.]/.test(i)||/^\d+[、.]/.test(r.trimStart()))return!1;if(/\d+[、.]/.test(r))return!0;let a=r.trimEnd().split(/\n/).pop()?.trim()??``;return/下面分|如下|包括|分别为|计有|默认字段/u.test(a)||/[::))]\s*$/u.test(a)}function He(e,t,n=Be,r){let i=String(t??``),a=G(e,i);if(a<0)return``;let o=Math.min(i.length,a+n),s=r?.endBefore!=null&&r.endBefore>a?r.endBefore:void 0;if(s!=null&&!Y(i,a,s)){let e=J(i,a,Math.min(o,s));return i.slice(a,Math.min(o,s,e)).trim()}let c=J(i,a,o);return i.slice(a,Math.max(c,a+1)).trim()}function Ue(e,t,n){let r=Math.min(e.length,t+H),i=n==null?r:Math.min(r,n);return i=n!=null&&Y(e,t,n)?J(e,t,r):J(e,t,i),e.slice(t,i).trim()}function We(e,t,n,r,i){if(!e||i<0||!r.length)return e;let a=r.filter(e=>e.id!==t.id&&e.start>i).sort((e,t)=>e.start-t.start)[0]?.id;if(!a)return e;let o=n.find(e=>e.id===a);if(!o)return e;let s=[(o.quote||``).trim(),(o.body||``).trim().split(/\n/)[0]?.trim()||``].filter(e=>e.length>=4);for(let t of s){let n=e.indexOf(t);if(n>0)return e.slice(0,n).trim();let r=t.split(/\n/)[0]?.trim()||``;if(r.length>=4&&r!==t){let t=e.indexOf(r);if(t>0)return e.slice(0,t).trim()}}return e}function Ge(e,t,n){let r=(e.body||``).trim(),i=(e.quote||``).trim(),a=(t?.body||t?.quote||``).trim();if(!a)return{text:r||i||`(无原文切片)`,fromParent:!1};let o=n&&n.length?j(t??{id:``,title:``,quote:``},n):[],s=o.map(e=>({id:e.id,start:q(e,a)})),c=i?G(i,a):-1,l=r?G(r,a):-1,u=c>=0?c:l>=0?l:q(e,a),d;if(u>=0&&s.length){let t=s.filter(t=>t.id!==e.id&&t.start>u).sort((e,t)=>e.start-t.start);t[0]&&(d=t[0].start)}let f=u>=0&&s.some(t=>t.id!==e.id&&t.start===u);if(r)return{text:o.length?We(r,e,o,s,u):r,fromParent:!1};if(o.length&&u>=0&&!f&&d!=null){let e=Ue(a,u,d);if(e)return{text:e,fromParent:!1}}if(i){if(f)return{text:i,fromParent:!1};if(i.length<400||i.length<a.length*.35){let e=He(i,a,H,{endBefore:d});if(e&&(e.length>i.length||d!=null))return{text:e,fromParent:!1}}return{text:i,fromParent:!1}}if(u>=0&&!f){let e=Ue(a,u,d);if(e)return{text:e,fromParent:!1}}return{text:`(未定位到该需求点对应原文)`,fromParent:!1}}function Ke(e){let t=h(e.title??``);return`${e.type}|${e.storyId||``}|${e.outlineId||``}|${t}`}function X(e,t){if(Ke(e)===Ke(t))return!0;if(e.type!==t.type||(e.storyId||``)!==(t.storyId||``))return!1;let n=h(e.title??``),r=h(t.title??``);if(!n||!r)return!1;if(n===r)return!0;let i=n.length<=r.length?n:r,a=n.length<=r.length?r:n;return i.length>=8&&a.includes(i)}function qe(e,t){return t?.length?e.filter(e=>!t.some(t=>X(e,t))):[...e]}function Je(e,t,n,r){let i=r?.allowNew!==!1,a=qe(t,n),o=new Set,s=[],c=0,l=e=>i?!0:e.type===`uncovered-outline`;for(let t of a){let n=e.length?e.find(e=>e.id===t.id&&!o.has(e.id))||e.find(e=>!o.has(e.id)&&X(e,t)):void 0;if(n)o.add(n.id),s.push({...t,id:n.id,title:n.title,selected:n.selected||t.selected,conclusion:t.conclusion?.trim()||n.conclusion});else{if(!l(t)){c+=1;continue}s.push({...t})}}if(!i)for(let t of e)o.has(t.id)||t.type!==`uncovered-outline`&&(n?.some(e=>X(t,e))||s.push({...t}));return{gaps:s,suppressed:c}}function Ye(e){let t=e.pending??[],n=e.ignored??[];if(!t.length&&!n.length)return``;let r=[];if(t.length){r.push(`## 上轮待确认(复审底稿:只更新/收敛,禁止新开条;问题仍在则沿用原 title)`);for(let e of t)r.push(`- id=${e.id} type=${e.type} storyId=${e.storyId||`-`} outlineId=${e.outlineId||`-`}`),r.push(` title: ${e.title}`),e.detail?.trim()&&r.push(` detail: ${e.detail.trim()}`),e.conclusion?.trim()&&r.push(` conclusion: ${e.conclusion.trim()}(已有结论待补写,勿另开一条)`);r.push(``)}if(n.length){r.push(`## 已忽略(禁止再报同类,不要求标题字面一致)`);for(let e of n)r.push(`- type=${e.type} storyId=${e.storyId||`-`} outlineId=${e.outlineId||`-`} title: ${e.title}`)}return r.join(`
|
|
13
|
-
`).trim()}function Xe(e){let t=[];return e.role||t.push({key:`role`,label:`缺角色`}),e.goal||t.push({key:`goal`,label:`缺目标`}),e.preconditions.length||t.push({key:`preconditions`,label:`缺前置条件`}),e.mainFlow.length||t.push({key:`mainFlow`,label:`缺主流程`}),e.sourceRefs.length||t.push({key:`sourceRefs`,label:`未挂需求点`}),e.exceptions.length?ft(e)&&e.exceptions.length<2&&t.push({key:`write-exceptions`,label:`写操作异常不足`}):t.push({key:`exceptions`,label:`缺异常场景`}),!e.altFlows.length&&ft(e)&&t.push({key:`altFlows`,label:`缺替代流程`}),e.acceptance.length?e.acceptance.some(e=>!e.then)&&t.push({key:`acceptance-then`,label:`验收缺 then`}):t.push({key:`acceptance`,label:`缺验收标准`}),t}function Ze(e){return O(e).map(e=>e.small)}function Qe(e){let t=O(e);if(!t.length)return``;let n=e=>/[,"\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,r=[`Ideal 小模块行序(用例「子模块 / 小模块」填下列原文;最终文件按此序排列,优先于用户故事 US 编号):`,`大模块,小模块,优化/问题内容`];for(let e of t)r.push(`${n(e.big)},${n(e.small)},【${e.title}】`);return r.join(`
|
|
14
|
-
`)}var $e=`需求章节顺序`;function et(e){let t=String(e??``).replace(/\r\n/g,`
|
|
15
|
-
`).trim();if(!t)return[];let n=[],r=new Set,i=/^(概述|简介|目录|修订|附录|背景|术语|参考)/;for(let e of t.matchAll(/^#{2,3}\s+(.+?)\s*$/gm)){let t=b(e[1]??``);!t||t.length>40||i.test(t)||r.has(t)||(r.add(t),n.push(t))}return n}function tt(e){let t=String(e??``).replace(/\r\n/g,`
|
|
16
|
-
`),n=t.indexOf($e);if(n<0)return[];let r=t.slice(n,n+4e3),i=[],a=new Set;for(let e of r.matchAll(/^\s*\d+[.)、]\s*(.+?)\s*$/gm)){let t=b(e[1]??``);!t||t.length>40||a.has(t)||(a.add(t),i.push(t))}return i}function Z(e){let t=Ze(e);if(t.length)return t;let n=tt(e);if(n.length)return n;let r=rt(e);return r.length?r:et(e)}function nt(e){let t=Qe(e);if(t)return t;let n=Z(e);return n.length<2?``:[`${$e}(用例「模块 / 子模块 / 标题」应对齐下列原文;最终文件按此序排列,优先于用户故事 US 编号):`,...n.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
17
|
-
`)}function rt(e){let t=O(e);if(t.length)return t.map(e=>e.title);let n=String(e??``).replace(/\r\n/g,`
|
|
18
|
-
`).trim(),r=[],i=new Set;for(let e of n.matchAll(/【([^】\n]{1,40})】/g)){let t=b(e[1]??``);!t||t.length>24||i.has(t)||(i.add(t),r.push(t))}return r}function it(e,t,n){return`g_${y(`${e}|${t}|${n}`)}`}function at(e){let t=e&&typeof e==`object`?e:{},n=_(t.priority,4);return{id:_(t.id,20),title:_(t.title,200),role:_(t.role,120),goal:_(t.goal,500),value:_(t.value,500),sourceRefs:v(t.sourceRefs,20,40),priority:n===`P0`||n===`P1`||n===`P2`?n:`P1`,preconditions:v(t.preconditions),mainFlow:(Array.isArray(t.mainFlow)?t.mainFlow:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{actor:_(t.actor,80),action:_(t.action,500),result:_(t.result,500)}}).filter(e=>e.action).slice(0,40),altFlows:(Array.isArray(t.altFlows)?t.altFlows:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{name:_(t.name,120)||`替代流程`,trigger:_(t.trigger,500),steps:v(t.steps,20)}}).slice(0,20),exceptions:(Array.isArray(t.exceptions)?t.exceptions:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{scenario:_(t.scenario,500),expected:_(t.expected,500)}}).filter(e=>e.scenario).slice(0,30),postconditions:v(t.postconditions),acceptance:(Array.isArray(t.acceptance)?t.acceptance:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{given:_(t.given,500),when:_(t.when,500),then:_(t.then,500)}}).filter(e=>e.given||e.when||e.then).slice(0,30),dimensions:v(t.dimensions,12,40)}}function ot(e){return{...e,sourceRefs:[...e.sourceRefs],preconditions:[...e.preconditions],mainFlow:e.mainFlow.map(e=>({...e})),altFlows:e.altFlows.map(e=>({...e,steps:[...e.steps]})),exceptions:e.exceptions.map(e=>({...e})),postconditions:[...e.postconditions],acceptance:e.acceptance.map(e=>({...e})),dimensions:[...e.dimensions]}}function Q(e){let t=e.mainFlow?.[0];return`${h(e.title)}|${t?h(`${t.action}${t.result??``}`):``}`}function st(e,t){let n=e.map(ot),r=new Map(n.filter(e=>e.id).map(e=>[e.id,e])),i=new Map(n.map(e=>[Q(e),e]));for(let e of t){let t=at(e);if(!t.title)continue;let a=t.id&&r.get(t.id)||i.get(Q(t));if(a)!a.role&&t.role&&(a.role=t.role),!a.goal&&t.goal&&(a.goal=t.goal),!a.value&&t.value&&(a.value=t.value),a.sourceRefs=g([...a.sourceRefs,...t.sourceRefs]),a.dimensions=g([...a.dimensions,...t.dimensions]),a.preconditions.length||(a.preconditions=[...t.preconditions]),a.mainFlow.length||(a.mainFlow=t.mainFlow.map(e=>({...e}))),a.altFlows.length||(a.altFlows=t.altFlows.map(e=>({...e}))),a.exceptions.length||(a.exceptions=t.exceptions.map(e=>({...e}))),a.postconditions.length||(a.postconditions=[...t.postconditions]),a.acceptance.length||(a.acceptance=t.acceptance.map(e=>({...e}))),t.priority===`P0`&&a.priority!==`P0`?a.priority=`P0`:t.priority===`P1`&&a.priority===`P2`&&(a.priority=`P1`);else{let e={...t,id:``};n.push(e),i.set(Q(e),e)}}return n}function ct(e,t){let n=h(e),r=h(t);if(!n||!r)return 0;if(n===r)return 1e3;if(n.includes(r)||r.includes(n))return 800+Math.min(n.length,r.length);let i=n.length<=r.length?n:r,a=n.length<=r.length?r:n,o=0;for(let e=0;e<i.length-1;e++)a.includes(i.slice(e,e+2))&&(o+=1);let s=Math.max(1,i.length-1);return o+Math.round(o/s*10)}var lt=4;function ut(e,t){let n=e.map(ot);if(!t.length)return{stories:n,filled:0};let r=new Set(t.filter(e=>e.parentId).map(e=>e.parentId)),i=[...t.filter(e=>e.kind===`query`||e.kind===`mutate`),...t.filter(e=>!e.kind&&!e.parentId&&!r.has(e.id))];if(!i.length)return{stories:n,filled:0};let a=new Set(n.flatMap(e=>e.sourceRefs).filter(e=>i.some(t=>t.id===e))),o=0;for(let e of n){if(e.sourceRefs.length)continue;let t=null,n=0;for(let r of i){if(a.has(r.id))continue;let i=ct(e.title,r.title);i>n&&(n=i,t=r)}!t||n<lt||(e.sourceRefs=[t.id],a.add(t.id),o+=1)}return{stories:n,filled:o}}function dt(e){return[e.title,e.role,e.goal,e.value,...e.dimensions,...e.preconditions,...e.postconditions,...e.mainFlow.map(e=>`${e.actor??``} ${e.action} ${e.result??``}`),...e.altFlows.map(e=>`${e.name} ${e.trigger} ${e.steps.join(` `)}`),...e.exceptions.map(e=>`${e.scenario} ${e.expected}`),...e.acceptance.map(e=>`${e.given} ${e.when} ${e.then}`)].join(` `)}function ft(e){return e.mainFlow.some(e=>f.test(e.action))}function pt(e,t,n,r,i,a,o=``){return{id:it(e,t||o,n),storyId:t,outlineId:o||void 0,type:e,severity:a,title:n,detail:r,suggestion:i,origin:`rule`,selected:!1}}var mt=new Set([`缺少角色`,`缺少目标`,`缺少前置条件`,`缺少主流程`,`没有异常场景`,`写操作缺少异常分支`,`缺少验收标准`,`验收标准缺 then`,`没有关联需求条目`,`只写了主流程`]);function ht(e){let t=e.outline??[],n=e.stories??[],r=[],i=A(t),a=new Set(n.flatMap(e=>e.sourceRefs));for(let e of i){if(a.has(e.id))continue;let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``,n=t?`${e.title}(${t})`:e.title;r.push(pt(`uncovered-outline`,``,`${n}:还没有用户故事挂上`,`需求点「${n}」在文档里有,但目前没有任何故事引用它。可能是漏拆了,也可能这块其实不用测。`,`跟业务确认要不要覆盖:要的话补一条故事(或在已有故事里挂上这个点);不要的话直接忽略。`,`high`,e.id))}let o=d.map(e=>{let t=n.filter(t=>{let n=dt(t).toLowerCase();return e.keywords.some(e=>n.includes(e.toLowerCase()))}).map(e=>e.id);return{key:e.key,label:e.label,covered:t.length>0,stories:t}}),s=i.filter(e=>a.has(e.id)).length,c={total:i.length,covered:s,rate:i.length?s/i.length:0};return{at:new Date().toISOString(),summary:`规则检查:${n.length} 个故事、${i.length} 个需求点,覆盖率 ${i.length?Math.round(c.rate*100):0}%,${r.length} 项待确认未覆盖。`,coverage:c,dimensions:o,gaps:r}}function gt(e,t){let n=e.map(e=>({...e})),r=new Map(n.map(e=>[`${e.storyId}|${e.type}`,e])),i=new Set(n.map(e=>e.id));for(let e of t){if(i.has(e.id))continue;let t=`${e.storyId}|${e.type}`,a=r.get(t);a?mt.has(a.title)?(a.title=e.title,a.detail=[a.detail,e.detail].filter(Boolean).join(` / `),a.suggestion=e.suggestion||a.suggestion,a.severity=e.severity):h(a.title)!==h(e.title)&&(n.push({...e}),i.add(e.id)):(n.push({...e}),r.set(t,e),i.add(e.id))}return n}function _t(e,t){let n=[],r=``;for(let i of e.split(/\n{2,}/)){let e=r?`${r}\n\n${i}`:i;if(e.length<=t)r=e;else if(r&&n.push(r),i.length<=t)r=i;else{for(let e=0;e<i.length;e+=t)n.push(i.slice(e,e+t));r=``}}return r&&n.push(r),n}function vt(e,t=12e3){let n=String(e??``).replace(/\r\n/g,`
|
|
19
|
-
`).trim();if(!n)return[];let r=Math.max(2e3,Math.floor(t));if(n.length<=r)return[{index:0,title:``,text:n}];let i=[],a=``,o=[],s=()=>{let e=o.join(`
|
|
20
|
-
`).trim();e&&i.push({title:a,text:e}),o=[]};for(let e of n.split(`
|
|
21
|
-
`)){let t=/^#{2,6}\s+(.+?)\s*$/.exec(e);t&&(s(),a=t[1]),o.push(e)}if(s(),!i.length)return[{index:0,title:``,text:n}];let c=[],l=``,u=``,d=()=>{let e=l.trim();if(e){for(let t of e.length>r?_t(e,r):[e])c.push({index:c.length,title:u,text:t});l=``}};for(let e of i){let t=l?`${l}\n\n${e.text}`:e.text;t.length<=r?(l||(u=e.title),l=t):(d(),u=e.title,l=e.text,l.length>r&&d())}return d(),c.length?c:[{index:0,title:``,text:n}]}function $(e,t){return t?`- **${e}**:${t}`:``}function yt(e){return e.filter(Boolean).map(e=>`- ${e}`)}function bt(e,t=[]){let n=[];n.push(`### ${e.id} ${e.title}`),n.push(``);let r=t.length?ze(e.sourceRefs,t):e.sourceRefs.join(`、`),i=[$(`角色`,e.role),$(`目标`,e.goal),$(`价值`,e.value),$(`优先级`,e.priority),$(`来源条目`,r)].filter(Boolean);if(n.push(...i),i.length&&n.push(``),e.preconditions.length&&(n.push(`**前置条件**`),n.push(...yt(e.preconditions)),n.push(``)),e.mainFlow.length&&(n.push(`**主流程**`),e.mainFlow.forEach((e,t)=>{let r=e.actor?`${e.actor}:`:``;n.push(`${t+1}. ${r}${e.action}${e.result?` → ${e.result}`:``}`)}),n.push(``)),e.altFlows.length){n.push(`**替代流程**`);for(let t of e.altFlows)n.push(`- **${t.name}**${t.trigger?`(触发:${t.trigger})`:``}`),t.steps.forEach((e,t)=>n.push(` ${t+1}. ${e}`));n.push(``)}if(e.exceptions.length){n.push(`**异常场景**`);for(let t of e.exceptions)n.push(`- ${t.scenario}${t.expected?` → ${t.expected}`:``}`);n.push(``)}if(e.postconditions.length&&(n.push(`**后置条件**`),n.push(...yt(e.postconditions)),n.push(``)),e.acceptance.length){n.push(`**验收标准**`);for(let t of e.acceptance)n.push(`- Given ${t.given||`(未写)`};When ${t.when||`(未写)`};Then ${t.then||`(未写)`}`);n.push(``)}return e.dimensions.length&&(n.push(`**覆盖维度**:${e.dimensions.join(`、`)}`),n.push(``)),n[n.length-1]!==``&&n.push(``),n}function xt(e,t){let n=new Set((t??[]).filter(Boolean)),i=n.size?e.stories.filter(e=>n.has(e.id)):e.stories,a=[];if(a.push(`# ${e.title||`需求分析`} · 用户故事`),a.push(``),a.push(`> 来源需求文档:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),a.push(``),e.outline.length){a.push(`## 需求条目`),a.push(``),a.push(`> 「引用需求点」请填下列真实 RO id,格式「RO-id 标题」;不要填 US-…。`),a.push(``);for(let t of R(e.outline,i)){if(a.push(`### ${t.parent.id} ${t.parent.title}`),t.parent.quote||t.parent.body){let e=(t.parent.quote||t.parent.body||``).replace(/\s+/g,` `).slice(0,200);a.push(`> ${e}`)}if(t.points.length)for(let e of t.points){let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``;a.push(`- **${e.id}** ${e.title}${t?`(${t})`:``}`),e.quote&&a.push(` > ${e.quote.replace(/\n+/g,` `)}`)}a.push(``)}}a.push(`## 用户故事`),a.push(``),i.length||(a.push(`- (暂无)`),a.push(``));let o=z(i,e.outline);for(let t of o)a.push(...bt(t,e.outline));return a.join(`
|
|
22
|
-
`)}function St(e){let t=[];t.push(`# ${e.title||`需求分析`}`),t.push(``),t.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),t.push(``),t.push(`## 需求条目`),t.push(``),e.outline.length||t.push(`- (暂无)`);for(let n of R(e.outline,e.stories)){t.push(`- **${n.parent.id}** ${n.parent.title}`),n.parent.quote&&t.push(` > ${n.parent.quote.replace(/\n+/g,` `)}`);for(let e of n.points){let n=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``;t.push(` - **${e.id}** ${e.title}${n?`(${n})`:``}`),e.quote&&t.push(` > ${e.quote.replace(/\n+/g,` `)}`)}}t.push(``),t.push(`## 用户故事`),t.push(``),e.stories.length||t.push(`- (暂无)`);for(let n of z(e.stories,e.outline))t.push(...bt(n,e.outline));if(t.push(`## 审查摘要`),t.push(``),!e.check)t.push(`- 还没有跑过审查。`);else{let n=e.check.coverage.total?Math.round(e.check.coverage.rate*100):0;t.push(`- 覆盖率:${e.check.coverage.covered}/${e.check.coverage.total}(${n}%)`),t.push(`- 维度覆盖:${e.check.dimensions.map(e=>`${e.label}${e.covered?` ✓`:` ✗`}`).join(` · `)||`(无)`}`),e.check.summary&&(t.push(``),t.push(e.check.summary)),t.push(``),t.push(`### 缺口清单`),t.push(``),e.check.gaps.length||t.push(`- 没有发现缺口。`);let r=[...e.check.gaps].sort((e,t)=>{let n={high:0,medium:1,low:2};return n[e.severity]-n[t.severity]});for(let e of r){let n=e.storyId?`${e.storyId} `:``;t.push(`- **[${l[e.severity]}] ${a[e.type]}** · ${n}${e.title}`),e.detail&&t.push(` - 原因:${e.detail}`),e.suggestion&&t.push(` - 建议:${e.suggestion}`)}}return t.push(``),t.join(`
|
|
23
|
-
`)}function Ct(e){return`${(e.title||e.sourcePath.split(`/`).pop()||`需求分析`).replace(/\.(md|markdown|txt)$/i,``).replace(/[\\/:*?"<>|]/g,` `).trim()||`需求分析`}-用户故事.md`}export{oe as $,ce as A,Je as B,be as C,je as D,R as E,V as F,xe as G,Me as H,Ge as I,z as J,ye as K,B as L,st as M,Ae as N,he as O,A as P,Xe as Q,m as R,Re as S,it as T,x as U,Pe as V,fe as W,vt as X,de as Y,xt as Z,ae as _,t as a,c as b,ht as c,ne as d,St as et,ie as f,ee as g,Z as h,n as i,gt as j,te as k,Oe as l,rt as m,u as n,Ne as nt,i as o,Ct as p,Ee as q,a as r,re as rt,r as s,l as t,De as tt,ge as u,ut as v,nt as w,Ye as x,qe as y,se as z};
|