nx-kv 0.44.2 → 0.45.0

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/assets/kv-get/references/wait-workflow.md +14 -4
  3. package/assets/kv-get/references/waitloop.md +7 -1
  4. package/package.json +1 -1
  5. package/src/core/instruction-template.js +187 -0
  6. package/src/modules/localtask/action-lifecycle.js +6 -2
  7. package/src/modules/localtask/task-lifecycle.js +41 -1
  8. package/src/shared/prompt-blocks.js +36 -7
  9. package/src/web/frontend/page/settings/prompt-template-params.js +36 -0
  10. package/src/web/public/assets/{Introduction-DhwPj5cV.js → Introduction-EHroxF1H.js} +1 -1
  11. package/src/web/public/assets/{bar-Asff3O_q.js → bar-BvS_Jfi4.js} +1 -1
  12. package/src/web/public/assets/{cloud-B4teh9iW.js → cloud-DlWk0wnP.js} +1 -1
  13. package/src/web/public/assets/{composer-panel-DdJnqWyB.js → composer-panel-D3w-CjhN.js} +1 -1
  14. package/src/web/public/assets/{deleted-panel-Du_QekTw.js → deleted-panel-BMJEEBWD.js} +1 -1
  15. package/src/web/public/assets/{dir-Bm8iRhk_.js → dir-BtjHgH4Q.js} +1 -1
  16. package/src/web/public/assets/{group-DWUqMR0V.js → group-Bxq8JamU.js} +1 -1
  17. package/src/web/public/assets/{index-D2fKyD1k.js → index-ChlZPTea.js} +2 -2
  18. package/src/web/public/assets/{md-history-CfpJ9GT6.js → md-history-CBqcR086.js} +1 -1
  19. package/src/web/public/assets/{overview-B8afcbd6.js → overview-BP5sB1WX.js} +1 -1
  20. package/src/web/public/assets/{refs-OOuAfThN.js → refs-Dt7DQIOo.js} +1 -1
  21. package/src/web/public/assets/{repos-C8HvsdC7.js → repos-Zl1_SfPX.js} +1 -1
  22. package/src/web/public/assets/{route-crumb-CvrRU1gp.js → route-crumb-PqhQSVWL.js} +1 -1
  23. package/src/web/public/assets/settings-CXWFvvvv.js +8 -0
  24. package/src/web/public/assets/{status-tag-BhZgdBJz.js → status-tag-BK-45ld2.js} +1 -1
  25. package/src/web/public/assets/{task-Bq8Rd03M.js → task-COFIPegR.js} +1 -1
  26. package/src/web/public/assets/{templates-C9VpC4gA.js → templates-CIxgTTt-.js} +1 -1
  27. package/src/web/public/assets/{tool-bar-D5yvblnb.js → tool-bar-TIqYxsQl.js} +1 -1
  28. package/src/web/public/index.html +1 -1
  29. package/src/web/public/assets/settings-jom_vACN.js +0 -7
