nx-kv 0.69.0 → 0.69.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/package.json +1 -1
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v16-data.ts +0 -1
- package/src/core/db/migrations/v18.sql +24 -0
- package/src/core/db/version.ts +3 -1
- package/src/modules/localtask/actions/localtask-add.ts +4 -4
- package/src/modules/localtask/actions/localtask-boardtasks.ts +1 -1
- package/src/modules/localtask/lifecycle/topics.ts +3 -1
- package/src/web/frontend/api/cli-tree.json +1 -1
- package/src/web/frontend/api/client.generated.ts +1 -1
- package/src/web/frontend/components/md/attachments/attach-modal.tsx +1 -1
- package/src/web/frontend/components/md/hooks/use-live-preview.ts +1 -1
- package/src/web/frontend/components/md/model/divider/index.ts +0 -3
- package/src/web/frontend/components/md/panes/md-panes-helpers.ts +1 -3
- package/src/web/frontend/modules/md/styles/editor.css +0 -26
- package/src/web/public/assets/{composer-launch-BL344XZg.js → composer-launch-C20VCKMu.js} +1 -1
- package/src/web/public/assets/{composer-panel-D0ojgf7z.js → composer-panel-C3ET4SBT.js} +1 -1
- package/src/web/public/assets/{dag-BY0lf-Nl.js → dag-xQRISqLX.js} +1 -1
- package/src/web/public/assets/{dir-BNHyviHQ.js → dir-B-UPu7OY.js} +1 -1
- package/src/web/public/assets/{doc-wmc4swmo.js → doc-zDLeR8PE.js} +1 -1
- package/src/web/public/assets/{group-BSQ9_Gjs.js → group-Hh-NL_sa.js} +1 -1
- package/src/web/public/assets/{index-DHLeXl42.css → index-DXJxcKIU.css} +1 -1
- package/src/web/public/assets/{index-D2P-v30u.js → index-Di6ErKBG.js} +3 -3
- package/src/web/public/assets/{md-history-D0bYVPZY.js → md-history-B7TamGno.js} +1 -3
- package/src/web/public/assets/{refs-Cf4ZbAra.js → refs-C6rZJhnb.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-BahZhXq3.js → repo-form-modal-DpwLdBYp.js} +1 -1
- package/src/web/public/assets/{repos-C2cZtRFo.js → repos-BjVw1SQ2.js} +1 -1
- package/src/web/public/assets/{settings-C_VmzG7F.js → settings-C1NfJqNk.js} +1 -1
- package/src/web/public/assets/{task-C4Sqe4vT.js → task-Ddr-iU14.js} +1 -1
- package/src/web/public/assets/{task-ops-SFagO-OC.js → task-ops-s9kkuLcK.js} +1 -1
- package/src/web/public/assets/{templates-B8jnGSAl.js → templates-BnEJVU91.js} +3 -3
- package/src/web/public/assets/{use-rail-drag-CtZxisjE.js → use-rail-drag-4iK6t5ab.js} +1 -1
- package/src/web/public/index.html +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,d as t,f as n,h as r,i,l as a,o,r as s,t as c,u as l}from"./popup-DLfU1TXG.js";import{f as u}from"./tool-bar-NHeX0Kmo.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as b,f as x,g as S,h as C,i as w,k as T,l as E,m as D,n as O,o as ee,p as k,r as A,s as j,t as M,u as N,v as P,w as F,x as I,y as L}from"./repo-form-modal-BahZhXq3.js";import{n as R}from"./app-context-DPFYOrgE.js";import{t as z}from"./button-VP4pjVsx.js";import{i as B,n as V}from"./doc-wmc4swmo.js";import{m as H}from"./md-history-D0bYVPZY.js";import{i as U,t as te}from"./route-crumb-DS76cmRK.js";import{t as ne}from"./bar-I4qGaKTO.js";import{t as W}from"./member-picker-BtWykPer.js";var G=r(n(),1),K=t(),q={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function re({onClose:t,onChanged:n,repos:r,boards:i}){let o=e(),s=a(),[c,u]=(0,G.useState)(`import`),[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)({}),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)({}),[T,E]=(0,G.useState)({}),[D,O]=(0,G.useState)(`ours`),[ee,k]=(0,G.useState)(`none`),[A,j]=(0,G.useState)(``),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(!1),I=(0,G.useMemo)(()=>r||[],[r]),L=(0,G.useMemo)(()=>I.map(e=>e.key),[I]),R=(0,G.useMemo)(()=>(i||[]).map(e=>e.name),[i]),z=e=>{let t={};for(let n of L)t[n]=e;f(t)},B=e=>{let t={};for(let n of R)t[n]=e;m(t)},V=()=>{let e={};for(let t of L)e[t]=!d[t];f(e)},H=()=>o(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==L.length?e:void 0,boards:t.length&&t.length!==R.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 i=await l(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),U=()=>{if(!_)return;let e=new Blob([_],{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)},te=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),N(null))},ne=()=>o(async()=>{if(y.trim()){F(!0);try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),N(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{F(!1)}}}),W=()=>o(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);F(!0);try{let r=await l(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:ee,selection:e.length?e:void 0,boards:t.length?t:void 0}});N(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await re(),n&&await n()}finally{F(!1)}}),re=(0,G.useCallback)(async()=>{try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),ie=(0,G.useMemo)(()=>x?A?x.repos.filter(e=>e.status===A):x.repos:[],[x,A]),ae=(e,t)=>o(async()=>{if(t){F(!0);try{await l(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await re(),n&&await n()}finally{F(!1)}}}),oe=e=>{let t={...C};for(let n of ie)t[n.key]=e;w(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 se=(0,G.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,K.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,K.jsxs)(`div`,{className:`rp-full-box`,children:[(0,K.jsxs)(`div`,{className:`rp-full-head`,children:[(0,K.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,K.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,K.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,K.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,K.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),c===`export`?(0,K.jsxs)(`div`,{className:`rp-full-body`,children:[(0,K.jsxs)(`div`,{className:`rp-full-col`,children:[(0,K.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,K.jsx)(`span`,{children:`导出范围`}),(0,K.jsxs)(`span`,{className:`acts`,children:[(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!0),children:`全选仓库`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!1),children:`全不选`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:V,children:`反选`})]})]}),(0,K.jsxs)(`div`,{className:`rp-full-sel`,children:[I.map(e=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,K.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,K.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),I.length?null:(0,K.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,K.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,K.jsx)(`span`,{children:`看板`}),(0,K.jsxs)(`span`,{className:`acts`,children:[(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`})]})]}),(0,K.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,K.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,K.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,K.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,K.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,K.jsxs)(`div`,{className:`form-acts`,children:[(0,K.jsx)(`button`,{className:`btn`,onClick:H,children:`生成布局`}),(0,K.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:U,children:`下载 JSON`})]})]}),(0,K.jsxs)(`div`,{className:`rp-full-col`,children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,children:(0,K.jsx)(`span`,{children:`导出结果`})}),(0,K.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,K.jsxs)(`div`,{className:`rp-full-body`,children:[(0,K.jsxs)(`div`,{className:`rp-full-col`,children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,children:(0,K.jsx)(`span`,{children:`导入来源`})}),(0,K.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,K.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,K.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,K.jsx)(`div`,{className:`form-acts`,children:(0,K.jsx)(`button`,{className:`btn`,disabled:!y.trim()||P,onClick:ne,children:`差异检查`})}),x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,K.jsx)(`span`,{children:`冲突方案`})}),(0,K.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,K.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,K.jsx)(`span`,{children:t})]},e))}),(0,K.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,K.jsx)(`span`,{children:`克隆`})}),(0,K.jsxs)(`select`,{value:ee,onChange:e=>k(e.target.value),children:[(0,K.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,K.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,K.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,K.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,K.jsx)(`div`,{className:`form-acts`,children:(0,K.jsxs)(`button`,{className:`btn`,disabled:P,onClick:W,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,M?(0,K.jsxs)(`div`,{className:`rp-import-result`,children:[(0,K.jsxs)(`div`,{children:[`新建 `,M.created.length,` · 覆盖 `,M.updated.length,` · 另存 `,M.duplicated.length,` · 跳过 `,M.skipped.length]}),(0,K.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,M.boardsCreated,` / 合并 `,M.boardsMerged,` · 参考关系 `,M.links]}),M.cloned.length?(0,K.jsxs)(`div`,{children:[`克隆 `,M.cloned.length,` 个`]}):null,M.unmatched.length?(0,K.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,M.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,K.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,K.jsxs)(`span`,{children:[`差异(新增 `,se.new,` · 有差异 `,se.changed,` · 一致 `,se.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,K.jsxs)(`span`,{className:`acts`,children:[(0,K.jsx)(`button`,{className:`rp-chip`+(A===``?` on`:``),onClick:()=>j(``),children:`全部`}),(0,K.jsx)(`button`,{className:`rp-chip`+(A===`new`?` on`:``),onClick:()=>j(`new`),children:`新增`}),(0,K.jsx)(`button`,{className:`rp-chip`+(A===`changed`?` on`:``),onClick:()=>j(`changed`),children:`有差异`}),(0,K.jsx)(`button`,{className:`rp-chip`+(A===`same`?` on`:``),onClick:()=>j(`same`),children:`一致`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!0),children:`全选`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!1),children:`全不选`})]})]}),(0,K.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,K.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{style:{width:`32px`}}),(0,K.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,K.jsx)(`th`,{children:`仓库 key`}),(0,K.jsx)(`th`,{children:`差异字段`})]})}),(0,K.jsxs)(`tbody`,{children:[ie.map(e=>(0,K.jsxs)(`tr`,{className:`rp-diff-row `+(q[e.status]?.cls??``),children:[(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`span`,{className:`rp-status `+(q[e.status]?.cls??``),children:q[e.status]?.label})}),(0,K.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,K.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,K.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:P,onClick:()=>ae(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,K.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`b`,{children:e.field}),`: `,(0,K.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,K.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,K.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,K.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,K.jsx)(`td`,{}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,K.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,K.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,K.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,children:(0,K.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,K.jsx)(`span`,{className:`rp-status `+(q[e.status]?.cls??``),children:q[e.status]?.label}),(0,K.jsx)(`span`,{children:e.key}),(0,K.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,K.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,K.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,K.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,K.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,K.jsx)(`button`,{className:`btn small`,disabled:P,onClick:()=>ae(e.key,e.remote),children:`克隆到本地`}):(0,K.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,K.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var ie=o(`board`),ae=o(`repo`),oe=o(`repo-ref`),se=o(`doc`),ce=o(`docs`),le=o(`search`),ue=o(`plus`),de=o(`refresh`),fe=o(`open`),pe=o(`chevron-down`),me=o(`check`);o(`x`);var he=o(`users`);o(`folder`);var J=o(`unlink`),ge=o(`overview`),_e=o(`edit`),ve=o(`trash`),ye=o(`link`);function be({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,K.jsx)(T,{text:t,title:void 0,children:t}):(0,K.jsxs)(T,{text:t,title:`点击复制完整路径`,children:[(0,K.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Y({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(`
|
|
1
|
+
import{c as e,d as t,f as n,h as r,i,l as a,o,r as s,t as c,u as l}from"./popup-DLfU1TXG.js";import{f as u}from"./tool-bar-NHeX0Kmo.js";import{C as d,D as f,E as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as b,f as x,g as S,h as C,i as w,k as T,l as E,m as D,n as O,o as ee,p as k,r as A,s as j,t as M,u as N,v as P,w as F,x as I,y as L}from"./repo-form-modal-DpwLdBYp.js";import{n as R}from"./app-context-DPFYOrgE.js";import{t as z}from"./button-VP4pjVsx.js";import{i as B,n as V}from"./doc-zDLeR8PE.js";import{m as H}from"./md-history-B7TamGno.js";import{i as U,t as te}from"./route-crumb-DS76cmRK.js";import{t as ne}from"./bar-I4qGaKTO.js";import{t as W}from"./member-picker-BtWykPer.js";var G=r(n(),1),K=t(),q={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function re({onClose:t,onChanged:n,repos:r,boards:i}){let o=e(),s=a(),[c,u]=(0,G.useState)(`import`),[d,f]=(0,G.useState)({}),[p,m]=(0,G.useState)({}),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)({}),[T,E]=(0,G.useState)({}),[D,O]=(0,G.useState)(`ours`),[ee,k]=(0,G.useState)(`none`),[A,j]=(0,G.useState)(``),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(!1),I=(0,G.useMemo)(()=>r||[],[r]),L=(0,G.useMemo)(()=>I.map(e=>e.key),[I]),R=(0,G.useMemo)(()=>(i||[]).map(e=>e.name),[i]),z=e=>{let t={};for(let n of L)t[n]=e;f(t)},B=e=>{let t={};for(let n of R)t[n]=e;m(t)},V=()=>{let e={};for(let t of L)e[t]=!d[t];f(e)},H=()=>o(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==L.length?e:void 0,boards:t.length&&t.length!==R.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 i=await l(`/api/repos/export`+(r.toString()?`?`+r:``));v(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),U=()=>{if(!_)return;let e=new Blob([_],{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)},te=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),N(null))},ne=()=>o(async()=>{if(y.trim()){F(!0);try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),N(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{F(!1)}}}),W=()=>o(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);F(!0);try{let r=await l(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:ee,selection:e.length?e:void 0,boards:t.length?t:void 0}});N(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await re(),n&&await n()}finally{F(!1)}}),re=(0,G.useCallback)(async()=>{try{let e=await l(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),ie=(0,G.useMemo)(()=>x?A?x.repos.filter(e=>e.status===A):x.repos:[],[x,A]),ae=(e,t)=>o(async()=>{if(t){F(!0);try{await l(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await re(),n&&await n()}finally{F(!1)}}}),oe=e=>{let t={...C};for(let n of ie)t[n.key]=e;w(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 se=(0,G.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,K.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,K.jsxs)(`div`,{className:`rp-full-box`,children:[(0,K.jsxs)(`div`,{className:`rp-full-head`,children:[(0,K.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,K.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,K.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,K.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,K.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),c===`export`?(0,K.jsxs)(`div`,{className:`rp-full-body`,children:[(0,K.jsxs)(`div`,{className:`rp-full-col`,children:[(0,K.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,K.jsx)(`span`,{children:`导出范围`}),(0,K.jsxs)(`span`,{className:`acts`,children:[(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!0),children:`全选仓库`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>z(!1),children:`全不选`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:V,children:`反选`})]})]}),(0,K.jsxs)(`div`,{className:`rp-full-sel`,children:[I.map(e=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,K.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,K.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),I.length?null:(0,K.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,K.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,K.jsx)(`span`,{children:`看板`}),(0,K.jsxs)(`span`,{className:`acts`,children:[(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`})]})]}),(0,K.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,K.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,K.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,K.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,K.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,K.jsxs)(`div`,{className:`form-acts`,children:[(0,K.jsx)(`button`,{className:`btn`,onClick:H,children:`生成布局`}),(0,K.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:U,children:`下载 JSON`})]})]}),(0,K.jsxs)(`div`,{className:`rp-full-col`,children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,children:(0,K.jsx)(`span`,{children:`导出结果`})}),(0,K.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,K.jsxs)(`div`,{className:`rp-full-body`,children:[(0,K.jsxs)(`div`,{className:`rp-full-col`,children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,children:(0,K.jsx)(`span`,{children:`导入来源`})}),(0,K.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,K.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,K.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,K.jsx)(`div`,{className:`form-acts`,children:(0,K.jsx)(`button`,{className:`btn`,disabled:!y.trim()||P,onClick:ne,children:`差异检查`})}),x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,K.jsx)(`span`,{children:`冲突方案`})}),(0,K.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,K.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,K.jsx)(`span`,{children:t})]},e))}),(0,K.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,K.jsx)(`span`,{children:`克隆`})}),(0,K.jsxs)(`select`,{value:ee,onChange:e=>k(e.target.value),children:[(0,K.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,K.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,K.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,K.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,K.jsx)(`div`,{className:`form-acts`,children:(0,K.jsxs)(`button`,{className:`btn`,disabled:P,onClick:W,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,M?(0,K.jsxs)(`div`,{className:`rp-import-result`,children:[(0,K.jsxs)(`div`,{children:[`新建 `,M.created.length,` · 覆盖 `,M.updated.length,` · 另存 `,M.duplicated.length,` · 跳过 `,M.skipped.length]}),(0,K.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,M.boardsCreated,` / 合并 `,M.boardsMerged,` · 参考关系 `,M.links]}),M.cloned.length?(0,K.jsxs)(`div`,{children:[`克隆 `,M.cloned.length,` 个`]}):null,M.unmatched.length?(0,K.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,M.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,K.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,K.jsxs)(`span`,{children:[`差异(新增 `,se.new,` · 有差异 `,se.changed,` · 一致 `,se.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,K.jsxs)(`span`,{className:`acts`,children:[(0,K.jsx)(`button`,{className:`rp-chip`+(A===``?` on`:``),onClick:()=>j(``),children:`全部`}),(0,K.jsx)(`button`,{className:`rp-chip`+(A===`new`?` on`:``),onClick:()=>j(`new`),children:`新增`}),(0,K.jsx)(`button`,{className:`rp-chip`+(A===`changed`?` on`:``),onClick:()=>j(`changed`),children:`有差异`}),(0,K.jsx)(`button`,{className:`rp-chip`+(A===`same`?` on`:``),onClick:()=>j(`same`),children:`一致`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!0),children:`全选`}),(0,K.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!1),children:`全不选`})]})]}),(0,K.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,K.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{style:{width:`32px`}}),(0,K.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,K.jsx)(`th`,{children:`仓库 key`}),(0,K.jsx)(`th`,{children:`差异字段`})]})}),(0,K.jsxs)(`tbody`,{children:[ie.map(e=>(0,K.jsxs)(`tr`,{className:`rp-diff-row `+(q[e.status]?.cls??``),children:[(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`span`,{className:`rp-status `+(q[e.status]?.cls??``),children:q[e.status]?.label})}),(0,K.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,K.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,K.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:P,onClick:()=>ae(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,K.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`b`,{children:e.field}),`: `,(0,K.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,K.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,K.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,K.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,K.jsx)(`td`,{}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,K.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,K.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,K.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,K.jsx)(`div`,{className:`rp-full-colhead`,children:(0,K.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,K.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,K.jsx)(`span`,{className:`rp-status `+(q[e.status]?.cls??``),children:q[e.status]?.label}),(0,K.jsx)(`span`,{children:e.key}),(0,K.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,K.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,K.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,K.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,K.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,K.jsx)(`button`,{className:`btn small`,disabled:P,onClick:()=>ae(e.key,e.remote),children:`克隆到本地`}):(0,K.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,K.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var ie=o(`board`),ae=o(`repo`),oe=o(`repo-ref`),se=o(`doc`),ce=o(`docs`),le=o(`search`),ue=o(`plus`),de=o(`refresh`),fe=o(`open`),pe=o(`chevron-down`),me=o(`check`);o(`x`);var he=o(`users`);o(`folder`);var J=o(`unlink`),ge=o(`overview`),_e=o(`edit`),ve=o(`trash`),ye=o(`link`);function be({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,K.jsx)(T,{text:t,title:void 0,children:t}):(0,K.jsxs)(T,{text:t,title:`点击复制完整路径`,children:[(0,K.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Y({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(`
|
|
2
2
|
`):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`,o=(e,t)=>e.title||e.desc||`第 ${t+1} 篇`,s=[];return n&&n.exists&&s.push({id:`main`,label:o(n,0),kind:`repo`,main:!0,title:n.title||n.summary||``}),r.forEach((e,t)=>{s.push({id:(e.docId||e.refId||`link`)+`:`+t,label:o(e,t),kind:`repo`,title:String(e.title||e.desc||``)})}),(0,K.jsxs)(`div`,{className:`rp-docs-entry`,role:`button`,tabIndex:0,title:a,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&t()},children:[s.length?(0,K.jsx)(B,{items:s,onMore:t}):(0,K.jsx)(`span`,{className:`rp-docs-entry-main ghost`,children:`+ 写项目介绍`}),(0,K.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function xe({chips:e,acts:t}){let[n,r]=(0,G.useState)(!1),i=n?e:e.slice(0,4);return(0,K.jsxs)(K.Fragment,{children:[i.map(e=>(0,K.jsx)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:(0,K.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`本仓库直接绑定的参考仓库`,`点击跳到这个参考仓库`].join(`
|
|
3
3
|
`),onClick:()=>t.gotoRefRepo(e.key),children:[(0,K.jsx)(`b`,{children:`自`}),(0,K.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.key)),e.length>4?(0,K.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>r(e=>!e),children:n?`收起`:`+${e.length-4}`}):null]})}function Se({r:e,mode:t,filterBoard:n,refRepoChipsByRepo:r,acts:i}){let a=r.get(e.key)||[];return(0,K.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,K.jsxs)(`td`,{className:`rp-name`,children:[(0,K.jsxs)(`strong`,{children:[e.icon?(0,K.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name]}),(0,K.jsx)(`span`,{className:`mono rp-name-path`,children:(0,K.jsx)(be,{path:e.path})})]}),(0,K.jsx)(`td`,{className:`rp-cell-docs`,children:(0,K.jsx)(Y,{docs:e.descDocs,onOpen:()=>i.docs(e)})}),t===`group`?null:(0,K.jsx)(`td`,{className:`rp-boards`,children:(e.boards||[]).length?(e.boards||[]).map(e=>(0,K.jsx)(`button`,{type:`button`,className:`rp-board-chip`,title:`跳到分组「${e.name}」`,onClick:()=>i.filter?.(e.id),children:e.name},e.id)):(0,K.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}),t===`group`?null:(0,K.jsxs)(`td`,{className:`rp-refs`,children:[a.length?(0,K.jsx)(xe,{chips:a,acts:i}):(0,K.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,K.jsx)(z,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>i.bind(e),children:`绑定`})]}),(0,K.jsxs)(`td`,{className:`rp-acts`+(t===`group`?` rp-acts-wrap`:``),children:[(0,K.jsx)(ne,{kind:`repos-row`,renderers:{edit:()=>(0,K.jsxs)(z,{small:!0,onClick:()=>i.edit(e),children:[(0,K.jsx)(`span`,{className:`rp-btn-ico`,children:(0,K.jsx)(_e,{size:12})}),`编辑`]}),open:()=>(0,K.jsxs)(z,{small:!0,title:`在文件管理器中打开`,onClick:()=>i.open(e),children:[(0,K.jsx)(`span`,{className:`rp-btn-ico`,children:(0,K.jsx)(fe,{size:12})}),`打开`]}),del:()=>(0,K.jsxs)(z,{small:!0,danger:!0,onClick:()=>i.del(e),children:[(0,K.jsx)(`span`,{className:`rp-btn-ico`,children:(0,K.jsx)(ve,{size:12})}),`删除`]}),remote:()=>(0,K.jsx)(z,{small:!0,onClick:()=>i.remote(e),children:`对齐 remote`})},actions:{edit:()=>i.edit(e),open:()=>i.open(e),del:()=>i.del(e),remote:()=>i.remote(e)},titles:{remote:`key 与远程 git 地址对齐`,del:`删除仓库登记(磁盘文件不受影响)`}}),t===`group`&&n?(0,K.jsxs)(z,{small:!0,danger:!0,title:`只从这个分组摘除(不影响仓库本体与其它分组)`,onClick:()=>i.unbindBoard?.(e,n.id),children:[(0,K.jsx)(`span`,{className:`rp-btn-ico`,children:(0,K.jsx)(J,{size:12})}),`移出本组`]}):null]})]})}function Ce({shown:e,devRepos:t,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a,onAddMember:o}){let s=n===`group`;return(0,K.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,K.jsxs)(`table`,{className:`rp-table`+(s?` rp-table-group`:``),children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`col`,style:{width:s?`30%`:`22%`},children:`仓库`}),(0,K.jsxs)(`th`,{scope:`col`,style:{width:s?`46%`:`30%`},children:[`文档`,(0,K.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),s?null:(0,K.jsx)(`th`,{scope:`col`,style:{width:`14%`},children:`所在组`}),s?null:(0,K.jsx)(`th`,{scope:`col`,style:{width:`16%`},children:`参考仓库`}),(0,K.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,K.jsxs)(`tbody`,{children:[e.map(e=>(0,K.jsx)(Se,{r:e,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a},e.id)),e.length?null:(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:s?3:5,className:`muted rp-empty`,children:s?(0,K.jsxs)(K.Fragment,{children:[`这个分组里还没有仓库`,` `,r?(0,K.jsx)(z,{small:!0,onClick:()=>o(r.id),children:`添加成员`}):null]}):n==="default"?`没有未归组的仓库 —— 所有仓库都至少在一个分组里。`:t.length?`没有匹配的仓库:换个关键字,或切换分组看看。`:`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}var we=`main`,Te=`default`;function Ee({branches:e,value:t,onChange:n,onCreate:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=e.find(e=>e.id===t)||e[0];(0,G.useEffect)(()=>{if(!i)return;let e=e=>{c.current&&!c.current.contains(e.target)&&a(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),a(!1))};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0);let n=window.setTimeout(()=>l.current?.focus(),20);return()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0),window.clearTimeout(n)}},[i]);let d=(0,G.useMemo)(()=>{let t=o.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||String(e.key||``).toLowerCase().includes(t)):e},[e,o]),f=e=>{a(!1),s(``),e!==t&&n(e)};return(0,K.jsxs)(`div`,{className:`rp-branch`,ref:c,children:[(0,K.jsxs)(`button`,{type:`button`,className:`rp-branch-btn`+(i?` open`:``),title:`切换分组:main = 全部仓库;其余项 = 项目组`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[u&&u.virtual&&u.id===`main`?(0,K.jsx)(ge,{size:14}):(0,K.jsx)(ie,{size:14}),(0,K.jsx)(`span`,{className:`rp-branch-name`,children:u?u.name:we}),(0,K.jsx)(`span`,{className:`rp-branch-btn-caret`,children:(0,K.jsx)(pe,{size:13})})]}),i?(0,K.jsxs)(`div`,{className:`rp-branch-pop`,role:`listbox`,"aria-label":`分组`,children:[(0,K.jsxs)(`div`,{className:`rp-branch-filter`,children:[(0,K.jsx)(le,{size:13}),(0,K.jsx)(`input`,{ref:l,value:o,placeholder:`筛选分组…`,"aria-label":`筛选分组`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d[0]&&f(d[0].id)}})]}),(0,K.jsxs)(`div`,{className:`rp-branch-list`,children:[d.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===t,className:`rp-branch-item`+(e.id===t?` on`:``),title:e.virtual?e.id===`main`?`全部:所有仓库 / 参考仓库 / 文档`:`没有归组的仓库都落在这里`:`项目组「${e.name}」`,onClick:()=>f(e.id),children:[(0,K.jsx)(`span`,{className:`rp-branch-item-ico`,children:e.virtual&&e.id===`main`?(0,K.jsx)(ge,{size:13}):(0,K.jsx)(ie,{size:13})}),(0,K.jsx)(`span`,{className:`rp-branch-item-name`,children:e.name}),(0,K.jsx)(`span`,{className:`rp-branch-item-n`,children:e.repoCount}),(0,K.jsx)(`span`,{className:`rp-branch-item-check`,children:e.id===t?(0,K.jsx)(me,{size:13}):null})]},e.id)),d.length?null:(0,K.jsx)(`div`,{className:`rp-branch-empty`,children:`没有匹配的分组`})]}),r?(0,K.jsxs)(`button`,{type:`button`,className:`rp-branch-new`,onClick:()=>{a(!1),s(``),r()},children:[(0,K.jsx)(ue,{size:13}),(0,K.jsx)(`span`,{children:`新建分组`})]}):null]}):null]})}function De(e,t){if(!t||!e)return!1;let n=e.main;return n&&[n.title,n.summary,n.desc].some(e=>e&&String(e).toLowerCase().includes(t))?!0:(e.links||[]).some(e=>[e.title,e.desc].some(e=>e&&String(e).toLowerCase().includes(t)))}function Oe(e,t,n,r,i){let a;if(n){let t=new Set((n.repos||[]).filter(e=>e.present!==!1).map(e=>e.key));a=e.filter(e=>t.has(e.key))}else a=r==="default"?t:e;return i?a.filter(e=>[e.name,e.key,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(i))||De(e.descDocs,i)):a}function ke(e,t,n,r){let i;if(t){let n=new Set((t.refs||[]).map(e=>e.id));i=e.filter(e=>n.has(e.key))}else i=n==="default"?[]:e;return r?i.filter(e=>[e.name,e.key,e.remote,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(r))):i}function X(e,t){let n=[{id:we,name:`main`,repoCount:t.dev,refCount:t.ref,docCount:t.docs||0,virtual:!0}];for(let t of e)n.push({id:t.id,name:t.name,key:t.key||t.id,repoCount:(t.repos||[]).filter(e=>e.present!==!1).length,refCount:(t.refs||[]).length,docCount:Number(t.docCount)||0});return n.push({id:Te,name:`default`,repoCount:t.ungrouped,refCount:0,docCount:0,virtual:!0}),n}function Ae({repos:e,boardList:t,branch:n,kw:r,docCount:i}){let a=(0,G.useMemo)(()=>e.filter(e=>(e.type||`dev`)!==`ref`),[e]),o=(0,G.useMemo)(()=>e.filter(e=>e.type===`ref`),[e]),s=(0,G.useMemo)(()=>t.find(e=>e.id===n)||null,[t,n]),c=(0,G.useMemo)(()=>a.filter(e=>!(e.boards||[]).length),[a]);return{devRepos:a,refRepos:o,branchBoard:s,ungrouped:c,branches:(0,G.useMemo)(()=>X(t,{dev:a.length,ref:o.length,ungrouped:c.length,docs:i}),[t,a.length,o.length,c.length,i]),groupRefReposByRepo:(0,G.useMemo)(()=>{let e=new Map,n=new Map(o.map(e=>[e.key,e]));for(let r of t){let t=r.key||`board/${r.name}`;for(let i of(r.repos||[]).map(e=>e.key))for(let a of r.refs||[]){let o=n.get(a.id);if(!o)continue;e.has(i)||e.set(i,[]);let s=e.get(i);if(!s)continue;let c=s.find(e=>e.key===o.key);if(c){c.group&&c.group.name!==r.name&&(c.alsoIn=[...c.alsoIn||[],r.name]);continue}s.push({key:o.key,id:o.id,name:o.name,remote:o.remote||``,group:{id:r.id,key:t,name:r.name}})}}return e},[t,o]),refRepoChipsByRepo:(0,G.useMemo)(()=>{let e=new Map,t=new Map(o.map(e=>[e.key,e]));for(let n of a){let r=(n.linked||[]).filter(e=>e&&e.kind===`ref`).map(e=>{let n=t.get(e.id);return n?{key:n.key,name:n.name}:null}).filter(e=>e!==null);e.set(n.key,r)}return e},[a,o]),refRepoBackLinks:(0,G.useMemo)(()=>{let e=new Map;for(let t of a)for(let n of t.linked||[]){if(!n||n.kind!==`ref`)continue;e.has(n.id)||e.set(n.id,[]);let r=e.get(n.id);r&&r.push({repo:t})}return e},[a]),repoRows:(0,G.useMemo)(()=>Oe(a,c,s,n,r),[a,c,s,n,r]),refRows:(0,G.useMemo)(()=>ke(o,s,n,r),[o,s,n,r])}}var Z=`nx-kv-repos-branch-v1`;function je(){try{let e=localStorage.getItem(Z);return(e==null?null:String(e))||null}catch{return null}}function Me(e){try{let t=String(e||``);t&&localStorage.setItem(Z,t)}catch{}}function Ne({value:e,onChange:t,placeholder:n,count:r}){return(0,K.jsxs)(`label`,{className:`rp-q`,title:`全局检索:仓库 / 参考仓库 / 文档 一起搜`,children:[(0,K.jsx)(le,{size:13}),(0,K.jsx)(`input`,{value:e,placeholder:n||`搜索仓库 / 参考仓库 / 文档…`,"aria-label":`全局检索`,onChange:e=>t(e.target.value)}),e?(0,K.jsx)(`span`,{className:`rp-q-n`,children:r===void 0?``:r}):null,e?(0,K.jsx)(`button`,{type:`button`,className:`rp-q-x`,title:`清空检索`,onClick:()=>t(``),children:`×`}):null]})}function Pe({tabs:e,value:t,onChange:n}){return(0,K.jsx)(`div`,{className:`rp-blocks`,children:(0,K.jsx)(`div`,{className:`rp-block-tabs`,role:`tablist`,"aria-label":`区块`,children:e.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===t,disabled:e.disabled,className:`rp-block-tab`+(e.id===t?` on`:``),title:e.tip||`${e.label}(${e.count})`,onClick:()=>{!e.disabled&&e.id!==t&&n(e.id)},children:[(0,K.jsx)(`span`,{className:`rp-block-tab-ico`,children:e.icon}),(0,K.jsx)(`span`,{className:`rp-block-tab-label`,children:e.label}),(0,K.jsx)(`span`,{className:`rp-block-tab-n`,children:e.count})]},e.id))})})}function Fe({rows:e,mode:t,group:n,boardList:r,refRepoBackLinks:i,checkOf:a,onSync:o,onOpen:s,onDocs:c,onBind:l,onUnbindGroup:u,onUnbindRepo:d,onGoBind:f,onManage:p}){let m=t===`group`,[h,g]=(0,G.useState)({});return e.length?(0,K.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-refs`,children:(0,K.jsxs)(`table`,{className:`rp-table rp-table-ref`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`col`,style:{width:`26%`},children:`参考仓库`}),(0,K.jsx)(`th`,{scope:`col`,style:{width:`24%`},children:`远程地址`}),(0,K.jsx)(`th`,{scope:`col`,children:`绑定对象`}),(0,K.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,K.jsx)(`tbody`,{children:e.map(e=>{let t=a.get(e.id),p=r.map(t=>(t.refs||[]).find(t=>t.id===e.key)?{board:t}:null).filter(e=>e!==null),_=i.get(e.key)||[],v=!!h[e.id];return(0,K.jsxs)(`tr`,{id:`rp-refrepo-row-`+e.key,children:[(0,K.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,K.jsxs)(`strong`,{children:[(0,K.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:(t.issues||[]).join(`
|
|
4
4
|
`):`尚未检查`}),e.name]}),(0,K.jsx)(Y,{docs:e.descDocs,onOpen:()=>c(e)})]}),(0,K.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,K.jsx)(T,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,K.jsx)(`td`,{className:`rp-ref-cell-links`,children:p.length||_.length?(0,K.jsxs)(K.Fragment,{children:[p.length?(0,K.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,K.jsx)(`span`,{className:`rp-bind-label`,children:`组`}),(v?p:p.slice(0,3)).map(t=>(0,K.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-group`,children:[(0,K.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`点击跳到这个分组`,`组级绑定(组内共享)`].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-DLfU1TXG.js";import{n as o}from"./app-context-DPFYOrgE.js";import{t as s}from"./button-VP4pjVsx.js";import{a as c,c as l,i as u,l as d,n as f,o as p,r as m,s as h,t as g}from"./index-D2P-v30u.js";var _=r(n(),1);function v(e,t=``){let n=t.trim().toLowerCase(),r=new Map;for(let t of e){let e=t.key.indexOf(`[]`),i=e>=0?t.key.slice(0,e+2):``,a=e>=0?t.key.slice(e+3):t.key;if(!(!n||t.key.toLowerCase().includes(n)||String(t.label||``).toLowerCase().includes(n)||String(t.desc||``).toLowerCase().includes(n)))continue;let o=r.get(i)||[];o.push({full:t.key,rel:a,label:t.label,desc:t.desc,kind:t.kind}),r.set(i,o)}return[...r.entries()].sort(([e],[t])=>e===``?-1:t===``?1:e.localeCompare(t)).map(([e,t])=>({group:e,rows:t}))}var y=t();function b({segment:e,label:t,builtinText:n,seg:r,onChanged:i}){let o=a(),c=r?.activeId||`builtin`,u=r?.items||[],[d,p]=(0,_.useState)(c),[m,h]=(0,_.useState)(``),[v,b]=(0,_.useState)(n),[x,S]=(0,_.useState)(!1);(0,_.useEffect)(()=>{p(c)},[e,c]),(0,_.useEffect)(()=>{if(d===`builtin`)h(`系统内置`),b(n);else{let e=(r?.items||[]).find(e=>e.id===d);h(e?.name||``),b(e?.text||``)}},[d,e,n,r]);let C=d===`builtin`,w=u.find(e=>e.id===d),T=d===c,E=e=>{x||(S(!0),e().catch(e=>o(String(e.message||e))).finally(()=>S(!1)))},D=()=>E(async()=>{C||(await l({segment:e,id:d,name:m,text:v}),o(`模板已保存(启用中的修改即时生效)`),i())}),O=()=>E(async()=>{await l({segment:e,name:m===`系统内置`?`${t} · 副本`:m,text:v}),o(`已存为新模板并启用`),i()}),k=t=>E(async()=>{await g(e,t),o(t===`builtin`?`已切回出厂模板`:`已启用该模板`),i()});return(0,y.jsxs)(`div`,{className:`ppt-tpl-mgr`,children:[(0,y.jsxs)(`div`,{className:`ppt-tpl-bar`,children:[(0,y.jsxs)(`select`,{className:`ppt-tpl-select`,value:d,"aria-label":`${t} 的模板选择`,onChange:e=>p(e.target.value),children:[(0,y.jsxs)(`option`,{value:`builtin`,children:[`出厂内置`,c===`builtin`?`(启用中)`:``]}),u.map(e=>(0,y.jsxs)(`option`,{value:e.id,children:[e.name,c===e.id?`(启用中)`:``]},e.id))]}),!C&&(0,y.jsx)(`input`,{className:`ppt-tpl-name`,value:m,placeholder:`模板名`,"aria-label":`模板名`,onChange:e=>h(e.target.value)}),C?(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`以出厂正文为底稿存成一条用户模板(新建即启用)`,onClick:O,children:`复制为新模板`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{variant:`primary`,disabled:x,title:`保存这条模板的修改`,onClick:D,children:`保存`}),(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`以当前编辑内容为底稿再存一条`,onClick:O,children:`另存为`}),!T&&(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`让这一段使用这条模板`,onClick:()=>k(d),children:`启用`}),T&&(0,y.jsx)(`span`,{className:`ppt-pill is-write`,children:`启用中`}),(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`删除这条用户模板(回落出厂)`,onClick:()=>E(async()=>{w&&(await f(e,d),o(`已删除(回落出厂模板)`),i())}),children:`删除`})]}),C&&c!==`builtin`&&(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`放弃用户模板,回到出厂正文`,onClick:()=>k(`builtin`),children:`回出厂`})]}),(0,y.jsx)(`textarea`,{className:`ppt-tpl-area`,value:v,spellCheck:!1,"aria-label":`${t} 的模板正文${C?`(出厂,只读)`:``}`,readOnly:C,onChange:e=>b(e.target.value)}),(0,y.jsx)(`div`,{className:`ppt-ro-note`,children:C?`出厂正文在插件类里(modules/promptplug/plugins),这里只读——要改就「复制为新模板」后在副本上编辑。`:`保存前会按本段变量白名单校验(引用了不存在的变量会被拒收)。启用中的模板对 get 交付与 CLI 实时生效。`})]})}var x={get:`领取交付(get)`,check:`每轮检查(check)`,done:`尝试完成(done)`},S={get:`agent 执行 get 领走任务时拼在任务正文之后的一大段`,check:`每轮等待检查时告诉 agent「离目标还差多少」`,done:`agent 调 done 时给出的完成门禁`};function C(e){return x[e]||e}function w(){let e=a(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)({}),[o,c]=(0,_.useState)(``),[l,d]=(0,_.useState)(!1),[f,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[x,w]=(0,_.useState)(``),[T,E]=(0,_.useState)({}),D=t=>{u().then(e=>{let r=Array.isArray(e?.plugins)?e.plugins:[];n(r),i(e?.groups||{}),E((e?.segmentTemplates&&typeof e.segmentTemplates==`object`?e.segmentTemplates:{})||{}),t(e)}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,_.useEffect)(()=>{let t=!0;return u().then(e=>{if(!t)return;let r=Array.isArray(e?.plugins)?e.plugins:[];n(r),i(e?.groups||{}),E((e?.segmentTemplates&&typeof e.segmentTemplates==`object`?e.segmentTemplates:{})||{});let a=e?.groups?.get?.[0]||r[0]?.id||``;c(a)}).catch(n=>t&&e(`读取失败:`+(n.message||n))),()=>{t=!1}},[e]),!t)return(0,y.jsx)(`div`,{className:`setp-note`,children:`读取提示词注册表…`});let O=t.find(e=>e.id===o)||t[0];if(!O)return(0,y.jsx)(`div`,{className:`setp-note`,children:`注册表为空:没有任何提示词插件。`});let k=Object.keys(r).length?Object.keys(r):[...new Set(t.map(e=>e.group))],A=new Map(t.map(e=>[e.id,e])),j=v(O.fields,x),M=async()=>{if(!l){d(!0);try{let e=await p({id:0,text:`(预览草稿)这是一条用于查看提示词渲染效果的任务`,summary:``});m({instruction:String(e?.instruction||``),segments:Array.isArray(e?.segments)?e.segments:[],at:new Date().toLocaleTimeString(`zh-CN`,{hour12:!1})}),g(!0)}catch(t){e(String(t.message||t))}finally{d(!1)}}};return(0,y.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,y.jsxs)(`div`,{className:`setp-tpl-head`,children:[(0,y.jsx)(`span`,{className:`setp-tpl-head-label`,children:`提示词模板`}),(0,y.jsx)(`span`,{className:`setp-note`,children:`系统提示词固定按 XML 区块包裹(每段独立标签,agent 一眼分清任务原文与系统规则)`})]}),(0,y.jsxs)(`div`,{className:`ppt-split`,children:[(0,y.jsxs)(`div`,{className:`ppt-rail`,children:[(0,y.jsxs)(`div`,{className:`ppt-rail-head`,children:[(0,y.jsx)(`b`,{children:`时机 / 段落`}),(0,y.jsxs)(`span`,{className:`setp-note`,children:[`共 `,t.length,` 段`]})]}),(0,y.jsx)(`div`,{className:`ppt-rail-list`,children:k.map(e=>{let n=r[e]||t.filter(t=>t.group===e).map(e=>e.id);return(0,y.jsxs)(`div`,{className:`ppt-grp`,children:[(0,y.jsx)(`div`,{className:`ppt-grp-head`,title:S[e]||``,children:C(e)}),n.map((e,t)=>{let n=A.get(e);return n?(0,y.jsxs)(`div`,{className:`ppt-rail-row`+(n.id===O.id?` is-on`:``),role:`button`,tabIndex:0,onClick:()=>c(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c(e))},children:[(0,y.jsx)(`span`,{className:`ppt-rail-pos`,children:t+1}),(0,y.jsxs)(`span`,{className:`ppt-rail-main`,children:[(0,y.jsx)(`span`,{className:`ppt-rail-label`,children:n.label}),(0,y.jsx)(`span`,{className:`ppt-rail-active`,children:n.id})]})]},e):null})]},e)})})]}),(0,y.jsxs)(`div`,{className:`ppt-ed`,children:[(0,y.jsx)(`div`,{className:`ppt-ed-head`,children:(0,y.jsxs)(`div`,{className:`ppt-ed-title`,children:[(0,y.jsx)(`b`,{children:O.label}),(0,y.jsx)(`code`,{className:`ppt-ed-tag`,children:O.tag}),(0,y.jsxs)(`span`,{className:`ppt-pill is-write`,title:`本段渲染时的数据域:${O.varScope.join(` / `)}(seed + 本段自己产的数据;不含别的段)`,children:[`数据域 `,O.varScope.filter(e=>![`task`,`cwd`,`goal`,`source`,`summary`,`name`,`params`].includes(e)).join(` · `)||`仅任务上下文`]}),(0,y.jsxs)(`span`,{className:`ppt-pill`,children:[C(O.group),` · 第 `,O.order,` 位`]})]})}),(0,y.jsx)(b,{segment:O.id,label:O.label,builtinText:O.template,seg:T[O.id],onChanged:()=>D(()=>e(`注册表已刷新`))}),(0,y.jsx)(`div`,{className:`ppt-ed-desc`,children:(0,y.jsxs)(`span`,{className:`ppt-ed-sub`,children:[S[O.group]||``,` · 本段的模板只能引用自己的变量与任务上下文,别的段的数据引用不到`]})}),O.fields.length>0&&(0,y.jsxs)(`div`,{className:`ppt-vars`,"aria-label":`该段可用变量`,children:[(0,y.jsxs)(`div`,{className:`ppt-vars-head`,children:[(0,y.jsxs)(`span`,{className:`ppt-vars-cap`,children:[`可用变量(`,O.fields.length,`)`]}),(0,y.jsx)(`input`,{className:`ppt-vars-q`,value:x,placeholder:`过滤变量,如 localPath`,"aria-label":`过滤变量`,onChange:e=>w(e.target.value)})]}),(0,y.jsxs)(`div`,{className:`ppt-vars-body`,children:[j.map(e=>(0,y.jsxs)(`div`,{className:`ppt-vars-grp`,children:[e.group&&(0,y.jsxs)(`div`,{className:`ppt-vars-grp-head`,title:`在 {{#each ${e.group.slice(0,-2)}}} 内部写相对名`,children:[e.group,` 内部(each 里写相对名,共 `,e.rows.length,`)`]}),(0,y.jsx)(`div`,{className:`ppt-vars-chips`,children:e.rows.map(e=>(0,y.jsxs)(`code`,{className:`ppt-var`,"aria-disabled":`true`,title:`${e.full}${e.desc?` —— ${e.desc}`:``}`,children:[(0,y.jsx)(`span`,{className:`ppt-var-key`,children:e.rel}),e.label&&e.label!==e.full&&e.label!==e.rel&&(0,y.jsx)(`span`,{className:`ppt-var-desc`,children:e.label})]},e.full))})]},e.group||`_main`)),j.length===0&&(0,y.jsxs)(`span`,{className:`ppt-vars-cap`,children:[`没有匹配「`,x,`」的变量`]})]})]}),(0,y.jsxs)(`div`,{className:`ppt-actions`,children:[(0,y.jsx)(`span`,{className:`setp-note`,children:`模板改动即时生效(交付与 timegoal check 同源)。`}),(0,y.jsx)(`span`,{className:`spacer`}),(0,y.jsx)(s,{variant:`secondary`,className:`ppt-preview-btn`,disabled:l,title:`用一条草稿任务渲染当前内置模板的实际输出`,onClick:()=>void M(),children:`预览交付`})]}),(0,y.jsxs)(`div`,{className:`ppt-pv`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`ppt-pv-head`,"aria-expanded":h,onClick:()=>g(e=>!e),children:[(0,y.jsx)(`b`,{children:`交付预览`}),(0,y.jsx)(`span`,{className:`setp-note`,children:f?`命中 ${f.segments.length}/${t.length} 段 · ${f.at} 渲染`:`尚未渲染 · 按内置模板合成`}),(0,y.jsx)(`span`,{className:`ppt-pv-toggle`,children:h?`收起 ⌃`:`展开 ⌄`})]}),h&&(0,y.jsx)(`div`,{className:`ppt-pv-body`,children:f?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`pre`,{className:`ppt-pv-pre`,children:f.instruction||`(本次领取没有可输出的段落)`}),f.segments.length>0&&(0,y.jsx)(`div`,{className:`ppt-pv-segs`,children:f.segments.map((e,t)=>(0,y.jsx)(`span`,{className:`ppt-pv-seg`,children:(0,y.jsx)(`span`,{className:`ppt-pv-seg-label`,children:e.label})},`${e.id}-${t}`))})]}):(0,y.jsx)(`div`,{className:`ppt-pv-empty`,children:`点右上「预览交付」,用一条草稿任务渲染真实领取时会拿到的提示词。`})})]})]})]})]})}var T=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`storage`,label:`本机存储`,icon:`archive`},{id:`docsCleanup`,label:`文档清理`,icon:`archive`},{id:`prompts`,label:`提示词模板`,icon:`flow`}];function E(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function D(){let t=o(),n=a(),{dialog:r,node:l}=i(),u=t.prefs,f=t.patchPrefs||(()=>{}),[p,g]=(0,_.useState)(`pref`),[v,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(!1),[C,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),A=(0,_.useCallback)(async()=>{try{b(await c())}catch(e){n(`读取设置失败:`+(e.message||e))}},[n]),j=(0,_.useCallback)(async()=>{try{D(await m())}catch(e){n(`读取孤儿文档失败:`+(e.message||e))}},[n]);(0,_.useEffect)(()=>{A()},[A]),(0,_.useEffect)(()=>{p===`docsCleanup`&&j()},[p,j]);let M=e=>e().catch(e=>n(String(e.message||e))),N=e=>M(async()=>{if(!e||await r({title:`立即清理孤儿文档`,message:`软删所有「到期 + 没有正文」的孤儿文档;有正文的只列清单,不会自动删。继续?`,okText:`清理`})){k(!0);try{let t=await h({apply:e});D(t),n(e?`已清理 ${t.deleted?.length??0} 篇孤儿文档`:`预演:将清理 ${t.eligible?.length??0} 篇孤儿文档(未删除)`)}finally{k(!1)}}}),P=e=>M(async()=>{S(!0);try{b(await d(e)),n(`已保存`)}finally{S(!1)}}),F={pref:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`侧边栏默认收起`}),(0,y.jsxs)(`button`,{className:`toggle`+(u?.defaultFolded?` on`:``),onClick:()=>f({defaultFolded:!u?.defaultFolded}),children:[(0,y.jsx)(`span`,{className:`dot`}),u?.defaultFolded?`开`:`关`]})]}),(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{title:`任务页面包屑悬浮出的复制钮复制什么:原始路径 =「目录 #任务号」;访问提示词 = 可直接执行的 CLI 指令加引导`,children:`路径复制偏好`}),(0,y.jsxs)(`span`,{className:`setp-seg`,role:`group`,"aria-label":`路径复制偏好`,children:[(0,y.jsx)(`button`,{className:`seg`+(u?.copyPathStyle===`prompt`?``:` on`),onClick:()=>f({copyPathStyle:`raw`}),children:`原始路径`}),(0,y.jsx)(`button`,{className:`seg`+(u?.copyPathStyle===`prompt`?` on`:``),onClick:()=>f({copyPathStyle:`prompt`}),children:`访问提示词`})]})]})]}),work:(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`布局`}),(0,y.jsx)(s,{variant:`secondary`,onClick:async()=>{await r({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&t.shell&&t.shell.resetLayout()},children:`重置为初始两栏`})]})}),storage:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`参考仓库存储根`}),(0,y.jsxs)(`span`,{className:`setp-input`,children:[(0,y.jsx)(`input`,{value:v&&v.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>b(t=>({...t||{},gitRepoRoot:e.target.value}))}),(0,y.jsx)(s,{variant:`secondary`,disabled:!v||x,onClick:()=>v&&P({gitRepoRoot:v.gitRepoRoot}),children:`保存`})]})]}),(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`开发仓库克隆根`}),(0,y.jsxs)(`span`,{className:`setp-input`,children:[(0,y.jsx)(`input`,{value:v&&v.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>b(t=>({...t||{},gitDevRoot:e.target.value}))}),(0,y.jsx)(s,{variant:`secondary`,disabled:!v||x,onClick:()=>v&&P({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),docsCleanup:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`孤儿保留天数`}),(0,y.jsxs)(`span`,{className:`setp-input`,children:[(0,y.jsx)(`input`,{type:`number`,min:1,max:3650,value:v?v.orphanTtlDays??3:3,onChange:e=>b(t=>({...t||{},orphanTtlDays:Number(e.target.value)}))}),(0,y.jsx)(s,{variant:`secondary`,disabled:!v||x,onClick:()=>v&&P({orphanTtlDays:v.orphanTtlDays}),children:`保存`})]})]}),(0,y.jsx)(`div`,{className:`setp-note`,children:`孤儿 = 没有任何 ref_bindings 归属的 ref。到期后软删(ref_bodies 保留);有正文的到期孤儿不自动删,需人工处置。`}),(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:C?`孤儿 ${C.total} 篇 · 到期 ${C.due}(空壳 ${C.dueEmpty} / 有正文 ${C.dueWithBody})`+(C.dueSoon?` · 24h 内到期 ${C.dueSoon}`:``)+(C.untimed?` · 未计时 ${C.untimed}`:``):`孤儿清单:读取中…`}),(0,y.jsxs)(`span`,{className:`setp-gc-actions`,children:[(0,y.jsx)(s,{variant:`secondary`,onClick:()=>void j(),children:`刷新`}),(0,y.jsx)(s,{variant:`secondary`,disabled:O,onClick:()=>void N(!1),children:`预演清理`}),(0,y.jsx)(s,{variant:`secondary`,disabled:O,onClick:()=>void N(!0),children:`立即清理`})]})]}),(0,y.jsxs)(`div`,{className:`setp-gc-list`,children:[(C?.orphans||[]).map(e=>(0,y.jsxs)(`div`,{className:`setp-gc-item`+(e.due?` is-due`:``),children:[(0,y.jsxs)(`div`,{className:`setp-gc-main`,children:[(0,y.jsx)(`b`,{children:e.desc||e.refId}),(0,y.jsx)(`span`,{className:`setp-badge`+(e.hasBody?` soft`:``),children:e.hasBody?`有正文 ${e.bodyBytes}B`:`空壳`}),e.due&&(0,y.jsx)(`span`,{className:`setp-badge is-due`,children:`已到期`})]}),(0,y.jsxs)(`div`,{className:`setp-gc-meta`,children:[(0,y.jsx)(`code`,{children:e.refId}),(0,y.jsxs)(`span`,{children:[`失绑 `,E(e.unboundAt)]}),(0,y.jsx)(`span`,{children:e.unboundAt?`剩余 ${e.remainingDays} 天`:`未计时(维护时起算)`}),e.origin===`external`&&e.locator&&(0,y.jsx)(`span`,{className:`setp-gc-path`,children:e.locator})]})]},e.refId)),C&&C.orphans.length===0&&(0,y.jsx)(`div`,{className:`setp-note`,children:`(当前没有孤儿文档)`}),!C&&(0,y.jsx)(`div`,{className:`setp-note`,children:`(点「刷新」读取)`})]}),(C?.recentDeletions||[]).length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`setp-h`,children:`最近清理`}),(0,y.jsx)(`div`,{className:`setp-gc-list`,children:(C?.recentDeletions||[]).map(e=>(0,y.jsxs)(`div`,{className:`setp-gc-log`,children:[E(e.deletedAt),` · `,(0,y.jsx)(`code`,{children:e.refId}),` · `,e.reason,` · TTL `,e.ttlDays,` 天`,e.desc?` · ${e.desc}`:``]},e.refId+`@`+e.deletedAt))})]})]}),prompts:(0,y.jsx)(w,{})};return(0,y.jsxs)(`div`,{className:`setp`,children:[(0,y.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:T.map(t=>(0,y.jsxs)(`button`,{className:`setp-navitem`+(p===t.id?` on`:``),"aria-current":p===t.id,onClick:()=>g(t.id),children:[(0,y.jsx)(e,{name:t.icon,size:14}),(0,y.jsx)(`span`,{children:t.label})]},t.id))}),(0,y.jsxs)(`div`,{className:`setp-body`,children:[(0,y.jsx)(`div`,{className:`setp-h`,children:T.find(e=>e.id===p)?.label}),F[p]]}),l]})}export{D as default};
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-DLfU1TXG.js";import{n as o}from"./app-context-DPFYOrgE.js";import{t as s}from"./button-VP4pjVsx.js";import{a as c,c as l,i as u,l as d,n as f,o as p,r as m,s as h,t as g}from"./index-Di6ErKBG.js";var _=r(n(),1);function v(e,t=``){let n=t.trim().toLowerCase(),r=new Map;for(let t of e){let e=t.key.indexOf(`[]`),i=e>=0?t.key.slice(0,e+2):``,a=e>=0?t.key.slice(e+3):t.key;if(!(!n||t.key.toLowerCase().includes(n)||String(t.label||``).toLowerCase().includes(n)||String(t.desc||``).toLowerCase().includes(n)))continue;let o=r.get(i)||[];o.push({full:t.key,rel:a,label:t.label,desc:t.desc,kind:t.kind}),r.set(i,o)}return[...r.entries()].sort(([e],[t])=>e===``?-1:t===``?1:e.localeCompare(t)).map(([e,t])=>({group:e,rows:t}))}var y=t();function b({segment:e,label:t,builtinText:n,seg:r,onChanged:i}){let o=a(),c=r?.activeId||`builtin`,u=r?.items||[],[d,p]=(0,_.useState)(c),[m,h]=(0,_.useState)(``),[v,b]=(0,_.useState)(n),[x,S]=(0,_.useState)(!1);(0,_.useEffect)(()=>{p(c)},[e,c]),(0,_.useEffect)(()=>{if(d===`builtin`)h(`系统内置`),b(n);else{let e=(r?.items||[]).find(e=>e.id===d);h(e?.name||``),b(e?.text||``)}},[d,e,n,r]);let C=d===`builtin`,w=u.find(e=>e.id===d),T=d===c,E=e=>{x||(S(!0),e().catch(e=>o(String(e.message||e))).finally(()=>S(!1)))},D=()=>E(async()=>{C||(await l({segment:e,id:d,name:m,text:v}),o(`模板已保存(启用中的修改即时生效)`),i())}),O=()=>E(async()=>{await l({segment:e,name:m===`系统内置`?`${t} · 副本`:m,text:v}),o(`已存为新模板并启用`),i()}),k=t=>E(async()=>{await g(e,t),o(t===`builtin`?`已切回出厂模板`:`已启用该模板`),i()});return(0,y.jsxs)(`div`,{className:`ppt-tpl-mgr`,children:[(0,y.jsxs)(`div`,{className:`ppt-tpl-bar`,children:[(0,y.jsxs)(`select`,{className:`ppt-tpl-select`,value:d,"aria-label":`${t} 的模板选择`,onChange:e=>p(e.target.value),children:[(0,y.jsxs)(`option`,{value:`builtin`,children:[`出厂内置`,c===`builtin`?`(启用中)`:``]}),u.map(e=>(0,y.jsxs)(`option`,{value:e.id,children:[e.name,c===e.id?`(启用中)`:``]},e.id))]}),!C&&(0,y.jsx)(`input`,{className:`ppt-tpl-name`,value:m,placeholder:`模板名`,"aria-label":`模板名`,onChange:e=>h(e.target.value)}),C?(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`以出厂正文为底稿存成一条用户模板(新建即启用)`,onClick:O,children:`复制为新模板`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{variant:`primary`,disabled:x,title:`保存这条模板的修改`,onClick:D,children:`保存`}),(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`以当前编辑内容为底稿再存一条`,onClick:O,children:`另存为`}),!T&&(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`让这一段使用这条模板`,onClick:()=>k(d),children:`启用`}),T&&(0,y.jsx)(`span`,{className:`ppt-pill is-write`,children:`启用中`}),(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`删除这条用户模板(回落出厂)`,onClick:()=>E(async()=>{w&&(await f(e,d),o(`已删除(回落出厂模板)`),i())}),children:`删除`})]}),C&&c!==`builtin`&&(0,y.jsx)(s,{variant:`secondary`,disabled:x,title:`放弃用户模板,回到出厂正文`,onClick:()=>k(`builtin`),children:`回出厂`})]}),(0,y.jsx)(`textarea`,{className:`ppt-tpl-area`,value:v,spellCheck:!1,"aria-label":`${t} 的模板正文${C?`(出厂,只读)`:``}`,readOnly:C,onChange:e=>b(e.target.value)}),(0,y.jsx)(`div`,{className:`ppt-ro-note`,children:C?`出厂正文在插件类里(modules/promptplug/plugins),这里只读——要改就「复制为新模板」后在副本上编辑。`:`保存前会按本段变量白名单校验(引用了不存在的变量会被拒收)。启用中的模板对 get 交付与 CLI 实时生效。`})]})}var x={get:`领取交付(get)`,check:`每轮检查(check)`,done:`尝试完成(done)`},S={get:`agent 执行 get 领走任务时拼在任务正文之后的一大段`,check:`每轮等待检查时告诉 agent「离目标还差多少」`,done:`agent 调 done 时给出的完成门禁`};function C(e){return x[e]||e}function w(){let e=a(),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)({}),[o,c]=(0,_.useState)(``),[l,d]=(0,_.useState)(!1),[f,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(!1),[x,w]=(0,_.useState)(``),[T,E]=(0,_.useState)({}),D=t=>{u().then(e=>{let r=Array.isArray(e?.plugins)?e.plugins:[];n(r),i(e?.groups||{}),E((e?.segmentTemplates&&typeof e.segmentTemplates==`object`?e.segmentTemplates:{})||{}),t(e)}).catch(t=>e(`读取失败:`+(t.message||t)))};if((0,_.useEffect)(()=>{let t=!0;return u().then(e=>{if(!t)return;let r=Array.isArray(e?.plugins)?e.plugins:[];n(r),i(e?.groups||{}),E((e?.segmentTemplates&&typeof e.segmentTemplates==`object`?e.segmentTemplates:{})||{});let a=e?.groups?.get?.[0]||r[0]?.id||``;c(a)}).catch(n=>t&&e(`读取失败:`+(n.message||n))),()=>{t=!1}},[e]),!t)return(0,y.jsx)(`div`,{className:`setp-note`,children:`读取提示词注册表…`});let O=t.find(e=>e.id===o)||t[0];if(!O)return(0,y.jsx)(`div`,{className:`setp-note`,children:`注册表为空:没有任何提示词插件。`});let k=Object.keys(r).length?Object.keys(r):[...new Set(t.map(e=>e.group))],A=new Map(t.map(e=>[e.id,e])),j=v(O.fields,x),M=async()=>{if(!l){d(!0);try{let e=await p({id:0,text:`(预览草稿)这是一条用于查看提示词渲染效果的任务`,summary:``});m({instruction:String(e?.instruction||``),segments:Array.isArray(e?.segments)?e.segments:[],at:new Date().toLocaleTimeString(`zh-CN`,{hour12:!1})}),g(!0)}catch(t){e(String(t.message||t))}finally{d(!1)}}};return(0,y.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,y.jsxs)(`div`,{className:`setp-tpl-head`,children:[(0,y.jsx)(`span`,{className:`setp-tpl-head-label`,children:`提示词模板`}),(0,y.jsx)(`span`,{className:`setp-note`,children:`系统提示词固定按 XML 区块包裹(每段独立标签,agent 一眼分清任务原文与系统规则)`})]}),(0,y.jsxs)(`div`,{className:`ppt-split`,children:[(0,y.jsxs)(`div`,{className:`ppt-rail`,children:[(0,y.jsxs)(`div`,{className:`ppt-rail-head`,children:[(0,y.jsx)(`b`,{children:`时机 / 段落`}),(0,y.jsxs)(`span`,{className:`setp-note`,children:[`共 `,t.length,` 段`]})]}),(0,y.jsx)(`div`,{className:`ppt-rail-list`,children:k.map(e=>{let n=r[e]||t.filter(t=>t.group===e).map(e=>e.id);return(0,y.jsxs)(`div`,{className:`ppt-grp`,children:[(0,y.jsx)(`div`,{className:`ppt-grp-head`,title:S[e]||``,children:C(e)}),n.map((e,t)=>{let n=A.get(e);return n?(0,y.jsxs)(`div`,{className:`ppt-rail-row`+(n.id===O.id?` is-on`:``),role:`button`,tabIndex:0,onClick:()=>c(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c(e))},children:[(0,y.jsx)(`span`,{className:`ppt-rail-pos`,children:t+1}),(0,y.jsxs)(`span`,{className:`ppt-rail-main`,children:[(0,y.jsx)(`span`,{className:`ppt-rail-label`,children:n.label}),(0,y.jsx)(`span`,{className:`ppt-rail-active`,children:n.id})]})]},e):null})]},e)})})]}),(0,y.jsxs)(`div`,{className:`ppt-ed`,children:[(0,y.jsx)(`div`,{className:`ppt-ed-head`,children:(0,y.jsxs)(`div`,{className:`ppt-ed-title`,children:[(0,y.jsx)(`b`,{children:O.label}),(0,y.jsx)(`code`,{className:`ppt-ed-tag`,children:O.tag}),(0,y.jsxs)(`span`,{className:`ppt-pill is-write`,title:`本段渲染时的数据域:${O.varScope.join(` / `)}(seed + 本段自己产的数据;不含别的段)`,children:[`数据域 `,O.varScope.filter(e=>![`task`,`cwd`,`goal`,`source`,`summary`,`name`,`params`].includes(e)).join(` · `)||`仅任务上下文`]}),(0,y.jsxs)(`span`,{className:`ppt-pill`,children:[C(O.group),` · 第 `,O.order,` 位`]})]})}),(0,y.jsx)(b,{segment:O.id,label:O.label,builtinText:O.template,seg:T[O.id],onChanged:()=>D(()=>e(`注册表已刷新`))}),(0,y.jsx)(`div`,{className:`ppt-ed-desc`,children:(0,y.jsxs)(`span`,{className:`ppt-ed-sub`,children:[S[O.group]||``,` · 本段的模板只能引用自己的变量与任务上下文,别的段的数据引用不到`]})}),O.fields.length>0&&(0,y.jsxs)(`div`,{className:`ppt-vars`,"aria-label":`该段可用变量`,children:[(0,y.jsxs)(`div`,{className:`ppt-vars-head`,children:[(0,y.jsxs)(`span`,{className:`ppt-vars-cap`,children:[`可用变量(`,O.fields.length,`)`]}),(0,y.jsx)(`input`,{className:`ppt-vars-q`,value:x,placeholder:`过滤变量,如 localPath`,"aria-label":`过滤变量`,onChange:e=>w(e.target.value)})]}),(0,y.jsxs)(`div`,{className:`ppt-vars-body`,children:[j.map(e=>(0,y.jsxs)(`div`,{className:`ppt-vars-grp`,children:[e.group&&(0,y.jsxs)(`div`,{className:`ppt-vars-grp-head`,title:`在 {{#each ${e.group.slice(0,-2)}}} 内部写相对名`,children:[e.group,` 内部(each 里写相对名,共 `,e.rows.length,`)`]}),(0,y.jsx)(`div`,{className:`ppt-vars-chips`,children:e.rows.map(e=>(0,y.jsxs)(`code`,{className:`ppt-var`,"aria-disabled":`true`,title:`${e.full}${e.desc?` —— ${e.desc}`:``}`,children:[(0,y.jsx)(`span`,{className:`ppt-var-key`,children:e.rel}),e.label&&e.label!==e.full&&e.label!==e.rel&&(0,y.jsx)(`span`,{className:`ppt-var-desc`,children:e.label})]},e.full))})]},e.group||`_main`)),j.length===0&&(0,y.jsxs)(`span`,{className:`ppt-vars-cap`,children:[`没有匹配「`,x,`」的变量`]})]})]}),(0,y.jsxs)(`div`,{className:`ppt-actions`,children:[(0,y.jsx)(`span`,{className:`setp-note`,children:`模板改动即时生效(交付与 timegoal check 同源)。`}),(0,y.jsx)(`span`,{className:`spacer`}),(0,y.jsx)(s,{variant:`secondary`,className:`ppt-preview-btn`,disabled:l,title:`用一条草稿任务渲染当前内置模板的实际输出`,onClick:()=>void M(),children:`预览交付`})]}),(0,y.jsxs)(`div`,{className:`ppt-pv`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`ppt-pv-head`,"aria-expanded":h,onClick:()=>g(e=>!e),children:[(0,y.jsx)(`b`,{children:`交付预览`}),(0,y.jsx)(`span`,{className:`setp-note`,children:f?`命中 ${f.segments.length}/${t.length} 段 · ${f.at} 渲染`:`尚未渲染 · 按内置模板合成`}),(0,y.jsx)(`span`,{className:`ppt-pv-toggle`,children:h?`收起 ⌃`:`展开 ⌄`})]}),h&&(0,y.jsx)(`div`,{className:`ppt-pv-body`,children:f?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`pre`,{className:`ppt-pv-pre`,children:f.instruction||`(本次领取没有可输出的段落)`}),f.segments.length>0&&(0,y.jsx)(`div`,{className:`ppt-pv-segs`,children:f.segments.map((e,t)=>(0,y.jsx)(`span`,{className:`ppt-pv-seg`,children:(0,y.jsx)(`span`,{className:`ppt-pv-seg-label`,children:e.label})},`${e.id}-${t}`))})]}):(0,y.jsx)(`div`,{className:`ppt-pv-empty`,children:`点右上「预览交付」,用一条草稿任务渲染真实领取时会拿到的提示词。`})})]})]})]})]})}var T=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`storage`,label:`本机存储`,icon:`archive`},{id:`docsCleanup`,label:`文档清理`,icon:`archive`},{id:`prompts`,label:`提示词模板`,icon:`flow`}];function E(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function D(){let t=o(),n=a(),{dialog:r,node:l}=i(),u=t.prefs,f=t.patchPrefs||(()=>{}),[p,g]=(0,_.useState)(`pref`),[v,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(!1),[C,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(!1),A=(0,_.useCallback)(async()=>{try{b(await c())}catch(e){n(`读取设置失败:`+(e.message||e))}},[n]),j=(0,_.useCallback)(async()=>{try{D(await m())}catch(e){n(`读取孤儿文档失败:`+(e.message||e))}},[n]);(0,_.useEffect)(()=>{A()},[A]),(0,_.useEffect)(()=>{p===`docsCleanup`&&j()},[p,j]);let M=e=>e().catch(e=>n(String(e.message||e))),N=e=>M(async()=>{if(!e||await r({title:`立即清理孤儿文档`,message:`软删所有「到期 + 没有正文」的孤儿文档;有正文的只列清单,不会自动删。继续?`,okText:`清理`})){k(!0);try{let t=await h({apply:e});D(t),n(e?`已清理 ${t.deleted?.length??0} 篇孤儿文档`:`预演:将清理 ${t.eligible?.length??0} 篇孤儿文档(未删除)`)}finally{k(!1)}}}),P=e=>M(async()=>{S(!0);try{b(await d(e)),n(`已保存`)}finally{S(!1)}}),F={pref:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`侧边栏默认收起`}),(0,y.jsxs)(`button`,{className:`toggle`+(u?.defaultFolded?` on`:``),onClick:()=>f({defaultFolded:!u?.defaultFolded}),children:[(0,y.jsx)(`span`,{className:`dot`}),u?.defaultFolded?`开`:`关`]})]}),(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{title:`任务页面包屑悬浮出的复制钮复制什么:原始路径 =「目录 #任务号」;访问提示词 = 可直接执行的 CLI 指令加引导`,children:`路径复制偏好`}),(0,y.jsxs)(`span`,{className:`setp-seg`,role:`group`,"aria-label":`路径复制偏好`,children:[(0,y.jsx)(`button`,{className:`seg`+(u?.copyPathStyle===`prompt`?``:` on`),onClick:()=>f({copyPathStyle:`raw`}),children:`原始路径`}),(0,y.jsx)(`button`,{className:`seg`+(u?.copyPathStyle===`prompt`?` on`:``),onClick:()=>f({copyPathStyle:`prompt`}),children:`访问提示词`})]})]})]}),work:(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`布局`}),(0,y.jsx)(s,{variant:`secondary`,onClick:async()=>{await r({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&t.shell&&t.shell.resetLayout()},children:`重置为初始两栏`})]})}),storage:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`参考仓库存储根`}),(0,y.jsxs)(`span`,{className:`setp-input`,children:[(0,y.jsx)(`input`,{value:v&&v.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>b(t=>({...t||{},gitRepoRoot:e.target.value}))}),(0,y.jsx)(s,{variant:`secondary`,disabled:!v||x,onClick:()=>v&&P({gitRepoRoot:v.gitRepoRoot}),children:`保存`})]})]}),(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`开发仓库克隆根`}),(0,y.jsxs)(`span`,{className:`setp-input`,children:[(0,y.jsx)(`input`,{value:v&&v.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>b(t=>({...t||{},gitDevRoot:e.target.value}))}),(0,y.jsx)(s,{variant:`secondary`,disabled:!v||x,onClick:()=>v&&P({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),docsCleanup:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:`孤儿保留天数`}),(0,y.jsxs)(`span`,{className:`setp-input`,children:[(0,y.jsx)(`input`,{type:`number`,min:1,max:3650,value:v?v.orphanTtlDays??3:3,onChange:e=>b(t=>({...t||{},orphanTtlDays:Number(e.target.value)}))}),(0,y.jsx)(s,{variant:`secondary`,disabled:!v||x,onClick:()=>v&&P({orphanTtlDays:v.orphanTtlDays}),children:`保存`})]})]}),(0,y.jsx)(`div`,{className:`setp-note`,children:`孤儿 = 没有任何 ref_bindings 归属的 ref。到期后软删(ref_bodies 保留);有正文的到期孤儿不自动删,需人工处置。`}),(0,y.jsxs)(`div`,{className:`setp-row`,children:[(0,y.jsx)(`span`,{children:C?`孤儿 ${C.total} 篇 · 到期 ${C.due}(空壳 ${C.dueEmpty} / 有正文 ${C.dueWithBody})`+(C.dueSoon?` · 24h 内到期 ${C.dueSoon}`:``)+(C.untimed?` · 未计时 ${C.untimed}`:``):`孤儿清单:读取中…`}),(0,y.jsxs)(`span`,{className:`setp-gc-actions`,children:[(0,y.jsx)(s,{variant:`secondary`,onClick:()=>void j(),children:`刷新`}),(0,y.jsx)(s,{variant:`secondary`,disabled:O,onClick:()=>void N(!1),children:`预演清理`}),(0,y.jsx)(s,{variant:`secondary`,disabled:O,onClick:()=>void N(!0),children:`立即清理`})]})]}),(0,y.jsxs)(`div`,{className:`setp-gc-list`,children:[(C?.orphans||[]).map(e=>(0,y.jsxs)(`div`,{className:`setp-gc-item`+(e.due?` is-due`:``),children:[(0,y.jsxs)(`div`,{className:`setp-gc-main`,children:[(0,y.jsx)(`b`,{children:e.desc||e.refId}),(0,y.jsx)(`span`,{className:`setp-badge`+(e.hasBody?` soft`:``),children:e.hasBody?`有正文 ${e.bodyBytes}B`:`空壳`}),e.due&&(0,y.jsx)(`span`,{className:`setp-badge is-due`,children:`已到期`})]}),(0,y.jsxs)(`div`,{className:`setp-gc-meta`,children:[(0,y.jsx)(`code`,{children:e.refId}),(0,y.jsxs)(`span`,{children:[`失绑 `,E(e.unboundAt)]}),(0,y.jsx)(`span`,{children:e.unboundAt?`剩余 ${e.remainingDays} 天`:`未计时(维护时起算)`}),e.origin===`external`&&e.locator&&(0,y.jsx)(`span`,{className:`setp-gc-path`,children:e.locator})]})]},e.refId)),C&&C.orphans.length===0&&(0,y.jsx)(`div`,{className:`setp-note`,children:`(当前没有孤儿文档)`}),!C&&(0,y.jsx)(`div`,{className:`setp-note`,children:`(点「刷新」读取)`})]}),(C?.recentDeletions||[]).length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`setp-h`,children:`最近清理`}),(0,y.jsx)(`div`,{className:`setp-gc-list`,children:(C?.recentDeletions||[]).map(e=>(0,y.jsxs)(`div`,{className:`setp-gc-log`,children:[E(e.deletedAt),` · `,(0,y.jsx)(`code`,{children:e.refId}),` · `,e.reason,` · TTL `,e.ttlDays,` 天`,e.desc?` · ${e.desc}`:``]},e.refId+`@`+e.deletedAt))})]})]}),prompts:(0,y.jsx)(w,{})};return(0,y.jsxs)(`div`,{className:`setp`,children:[(0,y.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:T.map(t=>(0,y.jsxs)(`button`,{className:`setp-navitem`+(p===t.id?` on`:``),"aria-current":p===t.id,onClick:()=>g(t.id),children:[(0,y.jsx)(e,{name:t.icon,size:14}),(0,y.jsx)(`span`,{children:t.label})]},t.id))}),(0,y.jsxs)(`div`,{className:`setp-body`,children:[(0,y.jsx)(`div`,{className:`setp-h`,children:T.find(e=>e.id===p)?.label}),F[p]]}),l]})}export{D as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,i,l as a,n as o,t as s,u as c}from"./popup-DLfU1TXG.js";import{D as l,f as u,n as d,u as f}from"./tool-bar-NHeX0Kmo.js";import{n as p}from"./app-context-DPFYOrgE.js";import{a as m,r as h,t as g}from"./md-parse-BjzYV8n7.js";import{t as _}from"./board-view-jt8QixVg.js";import{a as v,c as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,w as O}from"./md-history-
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a,n as o,t as s,u as c}from"./popup-DLfU1TXG.js";import{D as l,f as u,n as d,u as f}from"./tool-bar-NHeX0Kmo.js";import{n as p}from"./app-context-DPFYOrgE.js";import{a as m,r as h,t as g}from"./md-parse-BjzYV8n7.js";import{t as _}from"./board-view-jt8QixVg.js";import{a as v,c as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,w as O}from"./md-history-B7TamGno.js";import{i as ee,r as te,t as k}from"./use-rail-drag-4iK6t5ab.js";import{C as ne,S as A,_ as j,b as M,g as N,h as P,v as F,x as I,y as re}from"./index-Di6ErKBG.js";import{a as L,i as R,n as ie,o as z}from"./composer-launch-C20VCKMu.js";import{a as B,d as ae,f as V,g as oe,i as se,l as ce,m as H,n as le,o as ue,r as U,s as de,t as W,u as G}from"./reopen-text-D0eQ2XAC.js";import{t as fe}from"./template-preview-EM3OQ1Rc.js";import{n as pe,r as me,t as he}from"./task-utils-Y-j-zi8J.js";import{n as ge}from"./task-intent-CX5DZccN.js";import{n as _e}from"./group-project-memo-G-O6sPRw.js";var K=r(n(),1),q=t();function ve(e){return c(`/api/localtasks/chain?${e}`)}function ye(e){return c(`/api/localtasks/timegoal-log?${e}`)}function be(e){return c(`/api/localtasks/clone`,{method:`POST`,body:e})}function xe(e){return c(`/api/localtasks/fork`,{method:`POST`,body:e})}function Se(e){return c(`/api/localtasks/attachments?${e}`)}function Ce(e){return c(`/api/docs/mdfile?attachment=${encodeURIComponent(e)}`)}function we(e){return c(`/api/localtasks/preview`,{method:`POST`,body:e})}var Te=_,Ee=/^draft/i;function De(e){return e.status===`done`?`(已完成)`:e.status===`claimed`?`(已领取)`:e.status===`plan`?`(草稿)`:``}var Oe={pending:0,plan:1,claimed:2,done:3};function J(e){return[...e].sort((e,t)=>{let n=(Oe[String(e.status)]??9)-(Oe[String(t.status)]??9);return n===0?e.status===`done`&&t.status===`done`?String(t.doneAt||``).localeCompare(String(e.doneAt||``)):0:n})}function ke(e,t,n){let r=new Map;for(let e of t||[]){let t=e&&e.repo&&e.repo.key?String(e.repo.key):``;t&&!r.has(t)&&r.set(t,e)}let i=[],a=new Set,o=e=>{e&&e.key&&!a.has(e.key)&&(a.add(e.key),i.push(e))};for(let t of e&&Array.isArray(e.items)?e.items:[])if(t.startsWith(`board:`)){let e=n.find(e=>e&&e.id===t.slice(6));for(let t of e&&Array.isArray(e.repos)?e.repos:[])t&&t.key&&o(r.get(String(t.key)))}else o(r.get(t));return i}function Ae(e,t,n){let r=new Set;for(let i of n)for(let n of ke(i,e,t))r.add(n.key);return(e||[]).filter(e=>e&&e.key&&!r.has(e.key))}function je(e,t,n){for(let r of ke(e,t,n)){let e=r.repo&&Array.isArray(r.repo.boards)?r.repo.boards[0]:null;return e&&e.id&&n.some(t=>t&&t.id===e.id)?`#/group/`+encodeURIComponent(String(e.id)):`#/dir/`+encodeURIComponent(String(r.key))}return``}function Me(e,t=[],n={},r={}){if(!e||!e.view)return null;let i=e.view===`group`,a=e.view===`dir`;if(!i&&!a)return null;let o=n.boards||[],s=Array.isArray(r.namespaces)?r.namespaces:[],c=null,l=null,u=null;if(i){let n=Te(t,o,e.key,e.task==null?``:e.task)||{};l=n.board||null,c=n.topic||null,u=n.taskRow||null}else{c=(t||[]).find(t=>t&&t.key===e.key)||null,c&&e.task&&!Ee.test(String(e.task))&&(u=(c.tasks||[]).find(t=>t&&String(t.id)===String(e.task))||null);let n=c&&c.repo&&Array.isArray(c.repo.boards)?c.repo.boards:[];n.length&&n[0]&&n[0].id&&(l=o.find(e=>e&&e.id===n[0].id)||null)}if(!c||!c.key)return null;let d=c.repo&&c.repo.key?String(c.repo.key):``,f=!e.task||Ee.test(String(e.task)),p=f?``:String(e.task),m=s.find(e=>{let t=Array.isArray(e.items)?e.items:[];return t.includes(d)||!!l&&t.includes(`board:`+String(l.id))})||null,h=s.filter(e=>!m||e.id!==m.id).map(e=>({label:String(e.name||e.id),hash:``,nsId:e.id})),g=(m?ke(m,t,o):Ae(t,o,s)).filter(e=>e.key!==c.key).map(e=>({label:String(e.name||e.key),hash:`#/dir/`+encodeURIComponent(String(e.key))})),_=[];if(e.task){let e=i&&l?`#/group/`+encodeURIComponent(String(l.id)):`#/dir/`+encodeURIComponent(String(c.key)),t=J((c.tasks||[]).filter(e=>e&&!e.deletedAt&&!e.migratedTo&&String(e.id)!==p));for(let n of t.slice(0,40))_.push({label:`#`+String(n.id)+De(n),hash:e+`?task=`+encodeURIComponent(String(n.id)),taskId:String(n.id)})}let v=[{kind:`ns`,label:m?String(m.name||m.id):`未分组`,siblings:h},{kind:`owner`,label:String(l?l.name:c.name||c.key),siblings:g}];if(e.task){let e=f?`draft`:`#`+(u?String(u.id):p);v.push({kind:`task`,label:e,siblings:_})}return{segments:v,topicKey:String(c.key),dirName:String(c.name||c.key),cwd:String(c.cwd||``),taskId:p,boardId:l?String(l.id):``,isGroup:i}}function Y(e,t,n,r){let i=e||t;return n?r===`prompt`?[`任务 #${n} 在队列「${t}」(cwd:${i})`,`查看:nx-kv localtask show --id ${n} --cwd "${i}" --json`,`领取处理:nx-kv localtask get --cwd "${i}" --json`].join(`
|
|
2
2
|
`):i+` #`+n:i+` (draft)`}function Ne(e,t){return Y(e.cwd,e.dirName,e.taskId,t)}function Pe({onPreviewTask:t}={}){let n=p(),r=a(),[i,s]=(0,K.useState)(null),c=(0,K.useMemo)(()=>Me(n.route,n.rows||[],n.repoData||{},n.prefs||{}),[n.route,n.rows,n.repoData,n.prefs]);if(!c)return null;let l=n.prefs&&n.prefs.copyPathStyle===`prompt`?`prompt`:`raw`,u=async(e,t)=>{try{await navigator.clipboard.writeText(e),r(t)}catch{r(`复制失败:剪贴板不可用`)}},d=(i,a)=>{i.siblings.length&&s({x:a.clientX,y:a.clientY+6,width:150,items:i.siblings.map(a=>({label:a.label,icon:a.nsId?`flow`:void 0,onClick:()=>{if(a.nsId){n.patchPrefs?.({focusNs:a.nsId});let e=je(((n.prefs||{}).namespaces||[]).find(e=>e.id===a.nsId),n.rows||[],(n.repoData||{}).boards||[]);e&&n.onNavigate?n.onNavigate(e):r(`已切到「${a.label}」(还没有可打开的目录)`);return}a.hash&&n.onNavigate&&n.onNavigate(a.hash)},hoverActions:a.taskId&&i.kind===`task`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{role:`button`,title:l===`prompt`?`复制该任务的访问提示词`:`复制该任务的路径 + 任务号`,onClick:()=>u(Y(c.cwd,c.dirName,a.taskId||``,l),l===`prompt`?`已复制访问提示词`:`已复制路径`),children:(0,q.jsx)(e,{name:`copy`,size:12})}),t&&(0,q.jsx)(`span`,{role:`button`,title:`预览原文(旁路打开)`,onClick:()=>t(a.taskId||``),children:(0,q.jsx)(e,{name:`eye`,size:12})})]}):void 0}))})},f=l===`prompt`?`复制访问提示词(CLI 指令 + 引导)——设置 → 偏好可切换为原始路径`:`复制路径 + 任务号——设置 → 偏好可切换为访问提示词`;return(0,q.jsxs)(`div`,{className:`vsc-crumbs`,children:[(0,q.jsx)(`nav`,{className:`vsc-crumbs-path`,"aria-label":`当前位置`,children:c.segments.map((e,t)=>(0,q.jsxs)(`span`,{className:`vsc-crumb`+(t===c.segments.length-1?` is-cur`:``),children:[t>0&&(0,q.jsx)(`span`,{className:`vsc-sep`,"aria-hidden":!0,children:`>`}),(0,q.jsx)(`button`,{type:`button`,className:`vsc-crumb-t`,disabled:!e.siblings.length,title:e.siblings.length?`显示「${e.label}」的同级`:e.label,onClick:t=>d(e,t),children:e.label})]},e.kind))}),(0,q.jsx)(`button`,{type:`button`,className:`vsc-copy`,title:f,"aria-label":f,onClick:()=>u(Ne(c,l),l===`prompt`?`已复制访问提示词`:`已复制路径`),children:(0,q.jsx)(e,{name:`copy`,size:13})}),i&&(0,q.jsx)(o,{x:i.x,y:i.y,width:i.width,items:i.items,onClose:()=>s(null)})]})}function Fe(e){let t=String(e??``).split(`
|
|
3
3
|
`),n=B(t[0]);return n?{head:n,body:t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
|
|
4
4
|
`)}:null}function Ie(e){let t=E(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=Fe(a);if(o&&se(o.head)===`summary`){let e=o.head.round;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&&se(o.head)===`feedback`){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?`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,d as t,f as n,h as r,l as i,n as a,r as o,t as s}from"./popup-DLfU1TXG.js";import{O as c}from"./repo-form-modal-BahZhXq3.js";import{n as l}from"./app-context-DPFYOrgE.js";import{r as u}from"./md-parse-BjzYV8n7.js";import{t as d}from"./button-VP4pjVsx.js";import{d as f,g as p,h as m}from"./md-history-D0bYVPZY.js";import{S as h,h as g,w as _,x as v}from"./index-D2P-v30u.js";import{t as y}from"./graph-BTEfvFz6.js";import{c as b,d as x,f as S,g as C,l as w,m as T,n as E,p as D,r as O,s as ee,t as te,u as k}from"./reopen-text-D0eQ2XAC.js";import{n as A}from"./template-preview-EM3OQ1Rc.js";import{a as j}from"./manage-session-CuaL7QqQ.js";import{t as ne}from"./bar-I4qGaKTO.js";var M=r(n(),1),N=t(),P=10;function re({repo:e,onClose:t,onSaved:n}){let r=l(),a=i(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,f]=(0,M.useState)(!!(o&&o.enabled)),[p,m]=(0,M.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(P)),[h,g]=(0,M.useState)(!1),_=e=>{let t=String(e??``).trim();if(t===``)return P;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):P},v=async t=>{let i=String(e.id??``);g(!0);try{let o=t&&t.enabled!==void 0?t.enabled:u;await c(i,{"get-loop":o?`on`:`off`,...o?{"get-loop-minutes":_(p)}:{}});let s=_(p);a(o?`已保存「${e.name}」的持续 get 设置(${s>0?`${s} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){a(String(e.message||e))}finally{g(!1)}},y=async e=>{f(e),await v({enabled:e})};return(0,N.jsx)(s,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,N.jsxs)(`div`,{className:`rp-gl`,children:[(0,N.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,N.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,N.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,N.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,N.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>y(!u),disabled:h,children:[(0,N.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,N.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,N.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,N.jsx)(`span`,{children:`阻塞窗口`}),(0,N.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,N.jsx)(`input`,{className:`rp-gl-min`,value:p,onChange:e=>m(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,N.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,N.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,N.jsx)(`span`,{className:`spacer`}),(0,N.jsx)(d,{variant:`primary`,disabled:h,onClick:()=>v(),children:`保存持续 get 设置`})]})]})]})})}var F=s,I=(e,t,n)=>y(e=>n.get(Number(e))||[],e,t);function L({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,M.useState)(!!e.blocksFollowing),[l,d]=(0,M.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,p]=(0,M.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,M.useState)(!1),g=t.findIndex(e=>i(e)===a),_=t.slice(g+1).map(i),v=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),y=e=>s||!l.has(i(e))&&I(i(e),a,v),b=e=>!f.has(i(e))&&I(a,i(e),v),x=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),S=()=>c(e=>(e||d(new Set),!e)),C=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=f.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},w=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,N.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,N.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,N.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,N.jsx)(F,{title:`编排 · #${a} ${u(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,N.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,N.jsxs)(`div`,{className:`mdw-dag`,children:[(0,N.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,N.jsx)(`b`,{children:`闸门`}),(0,N.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,N.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,N.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,N.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,N.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,l.has(i(e)),y(e),x(d))):(0,N.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,N.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,N.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,N.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,f.has(i(e)),s||b(e),x(p))):(0,N.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,N.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function R(e,t,n){if(!A(e?.body).length||!e?.id)return!1;let r=j({...t,templateId:String(e.id)});return n.onNavigate?.(`#/templates/fill/${r}`),!0}function ie(e,t){let n=Array.isArray(e)?e:[],[r,i]=(0,M.useState)(0),a=Math.max(1,Number(t)||1),o=Math.max(1,Math.ceil(n.length/a)),s=Math.min(Math.max(0,r),o-1),c=s*a;return{page:s,pageCount:o,total:n.length,items:n.slice(c,c+a),setPage:i}}function ae({page:e=0,pageCount:t=1,total:n=0,onPage:r,unit:i=`条`}){let a=e=>r&&r(Math.max(0,Math.min(e,t-1)));return t<=1?(0,N.jsxs)(`span`,{className:`pager-n`,children:[`共 `,n,` `,i]}):(0,N.jsxs)(`span`,{className:`pager`,children:[(0,N.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e<=0,onClick:()=>a(e-1),"aria-label":`上一页`,title:`上一页`,children:`‹`}),(0,N.jsxs)(`span`,{className:`pager-n`,children:[`第 `,e+1,`/`,t,` 页 · 共 `,n,` `,i]}),(0,N.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e>=t-1,onClick:()=>a(e+1),"aria-label":`下一页`,title:`下一页`,children:`›`})]})}function oe({icon:t=`list`,title:n,pendingCount:r=0,headerExtra:i=null,children:a=null,emptyText:o=``}){let s=Array.isArray(a)?a.length>0:!!a;return(0,N.jsxs)(`div`,{className:`rp-tasks`,children:[(0,N.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,N.jsx)(e,{name:t,size:13}),` `,n,r>0&&(0,N.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!s&&o?(0,N.jsx)(`div`,{className:`rp-proj-none muted`,children:o}):null]})}function se({name:t,counts:n=[],icon:r=`folder`,actions:i=null,intro:a=null,batch:o=null,list:s=null,footer:c=null,extra:l=null}){return(0,N.jsxs)(`div`,{className:`rp-page`,children:[(0,N.jsxs)(`div`,{className:`rp-group-head`,children:[(0,N.jsxs)(`h2`,{children:[(0,N.jsx)(e,{name:r,size:15}),` `,t,n.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,N.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,N.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,o,s,c,l]})}function z(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/),r=n?.[1],i=n?.[2];return r&&i?`${r.slice(5)} ${i}`:t.slice(0,16)}function ce({t,projectTag:n=``,projectTitle:r=``,selectable:i=!1,picked:a=!1,onTogglePick:o,draggable:s=!1,dragHandlers:c=null,dragVisual:l,onOpen:u,showTimes:d=!1,downs:p=[],history:h=!1,ops:g=null,searchCtx:v=null,searchQuery:y=``}){let[b,x]=(0,M.useState)(!1),S=`rp-proj-row`+(l?.dragging?` dragging`:``)+(l?.drop?` drop-`+l.drop:``),C=t.status===`pending`&&t.ready===!1;return(0,N.jsxs)(`div`,{className:S,...c?{onDragOver:c.onDragOver,onDragLeave:c.onDragLeave,onDrop:c.onDrop}:{},children:[s?(0,N.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:c?.onDragStart,onDragEnd:c?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,N.jsx)(e,{name:`grip`,size:12})}):(0,N.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),i?(0,N.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,N.jsx)(`input`,{type:`checkbox`,checked:a,onChange:()=>o?.(t.id),"aria-label":`选择任务 #${t.id}`})}):null,(0,N.jsxs)(`div`,{className:`rp-proj-task`+(h?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:[(0,N.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),n?(0,N.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||n}`,children:n}):null,(0,N.jsx)(`span`,{className:`rp-proj-task-tx`,children:_(t)}),t.timegoal&&(0,N.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,N.jsx)(e,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,N.jsxs)(`span`,{className:`rp-tgate`,title:p.length?`闸门:未完成前挡住 ${p.length} 个后续任务(#${p.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,p.length?`×${p.length}`:``]}),C&&(0,N.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),d&&(0,N.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${t.createdAt||`—`}${t.consumedAt?` · 领取 ${t.consumedAt}`:``}`,children:[z(t.createdAt),t.consumedAt?` → ${z(t.consumedAt)}`:``]}),(0,N.jsx)(f,{t}),g?(0,N.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:g}):null]}),v?(0,N.jsxs)(`div`,{className:`rp-proj-task-ctx`,children:[(0,N.jsxs)(`div`,{className:`ctx-head`,children:[(0,N.jsx)(`span`,{className:`ctx-head-label`,children:`匹配上下文`}),(0,N.jsxs)(`button`,{type:`button`,className:`ctx-expand`+(b?` is-open`:``),title:b?`收起,只看命中附近`:`展开这条任务的完整原文`,onClick:e=>{e.stopPropagation(),x(e=>!e)},onKeyDown:e=>e.stopPropagation(),children:[(0,N.jsx)(e,{name:`chevron`,size:11}),(0,N.jsx)(`span`,{children:b?`收起`:`展开全文`})]})]}),(0,N.jsx)(`div`,{className:`ctx-lines`,role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:(()=>{let e=b&&m(t,y,2**53-1)||v;return e.lines.map((t,n)=>(0,N.jsxs)(`div`,{className:`ctx-line`+(n===e.hitIndex?` hit`:``),children:[(0,N.jsx)(`span`,{className:`ctx-no`,children:e.hitLineNo-e.hitIndex+n}),(0,N.jsx)(`span`,{className:`ctx-tx`,children:t||`\xA0`})]},n))})()})]}):null]})}var le=20;function B({kind:t,name:n,title:r,rows:s,emptyText:c,intro:l=null,extraCounts:u=[],actionExtra:d=null,toolActs:f={},onNew:h,newDisabled:g=!1,tplMenuItems:_,onOpenRow:v,onMoveRow:y,onImportFile:b,onTogglePlan:x,onOpenDag:S,onToggleGate:C,onFeedback:w,onDeleteRow:T,onDeleteRows:E,onCancelRows:D,onCompleteRows:O,extra:ee=null}){let te=i(),k=(0,M.useRef)(null),[A,j]=(0,M.useState)(null),[P,re]=(0,M.useState)(``),F=!!String(P).trim(),I=(0,M.useMemo)(()=>F?s.filter(e=>p({id:e.task.id,text:e.task.text},P)):s,[s,P,F]),L=(0,M.useMemo)(()=>I.filter(e=>e.task.status===`pending`&&!e.task.migratedTo).length,[I]),R=ie(I,le);(0,M.useEffect)(()=>{R.setPage(0)},[P]);let[z,B]=(0,M.useState)(()=>new Set),V=R.items,H=V.map(e=>e.key),U=H.length>0&&H.every(e=>z.has(e));(0,M.useEffect)(()=>{B(new Set)},[R.page]);let W=s.filter(e=>z.has(e.key)),G=W.filter(e=>(e.task.status===`pending`||e.task.status===`claimed`)&&!e.task.migratedTo&&!e.task.deletedAt),K=W.filter(e=>e.task.status===`pending`&&!e.task.migratedTo&&!e.task.deletedAt),q=G.filter(e=>e.task.status===`claimed`).length,J=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ue=()=>{B(e=>{let t=new Set(e);return U?H.forEach(e=>t.delete(e)):H.forEach(e=>t.add(e)),t})},Y=async e=>{W.length&&e&&await e(W)&&B(new Set)},X=W.filter(e=>e.task.status===`pending`),Z=W.filter(e=>e.task.status===`plan`),de=X.length?X:Z,fe=X.length?`plan`:`pending`,pe=W.length?fe===`plan`?`转草稿 (${X.length})`:`转回待领取 (${Z.length})`:`草稿态`,Q=(0,M.useRef)(null),[me,he]=(0,M.useState)(null),[ge,$]=(0,M.useState)(null),_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{Q.current=t.key,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.task.id),he(t.key)},ye=(e,t)=>{Q.current&&t.movable&&t.key!==Q.current&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,$({key:t.key,zone:_e(e,e.currentTarget)}))},be=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||$(null)},xe=(e,t)=>{e.preventDefault();let n=_e(e,e.currentTarget),r=Q.current;if(Q.current=null,he(null),$(null),!r||!t.movable||t.key===r)return;let i=s.find(e=>e.key===r);i&&y&&y(i,t,n)},Se=()=>{Q.current=null,he(null),$(null)},Ce=e=>{let t=e.task;return[(t.status===`pending`||t.status===`plan`)&&x?{label:t.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>x([e],t.status===`pending`?`plan`:`pending`)}:null,e.movable&&S?{label:`编排依赖…`,onPick:()=>S(e)}:null,e.movable&&C?{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>C(e)}:null,w&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)?{label:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>w(e)}:null,T?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>T(e)}:null]},we=W.length>0?(0,N.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,N.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,W.length,` 条`]}),O&&(0,N.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!G.length,title:G.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${q?`;其中 ${q} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>void Y(O),children:[`标为完成选中`,G.length?` (${G.length})`:``]}),D&&(0,N.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>void Y(D),children:[`取消选中`,K.length?` (${K.length})`:``]}),E&&(0,N.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>void Y(E),children:[`删除选中 (`,W.length,`)`]}),(0,N.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>B(new Set),children:`清空`})]}):null,Te=(0,N.jsx)(oe,{title:r,pendingCount:L,headerExtra:(0,N.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,N.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:P,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>re(e.target.value)}),V.length?(0,N.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:U,onChange:ue,"aria-label":`全选当前页任务`}),`全选本页`]}):null]}),emptyText:F?`没有匹配「${P.trim()}」的任务(标题与正文都搜过了)`:c,children:V.map(e=>{let t=e.movable?{onDragStart:t=>ve(t,e),onDragOver:t=>ye(t,e),onDragLeave:be,onDrop:t=>xe(t,e),onDragEnd:Se}:null;return(0,N.jsx)(ce,{t:e.task,projectTag:e.projectTag,projectTitle:e.projectTitle,searchCtx:F?m(e.task,P):null,searchQuery:F?String(P||``):``,selectable:!0,picked:z.has(e.key),onTogglePick:()=>J(e.key),draggable:!!e.movable,dragHandlers:t,dragVisual:{dragging:me===e.key,drop:ge&&ge.key===e.key?ge.zone:null},showTimes:e.showTimes,downs:e.downs,onOpen:()=>v(e),ops:(0,N.jsx)(o,{items:Ce(e)})},e.key)})}),Ee=R.total>0?(0,N.jsx)(`div`,{className:`mdw-land-pager`,children:(0,N.jsx)(ae,{page:R.page,pageCount:R.pageCount,total:R.total,onPage:R.setPage,unit:`个任务`})}):null,De=e=>{j({x:e.clientX,y:e.clientY})},Oe=()=>(0,N.jsx)(`span`,{className:`rp-newtask`,children:(0,N.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,disabled:g,onClick:()=>h(),children:[`+ 新建页`,(0,N.jsx)(`span`,{role:`button`,tabIndex:g?void 0:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),De(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),De(e))},children:(0,N.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(se,{name:n,counts:[`${F?`命中 `:``}${R.total} 个任务`,...L>0?[`待领取 ${L}`]:[],...u],intro:l,batch:we,list:Te,footer:Ee,actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ne,{kind:t,labels:{more:`更多`,...f.labels,plan:pe},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`,...f.titles},disabled:f.disabled,renderers:{new:Oe,...f.renderers},actions:{...f.actions,new:()=>h(),import:()=>k.current?.click(),plan:()=>{if(!de.length){te(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}x?.(de,fe)}}}),d]})}),A&&(0,N.jsx)(a,{x:A.x,y:A.y,items:_,onClose:()=>j(null)}),(0,N.jsx)(`input`,{ref:k,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&b&&b(t)}}),ee]})}function V(e){return((e.text||``).split(`
|
|
1
|
+
import{a as e,d as t,f as n,h as r,l as i,n as a,r as o,t as s}from"./popup-DLfU1TXG.js";import{O as c}from"./repo-form-modal-DpwLdBYp.js";import{n as l}from"./app-context-DPFYOrgE.js";import{r as u}from"./md-parse-BjzYV8n7.js";import{t as d}from"./button-VP4pjVsx.js";import{d as f,g as p,h as m}from"./md-history-B7TamGno.js";import{S as h,h as g,w as _,x as v}from"./index-Di6ErKBG.js";import{t as y}from"./graph-BTEfvFz6.js";import{c as b,d as x,f as S,g as C,l as w,m as T,n as E,p as D,r as O,s as ee,t as te,u as k}from"./reopen-text-D0eQ2XAC.js";import{n as A}from"./template-preview-EM3OQ1Rc.js";import{a as j}from"./manage-session-CuaL7QqQ.js";import{t as ne}from"./bar-I4qGaKTO.js";var M=r(n(),1),N=t(),P=10;function re({repo:e,onClose:t,onSaved:n}){let r=l(),a=i(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,f]=(0,M.useState)(!!(o&&o.enabled)),[p,m]=(0,M.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(P)),[h,g]=(0,M.useState)(!1),_=e=>{let t=String(e??``).trim();if(t===``)return P;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):P},v=async t=>{let i=String(e.id??``);g(!0);try{let o=t&&t.enabled!==void 0?t.enabled:u;await c(i,{"get-loop":o?`on`:`off`,...o?{"get-loop-minutes":_(p)}:{}});let s=_(p);a(o?`已保存「${e.name}」的持续 get 设置(${s>0?`${s} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){a(String(e.message||e))}finally{g(!1)}},y=async e=>{f(e),await v({enabled:e})};return(0,N.jsx)(s,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,N.jsxs)(`div`,{className:`rp-gl`,children:[(0,N.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,N.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,N.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,N.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,N.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>y(!u),disabled:h,children:[(0,N.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,N.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,N.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,N.jsx)(`span`,{children:`阻塞窗口`}),(0,N.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,N.jsx)(`input`,{className:`rp-gl-min`,value:p,onChange:e=>m(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,N.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,N.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,N.jsx)(`span`,{className:`spacer`}),(0,N.jsx)(d,{variant:`primary`,disabled:h,onClick:()=>v(),children:`保存持续 get 设置`})]})]})]})})}var F=s,I=(e,t,n)=>y(e=>n.get(Number(e))||[],e,t);function L({task:e,tasks:t,onClose:n,onSave:r}){let i=e=>Number(e.id),a=i(e),o=t.filter(e=>i(e)!==a),[s,c]=(0,M.useState)(!!e.blocksFollowing),[l,d]=(0,M.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,p]=(0,M.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,M.useState)(!1),g=t.findIndex(e=>i(e)===a),_=t.slice(g+1).map(i),v=new Map(t.map(e=>[i(e),i(e)===a?[...l]:(e.blockBy||[]).map(Number)])),y=e=>s||!l.has(i(e))&&I(i(e),a,v),b=e=>!f.has(i(e))&&I(a,i(e),v),x=e=>t=>e(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}),S=()=>c(e=>(e||d(new Set),!e)),C=async()=>{h(!0);try{let e=[{id:a,gate:s,blockBy:[...l]}];if(!s)for(let t of o){let n=i(t),r=f.has(n),o=(t.blockBy||[]).map(Number);r!==o.includes(a)&&e.push({id:n,blockBy:r?[...o,a]:o.filter(e=>e!==a)})}await r(e),n()}catch{}finally{h(!1)}},w=(e,t,n,r)=>{let a=u(e.text)||`#${i(e)}`;return(0,N.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,N.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,N.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,N.jsx)(F,{title:`编排 · #${a} ${u(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,N.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,N.jsxs)(`div`,{className:`mdw-dag`,children:[(0,N.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,N.jsx)(`b`,{children:`闸门`}),(0,N.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,N.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,N.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,N.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,N.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,l.has(i(e)),y(e),x(d))):(0,N.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,N.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,N.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,N.jsx)(`div`,{className:`mdw-dag-list`+(s?` dim`:``),children:o.length?o.map(e=>w(e,f.has(i(e)),s||b(e),x(p))):(0,N.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,N.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function R(e,t,n){if(!A(e?.body).length||!e?.id)return!1;let r=j({...t,templateId:String(e.id)});return n.onNavigate?.(`#/templates/fill/${r}`),!0}function ie(e,t){let n=Array.isArray(e)?e:[],[r,i]=(0,M.useState)(0),a=Math.max(1,Number(t)||1),o=Math.max(1,Math.ceil(n.length/a)),s=Math.min(Math.max(0,r),o-1),c=s*a;return{page:s,pageCount:o,total:n.length,items:n.slice(c,c+a),setPage:i}}function ae({page:e=0,pageCount:t=1,total:n=0,onPage:r,unit:i=`条`}){let a=e=>r&&r(Math.max(0,Math.min(e,t-1)));return t<=1?(0,N.jsxs)(`span`,{className:`pager-n`,children:[`共 `,n,` `,i]}):(0,N.jsxs)(`span`,{className:`pager`,children:[(0,N.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e<=0,onClick:()=>a(e-1),"aria-label":`上一页`,title:`上一页`,children:`‹`}),(0,N.jsxs)(`span`,{className:`pager-n`,children:[`第 `,e+1,`/`,t,` 页 · 共 `,n,` `,i]}),(0,N.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e>=t-1,onClick:()=>a(e+1),"aria-label":`下一页`,title:`下一页`,children:`›`})]})}function oe({icon:t=`list`,title:n,pendingCount:r=0,headerExtra:i=null,children:a=null,emptyText:o=``}){let s=Array.isArray(a)?a.length>0:!!a;return(0,N.jsxs)(`div`,{className:`rp-tasks`,children:[(0,N.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,N.jsx)(e,{name:t,size:13}),` `,n,r>0&&(0,N.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!s&&o?(0,N.jsx)(`div`,{className:`rp-proj-none muted`,children:o}):null]})}function se({name:t,counts:n=[],icon:r=`folder`,actions:i=null,intro:a=null,batch:o=null,list:s=null,footer:c=null,extra:l=null}){return(0,N.jsxs)(`div`,{className:`rp-page`,children:[(0,N.jsxs)(`div`,{className:`rp-group-head`,children:[(0,N.jsxs)(`h2`,{children:[(0,N.jsx)(e,{name:r,size:15}),` `,t,n.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,N.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,N.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,o,s,c,l]})}function z(e){let t=String(e||``).trim();if(!t)return`—`;let n=t.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/),r=n?.[1],i=n?.[2];return r&&i?`${r.slice(5)} ${i}`:t.slice(0,16)}function ce({t,projectTag:n=``,projectTitle:r=``,selectable:i=!1,picked:a=!1,onTogglePick:o,draggable:s=!1,dragHandlers:c=null,dragVisual:l,onOpen:u,showTimes:d=!1,downs:p=[],history:h=!1,ops:g=null,searchCtx:v=null,searchQuery:y=``}){let[b,x]=(0,M.useState)(!1),S=`rp-proj-row`+(l?.dragging?` dragging`:``)+(l?.drop?` drop-`+l.drop:``),C=t.status===`pending`&&t.ready===!1;return(0,N.jsxs)(`div`,{className:S,...c?{onDragOver:c.onDragOver,onDragLeave:c.onDragLeave,onDrop:c.onDrop}:{},children:[s?(0,N.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:c?.onDragStart,onDragEnd:c?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,N.jsx)(e,{name:`grip`,size:12})}):(0,N.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),i?(0,N.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,N.jsx)(`input`,{type:`checkbox`,checked:a,onChange:()=>o?.(t.id),"aria-label":`选择任务 #${t.id}`})}):null,(0,N.jsxs)(`div`,{className:`rp-proj-task`+(h?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:[(0,N.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),n?(0,N.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||n}`,children:n}):null,(0,N.jsx)(`span`,{className:`rp-proj-task-tx`,children:_(t)}),t.timegoal&&(0,N.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,N.jsx)(e,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,N.jsxs)(`span`,{className:`rp-tgate`,title:p.length?`闸门:未完成前挡住 ${p.length} 个后续任务(#${p.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,p.length?`×${p.length}`:``]}),C&&(0,N.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),d&&(0,N.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${t.createdAt||`—`}${t.consumedAt?` · 领取 ${t.consumedAt}`:``}`,children:[z(t.createdAt),t.consumedAt?` → ${z(t.consumedAt)}`:``]}),(0,N.jsx)(f,{t}),g?(0,N.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:g}):null]}),v?(0,N.jsxs)(`div`,{className:`rp-proj-task-ctx`,children:[(0,N.jsxs)(`div`,{className:`ctx-head`,children:[(0,N.jsx)(`span`,{className:`ctx-head-label`,children:`匹配上下文`}),(0,N.jsxs)(`button`,{type:`button`,className:`ctx-expand`+(b?` is-open`:``),title:b?`收起,只看命中附近`:`展开这条任务的完整原文`,onClick:e=>{e.stopPropagation(),x(e=>!e)},onKeyDown:e=>e.stopPropagation(),children:[(0,N.jsx)(e,{name:`chevron`,size:11}),(0,N.jsx)(`span`,{children:b?`收起`:`展开全文`})]})]}),(0,N.jsx)(`div`,{className:`ctx-lines`,role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:(()=>{let e=b&&m(t,y,2**53-1)||v;return e.lines.map((t,n)=>(0,N.jsxs)(`div`,{className:`ctx-line`+(n===e.hitIndex?` hit`:``),children:[(0,N.jsx)(`span`,{className:`ctx-no`,children:e.hitLineNo-e.hitIndex+n}),(0,N.jsx)(`span`,{className:`ctx-tx`,children:t||`\xA0`})]},n))})()})]}):null]})}var le=20;function B({kind:t,name:n,title:r,rows:s,emptyText:c,intro:l=null,extraCounts:u=[],actionExtra:d=null,toolActs:f={},onNew:h,newDisabled:g=!1,tplMenuItems:_,onOpenRow:v,onMoveRow:y,onImportFile:b,onTogglePlan:x,onOpenDag:S,onToggleGate:C,onFeedback:w,onDeleteRow:T,onDeleteRows:E,onCancelRows:D,onCompleteRows:O,extra:ee=null}){let te=i(),k=(0,M.useRef)(null),[A,j]=(0,M.useState)(null),[P,re]=(0,M.useState)(``),F=!!String(P).trim(),I=(0,M.useMemo)(()=>F?s.filter(e=>p({id:e.task.id,text:e.task.text},P)):s,[s,P,F]),L=(0,M.useMemo)(()=>I.filter(e=>e.task.status===`pending`&&!e.task.migratedTo).length,[I]),R=ie(I,le);(0,M.useEffect)(()=>{R.setPage(0)},[P]);let[z,B]=(0,M.useState)(()=>new Set),V=R.items,H=V.map(e=>e.key),U=H.length>0&&H.every(e=>z.has(e));(0,M.useEffect)(()=>{B(new Set)},[R.page]);let W=s.filter(e=>z.has(e.key)),G=W.filter(e=>(e.task.status===`pending`||e.task.status===`claimed`)&&!e.task.migratedTo&&!e.task.deletedAt),K=W.filter(e=>e.task.status===`pending`&&!e.task.migratedTo&&!e.task.deletedAt),q=G.filter(e=>e.task.status===`claimed`).length,J=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ue=()=>{B(e=>{let t=new Set(e);return U?H.forEach(e=>t.delete(e)):H.forEach(e=>t.add(e)),t})},Y=async e=>{W.length&&e&&await e(W)&&B(new Set)},X=W.filter(e=>e.task.status===`pending`),Z=W.filter(e=>e.task.status===`plan`),de=X.length?X:Z,fe=X.length?`plan`:`pending`,pe=W.length?fe===`plan`?`转草稿 (${X.length})`:`转回待领取 (${Z.length})`:`草稿态`,Q=(0,M.useRef)(null),[me,he]=(0,M.useState)(null),[ge,$]=(0,M.useState)(null),_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{Q.current=t.key,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.task.id),he(t.key)},ye=(e,t)=>{Q.current&&t.movable&&t.key!==Q.current&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,$({key:t.key,zone:_e(e,e.currentTarget)}))},be=e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||$(null)},xe=(e,t)=>{e.preventDefault();let n=_e(e,e.currentTarget),r=Q.current;if(Q.current=null,he(null),$(null),!r||!t.movable||t.key===r)return;let i=s.find(e=>e.key===r);i&&y&&y(i,t,n)},Se=()=>{Q.current=null,he(null),$(null)},Ce=e=>{let t=e.task;return[(t.status===`pending`||t.status===`plan`)&&x?{label:t.status===`pending`?`转为草稿(不进队列)`:`转回待领取`,onPick:()=>x([e],t.status===`pending`?`plan`:`pending`)}:null,e.movable&&S?{label:`编排依赖…`,onPick:()=>S(e)}:null,e.movable&&C?{label:t.blocksFollowing?`取消闸门(不再挡后续)`:`设为闸门(挡住后续)`,onPick:()=>C(e)}:null,w&&t.status!==`cancelled`&&!t.childCount&&(t.status===`claimed`||t.status===`done`||t.completedAt)?{label:t.completedAt?`反馈:新开一条任务(原任务不动)`:`反馈修改:回写本任务并记入任务链`,onPick:()=>w(e)}:null,T?{label:`删除此任务(软删除,CLI 可恢复)`,danger:!0,onPick:()=>T(e)}:null]},we=W.length>0?(0,N.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,N.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,W.length,` 条`]}),O&&(0,N.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!G.length,title:G.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${q?`;其中 ${q} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>void Y(O),children:[`标为完成选中`,G.length?` (${G.length})`:``]}),D&&(0,N.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>void Y(D),children:[`取消选中`,K.length?` (${K.length})`:``]}),E&&(0,N.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>void Y(E),children:[`删除选中 (`,W.length,`)`]}),(0,N.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>B(new Set),children:`清空`})]}):null,Te=(0,N.jsx)(oe,{title:r,pendingCount:L,headerExtra:(0,N.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,N.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:P,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>re(e.target.value)}),V.length?(0,N.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:U,onChange:ue,"aria-label":`全选当前页任务`}),`全选本页`]}):null]}),emptyText:F?`没有匹配「${P.trim()}」的任务(标题与正文都搜过了)`:c,children:V.map(e=>{let t=e.movable?{onDragStart:t=>ve(t,e),onDragOver:t=>ye(t,e),onDragLeave:be,onDrop:t=>xe(t,e),onDragEnd:Se}:null;return(0,N.jsx)(ce,{t:e.task,projectTag:e.projectTag,projectTitle:e.projectTitle,searchCtx:F?m(e.task,P):null,searchQuery:F?String(P||``):``,selectable:!0,picked:z.has(e.key),onTogglePick:()=>J(e.key),draggable:!!e.movable,dragHandlers:t,dragVisual:{dragging:me===e.key,drop:ge&&ge.key===e.key?ge.zone:null},showTimes:e.showTimes,downs:e.downs,onOpen:()=>v(e),ops:(0,N.jsx)(o,{items:Ce(e)})},e.key)})}),Ee=R.total>0?(0,N.jsx)(`div`,{className:`mdw-land-pager`,children:(0,N.jsx)(ae,{page:R.page,pageCount:R.pageCount,total:R.total,onPage:R.setPage,unit:`个任务`})}):null,De=e=>{j({x:e.clientX,y:e.clientY})},Oe=()=>(0,N.jsx)(`span`,{className:`rp-newtask`,children:(0,N.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,disabled:g,onClick:()=>h(),children:[`+ 新建页`,(0,N.jsx)(`span`,{role:`button`,tabIndex:g?void 0:0,"aria-label":`选择模板新建一页`,"aria-haspopup":`menu`,className:`rp-newtask-caret`,title:`选择模板新建一页`,onClick:e=>{e.stopPropagation(),De(e)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),De(e))},children:(0,N.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})});return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(se,{name:n,counts:[`${F?`命中 `:``}${R.total} 个任务`,...L>0?[`待领取 ${L}`]:[],...u],intro:l,batch:we,list:Te,footer:Ee,actions:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ne,{kind:t,labels:{more:`更多`,...f.labels,plan:pe},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`,...f.titles},disabled:f.disabled,renderers:{new:Oe,...f.renderers},actions:{...f.actions,new:()=>h(),import:()=>k.current?.click(),plan:()=>{if(!de.length){te(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}x?.(de,fe)}}}),d]})}),A&&(0,N.jsx)(a,{x:A.x,y:A.y,items:_,onClose:()=>j(null)}),(0,N.jsx)(`input`,{ref:k,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&b&&b(t)}}),ee]})}function V(e){return((e.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${e.id}`).replace(/^#\s*/,``)}function H(e,t){return e.key&&!e.cwd?`key=${encodeURIComponent(e.key)}&id=${Number(t)}`:`cwd=${encodeURIComponent(e.cwd||``)}&id=${Number(t)}`}function U(e){return{cwd:e.cwd}}function W(e,t,n,r){r&&v(g(h(t||e.docKey),String(n)),{body:r})}async function G(e,t){try{return await t()}catch(t){return e.toast(String(t?.message||t)),!1}}async function K(e,t,n){let{dialog:r,toast:i}=e,a=V(n),o=!!n.completedAt,s=await r({title:o?`反馈 · #${n.id}`:`反馈修改 · #${n.id}`,input:!0,placeholder:o?`写下反馈(将新开一条任务,原任务不动)`:`写下要改的地方(留空 = 只重开,不改正文)`});if(s==null)return;let c=String(s).trim();await G(e,async()=>{let r=await k(H(t,n.id)),s=String(r?.text??``).trim()||String(n.text||``).trim(),l=o&&(r?.roundSummary||n.roundSummary)||``;if(!c&&!o&&!s){i(`拿不到任务当前正文,已取消(防止丢内容)`);return}if(o){let r=c?te({base:s,feedback:c,ackSummary:l,feedbackHeading:E,bold:!0}):``;if(!r){i(`写一下反馈`);return}let o=await ee({...U(t),text:r,forkOf:String(n.id),forkKind:`reopen`}),u=String(o?.task?.id??o?.id??``);W(e,o?.key,u,r),i(`已反馈「${a}」→ 新任务 #${u||`?`}`),e.refresh?.();return}let u=await S({...t,id:n.id,kind:`reopen`,...c?{feedback:c,feedbackHeading:O,feedbackBold:!1}:{}}),d=String(u?.task?.id??n.id);W(e,u?.key,d,String(u?.task?.text??``)),i(`已回写「${a}」#${d}`+(u?.moved&&u.name?`;归属迁到「${u.name}」`:``)),e.refresh?.()})}async function q(e,t,n){let{dialog:r,toast:i}=e;await r({title:`删除任务「${V(n)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&await G(e,async()=>(await T({...t,id:n.id}),i(`已删除「${V(n)}」`),e.onDeleted?.(n),e.refresh?.(),!0))}var J=e=>e.reduce((e,t)=>e+t.ids.length,0);async function ue(e,t){let n=J(t);if(!n||!await e.dialog({title:`删除选中的 ${n} 条任务`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`}))return!1;let r=0;for(let n of t){let t=await G(e,()=>D({...n.scope,ids:n.ids}));if(t===!1)return!1;r+=t.count??n.ids.length}return e.toast(`已删除 ${r} 条任务`),e.refresh?.(),!0}async function Y(e,t){let n=J(t);if(!n||!await e.dialog({title:`取消选中的 ${n} 条待领取任务`,message:`只处理待领取任务;已领取/已完成/已取消会跳过。取消为终态,原文留档。`,okText:`取消任务`}))return!1;let r=0,i=0;for(let n of t){let t=await G(e,()=>b({...n.scope,ids:n.ids}));if(t===!1)return!1;let a=t;r+=a.count??0,i+=a.skipped?.length||0}return e.toast(`已取消 ${r} 条任务${i?`,跳过 ${i} 条`:``}`),e.refresh?.(),!0}async function X(e,t){let n=J(t);if(!n||!await e.dialog({title:`把选中的 ${n} 条任务标为完成`,message:`待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。`,okText:`标为完成`}))return!1;let r=0,i=0,a=0;for(let n of t){let t=await G(e,()=>w({...n.scope,ids:n.ids,status:`done`}));if(t===!1)return!1;let o=t;r+=o.count??0,i+=o.skipped?.length||0,a+=o.claimedClosed?.length||0}return e.toast(`已标为完成 ${r} 条任务${a?`(含 ${a} 条已领取)`:``}${i?`,跳过 ${i} 条`:``}`),e.refresh?.(),!0}async function Z(e,t,n){let r=!n.blocksFollowing;await G(e,()=>x({...t,id:n.id,gate:r}))&&(e.toast(r?`#${n.id} 已设为闸门——挡住所有后续待领取任务`:`#${n.id} 闸门已取消`),e.refresh?.())}async function de(e,t,n){let r=t.reduce((e,t)=>e+t.ids.length,0);r&&await G(e,async()=>{for(let e of t)for(let t of e.ids)await C({...e.scope,id:Number(t),to:n});return e.toast(n===`plan`?`已把 ${r} 条任务转为草稿(不进队列)`:`已把 ${r} 条草稿转回待领取`),e.refresh?.(),!0})}async function fe(e,t,n){try{for(let e of n)await x({...t,...e});e.toast(`编排已保存`),e.refresh?.()}catch(t){throw e.toast(String(t?.message||t)),t}}export{K as a,fe as c,L as d,re as f,q as i,B as l,X as n,de as o,ue as r,Z as s,Y as t,R as u};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-DLfU1TXG.js";import{D as o}from"./tool-bar-NHeX0Kmo.js";import{n as s}from"./app-context-DPFYOrgE.js";import{a as c,r as l}from"./md-parse-BjzYV8n7.js";import{t as u}from"./button-VP4pjVsx.js";import{a as d,i as f,m as p,n as m,r as h,t as g}from"./md-history-
|
|
3
|
-
`).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``)).filter(Boolean).slice(0,2).join(` · `)}function F(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[d,f]=(0,M.useState)(null),[m,h]=(0,M.useState)(!1),[g,v]=(0,M.useState)(``),y=e=>t.onNavigate?.(e);if(!n)return(0,N.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,N.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,N.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,N.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let b=n.templates||[],x=p(b,g,e=>[e.name,P(e.body)]),S=async(e,t)=>{if(!m){h(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{h(!1)}}},C=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await S(()=>n.remove(e.id),`已删除「${e.name}」`)},w=(t,n,r,i={})=>(0,N.jsxs)(`button`,{type:`button`,className:`tpl-act`+(i.on?` is-on`:``),title:n,disabled:m||i.disabled,onClick:r,children:[(0,N.jsx)(e,{name:t,size:16}),(0,N.jsx)(`span`,{children:n})]});return(0,N.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,N.jsxs)(`div`,{className:`page-head`,children:[(0,N.jsxs)(`div`,{className:`title-block`,children:[(0,N.jsxs)(`h2`,{children:[(0,N.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,N.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,N.jsx)(`div`,{className:`acts`,children:(0,N.jsxs)(u,{variant:`primary`,small:!0,disabled:m,onClick:()=>y(`#/templates/new`),children:[(0,N.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),(0,N.jsx)(`div`,{className:`tpl-search`,children:(0,N.jsx)(_,{value:g,onChange:v,placeholder:`搜索名称 / 正文…`,title:`过滤任务模板`,count:x.length,className:`wide`})}),!b.length&&(0,N.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),(0,N.jsxs)(`div`,{className:`tpl-list`,children:[x.map(e=>{let t=e.id===n.defaultId,r=d===e.id;return(0,N.jsxs)(`div`,{className:`tpl-card`+(t?` is-default`:``),children:[(0,N.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,N.jsx)(`span`,{className:`tpl-card-name`,children:e.name}),t&&(0,N.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),e.builtin&&(0,N.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,N.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,N.jsxs)(`div`,{className:`tpl-card-acts`,children:[w(`monitor`,r?`收起`:`预览`,()=>f(r?null:e.id),{on:r}),!e.builtin&&w(`edit`,`编辑`,()=>y(`#/templates/edit/${encodeURIComponent(e.id)}`)),!t&&w(`star`,`设为默认`,()=>S(()=>n.setDefault(e.id),`默认模板已设为「${e.name}」`)),!e.builtin&&w(`trash`,`删除`,()=>C(e))]})]}),(0,N.jsx)(`div`,{className:`tpl-card-sum`,children:P(e.body)||`(空模板)`}),r&&(0,N.jsx)(`div`,{className:`tpl-preview`,children:(0,N.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:c(e.body)}})})]},e.id)}),b.length&&!x.length?(0,N.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function I({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,M.useMemo)(()=>A(t?.id),[t?.id]),c=x(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[l,d]=(0,M.useState)(``),[f,m]=(0,M.useState)(null),[h,g]=(0,M.useState)(null),[v,b]=(0,M.useState)(!1),S=c.templates||[],w=p(S,l,e=>[e.name,e.body]),T=async(e,t)=>{if(!v){b(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{b(!1)}}},E=async(e,t)=>{if(e===t)return;let n=S.map(e=>e.id),r=n.indexOf(e),a=n.indexOf(t);r<0||a<0||(n.splice(r,1),n.splice(a,0,e),await T(()=>i.reorder(n)))},D=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];C(async()=>{let{openTemplateEditor:e}=await import(`./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Di6ErKBG.js","assets/popup-DLfU1TXG.js","assets/popup-DzBICcYS.css","assets/tool-bar-NHeX0Kmo.js","assets/tool-bar-CLIs9Dr0.css","assets/repo-form-modal-DpwLdBYp.js","assets/button-VP4pjVsx.js","assets/button-DA4lNJeC.css","assets/doc-zDLeR8PE.js","assets/app-context-DPFYOrgE.js","assets/md-parse-BjzYV8n7.js","assets/md-history-B7TamGno.js","assets/use-rail-drag-4iK6t5ab.js","assets/route-crumb-DS76cmRK.js","assets/board-view-jt8QixVg.js","assets/doc-Ka-2V5jn.css","assets/index-DXJxcKIU.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,d as t,f as n,h as r,i,l as a}from"./popup-DLfU1TXG.js";import{D as o}from"./tool-bar-NHeX0Kmo.js";import{n as s}from"./app-context-DPFYOrgE.js";import{a as c,r as l}from"./md-parse-BjzYV8n7.js";import{t as u}from"./button-VP4pjVsx.js";import{a as d,i as f,m as p,n as m,r as h,t as g}from"./md-history-B7TamGno.js";import{i as _,n as v,t as y}from"./route-crumb-DS76cmRK.js";import{S as b,d as x,h as S,m as C,v as w,x as T}from"./index-Di6ErKBG.js";import{n as E,t as D}from"./template-preview-EM3OQ1Rc.js";import{i as O,r as k,t as A}from"./manage-session-CuaL7QqQ.js";import{t as j}from"./task-intent-CX5DZccN.js";var M=r(n(),1),N=t();function P(e){return String(e||``).split(`
|
|
3
|
+
`).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``)).filter(Boolean).slice(0,2).join(` · `)}function F(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[d,f]=(0,M.useState)(null),[m,h]=(0,M.useState)(!1),[g,v]=(0,M.useState)(``),y=e=>t.onNavigate?.(e);if(!n)return(0,N.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,N.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,N.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,N.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let b=n.templates||[],x=p(b,g,e=>[e.name,P(e.body)]),S=async(e,t)=>{if(!m){h(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{h(!1)}}},C=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await S(()=>n.remove(e.id),`已删除「${e.name}」`)},w=(t,n,r,i={})=>(0,N.jsxs)(`button`,{type:`button`,className:`tpl-act`+(i.on?` is-on`:``),title:n,disabled:m||i.disabled,onClick:r,children:[(0,N.jsx)(e,{name:t,size:16}),(0,N.jsx)(`span`,{children:n})]});return(0,N.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,N.jsxs)(`div`,{className:`page-head`,children:[(0,N.jsxs)(`div`,{className:`title-block`,children:[(0,N.jsxs)(`h2`,{children:[(0,N.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,N.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,N.jsx)(`div`,{className:`acts`,children:(0,N.jsxs)(u,{variant:`primary`,small:!0,disabled:m,onClick:()=>y(`#/templates/new`),children:[(0,N.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),(0,N.jsx)(`div`,{className:`tpl-search`,children:(0,N.jsx)(_,{value:g,onChange:v,placeholder:`搜索名称 / 正文…`,title:`过滤任务模板`,count:x.length,className:`wide`})}),!b.length&&(0,N.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),(0,N.jsxs)(`div`,{className:`tpl-list`,children:[x.map(e=>{let t=e.id===n.defaultId,r=d===e.id;return(0,N.jsxs)(`div`,{className:`tpl-card`+(t?` is-default`:``),children:[(0,N.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,N.jsx)(`span`,{className:`tpl-card-name`,children:e.name}),t&&(0,N.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),e.builtin&&(0,N.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,N.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,N.jsxs)(`div`,{className:`tpl-card-acts`,children:[w(`monitor`,r?`收起`:`预览`,()=>f(r?null:e.id),{on:r}),!e.builtin&&w(`edit`,`编辑`,()=>y(`#/templates/edit/${encodeURIComponent(e.id)}`)),!t&&w(`star`,`设为默认`,()=>S(()=>n.setDefault(e.id),`默认模板已设为「${e.name}」`)),!e.builtin&&w(`trash`,`删除`,()=>C(e))]})]}),(0,N.jsx)(`div`,{className:`tpl-card-sum`,children:P(e.body)||`(空模板)`}),r&&(0,N.jsx)(`div`,{className:`tpl-preview`,children:(0,N.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:c(e.body)}})})]},e.id)}),b.length&&!x.length?(0,N.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function I({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,M.useMemo)(()=>A(t?.id),[t?.id]),c=x(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[l,d]=(0,M.useState)(``),[f,m]=(0,M.useState)(null),[h,g]=(0,M.useState)(null),[v,b]=(0,M.useState)(!1),S=c.templates||[],w=p(S,l,e=>[e.name,e.body]),T=async(e,t)=>{if(!v){b(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{b(!1)}}},E=async(e,t)=>{if(e===t)return;let n=S.map(e=>e.id),r=n.indexOf(e),a=n.indexOf(t);r<0||a<0||(n.splice(r,1),n.splice(a,0,e),await T(()=>i.reorder(n)))},D=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];C(async()=>{let{openTemplateEditor:e}=await import(`./index-Di6ErKBG.js`).then(e=>e.p);return{openTemplateEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(({openTemplateEditor:t})=>{n.model&&t(n.model,{mode:`new`,scope:e,topic:o?.topic||``,name:``})})},O=o?.label||o?.topic||o?.group||o?.repo||`本主题`;return(0,N.jsxs)(`div`,{className:`rp-page tpl-mng-page`,children:[(0,N.jsx)(y,{}),(0,N.jsxs)(`div`,{className:`page-head`,children:[(0,N.jsxs)(`div`,{className:`title-block`,children:[(0,N.jsxs)(`h2`,{children:[(0,N.jsx)(e,{name:`gear`,size:16}),` 管理模板 · `,O]}),(0,N.jsx)(`p`,{className:`muted tpl-head-note`,children:`这里管理本主题的模板:拖动左侧把手调整顺序,编辑正文 / 设默认 / 删除。搜索框会同步隐藏不匹配的行。`})]}),(0,N.jsx)(`div`,{className:`acts`,children:(0,N.jsxs)(u,{variant:`primary`,small:!0,disabled:v,onClick:D,children:[(0,N.jsx)(e,{name:`plus`,size:13}),` 新建模板`]})})]}),(0,N.jsx)(`div`,{className:`tpl-mng-search`,children:(0,N.jsx)(_,{value:l,onChange:d,placeholder:`搜索名称 / 正文…`,title:`过滤本主题模板`,count:w.length,className:`wide`})}),S.length?(0,N.jsx)(`div`,{className:`tpl-mng-list`,children:w.map(t=>{let r=t.id===i?.defaultId;return(0,N.jsxs)(`div`,{className:[`tpl-mng-row`,f===t.id?`is-dragging`:``,h===t.id&&f!==t.id?`is-over`:``].filter(Boolean).join(` `),draggable:!0,onDragStart:e=>{m(t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,g(t.id)},onDrop:e=>{e.preventDefault(),g(null),f&&E(f,t.id),m(null)},onDragEnd:()=>{m(null),g(null)},children:[(0,N.jsx)(`span`,{className:`tpl-mng-grip`,title:`拖动排序`,children:(0,N.jsx)(e,{name:`grip`,size:14})}),(0,N.jsx)(`div`,{className:`tpl-mng-main`,children:(0,N.jsxs)(`div`,{className:`tpl-mng-line`,children:[(0,N.jsx)(`span`,{className:`tpl-mng-name`,children:t.name}),r&&(0,N.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,N.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`})]})}),(0,N.jsxs)(`div`,{className:`tpl-mng-acts`,children:[(0,N.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,onClick:()=>n.onNavigate?.(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,N.jsx)(e,{name:`edit`,size:14})}),!r&&(0,N.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:v,onClick:()=>T(()=>i.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,N.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,N.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:v,onClick:()=>T(()=>i.remove(t.id),`已删除「${t.name}」`),children:(0,N.jsx)(e,{name:`trash`,size:14})})]})]},t.id)})}):(0,N.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`本主题下没有可见模板。`})]})}function L({config:t}){let n=s(),r=a(),i=(0,M.useMemo)(()=>O(t?.id),[t?.id]),o=(0,M.useMemo)(()=>(n.tpl?.templates||[]).find(e=>e.id===(i||{})?.templateId)||null,[n.tpl?.templates,i]),c=(0,M.useMemo)(()=>o?E(o.body):[],[o]),[d,f]=(0,M.useState)(()=>{let e={};for(let t of c)e[t]=String((o?.values||{})[t]??``);return e});if(!i||!o)return(0,N.jsxs)(`div`,{className:`rp-page tpl-fill-page`,children:[(0,N.jsx)(y,{}),(0,N.jsx)(`div`,{className:`pad muted`,children:`参数会话已失效——请从「新建任务」下拉重新选择模板。`})]});let p=(e,t)=>f(n=>({...n,[e]:t})),m=e=>{let a={};i.board&&(a.board=i.board),i.project&&(a.project=i.project);let s=D({id:o.id,body:o.body,values:o.values},a,d),c=w(),u=i.groupId||i.dirKey||``,f=S(b(u),c);T(f,{title:l(s,``),body:s}),e&&j(f,{submit:!0}),k(t?.id);let p=i.groupId?{groupId:i.groupId,task:c,name:`新任务`}:{dirKey:i.dirKey,task:c,name:`新任务`};n.openPage?.(p),r(e?`正在提交任务…`:`已进入草稿编辑`)};return(0,N.jsxs)(`div`,{className:`rp-page tpl-fill-page`,children:[(0,N.jsx)(y,{}),(0,N.jsxs)(`div`,{className:`page-head`,children:[(0,N.jsxs)(`div`,{className:`title-block`,children:[(0,N.jsxs)(`h2`,{children:[(0,N.jsx)(e,{name:`list`,size:16}),` 填写模板参数`]}),(0,N.jsxs)(`p`,{className:`muted tpl-head-note`,children:[`「`,o.name,`」· 全部可选,留空即为空白。生成的是纯文本任务,编辑页不会再出现槽位框。`]})]}),(0,N.jsx)(`div`,{className:`acts`,children:(0,N.jsxs)(u,{variant:`secondary`,small:!0,onClick:()=>n.onNavigate?.(v()||`#/templates`),children:[(0,N.jsx)(e,{name:`back`,size:13}),` 返回`]})})]}),(0,N.jsx)(`div`,{className:`tpl-fill-body`,children:c.length===0?(0,N.jsx)(`div`,{className:`muted tpl-fill-empty`,children:`这条模板没有参数槽位,可直接进入任务编辑。`}):c.map(e=>(0,N.jsxs)(`label`,{className:`tpl-fill-field`,children:[(0,N.jsx)(`span`,{className:`tpl-fill-label`,children:e}),(0,N.jsx)(`textarea`,{className:`tpl-fill-input`,value:d[e]??``,placeholder:`填写「${e}」(可留空)`,onChange:t=>p(e,t.target.value),rows:4})]},e))}),(0,N.jsxs)(`div`,{className:`tpl-fill-foot`,children:[(0,N.jsxs)(u,{variant:`secondary`,onClick:()=>m(!1),children:[(0,N.jsx)(e,{name:`edit`,size:13}),` 进入编辑页(草稿)`]}),(0,N.jsxs)(u,{variant:`primary`,onClick:()=>m(!0),children:[(0,N.jsx)(e,{name:`check`,size:13}),` 直接提交`]})]})]})}var R=e=>`tpl:${e||`new`}`,z=`## 背景
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## 验收
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-DLfU1TXG.js";import{a as s}from"./md-parse-BjzYV8n7.js";import{C as c,E as l,S as u,T as d,_ as f,b as p,u as ee,x as m}from"./md-history-D0bYVPZY.js";var h=n(t(),1),g=e(),_=a,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(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let l=e.kind===`image`?c(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:l,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:l,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:u(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:c(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:c(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function b({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:c,allow:u={file:!0,url:!0,folder:!0,task:!1,ref:!1,repo:!1},taskOptions:b=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=i(),{dialog:te,node:ne}=r(),[k,A]=(0,h.useState)([]),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(``),[re,F]=(0,h.useState)(!1),[ie,I]=(0,h.useState)(!1),[ae,L]=(0,h.useState)(!1),[R,oe]=(0,h.useState)(`position`),[z,B]=(0,h.useState)(null),[V,H]=(0,h.useState)(null),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)(null),Y=(0,h.useMemo)(()=>d(e,{hostId:t,hostKey:n,hostCwd:a,refId:c}),[e,t,n,a,c]),X=(0,h.useCallback)(async()=>{if(S){A([]);return}M(!0),P(``);try{let e=await Y.list();A((e.attachments||[]).map(l))}catch(e){P(String(e.message||e))}finally{M(!1)}},[Y,S]);(0,h.useEffect)(()=>{X()},[X]),(0,h.useImperativeHandle)(w,()=>({open:()=>F(!0),refresh:X}),[X]),(0,h.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Z=(0,h.useMemo)(()=>[...k].sort(v[R]||v.position),[k,R]),Q=Z.filter(e=>e.area===`inline`),$=Z.filter(e=>e.area===`area`),se=async(e,t)=>{if(S)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;L(!0);let i=0;for(let e of r)try{let t=await p(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Y.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t.message||t}`)}L(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await X(),T?.())},ce=async r=>{if(r&&e!==`doc`)try{let e=await te({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),O(i?`已保存说明:${i}`:`已清空说明`),await X(),T?.()}catch(e){O(`改说明失败:${e.message||e}`)}},le=e=>{e&&(H(e),F(!0))},ue=async()=>{let e=z;if(e){W(!0);try{await Y.detach(e.id),B(null),O(`已解除关联:${e.name}`),await X(),T?.()}catch(e){O(`移除失败:${e.message||e}`)}finally{W(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);J({name:e.name||`md`,html:s(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){O(`读取失败:${e.message||e}`)}},fe=!j&&!N&&!k.length;return(0,g.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),se(null,e))},children:[ne,(0,g.jsxs)(`div`,{className:`att-area-head`+(ie&&!S?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,k.length?(0,g.jsx)(`span`,{className:`att-count`,children:k.length}):null,ae?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[k.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:R,onChange:e=>oe(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>F(!0),children:`添加附件`})]})]}),S?(0,g.jsx)(`div`,{className:`att-empty`,children:C}):null,j?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,N?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,N]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[m.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Q.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,$.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[m.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),$.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(ee,{open:re,host:e,hostId:t,hostKey:n,hostCwd:a,refId:c,allow:u,taskOptions:b,docOptions:x,replaceAttachment:V?V.id:null,replaceNote:V&&V.note||``,onClose:()=>{F(!1),H(null)},onDone:async()=>{H(null),await X(),T?.()}}),z?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>B(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>B(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>void ue(),children:`移除(解除关联)`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:z.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`会从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源本身(行与字节)保留在孤儿池, 之后仍可重新挂载;需要清理时由库级 GC 统一回收。`]})]})}):null,q?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[q.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:q.path})]}),size:`lg`,onClose:()=>J(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>J(null),children:`关闭`}),children:q.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,q.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[q.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:q.html}})]})}):null,G?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function x(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var S=`nx-kv-ack-rail-pos`,C=`nx-kv-doc-rail-pos`;function w(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function T(e=S){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function E(e,t=S){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var D=4;function O(e){let[t,n]=(0,h.useState)(()=>T(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=w({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<D)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=w({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,E(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),E(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{b as i,C as n,x as r,O as t};
|
|
1
|
+
import{d as e,f as t,h as n,i as r,l as i,t as a,u as o}from"./popup-DLfU1TXG.js";import{a as s}from"./md-parse-BjzYV8n7.js";import{C as c,E as l,S as u,T as d,_ as f,b as p,u as ee,x as m}from"./md-history-B7TamGno.js";var h=n(t(),1),g=e(),_=a,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(e,{onRemove:t,onPreview:n,onPreviewMd:r,onOpenTask:i,onOpenDoc:a,onEditNote:o,onReplace:s}){let l=e.kind===`image`?c(e.id):``;return(0,g.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,g.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:l,name:e.name}),title:`点击看大图`,children:(0,g.jsx)(`img`,{src:l,alt:e.name,loading:`lazy`})}):(0,g.jsx)(`span`,{className:`att-kind-badge`,children:u(e.kind)}),(0,g.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>i?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,g.jsx)(`button`,{type:`button`,className:`att-link`,title:e.note||e.title||e.name||`打开文档`,onClick:()=>a?.(e.refId?`ref:`+e.refId:e.locator||e.targetRef),children:e.title||e.name}):e.kind===`url`?(0,g.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,g.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,g.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,g.jsx)(`span`,{children:e.sizeText}):null,e.kind===`mdfile`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 源文件已不在`:``]}):null,e.kind===`folder`?(0,g.jsxs)(`span`,{className:`att-note`,title:e.absPath||``,children:[e.absPath||`(路径为空)`,e.missing?` · 目录已不在`:``]}):null,e.note?(0,g.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`mdfile`?(0,g.jsx)(`span`,{className:`att-item-acts`,children:(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`按 md 渲染磁盘当前内容(读时核对指纹)`,onClick:()=>r?.(e),children:`预览`})}):null,e.kind===`file`||e.kind===`image`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[(0,g.jsx)(`a`,{className:`att-act`,href:c(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,g.jsx)(`a`,{className:`att-act`,href:c(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,g.jsxs)(`span`,{className:`att-item-acts`,children:[o?(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>o(e),children:`✎ 说明`}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>s?.(e),children:`⇄ 更换`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}function b({host:e=`task`,hostId:t,hostKey:n,hostCwd:a,refId:c,allow:u={file:!0,url:!0,folder:!0,task:!1,ref:!1,repo:!1},taskOptions:b=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=i(),{dialog:te,node:ne}=r(),[k,A]=(0,h.useState)([]),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(``),[re,F]=(0,h.useState)(!1),[ie,I]=(0,h.useState)(!1),[ae,L]=(0,h.useState)(!1),[R,oe]=(0,h.useState)(`position`),[z,B]=(0,h.useState)(null),[V,H]=(0,h.useState)(null),[U,W]=(0,h.useState)(!1),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)(null),Y=(0,h.useMemo)(()=>d(e,{hostId:t,hostKey:n,hostCwd:a,refId:c}),[e,t,n,a,c]),X=(0,h.useCallback)(async()=>{if(S){A([]);return}M(!0),P(``);try{let e=await Y.list();A((e.attachments||[]).map(l))}catch(e){P(String(e.message||e))}finally{M(!1)}},[Y,S]);(0,h.useEffect)(()=>{X()},[X]),(0,h.useImperativeHandle)(w,()=>({open:()=>F(!0),refresh:X}),[X]),(0,h.useEffect)(()=>{if(!G)return;let e=e=>{e.key===`Escape`&&K(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[G]);let Z=(0,h.useMemo)(()=>[...k].sort(v[R]||v.position),[k,R]),Q=Z.filter(e=>e.area===`inline`),$=Z.filter(e=>e.area===`area`),se=async(e,t)=>{if(S)return;let n=f(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;L(!0);let i=0;for(let e of r)try{let t=await p(e),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Y.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t.message||t}`)}L(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await X(),T?.())},ce=async r=>{if(r&&e!==`doc`)try{let e=await te({title:`说明 · ${r.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:r.note||``,okText:`保存说明`});if(e===null)return;let i=typeof e==`string`?e:e&&e.value||``,s={id:Number(t),...n?{key:n}:a?{cwd:a}:{},attachment:r.id,note:i};await o(`/api/localtasks/attach-note`,{method:`PATCH`,body:s}),O(i?`已保存说明:${i}`:`已清空说明`),await X(),T?.()}catch(e){O(`改说明失败:${e.message||e}`)}},le=e=>{e&&(H(e),F(!0))},ue=async()=>{let e=z;if(e){W(!0);try{await Y.detach(e.id),B(null),O(`已解除关联:${e.name}`),await X(),T?.()}catch(e){O(`移除失败:${e.message||e}`)}finally{W(!1)}}},de=async e=>{if(e)try{let t=await o(`/api/docs/mdfile?attachment=${encodeURIComponent(String(e.id))}`),n=String(t.body||``);J({name:e.name||`md`,html:s(n),path:String(t.absPath||e.absPath||``),stale:!!t.stale,missing:!!t.missing})}catch(e){O(`读取失败:${e.message||e}`)}},fe=!j&&!N&&!k.length;return(0,g.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),I(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||I(!1)},onDrop:e=>{I(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),se(null,e))},children:[ne,(0,g.jsxs)(`div`,{className:`att-area-head`+(ie&&!S?` is-over`:``),children:[(0,g.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,k.length?(0,g.jsx)(`span`,{className:`att-count`,children:k.length}):null,ae?(0,g.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,g.jsxs)(`span`,{className:`att-area-acts`,children:[k.length?(0,g.jsxs)(`select`,{className:`att-sort`,value:R,onChange:e=>oe(e.target.value),"aria-label":`附件排序`,children:[(0,g.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,g.jsx)(`option`,{value:`name`,children:`按名称`}),(0,g.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,g.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>F(!0),children:`添加附件`})]})]}),S?(0,g.jsx)(`div`,{className:`att-empty`,children:C}):null,j?(0,g.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,N?(0,g.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,N]}):null,fe?(0,g.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,Q.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[m.inline,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),Q.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,$.length?(0,g.jsxs)(`div`,{className:`att-section`,children:[(0,g.jsxs)(`div`,{className:`att-section-head`,children:[m.area,(0,g.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),$.map(t=>y(t,{onRemove:B,onPreview:K,onPreviewMd:de,onOpenTask:E,onOpenDoc:D,onEditNote:e===`task`?ce:void 0,onReplace:le,key:t.id}))]}):null,(0,g.jsx)(ee,{open:re,host:e,hostId:t,hostKey:n,hostCwd:a,refId:c,allow:u,taskOptions:b,docOptions:x,replaceAttachment:V?V.id:null,replaceNote:V&&V.note||``,onClose:()=>{F(!1),H(null)},onDone:async()=>{H(null),await X(),T?.()}}),z?(0,g.jsx)(_,{title:`移除附件`,size:`sm`,busy:U,onClose:U?void 0:()=>B(null),footer:(0,g.jsxs)(`div`,{className:`att-foot`,children:[(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:U,onClick:()=>B(null),children:`取消`}),(0,g.jsx)(`button`,{type:`button`,className:`btn`,disabled:U,onClick:()=>void ue(),children:`移除(解除关联)`})]}),children:(0,g.jsxs)(`div`,{className:`att-confirm`,children:[(0,g.jsx)(`div`,{className:`att-confirm-name`,children:z.name}),(0,g.jsxs)(`div`,{className:`att-confirm-text`,children:[`会从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源本身(行与字节)保留在孤儿池, 之后仍可重新挂载;需要清理时由库级 GC 统一回收。`]})]})}):null,q?(0,g.jsx)(_,{title:(0,g.jsxs)(`span`,{children:[q.name,(0,g.jsx)(`span`,{className:`att-md-path`,children:q.path})]}),size:`lg`,onClose:()=>J(null),footer:(0,g.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:()=>J(null),children:`关闭`}),children:q.missing?(0,g.jsxs)(`div`,{className:`att-empty`,children:[`源文件已不在:`,q.path||`(路径为空)`]}):(0,g.jsxs)(`div`,{className:`att-md-preview`,children:[q.stale?(0,g.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,g.jsx)(`article`,{dangerouslySetInnerHTML:{__html:q.html}})]})}):null,G?(0,g.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&K(null)},children:(0,g.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,g.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,g.jsx)(`span`,{className:`att-lightbox-name`,children:G.name}),(0,g.jsx)(`a`,{className:`att-lightbox-open`,href:G.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,g.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>K(null),children:`×`})]}),(0,g.jsx)(`img`,{className:`att-lightbox-img`,src:G.src,alt:G.name})]})}):null]})}function x(e=`task`,t=!0){let n=(0,h.useCallback)(t=>`nxkv.${e}Dock${t}`,[e]),[r,i]=(0,h.useState)(()=>{let e=localStorage.getItem(n(`Open`));return e===null?t:e!==`0`}),[a,o]=(0,h.useState)(()=>localStorage.getItem(n(`Tab`))||`attach`),[s,c]=(0,h.useState)(()=>{let e=Number(localStorage.getItem(n(`H`)));return Number.isFinite(e)&&e>=96?e:176}),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=(0,h.useRef)(176);return(0,h.useEffect)(()=>{localStorage.setItem(n(`Open`),r?`1`:`0`)},[r,n]),(0,h.useEffect)(()=>{localStorage.setItem(n(`Tab`),a)},[a,n]),{dockOpen:r,setDockOpen:i,dockTab:a,setDockTab:o,dockH:s,dockHRef:l,dockRef:u,dockMax:d,setDockMax:f,dockPrevHRef:p,showDockTab:(0,h.useCallback)(e=>{o(e),i(!0)},[]),onDockDragStart:(0,h.useCallback)(e=>{if(!r)return;e.preventDefault(),f(!1);let t=e.clientY,i=l.current,a=u.current?.parentElement?.clientHeight||window.innerHeight,o=e=>Math.max(96,Math.min(Math.round(a*.62),Math.round(e))),s=e=>{let n=o(i-(e.clientY-t));l.current=n,c(n)},d=()=>{window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(n(`H`),String(l.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,d)},[r,n]),toggleDockMax:(0,h.useCallback)(()=>{if(d){c(p.current),f(!1);return}p.current=l.current;let e=u.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));l.current=t,c(t),f(!0)},[d])}}var S=`nx-kv-ack-rail-pos`,C=`nx-kv-doc-rail-pos`;function w(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Number(t),l=Number(n),u=Number(r),d=Number(i),f=Math.max(s,u-a-s),p=Math.max(s,d-o-s);return{x:Math.min(f,Math.max(s,c)),y:Math.min(p,Math.max(s,l))}}function T(e=S){try{let t=JSON.parse(localStorage.getItem(e)||`null`);if(!t||typeof t!=`object`)return null;let n=Number(t.x),r=Number(t.y);return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r}}catch{return null}}function E(e,t=S){try{e?localStorage.setItem(t,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(t)}catch{}}var D=4;function O(e){let[t,n]=(0,h.useState)(()=>T(e)),[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=a.current,t=e&&e.parentElement;if(!e||!t)return;let r=()=>{n(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=w({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return r(),window.addEventListener(`resize`,r,{passive:!0}),()=>window.removeEventListener(`resize`,r)},[]);let c=(0,h.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=a.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();t.style.bottom=r||``;let s=n.getBoundingClientRect();o.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-s.left,startTop:i.top-s.top,parentW:s.width,parentH:s.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),l=(0,h.useCallback)(e=>{let t=o.current;if(!t||e.pointerId!==t.pointerId)return;let r=e.clientX-t.startX,a=e.clientY-t.startY;if(!t.moved){if(Math.hypot(r,a)<D)return;t.moved=!0,s.current=!0,i(!0),document.body.style.userSelect=`none`}let c=w({x:t.startLeft+r,y:t.startTop+a,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});c&&(t.last=c,n(c))},[]),u=(0,h.useCallback)(t=>{let n=o.current;n&&t.pointerId===n.pointerId&&(o.current=null,n.moved&&(i(!1),document.body.style.userSelect=``,E(n.last,e)))},[e]),d=(0,h.useCallback)(()=>{n(null),E(null,e)},[e]);return{railRef:a,pos:t,dragging:r,draggedRef:s,resetPos:d,handleProps:{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,onDoubleClick:d}}}export{b as i,C as n,x as r,O as t};
|
|
@@ -12,23 +12,23 @@
|
|
|
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-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-Di6ErKBG.js"></script>
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/popup-DLfU1TXG.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/tool-bar-NHeX0Kmo.js">
|
|
18
18
|
<link rel="modulepreload" crossorigin href="/assets/button-VP4pjVsx.js">
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/app-context-DPFYOrgE.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="/assets/md-parse-BjzYV8n7.js">
|
|
21
|
-
<link rel="modulepreload" crossorigin href="/assets/md-history-
|
|
22
|
-
<link rel="modulepreload" crossorigin href="/assets/use-rail-drag-
|
|
21
|
+
<link rel="modulepreload" crossorigin href="/assets/md-history-B7TamGno.js">
|
|
22
|
+
<link rel="modulepreload" crossorigin href="/assets/use-rail-drag-4iK6t5ab.js">
|
|
23
23
|
<link rel="modulepreload" crossorigin href="/assets/board-view-jt8QixVg.js">
|
|
24
24
|
<link rel="modulepreload" crossorigin href="/assets/route-crumb-DS76cmRK.js">
|
|
25
|
-
<link rel="modulepreload" crossorigin href="/assets/doc-
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/assets/repo-form-modal-
|
|
25
|
+
<link rel="modulepreload" crossorigin href="/assets/doc-zDLeR8PE.js">
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/assets/repo-form-modal-DpwLdBYp.js">
|
|
27
27
|
<link rel="stylesheet" crossorigin href="/assets/popup-DzBICcYS.css">
|
|
28
28
|
<link rel="stylesheet" crossorigin href="/assets/tool-bar-CLIs9Dr0.css">
|
|
29
29
|
<link rel="stylesheet" crossorigin href="/assets/button-DA4lNJeC.css">
|
|
30
30
|
<link rel="stylesheet" crossorigin href="/assets/doc-Ka-2V5jn.css">
|
|
31
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
31
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DXJxcKIU.css">
|
|
32
32
|
</head>
|
|
33
33
|
<body>
|
|
34
34
|
<div id="root"></div>
|