lantern-harness 0.1.34 → 0.1.35
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 +23 -0
- package/README.md +2 -2
- package/builtin/session/lh-nav-groups.mjs +9 -0
- package/cli/server.mjs +2 -0
- package/config/app.defaults.json +2 -1
- package/dist/500.html +72 -9
- package/dist/_astro/Base.DjXU-4S_.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.CuCwv2e7.js → Base.astro_astro_type_script_index_0_lang.CiZNg228.js} +1 -1
- package/dist/_astro/{CaseExecBoard.CTVdi8MV.js → CaseExecBoard.DzNtPCwr.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.BONj-skB.js → CaseGenerateApp.BvRwwxhs.js} +1 -1
- package/dist/_astro/{CasesLibrary.e6nFqhN3.js → CasesLibrary.B9I31b7C.js} +1 -1
- package/dist/_astro/{ChatApp.XcaVtt7c.js → ChatApp.79JSgx7d.js} +2 -2
- package/dist/_astro/ColumnResize.CkE59sGq.js +1 -0
- package/dist/_astro/{DashboardBoard.BaJyXPXA.js → DashboardBoard.BuyuI8WW.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.D2Cff2LP.js → DocsFileBrowser.9WTBumS5.js} +1 -1
- package/dist/_astro/{DocsPager.CnXEnQqa.js → DocsPager.BS20yicJ.js} +1 -1
- package/dist/_astro/{DrawerField.C0MkN-LW.js → DrawerField.CiHAvXHQ.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.CWxIHa8I.js → KnowledgeLibrary.CQ8ULHI5.js} +1 -1
- package/dist/_astro/LifeKrTasksBoard.BWoB442i.js +1 -0
- package/dist/_astro/LifeKrTodosBoard.rDbG9XcJ.js +1 -0
- package/dist/_astro/LifeObjectivesBoard.DUDQg_RD.js +1 -0
- package/dist/_astro/LifePlanTypeSelect.BtXnXOkz.js +1 -0
- package/dist/_astro/LifeReviewsBoard.p-dp_NXl.js +5 -0
- package/dist/_astro/LifeShared.Di9sdb_T.js +3 -0
- package/dist/_astro/LifeStagesBoard.BSvhzmp_.js +1 -0
- package/dist/_astro/LifeYearCycleSelect.Q4VvLY8X.js +1 -0
- package/dist/_astro/LifeYearPlansBoard.CYN2gZKp.js +1 -0
- package/dist/_astro/MultiSelectDropdown.y8JMbCxO.js +1 -0
- package/dist/_astro/{NavLibraries.CZlA6Z1w.js → NavLibraries.D9EKoN80.js} +1 -1
- package/dist/_astro/{PluginsPage.DOGWQcVc.js → PluginsPage.DE3qbeY5.js} +1 -1
- package/dist/_astro/PluginsPage.r98lZChB.js +1 -0
- package/dist/_astro/{PmBugsBoard.ChL0RBVn.js → PmBugsBoard.Cu1uf0TC.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.hTKVnMgh.js → PmIterationsBoard.RzRKkAH0.js} +1 -1
- package/dist/_astro/{PmProjectDetail.Saj76lNM.js → PmProjectDetail.DH8Z3nHb.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.CCtClGM1.js → PmProjectsBoard.Dokaj4V1.js} +1 -1
- package/dist/_astro/{PmRequirementsBoard.DGXYC1Te.js → PmRequirementsBoard.DET5YIVX.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.i203nmYC.js +1 -0
- package/dist/_astro/{PmShared.BuhrL7Gb.js → PmShared.BJpoEYvk.js} +1 -1
- package/dist/_astro/{PromptsLibrary.C9F9RVpz.js → PromptsLibrary.Dp1S_lHQ.js} +1 -1
- package/dist/_astro/{ReportsPage.BjD8w0zS.js → ReportsPage.C8uufWVb.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.JfmIK2Bb.js → ReqAnalysisBoard.B3bhMWmE.js} +1 -1
- package/dist/_astro/{RequirementsLibrary.WxAFCP3X.js → RequirementsLibrary.BnY7_YXU.js} +1 -1
- package/dist/_astro/{SearchableSelect.D3ODywC4.js → SearchableSelect.5SfNLwNW.js} +1 -1
- package/dist/_astro/SelectDropdown.TgxIOKMD.js +1 -0
- package/dist/_astro/{SettingsDialog.BpKHIbID.js → SettingsDialog.BzGBZlo2.js} +1 -1
- package/dist/_astro/{SpaceSwitcher.BCZbiL7o.js → SpaceSwitcher.Cy4UrzbH.js} +1 -1
- package/dist/_astro/TasksBoard.CWkx5cD1.js +1 -0
- package/dist/_astro/{TemplatesLibrary.y_RtSjYC.js → TemplatesLibrary.phzK5kho.js} +1 -1
- package/dist/_astro/{TestStatsBoard.C3vkF9vc.js → TestStatsBoard.Dp1TWEf7.js} +1 -1
- package/dist/_astro/TodosBoard.Bkuw_LDW.js +1 -0
- package/dist/_astro/{UiAutoBoard._og5jRon.js → UiAutoBoard.Cpb_EF46.js} +1 -1
- package/dist/_astro/app-config.C4rpn1Ix.js +1 -0
- package/dist/_astro/app-version.CXqYg1a3.js +1 -0
- package/dist/_astro/{bash-tools.cciCC33C.js → bash-tools.RQcI4_42.js} +1 -1
- package/dist/_astro/{case-gen-run.BSJ0o4Zq.js → case-gen-run.CH0ldlsU.js} +1 -1
- package/dist/_astro/{case-types.CJ5PHz59.js → case-types.CprZTsyX.js} +1 -1
- package/dist/_astro/{hydrate-cache.B7--LFB_.js → hydrate-cache.DI6vqM0o.js} +1 -1
- package/dist/_astro/i18n.BJeTr39S.js +7 -0
- package/dist/_astro/{open-docs-in-session.DQ2_5fkC.js → open-docs-in-session.BdihMTEh.js} +1 -1
- package/dist/_astro/plugins.C0NrHGZv.js +1 -0
- package/dist/_astro/{req-analysis.D-dTIxXF.js → req-analysis.CjhgP3jI.js} +1 -1
- package/dist/_astro/{settings.Cu00if4D.js → settings.NTeTjmxg.js} +2 -2
- package/dist/_astro/{spaces-client.Czm-VPh5.js → spaces-client.CMGNsQJ-.js} +1 -1
- package/dist/_astro/{story-review.CvXvtZ90.js → story-review.BBfB1qYF.js} +1 -1
- package/dist/_astro/tasks.DefXqRfI.js +1 -0
- package/dist/_astro/{view-prefs.SdItxolG.js → view-prefs.8MPl3A7e.js} +1 -1
- package/dist/case-exec/index.html +141 -15
- package/dist/cases/generate/index.html +73 -10
- package/dist/cases/library/index.html +141 -15
- package/dist/dashboard/index.html +141 -15
- package/dist/docs/changelog/index.html +129 -45
- package/dist/docs/install/index.html +77 -9
- package/dist/docs/manual/index.html +137 -14
- package/dist/knowledge/index.html +141 -15
- package/dist/life/kr-tasks/index.html +921 -0
- package/dist/life/kr-todos/index.html +921 -0
- package/dist/life/objectives/index.html +921 -0
- package/dist/life/reviews/index.html +921 -0
- package/dist/life/stages/index.html +921 -0
- package/dist/life/year-plans/index.html +921 -0
- package/dist/plugins/index.html +73 -10
- package/dist/pm/bugs/index.html +141 -15
- package/dist/pm/iterations/index.html +141 -15
- package/dist/pm/projects/detail/index.html +141 -15
- package/dist/pm/projects/index.html +141 -15
- package/dist/pm/requirements/index.html +141 -15
- package/dist/prompts/index.html +141 -15
- package/dist/reports/index.html +141 -15
- package/dist/requirement-analysis/index.html +141 -15
- package/dist/requirements/index.html +141 -15
- package/dist/tasks/index.html +141 -15
- package/dist/templates/index.html +141 -15
- package/dist/test-automation/index.html +141 -15
- package/dist/test-stats/index.html +141 -15
- package/dist/todos/index.html +141 -15
- package/dist/workbench/index.html +73 -10
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +1 -0
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +31 -4
- package/lh-plugins/lh-life.mjs +1130 -0
- package/package.json +1 -1
- package/dist/_astro/Base.huFPH3Mp.css +0 -1
- package/dist/_astro/ColumnResize._Iq05ix_.js +0 -1
- package/dist/_astro/MultiSelectDropdown.BHxW9XLR.js +0 -1
- package/dist/_astro/PluginsPage.Ch3rrYRF.js +0 -1
- package/dist/_astro/PmRequirementsBoard.BNNq671Z.js +0 -1
- package/dist/_astro/SelectDropdown.apWlFGbA.js +0 -1
- package/dist/_astro/TasksBoard.CdWQSwlg.js +0 -1
- package/dist/_astro/TodosBoard.CSupMlTp.js +0 -1
- package/dist/_astro/app-config.Bg6v8zQQ.js +0 -1
- package/dist/_astro/app-version.trTEbNVs.js +0 -1
- package/dist/_astro/i18n.CH6ZNsHf.js +0 -7
- package/dist/_astro/plugins.CVnHeKyf.js +0 -1
- package/dist/_astro/tasks.jfnSAEmg.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.Bg6v8zQQ.js";import{i as r,o as i,s as a}from"./plugins.CVnHeKyf.js";import{_ as o,a as s,b as ee,c as te,d as ne,f as re,g as ie,h as ae,i as c,l,m as oe,n as se,o as u,p as d,r as f,s as p,u as m,v as ce,y as le}from"./case-exec.BLqTXR7U.js";import{r as ue,s as de}from"./view-prefs.SdItxolG.js";import{t as fe}from"./jsx-runtime.DUg_B_vD.js";import{t as pe}from"./ConfirmDialog.D5qXeML0.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{n as me,t as he}from"./DocsPager.CnXEnQqa.js";import{t as g}from"./TagSelect.UUXgkMqJ.js";import{showToast as _}from"./Toast.BO2NFckG.js";var v=e(t(),1),y=fe(),ge=8e3,b=600,_e=20,ve=`tw.case-exec.page-size.v1`,x=`case-exec.search`,S=[{key:`select`,width:`6%`},{key:`date`,width:`20%`},{key:`total`,width:`12%`},{key:`pending`,width:`12%`},{key:`executed`,width:`12%`},{key:`remaining`,width:`12%`},{key:`ratio`,width:`20%`},{key:`action`,width:`6%`}],C=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,w=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,T=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,E=(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,y.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,y.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),D=(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,y.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function O(e){let[t,n]=(0,v.useState)(e.value?String(e.value):``),r=(0,v.useRef)(e.value),i=(0,v.useRef)(e.onCommit);i.current=e.onCommit,(0,v.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,v.useEffect)(()=>{let e=t?o(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},b);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?o(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,y.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:C})}function k(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#3370ff]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function A(e){let t=s(e.item,e.baseline),n=d(e.item,e.baseline),r=f(e.item,e.baseline),i=k(t);return(0,y.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,y.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function j(){let[e,t]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)([]),[fe,h]=(0,v.useState)([]),[g,b]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(()=>ue(x)),[E,D]=(0,v.useState)({}),[O,k]=(0,v.useState)(1),[A,j]=me(_e,ve),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(null);function be(e){de(x,e),T(e),k(1)}let B=(0,v.useRef)(!0),V=(0,v.useRef)(!1);(0,v.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let H=(0,v.useCallback)(async()=>{try{let e=await ae();if(!B.current)return;p(e.items),h(e.projects),D(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>{let e=i(e=>s(!!e.caseExec));return n().then(()=>{s(r(`caseExec`)),t(!0)}),e},[]),(0,v.useEffect)(()=>{e&&o&&(async()=>{let e=await re();B.current&&(e?(await H(),B.current&&d(!0)):d(!1))})()},[e,o,H]),(0,v.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{V.current||H()},ge),t=()=>{V.current||H()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,H]);let U=ce(),W=(0,v.useMemo)(()=>se(f),[f]),G=(0,v.useMemo)(()=>oe(f,{keyword:w}),[f,w]),xe=Math.max(1,Math.ceil(G.length/A)),K=Math.min(O,xe),q=(0,v.useMemo)(()=>G.slice((K-1)*A,K*A),[G,K,A]),J=(0,v.useMemo)(()=>q.flatMap(e=>P[e.key]?[]:e.items),[q,P]),Y=(0,v.useMemo)(()=>f.filter(e=>E[e.id]),[f,E]),Se=J.length>0&&J.every(e=>E[e.id]);function Ce(e){F(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function we(e){F(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function X(e,t){D(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Z(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return f.filter(t=>t.project===e.project).map(e=>e.id)}(0,v.useEffect)(()=>{if(!M)return;let e=G.findIndex(e=>e.items.some(e=>e.id===M));if(e<0)return;k(Math.floor(e/A)+1);let t=window.setTimeout(()=>N(null),2e3);return()=>window.clearTimeout(t)},[M,G,A]);async function Te(){if(!S){C(!0),b(null),be(``);try{let e=await l([{date:U,project:``,startDate:U,endDate:U}],{mode:`manual`});if(!B.current)return;let t=e.items[0];if(e.projects.length&&h(e.projects),await H(),!B.current||!t)return;N(t.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Ee(e){if(!S&&e.project){C(!0),b(null);try{let t=await l([{date:U,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!B.current)return;let n=t.items[0];if(t.projects.length&&h(t.projects),we(e.key),await H(),!B.current||!n)return;N(n.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Q(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await le(e,t);if(!B.current)return;p(t=>t.map(t=>t.id===e?n:t)),h(r),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),await H()}}function De(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){_(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&Q(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await ee(i,{startDate:n,endDate:r});if(!B.current)return;p(e.items),h(e.projects),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),_(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await H()}})()}function Oe(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)$(e.project,n);else{let t=e.items[0];t&&Q(t.id,{project:n})}}}function ke(e,t){e.pending>0?Q(e.id,{total:t,executed:c(t,e.pending)}):Q(e.id,{total:t})}function Ae(e,t){Q(e.id,{pending:t,executed:c(e.total,t)})}async function $(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ie(e,n);if(!B.current)return;p(t.items),h(t.projects),b(null),_(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!B.current)return;_(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function je(e){let t=te(f,e);if(t>0)_(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await ne(e);if(!B.current)return;p(t.items),h(t.projects),b(null),_(`已删除项目名称「${e}」`,`success`)}catch(e){if(!B.current)return;_(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Me(){let e=I;if(e&&e.length!==0){L(null),C(!0);try{if(await m(e.map(e=>e.id)),!B.current)return;D({}),b(null),await H(),_(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}async function Ne(){let e=R;if(!e)return;z(null);let t=Z(e);if(t.length){C(!0);try{if(await m(t),!B.current)return;X(t,!1),b(null),await H(),_(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}return e?o?u===null?(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.records}),` 条统计`,(0,y.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,W.projects,` 个项目 · 已执行 `,W.executed,` / `,W.baseline,` 个用例 · 整体执行率 `,W.percent.toFixed(2),`%`,Y.length?` · 已选 ${Y.length} 条`:``]})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Se,disabled:J.length===0,onChange:e=>X(J.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,y.jsx)(`input`,{value:w,onChange:e=>be(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,y.jsx)(`button`,{type:`button`,disabled:S||Y.length===0,onClick:()=>L(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,y.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>void Te(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加项目`})]})]}),g?(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:g}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>b(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,y.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{V.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{V.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[G.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,q.map(e=>{let t=Z(e);return(0,y.jsx)(ye,{group:e,collapsed:!!P[e.key],groupSelected:t.length>0&&t.every(e=>!!E[e]),recordCount:t.length,projects:fe,addedId:M,selected:E,busy:S,onToggle:()=>Ce(e.key),onToggleGroupSelect:e=>X(t,e),onToggleRow:(e,t)=>X([e],t),onCommitProject:t=>Oe(e,t),onRenameProject:(e,t)=>void $(e,t),onRemoveProject:e=>void je(e),onCommitCycle:t=>De(e,t),onAddStatDate:()=>void Ee(e),onDeleteGroup:()=>z(e),onPatch:Q,onCommitTotal:ke,onCommitPending:Ae,onDeleteRow:e=>L([e])},e.key)})]}),G.length>0?(0,y.jsx)(he,{page:K,totalPages:xe,pageSize:A,busy:S,unit:`个项目`,onPage:k,onPageSize:e=>{j(e),k(1)}}):(0,y.jsx)(`div`,{className:`pb-1`}),(0,y.jsx)(pe,{open:I!==null,title:`删除用例执行统计`,message:I&&I.length>1?`确定删除选中的 ${I.length} 条记录吗?删除后不可恢复。`:`确定删除「${I?.[0]?.project??``} ${I?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>L(null),onConfirm:()=>void Me()}),(0,y.jsx)(pe,{open:R!==null,title:`删除整个项目的统计`,message:R?.project?`确定删除「${R.project}」的全部 ${Z(R).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ne()})]}):(0,y.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:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`caseExec`)}):(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function ye(e){let{group:t}=e,n=k(t.percent);return(0,y.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,y.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,y.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:D})}),(0,y.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,y.jsx)(g,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:w})}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:w})})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,y.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${T} border-stone-200 text-stone-700 hover:border-[#3370ff] hover:text-[#3370ff]`,children:`添加统计`}),(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${T} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,y.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,y.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,y.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${n.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,y.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${n.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,y.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,y.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[820px] table-fixed text-sm`,children:[(0,y.jsx)(`colgroup`,{children:S.map(e=>(0,y.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,y.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,title:`自动计算:用例总数 − 待执行用例`,children:`已执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,y.jsx)(`tbody`,{children:t.items.map(n=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${n.id===e.addedId?`bg-[#f2f6ff]`:`hover:bg-[#f7f8fa]`}`,children:[(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${n.date}`,checked:!!e.selected[n.id],onChange:t=>e.onToggleRow(n.id,t.target.checked)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(h,{value:n.date,onChange:t=>e.onPatch(n.id,{date:t}),placeholder:`选择日期`,className:w})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(n,t)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(n,t)})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,title:`自动计算:用例总数 − 待执行用例`,children:p(n)}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:u(n)}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(A,{item:n,baseline:t.baseline||n.total})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(n),"aria-label":`删除 ${t.project} ${n.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:E})})]},n.id))})]})})})})]})}export{j as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{_ as o,a as s,b as ee,c as te,d as ne,f as re,g as ie,h as ae,i as c,l,m as oe,n as se,o as u,p as d,r as f,s as p,u as m,v as ce,y as le}from"./case-exec.BLqTXR7U.js";import{r as ue,s as de}from"./view-prefs.8MPl3A7e.js";import{t as fe}from"./jsx-runtime.DUg_B_vD.js";import{t as pe}from"./ConfirmDialog.D5qXeML0.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{n as me,t as he}from"./DocsPager.BS20yicJ.js";import{t as g}from"./TagSelect.UUXgkMqJ.js";import{showToast as _}from"./Toast.BO2NFckG.js";var v=e(t(),1),y=fe(),ge=8e3,b=600,_e=20,ve=`tw.case-exec.page-size.v1`,x=`case-exec.search`,S=[{key:`select`,width:`6%`},{key:`date`,width:`20%`},{key:`total`,width:`12%`},{key:`pending`,width:`12%`},{key:`executed`,width:`12%`},{key:`remaining`,width:`12%`},{key:`ratio`,width:`20%`},{key:`action`,width:`6%`}],C=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,w=`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,T=`h-7 shrink-0 rounded-md border bg-white px-2 text-xs font-medium whitespace-nowrap disabled:opacity-40`,E=(0,y.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,y.jsx)(`path`,{d:`M3 6h18`}),(0,y.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,y.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,y.jsx)(`path`,{d:`M10 11v6M14 11v6`})]}),D=(0,y.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,y.jsx)(`path`,{d:`M6 9l6 6 6-6`})});function O(e){let[t,n]=(0,v.useState)(e.value?String(e.value):``),r=(0,v.useRef)(e.value),i=(0,v.useRef)(e.onCommit);i.current=e.onCommit,(0,v.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,v.useEffect)(()=>{let e=t?o(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},b);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?o(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,y.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:C})}function k(e){return e>=80?{text:`text-[#4176e6]`,bar:`bg-[#3370ff]`}:e>=40?{text:`text-[#a85b00]`,bar:`bg-[#f5a524]`}:{text:`text-stone-500`,bar:`bg-stone-400`}}function A(e){let t=s(e.item,e.baseline),n=d(e.item,e.baseline),r=f(e.item,e.baseline),i=k(t);return(0,y.jsxs)(`div`,{className:`flex flex-col justify-center gap-1.5 px-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-1.5`,children:[(0,y.jsx)(`span`,{className:`shrink-0 text-[13px] font-semibold leading-none tabular-nums ${i.text}`,children:n}),(0,y.jsxs)(`span`,{className:`min-w-0 truncate text-right text-[10px] leading-none text-stone-400 tabular-nums`,children:[`已执行 `,r,` / `,e.baseline]})]}),(0,y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${i.bar}`,style:{width:`${t}%`},"aria-hidden":`true`})})]})}function j(){let[e,t]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!0),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)([]),[fe,h]=(0,v.useState)([]),[g,b]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(()=>ue(x)),[E,D]=(0,v.useState)({}),[O,k]=(0,v.useState)(1),[A,j]=me(_e,ve),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(null);function be(e){de(x,e),T(e),k(1)}let B=(0,v.useRef)(!0),V=(0,v.useRef)(!1);(0,v.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let H=(0,v.useCallback)(async()=>{try{let e=await ae();if(!B.current)return;p(e.items),h(e.projects),D(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e))}},[]);(0,v.useEffect)(()=>{let e=i(e=>s(!!e.caseExec));return n().then(()=>{s(r(`caseExec`)),t(!0)}),e},[]),(0,v.useEffect)(()=>{e&&o&&(async()=>{let e=await re();B.current&&(e?(await H(),B.current&&d(!0)):d(!1))})()},[e,o,H]),(0,v.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{V.current||H()},ge),t=()=>{V.current||H()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,H]);let U=ce(),W=(0,v.useMemo)(()=>se(f),[f]),G=(0,v.useMemo)(()=>oe(f,{keyword:w}),[f,w]),xe=Math.max(1,Math.ceil(G.length/A)),K=Math.min(O,xe),q=(0,v.useMemo)(()=>G.slice((K-1)*A,K*A),[G,K,A]),J=(0,v.useMemo)(()=>q.flatMap(e=>P[e.key]?[]:e.items),[q,P]),Y=(0,v.useMemo)(()=>f.filter(e=>E[e.id]),[f,E]),Se=J.length>0&&J.every(e=>E[e.id]);function Ce(e){F(t=>{let n={...t};return n[e]?delete n[e]:n[e]=!0,n})}function we(e){F(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})}function X(e,t){D(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r})}function Z(e){if(!e.project){let t=e.items[0];return t?[t.id]:[]}return f.filter(t=>t.project===e.project).map(e=>e.id)}(0,v.useEffect)(()=>{if(!M)return;let e=G.findIndex(e=>e.items.some(e=>e.id===M));if(e<0)return;k(Math.floor(e/A)+1);let t=window.setTimeout(()=>N(null),2e3);return()=>window.clearTimeout(t)},[M,G,A]);async function Te(){if(!S){C(!0),b(null),be(``);try{let e=await l([{date:U,project:``,startDate:U,endDate:U}],{mode:`manual`});if(!B.current)return;let t=e.items[0];if(e.projects.length&&h(e.projects),await H(),!B.current||!t)return;N(t.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Ee(e){if(!S&&e.project){C(!0),b(null);try{let t=await l([{date:U,project:e.project,startDate:e.startDate,endDate:e.endDate}],{mode:`manual`});if(!B.current)return;let n=t.items[0];if(t.projects.length&&h(t.projects),we(e.key),await H(),!B.current||!n)return;N(n.id)}catch(e){B.current&&b(e instanceof Error?e.message:String(e))}finally{B.current&&C(!1)}}}async function Q(e,t){p(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,projects:r}=await le(e,t);if(!B.current)return;p(t=>t.map(t=>t.id===e?n:t)),h(r),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),await H()}}function De(e,t){let n=t.startDate??e.startDate,r=t.endDate??e.endDate;if(n&&r&&r<n){_(`结束日期不能早于开始日期`,`error`);return}if(!e.project){let n=e.items[0];n&&Q(n.id,t);return}let i=e.project;p(e=>e.map(e=>e.project===i?{...e,startDate:n,endDate:r}:e)),(async()=>{try{let e=await ee(i,{startDate:n,endDate:r});if(!B.current)return;p(e.items),h(e.projects),b(null)}catch(e){if(!B.current)return;b(e instanceof Error?e.message:String(e)),_(`修改周期失败:${e instanceof Error?e.message:String(e)}`,`error`),await H()}})()}function Oe(e,t){let n=t.trim();if(n&&n!==e.project){if(e.project)$(e.project,n);else{let t=e.items[0];t&&Q(t.id,{project:n})}}}function ke(e,t){e.pending>0?Q(e.id,{total:t,executed:c(t,e.pending)}):Q(e.id,{total:t})}function Ae(e,t){Q(e.id,{pending:t,executed:c(e.total,t)})}async function $(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ie(e,n);if(!B.current)return;p(t.items),h(t.projects),b(null),_(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名项目名称`,`success`)}catch(e){if(!B.current)return;_(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function je(e){let t=te(f,e);if(t>0)_(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await ne(e);if(!B.current)return;p(t.items),h(t.projects),b(null),_(`已删除项目名称「${e}」`,`success`)}catch(e){if(!B.current)return;_(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Me(){let e=I;if(e&&e.length!==0){L(null),C(!0);try{if(await m(e.map(e=>e.id)),!B.current)return;D({}),b(null),await H(),_(e.length>1?`已删除 ${e.length} 条执行记录`:`已删除执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}async function Ne(){let e=R;if(!e)return;z(null);let t=Z(e);if(t.length){C(!0);try{if(await m(t),!B.current)return;X(t,!1),b(null),await H(),_(e.project?`已删除「${e.project}」的 ${t.length} 条统计`:`已删除 ${t.length} 条执行记录`,`success`)}catch(e){if(!B.current)return;let t=e instanceof Error?e.message:String(e);b(t),_(`删除失败:${t}`,`error`)}finally{B.current&&C(!1)}}}return e?o?u===null?(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接用例执行统计服务`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,y.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-800`,children:W.records}),` 条统计`,(0,y.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· `,W.projects,` 个项目 · 已执行 `,W.executed,` / `,W.baseline,` 个用例 · 整体执行率 `,W.percent.toFixed(2),`%`,Y.length?` · 已选 ${Y.length} 条`:``]})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`label`,{className:`flex h-9 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap text-sm text-stone-600`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Se,disabled:J.length===0,onChange:e=>X(J.map(e=>e.id),e.target.checked)}),`全选本页`]}),(0,y.jsx)(`input`,{value:w,onChange:e=>be(e.target.value),placeholder:`搜索项目 / 统计日期…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,y.jsx)(`button`,{type:`button`,disabled:S||Y.length===0,onClick:()=>L(Y),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,y.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>void Te(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加项目`})]})]}),g?(0,y.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,y.jsx)(`span`,{className:`min-w-0 flex-1`,children:g}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>b(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,y.jsxs)(`div`,{"data-case-exec":!0,className:`min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4`,onFocusCapture:()=>{V.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{V.current=!!document.activeElement?.closest(`[data-case-exec]`)},0)},children:[G.length===0?(0,y.jsx)(`div`,{className:`rounded-lg border border-dashed border-stone-200 px-4 py-14 text-center text-sm text-stone-400`,children:`还没有用例执行统计记录,点右上角「+ 添加项目」开始。`}):null,q.map(e=>{let t=Z(e);return(0,y.jsx)(ye,{group:e,collapsed:!!P[e.key],groupSelected:t.length>0&&t.every(e=>!!E[e]),recordCount:t.length,projects:fe,addedId:M,selected:E,busy:S,onToggle:()=>Ce(e.key),onToggleGroupSelect:e=>X(t,e),onToggleRow:(e,t)=>X([e],t),onCommitProject:t=>Oe(e,t),onRenameProject:(e,t)=>void $(e,t),onRemoveProject:e=>void je(e),onCommitCycle:t=>De(e,t),onAddStatDate:()=>void Ee(e),onDeleteGroup:()=>z(e),onPatch:Q,onCommitTotal:ke,onCommitPending:Ae,onDeleteRow:e=>L([e])},e.key)})]}),G.length>0?(0,y.jsx)(he,{page:K,totalPages:xe,pageSize:A,busy:S,unit:`个项目`,onPage:k,onPageSize:e=>{j(e),k(1)}}):(0,y.jsx)(`div`,{className:`pb-1`}),(0,y.jsx)(pe,{open:I!==null,title:`删除用例执行统计`,message:I&&I.length>1?`确定删除选中的 ${I.length} 条记录吗?删除后不可恢复。`:`确定删除「${I?.[0]?.project??``} ${I?.[0]?.date??``}」这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>L(null),onConfirm:()=>void Me()}),(0,y.jsx)(pe,{open:R!==null,title:`删除整个项目的统计`,message:R?.project?`确定删除「${R.project}」的全部 ${Z(R).length} 条统计吗?删除后不可恢复(项目名称仍保留在下拉里)。`:`确定删除这条占位记录吗?删除后不可恢复。`,confirmLabel:`删除整组`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ne()})]}):(0,y.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:`用例执行统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,y.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`caseExec`)}):(0,y.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,y.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,y.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function ye(e){let{group:t}=e,n=k(t.percent);return(0,y.jsxs)(`article`,{className:`overflow-hidden rounded-lg border border-stone-200 bg-white`,children:[(0,y.jsxs)(`div`,{onClick:t=>{t.target.closest(`button, input, a, select, textarea, label, [role="button"], [role="combobox"]`)||window.getSelection()?.toString()||e.onToggle()},className:`cursor-pointer border-b border-stone-100 bg-[#fbfbfc] px-3 py-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5`,children:[(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择项目 ${t.project||`未命名`}`,checked:e.groupSelected,disabled:e.recordCount===0,onChange:t=>e.onToggleGroupSelect(t.target.checked)}),(0,y.jsx)(`button`,{type:`button`,"aria-expanded":!e.collapsed,"aria-label":`${e.collapsed?`展开`:`收起`} ${t.project||`未命名项目`}`,onClick:e.onToggle,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-200/70 hover:text-stone-700`,children:(0,y.jsx)(`span`,{className:`transition-transform ${e.collapsed?`-rotate-90`:``}`,"aria-hidden":`true`,children:D})}),(0,y.jsx)(`div`,{className:`w-52 shrink-0`,children:(0,y.jsx)(g,{compact:!0,ariaLabel:`项目名称`,options:e.projects,value:t.project,onChange:e.onCommitProject,onRenameOption:e.onRenameProject,onDeleteOption:e.onRemoveProject,placeholder:`选择或创建项目`})}),t.draft?(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,children:`选好项目名称后就能在这条项目下按统计日期记录`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.startDate,onChange:t=>e.onCommitCycle({startDate:t}),placeholder:`开始日期`,className:w})}),(0,y.jsx)(`span`,{className:`text-xs text-stone-400`,"aria-hidden":`true`,children:`~`}),(0,y.jsx)(`div`,{className:`w-28 shrink-0`,children:(0,y.jsx)(h,{value:t.endDate,onChange:t=>e.onCommitCycle({endDate:t}),placeholder:`结束日期`,className:w})})]}),(0,y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,y.jsxs)(`span`,{className:`mr-1 whitespace-nowrap text-xs text-stone-400 tabular-nums`,children:[e.recordCount,` 条统计`]}),t.draft?null:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onAddStatDate,className:`${T} border-stone-200 text-stone-700 hover:border-[#3370ff] hover:text-[#3370ff]`,children:`添加统计`}),(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:e.onDeleteGroup,className:`${T} border-red-200 text-red-600 hover:bg-red-50`,children:`删除整组`})]})]}),t.draft?null:(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs text-stone-500 tabular-nums`,children:[(0,y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`基线 `,(0,y.jsx)(`span`,{className:`font-medium text-stone-700`,children:t.baseline}),(0,y.jsx)(`span`,{className:`mx-1.5 text-stone-300`,children:`·`}),`已执行`,` `,(0,y.jsxs)(`span`,{className:`font-medium text-stone-700`,children:[t.executed,` / `,t.baseline]})]}),(0,y.jsxs)(`span`,{className:`shrink-0 text-[13px] font-semibold ${n.text}`,children:[t.percent.toFixed(2),`%`]})]}),(0,y.jsx)(`div`,{className:`mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-stone-200/70`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full ${n.bar}`,style:{width:`${t.percent}%`},"aria-hidden":`true`})})]})]}),(0,y.jsx)(`div`,{className:`grid transition-[grid-template-rows,opacity] duration-200 ease-out ${e.collapsed?`grid-rows-[0fr] opacity-0`:`grid-rows-[1fr] opacity-100`}`,"aria-hidden":e.collapsed,children:(0,y.jsx)(`div`,{className:`min-h-0 overflow-hidden`,inert:e.collapsed,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[820px] table-fixed text-sm`,children:[(0,y.jsx)(`colgroup`,{children:S.map(e=>(0,y.jsx)(`col`,{style:{width:e.width}},e.key))}),(0,y.jsx)(`thead`,{className:`bg-stone-50 text-xs text-stone-500`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`选择`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`统计日期`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`用例总数`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`待执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,title:`自动计算:用例总数 − 待执行用例`,children:`已执行用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`当前剩余用例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-left font-medium whitespace-nowrap`,children:`执行比例`}),(0,y.jsx)(`th`,{className:`px-2 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,y.jsx)(`tbody`,{children:t.items.map(n=>(0,y.jsxs)(`tr`,{className:`border-t border-stone-100 first:border-t-0 ${n.id===e.addedId?`bg-[#f2f6ff]`:`hover:bg-[#f7f8fa]`}`,children:[(0,y.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,y.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${t.project} ${n.date}`,checked:!!e.selected[n.id],onChange:t=>e.onToggleRow(n.id,t.target.checked)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(h,{value:n.date,onChange:t=>e.onPatch(n.id,{date:t}),placeholder:`选择日期`,className:w})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.total,ariaLabel:`用例总数`,onCommit:t=>e.onCommitTotal(n,t)})}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(O,{value:n.pending,ariaLabel:`待执行用例`,onCommit:t=>e.onCommitPending(n,t)})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-sm text-stone-800 tabular-nums`,title:`自动计算:用例总数 − 待执行用例`,children:p(n)}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle text-xs text-stone-500 tabular-nums`,children:u(n)}),(0,y.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,y.jsx)(A,{item:n,baseline:t.baseline||n.total})}),(0,y.jsx)(`td`,{className:`px-2 py-1 text-center align-middle`,children:(0,y.jsx)(`button`,{type:`button`,disabled:e.busy,onClick:()=>e.onDeleteRow(n),"aria-label":`删除 ${t.project} ${n.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:E})})]},n.id))})]})})})})]})}export{j as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.
|
|
2
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./SelectDropdown.TgxIOKMD.js";import{showToast as a}from"./Toast.BO2NFckG.js";import{i as o,r as s}from"./case-types.CprZTsyX.js";import{d as c,f as l,m as u,p as d,r as f,u as ee}from"./case-gen-run.CH0ldlsU.js";import{t as p}from"./export.joBT53eb.js";import{a as m,i as h,n as g,o as _,r as v,s as te,t as ne}from"./case-template.F1Nv08GV.js";import{b as y,m as re,p as b,u as x}from"./settings.NTeTjmxg.js";import{_ as S,c as C,f as w,l as ie,p as T,r as E,u as D,v as ae}from"./project-docs.DAw9bzgk.js";import{o as oe}from"./llm.DyweO-KK.js";import{n as O}from"./doc-roots.DAJP9Svr.js";import{r as se}from"./prompts-meta.Dnmq-SnF.js";import{t as ce}from"./ExcelFieldTags.CXif3Ilh.js";import{t as le}from"./MultiSelectDropdown.y8JMbCxO.js";import{t as k}from"./SearchableSelect.5SfNLwNW.js";var A=e(t(),1),j=r(),ue=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];function de(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 fe(e){return(e.split(`/`).pop()||e).replace(/\.[^.]+$/,``).trim()}function pe(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 me(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 he(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 ge(e){if(!e)return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}async function _e(e){let t=s(e).templateFolder;try{let{entries:e}=await C(`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=[...p],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await w(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=h(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await T(`templates`,e.path),r=g(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await T(`templates`,e.path),r=v(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 ve(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await T(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await w(`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++)i[e]=r.charCodeAt(e);return((await(await y(()=>import(`./lib.S37S0T6S.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}throw Error(`该需求文件类型暂不支持正文提取`)}function M(){let[e,t]=(0,A.useState)(null),[r,h]=(0,A.useState)(!1),[g,v]=(0,A.useState)([]),[y,w]=(0,A.useState)(``),[M,N]=(0,A.useState)(`functional`),[P,ye]=(0,A.useState)([]),[be,F]=(0,A.useState)(``),[xe,Se]=(0,A.useState)([]),[I,L]=(0,A.useState)(``),[Ce,R]=(0,A.useState)(``),[we,Te]=(0,A.useState)([]),[z,B]=(0,A.useState)([]),[V,H]=(0,A.useState)(`md`),[U,Ee]=(0,A.useState)(``),[W,G]=(0,A.useState)(null),[K,De]=(0,A.useState)(!1),[Oe,q]=(0,A.useState)(null),[J,Y]=(0,A.useState)(null),X=(0,A.useRef)(null),ke=(0,A.useRef)(null),Z=(0,A.useMemo)(()=>P.find(e=>e.id===be)??P[0],[P,be]),Q=M,Ae=s(Q).label;(0,A.useEffect)(()=>{n().then(()=>t(x()));let e=b(()=>t(x()));return(async()=>{await c();let e=await E(`requirements`),t=await E(`cases`),n=await E(`templates`),r=await E(`prompts`),i=await E(`knowledge`);h(e&&t&&n&&r);async function a(e,t,n){let{entries:r}=await C(e,t);for(let t of r)t.type===`file`?n.push(t):await a(e,t.path,n)}if(e)try{let e=[];await a(`requirements`,`.`,e),v(e)}catch{}if(i)try{let e=[];await a(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Te(e)}catch{}if(r)try{let e=[];await a(`prompts`,`.`,e);let t=e.filter(e=>!se(e.path));t.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),Se(t);let n=t.find(e=>e.path.includes(`功能测试用例提示词`))?.path??t[0]?.path??``;L(e=>e&&!se(e)&&t.some(t=>t.path===e)?e:n)}catch{}let s=new URLSearchParams(window.location.search),d=s.get(`session`),f=s.get(`path`),p=l();if(d){let e=p.sessions.find(e=>e.id===d);e&&(G(e),N(e.caseType),H(e.outputFormat),w(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0}))}else if(f){let e=p.sessions.find(e=>e.linkedCasePath===f);if(e)G(e),N(e.caseType),H(e.outputFormat),w(e.reqPaths[0]??``),e.templateId&&F(e.templateId),e.promptPath&&L(e.promptPath),e.knowledgePaths?.length&&B([...e.knowledgePaths]),e.linkedCasePath&&Y({path:e.linkedCasePath,count:0});else{let e=f.split(`.`).pop()?.toLowerCase(),t=e===`csv`?`csv`:e===`xlsx`||e===`xls`?`xlsx`:`md`,n=f.split(`/`)[0]??``,r=o().find(e=>e.casesFolder===n)?.id??o()[0]?.id??`functional`,i=ee({title:f.split(`/`).pop()?.replace(/\.[^.]+$/,``)||`用例续改`,caseType:r,outputFormat:t,reqPaths:[]}),a=u(i.id,{linkedCasePath:f}).sessions.find(e=>e.id===i.id)??null;G(a),N(r),H(t),Y({path:f,count:0})}}})(),e},[]),(0,A.useEffect)(()=>{if(!r)return;let e=!1;return _e(M).then(t=>{e||(ye(t),F(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)(()=>{I?T(`prompts`,I).then(e=>{let t=e.content??``;R(t),t.trim()||a(`「提示词管理/${I}」是空的,生成前请先补上提示词内容。`,`error`)}).catch(e=>{R(``);let t=e instanceof Error?e.message:String(e);a(`没有读到「提示词管理/${I}」:${t}`,`error`)}):R(``)},[I]),(0,A.useEffect)(()=>{ke.current?.scrollIntoView({behavior:`smooth`,block:`end`})},[W?.messages,K]);function $(e){if(!W)return;let t=u(W.id,e);G(t.sessions.find(e=>e.id===W.id)??W)}async function je(){let e=``;if(y)try{let t=await ve(y);e+=`\n### 需求文档:${y}\n${t}\n`}catch{e+=`\n### 需求文档:${y}\n(无法读取正文)\n`}Z?.body?e+=`\n### 用例模板:${Z.title}\n${Z.body}\n`:Z&&(e+=`\n### 用例模板:${Z.title}\n字段:${(Z.headers.length?Z.headers:p).join(`、`)}\n`);for(let t of z)try{let n=await T(`knowledge`,t);e+=`\n### 知识库:${t}\n${n.content}\n`}catch{e+=`\n### 知识库:${t}\n(无法读取)\n`}return e}async function Me(e,t,n,r){let i=s(t.caseType),a=n||t.title||i.label,o=f(a,t.caseType),c=i.casesFolder;try{await ie(`cases`,`.`,c)}catch{}let l=`${c}/${o}${t.outputFormat===`md`?`.md`:t.outputFormat===`csv`?`.csv`:`.xlsx`}`,u=r.length?r:[...p];return t.outputFormat===`md`?await ae(`cases`,l,_(e,a,u)):t.outputFormat===`csv`?await ae(`cases`,l,m(e,u)):await S(`cases`,l,await te(e,u,i.label)),l}async function Ne(){if(!y)return``;let e=fe(y);try{return pe(await ve(y))||e}catch{return e}}async function Pe(t,n){if(!e){re(`model`);return}if(!r){q(`本地文档服务未就绪,无法读写用例 / 需求 / 模板库`);return}let i=await Ne(),o=n;o?(u(o.id,{caseType:M,outputFormat:V,reqPaths:y?[y]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),o={...o,caseType:M,outputFormat:V,reqPaths:y?[y]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}):(o=ee({title:i||t.slice(0,24)||`用例生成`,caseType:M,outputFormat:V,reqPaths:y?[y]:[],templateId:Z?.id,templateTitle:Z?.title,promptPath:I||void 0,knowledgePaths:z.length?[...z]:void 0}),G(o));let c=await je(),l=s(M).label,d=Z?.headers?.length?Z.headers:[...p],f=V===`md`?`最终结果将保存为 Markdown 表格文件`:V===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,m=Ce.trim();if(!m){let e=I?`「提示词管理/${I}」没读到内容,请先在提示词管理里补上`:`请先选择提示词`;q(e),a(e,`error`);return}let h=`${m}
|
|
3
3
|
|
|
4
4
|
【运行时约束】
|
|
5
5
|
- 用例类型:${l}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/export.joBT53eb.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{i as n}from"./app-config.Bg6v8zQQ.js";import{i as r,o as i,s as a}from"./plugins.CVnHeKyf.js";import{n as o,o as s,r as c,s as l}from"./view-prefs.SdItxolG.js";import{i as u,n as d,r as f,t as p}from"./dialog.DZHZCe_T.js";import{t as m}from"./jsx-runtime.DUg_B_vD.js";import{t as h}from"./ConfirmDialog.D5qXeML0.js";import{n as g,t as _}from"./DocsPager.CnXEnQqa.js";import{t as v}from"./OverflowHint.pvo2Xc8R.js";import{t as y}from"./SelectDropdown.apWlFGbA.js";import{showToast as b}from"./Toast.BO2NFckG.js";import{i as x,n as S,o as C}from"./case-gen-run.BSJ0o4Zq.js";import{a as ee,i as w,t as T}from"./export.joBT53eb.js";import{i as E,n as D,r as O,t as k}from"./case-fields.Dqkws1iX.js";import{b as A,p as j,s as M,u as N}from"./settings.Cu00if4D.js";import{M as P,v as F,z as te}from"./req-analysis.D-dTIxXF.js";import{c as ne,d as re,f as ie,g as ae,h as oe,n as se,o as ce,p as le,r as ue,u as de}from"./project-docs.DAw9bzgk.js";import{s as fe}from"./llm.DyweO-KK.js";import{n as pe}from"./doc-roots.DAJP9Svr.js";import{i as me,n as he,r as ge,t as _e}from"./DocsFileBrowser.D2Cff2LP.js";import{_ as ve,d as I,f as ye,l as L,m as be,n as xe,o as R,t as Se}from"./open-docs-in-session.DQ2_5fkC.js";import{A as Ce,C as z,D as we,E as Te,M as Ee,N as De,O as B,P as V,S as Oe,T as ke,_ as Ae,a as H,b as je,c as U,d as Me,f as Ne,g as Pe,h as Fe,j as W,k as Ie,l as Le,m as Re,n as ze,o as G,p as K,s as Be,t as Ve,u as q,v as J,w as He,x as Ue,y as We}from"./case-review.s1w_mD4l.js";import{a as Ge,c as Ke,d as qe,i as Je,l as Ye,n as Xe,o as Ze,t as Y}from"./ColumnResize._Iq05ix_.js";import{t as Qe}from"./NamePromptDialog.Csfnh5eM.js";import{t as $e}from"./SlideOverDrawer.C1IVOc_8.js";import{m as et}from"./PmShared.BuhrL7Gb.js";import{o as tt,r as nt,s as rt,t as it}from"./composer-task.DJmluzPT.js";var X=e(t(),1),at=`备份列表`;function ot(e){return String(e??``).replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()===at}function st(e){let t=String(e??``).split(/[/\\]/).pop();return t?/\.bak(?:$|[-_.])/i.test(t):!1}var Z=m(),ct=40,lt=20,ut=`tw.case-backup.page-size.v1`,dt=[{key:`select`,width:ct,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 ft(e=`.`){let{entries:t}=await ne(`cases`,e),n=[];for(let e of t)e.type===`file`?(st(e.name)||st(e.path))&&n.push(e):!ot(e.name)&&!ot(e.path)&&n.push(...await ft(e.path));return n}function pt(e){return e===`folder`?`备份列表`:e===`sidecar`?`旁路`:`历史`}function mt(e){if(!Number.isFinite(e))return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}function ht(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 gt(){let e=[];try{if(await ke()){let t=await z();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 ft(`.`);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 _t({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,f]=(0,X.useState)({}),[p,m]=(0,X.useState)(null),[y,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(``),[ee,w]=(0,X.useState)(1),[T,E]=g(lt,ut),D=Ye(`lh:case-backup:cols:v4`,dt),O=qe(`case-backup`),k=(0,X.useCallback)(async()=>{o(!0),u(null);try{let e=await gt();i(e),f(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&&(w(1),k())},[e,k]);let A=Math.max(1,Math.ceil(r.length/T)),j=Math.min(ee,A),M=(0,X.useMemo)(()=>r.slice((j-1)*T,j*T),[r,j,T]),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 se(`cases`,e.path);r.length&&await We(r.map(e=>e.reviewName||e.name)),b(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),b(`删除失败:${t}`,`error`)}finally{c(!1)}}async function te(){let e=p;if(m(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 ne(e){if(e.kind!==`legacy`)try{await de(`cases`,e.path)}catch(e){u(e instanceof Error?e.message:String(e))}}function ie(e){e.kind!==`legacy`&&(C(``),x(e))}async function ae(e){let t=y;if(!t||t.kind===`legacy`)return;let i=e.trim();if(!i||i===t.name){x(null),C(``);return}let a=re(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)C(`已存在同名文件「${s.name}」,换个名字再试`);else{c(!0),u(null),C(``);try{await oe(`cases`,t.path,i),x(null),b(`已重命名为「${i}」`,`success`),await k(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);C(t),b(`重命名失败:${t}`,`error`)}finally{c(!1)}}}let ce=p?.kind===`one`?`删除备份「${p.row.name}」?此操作不可恢复。`:p?.kind===`batch`?`确认删除已选中的 ${p.ids.length} 个备份?此操作不可恢复。`:``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($e,{open:e,onClose:t,title:`备份列表`,closeAriaLabel:`关闭备份列表`,widthClass:`max-w-5xl`,bodyClassName:`flex flex-col gap-3 overflow-hidden`,escDisabled:!!p||y!=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:()=>m({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:[`新备份在「用例管理/`,at,`/」(首次备份时自动创建,主列表不展示该文件夹)。历史旁路 .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:dt.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:`${Ge} relative`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:P,disabled:s||M.length===0,onChange:e=>{let t=e.target.checked;f(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:Ze,style:{"--tw-sticky-left":`${ct}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:Ke,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||ne(e)},children:[(0,Z.jsx)(`td`,{className:Xe,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!d[e.id],disabled:s,onChange:t=>f(n=>({...n,[e.id]:t.target.checked})),"aria-label":`选择 ${e.name}`})}),(0,Z.jsx)(`td`,{className:`${Xe} min-w-0 max-w-0`,style:{"--tw-sticky-left":`${ct}px`},children:(0,Z.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center`,children:[(0,Z.jsx)(v,{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:()=>ie(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)(et,{name:`pencil`,size:12})})})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:pt(e.kind)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:mt(e.mtime)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap tabular-nums`,children:ht(e.size)}),(0,Z.jsx)(`td`,{"aria-hidden":`true`}),(0,Z.jsx)(`td`,{className:Je,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:()=>m({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)(_,{page:j,totalPages:A,pageSize:T,busy:s||a,className:`shrink-0 !px-4 !py-2`,onPage:w,onPageSize:e=>{E(e),w(1)}}):null]})]}),(0,Z.jsx)(h,{open:!!p,title:p?.kind===`batch`?`批量删除备份`:`删除备份`,message:ce,confirmLabel:`删除`,danger:!0,onClose:()=>m(null),onConfirm:()=>void te()}),(0,Z.jsx)(Qe,{open:y!=null,title:`重命名备份`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:y?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:S,onClose:()=>{s||(x(null),C(``))},onConfirm:e=>void ae(e)})]})}var vt=[`.md`,`.markdown`,`.txt`,`.csv`],yt=[`.xlsx`,`.xls`];function bt(e){return e.replace(/<br\s*\/?>/gi,`
|
|
2
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{n as o,o as s,r as c,s as l}from"./view-prefs.8MPl3A7e.js";import{i as u,n as d,r as f,t as p}from"./dialog.DZHZCe_T.js";import{t as m}from"./jsx-runtime.DUg_B_vD.js";import{t as h}from"./ConfirmDialog.D5qXeML0.js";import{n as g,t as _}from"./DocsPager.BS20yicJ.js";import{t as v}from"./OverflowHint.pvo2Xc8R.js";import{t as y}from"./SelectDropdown.TgxIOKMD.js";import{showToast as b}from"./Toast.BO2NFckG.js";import{i as x,n as S,o as C}from"./case-gen-run.CH0ldlsU.js";import{a as ee,i as w,t as T}from"./export.joBT53eb.js";import{i as E,n as D,r as O,t as k}from"./case-fields.Dqkws1iX.js";import{b as A,p as j,s as M,u as N}from"./settings.NTeTjmxg.js";import{M as P,v as F,z as te}from"./req-analysis.CjhgP3jI.js";import{c as ne,d as re,f as ie,g as ae,h as oe,n as se,o as ce,p as le,r as ue,u as de}from"./project-docs.DAw9bzgk.js";import{s as fe}from"./llm.DyweO-KK.js";import{n as pe}from"./doc-roots.DAJP9Svr.js";import{i as me,n as he,r as ge,t as _e}from"./DocsFileBrowser.9WTBumS5.js";import{_ as ve,d as I,f as ye,l as L,m as be,n as xe,o as R,t as Se}from"./open-docs-in-session.BdihMTEh.js";import{A as Ce,C as z,D as we,E as Te,M as Ee,N as De,O as B,P as V,S as Oe,T as ke,_ as Ae,a as H,b as je,c as U,d as Me,f as Ne,g as Pe,h as Fe,j as W,k as Ie,l as Le,m as Re,n as ze,o as G,p as K,s as Be,t as Ve,u as q,v as J,w as He,x as Ue,y as We}from"./case-review.s1w_mD4l.js";import{a as Ge,c as Ke,d as qe,i as Je,l as Ye,n as Xe,o as Ze,t as Y}from"./ColumnResize.CkE59sGq.js";import{t as Qe}from"./NamePromptDialog.Csfnh5eM.js";import{t as $e}from"./SlideOverDrawer.C1IVOc_8.js";import{m as et}from"./PmShared.BJpoEYvk.js";import{o as tt,r as nt,s as rt,t as it}from"./composer-task.DJmluzPT.js";var X=e(t(),1),at=`备份列表`;function ot(e){return String(e??``).replace(/\\/g,`/`).split(`/`).filter(Boolean).pop()===at}function st(e){let t=String(e??``).split(/[/\\]/).pop();return t?/\.bak(?:$|[-_.])/i.test(t):!1}var Z=m(),ct=40,lt=20,ut=`tw.case-backup.page-size.v1`,dt=[{key:`select`,width:ct,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 ft(e=`.`){let{entries:t}=await ne(`cases`,e),n=[];for(let e of t)e.type===`file`?(st(e.name)||st(e.path))&&n.push(e):!ot(e.name)&&!ot(e.path)&&n.push(...await ft(e.path));return n}function pt(e){return e===`folder`?`备份列表`:e===`sidecar`?`旁路`:`历史`}function mt(e){if(!Number.isFinite(e))return`—`;try{return new Date(e).toLocaleString(`zh-CN`,{hour12:!1})}catch{return`—`}}function ht(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 gt(){let e=[];try{if(await ke()){let t=await z();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 ft(`.`);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 _t({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,f]=(0,X.useState)({}),[p,m]=(0,X.useState)(null),[y,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(``),[ee,w]=(0,X.useState)(1),[T,E]=g(lt,ut),D=Ye(`lh:case-backup:cols:v4`,dt),O=qe(`case-backup`),k=(0,X.useCallback)(async()=>{o(!0),u(null);try{let e=await gt();i(e),f(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&&(w(1),k())},[e,k]);let A=Math.max(1,Math.ceil(r.length/T)),j=Math.min(ee,A),M=(0,X.useMemo)(()=>r.slice((j-1)*T,j*T),[r,j,T]),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 se(`cases`,e.path);r.length&&await We(r.map(e=>e.reviewName||e.name)),b(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),b(`删除失败:${t}`,`error`)}finally{c(!1)}}async function te(){let e=p;if(m(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 ne(e){if(e.kind!==`legacy`)try{await de(`cases`,e.path)}catch(e){u(e instanceof Error?e.message:String(e))}}function ie(e){e.kind!==`legacy`&&(C(``),x(e))}async function ae(e){let t=y;if(!t||t.kind===`legacy`)return;let i=e.trim();if(!i||i===t.name){x(null),C(``);return}let a=re(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)C(`已存在同名文件「${s.name}」,换个名字再试`);else{c(!0),u(null),C(``);try{await oe(`cases`,t.path,i),x(null),b(`已重命名为「${i}」`,`success`),await k(),n?.()}catch(e){let t=e instanceof Error?e.message:String(e);C(t),b(`重命名失败:${t}`,`error`)}finally{c(!1)}}}let ce=p?.kind===`one`?`删除备份「${p.row.name}」?此操作不可恢复。`:p?.kind===`batch`?`确认删除已选中的 ${p.ids.length} 个备份?此操作不可恢复。`:``;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)($e,{open:e,onClose:t,title:`备份列表`,closeAriaLabel:`关闭备份列表`,widthClass:`max-w-5xl`,bodyClassName:`flex flex-col gap-3 overflow-hidden`,escDisabled:!!p||y!=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:()=>m({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:[`新备份在「用例管理/`,at,`/」(首次备份时自动创建,主列表不展示该文件夹)。历史旁路 .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:dt.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:`${Ge} relative`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:P,disabled:s||M.length===0,onChange:e=>{let t=e.target.checked;f(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:Ze,style:{"--tw-sticky-left":`${ct}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:Ke,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||ne(e)},children:[(0,Z.jsx)(`td`,{className:Xe,onDoubleClick:e=>e.stopPropagation(),children:(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!d[e.id],disabled:s,onChange:t=>f(n=>({...n,[e.id]:t.target.checked})),"aria-label":`选择 ${e.name}`})}),(0,Z.jsx)(`td`,{className:`${Xe} min-w-0 max-w-0`,style:{"--tw-sticky-left":`${ct}px`},children:(0,Z.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center`,children:[(0,Z.jsx)(v,{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:()=>ie(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)(et,{name:`pencil`,size:12})})})]})}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:pt(e.kind)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap`,children:mt(e.mtime)}),(0,Z.jsx)(`td`,{className:`px-3 py-2.5 text-xs text-stone-600 whitespace-nowrap tabular-nums`,children:ht(e.size)}),(0,Z.jsx)(`td`,{"aria-hidden":`true`}),(0,Z.jsx)(`td`,{className:Je,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:()=>m({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)(_,{page:j,totalPages:A,pageSize:T,busy:s||a,className:`shrink-0 !px-4 !py-2`,onPage:w,onPageSize:e=>{E(e),w(1)}}):null]})]}),(0,Z.jsx)(h,{open:!!p,title:p?.kind===`batch`?`批量删除备份`:`删除备份`,message:ce,confirmLabel:`删除`,danger:!0,onClose:()=>m(null),onConfirm:()=>void te()}),(0,Z.jsx)(Qe,{open:y!=null,title:`重命名备份`,label:`文件名称`,placeholder:`请输入文件名`,initialValue:y?.name??``,lockExtension:!0,confirmLabel:`保存`,cancelLabel:`取消`,error:S,onClose:()=>{s||(x(null),C(``))},onConfirm:e=>void ae(e)})]})}var vt=[`.md`,`.markdown`,`.txt`,`.csv`],yt=[`.xlsx`,`.xls`];function bt(e){return e.replace(/<br\s*\/?>/gi,`
|
|
3
3
|
`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`).trim()}function xt(e){return e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(bt)}function St(e){return/^\s*\|?[\s-:|]+\|?\s*$/.test(e)&&/-+/.test(e)}function Ct(e){let t=String(e??``).split(/\r?\n/),n=-1,r=[];for(let e=0;e<t.length;e++){if(!t[e].includes(`|`))continue;let i=xt(t[e]);if(i.some(e=>e.includes(`用例`))&&i.length>=2){n=e,r=i;break}}if(n<0||!r.length)return{headers:[...T],rows:[]};let i=St(t[n+1]??``)?n+2:n+1,a=[];for(let e=i;e<t.length;e++){let n=t[e];if(!n.includes(`|`)||St(n)){if(a.length>0&&!n.includes(`|`))break;continue}let i=xt(n);if(i.every(e=>!e))continue;let o={};r.forEach((e,t)=>{o[e]=i[t]??``}),Object.values(o).some(e=>e.trim())&&a.push(o)}return{headers:r,rows:a}}function wt(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=``,i=[],a=!1;for(let e=0;e<t.length;e++){let o=t[e];a?o===`"`?t[e+1]===`"`?(r+=`"`,e+=1):a=!1:r+=o:o===`"`?a=!0:o===`,`?(i.push(r),r=``):o===`
|
|
4
4
|
`||o===`\r`?(o===`\r`&&t[e+1]===`
|
|
5
5
|
`&&(e+=1),i.push(r),r=``,i.some(e=>e.trim())&&n.push(i),i=[]):r+=o}i.push(r),i.some(e=>e.trim())&&n.push(i);let[o,...s]=n,c=(o??[]).map(e=>String(e??``).trim()),l=c.filter(Boolean);return l.length?{headers:l,rows:s.map(e=>{let t={};return c.forEach((n,r)=>{n&&(t[n]=String(e[r]??``).trim())}),t})}:{headers:[...T],rows:[]}}function Tt(e){let t=w(e,{type:`base64`,cellDates:!0}),n=t.SheetNames[0],r=n?t.Sheets[n]:void 0;if(!r)return{headers:[...T],rows:[]};let i=ee.sheet_to_json(r,{header:1,defval:``,raw:!1,blankrows:!1}),a=(i[0]??[]).map(e=>String(e??``).trim()),o=a.filter(Boolean);if(!o.length)return{headers:[...T],rows:[]};let s=[];for(let e of i.slice(1)){let t={};a.forEach((n,r)=>{n&&(t[n]=String(e[r]??``).trim())}),Object.values(t).some(e=>e.trim())&&s.push(t)}return{headers:o,rows:s}}async function Et(e){let t=`.${(e.split(`.`).pop()??``).toLowerCase()}`;if(yt.includes(t)){let n=await ie(`cases`,e);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取该用例文件`);let r=Tt(n.contentBase64);return{ext:t,...r,rows:D(r.rows)}}if(!vt.includes(t))throw Error(`暂不支持评审 ${t} 文件,请用 md / csv / xlsx`);let{content:n}=await le(`cases`,e),r=t===`.csv`?wt(n):Ct(n);return{ext:t,...r,rows:D(r.rows),text:n}}async function Dt(e){let t=[...te(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 Ot(e.sourcePath);r=F(t)}catch{r=[]}return{outlineOrder:t,testPointIds:e.testPoints?.points?.map(e=>e.id)??void 0,idealOrder:r,storySourceRefs:n}}async function Ot(t){let n=t.toLowerCase();if(n.endsWith(`.xlsx`)||n.endsWith(`.xls`)){let e=await ie(`requirements`,t);if(e.encoding!==`base64`||!e.contentBase64)throw Error(`无法读取 Excel`);let n=await A(()=>import(`./export.joBT53eb.js`).then(e=>e.s),__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(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.S37S0T6S.js","_astro/react.Blvh0GOs.js","_astro/jszip.min.Bh2Mgo40.js","_astro/export.joBT53eb.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{B as n,H as r,U as i,V as a,W as o,i as s,p as c,r as l,t as u,u as d,z as f}from"./app-config.
|
|
2
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{B as n,H as r,U as i,V as a,W as o,i as s,p as c,r as l,t as u,u as d,z as f}from"./app-config.C4rpn1Ix.js";import{a as p,i as m,o as h,s as g,t as _}from"./plugins.C0NrHGZv.js";import{a as v,h as y,o as b,s as x,t as S}from"./case-exec.BLqTXR7U.js";import{n as C,o as w}from"./view-prefs.8MPl3A7e.js";import{t as T}from"./react-dom.DLW9pGCF.js";import{i as E,n as D,r as O,t as k}from"./dialog.DZHZCe_T.js";import{i as ee,n as te,r as ne,t as re}from"./menu.Dnrpz489.js";import{t as A}from"./jsx-runtime.DUg_B_vD.js";import{t as j}from"./ConfirmDialog.D5qXeML0.js";import{t as ie}from"./DatePicker.Bkl71M49.js";import{t as ae}from"./OverflowHint.pvo2Xc8R.js";import{t as oe}from"./SelectDropdown.TgxIOKMD.js";import{showToast as M}from"./Toast.BO2NFckG.js";import{a as N,i as P,n as se,o as ce,r as F,t as I}from"./case-types.CprZTsyX.js";import{a as le,c as ue,l as de,s as fe,t as pe}from"./case-gen-run.CH0ldlsU.js";import{a as L,i as me,t as he}from"./export.joBT53eb.js";import{i as ge,n as R,r as _e}from"./case-template.F1Nv08GV.js";import{a as ve,b as ye,c as be,f as xe,h as z,m as B,p as Se,r as Ce,s as we,u as Te}from"./settings.NTeTjmxg.js";import{D as Ee,M as De,rt as Oe,y as ke,z as Ae}from"./req-analysis.CjhgP3jI.js";import{c as je,f as Me,p as Ne,r as Pe,u as Fe,v as Ie}from"./project-docs.DAw9bzgk.js";import{a as Le,i as Re,r as ze,s as Be,t as Ve}from"./llm.DyweO-KK.js";import{n as He,t as Ue}from"./doc-roots.DAJP9Svr.js";import{a as We,l as Ge,n as Ke,r as qe,t as Je}from"./prompts-meta.Dnmq-SnF.js";import{t as Ye}from"./ExcelFieldTags.CXif3Ilh.js";import{t as Xe}from"./MultiSelectDropdown.y8JMbCxO.js";import{t as Ze}from"./SearchableSelect.5SfNLwNW.js";import{A as Qe,C as $e,D as et,E as tt,O as nt,S as rt,T as it,_ as at,a as ot,b as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,k as mt,l as ht,m as gt,n as _t,o as vt,p as yt,r as bt,s as xt,u as St,v as Ct,w as wt,x as Tt,y as Et}from"./open-docs-in-session.BdihMTEh.js";import{t as Dt}from"./NamePromptDialog.Csfnh5eM.js";import{C as Ot,E as kt,M as At,O as jt,R as V,S as Mt,T as Nt,a as Pt,d as Ft,g as It,h as Lt,k as Rt,l as zt,r as H,s as Bt,t as Vt,w as Ht,x as Ut,y as Wt}from"./pm.BXmOiFfW.js";import{t as Gt}from"./SlideOverDrawer.C1IVOc_8.js";import{a as Kt,c as qt,i as Jt,n as Yt,o as Xt,r as Zt,s as Qt}from"./composer-task.DJmluzPT.js";import{n as $t}from"./i18n.BJeTr39S.js";import{n as en,t as tn}from"./PromptMountDialog.CpTT6L0a.js";import{_ as nn,a as rn,b as an,c as on,d as sn,f as cn,g as ln,h as un,i as dn,l as fn,m as pn,n as mn,o as hn,p as gn,r as _n,s as vn,t as yn,u as bn,v as xn,y as Sn}from"./fs-tools.3F9MFrLf.js";import{C as Cn,D as wn,E as Tn,F as En,O as U,P as Dn,S as On,T as kn,_ as An,a as jn,b as Mn,c as Nn,d as Pn,g as Fn,i as In,j as Ln,k as Rn,l as zn,m as Bn,n as Vn,o as Hn,r as Un,t as Wn,u as Gn,v as W,x as Kn,y as qn}from"./tasks.DefXqRfI.js";import{_ as Jn,a as Yn,c as Xn,d as Zn,f as Qn,g as $n,h as er,i as tr,l as nr,m as rr,n as ir,o as ar,p as or,r as sr,s as cr,t as lr,u as ur,v as dr,y as fr}from"./bash-tools.RQcI4_42.js";import{C as pr,S as mr,_ as hr,a as gr,b as _r,c as vr,d as yr,g as br,h as xr,i as Sr,l as G,m as Cr,n as wr,o as Tr,p as Er,r as Dr,s as Or,t as kr,u as Ar,v as jr,w as Mr,x as Nr,y as Pr}from"./PluginsPage.DE3qbeY5.js";import{c as Fr,n as Ir,t as Lr}from"./report-prompt.CAfZ6RIo.js";import{s as Rr}from"./test-stats.Cf3_L4wu.js";import{i as zr}from"./ui-auto-prompt.l_EXfDs5.js";import{h as Br}from"./ui-auto.BmC9JJ_X.js";import{b as Vr,l as Hr,v as Ur}from"./story-review.BBfB1qYF.js";var K=e(t(),1),Wr=e(T(),1),Gr=`/__tb_sessions/runs`;async function Kr(e){try{return(await fetch(Gr,{signal:e??AbortSignal.timeout(1500)})).ok}catch{return!1}}async function qr(e){let t=await fetch(Gr,{signal:e??AbortSignal.timeout(3e3)});if(!t.ok)return[];let n=await t.json();return Array.isArray(n.runs)?n.runs:[]}async function Jr(e){let t=await fetch(Gr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error||`HTTP ${t.status}`}}async function Yr(e){await fetch(`${Gr}/${encodeURIComponent(e)}/stop`,{method:`POST`}).catch(()=>{})}async function Xr(e){try{let t=await fetch(`${Gr}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(3e3)});return t.status===404?{ok:!1}:t.ok?await t.json():null}catch{return null}}function Zr(e){return e===`completed`||e===`stopped`||e===`error`}function Qr(e,t,n,r){let i=new AbortController,a=`${Gr}/${encodeURIComponent(e)}/events?after=${Math.max(0,t)}`;return(async()=>{try{let e=await fetch(a,{headers:{Accept:`text/event-stream`},signal:i.signal});if(!e.ok||!e.body){r?.(Error(`SSE ${e.status}`));return}let t=e.body.getReader(),o=new TextDecoder,s=``;for(;;){let{done:e,value:a}=await t.read();if(e){i.signal.aborted||r?.(Error(`SSE disconnected`));break}s+=o.decode(a,{stream:!0});let c=s.split(`
|
|
3
3
|
`);s=c.pop()??``;for(let e of c){let t=e.trim();if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(r)try{n(JSON.parse(r))}catch{}}}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;r?.(e instanceof Error?e:Error(String(e)))}})(),()=>i.abort()}function $r(e,t,n){let r=!1,i=Math.max(0,t),a=0,o=null,s,c=n.maxAttempts??10,l=()=>{r=!0,s!=null&&clearTimeout(s),s=void 0,o?.(),o=null},u=()=>{r||n.signal?.aborted||(o?.(),o=Qr(e,i,e=>{typeof e.seq==`number`&&Number.isFinite(e.seq)&&(i=Math.max(i,e.seq)),n.onEvent(e),e.type===`status`&&Zr(e.status)&&(n.onTerminal?.(e),l())},t=>{r||n.signal?.aborted||(async()=>{a+=1;try{let r=await Xr(e);if(r?.ok&&typeof r.seq==`number`&&(i=Math.max(i,r.seq)),r?.ok&&Zr(r.status)){let e={type:`status`,status:r.status,seq:r.seq,assistant:r.assistant};n.onEvent(e),n.onTerminal?.(e),l();return}if(r&&r.ok===!1){n.onGaveUp?.(Error(t.message||`run not found`)),l();return}}catch{}if(a>=c){n.onGaveUp?.(t),l();return}let r=Math.min(4e3,250*a);s=setTimeout(u,r)})()}))},d=()=>l();return n.signal?.addEventListener(`abort`,d),u(),()=>{n.signal?.removeEventListener(`abort`,d),l()}}function ei(e){for(let t of e)if(t.role===`user`&&typeof t.content==`string`){let e=t.content.trim();if(e)return e}return``}function ti(e,t){let n=(e||``).trim()||`新对话`;return n===`新对话`||n===it(t)}function ni(e){let t=String(e??``).trim().replace(/^["「『]+|["」』]+$/g,``).replace(/\s+/g,` `).replace(/^标题[::]\s*/i,``);return t=t.replace(/[。.!!]+$/g,``).trim(),t?t.length>28?`${t.slice(0,28)}…`:t:``}async function ri(e,t,n){let r=t.trim().slice(0,800);if(!r)return null;let i=[{role:`system`,content:`你为对话生成侧栏短标题。只输出标题本身:中文优先,不超过 16 个字,无引号、无标点收尾、无解释。`},{role:`user`,content:`用户首条消息:\n${r}\n\n请给出标题:`}];try{return ni(await ze(e,i,n))||null}catch{return null}}function ii(e){let t=Array.isArray(e.messages)?e.messages:[],n=0,r=0,i=0,a=0,o=0;for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;t.role===`user`?n+=1:t.role===`assistant`&&(r+=1);let s=t.usage;if(s&&typeof s==`object`){let e=s;typeof e.promptTokens==`number`&&(i+=e.promptTokens),typeof e.completionTokens==`number`&&(a+=e.completionTokens),typeof e.totalTokens==`number`?o+=e.totalTokens:(typeof e.promptTokens==`number`||typeof e.completionTokens==`number`)&&(o+=(Number(e.promptTokens)||0)+(Number(e.completionTokens)||0))}}let s=e.goal,c=!!(s&&s.status!==`cleared`&&s.text?.trim());return{sessionId:e.id,title:e.title||`新对话`,messageCount:t.length,userCount:n,assistantCount:r,promptTokens:i,completionTokens:a,totalTokens:o,createdAt:e.createdAt,updatedAt:e.updatedAt,hasGoal:c,todoCount:Array.isArray(e.todos)?e.todos.length:0}}function ai(e){let t=new Date(e.createdAt).toLocaleString(),n=new Date(e.updatedAt).toLocaleString();return[`会话:${e.title}`,`消息 ${e.messageCount}(用户 ${e.userCount} / 助手 ${e.assistantCount})`,`用量≈ 输入 ${e.promptTokens} · 输出 ${e.completionTokens} · 合计 ${e.totalTokens}`,`待办 ${e.todoCount} · 目标 ${e.hasGoal?`有`:`无`}`,`创建 ${t}`,`更新 ${n}`].join(`
|
|
4
4
|
`)}var oi=new Map,si=new Map,ci=40;function li(e,t,n=``){return`${e}:${t}:${n}`}function ui(e){for(;e.size>ci;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function di(e,t,n,r,i=``){let a=e===`outline`?oi:si,o=li(t,n,i),s=a.get(t);if(s&&s.stamp===o)return s.value;let c=r();return a.set(t,{stamp:o,value:c}),ui(a),c}var fi=`/__tb_sessions/log`;function pi(e){let t=String(e.userContent??``).trim(),n=String(e.assistantContent??``).trim(),r=String(e.reasoning??``).trim(),i=[];if(t&&i.push({role:`user`,content:t}),n||r){let e={role:`assistant`,content:n};r&&(e.reasoning_content=r),i.push(e)}return i}async function mi(e){try{let t=await fetch(fi,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,path:n.path}:{ok:!1,error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function hi(e){return String(e??``).trim()}function gi(e,t=80){let n=hi(e).replace(/\s+/g,` `);return n?n.length>t?`${n.slice(0,t)}…`:n:``}function _i(e,t=40){let n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];if(a.role===`user`){let e=hi(a.content),t=gi(e);if(!t)continue;r&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),r={text:e,preview:t,time:typeof a.time==`number`?a.time:void 0,messageIndex:i}}else if(a.role===`assistant`&&r){let e=hi(a.content),t=hi(a.reasoning)||void 0;n.push({index:n.length+1,userPreview:r.preview,assistantPreview:gi(e)||(t?`(含思考)`:``),userText:r.text,assistantText:e,reasoning:t,reasoningDuration:typeof a.reasoningDuration==`number`?a.reasoningDuration:void 0,userTime:r.time,assistantTime:typeof a.time==`number`?a.time:void 0,endMessageIndex:i}),r=null}if(n.length>=t)break}return r&&n.length<t&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),n}function vi(e,t){let n=String(t??``).trim();return!n||n===`inherit`||n===e.model?e:{...e,model:n}}var yi=`/__tb_fs`,bi=`你可以使用 office_to_pdf:优先用本机 LibreOffice 转为 PDF;若未安装,则对 docx/xlsx/pptx 降级抽取正文为同目录 .extracted.md(需写权限)。`,xi={type:`function`,function:{name:`office_to_pdf`,description:`Convert Office docs to PDF via LibreOffice when available; otherwise extract text to .extracted.md for docx/xlsx/pptx.`,parameters:{type:`object`,properties:{path:{type:`string`,description:`Input file path relative to workspace (or absolute when allowed)`},outDir:{type:`string`,description:`Optional output directory (default: same as input)`}},required:[`path`]}}};async function Si(e,t,n){if(e!==`office_to_pdf`)return JSON.stringify({error:`unknown tool: ${e}`});let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({ok:!1,error:`invalid JSON arguments`})}let i=String(r.path??``).trim();if(!i)return JSON.stringify({ok:!1,error:`path is required`});try{let e=await(await fetch(`${yi}/office-to-pdf`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i,outDir:typeof r.outDir==`string`?r.outDir:void 0,access:n}),signal:AbortSignal.timeout(13e4)})).json().catch(()=>({}));return JSON.stringify(e,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}var Ci=`/__tb_fs`,wi=`你可以使用 load_workspace_dependencies:查询本机 node / npm / pnpm / python 等可执行文件绝对路径(需本地 fs 服务)。`,Ti={type:`function`,function:{name:`load_workspace_dependencies`,description:`Resolve absolute paths of common runtimes/package managers on this machine (node, npm, pnpm, python, …).`,parameters:{type:`object`,properties:{}}}};async function Ei(e){if(e!==`load_workspace_dependencies`)return JSON.stringify({error:`unknown tool: ${e}`});try{let e=await fetch(`${Ci}/workspace-dependencies`,{signal:AbortSignal.timeout(8e3)}),t=await e.json().catch(()=>({}));if(!e.ok){let n=typeof t==`object`&&t&&`error`in t?String(t.error):`HTTP ${e.status}`;return JSON.stringify({ok:!1,error:n})}return JSON.stringify(t,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}function Di(e){return Array.isArray(e)}function Oi(e){return Di(e)?e.some(e=>e.type===`image_url`):!1}function ki(e){let t=e.filter(e=>e.type===`text`).map(e=>e.text),n=e.filter(e=>e.type===`image_url`).length,r=n>0?`[image-offload] 已卸载 ${n} 张图片(超预算,仅保留最近附图)。`:``;return[{type:`text`,text:[...t,r].filter(Boolean).join(`
|
|
5
5
|
`)||r||`(图片已卸载)`}]}function Ai(e,t={}){let n=Math.max(0,Math.floor(t.keepRecentImageMessages??1)),r=[];for(let t=0;t<e.length;t++){let n=e[t];n.role===`user`&&Oi(n.content)&&r.push(t)}if(r.length<=n)return e;let i=new Set(r.slice(-n)),a=!1,o=e.map((e,t)=>e.role!==`user`||!Oi(e.content)||i.has(t)||!Di(e.content)?e:(a=!0,{...e,content:ki(e.content)}));return a?o:e}var ji=/(\s*(TP-[A-Za-z0-9_-]+)\s*)|\(\s*(TP-[A-Za-z0-9_-]+)\s*\)/i;function Mi(e){let t=String(e||``).replace(/\r\n/g,`
|
|
@@ -214,7 +214,7 @@ ${t}
|
|
|
214
214
|
`:`按文档条目 / 章节自上而下的顺序编写用例,不要重排。
|
|
215
215
|
`;c=`### 需求文档:${o.path}\n${t}${e}`}catch(e){B(e instanceof Error?e.message:String(e));return}}else if(o?.kind===`stories`){if(!y){B(We?`需求分析服务未就绪,暂时读不到用户故事;可切回「需求文档」`:`需求分析插件未启用,读不到用户故事;可切回「需求文档」`);return}if(!ft){B(`所选需求分析记录已不存在,请重新选择`);return}if(!mt){B(`请至少勾选一条用户故事,或点「全选」`);return}s=ft.title;let e=ft.outline??[];if(e.length&&(l=[...Ae(e).entries()].sort((e,t)=>e[1]-t[1]).map(([e])=>e)),c=`### 用户故事:${ft.title}\n按下列用户故事逐条覆盖;用例顺序以「需求条目(RO)→ 条目内测试点(TP)」为准,模块字段取来源需求的章节 / Ideal 小模块原文(优先于 US 编号)。\n${Oe(ft,a)}`,ft.sourcePath)try{let e=await Nl(ft.sourcePath),t=Ee(e);t&&(c=`${t}\n\n${c}`)}catch{}}let u=[];for(let e of R)try{let t=await Ne(`knowledge`,e);u.push(`\n### 知识库:${e}\n${t.content}`)}catch{u.push(`\n### 知识库:${e}\n(无法读取)`)}let f=ht.filter(e=>gt.includes(e.id)),m=f.length?Ur(f,r):[];i({active:!0,caseType:D,outputFormat:be,reqPath:o?.kind===`doc`?o.path:void 0,reqSource:o,docTitle:s||void 0,reqBlock:[c,...u].filter(Boolean).join(`
|
|
216
216
|
|
|
217
|
-
`)||void 0,templateId:e?.id,templateTitle:e?.title,promptPath:le,knowledgePaths:R.length?[...R]:void 0,testPointIds:m.length?m.map(e=>e.id):void 0,outlineOrder:l,testPointBlock:m.length?Vr(m,r):void 0,templateHeaders:e?.headers?.length?e.headers:[...he],templateBody:(e?.body||``).trim(),promptBody:pe.trim(),confirmedAt:Date.now(),linkedCasePath:n?.linkedCasePath}),t()}finally{Ce(!1)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Gt,{open:e,onClose:t,title:`生成测试用例 · 配置`,closeAriaLabel:`关闭生成测试用例面板`,widthClass:`max-w-3xl`,escDisabled:we!==null,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 border-t border-stone-100 px-4 py-3 flex items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 min-w-0 truncate text-[11px] text-stone-400`,children:`配置仅对当前会话生效,可在输入区胶囊里再改`}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:Se||!a||!Ie||!et,onClick:()=>void bt(),className:`h-9 px-5 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[a?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写文档库。`}),z?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:z}):null,(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-1 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`order-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:`用例类型`}),(0,Q.jsx)(oe,{options:T.map(e=>({value:e.id,label:e.label})),value:D,onChange:O,dimWhenOpen:!0})]}),(0,Q.jsxs)(`div`,{className:`order-3 min-w-0 lg:order-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:[`用例模板`,(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,Qe,` · `,Je.templateFolder,`)`]})]}),(0,Q.jsx)(Ze,{options:lt,value:Ke?.id??``,onChange:ne,allowEmpty:!1,disabled:!He,placeholder:He?lt.length?`搜索并选择模板…`:`暂无「${Je.templateFolder}」模板`:`测试模板库未启用`})]}),(0,Q.jsxs)(`div`,{className:`order-2 flex min-w-0 items-start justify-end gap-1 pt-1.5 lg:order-3`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-[#4176e6] transition-colors hover:border-[#4176e6]/40 hover:bg-[#edf3fe]`,onClick:()=>{Fe(null),Te(`add`)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-stone-600 transition-colors hover:border-stone-300 hover:bg-stone-50`,onClick:()=>{Fe(null),Te(`edit`)},children:`编辑`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-red-600 transition-colors hover:border-red-300 hover:bg-red-50 disabled:opacity-40 disabled:hover:border-stone-200 disabled:hover:bg-transparent`,disabled:T.length<=1,onClick:()=>{Fe(null),Te(`delete`)},children:`删除`})]}),(0,Q.jsx)(`div`,{className:`order-4 min-w-0 lg:order-4`,children:He?Ke?.headers?.length?(0,Q.jsx)(Ye,{fields:Ke.headers}):null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「测试模板库」后再选择;未启用时按默认字段生成。`})})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-4 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:`输出格式`}),(0,Q.jsx)(oe,{options:jl,value:be,onChange:xe,dimWhenOpen:!0})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:`引用知识库(可多选)`}),(0,Q.jsx)(Xe,{options:dt,values:R,onChange:_e,disabled:!Re,placeholder:Re?dt.length?`选择知识库文档…`:`暂无知识库文档`:`知识库管理未启用`}),Re?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「知识库管理」后再引用。`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`需求来源`}),(0,Q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>g(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${p===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`需求文档`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!y,onClick:()=>{y&&g(`stories`)},className:`h-7 rounded-md px-2.5 text-xs transition-colors disabled:opacity-40 ${p===`stories`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`用户故事`})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:p===`stories`?`来自「需求分析」拆好的故事:按 US 编号逐条覆盖,改动后重新生成即可`:`来自「需求文档库」的原始文档`})]}),(0,Q.jsx)(`div`,{className:`mt-2`,children:p===`stories`?(0,Q.jsx)(Ze,{options:_.map(e=>({value:e.id,label:`${e.title}(${e.stories.length} 个故事)`})),value:x,onChange:e=>{S(e);let t=_.find(t=>t.id===e);w(t?.stories.map(e=>e.id)??[]),ye([])},allowEmpty:!1,disabled:!y,placeholder:We?y?_.length?`搜索并选择需求分析记录…`:`暂无需求分析记录,请先在「需求分析」拆解`:`需求分析服务未就绪`:`需求分析插件未启用`}):(0,Q.jsx)(Ze,{options:ct,value:d,onChange:f,allowEmpty:!1,disabled:!Be,placeholder:Be?ct.length?`搜索并选择需求文档…`:`请先在需求文档库中上传`:`需求文档库未启用`})}),p===`stories`?(0,Q.jsxs)(`div`,{className:`mt-2 rounded-lg bg-stone-50/80 p-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 text-[11px] text-stone-500`,children:[`选择故事`,(0,Q.jsxs)(`span`,{className:`ml-1 text-stone-400`,children:[mt,`/`,pt.length]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#4176e6] hover:underline`,onClick:()=>w(pt.map(e=>e.id)),children:`全选`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-500 hover:underline`,onClick:()=>w([]),children:`全不选`})]}),pt.length?(0,Q.jsx)(`div`,{className:`mt-1.5 grid max-h-56 grid-cols-1 gap-x-4 overflow-y-auto sm:grid-cols-2`,children:pt.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-1.5 py-1 text-xs`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:C.includes(e.id),onChange:t=>w(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:e.id}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ae,{text:e.title,className:`block truncate text-stone-800`})}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:e.priority})]},e.id))}):(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:x?`这份分析还没有拆出用户故事`:`先选择一份需求分析记录`}),We?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:`需求分析插件已关闭;用户故事来源暂不可用,可改用「需求文档」。`})]}):Be?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「需求文档库」后再选择。`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-stone-500`,children:[`测试点(可多选)`,ht.length?(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[gt.length,`/`,ht.length]}):null]}),ht.length?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`text-[#4176e6] transition-colors hover:text-[#3565c7]`,onClick:()=>ye(ht.map(e=>e.id)),children:`全选`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-stone-500 transition-colors hover:text-stone-700`,onClick:()=>ye([]),children:`清空`})]}):null]}),(0,Q.jsx)(Xe,{options:_t,values:gt,onChange:ye,disabled:!_t.length,placeholder:vt}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:yt})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:[`提示词`,(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,Qe,` 挂载)`]})]}),(0,Q.jsx)(`button`,{type:`button`,disabled:!Ie,onClick:()=>fe(!0),className:`flex h-9 w-full min-w-0 items-center gap-2 rounded-lg border px-2.5 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${tt?`border-amber-300 bg-amber-50/50 text-amber-700 hover:border-amber-400`:`border-stone-200 bg-white text-stone-800 hover:border-stone-300`}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:Ie?et?et.replace(/\.md$/i,``):j?`未挂载提示词 · 点击挂载`:`读取提示词…`:`提示词管理未启用`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:Ie?tt?j?`当前类型还没有挂载提示词,未挂载时无法确认。`:`正在读取提示词列表…`:`每个用例类型只挂一份提示词:换类型会切到该类型挂载的那份。`:`请先在「我的插件」中启用「提示词管理」后再挂载。`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-stone-50/60 px-4 py-3`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-stone-600`,children:`本次配置`}),(0,Q.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-4 gap-y-2 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`用例类型`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:Qe})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`用例模板`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:Ke?.title||`—`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`输出格式`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:jl.find(e=>e.value===be)?.label??be})]}),(0,Q.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`需求来源`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:p===`stories`?ft?`用户故事 · ${ft.title}(${mt}/${pt.length} 条)`:`用户故事 · 未选择`:d?`需求文档 · ${d}`:`需求文档 · 未选择`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`引用知识库`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:R.length?`${R.length} 个文档`:`未引用`})]}),(0,Q.jsxs)(`div`,{className:`col-span-2 grid min-w-0 grid-cols-2 gap-x-4 sm:col-span-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`测试点`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:gt.length?`${gt.length} 条`:`未选择`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`提示词`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:et?`${et.replace(/\.md$/i,``)}(${Qe})`:`未挂载`})]})]})]}),(0,Q.jsx)(`p`,{className:`mt-2.5 text-[10px] leading-4 text-stone-400`,children:`确认后输入区出现「生成测试用例」胶囊,直接发送或补充范围说明即可;点 × 取消后按普通对话修改,不再整批生成。`})]})]}),(0,Q.jsx)(Al,{mode:we,currentLabel:Je.label,templateFolder:Je.templateFolder,error:Me??``,onClose:()=>{Te(null),Fe(null)},onSubmit:ot,onDelete:st}),(0,Q.jsx)(tn,{open:de,prompts:ut,value:et,force:!et,onClose:()=>fe(!1),onMount:nt,onCreate:it,target:`用例类型`,createHint:`会按用例生成的模板生成一份(逐条覆盖、边界 / 异常 / 优先级),之后可在「提示词管理」里改。`})]})}function Fl({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(()=>Ri()),[u,d]=(0,K.useState)(Ri()[0]?.id??`case`),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),v=c.find(e=>e.id===u)??c[0]??zi(u);function y(e){let t=Ri();l(t),d(n=>{let r=e??n;return t.some(e=>e.id===r)?r:t[0]?.id??n})}function b(e){let t=m===`add`;try{if(t){let t=Vi(e);y(t.id),M(`已新增提示词类型「${t.label}」`,`success`)}else Hi(u,e),y(u),M(`已重命名为「${e.trim()}」`,`success`);h(null),_(null)}catch(e){let n=e instanceof Error?e.message:String(e);_(n),M(`${t?`新增`:`保存`}提示词类型失败:${n}`,`error`)}}function x(){try{let e=v.label,t=Ui(u);l(t),d(t[0]?.id??``),h(null),_(null),p(null),M(`已删除提示词类型「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),M(`删除提示词类型失败:${t}`,`error`)}}(0,K.useEffect)(()=>{e&&(y(n?.kind),s(n?.titleHint??``),d(n?.kind??Ri()[0]?.id??`case`),h(null),_(null),p(null),Pe(`prompts`).then(a))},[e,n]);function S(){p(null),i?(r({active:!0,titleHint:o.trim(),kind:u,confirmedAt:Date.now(),linkedPromptPath:n?.linkedPromptPath}),t()):p(`本地文档服务未就绪,无法写入提示词库`)}return(0,Q.jsxs)(Gt,{open:e,onClose:t,title:`生成提示词 · 配置`,closeAriaLabel:`关闭生成提示词面板`,escDisabled:m!==null,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!i,onClick:S,className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写提示词库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选类型生成可复用提示词:确认后输入区出现「生成提示词」胶囊,描述编写要求后发送;点 × 取消后按普通对话修改,不再整批生成。质检通过后写入提示词库。`}),f?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:f}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 text-xs font-medium text-stone-500`,children:`提示词类型`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-[#4176e6] transition-colors hover:border-[#4176e6]/40 hover:bg-[#edf3fe]`,onClick:()=>{h(`add`),_(null)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-stone-600 transition-colors hover:border-stone-300 hover:bg-stone-50`,onClick:()=>{h(`edit`),_(null)},children:`编辑`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-red-600 transition-colors hover:border-red-300 hover:bg-red-50 disabled:opacity-40 disabled:hover:border-stone-200 disabled:hover:bg-transparent`,disabled:c.length<=1,onClick:()=>{h(`delete`),_(null)},children:`删除`})]}),(0,Q.jsx)(oe,{options:c.map(e=>({value:e.id,label:e.label})),value:u,onChange:d,dimWhenOpen:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4`,children:v.hint}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4`,children:`类型决定生成时给模型的写作侧重(例如用例提示词要求约束 JSON 与模板字段), 同时出现在这份提示词的配置标签里;不影响你在主输入框补充的具体要求。`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,htmlFor:`pg-title`,children:`期望名称`}),(0,Q.jsx)(`input`,{id:`pg-title`,value:o,onChange:e=>s(e.target.value),placeholder:`如:接口测试用例提示词.md`,className:`mt-1 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-4`,children:`可填期望文件名;留空则由模型自拟。具体编写要求在主输入框描述。`})]}),(0,Q.jsx)(kl,{mode:m,entityLabel:`提示词类型`,currentLabel:v.label,placeholder:`如:缺陷分析提示词`,error:g??``,onClose:()=>{h(null),_(null)},onSubmit:b,onDelete:x,hint:e=>(0,Q.jsxs)(Q.Fragment,{children:[`类型名称会写入这份提示词的配置标签:`,e||`名称`]}),deleteMessage:e=>(0,Q.jsxs)(Q.Fragment,{children:[`确定删除「`,e,`」?已生成的提示词与文档不会被删除,只是不能再选这个类型。`]})})]})}function Il({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(()=>$i()),[u,d]=(0,K.useState)($i()[0]??`测试规范`),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null);function v(e){let t=$i();l(t),d(n=>{let r=e??n;return t.includes(r)?r:t[0]??n})}function y(e){let t=m===`add`;try{if(t){let t=ta(e);v(t),M(`已新增分类「${t}」`,`success`)}else{let t=na(u,e);v(t),M(`已重命名为「${t}」`,`success`)}h(null),_(null)}catch(e){let n=e instanceof Error?e.message:String(e);_(n),M(`${t?`新增`:`保存`}分类失败:${n}`,`error`)}}function b(){try{let e=u,t=ra(u);l(t),d(t[0]??``),h(null),_(null),p(null),M(`已删除分类「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),M(`删除分类失败:${t}`,`error`)}}(0,K.useEffect)(()=>{e&&(v(n?.category),s(n?.titleHint??``),d(n?.category??$i()[0]??`测试规范`),h(null),_(null),p(null),Pe(`knowledge`).then(a))},[e,n]);function x(){p(null),i?(r({active:!0,titleHint:o.trim(),category:u,confirmedAt:Date.now(),linkedKnowledgePath:n?.linkedKnowledgePath}),t()):p(`本地文档服务未就绪,无法写入知识库`)}return(0,Q.jsxs)(Gt,{open:e,onClose:t,title:`生成知识库 · 配置`,closeAriaLabel:`关闭生成知识库面板`,escDisabled:m!==null,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!i,onClick:x,className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写知识库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选分类沉淀测试规范、方法论或环境约定:确认后输入区出现「生成知识库」胶囊,粘贴或描述素材后发送;点 × 取消后按普通对话修改,不再整批生成。质检通过后写入知识库,可在「知识库管理」中查看与 @ 引用。`}),f?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:f}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 text-xs font-medium text-stone-500`,children:`分类`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-[#4176e6] transition-colors hover:border-[#4176e6]/40 hover:bg-[#edf3fe]`,onClick:()=>{h(`add`),_(null)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-stone-600 transition-colors hover:border-stone-300 hover:bg-stone-50`,onClick:()=>{h(`edit`),_(null)},children:`编辑`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-red-600 transition-colors hover:border-red-300 hover:bg-red-50 disabled:opacity-40 disabled:hover:border-stone-200 disabled:hover:bg-transparent`,disabled:c.length<=1,onClick:()=>{h(`delete`),_(null)},children:`删除`})]}),(0,Q.jsx)(oe,{options:c.map(e=>({value:e,label:e})),value:u,onChange:d,dimWhenOpen:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4`,children:`分类决定两件事:生成时告诉模型按哪类知识写(规范 / 方法论 / 环境约定侧重不同), 入库时写进文档 frontmatter 的 category,知识库管理里就按它归类展示。`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,htmlFor:`kg-title`,children:`期望名称`}),(0,Q.jsx)(`input`,{id:`kg-title`,value:o,onChange:e=>s(e.target.value),placeholder:`如:接口自动化环境约定.md`,className:`mt-1 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-4`,children:`可填期望文件名;留空则由模型自拟。素材与编写要求在主输入框描述。`})]}),(0,Q.jsx)(kl,{mode:m,entityLabel:`知识库分类`,currentLabel:u,placeholder:`如:安全基线`,error:g??``,onClose:()=>{h(null),_(null)},onSubmit:y,onDelete:b,hint:()=>(0,Q.jsx)(Q.Fragment,{children:`分类写入文档 frontmatter,文件平铺存放于 知识库管理/;改名不会自动迁移已有文件。`}),deleteMessage:e=>(0,Q.jsxs)(Q.Fragment,{children:[`确定删除「`,e,`」?已入库的知识文档不会被删除,但该分类将不能再用于生成。`]})})]})}function Ll({task:e,onClose:t,onSave:n,onRemove:r,readOnly:i=!1}){let[a,o]=(0,K.useState)(``),s=!!e;(0,K.useEffect)(()=>{o(e?.body??``)},[e]);let c=!!e&&a.trim()!==e?.body.trim();return(0,Q.jsxs)(O,{open:s,onClose:t,className:`relative z-110`,children:[(0,Q.jsx)(k,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Q.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Q.jsxs)(E,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[85vh] w-full max-w-2xl flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`absolute top-3.5 right-3.5 flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,"aria-label":`关闭`,children:`✕`}),(0,Q.jsx)(D,{className:`pr-8 text-base font-semibold text-stone-900`,children:e?.label||`任务要求`}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,Q.jsx)(`span`,{children:i?`已随消息发送给模型`:`发送时这段要求会随消息一起带给模型`}),e?.detail?(0,Q.jsxs)(`span`,{className:`truncate`,children:[`· `,e.detail]}):null]}),(0,Q.jsx)(`textarea`,{value:a,onChange:e=>{i||o(e.target.value)},readOnly:i,spellCheck:!1,className:`mt-3 min-h-[240px] flex-1 resize-none overflow-y-auto rounded-lg border border-stone-200 px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-stone-700 outline-none ${i?`bg-stone-50/80`:`bg-stone-50/60 focus:border-[#4176e6]/40 focus:bg-white`}`}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2`,children:[i||!r?(0,Q.jsx)(`span`,{}):(0,Q.jsx)(`button`,{type:`button`,onClick:r,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-500 transition-colors hover:border-red-300 hover:bg-red-50 hover:text-red-600`,children:`移除`}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:i||!n?(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-sm text-white transition-colors hover:bg-[#3566d0]`,children:`关闭`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!a.trim(),onClick:()=>n(a.trim()),className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-sm text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:bg-stone-300`,children:c?`保存修改`:`完成`})]})})]})]})})]})}var Rl={user:`用户档案`,memory:`长期记忆`,key:`项目关键记忆`,project:`项目日志`};function zl(e){return e?e.replace(/\\/g,`/`).replace(/^\/Users\/[^/]+/,`~`):``}var Bl={project:{title:`项目日志`,fileHint:`MEMORY.md`,desc:`项目进展流水账,按需查阅,默认不注入上下文。`,curated:!1},key:{title:`项目关键记忆`,fileHint:`KEY.md`,desc:`项目关键约定与事实;写入需经待确认记忆建议采纳后注入。`,curated:!0},memory:{title:`长期记忆`,fileHint:`MEMORY.md`,desc:`全局环境与跨项目事实,注入所有会话;写入需审查建议并经确认。`,curated:!0}},Vl=[{id:`guide`,label:`指南`},{id:`suggestions`,label:`待确认记忆建议`},{id:`project`,label:`项目日志`},{id:`key`,label:`项目关键记忆 KEY.md`},{id:`memory`,label:`长期记忆 MEMORY.md`},{id:`agents`,label:`全局规则 AGENTS.md`},{id:`archive`,label:`归档`},{id:`settings`,label:`设置`}];function Hl({live:e,pluginOn:t,workspacePath:n=``,onHealthChange:r}){let[i,a]=(0,K.useState)(`suggestions`),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)({}),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)([]),[m,h]=(0,K.useState)([]),[g,_]=(0,K.useState)(`memory`),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)([]),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(!1),[O,k]=(0,K.useState)(null),[ee,te]=(0,K.useState)(null),[ne,re]=(0,K.useState)(null),A=n.trim(),ie=(0,K.useRef)(r);ie.current=r;let ae=(0,K.useCallback)(async()=>{if(!e)s(null),l({}),p([]),x([]),ie.current?.(null);else{C(null);try{let[e,t,n,r,a]=await Promise.all([xr(),br(A,`all`),hr(),Cr(),hn().catch(()=>null)]);s(e),l(t.tracks),d(t.projectId||``),p(n),y(r),x(a?.files?.length?a.files:a?.text?[{path:`AGENTS.md`,name:`AGENTS.md`}]:[]),i===`archive`&&h(await Er(g,A)),ie.current?.(e)}catch(e){C(e instanceof Error?e.message:String(e))}}},[e,A,i,g]);if((0,K.useEffect)(()=>{ae()},[ae]),!t)return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`会话记忆未启用`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`在「我的插件」中打开「会话记忆」后,可在此管理记忆轨与待确认记忆建议`})]});if(!e)return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`会话记忆中间件未就绪`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`本地记忆服务未就绪`})]});let oe=i===`memory`||i===`key`,M=i===`memory`||i===`key`||i===`project`,N=M?c[i]?.entries??[]:[],P=M?c[i]?.path:null,se=o?.path||`.lantern/local/memories`;async function ce(e){D(!0);try{await vr(e),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}async function F(e){D(!0);try{await mr(e),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}function I(e){oe&&te(e)}async function le(){if(ee==null||!oe)return;let e=ee;te(null),D(!0);try{await G(i,e,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}async function ue(){if(ne==null)return;let e=ne;re(null),D(!0);try{await Ar(g,e,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}function de(e){k(e)}async function fe(){if(O==null)return;let e=O;k(null),D(!0);try{await yr(i,e,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}async function pe(){if(oe&&w.trim()){D(!0);try{await jr(i,w.trim(),A),T(``),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}}async function L(e){D(!0);try{let t=await Mr(e);y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}function me(e){let t=Bl[e],n=e===`key`?`KEY.md`:t.fileHint,r=e===`key`?`项目关键记忆 ${n}`:e===`memory`?`长期记忆 ${n}`:t.title,i=zl(P)||`${zl(se)}/…/${n}`;return(0,Q.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 flex-wrap min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:r}),t.curated?null:(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-stone-100 text-stone-500 border border-stone-200`,children:`只读追加`}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-stone-400 tabular-nums`,children:[N.length,` 条`]}),(0,Q.jsx)(`span`,{className:`max-w-full break-all whitespace-normal text-[11px] text-[#4176e6] bg-[#edf3fe] border border-[#4176e6]/20 rounded-lg px-2 py-0.5 font-mono leading-4`,"data-hint":P||i,children:i})]}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5 break-words`,children:t.desc}),A?(0,Q.jsxs)(`p`,{className:`text-[11px] text-stone-400 break-all`,children:[`当前会话工作目录:`,(0,Q.jsx)(`span`,{className:`font-mono`,children:A}),u?(0,Q.jsxs)(Q.Fragment,{children:[` · `,`项目 id `,(0,Q.jsx)(`span`,{className:`font-mono`,children:u.slice(0,12)})]}):null]}):null]})}return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 flex flex-wrap items-center gap-2 px-4 py-2 border-b border-stone-200/80`,children:[Vl.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`h-7 px-2.5 text-xs rounded-md whitespace-normal text-left leading-tight ${i===e.id?`bg-stone-900 text-white`:`text-stone-600 hover:bg-stone-100`}`,children:[e.label,e.id===`suggestions`&&f.length>0?(0,Q.jsxs)(`span`,{className:`ml-1 tabular-nums`,children:[`(`,f.length,`)`]}):null]},e.id)),(0,Q.jsxs)(`span`,{className:`text-[11px] text-stone-400 tabular-nums`,children:[o?.entryCount??0,` 条 · 待确认 `,o?.suggestionCount??f.length]})]}),S?(0,Q.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:S}):null,(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4`,children:[i===`guide`?(0,Q.jsxs)(`div`,{className:`space-y-3 max-w-2xl`,children:[(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`确认制:为什么必须你点头`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`记忆会改变后续对话行为。长期记忆 / 项目关键记忆经「待确认记忆建议」采纳后才写入并注入;项目日志可直写但不注入。`})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`待确认记忆建议:AI 只提议,你拍板`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`后台或对话中产出的记忆建议进入独立队列。采纳可写入对应轨;拒绝则丢弃。`}),(0,Q.jsxs)(`ul`,{className:`mt-2 space-y-1.5 text-xs text-stone-600`,children:[(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2 break-words`,children:`采纳 → 长期记忆 MEMORY.md / 项目关键记忆 KEY.md`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`拒绝 → 丢弃,不落盘`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`各轨文件(对齐 dsh)`}),(0,Q.jsxs)(`ul`,{className:`mt-2 space-y-1.5 text-xs text-stone-600`,children:[(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`项目日志 · 项目目录 MEMORY.md(不注入)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`项目关键记忆 KEY.md(注入,需确认)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`长期记忆 MEMORY.md(注入,需确认)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`全局规则:展示工作区 AGENTS.md 等规则文件`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`编辑与维护`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`可在本 Tab 浏览条目、手动添加(注入轨)、归档或删除。文件为 § 分隔结构化记忆,用外部编辑器打开时请谨慎修改。`}),(0,Q.jsxs)(`p`,{className:`mt-2 text-[11px] text-amber-700/90`,children:[`存储目录:`,(0,Q.jsx)(`code`,{className:`font-mono`,children:se})]})]})]}):null,i===`suggestions`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`待确认记忆建议`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-5`,children:`后台审查或对话沉淀产出的记忆建议:采纳后写入记忆文件并注入;拒绝则丢弃。`})]}),f.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-16 text-center text-sm text-stone-400`,children:`没有待确认的建议。`}):(0,Q.jsx)(`ul`,{className:`space-y-3`,children:f.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-amber-200/80 bg-amber-50/30 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-stone-400 mb-1 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-amber-100 text-amber-900 border border-amber-200 font-medium`,children:`待确认记忆建议`}),(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-white text-stone-600 border border-stone-200`,children:Rl[e.target]??e.target}),(0,Q.jsx)(`span`,{children:e.time}),e.hits&&e.hits>1?(0,Q.jsxs)(`span`,{children:[`×`,e.hits]}):null]}),(0,Q.jsx)(`p`,{className:`text-sm text-stone-800 whitespace-pre-wrap`,children:e.content}),e.reason?(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-stone-500`,children:[`原因:`,e.reason]}):null,(0,Q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void ce(e.id),className:`h-7 px-2.5 text-xs text-white bg-emerald-600 rounded-md hover:bg-emerald-700 disabled:opacity-40`,children:`采纳`}),(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void F(e.id),className:`h-7 px-2.5 text-xs text-stone-600 border border-stone-200 rounded-md hover:bg-stone-50 disabled:opacity-40`,children:`拒绝`})]})]},e.id))})]}):null,M?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[me(i),oe?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white p-3 space-y-2`,children:[(0,Q.jsx)(`textarea`,{value:w,onChange:e=>T(e.target.value),placeholder:i===`key`?`输入一条项目关键约定,例如:本仓库包管理器用 pnpm…`:`输入一条想长期记住的全局事实/惯例/环境…`,rows:3,className:`w-full text-sm rounded-lg border border-stone-200 px-3 py-2 focus:outline-none focus:border-[#4176e6] resize-y`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`手动写入会直接落盘;重要偏好更推荐走「待确认记忆建议」。`}),(0,Q.jsx)(`button`,{type:`button`,disabled:E||!w.trim(),onClick:()=>void pe(),className:`shrink-0 h-8 px-3 text-xs text-white bg-[#4176e6] rounded-lg disabled:opacity-40`,children:`保存`})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-stone-400`,children:`本轨由对话中 memory_append 自动追加,一般不注入上下文。`}),N.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-12 text-center text-sm text-stone-400`,children:`(文件不存在或为空)`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:N.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2.5 flex gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 text-sm text-stone-800 whitespace-pre-wrap`,children:e.text}),(0,Q.jsxs)(`div`,{className:`shrink-0 self-start flex flex-col gap-0.5`,children:[oe?(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void I(e.index),className:`h-7 px-2 text-[11px] text-stone-500 hover:bg-stone-50 rounded-md`,children:`归档`}):null,(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void de(e.index),className:`h-7 px-2 text-[11px] text-red-600 hover:bg-red-50 rounded-md`,children:`删除`})]})]},`${i}-${e.index}`))})]}):null,i===`agents`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`全局规则`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`工作区规则文件(AGENTS.md 等),随系统提示注入。`}),b.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-12 text-center text-sm text-stone-400`,children:`(未找到规则文件)`}):(0,Q.jsx)(`ul`,{className:`space-y-2 w-full`,children:b.map(e=>{let t=zl(e.abs)||zl(e.path)||e.label||e.path||e.name;return(0,Q.jsx)(`li`,{className:`w-full`,children:(0,Q.jsxs)(`div`,{className:`w-full flex items-center gap-4 rounded-xl border border-stone-200 bg-white px-4 py-3.5`,children:[(0,Q.jsx)(`span`,{className:`w-12 h-12 rounded-xl bg-[#edf3fe] text-[#4176e6] flex items-center justify-center text-[11px] font-semibold shrink-0`,children:(e.name.split(`.`).pop()||`MD`).toUpperCase()}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-medium text-stone-800 break-all`,children:e.name||`AGENTS.md`}),(0,Q.jsx)(`span`,{className:`block text-xs text-stone-400 break-all font-mono mt-1`,children:t})]}),(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>{C(null),D(!0),sn(e.path||e.name||`AGENTS.md`,we(),{abs:e.abs}).catch(e=>C(e instanceof Error?e.message:String(e))).finally(()=>D(!1))},className:`shrink-0 h-9 px-4 text-xs text-[#4176e6] border border-[#4176e6]/30 rounded-lg hover:bg-[#f5f8ff] disabled:opacity-40`,children:`打开文件`})]})},e.abs||e.path)})})]}):null,i===`archive`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`flex gap-2`,children:[`user`,`memory`,`key`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{_(e)},className:`h-7 px-2.5 text-xs rounded-md ${g===e?`bg-stone-800 text-white`:`border border-stone-200`}`,children:Rl[e]??e},e))}),m.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-stone-400 text-center py-10`,children:`暂无归档`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2.5 flex gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 text-sm text-stone-800 whitespace-pre-wrap`,children:e.text}),(0,Q.jsxs)(`div`,{className:`shrink-0 self-start flex flex-col gap-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void(async()=>{D(!0);try{await _r(g,e.index,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}})(),className:`h-7 px-2 text-[11px] text-emerald-700 hover:bg-emerald-50 rounded-md`,children:`转正`}),(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>re(e.index),className:`h-7 px-2 text-[11px] text-red-600 hover:bg-red-50 rounded-md`,children:`删除`})]})]},`a-${e.index}`))})]}):null,i===`settings`&&v?(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-md`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`每回合注入 USER / MEMORY / KEY`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:v.injectMemory,onChange:e=>void L({injectMemory:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`收尾提示写 project`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:v.perTurnProjectWrites,onChange:e=>void L({perTurnProjectWrites:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`重要事实用 suggest(KEY)`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:v.perTurnKeyWrites,onChange:e=>void L({perTurnKeyWrites:e.target.checked})})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-stone-400 leading-5 break-all`,children:[`存储目录:`,(0,Q.jsx)(`code`,{className:`font-mono`,children:o?.path??`.lantern/local/memories`}),`。memory/key 经待确认记忆建议后注入;project 不注入。`]})]}):null]}),(0,Q.jsx)(j,{open:O!=null,title:`删除记忆`,message:`永久删除该条目?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>k(null),onConfirm:()=>void fe()}),(0,Q.jsx)(j,{open:ee!=null,title:`归档记忆`,message:`归档该条目?归档后不再注入上下文。`,confirmLabel:`归档`,cancelLabel:`取消`,onClose:()=>te(null),onConfirm:()=>void le()}),(0,Q.jsx)(j,{open:ne!=null,title:`删除归档`,message:`永久删除该归档?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>re(null),onConfirm:()=>void ue()})]})}var Ul=`/`,Wl=[{id:`all`,label:`全部待办`},{id:`open`,label:`未完成`},{id:`done`,label:`已完成`}],Gl={urgent_important:`bg-red-500`,important:`bg-amber-500`,urgent:`bg-orange-500`,normal:`bg-stone-300`},Kl={urgent_important:`text-red-600`,important:`text-amber-600`,urgent:`text-orange-600`,normal:`text-stone-500`};function ql(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Jl(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return t?`${t[1]}/${t[2]}/${t[3]}`:``}function Yl(e,t){let n=Jl(e.dueDate),r=e.status===`done`||e.status===`cancelled`,i=Dn(e,t),a=``,o=`text-stone-500`;return r?a=Mn[e.status]:i===null?(a=`未设置截止`,o=`text-stone-400`):i<0?(a=`逾期 ${Math.abs(i)} 天`,o=`text-red-600`):i===0?(a=`今天截止`,o=`text-[#4176e6]`):a=`剩余 ${i} 天`,{due:n,remain:a,tone:r?`text-stone-400`:o}}function Xl(e){return[...e].filter(e=>e.status===`done`||e.status===`cancelled`).sort((e,t)=>e.updatedAt<t.updatedAt?1:-1).slice(0,30)}function Zl(e,t,n){if(t===`done`)return[{key:`done`,label:`已完成 / 已取消`,items:Xl(e)}];let r=e.filter(e=>{let t=Cn(e,n);return t!==`done`&&t!==`cancelled`}),i=[],a=[],o=[],s=[];for(let e of r){let t=Dn(e,n);t===null?s.push(e):t<0?i.push(e):t===0?a.push(e):o.push(e)}let c=[{key:`overdue`,label:`已逾期`,items:i,tone:`text-red-600`},{key:`today`,label:`今天截止`,items:a,tone:`text-[#4176e6]`},{key:`later`,label:`接下来`,items:o},{key:`undated`,label:`没有截止日期`,items:s}];return t===`all`&&c.push({key:`done`,label:`已完成 / 已取消`,items:Xl(e)}),c.filter(e=>e.items.length>0)}function Ql(e){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(`all`),[s,c]=(0,K.useState)({}),l=(0,K.useCallback)(async()=>{try{let e=await U();n(e),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,K.useEffect)(()=>{l();let e=window.setInterval(()=>void l(),15e3);return()=>window.clearInterval(e)},[l]);let u=ql(),d=(0,K.useMemo)(()=>t?Zl(t,a,u):[],[t,a,u]),f=(0,K.useMemo)(()=>{let e=t??[],n=0,r=0,i=0;for(let t of e){let e=Cn(t,u);if(e===`done`||e===`cancelled`)continue;i+=1;let a=Dn(t,u);a!==null&&a<0?n+=1:a===0&&(r+=1)}return{overdue:n,dueToday:r,open:i}},[t,u]);async function p(e){if(s[e.id])return;let t=e.status===`done`?`pending`:`done`;c(t=>({...t,[e.id]:!0})),n(n=>n&&n.map(n=>n.id===e.id?{...n,status:t}:n));try{await En(e.id,{status:t}),i(null)}catch(t){n(t=>t&&t.map(t=>t.id===e.id?{...t,status:e.status}:t)),i(t instanceof Error?t.message:String(t))}finally{c(t=>{let n={...t};return delete n[e.id],n})}}return e.live===!1?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`待办事项需要本地服务`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`当前未就绪(仅 npm run dev / 本地一体服务可用)`})]}):(0,Q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-stone-200/80`,children:(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[min(64rem,100%)] flex-wrap items-center gap-2 px-4 py-2 sm:px-8 lg:px-12`,children:[Wl.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-pressed":a===e.id,className:`h-7 px-2.5 text-xs rounded-md ${a===e.id?`bg-stone-900 text-white`:`text-stone-600 hover:bg-stone-100`}`,children:[e.label,e.id===`all`&&f.dueToday+f.overdue>0?(0,Q.jsx)(`span`,{className:`ml-1 tabular-nums`,children:f.dueToday+f.overdue}):null]},e.id)),(0,Q.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400 tabular-nums`,children:[`未完成 `,f.open,f.overdue?` · 逾期 ${f.overdue}`:``]}),(0,Q.jsx)(`a`,{href:`${Ul}todos/`,className:`text-[11px] text-[#4176e6] hover:underline shrink-0`,children:`打开待办页 →`})]})}),r?(0,Q.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-[min(64rem,100%)] px-4 sm:px-8 lg:px-12`,children:(0,Q.jsx)(`div`,{className:`px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:r})}):null,(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-4 py-3 sm:px-8 lg:px-12`,children:t===null?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):d.length===0?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-500`,children:a===`all`?`当前空间还没有待办`:a===`done`?`还没有已完成的待办`:`当前没有未完成的待办`}),(0,Q.jsx)(`a`,{href:`${Ul}todos/`,className:`mt-2 text-xs text-[#4176e6] hover:underline`,children:`去待办页新增 →`})]}):(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(64rem,100%)] space-y-5`,children:d.map(e=>(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`h3`,{className:`mb-2 flex items-center gap-1.5 px-0.5 text-[11px] font-medium ${e.tone??`text-stone-500`}`,children:[e.label,(0,Q.jsx)(`span`,{className:`text-stone-400 tabular-nums`,children:e.items.length})]}),(0,Q.jsx)(`ul`,{className:`list-none m-0 space-y-1.5 p-0`,children:e.items.map(e=>{let t=e.status===`done`||e.status===`cancelled`,n=Yl(e,u);return(0,Q.jsxs)(`li`,{className:`group flex min-w-0 items-start gap-2.5 rounded-xl border border-stone-200 bg-white px-3 py-2.5 hover:border-stone-300`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void p(e),"aria-label":t?`恢复 ${e.title}`:`完成 ${e.title}`,"aria-pressed":t,className:`mt-0.5 grid h-4 w-4 shrink-0 place-items-center rounded-full border transition-colors ${t?`border-[#4176e6] bg-[#4176e6] text-white`:`border-stone-300 text-transparent hover:border-[#4176e6]`}`,children:(0,Q.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`10`,height:`10`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`m4 10 4 4 8-9`})})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-5 ${t?`text-stone-400 line-through`:`text-stone-800`}`,children:e.title}),t?(0,Q.jsx)(`span`,{className:`shrink-0 pt-0.5 text-[11px] text-stone-400`,children:Mn[e.status]}):e.priority?(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 pt-0.5 text-[11px] ${Kl[e.priority]??`text-stone-400`}`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${Gl[e.priority]??`bg-stone-300`}`}),W[e.priority]]}):null]}),(0,Q.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[11px] leading-4`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-stone-400 tabular-nums`,children:n.due?`截止 ${n.due}`:`无截止日期`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-stone-300`,children:`·`}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums ${n.tone}`,children:n.remain}),e.linkedTask?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-stone-300`,children:`·`}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate ${t?`text-stone-400`:`text-stone-500`}`,children:[`任务 `,e.linkedTask]})]}):null]})]})]},e.id)})})]},e.key))})})]})}var $l=`__routine__`;function eu(e){let t=Ln(),n=Ln();return{title:``,status:e===`todo`?Tn(t,n)??`in_progress`:`pool`,statusManual:!1,priority:``,taskId:``,linkedTask:``,startDate:t,dueDate:n,note:``}}function tu(e,t){let n=Array.isArray(t)?t:[],r=[];for(let t of n){if(!t||typeof t!=`object`)continue;let n=t,i=typeof n.title==`string`?n.title.trim():``;if(!i)continue;let a=e===`todo`?qn:Un,o=e===`todo`?An:Wn,s=eu(e),c=typeof n.status==`string`&&a.includes(n.status),l=c?n.status:e===`todo`?s.status:`pool`;r.push({...s,title:i,status:l,statusManual:e===`todo`&&c,priority:typeof n.priority==`string`&&o.includes(n.priority)?n.priority:``,taskId:typeof n.taskId==`string`?n.taskId.trim():``,linkedTask:typeof n.linkedTask==`string`?n.linkedTask.trim():``,startDate:typeof n.startDate==`string`?n.startDate.trim().slice(0,10):s.startDate,dueDate:typeof n.dueDate==`string`?n.dueDate.trim().slice(0,10):s.dueDate,note:typeof n.note==`string`?n.note.trim():``})}return r}function nu(e,t){return t.map(t=>{let n={title:t.title.trim(),status:t.status,priority:t.priority,startDate:t.startDate,dueDate:t.dueDate,note:t.note};return e===`todo`&&(n.taskId=t.taskId,n.linkedTask=t.linkedTask,n.statusManual=!!t.statusManual),n})}var ru=`text-[11px] font-medium text-stone-500`,iu=`h-9 w-full rounded-lg border border-stone-200 px-2.5 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`;function au(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return t?`${t[1]}/${t[2]}/${t[3]}`:``}function ou(e){return(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-stone-700`,children:e.children})]})}function su(e){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[48px_minmax(0,1fr)] items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-stone-700`,children:e.children})]})}function cu(e){let{startDate:t,dueDate:n}=e,r=n||t,i=`h-7 rounded-md px-1.5 text-[12px] text-stone-700 tabular-nums transition-colors hover:bg-stone-100`;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[48px_minmax(0,1fr)] items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`日期`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ie,{value:t,ariaLabel:`开始日期`,placeholder:`开始日期`,clearable:!1,className:i,onChange:t=>{t&&e.onChange({startDate:t,dueDate:t>r?t:r})}})}),(0,Q.jsx)(`span`,{className:`shrink-0 px-0.5 text-[11px] text-stone-300`,"aria-hidden":!0,children:`~`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ie,{value:n,ariaLabel:`截止日期`,placeholder:`截止日期`,clearable:!1,className:i,onChange:n=>{n&&e.onChange({startDate:n<t?n:t,dueDate:n})}})})]})]})}function lu(e){let[t,n]=(0,K.useState)(()=>e.items),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)([]);(0,K.useEffect)(()=>{n(e.items),i(0)},[e.items]);let s=e.kind===`todo`,c=!!e.quick&&s,l=s&&e.tasksOn!==!1,u=s&&!c&&l,d=s?`待办`:`任务`,f=s?`待办事项`:`任务管理`;(0,K.useEffect)(()=>{if(!l)return;let e=!0;return Gn().then(t=>{e&&o(t)}).catch(()=>{}),()=>{e=!1}},[l]);let p=s?qn:Un,m=s?An:Wn,h=(0,K.useMemo)(()=>p.map(e=>({value:e,label:s?Mn[e]:In[e]})),[s,p]),g=(0,K.useMemo)(()=>[{value:``,label:`未设置`},...m.map(e=>({value:e,label:s?W[e]:Vn[e]}))],[s,m]),_=(0,K.useMemo)(()=>[{value:``,label:`不关联`},...a.filter(e=>e.status!==`closed`&&e.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))],[a]),v=(0,K.useMemo)(()=>!!no(a),[a]),y=(0,K.useMemo)(()=>{let e=new Set(t.map(e=>e.taskId).filter(Boolean));return[{value:``,label:`不关联`},...v?[]:[{value:$l,label:`${eo}(确认后自动创建)`}],...a.filter(t=>e.has(t.id)||t.status!==`closed`&&t.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))]},[t,a,v]);function b(e){return e.taskId&&a.some(t=>t.id===e.taskId)?e.taskId:!v&&e.linkedTask.trim()===`日常待办`?$l:``}function x(e,t){if(t===$l){S(e,{taskId:``,linkedTask:eo});return}let n=a.find(e=>e.id===t);S(e,{taskId:n?.id??``,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})}function S(e,t){n(n=>n.map((n,r)=>{if(r!==e)return n;let i={...n,...t};if(!s)return i;if(`status`in t&&!(`startDate`in t||`dueDate`in t))i.statusManual=!0;else if((`startDate`in t||`dueDate`in t)&&!i.statusManual&&!wn(i.status)){let e=Tn(i.startDate,i.dueDate);e&&(i.status=e)}return i}))}function C(e,n){let r=t[e],i=a.find(e=>e.id===n);i?S(e,{taskId:i.id,linkedTask:i.title,startDate:i.startDate||r?.startDate||``,dueDate:i.dueDate||r?.dueDate||``,priority:r?.priority||i.priority||``}):S(e,{taskId:``,linkedTask:``})}function w(e){n(t=>t.filter((t,n)=>n!==e))}let T=t.length>0&&t.every(e=>!!e.title.trim()),E=u&&r>=1,D=c&&t.some(e=>!e.taskId.trim()&&e.linkedTask.trim()===`日常待办`)&&!v,O=E?`所属任务的日期与紧急程度已带到第一页,可回去再调`:c?D?e.quickNote??`确认后会自动创建任务「日常待办」并关联`:`状态 / 所属任务 / 日期已填好(日期可点开改),确认后写入「待办事项」`:`确认后才会写入「${f}」`;return(0,Q.jsxs)(`div`,{className:[`tw-create-card tw-create-card-anim mb-2 flex max-h-[min(62vh,560px)] flex-col overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-[0_6px_24px_rgba(15,23,42,0.08)]`,e.closing?`is-closing`:``].filter(Boolean).join(` `),children:[(0,Q.jsxs)(`div`,{className:`shrink-0 px-5 pt-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] leading-4 text-stone-400`,children:[(0,Q.jsxs)(`span`,{children:[`新增 `,t.length,` 条`,d]}),u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[`第 `,r+1,` / 2 步`]})]}):null]}),(0,Q.jsx)(`h3`,{className:`text-[15px] leading-5.5 font-medium text-stone-900`,children:E?`关联任务`:r===0?`确认内容后再添加到${f}`:f})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[t.map((e,n)=>{let r=a.find(t=>t.id===e.taskId);return(0,Q.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-stone-50/40 p-3`,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`input`,{value:e.title,onChange:e=>S(n,{title:e.target.value}),placeholder:`待办名称`,className:`${iu} bg-white`,autoFocus:n===0}),t.length>1?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(n),"aria-label":`移除这一条`,className:`h-9 shrink-0 rounded-lg px-2 text-[12px] text-stone-400 hover:bg-white hover:text-red-600`,children:`移除`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-stone-200 bg-white px-2.5 py-2`,children:[(0,Q.jsx)(su,{label:`状态`,children:Mn[e.status]??`进行中`}),l?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[48px_minmax(0,1fr)] items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`所属任务`}),a.length||!v?(0,Q.jsx)(oe,{flat:!0,ariaLabel:`所属任务`,menuMatchTrigger:!1,menuMinWidth:200,options:y,value:b(e),onChange:e=>x(n,e),className:`min-w-0`,triggerClassName:`h-7 gap-1 rounded-md border-0 bg-transparent pl-0 pr-0.5 text-[12px] hover:bg-stone-50`}):(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-stone-700`,children:e.linkedTask||`未关联`})]}):null,(0,Q.jsx)(cu,{startDate:e.startDate,dueDate:e.dueDate,onChange:e=>S(n,e)})]})]}):E?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`所属任务`}),a.length?(0,Q.jsx)(oe,{flat:!0,ariaLabel:`所属任务`,options:_,value:e.taskId,onChange:e=>C(n,e),className:`w-full`}):(0,Q.jsx)(`span`,{className:`flex h-9 items-center rounded-lg border border-stone-200 bg-white px-2 text-[13px] text-stone-400`,children:`任务管理里还没有任务,可稍后到任务管理关联`})]}),r?(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-stone-200 bg-white px-2.5 py-2`,children:[(0,Q.jsx)(ou,{label:`任务名称`,children:r.title}),(0,Q.jsx)(ou,{label:`状态`,children:In[r.status]??r.status}),(0,Q.jsx)(ou,{label:`紧急程度`,children:r.priority?Vn[r.priority]:`未设置`}),(0,Q.jsx)(ou,{label:`开始日期`,children:au(r.startDate)||`未设置`}),(0,Q.jsx)(ou,{label:`结束日期`,children:au(r.dueDate)||`未设置`})]}):(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-stone-400`,children:`选中任务后,它的开始 / 结束日期与紧急程度会自动带到第一页。`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`input`,{value:e.title,onChange:e=>S(n,{title:e.target.value}),placeholder:s?`待办名称`:`任务名称`,className:`${iu} bg-white`,autoFocus:n===0}),t.length>1?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(n),"aria-label":`移除这一条`,className:`h-9 shrink-0 rounded-lg px-2 text-[12px] text-stone-400 hover:bg-white hover:text-red-600`,children:`移除`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`状态`}),(0,Q.jsx)(oe,{flat:!0,ariaLabel:s?`待办状态`:`任务状态`,options:h,value:e.status,onChange:e=>S(n,{status:e}),className:`w-full`})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`紧急程度`}),(0,Q.jsx)(oe,{flat:!0,ariaLabel:`紧急程度`,options:g,value:e.priority,onChange:e=>S(n,{priority:e}),className:`w-full`})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`开始日期`}),(0,Q.jsx)(ie,{value:e.startDate,onChange:e=>S(n,{startDate:e}),placeholder:`选择日期`,className:`h-9 rounded-lg border border-stone-200 bg-white px-2 text-[13px] tabular-nums`})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`截止日期`}),(0,Q.jsx)(ie,{value:e.dueDate,onChange:e=>S(n,{dueDate:e}),placeholder:`选择日期`,className:`h-9 rounded-lg border border-stone-200 bg-white px-2 text-[13px] tabular-nums`})]})]}),(0,Q.jsxs)(`label`,{className:`mt-2 flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`备注`}),(0,Q.jsx)(`input`,{value:e.note,onChange:e=>S(n,{note:e.target.value}),placeholder:`备注(可选)`,className:`${iu} bg-white`})]})]})},n)}),t.length?null:(0,Q.jsx)(`p`,{className:`py-4 text-center text-[12px] text-stone-400`,children:`内容已清空,点「取消」放弃这次新增。`})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-stone-100 px-5 py-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:O}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:E?()=>i(0):e.onCancel,className:`h-8 rounded-lg px-3 text-[12px] text-stone-600 outline-none hover:bg-stone-100`,children:E?`上一步`:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!E&&!T,onClick:()=>{u&&r===0?i(1):e.onConfirm(t)},className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-[12px] font-medium text-white hover:bg-[#3467d4] disabled:cursor-not-allowed disabled:bg-stone-300`,children:u&&r===0?`下一步`:e.manual?`提交`:`确认新增`})]})]})]})}function uu(e,t,n){let r=e;if(n.knowledge&&(r=`${r}\n\n${kc}`),n.fs&&(r=`${r}\n\n${mn}\n\n${ba}\n\n${xo}\n\n${wi}\n\n${bi}`),n.bash&&(r=`${r}\n\n${ir}`),n.pwsh&&(r=`${r}\n\n${ar}`),n.web&&(r=`${r}\n\n${er}`),n.memory&&(r=`${r}\n\n${Tr}`),n.interact&&(r=`${r}\n\n${jo}`),n.todos&&(r=`${r}\n\n${Ga}`),n.tasks&&(r=`${r}\n\n${so}`),n.projects&&(r=`${r}\n\n${wa}`),n.iterations&&(r=`${r}\n\n${Ta}`),n.pmRequirements&&(r=`${r}\n\n${Ea}`),n.bugs&&(r=`${r}\n\n${Da}`),n.planPhase===`planning`&&(r=`${r}\n\n${zo}`),n.planPhase===`approved`&&(r=`${r}\n\n${Bo}`),n.goalEnabled){r=`${r}\n\n${ts}`;let e=as(n.goal);e&&(r=`${r}\n\n【当前会话目标】${e}`)}n.scheduleEnabled&&(r=`${r}\n\n${Ss}`),n.subagentEnabled&&(r=`${r}\n\n${Vs}`),n.workflowEnabled&&(r=`${r}\n\n${yc}`),n.mcpEnabled&&(r=`${r}\n\n${wr}`);let i=n.memory?t.slice(-10):t;return[{role:`system`,content:r},...i]}function du(e){if(!/(?:^|[\s\n])\/$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:{from:t}}function fu(e){let t=/(?:^|[\s\n])@([^\s@]*)$/.exec(e);if(!t)return null;let n=e.lastIndexOf(`@`);return n<0?null:{from:n,query:t[1]??``}}function pu(e){let t=/\s*(?:[((](?:recommended|推荐)[))])\s*$/i;return t.test(e)?{label:e.replace(t,``),recommended:!0}:{label:e,recommended:!1}}var mu=Ke,hu=5,gu=[`image/png`,`image/jpeg`,`image/jpg`,`image/webp`,`image/gif`],_u=[`dialog`,`thread`,`todos`,`memory`],vu=`chat.tab`;function yu(e){let t=[];if(e.content&&t.push(e.content),e.refs?.length){let n=e.refs.filter(e=>e.collection!==`workspace`),r=e.refs.filter(e=>e.collection===`workspace`);if(n.length){let e=n.filter(e=>e.collection===`knowledge`||e.collection===`templates`),r=n.filter(e=>e.collection===`prompts`||e.collection===`cases`);if(e.length){let n=e.map(e=>`- ${e.path} 《${e.title}》(${e.category} · ${Dc(e.format)})`);t.push(`引用项目文档(请使用 kb_read 读取):\n${n.join(`
|
|
217
|
+
`)||void 0,templateId:e?.id,templateTitle:e?.title,promptPath:le,knowledgePaths:R.length?[...R]:void 0,testPointIds:m.length?m.map(e=>e.id):void 0,outlineOrder:l,testPointBlock:m.length?Vr(m,r):void 0,templateHeaders:e?.headers?.length?e.headers:[...he],templateBody:(e?.body||``).trim(),promptBody:pe.trim(),confirmedAt:Date.now(),linkedCasePath:n?.linkedCasePath}),t()}finally{Ce(!1)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Gt,{open:e,onClose:t,title:`生成测试用例 · 配置`,closeAriaLabel:`关闭生成测试用例面板`,widthClass:`max-w-3xl`,escDisabled:we!==null,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 border-t border-stone-100 px-4 py-3 flex items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 min-w-0 truncate text-[11px] text-stone-400`,children:`配置仅对当前会话生效,可在输入区胶囊里再改`}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:Se||!a||!Ie||!et,onClick:()=>void bt(),className:`h-9 px-5 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[a?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写文档库。`}),z?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:z}):null,(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-1 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`order-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:`用例类型`}),(0,Q.jsx)(oe,{options:T.map(e=>({value:e.id,label:e.label})),value:D,onChange:O,dimWhenOpen:!0})]}),(0,Q.jsxs)(`div`,{className:`order-3 min-w-0 lg:order-2`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:[`用例模板`,(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,Qe,` · `,Je.templateFolder,`)`]})]}),(0,Q.jsx)(Ze,{options:lt,value:Ke?.id??``,onChange:ne,allowEmpty:!1,disabled:!He,placeholder:He?lt.length?`搜索并选择模板…`:`暂无「${Je.templateFolder}」模板`:`测试模板库未启用`})]}),(0,Q.jsxs)(`div`,{className:`order-2 flex min-w-0 items-start justify-end gap-1 pt-1.5 lg:order-3`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-[#4176e6] transition-colors hover:border-[#4176e6]/40 hover:bg-[#edf3fe]`,onClick:()=>{Fe(null),Te(`add`)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-stone-600 transition-colors hover:border-stone-300 hover:bg-stone-50`,onClick:()=>{Fe(null),Te(`edit`)},children:`编辑`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-red-600 transition-colors hover:border-red-300 hover:bg-red-50 disabled:opacity-40 disabled:hover:border-stone-200 disabled:hover:bg-transparent`,disabled:T.length<=1,onClick:()=>{Fe(null),Te(`delete`)},children:`删除`})]}),(0,Q.jsx)(`div`,{className:`order-4 min-w-0 lg:order-4`,children:He?Ke?.headers?.length?(0,Q.jsx)(Ye,{fields:Ke.headers}):null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「测试模板库」后再选择;未启用时按默认字段生成。`})})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-4 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:`输出格式`}),(0,Q.jsx)(oe,{options:jl,value:be,onChange:xe,dimWhenOpen:!0})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:`引用知识库(可多选)`}),(0,Q.jsx)(Xe,{options:dt,values:R,onChange:_e,disabled:!Re,placeholder:Re?dt.length?`选择知识库文档…`:`暂无知识库文档`:`知识库管理未启用`}),Re?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「知识库管理」后再引用。`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`需求来源`}),(0,Q.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>g(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${p===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`需求文档`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!y,onClick:()=>{y&&g(`stories`)},className:`h-7 rounded-md px-2.5 text-xs transition-colors disabled:opacity-40 ${p===`stories`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`用户故事`})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:p===`stories`?`来自「需求分析」拆好的故事:按 US 编号逐条覆盖,改动后重新生成即可`:`来自「需求文档库」的原始文档`})]}),(0,Q.jsx)(`div`,{className:`mt-2`,children:p===`stories`?(0,Q.jsx)(Ze,{options:_.map(e=>({value:e.id,label:`${e.title}(${e.stories.length} 个故事)`})),value:x,onChange:e=>{S(e);let t=_.find(t=>t.id===e);w(t?.stories.map(e=>e.id)??[]),ye([])},allowEmpty:!1,disabled:!y,placeholder:We?y?_.length?`搜索并选择需求分析记录…`:`暂无需求分析记录,请先在「需求分析」拆解`:`需求分析服务未就绪`:`需求分析插件未启用`}):(0,Q.jsx)(Ze,{options:ct,value:d,onChange:f,allowEmpty:!1,disabled:!Be,placeholder:Be?ct.length?`搜索并选择需求文档…`:`请先在需求文档库中上传`:`需求文档库未启用`})}),p===`stories`?(0,Q.jsxs)(`div`,{className:`mt-2 rounded-lg bg-stone-50/80 p-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 text-[11px] text-stone-500`,children:[`选择故事`,(0,Q.jsxs)(`span`,{className:`ml-1 text-stone-400`,children:[mt,`/`,pt.length]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#4176e6] hover:underline`,onClick:()=>w(pt.map(e=>e.id)),children:`全选`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-500 hover:underline`,onClick:()=>w([]),children:`全不选`})]}),pt.length?(0,Q.jsx)(`div`,{className:`mt-1.5 grid max-h-56 grid-cols-1 gap-x-4 overflow-y-auto sm:grid-cols-2`,children:pt.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-1.5 py-1 text-xs`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:C.includes(e.id),onChange:t=>w(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:e.id}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ae,{text:e.title,className:`block truncate text-stone-800`})}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:e.priority})]},e.id))}):(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:x?`这份分析还没有拆出用户故事`:`先选择一份需求分析记录`}),We?null:(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400`,children:`需求分析插件已关闭;用户故事来源暂不可用,可改用「需求文档」。`})]}):Be?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「需求文档库」后再选择。`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-stone-500`,children:[`测试点(可多选)`,ht.length?(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[gt.length,`/`,ht.length]}):null]}),ht.length?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-[11px]`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`text-[#4176e6] transition-colors hover:text-[#3565c7]`,onClick:()=>ye(ht.map(e=>e.id)),children:`全选`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-stone-500 transition-colors hover:text-stone-700`,onClick:()=>ye([]),children:`清空`})]}):null]}),(0,Q.jsx)(Xe,{options:_t,values:gt,onChange:ye,disabled:!_t.length,placeholder:vt}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:yt})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 text-xs font-medium text-stone-500`,children:[`提示词`,(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,Qe,` 挂载)`]})]}),(0,Q.jsx)(`button`,{type:`button`,disabled:!Ie,onClick:()=>fe(!0),className:`flex h-9 w-full min-w-0 items-center gap-2 rounded-lg border px-2.5 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${tt?`border-amber-300 bg-amber-50/50 text-amber-700 hover:border-amber-400`:`border-stone-200 bg-white text-stone-800 hover:border-stone-300`}`,children:(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:Ie?et?et.replace(/\.md$/i,``):j?`未挂载提示词 · 点击挂载`:`读取提示词…`:`提示词管理未启用`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:Ie?tt?j?`当前类型还没有挂载提示词,未挂载时无法确认。`:`正在读取提示词列表…`:`每个用例类型只挂一份提示词:换类型会切到该类型挂载的那份。`:`请先在「我的插件」中启用「提示词管理」后再挂载。`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-stone-50/60 px-4 py-3`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-semibold text-stone-600`,children:`本次配置`}),(0,Q.jsxs)(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-4 gap-y-2 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`用例类型`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:Qe})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`用例模板`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:Ke?.title||`—`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`输出格式`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:jl.find(e=>e.value===be)?.label??be})]}),(0,Q.jsxs)(`div`,{className:`col-span-2 min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`需求来源`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:p===`stories`?ft?`用户故事 · ${ft.title}(${mt}/${pt.length} 条)`:`用户故事 · 未选择`:d?`需求文档 · ${d}`:`需求文档 · 未选择`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`引用知识库`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:R.length?`${R.length} 个文档`:`未引用`})]}),(0,Q.jsxs)(`div`,{className:`col-span-2 grid min-w-0 grid-cols-2 gap-x-4 sm:col-span-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`测试点`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:gt.length?`${gt.length} 条`:`未选择`})]}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`dt`,{className:`text-[10px] text-stone-400`,children:`提示词`}),(0,Q.jsx)(`dd`,{className:`truncate text-xs text-stone-700`,children:et?`${et.replace(/\.md$/i,``)}(${Qe})`:`未挂载`})]})]})]}),(0,Q.jsx)(`p`,{className:`mt-2.5 text-[10px] leading-4 text-stone-400`,children:`确认后输入区出现「生成测试用例」胶囊,直接发送或补充范围说明即可;点 × 取消后按普通对话修改,不再整批生成。`})]})]}),(0,Q.jsx)(Al,{mode:we,currentLabel:Je.label,templateFolder:Je.templateFolder,error:Me??``,onClose:()=>{Te(null),Fe(null)},onSubmit:ot,onDelete:st}),(0,Q.jsx)(tn,{open:de,prompts:ut,value:et,force:!et,onClose:()=>fe(!1),onMount:nt,onCreate:it,target:`用例类型`,createHint:`会按用例生成的模板生成一份(逐条覆盖、边界 / 异常 / 优先级),之后可在「提示词管理」里改。`})]})}function Fl({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(()=>Ri()),[u,d]=(0,K.useState)(Ri()[0]?.id??`case`),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null),v=c.find(e=>e.id===u)??c[0]??zi(u);function y(e){let t=Ri();l(t),d(n=>{let r=e??n;return t.some(e=>e.id===r)?r:t[0]?.id??n})}function b(e){let t=m===`add`;try{if(t){let t=Vi(e);y(t.id),M(`已新增提示词类型「${t.label}」`,`success`)}else Hi(u,e),y(u),M(`已重命名为「${e.trim()}」`,`success`);h(null),_(null)}catch(e){let n=e instanceof Error?e.message:String(e);_(n),M(`${t?`新增`:`保存`}提示词类型失败:${n}`,`error`)}}function x(){try{let e=v.label,t=Ui(u);l(t),d(t[0]?.id??``),h(null),_(null),p(null),M(`已删除提示词类型「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),M(`删除提示词类型失败:${t}`,`error`)}}(0,K.useEffect)(()=>{e&&(y(n?.kind),s(n?.titleHint??``),d(n?.kind??Ri()[0]?.id??`case`),h(null),_(null),p(null),Pe(`prompts`).then(a))},[e,n]);function S(){p(null),i?(r({active:!0,titleHint:o.trim(),kind:u,confirmedAt:Date.now(),linkedPromptPath:n?.linkedPromptPath}),t()):p(`本地文档服务未就绪,无法写入提示词库`)}return(0,Q.jsxs)(Gt,{open:e,onClose:t,title:`生成提示词 · 配置`,closeAriaLabel:`关闭生成提示词面板`,escDisabled:m!==null,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!i,onClick:S,className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写提示词库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选类型生成可复用提示词:确认后输入区出现「生成提示词」胶囊,描述编写要求后发送;点 × 取消后按普通对话修改,不再整批生成。质检通过后写入提示词库。`}),f?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:f}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 text-xs font-medium text-stone-500`,children:`提示词类型`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-[#4176e6] transition-colors hover:border-[#4176e6]/40 hover:bg-[#edf3fe]`,onClick:()=>{h(`add`),_(null)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-stone-600 transition-colors hover:border-stone-300 hover:bg-stone-50`,onClick:()=>{h(`edit`),_(null)},children:`编辑`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-red-600 transition-colors hover:border-red-300 hover:bg-red-50 disabled:opacity-40 disabled:hover:border-stone-200 disabled:hover:bg-transparent`,disabled:c.length<=1,onClick:()=>{h(`delete`),_(null)},children:`删除`})]}),(0,Q.jsx)(oe,{options:c.map(e=>({value:e.id,label:e.label})),value:u,onChange:d,dimWhenOpen:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4`,children:v.hint}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4`,children:`类型决定生成时给模型的写作侧重(例如用例提示词要求约束 JSON 与模板字段), 同时出现在这份提示词的配置标签里;不影响你在主输入框补充的具体要求。`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,htmlFor:`pg-title`,children:`期望名称`}),(0,Q.jsx)(`input`,{id:`pg-title`,value:o,onChange:e=>s(e.target.value),placeholder:`如:接口测试用例提示词.md`,className:`mt-1 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-4`,children:`可填期望文件名;留空则由模型自拟。具体编写要求在主输入框描述。`})]}),(0,Q.jsx)(kl,{mode:m,entityLabel:`提示词类型`,currentLabel:v.label,placeholder:`如:缺陷分析提示词`,error:g??``,onClose:()=>{h(null),_(null)},onSubmit:b,onDelete:x,hint:e=>(0,Q.jsxs)(Q.Fragment,{children:[`类型名称会写入这份提示词的配置标签:`,e||`名称`]}),deleteMessage:e=>(0,Q.jsxs)(Q.Fragment,{children:[`确定删除「`,e,`」?已生成的提示词与文档不会被删除,只是不能再选这个类型。`]})})]})}function Il({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(()=>$i()),[u,d]=(0,K.useState)($i()[0]??`测试规范`),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)(null);function v(e){let t=$i();l(t),d(n=>{let r=e??n;return t.includes(r)?r:t[0]??n})}function y(e){let t=m===`add`;try{if(t){let t=ta(e);v(t),M(`已新增分类「${t}」`,`success`)}else{let t=na(u,e);v(t),M(`已重命名为「${t}」`,`success`)}h(null),_(null)}catch(e){let n=e instanceof Error?e.message:String(e);_(n),M(`${t?`新增`:`保存`}分类失败:${n}`,`error`)}}function b(){try{let e=u,t=ra(u);l(t),d(t[0]??``),h(null),_(null),p(null),M(`已删除分类「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);_(t),M(`删除分类失败:${t}`,`error`)}}(0,K.useEffect)(()=>{e&&(v(n?.category),s(n?.titleHint??``),d(n?.category??$i()[0]??`测试规范`),h(null),_(null),p(null),Pe(`knowledge`).then(a))},[e,n]);function x(){p(null),i?(r({active:!0,titleHint:o.trim(),category:u,confirmedAt:Date.now(),linkedKnowledgePath:n?.linkedKnowledgePath}),t()):p(`本地文档服务未就绪,无法写入知识库`)}return(0,Q.jsxs)(Gt,{open:e,onClose:t,title:`生成知识库 · 配置`,closeAriaLabel:`关闭生成知识库面板`,escDisabled:m!==null,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!i,onClick:x,className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写知识库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选分类沉淀测试规范、方法论或环境约定:确认后输入区出现「生成知识库」胶囊,粘贴或描述素材后发送;点 × 取消后按普通对话修改,不再整批生成。质检通过后写入知识库,可在「知识库管理」中查看与 @ 引用。`}),f?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:f}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 text-xs font-medium text-stone-500`,children:`分类`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-[#4176e6] transition-colors hover:border-[#4176e6]/40 hover:bg-[#edf3fe]`,onClick:()=>{h(`add`),_(null)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-stone-600 transition-colors hover:border-stone-300 hover:bg-stone-50`,onClick:()=>{h(`edit`),_(null)},children:`编辑`}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex h-[23px] items-center rounded border border-stone-200 px-1.5 text-[11px] leading-none text-red-600 transition-colors hover:border-red-300 hover:bg-red-50 disabled:opacity-40 disabled:hover:border-stone-200 disabled:hover:bg-transparent`,disabled:c.length<=1,onClick:()=>{h(`delete`),_(null)},children:`删除`})]}),(0,Q.jsx)(oe,{options:c.map(e=>({value:e,label:e})),value:u,onChange:d,dimWhenOpen:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4`,children:`分类决定两件事:生成时告诉模型按哪类知识写(规范 / 方法论 / 环境约定侧重不同), 入库时写进文档 frontmatter 的 category,知识库管理里就按它归类展示。`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,htmlFor:`kg-title`,children:`期望名称`}),(0,Q.jsx)(`input`,{id:`kg-title`,value:o,onChange:e=>s(e.target.value),placeholder:`如:接口自动化环境约定.md`,className:`mt-1 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-4`,children:`可填期望文件名;留空则由模型自拟。素材与编写要求在主输入框描述。`})]}),(0,Q.jsx)(kl,{mode:m,entityLabel:`知识库分类`,currentLabel:u,placeholder:`如:安全基线`,error:g??``,onClose:()=>{h(null),_(null)},onSubmit:y,onDelete:b,hint:()=>(0,Q.jsx)(Q.Fragment,{children:`分类写入文档 frontmatter,文件平铺存放于 知识库管理/;改名不会自动迁移已有文件。`}),deleteMessage:e=>(0,Q.jsxs)(Q.Fragment,{children:[`确定删除「`,e,`」?已入库的知识文档不会被删除,但该分类将不能再用于生成。`]})})]})}function Ll({task:e,onClose:t,onSave:n,onRemove:r,readOnly:i=!1}){let[a,o]=(0,K.useState)(``),s=!!e;(0,K.useEffect)(()=>{o(e?.body??``)},[e]);let c=!!e&&a.trim()!==e?.body.trim();return(0,Q.jsxs)(O,{open:s,onClose:t,className:`relative z-110`,children:[(0,Q.jsx)(k,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,Q.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,Q.jsxs)(E,{transition:!0,className:`tw-dialog-panel-anim relative flex max-h-[85vh] w-full max-w-2xl flex-col rounded-xl border border-stone-200 bg-white p-5 shadow-xl`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`absolute top-3.5 right-3.5 flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,"aria-label":`关闭`,children:`✕`}),(0,Q.jsx)(D,{className:`pr-8 text-base font-semibold text-stone-900`,children:e?.label||`任务要求`}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,Q.jsx)(`span`,{children:i?`已随消息发送给模型`:`发送时这段要求会随消息一起带给模型`}),e?.detail?(0,Q.jsxs)(`span`,{className:`truncate`,children:[`· `,e.detail]}):null]}),(0,Q.jsx)(`textarea`,{value:a,onChange:e=>{i||o(e.target.value)},readOnly:i,spellCheck:!1,className:`mt-3 min-h-[240px] flex-1 resize-none overflow-y-auto rounded-lg border border-stone-200 px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-stone-700 outline-none ${i?`bg-stone-50/80`:`bg-stone-50/60 focus:border-[#4176e6]/40 focus:bg-white`}`}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2`,children:[i||!r?(0,Q.jsx)(`span`,{}):(0,Q.jsx)(`button`,{type:`button`,onClick:r,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-500 transition-colors hover:border-red-300 hover:bg-red-50 hover:text-red-600`,children:`移除`}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:i||!n?(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-sm text-white transition-colors hover:bg-[#3566d0]`,children:`关闭`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-8 rounded-lg border border-stone-200 px-3 text-sm text-stone-600 transition-colors hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!a.trim(),onClick:()=>n(a.trim()),className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-sm text-white transition-colors hover:bg-[#3566d0] disabled:cursor-not-allowed disabled:bg-stone-300`,children:c?`保存修改`:`完成`})]})})]})]})})]})}var Rl={user:`用户档案`,memory:`长期记忆`,key:`项目关键记忆`,project:`项目日志`};function zl(e){return e?e.replace(/\\/g,`/`).replace(/^\/Users\/[^/]+/,`~`):``}var Bl={project:{title:`项目日志`,fileHint:`MEMORY.md`,desc:`项目进展流水账,按需查阅,默认不注入上下文。`,curated:!1},key:{title:`项目关键记忆`,fileHint:`KEY.md`,desc:`项目关键约定与事实;写入需经待确认记忆建议采纳后注入。`,curated:!0},memory:{title:`长期记忆`,fileHint:`MEMORY.md`,desc:`全局环境与跨项目事实,注入所有会话;写入需审查建议并经确认。`,curated:!0}},Vl=[{id:`guide`,label:`指南`},{id:`suggestions`,label:`待确认记忆建议`},{id:`project`,label:`项目日志`},{id:`key`,label:`项目关键记忆 KEY.md`},{id:`memory`,label:`长期记忆 MEMORY.md`},{id:`agents`,label:`全局规则 AGENTS.md`},{id:`archive`,label:`归档`},{id:`settings`,label:`设置`}];function Hl({live:e,pluginOn:t,workspacePath:n=``,onHealthChange:r}){let[i,a]=(0,K.useState)(`suggestions`),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)({}),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)([]),[m,h]=(0,K.useState)([]),[g,_]=(0,K.useState)(`memory`),[v,y]=(0,K.useState)(null),[b,x]=(0,K.useState)([]),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(!1),[O,k]=(0,K.useState)(null),[ee,te]=(0,K.useState)(null),[ne,re]=(0,K.useState)(null),A=n.trim(),ie=(0,K.useRef)(r);ie.current=r;let ae=(0,K.useCallback)(async()=>{if(!e)s(null),l({}),p([]),x([]),ie.current?.(null);else{C(null);try{let[e,t,n,r,a]=await Promise.all([xr(),br(A,`all`),hr(),Cr(),hn().catch(()=>null)]);s(e),l(t.tracks),d(t.projectId||``),p(n),y(r),x(a?.files?.length?a.files:a?.text?[{path:`AGENTS.md`,name:`AGENTS.md`}]:[]),i===`archive`&&h(await Er(g,A)),ie.current?.(e)}catch(e){C(e instanceof Error?e.message:String(e))}}},[e,A,i,g]);if((0,K.useEffect)(()=>{ae()},[ae]),!t)return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`会话记忆未启用`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`在「我的插件」中打开「会话记忆」后,可在此管理记忆轨与待确认记忆建议`})]});if(!e)return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`会话记忆中间件未就绪`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`本地记忆服务未就绪`})]});let oe=i===`memory`||i===`key`,M=i===`memory`||i===`key`||i===`project`,N=M?c[i]?.entries??[]:[],P=M?c[i]?.path:null,se=o?.path||`.lantern/local/memories`;async function ce(e){D(!0);try{await vr(e),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}async function F(e){D(!0);try{await mr(e),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}function I(e){oe&&te(e)}async function le(){if(ee==null||!oe)return;let e=ee;te(null),D(!0);try{await G(i,e,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}async function ue(){if(ne==null)return;let e=ne;re(null),D(!0);try{await Ar(g,e,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}function de(e){k(e)}async function fe(){if(O==null)return;let e=O;k(null),D(!0);try{await yr(i,e,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}async function pe(){if(oe&&w.trim()){D(!0);try{await jr(i,w.trim(),A),T(``),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}}async function L(e){D(!0);try{let t=await Mr(e);y(t)}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}}function me(e){let t=Bl[e],n=e===`key`?`KEY.md`:t.fileHint,r=e===`key`?`项目关键记忆 ${n}`:e===`memory`?`长期记忆 ${n}`:t.title,i=zl(P)||`${zl(se)}/…/${n}`;return(0,Q.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 flex-wrap min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:r}),t.curated?null:(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-stone-100 text-stone-500 border border-stone-200`,children:`只读追加`}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-stone-400 tabular-nums`,children:[N.length,` 条`]}),(0,Q.jsx)(`span`,{className:`max-w-full break-all whitespace-normal text-[11px] text-[#4176e6] bg-[#edf3fe] border border-[#4176e6]/20 rounded-lg px-2 py-0.5 font-mono leading-4`,"data-hint":P||i,children:i})]}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5 break-words`,children:t.desc}),A?(0,Q.jsxs)(`p`,{className:`text-[11px] text-stone-400 break-all`,children:[`当前会话工作目录:`,(0,Q.jsx)(`span`,{className:`font-mono`,children:A}),u?(0,Q.jsxs)(Q.Fragment,{children:[` · `,`项目 id `,(0,Q.jsx)(`span`,{className:`font-mono`,children:u.slice(0,12)})]}):null]}):null]})}return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 flex flex-wrap items-center gap-2 px-4 py-2 border-b border-stone-200/80`,children:[Vl.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:`h-7 px-2.5 text-xs rounded-md whitespace-normal text-left leading-tight ${i===e.id?`bg-stone-900 text-white`:`text-stone-600 hover:bg-stone-100`}`,children:[e.label,e.id===`suggestions`&&f.length>0?(0,Q.jsxs)(`span`,{className:`ml-1 tabular-nums`,children:[`(`,f.length,`)`]}):null]},e.id)),(0,Q.jsxs)(`span`,{className:`text-[11px] text-stone-400 tabular-nums`,children:[o?.entryCount??0,` 条 · 待确认 `,o?.suggestionCount??f.length]})]}),S?(0,Q.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:S}):null,(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4`,children:[i===`guide`?(0,Q.jsxs)(`div`,{className:`space-y-3 max-w-2xl`,children:[(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`确认制:为什么必须你点头`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`记忆会改变后续对话行为。长期记忆 / 项目关键记忆经「待确认记忆建议」采纳后才写入并注入;项目日志可直写但不注入。`})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`待确认记忆建议:AI 只提议,你拍板`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`后台或对话中产出的记忆建议进入独立队列。采纳可写入对应轨;拒绝则丢弃。`}),(0,Q.jsxs)(`ul`,{className:`mt-2 space-y-1.5 text-xs text-stone-600`,children:[(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2 break-words`,children:`采纳 → 长期记忆 MEMORY.md / 项目关键记忆 KEY.md`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`拒绝 → 丢弃,不落盘`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`各轨文件(对齐 dsh)`}),(0,Q.jsxs)(`ul`,{className:`mt-2 space-y-1.5 text-xs text-stone-600`,children:[(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`项目日志 · 项目目录 MEMORY.md(不注入)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`项目关键记忆 KEY.md(注入,需确认)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`长期记忆 MEMORY.md(注入,需确认)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`全局规则:展示工作区 AGENTS.md 等规则文件`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`编辑与维护`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`可在本 Tab 浏览条目、手动添加(注入轨)、归档或删除。文件为 § 分隔结构化记忆,用外部编辑器打开时请谨慎修改。`}),(0,Q.jsxs)(`p`,{className:`mt-2 text-[11px] text-amber-700/90`,children:[`存储目录:`,(0,Q.jsx)(`code`,{className:`font-mono`,children:se})]})]})]}):null,i===`suggestions`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`待确认记忆建议`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-5`,children:`后台审查或对话沉淀产出的记忆建议:采纳后写入记忆文件并注入;拒绝则丢弃。`})]}),f.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-16 text-center text-sm text-stone-400`,children:`没有待确认的建议。`}):(0,Q.jsx)(`ul`,{className:`space-y-3`,children:f.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-amber-200/80 bg-amber-50/30 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-stone-400 mb-1 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-amber-100 text-amber-900 border border-amber-200 font-medium`,children:`待确认记忆建议`}),(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-white text-stone-600 border border-stone-200`,children:Rl[e.target]??e.target}),(0,Q.jsx)(`span`,{children:e.time}),e.hits&&e.hits>1?(0,Q.jsxs)(`span`,{children:[`×`,e.hits]}):null]}),(0,Q.jsx)(`p`,{className:`text-sm text-stone-800 whitespace-pre-wrap`,children:e.content}),e.reason?(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-stone-500`,children:[`原因:`,e.reason]}):null,(0,Q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void ce(e.id),className:`h-7 px-2.5 text-xs text-white bg-emerald-600 rounded-md hover:bg-emerald-700 disabled:opacity-40`,children:`采纳`}),(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void F(e.id),className:`h-7 px-2.5 text-xs text-stone-600 border border-stone-200 rounded-md hover:bg-stone-50 disabled:opacity-40`,children:`拒绝`})]})]},e.id))})]}):null,M?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[me(i),oe?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white p-3 space-y-2`,children:[(0,Q.jsx)(`textarea`,{value:w,onChange:e=>T(e.target.value),placeholder:i===`key`?`输入一条项目关键约定,例如:本仓库包管理器用 pnpm…`:`输入一条想长期记住的全局事实/惯例/环境…`,rows:3,className:`w-full text-sm rounded-lg border border-stone-200 px-3 py-2 focus:outline-none focus:border-[#4176e6] resize-y`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`手动写入会直接落盘;重要偏好更推荐走「待确认记忆建议」。`}),(0,Q.jsx)(`button`,{type:`button`,disabled:E||!w.trim(),onClick:()=>void pe(),className:`shrink-0 h-8 px-3 text-xs text-white bg-[#4176e6] rounded-lg disabled:opacity-40`,children:`保存`})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-stone-400`,children:`本轨由对话中 memory_append 自动追加,一般不注入上下文。`}),N.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-12 text-center text-sm text-stone-400`,children:`(文件不存在或为空)`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:N.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2.5 flex gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 text-sm text-stone-800 whitespace-pre-wrap`,children:e.text}),(0,Q.jsxs)(`div`,{className:`shrink-0 self-start flex flex-col gap-0.5`,children:[oe?(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void I(e.index),className:`h-7 px-2 text-[11px] text-stone-500 hover:bg-stone-50 rounded-md`,children:`归档`}):null,(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void de(e.index),className:`h-7 px-2 text-[11px] text-red-600 hover:bg-red-50 rounded-md`,children:`删除`})]})]},`${i}-${e.index}`))})]}):null,i===`agents`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`全局规则`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`工作区规则文件(AGENTS.md 等),随系统提示注入。`}),b.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-12 text-center text-sm text-stone-400`,children:`(未找到规则文件)`}):(0,Q.jsx)(`ul`,{className:`space-y-2 w-full`,children:b.map(e=>{let t=zl(e.abs)||zl(e.path)||e.label||e.path||e.name;return(0,Q.jsx)(`li`,{className:`w-full`,children:(0,Q.jsxs)(`div`,{className:`w-full flex items-center gap-4 rounded-xl border border-stone-200 bg-white px-4 py-3.5`,children:[(0,Q.jsx)(`span`,{className:`w-12 h-12 rounded-xl bg-[#edf3fe] text-[#4176e6] flex items-center justify-center text-[11px] font-semibold shrink-0`,children:(e.name.split(`.`).pop()||`MD`).toUpperCase()}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-medium text-stone-800 break-all`,children:e.name||`AGENTS.md`}),(0,Q.jsx)(`span`,{className:`block text-xs text-stone-400 break-all font-mono mt-1`,children:t})]}),(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>{C(null),D(!0),sn(e.path||e.name||`AGENTS.md`,we(),{abs:e.abs}).catch(e=>C(e instanceof Error?e.message:String(e))).finally(()=>D(!1))},className:`shrink-0 h-9 px-4 text-xs text-[#4176e6] border border-[#4176e6]/30 rounded-lg hover:bg-[#f5f8ff] disabled:opacity-40`,children:`打开文件`})]})},e.abs||e.path)})})]}):null,i===`archive`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`flex gap-2`,children:[`user`,`memory`,`key`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{_(e)},className:`h-7 px-2.5 text-xs rounded-md ${g===e?`bg-stone-800 text-white`:`border border-stone-200`}`,children:Rl[e]??e},e))}),m.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-stone-400 text-center py-10`,children:`暂无归档`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:m.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2.5 flex gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 text-sm text-stone-800 whitespace-pre-wrap`,children:e.text}),(0,Q.jsxs)(`div`,{className:`shrink-0 self-start flex flex-col gap-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>void(async()=>{D(!0);try{await _r(g,e.index,A),await ae()}catch(e){C(e instanceof Error?e.message:String(e))}finally{D(!1)}})(),className:`h-7 px-2 text-[11px] text-emerald-700 hover:bg-emerald-50 rounded-md`,children:`转正`}),(0,Q.jsx)(`button`,{type:`button`,disabled:E,onClick:()=>re(e.index),className:`h-7 px-2 text-[11px] text-red-600 hover:bg-red-50 rounded-md`,children:`删除`})]})]},`a-${e.index}`))})]}):null,i===`settings`&&v?(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-md`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`每回合注入 USER / MEMORY / KEY`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:v.injectMemory,onChange:e=>void L({injectMemory:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`收尾提示写 project`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:v.perTurnProjectWrites,onChange:e=>void L({perTurnProjectWrites:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`重要事实用 suggest(KEY)`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:v.perTurnKeyWrites,onChange:e=>void L({perTurnKeyWrites:e.target.checked})})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-stone-400 leading-5 break-all`,children:[`存储目录:`,(0,Q.jsx)(`code`,{className:`font-mono`,children:o?.path??`.lantern/local/memories`}),`。memory/key 经待确认记忆建议后注入;project 不注入。`]})]}):null]}),(0,Q.jsx)(j,{open:O!=null,title:`删除记忆`,message:`永久删除该条目?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>k(null),onConfirm:()=>void fe()}),(0,Q.jsx)(j,{open:ee!=null,title:`归档记忆`,message:`归档该条目?归档后不再注入上下文。`,confirmLabel:`归档`,cancelLabel:`取消`,onClose:()=>te(null),onConfirm:()=>void le()}),(0,Q.jsx)(j,{open:ne!=null,title:`删除归档`,message:`永久删除该归档?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>re(null),onConfirm:()=>void ue()})]})}var Ul=`/`,Wl=[{id:`all`,label:`全部待办`},{id:`open`,label:`未完成`},{id:`done`,label:`已完成`}],Gl={urgent_important:`bg-red-500`,important:`bg-amber-500`,urgent:`bg-orange-500`,normal:`bg-stone-300`},Kl={urgent_important:`text-red-600`,important:`text-amber-600`,urgent:`text-orange-600`,normal:`text-stone-500`};function ql(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Jl(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return t?`${t[1]}/${t[2]}/${t[3]}`:``}function Yl(e,t){let n=Jl(e.dueDate),r=e.status===`done`||e.status===`cancelled`,i=Dn(e,t),a=``,o=`text-stone-500`;return r?a=Mn[e.status]:i===null?(a=`未设置截止`,o=`text-stone-400`):i<0?(a=`逾期 ${Math.abs(i)} 天`,o=`text-red-600`):i===0?(a=`今天截止`,o=`text-[#4176e6]`):a=`剩余 ${i} 天`,{due:n,remain:a,tone:r?`text-stone-400`:o}}function Xl(e){return[...e].filter(e=>e.status===`done`||e.status===`cancelled`).sort((e,t)=>e.updatedAt<t.updatedAt?1:-1).slice(0,30)}function Zl(e,t,n){if(t===`done`)return[{key:`done`,label:`已完成 / 已取消`,items:Xl(e)}];let r=e.filter(e=>{let t=Cn(e,n);return t!==`done`&&t!==`cancelled`}),i=[],a=[],o=[],s=[];for(let e of r){let t=Dn(e,n);t===null?s.push(e):t<0?i.push(e):t===0?a.push(e):o.push(e)}let c=[{key:`overdue`,label:`已逾期`,items:i,tone:`text-red-600`},{key:`today`,label:`今天截止`,items:a,tone:`text-[#4176e6]`},{key:`later`,label:`接下来`,items:o},{key:`undated`,label:`没有截止日期`,items:s}];return t===`all`&&c.push({key:`done`,label:`已完成 / 已取消`,items:Xl(e)}),c.filter(e=>e.items.length>0)}function Ql(e){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(`all`),[s,c]=(0,K.useState)({}),l=(0,K.useCallback)(async()=>{try{let e=await U();n(e),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}},[]);(0,K.useEffect)(()=>{l();let e=window.setInterval(()=>void l(),15e3);return()=>window.clearInterval(e)},[l]);let u=ql(),d=(0,K.useMemo)(()=>t?Zl(t,a,u):[],[t,a,u]),f=(0,K.useMemo)(()=>{let e=t??[],n=0,r=0,i=0;for(let t of e){let e=Cn(t,u);if(e===`done`||e===`cancelled`)continue;i+=1;let a=Dn(t,u);a!==null&&a<0?n+=1:a===0&&(r+=1)}return{overdue:n,dueToday:r,open:i}},[t,u]);async function p(e){if(s[e.id])return;let t=e.status===`done`?`pending`:`done`;c(t=>({...t,[e.id]:!0})),n(n=>n&&n.map(n=>n.id===e.id?{...n,status:t}:n));try{await En(e.id,{status:t}),i(null)}catch(t){n(t=>t&&t.map(t=>t.id===e.id?{...t,status:e.status}:t)),i(t instanceof Error?t.message:String(t))}finally{c(t=>{let n={...t};return delete n[e.id],n})}}return e.live===!1?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`待办事项需要本地服务`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`当前未就绪(仅 npm run dev / 本地一体服务可用)`})]}):(0,Q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-stone-200/80`,children:(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[min(64rem,100%)] flex-wrap items-center gap-2 px-4 py-2 sm:px-8 lg:px-12`,children:[Wl.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-pressed":a===e.id,className:`h-7 px-2.5 text-xs rounded-md ${a===e.id?`bg-stone-900 text-white`:`text-stone-600 hover:bg-stone-100`}`,children:[e.label,e.id===`all`&&f.dueToday+f.overdue>0?(0,Q.jsx)(`span`,{className:`ml-1 tabular-nums`,children:f.dueToday+f.overdue}):null]},e.id)),(0,Q.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400 tabular-nums`,children:[`未完成 `,f.open,f.overdue?` · 逾期 ${f.overdue}`:``]}),(0,Q.jsx)(`a`,{href:`${Ul}todos/`,className:`text-[11px] text-[#4176e6] hover:underline shrink-0`,children:`打开待办页 →`})]})}),r?(0,Q.jsx)(`div`,{className:`mx-auto mt-3 w-full max-w-[min(64rem,100%)] px-4 sm:px-8 lg:px-12`,children:(0,Q.jsx)(`div`,{className:`px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:r})}):null,(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-4 py-3 sm:px-8 lg:px-12`,children:t===null?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})}):d.length===0?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-500`,children:a===`all`?`当前空间还没有待办`:a===`done`?`还没有已完成的待办`:`当前没有未完成的待办`}),(0,Q.jsx)(`a`,{href:`${Ul}todos/`,className:`mt-2 text-xs text-[#4176e6] hover:underline`,children:`去待办页新增 →`})]}):(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(64rem,100%)] space-y-5`,children:d.map(e=>(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`h3`,{className:`mb-2 flex items-center gap-1.5 px-0.5 text-[11px] font-medium ${e.tone??`text-stone-500`}`,children:[e.label,(0,Q.jsx)(`span`,{className:`text-stone-400 tabular-nums`,children:e.items.length})]}),(0,Q.jsx)(`ul`,{className:`list-none m-0 space-y-1.5 p-0`,children:e.items.map(e=>{let t=e.status===`done`||e.status===`cancelled`,n=Yl(e,u);return(0,Q.jsxs)(`li`,{className:`group flex min-w-0 items-start gap-2.5 rounded-xl border border-stone-200 bg-white px-3 py-2.5 hover:border-stone-300`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void p(e),"aria-label":t?`恢复 ${e.title}`:`完成 ${e.title}`,"aria-pressed":t,className:`mt-0.5 grid h-4 w-4 shrink-0 place-items-center rounded-full border transition-colors ${t?`border-[#4176e6] bg-[#4176e6] text-white`:`border-stone-300 text-transparent hover:border-[#4176e6]`}`,children:(0,Q.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`10`,height:`10`,fill:`none`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:`m4 10 4 4 8-9`})})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-5 ${t?`text-stone-400 line-through`:`text-stone-800`}`,children:e.title}),t?(0,Q.jsx)(`span`,{className:`shrink-0 pt-0.5 text-[11px] text-stone-400`,children:Mn[e.status]}):e.priority?(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 pt-0.5 text-[11px] ${Kl[e.priority]??`text-stone-400`}`,children:[(0,Q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${Gl[e.priority]??`bg-stone-300`}`}),W[e.priority]]}):null]}),(0,Q.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[11px] leading-4`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-stone-400 tabular-nums`,children:n.due?`截止 ${n.due}`:`无截止日期`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-stone-300`,children:`·`}),(0,Q.jsx)(`span`,{className:`shrink-0 tabular-nums ${n.tone}`,children:n.remain}),e.linkedTask?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-stone-300`,children:`·`}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate ${t?`text-stone-400`:`text-stone-500`}`,children:[`任务 `,e.linkedTask]})]}):null]})]})]},e.id)})})]},e.key))})})]})}var $l=`__routine__`;function eu(e){let t=Ln(),n=Ln();return{title:``,status:e===`todo`?Tn(t,n)??`in_progress`:`pool`,statusManual:!1,priority:``,taskId:``,linkedTask:``,startDate:t,dueDate:n,note:``}}function tu(e,t){let n=Array.isArray(t)?t:[],r=[];for(let t of n){if(!t||typeof t!=`object`)continue;let n=t,i=typeof n.title==`string`?n.title.trim():``;if(!i)continue;let a=e===`todo`?qn:Un,o=e===`todo`?An:Wn,s=eu(e),c=typeof n.status==`string`&&a.includes(n.status),l=c?n.status:e===`todo`?s.status:`pool`;r.push({...s,title:i,status:l,statusManual:e===`todo`&&c,priority:typeof n.priority==`string`&&o.includes(n.priority)?n.priority:``,taskId:typeof n.taskId==`string`?n.taskId.trim():``,linkedTask:typeof n.linkedTask==`string`?n.linkedTask.trim():``,startDate:typeof n.startDate==`string`?n.startDate.trim().slice(0,10):s.startDate,dueDate:typeof n.dueDate==`string`?n.dueDate.trim().slice(0,10):s.dueDate,note:typeof n.note==`string`?n.note.trim():``})}return r}function nu(e,t){return t.map(t=>{let n={title:t.title.trim(),status:t.status,priority:t.priority,startDate:t.startDate,dueDate:t.dueDate,note:t.note};return e===`todo`&&(n.taskId=t.taskId,n.linkedTask=t.linkedTask,n.statusManual=!!t.statusManual),n})}var ru=`text-[11px] font-medium text-stone-500`,iu=`h-9 w-full rounded-lg border border-stone-200 px-2.5 text-[13px] text-stone-800 outline-none focus:border-[#4176e6]`;function au(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);return t?`${t[1]}/${t[2]}/${t[3]}`:``}function ou(e){return(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-stone-700`,children:e.children})]})}function su(e){return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[48px_minmax(0,1fr)] items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-stone-700`,children:e.children})]})}function cu(e){let{startDate:t,dueDate:n}=e,r=n||t,i=`h-7 rounded-md px-1.5 text-[12px] text-stone-700 tabular-nums transition-colors hover:bg-stone-100`;return(0,Q.jsxs)(`div`,{className:`grid grid-cols-[48px_minmax(0,1fr)] items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`日期`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ie,{value:t,ariaLabel:`开始日期`,placeholder:`开始日期`,clearable:!1,className:i,onChange:t=>{t&&e.onChange({startDate:t,dueDate:t>r?t:r})}})}),(0,Q.jsx)(`span`,{className:`shrink-0 px-0.5 text-[11px] text-stone-300`,"aria-hidden":!0,children:`~`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ie,{value:n,ariaLabel:`截止日期`,placeholder:`截止日期`,clearable:!1,className:i,onChange:n=>{n&&e.onChange({startDate:n<t?n:t,dueDate:n})}})})]})]})}function lu(e){let[t,n]=(0,K.useState)(()=>e.items),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)([]);(0,K.useEffect)(()=>{n(e.items),i(0)},[e.items]);let s=e.kind===`todo`,c=!!e.quick&&s,l=s&&e.tasksOn!==!1,u=s&&!c&&l,d=s?`待办`:`任务`,f=s?`待办事项`:`任务管理`;(0,K.useEffect)(()=>{if(!l)return;let e=!0;return Gn().then(t=>{e&&o(t)}).catch(()=>{}),()=>{e=!1}},[l]);let p=s?qn:Un,m=s?An:Wn,h=(0,K.useMemo)(()=>p.map(e=>({value:e,label:s?Mn[e]:In[e]})),[s,p]),g=(0,K.useMemo)(()=>[...m.map(e=>({value:e,label:s?W[e]:Vn[e]}))],[s,m]),_=(0,K.useMemo)(()=>[{value:``,label:`不关联`},...a.filter(e=>e.status!==`closed`&&e.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))],[a]),v=(0,K.useMemo)(()=>!!no(a),[a]),y=(0,K.useMemo)(()=>{let e=new Set(t.map(e=>e.taskId).filter(Boolean));return[{value:``,label:`不关联`},...v?[]:[{value:$l,label:`${eo}(确认后自动创建)`}],...a.filter(t=>e.has(t.id)||t.status!==`closed`&&t.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))]},[t,a,v]);function b(e){return e.taskId&&a.some(t=>t.id===e.taskId)?e.taskId:!v&&e.linkedTask.trim()===`日常待办`?$l:``}function x(e,t){if(t===$l){S(e,{taskId:``,linkedTask:eo});return}let n=a.find(e=>e.id===t);S(e,{taskId:n?.id??``,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})}function S(e,t){n(n=>n.map((n,r)=>{if(r!==e)return n;let i={...n,...t};if(!s)return i;if(`status`in t&&!(`startDate`in t||`dueDate`in t))i.statusManual=!0;else if((`startDate`in t||`dueDate`in t)&&!i.statusManual&&!wn(i.status)){let e=Tn(i.startDate,i.dueDate);e&&(i.status=e)}return i}))}function C(e,n){let r=t[e],i=a.find(e=>e.id===n);i?S(e,{taskId:i.id,linkedTask:i.title,startDate:i.startDate||r?.startDate||``,dueDate:i.dueDate||r?.dueDate||``,priority:r?.priority||i.priority||``}):S(e,{taskId:``,linkedTask:``})}function w(e){n(t=>t.filter((t,n)=>n!==e))}let T=t.length>0&&t.every(e=>!!e.title.trim()),E=u&&r>=1,D=c&&t.some(e=>!e.taskId.trim()&&e.linkedTask.trim()===`日常待办`)&&!v,O=E?`所属任务的日期与紧急程度已带到第一页,可回去再调`:c?D?e.quickNote??`确认后会自动创建任务「日常待办」并关联`:`状态 / 所属任务 / 日期已填好(日期可点开改),确认后写入「待办事项」`:`确认后才会写入「${f}」`;return(0,Q.jsxs)(`div`,{className:[`tw-create-card tw-create-card-anim mb-2 flex max-h-[min(62vh,560px)] flex-col overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-[0_6px_24px_rgba(15,23,42,0.08)]`,e.closing?`is-closing`:``].filter(Boolean).join(` `),children:[(0,Q.jsxs)(`div`,{className:`shrink-0 px-5 pt-4`,children:[(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] leading-4 text-stone-400`,children:[(0,Q.jsxs)(`span`,{children:[`新增 `,t.length,` 条`,d]}),u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[`第 `,r+1,` / 2 步`]})]}):null]}),(0,Q.jsx)(`h3`,{className:`text-[15px] leading-5.5 font-medium text-stone-900`,children:E?`关联任务`:r===0?`确认内容后再添加到${f}`:f})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[t.map((e,n)=>{let r=a.find(t=>t.id===e.taskId);return(0,Q.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-stone-50/40 p-3`,children:c?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`input`,{value:e.title,onChange:e=>S(n,{title:e.target.value}),placeholder:`待办名称`,className:`${iu} bg-white`,autoFocus:n===0}),t.length>1?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(n),"aria-label":`移除这一条`,className:`h-9 shrink-0 rounded-lg px-2 text-[12px] text-stone-400 hover:bg-white hover:text-red-600`,children:`移除`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-stone-200 bg-white px-2.5 py-2`,children:[(0,Q.jsx)(su,{label:`状态`,children:Mn[e.status]??`进行中`}),l?(0,Q.jsxs)(`div`,{className:`grid grid-cols-[48px_minmax(0,1fr)] items-center gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`所属任务`}),a.length||!v?(0,Q.jsx)(oe,{flat:!0,ariaLabel:`所属任务`,menuMatchTrigger:!1,menuMinWidth:200,options:y,value:b(e),onChange:e=>x(n,e),className:`min-w-0`,triggerClassName:`h-7 gap-1 rounded-md border-0 bg-transparent pl-0 pr-0.5 text-[12px] hover:bg-stone-50`}):(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-stone-700`,children:e.linkedTask||`未关联`})]}):null,(0,Q.jsx)(cu,{startDate:e.startDate,dueDate:e.dueDate,onChange:e=>S(n,e)})]})]}):E?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`所属任务`}),a.length?(0,Q.jsx)(oe,{flat:!0,ariaLabel:`所属任务`,options:_,value:e.taskId,onChange:e=>C(n,e),className:`w-full`}):(0,Q.jsx)(`span`,{className:`flex h-9 items-center rounded-lg border border-stone-200 bg-white px-2 text-[13px] text-stone-400`,children:`任务管理里还没有任务,可稍后到任务管理关联`})]}),r?(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1.5 rounded-lg border border-stone-200 bg-white px-2.5 py-2`,children:[(0,Q.jsx)(ou,{label:`任务名称`,children:r.title}),(0,Q.jsx)(ou,{label:`状态`,children:In[r.status]??r.status}),(0,Q.jsx)(ou,{label:`紧急程度`,children:r.priority?Vn[r.priority]:`未选择`}),(0,Q.jsx)(ou,{label:`开始日期`,children:au(r.startDate)||`未设置`}),(0,Q.jsx)(ou,{label:`结束日期`,children:au(r.dueDate)||`未设置`})]}):(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] leading-4 text-stone-400`,children:`选中任务后,它的开始 / 结束日期与紧急程度会自动带到第一页。`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`input`,{value:e.title,onChange:e=>S(n,{title:e.target.value}),placeholder:s?`待办名称`:`任务名称`,className:`${iu} bg-white`,autoFocus:n===0}),t.length>1?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>w(n),"aria-label":`移除这一条`,className:`h-9 shrink-0 rounded-lg px-2 text-[12px] text-stone-400 hover:bg-white hover:text-red-600`,children:`移除`}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`状态`}),(0,Q.jsx)(oe,{flat:!0,ariaLabel:s?`待办状态`:`任务状态`,options:h,value:e.status,onChange:e=>S(n,{status:e}),className:`w-full`})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`紧急程度`}),(0,Q.jsx)(oe,{flat:!0,ariaLabel:`紧急程度`,options:g,value:e.priority,onChange:e=>S(n,{priority:e}),className:`w-full`,renderTrigger:()=>(0,Q.jsx)(`span`,{className:`truncate ${e.priority?`text-stone-800`:`text-stone-400`}`,children:e.priority?s?W[e.priority]:Vn[e.priority]:`未选择`})})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`开始日期`}),(0,Q.jsx)(ie,{value:e.startDate,onChange:e=>S(n,{startDate:e}),placeholder:`选择日期`,className:`h-9 rounded-lg border border-stone-200 bg-white px-2 text-[13px] tabular-nums`})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`截止日期`}),(0,Q.jsx)(ie,{value:e.dueDate,onChange:e=>S(n,{dueDate:e}),placeholder:`选择日期`,className:`h-9 rounded-lg border border-stone-200 bg-white px-2 text-[13px] tabular-nums`})]})]}),(0,Q.jsxs)(`label`,{className:`mt-2 flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:ru,children:`备注`}),(0,Q.jsx)(`input`,{value:e.note,onChange:e=>S(n,{note:e.target.value}),placeholder:`备注(可选)`,className:`${iu} bg-white`})]})]})},n)}),t.length?null:(0,Q.jsx)(`p`,{className:`py-4 text-center text-[12px] text-stone-400`,children:`内容已清空,点「取消」放弃这次新增。`})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-stone-100 px-5 py-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:O}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:E?()=>i(0):e.onCancel,className:`h-8 rounded-lg px-3 text-[12px] text-stone-600 outline-none hover:bg-stone-100`,children:E?`上一步`:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!E&&!T,onClick:()=>{u&&r===0?i(1):e.onConfirm(t)},className:`h-8 rounded-lg bg-[#4176e6] px-3.5 text-[12px] font-medium text-white hover:bg-[#3467d4] disabled:cursor-not-allowed disabled:bg-stone-300`,children:u&&r===0?`下一步`:e.manual?`提交`:`确认新增`})]})]})]})}function uu(e,t,n){let r=e;if(n.knowledge&&(r=`${r}\n\n${kc}`),n.fs&&(r=`${r}\n\n${mn}\n\n${ba}\n\n${xo}\n\n${wi}\n\n${bi}`),n.bash&&(r=`${r}\n\n${ir}`),n.pwsh&&(r=`${r}\n\n${ar}`),n.web&&(r=`${r}\n\n${er}`),n.memory&&(r=`${r}\n\n${Tr}`),n.interact&&(r=`${r}\n\n${jo}`),n.todos&&(r=`${r}\n\n${Ga}`),n.tasks&&(r=`${r}\n\n${so}`),n.projects&&(r=`${r}\n\n${wa}`),n.iterations&&(r=`${r}\n\n${Ta}`),n.pmRequirements&&(r=`${r}\n\n${Ea}`),n.bugs&&(r=`${r}\n\n${Da}`),n.planPhase===`planning`&&(r=`${r}\n\n${zo}`),n.planPhase===`approved`&&(r=`${r}\n\n${Bo}`),n.goalEnabled){r=`${r}\n\n${ts}`;let e=as(n.goal);e&&(r=`${r}\n\n【当前会话目标】${e}`)}n.scheduleEnabled&&(r=`${r}\n\n${Ss}`),n.subagentEnabled&&(r=`${r}\n\n${Vs}`),n.workflowEnabled&&(r=`${r}\n\n${yc}`),n.mcpEnabled&&(r=`${r}\n\n${wr}`);let i=n.memory?t.slice(-10):t;return[{role:`system`,content:r},...i]}function du(e){if(!/(?:^|[\s\n])\/$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:{from:t}}function fu(e){let t=/(?:^|[\s\n])@([^\s@]*)$/.exec(e);if(!t)return null;let n=e.lastIndexOf(`@`);return n<0?null:{from:n,query:t[1]??``}}function pu(e){let t=/\s*(?:[((](?:recommended|推荐)[))])\s*$/i;return t.test(e)?{label:e.replace(t,``),recommended:!0}:{label:e,recommended:!1}}var mu=Ke,hu=5,gu=[`image/png`,`image/jpeg`,`image/jpg`,`image/webp`,`image/gif`],_u=[`dialog`,`thread`,`todos`,`memory`],vu=`chat.tab`;function yu(e){let t=[];if(e.content&&t.push(e.content),e.refs?.length){let n=e.refs.filter(e=>e.collection!==`workspace`),r=e.refs.filter(e=>e.collection===`workspace`);if(n.length){let e=n.filter(e=>e.collection===`knowledge`||e.collection===`templates`),r=n.filter(e=>e.collection===`prompts`||e.collection===`cases`);if(e.length){let n=e.map(e=>`- ${e.path} 《${e.title}》(${e.category} · ${Dc(e.format)})`);t.push(`引用项目文档(请使用 kb_read 读取):\n${n.join(`
|
|
218
218
|
`)}`)}if(r.length){let e=r.map(e=>`- ${e.collection}/${e.path} 《${e.title}》(${e.category})`);t.push(`引用管理文档(路径已给出,正文可能已在上文):\n${e.join(`
|
|
219
219
|
`)}`)}}if(r.length){let e=r.map(e=>`- ${e.path} 《${e.title}》(${e.format===`dir`?`文件夹`:`文件`})`);t.push(`引用工作区路径(请使用 fs_list / fs_read):\n${e.join(`
|
|
220
220
|
`)}`)}}return e.attachments?.length&&t.push(e.attachments.map(e=>`附件《${e.name}》:\n\`\`\`\`\n${e.content}\n\`\`\`\``).join(`
|