lantern-harness 0.2.2 → 0.2.3
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 +27 -0
- package/README.md +7 -7
- package/builtin/case-backup-contract.mjs +27 -0
- package/builtin/case-workflow-contract.mjs +158 -0
- package/builtin/session/lh-nav-groups.mjs +33 -1
- package/builtin/session/space-layout.mjs +8 -1
- package/builtin/session/space-skills.mjs +8 -1
- package/cli/mcp-server.mjs +986 -32
- package/cli/server.mjs +2 -0
- package/dist/500.html +9 -4
- package/dist/_astro/Base.BQf1tZMl.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js → Base.astro_astro_type_script_index_0_lang.Dm3O_y-S.js} +1 -1
- package/dist/_astro/{BusinessMapBoard.mRxl2G3D.js → BusinessMapBoard.CYxHcku_.js} +1 -1
- package/dist/_astro/{CaseExecBoard.Cqkxuf5c.js → CaseExecBoard.CK9aGPmH.js} +1 -1
- package/dist/_astro/CaseExecutionBoard.C94pmIMQ.js +5 -0
- package/dist/_astro/CaseGenerateApp.D5xlk9At.js +10 -0
- package/dist/_astro/CasesLibrary.BHQC955x.js +21 -0
- package/dist/_astro/ChatApp.CIt15w_1.js +1 -0
- package/dist/_astro/ChatApp.d4a9R3YS.js +262 -0
- package/dist/_astro/{DashboardBoard.CAJVE2G4.js → DashboardBoard.qgc1s7pG.js} +1 -1
- package/dist/_astro/{DefectSubmitEntry.BzKXJ-zq.js → DefectSubmitEntry.JI85N1-i.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.apKMbGVf.js → DocsFileBrowser.z5JZ74cy.js} +1 -1
- package/dist/_astro/{DocsPager.DMN9-Tjg.js → DocsPager.Dg765uHW.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.BcoMQeUd.js → KnowledgeLibrary.mkShtVun.js} +1 -1
- package/dist/_astro/{LifeKrTasksBoard.DJU0-QI-.js → LifeKrTasksBoard.DpAwQffE.js} +1 -1
- package/dist/_astro/{LifeKrTodosBoard.GK7KRAO3.js → LifeKrTodosBoard.BIjPiZ8H.js} +1 -1
- package/dist/_astro/{LifeObjectivesBoard.DuKa6Q3k.js → LifeObjectivesBoard.DYwLHPEG.js} +1 -1
- package/dist/_astro/{LifePlanTypeSelect.Cm2lUmnH.js → LifePlanTypeSelect.CYaziESp.js} +1 -1
- package/dist/_astro/{LifeReviewsBoard.BWOOVMtz.js → LifeReviewsBoard.DIxoWBDA.js} +1 -1
- package/dist/_astro/{LifeShared.bY2l01Ha.js → LifeShared.DuFQsMEx.js} +1 -1
- package/dist/_astro/{LifeStagesBoard.CIzxPOJB.js → LifeStagesBoard.DtOri9EW.js} +1 -1
- package/dist/_astro/{LifeYearCycleSelect.BlsyPmmI.js → LifeYearCycleSelect.ByJ9-PGg.js} +1 -1
- package/dist/_astro/{LifeYearPlansBoard.DaA9O08j.js → LifeYearPlansBoard.BQN07wcv.js} +1 -1
- package/dist/_astro/NavLibraries.BO4ezcUc.js +1 -0
- package/dist/_astro/{PluginsPage.B063QIlQ.js → PluginsPage.B1VeDtLx.js} +2 -2
- package/dist/_astro/{PmBugsBoard.Cu-v0Gfd.js → PmBugsBoard.Ddl3kqqt.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.CgRzkP-j.js → PmIterationsBoard.BJN7disI.js} +1 -1
- package/dist/_astro/{PmProjectDetail.DVCEh0Lm.js → PmProjectDetail.D78gWhqk.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.z-bQa98r.js → PmProjectsBoard.Bf8VB3t6.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.CDyNHN2a.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.CyfBI0u_.js → PmRequirementsBoard.DarfGIrL.js} +1 -1
- package/dist/_astro/{PmShared.BQVzwsiz.js → PmShared.TOjBbtV8.js} +1 -1
- package/dist/_astro/{ReportsPage.najSzJeT.js → ReportsPage.BXGduuY3.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.BQb8dHFD.js → ReqAnalysisBoard.WLtIfBg8.js} +1 -1
- package/dist/_astro/{RequirementBreakdownLibrary.Cn6OV6xt.js → RequirementBreakdownLibrary.DMoeTeqX.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.CqKNFVsP.js → RequirementsLibrary.Iv7zOqWe.js} +1 -1
- package/dist/_astro/{SettingsDialog.db3BpFw0.js → SettingsDialog.BvDU9EU6.js} +1 -1
- package/dist/_astro/SlideOverDrawer.CvyB-quk.js +1 -0
- package/dist/_astro/{SpaceSwitcher.DSUVAPOi.js → SpaceSwitcher.D9bBNQBZ.js} +1 -1
- package/dist/_astro/{TableFieldConfig.72AL-8p-.js → TableFieldConfig.DHj25OKN.js} +1 -1
- package/dist/_astro/{TasksBoard.CCDhCSR7.js → TasksBoard.CXmGdylV.js} +1 -1
- package/dist/_astro/TemplatesLibrary.DsL2q-wp.js +1 -0
- package/dist/_astro/{TestReportsLibrary.fWiEyCRx.js → TestReportsLibrary.BBC1TYgP.js} +1 -1
- package/dist/_astro/{TestStatsBoard.BSUBsWSu.js → TestStatsBoard.VXjP4hu6.js} +1 -1
- package/dist/_astro/{TodosBoard.By5YdlUe.js → TodosBoard.-yKgp06M.js} +1 -1
- package/dist/_astro/UiAutoBoard.BD5ZyLHj.js +3 -0
- package/dist/_astro/UiAutoEnvPanel.DrHUOlmH.js +10 -0
- package/dist/_astro/UiAutoGenerationDialog.gypq1zP9.js +12 -0
- package/dist/_astro/UiAutoProjectsPage.Dhzr09E9.js +3 -0
- package/dist/_astro/app-config.BSO5r82v.js +1 -0
- package/dist/_astro/app-version.CkDFkv4s.js +1 -0
- package/dist/_astro/{bash-tools.CS2w8LOb.js → bash-tools.C4DJiRJs.js} +1 -1
- package/dist/_astro/case-fields.C03NY3zC.js +148 -0
- package/dist/_astro/case-gen-run.C4p8uyU3.js +26 -0
- package/dist/_astro/case-prompt.ByLTgz4r.js +2 -0
- package/dist/_astro/{case-review.DFWZkoR9.js → case-review.BodP2jKm.js} +1 -1
- package/dist/_astro/{case-template.Clb7HrDB.js → case-template.CC2eXegU.js} +2 -2
- package/dist/_astro/case-types.BjF1BivA.js +1 -0
- package/dist/_astro/case-workflow-contract.BBQ9bbKL.js +1 -0
- package/dist/_astro/{defect-workbench.CjTb4FDv.js → defect-workbench.DBmohR-y.js} +1 -1
- package/dist/_astro/{hydrate-cache.O4CIma9y.js → hydrate-cache.CMMErx63.js} +1 -1
- package/dist/_astro/{i18n.Cp4so7KR.js → i18n.CEWjL5GX.js} +2 -2
- package/dist/_astro/{open-docs-in-session.BpcAcBSI.js → open-docs-in-session.BoyV6R2A.js} +1 -1
- package/dist/_astro/plugins.ChGmBEkF.js +1 -0
- package/dist/_astro/{project-docs.bB9lQ1Ki.js → project-docs.BRgNjXhG.js} +1 -1
- package/dist/_astro/{req-analysis.C_gARMrB.js → req-analysis.BLvcktvQ.js} +1 -1
- package/dist/_astro/{settings.D02wZj3w.js → settings.BojKNwUC.js} +2 -2
- package/dist/_astro/{spaces-client.BAtG6PkW.js → spaces-client.B28rzu8J.js} +1 -1
- package/dist/_astro/{story-review.DTN91Vl9.js → story-review.dEBWTeOW.js} +1 -1
- package/dist/_astro/{test-points.C7ZgggQT.js → test-points.BuNgdNcU.js} +1 -1
- package/dist/_astro/ui-auto.LUcREUMe.js +1 -0
- package/dist/_astro/{view-prefs.COAKEQtZ.js → view-prefs.CWc5cQ2q.js} +1 -1
- package/dist/business-map/index.html +10 -5
- package/dist/case-exec/index.html +10 -5
- package/dist/case-execution/index.html +10 -5
- package/dist/cases/api/index.html +988 -0
- package/dist/cases/automation/index.html +988 -0
- package/dist/cases/functional/index.html +988 -0
- package/dist/cases/generate/index.html +10 -5
- package/dist/cases/index.html +1 -1
- package/dist/cases/library/index.html +1 -983
- package/dist/cases/other/index.html +988 -0
- package/dist/cases/performance/index.html +988 -0
- package/dist/dashboard/index.html +10 -5
- package/dist/defect-rules/index.html +10 -5
- package/dist/defect-submit/index.html +10 -5
- package/dist/defect-submit/templates/index.html +10 -5
- package/dist/docs/changelog/index.html +88 -58
- package/dist/docs/install/index.html +12 -6
- package/dist/docs/manual/index.html +42 -31
- package/dist/knowledge/index.html +10 -5
- package/dist/life/kr-tasks/index.html +10 -5
- package/dist/life/kr-todos/index.html +10 -5
- package/dist/life/objectives/index.html +10 -5
- package/dist/life/reviews/index.html +10 -5
- package/dist/life/stages/index.html +10 -5
- package/dist/life/year-plans/index.html +10 -5
- package/dist/plugins/index.html +10 -5
- package/dist/pm/bugs/index.html +10 -5
- package/dist/pm/iterations/index.html +10 -5
- package/dist/pm/projects/detail/index.html +10 -5
- package/dist/pm/projects/index.html +10 -5
- package/dist/pm/requirements/index.html +10 -5
- package/dist/reports/index.html +10 -5
- package/dist/requirement-analysis/index.html +10 -5
- package/dist/requirement-breakdowns/index.html +10 -5
- package/dist/requirements/index.html +10 -5
- package/dist/tasks/index.html +10 -5
- package/dist/templates/index.html +10 -5
- package/dist/test-automation/index.html +10 -5
- package/dist/test-automation/projects/index.html +10 -5
- package/dist/test-reports/index.html +10 -5
- package/dist/test-stats/index.html +10 -5
- package/dist/todos/index.html +10 -5
- package/dist/workbench/index.html +10 -5
- package/docs/Codex-MCP/351/233/206/346/210/220.md +97 -53
- package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +7 -1
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +1 -1
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +4 -2
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +43 -36
- package/lh-plugins/case-automation/service.mjs +921 -0
- package/lh-plugins/case-automation/store.mjs +231 -0
- package/lh-plugins/case-automation/tables.mjs +115 -0
- package/lh-plugins/case-automation-prompt.mjs +57 -0
- package/lh-plugins/case-execution/assets.mjs +180 -0
- package/lh-plugins/case-execution/files.mjs +67 -15
- package/lh-plugins/case-execution/plans.mjs +318 -0
- package/lh-plugins/case-execution/service.mjs +80 -13
- package/lh-plugins/case-execution-prompt.mjs +4 -1
- package/lh-plugins/lh-case-automation.mjs +169 -0
- package/lh-plugins/lh-case-design.mjs +456 -0
- package/lh-plugins/lh-case-execution.mjs +53 -1
- package/lh-plugins/lh-case-review.mjs +29 -11
- package/lh-plugins/lh-project-docs.mjs +24 -0
- package/lh-plugins/lh-uiauto.mjs +111 -2
- package/lh-plugins/plugin-prompts.mjs +1 -0
- package/lh-plugins/uiauto-adapters/playwright.mjs +44 -4
- package/lh-plugins/uiauto-adapters/shared.mjs +4 -0
- package/lh-plugins/uiauto-explorer/emit-files.mjs +16 -2
- package/lh-plugins/uiauto-explorer/ir.mjs +3 -0
- package/lh-plugins/uiauto-explorer/merge.mjs +37 -1
- package/lh-plugins/uiauto-explorer/navigation-guard.mjs +255 -0
- package/lh-plugins/uiauto-explorer/runner.mjs +65 -3
- package/lh-plugins/uiauto-explorer/sessions.mjs +29 -1
- package/package.json +1 -1
- package/skills/case-automation-bridge/SKILL.md +27 -0
- package/skills/case-execution/SKILL.md +11 -0
- package/skills/lantern-workflow/SKILL.md +39 -1
- package/dist/_astro/Base.Du_-4L-4.css +0 -1
- package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +0 -5
- package/dist/_astro/CaseGenerateApp.acgnxl79.js +0 -10
- package/dist/_astro/CasesLibrary.zmzOQwdn.js +0 -21
- package/dist/_astro/ChatApp.Ben9LFra.js +0 -1
- package/dist/_astro/ChatApp.DBi6q7Qv.js +0 -262
- package/dist/_astro/NavLibraries.DVR5Ua-S.js +0 -1
- package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +0 -1
- package/dist/_astro/SlideOverDrawer.BMg2tce6.js +0 -1
- package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +0 -1
- package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +0 -3
- package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +0 -10
- package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +0 -12
- package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +0 -3
- package/dist/_astro/app-config.Dvfzl5_N.js +0 -1
- package/dist/_astro/app-version.CNpnKIb9.js +0 -1
- package/dist/_astro/case-fields.CmePqYfh.js +0 -148
- package/dist/_astro/case-gen-run.Cvvdv_kv.js +0 -26
- package/dist/_astro/case-prompt.CZ3vWUju.js +0 -2
- package/dist/_astro/plugins.Db9xoFZb.js +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
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.Dvfzl5_N.js";import{t as s}from"./jsx-runtime.DUg_B_vD.js";import{t as c}from"./ConfirmDialog.DQFd6g2r.js";import{a as ee,o as te,r as ne}from"./plugins.Db9xoFZb.js";import{n as re,t as ie}from"./SelectDropdown.D7IeyHDI.js";import{t as ae}from"./SlideOverDrawer.BMg2tce6.js";import{showToast as l}from"./Toast.BydY-X7T.js";import{h as oe}from"./case-exec.BMNk9OyF.js";import{t as se}from"./DatePicker.BRO_CjVQ.js";import{t as ce}from"./defect-workbench.CjTb4FDv.js";var u=e(t(),1),d=`/__tb_case_run`;function f(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 le(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=f(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 p(e=``,t){let n=await fetch(`${d}${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 m(e){return{method:`POST`,body:JSON.stringify(e)}}async function ue(){try{return(await fetch(`${d}/health?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function de(){return((await p(`/files`)).files||[]).filter(Boolean)}async function fe(e){let t=await p(`/cases?path=${encodeURIComponent(e)}`);if(!t.document)throw Error(`用例文件读取失败`);return t.document}async function pe(e=``){return(await p(`/runs?path=${encodeURIComponent(e)}`)).runs||[]}async function me(e){let t=await p(`/runs/${encodeURIComponent(e)}`);if(!t.run)throw Error(`执行记录不存在`);return t.run}async function he(e){return!!(await p(`/auth/status?url=${encodeURIComponent(e)}`)).exists}async function ge(e){return p(`/auth/start`,m({url:e}))}async function _e(){return p(`/auth/complete`,m({}))}async function ve(){await p(`/auth/cancel`,m({}))}async function ye(e){let t=await p(`/runs`,m(e));if(!t.run)throw Error(`用例执行启动失败`);return t.run}async function be(e){let t=await p(`/runs/${encodeURIComponent(e)}/stop`,m({}));if(!t.run)throw Error(`停止执行失败`);return t.run}async function xe(e,t){let n=await p(`/runs/${encodeURIComponent(e)}/apply`,m(t));if(!n.run)throw Error(`结果写入失败`);return n.run}async function Se(e){let t=await p(`/fields`,m(e));if(!t.applied?.fileHash)throw Error(`字段保存失败`);return{fileHash:t.applied.fileHash,backup:t.applied.backup||``}}function Ce(e,t,n,r){let i=new EventSource(`${d}/runs/${encodeURIComponent(e)}/events?after=${t}`);return i.onmessage=e=>{try{n(JSON.parse(e.data))}catch{}},i.onerror=()=>{i.close(),r()},()=>i.close()}async function we(e){return p(`/stats/sync`,m(e))}var h=s(),Te={通过:`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 Ee(e){return Te[e]||`border-stone-200 bg-stone-50 text-stone-500`}function g(e){return e.trim()?f(e):`未执行`}function De(e){let t=f(e);return t===`不通过`||t===`阻塞`}function Oe(e){try{let t=new URL(e);return[`http:`,`https:`].includes(t.protocol)?t.href:``}catch{return``}}function ke(e,t){return t.length>80||/标题|步骤|预期|条件|实际|备注|内容|说明|描述/.test(e)}function Ae(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.defectUrl]].map(([e,t])=>({name:e,value:t})).filter(e=>e.value)}function je({value:e,onChange:t,onBlur:n,disabled:r,className:i,placeholder:a,ariaLabel:o}){let s=(0,u.useRef)(null),c=(0,u.useCallback)(e=>{e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`},[]);return(0,u.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,h.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 Me(e){return e?.status===`running`}function Ne(e,t,n,r,i,a){return[`用例文件:${e.path}`,`用例编号:${t.no||`未填写`}`,`用例标题:${t.title}`,`模块:${t.module||`未填写`}`,`优先级:${t.priority||`未填写`}`,`目标地址:${a||n?.target.url||`未填写`}`,`执行结论:${r}`,`前置条件:\n${t.precondition||`无`}`,`测试步骤:\n${t.steps||`无`}`,`预期结果:\n${t.expected||`无`}`,`实际结果:\n${i||n?.result?.actualResult||`无`}`,`判定依据:\n${n?.result?.rationale||`人工记录`}`,...n?.result?.blocker?[`阻塞原因:\n${n.result.blocker}`]:[],...n?.result?.unverified?.length?[`未验证项:\n${n.result.unverified.map(e=>`- ${e}`).join(`
|
|
2
|
-
`)}`]:[],...n?.events.some(e=>e.type===`screenshot`)?[`执行证据:\n${n.events.filter(e=>e.type===`screenshot`).map(e=>e.url).filter(Boolean).join(`
|
|
3
|
-
`)}`]:[]].join(`
|
|
4
|
-
|
|
5
|
-
`)}function Pe(){let[e,t]=(0,u.useState)(!1),[s,d]=(0,u.useState)(!0),[p,m]=(0,u.useState)(null),[Te,Pe]=(0,u.useState)([]),[Fe,Ie]=(0,u.useState)(``),[_,Le]=(0,u.useState)(null),[Re,v]=(0,u.useState)([]),[y,ze]=(0,u.useState)(``),[b,Be]=(0,u.useState)(``),[Ve,He]=(0,u.useState)(!1),[Ue,x]=(0,u.useState)(!1),[We,S]=(0,u.useState)(!1),[Ge,C]=(0,u.useState)(!1),[Ke,w]=(0,u.useState)(``),[T,qe]=(0,u.useState)(!1),[E,D]=(0,u.useState)(null),[Je,Ye]=(0,u.useState)(null),[O,k]=(0,u.useState)(`待验证`),[Xe,A]=(0,u.useState)(``),[Ze,j]=(0,u.useState)(``),[Qe,M]=(0,u.useState)(``),[$e,et]=(0,u.useState)({}),[N,P]=(0,u.useState)(`idle`),[tt,nt]=(0,u.useState)(null),[rt,it]=(0,u.useState)(!1),[at,F]=(0,u.useState)(!1),[ot,st]=(0,u.useState)(null),[I,ct]=(0,u.useState)(``),[lt,ut]=(0,u.useState)(()=>new Date().toISOString().slice(0,10)),[L,dt]=(0,u.useState)(null),[ft,pt]=(0,u.useState)(!1),mt=(0,u.useRef)(null),R=(0,u.useRef)(``),ht=(0,u.useRef)({}),z=(0,u.useRef)(new Map),B=(0,u.useRef)(null),V=(0,u.useRef)(Promise.resolve()),gt=(0,u.useRef)(new Set),_t=(0,u.useRef)(``),vt=(0,u.useMemo)(()=>Te.map(e=>({value:e.path,label:e.name,secondary:`${e.caseCount} 条用例 · ${e.executable?`可执行`:e.ext===`.xls`?`需另存为 xlsx`:e.executionIssue||e.error||`不可执行`}`})),[Te]),H=E?_?.cases.find(e=>e.rowIndex===E.rowIndex)||E.case:Je,U=(0,u.useMemo)(()=>H?Ae(H):[],[H]),W=_?.columns.status||``,G=_?.columns.actual||``,K=_?.columns.defectNo||``,yt=_?.columns.defectUrl||`缺陷地址`,bt=_?.columns.expected||``,q=_?.columns.priority||``,xt=(0,u.useMemo)(()=>{let e=new Set([W,G,K,yt,q].filter(Boolean));return U.filter(t=>!e.has(t.name))},[U,G,K,yt,q,W]),St=$e[q]??U.find(e=>e.name===q)?.value??``,Ct=(0,u.useMemo)(()=>new Set([`用例编号`,`需求编号`,`模块`,`子模块`]),[]),J=!!E,wt=!!y.trim(),Tt=!!(Ve||b.trim()),Et=wt&&Tt,Y=E?.status===`running`,Dt=`测试地址:${wt?`已填写`:`未填写`};登录态:${Tt?`已准备`:`未准备`}`,X=(0,u.useMemo)(()=>le(_?.cases||[]),[_?.cases]),Ot=[{label:`总数`,value:X.total,className:`text-stone-900`},{label:`已执行`,value:X.executed,className:`text-[#275fc8]`},{label:`未执行`,value:X.pending,className:`text-stone-700`},{label:`通过`,value:X.passed,className:`text-emerald-600`},{label:`未通过`,value:X.failed,className:`text-red-600`},{label:`阻塞`,value:X.blocked,className:`text-amber-600`},{label:`跳过`,value:X.skipped,className:`text-stone-600`}],kt=(0,u.useCallback)(e=>Re.find(t=>t.rowIndex===e.rowIndex&&t.casePath===_?.path)||null,[_?.path,Re]),At=(0,u.useCallback)(async()=>{let e=await de();Pe(e),Ie(t=>t&&e.some(e=>e.path===t)?t:e.find(e=>e.executable)?.path||e[0]?.path||``)},[]),Z=(0,u.useCallback)(async e=>{if(!e){Le(null),v([]),R.current=``;return}let[t,n]=await Promise.all([fe(e),pe(e)]);Le(t),v(n),R.current=t.fileHash},[]);(0,u.useEffect)(()=>{let e=ee(e=>d(!!e.caseExecution));return o().then(()=>{d(ne(`caseExecution`)),t(!0)}),e},[]),(0,u.useEffect)(()=>{e&&s&&(async()=>{let e=await ue();if(m(e),e)try{await At()}catch(e){w(e instanceof Error?e.message:String(e))}})()},[s,e,At]),(0,u.useEffect)(()=>{Fe&&(w(``),Z(Fe).catch(e=>w(e instanceof Error?e.message:String(e))))},[Z,Fe]),(0,u.useEffect)(()=>{if(!T||!H){T||(_t.current=``);return}let e=`${E?.casePath||_?.path||``}:${H.rowIndex}`;if(_t.current===e)return;_t.current=e;let t=new Set([W,G,K].filter(Boolean)),n=Object.fromEntries(Ae(H).filter(e=>!t.has(e.name)).map(e=>[e.name,e.value]));ht.current=n,et(n),z.current.clear(),B.current!==null&&window.clearTimeout(B.current),B.current=null,P(`idle`)},[H,E?.casePath,G,K,_?.path,T,W]),(0,u.useEffect)(()=>{if(!y.trim()){He(!1);return}let e=window.setTimeout(()=>{he(y).then(He).catch(()=>He(!1))},250);return()=>window.clearTimeout(e)},[y]),(0,u.useEffect)(()=>()=>mt.current?.(),[]);async function jt(){if(!y.trim())x(!0),w(`请先填写测试地址`);else{S(!0),w(``);try{await ge(y.trim()),l(`登录窗口已打开,请完成验证后回到页面保存登录态`)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}}}async function Mt(){S(!0),w(``);try{await _e(),He(!0),l(`登录态已保存`,`success`)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}}async function Nt(){S(!0);try{await ve()}finally{S(!1)}}function Pt(){P(`pending`),B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,$()},650)}function Q(e,t){e&&(z.current.set(e,t),Pt())}function Ft(e,t){let n={...ht.current,[e]:t};ht.current=n,et(n),Q(e,t)}async function $(){if(!_||!H||!z.current.size)return;let e=_.path,t=H.rowIndex,n=[...z.current.entries()].map(([e,t])=>({header:e,value:t}));z.current.clear(),B.current!==null&&(window.clearTimeout(B.current),B.current=null),P(`saving`),V.current=V.current.then(async()=>{try{let r=await Se({casePath:e,expectedFileHash:R.current||_.fileHash,rowIndex:t,updates:n});R.current=r.fileHash,await Z(e),w(``),P(`saved`)}catch(e){P(`error`),w(e instanceof Error?e.message:String(e))}})}function It(e,t){let n=_?.columns.status;if(!_||!n||J)return;let r=_.path;Le(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`),V.current=V.current.then(async()=>{try{let i=await Se({casePath:r,expectedFileHash:R.current||_.fileHash,rowIndex:e.rowIndex,updates:[{header:n,value:t}]});R.current=i.fileHash,await Z(r),P(`saved`),w(``)}catch(e){P(`error`),w(e instanceof Error?e.message:String(e)),await Z(r)}})}async function Lt(e){if(e.result&&!gt.current.has(e.id)&&[`awaiting_confirmation`,`stopped`,`error`].includes(e.status)){gt.current.add(e.id),P(`saving`);try{let t=await xe(e.id,{status:e.result.status,actualResult:e.result.actualResult,defectNo:e.case.defectNo});D(t),v(e=>[t,...e.filter(e=>e.id!==t.id)]),k(t.confirmed?.status||e.result.status),A(t.confirmed?.actualResult||e.result.actualResult),j(e.case.defectNo||``),t.confirmed?.fileHash&&(R.current=t.confirmed.fileHash),await Z(e.casePath),P(`saved`),l(`AI 执行结果已自动保存到用例文件`,`success`)}catch(t){gt.current.delete(e.id),P(`error`),w(t instanceof Error?t.message:String(t))}}}function Rt(e){D(e),qe(!0),mt.current?.(),mt.current=Ce(e.id,e.seq,t=>{D(n=>n&&n.id===e.id?{...n,events:[...n.events,t],seq:Math.max(n.seq,t.seq)}:n)},()=>{me(e.id).then(e=>{D(e),e.result&&(k(e.result.status),A(e.result.actualResult)),v(t=>[e,...t.filter(t=>t.id!==e.id)]),e.result&&Lt(e)})})}async function zt(e){if(!_||!y.trim())x(!0),w(`请先选择用例文件并填写测试地址`);else if(!Ve&&!b.trim())x(!0),w(`请先填写登录态文件路径,或点「打开登录页面」完成手动登录`);else{C(!0),w(``);try{let t=await ye({casePath:_.path,rowIndex:e.rowIndex,url:y.trim(),storageStatePath:b.trim()||void 0});k(`待验证`),A(``),j(``),M(e.defectUrl),Rt(t),v(e=>[t,...e])}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}}}function Bt(e,t=!1){t&&!_?.executable?w(_?.executionIssue||`该用例文件暂不可执行`):(D(null),Ye(e),k(f(e.status)),A(e.actual),j(e.defectNo),M(e.defectUrl),qe(!0))}function Vt(e){Bt(e,!0)}async function Ht(){if(E){pt(!1);try{let e=await be(E.id);D(e),e.result&&(k(e.result.status),A(e.result.actualResult))}catch(e){w(e instanceof Error?e.message:String(e))}}}async function Ut(e=H,t=E,n=O,r=Xe){if(_&&e){it(!0);try{let i=await fetch(`/__tb_defect_submit/templates`),a=await i.json();if(!i.ok)throw Error(a.error||`缺陷规则读取失败`);let o=a.templates||[];if(!o.length)throw Error(`还没有缺陷规则,请先在「缺陷规则」页面创建`);nt({templates:o,context:Ne(_,e,t,n,r||e.actual,y)})}catch(e){l(e instanceof Error?e.message:String(e),`error`)}finally{it(!1)}}}async function Wt(){if(_){C(!0);try{st(await oe()),ct(_.path.split(/[\\/]/).pop()?.split(`_`)[0]||``),dt(null),F(!0)}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}}}async function Gt(){if(_&&I.trim())try{dt(await we({casePath:_.path,project:I.trim(),date:lt,mode:`preview`}))}catch(e){w(e instanceof Error?e.message:String(e))}}async function Kt(e){if(_&&I.trim()){C(!0);try{let t=await we({casePath:_.path,project:I.trim(),date:lt,mode:e});dt(t),l(t.skipped?`已跳过已有统计`:`用例执行统计已同步`,`success`),F(!1)}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}}}return e?s?p===null?(0,h.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-5 py-16 text-center text-sm text-stone-500`,children:`正在连接用例执行服务…`}):p?(0,h.jsxs)(h.Fragment,{children:[(0,h.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,h.jsxs)(`div`,{className:`shrink-0 border-b border-stone-100 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`min-w-[240px] max-w-[460px] flex-1`,children:(0,h.jsx)(ie,{value:Fe,onChange:Ie,options:vt,disabled:J,searchable:!0,searchPlaceholder:`搜索用例文件…`,ariaLabel:`选择用例文件`})}),(0,h.jsxs)(`button`,{type:`button`,onClick:()=>x(e=>!e),"aria-expanded":Ue,"data-hint":Dt,className:`flex h-8 min-w-[136px] flex-1 items-center justify-center gap-2 rounded-lg border border-stone-200 px-3 text-xs font-medium text-stone-700 hover:bg-stone-100 md:max-w-[220px]`,children:[(0,h.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Et?`bg-emerald-500`:`bg-amber-500`}`}),`执行配置`,(0,h.jsx)(`span`,{className:`text-[10px] ${Ue?`rotate-180`:``}`,children:`⌄`})]}),E?(0,h.jsx)(`button`,{type:`button`,onClick:()=>qe(!0),className:`h-8 whitespace-nowrap rounded-lg border px-3 text-xs font-medium ${Me(E)?`border-[#b8cdf7] bg-[#f2f6ff] text-[#275fc8] hover:bg-[#e8f0fe]`:`border-stone-200 text-stone-700 hover:bg-stone-100`}`,children:Me(E)?`查看进度`:`查看结果`}):null,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Wt(),disabled:!_?.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,h.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:[Ot.map(e=>(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 whitespace-nowrap`,"data-hint":e.label===`已执行`?`不包含待验证`:void 0,children:[(0,h.jsx)(`span`,{children:e.label}),(0,h.jsx)(`span`,{className:`font-semibold tabular-nums ${e.className}`,children:e.value})]},e.label)),(0,h.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2 whitespace-nowrap`,children:[(0,h.jsx)(`span`,{children:`执行率`}),(0,h.jsxs)(`span`,{className:`font-semibold tabular-nums text-stone-800`,children:[X.executionRate,`%`]}),(0,h.jsx)(`span`,{className:`h-1.5 w-20 overflow-hidden rounded-full bg-stone-200`,children:(0,h.jsx)(`span`,{className:`block h-full rounded-full bg-[#4176e6] transition-[width] duration-300`,style:{width:`${X.executionRate}%`}})})]})]}),Ue?(0,h.jsxs)(`div`,{className:`mt-2 grid gap-2 md:grid-cols-2`,children:[(0,h.jsx)(`input`,{value:y,onChange:e=>ze(e.target.value),"aria-label":`测试地址`,placeholder:`测试地址:https://业务系统地址`,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6]`}),(0,h.jsx)(`input`,{value:b,onChange:e=>Be(e.target.value),"aria-label":`登录态文件`,placeholder:Ve?`已保存当前地址登录态,可留空`:`登录态文件:/path/to/storageState.json`,className:`h-9 w-full rounded-lg border border-stone-200 px-3 text-sm outline-none focus:border-[#4176e6]`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 md:col-span-2 md:justify-end`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>void jt(),disabled:We||!y.trim(),className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium hover:bg-stone-100 disabled:opacity-40`,children:`打开登录页面`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Mt(),disabled:We,className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium hover:bg-stone-100 disabled:opacity-40`,children:`保存登录态`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Nt(),disabled:We,className:`h-8 whitespace-nowrap rounded-lg border border-stone-200 px-3 text-xs font-medium text-stone-500 hover:bg-stone-100 disabled:opacity-40`,children:`取消`})]})]}):null,_&&!_.executable?(0,h.jsx)(`p`,{className:`mt-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800`,children:_.executionIssue||`该用例文件暂不能执行。`}):null,Ke?(0,h.jsx)(`p`,{className:`mt-2 text-xs text-red-600`,children:Ke}):null]}),(0,h.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,h.jsxs)(`table`,{className:`w-full min-w-[730px] table-fixed text-sm`,children:[(0,h.jsx)(`thead`,{className:`sticky top-0 z-10 bg-stone-50 text-xs text-stone-500`,children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`用例`}),(0,h.jsx)(`th`,{className:`w-[110px] px-3 py-2 text-center font-medium`,children:`执行结果`}),(0,h.jsx)(`th`,{className:`w-[150px] px-3 py-2 text-center font-medium`,children:`缺陷地址`}),(0,h.jsx)(`th`,{className:`w-[230px] px-3 py-2 text-center font-medium`,children:`操作`})]})}),(0,h.jsx)(`tbody`,{children:_?.cases.map(e=>(0,h.jsxs)(`tr`,{tabIndex:J?-1:0,"aria-label":`查看用例:${e.title||`未命名用例`}`,onClick:()=>{J||Bt(e)},onKeyDown:t=>{J||t.target!==t.currentTarget||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Bt(e))},className:`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 ${J?``:`cursor-pointer`}`,children:[(0,h.jsxs)(`td`,{className:`px-3 py-2 align-top`,children:[(0,h.jsx)(re,{text:[e.no?`#${e.no}`:``,e.module||``,e.priority||``].filter(Boolean).join(` · `)||`未编号`,className:`block truncate text-[11px] text-stone-400`}),(0,h.jsx)(re,{text:e.title||`未命名用例`,className:`mt-0.5 block truncate font-medium text-stone-800`}),(0,h.jsx)(re,{text:e.steps||e.expected||`无步骤`,className:`mt-1 block truncate text-[11px] text-stone-400`})]}),(0,h.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:_?.columns.status?(0,h.jsx)(ie,{value:g(e.status),onChange:t=>It(e,t),options:[...g(e.status)===`未执行`?[{value:`未执行`,label:`未执行`}]:[],...(_.statuses||[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`]).map(e=>({value:e,label:e}))],ariaLabel:`选择用例状态:${e.title||`未命名用例`}`,disabled:J,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 ${Ee(g(e.status))} disabled:opacity-50`,renderTrigger:()=>(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[g(e.status),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`text-[9px] opacity-70`,children:`▼`})]})}):(0,h.jsx)(`span`,{className:`inline-flex whitespace-nowrap rounded-full border px-2 py-0.5 text-[11px] ${Ee(g(e.status))}`,children:g(e.status)})}),(0,h.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:Oe(e.defectUrl)?(0,h.jsx)(`a`,{href:Oe(e.defectUrl),target:`_blank`,rel:`noreferrer`,className:`inline-flex max-w-full items-center gap-1 truncate text-xs font-medium text-[#4176e6] hover:underline`,children:`打开缺陷`}):(0,h.jsx)(`span`,{className:`text-xs text-stone-400`,children:`—`})}),(0,h.jsx)(`td`,{className:`px-3 py-2 text-center align-middle`,children:(0,h.jsxs)(`div`,{className:`flex justify-center gap-1.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,h.jsx)(`button`,{type:`button`,disabled:Ge||!_?.executable||J,onClick:()=>void zt(e),className:`h-7 rounded-md bg-[#4176e6] px-2.5 text-xs font-medium text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`AI执行`}),(0,h.jsx)(`button`,{type:`button`,disabled:Ge||!_?.executable||J,onClick:()=>Vt(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:`手动记录`}),De(e.status)?(0,h.jsx)(`button`,{type:`button`,disabled:Ge||rt||J,onClick:()=>{let t=kt(e);Ut(e,t,f(e.status),t?.confirmed?.actualResult||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))})]}),_?.cases.length?null:(0,h.jsx)(`div`,{className:`px-4 py-20 text-center text-sm text-stone-400`,children:`暂无可执行用例`})]})]}),(0,h.jsx)(ae,{open:T,onClose:()=>{$(),qe(!1)},title:E&&E.status===`running`?`AI 正在执行用例`:`用例详情与执行结果`,widthClass:`max-w-3xl`,escDisabled:!1,bodyClassName:`flex flex-col gap-4`,footer:E?.status===`running`?(0,h.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,h.jsx)(`button`,{type:`button`,onClick:()=>pt(!0),className:`mr-auto h-8 rounded-lg border border-red-200 px-3 text-xs font-medium text-red-600 hover:bg-red-50`,children:`停止执行`})}):void 0,children:H?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`rounded-lg bg-stone-50 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-stone-400`,children:[(0,h.jsx)(`span`,{children:H.no?`#${H.no}`:`未编号`}),H.module?(0,h.jsxs)(`span`,{children:[`· `,H.module]}):null,H.priority?(0,h.jsxs)(`span`,{children:[`· `,H.priority]}):null]}),(0,h.jsx)(`div`,{className:`mt-1 text-sm font-semibold text-stone-900`,children:H.title})]}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`字段内容`}),(0,h.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`?`保存失败`:`${U.length} 个字段`})]}),(0,h.jsxs)(`div`,{className:`grid gap-x-4 gap-y-3 md:grid-cols-2`,children:[xt.map((e,t)=>{let n=$e[e.name]??e.value,r=ke(e.name,n);return(0,h.jsxs)(u.Fragment,{children:[(0,h.jsxs)(`label`,{className:`block ${r?`md:col-span-2`:``}`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:e.name}),Ct.has(e.name)?(0,h.jsx)(`input`,{value:n,onChange:t=>Ft(e.name,t.target.value),onBlur:()=>void $(),disabled:Y,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,h.jsx)(je,{value:n,onChange:t=>Ft(e.name,t),onBlur:()=>void $(),disabled:Y,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`})]}),G&&e.name===bt?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:G}),(0,h.jsx)(je,{value:Xe,onChange:e=>{A(e),Q(G,e)},onBlur:()=>void $(),disabled:Y,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,e.name===bt?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:`缺陷地址`}),(0,h.jsx)(`input`,{type:`url`,value:Qe,onChange:e=>{M(e.target.value),Q(yt,e.target.value)},onBlur:()=>void $(),disabled:Y,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:`https://缺陷管理平台/...`})]}):null]},`${e.name}-${t}`)}),G&&!xt.some(e=>e.name===bt)?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:G}),(0,h.jsx)(je,{value:Xe,onChange:e=>{A(e),Q(G,e)},onBlur:()=>void $(),disabled:Y,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,xt.some(e=>e.name===bt)?null:(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-stone-400`,children:`缺陷地址`}),(0,h.jsx)(`input`,{type:`url`,value:Qe,onChange:e=>{M(e.target.value),Q(yt,e.target.value)},onBlur:()=>void $(),disabled:Y,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:`https://缺陷管理平台/...`})]})]})]}),E?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,h.jsx)(`span`,{className:`font-medium text-stone-700`,children:E.progress.label}),(0,h.jsxs)(`span`,{className:`text-stone-400`,children:[E.progress.elapsedSeconds,`s · `,E.progress.toolCount,` 次操作`]})]}),(0,h.jsx)(`div`,{className:`mt-3 max-h-56 space-y-2 overflow-y-auto`,children:E.events.slice(-40).map(e=>(0,h.jsxs)(`div`,{className:`rounded-md bg-stone-50 px-2.5 py-2 text-xs`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`font-medium text-stone-700`,children:e.title}),(0,h.jsx)(`span`,{className:`text-stone-400`,children:e.detail||``})]}),e.url&&e.type===`screenshot`?(0,h.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-block text-[#4176e6]`,children:`查看截图`}):null]},`${e.seq}-${e.type}`))})]}):null,(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`h3`,{className:`text-sm font-medium text-stone-700`,children:`执行信息`}),(0,h.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:E?.status===`running`?`执行完成后可编辑`:`修改后自动保存到文件`})]}),_?.executable?null:(0,h.jsx)(`p`,{className:`rounded-md bg-amber-50 px-2.5 py-2 text-xs text-amber-800`,children:_?.executionIssue||`该文件缺少执行列;其他已有字段仍可编辑,补齐后可记录完整执行结果。`}),(0,h.jsxs)(`div`,{className:`grid gap-x-4 gap-y-3 md:grid-cols-2`,children:[q?(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:q}),(0,h.jsx)(`input`,{value:St,onChange:e=>Ft(q,e.target.value),onBlur:()=>void $(),disabled:Y,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,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:W}),(0,h.jsx)(ie,{value:O,onChange:e=>{k(e),Q(W,e)},ariaLabel:`选择${W}`,disabled:Y,options:(_?.statuses||[`待验证`,`通过`,`不通过`,`阻塞`,`跳过`]).map(e=>({value:e,label:e}))})]}):null,K?(0,h.jsxs)(`label`,{className:`block md:col-span-2`,children:[(0,h.jsxs)(`span`,{className:`mb-1 block text-xs font-medium text-stone-600`,children:[K,`(可选)`]}),(0,h.jsx)(`input`,{value:Ze,onChange:e=>{j(e.target.value),Q(K,e.target.value)},onBlur:()=>void $(),disabled:Y,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]})]}),E?.result?.rationale?(0,h.jsxs)(`div`,{className:`rounded-lg border border-sky-200 bg-sky-50 p-3 text-xs text-sky-800`,children:[(0,h.jsx)(`div`,{className:`font-medium`,children:`AI 判定依据`}),(0,h.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap`,children:E.result.rationale}),E.result.blocker?(0,h.jsxs)(`p`,{className:`mt-1 text-amber-700`,children:[`阻塞原因:`,E.result.blocker]}):null]}):null,E?.status!==`running`&&(O===`不通过`||O===`阻塞`)?(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Ut(),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:O===`阻塞`?`仍要创建缺陷`:`创建缺陷`}):null]}):null}),(0,h.jsxs)(i,{open:!!tt,onClose:()=>nt(null),className:`relative z-110`,children:[(0,h.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,h.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,h.jsxs)(n,{className:`w-full max-w-md rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,h.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`选择缺陷规则`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`选择后将进入缺陷提交工作台,不会自动提交。`}),(0,h.jsx)(`div`,{className:`mt-4 space-y-2`,children:tt?.templates.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>void ce(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,h.jsx)(`span`,{className:`block font-medium text-stone-800`,children:e.name}),(0,h.jsx)(`span`,{className:`mt-0.5 block text-xs text-stone-500`,children:e.config.target.sheetTitle||e.config.target.platform||`缺陷入口`})]},e.id))}),(0,h.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,h.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,h.jsxs)(i,{open:at,onClose:()=>F(!1),className:`relative z-110`,children:[(0,h.jsx)(a,{className:`fixed inset-0 bg-black/30`}),(0,h.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,h.jsxs)(n,{className:`w-full max-w-lg rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,h.jsx)(r,{className:`text-base font-semibold text-stone-900`,children:`同步到用例执行统计`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-stone-500`,children:`同步不会自动覆盖手工统计,覆盖前会再次确认。`}),(0,h.jsxs)(`div`,{className:`mt-4 grid gap-3`,children:[(0,h.jsxs)(`label`,{className:`grid gap-1 text-xs text-stone-600`,children:[`统计项目`,(0,h.jsx)(`input`,{list:`case-execution-stats-projects`,value:I,onChange:e=>ct(e.target.value),className:`h-9 rounded-lg border border-stone-200 px-3 text-sm`,placeholder:`选择或输入项目名称`}),(0,h.jsx)(`datalist`,{id:`case-execution-stats-projects`,children:(ot?.projects||[]).map(e=>(0,h.jsx)(`option`,{value:e},e))})]}),(0,h.jsxs)(`label`,{className:`grid gap-1 text-xs text-stone-600`,children:[`统计日期`,(0,h.jsx)(se,{value:lt,onChange:ut,className:`h-9 rounded-lg border border-stone-200 px-3 text-sm`})]}),L?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 bg-stone-50 p-3 text-sm text-stone-700`,children:[(0,h.jsxs)(`div`,{children:[`总数:`,L.preview.total]}),(0,h.jsxs)(`div`,{children:[`已执行:`,L.preview.executed]}),(0,h.jsxs)(`div`,{children:[`剩余:`,L.preview.pending]}),L.preview.existing?(0,h.jsx)(`div`,{className:`mt-1 text-amber-700`,children:`该日期已有手工统计,不会自动覆盖。`}):null]}):null]}),(0,h.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>F(!1),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-600`,children:`取消`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Gt(),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-700`,children:`预览`}),L?.preview.existing?(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Kt(`skip`),className:`h-8 rounded-lg border border-stone-200 px-3 text-xs text-stone-700`,children:`跳过`}):null,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void Kt(L?.preview.existing?`overwrite`:`skip`),className:`h-8 rounded-lg bg-[#4176e6] px-3 text-xs text-white`,children:`同步`})]})]})})]}),(0,h.jsx)(c,{open:ft,title:`停止用例执行`,message:`停止后可以重新执行,已产生的截图和日志会保留。`,confirmLabel:`停止`,danger:!0,onClose:()=>pt(!1),onConfirm:()=>void Ht()})]}):(0,h.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`用例执行需要本地服务,当前未就绪。`}):(0,h.jsx)(`div`,{className:`rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:te(`caseExecution`)}):(0,h.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-5 py-16 text-center text-sm text-stone-500`,children:`正在读取插件状态…`})}export{Pe as default};
|
|
@@ -1,10 +0,0 @@
|
|
|
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.Dvfzl5_N.js";import{b as r,m as i,p as a,u as o}from"./settings.D02wZj3w.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{_ as u,d,f,g as p,m,p as h,r as g,u as _}from"./case-gen-run.Cvvdv_kv.js";import{a as v}from"./case-fields.CmePqYfh.js";import{_ as y,c as b,f as x,l as S,p as C,r as w,u as T,v as E}from"./project-docs.bB9lQ1Ki.js";import{a as ee,i as te,n as D,o as ne,r as O,s as re,t as ie}from"./case-template.Clb7HrDB.js";import{o as ae}from"./llm.BCYNgppW.js";import{n as k}from"./doc-roots.C-20VD0x.js";import{n as oe,t as se}from"./case-prompt.CZ3vWUju.js";import{t as ce}from"./ExcelFieldTags.CXif3Ilh.js";import{t as le}from"./MultiSelectDropdown.D-rbpivp.js";import{t as ue}from"./SearchableSelect.DXclLMJI.js";var A=e(t(),1),j=s(),de=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function fe(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 pe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function me(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 he(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 ge(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 _e(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function ve(e){let t=p(e).templateFolder;try{let{entries:e}=await b(`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=[...v],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await x(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=te(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await C(`templates`,e.path),r=D(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await C(`templates`,e.path),r=O(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 ye(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await C(`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,A.useState)(null),[r,s]=(0,A.useState)(!1),[x,te]=(0,A.useState)([]),[D,O]=(0,A.useState)(``),[M,N]=(0,A.useState)(`functional`),[P,be]=(0,A.useState)([]),[F,I]=(0,A.useState)(``),[L,xe]=(0,A.useState)(``),[Se,R]=(0,A.useState)(``),[Ce,we]=(0,A.useState)([]),[z,B]=(0,A.useState)([]),[V,H]=(0,A.useState)(`md`),[U,Te]=(0,A.useState)(``),[W,G]=(0,A.useState)(null),[K,Ee]=(0,A.useState)(!1),[De,q]=(0,A.useState)(null),[J,Y]=(0,A.useState)(null),X=(0,A.useRef)(null),Oe=(0,A.useRef)(null),Z=(0,A.useMemo)(()=>P.find(e=>e.id===F)??P[0],[P,F]),Q=M,ke=p(Q).label;(0,A.useEffect)(()=>{n().then(()=>t(o()));let e=a(()=>t(o()));return(async()=>{await d();let e=await w(`requirements`),t=await w(`cases`),n=await w(`templates`),r=await w(`knowledge`);s(e&&t&&n);async function i(e,t,n){let{entries:r}=await b(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),te(e)}catch{}if(r)try{let e=[];await i(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),we(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&&(G(e),N(e.caseType),H(e.outputFormat),O(e.reqPaths[0]??``),e.templateId&&I(e.templateId),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0}))}else if(c){let e=l.sessions.find(e=>e.linkedCasePath===c);if(e)G(e),N(e.caseType),H(e.outputFormat),O(e.reqPaths[0]??``),e.templateId&&I(e.templateId),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({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=u().find(e=>e.casesFolder===n)?.id??u()[0]?.id??`functional`,i=_({title:c.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=m(i.id,{linkedCasePath:c}).sessions.find(e=>e.id===i.id)??null;G(a),N(r),H(t),Y({path:c,count:0})}}})(),e},[]),(0,A.useEffect)(()=>{if(!r)return;let e=!1;return ve(M).then(t=>{e||(be(t),I(e=>e&&t.some(t=>t.id===e)?e:W?.templateId&&t.some(e=>e.id===W.templateId)?W.templateId:t[0]?.id??``))}),()=>{e=!0}},[r,M,W?.templateId]),(0,A.useEffect)(()=>{let e=!0;return se().then(()=>oe(M,p(M).label)).then(({skill:t,content:n})=>{e&&(xe(t.legacyPath),R(n),n.trim()||l(`技能「${t.name}」正文为空,请先到技能页补全`,`error`))}).catch(t=>{e&&(xe(``),R(``),l(t instanceof Error?t.message:String(t),`error`))}),()=>{e=!1}},[M]),(0,A.useEffect)(()=>{Oe.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[W?.messages,K]);function $(e){if(!W)return;let t=m(W.id,e);G(t.sessions.find(e=>e.id===W.id)??W)}async function Ae(){let e=``;if(D)try{let t=await ye(D);e+=`\n### 需求文档:${D}\n${t}\n`}catch{e+=`\n### 需求文档:${D}\n(无法读取正文)\n`}Z?.body?e+=`\n### 用例模板:${Z.title}\n${Z.body}\n`:Z&&(e+=`\n### 用例模板:${Z.title}\n字段:${(Z.headers.length?Z.headers:v).join(`、`)}\n`);for(let t of z)try{let n=await C(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function je(e,t,n,r){let i=p(t.caseType),a=n||t.title||i.label,o=g(a,t.caseType),s=i.casesFolder;try{await S(`cases`,`.`,s)}catch{}let c=`${s}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,l=r.length?r:[...v];return t.outputFormat===`md`?await E(`cases`,c,ne(e,a,l)):t.outputFormat===`csv`?await E(`cases`,c,ee(e,l)):await y(`cases`,c,await re(e,l,i.label)),c}async function Me(){if(!D)return``;let e=pe(D);try{return me(await ye(D))||e}catch{return e}}async function Ne(t,n){if(!e){i(`model`);return}if(!r){q(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let a=await Me(),o=n;o?(m(o.id,{caseType:M,outputFormat:V,reqPaths:D?[D]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:L||void 0,knowledgePaths:z.length?[...z]:void 0}),o={...o,caseType:M,outputFormat:V,reqPaths:D?[D]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:L||void 0,knowledgePaths:z.length?[...z]:void 0}):(o=_({title:a||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:V,reqPaths:D?[D]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:L||void 0,knowledgePaths:z.length?[...z]:void 0}),G(o));let s=await Ae(),c=p(M).label,u=Z?.headers?.length?Z.headers:[...v],d=V===`md`?`最终结果将保存为 Markdown 表格文件`:V===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,f=Se.trim();if(!f){let e=L?`默认技能「${L}」没读到内容,请先在技能页补上`:`默认用例生成技能尚未就绪,请重新打开插件`;q(e),l(e,`error`);return}let h=`${f}
|
|
3
|
-
|
|
4
|
-
【运行时约束】
|
|
5
|
-
- 用例类型:${c}
|
|
6
|
-
- ${d}
|
|
7
|
-
- 需求名称默认可用「${a||`未命名需求`}」
|
|
8
|
-
- 「用例」对象键必须与模板字段完全一致(另可多写「备注」):${u.includes(`备注`)?u.join(`、`):[...u,`备注`].join(`、`)}
|
|
9
|
-
- 「待业务确认 / 待确认」项也要写成用例,在「备注」写「待业务确认:…」,不要只丢进未覆盖说明
|
|
10
|
-
- 仅输出 JSON 对象:{"需求名称":"...","覆盖需求率":0-100,"未覆盖说明":[],"编写说明":"...","用例":[...]},不要其他解释`,g=[{role:`system`,content:h},{role:`user`,content:`${s}\n\n【用户请求】\n${t}`}];if(n&&n.messages.length){g.length=0,g.push({role:`system`,content:h});for(let e of n.messages.slice(-8))(e.role===`user`||e.role===`assistant`)&&g.push({role:e.role,content:e.content});g.push({role:`user`,content:t})}let y=Date.now(),b={role:`user`,content:t,time:y},x={role:`assistant`,content:``,time:y,result:{ok:!1,count:0}},S=[...o.messages||[],b,x],C=o.messages.length>0?o.title:a||t.slice(0,24)||o.title;o={...o,messages:S,title:C},G(o),m(o.id,{messages:S,title:o.title}),Ee(!0),q(null);let w=new AbortController;X.current=w;let T=``;function E(e,t=``){let n=[...S];n[n.length-1]={role:`assistant`,content:t,time:Date.now(),result:e};let r={messages:n,outputFormat:o.outputFormat,caseType:o.caseType};e.ok&&e.path&&(r.linkedCasePath=e.path,e.path&&Y({path:e.path,count:e.count}));let i=m(o.id,r);G(i.sessions.find(e=>e.id===o.id)??null)}try{for await(let t of ae(e,g,w.signal,{thinking:!1}))t.type===`content`&&(T+=t.delta);let t=Date.now()-y,n=fe(T);if(n){let e=Z?.headers?.length?Z.headers:[...v],r=ie(n.cases,e),i=a||o.title||n.docTitle||p(o.caseType).label,s=await je(r,{...o,title:i},i,e),c=he(r,e);m(o.id,{title:i}),E({ok:!0,count:r.length,path:s,durationMs:t,finishedAt:Date.now(),omissions:c})}else{let e=`未能解析出用例 JSON`;q(`${e},可调整关联技能或需求后重试。`),E({ok:!1,count:0,durationMs:t,finishedAt:Date.now(),error:e,omissions:[`输出无法解析,未写入用例文件`]})}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)E({ok:!1,count:0,durationMs:Date.now()-y,finishedAt:Date.now(),error:`已停止`,omissions:[`用户停止生成`]});else{let t=e instanceof Error?e.message:String(e);q(t),E({ok:!1,count:0,durationMs:Date.now()-y,finishedAt:Date.now(),error:t,omissions:[`生成过程中断或失败`]})}}finally{Ee(!1),X.current=null}}async function Pe(){let e=U.trim();e&&!K&&(Te(``),await Ne(e,W??void 0))}let Fe=!!U.trim()&&!K,Ie=x.map(e=>({value:e.path,label:e.path})),Le=P.map(e=>({value:e.id,label:e.title}));return(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 max-w-4xl mx-auto`,children:[r?null:(0,j.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900`,children:`本地文档或技能服务未就绪,无法读写需求 / 模板 / 技能 / 用例库。`}),(0,j.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4 space-y-4`,children:[(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`用例类型`}),(0,j.jsx)(c,{options:u().map(e=>({value:e.id,label:e.label})),value:Q,onChange:e=>{N(e),$({caseType:e})}})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`输出格式`}),(0,j.jsx)(c,{options:de,value:V,onChange:e=>{if(H(e),W?.linkedCasePath){let t=`${W.linkedCasePath.replace(/\.[^.]+$/,``)}${e===`md`?`.md`:e===`csv`?`.csv`:`.xlsx`}`;$({outputFormat:e,linkedCasePath:t}),Y(e=>e?{...e,path:t}:{path:t,count:0})}else $({outputFormat:e})}})]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`需求文档`}),(0,j.jsx)(ue,{options:Ie,value:D,onChange:e=>{O(e),$({reqPaths:e?[e]:[]})},allowEmpty:!1,placeholder:`未选择需求文档`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:[`用例模板`,(0,j.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,ke,` · `,p(Q).templateFolder,`)`]})]}),(0,j.jsx)(ue,{options:Le,value:Z?.id??``,onChange:e=>{I(e),$({templateId:e,templateTitle:P.find(t=>t.id===e)?.title})},allowEmpty:!1,placeholder:Le.length?`搜索并选择模板…`:`暂无「${p(Q).templateFolder}」模板`}),Z?.headers?.length?(0,j.jsx)(ce,{fields:Z.headers}):Z?(0,j.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:`未识别到模板字段`}):null]})]}),(0,j.jsx)(`div`,{children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`引用知识库(可多选)`}),(0,j.jsx)(le,{options:Ce.map(e=>({value:e.path,label:e.path.replace(/\.[^.]+$/,``)})),values:z,onChange:e=>{B(e),$({knowledgePaths:e.length?e:void 0})},placeholder:Ce.length?`选择知识库文档…`:`暂无知识库文档`})]})}),W?.linkedCasePath&&!J?(0,j.jsxs)(`p`,{className:`text-xs text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-md px-3 py-2`,children:[`已关联用例文件:`,k(`cases`),W.linkedCasePath]}):null]}),(0,j.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-[#f8f9fb] flex flex-col h-[min(520px,60vh)]`,children:[(0,j.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-4 py-4 space-y-3`,children:[W?.messages.length?(()=>{let e=[];for(let t of W.messages)if(t.role===`user`)e.push({user:t});else if(t.role===`assistant`){let n=e[e.length-1];n&&!n.assistant?n.assistant=t:e.push({assistant:t})}return e.map((t,n)=>{let r=n===e.length-1,i=K&&r&&!t.assistant?.result?.finishedAt,a=t.assistant?.result;return(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 items-stretch`,children:[(0,j.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-3 min-h-22`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-1.5`,children:`提问`}),(0,j.jsx)(`div`,{className:`text-sm text-stone-800 whitespace-pre-wrap leading-6`,children:t.user?.content||`—`})]}),(0,j.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-3 min-h-22`,children:[(0,j.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-1.5`,children:`生成结果`}),i?(0,j.jsx)(`div`,{className:`text-sm text-[#4176e6]`,children:`生成中…`}):a?(0,j.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsx)(`span`,{className:`inline-flex items-center h-6 px-2 rounded-md text-xs font-medium ${a.ok?`bg-emerald-50 text-emerald-700`:`bg-red-50 text-red-700`}`,children:a.ok?`成功`:`失败`}),(0,j.jsx)(`span`,{className:`text-xs text-stone-500`,children:_e(a.finishedAt??t.assistant?.time)}),(0,j.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`耗时 `,ge(a.durationMs)]})]}),(0,j.jsxs)(`div`,{className:`text-stone-700`,children:[`用例数量:`,(0,j.jsx)(`span`,{className:`font-medium text-stone-900`,children:a.count}),` 条`]}),a.path?(0,j.jsxs)(`button`,{type:`button`,className:`text-xs text-[#4176e6] hover:underline text-left truncate max-w-full`,"data-hint":`本地打开`,onClick:()=>void T(`cases`,a.path).catch(e=>q(e instanceof Error?e.message:String(e))),children:[k(`cases`),a.path]}):null,a.error?(0,j.jsx)(`div`,{className:`text-xs text-red-600`,children:a.error}):null,(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1`,children:`遗漏检测`}),a.omissions&&a.omissions.length>0?(0,j.jsx)(`ul`,{className:`text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-md px-2.5 py-2 space-y-1`,children:a.omissions.map(e=>(0,j.jsxs)(`li`,{children:[`· `,e]},e))}):a.ok?(0,j.jsx)(`div`,{className:`text-xs text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-md px-2.5 py-2`,children:`未发现明显遗漏`}):(0,j.jsx)(`div`,{className:`text-xs text-stone-400`,children:`—`})]})]}):(0,j.jsx)(`div`,{className:`text-sm text-stone-400`,children:`等待结果`})]})]},n)})})():(0,j.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-stone-400 py-16`,children:`选择上下文后,在下方输入需求说明并提交,将创建一条用例会话。`}),(0,j.jsx)(`div`,{ref:Oe})]}),De?(0,j.jsx)(`div`,{className:`shrink-0 mx-4 mb-2 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:De}):null,J?(0,j.jsxs)(`div`,{className:`shrink-0 mx-4 mb-3`,children:[(0,j.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:`生成的用例文件`}),(0,j.jsxs)(`button`,{type:`button`,"data-hint":`点击在本地打开`,onClick:()=>{T(`cases`,J.path).catch(e=>q(e instanceof Error?e.message:String(e)))},onDoubleClick:()=>{T(`cases`,J.path).catch(e=>q(e instanceof Error?e.message:String(e)))},className:`w-full flex items-center gap-3 rounded-lg border border-stone-200 bg-white px-3 py-2.5 text-left hover:border-[#4176e6] hover:bg-[#f5f8ff] transition-colors`,children:[(0,j.jsx)(`span`,{className:`w-9 h-9 rounded-lg bg-emerald-50 text-emerald-700 flex items-center justify-center text-xs font-semibold shrink-0`,children:J.path.split(`.`).pop()?.toUpperCase()||`FILE`}),(0,j.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`span`,{className:`block text-sm text-stone-800 truncate`,children:J.path.split(`/`).pop()}),(0,j.jsxs)(`span`,{className:`block text-[11px] text-stone-400 truncate`,children:[k(`cases`),J.path,J.count>0?` · ${J.count} 条`:``,` · 点击打开`]})]})]})]}):null,(0,j.jsxs)(`div`,{className:`shrink-0 p-3 border-t border-stone-200 bg-white rounded-b-xl`,children:[(0,j.jsxs)(`div`,{className:`rounded-2xl border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/25`,children:[(0,j.jsx)(`textarea`,{value:U,onChange:e=>Te(e.target.value),rows:3,placeholder:e?`描述要生成或修改的用例… Enter 发送,Shift+Enter 换行`:`请先配置模型`,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Pe())},className:`w-full px-4 pt-3 pb-2 text-sm resize-none outline-none bg-transparent`}),(0,j.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-3 pb-2`,children:[e?null:(0,j.jsx)(`button`,{type:`button`,onClick:()=>i(`model`),className:`text-xs text-amber-700 hover:underline`,children:`配置模型`}),K?(0,j.jsx)(`button`,{type:`button`,onClick:()=>X.current?.abort(),className:`h-8 px-3 text-sm rounded-full bg-stone-200 text-stone-700`,children:`停止`}):null,(0,j.jsx)(`button`,{type:`button`,disabled:!Fe,onClick:()=>void Pe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-full hover:bg-[#3565c7] disabled:opacity-40`,children:`提交`})]})]}),W?(0,j.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-stone-400 hover:text-stone-600`,onClick:()=>{G(null),Y(null),q(null);let e=f();h({...e,activeId:``})},children:`开始新的用例会话`}):null]})]})]})}export{M as default};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/case-fields.CmePqYfh.js","_astro/react.Blvh0GOs.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{i as o}from"./app-config.Dvfzl5_N.js";import{b as s,p as c,s as l,u}from"./settings.D02wZj3w.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.DQFd6g2r.js";import{a as p,o as m,r as h}from"./plugins.Db9xoFZb.js";import{n as g,o as _,r as v,s as y}from"./view-prefs.COAKEQtZ.js";import{n as b,t as x}from"./SelectDropdown.D7IeyHDI.js";import{t as S}from"./SlideOverDrawer.BMg2tce6.js";import{m as C}from"./PmShared.BQVzwsiz.js";import{showToast as w}from"./Toast.BydY-X7T.js";import{n as T,t as ee}from"./DocsPager.DMN9-Tjg.js";import{n as te,r as E,t as ne}from"./TableFieldConfig.72AL-8p-.js";import{r as D,t as O}from"./composer-task.DRi5tAJs.js";import{d as k,f as A,h as j,l as M,n as N,o as P,p as F,t as re,v as ie}from"./open-docs-in-session.BpcAcBSI.js";import{i as I,n as ae,o as oe}from"./case-gen-run.Cvvdv_kv.js";import{a as se,i as ce,r as le,t as L}from"./case-fields.CmePqYfh.js";import{c as ue,d as de,f as fe,g as pe,h as R,n as me,o as z,p as he,r as B,u as ge}from"./project-docs.bB9lQ1Ki.js";import{c as _e}from"./case-template.Clb7HrDB.js";import{A as ve,L as V,g as ye}from"./req-analysis.C_gARMrB.js";import{s as be}from"./llm.BCYNgppW.js";import{n as xe}from"./doc-roots.C-20VD0x.js";import{i as Se,n as Ce,r as H,t as we}from"./DocsFileBrowser.apKMbGVf.js";import{A as U,C as Te,D as Ee,E as De,M as Oe,O as ke,S as Ae,T as W,_ as je,a as Me,b as Ne,c as Pe,d as G,f as Fe,g as Ie,h as Le,i as Re,j as ze,k as K,l as Be,m as Ve,n as q,o as J,p as He,r as Ue,s as We,t as Ge,u as Ke,v as qe,w as Je,x as Ye,y as Xe}from"./case-review.DFWZkoR9.js";import{a as Ze,c as Qe,d as $e,i as et,l as tt,n as nt,o as rt,t as Y}from"./ColumnResize.CkE59sGq.js";import{t as it}from"./NamePromptDialog.KPCeXmri.js";import{n as at,t as ot}from"./composer-draft.llpvz3MW.js";var X=e(t(),1),st=`备份列表`;function ct(e){return String(e??``).replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()===st}function lt(e){let t=String(e??``).split(/[/\\]/).pop();return t?/\.bak(?:$|[-_.])/i.test(t):!1}var Z=d(),ut=40,dt=20,ft=`tw.case-backup.page-size.v1`,pt=[{key:`select`,width:ut,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 mt(e=`.`){let{entries:t}=await ue(`cases`,e),n=[];for(let e of t)e.type===`file`?(lt(e.name)||lt(e.path))&&n.push(e):!ct(e.name)&&!ct(e.path)&&n.push(...await mt(e.path));return n}function ht(e){return e===`folder`?`备份列表`:e===`sidecar`?`旁路`:`历史`}function gt(e){if(!Number.isFinite(e))return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}function _t(e){return e==null||!Number.isFinite(e)?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function vt(){let e=[];try{if(await Te()){let t=await Ye();for(let n of t){let t=n.kind===`legacy`?`legacy`:`folder`,r=n.casesPath||(t===`folder`?n.path:``);e.push({id:`${t}:${n.name}:${n.mtime}`,kind:t,name:n.name,path:r||n.path,reviewName:t===`legacy`?n.name:void 0,mtime:n.mtime,size:n.size})}}}catch{}try{let t=await mt(`.`);for(let n of t){let t=typeof n.mtime==`number`?n.mtime:0;e.push({id:`sidecar:${n.path}`,kind:`sidecar`,name:n.name,path:n.path,mtime:t,size:n.size})}}catch{}return e.sort((e,t)=>t.mtime-e.mtime),e}function yt({open:e,onClose:t,onChanged:n}){let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),[d,p]=(0,X.useState)({}),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(``),[x,te]=(0,X.useState)(1),[E,ne]=T(dt,ft),D=tt(`lh:case-backup:cols:v4`,pt),O=$e(`case-backup`),k=(0,X.useCallback)(async()=>{o(!0),u(null);try{let e=await vt();i(e),p(t=>{let n={};for(let r of e)t[r.id]&&(n[r.id]=!0);return n})}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[]);(0,X.useEffect)(()=>{e&&(te(1),k())},[e,k]);let A=Math.max(1,Math.ceil(r.length/E)),j=Math.min(x,A),M=(0,X.useMemo)(()=>r.slice((j-1)*E,j*E),[r,j,E]),N=(0,X.useMemo)(()=>Object.keys(d).filter(e=>d[e]),[d]),P=M.length>0&&M.every(e=>d[e.id]);async function F(e){c(!0),u(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 me(`cases`,e.path);r.length&&await je(r.map(e=>e.reviewName||e.name)),w(e.length===1?`已删除「${e[0].name}」`:`已删除 ${e.length} 个备份`,`success`),await k(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);u(t),w(`删除失败:${t}`,`error`)}finally{c(!1)}}async function re(){let e=m;if(h(null),!e)return;if(e.kind===`one`){await F([e.row]);return}let t=new Map(r.map(e=>[e.id,e])),n=e.ids.map(e=>t.get(e)).filter(Boolean);n.length&&await F(n)}async function ie(e){if(e.kind!==`legacy`)try{await ge(`cases`,e.path)}catch(e){u(e instanceof Error?e.message:String(e))}}function I(e){e.kind!==`legacy`&&(y(``),_(e))}async function ae(e){let t=g;if(!t||t.kind===`legacy`)return;let i=e.trim();if(!i||i===t.name){_(null),y(``);return}let a=de(t.path),o=(a===`.`?i:`${a}/${i}`).toLowerCase(),s=r.find(e=>e.id!==t.id&&e.kind!==`legacy`&&e.path.toLowerCase()===o);if(s)y(`已存在同名文件「${s.name}」,换个名字再试`);else{c(!0),u(null),y(``);try{await R(`cases`,t.path,i),_(null),w(`已重命名为「${i}」`,`success`),await k(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);y(t),w(`重命名失败:${t}`,`error`)}finally{c(!1)}}}let oe=m?.kind===`one`?`删除备份「${m.row.name}」?此操作不可恢复。`:m?.kind===`batch`?`确认删除已选中的 ${m.ids.length} 个备份?此操作不可恢复。`:``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{open:e,onClose:t,title:`备份列表`,closeAriaLabel:`关闭备份列表`,widthClass:`max-w-5xl`,bodyClassName:`flex flex-col gap-3 overflow-hidden`,escDisabled:!!m||g!=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:s||N.length===0,onClick:()=>h({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:s||a,onClick:()=>void k(),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:[`新备份在「用例管理/`,st,`/」(首次备份时自动创建,主列表不展示该文件夹)。历史旁路 .bak* 仍可在此查看。备份不会自动过期,请手动删除。`]}),l?(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:l}):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:r.length}),` 个`]}),a?(0,Z.jsx)(`span`,{children:`加载中…`}):null]}),r.length===0&&!a?(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:O,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:D.tableStyle,children:[(0,Z.jsx)(`colgroup`,{children:pt.map(e=>(0,Z.jsx)(`col`,{style:D.widthOf(e.key)?{width:D.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:`${Ze} relative`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:P,disabled:s||M.length===0,onChange:e=>{let t=e.target.checked;p(e=>{let n={...e};for(let e of M)t?n[e.id]=!0:delete n[e.id];return n})},"aria-label":`全选本页备份`}),(0,Z.jsx)(Y,{...D.resizeProps(`select`)})]}),(0,Z.jsxs)(`th`,{className:rt,style:{"--tw-sticky-left":`${ut}px`},children:[`文件名`,(0,Z.jsx)(Y,{...D.resizeProps(`name`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`类型`,(0,Z.jsx)(Y,{...D.resizeProps(`kind`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`备份时间`,(0,Z.jsx)(Y,{...D.resizeProps(`mtime`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-3 py-2 font-medium whitespace-nowrap`,children:[`大小`,(0,Z.jsx)(Y,{...D.resizeProps(`size`)})]}),(0,Z.jsx)(`th`,{"aria-hidden":`true`}),(0,Z.jsx)(`th`,{className:Qe,children:`操作`})]})}),(0,Z.jsx)(`tbody`,{children:M.map(e=>(0,Z.jsxs)(`tr`,{className:`group border-t border-stone-100 ${e.kind===`legacy`?``:`cursor-pointer`}`,onDoubleClick:()=>{e.kind===`legacy`||s||ie(e)},children:[(0,Z.jsx)(`td`,{className:nt,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!d[e.id],disabled:s,onChange:t=>p(n=>({...n,[e.id]:t.target.checked})),"aria-label":`选择 ${e.name}`})}),(0,Z.jsx)(`td`,{className:`${nt} min-w-0 max-w-0`,style:{"--tw-sticky-left":`${ut}px`},children:(0,Z.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center`,children:[(0,Z.jsx)(b,{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:s,"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)(C,{name:`pencil`,size:12})})})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:ht(e.kind)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:gt(e.mtime)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap tabular-nums`,children:_t(e.size)}),(0,Z.jsx)(`td`,{"aria-hidden":`true`}),(0,Z.jsx)(`td`,{className:et,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:s,onClick:()=>h({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))})]})}),r.length>0?(0,Z.jsx)(ee,{page:j,totalPages:A,pageSize:E,busy:s||a,className:`shrink-0 !px-4 !py-2`,onPage:te,onPageSize:e=>{ne(e),te(1)}}):null]})]}),(0,Z.jsx)(f,{open:!!m,title:m?.kind===`batch`?`批量删除备份`:`删除备份`,message:oe,confirmLabel:`删除`,danger:!0,onClose:()=>h(null),onConfirm:()=>void re()}),(0,Z.jsx)(it,{open:g!=null,title:`重命名备份`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:g?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:v,onClose:()=>{s||(_(null),y(``))},onConfirm:e=>void ae(e)})]})}async function bt(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 xt(e.sourcePath);r=ye(t)}catch{r=[]}return{outlineOrder:t,testPointIds:e.testPoints?.points?.map(e=>e.id)??void 0,idealOrder:r,storySourceRefs:n}}async function xt(t){let n=t.toLowerCase();if(n.endsWith(`.xlsx`)||n.endsWith(`.xls`)){let e=await fe(`requirements`,t);if(e.encoding!==`base64`||!e.contentBase64)throw Error(`无法读取 Excel`);let n=await s(()=>import(`./case-fields.CmePqYfh.js`).then(e=>e.d),__vite__mapDeps([0,1])),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 fe(`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 s(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([2,1,3]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}return(await he(`requirements`,t)).content}async function St(){try{return await ve()}catch{return[]}}function Ct(e,t){let n=le(t).no;return n?e.map((e,t)=>({...e,[n]:String(t+1)})):e}async function wt(e,t={}){let n=await _e(e),r=oe(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=Ct(r,n.headers),o=le(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 Tt(e){let t=await Ie(e.casePath);return{backup:(await K(e.casePath,e.headers,e.rows)).backup||t.backup}}var Et=`__none__`;function Dt({open:e,casePath:t,fileName:o,onClose:s,onDone:c,onError:l}){let[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(Et),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,S]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!e)return;let t=!0;return p(Et),h(null),S(``),y(!1),(async()=>{try{let e=await St();if(!t)return;d(e)}catch{t&&d([])}})(),()=>{t=!1}},[e]);let C=(0,X.useCallback)(async()=>{if(f===Et)return{};let e=u.find(e=>e.id===f);if(!e)return{};try{return await bt(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),S(``),(async()=>{try{let e=await wt(t,await C());n&&h(e)}catch(e){if(!n)return;h(null),S(e instanceof Error?e.message:String(e))}finally{n&&_(!1)}})(),()=>{n=!1}},[e,t,C]);let w=(0,X.useMemo)(()=>[{value:Et,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),S(``);try{await Tt(m),c(`已重排 ${m.total} 条用例(移动 ${m.moved} 行),原文件已备份到「备份列表」`),s()}catch(e){let t=e instanceof Error?e.message:String(e);S(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)(x,{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 Ot=[`all`,...We,`ignored`],kt={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`},At={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 jt(e){return e>=85?`green`:e>=60?`amber`:`red`}function Mt(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 Nt({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)(()=>g(`caseReview.quality.filter`,[...Ot],`all`)),[p,m]=(0,X.useState)(()=>v(`caseReview.quality.search`)),[h,b]=(0,X.useState)({}),[x,S]=(0,X.useState)(!1),[C,w]=(0,X.useState)(()=>g(`caseReview.quality.worstFirst`,[`1`,`0`],`0`)===`1`),T=e=>{f(e),_(`caseReview.quality.filter`,e)},ee=e=>{m(e),y(`caseReview.quality.search`,e)},te=e=>{w(e),_(`caseReview.quality.worstFirst`,e?`1`:`0`)},E=(0,X.useMemo)(()=>{let t=e?.cases??[];return l?.size?t.map(e=>{let t=G(e);return t&&l.has(t)?{...e,fixed:!0}:e}):t},[e,l]),ne=(0,X.useMemo)(()=>E.filter(e=>e.ignored).length,[E]),D=(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`,[A,j]=(0,X.useState)(()=>new Set);(0,X.useEffect)(()=>{j(new Set)},[d]);let M=(0,X.useMemo)(()=>O.filter(e=>!e.ignored&&e.verdict!==`usable`&&!e.fixed),[O]),N=(0,X.useMemo)(()=>M.filter(e=>{let t=G(e);return!!(t&&A.has(t))}),[M,A]),P=M.length>0&&M.every(e=>{let t=G(e);return!!(t&&A.has(t))}),F=N.length?N:M,re=!k||M.length===0,ie=e=>{e&&j(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:[`上次评审:`,Mt(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 ${kt[jt(e.score)]}`,children:e.score}),(0,Z.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:e.modeled?`规则 + 模型`:`仅规则`})]}),We.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 ${kt[J[e].tone]}`,children:D[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 ${At[Ue[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,` = 各维度得分 × 权重求和(不是右侧某个数字); ≥`,` `,Pe.usable,` 可用 · `,Pe.revise,`–`,Pe.usable-1,` 待修改 · < `,Pe.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:P,disabled:!M.length,onChange:()=>{if(P){j(new Set);return}let e=new Set;for(let t of M){let n=G(t);n&&e.add(n)}j(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)(Pt,{active:d===`all`,onClick:()=>T(`all`),children:[`全部 `,E.length-ne]}),We.map(e=>(0,Z.jsxs)(Pt,{active:d===e,onClick:()=>T(e),children:[J[e].label,` `,D[e]]},e)),(0,Z.jsxs)(Pt,{active:d===`ignored`,onClick:()=>T(`ignored`),children:[`忽略`,ne?` ${ne}`:``]})]}),(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:re,onClick:()=>o(F),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&&N.length?` ${N.length}`:k&&M.length?` ${M.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=G(e),r=`${e.no}-${t}`,i=!e.ignored&&e.verdict!==`usable`&&!e.fixed;return(0,Z.jsx)(Ft,{item:e,open:h[r]===!0,onToggle:()=>b(e=>({...e,[r]:!e[r]})),onFix:()=>a(e),onIgnore:()=>s(e),onUnignore:()=>c(e),selectable:k&&i,checked:!!(n&&A.has(n)),onToggleSelect:n?()=>ie(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 Pt({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 Ft({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=Fe(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(Ue).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:[Ue[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:[`[`,Ue[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 It={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 Lt({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)(()=>De(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=Ge[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] ${It[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)(Rt,{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 Rt({item:e,checked:t,onToggle:n}){let[r,i]=(0,X.useState)(!1),a=Me[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] ${It[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)(zt,{label:`归属需求`,value:e.reqAnchor}),(0,Z.jsx)(zt,{label:`前置条件`,value:e.precondition}),(0,Z.jsx)(zt,{label:`步骤`,value:e.steps.map((e,t)=>`${t+1}. ${e}`).join(` `)}),(0,Z.jsx)(zt,{label:`预期`,value:e.expected})]}):null]})}function zt({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 Bt=[`module`,`type`,`priority`],Vt=[{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}],Ht=new Set([`no`,`title`,`filler`]),Ut=[{key:`steps`,label:`测试步骤`},{key:`expected`,label:`预期结果`},{key:`verdict`,label:`规则判定`},{key:`suggestions`,label:`修改建议`}],Wt=`case-review.fields`,Gt=`lh:case-review:cols:v1`;function Kt(e){return e.replace(/\.[A-Za-z0-9]+$/,``).trim().toLowerCase()}function qt({file:e,audit:t,review:n,fileName:r,autoFixedKeys:i}){let a=(0,X.useMemo)(()=>e?.rows??[],[e]),[o,s]=(0,X.useState)(()=>g(`caseReview.table.filter`,[`all`,...We],`all`)),[c,l]=(0,X.useState)(()=>v(`caseReview.table.search`)),u=e=>{s(e),_(`caseReview.table.filter`,e)},d=e=>{l(e),y(`caseReview.table.search`,e)},f=E(Wt,Ut,Ht),p=(0,X.useMemo)(()=>te(Vt,f.isVisible),[f.isVisible]),m=tt(Gt,p),h=$e(`case-review`),x=(0,X.useMemo)(()=>le(e?.headers??[]),[e]),S=(0,X.useMemo)(()=>{let e=new Map,r=new Map;for(let t of n?.cases??[]){let n=G(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[x.no??L.no]??``).trim(),o=String(n[x.title??L.title]??``).trim();return(a?e.get(a):void 0)??(o?r.get(o):void 0)??t?.cases[i]??null})},[a,x,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[x[t]??L[t]]??``),a=r?Kt(r):``,o=Bt.map(i).map(e=>e.trim()).filter(e=>!!e&&(!a||Kt(e)!==a)).join(` · `);return{key:t,no:i(`no`),title:i(`title`),meta:o,steps:i(`steps`),expected:i(`expected`),verdict:n,suggestions:n?Fe(n):[]}}),[a,x,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)(Jt,{active:o===`all`,onClick:()=>u(`all`),children:[`全部 `,w.length]}),We.map(e=>(0,Z.jsxs)(Jt,{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:rt,children:[`用例编号`,(0,Z.jsx)(Y,{...m.resizeProps(`no`)})]}),(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`用例标题`,(0,Z.jsx)(Y,{...m.resizeProps(`title`)})]}),f.isVisible(`steps`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`测试步骤`,(0,Z.jsx)(Y,{...m.resizeProps(`steps`)})]}):null,f.isVisible(`expected`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`预期结果`,(0,Z.jsx)(Y,{...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)(Y,{...m.resizeProps(`verdict`)})]}):null,f.isVisible(`suggestions`)?(0,Z.jsxs)(`th`,{className:`relative px-2.5 py-2 font-medium`,children:[`修改建议`,(0,Z.jsx)(Y,{...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:`${nt} tabular-nums text-stone-600`,children:(0,Z.jsx)(b,{text:e.no||`—`,className:`block truncate`})}),(0,Z.jsxs)(`td`,{className:`px-2.5 py-1.5`,children:[(0,Z.jsx)(b,{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)(b,{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)(b,{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)(b,{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 Jt({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 Yt=`可用工具(只调用这些,不要自己编工具名):
|
|
6
|
-
- case_save_review:提交逐条用例判定(verdict / 五个维度分 / 扣分原因与建议),一次提交整批。
|
|
7
|
-
- case_save_blindspots:提交探测到的场景盲区(四类之一 + 可执行字段),一次提交全部。
|
|
8
|
-
|
|
9
|
-
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,Xt={coverage:`coverage`,steps:`steps`,expected:`expected`,data:`data`,convention:`convention`,需求覆盖:`coverage`,步骤可执行:`steps`,预期可判定:`expected`,数据与边界:`data`,规范完整:`convention`},Zt={nonfunctional:`nonfunctional`,security:`security`,compatibility:`compatibility`,business:`business`,非功能:`nonfunctional`,安全:`security`,兼容:`compatibility`,业务:`business`};function Qt(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 $t(e,t=0){let n=Number(e);return Number.isFinite(n)?Math.min(100,Math.max(0,Math.round(n))):t}function en(e){let t=Q(e,40);return Xt[t]??Xt[t.toLowerCase()]??`expected`}function tn(e){let t=Q(e,40);return Zt[t]??Zt[t.toLowerCase()]??`business`}function nn(e){let t=Q(e,10).toLowerCase();return t===`high`||t===`medium`||t===`low`?t:`medium`}function rn(e){let t=Q(e,4).toUpperCase();return[`P0`,`P1`,`P2`,`P3`].includes(t)?t:`P1`}function an(e){if(!e||typeof e!=`object`)return null;let t=Q(e.reason,1e3);if(!t)return null;let n=e;return{dimension:en(n.dimension),points:$t(n.points,0),reason:t,suggestion:Q(n.suggestion,1e3)}}function on(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 Re)a[e]=$t(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:$t(t.score,0),dimensions:a,deductions:Array.isArray(t.deductions)?t.deductions.map(an).filter(e=>!!e).slice(0,20):[]};return s&&(c.hard=s),c}function sn(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:tn(t.category),severity:nn(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:rn(t.priority),reqAnchor:Q(t.reqAnchor??t.requirement??t.reqRef,200),added:!1,caseNo:``}}var cn=[{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(Re.map(e=>[e,{type:`number`,description:e}])),required:[...Re]},deductions:{type:`array`,items:{type:`object`,properties:{dimension:{type:`string`,enum:[...Re]},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:[...q]},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 ln(e,t,n){let r=Qt(t);if(e===`case_save_review`){let e=(Array.isArray(r.cases)?r.cases:[]).map(on).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(sn).filter(e=>!!e).slice(0,300);return e.length?(n.onBlindspots(e,Q(r.summary,2e3)),JSON.stringify({ok:!0,count:e.length,categories:q.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 un(e){return!!at(e).trim()||D(e).length>0}function dn(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/^\/+/,``)}function fn(e){return/\.(xlsx|xlsm|xls)$/i.test(e)}function pn(e,t,n){return fn(e)?[`${n}. ${t===`fix`?`这个文件是 xlsx(二进制):会话里的文件工具一般写不了它。请不要假装写成功,改成把改好的整行按「文件表头顺序」用 markdown 表格贴出来(第一列是原编号),我直接粘回文件。`:`这个文件是 xlsx(二进制):会话里的文件工具一般写不了它。请不要假装写成功,改成把新增的行按「文件表头顺序」用 markdown 表格贴出来(编号按文件规则续),并标明每条应插在哪个归属需求分组的哪一行之后,我按位置粘进文件,不要默认贴到末尾。`}`,`${n+1}. 如果确实有 bash / python 能直接改 xlsx,也可以直接改,但改完必须把改动行贴出来让我核对。`]:[`${n}. ${t===`fix`?`改动写回原文件(写之前先备份),写完告诉我改了哪些列、改成什么。`:`写回原文件前先备份,写完告诉我加了哪几条、编号是什么。`}`,`${n+1}. 如果当前会话没有可用的文件工具,把${t===`fix`?`改好的整条用例`:`新行`}按文件表头贴给我,我自己粘回去。`]}function mn(e,t){return e.sessions.find(e=>{if(!F(e))return!1;let n=e.caseGen?.linkedCasePath;return!!(n&&dn(n)===t)})}function hn(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(...pn(n,`fix`,5)),o.join(`
|
|
10
|
-
`)}var gn=[`帮我改一下用例文件`,`帮我把下面`];function _n(e){let t=e.trim();return t.length>240&&gn.some(e=>t.startsWith(e))}async function vn(e,t,n){await k().catch(()=>null),await o().catch(()=>null);let r=dn(e),i=j(),a=mn(i,r);if(!a){let e=i.sessions.find(e=>e.id===i.activeId);if(e&&A(e)&&F(e))a=e;else{let e=i.sessions.find(e=>F(e)&&A(e)&&!un(e.id));e?(a=e,i={...i,activeId:e.id}):(i=P(i,{access:l()}),a=i.sessions.find(e=>e.id===i.activeId))}}if(!a)throw Error(`无法创建或定位会话`);i=ie(i,a.id,un),i.activeId!==a.id&&(i={...i,activeId:a.id}),await M(i),a=i.sessions.find(e=>e.id===a.id)??a,_n(at(a.id))&&ot(a.id),O(a.id,{...n,at:Date.now()});try{let e=i.sessions.find(e=>e.id===a.id)??a;sessionStorage.setItem(N(a.id),JSON.stringify({session:e}))}catch{}let s=t||r.split(`/`).pop()||r,c=new URLSearchParams({session:a.id,attachRoot:`cases`,attachPath:r,attachName:s});window.location.href=`/workbench/?${c.toString()}`}async function yn(e){let t=e.name||e.path.split(`/`).pop()||e.path;await vn(e.path,e.name,{id:`case-fix:${dn(e.path)}:${e.verdict.no||e.verdict.title}`,label:`修改用例 ${e.verdict.no||e.verdict.title||t}`,detail:`${e.verdict.verdict===`invalid`?`错误无效`:`待修改`} · ${t}`,body:hn(e)})}function bn(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(...pn(t,`fix`,6)),r.push(`8. 改完在回复里给我一张对照表(编号 / 改前问题 / 改后要点 / 已标待验证);对照表只写在对话里,不要另存成用例管理目录下的新文件。`),r.join(`
|
|
11
|
-
`)}async function xn(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 vn(e.path,e.name,{id:`case-batch-fix:${dn(e.path)}:${e.verdicts.map(e=>e.no||e.title).join(`,`)}`,label:`批量修改用例`,detail:r?`${n} 条 · ${r}${n>3?` 等`:``} · ${t}`:`${n} 条 · ${t}`,body:bn(e)})}function Sn(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=Ge[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(...pn(t,`add`,7)),n.join(`
|
|
12
|
-
`)}async function Cn(e){let t=e.name||e.path.split(`/`).pop()||e.path;await vn(e.path,e.name,{id:`blindspot-writeback:${dn(e.path)}:${e.items.map(e=>e.id).join(`,`)}`,label:`补进 ${e.items.length} 条场景用例`,detail:t,body:Sn(e)})}var wn=new Map,Tn=new Set,En={current:null};function Dn(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=wn.get(e)??Dn(e);wn.set(e,{...n,...t,path:e});for(let e of Tn)e()}function On(e){return Tn.add(e),()=>{Tn.delete(e)}}function kn(e){return e.replace(/\.[^.]+$/,``).replace(/[\s_\-—·()()[\]【】]/g,``).toLowerCase()}function An(e,t){let n=t.split(`/`).pop()??t,r=kn(n);if(!r)return``;let i=``,a=0;for(let t of e){let e=kn(t.title),o=kn(t.sourceTitle||``),s=ae(n,t.title)||ae(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 jn({open:e,path:t,reviewOn:n,blindspotOn:r,onClose:i,onSaved:a}){let[s,l]=(0,X.useState)(()=>g(`caseReview.tab`,[`quality`,`table`,`blindspot`],`quality`)),d=(0,X.useCallback)(e=>{l(e),_(`caseReview.tab`,e)},[]),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(``),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(null),[C,w]=(0,X.useState)(!1),[T,ee]=(0,X.useState)(null),[te,E]=(0,X.useState)(null),[ne,D]=(0,X.useState)(null),[O,k]=(0,X.useState)(null),[A,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(!1),[re,ie]=(0,X.useState)(``),[I,ae]=(0,X.useState)(``),[oe,L]=(0,X.useState)(0),[ue,de]=(0,X.useState)([]),[fe,pe]=(0,X.useState)(0),[R,me]=(0,X.useState)(0),[z,he]=(0,X.useState)([]),[B,ge]=(0,X.useState)(``),[V,ye]=(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),he(e.docs),ge(e.reqId),ye(new Set(e.selected)),E(e.reviewPrompt),D(e.blindspotPrompt),h(e.error),y(e.notice),j(e.reviewRunning),N(e.detectRunning),F(e.completing),ae(e.runLabel),de(e.runLog),pe(e.received),me(e.runTarget),ie(e.progress),L(e.runStartedAt?Math.round((Date.now()-e.runStartedAt)/1e3):0),p(!1)},[]),Ce=(0,X.useCallback)((e,n,r=0)=>{let i=Date.now();ae(e),de([n]),pe(0),L(0),ie(``),me(r),$(t,{runLabel:e,runLog:[n],received:0,progress:``,runTarget:r,runStartedAt:i,error:``})},[t]),H=(0,X.useCallback)(e=>{de(n=>{let r=[...n.slice(-11),e];return $(t,{runLog:r}),r})},[t]),we=(0,X.useCallback)(()=>{ae(``),ie(``),L(0),me(0),$(t,{runLabel:``,progress:``,runTarget:0,runStartedAt:0,reviewRunning:!1,detectRunning:!1,completing:!1})},[t]),De=(0,X.useCallback)(()=>{let e=En.current;e?e.signal.aborted||(e.abort(),H(`已请求停止,正在收尾…`)):H(`当前没有可中断的请求`)},[H]);(0,X.useEffect)(()=>{if(!I)return;let e=Date.now(),t=window.setInterval(()=>{L(Math.round((Date.now()-e)/1e3))},1e3);return()=>window.clearInterval(t)},[I]);let W=(0,X.useMemo)(()=>{let e=z.find(e=>e.id===B);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
|
-
`)},[z,B]);(0,X.useEffect)(()=>(o().then(()=>k(u())).catch(()=>k(u())),c(()=>k(u()))),[]);let je=(0,X.useCallback)(async()=>{if(t){p(!0),h(``),y(``);try{let[e,i]=await Promise.all([n?Te():Promise.resolve(!1),r?Xe():Promise.resolve(!1)]);if(!e&&!i){let e="评审服务没起来:确认已用 `lantern dev` 启动(插件依赖本地中间件)。";h(e),$(t,{error:e})}let a=e||i,[o,s]=await Promise.all([_e(t),a?Ae(t):Promise.resolve({entry:null,stale:!1})]),c=s.entry?.review?{...s.entry,review:ke(s.entry.review,o.rows)}:s.entry;if(c?.review&&s.entry?.review&&a){let e=new Map(s.entry.review.cases.map(e=>[G(e),e.contentFp]));if(c.review.cases.some(t=>{let n=G(t);return!!(t.contentFp&&n&&!e.get(n))}))try{c=await ze(t,{review:c.review})}catch{}}ee(o),x(c),w(s.stale);let l=null,u=null,d=[];if(e&&n&&(l=await Je(),E(l)),i&&r&&(u=await Ne(),D(u)),e||i)try{d=await ve()}catch{d=[]}he(d);let f=An(d,t);ge(f),ye(new Set),$(t,{file:o,entry:c,stale:s.stale,docs:d,reqId:f,selected:[],reviewPrompt:l,blindspotPrompt:u,error:!e&&!i?wn.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]),Me=(0,X.useCallback)(async()=>{if(t)try{let[e,n]=await Promise.all([_e(t),Ae(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=g(`caseReview.tab`,[`quality`,`table`,`blindspot`],`quality`);d((i===`blindspot`?r:i!==`quality`||n)?i:n?`quality`:`blindspot`);let a=wn.get(t);a?.file?(Se(a),Me()):je()},[e,t,je,Me,n,r,d,Se]),(0,X.useEffect)(()=>{if(e&&t)return On(()=>{let e=wn.get(t);e&&Se(e)})},[e,t,Se]),(0,X.useEffect)(()=>{if(B&&z.some(e=>e.id===B))return;let e=An(z,t);e&&(ge(e),$(t,{reqId:e}))},[z,t,B]);let Pe=(0,X.useMemo)(()=>T?.headers.length?T.headers:[...se],[T]),Fe=(0,X.useMemo)(()=>T?.headers.length?ce(le(T.headers)):``,[T]),Ie=(0,X.useMemo)(()=>z.find(e=>e.id===B)?.title??``,[z,B]),Re=(0,X.useMemo)(()=>T?Be(T.rows,W):null,[T,W]),K=b?.review??null,q=b?.blindspot??null,J=(0,X.useCallback)(async(e,n,r,i)=>{if(!O)throw Error(`还没读到模型设置`);let a=En.current??new AbortController;if(En.current=a,i?.aborted||a.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);let o=``;for await(let i of be(O,[{role:`system`,content:`${e}\n\n${Yt}`},{role:`user`,content:n}],a.signal,{tools:cn,runTool:(e,n)=>ln(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}),H(`模型交回 ${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}),H(`模型交回 ${e.length} 条盲区(累计 ${i} 条)`)}})}))i.type===`content`&&(o=`${o}${i.delta}`.slice(-400),ie(o),$(t,{progress:o}))},[O,H,t]),Ue=(0,X.useCallback)((e,t)=>{let n=t.length?t:se;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
|
-
`)},[]),We=(0,X.useCallback)(async()=>{if(!T)return;let e=Be(T.rows,W);if(!T.rows.length){h(`这个文件里没解析到用例行:确认第一行是表头,且有编号与标题列(「测试项目 / 用例名称」这类叫法也认)。`);return}let n=b?.review?ke(b.review,T.rows).cases:[],r=new Map(n.map(e=>[G(e),e]).filter(([e])=>e)),i=Ve(n),o=He(n,T.rows),s=n.length>0&&o.size>0,c=[];T.rows.forEach((t,n)=>{let r=e.cases[n],a=r?G(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=>G(e.cases[t])).filter(Boolean)),d=Be(l,W),f=new AbortController;En.current=f,j(!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} 条已忽略)。取消忽略后再评,或先改文件产生「已修改」。`:`没有待评用例。`;H(e),y(e),$(t,{notice:e});return}let o=async n=>{let o=Oe(e.cases,n,u,r,e.metrics),c=await ze(t,{review:o}),l=``;if(s){let e={usable:0,revise:0,invalid:0};for(let t of o.cases){let n=G(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){H(`没有配置模型,只跑规则判定(${p})`),await o(U(d));return}if(f.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);let c=te?.review?.trim();if(!c)throw Error(`「用例质量评审」技能缺少「评审」段,请先到「插件仓库 → 技能」补全。`);H(`规则体检完成:待评 ${d.cases.length} 条(${p}),按五维拼装技能要求`);let m=Ue(l,T.headers),h=c.replaceAll(`{{cases}}`,`见用户消息里的 ${l.length} 条用例`).replaceAll(`{{requirement}}`,W||`(未挂对照需求)`).replaceAll(`{{template}}`,Pe.join(` / `)).replaceAll(`{{fields}}`,Fe),g=[`## 对照需求`,W||`(未挂对照需求,只按用例自身结构评)`,``,`## 用例字段`,Pe.join(` / `),``,`## 字段对照`,Fe||`(按文件里的实际表头读)`,``,`## 待评审用例(${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(H(`关联技能已就绪,等待模型返回…`),await J(h,g,_,f.signal),f.signal.aborted)throw new DOMException(`Aborted`,`AbortError`);if(!_.cases.length)throw Error(`模型没有提交判定结果,可以重试一次或换成更擅长的模型。`);H(`正在按规则复算分数并落盘…`),await o(Ee(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{j(!1),we(),En.current===f&&(En.current=null)}},[T,W,xe,te,Ue,Pe,Fe,J,t,a,Ce,H,we,b]),Ge=(0,X.useCallback)(async()=>{if(T){N(!0),h(``),$(t,{detectRunning:!0,error:``}),Ce(`探测场景盲区`,`开始对照需求检查 ${T.rows.length} 条用例的盲区`);try{if(!xe)throw Error(`场景探测需要模型,请先在设置里配置。`);let e=ne?.detect?.trim();if(!e)throw Error(`「用例场景补全」技能缺少「探测」段,请先到「插件仓库 → 技能」补全。`);let n=(b?.blindspot?.items??[]).filter(e=>e.added),r=new Set(n.map(e=>Ke(e))),i=e.replaceAll(`{{cases}}`,`见用户消息里的 ${T.rows.length} 条用例`),o=[`## 对照需求`,W||`(未挂对照需求)`,``,`## 字段对照`,Fe||`(按文件里的实际表头读)`,``,`## 已有用例(${T.rows.length} 条)`,Ue(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(H(`上下文:需求${W?`已挂`:`未挂`} · 四类盲区 · ${T.rows.length} 条已有用例${r.size?` · 跳过已写回 ${r.size}`:``}`),await J(i,o,s),!s.items.length)throw Error(`模型没有提交盲区条目,可以重试一次。`);H(`正在去重并落盘探测结果…`);let c=new Map((b?.blindspot?.items??[]).map(e=>[Ke(e),e])),l=new Set,u=[],d=0;for(let e of s.items){let t=Ke(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:B,reqTitle:z.find(e=>e.id===B)?.title??``},items:u,summary:s.summary},p=await ze(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(En.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(),En.current=null}}},[T,xe,ne,W,Fe,Ue,b,B,z,J,t,a,Ce,H,we]),Ye=(0,X.useCallback)(async()=>{if(!q)return;let e=q.items.filter(e=>V.has(e.id)&&!e.added);if(e.length){F(!0),h(``),$(t,{completing:!0,error:``}),Ce(`补全选中条目`,`把 ${e.length} 条盲区补全为完整用例(前置 / 步骤 / 预期)`,e.length);try{if(!xe)throw Error(`补全需要模型,请先在设置里配置。`);let n=ne?.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 J(r,i,o),!o.items.length)throw Error(`模型没有返回补全结果,可以重试一次。`);let s=new Map(o.items.map(e=>[e.id,e])),c=q.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 ze(t,{blindspot:{...q,items:c,summary:o.summary||q.summary}}),u=`已补全 ${o.items.length} 条,确认后可写回用例文件。`;x(l),y(u),$(t,{entry:l,notice:u}),a?.()}catch(e){if(En.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{F(!1),we(),En.current=null}}},[q,V,xe,ne,J,t,a,Ce,we]),Ze=(0,X.useCallback)(()=>{if(!q)return;let e=q.items.filter(e=>V.has(e.id)&&!e.added);if(!e.length)return;h(``);let n=new Set(e.map(e=>e.id));(async()=>{try{let r=q.items.map(e=>n.has(e.id)?{...e,added:!0}:e),i={...q,items:r},o=await ze(t,{blindspot:i});x(o),$(t,{entry:o}),ye(e=>{let r=new Set(e);for(let e of n)r.delete(e);return $(t,{selected:[...r]}),r}),a?.(),await Cn({path:t,name:t.split(`/`).pop()??t,items:e,requirementTitle:Ie})}catch(e){h(e instanceof Error?e.message:String(e))}})()},[q,V,t,Ie,a]),Qe=(0,X.useCallback)(e=>{ye(n=>{let r=new Set(n);return r.has(e)?r.delete(e):r.add(e),$(t,{selected:[...r]}),r})},[t]),$e=(0,X.useCallback)((e,n)=>{ye(r=>{let i=new Set(r);for(let t of e)n?i.add(t):i.delete(t);return $(t,{selected:[...i]}),i})},[t]),et=(0,X.useMemo)(()=>K&&T?He(K.cases,T.rows):new Set,[K,T]),tt=(0,X.useCallback)(e=>{let n=G(e);e.ignored||e.fixed||n&&et.has(n)||(h(``),yn({path:t,name:t.split(`/`).pop()??t,verdict:e,requirementTitle:Ie}).catch(e=>h(e instanceof Error?e.message:String(e))))},[t,Ie,et]),nt=(0,X.useCallback)(e=>{let n=e.filter(e=>{let t=G(e);return!e.ignored&&!e.fixed&&!(t&&et.has(t))&&e.verdict!==`usable`});n.length&&(h(``),xn({path:t,name:t.split(`/`).pop()??t,verdicts:n,requirementTitle:Ie}).catch(e=>h(e instanceof Error?e.message:String(e))))},[t,Ie,et]),rt=(0,X.useCallback)(async(e,n)=>{if(!K||!e.length)return;let r=new Set(e.map(e=>G(e)).filter(Boolean));if(!r.size)return;let i=K.cases.map(e=>{if(!r.has(G(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 ze(t,{review:{...K,cases:i,counts:o}});x(s),$(t,{entry:s}),a?.()},[K,t,a]),Y=(0,X.useCallback)(e=>{e.ignored||e.verdict===`usable`||(h(``),rt([e],!0).catch(e=>h(e instanceof Error?e.message:String(e))))},[rt]),it=(0,X.useCallback)(e=>{e.ignored&&(h(``),rt([e],!1).catch(e=>h(e instanceof Error?e.message:String(e))))},[rt]),at=K?Le(K.cases,et):0,ot=q?q.items.filter(e=>!e.added).length:0,st=[{key:`quality`,label:`质量评审${K?` · 需改 ${at}`:``}`},{key:`table`,label:`用例表格${T?` ${T.rows.length}`:``}`},{key:`blindspot`,label:`场景补全${ot?` ${ot}`:``}`}],ct=t.split(`/`).pop()??t;return(0,Z.jsxs)(S,{open:e,onClose:i,title:`用例评审 · ${ct}`,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:st.map(e=>{let t=e.key===`quality`&&!n||e.key===`blindspot`&&!r;return(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>d(e.key),className:`h-7 rounded-md px-2.5 text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${s===e.key?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:e.label},e.key)})}),Ie?(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-stone-400`,children:[`已挂:`,Ie]}):(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-amber-700`,children:`未匹配到需求(覆盖率不计)`})]}),I?(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:[I,`中…`]}),(0,Z.jsxs)(`span`,{className:`tabular-nums text-stone-500`,children:[oe,`s`]}),fe?(0,Z.jsxs)(`span`,{className:`text-stone-500`,children:[`已收到 `,fe,` 条`,R?` / ${R}`:``]}):null]}),(0,Z.jsx)(`div`,{className:`tw-run-track mt-2`,role:`progressbar`,"aria-label":`${I}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":R>0?Math.round(Math.min(fe,R)/R*100):void 0,children:R>0?(0,Z.jsx)(`div`,{className:`tw-run-fill`,style:{width:`${Math.round(Math.min(fe,R)/R*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}`)),re?(0,Z.jsx)(`div`,{className:`line-clamp-2 text-[10px] leading-4 text-stone-500`,children:re}):null]})]}):null,C?(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,v?(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:v}):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}):s===`quality`?(0,Z.jsx)(Nt,{review:K,running:A,modelReady:xe,onRun:We,onStop:De,onFix:tt,onFixBatch:nt,onIgnore:Y,onUnignore:it,autoFixedKeys:et,onExport:()=>qe(ct,K,q)}):s===`table`?(0,Z.jsx)(qt,{file:T,audit:Re,review:K,fileName:ct,autoFixedKeys:et}):(0,Z.jsx)(Lt,{report:q,loading:f,running:M,completing:P,modelReady:xe,onStop:De,selected:V,onToggle:Qe,onToggleCategory:$e,onDetect:Ge,onComplete:Ye,onWriteback:Ze,onExport:()=>qe(ct,K,q)})]})}var Mn=10,Nn=new Set([`.xlsx`,`.xls`,`.csv`,`.md`]),Pn=`.xlsx,.xls,.csv,.md,text/csv,text/markdown,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`;function Fn(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function In(e){return Nn.has(Fn(e))}function Ln(e){let t=e.split(/[/\\]/).pop()||e;return!!(z(t)||lt(t)||t.startsWith(`~$`)||t.endsWith(`~`))}async function Rn(e=`.`){let{entries:t}=await ue(`cases`,e),n=[];for(let e of t)e.type===`file`?!Ln(e.path)&&!Ln(e.name)&&n.push(e):!ct(e.name)&&!ct(e.path)&&n.push(...await Rn(e.path));return n}function zn(){let e=H(`cases`),[t,n]=(0,X.useState)(!1),[r,i]=(0,X.useState)(!0),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)({}),[b,x]=(0,X.useState)(()=>v(`caseReview.path`)),[S,T]=(0,X.useState)(()=>!!v(`caseReview.path`)&&g(`caseReview.open`,[`0`,`1`],`0`)===`1`),[ee,te]=(0,X.useState)(e?!0:null),[E,ne]=(0,X.useState)(()=>e??[]),[D,O]=(0,X.useState)({}),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(null),[ie,I]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(0),[se,ce]=(0,X.useState)(null),[le,L]=(0,X.useState)(``),[ue,fe]=(0,X.useState)(null),[z,he]=(0,X.useState)(null),[_e,ve]=(0,X.useState)(``),[V,ye]=(0,X.useState)(null),be=(0,X.useRef)(null),U=Ce(E,Mn,`cases`),Te=(0,X.useCallback)(async()=>{try{let e=await vt();oe(e.length)}catch{oe(0)}},[]),Ee=(0,X.useCallback)(async()=>{j(null);let e=await Rn(`.`);ne(e),Se(`cases`,e),O(t=>{let n={};for(let r of e)t[r.path]&&(n[r.path]=!0);return n}),Te()},[Te]);(0,X.useEffect)(()=>{let e=p(e=>{i(!!e.cases),s(!!e.caseReview),l(!!e.caseBlindspot)});return o().then(()=>{i(h(`cases`)),s(h(`caseReview`)),l(h(`caseBlindspot`)),n(!0)}),e},[]);let De=(0,X.useCallback)(async()=>{if(!a&&!c)d({});else try{let e=await W();d(Object.fromEntries(e.map(e=>[e.path,e])))}catch{d({})}},[a,c]);(0,X.useEffect)(()=>{t&&r&&ee!==!1&&De()},[t,r,ee,De]),(0,X.useEffect)(()=>{t&&r&&(async()=>{if(!await B(`cases`))te(!1);else try{await k().catch(()=>null),await Ee(),te(!0)}catch(e){j(e instanceof Error?e.message:String(e)),te(!0)}})()},[t,r,Ee]);let Oe=(0,X.useMemo)(()=>Object.keys(D).filter(e=>D[e]),[D]);async function ke(){let e=P;if(e){F(null),N(!0),j(null);try{if(e.kind===`one`)await me(`cases`,e.entry.path);else{for(let t of e.paths)await me(`cases`,t);O({})}await Ee(),w(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个用例文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),w(`删除失败:${t}`,`error`)}finally{N(!1)}}}let je=P?.kind===`one`?`删除「${P.entry.name}」?将从 ${xe(`cases`)} 中移除。`:P?.kind===`batch`?`确认删除已选中的 ${P.paths.length} 个用例文件?此操作不可恢复。`:``;function Me(){h(`caseGen`)?window.location.href=`/workbench/?plugin=caseGen`:j(m(`caseGen`))}async function Ne(e){N(!0),j(null);try{await re(`cases`,e)}catch(e){j(e instanceof Error?e.message:String(e)),N(!1)}}function Pe(e){L(``),ce(e)}function G(e){ve(``),he(e)}let Fe=(0,X.useCallback)((e,t,n=``)=>{let r=(e===`.`?t:`${e}/${t}`).toLowerCase(),i=E.find(e=>e.path.toLowerCase()===r&&e.path.toLowerCase()!==n.toLowerCase());return i?i.name:``},[E]);async function Le(e){let t=z;if(!t)return;let n=e.trim();if(!n||n===t.name){he(null),ve(``);return}let r=Fe(de(t.path),n,t.path);if(r)ve(`已存在同名文件「${r}」,换个名字再试`);else{N(!0),j(null),ve(``);try{let e=await R(`cases`,t.path,n);if(e!==t.path&&(a||c))try{let{entry:n}=await Ae(t.path);(n?.review||n?.blindspot)&&(await ze(e,{review:n.review??null,blindspot:n.blindspot??null}),await ze(t.path,{review:null,blindspot:null}))}catch{}b===t.path&&(x(e),y(`caseReview.path`,e)),he(null),await Ee(),De(),w(`已重命名为「${n}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);ve(t),w(`重命名失败:${t}`,`error`)}finally{N(!1)}}}async function Re(e){let t=se;if(t){N(!0),j(null),L(``);try{let{name:n}=await Ie(t.path,e);ce(null),w(`已备份到备份列表:${n}`,`success`),await Te()}catch(e){let t=e instanceof Error?e.message:String(e);L(t),w(`备份失败:${t}`,`error`)}finally{N(!1)}}}async function K(e){let t=typeof e==`string`?e:e.path;j(null);try{await ge(`cases`,t)}catch(e){j(e instanceof Error?e.message:String(e))}}function Be(e){let t=new Set(E.filter(e=>de(e.path)===`.`).map(e=>e.name.toLowerCase())),n=[],r=new Set;for(let i of e){let e=i.name.toLowerCase();t.has(e)&&!r.has(e)&&(n.push(i.name),r.add(e))}return n}async function Ve(e){if(e.length){N(!0),j(null);try{for(let t of e)await pe(`cases`,`.`,t);await Ee(),w(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),w(`上传失败:${t}`,`error`)}finally{N(!1),ye(null),be.current&&(be.current.value=``)}}}function q(e){if(!e?.length)return;let t=Array.from(e),n=t.filter(e=>In(e.name)),r=t.filter(e=>!In(e.name));r.length&&w(`已跳过 ${r.length} 个不支持的格式(仅 .xlsx / .xls / .csv / .md)`,`error`),n.length?Be(n).length?ye(n):Ve(n):be.current&&(be.current.value=``)}return t?r?ee===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`})})}):ee?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,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.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[U.query.trim()?(0,Z.jsxs)(Z.Fragment,{children:[`匹配 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:U.filtered.length}),` 个`,(0,Z.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,E.length]})]}):(0,Z.jsxs)(Z.Fragment,{children:[`共 `,(0,Z.jsx)(`span`,{className:`font-medium text-stone-800`,children:E.length}),` 个文件`]}),Oe.length>0?(0,Z.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,Oe.length]}):null]}),(0,Z.jsx)(`input`,{ref:be,type:`file`,multiple:!0,accept:Pn,className:`hidden`,onChange:e=>q(e.target.files)}),(0,Z.jsxs)(`button`,{type:`button`,disabled:M,onClick:()=>I(!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:[`备份列表`,ae>0?`(${ae>99?`99+`:ae})`:``]}),(0,Z.jsx)(`button`,{type:`button`,disabled:M||Oe.length===0,onClick:()=>F({kind:`batch`,paths:Oe}),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:M,onClick:()=>be.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`,children:`上传用例`}),(0,Z.jsx)(`button`,{type:`button`,disabled:M,onClick:Me,className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`生成用例`})]}),A?(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:A}):null,(0,Z.jsx)(we,{files:E,filtered:U.filtered,pageFiles:U.pageFiles,query:U.query,onQuery:U.setQuery,sortBy:U.sortBy,onSortBy:U.setSortBy,page:U.page,totalPages:U.totalPages,pageSize:U.pageSize,onPage:U.setPage,onPageSize:U.setPageSize,busy:M,emptyText:`暂无用例文件,可「上传用例」导入本地文件,或点「生成用例」前往工作台。`,searchPlaceholder:`搜索文件名或路径…`,resizeKey:`docs:cases:cols:v1`,extraColumn:a||c?{header:`评审`,render:e=>{let t=u[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:D,onToggleRow:e=>O(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>O(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void K(e),renderNameAction:e=>(0,Z.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>G(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)(C,{name:`pencil`,size:12})}),renderActions:e=>(0,Z.jsxs)(Z.Fragment,{children:[a||c?(0,Z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>{x(e.path),T(!0),y(`caseReview.path`,e.path),_(`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:M,onClick:()=>Pe(e),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:M,onClick:()=>fe(e),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:M,onClick:()=>void Ne(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,Z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>F({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,Z.jsx)(f,{open:P!=null,title:P?.kind===`batch`?`批量删除`:`删除用例文件`,message:je,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>F(null),onConfirm:()=>void ke()}),(0,Z.jsx)(f,{open:V!=null,title:`覆盖同名文件`,message:V?`以下文件已存在于用例管理根目录,继续将覆盖:${Be(V).join(`、`)}。是否继续?`:``,confirmLabel:`覆盖上传`,cancelLabel:`取消`,danger:!0,onClose:()=>{M||(ye(null),be.current&&(be.current.value=``))},onConfirm:()=>{let e=V;e&&Ve(e)}}),(0,Z.jsx)(it,{open:se!=null,title:`备份用例`,label:`备份文件名`,placeholder:`请输入备份文件名`,initialValue:se?.name??``,lockExtension:!0,confirmLabel:`备份`,cancelLabel:`取消`,error:le,onClose:()=>{M||(ce(null),L(``))},onConfirm:e=>void Re(e)}),(0,Z.jsx)(it,{open:z!=null,title:`重命名用例`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:z?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:_e,onClose:()=>{M||(he(null),ve(``))},onConfirm:e=>void Le(e)}),(0,Z.jsx)(Dt,{open:ue!=null,casePath:ue?.path??``,fileName:ue?.name??``,onClose:()=>fe(null),onDone:e=>{w(e,`success`),Ee(),De()},onError:e=>w(e,`error`)}),(0,Z.jsx)(jn,{open:S&&!!b,path:b,reviewOn:a,blindspotOn:c,onClose:()=>{T(!1),_(`caseReview.open`,`0`),De()},onSaved:()=>void De()}),(0,Z.jsx)(yt,{open:ie,onClose:()=>I(!1),onChanged:()=>void Ee()})]}):(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:m(`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{zn as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./ChatApp.DBi6q7Qv.js";
|