@@ -1 +1 @@
1
- import{g as e,h as t,m as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{a}from"./workspace-C_5X2gIr.js";import{i as o}from"./Introduction-DhwPj5cV.js";var s=i(e(),1),c=t();function l(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function u(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function d(e){let t=[],n=e&&(e.main||e.introMain);n&&t.push({...n,docId:l(n),main:!0,label:e.repo?e.repo.name:`主篇`});for(let n of e&&(e.extras||e.introExtras)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}for(let n of e&&(e.links||e.docLinks)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}return t.filter(e=>e.docId)}function f({repoKey:e,boardKey:t,boardName:i,model:l}){let{openByDocId:u}=o(l),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(0),v=(0,s.useCallback)(()=>_(e=>e+1),[]);(0,s.useEffect)(()=>{let r=!0;return h(``),(async()=>{try{let i=e?await n(`/api/repos/docs?id=`+encodeURIComponent(e)):await n(`/api/boards/`+encodeURIComponent(String(t)));r&&p(i)}catch(e){r&&(p(null),h(String(e.message||e)))}})(),()=>{r=!1}},[e,t,g]);let y=d(f),b=f?f.repo?f.repo.name:f.name||i||`项目组`:i||`文档列表`,x=e?{repoKey:e}:{boardKey:t,boardName:i};return(0,c.jsxs)(`div`,{className:`nx-refs`,children:[(0,c.jsxs)(`div`,{className:`nx-refs-h`,children:[(0,c.jsxs)(`span`,{className:`t`,title:b,children:[b,` · 文档列表`]}),(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`刷新`,"aria-label":`刷新文档列表`,onClick:v,children:(0,c.jsx)(r,{name:`refresh`,size:13})}),l&&(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭文档列表面板`,"aria-label":`关闭文档列表面板`,onClick:()=>a(l,`refs`),children:(0,c.jsx)(r,{name:`x`,size:14})})]}),(0,c.jsxs)(`div`,{className:`nx-refs-list`,children:[m?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:m}):null,!m&&!f?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:`读取中…`}):null,!m&&f&&!y.length?(0,c.jsxs)(`div`,{className:`nx-refs-empty`,children:[`还没有文档`,(0,c.jsx)(`br`,{}),e?`在目录页「查看详情」里点「+ 补充」开始写`:`在项目组页「查看详情」里点「+ 补充」开始写`]}):null,y.map(e=>(0,c.jsxs)(`button`,{type:`button`,className:`nx-refs-row`+(e.main?` main`:``),title:`${e.rel||e.path||``}${e.note?`\n${e.note}`:``}`,onClick:()=>u(e.docId,null,x),children:[(0,c.jsxs)(`span`,{className:`nx-refs-row-label`,children:[e.main?`● `:`○ `,e.label]}),e.tag?(0,c.jsx)(`span`,{className:`nx-refs-row-tag`,children:e.tag}):null,(0,c.jsx)(`span`,{className:`nx-refs-row-sub mono`,children:e.rel||e.path||``})]},e.docId))]}),(0,c.jsx)(`div`,{className:`nx-refs-note`,children:`点一行在工作区打开文档页签;完整管理与就地编辑走「查看详情」。`})]})}export{f as default};
1
+ import{g as e,h as t,m as n,u as r,y as i}from"./task-status-BnymQMTw.js";import{a}from"./workspace-C_5X2gIr.js";import{i as o}from"./Introduction-EHroxF1H.js";var s=i(e(),1),c=t();function l(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function u(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function d(e){let t=[],n=e&&(e.main||e.introMain);n&&t.push({...n,docId:l(n),main:!0,label:e.repo?e.repo.name:`主篇`});for(let n of e&&(e.extras||e.introExtras)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}for(let n of e&&(e.links||e.docLinks)||[]){let e=l(n);e&&t.push({...n,docId:e,main:!1,label:u(n)})}return t.filter(e=>e.docId)}function f({repoKey:e,boardKey:t,boardName:i,model:l}){let{openByDocId:u}=o(l),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(0),v=(0,s.useCallback)(()=>_(e=>e+1),[]);(0,s.useEffect)(()=>{let r=!0;return h(``),(async()=>{try{let i=e?await n(`/api/repos/docs?id=`+encodeURIComponent(e)):await n(`/api/boards/`+encodeURIComponent(String(t)));r&&p(i)}catch(e){r&&(p(null),h(String(e.message||e)))}})(),()=>{r=!1}},[e,t,g]);let y=d(f),b=f?f.repo?f.repo.name:f.name||i||`项目组`:i||`文档列表`,x=e?{repoKey:e}:{boardKey:t,boardName:i};return(0,c.jsxs)(`div`,{className:`nx-refs`,children:[(0,c.jsxs)(`div`,{className:`nx-refs-h`,children:[(0,c.jsxs)(`span`,{className:`t`,title:b,children:[b,` · 文档列表`]}),(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`刷新`,"aria-label":`刷新文档列表`,onClick:v,children:(0,c.jsx)(r,{name:`refresh`,size:13})}),l&&(0,c.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭文档列表面板`,"aria-label":`关闭文档列表面板`,onClick:()=>a(l,`refs`),children:(0,c.jsx)(r,{name:`x`,size:14})})]}),(0,c.jsxs)(`div`,{className:`nx-refs-list`,children:[m?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:m}):null,!m&&!f?(0,c.jsx)(`div`,{className:`nx-refs-empty`,children:`读取中…`}):null,!m&&f&&!y.length?(0,c.jsxs)(`div`,{className:`nx-refs-empty`,children:[`还没有文档`,(0,c.jsx)(`br`,{}),e?`在目录页「查看详情」里点「+ 补充」开始写`:`在项目组页「查看详情」里点「+ 补充」开始写`]}):null,y.map(e=>(0,c.jsxs)(`button`,{type:`button`,className:`nx-refs-row`+(e.main?` main`:``),title:`${e.rel||e.path||``}${e.note?`\n${e.note}`:``}`,onClick:()=>u(e.docId,null,x),children:[(0,c.jsxs)(`span`,{className:`nx-refs-row-label`,children:[e.main?`● `:`○ `,e.label]}),e.tag?(0,c.jsx)(`span`,{className:`nx-refs-row-tag`,children:e.tag}):null,(0,c.jsx)(`span`,{className:`nx-refs-row-sub mono`,children:e.rel||e.path||``})]},e.docId))]}),(0,c.jsx)(`div`,{className:`nx-refs-note`,children:`点一行在工作区打开文档页签;完整管理与就地编辑走「查看详情」。`})]})}export{f as default};
@@ -1,4 +1,4 @@
1
- import{f as e,g as t,h as n,l as r,m as i,o as a,p as o,y as s}from"./task-status-BnymQMTw.js";import{n as c}from"./app-context-D7HAx67n.js";import{x as l}from"./index-D2fKyD1k.js";import{t as u}from"./route-crumb-CvrRU1gp.js";import{i as d,n as f}from"./Introduction-DhwPj5cV.js";import{t as p}from"./bar-Asff3O_q.js";import{t as m}from"./member-picker-BAgkj36N.js";import{t as h}from"./button-Cmo-6aoW.js";var g=s(t(),1),_=n(),v={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function y({onClose:t,onChanged:n,repos:r,boards:a}){let s=e(),c=o(),[l,u]=(0,g.useState)(`import`),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)({}),[h,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)({}),[O,k]=(0,g.useState)({}),[A,j]=(0,g.useState)(`ours`),[M,ee]=(0,g.useState)(`none`),[N,P]=(0,g.useState)(``),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(!1),z=(0,g.useMemo)(()=>r||[],[r]),B=(0,g.useMemo)(()=>z.map(e=>e.key),[z]),V=(0,g.useMemo)(()=>(a||[]).map(e=>e.name),[a]),H=e=>{let t={};for(let n of B)t[n]=e;f(t)},te=e=>{let t={};for(let n of V)t[n]=e;m(t)},U=()=>{let e={};for(let t of B)e[t]=!d[t];f(e)},W=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==B.length?e:void 0,boards:t.length&&t.length!==V.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let a=await i(`/api/repos/export`+(r.toString()?`?`+r:``));x(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),G=()=>{if(!b)return;let e=new Blob([b],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},K=async e=>{let t=e.target.files?.[0];t&&(C(await t.text()),T(null),I(null))},ne=()=>s(async()=>{if(S.trim()){R(!0);try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;k(n),I(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{R(!1)}}}),q=()=>s(async()=>{let e=Object.keys(E).filter(e=>E[e]),t=Object.keys(O).filter(e=>O[e]);R(!0);try{let r=await i(`/api/repos/import`,{method:`POST`,body:{json:S,strategy:A,clone:M,selection:e.length?e:void 0,boards:t.length?t:void 0}});I(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await J(),n&&await n()}finally{R(!1)}}),J=(0,g.useCallback)(async()=>{try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t)}catch{}},[S]),re=(0,g.useMemo)(()=>w?N?w.repos.filter(e=>e.status===N):w.repos:[],[w,N]),ie=(e,t)=>s(async()=>{if(t){R(!0);try{await i(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await J(),n&&await n()}finally{R(!1)}}}),ae=e=>{let t={...E};for(let n of re)t[n.key]=e;D(t)};(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let oe=(0,g.useMemo)(()=>{if(!w)return null;let e={new:0,changed:0,same:0};for(let t of w.repos)e[t.status]=(e[t.status]||0)+1;return e},[w]);return(0,_.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,_.jsxs)(`div`,{className:`rp-full-box`,children:[(0,_.jsxs)(`div`,{className:`rp-full-head`,children:[(0,_.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,_.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,_.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,_.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,_.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),l===`export`?(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsx)(`span`,{children:`导出范围`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!0),children:`全选仓库`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!1),children:`全不选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:U,children:`反选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[z.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,_.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),z.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,_.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,_.jsx)(`span`,{children:`看板`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!1),children:`全不选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,_.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,_.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>y(e.target.checked)}),(0,_.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,_.jsxs)(`div`,{className:`form-acts`,children:[(0,_.jsx)(`button`,{className:`btn`,onClick:W,children:`生成布局`}),(0,_.jsx)(`button`,{className:`btn ghost`,disabled:!b,onClick:G,children:`下载 JSON`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导出结果`})}),(0,_.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:b,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导入来源`})}),(0,_.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:K}),(0,_.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:S,onChange:e=>{C(e.target.value),T(null)}}),(0,_.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsx)(`button`,{className:`btn`,disabled:!S.trim()||L,onClick:ne,children:`差异检查`})}),w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,_.jsx)(`span`,{children:`冲突方案`})}),(0,_.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,_.jsx)(`input`,{type:`radio`,name:`strategy`,checked:A===e,onChange:()=>j(e)}),(0,_.jsx)(`span`,{children:t})]},e))}),(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,_.jsx)(`span`,{children:`克隆`})}),(0,_.jsxs)(`select`,{value:M,onChange:e=>ee(e.target.value),children:[(0,_.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,_.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,_.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,_.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsxs)(`button`,{className:`btn`,disabled:L,onClick:q,children:[`执行导入(已选 `,Object.values(E).filter(Boolean).length,`)`]})})]}):null,F?(0,_.jsxs)(`div`,{className:`rp-import-result`,children:[(0,_.jsxs)(`div`,{children:[`新建 `,F.created.length,` · 覆盖 `,F.updated.length,` · 另存 `,F.duplicated.length,` · 跳过 `,F.skipped.length]}),(0,_.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,F.boardsCreated,` / 合并 `,F.boardsMerged,` · 参考关系 `,F.links]}),F.cloned.length?(0,_.jsxs)(`div`,{children:[`克隆 `,F.cloned.length,` 个`]}):null,F.unmatched.length?(0,_.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,F.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,_.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsxs)(`span`,{children:[`差异(新增 `,oe.new,` · 有差异 `,oe.changed,` · 一致 `,oe.same,w.summary.missing?` · 本地未拥有 ${w.summary.missing}`:``,`)`]}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`rp-chip`+(N===``?` on`:``),onClick:()=>P(``),children:`全部`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`new`?` on`:``),onClick:()=>P(`new`),children:`新增`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`changed`?` on`:``),onClick:()=>P(`changed`),children:`有差异`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`same`?` on`:``),onClick:()=>P(`same`),children:`一致`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!1),children:`全不选`})]})]}),(0,_.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,_.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{style:{width:`32px`}}),(0,_.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,_.jsx)(`th`,{children:`仓库 key`}),(0,_.jsx)(`th`,{children:`差异字段`})]})}),(0,_.jsxs)(`tbody`,{children:[re.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row `+v[e.status]?.cls,children:[(0,_.jsx)(`td`,{children:(0,_.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!E[e.key],onChange:t=>D(n=>({...n,[e.key]:t.target.checked}))})}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label})}),(0,_.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,_.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,_.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:L,onClick:()=>ie(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,_.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`b`,{children:e.field}),`: `,(0,_.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,_.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,_.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),w.missing.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,_.jsx)(`td`,{}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,_.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,_.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),w.boards.length?(0,_.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`看板`})}),w.boards.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!O[e.key],onChange:t=>k(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label}),(0,_.jsx)(`span`,{children:e.key}),(0,_.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),w.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,_.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,_.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,_.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,_.jsx)(`button`,{className:`btn small`,disabled:L,onClick:()=>ie(e.key,e.remote),children:`克隆到本地`}):(0,_.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,_.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function b(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function x({value:e,onChange:t,placeholder:n,rows:r=3,hint:i=``}){return(0,_.jsxs)(`div`,{className:`pp-field`,children:[(0,_.jsx)(`textarea`,{className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value)}),i?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:i}):null]})}function S({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,accordion:a=!1,openIndex:o,onOpenChange:s}){let[c,l]=(0,g.useState)(-1),u=o===void 0?c:o,d=e=>{l(e),s&&s(e)},f=(n,r)=>t(e.map((e,t)=>t===n?r:e)),p=n=>{t(e.filter((e,t)=>t!==n)),d(e=>e===n?-1:e>n?e-1:e)};return a?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let a=u===t,o=b(e.split(`
1
+ import{f as e,g as t,h as n,l as r,m as i,o as a,p as o,y as s}from"./task-status-BnymQMTw.js";import{n as c}from"./app-context-D7HAx67n.js";import{x as l}from"./index-ChlZPTea.js";import{t as u}from"./route-crumb-PqhQSVWL.js";import{i as d,n as f}from"./Introduction-EHroxF1H.js";import{t as p}from"./bar-BvS_Jfi4.js";import{t as m}from"./member-picker-BAgkj36N.js";import{t as h}from"./button-Cmo-6aoW.js";var g=s(t(),1),_=n(),v={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function y({onClose:t,onChanged:n,repos:r,boards:a}){let s=e(),c=o(),[l,u]=(0,g.useState)(`import`),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)({}),[h,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)({}),[O,k]=(0,g.useState)({}),[A,j]=(0,g.useState)(`ours`),[M,ee]=(0,g.useState)(`none`),[N,P]=(0,g.useState)(``),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(!1),z=(0,g.useMemo)(()=>r||[],[r]),B=(0,g.useMemo)(()=>z.map(e=>e.key),[z]),V=(0,g.useMemo)(()=>(a||[]).map(e=>e.name),[a]),H=e=>{let t={};for(let n of B)t[n]=e;f(t)},te=e=>{let t={};for(let n of V)t[n]=e;m(t)},U=()=>{let e={};for(let t of B)e[t]=!d[t];f(e)},W=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==B.length?e:void 0,boards:t.length&&t.length!==V.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let a=await i(`/api/repos/export`+(r.toString()?`?`+r:``));x(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),G=()=>{if(!b)return;let e=new Blob([b],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},K=async e=>{let t=e.target.files?.[0];t&&(C(await t.text()),T(null),I(null))},ne=()=>s(async()=>{if(S.trim()){R(!0);try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;k(n),I(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{R(!1)}}}),q=()=>s(async()=>{let e=Object.keys(E).filter(e=>E[e]),t=Object.keys(O).filter(e=>O[e]);R(!0);try{let r=await i(`/api/repos/import`,{method:`POST`,body:{json:S,strategy:A,clone:M,selection:e.length?e:void 0,boards:t.length?t:void 0}});I(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await J(),n&&await n()}finally{R(!1)}}),J=(0,g.useCallback)(async()=>{try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t)}catch{}},[S]),re=(0,g.useMemo)(()=>w?N?w.repos.filter(e=>e.status===N):w.repos:[],[w,N]),ie=(e,t)=>s(async()=>{if(t){R(!0);try{await i(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await J(),n&&await n()}finally{R(!1)}}}),ae=e=>{let t={...E};for(let n of re)t[n.key]=e;D(t)};(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let oe=(0,g.useMemo)(()=>{if(!w)return null;let e={new:0,changed:0,same:0};for(let t of w.repos)e[t.status]=(e[t.status]||0)+1;return e},[w]);return(0,_.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,_.jsxs)(`div`,{className:`rp-full-box`,children:[(0,_.jsxs)(`div`,{className:`rp-full-head`,children:[(0,_.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,_.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,_.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,_.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,_.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),l===`export`?(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsx)(`span`,{children:`导出范围`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!0),children:`全选仓库`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!1),children:`全不选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:U,children:`反选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[z.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,_.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),z.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,_.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,_.jsx)(`span`,{children:`看板`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!1),children:`全不选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,_.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,_.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>y(e.target.checked)}),(0,_.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,_.jsxs)(`div`,{className:`form-acts`,children:[(0,_.jsx)(`button`,{className:`btn`,onClick:W,children:`生成布局`}),(0,_.jsx)(`button`,{className:`btn ghost`,disabled:!b,onClick:G,children:`下载 JSON`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导出结果`})}),(0,_.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:b,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导入来源`})}),(0,_.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:K}),(0,_.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:S,onChange:e=>{C(e.target.value),T(null)}}),(0,_.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsx)(`button`,{className:`btn`,disabled:!S.trim()||L,onClick:ne,children:`差异检查`})}),w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,_.jsx)(`span`,{children:`冲突方案`})}),(0,_.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,_.jsx)(`input`,{type:`radio`,name:`strategy`,checked:A===e,onChange:()=>j(e)}),(0,_.jsx)(`span`,{children:t})]},e))}),(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,_.jsx)(`span`,{children:`克隆`})}),(0,_.jsxs)(`select`,{value:M,onChange:e=>ee(e.target.value),children:[(0,_.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,_.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,_.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,_.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsxs)(`button`,{className:`btn`,disabled:L,onClick:q,children:[`执行导入(已选 `,Object.values(E).filter(Boolean).length,`)`]})})]}):null,F?(0,_.jsxs)(`div`,{className:`rp-import-result`,children:[(0,_.jsxs)(`div`,{children:[`新建 `,F.created.length,` · 覆盖 `,F.updated.length,` · 另存 `,F.duplicated.length,` · 跳过 `,F.skipped.length]}),(0,_.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,F.boardsCreated,` / 合并 `,F.boardsMerged,` · 参考关系 `,F.links]}),F.cloned.length?(0,_.jsxs)(`div`,{children:[`克隆 `,F.cloned.length,` 个`]}):null,F.unmatched.length?(0,_.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,F.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,_.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsxs)(`span`,{children:[`差异(新增 `,oe.new,` · 有差异 `,oe.changed,` · 一致 `,oe.same,w.summary.missing?` · 本地未拥有 ${w.summary.missing}`:``,`)`]}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`rp-chip`+(N===``?` on`:``),onClick:()=>P(``),children:`全部`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`new`?` on`:``),onClick:()=>P(`new`),children:`新增`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`changed`?` on`:``),onClick:()=>P(`changed`),children:`有差异`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`same`?` on`:``),onClick:()=>P(`same`),children:`一致`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!1),children:`全不选`})]})]}),(0,_.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,_.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{style:{width:`32px`}}),(0,_.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,_.jsx)(`th`,{children:`仓库 key`}),(0,_.jsx)(`th`,{children:`差异字段`})]})}),(0,_.jsxs)(`tbody`,{children:[re.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row `+v[e.status]?.cls,children:[(0,_.jsx)(`td`,{children:(0,_.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!E[e.key],onChange:t=>D(n=>({...n,[e.key]:t.target.checked}))})}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label})}),(0,_.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,_.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,_.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:L,onClick:()=>ie(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,_.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`b`,{children:e.field}),`: `,(0,_.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,_.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,_.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),w.missing.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,_.jsx)(`td`,{}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,_.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,_.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),w.boards.length?(0,_.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`看板`})}),w.boards.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!O[e.key],onChange:t=>k(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label}),(0,_.jsx)(`span`,{children:e.key}),(0,_.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),w.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,_.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,_.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,_.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,_.jsx)(`button`,{className:`btn small`,disabled:L,onClick:()=>ie(e.key,e.remote),children:`克隆到本地`}):(0,_.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,_.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function b(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function x({value:e,onChange:t,placeholder:n,rows:r=3,hint:i=``}){return(0,_.jsxs)(`div`,{className:`pp-field`,children:[(0,_.jsx)(`textarea`,{className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value)}),i?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:i}):null]})}function S({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,accordion:a=!1,openIndex:o,onOpenChange:s}){let[c,l]=(0,g.useState)(-1),u=o===void 0?c:o,d=e=>{l(e),s&&s(e)},f=(n,r)=>t(e.map((e,t)=>t===n?r:e)),p=n=>{t(e.filter((e,t)=>t!==n)),d(e=>e===n?-1:e>n?e-1:e)};return a?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let a=u===t,o=b(e.split(`
2
2
  `)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(x,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>d(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:o||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(x,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var C=10,w=2e3,T=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get 领取下一条任务,直到 get 返回 timeout 为止。`;function E({repo:e,onClose:t,onSaved:n}){let r=c()||{},s=o(),l=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,g.useState)(!!(l&&l.enabled)),[f,p]=(0,g.useState)(String(l&&l.waitMinutes||10)),[m,v]=(0,g.useState)(()=>{let e=l&&l.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[y,b]=(0,g.useState)(-1),[x,E]=(0,g.useState)(``),[D,O]=(0,g.useState)(!1),k=async t=>{O(!0);try{let a=t&&t.enabled!==void 0?t.enabled:u,o=m.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,C);await i(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:a,...a?{waitMinutes:Number(f)||10,template:o}:{}}}}),s(a?`已保存「${e.name}」的持续 get 设置(模板 ${o.length} 条)`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){s(String(e.message||e))}finally{O(!1)}},A=async e=>{d(e),await k({enabled:e})},j=()=>{let e=x.trim();!e||m.length>=C||(v([...m,e.slice(0,w)]),b(m.length),E(``))};return(0,_.jsx)(a,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,_.jsxs)(`div`,{className:`rp-gl`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,_.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,_.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,_.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>A(!u),disabled:D,children:[(0,_.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,_.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口`}),(0,_.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,_.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`}),`分钟`]})]}),(0,_.jsxs)(`div`,{className:`rp-gl-tpl`,children:[(0,_.jsx)(`div`,{className:`rp-gl-h`,children:`收尾模板`}),(0,_.jsxs)(`div`,{className:`rp-gl-oneline`,children:[(0,_.jsx)(h,{variant:`secondary`,title:`填入内置默认(继续 get 直到 timeout)`,onClick:()=>E(T),children:`填入内置默认`}),(0,_.jsx)(`input`,{className:`rp-gl-oneline-input`,value:x,placeholder:`一句话(%s = 任务编号)`,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()}}),(0,_.jsx)(h,{variant:`secondary`,disabled:D||!x.trim(),onClick:j,children:`添加`})]}),m.length?(0,_.jsx)(S,{items:m,onChange:v,disabled:D,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:y,onOpenChange:b}):(0,_.jsx)(`div`,{className:`rp-gl-note`,children:`未配置模板 —— 用默认「完成后续调 localtask get;没活时每轮最多阻塞 {{getloop.waitMinutes}} 分钟,直到 timeout」。`})]}),(0,_.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,_.jsx)(h,{variant:`secondary`,disabled:D||m.length>=C,title:m.length>=C?`最多 ${C} 条`:`新增一条「继续 get」指令`,onClick:()=>{v([...m,``]),b(m.length)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(h,{variant:`primary`,disabled:D,onClick:()=>k(),children:`保存持续 get 设置`})]})]})]})})}function D({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,_.jsx)(l,{text:t,children:t}):(0,_.jsxs)(l,{text:t,title:`点击复制完整路径`,children:[(0,_.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function O({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
3
3
  `):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`;return(0,_.jsxs)(`button`,{type:`button`,className:`rp-docs-entry`,title:a,onClick:t,children:[(0,_.jsx)(`span`,{className:`rp-docs-entry-main`+(n&&n.exists?``:` ghost`),children:n&&n.exists?n.title||n.summary||`未命名`:`+ 写项目介绍`}),(0,_.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function k({chips:e,boardId:t,acts:n}){let[r,i]=(0,g.useState)(!1),a=r?e:e.slice(0,4);return(0,_.jsxs)(_.Fragment,{children:[a.map(e=>(0,_.jsx)(`span`,{className:`rp-link-chip rp-link-chip-`+(e.source===`group`?`group`:`repo`),children:(0,_.jsxs)(`button`,{className:`rp-link-chip-main`,title:e.source===`group`?[`组「${e.groupName}」共享的参考仓库`,e.note].filter(Boolean).join(`
4
4
  `):[`本仓库直接绑定的参考仓库`,e.note,`点击跳到这个参考仓库`].filter(Boolean).join(`
@@ -1 +1 @@
1
- import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{n as r}from"./app-context-D7HAx67n.js";import{n as i}from"./board-view-CZKZsyk-.js";import{t as a}from"./index-D2fKyD1k.js";var o=n(e(),1);function s(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:if(e.task){let n=[t.boardName||`项目组`];return/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`),n}return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/overview`;case`overview`:return``;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/overview`}}function l(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let a=i(t,n.boards||[],e.key,e.task);return{boardName:a.board&&a.board.name||r&&r.name||``,dirName:a.topic?a.topic.name:``,pageTitle:a.taskRow?`#${a.taskRow.id}`:``}}let a=(t||[]).find(t=>t.key===e.key),o=a&&e.task?(a.tasks||[]).find(t=>String(t.id)===String(e.task)):null;if(e.view===`doc`){let t=(n.repos||[]).find(t=>t.key===e.repoKey),r=(n.boards||[]).find(t=>t.id===e.boardKey||t.key===e.boardKey);return{boardName:e.boardName||r&&r.name||``,dirName:``,pageTitle:``,repoName:t&&t.name||``}}return{boardName:r&&r.name||``,dirName:a?a.name:``,pageTitle:o?`#${o.id}`:``}}var u=t();function d({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let a=(0,o.useMemo)(()=>s(e,t),[e,t]),l=(0,o.useMemo)(()=>c(e,t),[e,t]);if(!a.length)return null;let d=`nx-crumb`+(i?` nx-crumb-inline`:``),f=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),a.map((e,t)=>(0,u.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,u.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,u.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]});return l&&n?(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:(0,u.jsx)(`button`,{type:`button`,className:`nx-crumb-path`,title:`返回上一级`,"aria-label":`返回上一级(${a.join(` / `)})`,onClick:()=>r?r():n(l),children:f})}):(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:f})}function f(){let e=r()||{},t=e.route||{},n=e.rows||[],i=e.repoData||{},f=(0,o.useMemo)(()=>l(t,n,i),[t,n,i]);return(0,o.useMemo)(()=>s(t,f),[t,f]).length?(0,u.jsx)(d,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=a();if(n&&e.onNavigate){e.onNavigate(n);return}let r=c(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{f as t};
1
+ import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{n as r}from"./app-context-D7HAx67n.js";import{n as i}from"./board-view-CZKZsyk-.js";import{t as a}from"./index-ChlZPTea.js";var o=n(e(),1);function s(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:if(e.task){let n=[t.boardName||`项目组`];return/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`),n}return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/overview`;case`overview`:return``;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/overview`}}function l(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let a=i(t,n.boards||[],e.key,e.task);return{boardName:a.board&&a.board.name||r&&r.name||``,dirName:a.topic?a.topic.name:``,pageTitle:a.taskRow?`#${a.taskRow.id}`:``}}let a=(t||[]).find(t=>t.key===e.key),o=a&&e.task?(a.tasks||[]).find(t=>String(t.id)===String(e.task)):null;if(e.view===`doc`){let t=(n.repos||[]).find(t=>t.key===e.repoKey),r=(n.boards||[]).find(t=>t.id===e.boardKey||t.key===e.boardKey);return{boardName:e.boardName||r&&r.name||``,dirName:``,pageTitle:``,repoName:t&&t.name||``}}return{boardName:r&&r.name||``,dirName:a?a.name:``,pageTitle:o?`#${o.id}`:``}}var u=t();function d({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let a=(0,o.useMemo)(()=>s(e,t),[e,t]),l=(0,o.useMemo)(()=>c(e,t),[e,t]);if(!a.length)return null;let d=`nx-crumb`+(i?` nx-crumb-inline`:``),f=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),a.map((e,t)=>(0,u.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,u.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,u.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]});return l&&n?(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:(0,u.jsx)(`button`,{type:`button`,className:`nx-crumb-path`,title:`返回上一级`,"aria-label":`返回上一级(${a.join(` / `)})`,onClick:()=>r?r():n(l),children:f})}):(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:f})}function f(){let e=r()||{},t=e.route||{},n=e.rows||[],i=e.repoData||{},f=(0,o.useMemo)(()=>l(t,n,i),[t,n,i]);return(0,o.useMemo)(()=>s(t,f),[t,f]).length?(0,u.jsx)(d,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=a();if(n&&e.onNavigate){e.onNavigate(n);return}let r=c(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{f as t};
@@ -0,0 +1,8 @@
1
+ import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{n as s}from"./app-context-D7HAx67n.js";import{n as c,o as l}from"./index-ChlZPTea.js";import{t as u}from"./button-Cmo-6aoW.js";var d=o(e(),1),f=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),p=8e3,m=`builtin`,h=`系统内置`,g=`{{#if repo}},{{#if repo.intro}},〔项目介绍 · {{repo.name}}〕({{repo.introPath}}):,{{repo.intro}},{{/if}},{{#if repo.docs}},项目补充文档(可直接读取):,{{#each repo.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.intro}},组介绍({{group.introPath}}):,{{group.intro}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}},{{/each}},{{/if}},{{#if group.docs}},组绑定参考文件(可直接读取):,{{#each group.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if refRepos.count}},参考仓库(可直接读取,共 {{refRepos.count}} 个):,{{#each refRepos.list}}, - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}}`.split(`,`).join(`
2
+ `),_=[`{{#if attach}}`,`〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容)再开始处理,不要跳过附件。`,``,`附件清单:`,`{{#each attach.list}}`,` - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{#if ref.relPath}}({{ref.relPath}}){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}`,`{{/each}}`,``,`取用方式:`,`{{#each attach.list}}`,` - {{kindLabel}} 《{{name}}》:{{usage}}`,`{{/each}}`,`{{#if attach.syncSummary}}`,`同步情况:{{attach.syncSummary.text}}`,`{{/if}}`,`{{#each attach.list}}{{#if ref}}{{#if ref.content}}〔文档原文 · {{ref.title}}〕({{ref.relPath}}):`,``,`{{ref.content}}`,``,`{{/if}}{{/if}}{{/each}}`,`{{/if}}`].join(`
3
+ `),v=[`{{#if goal.check}}`,`{{goal.check}}`,`{{/if}}`,`{{#if goal.statusLine}}`,`{{goal.statusLine}}`,`{{/if}}`].join(`
4
+ `),y=[`{{#if goal.check}}`,`〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),{{#if goal.reached}}已到点(超时 {{formatDuration goal.overtimeSec}}){{else}}剩余 {{goal.remainingHuman}}{{/if}}。`,`{{#if goal.reached}}——时间已到:可以收口,把改动收敛成可交付状态,补验证与说明后按 ack 段 done。`,`{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}——已过 2/3:进入收尾整理(收敛改动 / 补验证 / 写清遗留),别开新战线。`,`{{else}}{{#if (gte (percent goal.elapsedSec goal.durationSec) 50)}}——已过半:先确认主线走到哪,剩余时间只做收尾必需项。`,`{{else}}——时间尚足:先做主线,再补细节。{{/if}}{{/if}}{{/if}}`,`{{/if}}`].join(`
5
+ `),b=[`{{#if goal.blocked}}`,`〔完成门禁 · 时间未到〕任务 #{{task.id}} 还不能 done:持续 {{goal.durationHuman}},已过 {{goal.elapsedHuman}}({{percent goal.elapsedSec goal.durationSec}}%),剩余 {{goal.remainingHuman}}。`,`- 现在可做:{{#if (gte (percent goal.elapsedSec goal.durationSec) 67)}}收尾整理(收敛改动 / 补验证 / 写清遗留),或派 sub agent 提出新的需求继续推进{{else}}继续推进主线,并派 sub agent 重新提出新的需求{{/if}}。`,`- 每轮推进先跑:nx-kv timegoal check --task {{goal.goalKey}} --summary "<本轮现状>" --progress "<进展/下一步>"`,`- 到点后再:nx-kv localtask done --id {{task.id}} --summary "<完成总结>"`,`{{/if}}`].join(`
6
+ `),x=[`{{#if ext.count}}`,`本队列({{ext.topic}})还有 {{ext.count}} 条待领取任务:`,`{{#each ext.list}}`,` - #{{id}} {{title}}`,`{{/each}}`,`先完成当前任务,再领取下一条;不要因为后面还有活就提前收尾或分心。`,`{{/if}}`].join(`
7
+ `),S=`完成之后必须调用 nx-kv localtask done --id {{task.id}} --summary "<完成总结>" 汇报结果。`,C=[`{{#if getloop}}`,`{{getloop.text}}`,`{{/if}}`].join(`
8
+ `),w=Object.freeze([{id:`context`,tag:`nx-kv.context`,label:`组 / 项目上下文`,desc:`任务所在组、项目关键路径与参考文件;直接用 repo / group 变量拼装`,defaultTemplate:g},{id:`attachment`,tag:`nx-kv.attachment`,label:`附件识别`,desc:`任务带附件时出现:数量 / 清单 / 本地路径`,defaultTemplate:_},{id:`timecheck`,tag:`nx-kv.timecheck`,label:`时间目标检查`,desc:`任务带时间目标时出现:check 指令或目录级状态`,defaultTemplate:v},{id:`goalhint`,tag:`nx-kv.goalhint`,label:`特殊功能提示(timegoal)`,desc:`任务带时间目标时出现:可直接用 goal.* 时间变量与 task 全文占位;每轮 check 同源渲染`,defaultTemplate:y},{id:`doneguard`,tag:`nx-kv.doneguard`,label:`完成门禁提示(timegoal)`,desc:`agent 未到点就想 done 时出现(blocked 返回的 guard):说明剩余时间与可做事项,可用 helper 按进度分档`,defaultTemplate:b},{id:`ext`,tag:`nx-kv.ext`,label:`待领取队列(ext)`,desc:`同主题还有多少待领取任务与标题;队列空时不出现`,defaultTemplate:x},{id:`ack`,tag:`nx-kv.ack`,label:`ack 完成总结`,desc:`完成任务时调用 localtask done 回填的指令;默认已内置,可见可改`,defaultTemplate:S},{id:`getloop`,tag:`nx-kv.getloop`,label:`持续 get`,desc:`项目开启「持续 get」时出现:完成本任务并回填后继续领取下一条`,defaultTemplate:C}]);function T(e){let t=String(e??``).trim();return t.length>8e3?t.slice(0,p):t}function E(e){return{id:m,name:h,template:e.defaultTemplate,builtin:!0}}function D(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=String(e.id??``).trim().slice(0,64);return t?{id:t,name:String(e.name??``).trim().slice(0,60)||`未命名模板`,template:T(e.template),builtin:!1}:null}function O(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={};for(let e of w){let r=t[e.id],i=Array.isArray(r)?r:Array.isArray(r?.list)?r.list:[],a=[E(e)],o=new Set([m]);for(let e of i){if(e&&typeof e==`object`&&(e.id===`builtin`||e.builtin))continue;let t=D(e);if(t&&!o.has(t.id)&&(o.add(t.id),a.push(t),a.length>=20))break}let s=String(r?.active??``).trim();n[e.id]={active:a.some(e=>e.id===s)?s:m,list:a}}return n}var k={context:[{label:`项目`,items:[[`repo.name`,`项目名`],[`repo.intro`,`项目介绍正文`],[`repo.introPath`,`介绍全文路径`],[`repo.docs`,`补充文档(可循环 path/tag/note)`],[`repo.docCount`,`补充文档数`],[`repo.refRepos`,`本仓库直接绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`repo.refRepoCount`,`本仓库直接绑定的参考仓库数`]]},{label:`组`,items:[[`group.name`,`组名`],[`group.desc`,`组定位`],[`group.intro`,`组介绍正文`],[`group.note`,`本项目在组里的位置`],[`group.peers`,`组内成员(可循环 name/note)`],[`group.docs`,`组绑定参考文件(可循环)`],[`group.refRepos`,`本组绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`group.refRepoCount`,`本组绑定的参考仓库数`],[`groups`,`其余组(可循环 name/desc/path)`]]},{label:`参考仓库`,items:[[`refRepos.list`,`直接绑定 ∪ 组级绑定的去重并集(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`refRepos.count`,`去重并集的条目数(无绑定时为 0,整段不出现)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`params`,`外部参数(k=v)`]]}],attachment:[{label:`统计`,items:[[`attach.count`,`附件总数`],[`attach.inlineCount`,`正文内嵌数量`],[`attach.areaCount`,`附件区数量`],[`attach.hasInline`,`是否有正文内嵌`],[`attach.hasArea`,`是否有附件区条目`],[`attach.needsSyncCount`,`需要同步到本地的文件数`]]},{label:`附件条目(通用,attach.list 内循环)`,items:[[`kind`,`类型:file / url / task / ref`],[`kindLabel`,`类型显示名:附件/图片/链接/任务/文档`],[`name`,`展示名(任务型为实时标题,不是正文)`],[`size`,`字节数`],[`sizeText`,`可读大小(1.2 MB)`],[`mime`,`MIME 类型`],[`storage`,`存储来源:local / cloud / url / internal`],[`role`,`关系角色:inline / reference / doc / attach`],[`origin`,`来源:inline(正文内嵌)/ area(附件区)`],[`originLabel`,`来源显示名`],[`usage`,`取用说明(按类型生成,含确切命令)`],[`cmd`,`取用命令(file 未同步 / task / ref;url 为空)`],[`locator`,`简短定位串(路径 / 链接 / #seq 标题 / 文档路径)`],[`isImage`,`是否图片(kind=file 的子类型)`],[`needsSync`,`该条是否需要先同步到本地`]]},{label:`文件型(kind=file)· file 子对象`,items:[[`file.localPath`,`本地绝对路径(已同步时才有值)`],[`file.fileId`,`资源 id(未同步时用它拉取)`],[`file.exists`,`本机盘上是否已有副本`],[`file.syncCmd`,`未同步时的命令:nx-kv file sync --ids <fileId>`],[`localPath`,`file.localPath 的平铺别名(旧模板兼容)`],[`fileId`,`file.fileId 的平铺别名`]]},{label:`链接型(kind=url)· url 子对象`,items:[[`url.href`,`可访问的完整链接,可直接抓取`],[`url.host`,`链接域名(host)`],[`href`,`url.href 的平铺别名`],[`host`,`url.host 的平铺别名`],[`urlText`,`链接字符串别名`]]},{label:`任务型(kind=task)· task 子对象`,items:[[`task.taskId`,`本机 tasks.id(join 用;任务被清理后为 0)`],[`task.topicKey`,`任务所在 topic key`],[`task.topicName`,`任务所在 topic 名`],[`task.seq`,`topic 内编号(对外显示的任务号)`],[`task.title`,`实时标题(正文首行,不是正文)`],[`task.status`,`实时状态:pending/claimed/done/cancelled`],[`task.statusLabel`,`状态显示名`],[`task.address`,`地址 topicKey:seq`],[`task.storedAddress`,`附件行里存的旧地址(搬家前)`],[`task.addressDrift`,`地址是否已漂移(任务搬过 topic)`],[`task.resolved`,`正文当前是否可读`],[`task.purged`,`目标任务是否已被清理`],[`task.deleted`,`目标任务是否已软删`],[`task.showCmd`,`取正文命令:nx-kv localtask show --id <seq> --key <topicKey>`],[`seq`,`task.seq 的平铺别名`],[`title`,`task.title 的平铺别名`],[`showCmd`,`task.showCmd 的平铺别名`]]},{label:`文档型(kind=ref)· ref 子对象`,items:[[`ref.refId`,`refs 表 id`],[`ref.title`,`文档标题`],[`ref.relPath`,`文档相对路径 / 外部 md 绝对路径`],[`ref.readCmd`,`读取命令:nx-kv docs get rel:<路径>(或 path:<绝对路径>)`],[`refId`,`ref.refId 的平铺别名`],[`relPath`,`ref.relPath 的平铺别名`],[`readCmd`,`ref.readCmd 的平铺别名`]]},{label:`同步汇总`,items:[[`attach.syncSummary.text`,`本次批量同步的一行汇总`],[`attach.syncSummary.dir`,`同步目录`],[`attach.syncSummary.downloaded`,`已下载数`],[`attach.syncSummary.skipped`,`跳过数`],[`attach.syncSummary.failureCount`,`失败数`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文(交付模板等处仍在用)`]]}],timecheck:[{label:`时间目标`,items:[[`goal.check`,`时间检查指令(任务级;每轮 check 按当下模板渲染)`],[`goal.statusLine`,`目录级目标状态行`],[`goal.name`,`目标名`],[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话,如 2 小时)`],[`goal.durationSec`,`持续秒数`],[`goal.deadline`,`截止时间`],[`goal.remainingSec`,`剩余秒数`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingMin`,`剩余分钟(向上取整)`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`],[`goal.extra`,`发布方附加要求(领取后可动态改)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文`]]}],goalhint:[{label:`时间目标上下文(任务级)`,items:[[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话)`],[`goal.durationSec`,`持续秒数`],[`goal.startedAt`,`开始计时时间`],[`goal.deadline`,`截止时间`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingSec`,`剩余秒数`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`],[`goal.extra`,`发布方附加要求(领取后可动态改)`]]},{label:`任务`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文(check 返回对象同样可用)`]]}],doneguard:[{label:`时间目标上下文(任务级)`,items:[[`goal.blocked`,`恒为 true(只在这条拦截路径上出现,交付渲染时整段省略)`],[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话)`],[`goal.durationSec`,`持续秒数`],[`goal.startedAt`,`开始计时时间`],[`goal.deadline`,`截止时间`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingSec`,`剩余秒数`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`]]},{label:`任务`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文`]]},{label:`可用的 helper(与所有区块同一套)`,items:[[`percent goal.elapsedSec goal.durationSec`,`已用百分比(0 位小数;可加第三参控制小数位)`],[`gte a b / gt / lt / lte / eq / ne / between v min max`,`比较,返回布尔,可直接进 {{#if}}`],[`and / or / not`,`逻辑`],[`add / sub / mul / div / mod / round / floor / ceil / ratio / clamp`,`数值计算(坏输入输出 NaN,不抛错)`],[`includes / length / default`,`字符串`],[`formatDuration`,`秒数转人话`]]}],ext:[{label:`队列`,items:[[`ext.topic`,`主题 / 队列名`],[`ext.count`,`待领取任务数`],[`ext.list`,`待领取清单(可循环 id/title/topic)`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ack:[{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`source`,`任务来源(local/global)`],[`summary`,`领取方现状`],[`name`,`领取方名字`],[`cwd`,`领取方目录`],[`params`,`外部参数(k=v)`]]}],getloop:[{label:`持续 get`,items:[[`getloop.text`,`持续 get 指令正文`],[`getloop.waitMinutes`,`单轮等待分钟数`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}]},A=t();function j({blockId:e}){let t=k[e]||[];return t.length?(0,A.jsxs)(`div`,{className:`setp-params`,"aria-label":`可使用参数`,children:[(0,A.jsx)(`div`,{className:`setp-params-head`,children:`可使用参数`}),t.map(e=>(0,A.jsxs)(`div`,{className:`setp-params-row`,children:[(0,A.jsx)(`span`,{className:`setp-params-label`,children:e.label}),(0,A.jsx)(`div`,{className:`setp-params-items`,children:e.items.map(([e,t])=>(0,A.jsxs)(`span`,{className:`setp-param`,children:[(0,A.jsx)(`code`,{children:e}),(0,A.jsx)(`span`,{children:t})]},e))})]},e.label))]}):null}function M(){return`bt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function N(e){return w.find(t=>t.id===e)||w[0]}function P(e,t,n){let r=e[t];return r.list.find(e=>e.id===n)||r.list.find(e=>e.id===r.active)||r.list[0]}function F(){let e=i(),{dialog:t,node:a}=n(),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(w[0].id),[p,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),v=(e,t=null)=>{s(t=>({...t||{},lists:e}));let n=t||(p&&p.blockId===c?p:null),r=n?.blockId||c,i=P(e,r,n?.id||e[r].active);h({blockId:r,id:i.id,name:i.name,template:i.template})},y=()=>{r(`/api/localtasks`).then(e=>{let t=e?.settings||{},n=O(t.blockTemplates),r=t.appendMode===`plain`?`plain`:`xml`;s({lists:n,appendMode:r});let i=w[0],a=P(n,i.id,n[i.id].active);l(i.id),h({blockId:i.id,id:a.id,name:a.name,template:a.template})}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,d.useEffect)(y,[]),!o)return(0,A.jsx)(`div`,{className:`setp-note`,children:`读取提示词模板…`});let b=N(c),x=f.find(e=>e.id===o.appendMode)||f[0],S=o.lists[c],C=p?.id===m,T=async(t,n,i=null)=>{if(!g){_(!0);try{let a=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{blockTemplates:t}});v(O(a?.blockTemplates),i),e(n)}catch(t){e(String(t.message||t))}finally{_(!1)}}},E=()=>JSON.parse(JSON.stringify(o.lists)),D=e=>{if(g)return;l(e);let t=P(o.lists,e,o.lists[e].active);h({blockId:e,id:t.id,name:t.name,template:t.template})},k=e=>{let t=P(o.lists,c,e);h({blockId:c,id:t.id,name:t.name,template:t.template})},F=e=>h(t=>({...t,...e})),I=()=>{if(C){e(`系统内置模板不可编辑;请先「复制」一份再改`);return}let t=String(p.name||``).trim().slice(0,60)||`未命名模板`,n=String(p.template??``),r=E(),i=r[c],a=i.list.findIndex(e=>e.id===p.id),o={id:p.id,name:t,template:n,builtin:!1};a>=0?i.list[a]=o:i.list.push(o),T(r,`已保存模板(当前生效项保存后立即生效)`,{blockId:c,id:p.id})},L=()=>{if(g)return;let e=E(),t={id:M(),name:`新模板`,template:``,builtin:!1};e[c].list.push(t),T(e,`已新建模板,填写后保存,再点「启用」`,{blockId:c,id:t.id})},R=(e=p?.id)=>{if(g||!e)return;let t=P(o.lists,c,e),n=E(),r={id:M(),name:`${t.name||`模板`} 副本`.slice(0,60),template:t.template||``,builtin:!1};n[c].list.push(r),T(n,`已复制模板`,{blockId:c,id:r.id})},z=()=>{if(g||C)return;let e=String(p.name||``).trim().slice(0,60)||`未命名模板`,t=E(),n=t[c],r=n.list.findIndex(e=>e.id===p.id),i={id:p.id,name:e,template:String(p.template??``),builtin:!1};r>=0?n.list[r]=i:n.list.push(i),n.active=p.id,T(t,`已保存并启用「${e}」`,{blockId:c,id:p.id})},B=e=>{if(g||e===S.active)return;let t=E();t[c].active=e,T(t,`已启用「${P(o.lists,c,e).name}」`,{blockId:c,id:e})},V=async n=>{if(g)return;if(n===`builtin`){e(`系统内置模板不可删除`);return}let r=P(o.lists,c,n);if(!await t({title:`删除模板?`,message:`将删除「${r.name}」,保存后不可恢复。该区块的系统内置模板会保留。`,okText:`删除`,danger:!0}))return;let i=E(),a=i[c];a.list=a.list.filter(e=>e.id!==n),a.active===n&&(a.active=m),T(i,`已删除模板,当前生效项已回落到系统内置`)},H=()=>{if(g||S.active===`builtin`)return;let e=E();e[c].active=m,T(e,`已恢复系统内置模板`,{blockId:c,id:m})},U=async t=>{if(!(g||t===o.appendMode)){_(!0);try{let n=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{appendMode:t}});s(e=>({...e,appendMode:n?.appendMode===`plain`?`plain`:`xml`})),e(`已保存追加模式(全局生效)`)}catch(t){e(String(t.message||t))}finally{_(!1)}}};return(0,A.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,A.jsxs)(`div`,{className:`setp-tpl-head`,children:[(0,A.jsx)(`span`,{className:`setp-tpl-head-label`,children:`系统提示词追加方式`}),(0,A.jsx)(`div`,{className:`setp-seg`,role:`group`,"aria-label":`系统提示词追加方式`,children:f.map(e=>(0,A.jsx)(`button`,{type:`button`,className:`setp-seg-btn`+(o.appendMode===e.id?` is-on`:``),"aria-pressed":o.appendMode===e.id,title:e.desc,disabled:g,onClick:()=>U(e.id),children:e.label},e.id))}),(0,A.jsx)(`span`,{className:`setp-note`,children:x.desc})]}),(0,A.jsx)(`nav`,{className:`setp-block-tabs`,"aria-label":`提示词区块`,children:w.map(e=>{let t=P(o.lists,e.id,o.lists[e.id].active);return(0,A.jsxs)(`button`,{type:`button`,className:`setp-block-tab`+(e.id===c?` is-on`:``),disabled:g,onClick:()=>D(e.id),children:[(0,A.jsx)(`span`,{children:e.label}),(0,A.jsx)(`small`,{children:t.builtin?`系统内置`:t.name})]},e.id)})}),(0,A.jsxs)(`div`,{className:`setp-block-card`,children:[(0,A.jsxs)(`div`,{className:`setp-block-card-head`,children:[(0,A.jsxs)(`div`,{className:`setp-block-card-title`,children:[(0,A.jsx)(`b`,{children:b.label}),(0,A.jsx)(`span`,{className:`setp-note`,children:b.desc})]}),(0,A.jsxs)(`div`,{className:`setp-block-card-actions`,children:[(0,A.jsx)(u,{variant:`secondary`,disabled:g,onClick:L,children:`新建模板`}),(0,A.jsx)(u,{variant:`secondary`,disabled:g||S.active===`builtin`,onClick:H,children:`恢复内置`})]})]}),(0,A.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`${b.label}模板列表`,children:S.list.map(e=>{let t=e.id===S.active,n=e.id===p?.id;return(0,A.jsxs)(`div`,{className:`setp-tpl-pick${t?` is-on`:``}${n?` is-sel`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`setp-tpl-name`,title:e.name,onClick:()=>k(e.id),children:[(0,A.jsx)(`span`,{className:`setp-tpl-name-text`,children:e.name}),e.builtin&&(0,A.jsx)(`span`,{className:`setp-badge`,children:`内置`}),t&&(0,A.jsx)(`span`,{className:`setp-badge`,children:`启用中`})]}),(0,A.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g,title:e.builtin?`复制系统内置模板`:`复制该模板`,onClick:()=>R(e.id),children:`复制`}),(0,A.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g||t,title:`设为该区块当前生效模板`,onClick:()=>B(e.id),children:`启用`}),(0,A.jsx)(u,{variant:`secondary`,danger:!0,className:`setp-tpl-act`,disabled:g||e.builtin,title:e.builtin?`系统内置模板不可删除`:`删除该模板`,onClick:()=>V(e.id),children:`删除`})]},e.id)})}),p&&(0,A.jsxs)(`div`,{className:`setp-tpl-editor-box`,children:[(0,A.jsxs)(`div`,{className:`setp-tpl-editor-head`,children:[(0,A.jsx)(`span`,{children:C?`系统内置`:`编辑 · ${p.name||`未命名模板`}`}),(0,A.jsx)(`span`,{className:`setp-note`,children:p.id===S.active?`当前生效,保存后立即参与领取`:`未启用;保存后可点「启用」`})]}),!C&&(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`模板名`}),(0,A.jsx)(`div`,{className:`setp-input`,children:(0,A.jsx)(`input`,{value:p.name,maxLength:60,disabled:g,onChange:e=>F({name:e.target.value})})})]}),(0,A.jsx)(`textarea`,{className:`setp-area setp-tpl-textarea`,value:p.template,readOnly:C,spellCheck:!1,disabled:g,placeholder:C?``:`在这里写该区块的模板`,onChange:e=>F({template:e.target.value})}),(0,A.jsx)(j,{blockId:c}),(0,A.jsxs)(`div`,{className:`setp-proj-a`,children:[C?(0,A.jsx)(u,{variant:`secondary`,disabled:g,onClick:R,children:`复制为我的模板`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(u,{variant:`primary`,disabled:g,onClick:I,children:`保存`}),(0,A.jsx)(u,{variant:`secondary`,disabled:g,onClick:y,children:`撤销改动`}),p.id!==S.active&&(0,A.jsx)(u,{variant:`secondary`,disabled:g,onClick:z,children:`保存并启用`})]}),(0,A.jsx)(`span`,{className:`spacer`})]})]})]}),a]})}function I(){let e=s()||{},t=e.rows||[],n=e.repoData&&e.repoData.repos||[],r=e.repoData&&e.repoData.boards||[];return(0,d.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function L(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a={topic:`目录`,repo:`项目`,group:`组`}[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function R({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:a=`setp`}){let o=i(),s=I(),c=r||s,[l,u]=(0,d.useState)(null),f=Array.isArray(e)?e:[],p=f.includes(`*`),m=f.filter(e=>e!==`*`),h=a,g=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,_=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},v=async e=>{if(f.includes(e)){o(`已经在可见范围里了`),u(null);return}await _([...f,e]),u(null)},y=(0,d.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,A.jsxs)(`div`,{className:`${h}-scope-block`,children:[(0,A.jsx)(`div`,{className:`${h}-scope`,children:f.map(e=>(0,A.jsxs)(`button`,{type:`button`,className:`${h}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>_(f.filter(t=>t!==e)),children:[L(e,c),` ×`]},e))}),(0,A.jsxs)(`div`,{className:`${h}-scope-add`,children:[(0,A.jsx)(`span`,{className:`${h}-scope-add-label`,children:`添加`}),(0,A.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`,disabled:p,title:p?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!p&&_([`*`,...m]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,A.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:{topic:`目录`,repo:`项目`,group:`组`}[e]},e)),g?(0,A.jsxs)(`span`,{className:`${h}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,g]}):null]}),l&&(0,A.jsx)(`div`,{className:`${h}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:y.length?y.map(e=>(0,A.jsxs)(`button`,{type:`button`,className:`${h}-scope-pick-it`,disabled:f.includes(e.entry),title:e.sub||e.entry,onClick:()=>v(e.entry),children:[(0,A.jsx)(`span`,{className:`${h}-scope-pick-name`,children:e.label}),f.includes(e.entry)?(0,A.jsx)(`span`,{className:`${h}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,A.jsx)(`div`,{className:`${h}-scope-pick-empty`,children:`暂无可选项`})})]})}function z({openTemplateEditor:e}){let t=c(),r=i(),{dialog:a,node:o}=n(),s=t.templates||[],[l,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1);if(t.unsupported)return(0,A.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`});let h=async(e,t)=>{if(!p){m(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{m(!1)}}},g=async e=>{await a({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&(await h(()=>t.remove(e.id),`已删除「${e.name}」`),l===e.id&&f(null))};return(0,A.jsxs)(`div`,{className:`setp-tpl setp-tpl-cards`,children:[o,!s.length&&(0,A.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`}),s.map(n=>{let r=n.id===t.defaultId,i=l===n.id;return(0,A.jsxs)(`div`,{className:`setp-tpl-card`+(r?` is-default`:``),children:[(0,A.jsxs)(`div`,{className:`setp-tpl-card-head`,children:[(0,A.jsx)(`span`,{className:`setp-tpl-card-name`,children:n.name}),r&&(0,A.jsx)(`span`,{className:`setp-badge`,children:`默认`}),n.builtin&&(0,A.jsx)(`span`,{className:`setp-badge soft`,children:`内置`})]}),i&&(0,A.jsx)(`div`,{className:`setp-tpl-card-scope`,children:(0,A.jsx)(R,{scope:n.scope,originTopic:n.originTopic,onChange:e=>t.update(n.id,{scope:e})})}),(0,A.jsxs)(`div`,{className:`setp-tpl-card-foot`,children:[(0,A.jsx)(`span`,{className:`grow`}),(0,A.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>f(i?null:n.id),children:`可见绑定`}),(0,A.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({id:n.id,name:n.name,mode:`edit`}),children:`编辑`}),!r&&(0,A.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>h(()=>t.setDefault(n.id),`默认模板已设为「${n.name}」`),children:`设为默认`}),!n.builtin&&(0,A.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>g(n),children:`删除`})]})]},n.id)}),(0,A.jsx)(`div`,{className:`setp-tpl-card-new`,children:(0,A.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({mode:`new`,scope:[]}),children:`+ 新建模板`})})]})}function B(){let e=i(),t=s()||{},n=t.patchPrefs,[a,o]=(0,d.useState)([]),[c,l]=(0,d.useState)([]),[u,f]=(0,d.useState)([]),p=(0,d.useCallback)(()=>{Promise.all([r(`/api/repos`),r(`/api/boards`)]).then(([e,n])=>{o(Array.isArray(e)?e:e?.repos||[]),l(Array.isArray(n)?n:n?.boards||[]),f(t.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,t.prefs]);(0,d.useEffect)(()=>{p()},[p]);let m=e=>{let r=t.prefs?.hidden||[],i=r.includes(e)?r.filter(t=>t!==e):[...r,e];n&&n({hidden:i}),f(i)},h=(e,t,n,r)=>(0,A.jsx)(`div`,{className:`setp-row`,children:(0,A.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>m(t)}),(0,A.jsx)(`span`,{children:n}),r?(0,A.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,A.jsxs)(`div`,{className:`setp-side`,children:[(0,A.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,A.jsx)(`div`,{className:`setp-row`,children:(0,A.jsx)(`span`,{children:`项目组(指针)`})}),c.map(e=>h(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!c.length&&(0,A.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,A.jsx)(`div`,{className:`setp-row`,children:(0,A.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),a.map(e=>h(`repo`,e.key||e.id,e.name,e.path)),!a.length&&(0,A.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var V=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`taskTemplates`,label:`任务模板`,icon:`list`},{id:`prompts`,label:`提示词模板`,icon:`flow`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`}];function H(){let e=s()||{},t=i(),{dialog:o,node:c}=n(),f=e.prefs||{},p=e.patchPrefs||(()=>{}),m=e.model,[h,g]=(0,d.useState)(`pref`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),x=(0,d.useCallback)(async()=>{try{v(await r(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,d.useEffect)(()=>{x()},[x]);let S=e=>e().catch(e=>t(String(e.message||e))),C=e=>S(async()=>{b(!0);try{v(await r(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{b(!1)}}),w={pref:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`侧边栏默认收起`}),(0,A.jsxs)(`button`,{className:`toggle`+(f.defaultFolded?` on`:``),onClick:()=>p({defaultFolded:!f.defaultFolded}),children:[(0,A.jsx)(`span`,{className:`dot`}),f.defaultFolded?`开`:`关`]})]}),(f.hidden||[]).length>0&&(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsxs)(`span`,{children:[`隐藏仓库 `,f.hidden.length,` 个`]}),(0,A.jsx)(u,{variant:`secondary`,onClick:()=>p({hidden:[]}),children:`恢复显示`})]})]}),work:(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`布局`}),(0,A.jsx)(u,{variant:`secondary`,onClick:async()=>{await o({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,A.jsxs)(`button`,{className:`toggle`+(_&&_.autoSyncAttachments?` on`:``),disabled:!_||y,onClick:()=>C({autoSyncAttachments:!_.autoSyncAttachments}),children:[(0,A.jsx)(`span`,{className:`dot`}),_&&_.autoSyncAttachments?`开`:`关`]})]}),(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`附件目录`}),(0,A.jsxs)(`span`,{className:`setp-input`,children:[(0,A.jsx)(`input`,{value:_&&_.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>v(t=>({...t,attachmentsDir:e.target.value}))}),(0,A.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({attachmentsDir:_.attachmentsDir}),children:`保存`})]})]}),(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`参考仓库存储根`}),(0,A.jsxs)(`span`,{className:`setp-input`,children:[(0,A.jsx)(`input`,{value:_&&_.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>v(t=>({...t,gitRepoRoot:e.target.value}))}),(0,A.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitRepoRoot:_.gitRepoRoot}),children:`保存`})]})]}),(0,A.jsxs)(`div`,{className:`setp-row`,children:[(0,A.jsx)(`span`,{children:`开发仓库克隆根`}),(0,A.jsxs)(`span`,{className:`setp-input`,children:[(0,A.jsx)(`input`,{value:_&&_.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>v(t=>({...t,gitDevRoot:e.target.value}))}),(0,A.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitDevRoot:_.gitDevRoot}),children:`保存`})]})]})]}),taskTemplates:(0,A.jsx)(z,{openTemplateEditor:e=>{m&&l(m,e||{})}}),prompts:(0,A.jsx)(F,{}),sidebar:(0,A.jsx)(B,{})};return(0,A.jsxs)(`div`,{className:`setp`,children:[(0,A.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:V.map(e=>(0,A.jsxs)(`button`,{className:`setp-navitem`+(h===e.id?` on`:``),"aria-current":h===e.id,onClick:()=>g(e.id),children:[(0,A.jsx)(a,{name:e.icon,size:14}),(0,A.jsx)(`span`,{children:e.label})]},e.id))}),(0,A.jsxs)(`div`,{className:`setp-body`,children:[(0,A.jsx)(`div`,{className:`setp-h`,children:V.find(e=>e.id===h).label}),w[h]]}),c]})}export{H as default};
@@ -1 +1 @@
1
- import{h as e}from"./task-status-BnymQMTw.js";import{b as t,v as n,y as r}from"./index-D2fKyD1k.js";var i=e();function a({t:e,short:a=!1,className:o=``,title:s}){let c=t(e);return(0,i.jsx)(`span`,{className:`tstat tstat-`+c+(a?` tstat-short`:``)+(o?` `+o:``),title:s||(a?n(e):void 0),children:a?r(e):n(e)})}export{a as t};
1
+ import{h as e}from"./task-status-BnymQMTw.js";import{b as t,v as n,y as r}from"./index-ChlZPTea.js";var i=e();function a({t:e,short:a=!1,className:o=``,title:s}){let c=t(e);return(0,i.jsx)(`span`,{className:`tstat tstat-`+c+(a?` tstat-short`:``)+(o?` `+o:``),title:s||(a?n(e):void 0),children:a?r(e):n(e)})}export{a as t};
@@ -1,4 +1,4 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,t as l,v as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{n as f,r as p,t as m}from"./frontmatter-QvrjUNzF.js";import{a as h,g,h as _,i as v,m as y,n as b,p as x,r as S,t as C,u as w,v as T}from"./md-history-CfpJ9GT6.js";import{a as E,r as D}from"./md-parse-awNLHAzO.js";import{n as O,t as k}from"./board-view-CZKZsyk-.js";import{c as A,d as ee,f as j,h as M,l as N,m as P,p as F,s as I,u as L}from"./index-D2fKyD1k.js";import{t as R}from"./status-tag-BhZgdBJz.js";import{a as z,i as B,n as te,o as V}from"./composer-launch-Bf4rXhLs.js";import{t as ne}from"./route-crumb-CvrRU1gp.js";import{i as re,n as H,r as U,t as W}from"./reopen-text-BylkngqC.js";import{n as ie,u as ae}from"./tool-bar-D5yvblnb.js";var G=s(e(),1),K=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,q=/完成总结/,J=/反馈/,oe=/第\s*(\d+)\s*轮/;function se(e){let t=String(e??``).split(`
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,t as l,v as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{n as f,r as p,t as m}from"./frontmatter-QvrjUNzF.js";import{a as h,g,h as _,i as v,m as y,n as b,p as x,r as S,t as C,u as w,v as T}from"./md-history-CBqcR086.js";import{a as E,r as D}from"./md-parse-awNLHAzO.js";import{n as O,t as k}from"./board-view-CZKZsyk-.js";import{c as A,d as ee,f as j,h as M,l as N,m as P,p as F,s as I,u as L}from"./index-ChlZPTea.js";import{t as R}from"./status-tag-BK-45ld2.js";import{a as z,i as B,n as te,o as V}from"./composer-launch-Bf4rXhLs.js";import{t as ne}from"./route-crumb-PqhQSVWL.js";import{i as re,n as H,r as U,t as W}from"./reopen-text-BylkngqC.js";import{n as ie,u as ae}from"./tool-bar-TIqYxsQl.js";var G=s(e(),1),K=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,q=/完成总结/,J=/反馈/,oe=/第\s*(\d+)\s*轮/;function se(e){let t=String(e??``).split(`
2
2
  `),n=t.length&&String(t[0]).match(K);if(!n)return null;let r=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
3
3
  `);return{title:String(n[1]??``).trim(),body:r}}function ce(e){let t=y(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=se(a);if(o&&q.test(o.title)){let e=Number((o.title.match(oe)||[])[1]);r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&J.test(o.title)){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
4
4
  `:``)+a:r.feedbackText+=(r.feedbackText?`
@@ -1 +1 @@
1
- import{g as e,h as t,p as n,y as r}from"./task-status-BnymQMTw.js";import{n as i,v as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,r as u,t as d,v as f}from"./md-history-CfpJ9GT6.js";import{i as p,t as m}from"./index-D2fKyD1k.js";import{t as h}from"./route-crumb-CvrRU1gp.js";var g=r(e(),1),_=t(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:t,initialBody:r,isNew:i,onSave:a,onClose:o,busy:p}){let m=n(),[y,b]=(0,g.useState)(t||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(i?`new`:e),A=(0,g.useMemo)(()=>f(x||``),[x]),j=(e,t,n=`typing`)=>{l(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=c(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=u(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){m(`模板名不能为空(标题即名称)`);return}await a({name:y.trim(),body:x}),d(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:p,onClick:o,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:p||!T,onClick:I,children:i?`创建`:`保存`})]})]}),(0,_.jsx)(s,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:t,tabId:r}){let s=o()||{},c=s.tpl,l=n(),[u,d]=(0,g.useState)(!1),f=e||{},v=(f.mode||(f.id?`edit`:``))===`new`,b=f.id||``,x=()=>{let e=m();if(e&&s.onNavigate){s.onNavigate(e);return}if(s.onNavigate){s.onNavigate(`#/overview`);return}if(t&&r)try{t.doAction(a.deleteTab(r))}catch{}};if(!c)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{t&&i(t,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(c.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{d(!0);try{if(v){let n={};Array.isArray(f.scope)&&(n.scope=f.scope),f.topic&&(n.topic=f.topic),await c.add(e,t,!1,n),l(`已创建模板`)}else await c.update(b,{name:e,body:t}),l(`已保存模板`);x()}catch(e){l(String(e.message||e))}finally{d(!1)}},w=v?f.name||``:S.name,T=v?``:p(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:u,onSave:C,onClose:x},v?`new:${f.topic||``}:${(f.scope||[]).join(`,`)}`:b)}export{b as default};
1
+ import{g as e,h as t,p as n,y as r}from"./task-status-BnymQMTw.js";import{n as i,v as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,r as u,t as d,v as f}from"./md-history-CBqcR086.js";import{i as p,t as m}from"./index-ChlZPTea.js";import{t as h}from"./route-crumb-PqhQSVWL.js";var g=r(e(),1),_=t(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:t,initialBody:r,isNew:i,onSave:a,onClose:o,busy:p}){let m=n(),[y,b]=(0,g.useState)(t||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(i?`new`:e),A=(0,g.useMemo)(()=>f(x||``),[x]),j=(e,t,n=`typing`)=>{l(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=c(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=u(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){m(`模板名不能为空(标题即名称)`);return}await a({name:y.trim(),body:x}),d(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:p,onClick:o,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:p||!T,onClick:I,children:i?`创建`:`保存`})]})]}),(0,_.jsx)(s,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:t,tabId:r}){let s=o()||{},c=s.tpl,l=n(),[u,d]=(0,g.useState)(!1),f=e||{},v=(f.mode||(f.id?`edit`:``))===`new`,b=f.id||``,x=()=>{let e=m();if(e&&s.onNavigate){s.onNavigate(e);return}if(s.onNavigate){s.onNavigate(`#/overview`);return}if(t&&r)try{t.doAction(a.deleteTab(r))}catch{}};if(!c)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{t&&i(t,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(c.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{d(!0);try{if(v){let n={};Array.isArray(f.scope)&&(n.scope=f.scope),f.topic&&(n.topic=f.topic),await c.add(e,t,!1,n),l(`已创建模板`)}else await c.update(b,{name:e,body:t}),l(`已保存模板`);x()}catch(e){l(String(e.message||e))}finally{d(!1)}},w=v?f.name||``:S.name,T=v?``:p(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:u,onSave:C,onClose:x},v?`new:${f.topic||``}:${(f.scope||[]).join(`,`)}`:b)}export{b as default};
@@ -1 +1 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,y as o}from"./task-status-BnymQMTw.js";import{w as s}from"./workspace-C_5X2gIr.js";import{c,d as l,f as u,l as d,o as f,s as p}from"./md-history-CfpJ9GT6.js";import{n as m,o as h}from"./upload-BIMbGcCB.js";var g=o(e(),1),_=t(),v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y({host:e=`task`,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d={file:!0,url:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=a(),{dialog:k,node:A}=n(),[j,M]=(0,g.useState)([]),[N,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(`position`),[G,K]=(0,g.useState)(null),[q,J]=(0,g.useState)(null),[Y,ee]=(0,g.useState)(!1),[X,Z]=(0,g.useState)(null),Q=(0,g.useMemo)(()=>l(e,{hostId:t,hostKey:o,hostCwd:s,refId:c}),[e,t,o,s,c]),$=(0,g.useCallback)(async()=>{if(S){M([]);return}P(!0),I(``);try{let e=await Q.list();M((e.attachments||[]).map(u))}catch(e){I(String(e&&e.message||e))}finally{P(!1)}},[Q,S]);(0,g.useEffect)(()=>{$()},[$]),(0,g.useImperativeHandle)(w,()=>({open:()=>R(!0),refresh:$}),[$]),(0,g.useEffect)(()=>{if(!X)return;let e=e=>{e.key===`Escape`&&Z(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[X]);let te=(0,g.useMemo)(()=>[...j].sort(v[U]||v.position),[j,U]),ne=te.filter(e=>e.area===`inline`),re=te.filter(e=>e.area===`area`),ie=async(e,t)=>{if(S)return;let n=m(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;H(!0);let i=0;for(let e of r)try{let t=await h(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Q.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}H(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await $(),T?.())},ae=async n=>{if(n)try{let i=await k({title:`说明 · ${n.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:n.note||``,okText:`保存说明`});if(i===null)return;let a=typeof i==`string`?i:i&&(i.value||i.note)||``,l=e===`doc`?`/api/docs/attach-note?ref=${encodeURIComponent(String(c||``))}`:`/api/localtasks/attach-note`,u=e===`doc`?{attachment:n.id,note:a}:{id:Number(t),...o?{key:o}:s?{cwd:s}:{},attachment:n.id,note:a};await r(l,{method:`PATCH`,body:u}),O(a?`已保存说明:${a}`:`已清空说明`),await $(),T?.()}catch(e){O(`改说明失败:${e&&e.message||e}`)}},oe=e=>{e&&(J(e),R(!0))},se=async e=>{let t=G;if(t){ee(!0);try{await Q.detach(t.id,!!e),K(null),O(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await $(),T?.()}catch(e){O(`移除失败:${e&&e.message||e}`)}finally{ee(!1)}}},ce=!N&&!F&&!j.length;return(0,_.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),B(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||B(!1)},onDrop:e=>{B(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ie(null,e))},children:[A,(0,_.jsxs)(`div`,{className:`att-area-head`+(z&&!S?` is-over`:``),children:[(0,_.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,j.length?(0,_.jsx)(`span`,{className:`att-count`,children:j.length}):null,V?(0,_.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,_.jsxs)(`span`,{className:`att-area-acts`,children:[j.length?(0,_.jsxs)(`select`,{className:`att-sort`,value:U,onChange:e=>W(e.target.value),"aria-label":`附件排序`,children:[(0,_.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,_.jsx)(`option`,{value:`name`,children:`按名称`}),(0,_.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>R(!0),children:`添加附件`})]})]}),S?(0,_.jsx)(`div`,{className:`att-empty`,children:C}):null,N?(0,_.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,F?(0,_.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,F]}):null,ce?(0,_.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,ne.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.inline,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),ne.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,re.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.area,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),re.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,(0,_.jsx)(f,{open:L,host:e,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d,taskOptions:y,docOptions:x,replaceAttachment:q?q.id:null,replaceNote:q&&q.note||``,onClose:()=>{R(!1),J(null)},onDone:async()=>{J(null),await $(),T?.()}}),G?(0,_.jsx)(i,{title:`移除附件`,size:`sm`,busy:Y,onClose:Y?void 0:()=>K(null),footer:(0,_.jsxs)(`div`,{className:`att-foot`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:Y,onClick:()=>K(null),children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn`,disabled:Y,onClick:()=>se(!1),children:`只解除关联`}),(0,_.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:Y,onClick:()=>se(!0),children:G.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,_.jsxs)(`div`,{className:`att-confirm`,children:[(0,_.jsx)(`div`,{className:`att-confirm-name`,children:G.name}),(0,_.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,X?(0,_.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&Z(null)},children:(0,_.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,_.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,_.jsx)(`span`,{className:`att-lightbox-name`,children:X.name}),(0,_.jsx)(`a`,{className:`att-lightbox-open`,href:X.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,_.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>Z(null),children:`×`})]}),(0,_.jsx)(`img`,{className:`att-lightbox-img`,src:X.src,alt:X.name})]})}):null]})}function b(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i,onEditNote:a,onReplace:o}){let s=e.kind===`image`?d(e.id):``;return(0,_.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,_.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:s,name:e.name}),title:`点击看大图`,children:(0,_.jsx)(`img`,{src:s,alt:e.name,loading:`lazy`})}):(0,_.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,_.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,_.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,_.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,_.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,_.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,_.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>a?.(e),children:`✎ 说明`}),(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>o?.(e),children:`⇄ 更换`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var x=s(),S=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],C=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],w=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],T=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],E=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],D=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],O={dir:Object.fromEntries(S.map(e=>[e.id,e])),group:Object.fromEntries(C.map(e=>[e.id,e])),task:Object.fromEntries(w.map(e=>[e.id,e])),doc:Object.fromEntries(T.map(e=>[e.id,e])),repos:Object.fromEntries(E.map(e=>[e.id,e])),"repos-row":Object.fromEntries(D.map(e=>[e.id,e]))};function k(e){return e===`group`?C:e===`task`?w:e===`doc`?T:e===`repos`?E:e===`repos-row`?D:S}function A(e,t){return O[e]&&O[e][t]||{}}function j(e,t){let n=A(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function M(e,t){return A(e,t.id).noHide?!0:t.visible===void 0?!j(e,t.id):t.visible!==!1}function N(e,t){return t.id===`more`||A(e,t.id).noHide?!1:!M(e,t)}function P(e,t){let n=k(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=A(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!j(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(j(e,a[t].id)&&!M(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function F(e){return P(e,k(e).map(t=>({id:t.id,visible:t.noHide?!0:!j(e,t.id)})))}var I=e=>`nx-kv-tb-${e}`;function L(e){let[t,n]=(0,g.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(I(e)));if(Array.isArray(t))return P(e,t)}catch{}return F(e)});return(0,g.useEffect)(()=>{try{localStorage.setItem(I(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(F(e))}}function R(e,t){return!!A(e,t).lockLast}function z(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function B(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||R(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=A(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>R(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function V(e,t,n,r){let i=t.filter(t=>M(e,t)&&!R(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return B(e,t,{id:n,anchorId:s.id,after:r>0})}function H({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,g.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=i.filter(t=>M(e,t)),f=i.filter(t=>N(e,t)),p=d.filter(t=>!R(e,t.id)),m=()=>{let t=u.current;return t&&!R(e,t.id)?t:null},h=(t,n)=>{R(e,n.id)||(u.current={id:n.id,onBar:M(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>B(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=m();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=m();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=m();n&&!A(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=m();v(),n&&!A(e,n.id).noHide&&a(e=>z(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},O=(e,t)=>{let n=m();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},k=(e,t)=>{let n=D(t);t.preventDefault();let r=m();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},j=t=>{A(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return z(n,t,{visible:!(r&&M(e,r))})})},P=(t,n)=>a(r=>V(e,r,t.id,n)),I=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),P(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),P(e,1)))},L=()=>{n(i),r()},H=()=>a(F(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,R(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,_.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,_.jsxs)(`div`,{className:`tlp-head`,children:[(0,_.jsx)(`b`,{children:`自定义工具栏`}),(0,_.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,_.jsxs)(`div`,{className:`tlp-body`,children:[(0,_.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,_.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,_.jsx)(`span`,{className:[`tlp-chip`,A(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!R(e,t.id),role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,onDragOver:e=>O(t,e),onDrop:e=>k(t,e),children:A(e,t.id).label||t.id},t.id)})})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,_.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>R(e,t.id))?(0,_.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=A(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,_.jsxs)(`div`,{className:U(t,!0),draggable:!R(e,t.id),"data-row-id":t.id,tabIndex:R(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>I(t,e),onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:R(e,t.id)?`锁定`:`拖动排序`,children:R(e,t.id)?`·`:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>j(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,_.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,_.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),R(e,t.id)?null:(0,_.jsxs)(`span`,{className:`tlp-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>P(t,-1),children:`↑`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>P(t,1),children:`↓`})]})]},t.id)})]})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,_.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=A(e,t.id);return(0,_.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>j(t.id),title:`显示到工具栏`}),(0,_.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,_.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,_.jsxs)(`div`,{className:`tlp-foot`,children:[(0,_.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:L,children:`保存`})]})]})}var U=`task`,W=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function G(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)({x:0,y:0}),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function K({menu:e,className:t=``,style:n,children:r}){return e.open?(0,x.createPortal)((0,_.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function q(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function J({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:m,onMark:h,onDraft:v,onDelete:y,onOverview:b,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=G(),{layout:O,setLayout:k}=L(U),[j,P]=(0,g.useState)(!1);(0,g.useEffect)(()=>{D.setOpen(!1)},[e]);let F={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":m&&{label:`取消任务`,run:m,danger:!0},mark:n&&h&&{label:`评论`,run:h},delete:y&&{label:`删除`,run:y,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:b&&{label:`总览`,run:b},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},I=e=>e===`more`||!!F[e],R=O.filter(e=>M(U,e)&&I(e.id)),z=O.filter(e=>N(U,e)&&I(e.id)),B=e=>{F[e]?.run?.(),D.setOpen(!1)},V=e=>{if(e===`more`)return(0,_.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>q(D,e,`right`),children:`更多`})},`more`);let t=F[e];return t?(0,_.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>B(e),children:t.label},e):null},J=W.map(e=>({...e,items:z.filter(t=>A(U,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!A(U,e.id).menuGroup);return(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,_.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>q(D,e,`right`),children:T.label})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>V(e.id)),(0,_.jsxs)(K,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,_.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,_.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=F[e.id],n=t?.danger||A(U,e.id).danger;return(0,_.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>B(e.id),children:[t?.label||A(U,e.id).label||e.id,t?.hint?(0,_.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=F[e.id];return(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||A(U,e.id).danger?` danger`:``),onClick:()=>B(e.id),children:t?.label||A(U,e.id).label||e.id},e.id)}),(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),j&&(0,x.createPortal)((0,_.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,_.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,_.jsx)(H,{kind:U,layout:O,setLayout:k,onClose:()=>P(!1)})})}),document.body)]})}export{H as a,A as c,G as i,M as l,J as n,L as o,q as r,N as s,K as t,y as u};
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,y as o}from"./task-status-BnymQMTw.js";import{w as s}from"./workspace-C_5X2gIr.js";import{c,d as l,f as u,l as d,o as f,s as p}from"./md-history-CBqcR086.js";import{n as m,o as h}from"./upload-BIMbGcCB.js";var g=o(e(),1),_=t(),v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y({host:e=`task`,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d={file:!0,url:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=a(),{dialog:k,node:A}=n(),[j,M]=(0,g.useState)([]),[N,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(`position`),[G,K]=(0,g.useState)(null),[q,J]=(0,g.useState)(null),[Y,ee]=(0,g.useState)(!1),[X,Z]=(0,g.useState)(null),Q=(0,g.useMemo)(()=>l(e,{hostId:t,hostKey:o,hostCwd:s,refId:c}),[e,t,o,s,c]),$=(0,g.useCallback)(async()=>{if(S){M([]);return}P(!0),I(``);try{let e=await Q.list();M((e.attachments||[]).map(u))}catch(e){I(String(e&&e.message||e))}finally{P(!1)}},[Q,S]);(0,g.useEffect)(()=>{$()},[$]),(0,g.useImperativeHandle)(w,()=>({open:()=>R(!0),refresh:$}),[$]),(0,g.useEffect)(()=>{if(!X)return;let e=e=>{e.key===`Escape`&&Z(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[X]);let te=(0,g.useMemo)(()=>[...j].sort(v[U]||v.position),[j,U]),ne=te.filter(e=>e.area===`inline`),re=te.filter(e=>e.area===`area`),ie=async(e,t)=>{if(S)return;let n=m(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;H(!0);let i=0;for(let e of r)try{let t=await h(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Q.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}H(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await $(),T?.())},ae=async n=>{if(n)try{let i=await k({title:`说明 · ${n.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:n.note||``,okText:`保存说明`});if(i===null)return;let a=typeof i==`string`?i:i&&(i.value||i.note)||``,l=e===`doc`?`/api/docs/attach-note?ref=${encodeURIComponent(String(c||``))}`:`/api/localtasks/attach-note`,u=e===`doc`?{attachment:n.id,note:a}:{id:Number(t),...o?{key:o}:s?{cwd:s}:{},attachment:n.id,note:a};await r(l,{method:`PATCH`,body:u}),O(a?`已保存说明:${a}`:`已清空说明`),await $(),T?.()}catch(e){O(`改说明失败:${e&&e.message||e}`)}},oe=e=>{e&&(J(e),R(!0))},se=async e=>{let t=G;if(t){ee(!0);try{await Q.detach(t.id,!!e),K(null),O(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await $(),T?.()}catch(e){O(`移除失败:${e&&e.message||e}`)}finally{ee(!1)}}},ce=!N&&!F&&!j.length;return(0,_.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),B(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||B(!1)},onDrop:e=>{B(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ie(null,e))},children:[A,(0,_.jsxs)(`div`,{className:`att-area-head`+(z&&!S?` is-over`:``),children:[(0,_.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,j.length?(0,_.jsx)(`span`,{className:`att-count`,children:j.length}):null,V?(0,_.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,_.jsxs)(`span`,{className:`att-area-acts`,children:[j.length?(0,_.jsxs)(`select`,{className:`att-sort`,value:U,onChange:e=>W(e.target.value),"aria-label":`附件排序`,children:[(0,_.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,_.jsx)(`option`,{value:`name`,children:`按名称`}),(0,_.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>R(!0),children:`添加附件`})]})]}),S?(0,_.jsx)(`div`,{className:`att-empty`,children:C}):null,N?(0,_.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,F?(0,_.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,F]}):null,ce?(0,_.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,ne.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.inline,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),ne.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,re.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.area,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),re.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,(0,_.jsx)(f,{open:L,host:e,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d,taskOptions:y,docOptions:x,replaceAttachment:q?q.id:null,replaceNote:q&&q.note||``,onClose:()=>{R(!1),J(null)},onDone:async()=>{J(null),await $(),T?.()}}),G?(0,_.jsx)(i,{title:`移除附件`,size:`sm`,busy:Y,onClose:Y?void 0:()=>K(null),footer:(0,_.jsxs)(`div`,{className:`att-foot`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:Y,onClick:()=>K(null),children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn`,disabled:Y,onClick:()=>se(!1),children:`只解除关联`}),(0,_.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:Y,onClick:()=>se(!0),children:G.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,_.jsxs)(`div`,{className:`att-confirm`,children:[(0,_.jsx)(`div`,{className:`att-confirm-name`,children:G.name}),(0,_.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,X?(0,_.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&Z(null)},children:(0,_.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,_.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,_.jsx)(`span`,{className:`att-lightbox-name`,children:X.name}),(0,_.jsx)(`a`,{className:`att-lightbox-open`,href:X.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,_.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>Z(null),children:`×`})]}),(0,_.jsx)(`img`,{className:`att-lightbox-img`,src:X.src,alt:X.name})]})}):null]})}function b(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i,onEditNote:a,onReplace:o}){let s=e.kind===`image`?d(e.id):``;return(0,_.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,_.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:s,name:e.name}),title:`点击看大图`,children:(0,_.jsx)(`img`,{src:s,alt:e.name,loading:`lazy`})}):(0,_.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,_.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,_.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,_.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,_.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,_.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,_.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>a?.(e),children:`✎ 说明`}),(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>o?.(e),children:`⇄ 更换`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var x=s(),S=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],C=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],w=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],T=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],E=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],D=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],O={dir:Object.fromEntries(S.map(e=>[e.id,e])),group:Object.fromEntries(C.map(e=>[e.id,e])),task:Object.fromEntries(w.map(e=>[e.id,e])),doc:Object.fromEntries(T.map(e=>[e.id,e])),repos:Object.fromEntries(E.map(e=>[e.id,e])),"repos-row":Object.fromEntries(D.map(e=>[e.id,e]))};function k(e){return e===`group`?C:e===`task`?w:e===`doc`?T:e===`repos`?E:e===`repos-row`?D:S}function A(e,t){return O[e]&&O[e][t]||{}}function j(e,t){let n=A(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function M(e,t){return A(e,t.id).noHide?!0:t.visible===void 0?!j(e,t.id):t.visible!==!1}function N(e,t){return t.id===`more`||A(e,t.id).noHide?!1:!M(e,t)}function P(e,t){let n=k(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=A(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!j(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(j(e,a[t].id)&&!M(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function F(e){return P(e,k(e).map(t=>({id:t.id,visible:t.noHide?!0:!j(e,t.id)})))}var I=e=>`nx-kv-tb-${e}`;function L(e){let[t,n]=(0,g.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(I(e)));if(Array.isArray(t))return P(e,t)}catch{}return F(e)});return(0,g.useEffect)(()=>{try{localStorage.setItem(I(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(F(e))}}function R(e,t){return!!A(e,t).lockLast}function z(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function B(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||R(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=A(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>R(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function V(e,t,n,r){let i=t.filter(t=>M(e,t)&&!R(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return B(e,t,{id:n,anchorId:s.id,after:r>0})}function H({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,g.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=i.filter(t=>M(e,t)),f=i.filter(t=>N(e,t)),p=d.filter(t=>!R(e,t.id)),m=()=>{let t=u.current;return t&&!R(e,t.id)?t:null},h=(t,n)=>{R(e,n.id)||(u.current={id:n.id,onBar:M(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>B(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=m();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=m();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=m();n&&!A(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=m();v(),n&&!A(e,n.id).noHide&&a(e=>z(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},O=(e,t)=>{let n=m();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},k=(e,t)=>{let n=D(t);t.preventDefault();let r=m();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},j=t=>{A(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return z(n,t,{visible:!(r&&M(e,r))})})},P=(t,n)=>a(r=>V(e,r,t.id,n)),I=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),P(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),P(e,1)))},L=()=>{n(i),r()},H=()=>a(F(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,R(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,_.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,_.jsxs)(`div`,{className:`tlp-head`,children:[(0,_.jsx)(`b`,{children:`自定义工具栏`}),(0,_.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,_.jsxs)(`div`,{className:`tlp-body`,children:[(0,_.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,_.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,_.jsx)(`span`,{className:[`tlp-chip`,A(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!R(e,t.id),role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,onDragOver:e=>O(t,e),onDrop:e=>k(t,e),children:A(e,t.id).label||t.id},t.id)})})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,_.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>R(e,t.id))?(0,_.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=A(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,_.jsxs)(`div`,{className:U(t,!0),draggable:!R(e,t.id),"data-row-id":t.id,tabIndex:R(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>I(t,e),onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:R(e,t.id)?`锁定`:`拖动排序`,children:R(e,t.id)?`·`:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>j(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,_.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,_.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),R(e,t.id)?null:(0,_.jsxs)(`span`,{className:`tlp-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>P(t,-1),children:`↑`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>P(t,1),children:`↓`})]})]},t.id)})]})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,_.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=A(e,t.id);return(0,_.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>j(t.id),title:`显示到工具栏`}),(0,_.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,_.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,_.jsxs)(`div`,{className:`tlp-foot`,children:[(0,_.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:L,children:`保存`})]})]})}var U=`task`,W=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function G(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)({x:0,y:0}),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function K({menu:e,className:t=``,style:n,children:r}){return e.open?(0,x.createPortal)((0,_.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function q(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function J({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:m,onMark:h,onDraft:v,onDelete:y,onOverview:b,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=G(),{layout:O,setLayout:k}=L(U),[j,P]=(0,g.useState)(!1);(0,g.useEffect)(()=>{D.setOpen(!1)},[e]);let F={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":m&&{label:`取消任务`,run:m,danger:!0},mark:n&&h&&{label:`评论`,run:h},delete:y&&{label:`删除`,run:y,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:b&&{label:`总览`,run:b},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},I=e=>e===`more`||!!F[e],R=O.filter(e=>M(U,e)&&I(e.id)),z=O.filter(e=>N(U,e)&&I(e.id)),B=e=>{F[e]?.run?.(),D.setOpen(!1)},V=e=>{if(e===`more`)return(0,_.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>q(D,e,`right`),children:`更多`})},`more`);let t=F[e];return t?(0,_.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>B(e),children:t.label},e):null},J=W.map(e=>({...e,items:z.filter(t=>A(U,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!A(U,e.id).menuGroup);return(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,_.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>q(D,e,`right`),children:T.label})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>V(e.id)),(0,_.jsxs)(K,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,_.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,_.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=F[e.id],n=t?.danger||A(U,e.id).danger;return(0,_.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>B(e.id),children:[t?.label||A(U,e.id).label||e.id,t?.hint?(0,_.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=F[e.id];return(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||A(U,e.id).danger?` danger`:``),onClick:()=>B(e.id),children:t?.label||A(U,e.id).label||e.id},e.id)}),(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),j&&(0,x.createPortal)((0,_.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,_.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,_.jsx)(H,{kind:U,layout:O,setLayout:k,onClose:()=>P(!1)})})}),document.body)]})}export{H as a,A as c,G as i,M as l,J as n,L as o,q as r,N as s,K as t,y as u};
@@ -12,7 +12,7 @@
12
12
  <!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
13
13
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
14
14
  <link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
15
- <script type="module" crossorigin src="/assets/index-D2fKyD1k.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-ChlZPTea.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="/assets/task-status-BnymQMTw.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/workspace-C_5X2gIr.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/app-context-D7HAx67n.js">
@@ -1,7 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{n as s}from"./app-context-D7HAx67n.js";import{n as c,o as l}from"./index-D2fKyD1k.js";import{t as u}from"./button-Cmo-6aoW.js";var d=o(e(),1),f=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),p=8e3,m=`builtin`,h=`系统内置`,g=`{{#if repo}},{{#if repo.intro}},〔项目介绍 · {{repo.name}}〕({{repo.introPath}}):,{{repo.intro}},{{/if}},{{#if repo.docs}},项目补充文档(可直接读取):,{{#each repo.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.intro}},组介绍({{group.introPath}}):,{{group.intro}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}},{{/each}},{{/if}},{{#if group.docs}},组绑定参考文件(可直接读取):,{{#each group.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if refRepos.count}},参考仓库(可直接读取,共 {{refRepos.count}} 个):,{{#each refRepos.list}}, - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}}`.split(`,`).join(`
2
- `),_=[`{{#if attach}}`,`〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容)再开始处理,不要跳过附件。`,``,`附件清单:`,`{{#each attach.list}}`,` - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{#if ref.relPath}}({{ref.relPath}}){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}`,`{{/each}}`,``,`取用方式:`,`{{#each attach.list}}`,` - {{kindLabel}} 《{{name}}》:{{usage}}`,`{{/each}}`,`{{#if attach.syncSummary}}`,`同步情况:{{attach.syncSummary.text}}`,`{{/if}}`,`{{#each attach.list}}{{#if ref}}{{#if ref.content}}〔文档原文 · {{ref.title}}〕({{ref.relPath}}):`,``,`{{ref.content}}`,``,`{{/if}}{{/if}}{{/each}}`,`{{/if}}`].join(`
3
- `),v=[`{{#if goal.check}}`,`{{goal.check}}`,`{{/if}}`,`{{#if goal.statusLine}}`,`{{goal.statusLine}}`,`{{/if}}`].join(`
4
- `),y=[`{{#if goal.check}}`,`〔特殊功能提示 · 时间目标〕任务 #{{task.id}} 正在计时:持续 {{goal.durationHuman}},{{#if goal.reached}}已到点{{else}}剩余 {{goal.remainingHuman}}{{/if}}。`,`{{/if}}`].join(`
5
- `),b=[`{{#if ext.count}}`,`本队列({{ext.topic}})还有 {{ext.count}} 条待领取任务:`,`{{#each ext.list}}`,` - #{{id}} {{title}}`,`{{/each}}`,`先完成当前任务,再领取下一条;不要因为后面还有活就提前收尾或分心。`,`{{/if}}`].join(`
6
- `),x=`完成之后必须调用 nx-kv localtask done --id {{task.id}} --summary "<完成总结>" 汇报结果。`,S=[`{{#if getloop}}`,`{{getloop.text}}`,`{{/if}}`].join(`
7
- `),C=Object.freeze([{id:`context`,tag:`nx-kv.context`,label:`组 / 项目上下文`,desc:`任务所在组、项目关键路径与参考文件;直接用 repo / group 变量拼装`,defaultTemplate:g},{id:`attachment`,tag:`nx-kv.attachment`,label:`附件识别`,desc:`任务带附件时出现:数量 / 清单 / 本地路径`,defaultTemplate:_},{id:`timecheck`,tag:`nx-kv.timecheck`,label:`时间目标检查`,desc:`任务带时间目标时出现:check 指令或目录级状态`,defaultTemplate:v},{id:`goalhint`,tag:`nx-kv.goalhint`,label:`特殊功能提示(timegoal)`,desc:`任务带时间目标时出现:可直接用 goal.* 时间变量与 task 全文占位;每轮 check 同源渲染`,defaultTemplate:y},{id:`ext`,tag:`nx-kv.ext`,label:`待领取队列(ext)`,desc:`同主题还有多少待领取任务与标题;队列空时不出现`,defaultTemplate:b},{id:`ack`,tag:`nx-kv.ack`,label:`ack 完成总结`,desc:`完成任务时调用 localtask done 回填的指令;默认已内置,可见可改`,defaultTemplate:x},{id:`getloop`,tag:`nx-kv.getloop`,label:`持续 get`,desc:`项目开启「持续 get」时出现:完成本任务并回填后继续领取下一条`,defaultTemplate:S}]);function w(e){let t=String(e??``).trim();return t.length>8e3?t.slice(0,p):t}function T(e){return{id:m,name:h,template:e.defaultTemplate,builtin:!0}}function E(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=String(e.id??``).trim().slice(0,64);return t?{id:t,name:String(e.name??``).trim().slice(0,60)||`未命名模板`,template:w(e.template),builtin:!1}:null}function D(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={};for(let e of C){let r=t[e.id],i=Array.isArray(r)?r:Array.isArray(r?.list)?r.list:[],a=[T(e)],o=new Set([m]);for(let e of i){if(e&&typeof e==`object`&&(e.id===`builtin`||e.builtin))continue;let t=E(e);if(t&&!o.has(t.id)&&(o.add(t.id),a.push(t),a.length>=20))break}let s=String(r?.active??``).trim();n[e.id]={active:a.some(e=>e.id===s)?s:m,list:a}}return n}var O={context:[{label:`项目`,items:[[`repo.name`,`项目名`],[`repo.intro`,`项目介绍正文`],[`repo.introPath`,`介绍全文路径`],[`repo.docs`,`补充文档(可循环 path/tag/note)`],[`repo.docCount`,`补充文档数`],[`repo.refRepos`,`本仓库直接绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`repo.refRepoCount`,`本仓库直接绑定的参考仓库数`]]},{label:`组`,items:[[`group.name`,`组名`],[`group.desc`,`组定位`],[`group.intro`,`组介绍正文`],[`group.note`,`本项目在组里的位置`],[`group.peers`,`组内成员(可循环 name/note)`],[`group.docs`,`组绑定参考文件(可循环)`],[`group.refRepos`,`本组绑定的参考仓库(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`group.refRepoCount`,`本组绑定的参考仓库数`],[`groups`,`其余组(可循环 name/desc/path)`]]},{label:`参考仓库`,items:[[`refRepos.list`,`直接绑定 ∪ 组级绑定的去重并集(repos 中 type=ref,不是文档库 refs;可循环 name/path/note)`],[`refRepos.count`,`去重并集的条目数(无绑定时为 0,整段不出现)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`params`,`外部参数(k=v)`]]}],attachment:[{label:`统计`,items:[[`attach.count`,`附件总数`],[`attach.inlineCount`,`正文内嵌数量`],[`attach.areaCount`,`附件区数量`],[`attach.hasInline`,`是否有正文内嵌`],[`attach.hasArea`,`是否有附件区条目`],[`attach.needsSyncCount`,`需要同步到本地的文件数`]]},{label:`附件条目(通用,attach.list 内循环)`,items:[[`kind`,`类型:file / url / task / ref`],[`kindLabel`,`类型显示名:附件/图片/链接/任务/文档`],[`name`,`展示名(任务型为实时标题,不是正文)`],[`size`,`字节数`],[`sizeText`,`可读大小(1.2 MB)`],[`mime`,`MIME 类型`],[`storage`,`存储来源:local / cloud / url / internal`],[`role`,`关系角色:inline / reference / doc / attach`],[`origin`,`来源:inline(正文内嵌)/ area(附件区)`],[`originLabel`,`来源显示名`],[`usage`,`取用说明(按类型生成,含确切命令)`],[`cmd`,`取用命令(file 未同步 / task / ref;url 为空)`],[`locator`,`简短定位串(路径 / 链接 / #seq 标题 / 文档路径)`],[`isImage`,`是否图片(kind=file 的子类型)`],[`needsSync`,`该条是否需要先同步到本地`]]},{label:`文件型(kind=file)· file 子对象`,items:[[`file.localPath`,`本地绝对路径(已同步时才有值)`],[`file.fileId`,`资源 id(未同步时用它拉取)`],[`file.exists`,`本机盘上是否已有副本`],[`file.syncCmd`,`未同步时的命令:nx-kv file sync --ids <fileId>`],[`localPath`,`file.localPath 的平铺别名(旧模板兼容)`],[`fileId`,`file.fileId 的平铺别名`]]},{label:`链接型(kind=url)· url 子对象`,items:[[`url.href`,`可访问的完整链接,可直接抓取`],[`url.host`,`链接域名(host)`],[`href`,`url.href 的平铺别名`],[`host`,`url.host 的平铺别名`],[`urlText`,`链接字符串别名`]]},{label:`任务型(kind=task)· task 子对象`,items:[[`task.taskId`,`本机 tasks.id(join 用;任务被清理后为 0)`],[`task.topicKey`,`任务所在 topic key`],[`task.topicName`,`任务所在 topic 名`],[`task.seq`,`topic 内编号(对外显示的任务号)`],[`task.title`,`实时标题(正文首行,不是正文)`],[`task.status`,`实时状态:pending/claimed/done/cancelled`],[`task.statusLabel`,`状态显示名`],[`task.address`,`地址 topicKey:seq`],[`task.storedAddress`,`附件行里存的旧地址(搬家前)`],[`task.addressDrift`,`地址是否已漂移(任务搬过 topic)`],[`task.resolved`,`正文当前是否可读`],[`task.purged`,`目标任务是否已被清理`],[`task.deleted`,`目标任务是否已软删`],[`task.showCmd`,`取正文命令:nx-kv localtask show --id <seq> --key <topicKey>`],[`seq`,`task.seq 的平铺别名`],[`title`,`task.title 的平铺别名`],[`showCmd`,`task.showCmd 的平铺别名`]]},{label:`文档型(kind=ref)· ref 子对象`,items:[[`ref.refId`,`refs 表 id`],[`ref.title`,`文档标题`],[`ref.relPath`,`文档相对路径 / 外部 md 绝对路径`],[`ref.readCmd`,`读取命令:nx-kv docs get rel:<路径>(或 path:<绝对路径>)`],[`refId`,`ref.refId 的平铺别名`],[`relPath`,`ref.relPath 的平铺别名`],[`readCmd`,`ref.readCmd 的平铺别名`]]},{label:`同步汇总`,items:[[`attach.syncSummary.text`,`本次批量同步的一行汇总`],[`attach.syncSummary.dir`,`同步目录`],[`attach.syncSummary.downloaded`,`已下载数`],[`attach.syncSummary.skipped`,`跳过数`],[`attach.syncSummary.failureCount`,`失败数`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文(交付模板等处仍在用)`]]}],timecheck:[{label:`时间目标`,items:[[`goal.check`,`时间检查指令(任务级;每轮 check 按当下模板渲染)`],[`goal.statusLine`,`目录级目标状态行`],[`goal.name`,`目标名`],[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话,如 2 小时)`],[`goal.durationSec`,`持续秒数`],[`goal.deadline`,`截止时间`],[`goal.remainingSec`,`剩余秒数`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingMin`,`剩余分钟(向上取整)`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`],[`goal.extra`,`发布方附加要求(领取后可动态改)`]]},{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文`]]}],goalhint:[{label:`时间目标上下文(任务级)`,items:[[`goal.goalKey`,`任务级目标 key(check --task 用)`],[`goal.durationHuman`,`持续时长(人话)`],[`goal.durationSec`,`持续秒数`],[`goal.startedAt`,`开始计时时间`],[`goal.deadline`,`截止时间`],[`goal.remainingHuman`,`剩余时长(人话)`],[`goal.remainingSec`,`剩余秒数`],[`goal.elapsedHuman`,`已过时长(人话)`],[`goal.elapsedSec`,`已过秒数`],[`goal.overtimeSec`,`超时秒数`],[`goal.reached`,`是否到点`],[`goal.extra`,`发布方附加要求(领取后可动态改)`]]},{label:`任务`,items:[[`task.id`,`任务号`],[`task.text`,`任务实时原文(check 返回对象同样可用)`]]}],ext:[{label:`队列`,items:[[`ext.topic`,`主题 / 队列名`],[`ext.count`,`待领取任务数`],[`ext.list`,`待领取清单(可循环 id/title/topic)`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}],ack:[{label:`通用`,items:[[`task.id`,`任务号`],[`task.text`,`任务原文`],[`source`,`任务来源(local/global)`],[`summary`,`领取方现状`],[`name`,`领取方名字`],[`cwd`,`领取方目录`],[`params`,`外部参数(k=v)`]]}],getloop:[{label:`持续 get`,items:[[`getloop.text`,`持续 get 指令正文`],[`getloop.waitMinutes`,`单轮等待分钟数`]]},{label:`通用`,items:[[`task.id`,`任务号`]]}]},k=t();function A({blockId:e}){let t=O[e]||[];return t.length?(0,k.jsxs)(`div`,{className:`setp-params`,"aria-label":`可使用参数`,children:[(0,k.jsx)(`div`,{className:`setp-params-head`,children:`可使用参数`}),t.map(e=>(0,k.jsxs)(`div`,{className:`setp-params-row`,children:[(0,k.jsx)(`span`,{className:`setp-params-label`,children:e.label}),(0,k.jsx)(`div`,{className:`setp-params-items`,children:e.items.map(([e,t])=>(0,k.jsxs)(`span`,{className:`setp-param`,children:[(0,k.jsx)(`code`,{children:e}),(0,k.jsx)(`span`,{children:t})]},e))})]},e.label))]}):null}function j(){return`bt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function M(e){return C.find(t=>t.id===e)||C[0]}function N(e,t,n){let r=e[t];return r.list.find(e=>e.id===n)||r.list.find(e=>e.id===r.active)||r.list[0]}function P(){let e=i(),{dialog:t,node:a}=n(),[o,s]=(0,d.useState)(null),[c,l]=(0,d.useState)(C[0].id),[p,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!1),v=(e,t=null)=>{s(t=>({...t||{},lists:e}));let n=t||(p&&p.blockId===c?p:null),r=n?.blockId||c,i=N(e,r,n?.id||e[r].active);h({blockId:r,id:i.id,name:i.name,template:i.template})},y=()=>{r(`/api/localtasks`).then(e=>{let t=e?.settings||{},n=D(t.blockTemplates),r=t.appendMode===`plain`?`plain`:`xml`;s({lists:n,appendMode:r});let i=C[0],a=N(n,i.id,n[i.id].active);l(i.id),h({blockId:i.id,id:a.id,name:a.name,template:a.template})}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,d.useEffect)(y,[]),!o)return(0,k.jsx)(`div`,{className:`setp-note`,children:`读取提示词模板…`});let b=M(c),x=f.find(e=>e.id===o.appendMode)||f[0],S=o.lists[c],w=p?.id===m,T=async(t,n,i=null)=>{if(!g){_(!0);try{let a=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{blockTemplates:t}});v(D(a?.blockTemplates),i),e(n)}catch(t){e(String(t.message||t))}finally{_(!1)}}},E=()=>JSON.parse(JSON.stringify(o.lists)),O=e=>{if(g)return;l(e);let t=N(o.lists,e,o.lists[e].active);h({blockId:e,id:t.id,name:t.name,template:t.template})},P=e=>{let t=N(o.lists,c,e);h({blockId:c,id:t.id,name:t.name,template:t.template})},F=e=>h(t=>({...t,...e})),I=()=>{if(w){e(`系统内置模板不可编辑;请先「复制」一份再改`);return}let t=String(p.name||``).trim().slice(0,60)||`未命名模板`,n=String(p.template??``),r=E(),i=r[c],a=i.list.findIndex(e=>e.id===p.id),o={id:p.id,name:t,template:n,builtin:!1};a>=0?i.list[a]=o:i.list.push(o),T(r,`已保存模板(当前生效项保存后立即生效)`,{blockId:c,id:p.id})},L=()=>{if(g)return;let e=E(),t={id:j(),name:`新模板`,template:``,builtin:!1};e[c].list.push(t),T(e,`已新建模板,填写后保存,再点「启用」`,{blockId:c,id:t.id})},R=(e=p?.id)=>{if(g||!e)return;let t=N(o.lists,c,e),n=E(),r={id:j(),name:`${t.name||`模板`} 副本`.slice(0,60),template:t.template||``,builtin:!1};n[c].list.push(r),T(n,`已复制模板`,{blockId:c,id:r.id})},z=()=>{if(g||w)return;let e=String(p.name||``).trim().slice(0,60)||`未命名模板`,t=E(),n=t[c],r=n.list.findIndex(e=>e.id===p.id),i={id:p.id,name:e,template:String(p.template??``),builtin:!1};r>=0?n.list[r]=i:n.list.push(i),n.active=p.id,T(t,`已保存并启用「${e}」`,{blockId:c,id:p.id})},B=e=>{if(g||e===S.active)return;let t=E();t[c].active=e,T(t,`已启用「${N(o.lists,c,e).name}」`,{blockId:c,id:e})},V=async n=>{if(g)return;if(n===`builtin`){e(`系统内置模板不可删除`);return}let r=N(o.lists,c,n);if(!await t({title:`删除模板?`,message:`将删除「${r.name}」,保存后不可恢复。该区块的系统内置模板会保留。`,okText:`删除`,danger:!0}))return;let i=E(),a=i[c];a.list=a.list.filter(e=>e.id!==n),a.active===n&&(a.active=m),T(i,`已删除模板,当前生效项已回落到系统内置`)},H=()=>{if(g||S.active===`builtin`)return;let e=E();e[c].active=m,T(e,`已恢复系统内置模板`,{blockId:c,id:m})},U=async t=>{if(!(g||t===o.appendMode)){_(!0);try{let n=await r(`/api/localtasks/setting`,{method:`PATCH`,body:{appendMode:t}});s(e=>({...e,appendMode:n?.appendMode===`plain`?`plain`:`xml`})),e(`已保存追加模式(全局生效)`)}catch(t){e(String(t.message||t))}finally{_(!1)}}};return(0,k.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,k.jsxs)(`div`,{className:`setp-tpl-head`,children:[(0,k.jsx)(`span`,{className:`setp-tpl-head-label`,children:`系统提示词追加方式`}),(0,k.jsx)(`div`,{className:`setp-seg`,role:`group`,"aria-label":`系统提示词追加方式`,children:f.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`setp-seg-btn`+(o.appendMode===e.id?` is-on`:``),"aria-pressed":o.appendMode===e.id,title:e.desc,disabled:g,onClick:()=>U(e.id),children:e.label},e.id))}),(0,k.jsx)(`span`,{className:`setp-note`,children:x.desc})]}),(0,k.jsx)(`nav`,{className:`setp-block-tabs`,"aria-label":`提示词区块`,children:C.map(e=>{let t=N(o.lists,e.id,o.lists[e.id].active);return(0,k.jsxs)(`button`,{type:`button`,className:`setp-block-tab`+(e.id===c?` is-on`:``),disabled:g,onClick:()=>O(e.id),children:[(0,k.jsx)(`span`,{children:e.label}),(0,k.jsx)(`small`,{children:t.builtin?`系统内置`:t.name})]},e.id)})}),(0,k.jsxs)(`div`,{className:`setp-block-card`,children:[(0,k.jsxs)(`div`,{className:`setp-block-card-head`,children:[(0,k.jsxs)(`div`,{className:`setp-block-card-title`,children:[(0,k.jsx)(`b`,{children:b.label}),(0,k.jsx)(`span`,{className:`setp-note`,children:b.desc})]}),(0,k.jsxs)(`div`,{className:`setp-block-card-actions`,children:[(0,k.jsx)(u,{variant:`secondary`,disabled:g,onClick:L,children:`新建模板`}),(0,k.jsx)(u,{variant:`secondary`,disabled:g||S.active===`builtin`,onClick:H,children:`恢复内置`})]})]}),(0,k.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`${b.label}模板列表`,children:S.list.map(e=>{let t=e.id===S.active,n=e.id===p?.id;return(0,k.jsxs)(`div`,{className:`setp-tpl-pick${t?` is-on`:``}${n?` is-sel`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:`setp-tpl-name`,title:e.name,onClick:()=>P(e.id),children:[(0,k.jsx)(`span`,{className:`setp-tpl-name-text`,children:e.name}),e.builtin&&(0,k.jsx)(`span`,{className:`setp-badge`,children:`内置`}),t&&(0,k.jsx)(`span`,{className:`setp-badge`,children:`启用中`})]}),(0,k.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g,title:e.builtin?`复制系统内置模板`:`复制该模板`,onClick:()=>R(e.id),children:`复制`}),(0,k.jsx)(u,{variant:`secondary`,className:`setp-tpl-act`,disabled:g||t,title:`设为该区块当前生效模板`,onClick:()=>B(e.id),children:`启用`}),(0,k.jsx)(u,{variant:`secondary`,danger:!0,className:`setp-tpl-act`,disabled:g||e.builtin,title:e.builtin?`系统内置模板不可删除`:`删除该模板`,onClick:()=>V(e.id),children:`删除`})]},e.id)})}),p&&(0,k.jsxs)(`div`,{className:`setp-tpl-editor-box`,children:[(0,k.jsxs)(`div`,{className:`setp-tpl-editor-head`,children:[(0,k.jsx)(`span`,{children:w?`系统内置`:`编辑 · ${p.name||`未命名模板`}`}),(0,k.jsx)(`span`,{className:`setp-note`,children:p.id===S.active?`当前生效,保存后立即参与领取`:`未启用;保存后可点「启用」`})]}),!w&&(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`模板名`}),(0,k.jsx)(`div`,{className:`setp-input`,children:(0,k.jsx)(`input`,{value:p.name,maxLength:60,disabled:g,onChange:e=>F({name:e.target.value})})})]}),(0,k.jsx)(`textarea`,{className:`setp-area setp-tpl-textarea`,value:p.template,readOnly:w,spellCheck:!1,disabled:g,placeholder:w?``:`在这里写该区块的模板`,onChange:e=>F({template:e.target.value})}),(0,k.jsx)(A,{blockId:c}),(0,k.jsxs)(`div`,{className:`setp-proj-a`,children:[w?(0,k.jsx)(u,{variant:`secondary`,disabled:g,onClick:R,children:`复制为我的模板`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(u,{variant:`primary`,disabled:g,onClick:I,children:`保存`}),(0,k.jsx)(u,{variant:`secondary`,disabled:g,onClick:y,children:`撤销改动`}),p.id!==S.active&&(0,k.jsx)(u,{variant:`secondary`,disabled:g,onClick:z,children:`保存并启用`})]}),(0,k.jsx)(`span`,{className:`spacer`})]})]})]}),a]})}function F(){let e=s()||{},t=e.rows||[],n=e.repoData&&e.repoData.repos||[],r=e.repoData&&e.repoData.boards||[];return(0,d.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function I(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a={topic:`目录`,repo:`项目`,group:`组`}[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function L({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:a=`setp`}){let o=i(),s=F(),c=r||s,[l,u]=(0,d.useState)(null),f=Array.isArray(e)?e:[],p=f.includes(`*`),m=f.filter(e=>e!==`*`),h=a,g=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,_=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},v=async e=>{if(f.includes(e)){o(`已经在可见范围里了`),u(null);return}await _([...f,e]),u(null)},y=(0,d.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,k.jsxs)(`div`,{className:`${h}-scope-block`,children:[(0,k.jsx)(`div`,{className:`${h}-scope`,children:f.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`${h}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>_(f.filter(t=>t!==e)),children:[I(e,c),` ×`]},e))}),(0,k.jsxs)(`div`,{className:`${h}-scope-add`,children:[(0,k.jsx)(`span`,{className:`${h}-scope-add-label`,children:`添加`}),(0,k.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`,disabled:p,title:p?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!p&&_([`*`,...m]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,k.jsx)(`button`,{type:`button`,className:`${h}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:{topic:`目录`,repo:`项目`,group:`组`}[e]},e)),g?(0,k.jsxs)(`span`,{className:`${h}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,g]}):null]}),l&&(0,k.jsx)(`div`,{className:`${h}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:y.length?y.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`${h}-scope-pick-it`,disabled:f.includes(e.entry),title:e.sub||e.entry,onClick:()=>v(e.entry),children:[(0,k.jsx)(`span`,{className:`${h}-scope-pick-name`,children:e.label}),f.includes(e.entry)?(0,k.jsx)(`span`,{className:`${h}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,k.jsx)(`div`,{className:`${h}-scope-pick-empty`,children:`暂无可选项`})})]})}function R({openTemplateEditor:e}){let t=c(),r=i(),{dialog:a,node:o}=n(),s=t.templates||[],[l,f]=(0,d.useState)(null),[p,m]=(0,d.useState)(!1);if(t.unsupported)return(0,k.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`});let h=async(e,t)=>{if(!p){m(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{m(!1)}}},g=async e=>{await a({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&(await h(()=>t.remove(e.id),`已删除「${e.name}」`),l===e.id&&f(null))};return(0,k.jsxs)(`div`,{className:`setp-tpl setp-tpl-cards`,children:[o,!s.length&&(0,k.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`}),s.map(n=>{let r=n.id===t.defaultId,i=l===n.id;return(0,k.jsxs)(`div`,{className:`setp-tpl-card`+(r?` is-default`:``),children:[(0,k.jsxs)(`div`,{className:`setp-tpl-card-head`,children:[(0,k.jsx)(`span`,{className:`setp-tpl-card-name`,children:n.name}),r&&(0,k.jsx)(`span`,{className:`setp-badge`,children:`默认`}),n.builtin&&(0,k.jsx)(`span`,{className:`setp-badge soft`,children:`内置`})]}),i&&(0,k.jsx)(`div`,{className:`setp-tpl-card-scope`,children:(0,k.jsx)(L,{scope:n.scope,originTopic:n.originTopic,onChange:e=>t.update(n.id,{scope:e})})}),(0,k.jsxs)(`div`,{className:`setp-tpl-card-foot`,children:[(0,k.jsx)(`span`,{className:`grow`}),(0,k.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>f(i?null:n.id),children:`可见绑定`}),(0,k.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({id:n.id,name:n.name,mode:`edit`}),children:`编辑`}),!r&&(0,k.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>h(()=>t.setDefault(n.id),`默认模板已设为「${n.name}」`),children:`设为默认`}),!n.builtin&&(0,k.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>g(n),children:`删除`})]})]},n.id)}),(0,k.jsx)(`div`,{className:`setp-tpl-card-new`,children:(0,k.jsx)(u,{variant:`secondary`,disabled:p,onClick:()=>e?.({mode:`new`,scope:[]}),children:`+ 新建模板`})})]})}function z(){let e=i(),t=s()||{},n=t.patchPrefs,[a,o]=(0,d.useState)([]),[c,l]=(0,d.useState)([]),[u,f]=(0,d.useState)([]),p=(0,d.useCallback)(()=>{Promise.all([r(`/api/repos`),r(`/api/boards`)]).then(([e,n])=>{o(Array.isArray(e)?e:e?.repos||[]),l(Array.isArray(n)?n:n?.boards||[]),f(t.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,t.prefs]);(0,d.useEffect)(()=>{p()},[p]);let m=e=>{let r=t.prefs?.hidden||[],i=r.includes(e)?r.filter(t=>t!==e):[...r,e];n&&n({hidden:i}),f(i)},h=(e,t,n,r)=>(0,k.jsx)(`div`,{className:`setp-row`,children:(0,k.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>m(t)}),(0,k.jsx)(`span`,{children:n}),r?(0,k.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,k.jsxs)(`div`,{className:`setp-side`,children:[(0,k.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,k.jsx)(`div`,{className:`setp-row`,children:(0,k.jsx)(`span`,{children:`项目组(指针)`})}),c.map(e=>h(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!c.length&&(0,k.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,k.jsx)(`div`,{className:`setp-row`,children:(0,k.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),a.map(e=>h(`repo`,e.key||e.id,e.name,e.path)),!a.length&&(0,k.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var B=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`taskTemplates`,label:`任务模板`,icon:`list`},{id:`prompts`,label:`提示词模板`,icon:`flow`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`}];function V(){let e=s()||{},t=i(),{dialog:o,node:c}=n(),f=e.prefs||{},p=e.patchPrefs||(()=>{}),m=e.model,[h,g]=(0,d.useState)(`pref`),[_,v]=(0,d.useState)(null),[y,b]=(0,d.useState)(!1),x=(0,d.useCallback)(async()=>{try{v(await r(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,d.useEffect)(()=>{x()},[x]);let S=e=>e().catch(e=>t(String(e.message||e))),C=e=>S(async()=>{b(!0);try{v(await r(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{b(!1)}}),w={pref:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`侧边栏默认收起`}),(0,k.jsxs)(`button`,{className:`toggle`+(f.defaultFolded?` on`:``),onClick:()=>p({defaultFolded:!f.defaultFolded}),children:[(0,k.jsx)(`span`,{className:`dot`}),f.defaultFolded?`开`:`关`]})]}),(f.hidden||[]).length>0&&(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsxs)(`span`,{children:[`隐藏仓库 `,f.hidden.length,` 个`]}),(0,k.jsx)(u,{variant:`secondary`,onClick:()=>p({hidden:[]}),children:`恢复显示`})]})]}),work:(0,k.jsx)(k.Fragment,{children:(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`布局`}),(0,k.jsx)(u,{variant:`secondary`,onClick:async()=>{await o({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,k.jsxs)(`button`,{className:`toggle`+(_&&_.autoSyncAttachments?` on`:``),disabled:!_||y,onClick:()=>C({autoSyncAttachments:!_.autoSyncAttachments}),children:[(0,k.jsx)(`span`,{className:`dot`}),_&&_.autoSyncAttachments?`开`:`关`]})]}),(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`附件目录`}),(0,k.jsxs)(`span`,{className:`setp-input`,children:[(0,k.jsx)(`input`,{value:_&&_.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>v(t=>({...t,attachmentsDir:e.target.value}))}),(0,k.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({attachmentsDir:_.attachmentsDir}),children:`保存`})]})]}),(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`参考仓库存储根`}),(0,k.jsxs)(`span`,{className:`setp-input`,children:[(0,k.jsx)(`input`,{value:_&&_.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>v(t=>({...t,gitRepoRoot:e.target.value}))}),(0,k.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitRepoRoot:_.gitRepoRoot}),children:`保存`})]})]}),(0,k.jsxs)(`div`,{className:`setp-row`,children:[(0,k.jsx)(`span`,{children:`开发仓库克隆根`}),(0,k.jsxs)(`span`,{className:`setp-input`,children:[(0,k.jsx)(`input`,{value:_&&_.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>v(t=>({...t,gitDevRoot:e.target.value}))}),(0,k.jsx)(u,{variant:`secondary`,disabled:!_||y,onClick:()=>C({gitDevRoot:_.gitDevRoot}),children:`保存`})]})]})]}),taskTemplates:(0,k.jsx)(R,{openTemplateEditor:e=>{m&&l(m,e||{})}}),prompts:(0,k.jsx)(P,{}),sidebar:(0,k.jsx)(z,{})};return(0,k.jsxs)(`div`,{className:`setp`,children:[(0,k.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:B.map(e=>(0,k.jsxs)(`button`,{className:`setp-navitem`+(h===e.id?` on`:``),"aria-current":h===e.id,onClick:()=>g(e.id),children:[(0,k.jsx)(a,{name:e.icon,size:14}),(0,k.jsx)(`span`,{children:e.label})]},e.id))}),(0,k.jsxs)(`div`,{className:`setp-body`,children:[(0,k.jsx)(`div`,{className:`setp-h`,children:B.find(e=>e.id===h).label}),w[h]]}),c]})}export{V as default};