lantern-harness 0.1.23 → 0.1.25
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 +51 -0
- package/builtin/session/bash-session.mjs +91 -0
- package/builtin/session/lh-bash.mjs +67 -1
- package/builtin/session/lh-web.mjs +103 -52
- package/builtin/session/mcp-client.mjs +290 -0
- package/builtin/session/pwsh-session.mjs +90 -0
- package/builtin/session/session-runs.mjs +6 -1
- package/builtin/session/tool-run-policy.mjs +32 -0
- package/builtin/session/web-fetch-policy.mjs +79 -0
- package/cli/acp-server.mjs +19 -9
- package/cli/agent-policy.mjs +60 -0
- package/cli/headless.mjs +30 -6
- package/cli/jsonrpc-server.mjs +9 -3
- package/cli/lantern.mjs +40 -5
- package/cli/server.mjs +2 -0
- package/dist/500.html +4 -4
- package/dist/_astro/Base.COYvzmy5.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.CWRCetQl.js → Base.astro_astro_type_script_index_0_lang.Cb6ggViJ.js} +1 -1
- package/dist/_astro/{CaseExecBoard.Dnb8oP5i.js → CaseExecBoard.cl2Od7av.js} +1 -1
- package/dist/_astro/{CaseGenerateApp.ci_JowEk.js → CaseGenerateApp.nE3RR7bV.js} +5 -5
- package/dist/_astro/CasesLibrary.e3vlOqSQ.js +21 -0
- package/dist/_astro/ChatApp.CECImcJo.js +226 -0
- package/dist/_astro/ConfirmDialog.D5qXeML0.js +1 -0
- package/dist/_astro/{DashboardBoard.D-zHXRds.js → DashboardBoard.CmxqpmzI.js} +2 -2
- package/dist/_astro/{DocsFileBrowser.BM3nH4VD.js → DocsFileBrowser.BdpWp8zQ.js} +1 -1
- package/dist/_astro/DocsPager.D55FTK9d.js +1 -0
- package/dist/_astro/{KnowledgeLibrary.D9KnqXzr.js → KnowledgeLibrary.DKci9jN8.js} +1 -1
- package/dist/_astro/MultiSelectDropdown.BHxW9XLR.js +1 -0
- package/dist/_astro/NamePromptDialog.Csfnh5eM.js +1 -0
- package/dist/_astro/{NavLibraries.RH3Sinuh.js → NavLibraries.BybmHnXn.js} +1 -1
- package/dist/_astro/PluginsPage.B6dsHB44.js +1 -0
- package/dist/_astro/{PluginsPage.DBRfSxtq.js → PluginsPage.D5LXPMns.js} +2 -2
- package/dist/_astro/{PmBugsBoard.BnnaNP1y.js → PmBugsBoard.B6w50MHD.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.phiyhQVA.js → PmIterationsBoard.Dk7JheCU.js} +1 -1
- package/dist/_astro/{PmProjectDetail.C8kRX5lu.js → PmProjectDetail.O44fnczN.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.CFApEGPo.js → PmProjectsBoard.qgj9HAj8.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.BKY3h4CQ.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.DR9egcgA.js → PmRequirementsBoard.DTL_RFxq.js} +1 -1
- package/dist/_astro/{PmShared.BrBicDMN.js → PmShared.Bwphj4KH.js} +1 -1
- package/dist/_astro/{PromptsLibrary.sz6MivVn.js → PromptsLibrary.Dv5OABdK.js} +1 -1
- package/dist/_astro/{ReportsPage.CYZtpeiv.js → ReportsPage.B7MOskzc.js} +1 -1
- package/dist/_astro/ReqAnalysisBoard.nUp89z1s.js +39 -0
- package/dist/_astro/{RequirementsLibrary.R4dNZa9y.js → RequirementsLibrary._OviMClB.js} +1 -1
- package/dist/_astro/SearchableSelect.D3ODywC4.js +1 -0
- package/dist/_astro/SettingsDialog.D3f4EOwl.js +1 -0
- package/dist/_astro/SlideOverDrawer.CpQu7VMQ.js +1 -0
- package/dist/_astro/SpaceSwitcher.DQOG363O.js +7 -0
- package/dist/_astro/{TasksBoard.D0HwS5hd.js → TasksBoard.rwdPWLAh.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.CVv5Ef30.js → TemplatesLibrary.CEVQPDDz.js} +1 -1
- package/dist/_astro/{TestStatsBoard._qNcNorG.js → TestStatsBoard.CO4JMh4N.js} +1 -1
- package/dist/_astro/{TodosBoard.CF5wbJy7.js → TodosBoard.CrZMl6Ei.js} +1 -1
- package/dist/_astro/UiAutoBoard.BRMCH1zB.js +9 -0
- package/dist/_astro/{app-config.CF1xVPmo.js → app-config.DAIyT--R.js} +1 -1
- package/dist/_astro/app-version.BPkgRlbu.js +1 -0
- package/dist/_astro/bash-tools.D4DBYc9k.js +27 -0
- package/dist/_astro/case-fields.Dqkws1iX.js +1 -0
- package/dist/_astro/case-gen-run.Byxy6M5X.js +22 -0
- package/dist/_astro/case-review.DlCarphW.js +3 -0
- package/dist/_astro/{case-types.DS1EQ5yP.js → case-types.B6MLX3iE.js} +1 -1
- package/dist/_astro/{hydrate-cache.CmC22o_H.js → hydrate-cache.C0F0L04c.js} +1 -1
- package/dist/_astro/i18n.ele1lM9e.js +7 -0
- package/dist/_astro/{llm.BuR7z55C.js → llm.DyweO-KK.js} +1 -1
- package/dist/_astro/open-docs-in-session.D608wzlx.js +1 -0
- package/dist/_astro/{plugins.CVM1IaoC.js → plugins.Di6uuouN.js} +1 -1
- package/dist/_astro/req-analysis.CIZ_cIJQ.js +23 -0
- package/dist/_astro/settings.DbhUT6Ao.js +2 -0
- package/dist/_astro/{spaces-client.DnS6MgGy.js → spaces-client.OuJPy3GP.js} +1 -1
- package/dist/_astro/{story-review.BbdIf5zg.js → story-review.BvgXBApZ.js} +6 -3
- package/dist/_astro/{view-prefs.D1snIG5o.js → view-prefs.DkS1ldnh.js} +1 -1
- package/dist/case-exec/index.html +5 -5
- package/dist/cases/generate/index.html +5 -5
- package/dist/cases/library/index.html +5 -5
- package/dist/dashboard/index.html +5 -5
- package/dist/docs/changelog/index.html +52 -5
- package/dist/docs/install/index.html +48 -4
- package/dist/docs/manual/index.html +40 -33
- package/dist/knowledge/index.html +5 -5
- package/dist/plugins/index.html +5 -5
- package/dist/pm/bugs/index.html +5 -5
- package/dist/pm/iterations/index.html +5 -5
- package/dist/pm/projects/detail/index.html +5 -5
- package/dist/pm/projects/index.html +5 -5
- package/dist/pm/requirements/index.html +5 -5
- package/dist/prompts/index.html +5 -5
- package/dist/reports/index.html +5 -5
- package/dist/requirement-analysis/index.html +5 -5
- package/dist/requirements/index.html +5 -5
- package/dist/tasks/index.html +5 -5
- package/dist/templates/index.html +5 -5
- package/dist/test-automation/index.html +5 -5
- package/dist/test-stats/index.html +5 -5
- package/dist/todos/index.html +5 -5
- package/dist/workbench/index.html +5 -5
- package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +9 -7
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +14 -2
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +23 -0
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +35 -27
- package/lh-plugins/case-review-prompt.mjs +12 -106
- package/lh-plugins/lh-case-review.mjs +118 -34
- package/lh-plugins/lh-mcp.mjs +79 -0
- package/lh-plugins/lh-reports.mjs +11 -29
- package/lh-plugins/lh-req-analysis.mjs +59 -6
- package/lh-plugins/req-analysis-prompt.mjs +34 -44
- package/lh-plugins/story-review-prompt.mjs +8 -52
- package/lh-plugins/uiauto-prompt.mjs +9 -65
- package/package.json +3 -1
- package/dist/_astro/Base.GThhapKd.css +0 -1
- package/dist/_astro/CasesLibrary.CDjuLV_E.js +0 -21
- package/dist/_astro/ChatApp.Td2xCiQG.js +0 -216
- package/dist/_astro/ConfirmDialog.CsMwWevK.js +0 -1
- package/dist/_astro/DocsPager.B9VhI6E3.js +0 -1
- package/dist/_astro/NamePromptDialog.CS1pTTVl.js +0 -1
- package/dist/_astro/PluginsPage.DMDyUktn.js +0 -1
- package/dist/_astro/PmRequirementsBoard.B-AI9iZX.js +0 -1
- package/dist/_astro/ReqAnalysisBoard.CazI9SU-.js +0 -29
- package/dist/_astro/SearchableSelect.Cbb8jMnP.js +0 -1
- package/dist/_astro/SettingsDialog.Bs1I8b27.js +0 -1
- package/dist/_astro/SlideOverDrawer.DMWJPD_W.js +0 -1
- package/dist/_astro/SpaceSwitcher.Dw9LjKiJ.js +0 -7
- package/dist/_astro/UiAutoBoard.B-7mL3ez.js +0 -9
- package/dist/_astro/app-version.yT2l6J8H.js +0 -1
- package/dist/_astro/bash-tools.CPS0ZiKi.js +0 -25
- package/dist/_astro/case-fields.h0roo2br.js +0 -1
- package/dist/_astro/case-gen-run.D8DGX0mr.js +0 -19
- package/dist/_astro/case-review.C1hQRbQ2.js +0 -3
- package/dist/_astro/i18n.CjqQGCAI.js +0 -7
- package/dist/_astro/open-docs-in-session.Cj0J2-XT.js +0 -1
- package/dist/_astro/req-analysis.dhgy4p2f.js +0 -14
- package/dist/_astro/settings.B1yetppp.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"./dialog.DZHZCe_T.js";import{t as i}from"./jsx-runtime.DUg_B_vD.js";var a=i();function o({open:i,title:o=`确认`,message:s,confirmLabel:c=`确定`,cancelLabel:l=`取消`,danger:u=!1,hideCancel:d=!1,onClose:f,onConfirm:p}){let m=u===!0||u===`solid`?`solid`:u===`outline`?`outline`:null;return(0,a.jsxs)(n,{open:i,onClose:f,transition:!0,className:`relative z-110`,children:[(0,a.jsx)(r,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,a.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,a.jsxs)(e,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim relative w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:f,className:`tw-confirm-cancel absolute top-3.5 right-3.5 w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`}),(0,a.jsx)(t,{className:`tw-confirm-title pr-8 text-base font-semibold text-stone-900`,children:o}),(0,a.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed whitespace-pre-wrap`,children:s}),(0,a.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[d?null:(0,a.jsx)(`button`,{type:`button`,onClick:f,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:l}),(0,a.jsx)(`button`,{type:`button`,onClick:p,className:m===`outline`?`h-8 px-3 text-sm rounded-lg border border-red-300 text-red-600 bg-transparent hover:bg-red-50 transition-colors`:m===`solid`?`h-8 px-3 text-sm rounded-lg text-white bg-red-600 hover:bg-red-700 transition-colors`:`h-8 px-3 text-sm rounded-lg text-white bg-[#4176e6] hover:bg-[#3566d0] transition-colors`,children:c})]})]})})]})}export{o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.CF1xVPmo.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./SelectDropdown.apWlFGbA.js";var a=e(t(),1),o=[5,10,20,50],s=`tw.docs.page-size.v1`;function c(e){return typeof e==`number`&&o.includes(e)}function l(e,t=s){try{let r=localStorage.getItem(n(t)),i=r===null?NaN:Number(r);return c(i)?i:e}catch{return e}}function u(e,t=s){if(c(e))try{localStorage.setItem(n(t),String(e))}catch{}}var d=r(),f=`h-8 px-3 shrink-0 whitespace-nowrap text-sm text-stone-600 border border-stone-200 rounded-lg hover:bg-stone-50 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,p=o.map(e=>({value:String(e),label:String(e)}));function m(e,t){let[n,r]=(0,a.useState)(()=>l(e,t));return[n,(0,a.useCallback)(e=>{c(e)&&(u(e,t),r(e))},[t])]}function h({page:e,totalPages:t,pageSize:n,busy:r=!1,onPage:a,onPageSize:o}){return(0,d.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-t border-stone-100 flex items-center justify-between gap-2 flex-wrap`,children:[(0,d.jsxs)(`span`,{className:`text-xs text-stone-500 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{children:[`第 `,e,` / `,t,` 页 ·`]}),(0,d.jsx)(i,{compact:!0,centerContent:!0,options:p,value:String(n),onChange:e=>o(Number(e)),disabled:r,ariaLabel:`每页条数`,showCheck:!1,className:`w-18`}),(0,d.jsx)(`span`,{children:`条`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,disabled:r||e<=1,onClick:()=>a(1),className:f,children:`首页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e<=1,onClick:()=>a(e-1),className:f,children:`上一页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e>=t,onClick:()=>a(e+1),className:f,children:`下一页`}),(0,d.jsx)(`button`,{type:`button`,disabled:r||e>=t,onClick:()=>a(t),className:f,children:`末页`})]})]})}export{m as n,h as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./dialog.DZHZCe_T.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";var s=e(t(),1),c=o();function l({open:e,title:t=`新建文件夹`,label:o=`文件夹名称`,placeholder:l=`请输入名称`,initialValue:u=``,lockExtension:d=!1,confirmLabel:f=`创建`,cancelLabel:p=`取消`,error:m=``,onClose:h,onConfirm:g}){let[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(``),x=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(e){let e=u,t=``;if(d){let n=u.lastIndexOf(`.`);n>0&&(e=u.slice(0,n),t=u.slice(n))}v(e),b(t);let n=window.setTimeout(()=>{x.current?.focus(),x.current?.select()},50);return()=>window.clearTimeout(n)}},[e,u,d]);function S(){let e=_.trim();e&&g(e+y)}return(0,c.jsxs)(i,{open:e,onClose:h,transition:!0,className:`relative z-50`,children:[(0,c.jsx)(a,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,c.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,c.jsxs)(n,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,c.jsx)(r,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:t}),(0,c.jsxs)(`label`,{className:`tw-confirm-msg mt-4 block text-xs font-medium text-stone-500`,children:[o,(0,c.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-0 rounded-lg border border-stone-200 focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6] transition-colors`,children:[(0,c.jsx)(`input`,{ref:x,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:l,className:`flex-1 min-w-0 h-9 px-3 text-sm rounded-lg border-0 bg-transparent text-stone-800 outline-none`}),y?(0,c.jsx)(`span`,{className:`shrink-0 pr-3 text-sm text-stone-400 select-none`,children:y}):null]}),m?(0,c.jsx)(`span`,{className:`mt-1.5 block text-[11px] font-normal leading-relaxed text-red-600`,children:m}):null]}),(0,c.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:h,className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg text-stone-600 hover:bg-stone-100 transition-colors`,children:p}),(0,c.jsx)(`button`,{type:`button`,disabled:!_.trim(),onClick:S,className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:f})]})]})})]})}export{l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PluginsPage.DBRfSxtq.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{t as default}from"./PmRequirementsBoard.DR9egcgA.js";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.CVM1IaoC.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as p}from"./SelectDropdown.apWlFGbA.js";import{showToast as m}from"./Toast.BO2NFckG.js";import{A as h,C as g,D as ee,E as te,S as _,T as v,_ as y,a as ne,b as re,c as ie,d as ae,f as oe,h as se,i as ce,j as b,k as le,l as ue,m as de,n as x,o as fe,r as S,s as pe,t as me,u as he,v as ge,w as _e,x as ve,y as ye}from"./req-analysis.dhgy4p2f.js";import{o as be}from"./project-docs.DAw9bzgk.js";import{s as xe}from"./llm.BuR7z55C.js";import{f as Se,l as Ce,p as we}from"./settings.B1yetppp.js";import{a as C,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,l as je,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,u as Re,v as ze}from"./story-review.BbdIf5zg.js";import{t as Be}from"./hydrate-cache.CmC22o_H.js";import{S as w,_ as Ve,g as He,k as Ue,m as T,u as We}from"./PmShared.BrBicDMN.js";var E=e(t(),1),Ge=`可用工具(只调用这些,不要自己编工具名):
|
|
2
|
-
- req_set_outline:提交本批「需求条目」,返回每个条目的 id。
|
|
3
|
-
- req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
|
|
4
|
-
- req_save_check:提交体检结果(缺口清单 + 结论)。
|
|
5
|
-
- req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
|
|
6
|
-
|
|
7
|
-
提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,D=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function Ke(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function O(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function qe(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function k(e){let t=O(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function Je(e){let t=O(e,40);return D.includes(t)?t:`other`}var A=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function Ye(e){let t=O(e,40);if(A.includes(t))return t;let n=O(e,20);return A.find(e=>Le[e]===n)??`functional`}function j(e){let t=O(e,4).toUpperCase();return Re.includes(t)?t:`P1`}function Xe(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=O(n.title,200);if(!r)return null;let i=O(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:Ye(n.dimension),priority:j(n.priority),title:r,precondition:O(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>O(e,500)).filter(Boolean).slice(0,20):[],expected:O(n.expected,1e3)}}var Ze=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:D},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:A,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:Re},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function Qe(e,t,n){let r=Ke(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>qe(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=O(e.title,200)||O(e.quote,200);if(!r||a.has(qe(r)))continue;a.add(qe(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:O(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=ve(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=ie(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[qe(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=O(n.title,200);if(!r)continue;let i=O(n.storyId,20),o=a.has(i)&&i||t.get(qe(O(n.storyTitle,200)))||``,c=Je(n.type);s.push({id:y(c,o,r),storyId:o,type:c,severity:k(n.severity),title:r,detail:O(n.detail,1e3),suggestion:O(n.suggestion,1e3),origin:`model`,selected:!1})}let c=re(e.gaps,s),l=O(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>Xe(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:O(r.summary,2e3),points:a})).testPoints?.points??a,s=A.map(e=>({dimension:Le[e],count:o.filter(t=>t.dimension===e).length})),c=Re.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function M(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function $e(e){let t=M(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}function et(e,t=[]){let n=new Set(t),r=M(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>Xe(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?O(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var N=u(),P=`text-xs font-semibold tracking-wide text-stone-500`,tt=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,F=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function nt({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,N.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,N.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,N.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始审查`})]});let c=C(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Ne(e.gaps),p=new Map(t.map(e=>[e.id,e.title]));return(0,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:P,children:`需求条目覆盖率`}),(0,N.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,N.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,N.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,N.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,N.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,N.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,N.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,N.jsxs)(`div`,{className:`text-right`,children:[(0,N.jsx)(`p`,{className:P,children:`缺口`}),(0,N.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,N.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,N.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,N.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,N.jsx)(`p`,{className:P,children:`维度覆盖`}),(0,N.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,N.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,N.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,N.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,N.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,N.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,N.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,N.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,N.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,className:F,onClick:s,children:`导出 Markdown`}),(0,N.jsx)(`button`,{type:`button`,className:F,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,N.jsx)(`button`,{type:`button`,className:tt,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,N.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,N.jsxs)(`section`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,N.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,N.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,N.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,N.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,N.jsx)(rt,{gap:e,storyTitle:p.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,N.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function rt({gap:e,storyTitle:t,onToggle:n}){return(0,N.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,N.jsx)(w,{tone:x[e.severity],children:me[e.severity]}),(0,N.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:S[e.type]}),e.storyId?(0,N.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,N.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,N.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,N.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,N.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,N.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var it=`reqanalysis.testPointsView`,at=[`map`,`list`],I=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function ot({point:e}){return(0,N.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,N.jsxs)(`p`,{children:[(0,N.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,N.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,N.jsxs)(`p`,{children:[(0,N.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function L({req:e}){return(0,N.jsxs)(`div`,{className:`flex items-stretch gap-0`,children:[(0,N.jsxs)(`div`,{className:`flex w-36 shrink-0 flex-col justify-center rounded-l-xl border border-r-0 border-[#c9d8ff] bg-[#f5f8ff] px-3 py-3`,children:[(0,N.jsx)(`p`,{className:`text-[11px] text-[#5b7fd6]`,children:`需求`}),(0,N.jsx)(`p`,{className:`text-sm font-semibold leading-snug text-stone-800`,children:e.title}),(0,N.jsxs)(`p`,{className:`mt-1 text-[11px] tabular-nums text-stone-400`,children:[e.points.length,` 条`]})]}),(0,N.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-hidden rounded-r-xl border border-stone-200 bg-white`,children:e.dimensions.map((e,t)=>{let n=Te[e.key];return(0,N.jsxs)(`div`,{className:`flex w-[9.5rem] shrink-0 flex-col ${t>0?`border-l border-stone-100`:``}`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2 py-1.5`,children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n.accent}`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`truncate text-[11px] font-medium text-stone-700`,children:n.label})]}),(0,N.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,N.jsx)(`div`,{className:`max-h-52 space-y-1.5 overflow-y-auto px-1.5 py-1.5`,children:e.points.length?e.points.map(e=>(0,N.jsx)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/70 px-1.5 py-1`,children:(0,N.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,N.jsx)(w,{tone:je[e.priority].tone,children:e.priority}),(0,N.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-[11px] leading-snug text-stone-700`,children:e.title})]})},e.id)):(0,N.jsx)(`p`,{className:`py-3 text-center text-[11px] text-stone-300`,children:`无`})})]},e.key)})})]})}function R({doc:e,idealTitles:t}){let n=(0,E.useMemo)(()=>Oe(e,t),[e,t]);return(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,N.jsx)(`div`,{className:`min-w-[62rem] space-y-3`,children:n.length?n.map(e=>(0,N.jsx)(L,{req:e},e.key)):(0,N.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`还没有测试点。`})})}),(0,N.jsx)(`p`,{className:`text-center text-[11px] text-stone-400`,children:`每条需求横向展开五个维度;列过窄时整行左右滑动。导出 XMind 为同结构的向右逻辑图。`})]})}function z({doc:e,idealTitles:t}){let n=(0,E.useMemo)(()=>Oe(e,t),[e,t]);return(0,N.jsx)(`div`,{className:`space-y-3`,children:n.map(e=>(0,N.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`border-b border-stone-100 bg-[#f8fafc] px-3.5 py-2.5`,children:[(0,N.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`需求`}),(0,N.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title}),(0,N.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[e.points.length,` 条`]})]}),(0,N.jsx)(`div`,{className:`divide-y divide-stone-100`,children:e.dimensions.map(e=>(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${Te[e.key].accent}`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:e.label}),(0,N.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,N.jsx)(`ul`,{className:`border-t border-stone-50`,children:e.points.map(e=>(0,N.jsx)(`li`,{className:`border-t border-stone-50 first:border-t-0`,children:(0,N.jsxs)(`details`,{className:`group px-3.5 py-2 pl-8`,children:[(0,N.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,N.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,N.jsx)(w,{tone:je[e.priority].tone,children:e.priority})}),(0,N.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,N.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,N.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,N.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,N.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,N.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,N.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,N.jsx)(ot,{point:e})})]})},e.id))}):(0,N.jsx)(`p`,{className:`px-3.5 py-2 pl-8 text-[11px] text-stone-300`,children:`本维度没有测试点。`})]},e.key))})]},e.key))})}function st({doc:e,idealTitles:t=[],generating:n,busy:r,promptReady:a,onExportXmind:s,onExportMarkdown:c}){let[l,u]=(0,E.useState)(()=>o(it,at,`map`)),d=e.testPoints,f=De(d),p=!!e.sourcePath&&t.length===0,m=(0,E.useMemo)(()=>p?0:Oe(e,t).length,[e,t,p]),h=e=>{u(e),i(it,e)};if(!d){let t=e.stories.length?a?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,N.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,N.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`按需求文档每一行整理标题,再按功能 / 边界值 / 异常 / 业务规则 / 非功能拆测试点;导图左右展开,可导出 XMind(向右逻辑图)与 Markdown。`}),t?(0,N.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:t}):null,(0,N.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:n?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`需求 `,(0,N.jsx)(`span`,{className:`font-medium text-stone-700`,children:m}),` · 测试点`,` `,(0,N.jsx)(`span`,{className:`font-medium text-stone-700`,children:f.total})]}),(0,N.jsx)(`span`,{className:`flex items-center gap-1`,children:Re.map(e=>(0,N.jsxs)(w,{tone:je[e].tone,children:[e,` `,f.byPriority[e]]},e))}),(0,N.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,f.coveredDimensions,`/5`]}),(0,N.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,N.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${l===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>h(e.id),children:e.label},e.id))}),(0,N.jsx)(`button`,{type:`button`,className:I,disabled:r,onClick:s,children:`导出 XMind`}),(0,N.jsx)(`button`,{type:`button`,className:I,disabled:r,onClick:c,children:`导出 Markdown`})]})]}),p?(0,N.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-xl border border-dashed border-stone-200 py-16 text-xs text-stone-400`,"aria-busy":`true`,children:[(0,N.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),`正在按需求文档行整理…`]}):l===`map`?(0,N.jsx)(R,{doc:e,idealTitles:t}):(0,N.jsx)(z,{doc:e,idealTitles:t}),d.summary?(0,N.jsxs)(`details`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-stone-600`,children:`生成说明`}),(0,N.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed whitespace-pre-wrap text-stone-500`,children:d.summary})]}):null]})}var ct=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],lt=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,ut=`w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,B=`text-xs font-semibold tracking-wide text-stone-500`,dt=`text-[11px] font-medium tracking-wide text-stone-400`,ft={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function V({label:e,children:t}){return(0,N.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,N.jsx)(`p`,{className:`${dt} pt-0.5`,children:e}),(0,N.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function H(e){return e.split(`
|
|
8
|
-
`).map(e=>e.trim()).filter(Boolean)}function pt({label:e,value:t,placeholder:n,onChange:r}){return(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsxs)(`span`,{className:B,children:[e,`(一行一条)`]}),(0,N.jsx)(`textarea`,{className:`${ut} mt-1 min-h-[64px]`,value:t.join(`
|
|
9
|
-
`),placeholder:n,onChange:e=>r(H(e.target.value))})]})}function U({value:e,onChange:t}){return(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`主流程(一行一步:动作 -> 结果)`}),(0,N.jsx)(`textarea`,{className:`${ut} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
|
|
10
|
-
`),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(H(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{action:e}:{action:e.slice(0,t).trim(),result:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function mt({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
11
|
-
`)).join(`
|
|
12
|
-
|
|
13
|
-
`);return(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,N.jsx)(`textarea`,{className:`${ut} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
|
|
14
|
-
1. 提交后进入人工队列
|
|
15
|
-
2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
|
|
16
|
-
`).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function ht({value:e,onChange:t}){return(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`异常场景(一行一条:场景 -> 预期)`}),(0,N.jsx)(`textarea`,{className:`${ut} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
|
|
17
|
-
`),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(H(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{scenario:e,expected:``}:{scenario:e.slice(0,t).trim(),expected:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function gt({value:e,onChange:t}){return(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`验收标准(一行一条:Given | When | Then)`}),(0,N.jsx)(`textarea`,{className:`${ut} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
|
|
18
|
-
`),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(H(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function _t({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,E.useState)(!1),[d,f]=(0,E.useState)(!1),[m,h]=(0,E.useState)(e),[g,ee]=(0,E.useState)(!1);(0,E.useEffect)(()=>{if(l||d){ee(!0);return}let e=window.setTimeout(()=>ee(!1),200);return()=>window.clearTimeout(e)},[l,d]);let te=()=>{h({...e}),f(!0),u(!0)},_=e=>h(t=>({...t,...e})),v=r.filter(e=>e.severity===`high`).length;return(0,N.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,N.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${ft[e.priority]}`,"aria-hidden":`true`}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,N.jsx)(w,{tone:fe[e.priority],children:e.priority}),(0,N.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,N.jsxs)(w,{tone:v?`red`:`amber`,children:[r.length,` 个缺口`,v?` · 高 ${v}`:``]}):null]}),(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`}),l?null:(0,N.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,N.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,N.jsx)(T,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,N.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,N.jsx)(T,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,N.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):te(),children:(0,N.jsx)(T,{name:`pencil`,size:14})}),(0,N.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,N.jsx)(T,{name:`trash`,size:14})}),(0,N.jsx)(T,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,N.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,N.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[g&&d?(0,N.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`标题`}),(0,N.jsx)(`input`,{className:`${lt} mt-1`,value:m.title,onChange:e=>_({title:e.target.value})})]}),(0,N.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`角色`}),(0,N.jsx)(`input`,{className:`${lt} mt-1`,value:m.role,onChange:e=>_({role:e.target.value})})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`优先级`}),(0,N.jsx)(`div`,{className:`mt-1`,children:(0,N.jsx)(p,{options:ct,value:m.priority,onChange:e=>_({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`目标`}),(0,N.jsx)(`input`,{className:`${lt} mt-1`,value:m.goal,onChange:e=>_({goal:e.target.value})})]}),(0,N.jsxs)(`label`,{className:`block`,children:[(0,N.jsx)(`span`,{className:B,children:`价值 / 备注`}),(0,N.jsx)(`input`,{className:`${lt} mt-1`,value:m.value,onChange:e=>_({value:e.target.value})})]}),(0,N.jsx)(pt,{label:`前置条件`,value:m.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>_({preconditions:e})}),(0,N.jsx)(U,{value:m.mainFlow,onChange:e=>_({mainFlow:e})}),(0,N.jsx)(mt,{value:m.altFlows,onChange:e=>_({altFlows:e})}),(0,N.jsx)(ht,{value:m.exceptions,onChange:e=>_({exceptions:e})}),(0,N.jsx)(pt,{label:`后置条件`,value:m.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>_({postconditions:e})}),(0,N.jsx)(gt,{value:m.acceptance,onChange:e=>_({acceptance:e})}),(0,N.jsx)(pt,{label:`覆盖维度`,value:m.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>_({dimensions:e})}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>f(!1),children:`取消`}),(0,N.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!m.title.trim(),onClick:()=>{a(m),f(!1)},children:`保存`})]})]})]}):null,g&&!d?(0,N.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,N.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,N.jsx)(V,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,N.jsx)(V,{label:`前置条件`,children:(0,N.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,N.jsx)(V,{label:`主流程`,children:(0,N.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,N.jsxs)(`li`,{children:[e.actor?(0,N.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,N.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,N.jsx)(V,{label:`替代流程`,children:(0,N.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,N.jsxs)(`li`,{children:[(0,N.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,N.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,N.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,N.jsx)(V,{label:`异常场景`,children:(0,N.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,N.jsxs)(`li`,{children:[e.scenario,e.expected?(0,N.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,N.jsx)(V,{label:`后置条件`,children:(0,N.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,N.jsx)(V,{label:`验收标准`,children:(0,N.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,N.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,N.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,N.jsx)(`span`,{children:e.given||`—`}),(0,N.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,N.jsx)(`span`,{children:e.when||`—`}),(0,N.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,N.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,N.jsx)(V,{label:`覆盖维度`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,N.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,N.jsx)(V,{label:`来源条目`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,N.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,N.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,N.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,N.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,N.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,N.jsx)(w,{tone:x[e.severity],children:me[e.severity]}),(0,N.jsx)(`span`,{className:`text-stone-500`,children:S[e.type]}),(0,N.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var vt=`reqanalysis.doc`,yt=`reqanalysis.listmode`,bt=`reqanalysis.view`,xt=`reqanalysis.tab`,St=`reqanalysis.storykeyword`,Ct=[`list`,`work`],wt=[`stories`,`check`,`outline`,`points`],Tt=`reqanalysis.activity`,Et=[`info`,`tool`,`done`,`error`,`stage`];function Dt(e){return`${Tt}.${e}`}function Ot(e){if(!e)return[];let t=l(Dt(e),[]);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.text==`string`&&typeof t.at==`string`&&typeof(t.detail??``)==`string`&&Et.includes(t.kind)}).slice(-200):[]}var kt=`reqanalysis.run`,At=[`decompose`,`audit`,`fix`,`testpoints`],W=null,jt={current:null},Mt=new Set;function Nt(e){return`${kt}.${e}`}function Pt(e){let t=e?.docId??W?.docId;W=e,t&&a(Nt(t),e);for(let t of Mt)t(e)}function Ft(e){return Mt.add(e),()=>{Mt.delete(e)}}function G(e,t){if(!W||W.status!==`running`)return;let n=Math.max(0,Math.min(100,Math.round(e)));(n!==W.done||t!==void 0&&t!==W.message)&&Pt({...W,total:100,done:n,...t===void 0?{}:{message:t}})}var K=96;function It(e,t=1){if(!W||W.status!==`running`)return;let n=Math.max(1,Math.min(K,Math.round(e))),r=W.done;if(r>=n)return;let i=n-r,a=i>28?Math.min(Math.max(1,t),i):1;Pt({...W,total:100,done:Math.min(n,r+a)})}function Lt(e,t=1200){let n=0,r=window.setInterval(()=>{if(!W||W.status!==`running`)return;let t=Math.max(1,Math.min(K,Math.round(e)))-W.done;t<=0||(n+=1,n%(t>40?1:t>24?2:t>12?3:t>5?5:8)==0&&It(e,1))},t);return()=>window.clearInterval(r)}function Rt(e){if(!e)return null;let t=l(Nt(e),null);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.label!=`string`||typeof n.message!=`string`||!At.includes(n.kind))return null;let r=n.status===`done`||n.status===`error`?n.status:`stopped`;return{docId:e,kind:n.kind,label:n.label,done:Math.max(0,Number(n.done)||0),total:Math.max(0,Number(n.total)||0),message:n.message,startedAt:Number(n.startedAt)||0,status:r,finishedAt:Number(n.finishedAt)||void 0}}var zt={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},Bt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md bg-[#3370ff] px-3.5 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Vt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-stone-200 bg-white px-3 text-sm text-stone-700 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,Ht=`text-xs font-semibold tracking-wide text-stone-500`;function Ut(e){return e.split(`/`).pop()||e}function Wt(e){return(e.format||Ut(e.path).split(`.`).pop()||``).toLowerCase()}function Gt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`),r=`${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;return t.getFullYear()===new Date().getFullYear()?r:`${t.getFullYear()}/${r}`}function Kt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function q(e,t=160){if(e==null)return``;let n=``;try{n=typeof e==`string`?e:JSON.stringify(e)}catch{return``}return n?n.length>t?`${n.slice(0,t)}…`:n:``}function qt(e){let t=Math.max(0,(Date.now()-e)/1e3);return t<10?`${t.toFixed(1)}s`:`${Math.round(t)}s`}function Jt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Yt({name:e,ready:t}){return(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Xt(){let e=Ue(`reqAnalysis`),t=Ue(`storyReview`),u=Ue(`testPoints`),[y,re]=(0,E.useState)(null),[x,fe]=(0,E.useState)([]),[S,me]=(0,E.useState)(``),[C,Te]=(0,E.useState)(null),[De,Oe]=(0,E.useState)([]),[je,Ne]=(0,E.useState)(``),[Le,Re]=(0,E.useState)(``),[D,Ke]=(0,E.useState)(null),[O,qe]=(0,E.useState)(null),[k,Je]=(0,E.useState)(null),[A,Ye]=(0,E.useState)(null),[j,Xe]=(0,E.useState)(()=>W);(0,E.useEffect)(()=>(Xe(W),Ft(Xe)),[]);let M=j?.status===`running`?j.kind:null,P=j?.status===`running`&&j.docId===S?{label:j.label,done:j.done,total:j.total,message:j.message}:null,tt=(0,E.useRef)(Date.now()),F=j&&j.docId===S&&j.status!==`running`&&(j.finishedAt??0)<tt.current?j:null,[rt,it]=(0,E.useState)([]),[at,I]=(0,E.useState)(``),[ot,L]=(0,E.useState)(``),[R,z]=(0,E.useState)(()=>o(xt,wt,`stories`));(0,E.useEffect)(()=>{i(xt,R)},[R]);let[ct,lt]=(0,E.useState)(`list`),ut=(0,E.useRef)(o(bt,Ct,`list`)),[B,dt]=(0,E.useState)(!0),[ft,V]=(0,E.useState)(()=>o(yt,[`doc`,`story`],`doc`)),[H,pt]=(0,E.useState)(()=>c(St,``));(0,E.useEffect)(()=>{s(St,H)},[H]);let[U,mt]=(0,E.useState)(null),[ht,gt]=(0,E.useState)([]),Tt=(0,E.useRef)(``),[Et,kt]=(0,E.useState)(``),[At,Mt]=(0,E.useState)([]),K=(0,E.useRef)([]),[Xt,Zt]=(0,E.useState)(!1),[Qt,$t]=(0,E.useState)(!1),J=(0,E.useRef)(null),en=(0,E.useRef)(0),tn=(0,E.useRef)(null),nn=(0,E.useRef)(null),rn=(0,E.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?pe[e]:pe.decomposed,[t.on]),an=(0,E.useMemo)(()=>{let e=e=>+!e.supported,t=e=>e.ctime||e.mtime||0;return[...De].filter(e=>!be(e.name)).sort((n,r)=>e(n)-e(r)||t(r)-t(n)||n.path.localeCompare(r.path,`zh`)).map(e=>{let t=Wt(e),n=zt[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[De]),Y=(0,E.useCallback)(e=>{J.current=e,Te(e),fe(t=>Jt(t.map(t=>t.id===e.id?e:t)))},[]),X=(0,E.useCallback)((e,t=`info`,n)=>{en.current+=1,it(r=>[...r,{id:en.current,kind:t,text:e,detail:n?.trim()||void 0,at:new Date().toISOString()}])},[]),Z=(0,E.useCallback)((e,t,n,r)=>{Pt({docId:J.current?.id??``,kind:e,label:t,done:0,total:100,message:r,startedAt:Date.now(),status:`running`})},[]),on=(0,E.useCallback)(e=>{if(!W||W.status!==`running`)return;let t=e.done==null?W.done:Math.max(0,Math.min(100,Math.round(e.done)));Pt({...W,...e,total:100,done:t})},[]),Q=(0,E.useCallback)((e,t,n)=>{W?.kind===e&&(jt.current=null,Pt({...W,status:t,done:t===`done`?100:W.done,total:100,message:n??W.message,finishedAt:Date.now()}))},[]);(0,E.useEffect)(()=>{S&&Xe(W??Rt(S))},[S]);let sn=(0,E.useCallback)(()=>{S&&a(Nt(S),null),Pt(null)},[S]),cn=(0,E.useRef)(!1);(0,E.useEffect)(()=>{if(!S){cn.current=!0,it([]);return}let e=Ot(S);en.current=e.reduce((e,t)=>Math.max(e,t.id),0),cn.current=!0,it(e)},[S]),(0,E.useEffect)(()=>{cn.current?cn.current=!1:S&&a(Dt(S),rt.slice(-200))},[rt,S]);let ln=(0,E.useCallback)((e,t)=>{let n=K.current,r=n.length===t.length&&n.every((e,n)=>e===t[n]);K.current=t,r||Mt(t),e&&a(`reqanalysis.idealTitles.${e}`,t)},[]),un=(0,E.useCallback)(e=>{if(J.current=e,Te(e),me(e?.id??``),s(vt,e?.id??``),e?.sourcePath&&Ne(e.sourcePath),e?.id){let t=l(`reqanalysis.idealTitles.${e.id}`,[]),n=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];K.current=n,Mt(n)}else K.current=[],Mt([])},[]),dn=(0,E.useCallback)(e=>{lt(e),i(bt,e)},[]),fn=(0,E.useCallback)(async e=>{if(!e?.sourcePath)return ln(``,[]),[];try{let t=await g(e.sourcePath),n=oe(t);return ln(e.id,n),n}catch{return ln(e.id,K.current),K.current}},[ln]),pn=(0,E.useCallback)(async e=>{try{let t=await g(e.sourcePath),n=oe(t);return ln(e.id,n),e}catch{return e}},[ln]),mn=(0,E.useCallback)((e,t=`stories`)=>{un(e),z(t),dn(`work`),Be(`req-analysis`),pn(e)},[dn,un,pn]),hn=(0,E.useCallback)((e,t)=>{Tt.current=t,mn(e,`stories`)},[mn]);(0,E.useEffect)(()=>{if(ct!==`work`||!Tt.current)return;let e=Tt.current;Tt.current=``;let t=0,n=requestAnimationFrame(()=>{let n=document.getElementById(`req-story-${e}`);n&&(n.scrollIntoView({block:`center`,behavior:`smooth`}),n.classList.add(`tw-req-story-focus`),t=window.setTimeout(()=>n.classList.remove(`tw-req-story-focus`),1600))});return()=>{cancelAnimationFrame(n),t&&window.clearTimeout(t)}},[ct,C?.id]);let gn=(0,E.useMemo)(()=>x.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[x]),_n=gn.length,vn=(0,E.useMemo)(()=>{let e=H.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?gn.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(v(e))||t(e.title)):gn,r=[],i=new Map;for(let e of n){let t=i.get(e.doc.id);t===void 0?(i.set(e.doc.id,r.length),r.push({doc:e.doc,rows:[e]})):r[t].rows.push(e)}return r.sort((e,t)=>t.doc.updatedAt.localeCompare(e.doc.updatedAt))},[gn,H]),yn=(0,E.useMemo)(()=>new Set(U?.ids??[]),[U]),bn=(0,E.useCallback)((e,t)=>{mt(n=>{if(!n||n.docId!==e)return{docId:e,ids:[t]};let r=n.ids.includes(t)?n.ids.filter(e=>e!==t):[...n.ids,t];return r.length?{docId:e,ids:r}:null})},[]),xn=(0,E.useCallback)((e,t)=>{mt(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Sn=(0,E.useCallback)(e=>{V(e),i(yt,e)},[]);(0,E.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;Ke(Ce());let t=await de();if(e){if(re(t),!t)dt(!1);else try{let[t,n,r,i]=await Promise.all([ge(),se(),Ae(),ke()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await le(!0).catch(()=>void 0),a=await se()),!e)return;qe(a);let o=r;if((!r.exists||!r.review.trim())&&(await Pe(!0).catch(()=>void 0),o=await Ae()),!e)return;o.exists&&Je(o),i.exists&&Ye(i);let s=Jt(t);fe(s);let l=c(vt,``),u=s.find(e=>e.id===l)??s[0]??null;un(u);let d=ut.current;if(ut.current=`list`,d===`work`&&u&&l&&u.id===l&&(dn(`work`),Be(`req-analysis`)),u&&await pn(u),!e)return;dt(!1)}catch(t){e&&(dt(!1),L(t instanceof Error?t.message:String(t)))}}})();let t=Se(()=>Ke(Ce()));return()=>{e=!1,t()}},[dn,un,pn]),(0,E.useEffect)(()=>{if(!t.ready)return;if(!t.on){Je(null),z(e=>e===`check`?`stories`:e);return}if(!y||k!==null)return;let e=!0;return(async()=>{let t=await Ae();(!t.exists||!t.review.trim())&&(await Pe(!0).catch(()=>void 0),t=await Ae()),e&&Je(t)})(),()=>{e=!1}},[t.ready,t.on,y,k]),(0,E.useEffect)(()=>{R===`points`&&C?.sourcePath&&(K.current.length||fn(C))},[R,C,fn]),(0,E.useEffect)(()=>{if(!u.ready)return;if(!u.on){Ye(null),z(e=>e===`points`?`stories`:e);return}if(!y||A!==null)return;let e=!0;return(async()=>{let t=await ke();(!t.exists||!t.generate.trim())&&(await ze(!0).catch(()=>void 0),t=await ke()),e&&Ye(t)})(),()=>{e=!1}},[u.ready,u.on,y,A]),(0,E.useEffect)(()=>{if(!y)return;let e=!0;return ye().then(t=>{e&&Oe(t)}).catch(t=>{e&&Re(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[y]),(0,E.useEffect)(()=>{let e=C?.sourcePath;if(!e){kt(``);return}let t=!0;return g(e).then(e=>{t&&kt(te(e))}).catch(()=>{t&&kt(``)}),()=>{t=!1}},[C?.sourcePath,C?.sourceHash]),(0,E.useEffect)(()=>{let e=tn.current;e&&(e.scrollTop=e.scrollHeight)},[rt]);let Cn=!!(C?.sourceHash&&Et&&C.sourceHash!==Et),wn=(0,E.useMemo)(()=>new Set((C?.stories??[]).flatMap(e=>e.sourceRefs)),[C?.stories]),Tn=O??null,En=!!Tn?.decompose.trim(),Dn=(0,E.useMemo)(()=>(C?.check?.gaps??[]).filter(e=>e.selected).length,[C?.check]),$=(0,E.useCallback)(async(e,t)=>{let n=t??J.current;if(!n)throw Error(`还没有分析文档`);let r=await b(n.id,e);return Y(r),r},[Y]),On=(0,E.useCallback)(()=>{nn.current&&window.clearTimeout(nn.current),nn.current=window.setTimeout(()=>{let e=J.current;e?.check&&b(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),kn=(0,E.useCallback)(async e=>{if(!e)return null;let t=x.find(t=>t.sourcePath===e);if(t)return mn(t,`stories`),t;try{let t=await g(e),n=Ut(e),r=await ue({sourcePath:e,sourceTitle:n,sourceHash:te(t),title:n});return fe(e=>Jt([r,...e])),mn(r,`stories`),X(`新建分析:${v(r)}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),m(t,`error`),Ne(J.current?.sourcePath??``),null}},[x,mn,X]),An=!!(D?.baseURL&&D.apiKey&&D.model),jn=(0,E.useCallback)(()=>!An||!D?(m(`请先在设置里配置模型`,`error`),we(`model`),null):D,[An,D]),Mn=(0,E.useCallback)((e,t)=>({getDoc:()=>J.current,batch:t,saveOutline:async t=>{let n=await b(e.id,{outline:t});return Y(n),n.outline},saveStories:async t=>{let n=await b(e.id,{stories:t});return Y(n),X(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=J.current?.check,r={...t,gaps:_(n?.gaps??[],t.gaps)},i=await b(e.id,{check:r});return Y(i),i},saveTestPoints:async t=>{let n=await b(e.id,{testPoints:t});return Y(n),n}}),[Y,X]),Nn=(0,E.useCallback)(async()=>{let e=J.current,n=jn();if(!e||!n)return;let r=Tn?.decompose.trim()??``;if(!r){m(`没有读到「${ne}」的「## 拆解」段落`,`error`);return}L(``),I(``),X(`开始拆解`,`stage`),Z(`decompose`,`拆解`,100,`正在读取来源文档`);let i=new AbortController;jt.current=i;let a=`done`;try{let a=await b(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:100,message:`正在读取来源文档`,at:new Date().toISOString()}});Y(a);let o=await g(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=ee(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);G(5,`共 ${s.length} 批,准备拆第 1 批`),X(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await b(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:te(o)});Y(c);for(let t of s){if(i.signal.aborted)break;let a=J.current?.stories.length??0,o=[r,``,Ge,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(J.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
19
|
-
`)||`(本批还没有条目,先调用 req_set_outline)`].join(`
|
|
20
|
-
`),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
|
|
21
|
-
`),l=5+Math.floor(t.index/s.length*85),u=5+Math.floor((t.index+1)/s.length*85),d=t.index===s.length-1,f=Math.max(l+1,d?Math.min(90,u):Math.min(u-2,88));await $({progress:{stage:`stories`,done:l,total:100,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},J.current).catch(()=>void 0);let p=Date.now();X(`第 ${t.index+1}/${s.length} 批开始`,`info`,[t.title?`章节:${t.title}`:``,`${t.text.length} 字`].filter(Boolean).join(` · `)),G(l,`正在拆第 ${t.index+1}/${s.length} 批`);let m=Lt(f),h=``;try{for await(let r of xe(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Ze.filter(e=>[`req_set_outline`,`req_set_stories`].includes(e.function.name)),maxToolRounds:20,runTool:(n,r)=>Qe(n,r,Mn(e,t.index))}))r.type===`content`?(h+=r.delta,I(e=>e+r.delta),It(f,1)):r.type===`tool`&&r.status===`running`?(X(`调用 ${r.name}`,`tool`,q(r.args)),It(f,1)):r.type===`tool`&&r.status===`done`&&(X(`${r.name} 返回`,`tool`,q(r.result,120)),It(f,2))}finally{m()}if(G(Math.min(90,Math.max(f+2,u-2)),`第 ${t.index+1}/${s.length} 批返回,正在写入`),(J.current?.stories.length??0)===a){let n=$e(h);if(n.length){let t=ve(J.current?.stories??[],n),r=await b(e.id,{stories:t});Y(r),X(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else X(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}let g=Math.max(0,(J.current?.stories.length??0)-a);X(`第 ${t.index+1}/${s.length} 批完成`,`done`,`新增 ${g} 个故事 · 耗时 ${qt(p)}`),G(u,`第 ${t.index+1}/${s.length} 批已写入`)}if(i.signal.aborted){X(`已中断:已经写入的故事保留`,`info`);return}G(92,`正在保存拆解结果`);let l=await b(e.id,{status:`decomposed`,progress:{stage:`done`,done:100,total:100,message:`拆解完成`,at:new Date().toISOString()}});Y(l),X(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),z(`stories`),t.on&&!i.signal.aborted?(G(96,`拆解完成,接着审查`),m(`拆解完成,接着做用户故事审查`,`success`),await Fn.current?.(!0)):(G(100,`拆解完成`),m(`拆解完成`,`success`))}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a=`stopped`,X(`已中断:已经写入的故事保留`,`info`)):(a=`error`,L(t),X(`拆解失败:${t}`,`error`))}finally{i.signal.aborted&&(a=`stopped`),Q(`decompose`,a,a===`done`?`拆解完成`:a===`stopped`?`已中断:已经写入的故事保留`:`拆解失败,详见活动日志`)}},[Z,Q,Mn,Y,X,Tn,jn,on,t.on,$]),Pn=(0,E.useCallback)(async(e=!1)=>{let t=J.current;if(!t)return;if(!t.stories.length){e||m(`还没有用户故事,先做一次拆解`,`info`);return}L(``),e||I(``),X(e?`继续审查用户故事`:`开始审查用户故事`,`stage`,e?`拆解完成后自动接续`:void 0),Z(`audit`,`审查用户故事`,100,`正在跑规则体检`);let n=new AbortController;jt.current=n;let r={status:`done`,message:`审查完成`};try{let e=Date.now();G(8,`正在跑规则体检`);let i=ie(t),a=await b(t.id,{check:{...i,gaps:_(t.check?.gaps??[],i.gaps)},progress:{stage:`audit`,done:18,total:100,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});Y(a),X(`规则体检:覆盖率 ${Math.round(i.coverage.rate*100)}%,${i.gaps.length} 个缺口`,`info`,`${t.outline.length} 条需求条目 · ${t.stories.length} 个故事 · 耗时 ${qt(e)}`),G(18,`规则体检完成,等待模型评审`);let o=k?.review.trim()??``,s=An?D:null;if(!s||!o){X(s?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),r.message=`没有配置模型,只保留规则结果`,await b(t.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:r.message,at:new Date().toISOString()}}).then(Y).catch(()=>void 0),z(`check`);return}let c=!1,l=Mn(t,90),u=l.saveCheck;l.saveCheck=async e=>{c=!0,G(96,`正在写入审查结果`);let t=await u(e);return X(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let d=J.current??a,f=await _e(d.sourcePath);f.text||X(`没有读到原始需求,只能依据需求条目摘句审查`,`info`),X(`提交模型审查`,`tool`,`模型 ${s.model} · ${d.stories.length} 个故事 · 原文 ${f.text.length} 字`),G(22,`正在提交模型审查`);let p=[`## 原始需求`,f.text?f.truncated?`${f.text}\n\n(原文共 ${f.total} 字,以上为前 ${f.text.length} 字,没看到的部分不要猜)`:f.text:`(未读到原始需求,只能依据下面的需求条目摘句判断)`,``,`## 需求条目`,d.outline.length?d.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
22
|
-
`):`(无)`,``,`## 用户故事(${d.stories.length} 条)`,"```json",JSON.stringify(d.stories,null,2),"```"].join(`
|
|
23
|
-
`),h=Lt(90);try{for await(let e of xe(s,[{role:`system`,content:`${o}\n\n${Ge}`},{role:`user`,content:p}],n.signal,{tools:Ze.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Qe(e,t,l)}))e.type===`content`?(I(t=>t+e.delta),It(90,1)):e.type===`tool`&&e.status===`running`?(X(`调用 ${e.name}`,`tool`,q(e.args)),G(94,`模型正在提交审查结果`)):e.type===`tool`&&e.status===`done`&&(X(`${e.name} 返回`,`tool`,q(e.result,120)),G(97,`审查结果已返回`))}finally{h()}c||(X(`模型没有提交体检结果,当前只保留规则结果`,`error`),m(`模型没有提交体检结果,只保留了规则检查`,`error`)),G(100,c?`模型评审完成`:`已保留规则结果`),r.message=c?`审查完成`:`模型没提交结果,已保留规则结果`,await b(t.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:r.message,at:new Date().toISOString()}}).then(Y).catch(()=>void 0),z(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?(r.status=`stopped`,X(`已中断:规则体检结果已保留`,`info`)):(r.status=`error`,L(t),X(`体检失败:${t}`,`error`))}finally{n.signal.aborted&&(r.status=`stopped`),Q(`audit`,r.status,r.status===`error`?`审查失败,详见活动日志`:r.message)}},[Z,Q,Mn,An,Y,X,on,k,D]),Fn=(0,E.useRef)(null);Fn.current=Pn;let In=(0,E.useCallback)(async()=>{let e=J.current,t=jn();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){m(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=k?.fix.trim()??``;if(!r){m(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}L(``),I(``),X(`开始补写选中条目`,`stage`,`勾选 ${n.length} 个缺口`),Z(`fix`,`补写选中条目`,100,`正在按 ${n.length} 个勾选缺口补写`);let i=Date.now(),a=new AbortController;jt.current=a;let o={status:`done`,message:`补写完成`};try{G(5,`正在按 ${n.length} 个勾选缺口补写`),X(`按 ${n.length} 个勾选缺口补写`,`info`,n.map(e=>`[${e.severity}] ${e.storyId||`全局`}|${e.title}`).join(`;`));let s=new Map(e.stories.map(e=>[e.id,e.title])),c=await _e(e.sourcePath),l=[`## 原始需求`,c.text?c.truncated?`${c.text}\n\n(原文共 ${c.total} 字,以上为前 ${c.text.length} 字,没看到的部分不要猜)`:c.text:`(未读到原始需求,只能依据需求条目与当前故事集判断)`,``,`## 需求条目(新增故事的 sourceRefs 只能引用这里的 id)`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
24
|
-
`):`(无)`,``,`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${s.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
|
|
25
|
-
`)}).join(`
|
|
26
|
-
`)].join(`
|
|
27
|
-
`),u=Mn(e,90),d=!1,f=u.saveStories;u.saveStories=async e=>(d=!0,G(90,`正在写入补写结果`),f(e)),G(12,`正在提交模型补写`);let p=Lt(88);try{for await(let e of xe(t,[{role:`system`,content:`${r}\n\n${Ge}`},{role:`user`,content:l}],a.signal,{tools:Ze.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Qe(e,t,u)}))e.type===`content`?(I(t=>t+e.delta),It(88,1)):e.type===`tool`&&e.status===`running`?(X(`调用 ${e.name}`,`tool`,q(e.args)),G(90,`模型正在提交补写`)):e.type===`tool`&&e.status===`done`&&(X(`${e.name} 返回`,`tool`,q(e.result,120)),G(94,`补写结果已返回`))}finally{p()}if(!d){o.status=`error`,o.message=`模型没有提交补写结果,故事集保持不变`,X(`模型没有提交补写结果,故事集保持不变`,`error`),m(`模型没有提交补写结果`,`error`);return}G(94,`已写入补写结果,正在重算覆盖率`);let h=J.current;if(h){let e=ie(h),t=await b(h.id,{check:e,status:`decomposed`});Y(t)}let g=Math.round((J.current?.check?.coverage.rate??0)*100);X(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`,`覆盖率 ${g}% · 耗时 ${qt(i)}`),await $({progress:{stage:`done`,done:100,total:100,message:`补写完成`,at:new Date().toISOString()}},J.current).catch(()=>void 0),z(`check`),m(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);a.signal.aborted?(o.status=`stopped`,X(`已中断:已经写入的改动保留`,`info`)):(o.status=`error`,o.message=t,L(t),X(`补写失败:${t}`,`error`))}finally{a.signal.aborted&&(o.status=`stopped`),Q(`fix`,o.status,o.status===`error`?`补写失败:${o.message}`:o.message)}},[Z,Q,Mn,Y,X,on,jn,k,$]),Ln=(0,E.useCallback)(async()=>{let e=J.current,t=jn();if(!e||!t)return;if(!e.stories.length){m(`还没有用户故事,先做一次拆解`,`info`);return}let n=A?.generate.trim()??``;if(!n){m(`没有读到「${Ee}」的「## 生成」段落`,`error`);return}L(``),I(``),X(`开始生成测试点`,`stage`,`基于 ${e.stories.length} 个用户故事,五维覆盖 P0–P3`),Z(`testpoints`,`生成测试点`,100,`正在整理用户故事,等待模型生成`),z(`points`),await $({progress:{stage:`points`,done:5,total:100,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0);let r=Date.now();G(8,`正在整理用户故事`),X(`整理用户故事,提交模型生成`,`info`,`${e.outline.length} 条需求条目 · ${e.stories.length} 个故事 · 模型 ${t.model}`);let i=new AbortController;jt.current=i;let a={status:`done`,message:`测试点已生成`};try{let o=Mn(e,90),s=!1,c=o.saveTestPoints;o.saveTestPoints=async e=>{s=!0,G(90,`正在写入测试点`);let t=await c(e);return X(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let l=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
|
|
28
|
-
`):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
|
|
29
|
-
`);G(15,`正在提交模型生成`);let u=``,d=Lt(88);try{for await(let e of xe(t,[{role:`system`,content:`${n}\n\n${Ge}`},{role:`user`,content:l}],i.signal,{tools:Ze.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>Qe(e,t,o)}))e.type===`content`?(u+=e.delta,I(t=>t+e.delta),It(88,1)):e.type===`tool`&&e.status===`running`?(X(`调用 ${e.name}`,`tool`,q(e.args)),G(90,`模型正在提交测试点`)):e.type===`tool`&&e.status===`done`&&(X(`${e.name} 返回`,`tool`,q(e.result,120)),G(94,`测试点已返回`))}finally{d()}if(!s){let t=et(u,e.stories.map(e=>e.id));t&&(await o.saveTestPoints(t),s=!0,X(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!s)a.status=`error`,a.message=`模型没有提交测试点,原结果保持不变`,X(`模型没有提交测试点,原结果保持不变`,`error`),m(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=J.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;X(`测试点完成:${e.length} 条`,`done`,`P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)} · 耗时 ${qt(r)}`),G(100,`已生成 ${e.length} 条`),a.message=`测试点已生成 ${e.length} 条`,await $({progress:{stage:`done`,done:100,total:100,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},J.current).catch(()=>void 0),m(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a.status=`stopped`,X(`已中断:已经生成的测试点保留`,`info`)):(a.status=`error`,a.message=t,L(t),X(`生成测试点失败:${t}`,`error`))}finally{i.signal.aborted&&(a.status=`stopped`),Q(`testpoints`,a.status,a.status===`error`?`生成测试点失败:${a.message}`:a.message)}},[Z,Q,Mn,X,on,jn,$,A]),Rn=(0,E.useCallback)(async()=>{let e=J.current;if(!e?.testPoints)m(`还没有测试点可导出`,`info`);else try{let t=K.current;t.length||(t=await fn(e));let n=await Me(e,t);X(`已导出 ${n}`,`done`)}catch(e){m(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[X,fn]),zn=(0,E.useCallback)(async()=>{let e=J.current;if(!e?.testPoints){m(`还没有测试点可导出`,`info`);return}let t=K.current;t.length||(t=await fn(e));let n=Fe(e,t);X(`已导出 ${n}`,`done`)},[X,fn]),Bn=(0,E.useCallback)(async e=>{let t=J.current;if(t)try{await $({stories:e},t)}catch(e){m(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[$]),Vn=(0,E.useCallback)((e,t)=>{let n=J.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);Bn(r)},[Bn]),Hn=(0,E.useCallback)(e=>{let t=J.current;t&&Bn(t.stories.filter((t,n)=>n!==e))},[Bn]),Un=(0,E.useCallback)((e,t)=>{let n=J.current;if(!n)return;let r=e+t;if(r<0||r>=n.stories.length)return;let i=[...n.stories],a=i[e],o=i[r];a&&o&&(i[e]=o,i[r]=a,Bn(i))},[Bn]),Wn=(0,E.useCallback)((e,t)=>{let n=J.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};Y(r),On()},[Y,On]),Gn=(0,E.useCallback)(e=>{let t=J.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};Y(n),On()},[Y,On]),Kn=(0,E.useCallback)(async()=>{let e=J.current;if(e)try{await he(e.id);let t=x.filter(t=>t.id!==e.id);fe(t),un(t[0]??null),dn(`list`),m(`已删除分析记录`,`success`)}catch(e){m(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{Zt(!1)}},[dn,x,un]),qn=(0,E.useCallback)(()=>{let e=J.current;if(!e)return;let t=new Blob([h(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ae(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),m(`已导出 Markdown`,`success`)},[]),Jn=(0,E.useCallback)(()=>{let e=J.current;if(!e?.check)return;let t=Ie(e,e.check);m(`已导出 ${t}`,`success`)},[]),Yn=(0,E.useCallback)(()=>{jt.current?.abort()},[]);if(!e.ready)return(0,N.jsx)(He,{label:`正在读取插件开关`});if(!e.on)return(0,N.jsx)(Ve,{children:r(`reqAnalysis`)});if(y===null)return(0,N.jsx)(He,{label:`正在连接需求分析服务`});if(!y)return(0,N.jsx)(Ve,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(B)return(0,N.jsx)(He,{label:`正在回到上次的分析`});let Xn=C?.outline.filter(e=>wn.has(e.id)).length??0,Zn=C?.check?.gaps??[],Qn=(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,N.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,N.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,N.jsx)(`p`,{className:Ht,children:`新建分析`}),(0,N.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,N.jsx)(p,{options:an,value:je,onChange:e=>{Ne(e),e&&kn(e)},triggerTitle:je||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,N.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,x.length,` 份分析`]})]}),Le?(0,N.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Le,(0,N.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,ce,` 之外的内容目录没有被移动。`]}):null]}),ot?(0,N.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,N.jsx)(`span`,{className:`break-all`,children:ot}),(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>Sn(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${ft===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Sn(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${ft===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),ft===`story`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`label`,{className:`relative block`,children:[(0,N.jsx)(T,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,N.jsx)(`input`,{value:H,onChange:e=>pt(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,N.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[_n,` 个故事`,U?` · 已选 ${U.ids.length}`:``]}),(0,N.jsx)(`button`,{type:`button`,disabled:!U,onClick:()=>{if(!U)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:U.docId,stories:U.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${Bt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,N.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[x.length,` 份分析 · `,_n,` 个故事`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:ft===`doc`?x.length?(0,N.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:x.map(e=>{let t=rn(e.status);return(0,N.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,N.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>mn(e,`stories`),children:(0,N.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:v(e)}),(0,N.jsx)(w,{tone:t.tone,children:t.label})]}),(0,N.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,N.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,N.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,N.jsx)(`span`,{children:Gt(e.updatedAt)})]})]})}),(0,N.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>mn(e,`stories`),children:[`用户故事`,(0,N.jsx)(T,{name:`chevronRight`,size:13})]}),(0,N.jsx)(`button`,{type:`button`,"aria-label":`删除 ${v(e)}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{un(e),Zt(!0)},children:(0,N.jsx)(T,{name:`trash`,size:14})})]},e.id)})}):(0,N.jsx)(We,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):vn.length?(0,N.jsx)(`div`,{className:`divide-y divide-stone-100`,children:vn.map(({doc:e,rows:t})=>{let n=ht.includes(e.id),r=t.map(e=>e.story.id),i=U?.docId===e.id&&r.length>0&&r.every(e=>yn.has(e));return(0,N.jsxs)(`section`,{children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${v(e)} 的全部故事`,checked:i,onChange:()=>xn(e.id,r)}),(0,N.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>gt(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,N.jsx)(T,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:v(e)}),(0,N.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,Gt(e.updatedAt)]})]}),(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>mn(e,`stories`),children:`打开拆解`})]}),n?null:(0,N.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,N.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,N.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:yn.has(t.id)&&U?.docId===e.id,onChange:()=>bn(e.id,t.id)}),(0,N.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>hn(e,t.id),children:[(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,N.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,N.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,N.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,N.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,N.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,N.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,N.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,N.jsx)(We,{icon:`file`,title:H?`没有匹配的用户故事`:`还没有用户故事`,hint:H?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[ct===`list`?Qn:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,N.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{Ne(``),L(``),dn(`list`)},children:[(0,N.jsx)(T,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,N.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:C?`用户故事 · ${v(C)}`:`用户故事`})]}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,N.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,N.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,N.jsx)(`p`,{className:Ht,children:`分析记录`}),(0,N.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:x.length})]}),(0,N.jsx)(`div`,{className:`px-2 py-2`,children:x.length?(0,N.jsx)(`ul`,{className:`space-y-0.5`,children:x.map(e=>{let t=e.id===S,n=rn(e.status);return(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>un(e),children:(0,N.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(f,{text:v(e),matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,N.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,N.jsx)(w,{tone:n.tone,children:n.label}),(0,N.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,N.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,N.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,N.jsx)(`p`,{className:Ht,children:`提示词`})}),(0,N.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,N.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,N.jsx)(Yt,{name:ne,ready:En}),(0,N.jsx)(Yt,{name:k?.file??`用户故事审查提示词.md`,ready:t.on&&!!k?.review.trim()&&!!k?.fix.trim()}),(0,N.jsx)(Yt,{name:Ee,ready:u.on&&!!A?.generate.trim()})]}),(0,N.jsx)(`p`,{className:`mt-2 text-[11px] ${An?`text-stone-400`:`text-amber-700`}`,children:An?`模型:${D?.model}`:`还没配置模型`})]})]}),(0,N.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,N.jsx)(`p`,{className:Ht,children:`动作`})}),(0,N.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,N.jsx)(`button`,{type:`button`,className:`${Bt} w-full`,disabled:!C||!!M||!C.sourcePath,onClick:()=>{C?.stories.length?$t(!0):Nn()},children:M===`decompose`?`拆解中…`:C?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,N.jsx)(`button`,{type:`button`,className:`${Vt} w-full`,disabled:!C||!!M||!C.stories.length,onClick:()=>void Pn(),children:M===`audit`?`审查中…`:C?.check?`重新审查用户故事`:`用户故事审查`}):null,u.on?(0,N.jsx)(`button`,{type:`button`,className:`${Vt} w-full`,disabled:!C||!!M||!C.stories.length,onClick:()=>void Ln(),children:M===`testpoints`?`生成中…`:C?.testPoints?`重新生成测试点`:`生成测试点`}):null,M?(0,N.jsx)(`button`,{type:`button`,className:`${Vt} w-full`,onClick:Yn,children:`中断`}):(0,N.jsx)(`button`,{type:`button`,className:`${Vt} w-full`,disabled:!C,onClick:qn,children:`导出 Markdown`}),C&&!M?(0,N.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>Zt(!0),children:`删除这份分析`}):null]})]}),(0,N.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,N.jsx)(`p`,{className:Ht,children:`活动日志`}),rt.length?(0,N.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>it([]),children:`清空`}):null]}),(0,N.jsx)(`div`,{ref:tn,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:rt.length?rt.map(e=>e.kind===`stage`?(0,N.jsxs)(`div`,{className:`flex items-center gap-2 pt-1.5 first:pt-0`,children:[(0,N.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium text-stone-500`,children:e.text}),(0,N.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-300`,children:Kt(e.at)}),(0,N.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`})]},e.id):(0,N.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,N.jsx)(`span`,{className:`mt-px shrink-0 text-[10px] tabular-nums text-stone-300`,children:Kt(e.at)}),(0,N.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:e.kind===`done`?`text-stone-700`:`text-stone-500`,children:e.text}),e.detail?(0,N.jsx)(`span`,{className:`mt-0.5 block break-all text-[10px] leading-relaxed text-stone-400`,children:e.detail}):null]})]},e.id)):(0,N.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,N.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ot?(0,N.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,N.jsx)(`span`,{className:`break-all`,children:ot}),(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,F&&!M?(0,N.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border px-3 py-2 text-xs ${F.status===`done`?`border-emerald-200 bg-emerald-50 text-emerald-700`:F.status===`error`?`border-red-200 bg-red-50 text-red-700`:`border-amber-200 bg-amber-50 text-amber-700`}`,children:[(0,N.jsxs)(`span`,{className:`break-all`,children:[(0,N.jsxs)(`span`,{className:`font-medium`,children:[F.label,F.status===`done`?`已完成`:F.status===`error`?`失败`:`已中断`]}),(0,N.jsx)(`span`,{className:`ml-1.5 opacity-80`,children:F.message}),F.finishedAt?(0,N.jsxs)(`span`,{className:`ml-1.5 opacity-60`,children:[`· `,Gt(new Date(F.finishedAt).toISOString())]}):null]}),(0,N.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-60 transition-opacity hover:opacity-100`,"aria-label":`关闭上次任务提示`,onClick:sn,children:`✕`})]}):null,C?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(f,{text:v(C),matchAnchorWidth:!0,className:`min-w-0 flex-1 truncate px-1 py-0.5 text-[15px] font-semibold text-stone-800`}),M?(0,N.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,N.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),P?P.message:M===`decompose`?`拆解中`:M===`audit`?`审查中`:M===`testpoints`?`生成测试点中`:M===`fix`?`补写中`:`处理中`,P&&P.total>0?(0,N.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(P.done,P.total)/P.total*100),`%`]}):null]}):null,(0,N.jsx)(w,{tone:rn(C.status).tone,children:rn(C.status).label})]}),M?(0,N.jsx)(`div`,{className:`mt-2`,children:(0,N.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${P?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":P&&P.total>0?Math.round(Math.min(P.done,P.total)/P.total*100):void 0,children:(0,N.jsx)(`div`,{className:P&&P.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:P&&P.total>0?{width:`${Math.round(Math.min(P.done,P.total)/P.total*100)}%`}:void 0})})}):null,(0,N.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,N.jsx)(`span`,{className:`font-medium text-stone-600`,children:C.stories.length})]}),(0,N.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,N.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[Xn,`/`,C.outline.length]}),` `,`覆盖`]}),t.on?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,N.jsx)(`span`,{className:`font-medium text-stone-600`,children:Zn.length}),Dn?` · 已选 ${Dn}`:``]}),C.check?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,N.jsx)(`span`,{className:`font-medium text-stone-600`,children:C.check.coverage.total?`${Math.round(C.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,u.on?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,N.jsx)(`span`,{className:`font-medium text-stone-600`,children:C.testPoints?.points.length??0})]})]}):null,(0,N.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,C.sourcePath]}),Cn?(0,N.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,N.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:C.stories.length},{id:`check`,label:`审查结果`,count:Zn.length},{id:`outline`,label:`需求条目`,count:C.outline.length},{id:`points`,label:`测试点`,count:C.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||u.on)).map(e=>{let t=R===e.id;return(0,N.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>z(e.id),children:[e.label,(0,N.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,N.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[R===`stories`?C.stories.length?(0,N.jsx)(`ul`,{className:`space-y-2`,children:C.stories.map((e,t)=>(0,N.jsx)(_t,{story:e,index:t,total:C.stories.length,gaps:Zn.filter(t=>t.storyId===e.id),busy:!!M,onSave:e=>Vn(t,e),onDelete:()=>Hn(t),onMove:e=>Un(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,N.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,N.jsx)(We,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,R===`check`&&t.on?(0,N.jsx)(nt,{check:C.check,stories:C.stories,busy:!!M,onToggleGap:Wn,onToggleAll:Gn,onFix:()=>void In(),onReview:()=>void Pn(),onExport:Jn}):null,R===`points`&&u.on?(0,N.jsx)(st,{doc:C,idealTitles:At,generating:M===`testpoints`,busy:!!M,promptReady:!!A?.generate.trim(),onExportXmind:()=>void Rn(),onExportMarkdown:()=>void zn()}):null,R===`outline`?C.outline.length?(0,N.jsx)(`ul`,{className:`space-y-2`,children:C.outline.map(e=>{let t=wn.has(e.id);return(0,N.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,N.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,N.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,N.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,N.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,N.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,N.jsx)(We,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),at?(0,N.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,N.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:at})]}):null]}):(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,N.jsx)(We,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,N.jsx)(d,{open:Xt,title:`删除分析记录`,message:`确认删除「${C?v(C):``}」?故事、需求条目、体检报告与测试点都会一起清掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Zt(!1),onConfirm:()=>void Kn()}),(0,N.jsx)(d,{open:Qt,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${C?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>$t(!1),onConfirm:()=>{$t(!1),Nn()}})]})}export{Xt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./OverflowHint.pvo2Xc8R.js";import{t as i}from"./SelectDropdown.apWlFGbA.js";var a=e(t(),1),o=n();function s({options:e,values:t,onChange:n,placeholder:i=`选择…`,disabled:s=!1}){let[c,l]=(0,a.useState)(!1),u=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!c)return;function e(e){u.current?.contains(e.target)||l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let d=e.filter(e=>t.includes(e.value)).map(e=>e.label),f=s||d.length===0?i:d.length<=2?d.join(`、`):`已选 ${d.length} 项`;function p(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,o.jsxs)(`div`,{className:`relative mt-1`,ref:u,children:[(0,o.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>l(e=>!e),className:s?`w-full h-9 flex items-center justify-start gap-1 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center justify-start gap-1 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:(0,o.jsx)(r,{text:f,className:`min-w-0 truncate ${s||d.length?``:`text-stone-400`}`})}),c?(0,o.jsx)(`div`,{className:`tw-select-menu tw-dsh-scroll tw-popover-anim absolute z-80 mt-1 max-h-72 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,o.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>p(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,o.jsx)(r,{text:e.label,className:`min-w-0 flex-1 truncate`})]},e.value)})}):null]})}function c({options:e,value:t,onChange:n,placeholder:s=`搜索并选择…`,disabled:c=!1,allowEmpty:l=!0,emptyLabel:u=`不选择`}){let d=(0,a.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return l?[{value:``,label:u,muted:!0},...t]:t},[e,l,u]),f=t?d.find(e=>e.value===t):void 0;return(0,o.jsx)(i,{options:d,value:t,onChange:n,disabled:c,searchable:!0,searchPlaceholder:s,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>f?(0,o.jsx)(`span`,{className:`min-w-0 truncate ${t?`text-stone-400`:``}`,children:(0,o.jsx)(r,{text:f.label,className:`block truncate`})}):(0,o.jsx)(`span`,{className:`min-w-0 truncate text-stone-400`,children:s})})}export{s as n,c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as a}from"./app-config.CF1xVPmo.js";import{i as te,n as o,r as ne,t as s}from"./listbox.DNxAJmEo.js";import{a as re,o as ie}from"./dialog.DZHZCe_T.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as ae}from"./ConfirmDialog.CsMwWevK.js";import{showToast as oe}from"./Toast.BO2NFckG.js";import{i as se}from"./llm.BuR7z55C.js";import{_ as ce,a as l,c as u,d as le,g as ue,h as de,i as fe,l as d,n as f,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.B1yetppp.js";import{n as p}from"./i18n.CjqQGCAI.js";import{s as m}from"./fs-tools.3F9MFrLf.js";import{_ as h,c as g,l as ye}from"./bash-tools.CPS0ZiKi.js";import{t as be}from"./app-version.yT2l6J8H.js";import{n as xe,t as Se}from"./update.Fq2CGmCX.js";var _=e(t(),1);function v(e){return e===`time-context`||e===`tool-todo`||e===`tool-ask-user`||e===`user-questions`||e===`plan-mode`||e===`tool-result-pruner`||e===`compaction-basic`||e===`command-compact`||e===`tool-goal`||e===`command-goal`||e===`goal`||e===`tool-schedule`||e===`schedule`||e===`goal-round-driver`||e===`session-log-download`||e===`llm-retry`||e===`session-title-llm`||e===`session-stats`||e===`locale`||e===`config-editor`||e===`subagent`||e===`subagent-fork-in-process`||e===`spill-local`||e===`spill-policy`||e===`session-turn-outline`||e===`image-offload`||e===`session-persistence-jsonl`||e===`session-checkpoint-policy`||e===`session-query-sqlite`||e===`session-projection-cache`||e===`storage-domain`||e===`workspace-changes`||e===`workspace-dependencies`||e===`skill-office`||e===`fs-observation-policy`||e===`deepseek-llm-api-extensions`||e===`session-log-deepseek`||e===`subagent-model-selection-settings`||e===`authorization`||e===`modules`||e===`resources`||e===`mcp-resources`||e===`ptc-runtime`||e===`headless-runner`||e===`headless-startup`||e===`sdk-jsonrpc-server`||e===`sdk-app-startup`||e===`acp`||e===`acp-app-startup`||e===`subagent-spawn-in-process`||e===`llm-pi-ai`||e===`session-reference`||e===`tool-subagent`||e===`tool-subagent-control`||e===`tool-subagent-list-agents`||e===`tool-subagent-fork`||e===`tool-workflow`||e===`workflow-ptc`||e===`session-title`||e===`attachment-local`||e===`file-upload`||e===`file-reference-local`||e===`credentials`||e===`connection`||e===`token-meter`||e===`llm`||e===`llm-deepseek`||e===`agent-default-model`||e===`session`||e===`sessions`||e===`session-projection`||e===`storage`||e===`storage-json`||e===`settings`||e===`commands`||e===`shortcuts`||e===`timeout-policy`||e===`shell-env`||e===`approval`||e===`agent`||e===`system-prompt`||e===`tools`||e===`repeat-tool-reminder`?`ready`:e===`tool-web`||e===`web`||e===`web-fetch-http`||e===`web-search-deepseek`?`web`:e===`tool-bash`||e===`tool-jobs`||e===`jobs`||e===`sandbox-policy`||e===`bash-sandbox`||e===`sandbox`||e===`pty`||e===`terminal-bash`||e===`persistent-bash`||e===`subprocess`?`bash`:e===`tool-pwsh`||e===`persistent-pwsh`||e===`terminal-pwsh`||e===`pwsh-sandbox`?`pwsh`:e===`tool-fs`||e===`tool-fs-search`||e===`tool-skill`||e===`skill`||e===`agent-instructions`||e===`present`||e===`office-to-pdf`||e===`filesystem`||e===`fs-sandbox`||e===`permission`||e===`working-directory`||e===`tool-working-directory`||e===`workspace`?`fs`:`none`}var y=[{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`会话能力`},{id:`time-context`,packageName:`@deepseek-ai/dsh-time-context`,roleZh:`注入当前时间与耗时。`,category:`会话能力`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`会话能力`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`会话能力`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`会话能力`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`会话能力`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`会话能力`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载工作区 SKILL.md。`,category:`会话能力`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`会话能力`},{id:`tool-schedule`,packageName:`@deepseek-ai/dsh-tool-schedule`,roleZh:`模型可创建/查询/更新/删除定时提醒,到点投递回原会话。`,category:`会话能力`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`会话能力`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`会话能力`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`planning`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`compaction`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`compaction`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`compaction`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`delegation`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`delegation`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`delegation`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`delegation`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`delegation`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`delegation`},{id:`tool-ask-user`,packageName:`@deepseek-ai/dsh-tool-ask-user`,roleZh:`模型可向用户提出结构化问题并等待回答。`,category:`会话能力`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`会话能力`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`会话能力`},{id:`present`,packageName:`@deepseek-ai/dsh-tool-present`,roleZh:`模型可声明「交付了哪些工作区文件」,便于 UI 展示/打开。`,category:`会话能力`}],b=[{id:`attachment-local`,packageName:`@deepseek-ai/dsh-attachment-local`,roleZh:`本机附件存储与读取。`,category:`会话 / 存储`},{id:`session`,packageName:`@deepseek-ai/dsh-session`,roleZh:`事件溯源的会话存储(会话真相源)。`,category:`会话 / 存储`},{id:`session-checkpoint-policy`,packageName:`@deepseek-ai/dsh-session-checkpoint-policy`,roleZh:`会话检查点策略。`,category:`会话 / 存储`},{id:`session-log-deepseek`,packageName:`@deepseek-ai/dsh-session-log-deepseek`,roleZh:`DeepSeek 侧增量无损会话日志请求扩展。`,category:`会话 / 存储`},{id:`session-log-download`,packageName:`@deepseek-ai/dsh-session-log-export`,roleZh:`导出会话日志。`,category:`会话 / 存储`},{id:`session-persistence-jsonl`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话以 JSONL 持久化。`,category:`会话 / 存储`},{id:`session-projection`,packageName:`@deepseek-ai/dsh-session-projection`,roleZh:`会话投影视图(给 UI/查询用)。`,category:`会话 / 存储`},{id:`session-projection-cache`,packageName:`@deepseek-ai/dsh-session-projection-cache`,roleZh:`会话投影缓存。`,category:`会话 / 存储`},{id:`session-query-sqlite`,packageName:`@deepseek-ai/dsh-session-query-sqlite`,roleZh:`会话全文/结构化查询(sqlite)。`,category:`会话 / 存储`},{id:`session-reference`,packageName:`@deepseek-ai/dsh-session-reference`,roleZh:`会话内引用(消息/文件等)。`,category:`会话 / 存储`},{id:`session-stats`,packageName:`@deepseek-ai/dsh-session-stats`,roleZh:`会话统计信息。`,category:`会话 / 存储`},{id:`session-title`,packageName:`@deepseek-ai/dsh-session-title`,roleZh:`会话标题能力。`,category:`会话 / 存储`},{id:`session-turn-outline`,packageName:`@deepseek-ai/dsh-session-turn-outline`,roleZh:`对话回合摘要。`,category:`会话 / 存储`},{id:`sessions`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话 JSONL 持久化后端(与 session-persistence 同类)。`,category:`会话 / 存储`},{id:`storage`,packageName:`@deepseek-ai/dsh-storage`,roleZh:`通用存储服务。`,category:`会话 / 存储`},{id:`storage-domain`,packageName:`@deepseek-ai/dsh-storage-domain`,roleZh:`按域划分的存储。`,category:`会话 / 存储`},{id:`storage-json`,packageName:`@deepseek-ai/dsh-storage-json`,roleZh:`JSON 文件存储后端。`,category:`会话 / 存储`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`模型面工具/命令`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`模型面工具/命令`},{id:`skill-office`,packageName:`@deepseek-ai/dsh-skill-office`,roleZh:`Office(Word/PPT/Excel)相关工作流 Skill。`,category:`模型面工具/命令`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`模型面工具/命令`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`模型面工具/命令`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`模型面工具/命令`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`模型面工具/命令`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`模型面工具/命令`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`模型面工具/命令`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`模型面工具/命令`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载某个 Skill,把技能说明拉进上下文。`,category:`模型面工具/命令`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`模型面工具/命令`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`模型面工具/命令`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`模型面工具/命令`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`模型面工具/命令`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`模型面工具/命令`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`模型面工具/命令`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`模型面工具/命令`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`模型面工具/命令`},{id:`acp`,packageName:`@deepseek-ai/dsh-acp`,roleZh:`通过 JSON-RPC stdio 驱动 Harness Agent 的自动化协议服务(给外部编排用)。`,category:`其它`},{id:`acp-app-startup`,packageName:`@deepseek-ai/dsh-acp-app`,roleZh:`ACP 配置包启动:在 base 之上挂 JSON-RPC stdio 与进程生命周期。`,category:`其它`},{id:`authorization`,packageName:`@deepseek-ai/dsh-authorization`,roleZh:`授权/鉴权服务。`,category:`其它`},{id:`commands`,packageName:`@deepseek-ai/dsh-commands`,roleZh:`人类 slash 命令注册底座。`,category:`其它`},{id:`config-editor`,packageName:`@deepseek-ai/dsh-config-editor`,roleZh:`配置编辑能力。`,category:`其它`},{id:`connection`,packageName:`@deepseek-ai/dsh-client-connection`,roleZh:`客户端与 Host 连接。`,category:`其它`},{id:`credentials`,packageName:`@deepseek-ai/dsh-credentials-local`,roleZh:`本机凭证存储。`,category:`其它`},{id:`file-reference-local`,packageName:`@deepseek-ai/dsh-file-reference-local`,roleZh:`本机文件引用解析。`,category:`其它`},{id:`file-upload`,packageName:`@deepseek-ai/dsh-client-file-upload`,roleZh:`客户端上传文件。`,category:`其它`},{id:`filesystem`,packageName:`@deepseek-ai/dsh-fs-local`,roleZh:`本机文件系统实现(ctx.fs),供 tool-fs 等读写。`,category:`其它`},{id:`fs-observation-policy`,packageName:`@deepseek-ai/dsh-fs-observation-policy`,roleZh:`文件系统观察/上报策略。`,category:`其它`},{id:`headless-runner`,packageName:`@deepseek-ai/dsh-headless`,roleZh:`无 Host/HTTP/浏览器的一键 Agent/Session 运行器(纯 headless)。`,category:`其它`},{id:`headless-startup`,packageName:`@deepseek-ai/dsh-headless/startup`,roleZh:`Headless 配置包的启动插件。`,category:`其它`},{id:`image-offload`,packageName:`@deepseek-ai/dsh-compaction-image-offload`,roleZh:`超预算图片卸载为占位符并重试。`,category:`其它`},{id:`locale`,packageName:`@deepseek-ai/dsh-client-locale`,roleZh:`界面语言。`,category:`其它`},{id:`mcp-resources`,packageName:`@deepseek-ai/dsh-mcp-resources`,roleZh:`MCP 资源对接。`,category:`其它`},{id:`modules`,packageName:`@deepseek-ai/dsh-client-modules`,roleZh:`客户端模块加载。`,category:`其它`},{id:`office-to-pdf`,packageName:`@deepseek-ai/dsh-office-to-pdf`,roleZh:`Office 转 PDF。`,category:`其它`},{id:`pty`,packageName:`@deepseek-ai/dsh-terminal`,roleZh:`持久 PTY 会话能力缝:会话 id、后端注册、交互读写与信号。`,category:`其它`},{id:`repeat-tool-reminder`,packageName:`@deepseek-ai/dsh-repeat-tool-reminder`,roleZh:`重复工具调用时提醒模型。`,category:`其它`},{id:`resources`,packageName:`@deepseek-ai/dsh-client-resources`,roleZh:`客户端资源。`,category:`其它`},{id:`sdk-app-startup`,packageName:`@deepseek-ai/dsh-sdk-app`,roleZh:`SDK 配置包启动:stdio JSON-RPC 服务与进程生命周期。`,category:`其它`},{id:`sdk-jsonrpc-server`,packageName:`@deepseek-ai/dsh-sdk-jsonrpc-server`,roleZh:`给进程外 SDK 客户端用的 stdio JSON-RPC 服务端。`,category:`其它`},{id:`settings`,packageName:`@deepseek-ai/dsh-settings`,roleZh:`设置读写与校验。`,category:`其它`},{id:`shell-env`,packageName:`@deepseek-ai/dsh-shell-env`,roleZh:`注入/管理 shell 环境变量。`,category:`其它`},{id:`shortcuts`,packageName:`@deepseek-ai/dsh-client-shortcuts`,roleZh:`快捷键注册。`,category:`其它`},{id:`timeout-policy`,packageName:`@deepseek-ai/dsh-tool-call-timeout-policy`,roleZh:`单次工具调用超时策略。`,category:`其它`},{id:`user-questions`,packageName:`@deepseek-ai/dsh-user-questions`,roleZh:`用户提问通道(供 ask_user 等使用)。`,category:`其它`},{id:`working-directory`,packageName:`@deepseek-ai/dsh-working-directory`,roleZh:`会话工作目录状态。`,category:`其它`},{id:`workspace`,packageName:`@deepseek-ai/dsh-workspace`,roleZh:`工作区抽象(根目录、切换等)。`,category:`其它`},{id:`workspace-changes`,packageName:`@deepseek-ai/dsh-workspace-changes`,roleZh:`工作区变更追踪。`,category:`其它`},{id:`workspace-dependencies`,packageName:`@deepseek-ai/dsh-tool-workspace-dependencies`,roleZh:`向模型提供捆绑的 Python/Node/pnpm 依赖绝对路径(load_workspace_dependencies)。`,category:`其它`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`上下文压缩`},{id:`spill-local`,packageName:`@deepseek-ai/dsh-spill-local`,roleZh:`过大内容溢出到本机文件。`,category:`上下文压缩`},{id:`spill-policy`,packageName:`@deepseek-ai/dsh-spill-policy`,roleZh:`何时溢出、溢出策略。`,category:`上下文压缩`},{id:`token-meter`,packageName:`@deepseek-ai/dsh-token-meter`,roleZh:`统计上下文 token 用量。`,category:`上下文压缩`},{id:`web`,packageName:`@deepseek-ai/dsh-web`,roleZh:`网页能力缝(ctx.web):注册 search/fetch provider。`,category:`网页能力`},{id:`web-fetch-http`,packageName:`@deepseek-ai/dsh-web-fetch-http`,roleZh:`通用 HTTP 抓取网页正文 provider。`,category:`网页能力`},{id:`goal`,packageName:`@deepseek-ai/dsh-goal`,roleZh:`本会话目标状态机服务。`,category:`预设 / 能力服务`},{id:`goal-round-driver`,packageName:`@deepseek-ai/dsh-goal-round-driver`,roleZh:`按目标驱动多轮执行。`,category:`预设 / 能力服务`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`预设 / 能力服务`},{id:`schedule`,packageName:`@deepseek-ai/dsh-schedule`,roleZh:`主机级持久提醒,到点投递原会话。`,category:`预设 / 能力服务`},{id:`skill`,packageName:`@deepseek-ai/dsh-skill`,roleZh:`Skill 能力注册底座。`,category:`预设 / 能力服务`},{id:`approval`,packageName:`@deepseek-ai/dsh-user-approval`,roleZh:`敏感操作需用户批准。`,category:`执行 / 权限`},{id:`bash-sandbox`,packageName:`@deepseek-ai/dsh-bash-sandbox`,roleZh:`bash 专用沙箱绑定。`,category:`执行 / 权限`},{id:`fs-sandbox`,packageName:`@deepseek-ai/dsh-fs-sandbox`,roleZh:`文件系统沙箱。`,category:`执行 / 权限`},{id:`jobs`,packageName:`@deepseek-ai/dsh-jobs-local`,roleZh:`后台任务注册表(id、归属、轮询、取消)。`,category:`执行 / 权限`},{id:`permission`,packageName:`@deepseek-ai/dsh-permission-presets`,roleZh:`权限预设(只读/读写等档位)。`,category:`执行 / 权限`},{id:`persistent-bash`,packageName:`@deepseek-ai/dsh-tool-bash-persistent`,roleZh:`带 PTY 的持久 Bash 工具(跨调用保持 shell 状态)。`,category:`执行 / 权限`},{id:`persistent-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh-persistent`,roleZh:`带 PTY 的持久 PowerShell 工具。`,category:`执行 / 权限`},{id:`pwsh-sandbox`,packageName:`@deepseek-ai/dsh-pwsh-sandbox`,roleZh:`pwsh 专用沙箱绑定。`,category:`执行 / 权限`},{id:`sandbox`,packageName:`@deepseek-ai/dsh-sandbox-local`,roleZh:`本机沙箱执行环境。`,category:`执行 / 权限`},{id:`sandbox-policy`,packageName:`@deepseek-ai/dsh-sandbox-policy`,roleZh:`沙箱策略(能跑什么、不能跑什么)。`,category:`执行 / 权限`},{id:`subprocess`,packageName:`@deepseek-ai/dsh-subprocess-local`,roleZh:`本机子进程执行器。`,category:`执行 / 权限`},{id:`terminal-bash`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 bash PTY 后端。`,category:`执行 / 权限`},{id:`terminal-pwsh`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 pwsh PTY 后端。`,category:`执行 / 权限`},{id:`ptc-runtime`,packageName:`@deepseek-ai/dsh-ptc-runtime-node`,roleZh:`PTC(工具调用呈现)Node 运行时。`,category:`子代理 / 工作流`},{id:`subagent`,packageName:`@deepseek-ai/dsh-subagent`,roleZh:`子代理能力底座。`,category:`子代理 / 工作流`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`子代理 / 工作流`},{id:`agent`,packageName:`@deepseek-ai/dsh-agent`,roleZh:`Agent 主体:把会话、工具、模型串起来。`,category:`LLM / Agent 核心`},{id:`agent-default-model`,packageName:`@deepseek-ai/dsh-agent-default-model`,roleZh:`解析/提供默认模型配置。`,category:`LLM / Agent 核心`},{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`LLM / Agent 核心`},{id:`deepseek-llm-api-extensions`,packageName:`@deepseek-ai/dsh-deepseek-llm-api-extensions`,roleZh:`给官方 DeepSeek API 适配器登记额外请求字段。`,category:`LLM / Agent 核心`},{id:`llm`,packageName:`@deepseek-ai/dsh-llm`,roleZh:`厂商无关的 LLM 服务接口(发请求、流式、工具调用等)。`,category:`LLM / Agent 核心`},{id:`llm-deepseek`,packageName:`@deepseek-ai/dsh-llm-deepseek-api-key`,roleZh:`DeepSeek API Key 模型适配。`,category:`LLM / Agent 核心`},{id:`llm-pi-ai`,packageName:`@deepseek-ai/dsh-llm-pi-ai`,roleZh:`Pi AI 等 LLM 适配。`,category:`LLM / Agent 核心`},{id:`llm-retry`,packageName:`@deepseek-ai/dsh-llm-retry`,roleZh:`LLM 调用失败重试策略。`,category:`LLM / Agent 核心`},{id:`session-title-llm`,packageName:`@deepseek-ai/dsh-session-title-first-prompt-llm`,roleZh:`用首条用户消息经 LLM 自动起会话标题。`,category:`LLM / Agent 核心`},{id:`subagent-fork-in-process`,packageName:`@deepseek-ai/dsh-subagent-fork-in-process`,roleZh:`进程内 fork 子代理实现。`,category:`LLM / Agent 核心`},{id:`subagent-model-selection-settings`,packageName:`@deepseek-ai/dsh-tool-subagent/model-selection-settings`,roleZh:`子代理可选模型的设置项。`,category:`LLM / Agent 核心`},{id:`subagent-spawn-in-process`,packageName:`@deepseek-ai/dsh-subagent-spawn-in-process`,roleZh:`进程内 spawn 子代理实现。`,category:`LLM / Agent 核心`},{id:`system-prompt`,packageName:`@deepseek-ai/dsh-system-prompt`,roleZh:`系统提示词拼装服务。`,category:`LLM / Agent 核心`},{id:`tools`,packageName:`@deepseek-ai/dsh-tools`,roleZh:`工具注册与执行总闸。`,category:`LLM / Agent 核心`}],x=c();function S(e){return String(e??``).replace(/(\s*dsh[^)]*)/gi,``).replace(/\(\s*dsh[^)]*\)/gi,``).replace(/\bdsh\b/gi,``).replace(/\s{2,}/g,` `).replace(/(\s*)/g,``).trim()}function C({status:e}){let t=e.tone===`ready`?`bg-emerald-50 text-emerald-700 border-emerald-100`:e.tone===`warn`?`bg-amber-50 text-amber-800 border-amber-100`:`bg-stone-100 text-stone-500 border-stone-200`;return(0,x.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 py-0.5 text-[11px] ${t}`,children:e.label})}function Ce({tone:e}){return(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 shrink-0 rounded-full ${e===`ready`?`bg-emerald-500`:e===`warn`?`bg-amber-500`:`bg-stone-300`}`})}function w({open:e}){return(0,x.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-150 ${e?`rotate-90`:``}`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,x.jsx)(`path`,{fillRule:`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.17 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,clipRule:`evenodd`})})}function we(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,ee]=(0,_.useState)(null),[a,te]=(0,_.useState)(null),[o,ne]=(0,_.useState)(!0),[s,re]=(0,_.useState)(``),[ie,c]=(0,_.useState)({}),[ae,oe]=(0,_.useState)({});function se(e){c(t=>({...t,[e]:!t[e]}))}function ce(e){oe(t=>({...t,[e]:!t[e]}))}(0,_.useEffect)(()=>{let e=!0;return(async()=>{try{let[n,i,a,o]=await Promise.all([h(),m(),g(),ye()]);if(!e)return;t(n),r(i),ee(a),te(o)}finally{e&&ne(!1)}})(),()=>{e=!1}},[]);function l(t){let r=v(t.id);return r===`none`?{label:`规划中`,tone:`plan`}:r===`ready`?{label:`已就绪`,tone:`ready`}:o?{label:`探测中…`,tone:`plan`}:r===`web`?e?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`fs`?n?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`bash`?i?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`pwsh`?a?.ok&&a.available?{label:`已就绪`,tone:`ready`}:a?.ok?{label:`未装 PowerShell`,tone:`warn`}:{label:`需本地服务`,tone:`warn`}:{label:`规划中`,tone:`plan`}}let u=s.trim().toLowerCase(),le=e=>!u||e.id.toLowerCase().includes(u)||S(e.roleZh).toLowerCase().includes(u),ue=y.filter(le),de=b.filter(le),fe=[{id:`session`,title:`会话插件`,hint:`每个会话各自加载,随会话结束释放`,items:ue,total:y.length},{id:`global`,title:`全局插件`,hint:`由系统与所有会话共享,常驻运行`,items:de,total:b.length}];return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`div`,{className:`shrink-0 px-6 pt-5 pb-3`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`h3`,{className:`text-[15px] font-semibold text-stone-900`,children:`内置插件`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:`由平台按会话或全局提供,默认常开,不需要开关;状态取决于本机服务是否就绪。`})]}),(0,x.jsxs)(`label`,{className:`relative block w-44 shrink-0`,children:[(0,x.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,x.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,x.jsx)(`input`,{value:s,onChange:e=>re(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-8 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-2.5 text-xs text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})]})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:(0,x.jsx)(`div`,{className:`space-y-3`,children:fe.map(e=>{let t=!ie[e.id];return(0,x.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-expanded":t,className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors hover:bg-stone-50/70`,children:[(0,x.jsx)(w,{open:t}),(0,x.jsx)(`h4`,{className:`text-[13px] font-medium text-stone-700`,children:e.title}),(0,x.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:u?`${e.items.length}/${e.total}`:e.total}),(0,x.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-stone-400`,children:e.hint})]}),t?e.items.length?(0,x.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-2 border-t border-stone-100 p-2.5`,children:e.items.map(t=>{let n=l(t),r=`${e.id}:${t.id}`,i=!!ae[r];return(0,x.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,onClick:()=>ce(r),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(r))},className:`flex cursor-pointer flex-col rounded-lg border p-2.5 text-left transition-colors ${i?`border-[#4176e6]/40 bg-[#f6f9ff]`:`border-stone-200 bg-white hover:border-stone-300 hover:bg-stone-50/60`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(`span`,{className:`mt-1.5`,children:(0,x.jsx)(Ce,{tone:n.tone})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-[12.5px] text-stone-800`,children:t.id}),(0,x.jsx)(`p`,{className:`mt-0.5 text-[11.5px] leading-5 text-stone-500 ${i?``:`line-clamp-2`}`,children:S(t.roleZh)})]}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,x.jsx)(C,{status:n}),(0,x.jsx)(w,{open:i})]})]}),i?(0,x.jsxs)(`dl`,{className:`mt-2 grid w-full grid-cols-[auto_1fr] gap-x-2 gap-y-1 border-t border-stone-200/70 pt-2 text-[11px]`,children:[(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`分类`}),(0,x.jsx)(`dd`,{className:`truncate text-stone-600`,children:t.category}),(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`npm 包`}),(0,x.jsx)(`dd`,{className:`truncate font-mono text-stone-600`,children:t.packageName||`—`})]}):null]},r)})}):(0,x.jsx)(`p`,{className:`border-t border-stone-100 px-3.5 py-4 text-center text-xs text-stone-400`,children:`没有匹配的内置插件`}):null]},e.id)})})})]})}function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],T=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,E=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function ke({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,x.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,x.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function Ae({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M10 4a2 2 0 0 1 4 0v1h3a1 1 0 0 1 1 1v3h1a2 2 0 0 1 0 4h-1v3a1 1 0 0 1-1 1h-3v1a2 2 0 0 1-4 0v-1H7a1 1 0 0 1-1-1v-3H5a2 2 0 0 1 0-4h1V6a1 1 0 0 1 1-1h3V4z`})})}function je({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,x.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,x.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,x.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function D({title:e,description:t,control:n}){return(0,x.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,x.jsx)(`div`,{className:`shrink-0`,children:n})]})}function O({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,x.jsxs)(ne,{value:e,onChange:n,children:[(0,x.jsx)(te,{className:E,children:(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r})}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,x.jsxs)(o,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,x.jsx)(`span`,{children:e.label}),(0,x.jsx)(De,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function k(){let[e,t]=(0,_.useState)(!1),[c,m]=(0,_.useState)(`general`),[h,g]=(0,_.useState)(()=>ee().model.providers),[ye,v]=(0,_.useState)(()=>ee().model.activeId),[y,b]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),[Ce,w]=(0,_.useState)(`DeepSeek`),[E,k]=(0,_.useState)(``),[A,Me]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,Ne]=(0,_.useState)([]),[P,F]=(0,_.useState)(`idle`),[Pe,Fe]=(0,_.useState)(!1),[Ie,Le]=(0,_.useState)(`readonly`),[Re,ze]=(0,_.useState)(!1),[Be,I]=(0,_.useState)(!1),[Ve,He]=(0,_.useState)(null),[L,R]=(0,_.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[Ue,z]=(0,_.useState)(`14`),We=(0,_.useRef)(0),[B,Ge]=(0,_.useState)(null),[Ke,qe]=(0,_.useState)(!1),[Je,Ye]=(0,_.useState)(!1),[Xe,V]=(0,_.useState)(!1),[Ze,H]=(0,_.useState)(``),U=(0,_.useRef)(null),Qe=(0,_.useRef)(!1),W=y!==null,G=L.language,K=h.find(e=>e.id===ye),q=(K?.name||``).trim(),J=B?.status??null,$e=J?.phase===`done`&&!!J.to&&J.to===B?.current&&be!==B?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,et=J?.phase===`failed`?J.error:``,Y=Xe||J?.phase===`installing`||J?.phase===`restarting`,tt=(J?.to||B?.latest||``).replace(/^v/,``),X=et||Ze,nt=B?.checkedAt&&!Y?new Date(B.checkedAt).toLocaleTimeString():``,rt=Ke?``:Y?J?.phase===`restarting`?p(`settings.updateRestarting`,void 0,G):p(`settings.updateInstalling`,{v:tt},G):X?`${p(`settings.updateFailed`,void 0,G)}:${X}`:$e?p(`settings.updateDone`,{v:J?.to||``},G):B?.mode===`dev`&&B?.hasUpdate?p(`settings.updateDevMode`,void 0,G):B?.error?`${p(`settings.updateUnavailable`,void 0,G)}:${B.error}`:B?.hasUpdate?B.mode===`npx`?p(`settings.updateNpxHint`,void 0,G):``:B?`${p(`settings.updateLatest`,void 0,G)}${nt?` · ${p(`settings.updateCheckedAt`,{time:nt},G)}`:``}`:Je?p(`settings.updateUnavailable`,void 0,G):``,it=q||(G===`en`?`No model`:`未配置`),at=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function ot(e=`general`){m(e),r().then(()=>{st(),t(!0)})}function st(){ze(n()),g(u()),v(l()),I(!!d()),R(he()),me(he()),Le(pe()),b(null)}function Z(){U.current!==null&&(window.clearInterval(U.current),U.current=null)}async function ct(e=!0){qe(!0);try{let t=await Se(e);t&&(Ge(t),H(``))}finally{qe(!1),Ye(!0)}}function lt(e){Z();let t=Date.now()+18e4;U.current=window.setInterval(async()=>{if(!Qe.current){Qe.current=!0;try{let n=await Se(!0);if(n){Ge(n);let t=n.status;if(t?.phase===`failed`){Z(),V(!1),H(t.error||p(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),V(!1);return}}Date.now()>t&&(Z(),V(!1),H(p(`settings.updateTimeout`,void 0,G)))}finally{Qe.current=!1}}},1500)}async function ut(){let e=B?.latest||``;H(``),V(!0);let t=B?.current||be,n=await xe(e||void 0);n.ok?lt(t):(V(!1),H(n.error||p(`settings.updateFailed`,void 0,G)))}function dt(e){if(!e){let e=a();b(e),C(`DeepSeek`),w(`DeepSeek`),k(`https://api.deepseek.com/v1`),Me(``),M(``),Ne([]),F(`idle`),Fe(!1);return}b(e.id),C(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===l()?i().trim():``)||``;Me(t),M(e.model),Ne(e.availableModels??[]),F(e.availableModels?.length?`ok`:`idle`),w(f.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),Fe(!1)}(0,_.useEffect)(()=>{r().then(()=>st());let e=e=>{let n=e.detail;m(n?.tab===`model`?`model`:n?.tab===`builtin`?`builtin`:`general`),r().then(()=>{st(),t(!0)})};window.addEventListener(ge,e);let n=le(e=>R(e)),i=_e(e=>Le(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,_.useEffect)(()=>{if(e)return(async()=>{let e=await Se(!1);if(Ye(!0),!e)return;Ge(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(V(!0),lt(t.from||e.current))})(),Z},[e]),(0,_.useEffect)(()=>{if(!e||c!==`model`||!W)return;let t=E.trim(),n=A.trim();if(!t||!n){F(e=>e===`ok`?`ok`:`idle`);return}F(`loading`);let r=++We.current,i=setTimeout(()=>{se(t,n).then(e=>{r===We.current&&(Ne(e),F(`ok`))}).catch(()=>{r===We.current&&F(`fail`)})},800);return()=>clearTimeout(i)},[e,c,W,E,A]);function ft(e){w(e);let t=f.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!S.trim()||f.some(e=>e.label===S))&&C(t.label)),M(``)}function Q(e){R(ue(e))}(0,_.useEffect)(()=>{z(String(L.sessionFontSize))},[L.sessionFontSize]);function pt(){let e=Number(Ue);if(!Ue.trim()||!Number.isFinite(e)){z(String(L.sessionFontSize));return}let t=ue({sessionFontSize:Math.round(e)});R(t),z(String(t.sessionFontSize))}let mt=!!(S.trim()&&E.trim()&&A.trim()&&j.trim()),$=N.length>0;function ht(){if(!mt||!y)return;let e=!h.some(e=>e.id===y),t=ve({id:y,name:S.trim(),baseURL:E.trim(),apiKey:A.trim(),model:j.trim(),availableModels:$?N:void 0},{activate:!0});g(t),v(y),b(null),I(!!d()),oe(e?`已新增模型服务`:`已保存模型服务`,`success`)}function gt(e){He(e)}function _t(){let e=Ve;if(!e)return;let t=h.find(t=>t.id===e)?.name??`该服务`;He(null);let n=fe(e);g(n),v(l()),y===e&&b(null),I(!!d()),oe(`已删除模型服务「${t}」`,`success`)}function vt(e){ce(e),v(e),I(!!d())}let yt=[{value:`readonly`,label:p(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:p(`settings.access.readwrite`,void 0,G)},{value:`full`,label:p(`settings.access.full`,void 0,G)}],bt=[{value:`concise`,label:p(`settings.step.concise`,void 0,G)},{value:`standard`,label:p(`settings.step.standard`,void 0,G)},{value:`detailed`,label:p(`settings.step.detailed`,void 0,G)},{value:`full`,label:p(`settings.step.full`,void 0,G)}],xt=[{value:`queue`,label:p(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:p(`settings.busySend.interrupt`,void 0,G)}],St=[{value:`light`,label:p(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:p(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:p(`settings.appear.system`,void 0,G),icon:`monitor`}],Ct=[{id:`general`,label:p(`settings.general`,void 0,G),icon:(0,x.jsx)(Oe,{})},{id:`model`,label:p(`settings.model`,void 0,G),icon:(0,x.jsx)(ke,{})},{id:`builtin`,label:p(`settings.builtin`,void 0,G),icon:(0,x.jsx)(Ae,{})}],wt=c===`general`||c===`builtin`?p(c===`general`?`settings.general`:`settings.builtin`,void 0,G):W?h.some(e=>e.id===y)?p(`settings.editProvider`,void 0,G):p(`settings.addProviderTitle`,void 0,G):p(`settings.model`,void 0,G);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>ot(`general`),className:`tw-nav-settings-btn`,"data-hint":Be?`设置(已配置模型)`:`设置`,children:[(0,x.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,x.jsx)(`span`,{"data-i18n":`nav.settings`,children:p(`nav.settings`,void 0,G)})]}),(0,x.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":at,onClick:()=>ot(`model`),children:[(0,x.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`tw-nav-provider-name`,children:it})]})]}),(0,x.jsx)(re,{show:e,children:(0,x.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,x.jsx)(ie,{children:(0,x.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,x.jsx)(ie,{children:(0,x.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:wt}),(0,x.jsx)(`button`,{type:`button`,"aria-label":p(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,x.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,x.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:Ct.map(e=>{let t=c===e.id;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.id),e.id===`model`&&b(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,x.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:c===`general`?(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,x.jsx)(D,{title:p(`settings.access`,void 0,G),description:p(`settings.accessDesc`,void 0,G),control:(0,x.jsx)(O,{value:Ie,options:yt,onChange:e=>{Le(e),de(e)}})}),(0,x.jsx)(D,{title:p(`settings.language`,void 0,G),control:(0,x.jsx)(O,{value:L.language,options:Ee,onChange:e=>Q({language:e})})}),(0,x.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:p(`settings.appearance`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:St.map(e=>{let t=L.appearance===e.value;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(je,{kind:e.icon}),(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,x.jsx)(D,{title:p(`settings.fontSize`,void 0,G),description:p(`settings.fontSizeDesc`,void 0,G),control:(0,x.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,x.jsx)(`input`,{type:`number`,min:12,max:22,value:Ue,onChange:e=>z(e.target.value),onBlur:pt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,x.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,x.jsx)(D,{title:p(`settings.toolSteps`,void 0,G),description:p(`settings.toolStepsDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.toolStepDetail,options:bt,onChange:e=>Q({toolStepDetail:e})})}),(0,x.jsx)(D,{title:p(`settings.busySend`,void 0,G),description:p(`settings.busySendDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.busySendBehavior,options:xt,onChange:e=>Q({busySendBehavior:e})})}),(0,x.jsx)(D,{title:p(`settings.subagentModel`,void 0,G),description:p(`settings.subagentModelDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.subagentModel?.trim()?L.subagentModel:`inherit`,options:[{value:`inherit`,label:p(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:p(`settings.platformVersion`,void 0,G)}),(0,x.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,be]}),B?.hasUpdate&&!Y&&!$e?(0,x.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${p(`settings.updateAvailable`,void 0,G)} v${(B.latest||``).replace(/^v/,``)}`}):null]}),(0,x.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,x.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),p(`settings.updateWorking`,void 0,G)]}):$e?(0,x.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:p(`settings.updateReload`,void 0,G)}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:Ke,onClick:()=>void ct(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:Ke?(0,x.jsxs)(x.Fragment,{children:[p(`settings.updateChecking`,void 0,G),(0,x.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{})]})]}):p(`settings.updateCheck`,void 0,G)}),B?.hasUpdate?(0,x.jsx)(`button`,{type:`button`,disabled:B.mode===`dev`,onClick:()=>void ut(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:p(`settings.updateNow`,void 0,G)}):null]})})]}),rt?(0,x.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:rt}):null,X&&B?.logPath?(0,x.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:p(`settings.updateLog`,{path:B.logPath},G)}):null]})]}):W?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:p(`settings.back`,void 0,G)})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.displayName`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`DeepSeek`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.preset`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:f.map(e=>{let t=Ce===e.label;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>ft(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,x.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.baseUrl`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:E,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.apiKey`,void 0,G)}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`input`,{type:Pe?`text`:`password`,value:A,onChange:e=>Me(e.target.value),placeholder:`sk-...`,className:`${T} pr-14`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>Fe(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Pe?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),Re?(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:p(`settings.keyHint`,void 0,G)}):null]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,x.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:p(`settings.modelField`,void 0,G)}),P===`loading`&&(0,x.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:p(`settings.recognizing`,void 0,G)}),$&&P===`ok`&&(0,x.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:p(`settings.recognized`,{n:N.length},G)}),P===`fail`&&!$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeFail`,void 0,G)}),P===`fail`&&$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeKeep`,void 0,G)})]}),$?(0,x.jsxs)(ne,{value:j,onChange:M,children:[(0,x.jsx)(te,{className:`${T} flex items-center justify-start text-left hover:border-stone-400 cursor-pointer`,children:(0,x.jsx)(`span`,{className:`min-w-0 truncate text-stone-800`,children:j||(G===`en`?`Select a model`:`请选择模型`)})}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:N.map(e=>(0,x.jsxs)(o,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(De,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,x.jsx)(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:p(`settings.modelPlaceholder`,void 0,G),className:T})]})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:p(`settings.cancel`,void 0,G)}),(0,x.jsx)(`button`,{type:`button`,onClick:ht,disabled:!mt,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:p(`settings.save`,void 0,G)})]})]}):c===`builtin`?(0,x.jsx)(we,{}):(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,x.jsx)(`p`,{className:`text-sm text-stone-500`,children:p(`settings.modelIntro`,void 0,G)}),(0,x.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[h.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===ye;return(0,x.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,x.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>vt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,x.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>dt(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:p(`settings.edit`,void 0,G)}),h.length>1?(0,x.jsx)(`button`,{type:`button`,onClick:()=>gt(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:p(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>dt(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:p(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,x.jsx)(ae,{open:Ve!=null,title:p(`settings.delete`,void 0,G),message:p(`settings.deleteConfirm`,void 0,G),confirmLabel:p(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>He(null),onConfirm:_t})]})}export{k as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./react-dom.DLW9pGCF.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";var i=e(t(),1),a=e(n(),1),o=r(),s=280;function c({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,widthClass:c=`max-w-md`,escDisabled:l=!1,children:u,footer:d}){let[f,p]=(0,i.useState)(e),[m,h]=(0,i.useState)(!1);if((0,i.useEffect)(()=>{if(e){p(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>h(!0))});return()=>window.cancelAnimationFrame(e)}h(!1);let t=window.setTimeout(()=>p(!1),s);return()=>window.clearTimeout(t)},[e]),(0,i.useEffect)(()=>{if(!e||l)return;function n(e){e.key===`Escape`&&(document.querySelector(`[aria-haspopup="listbox"][aria-expanded="true"]`)||(e.preventDefault(),e.stopPropagation(),t()))}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t,l]),!f)return null;let g=(0,o.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,o.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-[280ms] ease-out ${m?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,o.jsxs)(`aside`,{className:`tw-slide-over relative w-full ${c} h-full shadow-2xl border-l border-stone-200 flex flex-col transition-[translate] duration-[280ms] ease-[cubic-bezier(0.32,0.72,0,1)] will-change-[translate] ${m?`translate-x-0`:`translate-x-full`}`,children:[(0,o.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,o.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,o.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,o.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-4`,children:u}),d]})]});return typeof document>`u`?g:(0,a.createPortal)(g,document.body)}export{c as t};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{E as n,f as r,i}from"./app-config.CF1xVPmo.js";import{c as a}from"./plugins.CVM1IaoC.js";import{i as o,n as s,r as c,t as l}from"./dialog.DZHZCe_T.js";import{i as ee,n as u,r as d,t as f}from"./menu.Dnrpz489.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{showToast as h}from"./Toast.BO2NFckG.js";import{p as te}from"./project-docs.DAw9bzgk.js";import{n as g}from"./llm.BuR7z55C.js";import{t as _}from"./prompts-meta.C_MeYq8G.js";import{l as ne}from"./settings.B1yetppp.js";import{n as v}from"./i18n.CjqQGCAI.js";import{a as y,c as re,d as ie,f as b,i as ae,l as oe,m as se,n as ce,o as x,p as le,r as ue,s as de,t as fe,u as pe}from"./spaces-client.DnS6MgGy.js";var S=e(t(),1),me=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
|
|
2
|
-
这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
|
|
3
|
-
要求:
|
|
4
|
-
- 用「你是…」起头设定角色;
|
|
5
|
-
- 紧扣用户描述的领域与工作方式;
|
|
6
|
-
- 写几条简洁的回答原则(问什么答什么、先结论);
|
|
7
|
-
- 只输出提示词正文,不要解释、不要标题。`;function he(e){let t=String(e??``).replace(/^\uFEFF/,``).trim(),n=/^```(?:markdown|md|text)?\s*\n([\s\S]*?)\n```$/i.exec(t);return n&&(t=n[1].trim()),t}var C=p();function ge(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function _e({hint:e,children:t}){return e?(0,C.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function ve(e){let{value:t,onChange:n,onGenerate:r,onStop:i,generating:a,disabled:o}=e,s=(0,S.useRef)(null);(0,S.useLayoutEffect)(()=>{let e=s.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[t]);let c=!!t.trim()&&!a&&!o;return(0,C.jsxs)(`div`,{className:`tw-space-prompt-composer pt-1 rounded-lg bg-white border border-stone-200 outline-none transition-colors focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6]`,children:[(0,C.jsx)(`textarea`,{ref:s,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),a){i();return}c&&r()}},placeholder:v(`space.promptBriefPlaceholder`),rows:1,disabled:o,className:`block w-full min-h-6 pl-3.5 pr-2 pt-0.5 pb-0 text-sm leading-5 text-stone-800 bg-transparent resize-none focus:outline-none placeholder:text-stone-400 disabled:opacity-60`}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,C.jsx)(`span`,{className:`flex-1`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>a?i():r(),disabled:!a&&!c,"aria-label":v(a?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${a?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:a?(0,C.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,C.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,C.jsx)(`path`,{d:`M12 19V5`})]})})]})]})}function ye(e){return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,C.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:v(`space.promptBodyLabel`)}),(0,C.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:_})]}),(0,C.jsx)(`textarea`,{value:e.value,onChange:t=>e.onChange(t.target.value),placeholder:v(`space.promptBodyPlaceholder`),rows:8,disabled:e.disabled,className:`w-full min-h-36 px-3 py-2 text-sm leading-relaxed rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors resize-y font-[inherit]`}),(0,C.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-snug`,children:e.hint??v(`space.promptHint`)})]})}function w({open:e,onClose:t,onListChanged:n}){let[a,ee]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[b,w]=(0,S.useState)(``),[T,E]=(0,S.useState)(!1),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(``),[j,M]=(0,S.useState)(``),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)(``),[L,R]=(0,S.useState)(``),[be,z]=(0,S.useState)(``),[B,xe]=(0,S.useState)(!1),[Se,Ce]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[we,Te]=(0,S.useState)(``),[G,K]=(0,S.useState)([]),[Ee,q]=(0,S.useState)({}),De=(0,S.useRef)(null),Oe=(0,S.useRef)(null),ke=(0,S.useRef)(null),J=(0,S.useRef)(null),[Ae,je]=(0,S.useState)(null),Y=(0,S.useCallback)(async(e=!1)=>{e&&d(`stats`);let t=await ie({stats:e});e&&d(null),t?(ee(t),n?.(t)):p(`无法读取数据空间列表(本地服务未运行?)`)},[n]),Me=(0,S.useRef)(Y);(0,S.useEffect)(()=>{Me.current=Y},[Y]);function X(){J.current?.abort()}(0,S.useEffect)(()=>{e?(p(``),w(``),E(!1),P(null),Me.current(!1)):(X(),E(!1),P(null),je(null))},[e]);async function Ne(e){if(Ae||u!==null)return;let t=(e===`create`?k:L).trim();if(!t){p(v(`space.promptNeedReq`));return}p(``);let n=new AbortController;J.current=n,je(e);try{await i();let r=ne();if(!r?.apiKey?.trim()||!r.model?.trim()||!r.baseURL?.trim()){p(v(`space.promptNeedModel`));return}let a=(e===`create`?D:F).trim(),o=await g(r,[{role:`system`,content:me},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${t}`}],n.signal);if(n.signal.aborted)return;let s=he(o);if(!s){p(v(`space.promptGenEmpty`));return}e===`create`?M(s):z(s)}catch(e){if(ge(e)||n.signal.aborted)return;p(e instanceof Error?e.message:String(e))}finally{J.current===n&&(J.current=null),je(null)}}function Pe(){X(),p(``),w(``),O(``),A(``),M(``),E(!0),requestAnimationFrame(()=>Oe.current?.scrollIntoView({block:`nearest`}))}async function Fe(){if(u!==null)return;let e=D.trim();if(!e){p(v(`space.needName`));return}X();let t=j.trim(),n=k.trim();d(`create`),p(``);let i=await ce(e,{switch:!0,...t?{systemPrompt:t}:{},...n?{promptBrief:n}:{}});if(d(null),!i.ok){p(i.error||v(`space.create`)+` 失败`);return}let a=i.space?.id;a&&r(a),window.location.reload()}async function Ie(e){X(),p(``),w(``),P(e),I(e.name),R(``),Ce(!1),z(``),xe(!0),requestAnimationFrame(()=>ke.current?.scrollIntoView({block:`nearest`}));let t=await re(e.id),n=``,r=``;if(t.ok)n=t.brief??``,r=t.systemPrompt??``;else if(e.isActive)try{r=(await te(`prompts`,_)).content.trim()}catch{}if(xe(!1),!t.ok&&!r){P(null),p(t.error||v(`space.detailFailed`));return}t.space&&I(t.space.name),z(r);let i=!n.trim()&&!!r;R(i?r:n),Ce(i)}async function Le(){if(!N||u!==null)return;let e=F.trim();if(!e){p(v(`space.needName`));return}X(),d(`update`),p(``);let t=await se(N.id,{name:e,...Se?{}:{brief:L},systemPrompt:be});if(d(null),!t.ok){let e=t.error||v(`space.updateFailed`);p(e),h(`保存空间失败:${e}`,`error`);return}let n=!!(t.space&&t.space.name!==N.name),r=N.isActive;P(null);let i=t.space?.name??e;w(v(`space.updated`,{name:i})),h(`已保存数据空间「${i}」`,`success`),n&&r?window.location.reload():await Y(!1)}async function Re(e){if(e.isActive||u!==null)return;d(`update`),p(``);let t=await le(e.id);d(null),t.ok?window.location.reload():p(t.error||`切换失败`)}async function ze(){if(!U)return;let e=we.trim();if(!e)return;d(`copy`),p(``);let t=await fe(U.id,e);if(d(null),!t.ok){let e=t.error||`复制失败`;p(e),h(`复制空间失败:${e}`,`error`)}else W(null),w(`已复制为「${t.space?.name}」`),h(`已复制为「${t.space?.name}」`,`success`),await Y(!1)}async function Be(e,t){d(`delete`),p(``);let n=await ue(e.id,t);if(d(null),!n.ok){let e=n.error||`删除失败`;p(e),h(`删除空间失败:${e}`,`error`)}else H(null),h(`已删除数据空间「${e.name}」`,`success`),e.isActive?(r(`public`),window.location.reload()):(w(n.warning?n.warning:n.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))}async function Ve(){d(`discover`),p(``),w(``),K([]);let e=await ae();if(d(null),!e.ok){p(e.error||`扫描失败`);return}let t=e.added?.length??0,n=e.backfilled?.length??0,r=e.skipped?.length??0,i=e.candidates??[],a=[];t?a.push(v(`space.discoverAdded`,{n:t})):i.length||a.push(v(`space.discoverNone`)),n&&a.push(v(`space.discoverBackfilled`,{n})),r&&a.push(v(`space.discoverSkipped`,{n:r})),w(a.join(`;`)),K(i),q(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function He(){let e=G.filter(e=>Ee[e.path]).map(e=>e.path);if(!e.length){K([]),w(v(`space.candidatesIgnored`));return}d(`discover`),p(``);let t=await ae(e);if(d(null),!t.ok){p(t.error||`纳入失败`);return}K([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?v(`space.candidatesAdopted`,{n}):v(`space.candidatesIgnored`)];r.length&&i.push(v(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),w(i.join(`;`)),await Y(!1)}async function Ue(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;d(`import`),p(``);let n=await pe(t);d(null),n.ok?(w(`已导入为「${n.space?.name}」`),await Y(!1)):p(n.error||`导入失败`)}let Z=a?.spaces??[],We=new Map(Z.map((e,t)=>[e.id,t])),Ge=e=>e.isPublic?0:e.isActive?1:2,Ke=[...Z].sort((e,t)=>Ge(e)-Ge(t)||(We.get(e.id)??0)-(We.get(t.id)??0)),Q=a?.baseRoot,$=u!==null,qe=Ae===`create`,Je=Ae===`edit`;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c,{open:e,onClose:t,transition:!0,className:`relative z-95`,children:[(0,C.jsx)(l,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,C.jsxs)(o,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-4xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col h-[86vh]`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:v(`space.manageTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:v(`space.manageDesc`)})]}),(0,C.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:(0,C.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`})})]}),(0,C.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[f?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 flex items-start gap-2`,children:[(0,C.jsx)(`span`,{className:`flex-1 min-w-0`,children:f}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>p(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,"aria-label":`关闭`,children:`✕`})]}):null,b?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-700 flex items-start gap-2`,children:[(0,C.jsx)(`span`,{className:`flex-1 min-w-0`,children:b}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-emerald-700/70 hover:bg-emerald-100 hover:text-emerald-900`,"aria-label":`关闭`,children:`✕`})]}):null,G.length?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:v(`space.candidatesTitle`,{n:G.length})}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:v(`space.candidatesHint`)}),(0,C.jsx)(`div`,{className:`mt-2 max-h-44 overflow-auto rounded-md border border-amber-200/70 bg-white divide-y divide-stone-100`,children:G.map(e=>(0,C.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:Ee[e.path]===!0,onChange:t=>q(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,C.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?x(e.path,Q):e.path})]})]},e.path))}),(0,C.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>q(Object.fromEntries(G.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:v(`space.candidatesSelectAll`)}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>q({}),className:`text-[11px] text-stone-500 hover:underline`,children:v(`space.candidatesClear`)}),(0,C.jsx)(`span`,{className:`flex-1`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>{K([]),q({}),w(v(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:v(`space.candidatesIgnore`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void He(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:v(`space.candidatesAdopt`)})]})]}):null,T?(0,C.jsxs)(`div`,{ref:Oe,children:[(0,C.jsxs)(`div`,{className:`mb-2`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:v(`space.newTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400`,children:v(`space.newDesc`)})]}),(0,C.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,C.jsx)(`input`,{autoFocus:!0,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Fe())},placeholder:v(`space.namePlaceholder`),className:`w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})}),a?(0,C.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,C.jsx)(`code`,{children:x(a.dataRoot,a.baseRoot)})}):null,(0,C.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:v(`space.promptBriefLabel`)}),(0,C.jsx)(ve,{value:k,onChange:A,onGenerate:()=>void Ne(`create`),onStop:X,generating:qe,disabled:$}),(0,C.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,C.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:v(`space.promptHint`)}),qe?(0,C.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[v(`space.promptGeneratingStatus`),(0,C.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,C.jsx)(ye,{value:j,onChange:M,disabled:$})]})]}):N?(0,C.jsxs)(`div`,{ref:ke,children:[(0,C.jsxs)(`div`,{className:`mb-2`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:v(`space.editTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400 font-mono truncate`,children:Q?x(N.path,Q):N.path})]}),(0,C.jsxs)(`label`,{className:`block text-xs font-medium text-stone-500`,children:[v(`space.nameLabel`),(0,C.jsx)(`input`,{autoFocus:!0,value:F,disabled:B||N.isPublic===!0,onChange:e=>I(e.target.value),className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors disabled:bg-stone-50 disabled:text-stone-400`})]}),N.isPublic?(0,C.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:v(`space.publicNameLocked`)}):null,(0,C.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:v(`space.promptBriefLabel`)}),(0,C.jsx)(ve,{value:L,onChange:e=>{R(e),Ce(!1)},onGenerate:()=>void Ne(`edit`),onStop:X,generating:Je,disabled:$||B}),(0,C.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,C.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:v(`space.promptBriefHint`)}),Je?(0,C.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[v(`space.promptGeneratingStatus`),(0,C.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,C.jsx)(ye,{value:be,onChange:z,disabled:$||B,hint:v(`space.promptEditHint`)}),B?(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-stone-400`,children:v(`space.loading`)}):null]})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,C.jsxs)(`div`,{className:`text-xs font-medium text-stone-500`,children:[v(`space.listTitle`),Z.length?(0,C.jsx)(`span`,{className:`ml-1.5 text-[11px] text-stone-400 tabular-nums`,children:Z.length}):null]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>De.current?.click(),className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:u===`import`?`…`:v(`space.import`)}),(0,C.jsx)(`input`,{ref:De,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void Ue(e)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Ve(),"data-hint":v(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:v(u===`discover`?`space.discovering`:`space.discover`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":v(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:v(u===`stats`?`space.sizing`:`space.size`)})]})]}),(0,C.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:Z.length===0?(0,C.jsx)(`div`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:v(`space.empty`)}):Ke.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:y(e)}),e.isPublic?(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:v(`space.builtin`)}):null,e.isActive?(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:v(`space.activeTag`)}):null,e.exists?null:(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:v(`space.missing`)}),e.bytes==null?null:(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:oe(e.bytes)})]}),(0,C.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?x(e.path,Q):e.path,"data-hint-always":``,children:Q?x(e.path,Q):e.path})]}),(0,C.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[!e.isActive&&e.exists?(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Re(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.switch`)}):null,(0,C.jsx)(`button`,{type:`button`,disabled:$||!e.exists,onClick:()=>void Ie(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.edit`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{W(e),Te(`${e.name}-copy`)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.copy`)}),(0,C.jsx)(`a`,{href:de(e.id,`content`),"data-hint":v(`space.exportContentTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:v(`space.exportContent`)}),(0,C.jsx)(`a`,{href:de(e.id,`full`),"data-hint":v(`space.exportFullTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:v(`space.exportFull`)}),(0,C.jsx)(_e,{hint:e.removable?void 0:v(`space.publicLocked`),children:(0,C.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({kind:`remove`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:v(`space.removeList`)})}),(0,C.jsx)(_e,{hint:e.removable?void 0:v(`space.publicLocked`),children:(0,C.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({kind:`delete`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-red-200 text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:v(`space.deleteDisk`)})})]})]},e.id))})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-3 border-t border-stone-200`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:$||T||N!==null,onClick:()=>{!T&&N===null&&Pe()},className:`h-8 px-3 text-xs font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-[#4176e6] transition-colors`,children:v(`space.addNew`)}),(0,C.jsx)(`span`,{className:`flex-1`}),T||N?(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{X(),E(!1),P(null)},className:`tw-confirm-cancel h-8 px-4 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:v(`space.cancel`)}):null,T?(0,C.jsx)(`button`,{type:`button`,disabled:!D.trim()||$,onClick:()=>void Fe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`create`?`…`:v(`space.create`)}):N?(0,C.jsx)(`button`,{type:`button`,disabled:!F.trim()||$||B,onClick:()=>void Le(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`update`?`…`:v(`space.save`)}):null]})]})})]}),(0,C.jsxs)(c,{open:U!==null,onClose:()=>W(null),transition:!0,className:`relative z-96`,children:[(0,C.jsx)(l,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,C.jsxs)(o,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,C.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:v(`space.confirmCopyTitle`)}),(0,C.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:v(`space.confirmCopyMsg`,{name:U?.name??``})}),(0,C.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[v(`space.copyName`),(0,C.jsx)(`input`,{autoFocus:!0,value:we,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ze())},className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})]}),(0,C.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>W(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:v(`space.cancel`)}),(0,C.jsx)(`button`,{type:`button`,disabled:!we.trim()||$,onClick:()=>void ze(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`copy`?`…`:v(`space.copy`)})]})]})})]}),(0,C.jsx)(m,{open:V?.kind===`remove`,title:v(`space.confirmRemoveTitle`),message:V?.kind===`remove`?v(`space.confirmRemoveMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:v(`space.removeList`),onClose:()=>H(null),onConfirm:()=>{V?.kind===`remove`&&Be(V.space,!1)}}),(0,C.jsx)(m,{open:V?.kind===`delete`,title:v(`space.confirmDeleteTitle`),message:V?.kind===`delete`?v(`space.confirmDeleteMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:v(`space.deleteDisk`),danger:`solid`,onClose:()=>H(null),onConfirm:()=>{V?.kind===`delete`&&Be(V.space,!0)}})]})}var T=`tw.spaces.list.v1`;async function E(){let e=n(window.location.pathname,`/`);if(!e?.plugin)return!0;try{let t=await fetch(`/__tb_config`,{signal:AbortSignal.timeout(1500)});if(!t.ok)return!0;let n=await t.json();return a(n.config?.plugins??{})[e.plugin]!==!1}catch{return!0}}function D(){try{let e=sessionStorage.getItem(T);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function O(e){try{sessionStorage.setItem(T,JSON.stringify(e))}catch{}}function k(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function A(){let e=D(),[t,n]=(0,S.useState)(e!==null),[r,i]=(0,S.useState)(e!==null),[a,o]=(0,S.useState)(e),[s,c]=(0,S.useState)(!1),[l,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(``);(0,S.useEffect)(()=>{let e=!0;return(async()=>{let t=await b();if(!e)return;if(i(!0),!t){n(!1),k(!0);return}k(!1),n(!0);let r=await ie();e&&r&&(o(r),O(r))})(),()=>{e=!1}},[]);async function te(e){if(e===a?.activeId)return;p(!0),h(``);let t=await le(e);t.ok?(a&&O({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),await E()?window.location.reload():window.location.replace(`/workbench/`)):(p(!1),h(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,C.jsx)(`div`,{className:`tw-nav-space`,children:(0,C.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,C.jsx)(j,{})}),(0,C.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-cap`,children:v(`space.offlineCap`)}),(0,C.jsx)(`span`,{className:`tw-nav-space-name`,children:v(`space.offline`)})]})]})});let g=a?.spaces.find(e=>e.isActive),_=(a?.spaces??[]).filter(e=>!e.isActive);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`tw-nav-space`,children:(0,C.jsxs)(d,{as:`div`,className:`tw-nav-space-menu`,children:[(0,C.jsxs)(f,{className:`tw-nav-space-btn`,"data-hint":v(`space.label`),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,C.jsx)(j,{})}),(0,C.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-cap`,children:v(`space.current`)}),(0,C.jsx)(`span`,{className:`tw-nav-space-name`,children:l?v(`space.switching`):g?y(g):`—`})]}),(0,C.jsx)(`svg`,{className:`tw-nav-space-caret`,viewBox:`0 0 24 24`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,C.jsxs)(ee,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[m?(0,C.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:m}):null,(0,C.jsx)(`div`,{className:`tw-nav-space-group`,children:v(`space.others`)}),_.length===0?(0,C.jsx)(`p`,{className:`tw-nav-space-hint`,children:v(`space.othersEmpty`)}):_.map(e=>(0,C.jsx)(u,{children:(0,C.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:l,onClick:()=>void te(e.id),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,C.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":y(e),children:y(e)})}),(0,C.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,C.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,C.jsx)(u,{children:(0,C.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>c(!0),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,C.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,C.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]})}),(0,C.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,C.jsx)(`span`,{className:`tw-nav-space-item-name`,children:v(`space.manage`)})}),(0,C.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,C.jsx)(w,{open:s,onClose:()=>c(!1),onListChanged:e=>{o(e),O(e)}})]})}function j(){return(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,C.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,C.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,C.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{A as default};
|