nx-kv 0.67.1 → 0.67.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/package.json +1 -1
- package/src/web/frontend/styles/base.css +3 -2
- package/src/web/frontend/workspace/open.ts +4 -2
- package/src/web/public/assets/{bar-C0Q_Qe4z.js → bar-C-XvccT_.js} +1 -1
- package/src/web/public/assets/{composer-launch-BF3_hyn5.js → composer-launch-DocQvHKh.js} +1 -1
- package/src/web/public/assets/{composer-panel-DWWQD3wE.js → composer-panel-CNHQT6LM.js} +1 -1
- package/src/web/public/assets/{dag-BLxdhwgd.js → dag-D--zCQnc.js} +1 -1
- package/src/web/public/assets/{dir-CvVny2yZ.js → dir-BUHnfIMz.js} +1 -1
- package/src/web/public/assets/{doc-CVIVBV6n.js → doc-z8eXM9dk.js} +1 -1
- package/src/web/public/assets/{group-CUtdxFrs.js → group-hJw7aCS3.js} +1 -1
- package/src/web/public/assets/index-BruTRXSA.css +1 -0
- package/src/web/public/assets/{index-yhpvk7gl.js → index-GSk_7QV5.js} +3 -3
- package/src/web/public/assets/{md-history-COQu16vy.js → md-history-sxG54jJ_.js} +1 -1
- package/src/web/public/assets/{progress-CDh6DY7g.js → progress-CPQSMxLp.js} +1 -1
- package/src/web/public/assets/{refs-t79ynSY8.js → refs-Cp2bMHIB.js} +1 -1
- package/src/web/public/assets/{repo-form-modal-dZqpHyUj.js → repo-form-modal-DJMWkbA6.js} +1 -1
- package/src/web/public/assets/{repos-DdhOQJqF.js → repos-CwB-fsSw.js} +1 -1
- package/src/web/public/assets/{settings-DS1z2peI.js → settings-CTsPHoTG.js} +1 -1
- package/src/web/public/assets/{task-CUqExIXn.js → task-_XhRBJ8y.js} +1 -1
- package/src/web/public/assets/{task-ops-BoCAzUv1.js → task-ops-D3pxL8l5.js} +1 -1
- package/src/web/public/assets/{templates-CZDRJJHr.js → templates-MH1Mxml2.js} +3 -3
- package/src/web/public/assets/{tool-bar-DPXnjdQF.js → tool-bar-DpfJRjFG.js} +1 -1
- package/src/web/public/assets/{use-rail-drag-B6J0iqFK.js → use-rail-drag-DcUzHeV_.js} +1 -1
- package/src/web/public/index.html +7 -7
- package/src/web/public/assets/index-DiTnp6Kh.css +0 -1
|
@@ -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-dBtYqEM1.js";import{f as u}from"./tool-bar-DPXnjdQF.js";import{C as d,E as f,O 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,l as T,m as E,n as D,o as O,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-dZqpHyUj.js";import{n as R}from"./app-context-CngKv8Tc.js";import{u as z}from"./md-history-COQu16vy.js";import{t as B}from"./button-Cs6w2CDi.js";import{i as V,n as H}from"./doc-CVIVBV6n.js";import{t as U}from"./list-search-DFvFY408.js";import{t as ee}from"./route-crumb-BKq2jry0.js";import{t as te}from"./bar-C0Q_Qe4z.js";import{t as ne}from"./member-picker-CHX0nS0O.js";var W=r(n(),1),G=t(),K={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,W.useState)(`import`),[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[C,w]=(0,W.useState)({}),[T,E]=(0,W.useState)({}),[D,O]=(0,W.useState)(`ours`),[k,A]=(0,W.useState)(`none`),[j,M]=(0,W.useState)(``),[N,P]=(0,W.useState)(null),[F,I]=(0,W.useState)(!1),L=(0,W.useMemo)(()=>r||[],[r]),R=(0,W.useMemo)(()=>L.map(e=>e.key),[L]),z=(0,W.useMemo)(()=>(i||[]).map(e=>e.name),[i]),B=e=>{let t={};for(let n of R)t[n]=e;f(t)},V=e=>{let t={};for(let n of z)t[n]=e;m(t)},H=()=>{let e={};for(let t of R)e[t]=!d[t];f(e)},U=()=>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!==R.length?e:void 0,boards:t.length&&t.length!==z.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} 个看板`)}),ee=()=>{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),P(null))},ne=()=>o(async()=>{if(y.trim()){I(!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),P(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{I(!1)}}}),re=()=>o(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);I(!0);try{let r=await l(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:k,selection:e.length?e:void 0,boards:t.length?t:void 0}});P(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await q(),n&&await n()}finally{I(!1)}}),q=(0,W.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,W.useMemo)(()=>x?j?x.repos.filter(e=>e.status===j):x.repos:[],[x,j]),ae=(e,t)=>o(async()=>{if(t){I(!0);try{await l(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await q(),n&&await n()}finally{I(!1)}}}),oe=e=>{let t={...C};for(let n of ie)t[n.key]=e;w(t)};(0,W.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,W.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,G.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,G.jsxs)(`div`,{className:`rp-full-box`,children:[(0,G.jsxs)(`div`,{className:`rp-full-head`,children:[(0,G.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,G.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,G.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,G.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,G.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),c===`export`?(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsx)(`span`,{children:`导出范围`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选仓库`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:H,children:`反选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[L.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,G.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),L.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,G.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,G.jsx)(`span`,{children:`看板`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!1),children:`全不选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,G.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,G.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,G.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(`button`,{className:`btn`,onClick:U,children:`生成布局`}),(0,G.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:ee,children:`下载 JSON`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导出结果`})}),(0,G.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导入来源`})}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,G.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,G.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsx)(`button`,{className:`btn`,disabled:!y.trim()||F,onClick:ne,children:`差异检查`})}),x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,G.jsx)(`span`,{children:`冲突方案`})}),(0,G.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,G.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,G.jsx)(`span`,{children:t})]},e))}),(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,G.jsx)(`span`,{children:`克隆`})}),(0,G.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),children:[(0,G.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,G.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,G.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,G.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsxs)(`button`,{className:`btn`,disabled:F,onClick:re,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,N?(0,G.jsxs)(`div`,{className:`rp-import-result`,children:[(0,G.jsxs)(`div`,{children:[`新建 `,N.created.length,` · 覆盖 `,N.updated.length,` · 另存 `,N.duplicated.length,` · 跳过 `,N.skipped.length]}),(0,G.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,N.boardsCreated,` / 合并 `,N.boardsMerged,` · 参考关系 `,N.links]}),N.cloned.length?(0,G.jsxs)(`div`,{children:[`克隆 `,N.cloned.length,` 个`]}):null,N.unmatched.length?(0,G.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,N.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,G.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsxs)(`span`,{children:[`差异(新增 `,se.new,` · 有差异 `,se.changed,` · 一致 `,se.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`rp-chip`+(j===``?` on`:``),onClick:()=>M(``),children:`全部`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`new`?` on`:``),onClick:()=>M(`new`),children:`新增`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`changed`?` on`:``),onClick:()=>M(`changed`),children:`有差异`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`same`?` on`:``),onClick:()=>M(`same`),children:`一致`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!1),children:`全不选`})]})]}),(0,G.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{style:{width:`32px`}}),(0,G.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,G.jsx)(`th`,{children:`仓库 key`}),(0,G.jsx)(`th`,{children:`差异字段`})]})}),(0,G.jsxs)(`tbody`,{children:[ie.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row `+(K[e.status]?.cls??``),children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label})}),(0,G.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,G.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,G.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:F,onClick:()=>ae(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,G.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`b`,{children:e.field}),`: `,(0,G.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,G.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,G.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,G.jsx)(`td`,{}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,G.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,G.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,G.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label}),(0,G.jsx)(`span`,{children:e.key}),(0,G.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,G.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,G.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,G.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,G.jsx)(`button`,{className:`btn small`,disabled:F,onClick:()=>ae(e.key,e.remote),children:`克隆到本地`}):(0,G.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,G.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var q=o(`board`),ie=o(`repo`),ae=o(`repo-ref`),oe=o(`doc`),se=o(`docs`),ce=o(`search`),le=o(`plus`),ue=o(`refresh`),de=o(`open`),fe=o(`chevron-down`),pe=o(`check`);o(`x`);var me=o(`users`);o(`folder`);var J=o(`unlink`),he=o(`overview`),ge=o(`edit`),_e=o(`trash`),ve=o(`link`);function ye({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,G.jsx)(p,{text:t,title:void 0,children:t}):(0,G.jsxs)(p,{text:t,title:`点击复制完整路径`,children:[(0,G.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-dBtYqEM1.js";import{f as u}from"./tool-bar-DpfJRjFG.js";import{C as d,E as f,O 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,l as T,m as E,n as D,o as O,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-DJMWkbA6.js";import{n as R}from"./app-context-CngKv8Tc.js";import{u as z}from"./md-history-sxG54jJ_.js";import{t as B}from"./button-Cs6w2CDi.js";import{i as V,n as H}from"./doc-z8eXM9dk.js";import{t as U}from"./list-search-DFvFY408.js";import{t as ee}from"./route-crumb-BKq2jry0.js";import{t as te}from"./bar-C-XvccT_.js";import{t as ne}from"./member-picker-CHX0nS0O.js";var W=r(n(),1),G=t(),K={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,W.useState)(`import`),[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[C,w]=(0,W.useState)({}),[T,E]=(0,W.useState)({}),[D,O]=(0,W.useState)(`ours`),[k,A]=(0,W.useState)(`none`),[j,M]=(0,W.useState)(``),[N,P]=(0,W.useState)(null),[F,I]=(0,W.useState)(!1),L=(0,W.useMemo)(()=>r||[],[r]),R=(0,W.useMemo)(()=>L.map(e=>e.key),[L]),z=(0,W.useMemo)(()=>(i||[]).map(e=>e.name),[i]),B=e=>{let t={};for(let n of R)t[n]=e;f(t)},V=e=>{let t={};for(let n of z)t[n]=e;m(t)},H=()=>{let e={};for(let t of R)e[t]=!d[t];f(e)},U=()=>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!==R.length?e:void 0,boards:t.length&&t.length!==z.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} 个看板`)}),ee=()=>{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),P(null))},ne=()=>o(async()=>{if(y.trim()){I(!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),P(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{I(!1)}}}),re=()=>o(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);I(!0);try{let r=await l(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:k,selection:e.length?e:void 0,boards:t.length?t:void 0}});P(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await q(),n&&await n()}finally{I(!1)}}),q=(0,W.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,W.useMemo)(()=>x?j?x.repos.filter(e=>e.status===j):x.repos:[],[x,j]),ae=(e,t)=>o(async()=>{if(t){I(!0);try{await l(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await q(),n&&await n()}finally{I(!1)}}}),oe=e=>{let t={...C};for(let n of ie)t[n.key]=e;w(t)};(0,W.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,W.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,G.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,G.jsxs)(`div`,{className:`rp-full-box`,children:[(0,G.jsxs)(`div`,{className:`rp-full-head`,children:[(0,G.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,G.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,G.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,G.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,G.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),c===`export`?(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsx)(`span`,{children:`导出范围`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选仓库`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:H,children:`反选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[L.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,G.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),L.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,G.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,G.jsx)(`span`,{children:`看板`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!1),children:`全不选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,G.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,G.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,G.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(`button`,{className:`btn`,onClick:U,children:`生成布局`}),(0,G.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:ee,children:`下载 JSON`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导出结果`})}),(0,G.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导入来源`})}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,G.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,G.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsx)(`button`,{className:`btn`,disabled:!y.trim()||F,onClick:ne,children:`差异检查`})}),x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,G.jsx)(`span`,{children:`冲突方案`})}),(0,G.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,G.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,G.jsx)(`span`,{children:t})]},e))}),(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,G.jsx)(`span`,{children:`克隆`})}),(0,G.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),children:[(0,G.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,G.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,G.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,G.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsxs)(`button`,{className:`btn`,disabled:F,onClick:re,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,N?(0,G.jsxs)(`div`,{className:`rp-import-result`,children:[(0,G.jsxs)(`div`,{children:[`新建 `,N.created.length,` · 覆盖 `,N.updated.length,` · 另存 `,N.duplicated.length,` · 跳过 `,N.skipped.length]}),(0,G.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,N.boardsCreated,` / 合并 `,N.boardsMerged,` · 参考关系 `,N.links]}),N.cloned.length?(0,G.jsxs)(`div`,{children:[`克隆 `,N.cloned.length,` 个`]}):null,N.unmatched.length?(0,G.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,N.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,G.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsxs)(`span`,{children:[`差异(新增 `,se.new,` · 有差异 `,se.changed,` · 一致 `,se.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`rp-chip`+(j===``?` on`:``),onClick:()=>M(``),children:`全部`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`new`?` on`:``),onClick:()=>M(`new`),children:`新增`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`changed`?` on`:``),onClick:()=>M(`changed`),children:`有差异`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`same`?` on`:``),onClick:()=>M(`same`),children:`一致`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>oe(!1),children:`全不选`})]})]}),(0,G.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{style:{width:`32px`}}),(0,G.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,G.jsx)(`th`,{children:`仓库 key`}),(0,G.jsx)(`th`,{children:`差异字段`})]})}),(0,G.jsxs)(`tbody`,{children:[ie.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row `+(K[e.status]?.cls??``),children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label})}),(0,G.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,G.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,G.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:F,onClick:()=>ae(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,G.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`b`,{children:e.field}),`: `,(0,G.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,G.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,G.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,G.jsx)(`td`,{}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,G.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,G.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,G.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label}),(0,G.jsx)(`span`,{children:e.key}),(0,G.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,G.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,G.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,G.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,G.jsx)(`button`,{className:`btn small`,disabled:F,onClick:()=>ae(e.key,e.remote),children:`克隆到本地`}):(0,G.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,G.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var q=o(`board`),ie=o(`repo`),ae=o(`repo-ref`),oe=o(`doc`),se=o(`docs`),ce=o(`search`),le=o(`plus`),ue=o(`refresh`),de=o(`open`),fe=o(`chevron-down`),pe=o(`check`);o(`x`);var me=o(`users`);o(`folder`);var J=o(`unlink`),he=o(`overview`),ge=o(`edit`),_e=o(`trash`),ve=o(`link`);function ye({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,G.jsx)(p,{text:t,title:void 0,children:t}):(0,G.jsxs)(p,{text:t,title:`点击复制完整路径`,children:[(0,G.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,G.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,G.jsx)(V,{items:s,onMore:t}):(0,G.jsx)(`span`,{className:`rp-docs-entry-main ghost`,children:`+ 写项目介绍`}),(0,G.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function be({chips:e,acts:t}){let[n,r]=(0,W.useState)(!1),i=n?e:e.slice(0,4);return(0,G.jsxs)(G.Fragment,{children:[i.map(e=>(0,G.jsx)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`本仓库直接绑定的参考仓库`,`点击跳到这个参考仓库`].join(`
|
|
3
3
|
`),onClick:()=>t.gotoRefRepo(e.key),children:[(0,G.jsx)(`b`,{children:`自`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.key)),e.length>4?(0,G.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>r(e=>!e),children:n?`收起`:`+${e.length-4}`}):null]})}function xe({r:e,mode:t,filterBoard:n,refRepoChipsByRepo:r,acts:i}){let a=r.get(e.key)||[];return(0,G.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,G.jsxs)(`td`,{className:`rp-name`,children:[(0,G.jsxs)(`strong`,{children:[e.icon?(0,G.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name]}),(0,G.jsx)(`span`,{className:`mono rp-name-path`,children:(0,G.jsx)(ye,{path:e.path})})]}),(0,G.jsx)(`td`,{className:`rp-cell-docs`,children:(0,G.jsx)(Y,{docs:e.descDocs,onOpen:()=>i.docs(e)})}),t===`group`?null:(0,G.jsx)(`td`,{className:`rp-boards`,children:(e.boards||[]).length?(e.boards||[]).map(e=>(0,G.jsx)(`button`,{type:`button`,className:`rp-board-chip`,title:`跳到分组「${e.name}」`,onClick:()=>i.filter?.(e.id),children:e.name},e.id)):(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}),t===`group`?null:(0,G.jsxs)(`td`,{className:`rp-refs`,children:[a.length?(0,G.jsx)(be,{chips:a,acts:i}):(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,G.jsx)(B,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>i.bind(e),children:`绑定`})]}),(0,G.jsxs)(`td`,{className:`rp-acts`+(t===`group`?` rp-acts-wrap`:``),children:[(0,G.jsx)(te,{kind:`repos-row`,renderers:{edit:()=>(0,G.jsxs)(B,{small:!0,onClick:()=>i.edit(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(ge,{size:12})}),`编辑`]}),open:()=>(0,G.jsxs)(B,{small:!0,title:`在文件管理器中打开`,onClick:()=>i.open(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(de,{size:12})}),`打开`]}),del:()=>(0,G.jsxs)(B,{small:!0,danger:!0,onClick:()=>i.del(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(_e,{size:12})}),`删除`]}),remote:()=>(0,G.jsx)(B,{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,G.jsxs)(B,{small:!0,danger:!0,title:`只从这个分组摘除(不影响仓库本体与其它分组)`,onClick:()=>i.unbindBoard?.(e,n.id),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(J,{size:12})}),`移出本组`]}):null]})]})}function Se({shown:e,devRepos:t,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a,onAddMember:o}){let s=n===`group`;return(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,G.jsxs)(`table`,{className:`rp-table`+(s?` rp-table-group`:``),children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:s?`30%`:`22%`},children:`仓库`}),(0,G.jsxs)(`th`,{scope:`col`,style:{width:s?`46%`:`30%`},children:[`文档`,(0,G.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),s?null:(0,G.jsx)(`th`,{scope:`col`,style:{width:`14%`},children:`所在组`}),s?null:(0,G.jsx)(`th`,{scope:`col`,style:{width:`16%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,G.jsxs)(`tbody`,{children:[e.map(e=>(0,G.jsx)(xe,{r:e,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a},e.id)),e.length?null:(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:s?3:5,className:`muted rp-empty`,children:s?(0,G.jsxs)(G.Fragment,{children:[`这个分组里还没有仓库`,` `,r?(0,G.jsx)(B,{small:!0,onClick:()=>o(r.id),children:`添加成员`}):null]}):n==="default"?`没有未归组的仓库 —— 所有仓库都至少在一个分组里。`:t.length?`没有匹配的仓库:换个关键字,或切换分组看看。`:`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}var Ce=`main`,we=`default`;function Te({branches:e,value:t,onChange:n,onCreate:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(``),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=e.find(e=>e.id===t)||e[0];(0,W.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,W.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,G.jsxs)(`div`,{className:`rp-branch`,ref:c,children:[(0,G.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,G.jsx)(he,{size:14}):(0,G.jsx)(q,{size:14}),(0,G.jsx)(`span`,{className:`rp-branch-name`,children:u?u.name:Ce}),(0,G.jsx)(`span`,{className:`rp-branch-btn-caret`,children:(0,G.jsx)(fe,{size:13})})]}),i?(0,G.jsxs)(`div`,{className:`rp-branch-pop`,role:`listbox`,"aria-label":`分组`,children:[(0,G.jsxs)(`div`,{className:`rp-branch-filter`,children:[(0,G.jsx)(ce,{size:13}),(0,G.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,G.jsxs)(`div`,{className:`rp-branch-list`,children:[d.map(e=>(0,G.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,G.jsx)(`span`,{className:`rp-branch-item-ico`,children:e.virtual&&e.id===`main`?(0,G.jsx)(he,{size:13}):(0,G.jsx)(q,{size:13})}),(0,G.jsx)(`span`,{className:`rp-branch-item-name`,children:e.name}),(0,G.jsx)(`span`,{className:`rp-branch-item-n`,children:e.repoCount}),(0,G.jsx)(`span`,{className:`rp-branch-item-check`,children:e.id===t?(0,G.jsx)(pe,{size:13}):null})]},e.id)),d.length?null:(0,G.jsx)(`div`,{className:`rp-branch-empty`,children:`没有匹配的分组`})]}),r?(0,G.jsxs)(`button`,{type:`button`,className:`rp-branch-new`,onClick:()=>{a(!1),s(``),r()},children:[(0,G.jsx)(le,{size:13}),(0,G.jsx)(`span`,{children:`新建分组`})]}):null]}):null]})}function Ee(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 De(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))||Ee(e.descDocs,i)):a}function Oe(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:Ce,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:we,name:`default`,repoCount:t.ungrouped,refCount:0,docCount:0,virtual:!0}),n}function ke({repos:e,boardList:t,branch:n,kw:r,docCount:i}){let a=(0,W.useMemo)(()=>e.filter(e=>(e.type||`dev`)!==`ref`),[e]),o=(0,W.useMemo)(()=>e.filter(e=>e.type===`ref`),[e]),s=(0,W.useMemo)(()=>t.find(e=>e.id===n)||null,[t,n]),c=(0,W.useMemo)(()=>a.filter(e=>!(e.boards||[]).length),[a]);return{devRepos:a,refRepos:o,branchBoard:s,ungrouped:c,branches:(0,W.useMemo)(()=>X(t,{dev:a.length,ref:o.length,ungrouped:c.length,docs:i}),[t,a.length,o.length,c.length,i]),groupRefReposByRepo:(0,W.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,W.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,W.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,W.useMemo)(()=>De(a,c,s,n,r),[a,c,s,n,r]),refRows:(0,W.useMemo)(()=>Oe(o,s,n,r),[o,s,n,r])}}var Z=`nx-kv-repos-branch-v1`;function Ae(){try{let e=localStorage.getItem(Z);return(e==null?null:String(e))||null}catch{return null}}function je(e){try{let t=String(e||``);t&&localStorage.setItem(Z,t)}catch{}}function Me({value:e,onChange:t,placeholder:n,count:r}){return(0,G.jsxs)(`label`,{className:`rp-q`,title:`全局检索:仓库 / 参考仓库 / 文档 一起搜`,children:[(0,G.jsx)(ce,{size:13}),(0,G.jsx)(`input`,{value:e,placeholder:n||`搜索仓库 / 参考仓库 / 文档…`,"aria-label":`全局检索`,onChange:e=>t(e.target.value)}),e?(0,G.jsx)(`span`,{className:`rp-q-n`,children:r===void 0?``:r}):null,e?(0,G.jsx)(`button`,{type:`button`,className:`rp-q-x`,title:`清空检索`,onClick:()=>t(``),children:`×`}):null]})}function Ne({tabs:e,value:t,onChange:n}){return(0,G.jsx)(`div`,{className:`rp-blocks`,children:(0,G.jsx)(`div`,{className:`rp-block-tabs`,role:`tablist`,"aria-label":`区块`,children:e.map(e=>(0,G.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,G.jsx)(`span`,{className:`rp-block-tab-ico`,children:e.icon}),(0,G.jsx)(`span`,{className:`rp-block-tab-label`,children:e.label}),(0,G.jsx)(`span`,{className:`rp-block-tab-n`,children:e.count})]},e.id))})})}function Pe({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:m}){let h=t===`group`,[g,_]=(0,W.useState)({});return e.length?(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-refs`,children:(0,G.jsxs)(`table`,{className:`rp-table rp-table-ref`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:`26%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`24%`},children:`远程地址`}),(0,G.jsx)(`th`,{scope:`col`,children:`绑定对象`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,G.jsx)(`tbody`,{children:e.map(e=>{let t=a.get(e.id),m=r.map(t=>(t.refs||[]).find(t=>t.id===e.key)?{board:t}:null).filter(e=>e!==null),v=i.get(e.key)||[],y=!!g[e.id];return(0,G.jsxs)(`tr`,{id:`rp-refrepo-row-`+e.key,children:[(0,G.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,G.jsxs)(`strong`,{children:[(0,G.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:(t.issues||[]).join(`
|
|
4
4
|
`):`尚未检查`}),e.name]}),(0,G.jsx)(Y,{docs:e.descDocs,onOpen:()=>c(e)})]}),(0,G.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,G.jsx)(p,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,G.jsx)(`td`,{className:`rp-ref-cell-links`,children:m.length||v.length?(0,G.jsxs)(G.Fragment,{children:[m.length?(0,G.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,G.jsx)(`span`,{className:`rp-bind-label`,children:`组`}),(y?m:m.slice(0,3)).map(t=>(0,G.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-group`,children:[(0,G.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-dBtYqEM1.js";import{n as o}from"./app-context-CngKv8Tc.js";import{t as s}from"./button-Cs6w2CDi.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-yhpvk7gl.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.jsx)(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?`开`:`关`]})]})}),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-dBtYqEM1.js";import{n as o}from"./app-context-CngKv8Tc.js";import{t as s}from"./button-Cs6w2CDi.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-GSk_7QV5.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.jsx)(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?`开`:`关`]})]})}),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,t as o,u as s}from"./popup-dBtYqEM1.js";import{D as c,f as l,n as u,u as d}from"./tool-bar-
|
|
1
|
+
import{a as e,d as t,f as n,h as r,i,l as a,t as o,u as s}from"./popup-dBtYqEM1.js";import{D as c,f as l,n as u,u as d}from"./tool-bar-DpfJRjFG.js";import{n as f}from"./app-context-CngKv8Tc.js";import{d as p,g as m,h,l as g,m as _,s as v}from"./task-status-Cjsm0xF7.js";import{C as y,E as b,T as x,a as S,b as C,i as w,n as T,r as E,s as D,t as O,w as ee}from"./md-history-sxG54jJ_.js";import{i as k,r as A,t as j}from"./use-rail-drag-DcUzHeV_.js";import{t as te}from"./route-crumb-BKq2jry0.js";import{C as ne,S as re,_ as ie,b as ae,g as M,h as N,v as P,x as F,y as I}from"./index-GSk_7QV5.js";import{a as L,i as R,n as z,o as oe}from"./composer-launch-DocQvHKh.js";import{a as B,d as V,f as H,g as se,i as U,l as ce,m as le,n as ue,o as W,r as de,s as fe,t as G,u as pe}from"./reopen-text-B2d9SZi0.js";import{n as K,r as me,t as he}from"./task-utils-Dh33OFKe.js";import{n as ge}from"./group-project-memo-G-O6sPRw.js";var q=r(n(),1);function _e(e){return s(`/api/localtasks/chain?${e}`)}function ve(e){return s(`/api/localtasks/timegoal-log?${e}`)}function ye(e){return s(`/api/localtasks/clone`,{method:`POST`,body:e})}function be(e){return s(`/api/localtasks/fork`,{method:`POST`,body:e})}function xe(e){return s(`/api/localtasks/attachments?${e}`)}function Se(e){return s(`/api/docs/mdfile?attachment=${encodeURIComponent(e)}`)}function Ce(e){return s(`/api/localtasks/preview`,{method:`POST`,body:e})}function we(e){let t=String(e??``).split(`
|
|
2
2
|
`),n=B(t[0]);return n?{head:n,body:t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
|
|
3
3
|
`)}:null}function Te(e){let t=ee(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=we(a);if(o&&U(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&&U(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?`
|
|
4
4
|
`:``)+a:r.feedbackText+=(r.feedbackText?`
|
|
@@ -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-dBtYqEM1.js";import{D as c}from"./repo-form-modal-dZqpHyUj.js";import{n as l}from"./app-context-CngKv8Tc.js";import{l as u}from"./task-status-Cjsm0xF7.js";import{d,f,s as p}from"./md-history-COQu16vy.js";import{t as m}from"./button-Cs6w2CDi.js";import{S as h,h as g,w as _,x as v}from"./index-yhpvk7gl.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-B2d9SZi0.js";import{t as ne}from"./bar-C0Q_Qe4z.js";var A=r(n(),1),j=t(),M=10;function N({repo:e,onClose:t,onSaved:n}){let r=l(),a=i(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,A.useState)(!!(o&&o.enabled)),[f,p]=(0,A.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(M)),[h,g]=(0,A.useState)(!1),_=e=>{let t=String(e??``).trim();if(t===``)return M;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):M},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":_(f)}:{}});let s=_(f);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=>{d(e),await v({enabled:e})};return(0,j.jsx)(s,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,j.jsxs)(`div`,{className:`rp-gl`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,j.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,j.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,j.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>y(!u),disabled:h,children:[(0,j.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,j.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,j.jsx)(`span`,{children:`阻塞窗口`}),(0,j.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,j.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,j.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,j.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(m,{variant:`primary`,disabled:h,onClick:()=>v(),children:`保存持续 get 设置`})]})]})]})})}var P=s,re=(e,t,n)=>y(e=>n.get(Number(e))||[],e,t);function F({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,A.useState)(!!e.blocksFollowing),[l,d]=(0,A.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,p]=(0,A.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,A.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))&&re(i(e),a,v),b=e=>!f.has(i(e))&&re(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,j.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,j.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,j.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,j.jsx)(P,{title:`编排 · #${a} ${u(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,j.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,j.jsxs)(`div`,{className:`mdw-dag`,children:[(0,j.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,j.jsx)(`b`,{children:`闸门`}),(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,j.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,j.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,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,j.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,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function ie(e,t){let n=Array.isArray(e)?e:[],[r,i]=(0,A.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,j.jsxs)(`span`,{className:`pager-n`,children:[`共 `,n,` `,i]}):(0,j.jsxs)(`span`,{className:`pager`,children:[(0,j.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e<=0,onClick:()=>a(e-1),"aria-label":`上一页`,title:`上一页`,children:`‹`}),(0,j.jsxs)(`span`,{className:`pager-n`,children:[`第 `,e+1,`/`,t,` 页 · 共 `,n,` `,i]}),(0,j.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,j.jsxs)(`div`,{className:`rp-tasks`,children:[(0,j.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,j.jsx)(e,{name:t,size:13}),` `,n,r>0&&(0,j.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!s&&o?(0,j.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,j.jsxs)(`div`,{className:`rp-page`,children:[(0,j.jsxs)(`div`,{className:`rp-group-head`,children:[(0,j.jsxs)(`h2`,{children:[(0,j.jsx)(e,{name:r,size:15}),` `,t,n.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,j.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,j.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,o,s,c,l]})}function I(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:f=[],history:m=!1,ops:h=null,searchCtx:g=null}){let v=`rp-proj-row`+(l?.dragging?` dragging`:``)+(l?.drop?` drop-`+l.drop:``),y=t.status===`pending`&&t.ready===!1;return(0,j.jsxs)(`div`,{className:v,...c?{onDragOver:c.onDragOver,onDragLeave:c.onDragLeave,onDrop:c.onDrop}:{},children:[s?(0,j.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:c?.onDragStart,onDragEnd:c?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,j.jsx)(e,{name:`grip`,size:12})}):(0,j.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),i?(0,j.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,j.jsx)(`input`,{type:`checkbox`,checked:a,onChange:()=>o?.(t.id),"aria-label":`选择任务 #${t.id}`})}):null,(0,j.jsxs)(`div`,{className:`rp-proj-task`+(m?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:[(0,j.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),n?(0,j.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||n}`,children:n}):null,(0,j.jsx)(`span`,{className:`rp-proj-task-tx`,children:_(t)}),t.timegoal&&(0,j.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,j.jsx)(e,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,j.jsxs)(`span`,{className:`rp-tgate`,title:f.length?`闸门:未完成前挡住 ${f.length} 个后续任务(#${f.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,f.length?`×${f.length}`:``]}),y&&(0,j.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),d&&(0,j.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${t.createdAt||`—`}${t.consumedAt?` · 领取 ${t.consumedAt}`:``}`,children:[I(t.createdAt),t.consumedAt?` → ${I(t.consumedAt)}`:``]}),(0,j.jsx)(p,{t}),h?(0,j.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:h}):null]}),g?(0,j.jsx)(`div`,{className:`rp-proj-task-ctx`,role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:g.lines.map((e,t)=>(0,j.jsxs)(`div`,{className:`ctx-line`+(t===g.hitIndex?` hit`:``),children:[(0,j.jsx)(`span`,{className:`ctx-no`,children:g.hitLineNo-g.hitIndex+t}),(0,j.jsx)(`span`,{className:`ctx-tx`,children:e||`\xA0`})]},t))}):null]})}var le=20;function L({kind:t,name:n,title:r,rows:s,emptyText:c,intro:l=null,extraCounts:u=[],actionExtra:p=null,toolActs:m={},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,A.useRef)(null),[M,N]=(0,A.useState)(null),[P,re]=(0,A.useState)(``),F=!!String(P).trim(),I=(0,A.useMemo)(()=>F?s.filter(e=>f({id:e.task.id,text:e.task.text},P)):s,[s,P,F]),L=(0,A.useMemo)(()=>I.filter(e=>e.task.status===`pending`&&!e.task.migratedTo).length,[I]),R=ie(I,le);(0,A.useEffect)(()=>{R.setPage(0)},[P]);let[z,B]=(0,A.useState)(()=>new Set),V=R.items,H=V.map(e=>e.key),U=H.length>0&&H.every(e=>z.has(e));(0,A.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,ue=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=()=>{B(e=>{let t=new Set(e);return U?H.forEach(e=>t.delete(e)):H.forEach(e=>t.add(e)),t})},J=async e=>{W.length&&e&&await e(W)&&B(new Set)},Y=W.filter(e=>e.task.status===`pending`),fe=W.filter(e=>e.task.status===`plan`),pe=Y.length?Y:fe,me=Y.length?`plan`:`pending`,he=W.length?me===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${fe.length})`:`草稿态`,X=(0,A.useRef)(null),[ge,Z]=(0,A.useState)(null),[Q,$]=(0,A.useState)(null),_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{X.current=t.key,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.task.id),Z(t.key)},ye=(e,t)=>{X.current&&t.movable&&t.key!==X.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=X.current;if(X.current=null,Z(null),$(null),!r||!t.movable||t.key===r)return;let i=s.find(e=>e.key===r);i&&y&&y(i,t,n)},Se=()=>{X.current=null,Z(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,j.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,j.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,W.length,` 条`]}),O&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!G.length,title:G.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${q?`;其中 ${q} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>void J(O),children:[`标为完成选中`,G.length?` (${G.length})`:``]}),D&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>void J(D),children:[`取消选中`,K.length?` (${K.length})`:``]}),E&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>void J(E),children:[`删除选中 (`,W.length,`)`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>B(new Set),children:`清空`})]}):null,Te=(0,j.jsx)(oe,{title:r,pendingCount:L,headerExtra:(0,j.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,j.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:P,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>re(e.target.value)}),V.length?(0,j.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:U,onChange:de,"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,j.jsx)(ce,{t:e.task,projectTag:e.projectTag,projectTitle:e.projectTitle,searchCtx:F?d(e.task,P):null,selectable:!0,picked:z.has(e.key),onTogglePick:()=>ue(e.key),draggable:!!e.movable,dragHandlers:t,dragVisual:{dragging:ge===e.key,drop:Q&&Q.key===e.key?Q.zone:null},showTimes:e.showTimes,downs:e.downs,onOpen:()=>v(e),ops:(0,j.jsx)(o,{items:Ce(e)})},e.key)})}),Ee=R.total>0?(0,j.jsx)(`div`,{className:`mdw-land-pager`,children:(0,j.jsx)(ae,{page:R.page,pageCount:R.pageCount,total:R.total,onPage:R.setPage,unit:`个任务`})}):null,De=e=>{N({x:e.clientX,y:e.clientY})},Oe=()=>(0,j.jsx)(`span`,{className:`rp-newtask`,children:(0,j.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,disabled:g,onClick:()=>h(),children:[`+ 新建页`,(0,j.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,j.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})});return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(se,{name:n,counts:[`${F?`命中 `:``}${R.total} 个任务`,...L>0?[`待领取 ${L}`]:[],...u],intro:l,batch:we,list:Te,footer:Ee,actions:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ne,{kind:t,labels:{more:`更多`,...m.labels,plan:he},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`,...m.titles},disabled:m.disabled,renderers:{new:Oe,...m.renderers},actions:{...m.actions,new:()=>h(),import:()=>k.current?.click(),plan:()=>{if(!pe.length){te(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}x?.(pe,me)}}}),p]})}),M&&(0,j.jsx)(a,{x:M.x,y:M.y,items:_,onClose:()=>N(null)}),(0,j.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 R(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-dBtYqEM1.js";import{D as c}from"./repo-form-modal-DJMWkbA6.js";import{n as l}from"./app-context-CngKv8Tc.js";import{l as u}from"./task-status-Cjsm0xF7.js";import{d,f,s as p}from"./md-history-sxG54jJ_.js";import{t as m}from"./button-Cs6w2CDi.js";import{S as h,h as g,w as _,x as v}from"./index-GSk_7QV5.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-B2d9SZi0.js";import{t as ne}from"./bar-C-XvccT_.js";var A=r(n(),1),j=t(),M=10;function N({repo:e,onClose:t,onSaved:n}){let r=l(),a=i(),o=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,A.useState)(!!(o&&o.enabled)),[f,p]=(0,A.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(M)),[h,g]=(0,A.useState)(!1),_=e=>{let t=String(e??``).trim();if(t===``)return M;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):M},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":_(f)}:{}});let s=_(f);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=>{d(e),await v({enabled:e})};return(0,j.jsx)(s,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,j.jsxs)(`div`,{className:`rp-gl`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,j.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,j.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,j.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>y(!u),disabled:h,children:[(0,j.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,j.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,j.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,j.jsx)(`span`,{children:`阻塞窗口`}),(0,j.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,j.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,j.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,j.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,j.jsx)(`span`,{className:`spacer`}),(0,j.jsx)(m,{variant:`primary`,disabled:h,onClick:()=>v(),children:`保存持续 get 设置`})]})]})]})})}var P=s,re=(e,t,n)=>y(e=>n.get(Number(e))||[],e,t);function F({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,A.useState)(!!e.blocksFollowing),[l,d]=(0,A.useState)(()=>new Set((e.blockBy||[]).map(Number))),[f,p]=(0,A.useState)(()=>new Set(o.filter(e=>(e.blockBy||[]).map(Number).includes(a)).map(i))),[m,h]=(0,A.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))&&re(i(e),a,v),b=e=>!f.has(i(e))&&re(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,j.jsxs)(`label`,{className:`mdw-dag-item`,title:n&&!m?`会造成循环依赖或与闸门约束冲突,已禁用`:void 0,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t,disabled:m||n,onChange:()=>r(i(e))}),(0,j.jsxs)(`span`,{className:`mono faint`,children:[`#`,i(e)]}),(0,j.jsx)(`span`,{className:`mdw-dag-name`,children:a})]},i(e))};return(0,j.jsx)(P,{title:`编排 · #${a} ${u(e.text)||``}`,onClose:n,busy:m,size:`md`,footer:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:m,onClick:n,children:`取消`}),(0,j.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:m,onClick:C,children:m?`保存中…`:`保存编排`})]}),children:(0,j.jsxs)(`div`,{className:`mdw-dag`,children:[(0,j.jsxs)(`label`,{className:`mdw-dag-item mdw-dag-gate`,title:`闸门:本任务未完成前,队列里排在后面的全部待领取任务都不能被领取`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:s,disabled:m,onChange:S}),(0,j.jsx)(`b`,{children:`闸门`}),(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`挡住队列里所有排在后面的待领取任务(闸门不声明上游依赖)`})]}),s?(0,j.jsxs)(`div`,{className:`mdw-dag-note`,children:[`开启时自动挡住 `,_.length,` 个后续任务`,_.length?`:${_.map(e=>`#${e}`).join(`, `)}`:`(后面已没有待领取任务)`]}):null,(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`上游依赖(我等谁完成)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时不声明上游,保存后已清空`}):null]}),(0,j.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,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsxs)(`div`,{className:`mdw-dag-sec`,children:[`下游任务(谁被我挡)`,s?(0,j.jsx)(`span`,{className:`mdw-dag-hint`,children:`—— 闸门开启时此表不生效,自动挡住全部后续`}):null]}),(0,j.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,j.jsx)(`div`,{className:`mdw-dag-note`,children:`队列里没有其他待领取任务`})}),(0,j.jsx)(`div`,{className:`mdw-dag-note`,children:`保存会同时改写相关任务的依赖(逐条落盘);勾选会成环的组合会被禁用。`})]})})}function ie(e,t){let n=Array.isArray(e)?e:[],[r,i]=(0,A.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,j.jsxs)(`span`,{className:`pager-n`,children:[`共 `,n,` `,i]}):(0,j.jsxs)(`span`,{className:`pager`,children:[(0,j.jsx)(`button`,{type:`button`,className:`pager-btn`,disabled:e<=0,onClick:()=>a(e-1),"aria-label":`上一页`,title:`上一页`,children:`‹`}),(0,j.jsxs)(`span`,{className:`pager-n`,children:[`第 `,e+1,`/`,t,` 页 · 共 `,n,` `,i]}),(0,j.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,j.jsxs)(`div`,{className:`rp-tasks`,children:[(0,j.jsxs)(`div`,{className:`rp-tasks-h`,children:[(0,j.jsx)(e,{name:t,size:13}),` `,n,r>0&&(0,j.jsxs)(`span`,{className:`rp-chip-count`,children:[`待领取 `,r]}),i]}),a,!s&&o?(0,j.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,j.jsxs)(`div`,{className:`rp-page`,children:[(0,j.jsxs)(`div`,{className:`rp-group-head`,children:[(0,j.jsxs)(`h2`,{children:[(0,j.jsx)(e,{name:r,size:15}),` `,t,n.map((e,t)=>{let n=typeof e==`string`?e:e&&e.text||``;return n?(0,j.jsx)(`span`,{className:`rp-chip-count`,children:n},t):null})]}),i?(0,j.jsx)(`div`,{className:`rp-group-acts`,children:i}):null]}),a,o,s,c,l]})}function I(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:f=[],history:m=!1,ops:h=null,searchCtx:g=null}){let v=`rp-proj-row`+(l?.dragging?` dragging`:``)+(l?.drop?` drop-`+l.drop:``),y=t.status===`pending`&&t.ready===!1;return(0,j.jsxs)(`div`,{className:v,...c?{onDragOver:c.onDragOver,onDragLeave:c.onDragLeave,onDrop:c.onDrop}:{},children:[s?(0,j.jsx)(`span`,{className:`rp-drag-handle`,draggable:!0,title:`拖动调整队列内顺序`,"aria-label":`拖动排序`,onDragStart:c?.onDragStart,onDragEnd:c?.onDragEnd,onClick:e=>e.stopPropagation(),children:(0,j.jsx)(e,{name:`grip`,size:12})}):(0,j.jsx)(`span`,{className:`rp-drag-handle off`,"aria-hidden":`true`}),i?(0,j.jsx)(`span`,{className:`rp-proj-pick`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:(0,j.jsx)(`input`,{type:`checkbox`,checked:a,onChange:()=>o?.(t.id),"aria-label":`选择任务 #${t.id}`})}):null,(0,j.jsxs)(`div`,{className:`rp-proj-task`+(m?` done`:``),role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:[(0,j.jsxs)(`span`,{className:`mono`,children:[`#`,t.id]}),n?(0,j.jsx)(`span`,{className:`rp-ptag`,title:`归属项目:${r||n}`,children:n}):null,(0,j.jsx)(`span`,{className:`rp-proj-task-tx`,children:_(t)}),t.timegoal&&(0,j.jsxs)(`span`,{className:`rp-proj-goal`,title:`时间目标 ${t.timegoal.duration}:领取即计时,未到点不许标完成`,children:[(0,j.jsx)(e,{name:`clock`,size:11}),` `,t.timegoal.duration]}),t.blocksFollowing&&(0,j.jsxs)(`span`,{className:`rp-tgate`,title:f.length?`闸门:未完成前挡住 ${f.length} 个后续任务(#${f.join(`, #`)})`:`闸门:未完成前挡住队列里排在后面的待领取任务`,children:[`闸门`,f.length?`×${f.length}`:``]}),y&&(0,j.jsx)(`span`,{className:`rp-tlock`,title:t.blockBy?.length?`等待依赖完成:#${t.blockBy.join(`, #`)}`:`被前方闸门挡住`,children:`锁定`}),d&&(0,j.jsxs)(`span`,{className:`rp-proj-times mono`,title:`创建 ${t.createdAt||`—`}${t.consumedAt?` · 领取 ${t.consumedAt}`:``}`,children:[I(t.createdAt),t.consumedAt?` → ${I(t.consumedAt)}`:``]}),(0,j.jsx)(p,{t}),h?(0,j.jsx)(`span`,{className:`rp-proj-ops`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:h}):null]}),g?(0,j.jsx)(`div`,{className:`rp-proj-task-ctx`,role:`button`,tabIndex:0,title:`打开这条任务`,onClick:()=>u?.(t),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u?.(t))},children:g.lines.map((e,t)=>(0,j.jsxs)(`div`,{className:`ctx-line`+(t===g.hitIndex?` hit`:``),children:[(0,j.jsx)(`span`,{className:`ctx-no`,children:g.hitLineNo-g.hitIndex+t}),(0,j.jsx)(`span`,{className:`ctx-tx`,children:e||`\xA0`})]},t))}):null]})}var le=20;function L({kind:t,name:n,title:r,rows:s,emptyText:c,intro:l=null,extraCounts:u=[],actionExtra:p=null,toolActs:m={},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,A.useRef)(null),[M,N]=(0,A.useState)(null),[P,re]=(0,A.useState)(``),F=!!String(P).trim(),I=(0,A.useMemo)(()=>F?s.filter(e=>f({id:e.task.id,text:e.task.text},P)):s,[s,P,F]),L=(0,A.useMemo)(()=>I.filter(e=>e.task.status===`pending`&&!e.task.migratedTo).length,[I]),R=ie(I,le);(0,A.useEffect)(()=>{R.setPage(0)},[P]);let[z,B]=(0,A.useState)(()=>new Set),V=R.items,H=V.map(e=>e.key),U=H.length>0&&H.every(e=>z.has(e));(0,A.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,ue=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=()=>{B(e=>{let t=new Set(e);return U?H.forEach(e=>t.delete(e)):H.forEach(e=>t.add(e)),t})},J=async e=>{W.length&&e&&await e(W)&&B(new Set)},Y=W.filter(e=>e.task.status===`pending`),fe=W.filter(e=>e.task.status===`plan`),pe=Y.length?Y:fe,me=Y.length?`plan`:`pending`,he=W.length?me===`plan`?`转草稿 (${Y.length})`:`转回待领取 (${fe.length})`:`草稿态`,X=(0,A.useRef)(null),[ge,Z]=(0,A.useState)(null),[Q,$]=(0,A.useState)(null),_e=(e,t)=>{let n=t.getBoundingClientRect();return e.clientY<n.top+n.height/2?`before`:`after`},ve=(e,t)=>{X.current=t.key,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,`task:`+t.task.id),Z(t.key)},ye=(e,t)=>{X.current&&t.movable&&t.key!==X.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=X.current;if(X.current=null,Z(null),$(null),!r||!t.movable||t.key===r)return;let i=s.find(e=>e.key===r);i&&y&&y(i,t,n)},Se=()=>{X.current=null,Z(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,j.jsxs)(`div`,{className:`mdw-land-batch`,children:[(0,j.jsxs)(`span`,{className:`mdw-land-batch-count`,children:[`已选 `,W.length,` 条`]}),O&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!G.length,title:G.length?`把选中的未结束任务标为已完成(补一条完成记录,原文留档)${q?`;其中 ${q} 条已被领取,会直接收口,agent 侧回执忽略`:``}`:`选中的任务都已结束,没有可标为完成的`,onClick:()=>void J(O),children:[`标为完成选中`,G.length?` (${G.length})`:``]}),D&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm`,disabled:!K.length,title:K.length?`把选中的待领取任务标为已取消(终态,原文留档)`:`只有待领取任务可以取消(已领取的交给 agent 回执)`,onClick:()=>void J(D),children:[`取消选中`,K.length?` (${K.length})`:``]}),E&&(0,j.jsxs)(`button`,{type:`button`,className:`btn ghost sm danger`,onClick:()=>void J(E),children:[`删除选中 (`,W.length,`)`]}),(0,j.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>B(new Set),children:`清空`})]}):null,Te=(0,j.jsx)(oe,{title:r,pendingCount:L,headerExtra:(0,j.jsxs)(`span`,{className:`rp-tasks-tools`,children:[(0,j.jsx)(`input`,{className:`rp-task-search`,type:`search`,value:P,placeholder:`搜索标题 / 内容`,"aria-label":`搜索任务`,onChange:e=>re(e.target.value)}),V.length?(0,j.jsxs)(`label`,{className:`rp-proj-pickall`,title:`全选/取消全选当前页`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:U,onChange:de,"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,j.jsx)(ce,{t:e.task,projectTag:e.projectTag,projectTitle:e.projectTitle,searchCtx:F?d(e.task,P):null,selectable:!0,picked:z.has(e.key),onTogglePick:()=>ue(e.key),draggable:!!e.movable,dragHandlers:t,dragVisual:{dragging:ge===e.key,drop:Q&&Q.key===e.key?Q.zone:null},showTimes:e.showTimes,downs:e.downs,onOpen:()=>v(e),ops:(0,j.jsx)(o,{items:Ce(e)})},e.key)})}),Ee=R.total>0?(0,j.jsx)(`div`,{className:`mdw-land-pager`,children:(0,j.jsx)(ae,{page:R.page,pageCount:R.pageCount,total:R.total,onPage:R.setPage,unit:`个任务`})}):null,De=e=>{N({x:e.clientX,y:e.clientY})},Oe=()=>(0,j.jsx)(`span`,{className:`rp-newtask`,children:(0,j.jsxs)(`button`,{type:`button`,className:`btn small primary`,title:`按默认模板新建一页(▾ 选模板)`,disabled:g,onClick:()=>h(),children:[`+ 新建页`,(0,j.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,j.jsx)(e,{name:`chevron`,size:11,title:void 0})})]})});return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(se,{name:n,counts:[`${F?`命中 `:``}${R.total} 个任务`,...L>0?[`待领取 ${L}`]:[],...u],intro:l,batch:we,list:Te,footer:Ee,actions:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ne,{kind:t,labels:{more:`更多`,...m.labels,plan:he},titles:{new:`按默认模板新建一页(▾ 选模板)`,import:`把一个 .md 文件导入成任务`,plan:`选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)`,...m.titles},disabled:m.disabled,renderers:{new:Oe,...m.renderers},actions:{...m.actions,new:()=>h(),import:()=>k.current?.click(),plan:()=>{if(!pe.length){te(`先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)`);return}x?.(pe,me)}}}),p]})}),M&&(0,j.jsx)(a,{x:M.x,y:M.y,items:_,onClose:()=>N(null)}),(0,j.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 R(e){return((e.text||``).split(`
|
|
2
2
|
`).find(e=>e.trim())||`#${e.id}`).replace(/^#\s*/,``)}function z(e,t){return e.key&&!e.cwd?`key=${encodeURIComponent(e.key)}&id=${Number(t)}`:`cwd=${encodeURIComponent(e.cwd||``)}&id=${Number(t)}`}function B(e){return{cwd:e.cwd}}function V(e,t,n,r){r&&v(g(h(t||e.docKey),String(n)),{body:r})}async function H(e,t){try{return await t()}catch(t){return e.toast(String(t?.message||t)),!1}}async function U(e,t,n){let{dialog:r,toast:i}=e,a=R(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 H(e,async()=>{let r=await k(z(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({...B(t),text:r,forkOf:String(n.id),forkKind:`reopen`}),u=String(o?.task?.id??o?.id??``);V(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);V(e,u?.key,d,String(u?.task?.text??``)),i(`已回写「${a}」#${d}`+(u?.moved&&u.name?`;归属迁到「${u.name}」`:``)),e.refresh?.()})}async function W(e,t,n){let{dialog:r,toast:i}=e;await r({title:`删除任务「${R(n)}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&await H(e,async()=>(await T({...t,id:n.id}),i(`已删除「${R(n)}」`),e.onDeleted?.(n),e.refresh?.(),!0))}var G=e=>e.reduce((e,t)=>e+t.ids.length,0);async function K(e,t){let n=G(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 H(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 q(e,t){let n=G(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 H(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 ue(e,t){let n=G(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 H(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 de(e,t,n){let r=!n.blocksFollowing;await H(e,()=>x({...t,id:n.id,gate:r}))&&(e.toast(r?`#${n.id} 已设为闸门——挡住所有后续待领取任务`:`#${n.id} 闸门已取消`),e.refresh?.())}async function J(e,t,n){let r=t.reduce((e,t)=>e+t.ids.length,0);r&&await H(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 Y(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{U as a,Y as c,N as d,W as i,L as l,ue as n,J as o,K as r,de as s,q as t,F 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-dBtYqEM1.js";import{D as o}from"./tool-bar-
|
|
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 k(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[_,v]=(0,S.useState)(!1),[y,b]=(0,S.useState)(``),x=e=>t.onNavigate?.(e);if(!n)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let w=n.templates||[],T=m(w,y,e=>[e.name,O(e.body),(e.scope||[]).join(` `)]),E=async(e,t)=>{if(!_){v(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{v(!1)}}},k=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await E(()=>n.remove(e.id),`已删除「${e.name}」`)};return(0,C.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(h,{variant:`primary`,small:!0,disabled:_,onClick:()=>x(`#/templates/new`),children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!w.length&&(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),w.length>1?(0,C.jsx)(`div`,{className:`tpl-search`,children:(0,C.jsx)(g,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:T.length,className:`wide`})}):null,(0,C.jsxs)(`div`,{className:`tpl-list`,children:[T.map(t=>{let r=t.id===n.defaultId,i=u===t.id,a=f===t.id;return(0,C.jsxs)(`div`,{className:`tpl-card`+(r?` is-default`:``),children:[(0,C.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,C.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,C.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,C.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>p(a?null:t.id),children:(0,C.jsx)(e,{name:`monitor`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`+(i?` is-on`:``),title:`可见范围`,disabled:_,onClick:()=>d(i?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:_,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:_,onClick:()=>E(()=>n.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:_,onClick:()=>k(t),children:(0,C.jsx)(e,{name:`trash`,size:14})})]})]}),(0,C.jsx)(`div`,{className:`tpl-card-sum`,children:O(t.body)||`(空模板)`}),i&&(0,C.jsx)(`div`,{className:`tpl-card-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>n.update(t.id,{scope:e})})}),a&&(0,C.jsx)(`div`,{className:`tpl-preview`,children:(0,C.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:c(t.body)}})})]},t.id)}),w.length&&!T.length?(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function A({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,S.useMemo)(()=>x(t?.id),[t?.id]),c=y(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,_]=(0,S.useState)(null),[w,T]=(0,S.useState)(null),[E,O]=(0,S.useState)(!1),k=c.templates||[],A=m(k,l,e=>[e.name,e.body,(e.scope||[]).join(` `)]),j=async(e,t)=>{if(!E){O(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{O(!1)}}},M=async(e,t)=>{if(e===t)return;let n=k.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 j(()=>i.reorder(n)))},N=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];b(async()=>{let{openTemplateEditor:e}=await import(`./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-GSk_7QV5.js","assets/popup-dBtYqEM1.js","assets/popup-BAvk7J7u.css","assets/tool-bar-DpfJRjFG.js","assets/tool-bar-CLIs9Dr0.css","assets/repo-form-modal-DJMWkbA6.js","assets/button-Cs6w2CDi.js","assets/button-DA4lNJeC.css","assets/doc-z8eXM9dk.js","assets/app-context-CngKv8Tc.js","assets/task-status-Cjsm0xF7.js","assets/md-history-sxG54jJ_.js","assets/use-rail-drag-DcUzHeV_.js","assets/list-search-DFvFY408.js","assets/route-crumb-BKq2jry0.js","assets/board-view-C8OQhkyi.js","assets/doc-DgYKv2wo.css","assets/index-BruTRXSA.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-dBtYqEM1.js";import{D as o}from"./tool-bar-DpfJRjFG.js";import{n as s}from"./app-context-CngKv8Tc.js";import{d as c}from"./task-status-Cjsm0xF7.js";import{a as l,i as u,n as d,r as f,t as p,u as m}from"./md-history-sxG54jJ_.js";import{t as h}from"./button-Cs6w2CDi.js";import{t as g}from"./list-search-DFvFY408.js";import{n as _,t as v}from"./route-crumb-BKq2jry0.js";import{d as y,m as b}from"./index-GSk_7QV5.js";import{t as x}from"./manage-session-CS8UvmUd.js";var S=r(n(),1),C=t(),w={topic:`目录`,repo:`项目`,group:`组`};function T(){let e=s(),t=e.rows||[],n=e.repoData?.repos||[],r=e.repoData?.boards||[];return(0,S.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function E(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a=w[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function D({scope:e,onChange:t,originTopic:n=``,catalog:r,classPrefix:i=`setp`}){let o=a(),s=T(),c=r||s,[l,u]=(0,S.useState)(null),d=Array.isArray(e)?e:[],f=d.includes(`*`),p=d.filter(e=>e!==`*`),m=i,h=n?c.topicByKey.get(n)||(/^[0-9a-f]{16}$/.test(n)?`${n.slice(0,6)}…`:n):``,g=async e=>{try{await t(e)}catch(e){o(String(e.message||e))}},_=async e=>{if(d.includes(e)){o(`已经在可见范围里了`),u(null);return}await g([...d,e]),u(null)},v=(0,S.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,C.jsxs)(`div`,{className:`${m}-scope-block`,children:[(0,C.jsx)(`div`,{className:`${m}-scope`,children:d.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`${m}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>g(d.filter(t=>t!==e)),children:[E(e,c),` ×`]},e))}),(0,C.jsxs)(`div`,{className:`${m}-scope-add`,children:[(0,C.jsx)(`span`,{className:`${m}-scope-add-label`,children:`添加`}),(0,C.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`,disabled:f,title:f?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!f&&g([`*`,...p]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,C.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:w[e]},e)),h?(0,C.jsxs)(`span`,{className:`${m}-scope-origin`,title:`创建于主题 ${n}`,children:[`创建于 `,h]}):null]}),l&&(0,C.jsx)(`div`,{className:`${m}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:v.length?v.map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`${m}-scope-pick-it`,disabled:d.includes(e.entry),title:e.sub||e.entry,onClick:()=>_(e.entry),children:[(0,C.jsx)(`span`,{className:`${m}-scope-pick-name`,children:e.label}),d.includes(e.entry)?(0,C.jsx)(`span`,{className:`${m}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,C.jsx)(`div`,{className:`${m}-scope-pick-empty`,children:`暂无可选项`})})]})}function O(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 k(){let t=s(),n=t.tpl,r=a(),{dialog:o,node:l}=i(),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[_,v]=(0,S.useState)(!1),[y,b]=(0,S.useState)(``),x=e=>t.onNavigate?.(e);if(!n)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(n.unsupported)return(0,C.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,C.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let w=n.templates||[],T=m(w,y,e=>[e.name,O(e.body),(e.scope||[]).join(` `)]),E=async(e,t)=>{if(!_){v(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{v(!1)}}},k=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await E(()=>n.remove(e.id),`已删除「${e.name}」`)};return(0,C.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`新建任务时的正文骨架;正式内容在编辑页自行填写。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(h,{variant:`primary`,small:!0,disabled:_,onClick:()=>x(`#/templates/new`),children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!w.length&&(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),w.length>1?(0,C.jsx)(`div`,{className:`tpl-search`,children:(0,C.jsx)(g,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:T.length,className:`wide`})}):null,(0,C.jsxs)(`div`,{className:`tpl-list`,children:[T.map(t=>{let r=t.id===n.defaultId,i=u===t.id,a=f===t.id;return(0,C.jsxs)(`div`,{className:`tpl-card`+(r?` is-default`:``),children:[(0,C.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,C.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),(0,C.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,C.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>p(a?null:t.id),children:(0,C.jsx)(e,{name:`monitor`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`+(i?` is-on`:``),title:`可见范围`,disabled:_,onClick:()=>d(i?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:_,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:_,onClick:()=>E(()=>n.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:_,onClick:()=>k(t),children:(0,C.jsx)(e,{name:`trash`,size:14})})]})]}),(0,C.jsx)(`div`,{className:`tpl-card-sum`,children:O(t.body)||`(空模板)`}),i&&(0,C.jsx)(`div`,{className:`tpl-card-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>n.update(t.id,{scope:e})})}),a&&(0,C.jsx)(`div`,{className:`tpl-preview`,children:(0,C.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:c(t.body)}})})]},t.id)}),w.length&&!T.length?(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function A({config:t}){let n=s(),r=a(),i=n.tpl,o=(0,S.useMemo)(()=>x(t?.id),[t?.id]),c=y(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(null),[p,_]=(0,S.useState)(null),[w,T]=(0,S.useState)(null),[E,O]=(0,S.useState)(!1),k=c.templates||[],A=m(k,l,e=>[e.name,e.body,(e.scope||[]).join(` `)]),j=async(e,t)=>{if(!E){O(!0);try{await e(),t&&r(t)}catch(e){r(String(e.message||e))}finally{O(!1)}}},M=async(e,t)=>{if(e===t)return;let n=k.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 j(()=>i.reorder(n)))},N=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];b(async()=>{let{openTemplateEditor:e}=await import(`./index-GSk_7QV5.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,17])).then(({openTemplateEditor:t})=>{n.model&&t(n.model,{mode:`new`,scope:e,topic:o?.topic||``,name:``})})},P=o?.label||o?.topic||o?.group||o?.repo||`本主题`;return(0,C.jsxs)(`div`,{className:`rp-page tpl-mng-page`,children:[(0,C.jsx)(v,{}),(0,C.jsxs)(`div`,{className:`page-head`,children:[(0,C.jsxs)(`div`,{className:`title-block`,children:[(0,C.jsxs)(`h2`,{children:[(0,C.jsx)(e,{name:`gear`,size:16}),` 管理模板 · `,P]}),(0,C.jsx)(`p`,{className:`muted tpl-head-note`,children:`只显示本主题可见的模板。拖动左侧把手调整顺序,点图标改可见范围;搜索框会同步隐藏不匹配的行。`})]}),(0,C.jsx)(`div`,{className:`acts`,children:(0,C.jsxs)(h,{variant:`primary`,small:!0,disabled:E,onClick:N,children:[(0,C.jsx)(e,{name:`plus`,size:13}),` 新建模板`]})})]}),(0,C.jsx)(`div`,{className:`tpl-mng-search`,children:(0,C.jsx)(g,{value:l,onChange:u,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤本主题模板`,count:A.length,className:`wide`})}),k.length?(0,C.jsx)(`div`,{className:`tpl-mng-list`,children:A.map(t=>{let r=t.id===i?.defaultId;return(0,C.jsxs)(`div`,{className:[`tpl-mng-row`,d===t.id?`is-dragging`:``,p===t.id&&d!==t.id?`is-over`:``].filter(Boolean).join(` `),draggable:!0,onDragStart:e=>{f(t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,_(t.id)},onDrop:e=>{e.preventDefault(),_(null),d&&M(d,t.id),f(null)},onDragEnd:()=>{f(null),_(null)},children:[(0,C.jsx)(`span`,{className:`tpl-mng-grip`,title:`拖动排序`,children:(0,C.jsx)(e,{name:`grip`,size:14})}),(0,C.jsxs)(`div`,{className:`tpl-mng-main`,children:[(0,C.jsxs)(`div`,{className:`tpl-mng-line`,children:[(0,C.jsx)(`span`,{className:`tpl-mng-name`,children:t.name}),r&&(0,C.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,C.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`})]}),(t.scope||[]).length>0&&!w&&(0,C.jsxs)(`div`,{className:`tpl-mng-scope-sum muted`,children:[`可见:`,(t.scope||[]).join(` / `)]})]}),(0,C.jsxs)(`div`,{className:`tpl-mng-acts`,children:[(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`可见范围`,onClick:()=>T(w===t.id?null:t.id),children:(0,C.jsx)(e,{name:`globe`,size:14})}),(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,onClick:()=>n.onNavigate?.(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,C.jsx)(e,{name:`edit`,size:14})}),!r&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:E,onClick:()=>j(()=>i.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,C.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,C.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:E,onClick:()=>j(()=>i.remove(t.id),`已删除「${t.name}」`),children:(0,C.jsx)(e,{name:`trash`,size:14})})]}),w===t.id&&(0,C.jsx)(`div`,{className:`tpl-mng-scope`,children:(0,C.jsx)(D,{scope:t.scope,originTopic:t.originTopic,onChange:e=>i.update(t.id,{scope:e})})})]},t.id)})}):(0,C.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`本主题下没有可见模板。`})]})}var j=e=>`tpl:${e||`new`}`,M=`## 背景
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## 验收
|