lantern-harness 0.2.3 → 0.2.4
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 +19 -0
- package/README.md +7 -7
- package/cli/mcp-server.mjs +186 -1
- package/dist/500.html +4 -4
- package/dist/_astro/Base.ANghvs5L.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.Dm3O_y-S.js → Base.astro_astro_type_script_index_0_lang.f7BIL9Qf.js} +1 -1
- package/dist/_astro/CaseExecutionBoard.p6Y23xyH.js +4 -0
- package/dist/_astro/{CaseGenerateApp.D5xlk9At.js → CaseGenerateApp.D5uj5bSb.js} +1 -1
- package/dist/_astro/CasesLibrary.CY1PRdzc.js +21 -0
- package/dist/_astro/ChatApp.BnV7drSC.js +1 -0
- package/dist/_astro/{ChatApp.d4a9R3YS.js → ChatApp.CqyrMX90.js} +1 -1
- package/dist/_astro/{PluginsPage.B1VeDtLx.js → PluginsPage.Cb6977dz.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.WLtIfBg8.js → ReqAnalysisBoard.C7V_fEh9.js} +1 -1
- package/dist/_astro/{SettingsDialog.BvDU9EU6.js → SettingsDialog.CRbfEiyw.js} +1 -1
- package/dist/_astro/{UiAutoBoard.BD5ZyLHj.js → UiAutoBoard.BZkPzwi8.js} +1 -1
- package/dist/_astro/app-version.B7nd7uBP.js +1 -0
- package/dist/_astro/{case-gen-run.C4p8uyU3.js → case-gen-run.DQR6uvH5.js} +1 -1
- package/dist/_astro/{req-analysis.BLvcktvQ.js → req-analysis.efWkT7Gv.js} +1 -1
- package/dist/_astro/{story-review.dEBWTeOW.js → story-review.Dm9VcR6v.js} +1 -1
- package/dist/_astro/{test-points.BuNgdNcU.js → test-points.BSfPfq8z.js} +1 -1
- package/dist/business-map/index.html +4 -4
- package/dist/case-exec/index.html +4 -4
- package/dist/case-execution/index.html +5 -5
- package/dist/cases/api/index.html +5 -5
- package/dist/cases/automation/index.html +5 -5
- package/dist/cases/functional/index.html +5 -5
- package/dist/cases/generate/index.html +5 -5
- package/dist/cases/other/index.html +5 -5
- package/dist/cases/performance/index.html +5 -5
- package/dist/dashboard/index.html +4 -4
- package/dist/defect-rules/index.html +4 -4
- package/dist/defect-submit/index.html +4 -4
- package/dist/defect-submit/templates/index.html +4 -4
- package/dist/docs/changelog/index.html +76 -59
- package/dist/docs/install/index.html +4 -4
- package/dist/docs/manual/index.html +28 -17
- package/dist/knowledge/index.html +4 -4
- package/dist/life/kr-tasks/index.html +4 -4
- package/dist/life/kr-todos/index.html +4 -4
- package/dist/life/objectives/index.html +4 -4
- package/dist/life/reviews/index.html +4 -4
- package/dist/life/stages/index.html +4 -4
- package/dist/life/year-plans/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/reports/index.html +4 -4
- package/dist/requirement-analysis/index.html +5 -5
- package/dist/requirement-breakdowns/index.html +4 -4
- package/dist/requirements/index.html +4 -4
- package/dist/tasks/index.html +4 -4
- package/dist/templates/index.html +4 -4
- package/dist/test-automation/index.html +5 -5
- package/dist/test-automation/projects/index.html +4 -4
- package/dist/test-reports/index.html +4 -4
- package/dist/test-stats/index.html +4 -4
- package/dist/todos/index.html +4 -4
- package/dist/workbench/index.html +5 -5
- package/docs/Codex-MCP/351/233/206/346/210/220.md +21 -1
- package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +7 -0
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +5 -1
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +6 -4
- package/lh-plugins/case-automation/service.mjs +7 -1
- package/lh-plugins/case-execution/files.mjs +57 -9
- package/lh-plugins/lh-stats.mjs +65 -4
- package/package.json +1 -1
- package/skills/case-execution/SKILL.md +9 -3
- package/dist/_astro/Base.BQf1tZMl.css +0 -1
- package/dist/_astro/CaseExecutionBoard.C94pmIMQ.js +0 -5
- package/dist/_astro/CasesLibrary.BHQC955x.js +0 -21
- package/dist/_astro/ChatApp.CIt15w_1.js +0 -1
- package/dist/_astro/app-version.CkDFkv4s.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./app-config.BSO5r82v.js";import{t}from"./settings.BojKNwUC.js";import{a as n,r}from"./plugins.ChGmBEkF.js";import{t as i}from"./app-version.
|
|
1
|
+
import{i as e}from"./app-config.BSO5r82v.js";import{t}from"./settings.BojKNwUC.js";import{a as n,r}from"./plugins.ChGmBEkF.js";import{t as i}from"./app-version.B7nd7uBP.js";import{t as ee}from"./update.Fq2CGmCX.js";var a=100,te=1010,ne=420,o=14,re=150,s=6,ie=3200,ae=180,c=null,l=null,u=null,d=null,f=null,p=!1,m=0,h=0,g=0,_=0,v=!1,y=0,b=null,x=null,S=0,C=!1,w=null,T=!1;function E(e){if(!e.isConnected||e.closest(`[data-closed]`)||e.checkVisibility&&!e.checkVisibility({checkVisibilityCSS:!0}))return!0;let t=e.getBoundingClientRect();return t.width===0&&t.height===0}function D(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;if(n<0||r<0||n>window.innerWidth||r>window.innerHeight)return!1;let i=document.elementFromPoint(n,r);return i?!(i===e||e.contains(i)||i.contains(e)):!1}function O(e){let t=e.getBoundingClientRect();b&&b.left===t.left&&b.top===t.top&&b.width===t.width&&b.height===t.height||(M(),N())}function k(e){let t=e.getBoundingClientRect();return t.bottom<=0||t.top>=window.innerHeight||t.right<=0||t.left>=window.innerWidth}function oe(e,t,n){return t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}function A(){_&&=(cancelAnimationFrame(_),0)}function j(){x=null,S&&=(window.clearTimeout(S),0)}function se(){A();let e=()=>{_=0;let t=d;t&&(E(t)||k(t)||D(t)||C&&w&&!oe(t.getBoundingClientRect(),w.x,w.y)||!C&&!t.contains(document.activeElement)?L():(O(t),_=requestAnimationFrame(e)))};_=requestAnimationFrame(e)}function ce(){c&&c.isConnected||(c=document.createElement(`div`),c.setAttribute(`role`,`tooltip`),c.className=`tw-tooltip tw-tooltip-anim pointer-events-none fixed rounded-md px-2 py-1 text-[12px] leading-5 break-all text-stone-700 shadow-lg`,c.style.zIndex=String(a),c.style.maxHeight=`40vh`,c.style.overflowY=`auto`,c.dataset.closed=``,l=document.createElement(`span`),l.setAttribute(`aria-hidden`,`true`),l.className=`tw-tooltip-arrow absolute h-2 w-2`,l.style.transform=`translateX(-50%) rotate(45deg)`,u=document.createTextNode(``),c.append(l,u),document.body.appendChild(c))}function M(){if(!d)return;let e=d.getBoundingClientRect(),t=Math.min(Math.max(e.width,160),ne),n=e.bottom+72>window.innerHeight-8,r=n?e.top-s:e.bottom+s,i=Math.max(8,Math.min(e.left,Math.max(8,window.innerWidth-t-8)));f={top:r,left:i,maxWidth:t,openUp:n,arrowLeft:Math.max(o,Math.min(e.left+e.width/2-i,t-o))},b={left:e.left,top:e.top,width:e.width,height:e.height}}function N(){if(!c||!l||!f)return;let e=d?.dataset.hintLayer===`popover`;c.style.zIndex=String(e?te:a),c.style.maxHeight=e?``:`40vh`,c.style.overflowY=e?`visible`:`auto`,c.style.top=`${f.top}px`,c.style.left=`${f.left}px`,c.style.maxWidth=`${f.maxWidth}px`,c.classList.toggle(`is-up`,f.openUp),c.classList.toggle(`is-down`,!f.openUp),l.classList.toggle(`is-up`,f.openUp),l.classList.toggle(`is-down`,!f.openUp),l.style.left=`${f.arrowLeft}px`,l.style.top=f.openUp?``:`-5px`,l.style.bottom=f.openUp?`-5px`:``}function le(e){let t=e.innerText||``;return e.querySelectorAll(`[class*="sr-only"]`).forEach(e=>{let n=e.innerText;n&&(t=t.replace(n,``))}),t.replace(/\s+/g,` `).trim()}function ue(e){return e.scrollWidth>e.clientWidth+1||e.scrollHeight>e.clientHeight+1}function P(e){return e.dataset.hintAlways!==void 0||e.dataset.hintFit===void 0&&!le(e)||ue(e)}function F(e){return!!e.dataset.hint&&P(e)}function I(e,t){let n=e.dataset.hint??``;if(!n||!P(e))return;let r=e.getBoundingClientRect();if(!r.width||!r.height||e.checkVisibility&&!e.checkVisibility({checkVisibilityCSS:!0})||D(e)||(ce(),!c||!u))return;d=e,C=t,h&&=(window.clearTimeout(h),0),u.data=n,c.style.whiteSpace=n.includes(`
|
|
2
2
|
`)?`pre-wrap`:``,M(),N(),c.style.display=``,p||(c.dataset.closed=``),cancelAnimationFrame(m);let i=++y;m=requestAnimationFrame(()=>{m=requestAnimationFrame(()=>{c&&i===y&&d===e&&(p=!0,delete c.dataset.closed)})}),se(),g&&window.clearTimeout(g),g=window.setTimeout(()=>{g=0,d===e&&L()},ie)}function L(){A(),j(),y+=1,m&&=(cancelAnimationFrame(m),0),d=null,C=!1,b=null,g&&=(window.clearTimeout(g),0),c&&(p=!1,c.dataset.closed=``,h&&window.clearTimeout(h),h=window.setTimeout(()=>{h=0,!p&&c&&(c.style.display=`none`)},re))}function R(e){if(!(e instanceof Element))return null;let t=e.closest(`[data-hint]`);return t instanceof HTMLElement?t:null}function z(e){T=!0,(e.clientX!==0||e.clientY!==0)&&(w={x:e.clientX,y:e.clientY});let t=R(e.target);t!==d&&(!t||!F(t)?(j(),d&&L()):t!==x&&(j(),x=t,S=window.setTimeout(()=>{S=0;let e=x;x=null,e&&e!==d&&I(e,!0)},ae)))}function B(e){let t=R(e.target);if(t&&t===x&&j(),!t||t!==d)return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||L()}function V(e){if(T)return;let t=R(e.target);t!==d&&(!t||!F(t)?d&&L():I(t,!1))}function H(e){let t=R(e.target);if(!t||t!==d)return;let n=e.relatedTarget;n instanceof Node&&t.contains(n)||L()}function U(){j(),d&&L()}function W(){d&&(E(d)||k(d)||D(d)?L():O(d))}function de(e){w={x:e.clientX,y:e.clientY},T=!0}function fe(){T=!0,j(),d&&L()}function pe(e){T=!1,e.key===`Escape`&&d&&L()}function me(){typeof document>`u`||v||(v=!0,document.addEventListener(`mouseover`,z,!0),document.addEventListener(`mouseout`,B,!0),document.addEventListener(`pointermove`,de,{capture:!0,passive:!0}),document.addEventListener(`pointerdown`,fe,!0),document.addEventListener(`focusin`,V,!0),document.addEventListener(`focusout`,H,!0),document.addEventListener(`click`,U,!0),document.addEventListener(`keydown`,pe,!0),window.addEventListener(`scroll`,W,!0),window.addEventListener(`resize`,W),window.addEventListener(`blur`,()=>{d&&L()}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&d&&L()}),document.documentElement.addEventListener(`mouseleave`,()=>{d&&L()}),document.addEventListener(`astro:after-swap`,()=>{A(),y+=1,m&&=(cancelAnimationFrame(m),0),g&&=(window.clearTimeout(g),0),d=null,p=!1,b=null,c?.isConnected&&c.remove(),c=null,l=null,u=null}))}var he=[`dashboard`,`tasks`,`todos`,`projects`,`iterations`,`pmRequirements`,`bugs`,`reports`,`testStats`,`caseExec`,`businessMap`,`defectSubmit`,`cases`,`knowledgeLib`,`requirements`,`templates`,`testReports`];function ge(e){return`pluginOff${e.charAt(0).toUpperCase()}${e.slice(1)}`}function G(){let e=document.documentElement;for(let t of he){let n=ge(t);r(t)?delete e.dataset[n]:e.dataset[n]=`1`}}function _e(){G(),n(()=>G()),e().then(()=>G()),document.addEventListener(`astro:page-load`,G)}var ve=`tw-update-dot`,ye=3e5,K=`tw.update.badge.checked-at.v1`,be=15e3,xe=4,q=0,J=null,Y=!1,X=`tw.update.stale.reload.v1`;function Se(e){let t=e.status?.phase;return t===`installing`||t===`restarting`}function Ce(e){if(e.mode===`dev`&&!Se(e)&&e.current&&e.current!==i){try{let e=Number(localStorage.getItem(X))||0;if(Date.now()-e<6e4)return;localStorage.setItem(X,String(Date.now()))}catch{}window.location.reload()}}function we(){try{return Number(localStorage.getItem(K))||0}catch{return 0}}function Te(){try{localStorage.setItem(K,String(Date.now()))}catch{}}function Z(e,t,n){e.hidden=!n,e.closest(`.tw-nav-brand-ver`)?.classList.toggle(`has-update`,n),n&&e.setAttribute(`aria-label`,t?`有新版本可用 v${t}`:`有新版本可更新`)}function Ee(e,t){q>=xe||(q+=1,J!==null&&window.clearTimeout(J),J=window.setTimeout(()=>{J=null,Q(e,t)},be))}async function Q(e,t){if(!Y){Y=!0;try{let n=await ee(t);if(!n){Ee(e,t);return}q=0,Te();let r=!!n.current&&n.current!==i;Z(e,n.latest,!!n.hasUpdate||r),r&&Ce(n)}finally{Y=!1}}}function $(){let e=document.getElementById(ve);if(!e)return;e.dataset.bound!==`1`&&(e.dataset.bound=`1`,e.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),window.dispatchEvent(new CustomEvent(t,{detail:{tab:`general`}}))}));let n=Date.now()-we()>ye;q=0,Q(e,n)}function De(){document.addEventListener(`astro:page-load`,$),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&$()}),document.readyState!==`loading`&&$()}me(),_e(),De();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{i as o}from"./app-config.BSO5r82v.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as l,o as ee,r as te}from"./plugins.ChGmBEkF.js";import{a as ne,n as u,o as d,r as re,s as ie,t as ae}from"./view-prefs.CWc5cQ2q.js";import{n as oe,t as f}from"./SelectDropdown.D7IeyHDI.js";import{t as se}from"./SlideOverDrawer.CvyB-quk.js";import{showToast as p}from"./Toast.BydY-X7T.js";import{h as ce}from"./case-exec.BMNk9OyF.js";import{t as le}from"./DatePicker.BRO_CjVQ.js";import{n as ue}from"./case-workflow-contract.BBQ9bbKL.js";import{t as de}from"./defect-workbench.DBmohR-y.js";import{d as fe}from"./ui-auto.LUcREUMe.js";import{d as m,l as h,t as g}from"./ColumnResize.CkE59sGq.js";var _=e(t(),1),v=`/__tb_case_run`;function y(e){let t=e.trim();return[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`].includes(t)?t:/^(p|pass|passed|ok|成功|true|1)$/i.test(t)?`通过`:/^(f|fail|failed|失败|false|0)$/i.test(t)?`不通过`:/block/i.test(t)?`阻塞`:/skip|n\/?a/i.test(t)?`跳过`:`待验证`}function b(e){let t={total:e.length,executed:0,pending:0,passed:0,failed:0,blocked:0,skipped:0,executionRate:0};for(let n of e){let e=y(n.status);e!==`待验证`&&(t.executed+=1,e===`通过`&&(t.passed+=1),e===`不通过`&&(t.failed+=1),e===`阻塞`&&(t.blocked+=1),e===`跳过`&&(t.skipped+=1))}return t.pending=Math.max(0,t.total-t.executed),t.executionRate=t.total?Math.round(t.executed/t.total*100):0,t}async function x(e=``,t){let n=await fetch(`${v}${e}`,{...t,headers:{...t?.body?{"Content-Type":`application/json`}:{},...t?.headers||{}}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}function S(e){return{method:`POST`,body:JSON.stringify(e)}}async function pe(){try{return(await fetch(`${v}/health?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function me(){return((await x(`/files`)).files||[]).filter(Boolean)}async function C(e){let t=await x(`/cases?path=${encodeURIComponent(e)}`);if(!t.document)throw Error(`用例文件读取失败`);return t.document}async function w(e){let t=await x(`/fields`,S(e));if(!t.applied?.fileHash)throw Error(`字段保存失败`);return{fileHash:t.applied.fileHash,backup:t.applied.backup||``}}async function he(e){return x(`/stats/sync`,S(e))}var T=`/__tb_case_automation`;async function E(e,t){let n=await fetch(`${T}${e}`,{...t,headers:{...t?.body?{"Content-Type":`application/json`}:{},...t?.headers||{}}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function D(e,t=``){return E(`/iterations?projectId=${encodeURIComponent(e)}&casePath=${encodeURIComponent(t)}`)}async function ge(e){return(await E(`/cases?path=${encodeURIComponent(e)}`)).document}async function _e(e){return(await E(`/selection?casePath=${encodeURIComponent(e)}`)).selection}async function O(e){return E(`/assess`,{method:`POST`,body:JSON.stringify(e)})}async function ve(e){return E(`/apply`,{method:`POST`,body:JSON.stringify(e)})}async function ye(e){return E(`/runs`,{method:`POST`,body:JSON.stringify(e)})}async function be(e){return E(`/runs/${encodeURIComponent(e)}`)}async function xe(e){return E(`/runs/${encodeURIComponent(e)}/stop`,{method:`POST`,body:`{}`})}var k=s(),A={automatable:`可自动生成`,needs_manual:`需人工补充`,not_automatable:`不可 UI 自动化`},Se={automatable:`border-emerald-200 bg-emerald-50 text-emerald-700`,needs_manual:`border-amber-200 bg-amber-50 text-amber-700`,not_automatable:`border-stone-200 bg-stone-50 text-stone-500`},Ce={not_configured:`未评估`,automatable:`可自动化`,needs_manual:`需人工`,not_automatable:`不可自动化`,connected:`已接入`,running:`运行中`,passed:`已通过`,failed:`异常`,partial:`部分执行`,stale:`已过期`,not_applicable:`不适用`},we={not_configured:`border-stone-200 bg-stone-50 text-stone-500`,automatable:`border-sky-200 bg-sky-50 text-sky-700`,needs_manual:`border-amber-200 bg-amber-50 text-amber-700`,not_automatable:`border-stone-200 bg-stone-50 text-stone-500`,connected:`border-blue-200 bg-blue-50 text-blue-700`,running:`border-indigo-200 bg-indigo-50 text-indigo-700`,passed:`border-emerald-200 bg-emerald-50 text-emerald-700`,failed:`border-red-200 bg-red-50 text-red-700`,partial:`border-orange-200 bg-orange-50 text-orange-700`,stale:`border-amber-200 bg-amber-50 text-amber-700`,not_applicable:`border-stone-200 bg-stone-50 text-stone-400`};function Te({open:e,casePath:t,initialCaseId:n=``,onClose:r,onApplied:i}){let[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)([]),[l,ee]=(0,_.useState)(``),[te,ne]=(0,_.useState)(null),[u,d]=(0,_.useState)(``),[re,ie]=(0,_.useState)(!1),[ae,oe]=(0,_.useState)(``),[ce,le]=(0,_.useState)(``),[ue,de]=(0,_.useState)({}),[m,h]=(0,_.useState)(null),[g,v]=(0,_.useState)({}),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(``),pe=(0,_.useMemo)(()=>s.filter(e=>e.kind===`ui`&&e.framework===`playwright`&&e.exists),[s]),me=(0,_.useCallback)(async()=>{if(t){b(!0),S(``),h(null),v({});try{let[e,r,i]=await Promise.all([ge(t),fe(),_e(t)]);o(e),c(r.projects||[]),oe(i?.iteration||``),i?.projectId&&ee(i.projectId);let a=n&&e.cases.some(e=>e.id===n)?[n]:e.cases.map(e=>e.id);de(Object.fromEntries(a.map(e=>[e,!0])))}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}},[t,n]);(0,_.useEffect)(()=>{e&&me()},[me,e]),(0,_.useEffect)(()=>{!e||!l?ne(null):(S(``),D(l,t).then(e=>{ne(e),d(e.suggestedIteration||ae||``)}).catch(e=>S(e instanceof Error?e.message:String(e))))},[t,e,l,ae]);let C=a?.cases||[],w=C.filter(e=>ue[e.id]).map(e=>e.id),he=C.filter(e=>(e.automation?.status||`not_configured`)===`not_configured`).length,T=(0,_.useMemo)(()=>({automatable:m?.cases.filter(e=>e.decision===`automatable`).length||0,needs_manual:m?.cases.filter(e=>e.decision===`needs_manual`).length||0,not_automatable:m?.cases.filter(e=>e.decision===`not_automatable`).length||0}),[m]);async function E(){if(l&&u&&w.length){b(!0),S(``),h(null);try{let e=await O({casePath:t,caseIds:w,projectId:l,iteration:u});h(e.assessment),v(Object.fromEntries(e.assessment.cases.filter(e=>e.decision!==`not_automatable`).map(e=>[e.sourceCaseId,!0])))}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}}async function ye(){if(!m)return;let e=Object.keys(g).filter(e=>g[e]);if(!e.length)S(`请至少选择一条有效转换结果`);else{b(!0),S(``);try{let t=await ve({assessmentId:m.id,selectedSourceCaseIds:e});p(`已生成 ${t.links?.length??0} 条自动化用例`,`success`),i()}catch(e){S(e instanceof Error?e.message:String(e))}finally{b(!1)}}}return(0,k.jsxs)(se,{open:e,onClose:r,title:`自动化识别评估`,widthClass:`max-w-3xl`,bodyClassName:`flex flex-col gap-4 overflow-hidden`,footer:(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-stone-100 bg-white px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[(0,k.jsx)(`span`,{className:`text-xs text-stone-500`,children:m?`可生成 ${T.automatable} · 需人工 ${T.needs_manual} · 不可自动化 ${T.not_automatable}`:`已选 ${w.length} / ${C.length} 条 · 未评估 ${he} 条`}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:y,onClick:r,className:`h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-600`,children:`关闭`}),m?(0,k.jsx)(`button`,{type:`button`,disabled:y,onClick:()=>void ye(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white disabled:opacity-40`,children:y?`正在生成…`:`生成自动化用例`}):(0,k.jsx)(`button`,{type:`button`,disabled:y||!l||!u||w.length===0,onClick:()=>void E(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white disabled:opacity-40`,children:y?`识别评估中…`:`开始识别评估`})]})]}),children:[(0,k.jsxs)(`section`,{className:`grid shrink-0 gap-3 rounded-lg border border-stone-200 bg-stone-50 p-4 md:grid-cols-2`,children:[(0,k.jsxs)(`label`,{children:[(0,k.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:`UI 自动化项目`}),(0,k.jsx)(f,{value:l,onChange:e=>{ee(e),d(``),ie(!1),h(null)},options:pe.map(e=>({value:e.id,label:e.name,secondary:`${e.frameworkLabel} · ${e.baseURL||e.detectedBaseURL||`未配置地址`}`})),ariaLabel:`选择 UI 自动化项目`,searchable:!0,searchPlaceholder:`搜索自动化项目…`})]}),(0,k.jsxs)(`label`,{children:[(0,k.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:`迭代版本`}),(0,k.jsx)(f,{value:re?`__new__`:u,onChange:e=>{e===`__new__`?(ie(!0),d(``),le(``)):(ie(!1),d(e),le(``)),h(null)},options:[...(te?.files||[]).map(e=>({value:e.name.replace(/\.spec\.ts$/i,``),label:e.name.replace(/\.spec\.ts$/i,``)})),{value:`__new__`,label:`+ 创建新迭代`}],ariaLabel:`选择迭代版本`,searchable:!0,searchPlaceholder:`搜索迭代版本…`,disabled:!l})]}),re?(0,k.jsxs)(`label`,{className:`md:col-span-2`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:`新迭代版本`}),(0,k.jsx)(`input`,{value:ce,onChange:e=>{le(e.target.value),d(e.target.value.trim())},placeholder:`例如 v1.12`,className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-sm outline-none focus:border-[#4176e6]`}),(0,k.jsxs)(`span`,{className:`mt-1 block text-[11px] text-stone-400`,children:[`将创建到 `,te?.iterationDir||`tests/iteration`,`/`,ce.trim()||`<迭代>`,`.spec.ts`]})]}):null]}),pe.length?null:(0,k.jsx)(`div`,{className:`shrink-0 rounded-lg border border-amber-200 bg-amber-50 px-4 py-5 text-sm text-amber-800`,children:`没有可生成脚本的 UI 自动化项目。请先在「自动化项目」挂载 Playwright 项目。`}),x?(0,k.jsx)(`div`,{className:`shrink-0 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:x}):null,m?(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,k.jsx)(Ee,{assessment:m,selected:g,onToggle:e=>v(t=>({...t,[e]:!t[e]}))})}):(0,k.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`评估范围`}),(0,k.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:`默认全选当前文件中的用例,可取消不需要识别的条目;已评估状态会保留。`})]}),(0,k.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400`,children:[C.length,` 条`]})]}),(0,k.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-2 overflow-y-auto pr-1`,children:[C.map(e=>(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg border border-stone-200 px-3 py-2.5 hover:bg-stone-50`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:!!ue[e.id],onChange:t=>de(n=>({...n,[e.id]:t.target.checked})),className:`mt-1`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-stone-800`,children:[e.no?`#${e.no} `:``,e.title]}),(()=>{let t=e.automation?.status||`not_configured`;return(0,k.jsx)(`span`,{className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] ${we[t]||we.not_configured}`,children:Ce[t]||t})})()]}),(0,k.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-5 text-stone-500`,children:e.steps||e.expected||`缺少步骤与预期`})]})]},e.id)),C.length?null:(0,k.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-10 text-center text-sm text-stone-400`,children:`当前文件没有可评估用例`})]})]})]})}function Ee({assessment:e,selected:t,onToggle:n}){return(0,k.jsxs)(`section`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`rounded-lg bg-[#f5f8ff] px-3 py-2 text-xs text-stone-600`,children:[`目标项目:`,e.projectName,` · 迭代 `,e.iteration,` ·`,` `,e.iterationFile]}),e.cases.map(e=>(0,k.jsx)(j,{item:e,checked:!!t[e.sourceCaseId],onToggle:()=>n(e.sourceCaseId)},e.sourceCaseId))]})}function j({item:e,checked:t,onToggle:n}){return(0,k.jsxs)(`article`,{className:`rounded-lg border border-stone-200 p-3`,children:[(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t,disabled:e.decision===`not_automatable`,onChange:n,className:`mt-1`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-stone-800`,children:e.sourceTitle}),(0,k.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] ${Se[e.decision]}`,children:A[e.decision]})]}),(0,k.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-stone-500`,children:e.reason})]})]}),e.automationCases.length?(0,k.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.automationCases.map(e=>(0,k.jsxs)(`div`,{className:`rounded-md bg-stone-50 p-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:e.title}),(0,k.jsx)(`span`,{className:`text-[10px] text-stone-400`,children:e.priority})]}),(0,k.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] leading-5 text-stone-500`,children:e.steps.join(` → `)}),(0,k.jsx)(`p`,{className:`mt-1 text-[11px] text-emerald-700`,children:e.expected})]},e.automationCaseId))}):null]})}var De={通过:`border-emerald-200 bg-emerald-50 text-emerald-700`,不通过:`border-red-200 bg-red-50 text-red-700`,阻塞:`border-amber-200 bg-amber-50 text-amber-700`,跳过:`border-stone-200 bg-stone-50 text-stone-600`,待验证:`border-sky-200 bg-sky-50 text-sky-700`};function Oe(e){return De[e]||`border-stone-200 bg-stone-50 text-stone-500`}function M(e){return e.trim()?y(e):`未执行`}function ke(e){let t=y(e);return t===`不通过`||t===`阻塞`}var Ae={automatable:`border-sky-200 bg-sky-50 text-sky-700`,needs_manual:`border-amber-200 bg-amber-50 text-amber-700`,not_automatable:`border-stone-200 bg-stone-50 text-stone-500`,connected:`border-blue-200 bg-blue-50 text-blue-700`,running:`border-indigo-200 bg-indigo-50 text-indigo-700`,passed:`border-emerald-200 bg-emerald-50 text-emerald-700`,failed:`border-red-200 bg-red-50 text-red-700`,partial:`border-orange-200 bg-orange-50 text-orange-700`,stale:`border-amber-200 bg-amber-50 text-amber-700`,not_configured:`border-stone-200 bg-stone-50 text-stone-400`,not_applicable:`border-stone-200 bg-stone-50 text-stone-400`},je={automatable:`可自动化`,needs_manual:`需人工`,not_automatable:`不可自动化`,connected:`已接入`,running:`运行中`,passed:`已通过`,failed:`异常`,partial:`部分执行`,stale:`已过期`,not_configured:`未评估`,not_applicable:`不适用`},Me=[{key:`case`,width:360,min:220},{key:`status`,width:110,min:90},{key:`automation`,width:125,min:105},{key:`defect`,width:150,min:120},{key:`filler`,filler:!0},{key:`action`,width:230,min:210}],Ne=[`all`,`executed`,`pending`,`passed`,`failed`,`blocked`,`skipped`],Pe=[`all`,`unconnected`,`pending`,`active`,`passed`,`issue`],Fe=`caseExecution.file`,Ie=`caseExecution.executionFilter`,Le=`caseExecution.automationFilter`,Re=`caseExecution.scrollByFile`;function ze(e,t=!1){let n=t?`not_applicable`:e.automation?.status||`not_configured`;return{status:n,label:je[n]||n,tone:Ae[n]||Ae.not_configured,total:e.automation?.total||0,passed:e.automation?.passed||0}}function Be(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.href:``}catch{return``}}function Ve(e,t){return t.length>80||/标题|步骤|预期|条件|实际|备注|内容|说明|描述/.test(e)}function He(e){return e.fields?.length?e.fields:[[`用例编号`,e.no],[`用例标题`,e.title],[`所属模块`,e.module],[`优先级`,e.priority],[`前置条件`,e.precondition],[`测试步骤`,e.steps],[`预期结果`,e.expected],[`用例状态`,e.status],[`实际结果`,e.actual],[`执行人`,e.executor],[`执行时间`,e.executedAt],[`执行证据`,e.evidence],[`缺陷编号`,e.defectNo],[`缺陷标题`,e.defectTitle],[`缺陷信息`,e.defectUrl]].map(([e,t])=>({name:e,value:t})).filter(e=>e.value)}function Ue({value:e,onChange:t,onBlur:n,disabled:r,className:i,placeholder:a,ariaLabel:o}){let s=(0,_.useRef)(null),c=(0,_.useCallback)(e=>{e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`},[]);return(0,_.useLayoutEffect)(()=>{let e=s.current;if(!e)return;c(e);let t=window.requestAnimationFrame(()=>c(e)),n=()=>c(e);return window.addEventListener(`resize`,n),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,n)}},[c,e]),(0,k.jsx)(`textarea`,{ref:s,value:e,onInput:e=>{c(e.currentTarget),t(e.currentTarget.value)},onBlur:n,disabled:r,rows:2,className:`${i} min-h-[4.25rem] resize-none overflow-hidden`,placeholder:a,"aria-label":o})}function We(e,t,n,r){return[`用例文件:${e.path}`,`用例编号:${t.no||`未填写`}`,`用例标题:${t.title}`,`模块:${t.module||`未填写`}`,`优先级:${t.priority||`未填写`}`,`执行结论:${n}`,`前置条件:\n${t.precondition||`无`}`,`测试步骤:\n${t.steps||`无`}`,`预期结果:\n${t.expected||`无`}`,`实际结果:\n${r||`无`}`,`判定依据:人工记录`].join(`
|
|
2
|
+
|
|
3
|
+
`)}function Ge({title:e,values:t,disabled:n,onTitleChange:r,onChange:i,onBlur:a}){let[o,s]=(0,_.useState)(null);return(0,k.jsxs)(`div`,{className:`space-y-2 md:col-span-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium text-stone-400`,children:`缺陷信息`}),(0,k.jsx)(`button`,{type:`button`,disabled:n||t.length>=50,onClick:()=>i([...t,``]),className:`text-xs text-[#4176e6] disabled:opacity-40`,children:`添加缺陷地址`})]}),(0,k.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:`缺陷标题`}),(0,k.jsx)(`input`,{value:e,disabled:n,onChange:e=>r(e.target.value),onBlur:a,className:`h-9 w-full rounded-md border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`填写缺陷标题`})]}),t.map((e,r)=>(0,k.jsxs)(`label`,{className:`block ${r?`md:col-start-2`:``}`,children:[(0,k.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:[`缺陷地址 `,r+1]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`input`,{type:`url`,"aria-label":`缺陷地址 ${r+1}`,value:e,disabled:n,onChange:e=>i(t.map((t,n)=>n===r?e.target.value:t)),onBlur:a,className:`h-9 min-w-0 flex-1 rounded-md border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`https://缺陷管理平台/...`}),Be(e)?(0,k.jsx)(`a`,{href:Be(e),target:`_blank`,rel:`noreferrer`,className:`text-xs text-[#4176e6]`,children:`打开`}):null,(0,k.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`删除缺陷地址 ${r+1}`,onClick:()=>s(r),className:`text-xs text-red-600`,children:`删除`})]})]},r))]}),(0,k.jsx)(c,{open:o!==null,title:`删除缺陷地址`,message:`删除「${o===null?``:t[o]||`空地址`}」?`,danger:!0,onClose:()=>s(null),onConfirm:()=>{let e=t.filter((e,t)=>t!==o);i(e.length?e:[``]),s(null)}})]})}function Ke(){let[e,t]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!0),[fe,v]=(0,_.useState)(null),[x,S]=(0,_.useState)([]),[T,E]=(0,_.useState)(()=>re(Fe)),[D,ge]=(0,_.useState)(null),[_e,O]=(0,_.useState)(!1),[ve,A]=(0,_.useState)(``),[Se,Ce]=(0,_.useState)(!1),[we,Ee]=(0,_.useState)(null),[j,De]=(0,_.useState)(`待验证`),[Ae,Ke]=(0,_.useState)(``),[qe,Je]=(0,_.useState)(``),[Ye,Xe]=(0,_.useState)(``),[Ze,Qe]=(0,_.useState)([``]),[$e,et]=(0,_.useState)({}),[N,P]=(0,_.useState)(`idle`),[tt,nt]=(0,_.useState)(null),[rt,it]=(0,_.useState)(!1),[at,ot]=(0,_.useState)(!1),[st,ct]=(0,_.useState)(null),[lt,ut]=(0,_.useState)(``),[dt,ft]=(0,_.useState)(()=>new Date().toISOString().slice(0,10)),[F,pt]=(0,_.useState)(null),[I,mt]=(0,_.useState)(()=>u(Ie,Ne,`all`)),[L,ht]=(0,_.useState)(()=>u(Le,Pe,`all`)),[gt,_t]=(0,_.useState)(!1),[vt,yt]=(0,_.useState)(``),[bt,xt]=(0,_.useState)(!1),[St,Ct]=(0,_.useState)({}),[wt,Tt]=(0,_.useState)(``),[R,Et]=(0,_.useState)(null),[z,Dt]=(0,_.useState)(!1),Ot=(0,_.useRef)(new Map),kt=(0,_.useRef)(T),At=(0,_.useRef)({}),jt=(0,_.useRef)(new Map),B=(0,_.useRef)(null),Mt=(0,_.useRef)(Promise.resolve()),Nt=(0,_.useRef)(``),V=h(`lh:case-execution:cols`,Me),Pt=m(`case-execution`),Ft=(0,_.useRef)(null),H=(0,_.useRef)(null),It=(0,_.useRef)(``),Lt=(0,_.useCallback)(e=>{Ft.current=e,Pt(e)},[Pt]),Rt=(0,_.useMemo)(()=>x.map(e=>({value:e.path,label:e.name,secondary:`${e.caseCount} 条用例 · ${e.executable?`可执行`:e.ext===`.xls`?`需另存为 xlsx`:e.executionIssue||e.error||`不可执行`}`})),[x]),U=we,zt=(0,_.useMemo)(()=>U?He(U):[],[U]),W=D?.columns.status||``,G=D?.columns.actual||``,K=D?.columns.defectNo||``,Bt=D?.columns.defectTitle||`缺陷标题`,q=D?.columns.defectUrl||`缺陷信息`,Vt=D?.columns.expected||``,J=D?.columns.priority||``,Ht=(0,_.useMemo)(()=>{let e=new Set([W,G,K,Bt,q,J].filter(Boolean));return zt.filter(t=>!e.has(t.name))},[zt,G,K,Bt,q,J,W]),Ut=Ht.findIndex(e=>e.name===Vt),Wt=Ut>=0?Ht.slice(0,Ut+1):Ht,Gt=Ut>=0?Ht.slice(Ut+1):[],Kt=$e[J]??zt.find(e=>e.name===J)?.value??``,qt=(0,_.useMemo)(()=>new Set([`用例编号`,`需求编号`,`模块`,`子模块`]),[]),Y=(0,_.useMemo)(()=>b(D?.cases||[]),[D?.cases]),Jt=[{label:`总数`,value:Y.total,className:`text-stone-900`,filter:`all`},{label:`已执行`,value:Y.executed,className:`text-[#275fc8]`,filter:`executed`},{label:`未执行`,value:Y.pending,className:`text-stone-700`,filter:`pending`},{label:`通过`,value:Y.passed,className:`text-emerald-600`,filter:`passed`},{label:`未通过`,value:Y.failed,className:`text-red-600`,filter:`failed`},{label:`阻塞`,value:Y.blocked,className:`text-amber-600`,filter:`blocked`},{label:`跳过`,value:Y.skipped,className:`text-stone-600`,filter:`skipped`}],Yt=!!D?.path.split(`/`).includes(`自动化测试`),Xt=(0,_.useMemo)(()=>{let e=(D?.cases||[]).filter(e=>{let t=y(e.status);return I===`all`?!0:I===`executed`?t!==`待验证`:I===`pending`?t===`待验证`:I===`passed`?t===`通过`:I===`failed`?t===`不通过`:I===`blocked`?t===`阻塞`:I!==`skipped`||t===`跳过`});return L===`all`?e:e.filter(e=>{let t=ze(e,Yt).status;return L===`unconnected`?[`not_configured`,`automatable`].includes(t):L===`pending`?[`needs_manual`,`not_automatable`].includes(t):L===`active`?[`connected`,`running`,`partial`].includes(t):L===`passed`?t===`passed`:L!==`issue`||[`failed`,`stale`].includes(t)})},[Yt,L,D?.cases,I]);(0,_.useEffect)(()=>{let e=D?.path;if(!e||e!==T||It.current===e)return;let t=window.setTimeout(()=>{let t=Ft.current;if(!t)return;let n=ae(Re,{}),r=Number(n[e]);t.scrollTop=Number.isFinite(r)&&r>0?Math.round(r):0,It.current=e},80);return()=>window.clearTimeout(t)},[D?.path,Xt.length,T]);let X=(0,_.useMemo)(()=>(D?.cases||[]).flatMap(e=>(e.automation?.items||[]).filter(e=>e.scriptPath&&[`connected`,`failed`,`passed`,`stale`].includes(e.status)).map(t=>({...t,sourceTitle:e.title}))),[D?.cases]),Zt=(0,_.useCallback)(async()=>{let e=await me();S(e),E(t=>t&&e.some(e=>e.path===t)?t:e.find(e=>e.executable)?.path||e[0]?.path||``)},[]),Z=(0,_.useCallback)(async e=>{if(!e){ge(null);return}let t=await C(e);Ot.current.set(e,t.fileHash),kt.current===e&&ge(t)},[]);(0,_.useEffect)(()=>{let e=l(e=>c(!!e.caseExecution));return o().then(()=>{c(te(`caseExecution`)),t(!0)}),e},[]),(0,_.useEffect)(()=>{e&&s&&(async()=>{let e=await pe();if(v(e),e)try{await Zt()}catch(e){A(e instanceof Error?e.message:String(e))}})()},[s,e,Zt]),(0,_.useEffect)(()=>{kt.current=T,T&&(A(``),Z(T).catch(e=>A(e instanceof Error?e.message:String(e))))},[Z,T]),(0,_.useEffect)(()=>{ie(Fe,T),It.current=``},[T]),(0,_.useEffect)(()=>{d(Ie,I)},[I]),(0,_.useEffect)(()=>{d(Le,L)},[L]),(0,_.useEffect)(()=>()=>{H.current!==null&&window.clearTimeout(H.current)},[]),(0,_.useEffect)(()=>{if(!Se||!U){Se||(Nt.current=``);return}let e=`${D?.path||``}:${U.rowIndex}`;if(Nt.current===e)return;Nt.current=e;let t=new Set([W,G,K,Bt,q].filter(Boolean)),n=Object.fromEntries(He(U).filter(e=>!t.has(e.name)).map(e=>[e.name,e.value]));At.current=n,et(n),jt.current.clear(),B.current!==null&&window.clearTimeout(B.current),B.current=null,P(`idle`)},[U,G,K,Bt,q,D?.path,Se,W]);function Qt(){P(`pending`),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,$()},650)}function Q(e,t){e&&(jt.current.set(e,t),Qt())}function $t(e,t){let n={...At.current,[e]:t};At.current=n,et(n),Q(e,t)}async function $(){if(!D||!U||!jt.current.size)return;let e=D.path,t=U.rowIndex,n=[...jt.current.entries()].map(([e,t])=>({header:e,value:t})),r=n.find(e=>e.header===W);jt.current.clear(),B.current!==null&&(window.clearTimeout(B.current),B.current=null),P(`saving`),Mt.current=Mt.current.then(async()=>{try{let i=await w({casePath:e,expectedFileHash:Ot.current.get(e)||D.fileHash,rowIndex:t,updates:n});Ot.current.set(e,i.fileHash),await Z(e),A(``),P(`saved`),r&&p(`执行结果已更新为「${r.value}」`,`success`)}catch(e){P(`error`),A(e instanceof Error?e.message:String(e))}})}function en(e,t){let n=D?.columns.status;if(!D||!n)return;let r=D.path;ge(r=>r&&{...r,cases:r.cases.map(r=>r.rowIndex===e.rowIndex?{...r,status:t,fields:r.fields?.map(e=>e.name===n?{...e,value:t}:e)}:r)}),P(`saving`),Mt.current=Mt.current.then(async()=>{try{let i=await w({casePath:r,expectedFileHash:Ot.current.get(r)||D.fileHash,rowIndex:e.rowIndex,updates:[{header:n,value:t}]});Ot.current.set(r,i.fileHash),await Z(r),P(`saved`),A(``),p(`执行结果已更新为「${t}」`,`success`)}catch(e){P(`error`),A(e instanceof Error?e.message:String(e)),await Z(r)}})}function tn(e,t=!1){t&&!D?.executable?A(D?.executionIssue||`该用例文件暂不可执行`):(Ee(e),De(y(e.status)),Ke(e.actual),Je(e.defectNo),Xe(e.defectTitle),Qe(ue(e.defectUrl).length?ue(e.defectUrl):[``]),Ce(!0))}function nn(e){tn(e,!0)}async function rn(e=U,t=j,n=Ae){if(D&&e){it(!0);try{let r=await fetch(`/__tb_defect_submit/templates`),i=await r.json();if(!r.ok)throw Error(i.error||`缺陷规则读取失败`);let a=i.templates||[];if(!a.length)throw Error(`还没有缺陷规则,请先在「缺陷规则」页面创建`);nt({templates:a,context:We(D,e,t,n||e.actual)})}catch(e){p(e instanceof Error?e.message:String(e),`error`)}finally{it(!1)}}}async function an(){if(D){O(!0);try{ct(await ce()),ut(D.path.split(/[\\/]/).pop()?.split(`_`)[0]||``),pt(null),ot(!0)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}}function on(e){let t=T;if(!t)return;let n=Math.max(0,Math.round(e.currentTarget.scrollTop));H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>{H.current=null;let e=ae(Re,{});ne(Re,{...e,[t]:n})},120)}function sn(){let e={};for(let t of X)e[t.automationCaseId]=!0;Ct(e),Et(null),Tt(``),xt(!0)}async function cn(){let e=Object.keys(St).filter(e=>St[e]);if(!e.length)A(`请至少选择一条已接入的自动化用例`);else{Dt(!0),A(``);try{let t=(await ye({automationCaseIds:e,env:wt})).batch;for(Et(t);t.status===`running`||t.status===`pending`;)await new Promise(e=>window.setTimeout(e,1e3)),t=(await be(t.id)).batch,Et({...t});T&&await Z(T),p(t.status===`completed`?`自动化运行结束`:`自动化运行已停止`,t.status===`completed`?`success`:void 0)}catch(e){A(e instanceof Error?e.message:String(e))}finally{Dt(!1)}}}async function ln(){if(R&&z!==!1)try{let e=await xe(R.id);Et(e.batch)}catch(e){A(e instanceof Error?e.message:String(e))}}async function un(){if(D&<.trim())try{pt(await he({casePath:D.path,project:lt.trim(),date:dt,mode:`preview`}))}catch(e){A(e instanceof Error?e.message:String(e))}}async function dn(e){if(D&<.trim()){O(!0);try{let t=await he({casePath:D.path,project:lt.trim(),date:dt,mode:e});pt(t),p(t.skipped?`已跳过已有统计`:`用例执行统计已同步`,`success`),ot(!1)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}}}function fn(e,t){let n=$e[e.name]??e.value,r=Ve(e.name,n);return(0,k.jsxs)(`label`,{className:`block ${r?`md:col-span-2`:``}`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:e.name}),qt.has(e.name)?(0,k.jsx)(`input`,{value:n,onChange:t=>$t(e.name,t.target.value),onBlur:()=>void $(),disabled:!1,className:`h-9 w-full rounded-md border border-stone-200 bg-white px-2.5 text-sm text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`}):(0,k.jsx)(Ue,{value:n,onChange:t=>$t(e.name,t),onBlur:()=>void $(),disabled:!1,className:`w-full rounded-md border border-stone-200 bg-white px-2.5 py-2 text-sm leading-6 text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`})]},`${e.name}-${t}`)}return e?s?fe===null?(0,k.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-5 py-16 text-center text-sm text-stone-500`,children:`正在连接用例执行服务…`}):fe?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`section`,{className:`flex h-[calc(100vh-4rem)] min-h-[640px] flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 p-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`div`,{className:`min-w-[240px] max-w-[460px] flex-1`,children:(0,k.jsx)(f,{value:T,onChange:E,options:Rt,searchable:!0,searchPlaceholder:`搜索用例文件…`,ariaLabel:`选择用例文件`})}),(0,k.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,k.jsx)(`div`,{className:`w-44 shrink-0`,children:(0,k.jsx)(f,{className:`!block w-full`,value:L,onChange:ht,options:[{value:`all`,label:`全部自动化状态`},{value:`unconnected`,label:`未接入`},{value:`pending`,label:`待处理`},{value:`active`,label:`进行中`},{value:`passed`,label:`已通过`},{value:`issue`,label:`异常或过期`}],ariaLabel:`筛选自动化状态`,compact:!0,menuMatchTrigger:!1,menuMinWidth:176})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>void an(),disabled:!D?.executable,className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium text-stone-700 hover:bg-stone-100 disabled:opacity-40`,children:`同步统计`}),(0,k.jsx)(`button`,{type:`button`,disabled:!D?.cases.length,onClick:()=>{yt(``),_t(!0)},className:`tw-btn tw-btn-ghost h-8 whitespace-nowrap text-xs`,title:`选择当前文件中的用例进行自动化识别评估`,children:`自动化评估`}),(0,k.jsx)(`button`,{type:`button`,disabled:!X.length,onClick:sn,className:`tw-btn tw-btn-ghost h-8 whitespace-nowrap text-xs`,title:X.length?`运行 ${X.length} 条已接入自动化用例`:`先为功能用例生成并写入自动化脚本`,children:`运行自动化`})]})]}),(0,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 rounded-lg bg-stone-50 px-3 py-2 text-xs text-stone-500`,children:[Jt.map(e=>{let t=I===e.filter;return(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":t,title:e.filter===`all`?`显示全部用例`:`筛选${e.label}用例;再次点击取消筛选`,onClick:()=>mt(t=>e.filter===`all`||t===e.filter?`all`:e.filter),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-1.5 py-0.5 transition-colors ${t?`bg-white text-stone-800 shadow-sm ring-1 ring-stone-200`:`hover:bg-white/70`}`,"data-hint":e.label===`已执行`?`不包含待验证`:void 0,children:[(0,k.jsx)(`span`,{children:e.label}),(0,k.jsx)(`span`,{className:`font-semibold tabular-nums ${e.className}`,children:e.value})]},e.label)}),(0,k.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2 whitespace-nowrap`,children:[(0,k.jsx)(`span`,{children:`执行率`}),(0,k.jsxs)(`span`,{className:`font-semibold tabular-nums text-stone-800`,children:[Y.executionRate,`%`]}),(0,k.jsx)(`span`,{className:`h-1.5 w-20 overflow-hidden rounded-full bg-stone-200`,children:(0,k.jsx)(`span`,{className:`block h-full rounded-full bg-[#4176e6] transition-[width] duration-300`,style:{width:`${Y.executionRate}%`}})})]})]}),D?.provenance?.stale?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:`需求基线已变化:历史结果保留,需更新基线并人工复核。`}):null,D&&!D.executable?(0,k.jsx)(`p`,{className:`mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:D.executionIssue||`该用例文件暂不能执行。`}):null,ve?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-red-600`,children:ve}):null]}),(0,k.jsxs)(`div`,{ref:Lt,onScroll:on,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:[(0,k.jsxs)(`table`,{className:`tw-sticky-table table-fixed text-sm`,style:V.tableStyle,children:[(0,k.jsx)(`colgroup`,{children:Me.map(e=>(0,k.jsx)(`col`,{style:V.widthOf(e.key)?{width:V.widthOf(e.key)}:void 0},e.key))}),(0,k.jsx)(`thead`,{className:`sticky top-0 z-10 bg-stone-50 text-xs text-stone-500`,children:(0,k.jsxs)(`tr`,{children:[(0,k.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium`,children:[`用例`,(0,k.jsx)(g,{...V.resizeProps(`case`)})]}),(0,k.jsxs)(`th`,{className:`relative px-3 py-2 text-center font-medium`,children:[`执行结果`,(0,k.jsx)(g,{...V.resizeProps(`status`)})]}),(0,k.jsxs)(`th`,{className:`relative px-3 py-2 text-center font-medium`,children:[`自动化状态`,(0,k.jsx)(g,{...V.resizeProps(`automation`)})]}),(0,k.jsxs)(`th`,{className:`relative px-3 py-2 text-center font-medium`,children:[`缺陷信息`,(0,k.jsx)(g,{...V.resizeProps(`defect`)})]}),(0,k.jsx)(`th`,{"aria-hidden":`true`}),(0,k.jsxs)(`th`,{className:`relative px-3 py-2 text-center font-medium`,children:[`操作`,(0,k.jsx)(g,{...V.resizeProps(`action`)})]})]})}),(0,k.jsx)(`tbody`,{children:Xt.map(e=>(0,k.jsxs)(`tr`,{tabIndex:0,"aria-label":`查看用例:${e.title||`未命名用例`}`,onClick:()=>tn(e),onKeyDown:t=>{t.target===t.currentTarget&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),tn(e))},className:`cursor-pointer border-t border-stone-100 hover:bg-stone-100 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#4176e6]/50 focus-visible:outline-none`,children:[(0,k.jsxs)(`td`,{className:`px-3 py-2 align-top`,children:[(0,k.jsx)(oe,{text:[e.no?`#${e.no}`:``,e.module||``,e.priority||``].filter(Boolean).join(` · `)||`未编号`,className:`block truncate text-[11px] text-stone-400`}),(0,k.jsx)(oe,{text:e.title||`未命名用例`,className:`mt-0.5 block truncate font-medium text-stone-800`}),(0,k.jsx)(oe,{text:e.steps||e.expected||`无步骤`,className:`mt-1 block truncate text-[11px] text-stone-400`})]}),(0,k.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:D?.columns.status?(0,k.jsx)(f,{value:M(e.status),onChange:t=>en(e,t),options:[...M(e.status)===`未执行`?[{value:`未执行`,label:`未执行`}]:[],...(D.statuses||[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`]).map(e=>({value:e,label:e}))],ariaLabel:`选择用例状态:${e.title||`未命名用例`}`,unstyled:!0,fitContent:!0,menuMatchTrigger:!1,menuMinWidth:120,triggerClassName:`h-6 cursor-pointer whitespace-nowrap rounded-full border px-2 text-[11px] font-medium shadow-sm transition-colors hover:opacity-80 focus-visible:ring-2 focus-visible:ring-[#4176e6]/40 ${Oe(M(e.status))} disabled:opacity-50`,renderTrigger:()=>(0,k.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[M(e.status),(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`text-[9px] opacity-70`,children:`▼`})]})}):(0,k.jsx)(`span`,{className:`inline-flex whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] ${Oe(M(e.status))}`,children:M(e.status)})}),(0,k.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(()=>{let t=ze(e,Yt);return(0,k.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] ${t.tone}`,title:t.status===`passed`?`${t.passed}/${t.total} 条自动化用例通过`:je[t.status]||t.status,children:[t.label,t.total?` ${t.passed}/${t.total}`:``]})})()}),(0,k.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(()=>{let t=ue(e.defectUrl),n=String(e.defectTitle||``).split(/\r?\n/).map(e=>e.trim()).filter(Boolean);return t.length?(0,k.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center gap-1`,children:t.map((e,t)=>{let r=n[t]||(t===0?n[0]:``)||`缺陷 ${t+1}`;return(0,k.jsx)(`a`,{href:Be(e),target:`_blank`,rel:`noreferrer`,className:`block w-full min-w-0 truncate text-xs font-medium text-[#4176e6] hover:underline`,children:(0,k.jsx)(oe,{text:r,className:`block truncate`})},e)})}):(0,k.jsx)(`span`,{className:`text-xs text-stone-400`,children:`—`})})()}),(0,k.jsx)(`td`,{"aria-hidden":`true`}),(0,k.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,children:(0,k.jsxs)(`div`,{className:`flex justify-center gap-1.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[Yt?null:(0,k.jsx)(`button`,{type:`button`,disabled:_e,onClick:()=>{yt(e.id),_t(!0)},className:`h-7 rounded-md border border-[#b8cdf7] px-2.5 text-xs font-medium text-[#275fc8] hover:bg-[#f2f6ff] disabled:opacity-40`,children:(e.automation?.status||`not_configured`)===`not_configured`?`评估`:`重新评估`}),(0,k.jsx)(`button`,{type:`button`,disabled:_e||!D?.executable,onClick:()=>nn(e),className:`h-7 rounded-md border border-stone-200 px-2.5 text-xs text-stone-700 hover:bg-stone-100 disabled:opacity-40`,children:`手动记录`}),ke(e.status)?(0,k.jsx)(`button`,{type:`button`,disabled:_e||rt,onClick:()=>{rn(e,y(e.status),e.actual)},className:`h-7 rounded-md border border-red-200 px-2.5 text-xs font-medium text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`创建缺陷`}):null]})})]},e.id))})]}),D?.cases.length?Xt.length?null:(0,k.jsx)(`div`,{className:`px-4 py-20 text-center text-sm text-stone-400`,children:`没有符合当前筛选条件的用例`}):(0,k.jsx)(`div`,{className:`px-4 py-20 text-center text-sm text-stone-400`,children:`暂无可执行用例`})]})]}),(0,k.jsx)(Te,{open:gt,casePath:T,initialCaseId:vt,onClose:()=>{_t(!1),yt(``),T&&Z(T)},onApplied:()=>{T&&Z(T)}}),(0,k.jsxs)(se,{open:bt,onClose:()=>{z||xt(!1)},title:`运行已接入自动化`,widthClass:`max-w-2xl`,bodyClassName:`space-y-4`,footer:(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-stone-500`,children:R?`${R.items.filter(e=>e.status===`passed`).length}/${R.items.length} 通过`:`已选择 ${Object.values(St).filter(Boolean).length} 条`}),(0,k.jsx)(`div`,{className:`flex gap-2`,children:R&&[`running`,`pending`].includes(R.status)?(0,k.jsx)(`button`,{type:`button`,onClick:()=>void ln(),className:`h-9 rounded-lg border border-[#f0c6c6] px-3 text-sm text-red-600 hover:bg-red-50`,children:`停止`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>xt(!1),className:`h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-600`,children:`关闭`}),(0,k.jsx)(`button`,{type:`button`,disabled:z||!X.length,onClick:()=>void cn(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white disabled:opacity-40`,children:z?`运行中…`:`开始运行`})]})})]}),children:[(0,k.jsx)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50 p-3 text-xs leading-5 text-stone-600`,children:`只运行已经写入 Playwright iteration 文件的自动化测试块。每个测试按 automationCaseId 独立回写,不会把同一文件里的其他用例结果混入。`}),(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:`运行环境 ENV`}),(0,k.jsx)(`input`,{value:wt,onChange:e=>Tt(e.target.value),placeholder:`留空使用项目默认 .env;例如 test / uat`,className:`h-9 w-full rounded-lg border border-stone-200 bg-white px-3 text-sm outline-none focus:border-[#4176e6]`})]}),X.length?(0,k.jsx)(`div`,{className:`space-y-2`,children:X.map(e=>(0,k.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg border border-stone-200 p-3 hover:bg-stone-50`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:!!St[e.automationCaseId],disabled:z,onChange:t=>Ct(n=>({...n,[e.automationCaseId]:t.target.checked})),className:`mt-1`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`span`,{className:`block truncate text-sm font-medium text-stone-800`,children:e.title}),(0,k.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-stone-400`,children:[e.sourceTitle,` · `,e.projectName,` · `,e.iteration,` · `,e.tag]}),(0,k.jsxs)(`span`,{className:`mt-1 block text-[11px] text-stone-500`,children:[je[e.status]||e.status,e.error?` · ${e.error}`:``]})]}),e.reportUrl?(0,k.jsx)(`a`,{href:e.reportUrl,target:`_blank`,rel:`noreferrer`,className:`text-xs text-[#4176e6]`,children:`报告`}):null]},e.automationCaseId))}):(0,k.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-10 text-center text-sm text-stone-400`,children:`当前文件还没有已写入项目的自动化脚本。`}),R?(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`运行进度`}),R.error?(0,k.jsx)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:R.error}):null,R.items.map(e=>(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md bg-stone-50 px-3 py-2 text-xs`,children:[(0,k.jsx)(`span`,{className:`truncate text-stone-600`,children:e.automationCaseId}),(0,k.jsx)(`span`,{className:e.status===`passed`?`text-emerald-600`:e.status===`failed`?`text-red-600`:`text-stone-500`,children:e.status})]},e.automationCaseId))]}):null]}),(0,k.jsx)(se,{open:Se,onClose:()=>{$(),Ce(!1)},title:`用例详情与执行结果`,widthClass:`max-w-3xl`,escDisabled:!1,bodyClassName:`flex flex-col gap-4 !pb-10`,children:U?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`rounded-lg bg-stone-50 p-3`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-400`,children:[(0,k.jsx)(`span`,{children:U.no?`#${U.no}`:`未编号`}),U.module?(0,k.jsxs)(`span`,{children:[`· `,U.module]}):null,U.priority?(0,k.jsxs)(`span`,{children:[`· `,U.priority]}):null]}),(0,k.jsx)(`div`,{className:`mt-1 text-sm font-semibold text-stone-900`,children:U.title})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`字段内容`}),(0,k.jsx)(`span`,{className:`text-[11px] ${N===`error`?`text-red-600`:N===`saved`?`text-emerald-600`:`text-stone-400`}`,children:N===`pending`?`等待自动保存`:N===`saving`?`正在保存…`:N===`saved`?`已自动保存`:N===`error`?`保存失败`:`${zt.length} 个字段`})]}),(0,k.jsxs)(`div`,{className:`grid gap-x-4 gap-y-3 md:grid-cols-2`,children:[Wt.map(fn),G?(0,k.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:G}),(0,k.jsx)(Ue,{value:Ae,onChange:e=>{Ke(e),Q(G,e)},onBlur:()=>void $(),disabled:!1,className:`w-full rounded-md border border-stone-200 bg-white px-2.5 py-2 text-sm leading-6 text-stone-700 outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`记录实际操作、页面现象和与预期的差异`})]}):null,(0,k.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 pt-4 md:col-span-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`执行信息`}),(0,k.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`修改后自动保存到文件`})]}),D?.executable?null:(0,k.jsx)(`p`,{className:`rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-800`,children:D?.executionIssue||`该文件缺少执行列;其他已有字段仍可编辑,补齐后可记录完整执行结果。`}),(0,k.jsxs)(`div`,{className:`grid gap-x-4 gap-y-3 md:grid-cols-2`,children:[J?(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:J}),(0,k.jsx)(`input`,{value:Kt,onChange:e=>$t(J,e.target.value),onBlur:()=>void $(),disabled:!1,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6] disabled:opacity-60`})]}):null,W?(0,k.jsxs)(`label`,{className:`block`,children:[(0,k.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:W}),(0,k.jsx)(f,{value:j,onChange:e=>{De(e),Q(W,e)},ariaLabel:`选择${W}`,disabled:!1,options:(D?.statuses||[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`]).map(e=>({value:e,label:e}))})]}):null,K?(0,k.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,k.jsxs)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:[K,`(可选)`]}),(0,k.jsx)(`input`,{value:qe,onChange:e=>{Je(e.target.value),Q(K,e.target.value)},onBlur:()=>void $(),disabled:!1,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6] disabled:opacity-60`,placeholder:`后续提交缺陷后回填`})]}):null]})]}),Gt.map(fn),(0,k.jsx)(Ge,{title:Ye,values:Ze,disabled:!1,onTitleChange:e=>{Xe(e),Q(Bt,e)},onChange:e=>{Qe(e),Q(q,e.filter(e=>e.trim()).join(`
|
|
4
|
+
`))},onBlur:()=>void $()})]})]}),U.automation?.items?.length?(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`自动化关联`}),U.automation.items.map(e=>(0,k.jsxs)(`div`,{className:`rounded-lg border border-stone-200 px-3 py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium text-stone-800`,children:e.title}),(0,k.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.iteration})]}),(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-stone-500`,children:[e.projectName||e.projectId,e.iterationFile?` · ${e.iterationFile}`:``]}),e.error?(0,k.jsx)(`p`,{className:`mt-1 text-xs text-red-600`,children:e.error}):null,(0,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs`,children:[(0,k.jsx)(`span`,{children:je[e.status]||e.status}),e.logUrl?(0,k.jsx)(`a`,{href:e.logUrl,target:`_blank`,rel:`noreferrer`,className:`text-[#4176e6]`,children:`查看日志`}):null,e.reportUrl?(0,k.jsx)(`a`,{href:e.reportUrl,target:`_blank`,rel:`noreferrer`,className:`text-[#4176e6]`,children:`查看报告`}):null]})]},e.automationCaseId))]}):null,j===`不通过`||j===`阻塞`?(0,k.jsx)(`button`,{type:`button`,onClick:()=>void rn(),disabled:rt,className:`h-9 rounded-lg border border-red-200 px-3 text-sm font-medium text-red-600 hover:bg-red-50 disabled:opacity-40`,children:j===`阻塞`?`仍要创建缺陷`:`创建缺陷`}):null]}):null}),(0,k.jsxs)(i,{open:!!tt,onClose:()=>nt(null),className:`relative z-110`,children:[(0,k.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,k.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,k.jsxs)(n,{className:`w-full max-w-md rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,k.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`选择缺陷规则`}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`选择后将进入缺陷提交工作台,不会自动提交。`}),(0,k.jsx)(`div`,{className:`mt-4 space-y-2`,children:tt?.templates.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void de(e,tt.context),className:`w-full rounded-lg border border-stone-200 px-3 py-2.5 text-left text-sm hover:border-[#4176e6] hover:bg-[#f7f9ff]`,children:[(0,k.jsx)(`span`,{className:`block font-medium text-stone-800`,children:e.name}),(0,k.jsx)(`span`,{className:`mt-0.5 block text-xs text-stone-500`,children:e.config.target.sheetTitle||e.config.target.platform||`缺陷入口`})]},e.id))}),(0,k.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>nt(null),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-600`,children:`取消`})})]})})]}),(0,k.jsxs)(i,{open:at,onClose:()=>ot(!1),className:`relative z-110`,children:[(0,k.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,k.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,k.jsxs)(n,{className:`w-full max-w-lg rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,k.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`同步到用例执行统计`}),(0,k.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`同步不会自动覆盖手工统计,覆盖前会再次确认。`}),(0,k.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,k.jsxs)(`label`,{className:`grid gap-1 text-xs text-stone-600`,children:[`统计项目`,(0,k.jsx)(`input`,{list:`case-execution-stats-projects`,value:lt,onChange:e=>ut(e.target.value),className:`h-9 rounded-lg border border-stone-200 px-3 text-sm`,placeholder:`选择或输入项目名称`}),(0,k.jsx)(`datalist`,{id:`case-execution-stats-projects`,children:(st?.projects||[]).map(e=>(0,k.jsx)(`option`,{value:e},e))})]}),(0,k.jsxs)(`label`,{className:`grid gap-1 text-xs text-stone-600`,children:[`统计日期`,(0,k.jsx)(le,{value:dt,onChange:ft,className:`h-9 rounded-lg border border-stone-200 px-3 text-sm`})]}),F?(0,k.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50 p-3 text-sm text-stone-700`,children:[(0,k.jsxs)(`div`,{children:[`总数:`,F.preview.total]}),(0,k.jsxs)(`div`,{children:[`已执行:`,F.preview.executed]}),(0,k.jsxs)(`div`,{children:[`剩余:`,F.preview.pending]}),F.preview.existing?(0,k.jsx)(`div`,{className:`mt-1 text-amber-700`,children:`该日期已有手工统计,不会自动覆盖。`}):null]}):null]}),(0,k.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>ot(!1),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-600`,children:`取消`}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>void un(),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-700`,children:`预览`}),F?.preview.existing?(0,k.jsx)(`button`,{type:`button`,onClick:()=>void dn(`skip`),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-700`,children:`跳过`}):null,(0,k.jsx)(`button`,{type:`button`,onClick:()=>void dn(F?.preview.existing?`overwrite`:`skip`),className:`h-8 rounded-lg bg-[#4176e6] px-3 text-xs text-white`,children:`同步`})]})]})})]})]}):(0,k.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行需要本地服务,当前未就绪。`}):(0,k.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`caseExecution`)}):(0,k.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-5 py-16 text-center text-sm text-stone-500`,children:`正在读取插件状态…`})}export{Ke as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BSO5r82v.js";import{b as r,m as i,p as a,u as o}from"./settings.BojKNwUC.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./SelectDropdown.D7IeyHDI.js";import{showToast as l}from"./Toast.BydY-X7T.js";import{n as u,r as d}from"./case-types.BjF1BivA.js";import{d as ee,f,m as p,p as m,r as h,u as te}from"./case-gen-run.
|
|
2
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.BSO5r82v.js";import{b as r,m as i,p as a,u as o}from"./settings.BojKNwUC.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./SelectDropdown.D7IeyHDI.js";import{showToast as l}from"./Toast.BydY-X7T.js";import{n as u,r as d}from"./case-types.BjF1BivA.js";import{d as ee,f,m as p,p as m,r as h,u as te}from"./case-gen-run.DQR6uvH5.js";import{a as g}from"./case-fields.C03NY3zC.js";import{c as _,d as v,l as y,m as b,p as x,r as S,v as C,y as w}from"./project-docs.BRgNjXhG.js";import{a as ne,i as re,n as T,o as ie,r as E,s as ae,t as oe}from"./case-template.CC2eXegU.js";import{o as se}from"./llm.BCYNgppW.js";import{n as D}from"./doc-roots.C-20VD0x.js";import{n as ce,t as le}from"./case-prompt.ByLTgz4r.js";import{t as ue}from"./ExcelFieldTags.CXif3Ilh.js";import{t as de}from"./MultiSelectDropdown.D-rbpivp.js";import{t as O}from"./SearchableSelect.DXclLMJI.js";var k=e(t(),1),A=s(),fe=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function pe(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title;return{docTitle:typeof r==`string`?r.trim():``,cases:n}}}catch{return null}return null}function me(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function he(e){let t=e.match(/^#\s+(.+)$/m);if(t?.[1])return t[1].trim().slice(0,48);let n=e.match(/^标题[::]\s*(.+)$/m);return n?.[1]?n[1].trim().slice(0,48):``}function ge(e,t){let n=[];if(!e.length)return n.push(`未生成任何用例`),n;for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}e.length<15&&n.push(`用例数量偏少(${e.length} 条),建议核对需求覆盖`);let r=e.map(e=>{for(let t of[`用例标题`,`标题`,`测试分项目`,`测试项目`])if(e[t]?.trim())return e[t].trim();return``}).filter(Boolean),i=new Set(r);return r.length>=4&&i.size<r.length*.6&&n.push(`用例标题/分项重复偏多,可能覆盖不足`),n}function _e(){if(typeof window>`u`)return`functional`;let e=new URLSearchParams(window.location.search).get(`caseType`)??``,t=d();return t.find(t=>t.id===e)?.id??t[0]?.id??`functional`}function ve(e){if(e==null||e<0)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)} s`;let n=Math.floor(t/60);return`${n} 分 ${Math.round(t-n*60)} 秒`}function ye(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function be(e){let t=u(e).templateFolder;try{let{entries:e}=await _(`templates`,t),n=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of n){let t=e.name.toLowerCase(),n=[...g],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await x(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=re(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await b(`templates`,e.path),r=T(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await b(`templates`,e.path),r=E(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function j(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await b(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await x(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let i=atob(n.contentBase64),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);return((await(await r(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2]))).extractRawText({arrayBuffer:a.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function M(){let[e,t]=(0,k.useState)(null),[r,s]=(0,k.useState)(!1),[x,re]=(0,k.useState)([]),[T,E]=(0,k.useState)(``),[M,N]=(0,k.useState)(_e),[P,xe]=(0,k.useState)([]),[F,I]=(0,k.useState)(``),[L,Se]=(0,k.useState)(``),[Ce,we]=(0,k.useState)(``),[Te,Ee]=(0,k.useState)([]),[R,z]=(0,k.useState)([]),[B,V]=(0,k.useState)(`md`),[H,De]=(0,k.useState)(``),[U,W]=(0,k.useState)(null),[G,Oe]=(0,k.useState)(!1),[ke,K]=(0,k.useState)(null),[q,J]=(0,k.useState)(null),Y=(0,k.useRef)(null),Ae=(0,k.useRef)(null),X=(0,k.useMemo)(()=>P.find(e=>e.id===F)??P[0],[P,F]),Z=M,je=u(Z).label;(0,k.useEffect)(()=>{n().then(()=>t(o()));let e=a(()=>t(o()));return(async()=>{await ee();let e=await S(`requirements`),t=await S(`cases`),n=await S(`templates`),r=await S(`knowledge`);s(e&&t&&n);async function i(e,t,n){let{entries:r}=await _(e,t);for(let t of r)t.type===`file`?n.push(t):await i(e,t.path,n)}if(e)try{let e=[];await i(`requirements`,`.`,e),re(e)}catch{}if(r)try{let e=[];await i(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Ee(e)}catch{}let a=new URLSearchParams(window.location.search),o=a.get(`session`),c=a.get(`path`),l=f();if(o){let e=l.sessions.find(e=>e.id===o);e&&(W(e),N(e.caseType),V(e.outputFormat),E(e.reqPaths[0]??``),e.templateId&&I(e.templateId),e.knowledgePaths?.length&&z([...e.knowledgePaths]),e.linkedCasePath&&J({path:e.linkedCasePath,count:0}))}else if(c){let e=l.sessions.find(e=>e.linkedCasePath===c);if(e)W(e),N(e.caseType),V(e.outputFormat),E(e.reqPaths[0]??``),e.templateId&&I(e.templateId),e.knowledgePaths?.length&&z([...e.knowledgePaths]),e.linkedCasePath&&J({path:e.linkedCasePath,count:0});else{let e=c.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=c.split(`/`)[0]??``,r=d().find(e=>e.casesFolder===n)?.id??d()[0]?.id??`functional`,i=te({title:c.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=p(i.id,{linkedCasePath:c}).sessions.find(e=>e.id===i.id)??null;W(a),N(r),V(t),J({path:c,count:0})}}})(),e},[]),(0,k.useEffect)(()=>{if(!r)return;let e=!1;return be(M).then(t=>{e||(xe(t),I(e=>e&&t.some(t=>t.id===e)?e:U?.templateId&&t.some(e=>e.id===U.templateId)?U.templateId:t[0]?.id??``))}),()=>{e=!0}},[r,M,U?.templateId]),(0,k.useEffect)(()=>{let e=!0;return le().then(()=>ce(M,u(M).label)).then(({skill:t,content:n})=>{e&&(Se(t.legacyPath),we(n),n.trim()||l(`技能「${t.name}」正文为空,请先到技能页补全`,`error`))}).catch(t=>{e&&(Se(``),we(``),l(t instanceof Error?t.message:String(t),`error`))}),()=>{e=!1}},[M]),(0,k.useEffect)(()=>{Ae.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[U?.messages,G]);function Q(e){if(!U)return;let t=p(U.id,e);W(t.sessions.find(e=>e.id===U.id)??U)}async function Me(){let e=``;if(T)try{let t=await j(T);e+=`\n### 需求文档:${T}\n${t}\n`}catch{e+=`\n### 需求文档:${T}\n(无法读取正文)\n`}X?.body?e+=`\n### 用例模板:${X.title}\n${X.body}\n`:X&&(e+=`\n### 用例模板:${X.title}\n字段:${(X.headers.length?X.headers:g).join(`、`)}\n`);for(let t of R)try{let n=await b(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function Ne(e,t,n,r){let i=u(t.caseType),a=n||t.title||i.label,o=h(a,t.caseType),s=i.casesFolder;try{await y(`cases`,`.`,s)}catch{}let c=`${s}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,l=r.length?r:[...g];return t.outputFormat===`md`?await w(`cases`,c,ie(e,a,l)):t.outputFormat===`csv`?await w(`cases`,c,ne(e,l)):await C(`cases`,c,await ae(e,l,i.label)),c}async function Pe(){if(!T)return``;let e=me(T);try{return he(await j(T))||e}catch{return e}}async function Fe(t,n){if(!e){i(`model`);return}if(!r){K(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let a=await Pe(),o=n;o?(p(o.id,{caseType:M,outputFormat:B,reqPaths:T?[T]:[],templateId:X?.id,templateTitle:X?.title,promptPath:L||void 0,knowledgePaths:R.length?[...R]:void 0}),o={...o,caseType:M,outputFormat:B,reqPaths:T?[T]:[],templateId:X?.id,templateTitle:X?.title,promptPath:L||void 0,knowledgePaths:R.length?[...R]:void 0}):(o=te({title:a||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:B,reqPaths:T?[T]:[],templateId:X?.id,templateTitle:X?.title,promptPath:L||void 0,knowledgePaths:R.length?[...R]:void 0}),W(o));let s=await Me(),c=u(M).label,d=X?.headers?.length?X.headers:[...g],ee=B===`md`?`最终结果将保存为 Markdown 表格文件`:B===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,f=Ce.trim();if(!f){let e=L?`默认技能「${L}」没读到内容,请先在技能页补上`:`默认用例生成技能尚未就绪,请重新打开插件`;K(e),l(e,`error`);return}let m=`${f}
|
|
3
3
|
|
|
4
4
|
【运行时约束】
|
|
5
5
|
- 用例类型:${c}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/case-fields.C03NY3zC.js","_astro/react.Blvh0GOs.js","_astro/case-workflow-contract.BBQ9bbKL.js","_astro/lib.S37S0T6S.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,n as r,r as i,t as a}from"./dialog.XgRGNF_Q.js";import{W as o,i as s}from"./app-config.BSO5r82v.js";import{b as c,p as l,s as u,u as d}from"./settings.BojKNwUC.js";import{t as f}from"./jsx-runtime.DUg_B_vD.js";import{t as p}from"./ConfirmDialog.DQFd6g2r.js";import{a as m,o as h,r as g}from"./plugins.ChGmBEkF.js";import{n as _,o as v,r as y,s as b}from"./view-prefs.CWc5cQ2q.js";import{n as x,t as S}from"./SelectDropdown.D7IeyHDI.js";import{t as C}from"./SlideOverDrawer.CvyB-quk.js";import{m as w}from"./PmShared.TOjBbtV8.js";import{showToast as T}from"./Toast.BydY-X7T.js";import{n as ee,t as te}from"./DocsPager.Dg765uHW.js";import{n as E,r as D,t as ne}from"./TableFieldConfig.DHj25OKN.js";import{r as O,t as k}from"./composer-task.DRi5tAJs.js";import{d as re,f as A,h as j,l as M,n as ie,o as N,p as ae,t as oe,v as se}from"./open-docs-in-session.BoyV6R2A.js";import{a as ce,c as P,d as le,i as ue,l as de,n as fe,o as pe,t as F}from"./ColumnResize.CkE59sGq.js";import{r as me}from"./case-types.BjF1BivA.js";import{i as I,n as L,o as R}from"./case-gen-run.DQR6uvH5.js";import{a as he,i as ge,r as _e,t as ve}from"./case-fields.C03NY3zC.js";import{_ as ye,c as be,d as xe,f as Se,g as Ce,i as z,l as we,m as Te,n as B,o as Ee,p as De,r as Oe,u as ke}from"./project-docs.BRgNjXhG.js";import{c as Ae}from"./case-template.CC2eXegU.js";import{A as je,L as V,g as Me}from"./req-analysis.efWkT7Gv.js";import{s as Ne}from"./llm.BCYNgppW.js";import{n as H}from"./doc-roots.C-20VD0x.js";import{i as U,n as Pe,r as Fe,t as Ie}from"./DocsFileBrowser.z5JZ74cy.js";import{A as Le,C as Re,D as ze,E as Be,M as Ve,O as He,S as Ue,T as We,_ as Ge,a as Ke,b as qe,c as Je,d as W,f as Ye,g as Xe,h as Ze,i as G,j as Qe,k as $e,l as K,m as q,n as et,o as J,p as tt,r as nt,s as rt,t as it,u as Y,v as at,w as ot,x as st,y as ct}from"./case-review.BodP2jKm.js";import{t as lt}from"./NamePromptDialog.KPCeXmri.js";import{n as ut,t as dt}from"./composer-draft.llpvz3MW.js";var X=e(t(),1),ft=`备份列表`;function pt(e){return String(e??``).replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()===ft}function mt(e){let t=String(e??``).split(/[/\\]/).pop();return t?/\.bak(?:$|[-_.])/i.test(t):!1}var Z=f(),ht=40,gt=20,_t=`tw.case-backup.page-size.v1`,vt=[{key:`select`,width:ht,min:36},{key:`name`,width:280,min:140},{key:`kind`,width:100,min:72},{key:`mtime`,width:148,min:120},{key:`size`,width:88,min:64},{key:`filler`,filler:!0},{key:`action`,width:72,min:64}];async function yt(e=`.`){let{entries:t}=await be(`cases`,e),n=[];for(let e of t)e.type===`file`?(mt(e.name)||mt(e.path))&&n.push(e):!pt(e.name)&&!pt(e.path)&&n.push(...await yt(e.path));return n}function bt(e){let t=e.kind===`folder`?`备份`:e.kind===`sidecar`?`旁路`:`历史`;return e.caseTypeLabel?`${e.caseTypeLabel} · ${t}`:t}function xt(e){if(!Number.isFinite(e))return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}function St(e){return e==null||!Number.isFinite(e)?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Ct(e,t){let n=String(e.path??``).replaceAll(`\\`,`/`).split(`/`).filter(Boolean),r=n.indexOf(ft);if(r>0||r!==0&&n.length>1)return n[0]||``;let i=e.name.replace(/[_\-\s.]/g,``);return t.find(e=>i.includes(`${e.label.replace(/[_\-\s.]/g,``)}用例`)||i.includes(`${e.casesFolder.replace(/[_\-\s.]/g,``)}用例`))?.casesFolder??``}async function wt(e={}){let t=e.caseTypes?.length?e.caseTypes:[{label:`功能测试`,casesFolder:`功能测试`},{label:`接口测试`,casesFolder:`接口测试`},{label:`性能测试`,casesFolder:`性能测试`},{label:`自动化测试`,casesFolder:`自动化测试`}],n=[];try{if(await Re()){let e=await st();for(let t of e){let e=t.kind===`legacy`?`legacy`:`folder`,r=t.casesPath||(e===`folder`?t.path:``);n.push({id:`${e}:${t.name}:${t.mtime}`,kind:e,name:t.name,path:r||t.path,reviewName:e===`legacy`?t.name:void 0,mtime:t.mtime,size:t.size})}}}catch{}try{let e=await yt(`.`);for(let t of e){let e=typeof t.mtime==`number`?t.mtime:0;n.push({id:`sidecar:${t.path}`,kind:`sidecar`,name:t.name,path:t.path,mtime:e,size:t.size})}}catch{}n.sort((e,t)=>t.mtime-e.mtime);let r=n.map(e=>{let n=Ct(e,t);return{...e,caseTypeFolder:n,caseTypeLabel:t.find(e=>e.casesFolder===n)?.label??``}}),i=new Set((e.scopeFolders??[]).filter(Boolean));return i.size?r.filter(e=>e.caseTypeFolder?i.has(e.caseTypeFolder):i.has(`功能测试`)):r}function Tt({open:e,onClose:t,onChanged:n,scopeFolders:r=[],caseTypes:i=[]}){let[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[m,h]=(0,X.useState)({}),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null),[b,S]=(0,X.useState)(``),[E,D]=(0,X.useState)(1),[ne,O]=ee(gt,_t),k=de(`lh:case-backup:cols:v4`,vt),re=le(`case-backup`),A=(0,X.useCallback)(async()=>{c(!0),f(null);try{let e=await wt({scopeFolders:r,caseTypes:i});o(e),h(t=>{let n={};for(let r of e)t[r.id]&&(n[r.id]=!0);return n})}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[i,r]);(0,X.useEffect)(()=>{e&&(D(1),A())},[e,A]);let j=Math.max(1,Math.ceil(a.length/ne)),M=Math.min(E,j),ie=(0,X.useMemo)(()=>a.slice((M-1)*ne,M*ne),[a,M,ne]),N=(0,X.useMemo)(()=>Object.keys(m).filter(e=>m[e]),[m]),ae=ie.length>0&&ie.every(e=>m[e.id]);async function oe(e){u(!0),f(null);try{let t=e.filter(e=>e.kind===`folder`||e.kind===`sidecar`),r=e.filter(e=>e.kind===`legacy`);for(let e of t)await B(`cases`,e.path);r.length&&await Ge(r.map(e=>e.reviewName||e.name)),T(e.length===1?`已删除「${e[0].name}」`:`已删除 ${e.length} 个备份`,`success`),await A(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),T(`删除失败:${t}`,`error`)}finally{u(!1)}}async function se(){let e=g;if(_(null),!e)return;if(e.kind===`one`){await oe([e.row]);return}let t=new Map(a.map(e=>[e.id,e])),n=e.ids.map(e=>t.get(e)).filter(Boolean);n.length&&await oe(n)}async function me(e){if(e.kind!==`legacy`)try{await xe(`cases`,e.path)}catch(e){f(e instanceof Error?e.message:String(e))}}function I(e){e.kind!==`legacy`&&(S(``),y(e))}async function L(e){let t=v;if(!t||t.kind===`legacy`)return;let r=e.trim();if(!r||r===t.name){y(null),S(``);return}let i=Se(t.path),o=(i===`.`?r:`${i}/${r}`).toLowerCase(),s=a.find(e=>e.id!==t.id&&e.kind!==`legacy`&&e.path.toLowerCase()===o);if(s)S(`已存在同名文件「${s.name}」,换个名字再试`);else{u(!0),f(null),S(``);try{await Ce(`cases`,t.path,r),y(null),T(`已重命名为「${r}」`,`success`),await A(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);S(t),T(`重命名失败:${t}`,`error`)}finally{u(!1)}}}let R=g?.kind===`one`?`删除备份「${g.row.name}」?此操作不可恢复。`:g?.kind===`batch`?`确认删除已选中的 ${g.ids.length} 个备份?此操作不可恢复。`:``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(C,{open:e,onClose:t,title:`备份列表`,closeAriaLabel:`关闭备份列表`,widthClass:`max-w-5xl`,bodyClassName:`flex flex-col gap-3 overflow-hidden`,escDisabled:!!g||v!=null,footer:(0,Z.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,disabled:l||N.length===0,onClick:()=>_({kind:`batch`,ids:N}),className:`h-9 px-3 text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:[`删除所选`,N.length?`(${N.length})`:``]}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,disabled:l||s,onClick:()=>void A(),className:`h-9 px-3 text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40`,children:`刷新`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50`,children:`关闭`})]}),children:[(0,Z.jsxs)(`p`,{className:`shrink-0 text-xs text-stone-500 leading-5`,children:[`新备份保存在源用例所属类型的「`,ft,`/」目录,例如「用例管理/接口测试/`,ft,`/」。当前只展示`,r.length?`「${r.join(` / `)}」`:`全部类型`,`的备份;历史旁路与旧根备份仍兼容读取。备份不会自动过期,请手动删除。`]}),d?(0,Z.jsx)(`div`,{className:`shrink-0 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:d}):null,(0,Z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 text-xs text-stone-500`,children:[(0,Z.jsxs)(`span`,{children:[`共 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:a.length}),` 个`]}),s?(0,Z.jsx)(`span`,{children:`加载中…`}):null]}),a.length===0&&!s?(0,Z.jsx)(`div`,{className:`flex-1 min-h-0 rounded-xl border border-dashed border-stone-200 px-4 py-10 flex items-center justify-center text-sm text-stone-400`,children:`暂无备份文件`}):(0,Z.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-hidden rounded-xl border border-stone-200 flex flex-col`,children:[(0,Z.jsx)(`div`,{ref:re,className:`tw-scroll-x flex-1 min-h-0 overflow-auto`,children:(0,Z.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-left text-sm`,style:k.tableStyle,children:[(0,Z.jsx)(`colgroup`,{children:vt.map(e=>(0,Z.jsx)(`col`,{style:k.widthOf(e.key)?{width:k.widthOf(e.key)}:void 0},e.key))}),(0,Z.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:`${ce} relative`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:ae,disabled:l||ie.length===0,onChange:e=>{let t=e.target.checked;h(e=>{let n={...e};for(let e of ie)t?n[e.id]=!0:delete n[e.id];return n})},"aria-label":`全选本页备份`}),(0,Z.jsx)(F,{...k.resizeProps(`select`)})]}),(0,Z.jsxs)(`th`,{className:pe,style:{"--tw-sticky-left":`${ht}px`},children:[`文件名`,(0,Z.jsx)(F,{...k.resizeProps(`name`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`类型`,(0,Z.jsx)(F,{...k.resizeProps(`kind`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`备份时间`,(0,Z.jsx)(F,{...k.resizeProps(`mtime`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`大小`,(0,Z.jsx)(F,{...k.resizeProps(`size`)})]}),(0,Z.jsx)(`th`,{"aria-hidden":`true`}),(0,Z.jsx)(`th`,{className:P,children:`操作`})]})}),(0,Z.jsx)(`tbody`,{children:ie.map(e=>(0,Z.jsxs)(`tr`,{className:`group border-t border-stone-100 ${e.kind===`legacy`?``:`cursor-pointer`}`,onDoubleClick:()=>{e.kind===`legacy`||l||me(e)},children:[(0,Z.jsx)(`td`,{className:fe,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!m[e.id],disabled:l,onChange:t=>h(n=>({...n,[e.id]:t.target.checked})),"aria-label":`选择 ${e.name}`})}),(0,Z.jsx)(`td`,{className:`${fe} min-w-0 max-w-0`,style:{"--tw-sticky-left":`${ht}px`},children:(0,Z.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center`,children:[(0,Z.jsx)(x,{text:e.name,className:`min-w-0 truncate font-medium text-stone-800`}),e.kind===`legacy`?null:(0,Z.jsx)(`span`,{className:`ml-0.5 mr-1 flex shrink-0 items-center opacity-0 transition-opacity focus-within:opacity-100 group-hover:opacity-100`,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`button`,{type:`button`,disabled:l,"aria-label":`重命名 ${e.name}`,onClick:()=>I(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,Z.jsx)(w,{name:`pencil`,size:12})})})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:bt(e)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:xt(e.mtime)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap tabular-nums`,children:St(e.size)}),(0,Z.jsx)(`td`,{"aria-hidden":`true`}),(0,Z.jsx)(`td`,{className:ue,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center gap-1.5 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>_({kind:`one`,row:e}),className:`h-7 px-2 text-xs font-medium text-red-600 rounded-md hover:bg-red-50 disabled:opacity-40`,children:`删除`})})})]},e.id))})]})}),a.length>0?(0,Z.jsx)(te,{page:M,totalPages:j,pageSize:ne,busy:l||s,className:`shrink-0 !px-4 !py-2`,onPage:D,onPageSize:e=>{O(e),D(1)}}):null]})]}),(0,Z.jsx)(p,{open:!!g,title:g?.kind===`batch`?`批量删除备份`:`删除备份`,message:R,confirmLabel:`删除`,danger:!0,onClose:()=>_(null),onConfirm:()=>void se()}),(0,Z.jsx)(lt,{open:v!=null,title:`重命名备份`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:v?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:b,onClose:()=>{l||(y(null),S(``))},onConfirm:e=>void L(e)})]})}async function Et(e){let t=[...V(e.outline??[]).entries()].sort((e,t)=>e[1]-t[1]).map(([e])=>e),n=new Map((e.stories??[]).map(e=>[e.id.toUpperCase(),e.sourceRefs??[]])),r=[];if(e.sourcePath)try{let t=await Dt(e.sourcePath);r=Me(t)}catch{r=[]}return{outlineOrder:t,testPointIds:e.testPoints?.points?.map(e=>e.id)??void 0,idealOrder:r,storySourceRefs:n}}async function Dt(t){let n=t.toLowerCase();if(n.endsWith(`.xlsx`)||n.endsWith(`.xls`)){let e=await De(`requirements`,t);if(e.encoding!==`base64`||!e.contentBase64)throw Error(`无法读取 Excel`);let n=await c(()=>import(`./case-fields.C03NY3zC.js`).then(e=>e.d),__vite__mapDeps([0,1,2])),r=n.read(e.contentBase64,{type:`base64`,cellDates:!0}),i=[];for(let e of r.SheetNames){let t=r.Sheets[e];if(!t)continue;let a=n.utils.sheet_to_csv(t,{blankrows:!1}).trim();a&&i.push(`## 工作表:${e}\n${a}`)}return i.join(`
|
|
3
|
+
|
|
4
|
+
`).trim()}if(n.endsWith(`.docx`)){let n=await De(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e+=1)i[e]=r.charCodeAt(e);return((await(await c(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([3,1,4]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}return(await Te(`requirements`,t)).content}async function Ot(){try{return await je()}catch{return[]}}function kt(e,t){let n=_e(t).no;return n?e.map((e,t)=>({...e,[n]:String(t+1)})):e}async function At(e,t={}){let n=await Ae(e),r=R(n.rows,n.headers,{outlineOrder:t.outlineOrder,testPointIds:t.testPointIds,idealOrder:t.idealOrder,storySourceRefs:t.storySourceRefs}),i=r.filter((e,t)=>e!==n.rows[t]).length,a=kt(r,n.headers),o=_e(n.headers),s=o.no,c=o.title,l=o.reqCite,u=a.slice(0,5).map(e=>({no:s?String(e[s]??``):``,title:c?String(e[c]??``):``,cite:l?String(e[l]??``):``}));return{casePath:e,headers:n.headers,rows:a,moved:i,total:a.length,preview:u}}async function jt(e){let t=await Xe(e.casePath);return{backup:(await $e(e.casePath,e.headers,e.rows)).backup||t.backup}}var Mt=`__none__`;function Nt({open:e,casePath:t,fileName:o,onClose:s,onDone:c,onError:l}){let[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(Mt),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!e)return;let t=!0;return p(Mt),h(null),x(``),y(!1),(async()=>{try{let e=await Ot();if(!t)return;d(e)}catch{t&&d([])}})(),()=>{t=!1}},[e]);let C=(0,X.useCallback)(async()=>{if(f===Mt)return{};let e=u.find(e=>e.id===f);if(!e)return{};try{return await Et(e)}catch{return{outlineOrder:void 0,testPointIds:e.testPoints?.points?.map(e=>e.id)}}},[f,u]);(0,X.useEffect)(()=>{if(!e||!t)return;let n=!0;return _(!0),x(``),(async()=>{try{let e=await At(t,await C());n&&h(e)}catch(e){if(!n)return;h(null),x(e instanceof Error?e.message:String(e))}finally{n&&_(!1)}})(),()=>{n=!1}},[e,t,C]);let w=(0,X.useMemo)(()=>[{value:Mt,label:`仅按引用编号(RO / TP)`,muted:!0},...u.map(e=>({value:e.id,label:e.title||e.sourceTitle||e.id,secondary:e.sourcePath}))],[u]);async function T(){if(m&&!v){if(m.moved===0)c(`用例顺序已是最终顺序,文件未改动`),s();else{y(!0),x(``);try{await jt(m),c(`已重排 ${m.total} 条用例(移动 ${m.moved} 行),原文件已备份到「备份列表」`),s()}catch(e){let t=e instanceof Error?e.message:String(e);x(t),l(`重排失败:${t}`)}finally{y(!1)}}}}return(0,Z.jsxs)(i,{open:e,onClose:()=>v?void 0:s(),className:`relative z-110`,children:[(0,Z.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Z.jsxs)(n,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim flex w-full max-w-lg flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Z.jsx)(r,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:`按需求重排用例`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 break-all`,children:o}),(0,Z.jsxs)(`div`,{className:`mt-4`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`需求来源`}),(0,Z.jsx)(S,{options:w,value:f,onChange:p,ariaLabel:`重排依据的需求分析记录`,className:`mt-1.5`,disabled:v}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-stone-400`,children:`排序口径:需求条目(RO)→ 条目内测试点(TP)→ 原文件顺序;用例编号会按新顺序重编为 1…N。`})]}),(0,Z.jsx)(`div`,{className:`mt-4 rounded-lg border border-stone-200 bg-stone-50/60 p-3`,children:g?(0,Z.jsx)(`p`,{className:`text-xs text-stone-500`,children:`正在计算排序结果…`}):m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-xs text-stone-600`,children:[`共 `,m.total,` 条用例,需要移动`,` `,(0,Z.jsx)(`span`,{className:`font-semibold tabular-nums`,children:m.moved}),` 行`,m.moved===0?`(已是最终顺序)`:``]}),m.preview.length?(0,Z.jsxs)(`table`,{className:`mt-2 w-full table-fixed border-collapse text-[11px]`,children:[(0,Z.jsx)(`thead`,{children:(0,Z.jsxs)(`tr`,{className:`text-stone-400`,children:[(0,Z.jsx)(`th`,{className:`w-10 pb-1 text-left font-normal`,children:`编号`}),(0,Z.jsx)(`th`,{className:`pb-1 text-left font-normal`,children:`用例标题`}),(0,Z.jsx)(`th`,{className:`w-40 pb-1 text-left font-normal`,children:`引用需求点`})]})}),(0,Z.jsx)(`tbody`,{children:m.preview.map((e,t)=>(0,Z.jsxs)(`tr`,{className:`align-top text-stone-600`,children:[(0,Z.jsx)(`td`,{className:`py-0.5 pr-2 tabular-nums`,children:e.no}),(0,Z.jsx)(`td`,{className:`truncate py-0.5 pr-2`,children:e.title}),(0,Z.jsx)(`td`,{className:`truncate py-0.5 text-stone-500`,children:e.cite})]},`${e.no}-${t}`))})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-stone-500`,children:`暂无可预览的行`})}),b?(0,Z.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-red-600`,children:b}):null,(0,Z.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:v,onClick:s,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:`取消`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v||g||!m,onClick:()=>void T(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:v?`重排中…`:`开始重排`})]})]})})]})}var Pt=[`all`,...rt,`ignored`],Ft={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`},It={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 Lt(e){return e>=85?`green`:e>=60?`amber`:`red`}function Rt(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 zt({review:e,running:t,modelReady:n,onRun:r,onStop:i,onFix:a,onFixBatch:o,onIgnore:s,onUnignore:c,autoFixedKeys:l,onExport:u}){let[d,f]=(0,X.useState)(()=>_(`caseReview.quality.filter`,[...Pt],`all`)),[p,m]=(0,X.useState)(()=>y(`caseReview.quality.search`)),[h,g]=(0,X.useState)({}),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(()=>_(`caseReview.quality.worstFirst`,[`1`,`0`],`0`)===`1`),T=e=>{f(e),v(`caseReview.quality.filter`,e)},ee=e=>{m(e),b(`caseReview.quality.search`,e)},te=e=>{w(e),v(`caseReview.quality.worstFirst`,e?`1`:`0`)},E=(0,X.useMemo)(()=>{let t=e?.cases??[];return l?.size?t.map(e=>{let t=W(e);return t&&l.has(t)?{...e,fixed:!0}:e}):t},[e,l]),D=(0,X.useMemo)(()=>E.filter(e=>e.ignored).length,[E]),ne=(0,X.useMemo)(()=>{let e={usable:0,revise:0,invalid:0};for(let t of E)t.ignored||(e[t.verdict]+=1);return e},[E]),O=(0,X.useMemo)(()=>{let e=p.trim().toLowerCase(),t=E.filter(t=>{if(d===`ignored`){if(!t.ignored)return!1}else if(t.ignored||d!==`all`&&t.verdict!==d)return!1;return!e||`${t.no} ${t.title}`.toLowerCase().includes(e)});return C?[...t].sort((e,t)=>e.score-t.score):t},[E,d,p,C]),k=d===`revise`||d===`invalid`,[re,A]=(0,X.useState)(()=>new Set);(0,X.useEffect)(()=>{A(new Set)},[d]);let j=(0,X.useMemo)(()=>O.filter(e=>!e.ignored&&e.verdict!==`usable`&&!e.fixed),[O]),M=(0,X.useMemo)(()=>j.filter(e=>{let t=W(e);return!!(t&&re.has(t))}),[j,re]),ie=j.length>0&&j.every(e=>{let t=W(e);return!!(t&&re.has(t))}),N=M.length?M:j,ae=!k||j.length===0,oe=e=>{e&&A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t?(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 px-3 rounded-lg text-xs font-medium border border-rose-300 bg-rose-50 text-rose-700 hover:bg-rose-100`,children:`停止评审`}):(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`h-8 px-3 rounded-lg text-xs font-medium bg-stone-900 text-white hover:bg-stone-800`,children:e?`重新评审`:`开始评审`}),(0,Z.jsx)(`button`,{type:`button`,onClick:u,disabled:!e||t,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,Z.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:n?`规则 + 模型:语义问题与扣分原因由模型补`:`未配置模型:只跑规则判定`}),e?(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 text-[11px] text-stone-400`,children:[e.modelCovered!=null&&e.modelCovered<E.length?(0,Z.jsxs)(`span`,{className:`text-amber-700`,children:[`模型只评到 `,e.modelCovered,`/`,E.length,` 条,其余按规则分`]}):null,(0,Z.jsxs)(`span`,{children:[`上次评审:`,Rt(e.at)]})]}):null]}),e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-stone-50/60 px-3 py-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>S(e=>!e),className:`flex w-full items-center gap-2 text-left`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`看到结论后怎么处理`}),(0,Z.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:x?`收起`:`展开`})]}),x?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`ul`,{className:`mt-1.5 space-y-1 text-[11px] leading-relaxed text-stone-600`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border px-1 ${J.invalid.badge}`,children:`错误无效`}),`点这条右侧的「修改」,会带着编号、扣分原因与建议跳到工作台(用例绑定的会话,没有就新建), 让模型按建议改;跳转本身不标「已修改」。改完文件后回来,若正文相对上次评审有变,会自动标「已修改」。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border px-1 ${J.revise.badge}`,children:`待修改`}),`不影响执行,按建议补齐边界 / 异常 / 前置条件即可;改完回来自动识别,或批量改完再整体重评一次。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`忽略`}),`这条不再参与后续评审与「待修改」统计;点「忽略」后可在「忽略」筛选里「取消忽略」。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`批量修改`}),`切到「错误无效 / 待修改」,可勾选后点「批量修改」;未勾选时对本筛选下全部可改条生效。跳转不标已修改。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border px-1 ${J.usable.badge}`,children:`可用`}),`可直接执行或入库;这里只读,不会自动改你的用例文件。`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`mr-1 rounded border border-stone-200 px-1 text-stone-600`,children:`重新评审`}),`首次(无「已修改」)评全部未忽略条;有「已修改」时只重审这些条并按分数重判(未达可用仍为待修改 / 无效,不会因标过「已修改」就自动变可用),未改的保留上次判定;忽略的永远不送评。`]})]}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-[10px] text-stone-400`,children:`改文件后报告会标「可能已过期」,重新评审即刷新;每次结果都存在「用例评审」目录里。`})]}):null]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:`总分`}),(0,Z.jsx)(`div`,{className:`text-xl font-semibold ${Ft[Lt(e.score)]}`,children:e.score}),(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:e.modeled?`规则 + 模型`:`仅规则`})]}),rt.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:J[e].label}),(0,Z.jsx)(`div`,{className:`text-xl font-semibold ${Ft[J[e].tone]}`,children:ne[e]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:J[e].hint})]},e))]}),(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`五维得分(整批平均)`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-stone-400`,children:`每维 0–100 分;左侧百分比是权重,右侧数字才是这一维的得分`})]}),(0,Z.jsxs)(`div`,{className:`mt-2 mb-1 flex items-center gap-2 text-[10px] text-stone-400`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0`,children:`维度`}),(0,Z.jsx)(`span`,{className:`w-9 shrink-0 text-right`,children:`权重`}),(0,Z.jsx)(`span`,{className:`flex-1`}),(0,Z.jsx)(`span`,{className:`w-8 shrink-0 text-right`,children:`得分`})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:e.dimensions.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0 text-[11px] text-stone-600`,children:e.label}),(0,Z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-[11px] tabular-nums text-stone-400`,children:[e.weight,`%`]}),(0,Z.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,Z.jsx)(`div`,{className:`h-full ${It[nt[e.key]?.tone??`gray`]}`,style:{width:`${e.score}%`}})}),(0,Z.jsx)(`span`,{className:`w-8 shrink-0 text-right text-[11px] tabular-nums text-stone-700`,children:e.score})]},e.key))}),(0,Z.jsxs)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-stone-400`,children:[`总分 `,e.score,` = 各维度得分 × 权重求和(不是右侧某个数字); ≥`,` `,Je.usable,` 可用 · `,Je.revise,`–`,Je.usable-1,` 待修改 · < `,Je.revise,` 错误无效。`]})]}),(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,Z.jsxs)(`h3`,{className:`mb-2 text-xs font-semibold text-stone-700`,children:[`量化指标`,(0,Z.jsx)(`span`,{className:`ml-1 font-normal text-stone-400`,children:`七项 + 硬伤条数`})]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:e.metrics.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-500`,children:e.label}),(0,Z.jsx)(`div`,{className:`text-base font-semibold text-stone-800 tabular-nums`,children:e.text}),(0,Z.jsx)(`div`,{className:`text-[10px] leading-tight text-stone-400`,children:e.hint})]},e.key))})]}),e.summary?(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-3`,children:[(0,Z.jsx)(`h3`,{className:`mb-1 text-xs font-semibold text-stone-700`,children:`整体结论`}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-stone-600 whitespace-pre-wrap`,children:e.summary})]}):null,(0,Z.jsx)(`div`,{className:`sticky -top-4 z-10 -mx-4 bg-white px-4 pt-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-xl border border-stone-200 bg-white px-3 py-2 shadow-sm`,children:[k?(0,Z.jsxs)(`label`,{className:`flex h-6 shrink-0 items-center gap-1.5 text-[11px] text-stone-600`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:ie,disabled:!j.length,onChange:()=>{if(ie){A(new Set);return}let e=new Set;for(let t of j){let n=W(t);n&&e.add(n)}A(e)},className:`rounded border-stone-300`}),`全选`]}):null,(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:`逐条明细`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(Bt,{active:d===`all`,onClick:()=>T(`all`),children:[`全部 `,E.length-D]}),rt.map(e=>(0,Z.jsxs)(Bt,{active:d===e,onClick:()=>T(e),children:[J[e].label,` `,ne[e]]},e)),(0,Z.jsxs)(Bt,{active:d===`ignored`,onClick:()=>T(`ignored`),children:[`忽略`,D?` ${D}`:``]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>te(!C),className:`ml-auto h-6 shrink-0 rounded-md px-2 text-[11px] transition-colors ${C?`bg-stone-900 text-white`:`text-stone-500 hover:bg-stone-100`}`,children:`按分数升序`}),(0,Z.jsx)(`input`,{value:p,onChange:e=>ee(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,Z.jsxs)(`button`,{type:`button`,disabled:ae,onClick:()=>o(N),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:cursor-not-allowed disabled:opacity-40`,children:[`批量修改`,k&&M.length?` ${M.length}`:k&&j.length?` ${j.length}`:``]})]})}),(0,Z.jsx)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:(0,Z.jsxs)(`ul`,{className:`divide-y divide-stone-100`,children:[O.map((e,t)=>{let n=W(e),r=`${e.no}-${t}`,i=!e.ignored&&e.verdict!==`usable`&&!e.fixed;return(0,Z.jsx)(Vt,{item:e,open:h[r]===!0,onToggle:()=>g(e=>({...e,[r]:!e[r]})),onFix:()=>a(e),onIgnore:()=>s(e),onUnignore:()=>c(e),selectable:k&&i,checked:!!(n&&re.has(n)),onToggleSelect:n?()=>oe(n):void 0},r)}),O.length?null:(0,Z.jsx)(`li`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:`没有符合条件的用例`})]})})]}):(0,Z.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-stone-600`,children:`还没有评审结果`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`评审按五维打分(需求覆盖 / 步骤可执行 / 预期可判定 / 数据与边界 / 规范完整), 算七项量化指标,并把每条判成「可用 / 待修改 / 错误无效」;只读不改用例。`})]})]})}function Bt({active:e,onClick:t,children:n}){return(0,Z.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 Vt({item:e,open:t,onToggle:n,onFix:r,onIgnore:i,onUnignore:a,selectable:o,checked:s,onToggleSelect:c}){let l=J[e.verdict],u=!e.ignored&&e.verdict!==`usable`&&!e.fixed,d=Ye(e);return(0,Z.jsxs)(`li`,{className:`group px-3 py-2 ${e.fixed||e.ignored?`opacity-70`:``}`,children:[(0,Z.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:[o?(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!s,onChange:()=>c?.(),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),className:`shrink-0 rounded border-stone-300`}):null,(0,Z.jsx)(`span`,{className:`inline-flex w-14 shrink-0 items-center justify-center rounded border px-1 py-0.5 text-[10px] leading-4 ${e.ignored?`border-stone-200 bg-stone-50 text-stone-500`:e.fixed?`border-emerald-200 bg-emerald-50 text-emerald-700`:l.badge}`,children:e.ignored?`已忽略`:e.fixed?`已修改`:l.label}),(0,Z.jsx)(`span`,{className:`w-16 shrink-0 truncate text-left text-[11px] tabular-nums leading-4 text-stone-500`,children:e.no||`—`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-left text-xs leading-4 text-stone-800`,children:e.title||`(无标题)`}),e.ignored?(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},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:`取消忽略`}):u?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.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:`修改`}),(0,Z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},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,Z.jsx)(`span`,{className:`w-7 shrink-0 text-right text-[11px] tabular-nums leading-4 text-stone-500`,children:e.score}),(0,Z.jsx)(`span`,{className:`flex h-5 w-8 shrink-0 items-center justify-center text-[10px] text-stone-400`,children:t?`收起`:`详情`})]}),t?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2 pl-1`,children:[e.hard?(0,Z.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,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.keys(nt).map(t=>(0,Z.jsxs)(`span`,{className:`rounded-md border border-stone-100 bg-stone-50 px-2 py-0.5 text-[10px] text-stone-600`,children:[nt[t].label,` `,e.dimensions[t]]},t))}),e.deductions.length?(0,Z.jsx)(`ul`,{className:`space-y-1.5`,children:e.deductions.map((e,t)=>(0,Z.jsxs)(`li`,{className:`rounded-md bg-stone-50 px-2 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`text-[11px] text-stone-700`,children:[(0,Z.jsxs)(`span`,{className:`mr-1 font-medium text-stone-500`,children:[`[`,nt[e.dimension]?.label??e.dimension,e.points?` −${e.points}`:``,`]`]}),e.reason]}),e.suggestion?(0,Z.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-emerald-700`,children:[`建议:`,e.suggestion]}):null]},t))}):d.length?(0,Z.jsx)(`ul`,{className:`space-y-1.5`,children:d.map((e,t)=>(0,Z.jsx)(`li`,{className:`rounded-md bg-stone-50 px-2 py-1.5 text-[11px] text-stone-500`,children:e},t))}):(0,Z.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`没有扣分项。`})]}):null]})}var Ht={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 Ut({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=e?.items??[],m=(0,X.useMemo)(()=>p.filter(e=>!e.added),[p]),h=p.length-m.length,g=(0,X.useMemo)(()=>Be(p),[p]),[_,v]=(0,X.useState)(new Set),y=(0,X.useMemo)(()=>m.map(e=>e.id),[m]),b=(0,X.useMemo)(()=>y.filter(e=>a.has(e)).length,[y,a]),x=y.length>0&&y.every(e=>a.has(e)),S=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.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,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.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,Z.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,Z.jsx)(`button`,{type:`button`,onClick:u,disabled:!b||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?`补全中…`:`补全选中 ${b||``}`}),(0,Z.jsx)(`button`,{type:`button`,onClick:d,disabled:!b||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:`去工作台写回 ${b||``}`}),(0,Z.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,Z.jsx)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:m.length?`已选 ${b} / 共 ${m.length}${h?` · 已修改 ${h}`:``}`:h?`已修改 ${h}`:``}),(0,Z.jsx)(`button`,{type:`button`,disabled:!y.length,onClick:()=>s(y,!x),className:`h-6 shrink-0 rounded-md px-2 text-[11px] text-stone-500 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:x?`清空`:`全选`})]}),i?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-[11px] text-amber-800`,children:`场景探测要靠模型推理,先在设置里配好模型。`}),t?(0,Z.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`读取中…`}):!e||!e.items.length&&!n?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-dashed border-stone-200 px-6 py-12 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-stone-600`,children:`还没有探测结果`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`会从非功能、安全边界、兼容性与隐藏业务规则四个方向找现有用例的缺口。`})]}):(0,Z.jsxs)(Z.Fragment,{children:[e.summary?(0,Z.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,g.map(e=>{let t=it[e.key],n=e.items.filter(e=>!e.added).map(e=>e.id),r=n.length>0&&n.every(e=>a.has(e)),i=_.has(e.key),c=n.filter(e=>a.has(e)).length,l=e.items.filter(e=>e.added).length;return(0,Z.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,Z.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>S(e.key),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,Z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${Ht[t.tone]}`,children:t.mark}),(0,Z.jsx)(`h3`,{className:`text-xs font-semibold text-stone-700`,children:t.label}),(0,Z.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[e.items.length,` 条`,c?` · 已选 ${c}`:``,l?` · 已修改 ${l}`:``]}),(0,Z.jsx)(`span`,{className:`ml-auto text-[10px] text-stone-400`,children:i?`展开`:`收起`})]}),n.length?(0,Z.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,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`px-3 pt-2 text-[11px] text-stone-400`,children:t.hint}),(0,Z.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.items.map(e=>(0,Z.jsx)(Wt,{item:e,checked:a.has(e.id),onToggle:()=>o(e.id)},e.id))})]})]},e.key)})]}),b?(0,Z.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:[`已选 `,b,` 条:可以先「补全选中」把字段写全,也可以直接「去工作台写回」—— 会按归属需求插到对应分组下面(不是整份追加到末尾),写前自动备份。`]}):null]})}function Wt({item:e,checked:t,onToggle:n}){let[r,i]=(0,X.useState)(!1),a=Ke[e.severity],o=e.added;return(0,Z.jsxs)(`li`,{className:`px-3 py-2 ${o?`opacity-70`:``}`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t&&!o,disabled:o,onChange:n,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-stone-900 disabled:opacity-40`,"aria-label":`选择 ${e.title}`}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex-1 min-w-0 text-left`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 rounded border px-1 py-0.5 text-[10px] ${Ht[a.tone]}`,children:a.label}),o?(0,Z.jsx)(`span`,{className:`shrink-0 rounded border border-emerald-200 bg-emerald-50 px-1 py-0.5 text-[10px] text-emerald-700`,children:`已修改`}):null,(0,Z.jsx)(`span`,{className:`flex-1 min-w-0 text-xs text-stone-800`,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:e.priority})]}),e.reqAnchor?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`归属:`,e.reqAnchor]}):null,e.why?(0,Z.jsxs)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-500`,children:[`容易漏:`,e.why]}):null]})]}),r?(0,Z.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,Z.jsx)(Gt,{label:`归属需求`,value:e.reqAnchor}),(0,Z.jsx)(Gt,{label:`前置条件`,value:e.precondition}),(0,Z.jsx)(Gt,{label:`步骤`,value:e.steps.map((e,t)=>`${t+1}. ${e}`).join(` `)}),(0,Z.jsx)(Gt,{label:`预期`,value:e.expected})]}):null]})}function Gt({label:e,value:t}){return t?(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`dt`,{className:`w-14 shrink-0 text-stone-400`,children:e}),(0,Z.jsx)(`dd`,{className:`flex-1 whitespace-pre-wrap`,children:t})]}):null}var Kt=[`module`,`type`,`priority`],qt=[{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}],Jt=new Set([`no`,`title`,`filler`]),Yt=[{key:`steps`,label:`测试步骤`},{key:`expected`,label:`预期结果`},{key:`verdict`,label:`规则判定`},{key:`suggestions`,label:`修改建议`}],Xt=`case-review.fields`,Zt=`lh:case-review:cols:v1`;function Qt(e){return e.replace(/\.[A-Za-z0-9]+$/,``).trim().toLowerCase()}function $t({file:e,audit:t,review:n,fileName:r,autoFixedKeys:i}){let a=(0,X.useMemo)(()=>e?.rows??[],[e]),[o,s]=(0,X.useState)(()=>_(`caseReview.table.filter`,[`all`,...rt],`all`)),[c,l]=(0,X.useState)(()=>y(`caseReview.table.search`)),u=e=>{s(e),v(`caseReview.table.filter`,e)},d=e=>{l(e),b(`caseReview.table.search`,e)},f=D(Xt,Yt,Jt),p=(0,X.useMemo)(()=>E(qt,f.isVisible),[f.isVisible]),m=de(Zt,p),h=le(`case-review`),g=(0,X.useMemo)(()=>_e(e?.headers??[]),[e]),S=(0,X.useMemo)(()=>{let e=new Map,r=new Map;for(let t of n?.cases??[]){let n=W(t),a=n&&i?.has(n)&&!t.fixed?{...t,fixed:!0}:t;a.no&&e.set(a.no.trim(),a),a.title&&r.set(a.title.trim(),a)}return a.map((n,i)=>{let a=String(n[g.no??ve.no]??``).trim(),o=String(n[g.title??ve.title]??``).trim();return(a?e.get(a):void 0)??(o?r.get(o):void 0)??t?.cases[i]??null})},[a,g,n,t,i]),C=(0,X.useMemo)(()=>{let e={usable:0,revise:0,invalid:0};for(let t of S)t&&(e[t.verdict]+=1);return e},[S]),w=(0,X.useMemo)(()=>a.map((e,t)=>{let n=S[t],i=t=>String(e[g[t]??ve[t]]??``),a=r?Qt(r):``,o=Kt.map(i).map(e=>e.trim()).filter(e=>!!e&&(!a||Qt(e)!==a)).join(` · `);return{key:t,no:i(`no`),title:i(`title`),meta:o,steps:i(`steps`),expected:i(`expected`),verdict:n,suggestions:n?Ye(n):[]}}),[a,g,S,r]),T=(0,X.useMemo)(()=>{let e=c.trim().toLowerCase();return w.filter(t=>o!==`all`&&t.verdict?.verdict!==o?!1:!e||`${t.no} ${t.title}`.toLowerCase().includes(e))},[w,o,c]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,style:{height:`calc(100vh - 9rem)`},children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e?`${a.length} 条 · ${e.ext}`:`未读到用例文件`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(en,{active:o===`all`,onClick:()=>u(`all`),children:[`全部 `,w.length]}),rt.map(e=>(0,Z.jsxs)(en,{active:o===e,onClick:()=>u(e),children:[J[e].label,` `,C[e]]},e))]}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{value:c,onChange:e=>d(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,Z.jsx)(ne,{fields:f.fields,isVisible:f.isVisible,onToggle:f.toggle})]})]}),(0,Z.jsxs)(`p`,{className:`shrink-0 text-[11px] text-stone-400`,children:[n?`只读对照:判定与「质量评审」一致;要改用例回对应类型用例菜单,或在质量评审里点「修改」跳工作台。`:`只读对照:还没评审,先用规则体检结果;要改用例回对应类型用例菜单。`,(0,Z.jsx)(`span`,{className:`ml-1 text-stone-300`,children:`拖动表头右边缘可调列宽,双击恢复默认。`})]}),a.length?(0,Z.jsx)(`div`,{ref:h,className:`tw-scroll-x min-h-0 flex-1 overflow-auto rounded-xl border border-stone-200 bg-white`,children:(0,Z.jsxs)(`table`,{className:`tw-sticky-table table-fixed text-left text-xs`,style:m.tableStyle,children:[(0,Z.jsx)(`colgroup`,{children:p.map(e=>(0,Z.jsx)(`col`,{style:m.widthOf(e.key)?{width:m.widthOf(e.key)}:void 0},e.key))}),(0,Z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-[11px] text-stone-500`,children:(0,Z.jsxs)(`tr`,{children:[(0,Z.jsxs)(`th`,{className:pe,children:[`用例编号`,(0,Z.jsx)(F,{...m.resizeProps(`no`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`用例标题`,(0,Z.jsx)(F,{...m.resizeProps(`title`)})]}),f.isVisible(`steps`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`测试步骤`,(0,Z.jsx)(F,{...m.resizeProps(`steps`)})]}):null,f.isVisible(`expected`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`预期结果`,(0,Z.jsx)(F,{...m.resizeProps(`expected`)})]}):null,f.isVisible(`verdict`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium whitespace-nowrap`,children:[`规则判定`,(0,Z.jsx)(F,{...m.resizeProps(`verdict`)})]}):null,f.isVisible(`suggestions`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`修改建议`,(0,Z.jsx)(F,{...m.resizeProps(`suggestions`)})]}):null,(0,Z.jsx)(`th`,{"aria-hidden":`true`})]})}),(0,Z.jsxs)(`tbody`,{children:[T.map(e=>{let t=e.verdict;return(0,Z.jsxs)(`tr`,{className:`align-top`,children:[(0,Z.jsx)(`td`,{className:`${fe} tabular-nums text-stone-600`,children:(0,Z.jsx)(x,{text:e.no||`—`,className:`block truncate`})}),(0,Z.jsxs)(`td`,{className:`px-2.5 py-1.5`,children:[(0,Z.jsx)(x,{text:e.title||`(无标题)`,className:`block truncate text-stone-800`}),e.meta?(0,Z.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-stone-400`,children:e.meta}):null]}),f.isVisible(`steps`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5 text-stone-700`,children:(0,Z.jsx)(x,{text:e.steps,clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words`})}):null,f.isVisible(`expected`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5 text-stone-700`,children:(0,Z.jsx)(x,{text:e.expected,clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words`})}):null,f.isVisible(`verdict`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5`,children:t?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[t.fixed?(0,Z.jsxs)(`span`,{className:`rounded border border-emerald-200 bg-emerald-50 px-1.5 py-0.5 text-[10px] text-emerald-700`,children:[`已修改 `,t.score]}):(0,Z.jsxs)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${J[t.verdict].badge}`,children:[J[t.verdict].label,` `,t.score]}),t.hard&&!t.fixed?(0,Z.jsx)(`span`,{className:`rounded border border-rose-200 bg-white px-1 py-0.5 text-[10px] text-rose-600`,children:`硬伤`}):null]}):(0,Z.jsx)(`span`,{className:`text-[10px] text-stone-300`,children:`—`})}):null,f.isVisible(`suggestions`)?(0,Z.jsx)(`td`,{className:`px-2.5 py-1.5`,children:e.suggestions.length?(0,Z.jsx)(x,{text:e.suggestions.map((e,t)=>`${t+1}. ${e}`).join(`
|
|
5
|
+
`),clamp:`y`,className:`line-clamp-2 whitespace-pre-wrap break-words text-[11px] text-stone-600`}):(0,Z.jsx)(`span`,{className:`text-[10px] text-stone-300`,children:`—`})}):null,(0,Z.jsx)(`td`,{"aria-hidden":`true`})]},e.key)}),T.length?null:(0,Z.jsx)(`tr`,{children:(0,Z.jsx)(`td`,{colSpan:p.length,className:`px-3 py-10 text-center text-xs text-stone-400`,children:`没有符合条件的用例`})})]})]})}):(0,Z.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 en({active:e,onClick:t,children:n}){return(0,Z.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 tn=`可用工具(只调用这些,不要自己编工具名):
|
|
6
|
+
- case_save_review:提交逐条用例判定(verdict / 五个维度分 / 扣分原因与建议),一次提交整批。
|
|
7
|
+
- case_save_blindspots:提交探测到的场景盲区(四类之一 + 可执行字段),一次提交全部。
|
|
8
|
+
|
|
9
|
+
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,nn={coverage:`coverage`,steps:`steps`,expected:`expected`,data:`data`,convention:`convention`,需求覆盖:`coverage`,步骤可执行:`steps`,预期可判定:`expected`,数据与边界:`data`,规范完整:`convention`},rn={nonfunctional:`nonfunctional`,security:`security`,compatibility:`compatibility`,business:`business`,非功能:`nonfunctional`,安全:`security`,兼容:`compatibility`,业务:`business`};function an(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function Q(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function on(e,t=0){let n=Number(e);return Number.isFinite(n)?Math.min(100,Math.max(0,Math.round(n))):t}function sn(e){let t=Q(e,40);return nn[t]??nn[t.toLowerCase()]??`expected`}function cn(e){let t=Q(e,40);return rn[t]??rn[t.toLowerCase()]??`business`}function ln(e){let t=Q(e,10).toLowerCase();return t===`high`||t===`medium`||t===`low`?t:`medium`}function un(e){let t=Q(e,4).toUpperCase();return[`P0`,`P1`,`P2`,`P3`].includes(t)?t:`P1`}function dn(e){if(!e||typeof e!=`object`)return null;let t=Q(e.reason,1e3);if(!t)return null;let n=e;return{dimension:sn(n.dimension),points:on(n.points,0),reason:t,suggestion:Q(n.suggestion,1e3)}}function fn(e){if(!e||typeof e!=`object`)return null;let t=e,n=Q(t.no,80),r=Q(t.title,300);if(!n&&!r)return null;let i=t.dimensions&&typeof t.dimensions==`object`?t.dimensions:{},a={};for(let e of G)a[e]=on(i[e],0);let o=Q(t.verdict,20),s=Q(t.hard,500),c={no:n,title:r,verdict:o===`usable`||o===`invalid`?o:`revise`,score:on(t.score,0),dimensions:a,deductions:Array.isArray(t.deductions)?t.deductions.map(dn).filter(e=>!!e).slice(0,20):[]};return s&&(c.hard=s),c}function pn(e){if(!e||typeof e!=`object`)return null;let t=e,n=Q(t.title,300);if(!n)return null;let r=Q(t.id,40);return{id:/^bs_[A-Za-z0-9_-]{4,40}$/.test(r)?r:``,category:cn(t.category),severity:ln(t.severity),title:n,why:Q(t.why,1e3),precondition:Q(t.precondition,1e3),steps:Array.isArray(t.steps)?t.steps.map(e=>Q(e,1e3)).filter(Boolean).slice(0,20):[],expected:Q(t.expected,1e3),priority:un(t.priority),reqAnchor:Q(t.reqAnchor??t.requirement??t.reqRef,200),added:!1,caseNo:``}}var mn=[{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(G.map(e=>[e,{type:`number`,description:e}])),required:[...G]},deductions:{type:`array`,items:{type:`object`,properties:{dimension:{type:`string`,enum:[...G]},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:[...et]},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`]},reqAnchor:{type:`string`,description:`归属需求:优先抄已有需求编号原文(前缀不限);没有编号时再补自定义编号(同组共用);写回时插到该组最后一行之后;对不上才留空`}},required:[`category`,`title`]}}},required:[`items`]}}}];async function hn(e,t,n){let r=an(t);if(e===`case_save_review`){let e=(Array.isArray(r.cases)?r.cases:[]).map(fn).filter(e=>!!e);return e.length?(n.onCases(e,Q(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(pn).filter(e=>!!e).slice(0,300);return e.length?(n.onBlindspots(e,Q(r.summary,2e3)),JSON.stringify({ok:!0,count:e.length,categories:et.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 gn(e){return!!ut(e).trim()||O(e).length>0}function _n(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function vn(e){return/\.(xlsx|xlsm|xls)$/i.test(e)}function yn(e,t,n){return vn(e)?[`${n}. ${t===`fix`?`这个文件是 xlsx(二进制):会话里的文件工具一般写不了它。请不要假装写成功,改成把改好的整行按「文件表头顺序」用 markdown 表格贴出来(第一列是原编号),我直接粘回文件。`:`这个文件是 xlsx(二进制):会话里的文件工具一般写不了它。请不要假装写成功,改成把新增的行按「文件表头顺序」用 markdown 表格贴出来(编号按文件规则续),并标明每条应插在哪个归属需求分组的哪一行之后,我按位置粘进文件,不要默认贴到末尾。`}`,`${n+1}. 如果确实有 bash / python 能直接改 xlsx,也可以直接改,但改完必须把改动行贴出来让我核对。`]:[`${n}. ${t===`fix`?`改动写回原文件(写之前先备份),写完告诉我改了哪些列、改成什么。`:`写回原文件前先备份,写完告诉我加了哪几条、编号是什么。`}`,`${n+1}. 如果当前会话没有可用的文件工具,把${t===`fix`?`改好的整条用例`:`新行`}按文件表头贴给我,我自己粘回去。`]}function bn(e,t){return e.sessions.find(e=>{if(!ae(e))return!1;let n=e.caseGen?.linkedCasePath;return!!(n&&_n(n)===t)})}function xn(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(`4. 我自己也会在「用例管理」里同时改,改动以文件当前内容为准,别按我给的建议覆盖我后来的手改;`),o.push(...yn(n,`fix`,5)),o.join(`
|
|
10
|
+
`)}var Sn=[`帮我改一下用例文件`,`帮我把下面`];function Cn(e){let t=e.trim();return t.length>240&&Sn.some(e=>t.startsWith(e))}async function wn(e,t,n){await re().catch(()=>null),await s().catch(()=>null);let r=_n(e),i=j(),a=bn(i,r);if(!a){let e=i.sessions.find(e=>e.id===i.activeId);if(e&&A(e)&&ae(e))a=e;else{let e=i.sessions.find(e=>ae(e)&&A(e)&&!gn(e.id));e?(a=e,i={...i,activeId:e.id}):(i=N(i,{access:u()}),a=i.sessions.find(e=>e.id===i.activeId))}}if(!a)throw Error(`无法创建或定位会话`);i=se(i,a.id,gn),i.activeId!==a.id&&(i={...i,activeId:a.id}),await M(i),a=i.sessions.find(e=>e.id===a.id)??a,Cn(ut(a.id))&&dt(a.id),k(a.id,{...n,at:Date.now()});try{let e=i.sessions.find(e=>e.id===a.id)??a;sessionStorage.setItem(ie(a.id),JSON.stringify({session:e}))}catch{}let o=t||r.split(`/`).pop()||r,c=new URLSearchParams({session:a.id,attachRoot:`cases`,attachPath:r,attachName:o});window.location.href=`/workbench/?${c.toString()}`}async function Tn(e){let t=e.name||e.path.split(`/`).pop()||e.path;await wn(e.path,e.name,{id:`case-fix:${_n(e.path)}:${e.verdict.no||e.verdict.title}`,label:`修改用例 ${e.verdict.no||e.verdict.title||t}`,detail:`${e.verdict.verdict===`invalid`?`错误无效`:`待修改`} · ${t}`,body:xn(e)})}function En(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. 我也在「用例管理」里同时手改,改之前先按文件当前内容确认一遍,不要用我早期的版本覆盖后来的手改;`),r.push(`5. 条数多时分包处理(每包 8 条以内),每包处理完先回报「编号 → 改了什么」,不要一口气静默改完;`),r.push(...yn(t,`fix`,6)),r.push(`8. 改完在回复里给我一张对照表(编号 / 改前问题 / 改后要点 / 已标待验证);对照表只写在对话里,不要另存成用例管理目录下的新文件。`),r.join(`
|
|
11
|
+
`)}async function Dn(e){let t=e.name||e.path.split(`/`).pop()||e.path,n=e.verdicts.length,r=e.verdicts.map(e=>e.no).filter(Boolean).slice(0,3).join(`、`);await wn(e.path,e.name,{id:`case-batch-fix:${_n(e.path)}:${e.verdicts.map(e=>e.no||e.title).join(`,`)}`,label:`批量修改用例`,detail:r?`${n} 条 · ${r}${n>3?` 等`:``} · ${t}`:`${n} 条 · ${t}`,body:En(e)})}function On(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=it[e.category];n.push(``),n.push(`### ${t+1}. [${r?.label??e.category}] ${e.title}`),n.push(`- 归属需求:${e.reqAnchor?.trim()||`(未标,按标题 / why / 对照需求与文件里已有分组推断)`}`),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. 先读一遍这个文件,看清表头,以及已有用例是怎么按需求分组的(常见分组列:需求编号 / 关联需求 / 所属模块 / 测试项目 / 模块;Ideal 一类常按「一行需求标题」聚在同一模块列)。`),n.push(`2. 每条新用例必须插到「归属需求」对应分组的最后一行之后,禁止整批发到文件末尾:`),n.push(` - 条目写了归属需求时,优先用它匹配(与文件「需求编号 / 关联需求」列原文一致即可,前缀不限;或模块 / 测试项目 / 标题列包含该文案);`),n.push(` - 没写归属时,根据标题、why、对照需求推断最贴近的一组,再插到该组末尾;`),n.push(` - 整份文件都对不上任何组时,才允许追加到文件末尾,并在回复里说明对不上的原因。`),n.push(`3. 分组列(需求编号 / 关联需求等)优先抄同组已有行的编号;同组也没有编号、且归属需求本身也没有编号时,再补一个自定义编号写入该列(同组多条共用同一个号,风格跟文件里已有编号一致;文件完全没有先例时用短递增号),并在回复里列出新编了哪些号。模块 / 测试项目等展示列仍跟同组邻行一致。`),n.push(`4. 再按文件表头填标题、前置、步骤、预期、优先级、类型、用例编号。用例编号沿用文件规则并避开已用编号。`),n.push(`5. 只插入这些新用例:原有行内容一个字都不要改,也不要重排无关行;步骤一步一个动作,预期写到可判定,不要留「待补」。`),n.push(`6. 我自己也会同时手改这个文件,插入前先按当前内容确认用例编号没有被占用;`),n.push(...yn(t,`add`,7)),n.join(`
|
|
12
|
+
`)}async function kn(e){let t=e.name||e.path.split(`/`).pop()||e.path;await wn(e.path,e.name,{id:`blindspot-writeback:${_n(e.path)}:${e.items.map(e=>e.id).join(`,`)}`,label:`补进 ${e.items.length} 条场景用例`,detail:t,body:On(e)})}var An=new Map,jn=new Set,Mn={current:null};function Nn(e){return{path:e,entry:null,file:null,stale:!1,docs:[],reqId:``,selected:[],reviewPrompt:null,blindspotPrompt:null,error:``,notice:``,reviewRunning:!1,detectRunning:!1,completing:!1,runLabel:``,runLog:[],received:0,runTarget:0,progress:``,runStartedAt:0}}function $(e,t){if(!e)return;let n=An.get(e)??Nn(e);An.set(e,{...n,...t,path:e});for(let e of jn)e()}function Pn(e){return jn.add(e),()=>{jn.delete(e)}}function Fn(e){return e.replace(/\.[^.]+$/,``).replace(/[\s_\-—·()()[\]【】]/g,``).toLowerCase()}function In(e,t){let n=t.split(`/`).pop()??t,r=Fn(n);if(!r)return``;let i=``,a=0;for(let t of e){let e=Fn(t.title),o=Fn(t.sourceTitle||``),s=L(n,t.title)||L(n,t.sourceTitle||``),c=e.length>=4&&(r.includes(e)||e.includes(r))||o.length>=4&&(r.includes(o)||o.includes(r));if(!s&&!c)continue;let l=Math.max(I(t.title).length,I(t.sourceTitle||``).length,e.length);l>a&&(i=t.id,a=l)}return i}function Ln({open:e,path:t,reviewOn:n,blindspotOn:r,onClose:i,onSaved:a}){let[o,c]=(0,X.useState)(()=>_(`caseReview.tab`,[`quality`,`table`,`blindspot`],`quality`)),u=(0,X.useCallback)(e=>{c(e),v(`caseReview.tab`,e)},[]),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),[g,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(null),[S,w]=(0,X.useState)(!1),[T,ee]=(0,X.useState)(null),[te,E]=(0,X.useState)(null),[D,ne]=(0,X.useState)(null),[O,k]=(0,X.useState)(null),[re,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[ie,N]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(``),[se,ce]=(0,X.useState)(``),[P,le]=(0,X.useState)(0),[ue,de]=(0,X.useState)([]),[fe,pe]=(0,X.useState)(0),[F,me]=(0,X.useState)(0),[I,L]=(0,X.useState)([]),[R,ve]=(0,X.useState)(``),[ye,be]=(0,X.useState)(new Set),xe=!!(O?.baseURL&&O.apiKey&&O.model),Se=(0,X.useCallback)(e=>{x(e.entry),ee(e.file),w(e.stale),L(e.docs),ve(e.reqId),be(new Set(e.selected)),E(e.reviewPrompt),ne(e.blindspotPrompt),h(e.error),y(e.notice),A(e.reviewRunning),M(e.detectRunning),N(e.completing),ce(e.runLabel),de(e.runLog),pe(e.received),me(e.runTarget),oe(e.progress),le(e.runStartedAt?Math.round((Date.now()-e.runStartedAt)/1e3):0),p(!1)},[]),Ce=(0,X.useCallback)((e,n,r=0)=>{let i=Date.now();ce(e),de([n]),pe(0),le(0),oe(``),me(r),$(t,{runLabel:e,runLog:[n],received:0,progress:``,runTarget:r,runStartedAt:i,error:``})},[t]),z=(0,X.useCallback)(e=>{de(n=>{let r=[...n.slice(-11),e];return $(t,{runLog:r}),r})},[t]),we=(0,X.useCallback)(()=>{ce(``),oe(``),le(0),me(0),$(t,{runLabel:``,progress:``,runTarget:0,runStartedAt:0,reviewRunning:!1,detectRunning:!1,completing:!1})},[t]),Te=(0,X.useCallback)(()=>{let e=Mn.current;e?e.signal.aborted||(e.abort(),z(`已请求停止,正在收尾…`)):z(`当前没有可中断的请求`)},[z]);(0,X.useEffect)(()=>{if(!se)return;let e=Date.now(),t=window.setInterval(()=>{le(Math.round((Date.now()-e)/1e3))},1e3);return()=>window.clearInterval(t)},[se]);let B=(0,X.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,X.useEffect)(()=>(s().then(()=>k(d())).catch(()=>k(d())),l(()=>k(d()))),[]);let Ee=(0,X.useCallback)(async()=>{if(t){p(!0),h(``),y(``);try{let[e,i]=await Promise.all([n?Re():Promise.resolve(!1),r?ct():Promise.resolve(!1)]);if(!e&&!i){let e="评审服务没起来:确认已用 `lantern dev` 启动(插件依赖本地中间件)。";h(e),$(t,{error:e})}let a=e||i,[o,s]=await Promise.all([Ae(t),a?Ue(t):Promise.resolve({entry:null,stale:!1})]),c=s.entry?.review?{...s.entry,review:He(s.entry.review,o.rows)}:s.entry;if(c?.review&&s.entry?.review&&a){let e=new Map(s.entry.review.cases.map(e=>[W(e),e.contentFp]));if(c.review.cases.some(t=>{let n=W(t);return!!(t.contentFp&&n&&!e.get(n))}))try{c=await Qe(t,{review:c.review})}catch{}}ee(o),x(c),w(s.stale);let l=null,u=null,d=[];if(e&&n&&(l=await ot(),E(l)),i&&r&&(u=await qe(),ne(u)),e||i)try{d=await je()}catch{d=[]}L(d);let f=In(d,t);ve(f),be(new Set),$(t,{file:o,entry:c,stale:s.stale,docs:d,reqId:f,selected:[],reviewPrompt:l,blindspotPrompt:u,error:!e&&!i?An.get(t)?.error??``:``,notice:``})}catch(e){let n=e instanceof Error?e.message:String(e);h(n),$(t,{error:n})}finally{p(!1)}}},[t,n,r]),De=(0,X.useCallback)(async()=>{if(t)try{let[e,n]=await Promise.all([Ae(t),Ue(t).catch(()=>({entry:null,stale:!1}))]);ee(e),w(n.stale),$(t,{file:e,stale:n.stale})}catch{}},[t]);(0,X.useEffect)(()=>{if(!e||!t)return;let i=_(`caseReview.tab`,[`quality`,`table`,`blindspot`],`quality`);u((i===`blindspot`?r:i!==`quality`||n)?i:n?`quality`:`blindspot`);let a=An.get(t);a?.file?(Se(a),De()):Ee()},[e,t,Ee,De,n,r,u,Se]),(0,X.useEffect)(()=>{if(e&&t)return Pn(()=>{let e=An.get(t);e&&Se(e)})},[e,t,Se]),(0,X.useEffect)(()=>{if(R&&I.some(e=>e.id===R))return;let e=In(I,t);e&&(ve(e),$(t,{reqId:e}))},[I,t,R]);let Oe=(0,X.useMemo)(()=>T?.headers.length?T.headers:[...he],[T]),ke=(0,X.useMemo)(()=>T?.headers.length?ge(_e(T.headers)):``,[T]),V=(0,X.useMemo)(()=>I.find(e=>e.id===R)?.title??``,[I,R]),Me=(0,X.useMemo)(()=>T?K(T.rows,B):null,[T,B]),H=b?.review??null,U=b?.blindspot??null,Pe=(0,X.useCallback)(async(e,n,r,i)=>{if(!O)throw Error(`还没读到模型设置`);let a=Mn.current??new AbortController;if(Mn.current=a,i?.aborted||a.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);let o=``;for await(let i of Ne(O,[{role:`system`,content:`${e}\n\n${tn}`},{role:`user`,content:n}],a.signal,{tools:mn,runTool:(e,n)=>hn(e,n,{onCases:(e,n)=>{r.cases.push(...e),n&&(r.summary=n);let i=r.cases.length+r.items.length;pe(i),$(t,{received:i}),z(`模型交回 ${e.length} 条判定(累计 ${i} 条)`)},onBlindspots:(e,n)=>{r.items.push(...e),n&&(r.summary=n);let i=r.cases.length+r.items.length;pe(i),$(t,{received:i}),z(`模型交回 ${e.length} 条盲区(累计 ${i} 条)`)}})}))i.type===`content`&&(o=`${o}${i.delta}`.slice(-400),oe(o),$(t,{progress:o}))},[O,z,t]),Fe=(0,X.useCallback)((e,t)=>{let n=t.length?t:he;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
|
+
`)},[]),Ie=(0,X.useCallback)(async()=>{if(!T)return;let e=K(T.rows,B);if(!T.rows.length){h(`这个文件里没解析到用例行:确认第一行是表头,且有编号与标题列(「测试项目 / 用例名称」这类叫法也认)。`);return}let n=b?.review?He(b.review,T.rows).cases:[],r=new Map(n.map(e=>[W(e),e]).filter(([e])=>e)),i=q(n),o=tt(n,T.rows),s=n.length>0&&o.size>0,c=[];T.rows.forEach((t,n)=>{let r=e.cases[n],a=r?W(r):``;a&&i.has(a)||(!s||a&&o.has(a))&&c.push(n)});let l=c.map(e=>T.rows[e]),u=new Set(c.map(t=>W(e.cases[t])).filter(Boolean)),d=K(l,B),f=new AbortController;Mn.current=f,A(!0),h(``),$(t,{reviewRunning:!0,error:``});let p=s?`重审已修改 ${l.length} 条`:i.size?`全量 ${l.length} 条(已忽略 ${i.size} 条不送评)`:`全量 ${l.length} 条`;Ce(`评审用例`,`开始评审:${p}(规则 + 模型)`,Math.max(l.length,1));try{if(!l.length){let e=i.size?`没有待评用例(${i.size} 条已忽略)。取消忽略后再评,或先改文件产生「已修改」。`:`没有待评用例。`;z(e),y(e),$(t,{notice:e});return}let o=async n=>{let o=Ve(e.cases,n,u,r,e.metrics),c=await Qe(t,{review:o}),l=``;if(s){let e={usable:0,revise:0,invalid:0};for(let t of o.cases){let n=W(t);n&&u.has(n)&&!t.ignored&&(e[t.verdict]+=1)}l=`(本轮重审 ${u.size} 条 → 升可用 ${e.usable} · 仍待修改 ${e.revise} · 仍无效 ${e.invalid})`}let d=`评审完成:${o.cases.length} 条,可用 ${o.counts.usable} · 待修改 ${o.counts.revise} · 错误无效 ${o.counts.invalid}${l}${i.size?` · 忽略 ${i.size}`:``}。`;x(c),w(!1),y(d),$(t,{entry:c,stale:!1,notice:d}),a?.()};if(!xe){z(`没有配置模型,只跑规则判定(${p})`),await o(Le(d));return}if(f.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);let c=te?.review?.trim();if(!c)throw Error(`「用例质量评审」技能缺少「评审」段,请先到「插件仓库 → 技能」补全。`);z(`规则体检完成:待评 ${d.cases.length} 条(${p}),按五维拼装技能要求`);let m=Fe(l,T.headers),h=c.replaceAll(`{{cases}}`,`见用户消息里的 ${l.length} 条用例`).replaceAll(`{{requirement}}`,B||`(未挂对照需求)`).replaceAll(`{{template}}`,Oe.join(` / `)).replaceAll(`{{fields}}`,ke),g=[`## 对照需求`,B||`(未挂对照需求,只按用例自身结构评)`,``,`## 用例字段`,Oe.join(` / `),``,`## 字段对照`,ke||`(按文件里的实际表头读)`,``,`## 待评审用例(${l.length} 条)`,m,i.size||n.length&&!s?[``,`## 说明`,s?`本轮只复查已修改的 ${u.size} 条;其余沿用上次判定,请勿评未列出的用例。`:i.size?`另有 ${i.size} 条用户已忽略,不在本次列表中。`:``].filter(Boolean).join(`
|
|
17
|
+
`):``].filter(Boolean).join(`
|
|
18
|
+
`),_={cases:[],items:[],summary:``};if(z(`关联技能已就绪,等待模型返回…`),await Pe(h,g,_,f.signal),f.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);if(!_.cases.length)throw Error(`模型没有提交判定结果,可以重试一次或换成更擅长的模型。`);z(`正在按规则复算分数并落盘…`),await o(ze(d,_.cases,_.summary))}catch(e){if(f.signal.aborted||e instanceof Error&&e.name===`AbortError`){let e=`已停止评审,本次结果没有保存;已有报告保持不变。`;y(e),$(t,{notice:e})}else{let n=e instanceof Error?e.message:String(e),r=/failed to fetch/i.test(n)?`连不上服务(Failed to fetch)。本机热更新或模型 Base URL / 跨域都可能导致;确认 lantern 仍在跑后重试「重新评审」。`:n;h(r),$(t,{error:r})}}finally{A(!1),we(),Mn.current===f&&(Mn.current=null)}},[T,B,xe,te,Fe,Oe,ke,Pe,t,a,Ce,z,we,b]),Be=(0,X.useCallback)(async()=>{if(T){M(!0),h(``),$(t,{detectRunning:!0,error:``}),Ce(`探测场景盲区`,`开始对照需求检查 ${T.rows.length} 条用例的盲区`);try{if(!xe)throw Error(`场景探测需要模型,请先在设置里配置。`);let e=D?.detect?.trim();if(!e)throw Error(`「用例场景补全」技能缺少「探测」段,请先到「插件仓库 → 技能」补全。`);let n=(b?.blindspot?.items??[]).filter(e=>e.added),r=new Set(n.map(e=>Y(e))),i=e.replaceAll(`{{cases}}`,`见用户消息里的 ${T.rows.length} 条用例`),o=[`## 对照需求`,B||`(未挂对照需求)`,``,`## 字段对照`,ke||`(按文件里的实际表头读)`,``,`## 已有用例(${T.rows.length} 条)`,Fe(T.rows,T.headers),n.length?[``,`## 以下场景已写回用例文件,不要再报为盲区`,...n.map((e,t)=>`${t+1}. [${e.category}] ${e.title}${e.reqAnchor?`(归属 ${e.reqAnchor})`:``}`)].join(`
|
|
19
|
+
`):``].filter(Boolean).join(`
|
|
20
|
+
`),s={cases:[],items:[],summary:``};if(z(`上下文:需求${B?`已挂`:`未挂`} · 四类盲区 · ${T.rows.length} 条已有用例${r.size?` · 跳过已写回 ${r.size}`:``}`),await Pe(i,o,s),!s.items.length)throw Error(`模型没有提交盲区条目,可以重试一次。`);z(`正在去重并落盘探测结果…`);let c=new Map((b?.blindspot?.items??[]).map(e=>[Y(e),e])),l=new Set,u=[],d=0;for(let e of s.items){let t=Y(e);if(l.has(t))continue;if(l.add(t),r.has(t)){d+=1;continue}let n=c.get(t);u.push({...e,id:n?.id||e.id||`bs_${Math.random().toString(16).slice(2,18)}`,reqAnchor:e.reqAnchor?.trim()||n?.reqAnchor||``,added:!1,caseNo:``})}let f={at:new Date().toISOString(),context:{reqRef:R,reqTitle:I.find(e=>e.id===R)?.title??``},items:u,summary:s.summary},p=await Qe(t,{blindspot:f}),m=`探测完成:${u.length} 条盲区${d?`(已去掉 ${d} 条已写回)`:``}。`;x(p),w(!1),y(m),$(t,{entry:p,stale:!1,notice:m}),a?.()}catch(e){if(Mn.current?.signal.aborted){let e=`已停止探测,本次结果没有保存。`;y(e),$(t,{notice:e})}else{let n=e instanceof Error?e.message:String(e);h(n),$(t,{error:n})}}finally{M(!1),we(),Mn.current=null}}},[T,xe,D,B,ke,Fe,b,R,I,Pe,t,a,Ce,z,we]),We=(0,X.useCallback)(async()=>{if(!U)return;let e=U.items.filter(e=>ye.has(e.id)&&!e.added);if(e.length){N(!0),h(``),$(t,{completing:!0,error:``}),Ce(`补全选中条目`,`把 ${e.length} 条盲区补全为完整用例(前置 / 步骤 / 预期)`,e.length);try{if(!xe)throw Error(`补全需要模型,请先在设置里配置。`);let n=D?.complete?.trim();if(!n)throw Error(`「用例场景补全」技能缺少「补全」段,请先到「插件仓库 → 技能」补全。`);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,reqAnchor:e.reqAnchor})),null,2)].join(`
|
|
21
|
+
`),o={cases:[],items:[],summary:``};if(await Pe(r,i,o),!o.items.length)throw Error(`模型没有返回补全结果,可以重试一次。`);let s=new Map(o.items.map(e=>[e.id,e])),c=U.items.map(e=>{let t=s.get(e.id);return t?{...e,...t,id:e.id,category:e.category,reqAnchor:t.reqAnchor?.trim()||e.reqAnchor,added:e.added,caseNo:e.caseNo}:e}),l=await Qe(t,{blindspot:{...U,items:c,summary:o.summary||U.summary}}),u=`已补全 ${o.items.length} 条,确认后可写回用例文件。`;x(l),y(u),$(t,{entry:l,notice:u}),a?.()}catch(e){if(Mn.current?.signal.aborted){let e=`已停止补全,本次结果没有保存。`;y(e),$(t,{notice:e})}else{let n=e instanceof Error?e.message:String(e);h(n),$(t,{error:n})}}finally{N(!1),we(),Mn.current=null}}},[U,ye,xe,D,Pe,t,a,Ce,we]),Ge=(0,X.useCallback)(()=>{if(!U)return;let e=U.items.filter(e=>ye.has(e.id)&&!e.added);if(!e.length)return;h(``);let n=new Set(e.map(e=>e.id));(async()=>{try{let r=U.items.map(e=>n.has(e.id)?{...e,added:!0}:e),i={...U,items:r},o=await Qe(t,{blindspot:i});x(o),$(t,{entry:o}),be(e=>{let r=new Set(e);for(let e of n)r.delete(e);return $(t,{selected:[...r]}),r}),a?.(),await kn({path:t,name:t.split(`/`).pop()??t,items:e,requirementTitle:V})}catch(e){h(e instanceof Error?e.message:String(e))}})()},[U,ye,t,V,a]),Ke=(0,X.useCallback)(e=>{be(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),$(t,{selected:[...r]}),r})},[t]),Je=(0,X.useCallback)((e,n)=>{be(r=>{let i=new Set(r);for(let t of e)n?i.add(t):i.delete(t);return $(t,{selected:[...i]}),i})},[t]),Ye=(0,X.useMemo)(()=>H&&T?tt(H.cases,T.rows):new Set,[H,T]),Xe=(0,X.useCallback)(e=>{let n=W(e);e.ignored||e.fixed||n&&Ye.has(n)||(h(``),Tn({path:t,name:t.split(`/`).pop()??t,verdict:e,requirementTitle:V}).catch(e=>h(e instanceof Error?e.message:String(e))))},[t,V,Ye]),G=(0,X.useCallback)(e=>{let n=e.filter(e=>{let t=W(e);return!e.ignored&&!e.fixed&&!(t&&Ye.has(t))&&e.verdict!==`usable`});n.length&&(h(``),Dn({path:t,name:t.split(`/`).pop()??t,verdicts:n,requirementTitle:V}).catch(e=>h(e instanceof Error?e.message:String(e))))},[t,V,Ye]),$e=(0,X.useCallback)(async(e,n)=>{if(!H||!e.length)return;let r=new Set(e.map(e=>W(e)).filter(Boolean));if(!r.size)return;let i=H.cases.map(e=>{if(!r.has(W(e)))return e;let t={...e};return n?t.ignored=!0:delete t.ignored,t}),o={usable:0,revise:0,invalid:0};for(let e of i)e.ignored||(o[e.verdict]+=1);let s=await Qe(t,{review:{...H,cases:i,counts:o}});x(s),$(t,{entry:s}),a?.()},[H,t,a]),et=(0,X.useCallback)(e=>{e.ignored||e.verdict===`usable`||(h(``),$e([e],!0).catch(e=>h(e instanceof Error?e.message:String(e))))},[$e]),J=(0,X.useCallback)(e=>{e.ignored&&(h(``),$e([e],!1).catch(e=>h(e instanceof Error?e.message:String(e))))},[$e]),nt=H?Ze(H.cases,Ye):0,rt=U?U.items.filter(e=>!e.added).length:0,it=[{key:`quality`,label:`质量评审${H?` · 需改 ${nt}`:``}`},{key:`table`,label:`用例表格${T?` ${T.rows.length}`:``}`},{key:`blindspot`,label:`场景补全${rt?` ${rt}`:``}`}],st=t.split(`/`).pop()??t;return(0,Z.jsxs)(C,{open:e,onClose:i,title:`用例评审 · ${st}`,widthClass:`max-w-5xl`,children:[!n||!r?(0,Z.jsxs)(`p`,{className:`text-[11px] text-stone-400`,children:[`未启用`,n?``:`「用例质量评审」`,!n&&!r?` / `:``,r?``:`「场景遗漏补全」`,`插件:到插件页开启后才能用对应 Tab。`]}):null,(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 rounded-lg bg-stone-100 p-0.5`,children:it.map(e=>{let t=e.key===`quality`&&!n||e.key===`blindspot`&&!r;return(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>u(e.key),className:`h-7 rounded-md px-2.5 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${o===e.key?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:e.label},e.key)})}),V?(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-stone-400`,children:[`已挂:`,V]}):(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-amber-700`,children:`未匹配到需求(覆盖率不计)`})]}),se?(0,Z.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`tw-lib-spin shrink-0`,style:{width:14,height:14,borderWidth:2},"aria-hidden":`true`}),(0,Z.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[se,`中…`]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[P,`s`]}),fe?(0,Z.jsxs)(`span`,{className:`text-stone-500`,children:[`已收到 `,fe,` 条`,F?` / ${F}`:``]}):null]}),(0,Z.jsx)(`div`,{className:`tw-run-track mt-2`,role:`progressbar`,"aria-label":`${se}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":F>0?Math.round(Math.min(fe,F)/F*100):void 0,children:F>0?(0,Z.jsx)(`div`,{className:`tw-run-fill`,style:{width:`${Math.round(Math.min(fe,F)/F*100)}%`}}):(0,Z.jsx)(`div`,{className:`tw-run-fill tw-run-fill--indeterminate`})}),(0,Z.jsxs)(`div`,{className:`mt-1.5 space-y-0.5`,children:[ue.slice(-3).map((e,t)=>(0,Z.jsxs)(`div`,{className:`truncate text-[10px] text-stone-400`,children:[`· `,e]},`${t}-${e}`)),ae?(0,Z.jsx)(`div`,{className:`line-clamp-2 text-[10px] leading-4 text-stone-500`,children:ae}):null]})]}):null,S?(0,Z.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,Z.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&&T?(0,Z.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,Z.jsx)(`p`,{className:`py-10 text-center text-xs text-stone-400`,children:`读取中…`}):m&&!T?(0,Z.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}):o===`quality`?(0,Z.jsx)(zt,{review:H,running:re,modelReady:xe,onRun:Ie,onStop:Te,onFix:Xe,onFixBatch:G,onIgnore:et,onUnignore:J,autoFixedKeys:Ye,onExport:()=>at(st,H,U)}):o===`table`?(0,Z.jsx)($t,{file:T,audit:Me,review:H,fileName:st,autoFixedKeys:Ye}):(0,Z.jsx)(Ut,{report:U,loading:f,running:j,completing:ie,modelReady:xe,onStop:Te,selected:ye,onToggle:Ke,onToggleCategory:Je,onDetect:Be,onComplete:We,onWriteback:Ge,onExport:()=>at(st,H,U)})]})}var Rn=10,zn=new Set([`.xlsx`,`.xls`,`.csv`,`.md`]),Bn=`.xlsx,.xls,.csv,.md,text/csv,text/markdown,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`;function Vn(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Hn(e){return zn.has(Vn(e))}function Un(e){let t=e.split(/[/\\]/).pop()||e;return!!(Ee(t)||mt(t)||t.startsWith(`~$`)||t.endsWith(`~`))}function Wn(e,t){if(e.startsWith(`${t.casesFolder}/`))return!0;if(e.includes(`/`))return!1;let n=t.label.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(?:^|[_\\-\\s])${n}用例(?:[_\\-.\\s]|$)`,`i`).test(e)}async function Gn(e=`.`){let{entries:t}=await be(`cases`,e),n=[];for(let e of t)e.type===`file`?!Un(e.path)&&!Un(e.name)&&n.push(e):!pt(e.name)&&!pt(e.path)&&n.push(...await Gn(e.path));return n}function Kn({open:e=!1}){return(0,Z.jsx)(`svg`,{className:`h-3.5 w-3.5 shrink-0 text-[#4176e6]`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:e?(0,Z.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,Z.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function qn({node:e,depth:t,active:n,expanded:r,onSelect:i,onToggle:a}){let o=r[e.path]===!0;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{i(e.path),e.children?.length&&a(e.path)},"aria-expanded":e.children?.length?o:void 0,className:`flex w-full items-center gap-1.5 rounded-md py-1.5 pr-1 text-left text-sm ${n===e.path?`bg-[#e8f0fe] text-[#4176e6]`:`text-stone-600 hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:[(0,Z.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,Z.jsx)(Kn,{open:!!(e.children?.length&&o)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]}),e.children?.length?(0,Z.jsx)(`div`,{className:`tw-collapse ${o?`is-open`:``}`,children:(0,Z.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,Z.jsx)(qn,{node:e,depth:t+1,active:n,expanded:r,onSelect:i,onToggle:a},e.path))})}):null]})}function Jn(e,t=0){return e.flatMap(e=>[{node:e,depth:t},...Jn(e.children||[],t+1)])}function Yn({fixedCaseType:e}={}){let t=Fe(`cases`),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!0),[f,x]=(0,X.useState)(!1),[C,ee]=(0,X.useState)(!1),[te,E]=(0,X.useState)({}),[D,ne]=(0,X.useState)(()=>y(`caseReview.path`)),[O,k]=(0,X.useState)(()=>!!y(`caseReview.path`)&&_(`caseReview.open`,[`0`,`1`],`0`)===`1`),[A,j]=(0,X.useState)(t?!0:null),[M,ie]=(0,X.useState)(()=>t??[]),[N,ae]=(0,X.useState)(()=>me()),[se,ce]=(0,X.useState)([]),[P,le]=(0,X.useState)(()=>y(`cases.folder`)||`.`),[ue,de]=(0,X.useState)({}),[fe,pe]=(0,X.useState)({}),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(!1),[he,ge]=(0,X.useState)(null),[_e,ve]=(0,X.useState)(!1),[be,Te]=(0,X.useState)(0),[Ee,De]=(0,X.useState)(null),[Ae,je]=(0,X.useState)(``),[V,Me]=(0,X.useState)(null),[Ne,Le]=(0,X.useState)(null),[Re,ze]=(0,X.useState)(``),[Be,Ve]=(0,X.useState)(null),[He,Ge]=(0,X.useState)(``),[Ke,qe]=(0,X.useState)(null),[Je,W]=(0,X.useState)(null),[Ye,Ze]=(0,X.useState)(``),[G,$e]=(0,X.useState)(N[0]?.casesFolder||`功能测试`),K=(0,X.useRef)(null),q=(0,X.useMemo)(()=>e&&e!==`other`?N.find(t=>t.id===e):void 0,[N,e]),et=(0,X.useMemo)(()=>N.filter(e=>!o(e.id)),[N]),J=(0,X.useMemo)(()=>e===`other`?et:q?[q]:N,[N,et,e,q]),tt=(0,X.useMemo)(()=>e?J.map(e=>e.casesFolder):[],[e,J]),nt=(0,X.useMemo)(()=>{let e=new Map(se.map(e=>[e.name,e])),t=new Set(N.map(e=>e.casesFolder)),n=N.map(t=>{let n=e.get(t.casesFolder),r=M.filter(e=>Wn(e.path,t)).length;return{...n||{name:t.casesFolder,path:t.casesFolder,children:[]},fileCount:r}});for(let e of se)t.has(e.name)||n.push(e);return n},[N,M,se]),rt=(0,X.useMemo)(()=>{if(e===`other`)return M.filter(e=>J.some(t=>Wn(e.path,t)));if(q)return M.filter(e=>Wn(e.path,q));if(P===`.`)return M;let t=P.split(`/`)[0],n=N.find(e=>e.casesFolder===t);return M.filter(e=>e.path.startsWith(`${P}/`)||P===t&&n&&Wn(e.path,n))},[P,N,M,e,q,J]),it=(0,X.useMemo)(()=>{if(e===`other`)return;if(q)return q;let t=P.split(`/`)[0];return N.find(e=>e.casesFolder===t)},[P,N,e,q]),Y=Pe(rt,Rn,`cases:${e||`all`}`),at=(0,X.useCallback)(async()=>{try{let e=await wt({scopeFolders:tt,caseTypes:N});Te(e.length)}catch{Te(0)}},[tt,N]),ot=(0,X.useCallback)(async()=>{I(null);let[e,t]=await Promise.all([Gn(`.`),z(`cases`)]);ie(e),ce(t.tree),U(`cases`,e),pe(t=>{let n={};for(let r of e)t[r.path]&&(n[r.path]=!0);return n}),at()},[at]);(0,X.useEffect)(()=>{let e=m(e=>{d(!!e.cases),x(!!e.caseReview),ee(!!e.caseBlindspot)});return s().then(()=>{d(g(`cases`)),x(g(`caseReview`)),ee(g(`caseBlindspot`)),ae(me()),l(!0)}),e},[]);let st=(0,X.useCallback)(async()=>{if(!f&&!C)E({});else try{let e=await We();E(Object.fromEntries(e.map(e=>[e.path,e])))}catch{E({})}},[f,C]);(0,X.useEffect)(()=>{c&&u&&A!==!1&&st()},[c,u,A,st]),(0,X.useEffect)(()=>{c&&u&&(async()=>{if(!await Oe(`cases`))j(!1);else try{await re().catch(()=>null),await ot(),j(!0)}catch(e){I(e instanceof Error?e.message:String(e)),j(!0)}})()},[c,u,ot]);let ct=(0,X.useMemo)(()=>Object.keys(fe).filter(e=>fe[e]),[fe]);async function ut(){let e=he;if(e){ge(null),R(!0),I(null);try{if(e.kind===`one`)await B(`cases`,e.entry.path);else{for(let t of e.paths)await B(`cases`,t);pe({})}await ot(),T(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个用例文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);I(t),T(`删除失败:${t}`,`error`)}finally{R(!1)}}}let dt=he?.kind===`one`?`删除「${he.entry.name}」?将从 ${H(`cases`)} 中移除。`:he?.kind===`batch`?`确认删除已选中的 ${he.paths.length} 个用例文件?此操作不可恢复。`:``;function ft(){if(!g(`caseGen`)){I(h(`caseGen`));return}let t=q?.id||(e===`other`?et[0]?.id:``),n=new URLSearchParams({plugin:`caseGen`});t&&n.set(`caseType`,t),window.location.href=`/workbench/?${n.toString()}`}async function pt(e){R(!0),I(null);try{await oe(`cases`,e)}catch(e){I(e instanceof Error?e.message:String(e)),R(!1)}}function mt(e){je(``),De(e)}function ht(e){Ge(``),Ve(e)}let gt=(0,X.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=M.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[M]);async function _t(e){let t=Be;if(!t)return;let n=e.trim();if(!n||n===t.name){Ve(null),Ge(``);return}let r=gt(Se(t.path),n,t.path);if(r)Ge(`已存在同名文件「${r}」,换个名字再试`);else{R(!0),I(null),Ge(``);try{let e=await Ce(`cases`,t.path,n);if(e!==t.path&&(f||C))try{let{entry:n}=await Ue(t.path);(n?.review||n?.blindspot)&&(await Qe(e,{review:n.review??null,blindspot:n.blindspot??null}),await Qe(t.path,{review:null,blindspot:null}))}catch{}D===t.path&&(ne(e),b(`caseReview.path`,e)),Ve(null),await ot(),st(),T(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);Ge(t),T(`重命名失败:${t}`,`error`)}finally{R(!1)}}}async function vt(e){let t=Ee;if(t){R(!0),I(null),je(``);try{let{name:n}=await Xe(t.path,e);De(null),T(`已备份到备份列表:${n}`,`success`),await at()}catch(e){let t=e instanceof Error?e.message:String(e);je(t),T(`备份失败:${t}`,`error`)}finally{R(!1)}}}async function yt(){if(Ne&&Re){R(!0),I(null);try{await we(`cases`,`.`,Re).catch(()=>void 0),await ke(`cases`,Ne.path,Re),Le(null),await ot(),T(`已移动到「${Re}」`,`success`)}catch(e){I(e instanceof Error?e.message:String(e))}finally{R(!1)}}}async function bt(e){let t=typeof e==`string`?e:e.path;I(null);try{await xe(`cases`,t)}catch(e){I(e instanceof Error?e.message:String(e))}}function xt(e,t){let n=new Set(M.filter(e=>Se(e.path)===t).map(e=>e.name.toLowerCase())),r=[],i=new Set;for(let t of e){let e=t.name.toLowerCase();n.has(e)&&!i.has(e)&&(r.push(t.name),i.add(e))}return r}async function St(e,t=G){if(e.length){R(!0),I(null);try{await we(`cases`,`.`,t).catch(()=>void 0);for(let n of e)await ye(`cases`,t,n);await ot(),T(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);I(t),T(`上传失败:${t}`,`error`)}finally{R(!1),qe(null),W(null),K.current&&(K.current.value=``)}}}function Ct(e){if(!e?.length)return;let t=Array.from(e),n=t.filter(e=>Hn(e.name)),r=t.filter(e=>!Hn(e.name));if(r.length&&T(`已跳过 ${r.length} 个不支持的格式(仅 .xlsx / .xls / .csv / .md)`,`error`),!n.length){K.current&&(K.current.value=``);return}if(q){let e=q.casesFolder;Ze(e),xt(n,e).length?qe(n):St(n,e);return}let i=J[0]?.casesFolder||it?.casesFolder||G||N[0]?.casesFolder||`功能测试`;$e(i),W(n)}function Et(){let e=Je;if(!e?.length)return;let t=it?.casesFolder===G?P:G;Ze(t),W(null),xt(e,t).length?qe(e):St(e,t)}return c?u?A===null?(0,Z.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,Z.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,Z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):A?(0,Z.jsxs)(`div`,{className:`flex min-h-0 gap-4`,children:[(0,Z.jsxs)(`aside`,{className:`${e?`hidden`:`hidden xl:flex`} w-56 shrink-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3 py-2.5`,children:(0,Z.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`用例目录`})}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1 overflow-y-auto px-1 py-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{le(`.`),b(`cases.folder`,`.`)},className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm ${P===`.`?`bg-[#e8f0fe] text-[#4176e6]`:`text-stone-600 hover:bg-stone-100`}`,children:[(0,Z.jsx)(Kn,{open:!0}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`全部用例`}),(0,Z.jsxs)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:[`(`,M.length,`)`]})]}),nt.map(e=>(0,Z.jsx)(qn,{node:e,depth:0,active:P,expanded:ue,onSelect:e=>{le(e),b(`cases.folder`,e)},onToggle:e=>de(t=>({...t,[e]:!t[e]}))},e.path))]})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`div`,{className:e?`hidden`:`w-40 xl:hidden`,children:(0,Z.jsx)(S,{value:P,onChange:e=>{le(e),b(`cases.folder`,e)},options:[{value:`.`,label:`全部用例 (${M.length})`},...Jn(nt).map(({node:e,depth:t})=>({value:e.path,label:`${` `.repeat(t)}${e.name} (${e.fileCount??0})`}))],ariaLabel:`切换用例目录`,compact:!0})}),(0,Z.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[Y.query.trim()?(0,Z.jsxs)(Z.Fragment,{children:[`匹配 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:Y.filtered.length}),` 个`,(0,Z.jsxs)(`span`,{className:`text-stone-400`,children:[` · 当前目录 `,rt.length]})]}):(0,Z.jsxs)(Z.Fragment,{children:[`当前 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:rt.length}),` `,`个文件`]}),ct.length>0?(0,Z.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,ct.length]}):null]}),(0,Z.jsx)(`input`,{ref:K,type:`file`,multiple:!0,accept:Bn,className:`hidden`,onChange:e=>Ct(e.target.files)}),(0,Z.jsxs)(`button`,{type:`button`,disabled:L,onClick:()=>ve(!0),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40`,children:[`备份列表`,be>0?`(${be>99?`99+`:be})`:``]}),(0,Z.jsx)(`button`,{type:`button`,disabled:L||ct.length===0,onClick:()=>ge({kind:`batch`,paths:ct}),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,Z.jsx)(`button`,{type:`button`,disabled:L||e===`other`&&et.length===0,onClick:()=>K.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-stone-700 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40`,title:e===`other`&&et.length===0?`请先在生成配置中新增自定义用例类型`:void 0,children:`上传用例`}),(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:ft,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:`生成用例`})]}),F?(0,Z.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:F}):null,(0,Z.jsx)(Ie,{files:rt,filtered:Y.filtered,pageFiles:Y.pageFiles,query:Y.query,onQuery:Y.setQuery,sortBy:Y.sortBy,onSortBy:Y.setSortBy,page:Y.page,totalPages:Y.totalPages,pageSize:Y.pageSize,onPage:Y.setPage,onPageSize:Y.setPageSize,busy:L,emptyText:e===`other`&&et.length===0?`还没有自定义用例类型。请先在生成用例配置中新增类型。`:`暂无用例文件,可「上传用例」导入本地文件,或点「生成用例」前往工作台。`,searchPlaceholder:`搜索文件名或路径…`,resizeKey:`docs:cases:${e||`all`}:cols:v1`,extraColumn:f||C?{header:`评审`,render:e=>{let t=te[e.path];if(!t)return(0,Z.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`—`});let n=t.score;return(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[n==null?(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:`未评审`}):(0,Z.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,Z.jsxs)(`span`,{className:`shrink-0 text-[10px] text-stone-400`,children:[`补 `,t.blindspotCount]}):null,t.stale?(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-amber-600`,children:`过期`}):null]})}}:void 0,selected:fe,onToggleRow:e=>pe(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>pe(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void bt(e),renderNameAction:e=>(0,Z.jsx)(`button`,{type:`button`,disabled:L,"aria-label":`重命名 ${e.name}`,onClick:()=>ht(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,Z.jsx)(w,{name:`pencil`,size:12})}),renderActions:t=>(0,Z.jsxs)(Z.Fragment,{children:[f||C?(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>{ne(t.path),k(!0),b(`caseReview.path`,t.path),v(`caseReview.open`,`1`)},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,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>mt(t),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:`备份`}),e?null:(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>{ze(N[0]?.casesFolder||`功能测试`),Le(t)},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:`移动`}),(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>Me(t),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:`重排`}),(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>void pt(t),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>ge({kind:`one`,entry:t}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,Z.jsx)(p,{open:he!=null,title:he?.kind===`batch`?`批量删除`:`删除用例文件`,message:dt,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>ge(null),onConfirm:()=>void ut()}),(0,Z.jsxs)(i,{open:Ne!=null,onClose:()=>{L||Le(null)},className:`relative z-110`,children:[(0,Z.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,Z.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Z.jsxs)(n,{className:`w-full max-w-sm rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Z.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`移动到分类目录`}),(0,Z.jsx)(`p`,{className:`mt-1 truncate text-xs text-stone-500`,children:Ne?.name}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(S,{value:Re,onChange:ze,options:N.map(e=>({value:e.casesFolder,label:e.label})),ariaLabel:`选择目标用例类型`})}),(0,Z.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>Le(null),className:`h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-600`,children:`取消`}),(0,Z.jsx)(`button`,{type:`button`,disabled:L||!Re,onClick:()=>void yt(),className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white disabled:opacity-40`,children:`移动`})]})]})})]}),(0,Z.jsxs)(i,{open:Je!=null,onClose:()=>{L||(W(null),K.current&&(K.current.value=``))},className:`relative z-110`,children:[(0,Z.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,Z.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Z.jsxs)(n,{className:`w-full max-w-md rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Z.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:e===`other`?`选择自定义用例类型`:`选择用例类型`}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`文件将归入对应用例类型目录,后续从对应类型菜单直接进入。`}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(S,{value:G,onChange:$e,options:J.map(e=>({value:e.casesFolder,label:e.label})),ariaLabel:`上用例文件类型`})}),(0,Z.jsxs)(`p`,{className:`mt-2 rounded-md bg-stone-50 px-3 py-2 text-xs text-stone-500`,children:[`保存位置: 用例管理 /`,it?.casesFolder===G?P:G]}),(0,Z.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>{W(null),K.current&&(K.current.value=``)},className:`h-9 rounded-lg border border-stone-200 px-3 text-sm text-stone-600`,children:`取消`}),(0,Z.jsx)(`button`,{type:`button`,disabled:L||!G,onClick:Et,className:`h-9 rounded-lg bg-[#4176e6] px-4 text-sm font-medium text-white disabled:opacity-40`,children:`上传到该类型`})]})]})})]}),(0,Z.jsx)(p,{open:Ke!=null,title:`覆盖同名文件`,message:Ke?`以下文件已存在于用例管理/${Ye},继续将覆盖:${xt(Ke,Ye).join(`、`)}。是否继续?`:``,confirmLabel:`覆盖上传`,cancelLabel:`取消`,danger:!0,onClose:()=>{L||(qe(null),K.current&&(K.current.value=``))},onConfirm:()=>{let e=Ke;e&&St(e,Ye)}}),(0,Z.jsx)(lt,{open:Ee!=null,title:`备份用例`,label:`备份文件名`,placeholder:`请输入备份文件名`,initialValue:Ee?.name??``,lockExtension:!0,confirmLabel:`备份`,cancelLabel:`取消`,error:Ae,onClose:()=>{L||(De(null),je(``))},onConfirm:e=>void vt(e)}),(0,Z.jsx)(lt,{open:Be!=null,title:`重命名用例`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:Be?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:He,onClose:()=>{L||(Ve(null),Ge(``))},onConfirm:e=>void _t(e)}),(0,Z.jsx)(Nt,{open:V!=null,casePath:V?.path??``,fileName:V?.name??``,onClose:()=>Me(null),onDone:e=>{T(e,`success`),ot(),st()},onError:e=>T(e,`error`)}),(0,Z.jsx)(Ln,{open:O&&!!D,path:D,reviewOn:f,blindspotOn:C,onClose:()=>{k(!1),v(`caseReview.open`,`0`),st()},onSaved:()=>void st()}),(0,Z.jsx)(Tt,{open:_e,onClose:()=>ve(!1),onChanged:()=>{ot(),at()},scopeFolders:tt,caseTypes:N})]})]}):(0,Z.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,Z.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:h(`cases`)}):(0,Z.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,Z.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,Z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{Yn as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{t as default}from"./ChatApp.CqyrMX90.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js","_astro/case-fields.C03NY3zC.js","_astro/case-workflow-contract.BBQ9bbKL.js","_astro/UiAutoGenerationDialog.gypq1zP9.js","_astro/dialog.XgRGNF_Q.js","_astro/portal.Chh6O5xk.js","_astro/react-dom.DLW9pGCF.js","_astro/app-config.BSO5r82v.js","_astro/settings.BojKNwUC.js","_astro/jsx-runtime.DUg_B_vD.js","_astro/view-prefs.CWc5cQ2q.js","_astro/PmShared.TOjBbtV8.js","_astro/plugins.ChGmBEkF.js","_astro/pm.BXmOiFfW.js","_astro/SelectDropdown.D7IeyHDI.js","_astro/listbox.DNxAJmEo.js","_astro/use-text-value.B3mOiuGb.js","_astro/SlideOverDrawer.CvyB-quk.js","_astro/Toast.BydY-X7T.js","_astro/open-docs-in-session.BoyV6R2A.js","_astro/ui-auto.LUcREUMe.js","_astro/fs-tools.3F9MFrLf.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{a as r,n as i,r as a,t as o}from"./dialog.XgRGNF_Q.js";import{i as s,n as c,r as l,t as u}from"./menu.Dnrpz489.js";import{g as d}from"./business-map.BiJ85oxm.js";import{B as f,V as p,W as m,i as h,p as g,r as _,t as v,u as y}from"./app-config.BSO5r82v.js";import{a as ee,b,c as x,f as S,h as C,m as te,p as w,r as T,s as E,u as ne}from"./settings.BojKNwUC.js";import{t as D}from"./jsx-runtime.DUg_B_vD.js";import{t as re}from"./ConfirmDialog.DQFd6g2r.js";import{a as ie,i as ae,o as oe,r as O,t as k}from"./plugins.ChGmBEkF.js";import{C as se,E as ce,M as A,O as le,R as j,S as M,T as N,a as ue,d as P,g as de,h as fe,k as pe,l as F,r as me,s as he,t as I,w as L,x as R,y as z}from"./pm.BXmOiFfW.js";import{n as ge,o as _e}from"./view-prefs.CWc5cQ2q.js";import{n as ve,t as B}from"./SelectDropdown.D7IeyHDI.js";import{t as ye}from"./SlideOverDrawer.CvyB-quk.js";import{showToast as be}from"./Toast.BydY-X7T.js";import{_ as xe,a as Se,h as V,o as Ce,r as we,s as Te,t as Ee}from"./case-exec.BMNk9OyF.js";import{t as De}from"./DatePicker.BRO_CjVQ.js";import{a as Oe,i as ke,n as Ae,r as je}from"./composer-task.DRi5tAJs.js";import{A as Me,C as Ne,D as Pe,E as Fe,O as Ie,S as Le,T as Re,_ as ze,a as Be,b as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,i as qe,j as Je,k as Ye,l as Xe,m as Ze,n as Qe,o as $e,p as et,r as tt,s as nt,u as rt,v as it,w as at,x as ot,y as st}from"./open-docs-in-session.BoyV6R2A.js";import{S as ct,d as lt}from"./ui-auto.LUcREUMe.js";import{a as ut,i as dt,n as ft,r as pt,t as mt}from"./case-types.BjF1BivA.js";import{a as ht,c as gt,l as _t,s as vt,t as yt}from"./case-gen-run.
|
|
2
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{a as r,n as i,r as a,t as o}from"./dialog.XgRGNF_Q.js";import{i as s,n as c,r as l,t as u}from"./menu.Dnrpz489.js";import{g as d}from"./business-map.BiJ85oxm.js";import{B as f,V as p,W as m,i as h,p as g,r as _,t as v,u as y}from"./app-config.BSO5r82v.js";import{a as ee,b,c as x,f as S,h as C,m as te,p as w,r as T,s as E,u as ne}from"./settings.BojKNwUC.js";import{t as D}from"./jsx-runtime.DUg_B_vD.js";import{t as re}from"./ConfirmDialog.DQFd6g2r.js";import{a as ie,i as ae,o as oe,r as O,t as k}from"./plugins.ChGmBEkF.js";import{C as se,E as ce,M as A,O as le,R as j,S as M,T as N,a as ue,d as P,g as de,h as fe,k as pe,l as F,r as me,s as he,t as I,w as L,x as R,y as z}from"./pm.BXmOiFfW.js";import{n as ge,o as _e}from"./view-prefs.CWc5cQ2q.js";import{n as ve,t as B}from"./SelectDropdown.D7IeyHDI.js";import{t as ye}from"./SlideOverDrawer.CvyB-quk.js";import{showToast as be}from"./Toast.BydY-X7T.js";import{_ as xe,a as Se,h as V,o as Ce,r as we,s as Te,t as Ee}from"./case-exec.BMNk9OyF.js";import{t as De}from"./DatePicker.BRO_CjVQ.js";import{a as Oe,i as ke,n as Ae,r as je}from"./composer-task.DRi5tAJs.js";import{A as Me,C as Ne,D as Pe,E as Fe,O as Ie,S as Le,T as Re,_ as ze,a as Be,b as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,i as qe,j as Je,k as Ye,l as Xe,m as Ze,n as Qe,o as $e,p as et,r as tt,s as nt,u as rt,v as it,w as at,x as ot,y as st}from"./open-docs-in-session.BoyV6R2A.js";import{S as ct,d as lt}from"./ui-auto.LUcREUMe.js";import{a as ut,i as dt,n as ft,r as pt,t as mt}from"./case-types.BjF1BivA.js";import{a as ht,c as gt,l as _t,s as vt,t as yt}from"./case-gen-run.DQR6uvH5.js";import{a as bt,c as xt,l as St}from"./case-fields.C03NY3zC.js";import{c as Ct,d as wt,m as Tt,p as Et,r as Dt,y as Ot}from"./project-docs.BRgNjXhG.js";import{i as kt,n as At,r as jt}from"./case-template.CC2eXegU.js";import{A as Mt,L as Nt,T as Pt,_ as Ft,tt as It}from"./req-analysis.efWkT7Gv.js";import{a as Lt,i as Rt,r as zt,s as Bt,t as H}from"./llm.BCYNgppW.js";import{n as Vt,t as Ht}from"./doc-roots.C-20VD0x.js";import{i as Ut}from"./space-skills.CPucW8zt.js";import{n as Wt,t as Gt}from"./case-prompt.ByLTgz4r.js";import{t as Kt}from"./ExcelFieldTags.CXif3Ilh.js";import{t as qt}from"./MultiSelectDropdown.D-rbpivp.js";import{t as Jt}from"./SearchableSelect.DXclLMJI.js";import{t as Yt}from"./NamePromptDialog.KPCeXmri.js";import{n as Xt,r as Zt,t as Qt}from"./composer-draft.llpvz3MW.js";import{n as $t}from"./i18n.CEWjL5GX.js";import{_ as en,a as tn,b as nn,c as rn,d as an,f as on,g as sn,h as cn,i as ln,l as un,m as dn,n as fn,o as pn,p as mn,r as U,s as hn,t as gn,u as _n,v as vn,y as yn}from"./fs-tools.3F9MFrLf.js";import{A as bn,M as xn,O as Sn,S as Cn,c as wn,k as Tn,n as En,t as Dn}from"./UiAutoGenerationDialog.gypq1zP9.js";import{i as On,s as kn}from"./requirement-breakdown-library.l0rPd7b3.js";import{C as An,D as jn,E as Mn,F as Nn,O as Pn,P as Fn,S as In,T as Ln,_ as Rn,a as zn,b as Bn,c as Vn,d as Hn,g as Un,i as Wn,j as W,k as Gn,l as Kn,m as qn,n as Jn,o as Yn,r as Xn,t as Zn,u as Qn,v as $n,x as er,y as tr}from"./tasks.DEyD8pmq.js";import{_ as nr,a as rr,c as ir,d as ar,f as or,g as sr,h as cr,i as lr,l as ur,m as dr,n as fr,o as pr,p as mr,r as hr,s as gr,t as _r,u as vr,v as yr,y as br}from"./bash-tools.C4DJiRJs.js";import{A as xr,C as Sr,D as Cr,E as wr,O as Tr,S as Er,T as Dr,_ as Or,b as kr,g as Ar,h as jr,j as Mr,k as Nr,m as Pr,o as Fr,p as Ir,s as Lr,t as Rr,u as zr,v as Br,w as Vr,x as Hr}from"./mcp-tools.Kf-lupGn.js";import{n as Ur,t as Wr}from"./prompts-meta.VAjE4OET.js";import{o as Gr,r as Kr,t as qr}from"./report-prompt.CwHuOcRN.js";import{s as Jr}from"./test-stats.Cf3_L4wu.js";import{f as Yr,n as Xr,u as Zr}from"./test-points.BSfPfq8z.js";var G=e(t(),1),Qr=e(n(),1),$r=`/__tb_sessions/runs`;async function ei(e){try{return(await fetch($r,{signal:e??AbortSignal.timeout(1500)})).ok}catch{return!1}}async function ti(e){let t=await fetch($r,{signal:e??AbortSignal.timeout(3e3)});if(!t.ok)return[];let n=await t.json();return Array.isArray(n.runs)?n.runs:[]}async function ni(e){let t=await fetch($r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error||`HTTP ${t.status}`}}async function ri(e){await fetch(`${$r}/${encodeURIComponent(e)}/stop`,{method:`POST`}).catch(()=>{})}async function ii(e){try{let t=await fetch(`${$r}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(3e3)});return t.status===404?{ok:!1}:t.ok?await t.json():null}catch{return null}}function ai(e){return e===`completed`||e===`stopped`||e===`error`}function oi(e,t,n,r){let i=new AbortController,a=`${$r}/${encodeURIComponent(e)}/events?after=${Math.max(0,t)}`;return(async()=>{try{let e=await fetch(a,{headers:{Accept:`text/event-stream`},signal:i.signal});if(!e.ok||!e.body){r?.(Error(`SSE ${e.status}`));return}let t=e.body.getReader(),o=new TextDecoder,s=``;for(;;){let{done:e,value:a}=await t.read();if(e){i.signal.aborted||r?.(Error(`SSE disconnected`));break}s+=o.decode(a,{stream:!0});let c=s.split(`
|
|
3
3
|
`);s=c.pop()??``;for(let e of c){let t=e.trim();if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(r)try{n(JSON.parse(r))}catch{}}}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;r?.(e instanceof Error?e:Error(String(e)))}})(),()=>i.abort()}function si(e,t,n){let r=!1,i=Math.max(0,t),a=0,o=null,s,c=n.maxAttempts??10,l=()=>{r=!0,s!=null&&clearTimeout(s),s=void 0,o?.(),o=null},u=()=>{r||n.signal?.aborted||(o?.(),o=oi(e,i,e=>{typeof e.seq==`number`&&Number.isFinite(e.seq)&&(i=Math.max(i,e.seq)),n.onEvent(e),e.type===`status`&&ai(e.status)&&(n.onTerminal?.(e),l())},t=>{r||n.signal?.aborted||(async()=>{a+=1;try{let r=await ii(e);if(r?.ok&&typeof r.seq==`number`&&(i=Math.max(i,r.seq)),r?.ok&&ai(r.status)){let e={type:`status`,status:r.status,seq:r.seq,assistant:r.assistant};n.onEvent(e),n.onTerminal?.(e),l();return}if(r&&r.ok===!1){n.onGaveUp?.(Error(t.message||`run not found`)),l();return}}catch{}if(a>=c){n.onGaveUp?.(t),l();return}let r=Math.min(4e3,250*a);s=setTimeout(u,r)})()}))},d=()=>l();return n.signal?.addEventListener(`abort`,d),u(),()=>{n.signal?.removeEventListener(`abort`,d),l()}}function ci(e){for(let t of e)if(t.role===`user`&&typeof t.content==`string`){let e=t.content.trim();if(e)return e}return``}function li(e,t){let n=(e||``).trim()||`新对话`;return n===`新对话`||n===`新会话`||n===`新编排`||n===`未命名编排`||/^编排\s+\d{1,2}\/\d{1,2}\s+\d{1,2}:\d{2}/.test(n)?!0:n===Fe(t)}function ui(e){let t=String(e??``).trim().replace(/^["「『]+|["」』]+$/g,``).replace(/\s+/g,` `).replace(/^标题[::]\s*/i,``);return t=t.replace(/[。.!!]+$/g,``).trim(),t?t.length>28?`${t.slice(0,28)}…`:t:``}async function di(e,t,n){let r=t.trim().slice(0,800);if(!r)return null;let i=[{role:`system`,content:`你为对话生成侧栏短标题。只输出标题本身:中文优先,不超过 16 个字,无引号、无标点收尾、无解释。`},{role:`user`,content:`用户首条消息:\n${r}\n\n请给出标题:`}];try{return ui(await zt(e,i,n))||null}catch{return null}}function fi(e){let t=Array.isArray(e.messages)?e.messages:[],n=0,r=0,i=0,a=0,o=0;for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;t.role===`user`?n+=1:t.role===`assistant`&&(r+=1);let s=t.usage;if(s&&typeof s==`object`){let e=s;typeof e.promptTokens==`number`&&(i+=e.promptTokens),typeof e.completionTokens==`number`&&(a+=e.completionTokens),typeof e.totalTokens==`number`?o+=e.totalTokens:(typeof e.promptTokens==`number`||typeof e.completionTokens==`number`)&&(o+=(Number(e.promptTokens)||0)+(Number(e.completionTokens)||0))}}let s=e.goal,c=!!(s&&s.status!==`cleared`&&s.text?.trim());return{sessionId:e.id,title:e.title||`新对话`,messageCount:t.length,userCount:n,assistantCount:r,promptTokens:i,completionTokens:a,totalTokens:o,createdAt:e.createdAt,updatedAt:e.updatedAt,hasGoal:c,todoCount:Array.isArray(e.todos)?e.todos.length:0}}function pi(e){let t=new Date(e.createdAt).toLocaleString(),n=new Date(e.updatedAt).toLocaleString();return[`会话:${e.title}`,`消息 ${e.messageCount}(用户 ${e.userCount} / 助手 ${e.assistantCount})`,`用量≈ 输入 ${e.promptTokens} · 输出 ${e.completionTokens} · 合计 ${e.totalTokens}`,`待办 ${e.todoCount} · 目标 ${e.hasGoal?`有`:`无`}`,`创建 ${t}`,`更新 ${n}`].join(`
|
|
4
4
|
`)}var mi=new Map,hi=new Map,gi=40;function _i(e,t,n=``){return`${e}:${t}:${n}`}function vi(e){for(;e.size>gi;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function yi(e,t,n,r,i=``){let a=e===`outline`?mi:hi,o=_i(t,n,i),s=a.get(t);if(s&&s.stamp===o)return s.value;let c=r();return a.set(t,{stamp:o,value:c}),vi(a),c}var bi=`/__tb_sessions/log`;function xi(e){let t=String(e.userContent??``).trim(),n=String(e.assistantContent??``).trim(),r=String(e.reasoning??``).trim(),i=[];if(t&&i.push({role:`user`,content:t}),n||r){let e={role:`assistant`,content:n};r&&(e.reasoning_content=r),i.push(e)}return i}async function Si(e){try{let t=await fetch(bi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,path:n.path}:{ok:!1,error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function Ci(e){return String(e??``).trim()}function wi(e,t=80){let n=Ci(e).replace(/\s+/g,` `);return n?n.length>t?`${n.slice(0,t)}…`:n:``}function Ti(e,t=40){let n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];if(a.role===`user`){let e=Ci(a.content),t=wi(e);if(!t)continue;r&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),r={text:e,preview:t,time:typeof a.time==`number`?a.time:void 0,messageIndex:i}}else if(a.role===`assistant`&&r){let e=Ci(a.content),t=Ci(a.reasoning)||void 0;n.push({index:n.length+1,userPreview:r.preview,assistantPreview:wi(e)||(t?`(含思考)`:``),userText:r.text,assistantText:e,reasoning:t,reasoningDuration:typeof a.reasoningDuration==`number`?a.reasoningDuration:void 0,userTime:r.time,assistantTime:typeof a.time==`number`?a.time:void 0,endMessageIndex:i}),r=null}if(n.length>=t)break}return r&&n.length<t&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),n}function Ei(e,t){let n=String(t??``).trim();return!n||n===`inherit`||n===e.model?e:{...e,model:n}}var Di=`/__tb_fs`,Oi=`你可以使用 office_to_pdf:优先用本机 LibreOffice 转为 PDF;若未安装,则对 docx/xlsx/pptx 降级抽取正文为同目录 .extracted.md(需写权限)。`,ki={type:`function`,function:{name:`office_to_pdf`,description:`Convert Office docs to PDF via LibreOffice when available; otherwise extract text to .extracted.md for docx/xlsx/pptx.`,parameters:{type:`object`,properties:{path:{type:`string`,description:`Input file path relative to workspace (or absolute when allowed)`},outDir:{type:`string`,description:`Optional output directory (default: same as input)`}},required:[`path`]}}};async function Ai(e,t,n){if(e!==`office_to_pdf`)return JSON.stringify({error:`unknown tool: ${e}`});let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({ok:!1,error:`invalid JSON arguments`})}let i=String(r.path??``).trim();if(!i)return JSON.stringify({ok:!1,error:`path is required`});try{let e=await(await fetch(`${Di}/office-to-pdf`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i,outDir:typeof r.outDir==`string`?r.outDir:void 0,access:n}),signal:AbortSignal.timeout(13e4)})).json().catch(()=>({}));return JSON.stringify(e,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}var ji=`/__tb_fs`,Mi=`你可以使用 load_workspace_dependencies:查询本机 node / npm / pnpm / python 等可执行文件绝对路径(需本地 fs 服务)。`,Ni={type:`function`,function:{name:`load_workspace_dependencies`,description:`Resolve absolute paths of common runtimes/package managers on this machine (node, npm, pnpm, python, …).`,parameters:{type:`object`,properties:{}}}};async function Pi(e){if(e!==`load_workspace_dependencies`)return JSON.stringify({error:`unknown tool: ${e}`});try{let e=await fetch(`${ji}/workspace-dependencies`,{signal:AbortSignal.timeout(8e3)}),t=await e.json().catch(()=>({}));if(!e.ok){let n=typeof t==`object`&&t&&`error`in t?String(t.error):`HTTP ${e.status}`;return JSON.stringify({ok:!1,error:n})}return JSON.stringify(t,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}function Fi(e){return Array.isArray(e)}function Ii(e){return Fi(e)?e.some(e=>e.type===`image_url`):!1}function Li(e){let t=e.filter(e=>e.type===`text`).map(e=>e.text),n=e.filter(e=>e.type===`image_url`).length,r=n>0?`[image-offload] 已卸载 ${n} 张图片(超预算,仅保留最近附图)。`:``;return[{type:`text`,text:[...t,r].filter(Boolean).join(`
|
|
5
5
|
`)||r||`(图片已卸载)`}]}function Ri(e,t={}){let n=Math.max(0,Math.floor(t.keepRecentImageMessages??1)),r=[];for(let t=0;t<e.length;t++){let n=e[t];n.role===`user`&&Ii(n.content)&&r.push(t)}if(r.length<=n)return e;let i=new Set(r.slice(-n)),a=!1,o=e.map((e,t)=>e.role!==`user`||!Ii(e.content)||i.has(t)||!Fi(e.content)?e:(a=!0,{...e,content:Li(e.content)}));return a?o:e}function zi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Bi=zi();function Vi(e){Bi=e}var Hi={exec:()=>null};function K(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Ui.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ui={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},Wi=/^(?:[ \t]*(?:\n|$))+/,Gi=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ki=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,qi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ji=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Yi=/(?:[*+-]|\d{1,9}[.)])/,Xi=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zi=K(Xi).replace(/bull/g,Yi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Qi=K(Xi).replace(/bull/g,Yi).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$i=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ea=/^[^\n]+/,ta=/(?!\s*\])(?:\\.|[^\[\]\\])+/,na=K(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ta).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ra=K(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Yi).getRegex(),ia=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,aa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,oa=K(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,aa).replace(`tag`,ia).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),sa=K($i).replace(`hr`,qi).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ia).getRegex(),ca={blockquote:K(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,sa).getRegex(),code:Gi,def:na,fences:Ki,heading:Ji,hr:qi,html:oa,lheading:Zi,list:ra,newline:Wi,paragraph:sa,table:Hi,text:ea},la=K(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,qi).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ia).getRegex(),ua={...ca,lheading:Qi,table:la,paragraph:K($i).replace(`hr`,qi).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,la).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ia).getRegex()},da={...ca,html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,aa).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Hi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K($i).replace(`hr`,qi).replace(`heading`,` *#{1,6} *[^
|