lantern-harness 0.1.32 → 0.1.34
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 +43 -0
- package/builtin/session/mcp-client.mjs +291 -2
- package/dist/500.html +4 -4
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.4j--gBo-.js → Base.astro_astro_type_script_index_0_lang.CuCwv2e7.js} +2 -2
- package/dist/_astro/Base.huFPH3Mp.css +1 -0
- package/dist/_astro/{CaseExecBoard.CTuf_Nom.js → CaseExecBoard.CTVdi8MV.js} +1 -1
- package/dist/_astro/CaseGenerateApp.BONj-skB.js +10 -0
- package/dist/_astro/{CasesLibrary.C-T3VrPa.js → CasesLibrary.e6nFqhN3.js} +10 -10
- package/dist/_astro/ChatApp.XcaVtt7c.js +226 -0
- package/dist/_astro/{ColumnResize.BgYkV9Iy.js → ColumnResize._Iq05ix_.js} +1 -1
- package/dist/_astro/{DashboardBoard.B5Qo5Y3e.js → DashboardBoard.BaJyXPXA.js} +1 -1
- package/dist/_astro/{DocsFileBrowser.DnxVsmed.js → DocsFileBrowser.D2Cff2LP.js} +1 -1
- package/dist/_astro/{KnowledgeLibrary.DARUegK8.js → KnowledgeLibrary.CWxIHa8I.js} +1 -1
- package/dist/_astro/{NavLibraries.FAj9zUuq.js → NavLibraries.CZlA6Z1w.js} +1 -1
- package/dist/_astro/PluginsPage.Ch3rrYRF.js +1 -0
- package/dist/_astro/PluginsPage.DOGWQcVc.js +17 -0
- package/dist/_astro/{PmBugsBoard.uNPzbw-N.js → PmBugsBoard.ChL0RBVn.js} +1 -1
- package/dist/_astro/{PmIterationsBoard.CjR8L71i.js → PmIterationsBoard.hTKVnMgh.js} +1 -1
- package/dist/_astro/{PmProjectDetail.Cpug99Lt.js → PmProjectDetail.Saj76lNM.js} +1 -1
- package/dist/_astro/{PmProjectsBoard.VLqrwucj.js → PmProjectsBoard.CCtClGM1.js} +1 -1
- package/dist/_astro/PmRequirementsBoard.BNNq671Z.js +1 -0
- package/dist/_astro/{PmRequirementsBoard.CdP4gEzq.js → PmRequirementsBoard.DGXYC1Te.js} +1 -1
- package/dist/_astro/{PmShared.ChKKU3Ww.js → PmShared.BuhrL7Gb.js} +1 -1
- package/dist/_astro/PromptsLibrary.C9F9RVpz.js +1 -0
- package/dist/_astro/{ReportsPage.iSM5TWMq.js → ReportsPage.BjD8w0zS.js} +1 -1
- package/dist/_astro/ReqAnalysisBoard.JfmIK2Bb.js +39 -0
- package/dist/_astro/{RequirementsLibrary.X89V8-QF.js → RequirementsLibrary.WxAFCP3X.js} +1 -1
- package/dist/_astro/{SettingsDialog.BlokCWBn.js → SettingsDialog.BpKHIbID.js} +1 -1
- package/dist/_astro/SpaceSwitcher.BCZbiL7o.js +7 -0
- package/dist/_astro/{TasksBoard.Z8rBCO1F.js → TasksBoard.CdWQSwlg.js} +1 -1
- package/dist/_astro/{TemplatesLibrary.DBHSAPQ0.js → TemplatesLibrary.y_RtSjYC.js} +1 -1
- package/dist/_astro/{TestStatsBoard.BtqoPuLc.js → TestStatsBoard.C3vkF9vc.js} +1 -1
- package/dist/_astro/{TodosBoard.ETI63YgA.js → TodosBoard.CSupMlTp.js} +1 -1
- package/dist/_astro/{UiAutoBoard.DxrlgvI7.js → UiAutoBoard._og5jRon.js} +3 -3
- package/dist/_astro/app-version.trTEbNVs.js +1 -0
- package/dist/_astro/{case-gen-run.BNNfA12U.js → case-gen-run.BSJ0o4Zq.js} +1 -1
- package/dist/_astro/{plugins.SqANn3ZB.js → plugins.CVnHeKyf.js} +1 -1
- package/dist/_astro/prompts-meta.Dnmq-SnF.js +2 -0
- package/dist/_astro/req-analysis.D-dTIxXF.js +31 -0
- package/dist/_astro/story-review.CvXvtZ90.js +14 -0
- 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 +77 -38
- package/dist/docs/install/index.html +13 -7
- package/dist/docs/manual/index.html +29 -19
- 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//345/205/250/345/261/200/346/217/222/344/273/266.md +3 -3
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +9 -3
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +32 -20
- package/lh-plugins/lh-mcp.mjs +67 -2
- package/lh-plugins/lh-req-analysis.mjs +60 -3
- package/lh-plugins/plugin-prompts.mjs +2 -0
- package/lh-plugins/req-analysis-prompt.mjs +30 -4
- package/package.json +1 -1
- package/dist/_astro/Base.9LLJ6KVG.css +0 -1
- package/dist/_astro/CaseGenerateApp.18SE0dLJ.js +0 -10
- package/dist/_astro/ChatApp.BpFXgd8K.js +0 -226
- package/dist/_astro/PluginsPage.DKPA2zw8.js +0 -1
- package/dist/_astro/PluginsPage.F0oMYJri.js +0 -7
- package/dist/_astro/PmRequirementsBoard.B5ypu68O.js +0 -1
- package/dist/_astro/PromptsLibrary.BlWPVm1Z.js +0 -1
- package/dist/_astro/ReqAnalysisBoard.CeQbq7Qh.js +0 -39
- package/dist/_astro/SpaceSwitcher.MmSkP3wb.js +0 -7
- package/dist/_astro/app-version.CLOjRiPN.js +0 -1
- package/dist/_astro/prompts-meta.C_MeYq8G.js +0 -2
- package/dist/_astro/req-analysis.Dbe_gqPz.js +0 -24
- package/dist/_astro/story-review.CNZnYMvW.js +0 -15
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var e=`/__tb_reqanalysis`,t=`需求分析提示词.md`,n=`需求分析`,r={draft:{label:`待拆解`,tone:`gray`},decomposed:{label:`已拆解`,tone:`blue`},checked:{label:`已审查`,tone:`amber`},accepted:{label:`已验收`,tone:`green`}},i={P0:`red`,P1:`amber`,P2:`gray`},a={"uncovered-outline":`待确认·未覆盖`,"pending-confirm":`待确认`,"missing-field":`字段缺失`,"missing-scenario":`场景遗漏`,"missing-dimension":`维度缺失`,"untestable-acceptance":`验收不可测`,conflict:`与原文冲突`,"over-split":`过度拆分`,other:`其它`},o=new Set([`uncovered-outline`,`pending-confirm`,`conflict`,`other`]);function s(e){return o.has(e.type)}function c(e){return e.filter(s)}var l={high:`高`,medium:`中`,low:`低`},u={high:`red`,medium:`amber`,low:`gray`},d=[{key:`permission`,label:`权限与角色`,keywords:[`权限`,`角色`,`授权`,`越权`,`未登录`,`登录`,`管理员`,`普通用户`],hint:`补充不同角色 / 未登录 / 越权访问时这条流程的行为。`},{key:`boundary`,label:`边界值`,keywords:[`边界`,`上限`,`下限`,`最大`,`最小`,`长度`,`超长`,`字数`,`为空`,`空值`],hint:`补充字段长度、数量上限、刚好等于阈值时的表现。`},{key:`concurrency`,label:`并发与幂等`,keywords:[`并发`,`重复`,`幂等`,`同时`,`加锁`,`冲突`,`重复提交`],hint:`补充重复提交、多人同时操作同一数据时的结果。`},{key:`empty`,label:`空数据`,keywords:[`空数据`,`无数据`,`没有数据`,`空列表`,`暂无`,`空态`],hint:`补充列表为空、首次使用、数据被清空时的空态。`},{key:`failure`,label:`超时与失败`,keywords:[`超时`,`失败`,`异常`,`错误`,`重试`,`断网`,`不可用`,`降级`,`回滚`],hint:`补充依赖超时、接口失败、网络中断时的提示与回滚。`},{key:`i18n`,label:`国际化与时区`,keywords:[`国际化`,`时区`,`多语言`,`语言`,`翻译`,`utc`,`夏令时`],hint:`补充跨时区时间展示、多语言文案与本地化格式。`}],f=/创建|新增|新建|保存|提交|删除|编辑|修改|更新|上传|导入|导出|发布|审批|撤回|绑定|解绑|发送|支付|下单|配置|启停|启用|停用/;async function p(t,n){let r=await fetch(`${e}${t}`,{...n,headers:n?.body===void 0?void 0:{"Content-Type":`application/json`,...n?.headers}}),i=await r.json().catch(()=>({}));if(!r.ok||i.ok===!1)throw Error(i.error||`HTTP ${r.status}`);return i}async function ee(){try{return(await fetch(`${e}?health=1`,{signal:AbortSignal.timeout(1500)})).ok}catch{return!1}}async function te(){return(await p(`/list`)).docs??[]}async function ne(e){return(await p(`/create`,{method:`POST`,body:JSON.stringify(e)})).doc}async function re(e,t){return(await p(`/`,{method:`PUT`,body:JSON.stringify({id:e,...t})})).doc}async function ie(e){await p(`/delete`,{method:`POST`,body:JSON.stringify({id:e})})}async function ae(){try{let e=await p(`/prompt`),t=e.decompose??``,n=e.stories??``;return{file:e.file||`需求分析提示词.md`,exists:e.exists===!0,decompose:t,stories:n||t,audit:e.audit??``,fix:e.fix??``}}catch(e){return{file:t,exists:!1,decompose:``,stories:``,audit:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function oe(e){return await p(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}async function se(e){return(await ue(e)).content}async function ce(e,t=2e4){try{let n=(await se(e)).trim();return{text:n.slice(0,t),total:n.length,truncated:n.length>t}}catch{return{text:``,total:0,truncated:!1}}}async function le(){return(await p(`/sources`)).files??[]}async function ue(e){return p(`/source?path=${encodeURIComponent(e)}`)}var de=/[\s\p{P}\p{S}]+/gu;function m(e){return String(e??``).toLowerCase().replace(de,``)}function h(e){return Array.from(new Set(e.map(e=>String(e??``).trim()).filter(Boolean)))}function g(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function _(e,t=30,n=500){return Array.isArray(e)?e.map(e=>g(e,n)).filter(Boolean).slice(0,t):[]}function v(e){let t=2166136261,n=String(e??``);for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,`0`)}function fe(e){return v(String(e??``))}function y(e,t=80){return String(e??``).replace(/\s+/g,` `).trim().slice(0,t)}function pe(e){let t=String(e.sourceTitle||e.sourcePath||``).trim();if(t){let e=t.split(/[/\\]/).pop()?.trim();if(e)return e}return String(e.title||``).trim()||`未命名文档`}function me(e){return y((String(e??``).split(/[/\\]/).pop()?.replace(/\.[^.]+$/,``).trim()||``).replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).trim())||`未命名需求`}function b(e){return String(e.sourceTitle||e.title||``).trim()||me(e.sourcePath)}function x(e){let t=String(e??``).split(/[/\\]/).pop()?.trim()||``;return t=t.replace(/\.(xlsx|xls|docx|doc|md|txt|csv)$/i,``),t.replace(/_?需求文档$/u,``).replace(/_?需求说明$/u,``).replace(/_?需求$/u,``).replace(/迭代版本$/u,``).replace(/版本$/u,``).trim()}function he(e){let t=x(e);return t=t.replace(/v?\d+(?:\.\d+)*/gi,``),t.replace(/[\s_\-—·()()[\]【】]+/gu,``).toLowerCase()}function S(e){let t=x(e),n=/v(\d+(?:\.\d+)*)/i.exec(t)||/(\d+(?:\.\d+)+)/.exec(t);return n?.[1]?n[1].split(`.`).map(e=>{let t=Number(e);return Number.isFinite(t)?t:0}):null}function C(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]??0,i=t[r]??0;if(n!==i)return n-i}return 0}function ge(e,t){let n=b(e),r=he(n),i=S(n);return!r||!i?[]:t.filter(t=>{if(t.id===e.id)return!1;let n=b(t);if(he(n)!==r)return!1;let a=S(n);return a?C(a,i)<0:!1}).sort((e,t)=>C(S(b(e))??[],S(b(t))??[]))}function _e(e){let t=[];for(let n of e){let e=b(n);for(let r of O(n.outline))t.push({docId:n.id,docLabel:e,point:r})}return t}function w(e){let t=String(e??``).toLowerCase().replace(/\s+/g,` `).trim();if(!t)return[];let n=[];for(let e of t.matchAll(/[a-z0-9_]{2,}|[\u4e00-\u9fff]{2}/gu))n.push(e[0]);let r=t.replace(/[^\u4e00-\u9fff]/g,``);for(let e=0;e<r.length-1;e++)n.push(r.slice(e,e+2));return[...new Set(n)].slice(0,80)}var ve=40,ye=7e3;function be(e,t,n){if(!t.length)return[];let r=Math.max(1,n?.maxItems??ve),i=Math.max(200,n?.maxChars??ye),a=w(e),o=String(e??``).toLowerCase();if(!a.length&&!o.trim())return[];let s=[];for(let e of t){let t=e.point.title||``,n=(e.point.quote||e.point.body||``).slice(0,200);`${t} ${n}`.toLowerCase();let r=0;t&&o.includes(t.toLowerCase())&&(r+=8),n&&n.length>=4&&o.includes(n.toLowerCase().slice(0,40))&&(r+=5);let i=w(`${t} ${n}`);for(let e of i)a.includes(e)&&(r+=e.length>=3?2:1);r<=0||s.push({...e,score:r})}s.sort((e,t)=>t.score-e.score||e.docLabel.localeCompare(t.docLabel,`zh`)||e.point.id.localeCompare(t.point.id));let c=[],l=0;for(let e of s){if(c.length>=r)break;let t=T(e);if(c.length>0&&l+t.length+1>i)break;c.push(e),l+=t.length+1}return c}function T(e){let t=e.point.kind===`query`?`查询`:e.point.kind===`mutate`?`修改`:`子点`,n=(e.point.quote||e.point.body||``).replace(/\s+/g,` `).trim().slice(0,120);return`- [${e.docLabel}] ${e.point.id} [${t}] ${e.point.title}${n?`(${n})`:``}`}function xe(e){return e.length?[`## 历史迭代需求条目(检索参考,勿当作本版文档条目 id)`,`来源版本:${[...new Set(e.map(e=>e.docLabel))].join(`、`)}。下列 id 属于历史分析,禁止写入本版 sourceRefs;仅作能力对照与延伸参考。`,...e.map(T)].join(`
|
|
2
|
-
`):``}function Se(e,t){if(!e?.length)return[];let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t);e&&O(e.outline).length&&r.push(e)}return r}function Ce(e){let t=String(e??``).trim();return t?!!(/^"+,{2,}/.test(t)||/^,{2,}/.test(t)&&/(待开发|已开发|需求\s*,\s*高|v\d+\.\d+)/.test(t)||!/【/.test(t)&&!/^\d+[、.]/.test(t)&&/,/.test(t)&&/(待开发|已关闭|已完成|需求\s*,\s*[高低中]|v\d+\.\d+|^\d{4}年\d{1,2}月)/.test(t)):!1}function we(e){let t=String(e??``),n=t.search(/"\s*,{2,}/);n>=0&&(t=t.slice(0,n));let r=t.split(`
|
|
3
|
-
`),i=[];for(let e of r){if(Ce(e))break;let t=e.search(/"\s*,{2,}/);if(t>=0){i.push(e.slice(0,t));break}i.push(e)}return i.join(`
|
|
4
|
-
`).replace(/^"/,``).replace(/"$/,``).trim()}function Te(e){let t=we(e.body).slice(0,4e3),n=y(t.match(/【([^】\n]{1,40})】/)?.[1]||e.title||e.small);return{...e,title:n||e.small,body:t||`【${n||e.small}】`}}function E(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function Ee(e){let t=[],n=[],r=``,i=!1,a=!0;for(let o=0;o<e.length;o+=1){let s=e[o];i?s===`"`?e[o+1]===`"`?(r+=`"`,o+=1):i=!1:r+=s:s===`"`&&a?(i=!0,a=!1):s===`,`?(n.push(r),r=``,a=!0):s===`
|
|
5
|
-
`?(n.push(r),t.push(n),n=[],r=``,a=!0):(r+=s,a=!1)}return n.push(r),(n.length>1||n[0]!==``)&&t.push(n),t}function De(e,t){let n=String(e??``).trim(),r=((n.startsWith(`【${t}】`)?n.slice(t.length+2).trim():n.replace(/^【[^】]{1,40}】/,``).trim()).split(`
|
|
6
|
-
`).find(e=>e.trim())??``).split(/[。;;::,,、\s]/)[0]?.trim()??``;return r.length>=2?y(r,14):``}function Oe(e){let t=new Set,n=new Map;return e.map(e=>{let r=e.title||e.small,i=E(r),a=(n.get(i)??0)+1;if(n.set(i,a),a===1&&!t.has(i))return t.add(i),e;let o=De(e.body,r),s=a,c=y(o?`${r} · ${o}`:`${r}(${s})`);for(;t.has(E(c));)s+=1,c=y(o?`${r} · ${o}(${s})`:`${r}(${s})`);return t.add(E(c)),{...e,title:c}})}function ke(e){let t=e=>/大模块/.test(e[0]??``)&&/小模块/.test(e[1]??``),n=Ee(e),r=n.findIndex(t);if(r>=0)return n.slice(r+1);let i=e.split(`
|
|
7
|
-
`).map(e=>e.trim().replace(/^\|/,``).replace(/\|$/,``).split(/\s*\|\s*/).map(e=>e.trim())).filter(e=>e.length>=2),a=i.findIndex(t);return a>=0?i.slice(a+1):[]}function D(e){let t=String(e??``).replace(/\r\n?/g,`
|
|
8
|
-
`).trim();if(!t)return[];let n=[];for(let e of t.split(/^(?=##\s+)/m)){let t=e.replace(/^##\s+.*\n?/,``);if(/大模块/.test(t)&&/小模块/.test(t))for(let e of ke(t)){let t=(e[0]??``).trim(),r=(e[1]??``).trim(),i=(e[2]??``).trim();r&&r!==`小模块`&&t!==`大模块`&&(/[。;;]/.test(r)||r.length>40||i&&n.push(Te({big:t,small:r,title:r,body:i})))}}return Oe(n)}function Ae(e){let t=D(e);if(t.length)return t.map(e=>({title:e.title||e.small,body:e.body||`【${e.title||e.small}】`,quote:(e.body||e.title||e.small).replace(/\s+/g,` `).slice(0,80)}));let n=String(e??``).replace(/\r\n/g,`
|
|
9
|
-
`).trim();if(!n)return[];let r=[],i=/^(概述|简介|目录|修订|附录|背景|术语|参考)/,a=[...n.matchAll(/^(#{2,3})\s+\S/gm)].map(e=>e[1].length).includes(3)?3:2,o=n.split(RegExp(`(?=^#{${a}}\\s+)`,`m`)).filter(e=>e.trim());if(o.length>1||RegExp(`^#{${a}}\\s+`,`m`).test(n)){for(let e of o){let t=e.match(RegExp(`^#{${a}}\\s+(.+?)\\s*$`,`m`));if(!t)continue;let n=y(t[1]??``);if(!n||n.length>40||i.test(n))continue;let o=e.replace(RegExp(`^#{${a}}\\s+.+?\\s*\\n?`),``).trim().slice(0,4e3);(o||!r.some(e=>e.title===n))&&r.push({title:n,body:o||n,quote:(o||n).replace(/\s+/g,` `).slice(0,80)})}if(r.length)return je(r)}return je(Z(e).map(e=>({title:e,body:e,quote:e.slice(0,80)})))}function je(e){let t=new Set,n=[];for(let r of e){let e=r.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``);e&&!t.has(e)&&(t.add(e),n.push(r))}return n}function Me(e,t=[]){let n=Ae(e);if(!n.length)return t.filter(e=>!e.kind);let r=new Map(t.filter(e=>!e.kind&&!e.parentId).map(e=>[e.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``),e])),i=new Set(t.map(e=>e.id)),a=[];n.forEach((e,t)=>{let n=e.title.toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``),o=r.get(n);if(o){a.push({...o,title:e.title,quote:e.quote||o.quote,body:e.body||o.body,kind:void 0,parentId:void 0});return}let s=`RO-E-${t+1}`,c=1;for(;i.has(s);)s=`RO-E-${t+1}-${c++}`;i.add(s),a.push({id:s,title:e.title,quote:e.quote,body:e.body})});let o=new Set(a.map(e=>e.id)),s=t.filter(e=>e.parentId&&o.has(e.parentId));return[...a,...s]}function O(e){let t=e.filter(e=>e.kind&&e.parentId);return t.length?t:e.filter(e=>!e.parentId)}function Ne(e,t){let n=new Set(t.flatMap(e=>e.sourceRefs));return O(e).filter(e=>!n.has(e.id))}function Pe(e,t=12){let n=Math.max(1,Math.floor(t)||12),r=O(e);if(!r.length)return[];let i=e.filter(e=>!e.parentId&&!e.kind),a=new Map(i.map(e=>[e.id,e])),o=new Map,s=[];for(let e of r){let t=e.parentId||``;if(t&&a.has(t)){let n=o.get(t)??[];n.push(e),o.set(t,n)}else s.push(e)}let c=[],l=(e,t)=>{for(let r=0;r<t.length;r+=n)c.push({parent:e,mustCover:t.slice(r,r+n)})};for(let e of i){let t=o.get(e.id);t?.length&&l(e,t)}return s.length&&l(null,s),c}function Fe(e,t){let n=String(e??``);if(!n)return 2**53-1;let r=K(t,n);return r>=0?r:2**53-1}function k(e,t){if(t.length<=1)return[...t];let n=e.body||e.quote||``;return[...t].map((e,t)=>({p:e,index:t,rank:Fe(n,e)})).sort((e,t)=>e.rank===t.rank?e.index-t.index:e.rank-t.rank).map(e=>e.p)}function A(e,t){return`${e}-${t}`}function j(e,t){return e.filter(e=>e.parentId===t)}function M(e,t,n){let r=new Map,i=n.map((e,n)=>{let i=A(t,n+1),a=e.id;a&&!a.startsWith(`__new_`)&&a!==i&&r.set(a,i);let o={id:i,title:e.title,quote:e.quote,kind:e.kind,parentId:t};return e.body&&(o.body=e.body),o}),a=e.filter(e=>e.parentId!==t),o=a.findIndex(e=>e.id===t);return{outline:o<0?[...a,...i]:[...a.slice(0,o+1),...i,...a.slice(o+1)],idMap:r}}function N(e,t){let n=j(e,t.id);if(!n.length)return{outline:[...e],idMap:new Map};let r=k(t,n);return M(e,t.id,r)}function Ie(e){let t=[...e],n=new Map,r=t.filter(e=>!e.parentId&&!e.kind);for(let e of r){let r=N(t,e);t=r.outline;for(let[e,t]of r.idMap)n.set(e,t)}return{outline:t,idMap:n}}function P(e,t){let n=e.find(e=>e.id===t);if(!n?.parentId||!n.kind)return{outline:[...e],pointId:t,idMap:new Map,parentId:``,error:`必须是已有的查询/修改子点`};let r=e.find(e=>e.id===n.parentId&&!e.parentId&&!e.kind);if(!r)return{outline:[...e],pointId:t,idMap:new Map,parentId:n.parentId,error:`找不到所属需求条目`};if(j(e,r.id).every(e=>e.id.startsWith(`${r.id}-`)))return{outline:[...e],pointId:t,idMap:new Map,parentId:r.id};let i=N(e,r),a=i.idMap.get(t)??t;return{outline:i.outline,pointId:a,idMap:i.idMap,parentId:r.id}}function F(e,t){let n=new Map;for(let[r,i]of e)n.set(r,t.get(i)??i);for(let[e,r]of t)n.has(e)||n.set(e,r);return n}function Le(e,t,n){let r=P(e,t);if(r.error)return{outline:[...e],idMap:new Map,addedIds:[],error:r.error.includes(`必须是`)?`afterId 必须是已有的查询/修改子点`:r.error};if(!n.length)return{outline:r.outline,idMap:r.idMap,addedIds:[]};let i=r.parentId,a=j(r.outline,i),o=a.findIndex(e=>e.id===r.pointId);if(o<0)return{outline:r.outline,idMap:r.idMap,addedIds:[],error:`找不到锚点子点`};let s=n.map((e,t)=>{let n={id:`__new_${t}`,title:e.title,quote:e.quote,kind:e.kind,parentId:i};return e.body&&(n.body=e.body),n}),c=[...a.slice(0,o+1),...s,...a.slice(o+1)],l=M(r.outline,i,c),u=n.map((e,t)=>A(i,o+2+t));return{outline:l.outline,idMap:F(r.idMap,l.idMap),addedIds:u}}function Re(e,t){let n=P(e,t);if(n.error)return{outline:[...e],idMap:new Map,removedId:t,removedIds:new Set([t]),error:n.error.includes(`必须是`)?`只能删除查询/修改子点`:n.error};let r=n.parentId,i=n.pointId,a=new Set([t,i]);for(let[e,t]of n.idMap)(t===i||e===i)&&a.add(e);let o=j(n.outline,r).filter(e=>e.id!==i),s=M(n.outline,r,o),c=new Map([...n.idMap].filter(([e,t])=>!a.has(e)&&!a.has(t)));return{outline:s.outline,idMap:F(c,s.idMap),removedId:i,removedIds:a}}function ze(e,t,n){let r=e.findIndex(e=>e.id===t);if(r<0)return{outline:[...e],error:`找不到需求点`};let i=e[r];if(!i.parentId||!i.kind)return{outline:[...e],error:`只能修改查询/修改子点的原文`};if(n.kind&&n.kind!==`query`&&n.kind!==`mutate`)return{outline:[...e],error:`kind 只能是 query 或 mutate`};let a=[...e],o={...i,quote:n.quote};return n.title!==void 0&&n.title.trim()&&(o.title=n.title.trim()),n.kind&&(o.kind=n.kind),n.body!==void 0&&(n.body?o.body=n.body:delete o.body),a[r]=o,{outline:a}}function Be(e,t,n=new Set){if(!t.size&&!n.size)return e;let r=e=>n.has(e)?null:t.get(e)??e,i=e=>h(e.map(r).filter(e=>!!e)),a=e.stories.map(e=>({...e,sourceRefs:i(e.sourceRefs)})),o=e=>{if(!e.outlineId)return e;let t=r(e.outlineId);return t===e.outlineId?e:t==null?{...e,outlineId:void 0}:{...e,outlineId:t}},s=e.check?{...e.check,gaps:e.check.gaps.map(o)}:e.check,c=e.ignoredGaps?.map(o);return{...e,stories:a,check:s,ignoredGaps:c}}function I(e,t=[]){let n=e.filter(e=>!e.parentId&&!e.kind),r=e.filter(e=>e.kind&&!e.parentId),i=new Set(t.flatMap(e=>e.sourceRefs)),a=new Map;for(let t of e){if(!t.parentId)continue;let e=a.get(t.parentId)??[];e.push(t),a.set(t.parentId,e)}let o=n.map(e=>{let n=a.get(e.id)??[],r=n.length>0&&n.every(t=>t.id.startsWith(`${e.id}-`))?n:k(e,n),o=r.length?r:[e],s=o.filter(e=>i.has(e.id)).length,c=t.filter(t=>t.sourceRefs.some(t=>t===e.id||r.some(e=>e.id===t)));return{parent:e,points:r,coveredCount:s,totalPoints:o.length,coveringStories:c}});if(r.length&&!n.length)for(let n of e)o.push({parent:n,points:n.kind?[n]:[],coveredCount:+!!i.has(n.id),totalPoints:1,coveringStories:t.filter(e=>e.sourceRefs.includes(n.id))});else r.length&&o.push({parent:{id:`__orphan__`,title:`其它需求点`,quote:``,body:``},points:r,coveredCount:r.filter(e=>i.has(e.id)).length,totalPoints:r.length,coveringStories:t.filter(e=>r.some(t=>e.sourceRefs.includes(t.id)))});return o}function L(e){let t=new Map,n=0;for(let r of I(e)){t.has(r.parent.id)||t.set(r.parent.id,n++);for(let e of r.points)t.has(e.id)||t.set(e.id,n++)}return t}var Ve=500,He=12e3;function Ue(e,t){if(!e.length)return`(无需求点)`;let n=Math.max(40,t?.excerptMax??Ve),r=Math.max(40,t?.blockMax??He),i=I(e);if(!i.length)return`(无需求点)`;let a=[];for(let e of i){let t=e.parent.id===`__orphan__`?`- ${e.parent.title}`:`- ${e.parent.id} ${e.parent.title}`;if(a.push({kind:`parent`,text:t,shrinkable:!1}),!e.points.length)a.push({kind:`empty`,text:` (尚无查/改子点)`,shrinkable:!1});else for(let t of e.points){let e=t.kind===`query`?`查询`:t.kind===`mutate`?`修改`:`子点`;a.push({kind:`point`,text:` - ${t.id} [${e}] ${t.title}`,shrinkable:!1});let r=(t.body||t.quote||``).replace(/\s+/g,` `).trim();if(r){let e=r.length>n?`${r.slice(0,n).trimEnd()}…`:r;a.push({kind:`excerpt`,text:` 原文:${e}`,shrinkable:!0})}}}let o=e=>e.map(e=>e.text).join(`
|
|
10
|
-
`),s=e=>e.length<=r?e:e.slice(0,r),c=o(a);if(c.length<=r)return c;let l=a.map(e=>({...e}));for(let e=0;e<3&&o(l).length>r;e++){let t=Math.max(40,Math.floor(n/(e+2)));for(let e=0;e<l.length;e++){let n=l[e];if(!n.shrinkable||n.kind!==`excerpt`)continue;let r=n.text.replace(/^ {4}原文:/,``);r.length<=t||(l[e]={...n,text:` 原文:${r.slice(0,t).trimEnd()}…`})}}return c=o(l),c.length<=r?c:s(o(l.filter(e=>!e.shrinkable)))}function R(e,t){if(e.length<=1)return[...e];let n=L(t),r=e=>{if(!e.sourceRefs.length)return 2**53-1;let t=2**53-1;for(let r of e.sourceRefs){let e=n.get(r);e!=null&&e<t&&(t=e)}return t};return[...e].map((e,t)=>({s:e,index:t,r:r(e)})).sort((e,t)=>e.r===t.r?e.index-t.index:e.r-t.r).map(e=>e.s)}function z(e){let t=new Map;for(let n of e){let e=n.kind===`query`?`查询`:n.kind===`mutate`?`修改`:``;t.set(n.id,e?`${n.title}(${e})`:n.title)}return t}function B(e){let t=z(e),n=new Map;for(let r of e){let e=t.get(r.id)||r.title;n.set(r.id,`${r.id} ${e}`.trim())}return n}function We(e,t){if(!e.length)return``;let n=B(t);return e.map(e=>n.get(e)||e).join(`;`)}var Ge=2e3,V=800;function H(e,t){let n=0;for(let r=0;r<e.length;r++)if(!/\s/.test(e[r])){if(n===t)return r;n+=1}return-1}function U(e,t,n){if(!n||n.length<4)return-1;let r=t.indexOf(n);return r<0||t.indexOf(n,r+n.length)>=0?-1:H(e,r)}function W(e,t){let n=String(e??``).trim(),r=String(t??``);if(!n||!r)return-1;let i=r.indexOf(n),a=n.replace(/\s+/g,``),o=r.replace(/\s+/g,``);if(i<0&&a&&(i=U(r,o,a)),i<0){let e=Math.min(4,a.length);for(let t of[64,48,32,24,16,12,8,4]){if(t<e)continue;let s=t<=8;if(n.length>=t){let e=n.slice(0,t),a=s?G(r,e):r.indexOf(e);if(a>=0){i=a;break}}let c=a.slice(0,Math.min(t,a.length));if(c.length<e)continue;let l=s?U(r,o,c):(()=>{let e=o.indexOf(c);return e>=0?H(r,e):-1})();if(l>=0){i=l;break}}}if(i<0){let e=/^(【[^】]{2,30}】)/u.exec(n);e&&n.slice(e[0].length).replace(/\s+/g,``).length<4&&(i=r.indexOf(e[1]))}if(i<0)return-1;let s=r.slice(Math.max(0,i-80),i),c=s.lastIndexOf(`
|
|
11
|
-
`);return c>=0&&(i-=s.length-c-1),i}function G(e,t){if(!t||t.length<4)return-1;let n=e.indexOf(t);return n<0||e.indexOf(t,n+t.length)>=0?-1:n}function Ke(e){let t=String(e??``).replace(/[((]?(查询|修改)[))]?$/u,``).replace(/^(政企通页面管理|政企通)/,``).trim();if(!t)return[];let n=[t,...t.split(/[与、及]/u).map(e=>e.trim()).filter(e=>e.length>=4)];t.length>12&&n.push(t.slice(-12));let r=new Set,i=[];for(let e of n)r.has(e)||e.length<4||(r.add(e),i.push(e));return i.sort((e,t)=>t.length-e.length),i}function K(e,t){let n=W(e.quote||e.body||``,t);if(n>=0)return n;for(let n of Ke(e.title??``)){let e=G(t,n);if(e>=0)return e}return-1}function q(e,t,n){let r=/^\d+[、.]/.test(e.slice(t,Math.min(e.length,t+24)).trimStart()),i=t;for(;i<n;){let t=e.indexOf(`
|
|
12
|
-
`,i);if(t<0||t>=n)return n;let a=t+1;for(;a<n&&(e[a]===`
|
|
13
|
-
`||e[a]===`\r`||e[a]===` `);)a+=1;if(a>=n)return t;let o=e.slice(a,Math.min(n,a+40));if(/^【|^#{2,3}\s|^-{3,}/.test(o)||r&&/^\d+[、.]/.test(o)||a>t+1&&!/^\d+[、.]/.test(o))return t;i=t+1}return n}function J(e,t,n){if(n<=t||n>=e.length)return!1;let r=e.slice(t,n),i=e.slice(n,Math.min(e.length,n+48)).trimStart();if(!/^\d+[、.]/.test(i)||/^\d+[、.]/.test(r.trimStart()))return!1;if(/\d+[、.]/.test(r))return!0;let a=r.trimEnd().split(/\n/).pop()?.trim()??``;return/下面分|如下|包括|分别为|计有|默认字段/u.test(a)||/[::))]\s*$/u.test(a)}function qe(e,t,n=Ge,r){let i=String(t??``),a=W(e,i);if(a<0)return``;let o=Math.min(i.length,a+n),s=r?.endBefore!=null&&r.endBefore>a?r.endBefore:void 0;if(s!=null&&!J(i,a,s)){let e=q(i,a,Math.min(o,s));return i.slice(a,Math.min(o,s,e)).trim()}let c=q(i,a,o);return i.slice(a,Math.max(c,a+1)).trim()}function Y(e,t,n){let r=Math.min(e.length,t+V),i=n==null?r:Math.min(r,n);return i=n!=null&&J(e,t,n)?q(e,t,r):q(e,t,i),e.slice(t,i).trim()}function Je(e,t,n,r,i){if(!e||i<0||!r.length)return e;let a=r.filter(e=>e.id!==t.id&&e.start>i).sort((e,t)=>e.start-t.start)[0]?.id;if(!a)return e;let o=n.find(e=>e.id===a);if(!o)return e;let s=[(o.quote||``).trim(),(o.body||``).trim().split(/\n/)[0]?.trim()||``].filter(e=>e.length>=4);for(let t of s){let n=e.indexOf(t);if(n>0)return e.slice(0,n).trim();let r=t.split(/\n/)[0]?.trim()||``;if(r.length>=4&&r!==t){let t=e.indexOf(r);if(t>0)return e.slice(0,t).trim()}}return e}function Ye(e,t,n){let r=(e.body||``).trim(),i=(e.quote||``).trim(),a=(t?.body||t?.quote||``).trim();if(!a)return{text:r||i||`(无原文切片)`,fromParent:!1};let o=n&&n.length?k(t??{id:``,title:``,quote:``},n):[],s=o.map(e=>({id:e.id,start:K(e,a)})),c=i?W(i,a):-1,l=r?W(r,a):-1,u=c>=0?c:l>=0?l:K(e,a),d;if(u>=0&&s.length){let t=s.filter(t=>t.id!==e.id&&t.start>u).sort((e,t)=>e.start-t.start);t[0]&&(d=t[0].start)}let f=u>=0&&s.some(t=>t.id!==e.id&&t.start===u);if(r)return{text:o.length?Je(r,e,o,s,u):r,fromParent:!1};if(o.length&&u>=0&&!f&&d!=null){let e=Y(a,u,d);if(e)return{text:e,fromParent:!1}}if(i){if(f)return{text:i,fromParent:!1};if(i.length<400||i.length<a.length*.35){let e=qe(i,a,V,{endBefore:d});if(e&&(e.length>i.length||d!=null))return{text:e,fromParent:!1}}return{text:i,fromParent:!1}}if(u>=0&&!f){let e=Y(a,u,d);if(e)return{text:e,fromParent:!1}}return{text:`(未定位到该需求点对应原文)`,fromParent:!1}}function Xe(e){let t=m(e.title??``);return`${e.type}|${e.storyId||``}|${e.outlineId||``}|${t}`}function X(e,t){if(Xe(e)===Xe(t))return!0;if(e.type!==t.type||(e.storyId||``)!==(t.storyId||``))return!1;let n=m(e.title??``),r=m(t.title??``);if(!n||!r)return!1;if(n===r)return!0;let i=n.length<=r.length?n:r,a=n.length<=r.length?r:n;return i.length>=8&&a.includes(i)}function Ze(e,t){return t?.length?e.filter(e=>!t.some(t=>X(e,t))):[...e]}function Qe(e,t,n,r){let i=r?.allowNew!==!1,a=Ze(t,n),o=new Set,s=[],c=0,l=e=>i?!0:e.type===`uncovered-outline`;for(let t of a){let n=e.length?e.find(e=>e.id===t.id&&!o.has(e.id))||e.find(e=>!o.has(e.id)&&X(e,t)):void 0;if(n)o.add(n.id),s.push({...t,id:n.id,title:n.title,selected:n.selected||t.selected,conclusion:t.conclusion?.trim()||n.conclusion});else{if(!l(t)){c+=1;continue}s.push({...t})}}if(!i)for(let t of e)o.has(t.id)||t.type!==`uncovered-outline`&&(n?.some(e=>X(t,e))||s.push({...t}));return{gaps:s,suppressed:c}}function $e(e){let t=e.pending??[],n=e.ignored??[];if(!t.length&&!n.length)return``;let r=[];if(t.length){r.push(`## 上轮待确认(复审底稿:只更新/收敛,禁止新开条;问题仍在则沿用原 title)`);for(let e of t)r.push(`- id=${e.id} type=${e.type} storyId=${e.storyId||`-`} outlineId=${e.outlineId||`-`}`),r.push(` title: ${e.title}`),e.detail?.trim()&&r.push(` detail: ${e.detail.trim()}`),e.conclusion?.trim()&&r.push(` conclusion: ${e.conclusion.trim()}(已有结论待补写,勿另开一条)`);r.push(``)}if(n.length){r.push(`## 已忽略(禁止再报同类,不要求标题字面一致)`);for(let e of n)r.push(`- type=${e.type} storyId=${e.storyId||`-`} outlineId=${e.outlineId||`-`} title: ${e.title}`)}return r.join(`
|
|
14
|
-
`).trim()}function et(e){let t=[];return e.role||t.push({key:`role`,label:`缺角色`}),e.goal||t.push({key:`goal`,label:`缺目标`}),e.preconditions.length||t.push({key:`preconditions`,label:`缺前置条件`}),e.mainFlow.length||t.push({key:`mainFlow`,label:`缺主流程`}),e.sourceRefs.length||t.push({key:`sourceRefs`,label:`未挂需求点`}),e.exceptions.length?gt(e)&&e.exceptions.length<2&&t.push({key:`write-exceptions`,label:`写操作异常不足`}):t.push({key:`exceptions`,label:`缺异常场景`}),!e.altFlows.length&>(e)&&t.push({key:`altFlows`,label:`缺替代流程`}),e.acceptance.length?e.acceptance.some(e=>!e.then)&&t.push({key:`acceptance-then`,label:`验收缺 then`}):t.push({key:`acceptance`,label:`缺验收标准`}),t}function tt(e){let t=new Set,n=[];for(let r of D(e)){let e=E(r.small);e&&!t.has(e)&&(t.add(e),n.push(r.small))}return n}function nt(e){let t=D(e);if(!t.length)return``;let n=e=>/[,"\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,r=[`Ideal 小模块行序(用例「子模块 / 小模块」填下列原文:层级路径取最后一段;最终文件按「需求条目 → 条目内测试点」排序,此序只做兜底):`,`大模块,小模块,优化/问题内容`],i=new Set;for(let e of t){let t=E(e.small);t&&!i.has(t)&&(i.add(t),r.push(`${n(e.big)},${n(e.small)},【${e.title}】`))}return r.join(`
|
|
15
|
-
`)}var rt=`需求章节顺序`;function it(e){let t=String(e??``).replace(/\r\n/g,`
|
|
16
|
-
`).trim();if(!t)return[];let n=[],r=new Set,i=/^(概述|简介|目录|修订|附录|背景|术语|参考)/;for(let e of t.matchAll(/^#{2,3}\s+(.+?)\s*$/gm)){let t=y(e[1]??``);!t||t.length>40||i.test(t)||r.has(t)||(r.add(t),n.push(t))}return n}function at(e){let t=String(e??``).replace(/\r\n/g,`
|
|
17
|
-
`),n=t.indexOf(rt);if(n<0)return[];let r=t.slice(n,n+4e3),i=[],a=new Set;for(let e of r.matchAll(/^\s*\d+[.)、]\s*(.+?)\s*$/gm)){let t=y(e[1]??``);!t||t.length>40||a.has(t)||(a.add(t),i.push(t))}return i}function Z(e){let t=tt(e);if(t.length)return t;let n=at(e);if(n.length)return n;let r=st(e);return r.length?r:it(e)}function ot(e){let t=nt(e);if(t)return t;let n=Z(e);return n.length<2?``:[`${rt}(用例「模块 / 子模块 / 标题」应对齐下列原文;最终文件按此序排列,优先于用户故事 US 编号):`,...n.map((e,t)=>`${t+1}. ${e}`)].join(`
|
|
18
|
-
`)}function st(e){let t=D(e);if(t.length)return t.map(e=>e.title);let n=String(e??``).replace(/\r\n/g,`
|
|
19
|
-
`).trim(),r=[],i=new Set;for(let e of n.matchAll(/【([^】\n]{1,40})】/g)){let t=y(e[1]??``);!t||t.length>24||i.has(t)||(i.add(t),r.push(t))}return r}function ct(e,t,n){return`g_${v(`${e}|${t}|${n}`)}`}function lt(e){let t=e&&typeof e==`object`?e:{},n=g(t.priority,4);return{id:g(t.id,20),title:g(t.title,200),role:g(t.role,120),goal:g(t.goal,500),value:g(t.value,500),sourceRefs:_(t.sourceRefs,20,40),priority:n===`P0`||n===`P1`||n===`P2`?n:`P1`,preconditions:_(t.preconditions),mainFlow:(Array.isArray(t.mainFlow)?t.mainFlow:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{actor:g(t.actor,80),action:g(t.action,500),result:g(t.result,500)}}).filter(e=>e.action).slice(0,40),altFlows:(Array.isArray(t.altFlows)?t.altFlows:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{name:g(t.name,120)||`替代流程`,trigger:g(t.trigger,500),steps:_(t.steps,20)}}).slice(0,20),exceptions:(Array.isArray(t.exceptions)?t.exceptions:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{scenario:g(t.scenario,500),expected:g(t.expected,500)}}).filter(e=>e.scenario).slice(0,30),postconditions:_(t.postconditions),acceptance:(Array.isArray(t.acceptance)?t.acceptance:[]).map(e=>{let t=e&&typeof e==`object`?e:{};return{given:g(t.given,500),when:g(t.when,500),then:g(t.then,500)}}).filter(e=>e.given||e.when||e.then).slice(0,30),dimensions:_(t.dimensions,12,40)}}function ut(e){return{...e,sourceRefs:[...e.sourceRefs],preconditions:[...e.preconditions],mainFlow:e.mainFlow.map(e=>({...e})),altFlows:e.altFlows.map(e=>({...e,steps:[...e.steps]})),exceptions:e.exceptions.map(e=>({...e})),postconditions:[...e.postconditions],acceptance:e.acceptance.map(e=>({...e})),dimensions:[...e.dimensions]}}function Q(e){let t=e.mainFlow?.[0];return`${m(e.title)}|${t?m(`${t.action}${t.result??``}`):``}`}function dt(e,t){let n=e.map(ut),r=new Map(n.filter(e=>e.id).map(e=>[e.id,e])),i=new Map(n.map(e=>[Q(e),e]));for(let e of t){let t=lt(e);if(!t.title)continue;let a=t.id&&r.get(t.id)||i.get(Q(t));if(a)!a.role&&t.role&&(a.role=t.role),!a.goal&&t.goal&&(a.goal=t.goal),!a.value&&t.value&&(a.value=t.value),a.sourceRefs=h([...a.sourceRefs,...t.sourceRefs]),a.dimensions=h([...a.dimensions,...t.dimensions]),a.preconditions.length||(a.preconditions=[...t.preconditions]),a.mainFlow.length||(a.mainFlow=t.mainFlow.map(e=>({...e}))),a.altFlows.length||(a.altFlows=t.altFlows.map(e=>({...e}))),a.exceptions.length||(a.exceptions=t.exceptions.map(e=>({...e}))),a.postconditions.length||(a.postconditions=[...t.postconditions]),a.acceptance.length||(a.acceptance=t.acceptance.map(e=>({...e}))),t.priority===`P0`&&a.priority!==`P0`?a.priority=`P0`:t.priority===`P1`&&a.priority===`P2`&&(a.priority=`P1`);else{let e={...t,id:``};n.push(e),i.set(Q(e),e)}}return n}function ft(e,t){let n=m(e),r=m(t);if(!n||!r)return 0;if(n===r)return 1e3;if(n.includes(r)||r.includes(n))return 800+Math.min(n.length,r.length);let i=n.length<=r.length?n:r,a=n.length<=r.length?r:n,o=0;for(let e=0;e<i.length-1;e++)a.includes(i.slice(e,e+2))&&(o+=1);let s=Math.max(1,i.length-1);return o+Math.round(o/s*10)}var pt=4;function mt(e,t){let n=e.map(ut);if(!t.length)return{stories:n,filled:0};let r=new Set(t.filter(e=>e.parentId).map(e=>e.parentId)),i=[...t.filter(e=>e.kind===`query`||e.kind===`mutate`),...t.filter(e=>!e.kind&&!e.parentId&&!r.has(e.id))];if(!i.length)return{stories:n,filled:0};let a=new Set(n.flatMap(e=>e.sourceRefs).filter(e=>i.some(t=>t.id===e))),o=0;for(let e of n){if(e.sourceRefs.length)continue;let t=null,n=0;for(let r of i){if(a.has(r.id))continue;let i=ft(e.title,r.title);i>n&&(n=i,t=r)}!t||n<pt||(e.sourceRefs=[t.id],a.add(t.id),o+=1)}return{stories:n,filled:o}}function ht(e){return[e.title,e.role,e.goal,e.value,...e.dimensions,...e.preconditions,...e.postconditions,...e.mainFlow.map(e=>`${e.actor??``} ${e.action} ${e.result??``}`),...e.altFlows.map(e=>`${e.name} ${e.trigger} ${e.steps.join(` `)}`),...e.exceptions.map(e=>`${e.scenario} ${e.expected}`),...e.acceptance.map(e=>`${e.given} ${e.when} ${e.then}`)].join(` `)}function gt(e){return e.mainFlow.some(e=>f.test(e.action))}function _t(e,t,n,r,i,a,o=``){return{id:ct(e,t||o,n),storyId:t,outlineId:o||void 0,type:e,severity:a,title:n,detail:r,suggestion:i,origin:`rule`,selected:!1}}var vt=new Set([`缺少角色`,`缺少目标`,`缺少前置条件`,`缺少主流程`,`没有异常场景`,`写操作缺少异常分支`,`缺少验收标准`,`验收标准缺 then`,`没有关联需求条目`,`只写了主流程`]);function yt(e){let t=e.outline??[],n=e.stories??[],r=[],i=O(t),a=new Set(n.flatMap(e=>e.sourceRefs));for(let e of i){if(a.has(e.id))continue;let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``,n=t?`${e.title}(${t})`:e.title;r.push(_t(`uncovered-outline`,``,`${n}:还没有用户故事挂上`,`需求点「${n}」在文档里有,但目前没有任何故事引用它。可能是漏拆了,也可能这块其实不用测。`,`跟业务确认要不要覆盖:要的话补一条故事(或在已有故事里挂上这个点);不要的话直接忽略。`,`high`,e.id))}let o=d.map(e=>{let t=n.filter(t=>{let n=ht(t).toLowerCase();return e.keywords.some(e=>n.includes(e.toLowerCase()))}).map(e=>e.id);return{key:e.key,label:e.label,covered:t.length>0,stories:t}}),s=i.filter(e=>a.has(e.id)).length,c={total:i.length,covered:s,rate:i.length?s/i.length:0};return{at:new Date().toISOString(),summary:`规则检查:${n.length} 个故事、${i.length} 个需求点,覆盖率 ${i.length?Math.round(c.rate*100):0}%,${r.length} 项待确认未覆盖。`,coverage:c,dimensions:o,gaps:r}}function bt(e,t){let n=e.map(e=>({...e})),r=new Map(n.map(e=>[`${e.storyId}|${e.type}`,e])),i=new Set(n.map(e=>e.id));for(let e of t){if(i.has(e.id))continue;let t=`${e.storyId}|${e.type}`,a=r.get(t);a?vt.has(a.title)?(a.title=e.title,a.detail=[a.detail,e.detail].filter(Boolean).join(` / `),a.suggestion=e.suggestion||a.suggestion,a.severity=e.severity):m(a.title)!==m(e.title)&&(n.push({...e}),i.add(e.id)):(n.push({...e}),r.set(t,e),i.add(e.id))}return n}function xt(e,t){let n=[],r=``;for(let i of e.split(/\n{2,}/)){let e=r?`${r}\n\n${i}`:i;if(e.length<=t)r=e;else if(r&&n.push(r),i.length<=t)r=i;else{for(let e=0;e<i.length;e+=t)n.push(i.slice(e,e+t));r=``}}return r&&n.push(r),n}function St(e,t=12e3){let n=String(e??``).replace(/\r\n/g,`
|
|
20
|
-
`).trim();if(!n)return[];let r=Math.max(2e3,Math.floor(t));if(n.length<=r)return[{index:0,title:``,text:n}];let i=[],a=``,o=[],s=()=>{let e=o.join(`
|
|
21
|
-
`).trim();e&&i.push({title:a,text:e}),o=[]};for(let e of n.split(`
|
|
22
|
-
`)){let t=/^#{2,6}\s+(.+?)\s*$/.exec(e);t&&(s(),a=t[1]),o.push(e)}if(s(),!i.length)return[{index:0,title:``,text:n}];let c=[],l=``,u=``,d=()=>{let e=l.trim();if(e){for(let t of e.length>r?xt(e,r):[e])c.push({index:c.length,title:u,text:t});l=``}};for(let e of i){let t=l?`${l}\n\n${e.text}`:e.text;t.length<=r?(l||(u=e.title),l=t):(d(),u=e.title,l=e.text,l.length>r&&d())}return d(),c.length?c:[{index:0,title:``,text:n}]}function $(e,t){return t?`- **${e}**:${t}`:``}function Ct(e){return e.filter(Boolean).map(e=>`- ${e}`)}function wt(e,t=[]){let n=[];n.push(`### ${e.id} ${e.title}`),n.push(``);let r=t.length?We(e.sourceRefs,t):e.sourceRefs.join(`、`),i=[$(`角色`,e.role),$(`目标`,e.goal),$(`价值`,e.value),$(`优先级`,e.priority),$(`来源条目`,r)].filter(Boolean);if(n.push(...i),i.length&&n.push(``),e.preconditions.length&&(n.push(`**前置条件**`),n.push(...Ct(e.preconditions)),n.push(``)),e.mainFlow.length&&(n.push(`**主流程**`),e.mainFlow.forEach((e,t)=>{let r=e.actor?`${e.actor}:`:``;n.push(`${t+1}. ${r}${e.action}${e.result?` → ${e.result}`:``}`)}),n.push(``)),e.altFlows.length){n.push(`**替代流程**`);for(let t of e.altFlows)n.push(`- **${t.name}**${t.trigger?`(触发:${t.trigger})`:``}`),t.steps.forEach((e,t)=>n.push(` ${t+1}. ${e}`));n.push(``)}if(e.exceptions.length){n.push(`**异常场景**`);for(let t of e.exceptions)n.push(`- ${t.scenario}${t.expected?` → ${t.expected}`:``}`);n.push(``)}if(e.postconditions.length&&(n.push(`**后置条件**`),n.push(...Ct(e.postconditions)),n.push(``)),e.acceptance.length){n.push(`**验收标准**`);for(let t of e.acceptance)n.push(`- Given ${t.given||`(未写)`};When ${t.when||`(未写)`};Then ${t.then||`(未写)`}`);n.push(``)}return e.dimensions.length&&(n.push(`**覆盖维度**:${e.dimensions.join(`、`)}`),n.push(``)),n[n.length-1]!==``&&n.push(``),n}function Tt(e,t){let n=new Set((t??[]).filter(Boolean)),i=n.size?e.stories.filter(e=>n.has(e.id)):e.stories,a=[];if(a.push(`# ${e.title||`需求分析`} · 用户故事`),a.push(``),a.push(`> 来源需求文档:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),a.push(``),e.outline.length){a.push(`## 需求条目`),a.push(``),a.push(`> 「引用需求点」请填下列真实 RO id,格式「RO-id 标题」;不要填 US-…。`),a.push(``);for(let t of I(e.outline,i)){if(a.push(`### ${t.parent.id} ${t.parent.title}`),t.parent.quote||t.parent.body){let e=(t.parent.quote||t.parent.body||``).replace(/\s+/g,` `).slice(0,200);a.push(`> ${e}`)}if(t.points.length)for(let e of t.points){let t=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``;a.push(`- **${e.id}** ${e.title}${t?`(${t})`:``}`),e.quote&&a.push(` > ${e.quote.replace(/\n+/g,` `)}`)}a.push(``)}}a.push(`## 用户故事`),a.push(``),i.length||(a.push(`- (暂无)`),a.push(``));let o=R(i,e.outline);for(let t of o)a.push(...wt(t,e.outline));return a.join(`
|
|
23
|
-
`)}function Et(e){let t=[];t.push(`# ${e.title||`需求分析`}`),t.push(``),t.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 状态:${r[e.status].label} · 更新:${e.updatedAt}`),t.push(``),t.push(`## 需求条目`),t.push(``),e.outline.length||t.push(`- (暂无)`);for(let n of I(e.outline,e.stories)){t.push(`- **${n.parent.id}** ${n.parent.title}`),n.parent.quote&&t.push(` > ${n.parent.quote.replace(/\n+/g,` `)}`);for(let e of n.points){let n=e.kind===`query`?`查询`:e.kind===`mutate`?`修改`:``;t.push(` - **${e.id}** ${e.title}${n?`(${n})`:``}`),e.quote&&t.push(` > ${e.quote.replace(/\n+/g,` `)}`)}}t.push(``),t.push(`## 用户故事`),t.push(``),e.stories.length||t.push(`- (暂无)`);for(let n of R(e.stories,e.outline))t.push(...wt(n,e.outline));if(t.push(`## 审查摘要`),t.push(``),!e.check)t.push(`- 还没有跑过审查。`);else{let n=e.check.coverage.total?Math.round(e.check.coverage.rate*100):0;t.push(`- 覆盖率:${e.check.coverage.covered}/${e.check.coverage.total}(${n}%)`),t.push(`- 维度覆盖:${e.check.dimensions.map(e=>`${e.label}${e.covered?` ✓`:` ✗`}`).join(` · `)||`(无)`}`),e.check.summary&&(t.push(``),t.push(e.check.summary)),t.push(``),t.push(`### 缺口清单`),t.push(``),e.check.gaps.length||t.push(`- 没有发现缺口。`);let r=[...e.check.gaps].sort((e,t)=>{let n={high:0,medium:1,low:2};return n[e.severity]-n[t.severity]});for(let e of r){let n=e.storyId?`${e.storyId} `:``;t.push(`- **[${l[e.severity]}] ${a[e.type]}** · ${n}${e.title}`),e.detail&&t.push(` - 原因:${e.detail}`),e.suggestion&&t.push(` - 建议:${e.suggestion}`)}}return t.push(``),t.join(`
|
|
24
|
-
`)}function Dt(e){return`${(e.title||e.sourcePath.split(`/`).pop()||`需求分析`).replace(/\.(md|markdown|txt)$/i,``).replace(/[\\/:*?"<>|]/g,` `).trim()||`需求分析`}-用户故事.md`}export{et as $,le as A,ce as B,xe as C,Le as D,I as E,L as F,pe as G,Be as H,B as I,Me as J,Se as K,Ye as L,dt as M,Ie as N,ge as O,O as P,Tt as Q,z as R,Ue as S,ct as T,Re as U,Qe as V,b as W,fe as X,R as Y,St as Z,ae as _,t as a,c as b,yt as c,ne as d,oe as et,ie as f,ee as g,Z as h,n as i,re as it,bt as j,te as k,Pe as l,st as m,u as n,Ne as nt,i as o,Dt as p,be as q,a as r,ze as rt,r as s,l as t,Et as tt,_e as u,mt as v,ot as w,$e as x,Ze as y,se as z};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/jszip.min.Bh2Mgo40.js","_astro/react.Blvh0GOs.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e}from"./react.Blvh0GOs.js";import{G as t,r as n,s as r,t as i}from"./req-analysis.Dbe_gqPz.js";import{b as a}from"./settings.Cu00if4D.js";import{t as o}from"./app-version.CLOjRiPN.js";function s(e){return t(e)}var c=`/__tb_testpoints`,l=`测试点生成提示词.md`,u=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`],d=[`P0`,`P1`,`P2`,`P3`],f={functional:{label:`功能`,hint:`主流程 / 替代流程 / 每个功能点`,tone:`blue`,accent:`bg-[#3370ff]`},boundary:{label:`边界值`,hint:`为空 / 上下限 / 刚好越界`,tone:`purple`,accent:`bg-[#7b5bd6]`},exception:{label:`异常`,hint:`失败路径 / 非法输入 / 并发`,tone:`red`,accent:`bg-[#e5484d]`},business:{label:`业务规则`,hint:`状态流转 / 权限 / 唯一性`,tone:`amber`,accent:`bg-[#d9820b]`},nonfunctional:{label:`非功能`,hint:`性能 / 安全 / 兼容 / 时区`,tone:`green`,accent:`bg-[#2f9e44]`}},p={P0:{label:`P0`,tone:`red`,markerId:`priority-1`},P1:{label:`P1`,tone:`amber`,markerId:`priority-2`},P2:{label:`P2`,tone:`blue`,markerId:`priority-3`},P3:{label:`P3`,tone:`gray`,markerId:`priority-4`}},m=Object.fromEntries(u.map(e=>[e,f[e].label]));async function h(e,t){let n=await fetch(`${c}${e}`,{...t,headers:t?.body===void 0?void 0:{"Content-Type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function g(){try{let e=await h(`/prompt`);return{file:l,exists:e.exists===!0,generate:e.generate??``}}catch(e){return{file:l,exists:!1,generate:``,error:e instanceof Error?e.message:String(e)}}}async function _(e){return h(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}var v={P0:0,P1:1,P2:2,P3:3};function y(e){let t=e?.points??[],n={P0:0,P1:0,P2:0,P3:0};for(let e of t)e.priority in n&&(n[e.priority]+=1);return{total:t.length,byPriority:n,coveredDimensions:u.filter(e=>t.some(t=>t.dimension===e)).length}}function b(e){return[...e].sort((e,t)=>Number(!!e.supplemental)-Number(!!t.supplemental)||u.indexOf(e.dimension)-u.indexOf(t.dimension)||v[e.priority]-v[t.priority]||e.title.localeCompare(t.title,`zh`))}function x(e,t=[]){if(!e.length)return``;let n=S(e,t),r=[],i=`\0`;for(let e of n){let t=e.storyId||``;t!==i&&(i=t,r.push(t?`#### ${t}`:`#### 全局测试点`)),r.push(`- **[${e.priority}]** ${e.title}(${e.id})`),e.storyId&&r.push(` - 来源故事:${e.storyId}`),r.push(` - 维度:${f[e.dimension].label}`),e.precondition&&r.push(` - 前置:${e.precondition}`),e.steps.length&&r.push(` - 步骤:${e.steps.join(`;`)}`),e.expected&&r.push(` - 预期:${e.expected}`)}return r.join(`
|
|
3
|
-
`)}function S(e,t=[]){if(!e.length)return[];if(!t.length)return[...e];let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({point:e,index:t})).sort((e,r)=>(e.point.storyId?n.get(e.point.storyId)??t.length+1:t.length)-(r.point.storyId?n.get(r.point.storyId)??t.length+1:t.length)||e.index-r.index).map(e=>e.point)}function C(e){return(e||`需求分析`).replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}function w(e){let t=[];return e.precondition&&t.push(`前置条件:${e.precondition}`),e.steps.length&&(t.push(`步骤:`),e.steps.forEach((e,n)=>t.push(`${n+1}. ${e}`))),e.expected&&t.push(`预期:${e.expected}`),t.join(`
|
|
4
|
-
`)}function T(e,t){let n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);let r=(n>>>0).toString(36),i=t.replace(/[^A-Za-z0-9_-]/g,``).slice(0,24);return i?`${e}-${i}-${r}`:`${e}-${r}`}function E(e){return{id:T(`tp`,e.id),title:`[${e.priority}] ${e.title}`,labels:[f[e.dimension].label],markers:[{markerId:p[e.priority].markerId}],notes:{plain:{content:w(e)}}}}var D=[{re:/ai\s*拆解|推送ai|回写拆解/i,title:`ai拆解`},{re:/ai自动同步|知识信息列表.*开关|知识信息管理/i,title:`知识信息管理`},{re:/信息审核|审核倒计时|出具审核结论|待审核信息/i,title:`政企通信息审核`},{re:/信息确认|确认无误|待确认信息/i,title:`政企通信息确认`},{re:/开通确认|确认开通/i,title:`政企通开通确认`},{re:/信息管理列表|承办单位修改|查看详情|政企通路径|关联信息标题/i,title:`政企通信息管理`},{re:/页面管理|页面树|节点|前台预览|本级节点布局|暂存|发给承办|信息列表|展示类型/i,title:`政企通页面管理`},{re:/菜单|子菜单|文案本地化|时间展示/i,title:`政企通`}];function O(e,t){return t.find(t=>t===e)||t.find(t=>e.length>=t.length&&e.includes(t))||t.find(t=>t.length>e.length&&t.includes(e))||null}function k(e,t,n){if(!n.length)return e.title||e.id;let r=e.title||``,i=`${r} ${e.sourceRefs.map(e=>t.get(e)||e).join(` `)}`,a=[...n].sort((e,t)=>t.length-e.length||e.localeCompare(t,`zh`));for(let e of D){if(!e.re.test(i))continue;let t=O(e.title,a);if(t)return t}for(let e of a)if(e&&r.includes(e))return e;for(let e of a)if(e&&i.includes(e))return e;for(let e of a){let t=e.split(` · `)[0]?.trim()??``;if(t&&r.includes(t))return e}for(let e of a){let t=e.split(` · `)[0]?.trim()??``;if(t&&i.includes(t))return e}return e.title||e.id}function A(e){let t=b(e);return u.map(e=>({key:e,label:f[e].label,hint:f[e].hint,points:t.filter(t=>t.dimension===e)}))}function j(e,t=[]){let n=e.testPoints?.points??[];if(!n.length)return[];let r=new Map(e.outline.map(e=>[e.id,e.title])),i=new Map(e.stories.map(e=>[e.id,e])),a=t.filter(Boolean),o=new Map,s=e=>{let t=o.get(e);return t||(t={title:e,storyIds:new Set,points:[]},o.set(e,t)),t};for(let e of a)s(e);for(let e of n){let t=e.storyId?i.get(e.storyId):void 0,n;n=t&&a.length?k(t,r,a):t?t.title||t.id:`全局测试点`;let o=s(n);o.points.push(e),e.storyId&&o.storyIds.add(e.storyId)}let c=[...a,...[...o.keys()].filter(e=>!a.includes(e)&&e!==`全局测试点`),...o.has(`全局测试点`)?[`全局测试点`]:[]],l=new Set,u=[];for(let e of c){if(l.has(e))continue;l.add(e);let t=o.get(e);t&&(t.points.length||a.includes(e))&&u.push({key:e,title:e,storyIds:[...t.storyIds],points:b(t.points),dimensions:A(t.points)})}return u}var M=`org.xmind.ui.logic.right`;function N(e,t){return t.map(t=>({id:T(`dim`,`${e}:${t.key}`),title:`${t.label}(${t.points.length})`,notes:{plain:{content:`${f[t.key].hint}\n测试点 ${t.points.length} 条`}},children:{attached:t.points.map(E)}}))}function P(e){return{id:T(`req`,e.key),title:`${e.title}(${e.points.length})`,notes:{plain:{content:[e.storyIds.length?`来源故事:${e.storyIds.join(`、`)}`:``,`测试点 ${e.points.length} 条`].filter(Boolean).join(`
|
|
5
|
-
`)}},children:{attached:N(e.key,e.dimensions)}}}function F(e,t=[]){let n=e.testPoints,r=j(e,t).filter(e=>e.points.length>0),i=s(e);if(!r.length)return[{id:`sheet-1`,class:`sheet`,title:i,rootTopic:{id:`root-topic`,title:`${i}(0)`,structureClass:M,notes:{plain:{content:n?.summary||`还没有测试点。`}},children:{attached:u.map(e=>({id:T(`dim`,e),title:`${f[e].label}(0)`,notes:{plain:{content:`${f[e].hint}\n测试点 0 条`}},children:{attached:[]}}))}}}];if(r.length===1){let e=r[0];return[{id:`sheet-1`,class:`sheet`,title:e.title,rootTopic:{id:T(`root`,e.key),title:`${e.title}(${e.points.length})`,structureClass:M,notes:{plain:{content:[n?.summary||``,e.storyIds.length?`来源故事:${e.storyIds.join(`、`)}`:``,`测试点 ${e.points.length} 条`].filter(Boolean).join(`
|
|
6
|
-
`)}},children:{attached:N(e.key,e.dimensions)}}}]}let a=r.reduce((e,t)=>e+t.points.length,0);return[{id:`sheet-1`,class:`sheet`,title:i,rootTopic:{id:`root-topic`,title:i,structureClass:M,notes:{plain:{content:[n?.summary||``,`测试点 ${a} 条`].filter(Boolean).join(`
|
|
7
|
-
`)}},children:{attached:r.map(P)}}}]}async function I(t,n=[]){let r=F(t,n),{default:i}=await a(async()=>{let{default:t}=await import(`./jszip.min.Bh2Mgo40.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1])),s=new i;s.file(`content.json`,JSON.stringify(r));let c=Array.isArray(r)?r:[],l=c[0]&&typeof c[0]==`object`&&c[0].id||`sheet-1`;return s.file(`metadata.json`,JSON.stringify({creator:{name:`Lantern Harness`,version:o},activeSheetId:l})),s.file(`manifest.json`,JSON.stringify({"file-entries":{"content.json":{},"metadata.json":{}}})),s.generateAsync({type:`blob`,compression:`DEFLATE`})}async function L(e,t=[]){let n=new Date().toISOString().slice(0,10),r=`${C(s(e))}-测试点-${n}.xmind`,i=await I(e,t),a=URL.createObjectURL(i),o=document.createElement(`a`);return o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a),r}function R(e,t=[]){let n=e.testPoints,r=s(e),i=[];i.push(`# ${r}`),i.push(``);let a=j(e,t);if(i.push(`> 需求测试点 · 来源:\`${e.sourcePath||`(未指定)`}\` · 需求 ${a.length||e.stories.length} 条 · 测试点 ${n?.points.length??0} 条`),i.push(``),!n?.points.length)return i.push(`- 还没有生成测试点。`),`${i.join(`
|
|
8
|
-
`).trimEnd()}\n`;let o=y(n);i.push(`- 生成时间:${n.at}`),i.push(`- 共 ${o.total} 条(P0 ${o.byPriority.P0} / P1 ${o.byPriority.P1} / P2 ${o.byPriority.P2} / P3 ${o.byPriority.P3})`),i.push(`- 需求 ${a.length} 条 · 维度覆盖 ${o.coveredDimensions}/5`),n.summary&&(i.push(``),i.push(n.summary)),i.push(``);for(let e of a){i.push(`## ${e.title} · ${e.points.length} 条`),i.push(``);for(let t of e.dimensions)if(i.push(`### ${t.label}(${t.points.length})`),i.push(``),!t.points.length)i.push(`- (无)`),i.push(``);else{for(let e of t.points)i.push(`- **[${e.priority}]** ${e.title}`),e.precondition&&i.push(` - 前置:${e.precondition}`),e.steps.length&&i.push(` - 步骤:${e.steps.join(`;`)}`),e.expected&&i.push(` - 预期:${e.expected}`);i.push(``)}}return`${i.join(`
|
|
9
|
-
`).trimEnd()}\n`}function z(e,t=[]){let n=new Date().toISOString().slice(0,10),r=`${C(s(e))}-测试点-${n}.md`,i=new Blob([R(e,t)],{type:`text/markdown;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);return o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a),r}var B=`/__tb_storyreview`,V=`用户故事审查提示词.md`;async function H(e,t){let n=await fetch(`${B}${e}`,{...t,headers:t?.body===void 0?void 0:{"Content-Type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function U(){try{let e=await H(`/prompt`);return{file:V,exists:e.exists===!0,review:e.review??``,fix:e.fix??``}}catch(e){return{file:V,exists:!1,review:``,fix:``,error:e instanceof Error?e.message:String(e)}}}async function W(e){return H(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}var G={high:0,medium:1,low:2};function K(e){let t={pending:[],uncovered:[],other:[]};for(let n of e)n.type===`uncovered-outline`?t.uncovered.push(n):n.type===`pending-confirm`||n.type===`conflict`?t.pending.push(n):t.other.push(n);let n=e=>[...e].sort((e,t)=>G[e.severity]-G[t.severity]||e.title.localeCompare(t.title,`zh`));return[{key:`pending`,label:`待确认`,hint:`原文不清或需业务拍板`,gaps:n(t.pending)},{key:`uncovered`,label:`需求点未覆盖`,hint:`文档点还没有故事挂接`,gaps:n(t.uncovered)},{key:`other`,label:`其它`,hint:`其余待处理项`,gaps:n(t.other)}].filter(e=>e.gaps.length>0)}function q(e){return{high:e.filter(e=>e.severity===`high`).length,medium:e.filter(e=>e.severity===`medium`).length,low:e.filter(e=>e.severity===`low`).length}}function J(e,t){let a=[];if(a.push(`# 用户故事审查报告 · ${e.title||`未命名分析`}`),a.push(``),a.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 故事 ${e.stories.length} 条`),a.push(``),!t)return a.push(`- 还没有审查结果。`),`${a.join(`
|
|
10
|
-
`)}\n`;let o=t.coverage.total?Math.round(t.coverage.rate*100):0;a.push(`## 结论`),a.push(``),a.push(`- 状态:${r[e.status]?.label??e.status}`),a.push(`- 审查时间:${t.at}`),a.push(`- 需求条目覆盖率:${t.coverage.covered}/${t.coverage.total}(${o}%)`),a.push(`- 维度覆盖:${t.dimensions.map(e=>`${e.label}${e.covered?` ✓`:` ✗`}`).join(` · `)||`(无)`}`);let s=q(t.gaps);a.push(`- 缺口:${t.gaps.length} 条(高 ${s.high} / 中 ${s.medium} / 低 ${s.low})`),t.summary&&(a.push(``),a.push(t.summary)),a.push(``);let c=new Map(e.stories.map(e=>[e.id,e.title])),l=K(t.gaps);if(!l.length)return a.push(`## 缺口清单`),a.push(``),a.push(`- 没有发现缺口。`),`${a.join(`
|
|
11
|
-
`)}\n`;for(let e of l){a.push(`## ${e.label}(${e.gaps.length})`),a.push(``);for(let t of e.gaps){let e=t.storyId?`${t.storyId}${c.get(t.storyId)?` ${c.get(t.storyId)}`:``}`:`全局`;a.push(`- **[${i[t.severity]}] ${n[t.type]}** · ${e} · ${t.title}`),t.detail&&a.push(` - 原因:${t.detail}`),t.suggestion&&a.push(` - 建议:${t.suggestion}`)}a.push(``)}return`${a.join(`
|
|
12
|
-
`).trimEnd()}\n`}function Y(e,t){let n=`${(e.title||`需求分析`).replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}-审查报告-${new Date().toISOString().slice(0,10)}.md`,r=new Blob([J(e,t)],{type:`text/markdown;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);return a.href=i,a.download=n,a.click(),URL.revokeObjectURL(i),n}function X(e,t,n){if(e.outlineId){let r=t?.get(e.outlineId)?.trim();if(r)return r;let i=n?.get(e.outlineId)?.trim();if(i)return i}return e.detail?.trim()||e.title?.trim()||`(无原文摘录)`}function Z(e,t,n){let r=[];if(r.push(`# 待确认事项 · ${e.title||`未命名分析`}`),r.push(``),r.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 请在每条「结论」里回填后交回,便于补写用户故事。`),r.push(``),!t?.gaps.length)return r.push(`(当前没有待确认项。)`),`${r.join(`
|
|
13
|
-
`)}\n`;let i=n?.gapIds?.length?new Set(n.gapIds):null,a=i?t.gaps.filter(e=>i.has(e.id)):[...t.gaps];if(!a.length)return r.push(`(未勾选任何项;请先勾选或清空选择后导出全部。)`),`${r.join(`
|
|
14
|
-
`)}\n`;let o=K(a),s=0;for(let e of o)for(let t of e.gaps){s+=1,r.push(`## ${s}. ${t.title}`),r.push(``),r.push(`需求内容:${X(t,n?.outlineBodies,n?.outlineTitles)}`),r.push(``);let e=t.detail?.trim()||t.title;r.push(`疑问:${e}`),r.push(``),r.push(`结论:${t.conclusion?.trim()||``}`),r.push(``)}return`${r.join(`
|
|
15
|
-
`).trimEnd()}\n`}function Q(e,t,n){let r=`${(e.title||`需求分析`).replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}-待确认-${new Date().toISOString().slice(0,10)}.md`,i=new Blob([Z(e,t,n)],{type:`text/markdown;charset=utf-8`}),a=URL.createObjectURL(i),o=document.createElement(`a`);return o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a),r}export{j as _,U as a,x as b,m as c,d,l as f,g,L as h,Y as i,f as l,z as m,q as n,K as o,y as p,Q as r,W as s,V as t,p as u,S as v,_ as y};
|