lantern-harness 0.1.18 → 0.1.20
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 +59 -0
- package/dist/500.html +4 -4
- package/dist/_astro/Base.8d5eaaN-.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.DZ45xGEk.js → Base.astro_astro_type_script_index_0_lang.D3Mv75pF.js} +1 -1
- package/dist/_astro/CaseGenerateApp.DLcUOrpS.js +9 -0
- package/dist/_astro/CasesLibrary.BghGVLeb.js +19 -0
- package/dist/_astro/{ChatApp.D9NIekGO.js → ChatApp.DFRI7l4j.js} +8 -8
- package/dist/_astro/KnowledgeLibrary.D0r8ieOZ.js +1 -0
- package/dist/_astro/{PluginsPage.Bhyuqbq0.js → PluginsPage.BkwleEJf.js} +2 -2
- package/dist/_astro/PluginsPage.tkNDzVHL.js +1 -0
- package/dist/_astro/PromptsLibrary.CjSQTnKT.js +1 -0
- package/dist/_astro/ReqAnalysisBoard.C9g4p0Q1.js +29 -0
- package/dist/_astro/{RequirementsLibrary.CgzwlAXi.js → RequirementsLibrary.B5TE-2Ds.js} +1 -1
- package/dist/_astro/{SettingsDialog.CDlXEl-R.js → SettingsDialog.CmY3q7-S.js} +1 -1
- package/dist/_astro/{SpaceSwitcher.DMoqOVpS.js → SpaceSwitcher.B8dzGxrR.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.B5KmjjFw.js → TemplatesLibrary.DazYm5Sh.js} +1 -1
- package/dist/_astro/{UiAutoBoard.DJljpjXT.js → UiAutoBoard.BwKG4DcV.js} +1 -1
- package/dist/_astro/app-version.BRO_L8TS.js +1 -0
- package/dist/_astro/project-docs.DAw9bzgk.js +1 -0
- package/dist/_astro/req-analysis.DGQa1vaH.js +6 -0
- package/dist/_astro/{story-review.C5gzEzBP.js → story-review.BXXv0Ko_.js} +2 -2
- package/dist/_astro/{ui-auto-prompt.QcLCZoV6.js → ui-auto-prompt.l_EXfDs5.js} +2 -2
- package/dist/case-exec/index.html +4 -4
- package/dist/cases/generate/index.html +5 -5
- package/dist/cases/library/index.html +5 -5
- package/dist/dashboard/index.html +4 -4
- package/dist/docs/changelog/index.html +60 -5
- package/dist/docs/install/index.html +4 -4
- package/dist/docs/manual/index.html +14 -12
- package/dist/knowledge/index.html +5 -5
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +4 -4
- package/dist/plugins/index.html +5 -5
- package/dist/pm/bugs/index.html +4 -4
- package/dist/pm/iterations/index.html +4 -4
- package/dist/pm/projects/detail/index.html +4 -4
- package/dist/pm/projects/index.html +4 -4
- package/dist/pm/requirements/index.html +4 -4
- package/dist/prompts/index.html +5 -5
- package/dist/reports/index.html +4 -4
- package/dist/requirement-analysis/index.html +5 -5
- package/dist/requirements/index.html +5 -5
- package/dist/tasks/index.html +4 -4
- package/dist/templates/index.html +5 -5
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +4 -4
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +4 -4
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +4 -4
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +4 -4
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +4 -4
- package/dist/test-automation/index.html +5 -5
- package/dist/test-stats/index.html +4 -4
- package/dist/todos/index.html +4 -4
- package/dist/workbench/index.html +5 -5
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +10 -8
- package/lh-plugins/case-review-prompt.mjs +67 -54
- package/lh-plugins/lh-reports.mjs +65 -6
- package/lh-plugins/lh-req-analysis.mjs +9 -1
- package/lh-plugins/req-analysis-prompt.mjs +13 -10
- package/lh-plugins/story-review-prompt.mjs +26 -16
- package/lh-plugins/test-points-prompt.mjs +13 -9
- package/lh-plugins/uiauto-prompt.mjs +30 -23
- package/package.json +1 -1
- package/dist/_astro/Base.VCz1UVxQ.css +0 -1
- package/dist/_astro/CaseGenerateApp.D2ftaUXT.js +0 -9
- package/dist/_astro/CasesLibrary.DWXEje9u.js +0 -19
- package/dist/_astro/KnowledgeLibrary.Dw-IX3Zt.js +0 -1
- package/dist/_astro/PluginsPage.C6ecLD6o.js +0 -1
- package/dist/_astro/PromptsLibrary.CEQ2PSE6.js +0 -1
- package/dist/_astro/ReqAnalysisBoard.MZap7sCK.js +0 -28
- package/dist/_astro/app-version.fDqj9z2r.js +0 -1
- package/dist/_astro/project-docs.Cd2gKPKh.js +0 -1
- package/dist/_astro/req-analysis.CkLx8c9E.js +0 -6
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{d as f,l as p,n as m,o as h,t as g}from"./ColumnResize.BgYkV9Iy.js";import{t as _}from"./OverflowHint.pvo2Xc8R.js";import{showToast as v}from"./Toast.BO2NFckG.js";import{a as y,i as b,t as x}from"./export.joBT53eb.js";import{s as ee}from"./llm.BZEzE0x2.js";import{d as S,f as C,l as w,n as T,r as E,s as D}from"./project-docs.Cd2gKPKh.js";import{n as te}from"./doc-roots.DAJP9Svr.js";import{f as O,l as k,o as A}from"./settings.BvxRxdqa.js";import{i as ne,n as re,r as ie,t as ae}from"./DocsFileBrowser.-dkkxR4X.js";import{l as j,n as oe,o as M,p as se,t as ce,u as le}from"./open-docs-in-session.B6uyOxPn.js";import{A as ue,C as de,D as fe,O as pe,S as me,_ as he,a as N,b as ge,c as P,d as _e,f as ve,g as ye,h as be,k as xe,l as F,m as Se,n as I,o as L,p as Ce,s as R,t as we,u as z,v as Te,w as Ee,x as De,y as Oe}from"./case-review.DYyZat83.js";import{t as ke}from"./SlideOverDrawer.HqVYaIjP.js";import{h as Ae}from"./req-analysis.CkLx8c9E.js";import{o as B,s as V,t as H}from"./composer-task.DJmluzPT.js";var U=e(t(),1),W=u(),G={blue:`text-sky-700`,purple:`text-violet-700`,green:`text-emerald-700`,amber:`text-amber-700`,yellow:`text-yellow-700`,red:`text-rose-700`,gray:`text-stone-600`,muted:`text-stone-500`},K={blue:`bg-sky-500`,purple:`bg-violet-500`,green:`bg-emerald-500`,amber:`bg-amber-500`,yellow:`bg-yellow-500`,red:`bg-rose-500`,gray:`bg-stone-400`,muted:`bg-stone-300`};function je(e){return e>=85?`green`:e>=60?`amber`:`red`}function q(e){let t=Date.parse(e);if(!Number.isFinite(t))return`—`;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<60)return`刚刚`;let r=Math.floor(n/60);if(r<60)return`${r} 分钟前`;let i=Math.floor(r/60);if(i<24)return`${i} 小时前`;let a=Math.floor(i/24);return a<30?`${a} 天前`:new Date(t).toLocaleDateString()}function Me({review:e,running:t,modelReady:n,onRun:r,onStop:i,onFix:a,onFixBatch:u,onExport:d}){let[f,p]=(0,U.useState)(()=>s(`caseReview.quality.filter`,[`all`,...F],`all`)),[m,h]=(0,U.useState)(()=>l(`caseReview.quality.search`)),[g,_]=(0,U.useState)({}),[v,y]=(0,U.useState)(!1),[b,x]=(0,U.useState)(()=>s(`caseReview.quality.worstFirst`,[`1`,`0`],`0`)===`1`),ee=e=>{p(e),o(`caseReview.quality.filter`,e)},S=e=>{h(e),c(`caseReview.quality.search`,e)},C=e=>{x(e),o(`caseReview.quality.worstFirst`,e?`1`:`0`)},w=(0,U.useMemo)(()=>e?.cases??[],[e]),T=(0,U.useMemo)(()=>{let e=m.trim().toLowerCase(),t=w.filter(t=>f!==`all`&&t.verdict!==f?!1:!e||`${t.no} ${t.title}`.toLowerCase().includes(e));return b?[...t].sort((e,t)=>e.score-t.score):t},[w,f,m,b]),E=(0,U.useMemo)(()=>T.filter(e=>e.verdict!==`usable`),[T]);return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:r,disabled:t,className:`h-8 px-3 rounded-lg text-xs font-medium bg-stone-900 text-white hover:bg-stone-800 disabled:opacity-50`,children:t?`评审中…`:e?`重新评审`:`开始评审`}),t?(0,W.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 px-3 rounded-lg text-xs border border-rose-200 text-rose-600 hover:bg-rose-50`,children:`停止`}):null,(0,W.jsx)(`button`,{type:`button`,onClick:d,disabled:!e,className:`h-8 px-3 rounded-lg text-xs border border-stone-200 text-stone-700 hover:bg-stone-50 disabled:opacity-40`,children:`导出 Markdown`}),(0,W.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:n?`规则 + 模型:语义问题与扣分原因由模型补`:`未配置模型:只跑规则判定`}),e?(0,W.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[11px] text-stone-400`,children:[e.modelCovered!=null&&e.modelCovered<w.length?(0,W.jsxs)(`span`,{className:`text-amber-700`,children:[`模型只评到 `,e.modelCovered,`/`,w.length,` 条,其余按规则分`]}):null,(0,W.jsxs)(`span`,{children:[`上次评审:`,q(e.at)]})]}):null]}),e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-stone-50/60 px-3 py-2`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center gap-2 text-left`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`看到结论后怎么处理`}),(0,W.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:v?`收起`:`展开`})]}),v?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`ul`,{className:`mt-1.5 space-y-1 text-[11px] leading-relaxed text-stone-600`,children:[(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`mr-1 rounded border px-1 ${P.invalid.badge}`,children:`错误无效`}),`点这条右侧的「修改」,会带着编号、扣分原因与建议跳到工作台(用例绑定的会话,没有就新建), 让模型按建议改;也可以自己回「用例管理」改这一条,两边同时改互不冲突。改完回来「重新评审」。`]}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`mr-1 rounded border px-1 ${P.revise.badge}`,children:`待修改`}),`不影响执行,按建议补齐边界 / 异常 / 前置条件即可;批量改完再整体重评一次。`]}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`批量修改`}),`在下面的「逐条明细」里:先按「错误无效 / 待修改」筛选(或搜索编号), 再点右侧「批量修改 N」,当前列出来的这批会一起交给工作台改;只改筛出来的,不会碰「可用」的。 自己分批手改也可以,AI 会按文件当前内容对照,不会覆盖你后来的手改。`]}),(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`mr-1 rounded border px-1 ${P.usable.badge}`,children:`可用`}),`可直接执行或入库;这里只读,不会自动改你的用例文件。`]})]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-stone-400`,children:`改文件后报告会标「可能已过期」,重新评审即刷新;每次结果都存在「用例评审」目录里。`})]}):null]}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,W.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:`总分`}),(0,W.jsx)(`div`,{className:`text-xl font-semibold ${G[je(e.score)]}`,children:e.score}),(0,W.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:e.modeled?`规则 + 模型`:`仅规则`})]}),F.map(t=>(0,W.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:P[t].label}),(0,W.jsx)(`div`,{className:`text-xl font-semibold ${G[P[t].tone]}`,children:e.counts[t]}),(0,W.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:P[t].hint})]},t))]}),(0,W.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`五维得分(整批平均)`}),(0,W.jsx)(`span`,{className:`text-[10px] text-stone-400`,children:`每维 0–100 分;左侧百分比是权重,右侧数字才是这一维的得分`})]}),(0,W.jsxs)(`div`,{className:`mt-2 mb-1 flex items-center gap-2 text-[10px] text-stone-400`,children:[(0,W.jsx)(`span`,{className:`w-20 shrink-0`,children:`维度`}),(0,W.jsx)(`span`,{className:`w-9 shrink-0 text-right`,children:`权重`}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(`span`,{className:`w-8 shrink-0 text-right`,children:`得分`})]}),(0,W.jsx)(`div`,{className:`space-y-2`,children:e.dimensions.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`w-20 shrink-0 text-[11px] text-stone-600`,children:e.label}),(0,W.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-[11px] tabular-nums text-stone-400`,children:[e.weight,`%`]}),(0,W.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,W.jsx)(`div`,{className:`h-full ${K[N[e.key]?.tone??`gray`]}`,style:{width:`${e.score}%`}})}),(0,W.jsx)(`span`,{className:`w-8 shrink-0 text-right text-[11px] tabular-nums text-stone-700`,children:e.score})]},e.key))}),(0,W.jsxs)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-stone-400`,children:[`总分 `,e.score,` = 各维度得分 × 权重求和(不是右侧某个数字); ≥`,` `,z.usable,` 可用 · `,z.revise,`–`,z.usable-1,` 待修改 · < `,z.revise,` 错误无效。`]})]}),(0,W.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,W.jsxs)(`h3`,{className:`mb-2 text-xs font-semibold text-stone-700`,children:[`量化指标`,(0,W.jsx)(`span`,{className:`ml-1 font-normal text-stone-400`,children:`七项 + 硬伤条数`})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:e.metrics.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2.5 py-2`,children:[(0,W.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:e.label}),(0,W.jsx)(`div`,{className:`text-base font-semibold text-stone-800 tabular-nums`,children:e.text}),(0,W.jsx)(`div`,{className:`text-[10px] leading-tight text-stone-400`,children:e.hint})]},e.key))})]}),e.summary?(0,W.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,W.jsx)(`h3`,{className:`mb-1 text-xs font-semibold text-stone-700`,children:`整体结论`}),(0,W.jsx)(`p`,{className:`text-xs leading-relaxed text-stone-600 whitespace-pre-wrap`,children:e.summary})]}):null,(0,W.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,W.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`逐条明细`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsxs)(Ne,{active:f===`all`,onClick:()=>ee(`all`),children:[`全部 `,w.length]}),F.map(t=>(0,W.jsxs)(Ne,{active:f===t,onClick:()=>ee(t),children:[P[t].label,` `,e.counts[t]]},t))]}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>C(!b),className:`ml-auto h-6 shrink-0 rounded-md px-2 text-[11px] transition-colors ${b?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:`按分数升序`}),(0,W.jsx)(`input`,{value:m,onChange:e=>S(e.target.value),placeholder:`搜编号 / 标题`,className:`h-7 w-40 rounded-lg border border-stone-200 px-2 text-xs outline-none focus:border-stone-400`}),(0,W.jsxs)(`button`,{type:`button`,disabled:!E.length,onClick:()=>u(E),className:`h-7 shrink-0 rounded-lg border border-stone-200 px-2 text-[11px] text-stone-600 transition-colors hover:bg-stone-50 disabled:opacity-40`,children:[`批量修改 `,E.length||``]})]}),(0,W.jsxs)(`ul`,{className:`divide-y divide-stone-100`,children:[T.map((e,t)=>(0,W.jsx)(Pe,{item:e,open:g[`${e.no}-${t}`]===!0,onToggle:()=>_(n=>({...n,[`${e.no}-${t}`]:!n[`${e.no}-${t}`]})),onFix:()=>a(e)},`${e.no}-${t}`)),T.length?null:(0,W.jsx)(`li`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:`没有符合条件的用例`})]})]})]}):(0,W.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm text-stone-600`,children:`还没有评审结果`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`评审按五维打分(需求覆盖 / 步骤可执行 / 预期可判定 / 数据与边界 / 规范完整), 算七项量化指标,并把每条判成「可用 / 待修改 / 错误无效」;只读不改用例。`})]})]})}function Ne({active:e,onClick:t,children:n}){return(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`h-6 rounded-md px-2 text-[11px] transition-colors ${e?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:n})}function Pe({item:e,open:t,onToggle:n,onFix:r}){let i=P[e.verdict],a=e.verdict!==`usable`;return(0,W.jsxs)(`li`,{className:`group px-3 py-2`,children:[(0,W.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:`flex w-full items-center gap-2 text-left`,children:[(0,W.jsx)(`span`,{className:`inline-flex w-14 shrink-0 items-center justify-center rounded border px-1 py-0.5 text-[10px] leading-4 ${i.badge}`,children:i.label}),(0,W.jsx)(`span`,{className:`w-16 shrink-0 truncate text-left text-[11px] tabular-nums leading-4 text-stone-500`,children:e.no||`—`}),(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-left text-xs leading-4 text-stone-800`,children:e.title||`(无标题)`}),a?(0,W.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r()},onKeyDown:e=>e.stopPropagation(),className:`h-5 shrink-0 rounded-md border border-stone-200 px-1.5 text-[10px] leading-none text-stone-600 opacity-0 transition-opacity hover:bg-stone-100 focus-visible:opacity-100 group-hover:opacity-100`,children:`修改`}):null]}),(0,W.jsx)(`span`,{className:`w-7 shrink-0 text-right text-[11px] tabular-nums leading-4 text-stone-500`,children:e.score}),(0,W.jsx)(`span`,{className:`flex h-5 w-8 shrink-0 items-center justify-center text-[10px] text-stone-400`,children:t?`收起`:`详情`})]}),t?(0,W.jsxs)(`div`,{className:`mt-2 space-y-2 pl-1`,children:[e.hard?(0,W.jsxs)(`p`,{className:`rounded-md border border-rose-200 bg-rose-50 px-2 py-1 text-[11px] text-rose-700`,children:[`硬伤:`,e.hard]}):null,(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.keys(N).map(t=>(0,W.jsxs)(`span`,{className:`rounded-md border border-stone-100 bg-stone-50 px-2 py-0.5 text-[10px] text-stone-600`,children:[N[t].label,` `,e.dimensions[t]]},t))}),e.deductions.length?(0,W.jsx)(`ul`,{className:`space-y-1.5`,children:e.deductions.map((e,t)=>(0,W.jsxs)(`li`,{className:`rounded-md bg-stone-50 px-2 py-1.5`,children:[(0,W.jsxs)(`div`,{className:`text-[11px] text-stone-700`,children:[(0,W.jsxs)(`span`,{className:`mr-1 font-medium text-stone-500`,children:[`[`,N[e.dimension]?.label??e.dimension,e.points?` −${e.points}`:``,`]`]}),e.reason]}),e.suggestion?(0,W.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-emerald-700`,children:[`建议:`,e.suggestion]}):null]},t))}):(0,W.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`没有扣分项。`})]}):null]})}var J={blue:`border-sky-200 bg-sky-50 text-sky-700`,purple:`border-violet-200 bg-violet-50 text-violet-700`,green:`border-emerald-200 bg-emerald-50 text-emerald-700`,amber:`border-amber-200 bg-amber-50 text-amber-800`,yellow:`border-yellow-200 bg-yellow-50 text-yellow-800`,red:`border-rose-200 bg-rose-50 text-rose-700`,gray:`border-stone-200 bg-stone-50 text-stone-600`,muted:`border-stone-200 bg-white text-stone-400`};function Fe({report:e,loading:t,running:n,completing:r,modelReady:i,selected:a,onToggle:o,onToggleCategory:s,onDetect:c,onStop:l,onComplete:u,onWriteback:d,onExport:f}){let p=(0,U.useMemo)(()=>(e?.items??[]).filter(e=>!e.added),[e]),m=(e?.items??[]).filter(e=>e.added).length,h=(0,U.useMemo)(()=>ge(p),[p]),[g,_]=(0,U.useState)(new Set),v=(0,U.useMemo)(()=>p.map(e=>e.id),[p]),y=v.length>0&&v.every(e=>a.has(e)),b=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`p`,{className:`rounded-lg border border-stone-200 bg-stone-50/60 px-3 py-2 text-[11px] leading-relaxed text-stone-500`,children:`用途:找出「需求里有、用例里没有」的场景(非功能、安全边界、兼容性、隐藏业务规则), 不是挑现有用例的毛病,而是补漏。流程:① 探测盲区 → ② 勾选要补的条目 → ③「补全选中」写全前置 / 步骤 / 预期 → ④「去工作台写回」跳到这条用例绑定的会话,由模型按文件表头补进原文件(写前备份,不动原有行)。`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:c,disabled:n||r,className:`h-8 px-3 rounded-lg text-xs font-medium bg-stone-900 text-white hover:bg-stone-800 disabled:opacity-50`,children:n?`探测中…`:e?`重新探测`:`探测盲区`}),n?(0,W.jsx)(`button`,{type:`button`,onClick:l,className:`h-8 px-3 rounded-lg text-xs border border-rose-200 text-rose-600 hover:bg-rose-50`,children:`停止`}):null,(0,W.jsx)(`button`,{type:`button`,onClick:u,disabled:!a.size||r||n,className:`h-8 px-3 rounded-lg text-xs border border-stone-200 text-stone-700 hover:bg-stone-50 disabled:opacity-40`,children:r?`补全中…`:`补全选中 ${a.size||``}`}),(0,W.jsx)(`button`,{type:`button`,onClick:d,disabled:!a.size||n||t,className:`h-8 px-3 rounded-lg text-xs font-medium border border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 disabled:opacity-40`,children:`去工作台写回 ${a.size||``}`}),(0,W.jsx)(`button`,{type:`button`,onClick:f,disabled:!e,className:`h-8 px-3 rounded-lg text-xs border border-stone-200 text-stone-700 hover:bg-stone-50 disabled:opacity-40`,children:`导出 Markdown`}),(0,W.jsx)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:p.length?`已选 ${a.size} / 共 ${p.length}`:``}),(0,W.jsx)(`button`,{type:`button`,disabled:!v.length,onClick:()=>s(v,!y),className:`h-6 shrink-0 rounded-md px-2 text-[11px] text-stone-500 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:y?`清空`:`全选`})]}),i?null:(0,W.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-800`,children:`场景探测要靠模型推理,先在设置里配好模型。`}),t?(0,W.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`读取中…`}):!e||!e.items.length&&!n?(0,W.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center`,children:[(0,W.jsx)(`p`,{className:`text-sm text-stone-600`,children:`还没有探测结果`}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`会从非功能、安全边界、兼容性与隐藏业务规则四个方向找现有用例的缺口。`})]}):(0,W.jsxs)(W.Fragment,{children:[e.summary?(0,W.jsx)(`p`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2 text-xs leading-relaxed text-stone-600 whitespace-pre-wrap`,children:e.summary}):null,m?(0,W.jsxs)(`p`,{className:`text-[10px] text-stone-400`,children:[`另有 `,m,` 条旧版本已写回的条目,不再显示(避免重复补进文件)。`]}):null,h.map(e=>{let t=we[e.key],n=e.items.map(e=>e.id),r=n.length>0&&n.every(e=>a.has(e)),i=g.has(e.key),c=n.filter(e=>a.has(e)).length;return(0,W.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,W.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>b(e.key),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,W.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${J[t.tone]}`,children:t.mark}),(0,W.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:t.label}),(0,W.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[n.length,` 条`,c?` · 已选 ${c}`:``]}),(0,W.jsx)(`span`,{className:`ml-auto text-[10px] text-stone-400`,children:i?`展开`:`收起`})]}),n.length?(0,W.jsx)(`button`,{type:`button`,onClick:()=>s(n,!r),className:`h-6 shrink-0 rounded-md px-2 text-[11px] text-stone-500 transition-colors hover:bg-stone-100`,children:r?`取消本类`:`全选本类`}):null]}),i?null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`px-3 pt-2 text-[11px] text-stone-400`,children:t.hint}),(0,W.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.items.map(e=>(0,W.jsx)(Y,{item:e,checked:a.has(e.id),onToggle:()=>o(e.id)},e.id))})]})]},e.key)})]}),a.size?(0,W.jsxs)(`p`,{className:`sticky bottom-0 rounded-lg border border-stone-200 bg-white/95 px-3 py-2 text-[11px] text-stone-500 shadow-sm backdrop-blur`,children:[`已选 `,a.size,` 条:可以先「补全选中」把字段写全,也可以直接「去工作台写回」—— 会在该用例绑定的会话里按文件表头补行,写前自动备份。`]}):null]})}function Y({item:e,checked:t,onToggle:n}){let[r,i]=(0,U.useState)(!1),a=R[e.severity];return(0,W.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-stone-900`,"aria-label":`选择 ${e.title}`}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex-1 min-w-0 text-left`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`shrink-0 rounded border px-1 py-0.5 text-[10px] ${J[a.tone]}`,children:a.label}),(0,W.jsx)(`span`,{className:`flex-1 min-w-0 text-xs text-stone-800`,children:e.title}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:e.priority})]}),e.why?(0,W.jsxs)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-500`,children:[`容易漏:`,e.why]}):null]})]}),r?(0,W.jsxs)(`dl`,{className:`mt-2 space-y-1 rounded-md bg-stone-50 px-2 py-1.5 text-[11px] text-stone-600`,children:[(0,W.jsx)(Ie,{label:`前置条件`,value:e.precondition}),(0,W.jsx)(Ie,{label:`步骤`,value:e.steps.map((e,t)=>`${t+1}. ${e}`).join(` `)}),(0,W.jsx)(Ie,{label:`预期`,value:e.expected})]}):null]})}function Ie({label:e,value:t}){return t?(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`dt`,{className:`w-14 shrink-0 text-stone-400`,children:e}),(0,W.jsx)(`dd`,{className:`flex-1 whitespace-pre-wrap`,children:t})]}):null}var X=[`module`,`type`,`priority`],Z=[{key:`no`,width:84,min:72},{key:`title`,width:168,min:120},{key:`steps`,width:200,min:150},{key:`expected`,width:192,min:150},{key:`verdict`,width:112,min:104},{key:`suggestions`,width:220,min:200},{key:`filler`,filler:!0}],Q=`lh:case-review:cols:v1`;function Le(e){return e.replace(/\.[A-Za-z0-9]+$/,``).trim().toLowerCase()}function Re({file:e,audit:t,review:n,fileName:r}){let i=(0,U.useMemo)(()=>e?.rows??[],[e]),[a,u]=(0,U.useState)(()=>s(`caseReview.table.filter`,[`all`,...F],`all`)),[d,v]=(0,U.useState)(()=>l(`caseReview.table.search`)),y=e=>{u(e),o(`caseReview.table.filter`,e)},b=e=>{v(e),c(`caseReview.table.search`,e)},x=p(Q,Z),ee=f(`case-review`),S=(0,U.useMemo)(()=>xe(e?.headers??[]),[e]),C=(0,U.useMemo)(()=>{let e=new Map,r=new Map;for(let t of n?.cases??[])t.no&&e.set(t.no.trim(),t),t.title&&r.set(t.title.trim(),t);return i.map((n,i)=>{let a=String(n[S.no??fe.no]??``).trim(),o=String(n[S.title??fe.title]??``).trim();return(a?e.get(a):void 0)??(o?r.get(o):void 0)??t?.cases[i]??null})},[i,S,n,t]),w=(0,U.useMemo)(()=>{let e={usable:0,revise:0,invalid:0};for(let t of C)t&&(e[t.verdict]+=1);return e},[C]),T=(0,U.useMemo)(()=>i.map((e,t)=>{let n=C[t],i=t=>String(e[S[t]??fe[t]]??``),a=r?Le(r):``,o=X.map(i).map(e=>e.trim()).filter(e=>!!e&&(!a||Le(e)!==a)).join(` · `);return{key:t,no:i(`no`),title:i(`title`),meta:o,steps:i(`steps`),expected:i(`expected`),verdict:n,suggestions:n?ve(n):[]}}),[i,S,C,r]),E=(0,U.useMemo)(()=>{let e=d.trim().toLowerCase();return T.filter(t=>a!==`all`&&t.verdict?.verdict!==a?!1:!e||`${t.no} ${t.title}`.toLowerCase().includes(e))},[T,a,d]);return(0,W.jsxs)(`div`,{className:`space-y-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e?`${i.length} 条 · ${e.ext}`:`未读到用例文件`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsxs)(ze,{active:a===`all`,onClick:()=>y(`all`),children:[`全部 `,T.length]}),F.map(e=>(0,W.jsxs)(ze,{active:a===e,onClick:()=>y(e),children:[P[e].label,` `,w[e]]},e))]}),(0,W.jsx)(`input`,{value:d,onChange:e=>b(e.target.value),placeholder:`搜编号 / 标题`,className:`ml-auto h-7 w-40 rounded-lg border border-stone-200 px-2 text-xs outline-none focus:border-stone-400`})]}),(0,W.jsxs)(`p`,{className:`text-[11px] text-stone-400`,children:[n?`只读对照:判定与「质量评审」一致;要改用例回「用例管理」,或在质量评审里点「修改」跳工作台。`:`只读对照:还没评审,先用规则体检结果;要改用例回「用例管理」。`,(0,W.jsx)(`span`,{className:`ml-1 text-stone-300`,children:`拖动表头右边缘可调列宽,双击恢复默认。`})]}),(0,W.jsx)(`div`,{className:`-mt-2 flex justify-end`}),i.length?(0,W.jsx)(`div`,{ref:ee,className:`tw-scroll-x max-h-[calc(100vh-300px)] overflow-auto rounded-xl border border-stone-200 bg-white`,children:(0,W.jsxs)(`table`,{className:`tw-sticky-table table-fixed text-left text-xs`,style:x.tableStyle,children:[(0,W.jsx)(`colgroup`,{children:Z.map(e=>(0,W.jsx)(`col`,{style:x.widthOf(e.key)?{width:x.widthOf(e.key)}:void 0},e.key))}),(0,W.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-[11px] text-stone-500`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsxs)(`th`,{className:h,children:[`用例编号`,(0,W.jsx)(g,{...x.resizeProps(`no`)})]}),(0,W.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`用例标题`,(0,W.jsx)(g,{...x.resizeProps(`title`)})]}),(0,W.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`测试步骤`,(0,W.jsx)(g,{...x.resizeProps(`steps`)})]}),(0,W.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`预期结果`,(0,W.jsx)(g,{...x.resizeProps(`expected`)})]}),(0,W.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium whitespace-nowrap`,children:[`规则判定`,(0,W.jsx)(g,{...x.resizeProps(`verdict`)})]}),(0,W.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`修改建议`,(0,W.jsx)(g,{...x.resizeProps(`suggestions`)})]}),(0,W.jsx)(`th`,{"aria-hidden":`true`})]})}),(0,W.jsxs)(`tbody`,{children:[E.map(e=>{let t=e.verdict;return(0,W.jsxs)(`tr`,{className:`align-top`,children:[(0,W.jsx)(`td`,{className:`${m} tabular-nums text-stone-600`,children:(0,W.jsx)(_,{text:e.no||`—`,className:`block truncate`})}),(0,W.jsxs)(`td`,{className:`px-2.5 py-1.5`,children:[(0,W.jsx)(_,{text:e.title||`(无标题)`,className:`block truncate text-stone-800`}),e.meta?(0,W.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-stone-400`,children:e.meta}):null]}),(0,W.jsx)(`td`,{className:`px-2.5 py-1.5 text-stone-700`,children:(0,W.jsx)(_,{text:e.steps,clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words`})}),(0,W.jsx)(`td`,{className:`px-2.5 py-1.5 text-stone-700`,children:(0,W.jsx)(_,{text:e.expected,clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words`})}),(0,W.jsx)(`td`,{className:`px-2.5 py-1.5`,children:t?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,W.jsxs)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${P[t.verdict].badge}`,children:[P[t.verdict].label,` `,t.score]}),t.hard?(0,W.jsx)(`span`,{className:`rounded border border-rose-200 bg-white px-1 py-0.5 text-[10px] text-rose-600`,children:`硬伤`}):null]}):(0,W.jsx)(`span`,{className:`text-[10px] text-stone-300`,children:`—`})}),(0,W.jsx)(`td`,{className:`px-2.5 py-1.5`,children:e.suggestions.length?(0,W.jsx)(_,{text:e.suggestions.map((e,t)=>`${t+1}. ${e}`).join(`
|
|
2
|
-
`),clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words text-[11px] text-stone-600`}):(0,W.jsx)(`span`,{className:`text-[10px] text-stone-300`,children:`—`})}),(0,W.jsx)(`td`,{"aria-hidden":`true`})]},e.key)}),E.length?null:(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:7,className:`px-3 py-10 text-center text-xs text-stone-400`,children:`没有符合条件的用例`})})]})]})}):(0,W.jsx)(`p`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center text-xs text-stone-400`,children:`没解析到用例行:确认第一行是表头,且有编号与标题列(也认「测试项目 / 用例名称」这类叫法)。支持 md 表格、csv、xlsx。`})]})}function ze({active:e,onClick:t,children:n}){return(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`h-6 rounded-md px-2 text-[11px] transition-colors ${e?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:n})}var Be=[`.md`,`.markdown`,`.txt`,`.csv`],Ve=[`.xlsx`,`.xls`];function He(e){return e.replace(/<br\s*\/?>/gi,`
|
|
3
|
-
`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`).trim()}function Ue(e){return e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(He)}function We(e){return/^\s*\|?[\s-:|]+\|?\s*$/.test(e)&&/-+/.test(e)}function Ge(e){let t=String(e??``).split(/\r?\n/),n=-1,r=[];for(let e=0;e<t.length;e++){if(!t[e].includes(`|`))continue;let i=Ue(t[e]);if(i.some(e=>e.includes(`用例`))&&i.length>=2){n=e,r=i;break}}if(n<0||!r.length)return{headers:[...x],rows:[]};let i=We(t[n+1]??``)?n+2:n+1,a=[];for(let e=i;e<t.length;e++){let n=t[e];if(!n.includes(`|`)||We(n)){if(a.length>0&&!n.includes(`|`))break;continue}let i=Ue(n);if(i.every(e=>!e))continue;let o={};r.forEach((e,t)=>{o[e]=i[t]??``}),Object.values(o).some(e=>e.trim())&&a.push(o)}return{headers:r,rows:a}}function Ke(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=``,i=[],a=!1;for(let e=0;e<t.length;e++){let o=t[e];a?o===`"`?t[e+1]===`"`?(r+=`"`,e+=1):a=!1:r+=o:o===`"`?a=!0:o===`,`?(i.push(r),r=``):o===`
|
|
4
|
-
`||o===`\r`?(o===`\r`&&t[e+1]===`
|
|
5
|
-
`&&(e+=1),i.push(r),r=``,i.some(e=>e.trim())&&n.push(i),i=[]):r+=o}i.push(r),i.some(e=>e.trim())&&n.push(i);let[o,...s]=n,c=(o??[]).map(e=>String(e??``).trim()),l=c.filter(Boolean);return l.length?{headers:l,rows:s.map(e=>{let t={};return c.forEach((n,r)=>{n&&(t[n]=String(e[r]??``).trim())}),t})}:{headers:[...x],rows:[]}}function qe(e){let t=b(e,{type:`base64`,cellDates:!0}),n=t.SheetNames[0],r=n?t.Sheets[n]:void 0;if(!r)return{headers:[...x],rows:[]};let i=y.sheet_to_json(r,{header:1,defval:``,raw:!1,blankrows:!1}),a=(i[0]??[]).map(e=>String(e??``).trim()),o=a.filter(Boolean);if(!o.length)return{headers:[...x],rows:[]};let s=[];for(let e of i.slice(1)){let t={};a.forEach((n,r)=>{n&&(t[n]=String(e[r]??``).trim())}),Object.values(t).some(e=>e.trim())&&s.push(t)}return{headers:o,rows:s}}async function Je(e){let t=`.${(e.split(`.`).pop()??``).toLowerCase()}`;if(Ve.includes(t)){let n=await S(`cases`,e);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取该用例文件`);let r=qe(n.contentBase64);return{ext:t,...r,rows:pe(r.rows)}}if(!Be.includes(t))throw Error(`暂不支持评审 ${t} 文件,请用 md / csv / xlsx`);let{content:n}=await C(`cases`,e),r=t===`.csv`?Ke(n):Ge(n);return{ext:t,...r,rows:pe(r.rows),text:n}}var Ye=`可用工具(只调用这些,不要自己编工具名):
|
|
6
|
-
- case_save_review:提交逐条用例判定(verdict / 五个维度分 / 扣分原因与建议),一次提交整批。
|
|
7
|
-
- case_save_blindspots:提交探测到的场景盲区(四类之一 + 可执行字段),一次提交全部。
|
|
8
|
-
|
|
9
|
-
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,Xe={coverage:`coverage`,steps:`steps`,expected:`expected`,data:`data`,convention:`convention`,需求覆盖:`coverage`,步骤可执行:`steps`,预期可判定:`expected`,数据与边界:`data`,规范完整:`convention`},Ze={nonfunctional:`nonfunctional`,security:`security`,compatibility:`compatibility`,business:`business`,非功能:`nonfunctional`,安全:`security`,兼容:`compatibility`,业务:`business`};function Qe(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function $(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function $e(e,t=0){let n=Number(e);return Number.isFinite(n)?Math.min(100,Math.max(0,Math.round(n))):t}function et(e){let t=$(e,40);return Xe[t]??Xe[t.toLowerCase()]??`expected`}function tt(e){let t=$(e,40);return Ze[t]??Ze[t.toLowerCase()]??`business`}function nt(e){let t=$(e,10).toLowerCase();return t===`high`||t===`medium`||t===`low`?t:`medium`}function rt(e){let t=$(e,4).toUpperCase();return[`P0`,`P1`,`P2`,`P3`].includes(t)?t:`P1`}function it(e){if(!e||typeof e!=`object`)return null;let t=$(e.reason,1e3);if(!t)return null;let n=e;return{dimension:et(n.dimension),points:$e(n.points,0),reason:t,suggestion:$(n.suggestion,1e3)}}function at(e){if(!e||typeof e!=`object`)return null;let t=e,n=$(t.no,80),r=$(t.title,300);if(!n&&!r)return null;let i=t.dimensions&&typeof t.dimensions==`object`?t.dimensions:{},a={};for(let e of L)a[e]=$e(i[e],0);let o=$(t.verdict,20),s=$(t.hard,500),c={no:n,title:r,verdict:o===`usable`||o===`invalid`?o:`revise`,score:$e(t.score,0),dimensions:a,deductions:Array.isArray(t.deductions)?t.deductions.map(it).filter(e=>!!e).slice(0,20):[]};return s&&(c.hard=s),c}function ot(e){if(!e||typeof e!=`object`)return null;let t=e,n=$(t.title,300);if(!n)return null;let r=$(t.id,40);return{id:/^bs_[A-Za-z0-9_-]{4,40}$/.test(r)?r:``,category:tt(t.category),severity:nt(t.severity),title:n,why:$(t.why,1e3),precondition:$(t.precondition,1e3),steps:Array.isArray(t.steps)?t.steps.map(e=>$(e,1e3)).filter(Boolean).slice(0,20):[],expected:$(t.expected,1e3),priority:rt(t.priority),added:!1,caseNo:``}}var st=[{type:`function`,function:{name:`case_save_review`,description:`提交用例质量评审结果:逐条给 verdict、五个维度分与扣分原因/建议。一次提交整批,不要一条调一次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话,指出最该先改的三条`},cases:{type:`array`,items:{type:`object`,properties:{no:{type:`string`,description:`用例编号,原样返回`},title:{type:`string`,description:`用例标题,原样返回`},verdict:{type:`string`,enum:[`usable`,`revise`,`invalid`],description:`可用 / 待修改 / 错误无效(系统最终按维度加权分与 hard 重算,分数与判定要自洽)`},hard:{type:`string`,description:`判「错误无效」时必须写清硬伤证据(与需求哪条冲突 / 和哪条重复);没有硬伤就留空`},dimensions:{type:`object`,description:`五维分数,0–100 整数`,properties:Object.fromEntries(L.map(e=>[e,{type:`number`,description:e}])),required:[...L]},deductions:{type:`array`,items:{type:`object`,properties:{dimension:{type:`string`,enum:[...L]},points:{type:`number`,description:`这一项扣几分`},reason:{type:`string`,description:`具体到位置与原因`},suggestion:{type:`string`,description:`要补什么`}},required:[`dimension`,`reason`]}}},required:[`no`,`verdict`,`dimensions`]}}},required:[`cases`]}}},{type:`function`,function:{name:`case_save_blindspots`,description:`提交场景遗漏补全的盲区清单:四类之一(nonfunctional / security / compatibility / business),每条带可执行字段。补全时带原 id 原地更新。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、四类各几条、风险最高的三条`},items:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`补全已有条目时才带(bs_ 开头)`},category:{type:`string`,enum:[...I]},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`,description:`一句话说清测什么`},why:{type:`string`,description:`为什么人工容易漏`},precondition:{type:`string`,description:`账号 / 数据 / 初始状态`},steps:{type:`array`,items:{type:`string`}},expected:{type:`string`,description:`可判定的预期结果`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`,`P3`]}},required:[`category`,`title`]}}},required:[`items`]}}}];async function ct(e,t,n){let r=Qe(t);if(e===`case_save_review`){let e=(Array.isArray(r.cases)?r.cases:[]).map(at).filter(e=>!!e);return e.length?(n.onCases(e,$(r.summary,2e3)),JSON.stringify({ok:!0,count:e.length,usable:e.filter(e=>e.verdict===`usable`).length,invalid:e.filter(e=>e.verdict===`invalid`).length})):JSON.stringify({ok:!1,error:`没有解析到任何用例判定`})}if(e===`case_save_blindspots`){let e=(Array.isArray(r.items)?r.items:[]).map(ot).filter(e=>!!e).slice(0,300);return e.length?(n.onBlindspots(e,$(r.summary,2e3)),JSON.stringify({ok:!0,count:e.length,categories:I.map(t=>[t,e.filter(e=>e.category===t).length]).filter(([,e])=>Number(e)>0)})):JSON.stringify({ok:!1,error:`没有解析到任何盲区条目`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function lt(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function ut(e){return/\.(xlsx|xlsm|xls)$/i.test(e)}function dt(e,t,n){return ut(e)?[`${n}. ${t===`fix`?`这个文件是 xlsx(二进制):会话里的文件工具一般写不了它。请不要假装写成功,改成把改好的整行按「文件表头顺序」用 markdown 表格贴出来(第一列是原编号),我直接粘回文件。`:`这个文件是 xlsx(二进制):会话里的文件工具一般写不了它。请不要假装写成功,改成把新增的行按「文件表头顺序」用 markdown 表格贴出来(编号按文件规则续),我直接粘进文件。`}`,`${n+1}. 如果确实有 bash / python 能直接改 xlsx,也可以直接改,但改完必须把改动行贴出来让我核对。`]:[`${n}. ${t===`fix`?`改动写回原文件(写之前先备份),写完告诉我改了哪些列、改成什么。`:`写回原文件前先备份,写完告诉我加了哪几条、编号是什么。`}`,`${n+1}. 如果当前会话没有可用的文件工具,把${t===`fix`?`改好的整条用例`:`新行`}按文件表头贴给我,我自己粘回去。`]}function ft(e,t){return e.sessions.find(e=>{let n=e.caseGen?.linkedCasePath;return!!(n&<(n)===t)})}function pt(e){let{verdict:t}=e,n=e.name||e.path.split(`/`).pop()||e.path,r=t.no||`(无编号)`,i=t.title||`(无标题)`,a=t.verdict===`invalid`?`错误无效`:`待修改`,o=[];if(o.push(`帮我改一下用例文件《${n}》里的这一条:${r} ${i}`),o.push(``),o.push(`评审结论:${a}(${t.score} 分)`),t.hard&&o.push(`硬伤:${t.hard}`),t.deductions.length){o.push(``),o.push(`扣分项与建议:`);for(let e of t.deductions)o.push(`- 扣 ${e.points} 分:${e.reason}`),e.suggestion&&o.push(` 建议:${e.suggestion}`)}return e.requirementTitle&&(o.push(``),o.push(`对照需求:${e.requirementTitle}(对不上时以需求分析的验收标准为准)`)),o.push(``),o.push(`要求:`),o.push(`1. 先读一遍这个文件,确认表头与已有用例的写法,只改这一条,其它用例一个字都不要动;`),o.push(`2. 标题、步骤、预期按上面建议补齐,步骤一步一个动作,预期写到可判定的状态 / 文案 / 数值;`),o.push(`3. 我自己也会在「用例管理」里同时改,改动以文件当前内容为准,别按我给的建议覆盖我后来的手改;`),o.push(...dt(n,`fix`,4)),o.join(`
|
|
10
|
-
`)}var mt=[`帮我改一下用例文件`,`帮我把下面`];function ht(e){let t=e.trim();return t.length>240&&mt.some(e=>t.startsWith(e))}async function gt(e,t,r){await le().catch(()=>null),await n().catch(()=>null);let i=lt(e),a=se(),o=ft(a,i);if(o||=(a=M(a,{access:A()}),await j(a),a.sessions.find(e=>e.id===a.activeId)),!o)throw Error(`无法创建或定位会话`);ht(V(o.id))&&B(o.id),H(o.id,{...r,at:Date.now()});try{let e=a.sessions.find(e=>e.id===o.id)??o;sessionStorage.setItem(oe(o.id),JSON.stringify({session:e}))}catch{}let s=`cases`,c=t||i.split(`/`).pop()||i,l=new URLSearchParams({session:o.id,focusRoot:s,focusPath:i,attachRoot:s,attachPath:i,attachName:c});window.location.href=`/workbench/?${l.toString()}`}async function _t(e){let t=e.name||e.path.split(`/`).pop()||e.path;await gt(e.path,e.name,{id:`case-fix:${lt(e.path)}:${e.verdict.no||e.verdict.title}`,label:`修改用例 ${e.verdict.no||e.verdict.title||t}`,detail:`${e.verdict.verdict===`invalid`?`错误无效`:`待修改`} · ${t}`,body:pt(e)})}function vt(e){let t=e.name||e.path.split(`/`).pop()||e.path,n=e.verdicts,r=[];return r.push(`帮我改一下用例文件《${t}》里这 ${n.length} 条评审没通过的用例,其它用例不要动。`),r.push(``),n.forEach((e,t)=>{let n=e.verdict===`invalid`?`错误无效`:`待修改`;r.push(`### ${t+1}. ${e.no||`(无编号)`} ${e.title||`(无标题)`} · ${n} ${e.score}`),e.hard&&r.push(`- 硬伤:${e.hard}`);for(let t of e.deductions)r.push(`- 扣 ${t.points} 分:${t.reason}${t.suggestion?`|建议:${t.suggestion}`:``}`)}),e.requirementTitle&&(r.push(``),r.push(`对照需求:${e.requirementTitle}(对不上时以需求分析的验收标准为准)`)),r.push(``),r.push(`要求:`),r.push(`1. 先读一遍这个文件,按编号定位要改的行,确认表头与已有用例的写法;只改上面列出的这些条,其它行一个字都不要动;`),r.push(`2. 标题、步骤、预期、前置条件按建议补齐:步骤一步一个动作,预期写到可判定的状态 / 文案 / 数值;`),r.push(`3. 我也在「用例管理」里同时手改,改之前先按文件当前内容确认一遍,不要用我早期的版本覆盖后来的手改;`),r.push(`4. 条数多时分包处理(每包 8 条以内),每包处理完先回报「编号 → 改了什么」,不要一口气静默改完;`),r.push(...dt(t,`fix`,5)),r.push(`7. 改完给我一张对照表(编号 / 改前问题 / 改后要点)。`),r.join(`
|
|
11
|
-
`)}async function yt(e){let t=e.name||e.path.split(`/`).pop()||e.path,n=e.verdicts.map(e=>e.no).filter(Boolean).slice(0,3).join(`、`);await gt(e.path,e.name,{id:`case-batch-fix:${lt(e.path)}:${e.verdicts.map(e=>e.no||e.title).join(`,`)}`,label:`批量修改 ${e.verdicts.length} 条用例`,detail:n?`${n}${e.verdicts.length>3?` 等`:``} · ${t}`:t,body:vt(e)})}function bt(e){let t=e.name||e.path.split(`/`).pop()||e.path,n=[];return n.push(`帮我把下面 ${e.items.length} 条「场景补全」用例补进用例文件《${t}》。`),n.push(``),e.requirementTitle&&(n.push(`对照需求:${e.requirementTitle}`),n.push(``)),n.push(`待补进的用例:`),e.items.forEach((e,t)=>{let r=we[e.category];n.push(``),n.push(`### ${t+1}. [${r?.label??e.category}] ${e.title}`),n.push(`- 为什么容易漏:${e.why||`—`}`),n.push(`- 前置条件:${e.precondition||`(待补)`}`),n.push(`- 测试步骤:${e.steps.length?e.steps.map((e,t)=>`${t+1}. ${e}`).join(`;`):`(待补)`}`),n.push(`- 预期结果:${e.expected||`(待补)`}`),n.push(`- 优先级:${e.priority||`P2`}`)}),n.push(``),n.push(`要求:`),n.push(`1. 先读一遍这个文件,看清表头与已有用例的写法(列名可能是项目自己的叫法),只追加这些新用例,原有行一个字都不要动;`),n.push(`2. 按文件已有的列填:标题、前置条件、步骤、预期、优先级、类型、编号都要填,编号沿用文件里的编号规则并避开已用编号;`),n.push(`3. 步骤一步一个动作,预期写到可判定的状态 / 文案 / 数值,缺的信息按需求与用例风格补齐,不要留「待补」;`),n.push(`4. 我自己也会同时手改这个文件,追加前先按当前内容确认编号没有被占用;`),n.push(...dt(t,`add`,5)),n.join(`
|
|
12
|
-
`)}async function xt(e){let t=e.name||e.path.split(`/`).pop()||e.path;await gt(e.path,e.name,{id:`blindspot-writeback:${lt(e.path)}:${e.items.map(e=>e.id).join(`,`)}`,label:`补进 ${e.items.length} 条场景用例`,detail:t,body:bt(e)})}function St(e){return e.replace(/\.[^.]+$/,``).replace(/[\s_\-—·()()[\]【】]/g,``).toLowerCase()}function Ct(e,t){let n=St(t.split(`/`).pop()??t);if(!n)return``;let r=``,i=0;for(let t of e){let e=St(t.title);e.length<4||(n.includes(e)||e.includes(n))&&e.length>i&&(r=t.id,i=e.length)}return r}function wt({open:e,path:t,reviewOn:r,blindspotOn:i,onClose:a,onSaved:c}){let[l,u]=(0,U.useState)(()=>s(`caseReview.tab`,[`quality`,`table`,`blindspot`],`quality`)),d=(0,U.useCallback)(e=>{u(e),o(`caseReview.tab`,e)},[]),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(``),[g,_]=(0,U.useState)(``),[v,y]=(0,U.useState)(null),[b,S]=(0,U.useState)(!1),[C,w]=(0,U.useState)(null),[T,E]=(0,U.useState)(null),[D,te]=(0,U.useState)(null),[A,ne]=(0,U.useState)(null),[re,ie]=(0,U.useState)(!1),[ae,j]=(0,U.useState)(!1),[oe,M]=(0,U.useState)(!1),[se,ce]=(0,U.useState)(``),[le,fe]=(0,U.useState)(``),[pe,N]=(0,U.useState)(0),[ge,P]=(0,U.useState)([]),[ve,F]=(0,U.useState)(0),[I,L]=(0,U.useState)([]),[R,we]=(0,U.useState)(``),[z,Oe]=(0,U.useState)(new Set),B=(0,U.useRef)(null),V=!!(A?.baseURL&&A.apiKey&&A.model),H=(0,U.useCallback)((e,t)=>{fe(e),P([t]),F(0),N(0),ce(``)},[]),G=(0,U.useCallback)(e=>{P(t=>[...t.slice(-11),e])},[]),K=(0,U.useCallback)(()=>{fe(``),ce(``),N(0)},[]),je=(0,U.useCallback)(()=>{B.current&&(B.current.abort(),G(`已请求停止,正在收尾…`))},[G]);(0,U.useEffect)(()=>{if(!le)return;let e=Date.now(),t=window.setInterval(()=>{N(Math.round((Date.now()-e)/1e3))},1e3);return()=>window.clearInterval(t)},[le]);let q=(0,U.useMemo)(()=>{let e=I.find(e=>e.id===R);if(!e)return``;let t=[`# ${e.title}`];for(let n of e.outline)t.push(`- ${n.title}${n.quote?`:${n.quote}`:``}`);for(let n of e.stories)t.push(`- ${n.id} ${n.title}(${n.role})${n.goal?`:${n.goal}`:``}${n.acceptance.length?`;验收:${n.acceptance.map(e=>`${e.given} ${e.when} 则 ${e.then}`).join(` / `)}`:``}`);return t.join(`
|
|
13
|
-
`)},[I,R]);(0,U.useEffect)(()=>(n().then(()=>ne(k())).catch(()=>ne(k())),O(()=>ne(k()))),[]);let Ne=(0,U.useCallback)(async()=>{if(t){p(!0),h(``),_(``);try{let[e,n]=await Promise.all([r?he():Promise.resolve(!1),i?Se():Promise.resolve(!1)]);!e&&!n&&h("评审服务没起来:确认已用 `lantern dev` 启动(插件依赖本地中间件)。");let a=e||n,[o,s]=await Promise.all([Je(t),a?ye(t):Promise.resolve({entry:null,stale:!1})]);if(w(o),y(s.entry?.review?{...s.entry,review:me(s.entry.review,o.rows)}:s.entry),S(s.stale),e&&r&&E(await Te()),n&&i){let e=await be();te(e)}if(e||n)try{L(await Ae())}catch{L([])}else L([]);Oe(new Set)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[t,r,i]);(0,U.useEffect)(()=>{if(!e)return;let t=s(`caseReview.tab`,[`quality`,`table`,`blindspot`],`quality`);d((t===`blindspot`?i:t!==`quality`||r)?t:r?`quality`:`blindspot`),we(``),Ne()},[e,Ne,r,i,d]),(0,U.useEffect)(()=>{if(R&&I.some(e=>e.id===R))return;let e=Ct(I,t);e&&we(e)},[I,t,R]),(0,U.useEffect)(()=>{e||(B.current?.abort(),B.current=null)},[e]);let Pe=(0,U.useMemo)(()=>C?.headers.length?C.headers:[...x],[C]),J=(0,U.useMemo)(()=>C?.headers.length?ue(xe(C.headers)):``,[C]),Y=(0,U.useMemo)(()=>I.find(e=>e.id===R)?.title??``,[I,R]),Ie=(0,U.useMemo)(()=>C?_e(C.rows,q):null,[C,q]),X=v?.review??null,Z=v?.blindspot??null,Q=(0,U.useCallback)(async(e,t,n)=>{if(!A)throw Error(`还没读到模型设置`);let r=new AbortController;B.current=r;let i=``;for await(let a of ee(A,[{role:`system`,content:`${e}\n\n${Ye}`},{role:`user`,content:t}],r.signal,{tools:st,runTool:(e,t)=>ct(e,t,{onCases:(e,t)=>{n.cases.push(...e),t&&(n.summary=t);let r=n.cases.length+n.items.length;F(r),G(`模型交回 ${e.length} 条判定(累计 ${r} 条)`)},onBlindspots:(e,t)=>{n.items.push(...e),t&&(n.summary=t);let r=n.cases.length+n.items.length;F(r),G(`模型交回 ${e.length} 条盲区(累计 ${r} 条)`)}})}))a.type===`content`&&(i=`${i}${a.delta}`.slice(-400),ce(i))},[A,G]),Le=(0,U.useCallback)((e,t)=>{let n=t.length?t:x;return e.map((e,t)=>{let r=[`### ${t+1}`];for(let t of n){let n=String(e[t]??``).trim();n&&r.push(`${t}:${n}`)}return r.join(`
|
|
14
|
-
`)}).join(`
|
|
15
|
-
|
|
16
|
-
`)},[]),ze=(0,U.useCallback)(async()=>{if(!C)return;let e=_e(C.rows,q);if(!C.rows.length)h(`这个文件里没解析到用例行:确认第一行是表头,且有编号与标题列(「测试项目 / 用例名称」这类叫法也认)。`);else{ie(!0),h(``),H(`评审用例`,`开始评审 ${C.rows.length} 条用例(规则 + 模型)`);try{if(!V){G(`没有配置模型,只跑规则判定`);let n=de(e),r=await Ee(t,{review:n});y(r),S(!1),c?.(),_(`没有配置模型,已保存纯规则结果。`);return}let n=T?.review?.trim();if(!n)throw Error(`没有读到「用例质量评审提示词.md」的「评审」段,先到插件页把插件关掉再打开重新生成。`);G(`规则体检完成:${e.cases.length} 条,按五维拼提示词`);let r=Le(C.rows,C.headers),i=n.replaceAll(`{{cases}}`,`见用户消息里的 ${C.rows.length} 条用例`).replaceAll(`{{requirement}}`,q||`(未挂对照需求)`).replaceAll(`{{template}}`,Pe.join(` / `)).replaceAll(`{{fields}}`,J),a=[`## 对照需求`,q||`(未挂对照需求,只按用例自身结构评)`,``,`## 用例字段`,Pe.join(` / `),``,`## 字段对照`,J||`(按文件里的实际表头读)`,``,`## 待评审用例(${C.rows.length} 条)`,r].join(`
|
|
17
|
-
`),o={cases:[],items:[],summary:``};if(G(`提示词已就绪,等待模型返回…`),await Q(i,a,o),!o.cases.length)throw Error(`模型没有提交判定结果,可以重试一次或换成更擅长的模型。`);G(`正在按规则复算分数并落盘…`);let s=De(e,o.cases,o.summary),l=await Ee(t,{review:s});y(l),S(!1),c?.(),_(`评审完成:${s.cases.length} 条,可用 ${s.counts.usable} · 待修改 ${s.counts.revise} · 错误无效 ${s.counts.invalid}。`)}catch(e){B.current?.signal.aborted?_(`已停止评审,本次结果没有保存;已有报告保持不变。`):h(e instanceof Error?e.message:String(e))}finally{ie(!1),K(),B.current=null}}},[C,q,V,T,Le,Pe,J,Q,t,c,H,G,K]),Be=(0,U.useCallback)(async()=>{if(C){j(!0),h(``),H(`探测场景盲区`,`开始对照需求检查 ${C.rows.length} 条用例的盲区`);try{if(!V)throw Error(`场景探测需要模型,请先在设置里配置。`);let e=D?.detect?.trim();if(!e)throw Error(`没有读到「场景遗漏补全提示词.md」的「探测」段,先到插件页把插件关掉再打开重新生成。`);let n=e.replaceAll(`{{cases}}`,`见用户消息里的 ${C.rows.length} 条用例`).replaceAll(`{{requirement}}`,q||`(未挂对照需求)`).replaceAll(`{{fields}}`,J),r=[`## 对照需求`,q||`(未挂对照需求)`,``,`## 字段对照`,J||`(按文件里的实际表头读)`,``,`## 已有用例(${C.rows.length} 条)`,Le(C.rows,C.headers)].join(`
|
|
18
|
-
`),i={cases:[],items:[],summary:``};if(G(`上下文:需求${q?`已挂`:`未挂`} · 四类盲区 · ${C.rows.length} 条已有用例`),await Q(n,r,i),!i.items.length)throw Error(`模型没有提交盲区条目,可以重试一次。`);G(`正在去重并落盘探测结果…`);let a=new Map((v?.blindspot?.items??[]).map(e=>[`${e.category}|${e.title}`,e])),o=new Set,s=[];for(let e of i.items){let t=`${e.category}|${e.title}`;if(o.has(t))continue;o.add(t);let n=a.get(t);s.push({...e,id:n?.id||e.id||`bs_${Math.random().toString(16).slice(2,18)}`,added:n?.added??!1,caseNo:n?.caseNo??``})}let l={at:new Date().toISOString(),context:{reqRef:R,reqTitle:I.find(e=>e.id===R)?.title??``},items:s,summary:i.summary},u=await Ee(t,{blindspot:l});y(u),S(!1),c?.(),_(`探测完成:${s.length} 条盲区。`)}catch(e){B.current?.signal.aborted?_(`已停止探测,本次结果没有保存。`):h(e instanceof Error?e.message:String(e))}finally{j(!1),K(),B.current=null}}},[C,V,D,q,J,Le,v,R,I,Q,t,c,H,G,K]),Ve=(0,U.useCallback)(async()=>{if(!Z)return;let e=Z.items.filter(e=>z.has(e.id));if(e.length){M(!0),h(``),H(`补全选中条目`,`把 ${e.length} 条盲区补全为完整用例(前置 / 步骤 / 预期)`);try{if(!V)throw Error(`补全需要模型,请先在设置里配置。`);let n=D?.complete?.trim();if(!n)throw Error(`没有读到「场景遗漏补全提示词.md」的「补全」段,先到插件页把插件关掉再打开重新生成。`);let r=n.replaceAll(`{{selected}}`,`见用户消息里的 ${e.length} 条`),i=[`## 需要补全的条目`,JSON.stringify(e.map(e=>({id:e.id,category:e.category,title:e.title,why:e.why,precondition:e.precondition,steps:e.steps,expected:e.expected,priority:e.priority})),null,2)].join(`
|
|
19
|
-
`),a={cases:[],items:[],summary:``};if(await Q(r,i,a),!a.items.length)throw Error(`模型没有返回补全结果,可以重试一次。`);let o=new Map(a.items.map(e=>[e.id,e])),s=Z.items.map(e=>{let t=o.get(e.id);return t?{...e,...t,id:e.id,category:e.category,added:e.added,caseNo:e.caseNo}:e}),l=await Ee(t,{blindspot:{...Z,items:s,summary:a.summary||Z.summary}});y(l),c?.(),_(`已补全 ${a.items.length} 条,确认后可写回用例文件。`)}catch(e){B.current?.signal.aborted?_(`已停止补全,本次结果没有保存。`):h(e instanceof Error?e.message:String(e))}finally{M(!1),K(),B.current=null}}},[Z,z,V,D,Q,t,c,H,K]),He=(0,U.useCallback)(()=>{if(!Z)return;let e=Z.items.filter(e=>z.has(e.id)&&!e.added);e.length&&(h(``),xt({path:t,name:t.split(`/`).pop()??t,items:e,requirementTitle:Y}).catch(e=>h(e instanceof Error?e.message:String(e))))},[Z,z,t,Y]),Ue=(0,U.useCallback)(e=>{Oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),We=(0,U.useCallback)((e,t)=>{Oe(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},[]),Ge=(0,U.useCallback)(e=>{_t({path:t,name:t.split(`/`).pop()??t,verdict:e,requirementTitle:Y}).catch(e=>h(e instanceof Error?e.message:String(e)))},[t,Y]),Ke=(0,U.useCallback)(e=>{e.length&&yt({path:t,name:t.split(`/`).pop()??t,verdicts:e,requirementTitle:Y}).catch(e=>h(e instanceof Error?e.message:String(e)))},[t,Y]),qe=X?X.counts.revise+X.counts.invalid:0,Xe=[{key:`quality`,label:`质量评审${X?` · 需改 ${qe}`:``}`},{key:`table`,label:`用例表格${C?` ${C.rows.length}`:``}`},{key:`blindspot`,label:`场景补全${Z?.items.length?` ${Z.items.length}`:``}`}],Ze=t.split(`/`).pop()??t;return(0,W.jsxs)(ke,{open:e,onClose:a,title:`用例评审 · ${Ze}`,widthClass:`max-w-5xl`,children:[!r||!i?(0,W.jsxs)(`p`,{className:`text-[11px] text-stone-400`,children:[`未启用`,r?``:`「用例质量评审」`,!r&&!i?` / `:``,i?``:`「场景遗漏补全」`,`插件:到插件页开启后才能用对应 Tab。`]}):null,(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg bg-stone-100 p-0.5`,children:Xe.map(e=>{let t=e.key===`quality`&&!r||e.key===`blindspot`&&!i;return(0,W.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>d(e.key),className:`h-7 rounded-md px-2.5 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${l===e.key?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:e.label},e.key)})}),Y?(0,W.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-stone-400`,children:[`已挂:`,Y]}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-amber-700`,children:`未匹配到需求(覆盖率不计)`})]}),le?(0,W.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,W.jsx)(`span`,{className:`tw-lib-spin shrink-0`,style:{width:14,height:14,borderWidth:2},"aria-hidden":`true`}),(0,W.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[le,`中…`]}),(0,W.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[pe,`s`]}),ve?(0,W.jsxs)(`span`,{className:`text-stone-500`,children:[`已收到 `,ve,` 条`]}):null,(0,W.jsx)(`button`,{type:`button`,onClick:je,className:`ml-auto h-6 shrink-0 rounded-md border border-rose-200 px-2 text-[11px] text-rose-600 transition-colors hover:bg-rose-50`,children:`停止`})]}),(0,W.jsx)(`div`,{className:`tw-run-track mt-2`,children:(0,W.jsx)(`div`,{className:`tw-run-fill tw-run-fill--indeterminate`})}),(0,W.jsxs)(`div`,{className:`mt-1.5 space-y-0.5`,children:[ge.slice(-3).map((e,t)=>(0,W.jsxs)(`div`,{className:`truncate text-[10px] text-stone-400`,children:[`· `,e]},`${t}-${e}`)),se?(0,W.jsx)(`div`,{className:`line-clamp-2 text-[10px] leading-4 text-stone-500`,children:se}):null]})]}):null,b?(0,W.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-800`,children:`文件在评审后改过,结论可能已过期;重新评审可刷新。`}):null,g?(0,W.jsx)(`p`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-[11px] text-emerald-700`,children:g}):null,m&&C?(0,W.jsx)(`p`,{className:`rounded-lg border border-rose-200 bg-rose-50 px-3 py-2 text-[11px] whitespace-pre-wrap text-rose-700`,children:m}):null,f?(0,W.jsx)(`p`,{className:`py-10 text-center text-xs text-stone-400`,children:`读取中…`}):m&&!C?(0,W.jsx)(`div`,{className:`rounded-xl border border-rose-200 bg-rose-50 px-4 py-6 text-center text-xs text-rose-700 whitespace-pre-wrap`,children:m}):l===`quality`?(0,W.jsx)(Me,{review:X,running:re,modelReady:V,onRun:ze,onStop:je,onFix:Ge,onFixBatch:Ke,onExport:()=>Ce(Ze,X,Z)}):l===`table`?(0,W.jsx)(Re,{file:C,audit:Ie,review:X,fileName:Ze}):(0,W.jsx)(Fe,{report:Z,loading:f,running:ae,completing:oe,modelReady:V,onStop:je,selected:z,onToggle:Ue,onToggleCategory:We,onDetect:Be,onComplete:Ve,onWriteback:He,onExport:()=>Ce(Ze,X,Z)})]})}var Tt=10;function Et(e){let t=e.split(`/`).pop()??e;return t.startsWith(`~$`)||t.startsWith(`.~`)}async function Dt(e=`.`){let{entries:t}=await D(`cases`,e),n=[];for(let e of t)e.type===`file`?!Et(e.path)&&!Et(e.name)&&n.push(e):n.push(...await Dt(e.path));return n}function Ot(){let e=ie(`cases`),[t,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!0),[l,u]=(0,U.useState)(!1),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)({}),[g,_]=(0,U.useState)(``),[y,b]=(0,U.useState)(e?!0:null),[x,ee]=(0,U.useState)(()=>e??[]),[S,C]=(0,U.useState)({}),[D,O]=(0,U.useState)(null),[k,A]=(0,U.useState)(!1),[j,oe]=(0,U.useState)(null),M=re(x,Tt,`cases`),se=(0,U.useCallback)(async()=>{O(null);let e=await Dt(`.`);ee(e),ne(`cases`,e),C(t=>{let n={};for(let r of e)t[r.path]&&(n[r.path]=!0);return n})},[]);(0,U.useEffect)(()=>{let e=i(e=>{c(!!e.cases),u(!!e.caseReview),p(!!e.caseBlindspot)});return n().then(()=>{c(r(`cases`)),u(r(`caseReview`)),p(r(`caseBlindspot`)),o(!0)}),e},[]);let ue=(0,U.useCallback)(async()=>{if(!l&&!f)h({});else try{let e=await Oe();h(Object.fromEntries(e.map(e=>[e.path,e])))}catch{h({})}},[l,f]);(0,U.useEffect)(()=>{t&&s&&y!==!1&&ue()},[t,s,y,ue]),(0,U.useEffect)(()=>{t&&s&&(async()=>{if(!await E(`cases`))b(!1);else try{await le().catch(()=>null),await se(),b(!0)}catch(e){O(e instanceof Error?e.message:String(e)),b(!0)}})()},[t,s,se]);let de=(0,U.useMemo)(()=>Object.keys(S).filter(e=>S[e]),[S]);async function fe(){let e=j;if(e){oe(null),A(!0),O(null);try{if(e.kind===`one`)await T(`cases`,e.entry.path);else{for(let t of e.paths)await T(`cases`,t);C({})}await se(),v(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个用例文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);O(t),v(`删除失败:${t}`,`error`)}finally{A(!1)}}}let pe=j?.kind===`one`?`删除「${j.entry.name}」?将从 ${te(`cases`)} 中移除。`:j?.kind===`batch`?`确认删除已选中的 ${j.paths.length} 个用例文件?此操作不可恢复。`:``;function me(){r(`caseGen`)?window.location.href=`/workbench/?plugin=caseGen`:O(a(`caseGen`))}async function he(e){A(!0),O(null);try{await ce(`cases`,e)}catch(e){O(e instanceof Error?e.message:String(e)),A(!1)}}async function N(e){let t=typeof e==`string`?e:e.path;O(null);try{await w(`cases`,t)}catch(e){O(e instanceof Error?e.message:String(e))}}return t?s?y===null?(0,W.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,W.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,W.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):y?(0,W.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,W.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,W.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[M.query.trim()?(0,W.jsxs)(W.Fragment,{children:[`匹配 `,(0,W.jsx)(`span`,{className:`font-medium text-stone-800`,children:M.filtered.length}),` 个`,(0,W.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,x.length]})]}):(0,W.jsxs)(W.Fragment,{children:[`共 `,(0,W.jsx)(`span`,{className:`font-medium text-stone-800`,children:x.length}),` 个文件`]}),de.length>0?(0,W.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,de.length]}):null]}),(0,W.jsx)(`button`,{type:`button`,disabled:k||de.length===0,onClick:()=>oe({kind:`batch`,paths:de}),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,W.jsx)(`button`,{type:`button`,disabled:k,onClick:me,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:`生成用例`})]}),D?(0,W.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:D}):null,(0,W.jsx)(ae,{files:x,filtered:M.filtered,pageFiles:M.pageFiles,query:M.query,onQuery:M.setQuery,sortBy:M.sortBy,onSortBy:M.setSortBy,page:M.page,totalPages:M.totalPages,pageSize:M.pageSize,onPage:M.setPage,onPageSize:M.setPageSize,busy:k,emptyText:`暂无用例文件,点击「生成用例」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,resizeKey:`docs:cases:cols:v1`,extraColumn:l||f?{header:`评审`,render:e=>{let t=m[e.path];if(!t)return(0,W.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`—`});let n=t.score;return(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[n==null?(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:`未评审`}):(0,W.jsxs)(`span`,{className:`shrink-0 text-[11px] font-medium tabular-nums ${n==null?`text-stone-500`:n>=85?`text-emerald-700`:n>=60?`text-amber-700`:`text-rose-700`}`,children:[n,` 分`]}),t.blindspotCount?(0,W.jsxs)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:[`补 `,t.blindspotCount]}):null,t.stale?(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] text-amber-600`,children:`过期`}):null]})}}:void 0,selected:S,onToggleRow:e=>C(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>C(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void N(e),renderActions:e=>(0,W.jsxs)(W.Fragment,{children:[l||f?(0,W.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>_(e.path),className:`text-xs whitespace-nowrap text-stone-700 border border-stone-200 px-2 py-1 rounded hover:bg-stone-50 cursor-pointer disabled:opacity-40`,children:`评审`}):null,(0,W.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void he(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,W.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>oe({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,W.jsx)(d,{open:j!=null,title:j?.kind===`batch`?`批量删除`:`删除用例文件`,message:pe,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>oe(null),onConfirm:()=>void fe()}),(0,W.jsx)(wt,{open:!!g,path:g,reviewOn:l,blindspotOn:f,onClose:()=>{_(``),ue()},onSaved:()=>void ue()})]}):(0,W.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,W.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`cases`)}):(0,W.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,W.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,W.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{Ot as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{showToast as c}from"./Toast.BO2NFckG.js";import{l,n as u,r as d,s as f}from"./project-docs.Cd2gKPKh.js";import{n as p}from"./doc-roots.DAJP9Svr.js";import{i as m,n as h,r as g,t as _}from"./DocsFileBrowser.-dkkxR4X.js";import{t as v,u as y}from"./open-docs-in-session.B6uyOxPn.js";var b=e(t(),1),x=o(),S=10;async function C(e=`.`){let{entries:t}=await f(`knowledge`,e),n=[];for(let e of t)e.type===`file`?e.name.endsWith(`.md`)&&n.push(e):n.push(...await C(e.path));return n}function w({staticCount:e=0,base:t}){let o=g(`knowledge`),[f,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)(o?!0:null),[k,A]=(0,b.useState)(()=>o??[]),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)({}),[L,R]=(0,b.useState)(null),z=h(k,S,`knowledge`),B=(0,b.useCallback)(async()=>{M(null);try{let e=await C(`.`);A(e),m(`knowledge`,e)}catch(e){M(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=i(e=>E(!!e.knowledgeLib));return n().then(()=>{E(r(`knowledgeLib`)),w(!0)}),e},[]),(0,b.useEffect)(()=>{f&&T&&(async()=>{await d(`knowledge`)?(await y().catch(()=>null),await B(),O(!0)):O(!1)})()},[f,T,B]);let V=(0,b.useMemo)(()=>Object.keys(F).filter(e=>F[e]),[F]);function H(){r(`knowledgeGen`)?window.location.href=`${t}workbench/?plugin=knowledgeGen`:M(a(`knowledgeGen`))}async function U(e){P(!0),M(null);try{await l(`knowledge`,e.path)}catch(e){M(e instanceof Error?e.message:String(e))}finally{P(!1)}}async function W(e){P(!0),M(null);try{await v(`knowledge`,e)}catch(e){M(e instanceof Error?e.message:String(e)),P(!1)}}async function G(){let e=L;if(e){R(null),P(!0),M(null);try{if(e.kind===`one`)await u(`knowledge`,e.entry.path);else{for(let t of e.paths)await u(`knowledge`,t);I({})}await B(),c(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个知识库文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),c(`删除失败:${t}`,`error`)}finally{P(!1)}}}let K=L?.kind===`one`?`删除「${L.entry.name}」?将从 ${p(`knowledge`)} 中移除。`:L?.kind===`batch`?`确认删除已选中的 ${L.paths.length} 个知识库文件?此操作不可恢复。`:``;return f?T?D===null?(0,x.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,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):D?(0,x.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[z.query.trim()?(0,x.jsxs)(x.Fragment,{children:[`匹配 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:z.filtered.length}),` 个`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,k.length]})]}):(0,x.jsxs)(x.Fragment,{children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:k.length}),` 个知识库文件`]}),V.length>0?(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,V.length]}):null]}),(0,x.jsx)(`button`,{type:`button`,disabled:N||V.length===0,onClick:()=>R({kind:`batch`,paths:V}),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,x.jsx)(`button`,{type:`button`,disabled:N,onClick:H,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:`生成知识库`})]}),j?(0,x.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:j}):null,(0,x.jsx)(_,{resizeKey:`docs:knowledge:cols:v1`,files:k,filtered:z.filtered,pageFiles:z.pageFiles,query:z.query,onQuery:z.setQuery,sortBy:z.sortBy,onSortBy:z.setSortBy,page:z.page,totalPages:z.totalPages,pageSize:z.pageSize,onPage:z.setPage,onPageSize:z.setPageSize,busy:N,emptyText:`暂无知识库文件,点击「生成知识库」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selected:F,onToggleRow:e=>I(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>I(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void U(e),renderBadge:e=>{let t=e.path.includes(`/`)?e.path.split(`/`)[0]:``;return t?(0,x.jsx)(`span`,{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-800 border border-amber-100`,children:t}):null},renderActions:e=>(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>void W(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>R({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,x.jsx)(s,{open:L!=null,title:L?.kind===`batch`?`批量删除`:`删除知识库文件`,message:K,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>R(null),onConfirm:()=>void G()})]}):(0,x.jsxs)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:[`知识库管理需要本地文档服务,当前未就绪`,e>0?`(构建期约有 ${e} 份文档可浏览)`:``,`。`]}):(0,x.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`knowledgeLib`)}):(0,x.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,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PluginsPage.Bhyuqbq0.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,p as r}from"./app-config.CF1xVPmo.js";import{a as i,i as a,n as o,o as s,s as c}from"./plugins.DYyAjBXb.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ee}from"./ConfirmDialog.CsMwWevK.js";import{showToast as u}from"./Toast.BO2NFckG.js";import{i as te}from"./case-types.DS1EQ5yP.js";import{_ as ne,f as re,l as ie,m as ae,n as d,r as oe,s as f,u as p}from"./project-docs.Cd2gKPKh.js";import{n as se}from"./doc-roots.DAJP9Svr.js";import{a as ce,c as m,d as le,i as h,l as g,o as _,s as v,u as y}from"./prompts-meta.C_MeYq8G.js";import{i as ue,n as de,r as fe,t as pe}from"./DocsFileBrowser.-dkkxR4X.js";import{t as me,u as he}from"./open-docs-in-session.B6uyOxPn.js";import{E as ge,T as _e,i as ve,r as ye}from"./case-review.DYyZat83.js";import{a as be,w as xe}from"./req-analysis.CkLx8c9E.js";import{r as Se}from"./report-prompt.CAfZ6RIo.js";import{g as Ce,s as we}from"./ui-auto.BmC9JJ_X.js";import{_ as Te,d as Ee,o as De,t as Oe}from"./story-review.C5gzEzBP.js";import{t as b}from"./NamePromptDialog.CS1pTTVl.js";import{m as x}from"./PmShared.DbDseTcc.js";var S=e(t(),1),C=`tw.prompts.mounted.v1`;function ke(){try{let e=sessionStorage.getItem(r(C));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 Ae(e){try{sessionStorage.setItem(r(C),JSON.stringify(e))}catch{}}var w=l(),je=10;async function T(e=`.`){let{entries:t}=await f(`prompts`,e),n=[];for(let e of t)e.type===`file`?n.push(e):n.push(...await T(e.path));return n}function Me({path:e,enabled:t,mounted:n}){let r=y(e,n);if(!r)return(0,w.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`未关联`});if(r===`system`)return(0,w.jsx)(`span`,{className:`text-[11px] text-stone-600`,children:`系统默认`});let i=o(r)?.name??r,a=t[r]===!0,s=_(e,n);return(0,w.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`truncate text-[11px] text-stone-600`,children:i}),s&&a?(0,w.jsx)(`span`,{className:`shrink-0 rounded bg-(--tw-accent-soft) px-1 text-[10px] text-(--tw-accent)`,children:`引用中`}):null]})}function E(){let e=fe(`prompts`),[t,r]=(0,S.useState)(!1),[l,f]=(0,S.useState)(!0),[_,C]=(0,S.useState)(e?!0:null),[E,Ne]=(0,S.useState)(()=>e??[]),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)({}),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)(()=>i()),[L,Pe]=(0,S.useState)(()=>ke()),[R,z]=(0,S.useState)(null),[B,V]=(0,S.useState)(null),[H,U]=(0,S.useState)(``),W=de(E,je,`prompts`),G=(0,S.useRef)(!1),K=(0,S.useRef)(!1),q=(0,S.useRef)(!1),J=(0,S.useRef)(!1),Y=(0,S.useRef)(!1),X=(0,S.useCallback)(async()=>{O(null);try{let e=await T(`.`);Ne(e),ue(`prompts`,e)}catch(e){O(e instanceof Error?e.message:String(e))}},[]);(0,S.useEffect)(()=>{_&&F.reqAnalysis===!0&&!G.current&&(E.some(e=>e.name===`需求分析提示词.md`)||(G.current=!0,xe(!0).then(()=>X()).catch(()=>void 0)))},[_,F.reqAnalysis,E,X]),(0,S.useEffect)(()=>{_&&F.storyReview===!0&&!K.current&&(E.some(e=>e.name===`用户故事审查提示词.md`)||(K.current=!0,De(!0).then(()=>X()).catch(()=>void 0)))},[_,F.storyReview,E,X]),(0,S.useEffect)(()=>{_&&F.testPoints===!0&&!q.current&&(E.some(e=>e.name===`测试点生成提示词.md`)||(q.current=!0,Te(!0).then(()=>X()).catch(()=>void 0)))},[_,F.testPoints,E,X]),(0,S.useEffect)(()=>{_&&F.caseReview===!0&&!J.current&&(E.some(e=>e.name===`用例质量评审提示词.md`)||(J.current=!0,ge(!0).then(()=>X()).catch(()=>void 0)))},[_,F.caseReview,E,X]),(0,S.useEffect)(()=>{_&&F.caseBlindspot===!0&&!Y.current&&(E.some(e=>e.name===`场景遗漏补全提示词.md`)||(Y.current=!0,_e(!0).then(()=>X()).catch(()=>void 0)))},[_,F.caseBlindspot,E,X]),(0,S.useEffect)(()=>{let e=s(e=>{f(!!e.prompts),I(e)});return n().then(()=>{f(a(`prompts`)),I(i()),r(!0)}),e},[]),(0,S.useEffect)(()=>{t&&l&&(async()=>{await oe(`prompts`)?(await he().catch(()=>null),await X(),C(!0)):C(!1)})()},[t,l,X]);let Z=(0,S.useCallback)(async()=>{let e=await we(),t=a(`reports`),n=t?await Se().catch(()=>null):null;Pe(r=>{let i={};if(e)for(let t of e)i[m(t)]=`uiAuto`;else for(let[e,t]of Object.entries(r))t===`uiAuto`&&(i[e]=t);if(t){if(n?.promptFile)i[m(n.promptFile)]=`reports`;else for(let[e,t]of Object.entries(r))t===`reports`&&(i[e]=t)}if(F.reqAnalysis&&(i[m(be)]=`reqAnalysis`),F.storyReview&&(i[m(Oe)]=`storyReview`),F.testPoints&&(i[m(Ee)]=`testPoints`),F.caseReview&&(i[m(ve)]=`caseReview`),F.caseBlindspot&&(i[m(ye)]=`caseBlindspot`),F.caseGen)for(let e of te()){let t=(e.promptPath??``).trim();t&&(i[m(t)]=`caseGen`)}return Ae(i),i})},[F.reqAnalysis,F.storyReview,F.testPoints,F.caseReview,F.caseBlindspot,F.caseGen]);(0,S.useEffect)(()=>{if(!t||!l)return;Z();let e=()=>{document.visibilityState===`visible`&&Z()};document.addEventListener(`visibilitychange`,e);let n=Ce(()=>void Z());return()=>{document.removeEventListener(`visibilitychange`,e),n()}},[t,l,F.uiAuto,F.reports,F.reqAnalysis,F.storyReview,F.testPoints,F.caseReview,F.caseBlindspot,F.caseGen,Z]);let Q=(0,S.useMemo)(()=>Object.keys(j).filter(e=>j[e]),[j]),$=(0,S.useCallback)(e=>{let t=y(e,L);return!t||t===`system`||le(e)?``:F[t]===!0?t:``},[L,F]);async function Fe(e){A(!0),O(null);try{await ie(`prompts`,e.path)}catch(e){O(e instanceof Error?e.message:String(e))}finally{A(!1)}}async function Ie(e){A(!0),O(null);try{await me(`prompts`,e)}catch(e){O(e instanceof Error?e.message:String(e)),A(!1)}}function Le(e){if(v(e.path)){O(`默认提示词不可删除`);return}if(h(e.path,F)){O(g(e.path,F));return}let t=$(e.path);if(t){let e=o(t)?.name??t;O(`这份提示词正被「${e}」的项目挂载,先在那里换一份再删除`)}else P({kind:`one`,entry:e})}function Re(e){if(v(e.path)){O(`默认提示词不可改名`);return}if(h(e.path,F)){O(g(e.path,F));return}let t=$(e.path);if(t){let e=o(t)?.name??t;O(`这份提示词正被「${e}」的项目挂载,先在那里换一份再改名`)}else z(e),U(``)}function ze(e){V(e),U(``)}async function Be(){let e=N;if(e){P(null),A(!0),O(null);try{if(e.kind===`one`)await d(`prompts`,e.entry.path);else{let t=0;for(let n of e.paths)v(n)||h(n,F)||$(n)?t+=1:await d(`prompts`,n);t&&O(`有 ${t} 个提示词仍被插件或项目引用,已跳过;先解除引用再删。`),M({})}await X(),u(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个提示词`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);O(t),u(`删除失败:${t}`,`error`)}finally{A(!1)}}}function Ve(){a(`promptGen`)?window.location.href=`/workbench/?plugin=promptGen`:O(c(`promptGen`))}let He=(0,S.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=E.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[E]);async function Ue(e){let t=R;if(!t)return;let n=e.trim();if(!n||n===t.name){z(null),U(``);return}let r=He(p(t.path),n,t.path);if(r)U(`已存在同名文件「${r}」,换个名字再试`);else{A(!0),U(``);try{await ae(`prompts`,t.path,n),z(null),await X(),u(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);U(t),u(`重命名失败:${t}`,`error`)}finally{A(!1)}}}async function We(e){let t=B;if(!t)return;let n=e.trim();if(!n)return;let r=He(p(t.path),n);if(r)U(`已存在同名文件「${r}」,换个名字再试`);else{A(!0),U(``);try{let{content:e}=await re(`prompts`,t.path);await ne(`prompts`,p(t.path)===`.`?n:`${p(t.path)}/${n}`,e),V(null),await X(),u(`已复制为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);U(t),u(`复制失败:${t}`,`error`)}finally{A(!1)}}}let Ge=N?.kind===`one`?`删除「${N.entry.name}」?将从 ${se(`prompts`)} 中移除。`:N?.kind===`batch`?`确认删除已选中的 ${N.paths.length} 个提示词?此操作不可恢复。`:``;return t?l?_===null?(0,w.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,w.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,w.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):_?(0,w.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,w.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,w.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[W.query.trim()?(0,w.jsxs)(w.Fragment,{children:[`匹配 `,(0,w.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.filtered.length}),` 个`,(0,w.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,E.length]})]}):(0,w.jsxs)(w.Fragment,{children:[`共 `,(0,w.jsx)(`span`,{className:`font-medium text-stone-800`,children:E.length}),` 个提示词`]}),Q.length>0?(0,w.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Q.length]}):null]}),(0,w.jsx)(`button`,{type:`button`,disabled:k||Q.length===0,onClick:()=>P({kind:`batch`,paths:Q}),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,w.jsx)(`button`,{type:`button`,disabled:k,onClick:Ve,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:`生成提示词`})]}),D?(0,w.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:D}):null,(0,w.jsx)(pe,{resizeKey:`docs:prompts:cols:v1`,files:E,filtered:W.filtered,pageFiles:W.pageFiles,query:W.query,onQuery:W.setQuery,sortBy:W.sortBy,onSortBy:W.setSortBy,page:W.page,totalPages:W.totalPages,pageSize:W.pageSize,onPage:W.setPage,onPageSize:W.setPageSize,busy:k,emptyText:`暂无提示词,点击「生成提示词」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selectable:e=>!ce(e.path,F)&&!$(e.path),selected:j,onToggleRow:e=>M(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>M(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void Fe(e),extraColumn:{header:`关联插件`,render:e=>(0,w.jsx)(Me,{path:e.path,enabled:F,mounted:L})},renderNameAction:e=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,disabled:k,"aria-label":`重命名 ${e.name}`,onClick:()=>Re(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,w.jsx)(x,{name:`pencil`,size:12})}),(0,w.jsx)(`button`,{type:`button`,disabled:k,"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,w.jsx)(x,{name:`copy`,size:12})})]}),renderActions:e=>{let t=ce(e.path,F)||!!$(e.path);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void Ie(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,w.jsx)(`button`,{type:`button`,disabled:k||t,"aria-label":`删除 ${e.name}`,onClick:()=>Le(e),className:`tw-icon-danger inline-flex h-6 w-6 items-center justify-center rounded`,children:(0,w.jsx)(x,{name:`trash`,size:12})})]})}}),(0,w.jsx)(b,{open:R!=null,title:`重命名提示词`,label:`文件名称`,initialValue:R?.name??``,lockExtension:!0,confirmLabel:`保存`,error:H,onClose:()=>{z(null),U(``)},onConfirm:e=>void Ue(e)}),(0,w.jsx)(b,{open:B!=null,title:`复制提示词`,label:`新文件名称`,initialValue:B?B.name.replace(/(\.[^.]+)?$/,e=>`(副本)${e}`):``,lockExtension:!0,confirmLabel:`复制`,error:H,onClose:()=>{V(null),U(``)},onConfirm:e=>void We(e)}),(0,w.jsx)(ee,{open:N!=null,title:N?.kind===`batch`?`批量删除`:`删除提示词`,message:Ge,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>P(null),onConfirm:()=>void Be()})]}):(0,w.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,w.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:c(`prompts`)}):(0,w.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,w.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,w.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{E as default};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.DYyAjBXb.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as ee}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as p}from"./Toast.BO2NFckG.js";import{s as te}from"./llm.BZEzE0x2.js";import{f as ne,l as re,p as ie}from"./settings.BvxRxdqa.js";import{E as m,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,l as ge,m as h,n as g,o as _,p as _e,r as ve,s as ye,t as v,u as be,v as xe,w as Se,x as Ce,y as we}from"./req-analysis.CkLx8c9E.js";import{_ as Te,a as Ee,c as De,d as Oe,f as ke,g as Ae,h as je,i as Me,l as y,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,u as b}from"./story-review.C5gzEzBP.js";import{t as ze}from"./hydrate-cache.CmC22o_H.js";import{O as Be,S as x,_ as Ve,g as He,m as S,u as Ue}from"./PmShared.DbDseTcc.js";var C=e(t(),1),We=`可用工具(只调用这些,不要自己编工具名):
|
|
2
|
-
- req_set_outline:提交本批「需求条目」,返回每个条目的 id。
|
|
3
|
-
- req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
|
|
4
|
-
- req_save_check:提交体检结果(缺口清单 + 结论)。
|
|
5
|
-
- req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
|
|
6
|
-
|
|
7
|
-
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,Ge=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function Ke(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function w(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function T(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function qe(e){let t=w(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function E(e){let t=w(e,40);return Ge.includes(t)?t:`other`}var D=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function O(e){let t=w(e,40);if(D.includes(t))return t;let n=w(e,20);return D.find(e=>Re[e]===n)??`functional`}function k(e){let t=w(e,4).toUpperCase();return b.includes(t)?t:`P1`}function A(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=w(n.title,200);if(!r)return null;let i=w(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:O(n.dimension),priority:k(n.priority),title:r,precondition:w(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>w(e,500)).filter(Boolean).slice(0,20):[],expected:w(n.expected,1e3)}}var Je=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:Ge},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:D,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:b},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function Ye(e,t,n){let r=Ke(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>T(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=w(e.title,200)||w(e.quote,200);if(!r||a.has(T(r)))continue;a.add(T(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:w(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=xe(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=ue(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[T(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=w(n.title,200);if(!r)continue;let i=w(n.storyId,20),o=a.has(i)&&i||t.get(T(w(n.storyTitle,200)))||``,c=E(n.type);s.push({id:h(c,o,r),storyId:o,type:c,severity:qe(n.severity),title:r,detail:w(n.detail,1e3),suggestion:w(n.suggestion,1e3),origin:`model`,selected:!1})}let c=se(e.gaps,s),l=w(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>A(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:w(r.summary,2e3),points:a})).testPoints?.points??a,s=D.map(e=>({dimension:Re[e],count:o.filter(t=>t.dimension===e).length})),c=b.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function j(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function Xe(e){let t=j(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}function Ze(e,t=[]){let n=new Set(t),r=j(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>A(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?w(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var M=u(),N=`text-xs font-semibold tracking-wide text-stone-500`,P=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Qe=`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 $e({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,M.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始审查`})]});let c=Ee(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Pe(e.gaps),ee=new Map(t.map(e=>[e.id,e.title]));return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:N,children:`需求条目覆盖率`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,M.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,M.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,M.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,M.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,M.jsxs)(`div`,{className:`text-right`,children:[(0,M.jsx)(`p`,{className:N,children:`缺口`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,M.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,M.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsx)(`p`,{className:N,children:`维度覆盖`}),(0,M.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,M.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,M.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,M.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,M.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:Qe,onClick:s,children:`导出 Markdown`}),(0,M.jsx)(`button`,{type:`button`,className:Qe,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,M.jsx)(`button`,{type:`button`,className:P,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,M.jsx)(F,{gap:e,storyTitle:ee.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,M.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function F({gap:e,storyTitle:t,onToggle:n}){return(0,M.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(x,{tone:g[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:ve[e.type]}),e.storyId?(0,M.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,M.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var I=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,L=`text-xs font-semibold tracking-wide text-stone-500`;function R({point:e}){return(0,M.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function z({doc:e}){let t=Ae(e.testPoints);return(0,M.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,M.jsxs)(`div`,{className:`min-w-[860px]`,children:[(0,M.jsx)(`div`,{className:`flex justify-center`,children:(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5 text-center shadow-sm`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title||`未命名分析`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`测试点 `,e.testPoints?.points.length??0,` 条 · 五维覆盖`]})]})}),(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 right-[10%] left-[10%] h-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsx)(`div`,{className:`grid grid-cols-5 gap-3`,children:t.map(e=>{let t=De[e.key];return(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:t.label})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,M.jsx)(`div`,{className:`space-y-1.5 px-2 py-2`,children:e.points.length?e.points.map(e=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority}),(0,M.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-stone-700`,children:e.title})]}),(0,M.jsx)(f,{text:`${e.storyId||`全局`}${e.expected?` · ${e.expected}`:``}`,className:`mt-1 block truncate text-[10px] text-stone-400`})]},e.id)):(0,M.jsx)(`p`,{className:`py-2 text-center text-[11px] text-stone-300`,children:`无`})})]})]},e.key)})})]}),(0,M.jsx)(`p`,{className:`mt-3 text-center text-[11px] text-stone-400`,children:`分支 = 五个维度,叶子 = 测试点;左侧标签为优先级。需要完整结构可导出 XMind。`})]})})}function et({doc:e}){let t=Ae(e.testPoints);return(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-stone-100 px-3.5 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${De[e.key].accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-stone-700`,children:e.label}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.points.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`details`,{className:`group px-3.5 py-2`,children:[(0,M.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority})}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`font-mono`,children:e.storyId||`全局`}),(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,M.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,M.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,M.jsx)(R,{point:e})})]})},e.id))}):(0,M.jsx)(`p`,{className:`px-3.5 py-3 text-xs text-stone-400`,children:`本维度没有测试点。`})]},e.key))})}function tt({doc:e,generating:t,busy:n,promptReady:r,onGenerate:i,onExportXmind:a,onExportMarkdown:o}){let[s,c]=(0,C.useState)(`map`),l=e.testPoints,u=ke(l);if(!l){let n=e.stories.length?r?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`基于拆好的用户故事,按功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度拆测试点,每条标 P0–P3;结果可看导图、可下载 XMind。`}),n?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:n}):null,(0,M.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:t?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:u.total}),` 条`]}),(0,M.jsx)(`span`,{className:`flex items-center gap-1`,children:b.map(e=>(0,M.jsxs)(x,{tone:y[e].tone,children:[e,` `,u.byPriority[e]]},e))}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,u.coveredDimensions,`/5`]}),(0,M.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,M.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${s===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>c(e.id),children:e.label},e.id))}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:i,children:t?`生成中…`:`重新生成`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:a,children:`导出 XMind`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:o,children:`导出 Markdown`})]})]}),s===`map`?(0,M.jsx)(z,{doc:e}):(0,M.jsx)(et,{doc:e}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:L,children:`生成说明`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:l.at})]}),(0,M.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-stone-600`,children:l.summary||`(模型没有给整体结论)`})]})]})}var nt=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],B=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,V=`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`,rt=`text-[11px] font-medium tracking-wide text-stone-400`,it={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function U({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,M.jsx)(`p`,{className:`${rt} pt-0.5`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function at(e){return e.split(`
|
|
8
|
-
`).map(e=>e.trim()).filter(Boolean)}function W({label:e,value:t,placeholder:n,onChange:r}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsxs)(`span`,{className:H,children:[e,`(一行一条)`]}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[64px]`,value:t.join(`
|
|
9
|
-
`),placeholder:n,onChange:e=>r(at(e.target.value))})]})}function ot({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`主流程(一行一步:动作 -> 结果)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
|
|
10
|
-
`),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(at(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 st({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
11
|
-
`)).join(`
|
|
12
|
-
|
|
13
|
-
`);return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
|
|
14
|
-
1. 提交后进入人工队列
|
|
15
|
-
2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
|
|
16
|
-
`).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function ct({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`异常场景(一行一条:场景 -> 预期)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
|
|
17
|
-
`),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(at(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 lt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`验收标准(一行一条:Given | When | Then)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
|
|
18
|
-
`),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(at(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function ut({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(!1),[p,te]=(0,C.useState)(e),[ne,re]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(l||d){re(!0);return}let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},[l,d]);let ie=()=>{te({...e}),f(!0),u(!0)},m=e=>te(t=>({...t,...e})),ae=r.filter(e=>e.severity===`high`).length;return(0,M.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,M.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${it[e.priority]}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,M.jsx)(x,{tone:_[e.priority],children:e.priority}),(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,M.jsxs)(x,{tone:ae?`red`:`amber`,children:[r.length,` 个缺口`,ae?` · 高 ${ae}`:``]}):null]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`}),l?null:(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):ie(),children:(0,M.jsx)(S,{name:`pencil`,size:14})}),(0,M.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,M.jsx)(S,{name:`trash`,size:14})}),(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,M.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,M.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[ne&&d?(0,M.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`标题`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.title,onChange:e=>m({title:e.target.value})})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`角色`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.role,onChange:e=>m({role:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`优先级`}),(0,M.jsx)(`div`,{className:`mt-1`,children:(0,M.jsx)(ee,{options:nt,value:p.priority,onChange:e=>m({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`目标`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.goal,onChange:e=>m({goal:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`价值 / 备注`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.value,onChange:e=>m({value:e.target.value})})]}),(0,M.jsx)(W,{label:`前置条件`,value:p.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>m({preconditions:e})}),(0,M.jsx)(ot,{value:p.mainFlow,onChange:e=>m({mainFlow:e})}),(0,M.jsx)(st,{value:p.altFlows,onChange:e=>m({altFlows:e})}),(0,M.jsx)(ct,{value:p.exceptions,onChange:e=>m({exceptions:e})}),(0,M.jsx)(W,{label:`后置条件`,value:p.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>m({postconditions:e})}),(0,M.jsx)(lt,{value:p.acceptance,onChange:e=>m({acceptance:e})}),(0,M.jsx)(W,{label:`覆盖维度`,value:p.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>m({dimensions:e})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>f(!1),children:`取消`}),(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!p.title.trim(),onClick:()=>{a(p),f(!1)},children:`保存`})]})]})]}):null,ne&&!d?(0,M.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,M.jsx)(U,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,M.jsx)(U,{label:`前置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,M.jsx)(U,{label:`主流程`,children:(0,M.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.actor?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,M.jsx)(U,{label:`替代流程`,children:(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,M.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,M.jsx)(U,{label:`异常场景`,children:(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.scenario,e.expected?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,M.jsx)(U,{label:`后置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,M.jsx)(U,{label:`验收标准`,children:(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,M.jsx)(`span`,{children:e.given||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,M.jsx)(`span`,{children:e.when||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,M.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,M.jsx)(U,{label:`覆盖维度`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,M.jsx)(U,{label:`来源条目`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,M.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,M.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,M.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,M.jsx)(x,{tone:g[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`text-stone-500`,children:ve[e.type]}),(0,M.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var dt=`reqanalysis.doc`,ft=`reqanalysis.listmode`,pt=`reqanalysis.view`,mt=`reqanalysis.tab`,ht=`reqanalysis.storykeyword`,gt=[`list`,`work`],_t=[`stories`,`check`,`outline`,`points`],vt=`reqanalysis.activity`,yt=[`info`,`tool`,`done`,`error`];function bt(e){return`${vt}.${e}`}function xt(e){if(!e)return[];let t=l(bt(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`&&yt.includes(t.kind)}).slice(-200):[]}var St=/\.[a-z0-9]+$/i,Ct={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},wt=`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`,Tt=`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`,Et=`text-xs font-semibold tracking-wide text-stone-500`;function Dt(e){return e.split(`/`).pop()||e}function Ot(e){return e.replace(St,``)}function kt(e){return(e.format||Dt(e.path).split(`.`).pop()||``).toLowerCase()}function At(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 jt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Mt({name:e,ready:t}){return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Nt(){let e=Be(`reqAnalysis`),t=Be(`storyReview`),l=Be(`testPoints`),[u,se]=(0,C.useState)(null),[h,g]=(0,C.useState)([]),[_,ve]=(0,C.useState)(``),[v,Ee]=(0,C.useState)(null),[De,ke]=(0,C.useState)([]),[Ae,y]=(0,C.useState)(``),[Pe,Re]=(0,C.useState)(``),[b,Ge]=(0,C.useState)(null),[Ke,w]=(0,C.useState)(null),[T,qe]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(null),[N,P]=(0,C.useState)([]),[Qe,F]=(0,C.useState)(``),[I,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(()=>o(mt,_t,`stories`));(0,C.useEffect)(()=>{i(mt,R)},[R]);let[et,nt]=(0,C.useState)(`list`),B=(0,C.useRef)(o(pt,gt,`list`)),[V,H]=(0,C.useState)(()=>B.current===`work`),[rt,it]=(0,C.useState)(()=>o(ft,[`doc`,`story`],`doc`)),[U,at]=(0,C.useState)(()=>c(ht,``));(0,C.useEffect)(()=>{s(ht,U)},[U]);let[W,ot]=(0,C.useState)(null),[st,ct]=(0,C.useState)([]),lt=(0,C.useRef)(``),[vt,yt]=(0,C.useState)(``),[St,Nt]=(0,C.useState)(!1),[Pt,Ft]=(0,C.useState)(!1),G=(0,C.useRef)(null),K=(0,C.useRef)(null),It=(0,C.useRef)(0),Lt=(0,C.useRef)(null),Rt=(0,C.useRef)(null),zt=(0,C.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?ye[e]:ye.decomposed,[t.on]),Bt=(0,C.useMemo)(()=>{let e=e=>+!e.supported;return[...De].sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=kt(e),n=Ct[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[De]),q=(0,C.useCallback)(e=>{G.current=e,Ee(e),g(t=>jt(t.map(t=>t.id===e.id?e:t)))},[]),J=(0,C.useCallback)((e,t=`info`)=>{It.current+=1,P(n=>[...n,{id:It.current,kind:t,text:e,at:new Date().toISOString()}])},[]),Vt=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!_){Vt.current=!0,P([]);return}let e=xt(_);It.current=e.reduce((e,t)=>Math.max(e,t.id),0),Vt.current=!0,P(e)},[_]),(0,C.useEffect)(()=>{Vt.current?Vt.current=!1:_&&a(bt(_),N.slice(-200))},[N,_]);let Y=(0,C.useCallback)(e=>{G.current=e,Ee(e),ve(e?.id??``),s(dt,e?.id??``),e?.sourcePath&&y(e.sourcePath)},[]),X=(0,C.useCallback)(e=>{nt(e),i(pt,e)},[]),Z=(0,C.useCallback)((e,t=`stories`)=>{Y(e),z(t),X(`work`),ze(`req-analysis`)},[X,Y]),Ht=(0,C.useCallback)((e,t)=>{lt.current=t,Z(e,`stories`)},[Z]);(0,C.useEffect)(()=>{if(et!==`work`||!lt.current)return;let e=lt.current;lt.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)}},[et,v?.id]);let Ut=(0,C.useMemo)(()=>h.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[h]),Wt=Ut.length,Gt=(0,C.useMemo)(()=>{let e=U.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?Ut.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(e.title)):Ut,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))},[Ut,U]),Kt=(0,C.useMemo)(()=>new Set(W?.ids??[]),[W]),qt=(0,C.useCallback)((e,t)=>{ot(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})},[]),Jt=(0,C.useCallback)((e,t)=>{ot(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Yt=(0,C.useCallback)(e=>{it(e),i(ft,e)},[]);(0,C.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;Ge(re());let t=await fe();if(e&&(se(t),t))try{let[t,n,r,i]=await Promise.all([me(),_e(),Me(),je()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await Se(!0).catch(()=>void 0),a=await _e()),!e)return;w(a);let o=r;if((!r.exists||!r.review.trim())&&(await Fe(!0).catch(()=>void 0),o=await Me()),!e)return;o.exists&&qe(o),i.exists&&D(i);let s=jt(t);g(s);let l=c(dt,``),u=s.find(e=>e.id===l)??s[0]??null;Y(u);let d=B.current;B.current=`list`,d===`work`&&u&&l&&u.id===l&&(X(`work`),ze(`req-analysis`)),H(!1)}catch(t){e&&(H(!1),L(t instanceof Error?t.message:String(t)))}})();let t=ne(()=>Ge(re()));return()=>{e=!1,t()}},[X,Y]),(0,C.useEffect)(()=>{if(!t.ready)return;if(!t.on){qe(null),z(e=>e===`check`?`stories`:e);return}if(!u||T!==null)return;let e=!0;return(async()=>{let t=await Me();(!t.exists||!t.review.trim())&&(await Fe(!0).catch(()=>void 0),t=await Me()),e&&qe(t)})(),()=>{e=!1}},[t.ready,t.on,u,T]),(0,C.useEffect)(()=>{if(!l.ready)return;if(!l.on){D(null),z(e=>e===`points`?`stories`:e);return}if(!u||E!==null)return;let e=!0;return(async()=>{let t=await je();(!t.exists||!t.generate.trim())&&(await Te(!0).catch(()=>void 0),t=await je()),e&&D(t)})(),()=>{e=!1}},[l.ready,l.on,u,E]),(0,C.useEffect)(()=>{if(!u)return;let e=!0;return pe().then(t=>{e&&ke(t)}).catch(t=>{e&&Re(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[u]),(0,C.useEffect)(()=>{let e=v?.sourcePath;if(!e){yt(``);return}let t=!0;return le(e).then(e=>{t&&yt(Ce(e))}).catch(()=>{t&&yt(``)}),()=>{t=!1}},[v?.sourcePath,v?.sourceHash]),(0,C.useEffect)(()=>{let e=Lt.current;e&&(e.scrollTop=e.scrollHeight)},[N]);let Xt=!!(v?.sourceHash&&vt&&v.sourceHash!==vt),Zt=(0,C.useMemo)(()=>new Set((v?.stories??[]).flatMap(e=>e.sourceRefs)),[v?.stories]),Qt=Ke??null,$t=!!Qt?.decompose.trim(),en=(0,C.useMemo)(()=>(v?.check?.gaps??[]).filter(e=>e.selected).length,[v?.check]),Q=(0,C.useCallback)(async(e,t)=>{let n=t??G.current;if(!n)throw Error(`还没有分析文档`);let r=await m(n.id,e);return q(r),r},[q]),tn=(0,C.useCallback)(()=>{Rt.current&&window.clearTimeout(Rt.current),Rt.current=window.setTimeout(()=>{let e=G.current;e?.check&&m(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),nn=(0,C.useCallback)(async e=>{if(!e)return null;let t=h.find(t=>t.sourcePath===e);if(t)return Z(t,`stories`),t;try{let t=await le(e),n=Dt(e),r=await ge({sourcePath:e,sourceTitle:n,sourceHash:Ce(t),title:Ot(n)});return g(e=>jt([r,...e])),Z(r,`stories`),J(`新建分析:${r.title}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),p(t,`error`),y(G.current?.sourcePath??``),null}},[h,Z,J]),rn=!!(b?.baseURL&&b.apiKey&&b.model),an=(0,C.useCallback)(()=>!rn||!b?(p(`请先在设置里配置模型`,`error`),ie(`model`),null):b,[rn,b]),$=(0,C.useCallback)((e,t)=>({getDoc:()=>G.current,batch:t,saveOutline:async t=>{let n=await m(e.id,{outline:t});return q(n),n.outline},saveStories:async t=>{let n=await m(e.id,{stories:t});return q(n),J(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=G.current?.check,r={...t,gaps:we(n?.gaps??[],t.gaps)},i=await m(e.id,{check:r,status:`checked`});return q(i),i},saveTestPoints:async t=>{let n=await m(e.id,{testPoints:t});return q(n),n}}),[q,J]),on=(0,C.useCallback)(async()=>{let e=G.current,n=an();if(!e||!n)return;let r=Qt?.decompose.trim()??``;if(!r){p(`没有读到「${ce}」的「## 拆解」段落`,`error`);return}L(``),F(``),P([]),k(`decompose`),j({label:`拆解`,done:0,total:0,message:`正在读取来源文档`});let i=new AbortController;K.current=i;try{let a=await m(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:0,message:`正在读取来源文档`,at:new Date().toISOString()}});q(a);let o=await le(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=ae(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);j({label:`拆解`,done:0,total:s.length,message:`共 ${s.length} 批,准备拆第 1 批`}),J(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await m(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:Ce(o)});q(c);for(let t of s){if(i.signal.aborted)break;let a=G.current?.stories.length??0,o=[r,``,We,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(G.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
19
|
-
`)||`(本批还没有条目,先调用 req_set_outline)`].join(`
|
|
20
|
-
`),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
|
|
21
|
-
`);await Q({progress:{stage:`stories`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},G.current).catch(()=>void 0),j({label:`拆解`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`});let l=``;for await(let r of te(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Je,maxToolRounds:20,runTool:(n,r)=>Ye(n,r,$(e,t.index))}))r.type===`content`?(l+=r.delta,F(e=>e+r.delta)):r.type===`tool`&&r.status===`running`&&J(`调用 ${r.name}`,`tool`);if((G.current?.stories.length??0)===a){let n=Xe(l);if(n.length){let t=xe(G.current?.stories??[],n),r=await m(e.id,{stories:t});q(r),J(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else J(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}j({label:`拆解`,done:t.index+1,total:s.length,message:`第 ${t.index+1}/${s.length} 批已写入`})}if(i.signal.aborted){J(`已中断:已经写入的故事保留`,`info`);return}let l=await m(e.id,{status:`decomposed`,progress:{stage:`done`,done:s.length,total:s.length,message:`拆解完成`,at:new Date().toISOString()}});q(l),J(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),z(`stories`),t.on&&!i.signal.aborted?(p(`拆解完成,接着做用户故事审查`,`success`),await cn.current?.(!0)):p(`拆解完成`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?J(`已中断:已经写入的故事保留`,`info`):(L(t),J(`拆解失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,q,J,Qt,an,t.on,Q]),sn=(0,C.useCallback)(async(e=!1)=>{let t=G.current;if(!t)return;if(!t.stories.length){e||p(`还没有用户故事,先做一次拆解`,`info`);return}L(``),e||(F(``),P([])),k(`audit`),j({label:`审查用户故事`,done:0,total:2,message:`正在跑规则体检`});let n=new AbortController;K.current=n;try{let e=ue(t),r=await m(t.id,{check:{...e,gaps:we(t.check?.gaps??[],e.gaps)},status:`checked`,progress:{stage:`audit`,done:0,total:1,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});q(r),J(`规则体检:覆盖率 ${Math.round(e.coverage.rate*100)}%,${e.gaps.length} 个缺口`),j({label:`审查用户故事`,done:1,total:2,message:`规则体检完成,等待模型评审`});let i=T?.review.trim()??``,a=rn?b:null;if(!a||!i){J(a?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),z(`check`);return}let o=!1,s=$(t,90),c=s.saveCheck;s.saveCheck=async e=>{o=!0;let t=await c(e);return J(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let l=G.current??r,u=[`## 需求条目`,l.outline.length?l.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
22
|
-
`):`(无)`,``,`## 用户故事(${l.stories.length} 条)`,"```json",JSON.stringify(l.stories,null,2),"```"].join(`
|
|
23
|
-
`);for await(let e of te(a,[{role:`system`,content:`${i}\n\n${We}`},{role:`user`,content:u}],n.signal,{tools:Je.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Ye(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);o||(J(`模型没有提交体检结果,当前只保留规则结果`,`error`),p(`模型没有提交体检结果,只保留了规则检查`,`error`)),j({label:`审查用户故事`,done:2,total:2,message:o?`模型评审完成`:`已保留规则结果`}),z(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?J(`已中断:规则体检结果已保留`,`info`):(L(t),J(`体检失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,rn,q,J,T,b]),cn=(0,C.useRef)(null);cn.current=sn;let ln=(0,C.useCallback)(async()=>{let e=G.current,t=an();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){p(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=T?.fix.trim()??``;if(!r){p(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}L(``),F(``),P([]),k(`fix`);let i=new AbortController;K.current=i;try{J(`按 ${n.length} 个勾选缺口补写`,`info`);let a=new Map(e.stories.map(e=>[e.id,e.title])),o=[`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${a.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
|
|
24
|
-
`)}).join(`
|
|
25
|
-
`)].join(`
|
|
26
|
-
`),s=$(e,90),c=!1,l=s.saveStories;s.saveStories=async e=>(c=!0,l(e));for await(let e of te(t,[{role:`system`,content:`${r}\n\n${We}`},{role:`user`,content:o}],i.signal,{tools:Je.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Ye(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);if(!c){J(`模型没有提交补写结果,故事集保持不变`,`error`),p(`模型没有提交补写结果`,`error`);return}let u=G.current;if(u){let e=ue(u),t=await m(u.id,{check:e,status:`decomposed`});q(t)}J(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`),z(`check`),p(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?J(`已中断:已经写入的改动保留`,`info`):(L(t),J(`补写失败:${t}`,`error`))}finally{k(null),K.current=null}},[$,q,J,an,T]),un=(0,C.useCallback)(async()=>{let e=G.current,t=an();if(!e||!t)return;if(!e.stories.length){p(`还没有用户故事,先做一次拆解`,`info`);return}let n=E?.generate.trim()??``;if(!n){p(`没有读到「${Oe}」的「## 生成」段落`,`error`);return}L(``),F(``),P([]),k(`testpoints`),z(`points`),j({label:`生成测试点`,done:0,total:2,message:`正在整理用户故事,等待模型生成`}),await Q({progress:{stage:`points`,done:0,total:2,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0),J(`开始生成测试点(五维覆盖,P0–P3)`,`info`);let r=new AbortController;K.current=r;try{let i=$(e,90),a=!1,o=i.saveTestPoints;i.saveTestPoints=async e=>{a=!0,j({label:`生成测试点`,done:1,total:2,message:`正在写入测试点`});let t=await o(e);return J(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let s=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
27
|
-
`):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
|
|
28
|
-
`),c=``;for await(let e of te(t,[{role:`system`,content:`${n}\n\n${We}`},{role:`user`,content:s}],r.signal,{tools:Je.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>Ye(e,t,i)}))e.type===`content`?(c+=e.delta,F(t=>t+e.delta)):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);if(!a){let t=Ze(c,e.stories.map(e=>e.id));t&&(await i.saveTestPoints(t),a=!0,J(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!a)J(`模型没有提交测试点,原结果保持不变`,`error`),p(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=G.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;J(`测试点完成:${e.length} 条(P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)})`,`done`),j({label:`生成测试点`,done:2,total:2,message:`已生成 ${e.length} 条`}),await Q({progress:{stage:`done`,done:2,total:2,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},G.current).catch(()=>void 0),p(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);r.signal.aborted?J(`已中断:已经生成的测试点保留`,`info`):(L(t),J(`生成测试点失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,J,an,Q,E]),dn=(0,C.useCallback)(async()=>{let e=G.current;if(!e?.testPoints)p(`还没有测试点可导出`,`info`);else try{let t=await Ne(e);J(`已导出 ${t}`,`done`)}catch(e){p(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[J]),fn=(0,C.useCallback)(()=>{let e=G.current;if(!e?.testPoints){p(`还没有测试点可导出`,`info`);return}let t=Ie(e);J(`已导出 ${t}`,`done`)},[J]),pn=(0,C.useCallback)(async e=>{let t=G.current;if(t)try{await Q({stories:e},t)}catch(e){p(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Q]),mn=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);pn(r)},[pn]),hn=(0,C.useCallback)(e=>{let t=G.current;t&&pn(t.stories.filter((t,n)=>n!==e))},[pn]),gn=(0,C.useCallback)((e,t)=>{let n=G.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,pn(i))},[pn]),_n=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};q(r),tn()},[q,tn]),vn=(0,C.useCallback)(e=>{let t=G.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};q(n),tn()},[q,tn]),yn=(0,C.useCallback)(e=>{let t=G.current,n=e.trim();t&&n&&n!==t.title&&Q({title:n},t).catch(()=>void 0)},[Q]),bn=(0,C.useCallback)(async()=>{let e=G.current;if(e)try{await be(e.id);let t=h.filter(t=>t.id!==e.id);g(t),Y(t[0]??null),X(`list`),p(`已删除分析记录`,`success`)}catch(e){p(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{Nt(!1)}},[X,h,Y]),xn=(0,C.useCallback)(()=>{let e=G.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=de(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),p(`已导出 Markdown`,`success`)},[]),Sn=(0,C.useCallback)(()=>{let e=G.current;if(!e?.check)return;let t=Le(e,e.check);p(`已导出 ${t}`,`success`)},[]),Cn=(0,C.useCallback)(()=>{K.current?.abort()},[]);if(!e.ready)return(0,M.jsx)(He,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(Ve,{children:r(`reqAnalysis`)});if(u===null)return(0,M.jsx)(He,{label:`正在连接需求分析服务`});if(!u)return(0,M.jsx)(Ve,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(V)return(0,M.jsx)(He,{label:`正在回到上次的分析`});let wn=v?.outline.filter(e=>Zt.has(e.id)).length??0,Tn=v?.check?.gaps??[],En=(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,M.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,M.jsx)(`p`,{className:Et,children:`新建分析`}),(0,M.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,M.jsx)(ee,{options:Bt,value:Ae,onChange:e=>{y(e),e&&nn(e)},triggerTitle:Ae||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,M.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,h.length,` 份分析`]})]}),Pe?(0,M.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Pe,(0,M.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,he,` 之外的内容目录没有被移动。`]}):null]}),I?(0,M.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>Yt(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${rt===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Yt(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${rt===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),rt===`story`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(S,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:U,onChange:e=>at(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[Wt,` 个故事`,W?` · 已选 ${W.ids.length}`:``]}),(0,M.jsx)(`button`,{type:`button`,disabled:!W,onClick:()=>{if(!W)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:W.docId,stories:W.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${wt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,M.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[h.length,` 份分析 · `,Wt,` 个故事`]})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:rt===`doc`?h.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:h.map(e=>{let t=zt(e.status);return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>Z(e,`stories`),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),(0,M.jsx)(x,{tone:t.tone,children:t.label})]}),(0,M.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,M.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,M.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,M.jsx)(`span`,{children:At(e.updatedAt)})]})]})}),(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>Z(e,`stories`),children:[`用户故事`,(0,M.jsx)(S,{name:`chevronRight`,size:13})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{Y(e),Nt(!0)},children:(0,M.jsx)(S,{name:`trash`,size:14})})]},e.id)})}):(0,M.jsx)(Ue,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):Gt.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:Gt.map(({doc:e,rows:t})=>{let n=st.includes(e.id),r=t.map(e=>e.story.id),i=W?.docId===e.id&&r.length>0&&r.every(e=>Kt.has(e));return(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${e.title} 的全部故事`,checked:i,onChange:()=>Jt(e.id,r)}),(0,M.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>ct(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,M.jsx)(S,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:e.title}),(0,M.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,At(e.updatedAt)]})]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>Z(e,`stories`),children:`打开拆解`})]}),n?null:(0,M.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:Kt.has(t.id)&&W?.docId===e.id,onChange:()=>qt(e.id,t.id)}),(0,M.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>Ht(e,t.id),children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,M.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,M.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,M.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,M.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,M.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,M.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,M.jsx)(Ue,{icon:`file`,title:U?`没有匹配的用户故事`:`还没有用户故事`,hint:U?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[et===`list`?En:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{y(``),L(``),X(`list`)},children:[(0,M.jsx)(S,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:v?.title?`用户故事 · ${v.title}`:`用户故事`})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,M.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,M.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Et,children:`分析记录`}),(0,M.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:h.length})]}),(0,M.jsx)(`div`,{className:`px-2 py-2`,children:h.length?(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:h.map(e=>{let t=e.id===_,n=zt(e.status);return(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>Y(e),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(f,{text:e.title,matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,M.jsx)(x,{tone:n.tone,children:n.label}),(0,M.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,M.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Et,children:`提示词`})}),(0,M.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(Mt,{name:ce,ready:$t}),(0,M.jsx)(Mt,{name:T?.file??`用户故事审查提示词.md`,ready:t.on&&!!T?.review.trim()&&!!T?.fix.trim()}),(0,M.jsx)(Mt,{name:Oe,ready:l.on&&!!E?.generate.trim()})]}),(0,M.jsx)(`p`,{className:`mt-2 text-[11px] ${rn?`text-stone-400`:`text-amber-700`}`,children:rn?`模型:${b?.model}`:`还没配置模型`})]})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Et,children:`动作`})}),(0,M.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,M.jsx)(`button`,{type:`button`,className:`${wt} w-full`,disabled:!v||!!O||!v.sourcePath,onClick:()=>{v?.stories.length?Ft(!0):on()},children:O===`decompose`?`拆解中…`:v?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void sn(),children:O===`audit`?`审查中…`:v?.check?`重新审查用户故事`:`用户故事审查`}):null,l.on?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void un(),children:O===`testpoints`?`生成中…`:v?.testPoints?`重新生成测试点`:`生成测试点`}):null,O?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,onClick:Cn,children:`中断`}):(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v,onClick:xn,children:`导出 Markdown`}),v&&!O?(0,M.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>Nt(!0),children:`删除这份分析`}):null]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Et,children:`活动日志`}),N.length?(0,M.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>P([]),children:`清空`}):null]}),(0,M.jsx)(`div`,{ref:Lt,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:N.length?N.map(e=>(0,M.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:`text-stone-500`,children:e.text})]},e.id)):(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[I?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,v?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{className:`min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-[15px] font-semibold text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,defaultValue:v.title,"aria-label":`分析标题`,onBlur:e=>yn(e.target.value)},v.id),O?(0,M.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),A?A.message:O===`decompose`?`拆解中`:O===`audit`?`审查中`:O===`testpoints`?`生成测试点中`:O===`fix`?`补写中`:`处理中`,A&&A.total>0?(0,M.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(A.done,A.total)/A.total*100),`%`]}):null]}):null,(0,M.jsx)(x,{tone:zt(v.status).tone,children:zt(v.status).label})]}),O?(0,M.jsx)(`div`,{className:`mt-2`,children:(0,M.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${A?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A&&A.total>0?Math.round(Math.min(A.done,A.total)/A.total*100):void 0,children:(0,M.jsx)(`div`,{className:A&&A.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:A&&A.total>0?{width:`${Math.round(Math.min(A.done,A.total)/A.total*100)}%`}:void 0})})}):null,(0,M.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.stories.length})]}),(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,M.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[wn,`/`,v.outline.length]}),` `,`覆盖`]}),t.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:Tn.length}),en?` · 已选 ${en}`:``]}),v.check?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.check.coverage.total?`${Math.round(v.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,l.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.testPoints?.points.length??0})]})]}):null,(0,M.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,v.sourcePath]}),Xt?(0,M.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,M.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:v.stories.length},{id:`check`,label:`审查结果`,count:Tn.length},{id:`outline`,label:`需求条目`,count:v.outline.length},{id:`points`,label:`测试点`,count:v.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||l.on)).map(e=>{let t=R===e.id;return(0,M.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>z(e.id),children:[e.label,(0,M.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[R===`stories`?v.stories.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.stories.map((e,t)=>(0,M.jsx)(ut,{story:e,index:t,total:v.stories.length,gaps:Tn.filter(t=>t.storyId===e.id),busy:!!O,onSave:e=>mn(t,e),onDelete:()=>hn(t),onMove:e=>gn(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,R===`check`&&t.on?(0,M.jsx)($e,{check:v.check,stories:v.stories,busy:!!O,onToggleGap:_n,onToggleAll:vn,onFix:()=>void ln(),onReview:()=>void sn(),onExport:Sn}):null,R===`points`&&l.on?(0,M.jsx)(tt,{doc:v,generating:O===`testpoints`,busy:!!O,promptReady:!!E?.generate.trim(),onGenerate:()=>void un(),onExportXmind:()=>void dn(),onExportMarkdown:fn}):null,R===`outline`?v.outline.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.outline.map(e=>{let t=Zt.has(e.id);return(0,M.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,M.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,M.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),Qe?(0,M.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,M.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:Qe})]}):null]}):(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,M.jsx)(d,{open:St,title:`删除分析记录`,message:`确认删除「${v?.title??``}」?故事、需求条目、体检报告与测试点都会一起删掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Nt(!1),onConfirm:()=>void bn()}),(0,M.jsx)(d,{open:Pt,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${v?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>Ft(!1),onConfirm:()=>{Ft(!1),on()}})]})}export{Nt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=`0.1.18`;export{e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){return e===`requirements`?`/__tb_requirements`:e===`cases`?`/__tb_cases`:e===`prompts`?`/__tb_prompts`:e===`knowledge`?`/__tb_knowledge`:`/__tb_templates`}async function t(t,n,r){let i=await fetch(`${e(t)}${n}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r??{})}),a=await i.json();if(!i.ok)throw Error(a.error||`HTTP ${i.status}`);return a}async function n(t){try{return(await fetch(`${e(t)}/health`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function r(e,n=`.`){let r=await t(e,`/list`,{path:n});return{path:r.path,entries:r.entries??[]}}async function i(t){let n=await fetch(`${e(t)}/tree`,{signal:AbortSignal.timeout(3e3)}),r=await n.json();if(!n.ok)throw Error(r.error||`HTTP ${n.status}`);return{tree:r.tree??[],totalFiles:r.totalFiles??0}}async function a(e,n,r){return(await t(e,`/mkdir`,{parent:n,name:r})).path}async function o(e,n,r){let i=await r.arrayBuffer(),a=new Uint8Array(i),o=``;for(let e=0;e<a.length;e++)o+=String.fromCharCode(a[e]);let s=btoa(o);return t(e,`/upload`,{parent:n,name:r.name,contentBase64:s})}async function s(e,n){let r=await t(e,`/read`,{path:n});if(r.encoding===`utf-8`&&typeof r.content==`string`)return{path:r.path,content:r.content,encoding:r.encoding};throw Error(`该文件不是可预览的文本`)}async function c(e,n){let r=await t(e,`/read`,{path:n});if(r.encoding===`utf-8`&&typeof r.content==`string`)return{path:r.path,encoding:`utf-8`,content:r.content};if(typeof r.contentBase64==`string`)return{path:r.path,encoding:`base64`,contentBase64:r.contentBase64};throw Error(`无法读取文件`)}async function l(e,n,r){await t(e,`/write-text`,{path:n,content:r})}async function u(e,n,r){await t(e,`/write-binary`,{path:n,contentBase64:r})}async function d(e,n){await t(e,`/delete`,{path:n})}async function f(e,n,r){return(await t(e,`/rename`,{path:n,name:r})).path}function p(e){let t=e.lastIndexOf(`/`);return t<0?`.`:e.slice(0,t)}function m(e,t){return e===t||e.startsWith(`${t}/`)}function h(e,t,n){return m(e,t)?n+e.slice(t.length):e}function g(e,t){for(let n of e){if(n.path===t)return n;let e=g(n.children,t);if(e)return e}return null}function _(e){let t=0;for(let n of e.children)t+=1+_(n);return t}async function v(e,n){await t(e,`/open`,{path:n})}export{l as _,g as a,a as c,c as d,s as f,u as g,o as h,i,v as l,f as m,d as n,m as o,h as p,n as r,r as s,_ as t,p as u};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
var e=`/__tb_reqanalysis`,t=`需求分析提示词.md`,n=`需求分析`,r={draft:{label:`待拆解`,tone:`gray`},decomposed:{label:`已拆解`,tone:`blue`},checked:{label:`已审查`,tone:`amber`},accepted:{label:`已验收`,tone:`green`}},i={P0:`red`,P1:`amber`,P2:`gray`},a={"uncovered-outline":`条目未覆盖`,"missing-field":`字段缺失`,"missing-scenario":`场景遗漏`,"missing-dimension":`维度缺失`,"untestable-acceptance":`验收不可测`,conflict:`与原文冲突`,"over-split":`过度拆分`,other:`其它`},o={high:`高`,medium:`中`,low:`低`},s={high:`red`,medium:`amber`,low:`gray`},c=[{key:`permission`,label:`权限与角色`,keywords:[`权限`,`角色`,`授权`,`越权`,`未登录`,`登录`,`管理员`,`普通用户`],hint:`补充不同角色 / 未登录 / 越权访问时这条流程的行为。`},{key:`boundary`,label:`边界值`,keywords:[`边界`,`上限`,`下限`,`最大`,`最小`,`长度`,`超长`,`字数`,`为空`,`空值`],hint:`补充字段长度、数量上限、刚好等于阈值时的表现。`},{key:`concurrency`,label:`并发与幂等`,keywords:[`并发`,`重复`,`幂等`,`同时`,`加锁`,`冲突`,`重复提交`],hint:`补充重复提交、多人同时操作同一数据时的结果。`},{key:`empty`,label:`空数据`,keywords:[`空数据`,`无数据`,`没有数据`,`空列表`,`暂无`,`空态`],hint:`补充列表为空、首次使用、数据被清空时的空态。`},{key:`failure`,label:`超时与失败`,keywords:[`超时`,`失败`,`异常`,`错误`,`重试`,`断网`,`不可用`,`降级`,`回滚`],hint:`补充依赖超时、接口失败、网络中断时的提示与回滚。`},{key:`i18n`,label:`国际化与时区`,keywords:[`国际化`,`时区`,`多语言`,`语言`,`翻译`,`utc`,`夏令时`],hint:`补充跨时区时间展示、多语言文案与本地化格式。`}],l=/创建|新增|新建|保存|提交|删除|编辑|修改|更新|上传|导入|导出|发布|审批|撤回|绑定|解绑|发送|支付|下单|配置|启停|启用|停用/;async function u(t,n){let r=await fetch(`${e}${t}`,{...n,headers:n?.body===void 0?void 0:{"Content-Type":`application/json`,...n?.headers}}),i=await r.json().catch(()=>({}));if(!r.ok||i.ok===!1)throw Error(i.error||`HTTP ${r.status}`);return i}async function d(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function f(){return(await u(`/list`)).docs??[]}async function p(e){return(await u(`/create`,{method:`POST`,body:JSON.stringify(e)})).doc}async function m(e,t){return(await u(`/`,{method:`PUT`,body:JSON.stringify({id:e,...t})})).doc}async function h(e){await u(`/delete`,{method:`POST`,body:JSON.stringify({id:e})})}async function g(){try{let e=await u(`/prompt`);return{file:e.file||`需求分析提示词.md`,exists:e.exists===!0,decompose:e.decompose??``,audit:e.audit??``,fix:e.fix??``}}catch(e){return{file:t,exists:!1,decompose:``,audit:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function _(e){return await u(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}async function v(e){return(await b(e)).content}async function y(){return(await u(`/sources`)).files??[]}async function b(e){return u(`/source?path=${encodeURIComponent(e)}`)}var x=/[\s\p{P}\p{S}]+/gu;function S(e){return String(e??``).toLowerCase().replace(x,``)}function C(e){return Array.from(new Set(e.map(e=>String(e??``).trim()).filter(Boolean)))}function w(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function T(e,t=30,n=500){return Array.isArray(e)?e.map(e=>w(e,n)).filter(Boolean).slice(0,t):[]}function E(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 D(e){return E(String(e??``))}function O(e,t,n){return`g_${E(`${e}|${t}|${n}`)}`}function k(e){let t=e&&typeof e==`object`?e:{},n=w(t.priority,4);return{id:w(t.id,20),title:w(t.title,200),role:w(t.role,120),goal:w(t.goal,500),value:w(t.value,500),sourceRefs:T(t.sourceRefs,20,40),priority:n===`P0`||n===`P1`||n===`P2`?n:`P1`,preconditions:T(t.preconditions),mainFlow:(Array.isArray(t.mainFlow)?t.mainFlow:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{actor:w(t.actor,80),action:w(t.action,500),result:w(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:w(t.name,120)||`替代流程`,trigger:w(t.trigger,500),steps:T(t.steps,20)}}).slice(0,20),exceptions:(Array.isArray(t.exceptions)?t.exceptions:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{scenario:w(t.scenario,500),expected:w(t.expected,500)}}).filter(e=>e.scenario).slice(0,30),postconditions:T(t.postconditions),acceptance:(Array.isArray(t.acceptance)?t.acceptance:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{given:w(t.given,500),when:w(t.when,500),then:w(t.then,500)}}).filter(e=>e.given||e.when||e.then).slice(0,30),dimensions:T(t.dimensions,12,40)}}function A(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 j(e){let t=e.mainFlow?.[0];return`${S(e.title)}|${t?S(`${t.action}${t.result??``}`):``}`}function M(e,t){let n=e.map(A),r=new Map(n.filter(e=>e.id).map(e=>[e.id,e])),i=new Map(n.map(e=>[j(e),e]));for(let e of t){let t=k(e);if(!t.title)continue;let a=t.id&&r.get(t.id)||i.get(j(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=C([...a.sourceRefs,...t.sourceRefs]),a.dimensions=C([...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(j(e),e)}}return n}function N(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 P(e){return e.mainFlow.some(e=>l.test(e.action))}function F(e,t,n,r,i,a){return{id:O(e,t,n),storyId:t,type:e,severity:a,title:n,detail:r,suggestion:i,origin:`rule`,selected:!1}}var I=new Set([`缺少角色`,`缺少目标`,`缺少前置条件`,`缺少主流程`,`没有异常场景`,`写操作缺少异常分支`,`缺少验收标准`,`验收标准缺 then`,`没有关联需求条目`,`只写了主流程`]);function L(e){let t=e.outline??[],n=e.stories??[],r=[],i=new Set(n.flatMap(e=>e.sourceRefs));for(let e of t)i.has(e.id)||r.push(F(`uncovered-outline`,``,`需求条目未覆盖:${e.title}`,`条目 ${e.id}「${e.title}」没有任何用户故事引用。`,`补一条覆盖该条目的用户故事,或在已有故事的 sourceRefs 里加上 ${e.id}。`,`high`));for(let e of n){let t=`${e.id} ${e.title}`;e.role||r.push(F(`missing-field`,e.id,`缺少角色`,`${t} 没有写清谁在用这个功能。`,`补一个来自原文的角色;原文没写就标注「推断」。`,`medium`)),e.goal||r.push(F(`missing-field`,e.id,`缺少目标`,`${t} 没有写用户要达成什么。`,`补一句用户目标(想要什么结果)。`,`medium`)),e.preconditions.length||r.push(F(`missing-field`,e.id,`缺少前置条件`,`${t} 没有前置条件。`,`补进入这条流程前必须成立的状态。`,`low`)),e.mainFlow.length||r.push(F(`missing-field`,e.id,`缺少主流程`,`${t} 没有主流程步骤。`,`按「动作 + 结果」补主流程。`,`high`)),e.sourceRefs.length||r.push(F(`missing-field`,e.id,`没有关联需求条目`,`${t} 的 sourceRefs 为空,覆盖率无法统计。`,`把这条故事挂到对应的需求条目 id 上。`,`low`)),e.exceptions.length?P(e)&&e.exceptions.length<2&&r.push(F(`missing-scenario`,e.id,`写操作缺少异常分支`,`${t} 包含写操作,但只写了 ${e.exceptions.length} 条异常。`,`补重复提交 / 并发修改 / 保存失败时的表现与回滚。`,`medium`)):r.push(F(`missing-scenario`,e.id,`没有异常场景`,`${t} 只写了顺利路径,没有异常分支。`,`至少补 3 条:输入非法、权限不足、依赖失败 / 超时。`,`high`)),!e.altFlows.length&&P(e)&&r.push(F(`missing-scenario`,e.id,`只写了主流程`,`${t} 没有替代流程:分支条件、可跳过步骤、不同入口都没覆盖。`,`按触发条件补至少一条替代路径。`,`low`)),e.acceptance.length?e.acceptance.some(e=>!e.then)&&r.push(F(`untestable-acceptance`,e.id,`验收标准缺 then`,`${t} 有 ${e.acceptance.filter(e=>!e.then).length} 条验收没有写 then。`,`补上「应该看到什么 / 查到什么」,不要停在操作步骤。`,`high`)):r.push(F(`untestable-acceptance`,e.id,`缺少验收标准`,`${t} 没有 Given / When / Then。`,`每条验收写成 Given / When / Then,then 必须可判定。`,`high`))}let a=c.map(e=>{let t=n.filter(t=>{let n=N(t).toLowerCase();return e.keywords.some(e=>n.includes(e.toLowerCase()))}).map(e=>e.id);return{key:e.key,label:e.label,covered:t.length>0,stories:t}});for(let e of a){if(e.covered)continue;let t=c.find(t=>t.key===e.key)?.hint??``;r.push(F(`missing-dimension`,``,`维度缺失:${e.label}`,`所有用户故事都没有覆盖「${e.label}」相关场景。`,t,`medium`))}let o=t.filter(e=>i.has(e.id)).length,s={total:t.length,covered:o,rate:t.length?o/t.length:0};return{at:new Date().toISOString(),summary:`规则检查:${n.length} 个故事、${t.length} 条需求条目,覆盖率 ${t.length?Math.round(s.rate*100):0}%,发现 ${r.length} 个问题。`,coverage:s,dimensions:a,gaps:r}}function R(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?I.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):S(a.title)!==S(e.title)&&(n.push({...e}),i.add(e.id)):(n.push({...e}),r.set(t,e),i.add(e.id))}return n}function z(e,t){let n=new Set(e.filter(e=>e.selected).map(e=>e.id));return n.size?t.map(e=>n.has(e.id)?{...e,selected:!0}:e):t}function B(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 V(e,t=12e3){let n=String(e??``).replace(/\r\n/g,`
|
|
2
|
-
`).trim();if(!n)return[];let r=Math.max(2e3,Math.floor(t));if(n.length<=r)return[{index:0,title:``,text:n}];let i=[],a=``,o=[],s=()=>{let e=o.join(`
|
|
3
|
-
`).trim();e&&i.push({title:a,text:e}),o=[]};for(let e of n.split(`
|
|
4
|
-
`)){let t=/^#{2,6}\s+(.+?)\s*$/.exec(e);t&&(s(),a=t[1]),o.push(e)}if(s(),!i.length)return[{index:0,title:``,text:n}];let c=[],l=``,u=``,d=()=>{let e=l.trim();if(e){for(let t of e.length>r?B(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 H(e,t){return t?`- **${e}**:${t}`:``}function U(e){return e.filter(Boolean).map(e=>`- ${e}`)}function W(e){let t=[];t.push(`### ${e.id} ${e.title}`),t.push(``);let n=[H(`角色`,e.role),H(`目标`,e.goal),H(`价值`,e.value),H(`优先级`,e.priority),H(`来源条目`,e.sourceRefs.join(`、`))].filter(Boolean);if(t.push(...n),n.length&&t.push(``),e.preconditions.length&&(t.push(`**前置条件**`),t.push(...U(e.preconditions)),t.push(``)),e.mainFlow.length&&(t.push(`**主流程**`),e.mainFlow.forEach((e,n)=>{let r=e.actor?`${e.actor}:`:``;t.push(`${n+1}. ${r}${e.action}${e.result?` → ${e.result}`:``}`)}),t.push(``)),e.altFlows.length){t.push(`**替代流程**`);for(let n of e.altFlows)t.push(`- **${n.name}**${n.trigger?`(触发:${n.trigger})`:``}`),n.steps.forEach((e,n)=>t.push(` ${n+1}. ${e}`));t.push(``)}if(e.exceptions.length){t.push(`**异常场景**`);for(let n of e.exceptions)t.push(`- ${n.scenario}${n.expected?` → ${n.expected}`:``}`);t.push(``)}if(e.postconditions.length&&(t.push(`**后置条件**`),t.push(...U(e.postconditions)),t.push(``)),e.acceptance.length){t.push(`**验收标准**`);for(let n of e.acceptance)t.push(`- Given ${n.given||`(未写)`};When ${n.when||`(未写)`};Then ${n.then||`(未写)`}`);t.push(``)}return e.dimensions.length&&(t.push(`**覆盖维度**:${e.dimensions.join(`、`)}`),t.push(``)),t[t.length-1]!==``&&t.push(``),t}function G(e,t){let n=new Set((t??[]).filter(Boolean)),i=n.size?e.stories.filter(e=>n.has(e.id)):e.stories,a=[];a.push(`# ${e.title||`需求分析`} · 用户故事`),a.push(``),a.push(`> 来源需求文档:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),a.push(``),e.outline.length&&(a.push(`## 需求条目`),a.push(``),e.outline.forEach((e,t)=>{a.push(`${t+1}. **${e.id}** ${e.title}`)}),a.push(``)),a.push(`## 用户故事`),a.push(``),i.length||(a.push(`- (暂无)`),a.push(``));for(let e of i)a.push(...W(e));return a.join(`
|
|
5
|
-
`)}function K(e){let t=[];t.push(`# ${e.title||`需求分析`}`),t.push(``),t.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),t.push(``),t.push(`## 需求条目`),t.push(``),e.outline.length||t.push(`- (暂无)`),e.outline.forEach((e,n)=>{t.push(`${n+1}. **${e.id}** ${e.title}`),e.quote&&t.push(` > ${e.quote.replace(/\n+/g,` `)}`)}),t.push(``),t.push(`## 用户故事`),t.push(``),e.stories.length||t.push(`- (暂无)`);for(let n of e.stories)t.push(...W(n));if(t.push(`## 审查摘要`),t.push(``),!e.check)t.push(`- 还没有跑过审查。`);else{let n=e.check.coverage.total?Math.round(e.check.coverage.rate*100):0;t.push(`- 覆盖率:${e.check.coverage.covered}/${e.check.coverage.total}(${n}%)`),t.push(`- 维度覆盖:${e.check.dimensions.map(e=>`${e.label}${e.covered?` ✓`:` ✗`}`).join(` · `)||`(无)`}`),e.check.summary&&(t.push(``),t.push(e.check.summary)),t.push(``),t.push(`### 缺口清单`),t.push(``),e.check.gaps.length||t.push(`- 没有发现缺口。`);let r=[...e.check.gaps].sort((e,t)=>{let n={high:0,medium:1,low:2};return n[e.severity]-n[t.severity]});for(let e of r){let n=e.storyId?`${e.storyId} `:``;t.push(`- **[${o[e.severity]}] ${a[e.type]}** · ${n}${e.title}`),e.detail&&t.push(` - 原因:${e.detail}`),e.suggestion&&t.push(` - 建议:${e.suggestion}`)}}return t.push(``),t.join(`
|
|
6
|
-
`)}function q(e){return`${(e.title||e.sourcePath.split(`/`).pop()||`需求分析`).replace(/\.(md|markdown|txt)$/i,``).replace(/[\\/:*?"<>|]/g,` `).trim()||`需求分析`}-用户故事.md`}export{G as C,m as E,V as S,K as T,R as _,t as a,v as b,L as c,q as d,d as f,y as g,f as h,n as i,p as l,O as m,s as n,i as o,g as p,a as r,r as s,o as t,h as u,M as v,_ as w,D as x,z as y};
|