epiq 1.15.2 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Index-HOECJ74Y.js +17 -0
- package/dist/{args-7BQCBFSS.js → args-5WLJ3JSM.js} +1 -1
- package/dist/chunk-5E42KQM3.js +10 -0
- package/dist/chunk-GOROXQFX.js +116 -0
- package/dist/chunk-SCSGIFUR.js +2 -0
- package/dist/gui/main.js +130 -130
- package/dist/index.js +1 -1
- package/dist/mcp.js +1 -1
- package/dist/server-JWNOKRFL.js +2 -0
- package/dist/{virtual-nodes-5IGKV5PO.js → virtual-nodes-W5WJQXFR.js} +1 -1
- package/package.json +2 -2
- package/readme.md +11 -1
- package/dist/Index-G4CUKBA2.js +0 -16
- package/dist/chunk-FDSMDDGG.js +0 -2
- package/dist/chunk-VRDQK5QD.js +0 -111
- package/dist/chunk-ZPUSANPS.js +0 -8
- package/dist/server-CMCAPC5E.js +0 -30
package/dist/chunk-ZPUSANPS.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{$b as Ge,A as kt,Aa as rt,B as Nt,Ba as de,C as Pt,Ca as Qt,D as ye,Da as ue,E as P,Ea as ne,F as Ot,Fa as Zt,G as Mt,Ga as en,H as te,Ha as S,I as Dt,J as D,K as Fe,Lb as bn,M as Re,Ma as tn,N as Ft,Na as nn,O as _t,P as tt,Pa as sn,Q as $t,Qa as on,Qb as yn,R as Wt,Ra as rn,Rb as at,S as Gt,Sa as an,Sb as Rn,T as _,Ta as ln,Ua as dn,V as Q,Va as un,W,Wa as cn,Wb as We,Xb as An,_ as C,_b as Tn,ab as it,ac as lt,b as Pe,bb as mn,c as le,ca as jt,cb as O,d as Oe,dc as dt,e as Me,ec as je,f as wt,fa as L,g as J,ga as Ut,ha as Ht,hc as F,i as St,ic as En,jc as wn,k as De,ka as zt,la as nt,lb as ce,ma as _e,mb as Te,n as ee,na as Kt,o as xt,oa as Xt,ob as me,pa as Ae,q as et,qa as $e,ra as qt,rb as pn,s as Ct,sa as Vt,sb as fn,ta as st,tb as gn,ua as ot,va as A,wa as Yt,wb as In,xa as w,xb as vn,y as Bt,ya as Jt,yb as hn,z as Lt}from"./chunk-VRDQK5QD.js";import{g as Et}from"./chunk-WUCQWBQE.js";import{b as d,c as p,d as l}from"./chunk-5RIQL7P4.js";var Ss=e=>e.payload??{},ut=e=>{let t=new Map,n={},s=new Set,o=new Set,a=new Set;for(let r of e){let{id:i,name:u}=Ss(r);if(i)switch(r.action){case"create.contributor":case"create.tag":t.set(i,u??""),s.add(i),o.delete(i);break;case"rename.contributor":u!==void 0&&s.has(i)&&!o.has(i)&&t.set(i,u);break;case"tombstone.contributor":s.has(i)&&(t.set(i,Fe),o.add(i));break;case"restore.contributor":case"restore.tag":u!==void 0&&s.has(i)&&(t.set(i,u),o.delete(i));break;case"add.board":u!==void 0&&(t.set(i,u),a.add(i));break;case"add.swimlane":u!==void 0&&(t.set(i,u),a.add(i),n[i]=u);break;case"edit.title":u!==void 0&&a.has(i)&&(t.set(i,u),i in n&&(n[i]=u));break;default:break}}return{byId:t,lanes:n}};var xs=e=>{let t=new Map,n=new Map;for(let s of e){let o=s.payload;!o?.id||!o.parent||(s.action==="move.node"&&t.set(s.id,n.get(o.id)),n.set(o.id,o.parent))}return t},xn=e=>{let t=e.payload;return e.action==="tombstone.tag"||e.action==="restore.tag"?t?.id:t?.tag},Cs=e=>{let t=new Set,n=new Map;for(let s of e){let o=s.payload,a=o?.id;a&&(s.action==="add.issue"&&t.add(a),o.parent&&n.set(a,o.parent))}return{issueIds:t,parentById:n}},Bs=(e,{issueIds:t,parentById:n})=>{let s=e.payload;if(s?.issue)return s.issue;let o=new Set,a=s?.id;for(;a!==void 0&&!o.has(a);){if(t.has(a))return a;o.add(a),a=n.get(a)}return null},Ls=new Set(["add.issue.comment","edit.issue.comment","delete.issue.comment"]),ks=e=>Ls.has(e.action)?e.payload?.id??null:null,Ns=new Set(["add.issue","move.node","close.issue","reopen.issue"]),Ps=(e,t)=>{let n=new Map;return e.map((s,o)=>{let a=t[o]??null;if(a===null)return{lane:null,laneBefore:null};let r=s.payload,i=null;if(Ns.has(s.action)&&r?.id===a&&r.parent){let u=n.get(a);u!==void 0&&u!==r.parent&&(i=u),n.set(a,r.parent)}return{lane:n.get(a)??null,laneBefore:i}})},Os=e=>{let t=new Map,n=new Map;return e.map(s=>{let{id:o,name:a}=s.payload??{};if(!o)return null;s.action==="add.board"&&t.set(o,"board"),s.action==="add.swimlane"&&t.set(o,"swimlane");let r=t.get(o);if(!r)return null;let i={kind:r,name:n.get(o)??a};return(s.action==="edit.title"||s.action.startsWith("add."))&&a!==void 0&&n.set(o,a),i})},Sn=90,Ms=e=>{let t=e.trim().split(`
|
|
3
|
-
`)[0]?.trim()??"";return t.length>Sn?`${t.slice(0,Sn).trimEnd()}\u2026`:t},Cn=({kind:e,name:t})=>t===void 0?e:`${e} "${t}"`,Ds=(e,t,n,s)=>{let{name:o,parent:a}=e.payload??{},r=Cn(t);switch(e.action){case"move.node":{if(t.kind==="board"||!a)return`Moved ${r}`;let i=n.get(a);return i?s.get(e.id)===a?`Moved ${r} within ${i}`:`Moved ${r} to ${i}`:`Moved ${r}`}case"edit.title":return o===void 0?`Renamed ${r}`:`Renamed ${r} to "${o}"`;case"delete.node":return`Deleted ${r}`;case"lock.node":return`Locked ${r}`;default:return null}},Fs=(e,t,n,s,o)=>{let a=e.payload,r=xn(e),i=e.action?En(e.action):"";if(a?.md!==void 0){let g=Ms(a.md),f=e.action==="edit.description"&&!s&&o?`${i} of ${Cn(o)}`:i;return g?`${f}: ${g}`:f}if(o&&!s){let g=Ds(e,o,t,n);if(g)return g}if(e.action==="move.node"&&a?.parent){let g=t.get(a.parent),f=s?`${w(s)} moved`:"Moved";return g?n.get(e.id)===a.parent?`${f} within ${g}`:`${f} to ${g}`:s?f:i}if(Nt(e.action))return[i,Pt(e)].filter(Boolean).join(" ");let u=r!==void 0?t.get(r)??"":a?.assignee!==void 0?t.get(a.assignee)??"":a?.email!==void 0?a.email:a?.name!==void 0?`"${a.name}"`:"";return[i,u].filter(Boolean).join(" ")},ct=(e,t)=>e?D(e,t.get(e)):null,_s=(e,t)=>{let n=e.payload;return{actor:ct(e.userId,t),tag:ct(xn(e),t),assignee:ct(n?.assignee,t)}},Bn=e=>{let t=new Map,n=new Set,s=o=>{let a=new Set,r=o;for(;r&&!a.has(r);){if(n.has(r))return r;a.add(r),r=t.get(r)}return null};return e.map(o=>{let a=o.payload,r=a?.id;if(!r)return null;o.action==="add.board"&&n.add(r);let i=o.action==="close.issue"?s(r):null,u=a.parent??a.issue;return u&&t.set(r,u),i!==null?i:n.has(r)?r:s(r)})},Ln=e=>$s.has(e),$s=new Set(["create.contributor","rename.contributor","tombstone.contributor","restore.contributor","link.contributor.user","link.contributor.email","unlink.contributor.email","connect.repo","edit.repo","disconnect.repo","create.tag","tombstone.tag","restore.tag"]),kn=(e,t)=>{let n=Bn(e);return e.filter((s,o)=>n[o]===t)},Ws=(e,t=new Map)=>{let n=new Map([...t,...ut(e).byId]),s=xs(e),o=Cs(e),a=e.map(c=>Bs(c,o)),r=Os(e),i=Ps(e,a),u=Bn(e),g=Ot(e.map(c=>te(c)));return e.flatMap((c,I)=>{let v=g[I]??null;return v===null?[]:[{id:c.id,t:v,action:c.action,label:Fs(c,n,s,a[I]??null,r[I]??null),issue:a[I]??null,target:ks(c),...i[I],board:u[I]??null,..._s(c,n)}]}).sort((c,I)=>c.t-I.t)},Gs=e=>{let t=new Map;for(let s of e){if(s.issue===null||s.lane===null)continue;let o=t.get(s.issue)??[],a=o[o.length-1];(a===void 0||a.lane!==s.lane)&&(o.push({t:s.t,lane:s.lane,board:s.board}),t.set(s.issue,o))}let n=new Map;for(let[s,o]of t){let a=o[o.length-1];n.set(s,{changes:o,from:o[0].t,closedFrom:a.lane===L?a.t:null})}return n},js=(e,t)=>{let n=0,s=e.length;for(;n<s;){let o=n+s>>1;e[o].t<t?n=o+1:s=o}return e[n-1]},Nn=(e,t,n)=>{let s={};for(let[o,a]of e){if(a.from>=t||a.closedFrom!==null&&a.closedFrom<t)continue;let r=js(a.changes,t);r===void 0||r.lane===L||n&&r.board!==n||(s[o]=r.lane)}return s},Us=e=>ut(e).lanes,Ee=null,Pn=e=>{let t=$e(e);if(Ee&&Ee.root===e&&Ee.signature===t)return p("Timeline entries, cached",Ee.index);let n=ne(e);if(l(n))return d(n.message);let s=Ws(n.value,ue(e)),o={entries:s,lanes:Gs(s),laneNames:Us(n.value)};return Ee={root:e,signature:t,index:o},p("Timeline entries, built",o)};var On=1e5,Hs=2e4,Ue=null,Mn=Promise.resolve(),Fn=e=>{let t=Mn.then(e,e);return Mn=t.then(()=>{},()=>{}),t},He=e=>{let t=Ae(e);return l(t)?t:J({repoRoot:t.value})},U=()=>{if(!je())return{mode:"live",asOfTime:null};let{timeMode:e}=Tn();return e==="live"?{mode:"live",asOfTime:null}:{mode:"scrub",asOfTime:Ue}},Dn=(e,t)=>{let n=0,s=e.length;for(;n<s;){let o=n+s>>1;e[o].t<t?n=o+1:s=o}return n},ui=async(e={})=>{let t=He(e.repoRoot);if(l(t))return d(t.message);let n=Pn(t.value);if(l(n))return d(n.message);let s=n.value.entries,o=Date.now(),a=e.end??o,r=e.start??s[0]?.t??a;if(a<=r)return p("Empty time window",{bucketMs:0,buckets:[],capped:!1,events:[],lanesAtStart:{},laneNames:n.value.laneNames,closedLane:L,earliest:r,latest:a});let i=Dn(s,r),u=Dn(s,a),g=s.slice(i,u).filter(m=>!e.boardId||m.board===e.boardId||Ln(m.action)),f=g.map(m=>m.t),c=Math.max(1,Math.ceil((a-r)/On)),I=new Map;for(let m of f){let b=Math.min(On-1,Math.floor((m-r)/c)),y=r+b*c;I.set(y,(I.get(y)??0)+1)}let v=[...I.entries()].sort(([m],[b])=>m-b).map(([m,b])=>({t:m,count:b})),h=g.length>Hs;return p("Computed event timeline",{bucketMs:c,buckets:v,capped:h,events:h?[]:g,lanesAtStart:Nn(n.value.lanes,r,e.boardId),laneNames:n.value.laneNames,closedLane:L,earliest:r,latest:a})},_n=e=>{let t=ne(e);if(l(t))return d(t.message);let n=dt();if(l(n))return d(n.message);Ue=null;let s=rt(t.value),{fatal:o,skipped:a}=st(s);return o.length>0?d(o.map(r=>r.message).join(", ")):(ot(a),lt({readOnly:!1,readOnlyReason:void 0,timeMode:"live",unappliedEvents:[],replay:null}),p("Restored live state",!0))},zs=(e,t)=>{Ue=null;let n=_n(e);return l(n)?d(`${t} (recovery to live also failed: ${n.message})`):d(t)},Ks=e=>Fn(async()=>{let t=He(e.repoRoot);if(l(t))return d(t.message);let n=Zt(t.value,e.targetTime);if(l(n))return d(n.message);let{appliedEvents:s,unappliedEvents:o}=n.value,a=dt();if(l(a))return a;let r=rt(s),{fatal:i,skipped:u}=st(r);return i.length>0?zs(t.value,i.map(g=>g.message).join(", ")):(ot(u),lt({readOnly:!0,timeMode:"peek",unappliedEvents:o,replay:null}),Ue=e.targetTime,p("Checked out historical state",{asOfTime:e.targetTime}))}),ci=async e=>{let t=He(e.repoRoot);if(l(t))return d(t.message);let n=en(t.value);if(l(n))return d(n.message);let s=n.value.get(e.eventId)??null;return s===null?d("Event not found in the log"):Ks({repoRoot:e.repoRoot,targetTime:s+1})},mi=(e={})=>Fn(async()=>{let t=He(e.repoRoot);if(l(t))return d(t.message);let n=_n(t.value);return l(n)?d(n.message):p("Returned to live state",!0)});import{ulid as Ys}from"ulid";import qs from"node:fs";var $n=new Map,Xs=3e4,Wn=async e=>{let t=$n.get(e);if(t&&Date.now()-t.readAt<Xs)return{name:t.name,email:t.email};let n=await Me({args:["config","--get-regexp","^user\\.(name|email)$"],cwd:e}),s=null,o=null;if(n.exitCode===0)for(let a of(n.stdout??"").split(`
|
|
4
|
-
`)){let r=a.indexOf(" ");if(r===-1)continue;let i=a.slice(0,r),u=a.slice(r+1);i==="user.name"&&(s=u.trim()||null),i==="user.email"&&(o=Re(u)||null)}return $n.set(e,{name:s,email:o,readAt:Date.now()}),{name:s,email:o}},Gn=async e=>(await Wn(e)).email,pe=async e=>(await Wn(e)).name;var se=e=>{let t=De(e??process.cwd());return l(t)?d(t.message):p("Resolved Epiq repo root",t.value)},ze=null,Vs=async(e,t)=>{let n=se(e);if(l(n))return n;let s=J({repoRoot:n.value});if(l(s))return d(s.message);let o=le(n.value);if(l(o))return d(o.message);if(!(ze!==null&&ze.repoRoot===n.value&&ze.stateBranchRoot===s.value&&qs.existsSync(St(s.value)))){let c=await In({repoRoot:n.value,stateBranchName:o.value});if(l(c))return d(c.message);let I=await vn({repoRoot:n.value,stateBranchRoot:s.value,stateBranchName:o.value});if(l(I))return d(I.message);ze={repoRoot:n.value,stateBranchRoot:s.value}}if(t?.pull??!1){let c=await Oe({cwd:s.value,args:["pull","--ff-only"]});l(c)&&Pe.info(3,c.message)}let r={repoRoot:n.value,stateBranchRoot:s.value},i=ee();l(i)||et(i.value),et({gitEmail:await Gn(n.value),gitName:await pe(n.value)});let u=$e(s.value);if(qt(s.value)===u&&je()&&U().mode==="live")return p("Booted Epiq state, unchanged",r);let g=de(s.value);if(l(g))return d(g.message);let f=me(g.value.events,g.value.unreadable);return l(f)?d(f.message):(Vt(s.value,u),p("Booted Epiq state",r))},G=()=>{let e=ee();return l(e)?d(e.message):e.value.userId?e.value.userName?p("Resolved actor",{userId:e.value.userId,userName:e.value.userName}):d("Unable to retrieve user name"):d("Unable to retrieve user id")},B=()=>{let e=Ge();return l(e)?d(e.message):e},M=e=>Vs(e,{pull:!1}),T=async e=>{let t=await M(e);if(l(t))return t;let n=G();if(l(n))return n;let s=B();return l(s)?s:p("Booted",{boot:t.value,actor:n.value,state:s.value})};var k=e=>{let t=B();if(l(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?d("Issue not found"):_(n)?n.readonly?d("Issue is readonly"):p("Found issue",n):d("Target must be an issue")},X=e=>{let t=B();if(l(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?d("Swimlane not found"):Q(n)?n.readonly?d("Swimlane is readonly"):p("Found swimlane",n):d("Target must be a swimlane")},we=e=>{let t=B();if(l(t))return t;let n=t.value.nodes[e];return!n||n.isDeleted?d("Board not found"):W(n)?n.readonly?d("Board is readonly"):p("Found board",n):d("Target must be a board")};var mt=e=>{if(!e)return;let t=B();if(l(t))return;let n=t.value.nodes[e];if(!n||!(W(n)||Q(n)))return;let s=n.props?.description;return s?.trim()?s:void 0},Ke=e=>{let t=mt(e);return t?{laneDescription:t}:{}},Se=e=>{let t=mt(e);return t?{boardDescription:t}:{}},fe=e=>{let t=mt(e);return t?{description:t}:{}},Xe=({node:e,label:t,max:n,description:s,actor:o,stateBranchRoot:a})=>{let r=mn(s),i=O(t,r,n);if(i)return d(i);if(U().mode!=="live")return d(`Cannot edit the ${t.toLowerCase()} while time travelling`);let u={id:e.id,ref:w(e.id),description:r};if((e.props?.description??"")===r)return p("No changes made",u);let g={id:Ys(),...A(o),action:"edit.description",payload:{id:e.id,md:r}},f=S([g],a);return l(f)?d(f.message):p(`Edited ${t.toLowerCase()}`,u)},Js=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=we(e.boardId);return l(n)?n:Xe({node:n.value,label:"Board description",max:it("board"),description:e.description,actor:t.value.actor,stateBranchRoot:t.value.boot.stateBranchRoot})},Qs=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=X(e.swimlaneId);return l(n)?n:Xe({node:n.value,label:"Swimlane description",max:it("swimlane"),description:e.description,actor:t.value.actor,stateBranchRoot:t.value.boot.stateBranchRoot})};import Zs from"node:fs";import eo from"node:path";import{ulid as pt}from"ulid";var to=e=>{if(e.filePath)try{return p("Read attachment file",{data:Zs.readFileSync(e.filePath),name:e.name??eo.basename(e.filePath)})}catch(t){return d(`Unable to read ${e.filePath}: ${t instanceof Error?t.message:String(t)}`)}return e.dataBase64?p("Decoded attachment data",{data:Buffer.from(e.dataBase64,"base64"),name:e.name??"image"}):d("Provide either filePath or dataBase64")},qe=()=>{let e=ee();return l(e)?nt:e.value.attachmentMaxKb??nt},no=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);if(l(n))return n;let s=to(e);if(l(s))return s;let o=Kt(t.value.boot.stateBranchRoot,s.value.data,qe());if(l(o))return o;let a=C(s.value.name).trim()||"image",r=pt(),i={id:pt(),...A(t.value.actor),action:"add.issue.attachment",payload:{id:r,issue:e.issueId,author:t.value.actor.userId,hash:o.value.hash,ext:o.value.ext,name:a,bytes:o.value.bytes}},u=S([i],t.value.boot.stateBranchRoot);if(l(u))return d(u.message);let g=_e(o.value.hash,o.value.ext);return p("Added issue attachment",{id:r,issueId:e.issueId,fileName:g,bytes:o.value.bytes,markdown:zt(a,g)})},so=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.eventLog.find(i=>i.action==="add.issue.attachment"&&i.payload.id===e.attachmentId);if(!n)return d("Unable to resolve attachment");if(n.payload.author!==t.value.actor.userId)return d("You can only delete your own attachments");let s=k(n.payload.issue);if(l(s))return s;if(t.value.state.eventLog.some(i=>i.action==="delete.issue.attachment"&&i.payload.id===e.attachmentId))return p("Attachment already deleted",{id:e.attachmentId,issueId:n.payload.issue});let a={id:pt(),...A(t.value.actor),action:"delete.issue.attachment",payload:{id:e.attachmentId,issue:n.payload.issue}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):p("Deleted issue attachment",{id:e.attachmentId,issueId:n.payload.issue})},oo=async e=>{let t=await M(e.repoRoot);return l(t)?t:Xt(t.value.stateBranchRoot,e.fileName,qe())};var ro=e=>{switch(e.action){case"add.issue":case"move.node":case"close.issue":case"reopen.issue":return e.payload.parent;default:return null}},ft=(e,t)=>{let n=[];for(let s of e){let o=ro(s);if(o===null||o===n.at(-1)?.laneId)continue;let a=te(s);n.push({laneId:o,enteredAt:a===null?t:ye(a)})}return n},jn=(e,t)=>e.reduce((n,s)=>{let o=te(s);return o===null?n:Math.max(n,ye(o))},t),xe=(e,t)=>ft(e,t).at(-1)?.enteredAt??t;var Un=new WeakMap,io=e=>{let t=F.getNode(e);if(!t)return[];let n=Un.get(t);if(n)return n;let s=new Set;t.parentNodeId&&s.add(t.parentNodeId);for(let a of t.log??[]){let r=a.payload;r.id===e&&r.parent&&s.add(r.parent)}let o=[...s];return Un.set(t,o),o},Ce=e=>{let t=new Set;e.parentNodeId&&t.add(e.parentNodeId);for(let s of e.log??[]){let o=s.payload;o.id===e.id&&o.parent&&t.add(o.parent)}let n=new Set;for(let s of t)for(let o of io(s))n.add(o);return[...n]},oe=e=>Ut(e).map(t=>D(t.id,t.name)),Hn=e=>F.getCommentsByIssue(e).sort((t,n)=>t.id<n.id?-1:t.id>n.id?1:0).map(t=>({id:t.id,author:Dt(t.authorId,F.getContributor(t.authorId)?.name),createdAt:P(t.id),body:t.md})),re=e=>Ht(e).map(({id:t,name:n})=>D(t,n));var ao=async(e={})=>{let t=await M(e.repoRoot);if(l(t))return t;let n=B();return l(n)?n:p("Retrieved Epiq state",{root:t.value.repoRoot,stateBranchRoot:t.value.stateBranchRoot,nodes:n.value.nodes,rootNodeId:n.value.rootNodeId,contextNode:n.value.contextNode,selectedIndex:n.value.selectedIndex,eventLog:n.value.eventLog})},lo=365*24*60*60*1e3,uo=e=>{let t=B();if(l(t))return t;let n=t.value.nodes[e];return p("Issue description",n&&_(n)&&!n.isDeleted?n.props.description??"":"")},gt=()=>{let e=B();if(l(e))return e;let t=U(),n=t.mode!=="live",s=Object.values(e.value.nodes),o=s.filter(m=>W(m)&&!m.isDeleted),a=Date.now()-lo,r=new Map,i=new Map;for(let m of s)if(!m.isDeleted){if(Q(m)&&m.parentNodeId){let b=r.get(m.parentNodeId)??[];b.push(m),r.set(m.parentNodeId,b)}if(_(m)&&m.parentNodeId){if(m.parentNodeId===L&&P(m.id)<a)continue;let b=i.get(m.parentNodeId)??[];b.push(m),i.set(m.parentNodeId,b)}}let u=new Set;for(let m of i.values())for(let b of m)u.add(b.id);let g=ee();if(l(g))return g;let f={},c=F.getCommentsGroupedByIssue();for(let m of s.filter(_))m.isDeleted||!u.has(m.id)||(f[m.id]=(c.get(m.id)??[]).map(b=>{let y=F.getContributor(b.authorId);return{id:b.id,issueId:b.issue,body:b.md,author:D(b.authorId,y?.name),createdAt:P(b.id)}}));let I=new Map;for(let m of e.value.eventLog)m.action==="add.issue.attachment"&&I.set(m.payload.id,m.payload.author);let v={},h=F.getAttachmentsGroupedByIssue();for(let m of s.filter(_))m.isDeleted||!u.has(m.id)||(v[m.id]=(h.get(m.id)??[]).map(b=>({id:b.id,issueId:b.issue,name:b.name,fileName:_e(b.hash,b.ext),bytes:b.bytes,createdAt:P(b.id),canDelete:I.get(b.id)===g.value.userId})));return p("Retrieved Epiq GUI state",{boards:o.sort((m,b)=>m.rank.localeCompare(b.rank)).map(m=>({id:m.id,ref:w(m.id),title:m.title,readonly:!!m.readonly||n,...fe(m.id),swimlanes:(r.get(m.id)??[]).sort((b,y)=>b.rank.localeCompare(y.rank)).map(b=>({id:b.id,title:b.title,readonly:!!b.readonly||n,issues:(i.get(b.id)??[]).sort((y,V)=>y.rank.localeCompare(V.rank)).map(y=>({id:y.id,ref:w(y.id),title:C(y.title),description:y.props.description??"",createdAt:P(y.id),enteredLaneAt:xe(y.log??[],P(y.id)),lastEventAt:jn(y.log??[],P(y.id)),readonly:!!y.readonly||n,tags:oe(y),assignees:re(y),parentNodeId:y.parentNodeId,isClosed:y.parentNodeId===L,boardIds:Ce(y)})),parentNodeId:b.parentNodeId,...fe(b.id)}))})),tags:F.getTags().map(m=>({...m,...D(m.id,m.name)})),contributors:Object.values(e.value.contributors).map(m=>({...m,...D(m.id,m.name)})),user:{id:g.value.userId??"",name:g.value.userName??"",color:Ct(g.value.userName??"")},commentsByIssueId:f,attachmentsByIssueId:v,attachmentMaxKb:qe(),timeTravel:t})},zn=null,co=e=>{if(e===zn)return;let t=jt({root:e});if(l(t)){Pe.info(t.message);return}zn=e},mo=async(e={})=>{if(U().mode!=="live")return gt();let t=await M(e.repoRoot);return l(t)?t:(co(t.value.repoRoot),gt())},po=async(e={})=>{pn();let t=se(e.repoRoot);if(l(t))return d("Sync failed");let n=G();if(l(n))return n;let s=await hn({cwd:t.value,ownEventFileName:Yt(n.value)});return l(s)?(gn(s.message),s):(fn(),p("Synced",s.value))};import{ulid as H}from"ulid";var Be=e=>{let t=[...new Set([...e.issueIds??[],...e.issueId?[e.issueId]:[]])];return t.length?p("Resolved targets",t):d("Provide issueId or issueIds")},ge=(e,t)=>{let n=t.done.length,s=`${e} ${n} issue${n===1?"":"s"}`+(t.failed.length?`, ${t.failed.length} failed`:"");return n?p(s,t):d(`${s}: ${t.failed.map(o=>`${o.ref} ${o.reason}`).join("; ")}`)},Le=(e,t)=>{let n={done:[],failed:[]};for(let s of e){let o=t(s);l(o)?n.failed.push({id:s,ref:w(s),reason:o.message}):n.done.push({id:s,ref:w(s)})}return n};var fo=async e=>{let t=await M(e.repoRoot);if(l(t))return t;let n=B();if(l(n))return n;let s=e.idOrRef.trim();if(!s)return d("Provide an issue id or ref");let o=Object.values(n.value.nodes).filter(_).filter(u=>!u.isDeleted),a=o.find(u=>u.id===s),r=a?[a]:o.filter(u=>Jt(u.id,s));if(r.length===0)return d(`No issue matches "${s}"`);if(r.length>1)return d(`"${s}" matches ${r.length} issues: ${r.map(u=>`${w(u.id)} (${C(u.title)})`).join(", ")}. Use a full ref or id.`);let i=r[0];return p("Found issue",{id:i.id,ref:w(i.id),title:C(i.title),description:i.props.description??"",createdAt:P(i.id),enteredLaneAt:xe(i.log??[],P(i.id)),parentNodeId:i.parentNodeId,isClosed:i.parentNodeId===L,boardIds:Ce(i),readonly:!!i.readonly,tags:oe(i),assignees:re(i),comments:Hn(i.id),...Ke(i.parentNodeId)})},qn=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();async function go(e){let t=await M(e.repoRoot);if(l(t))return t;let n=B();if(l(n))return n;let s=n.value.nodes,o=e.query?.trim().toLowerCase(),a=Object.values(s).filter(_).filter(i=>!i.isDeleted).filter(i=>e.includeClosed||i.parentNodeId!==L).filter(i=>e.boardId?(i.parentNodeId?s[i.parentNodeId]:void 0)?.parentNodeId===e.boardId:!0).filter(i=>!e.swimlaneId||i.parentNodeId===e.swimlaneId).filter(i=>!e.tag||oe(i).some(u=>qn(u.name,e.tag))).filter(i=>!e.assignee||re(i).some(u=>qn(u.name,e.assignee))).filter(i=>!o||i.title.toLowerCase().includes(o)||(i.props.description??"").toLowerCase().includes(o)),r=i=>C((i.parentNodeId?s[i.parentNodeId]?.title:void 0)??"");return e.brief?p("Listed issues",a.map(i=>({id:i.id,ref:w(i.id),title:C(i.title),swimlane:r(i),tags:oe(i).map(u=>u.name),assignees:re(i).map(u=>u.name)}))):p("Listed issues",a.map(i=>({id:i.id,ref:w(i.id),title:C(i.title),description:i.props.description??"",createdAt:P(i.id),enteredLaneAt:xe(i.log??[],P(i.id)),parentNodeId:i.parentNodeId,isClosed:i.parentNodeId===L,boardIds:Ce(i),readonly:!!i.readonly,tags:oe(i),assignees:re(i)})))}var Io=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=C(e.title);if(!n)return d("Issue title cannot be empty");let s=e.description??"",o=O("Issue title",n,300)??O("Issue description",s,2e4);if(o)return d(o);if((e.tagNames?.length??0)>20)return d(`Cannot set more than ${20} tags at once`);if((e.assigneeNames?.length??0)>20)return d(`Cannot set more than ${20} assignees at once`);let a=X(e.parentId);if(l(a))return a;let r=Te(e.parentId,t.value.actor,t.value.boot.stateBranchRoot);if(l(r))return r;let i=bn({name:n,parent:e.parentId,user:t.value.actor,rank:r.value});if(l(i))return i;let u=[...i.value],g=u.find(v=>v.action==="add.issue")?.payload.id;if(!g)return d("Unable to determine created issue id");s&&u.push({id:H(),...A(t.value.actor),action:"edit.description",payload:{id:g,md:s}});let f=[];for(let v of e.tagNames??[]){let h=C(v).trim();if(!h||f.some(V=>V.name===h))continue;let m=O("Tag name",h,60);if(m)return d(m);let b=F.findTagByName(h),y=b?.id??H();b||u.push({id:H(),...A(t.value.actor),action:"create.tag",payload:{id:y,name:h}}),u.push({id:H(),...A(t.value.actor),action:"add.issue.tag",payload:{id:g,tag:y}}),f.push({id:y,name:h})}let c=[];for(let v of e.assigneeNames??[]){let h=C(v).trim();if(!h||c.some(V=>V.name===h))continue;let m=O("Assignee name",h,80);if(m)return d(m);let b=Object.values(t.value.state.contributors).find(V=>V.name===h),y=b?.id??H();b||u.push({id:H(),...A(t.value.actor),action:"create.contributor",payload:{id:y,name:h}}),u.push({id:H(),...A(t.value.actor),action:"add.issue.assignee",payload:{id:g,assignee:y}}),c.push({id:y,name:h})}let I=S(u,t.value.boot.stateBranchRoot);return l(I)?d(I.message):p("Created issue",{id:g,ref:w(g),title:n,parentId:e.parentId,description:s,tags:f,assignees:c,...Ke(e.parentId),...Se(t.value.state.nodes[e.parentId]?.parentNodeId)})},vo=(e,t,n)=>{let s=k(e);if(l(s))return s;let o=ce(L,e,{at:"end"},t,n);if(l(o))return o;let a={id:H(),...A(t),action:"close.issue",payload:{id:e,parent:L,rank:o.value}},r=S([a],n);return l(r)?d(r.message):p("Closed issue",{id:e,ref:w(e)})};async function ho(e){let t=await M(e.repoRoot);if(l(t))return t;let n=G();if(l(n))return n;let s=Be(e);if(l(s))return s;let o=a=>vo(a,n.value,t.value.stateBranchRoot);return e.issueIds?ge("Closed",Le(s.value,o)):o(s.value[0])}var bo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.nodes[e.issueId];if(!n||n.isDeleted)return d("Issue not found");if(!_(n))return d("Target must be an issue");if(n.parentNodeId!==L)return d("Issue is not closed");let s=yn(n);if(!s)return d("Unable to resolve previous parent from issue history");if(s===L)return d("Previous parent resolves to closed swimlane");let o=X(s);if(l(o))return o;let a=o.value,r=ce(a.id,n.id,{at:"end"},t.value.actor,t.value.boot.stateBranchRoot);if(l(r))return r;let i={id:H(),...A(t.value.actor),action:"reopen.issue",payload:{id:n.id,parent:a.id,rank:r.value}},u=S([i],t.value.boot.stateBranchRoot);return l(u)?d(u.message):p("Reopened issue",{id:n.id,ref:w(n.id),parentId:a.id})},yo=(e,t,n,s)=>{let o=k(e);if(l(o))return o;let a=X(t.parentId);if(l(a))return a;let r=ce(t.parentId,e,t.position??{at:"end"},n,s);if(l(r))return r;let i={id:H(),...A(n),action:"move.node",payload:{id:e,parent:t.parentId,rank:r.value}},u=S([i],s);return l(u)?d(u.message):p("Moved issue",{id:e,ref:w(e),parentId:t.parentId})};async function Ro(e){let t=se(e.repoRoot);if(l(t))return t;let n=G();if(l(n))return n;let s=J({repoRoot:t.value});if(l(s))return s;let o=de(s.value);if(l(o))return o;let a=me(o.value.events,o.value.unreadable);if(l(a))return a;let r=Be(e);if(l(r))return r;let i=(()=>{let f=B();if(l(f))return()=>({});let{nodes:c}=f.value,I=m=>m?c[m]?.parentNodeId:void 0,v=I(e.parentId),h=r.value.some(m=>I(c[m]?.parentNodeId)!==v);return()=>({...Ke(e.parentId),...h?Se(v):{}})})(),u=f=>yo(f,e,n.value,s.value);if(!e.issueIds){let f=u(r.value[0]);return l(f)?f:p(f.message,{...f.value,...i()})}let g=ge("Moved",Le(r.value,u));return l(g)?g:p(g.message,{...g.value,...i()})}var Ao=e=>{let t=B();if(l(t))return t;let n=t.value.nodes[e];return n?p("Read issue history",(n.log??[]).map(s=>({id:s.id,t:P(s.id),action:s.action,label:wn(s),...s.action==="move.node"?{parentId:s.payload.parent}:{},actor:D(s.userId,t.value.contributors[s.userId]?.name)}))):d("Issue not found")},To=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);return l(n)?n:Xe({node:n.value,label:"Issue description",max:2e4,description:e.description,actor:t.value.actor,stateBranchRoot:t.value.boot.stateBranchRoot})},Eo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);if(l(n))return n;let s=n.value,o=C(e.title);if(!o.trim())return d("Issue title cannot be empty");let a=O("Issue title",o,300);if(a)return d(a);if(s.title===o)return p("No changes made",{id:e.issueId,ref:w(e.issueId),title:o});let r={id:H(),...A(t.value.actor),action:"edit.title",payload:{id:e.issueId,name:o}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):p("Edited issue title",{id:e.issueId,ref:w(e.issueId),title:o})};import{ulid as Z}from"ulid";var wo=async(e={})=>{let t=await M(e.repoRoot);if(l(t))return t;let n=B();if(l(n))return n;let s=Object.values(n.value.nodes).filter(o=>o.context==="BOARD"&&!o.isDeleted).map(o=>({id:o.id,ref:w(o.id),title:o.title,parentId:o.parentNodeId,readonly:!!o.readonly,...fe(o.id)}));return p("Listed boards",s)},So=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.nodes[t.value.state.rootNodeId];if(!n)return d("Workspace not found");if(U().mode!=="live")return d("Cannot add a board while time travelling");let s=C(e.title);if(!s.trim())return d("Board title cannot be empty");let o=O("Board title",s,300);if(o)return d(o);let a=Te(n.id,t.value.actor,t.value.boot.stateBranchRoot);if(l(a))return a;let r=Z(),i={id:Z(),...A(t.value.actor),action:"add.board",payload:{id:r,name:s,parent:n.id,rank:a.value}},u=S([i],t.value.boot.stateBranchRoot);return l(u)?d(u.message):p("Created board",{id:r,ref:w(r),title:s})},xo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.nodes[e.boardId];if(!n||n.isDeleted)return d("Board not found");if(!W(n))return d("Edit target must be a board");if(n.readonly)return d("Cannot edit readonly board");if(U().mode!=="live")return d("Cannot rename a board while time travelling");let s=C(e.title);if(!s.trim())return d("Board title cannot be empty");let o=O("Board title",s,300);if(o)return d(o);if(n.title===s)return p("No changes made",{id:e.boardId,ref:w(e.boardId),title:s});let a={id:Z(),...A(t.value.actor),action:"edit.title",payload:{id:e.boardId,name:s}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):p("Edited board title",{id:e.boardId,ref:w(e.boardId),title:s})},Co=async(e={})=>{let t=await M(e.repoRoot);if(l(t))return t;let n=B();if(l(n))return n;let s=Object.values(n.value.nodes).filter(o=>o.context==="SWIMLANE"&&!o.isDeleted).filter(o=>!e.boardId||o.parentNodeId===e.boardId).map(o=>({id:o.id,title:o.title,boardId:o.parentNodeId,isClosed:o.id===L,readonly:!!o.readonly,...fe(o.id)}));return p("Listed swimlanes",s)},Bo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=we(e.boardId);if(l(n))return n;if(U().mode!=="live")return d("Cannot add a swimlane while time travelling");let s=C(e.title);if(!s.trim())return d("Swimlane title cannot be empty");let o=O("Swimlane title",s,300);if(o)return d(o);let a=Te(e.boardId,t.value.actor,t.value.boot.stateBranchRoot);if(l(a))return a;let r=Z(),i={id:Z(),...A(t.value.actor),action:"add.swimlane",payload:{id:r,name:s,parent:e.boardId,rank:a.value}},u=S([i],t.value.boot.stateBranchRoot);return l(u)?d(u.message):p("Created swimlane",{id:r,ref:w(r),title:s,boardId:e.boardId})},Lo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=X(e.swimlaneId);if(l(n))return n;let s=n.value,o=C(e.title);if(!o.trim())return d("Swimlane title cannot be empty");let a=O("Swimlane title",o,300);if(a)return d(a);if(s.title===o)return p("No changes made",{id:e.swimlaneId,ref:w(e.swimlaneId),title:o});let r={id:Z(),...A(t.value.actor),action:"edit.title",payload:{id:e.swimlaneId,name:o}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):p("Edited swimlane title",{id:e.swimlaneId,ref:w(e.swimlaneId),title:o})},ko=async e=>{let t=se(e.repoRoot);if(l(t))return t;let n=G();if(l(n))return n;let s=J({repoRoot:t.value});if(l(s))return s;let o=de(s.value);if(l(o))return o;let a=me(o.value.events,o.value.unreadable);if(l(a))return a;let r=X(e.swimlaneId);if(l(r))return r;let i=we(e.boardId);if(l(i))return i;let u=ce(e.boardId,e.swimlaneId,e.position??{at:"end"},n.value,s.value);if(l(u))return u;let g={id:Z(),...A(n.value),action:"move.node",payload:{id:e.swimlaneId,parent:e.boardId,rank:u.value}},f=S([g],s.value);return l(f)?d(f.message):p("Moved swimlane",{id:e.swimlaneId,ref:w(e.swimlaneId),boardId:e.boardId})},No=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=X(e.swimlaneId);if(l(n))return n;let s={id:Z(),...A(t.value.actor),action:"delete.node",payload:{id:e.swimlaneId}},o=S([s],t.value.boot.stateBranchRoot);return l(o)?d(o.message):p("Deleted swimlane",{id:e.swimlaneId,ref:w(e.swimlaneId)})};import{ulid as Ie}from"ulid";async function Po(e){let t=await M(e.repoRoot);if(l(t))return t;let n=G();if(l(n))return n;let s=Be(e);if(l(s))return s;let o=C(e.tagName).trim();if(!o)return d("Tag name cannot be empty");let a=O("Tag name",o,60);if(a)return d(a);let r=Le(s.value,k);if(!e.issueIds&&r.failed[0])return d(r.failed[0].reason);if(r.done.length===0)return d(ge("Tagged",r).message);let i=F.findTagByName(o),u=i?.id??Ie(),g=[...i?[]:[{id:Ie(),...A(n.value),action:"create.tag",payload:{id:u,name:o}}],...r.done.map(({id:v})=>({id:Ie(),...A(n.value),action:"add.issue.tag",payload:{id:v,tag:u}}))],f=S(g,t.value.stateBranchRoot);if(l(f))return d(f.message);let c={id:u,name:o};if(!e.issueIds)return p("Added issue tag",{...r.done[0],tag:c});let I=ge("Tagged",r);return l(I)?I:p(I.message,{...I.value,tag:c})}var Oo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.tags[e.tagId];if(!n)return d("Tag not found");if(n.tombstoned)return d("Tag is already deleted");let s=[{id:Ie(),...A(t.value.actor),action:"tombstone.tag",payload:{id:e.tagId}}],o=S(s,t.value.boot.stateBranchRoot);return l(o)?d(o.message):p("Deleted tag",{id:n.id,name:n.name})},Mo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.tags[e.tagId];if(!n)return d("Tag not found");if(!n.tombstoned)return d("Tag is not deleted");if(F.findTagByName(n.name))return d(`Cannot restore: another tag is already named "${n.name}"`);let s=[{id:Ie(),...A(t.value.actor),action:"restore.tag",payload:{id:e.tagId,name:n.name}}],o=S(s,t.value.boot.stateBranchRoot);return l(o)?d(o.message):p("Restored tag",{id:n.id,name:n.name})},Do=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);if(l(n))return n;if(!t.value.state.tags[e.tagId])return d("Tag not found");let s={id:Ie(),...A(t.value.actor),action:"remove.issue.tag",payload:{id:e.issueId,tag:e.tagId}},o=S([s],t.value.boot.stateBranchRoot);return l(o)?d(o.message):p("Removed issue tag",{id:e.issueId,ref:w(e.issueId),tagId:e.tagId})};import{ulid as Y}from"ulid";var Fo=async e=>{let t=Et(e.name,"name");if(l(t))return d(t.message);let n=await T(e.repoRoot);if(l(n))return n;let s=n.value.actor,o=!!n.value.state.contributors[s.userId];if(!o){let r=S([{id:Y(),...A(s),action:"create.contributor",payload:{id:s.userId,name:s.userName}}],n.value.boot.stateBranchRoot);if(l(r))return d(r.message)}let a=Object.values(n.value.state.nodes).filter(r=>W(r)&&!r.isDeleted).flatMap(r=>{let{boardDescription:i}=Se(r.id);return i?[{id:r.id,title:C(r.title),boardDescription:i}]:[]});return p(`Assumed ${s.userName}`,{...s,registered:!o,...a.length?{boards:a}:{}})},Yn=async(e,t)=>{let n=ue(e).get(t);return n===void 0?void 0:{id:t,name:n}},_o=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);if(l(n))return n;let s=e.self?t.value.actor.userId:e.assigneeId;if(s){let v=t.value.state.contributors[s],h=v?void 0:await Yn(t.value.boot.stateBranchRoot,s);if(!v&&!h)return d("Unknown assignee id");let m=v??h,b=[...v?[]:[{id:Y(),...A(t.value.actor),action:"create.contributor",payload:{id:m.id,name:m.name}}],{id:Y(),...A(t.value.actor),action:"add.issue.assignee",payload:{id:e.issueId,assignee:m.id}}],y=S(b,t.value.boot.stateBranchRoot);return l(y)?d(y.message):p("Added issue assignee",{id:e.issueId,ref:w(e.issueId),assignee:{id:m.id,name:m.name}})}let o=C(e.assigneeName??"").trim();if(!o)return d("Provide assigneeId, self or assigneeName");let a=O("Assignee name",o,80);if(a)return d(a);let r=at({events:t.value.state.eventLog??[],registry:t.value.state.contributors,logFileNames:ue(t.value.boot.stateBranchRoot)}).filter(v=>v.name===o);if(r.length>1)return d(`"${o}" matches ${r.length} contributors (${r.map(({id:v})=>v).join(", ")}). Assign by assigneeId to choose.`);let i=r[0];if(!i&&!e.createUnlinked)return d(`No contributor named "${o}". Assign by id, or pass createUnlinked to add them as an external assignee.`);let u=i?.id??Y(),g=i?.name??o,c=[...!!t.value.state.contributors[u]?[]:[{id:Y(),...A(t.value.actor),action:"create.contributor",payload:{id:u,name:g}}],{id:Y(),...A(t.value.actor),action:"add.issue.assignee",payload:{id:e.issueId,assignee:u}}],I=S(c,t.value.boot.stateBranchRoot);return l(I)?d(I.message):p("Added issue assignee",{id:e.issueId,ref:w(e.issueId),assignee:{id:u,name:g}})},$o=async e=>{let t=await T(e.repoRoot);if(l(t))return t;if(!t.value.state.contributors[e.contributorId])return d("Contributor not found");if(await Yn(t.value.boot.stateBranchRoot,e.contributorId))return d("Cannot remove a contributor who has authored events \u2014 their name appears throughout the log");let o=[{id:Y(),...A(t.value.actor),action:"tombstone.contributor",payload:{id:e.contributorId}}],a=S(o,t.value.boot.stateBranchRoot);return l(a)?d(a.message):p("Tombstoned contributor",{id:e.contributorId,name:Fe})},Wo=async(e,t)=>{let n=ne(e);if(l(n))return;let s;for(let o of n.value){if(o.action!=="create.contributor")continue;let a=o.payload;a.id===t&&a.name&&(s=a.name)}return s},Go=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.contributors[e.contributorId];if(!n)return d("Contributor not found");if(!n.tombstoned)return d("Contributor is not tombstoned");let s=await Wo(t.value.boot.stateBranchRoot,e.contributorId);if(!s)return d("Cannot restore this contributor \u2014 no original name found in the event log");let o=[{id:Y(),...A(t.value.actor),action:"restore.contributor",payload:{id:e.contributorId,name:s}}],a=S(o,t.value.boot.stateBranchRoot);return l(a)?d(a.message):p("Restored contributor",{id:e.contributorId,name:s})},jo=async(e={})=>{let t=await T(e.repoRoot);if(l(t))return t;let n=ne(t.value.boot.stateBranchRoot);if(l(n))return d(n.message);let s=e.boardId?kn(n.value,e.boardId):n.value,o=new Set,a=Qt(t.value.boot.stateBranchRoot);if(l(a))return d(a.message);for(let u of a.value)u.userId&&o.add(u.userId);let r=t.value.state.contributors,i=at({events:s,registry:r,logFileNames:ue(t.value.boot.stateBranchRoot)}).map(({id:u,name:g,isExternal:f})=>({...D(u,g),isSelf:u===t.value.actor.userId,isExternal:f,isRemoved:r[u]?.tombstoned===!0,hasAuthoredAnywhere:o.has(u)}));return p("Listed board contributors",i)},Uo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);if(l(n))return n;if(!t.value.state.contributors[e.assigneeId])return d("Assignee not found");let s={id:Y(),...A(t.value.actor),action:"remove.issue.assignee",payload:{id:e.issueId,assignee:e.assigneeId}},o=S([s],t.value.boot.stateBranchRoot);return l(o)?d(o.message):p("Removed issue assignee",{id:e.issueId,ref:w(e.issueId),assigneeId:e.assigneeId})};import{ulid as Ye}from"ulid";var Ho=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=k(e.issueId);if(l(n))return n;let s=e.body.trim();if(!s)return d("Comment cannot be empty");if(s.length>4e3)return d(`Comment cannot exceed ${4e3} characters (got ${s.length})`);let o=Ye(),a={id:Ye(),...A(t.value.actor),action:"add.issue.comment",payload:{id:o,issue:e.issueId,md:s,author:t.value.actor.userId}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):p("Added issue comment",{id:o,issueId:e.issueId,body:s})},zo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.eventLog.find(i=>i.action==="add.issue.comment"&&i.payload.id===e.commentId);if(!n)return d("Unable to resolve comment");if(n.payload.author!==t.value.actor.userId)return d("You can only delete your own comments");let s=k(n.payload.issue);if(l(s))return s;if(t.value.state.eventLog.some(i=>i.action==="delete.issue.comment"&&i.payload.id===e.commentId))return p("Comment already deleted",{id:e.commentId,issueId:n.payload.issue});let a={id:Ye(),...A(t.value.actor),action:"delete.issue.comment",payload:{id:e.commentId,issue:n.payload.issue}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):p("Deleted issue comment",{id:e.commentId,issueId:n.payload.issue})},Ko=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=t.value.state.eventLog.find(u=>u.action==="add.issue.comment"&&u.payload.id===e.commentId);if(!n)return d("Unable to resolve comment");if(n.payload.author!==t.value.actor.userId)return d("You can only edit your own comments");let s=k(n.payload.issue);if(l(s))return s;if(t.value.state.eventLog.some(u=>u.action==="delete.issue.comment"&&u.payload.id===e.commentId))return d("Comment was deleted");let a=e.body.trim();if(!a)return d("Comment cannot be empty");if(a.length>4e3)return d(`Comment cannot exceed ${4e3} characters (got ${a.length})`);let r={id:Ye(),...A(t.value.actor),action:"edit.issue.comment",payload:{id:e.commentId,issue:n.payload.issue,md:a}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):p("Edited issue comment",{id:e.commentId,issueId:n.payload.issue,body:a})};import{ulid as Jn}from"ulid";var Xo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;if(!Ft(e.email))return d(`Not an email address: ${e.email}`);let n=Re(e.email),s=e.contributorId??t.value.actor.userId;if(!t.value.state.contributors[s])return d(`Unknown contributor: ${s}`);let o=tt(t.value.state.emailLinks,n);if(o.includes(s))return p(`${n} is already yours`,{contributor:s,email:n,contested:o.filter(r=>r!==s)});let a=S([{id:Jn(),action:"link.contributor.email",payload:{contributor:s,email:n},userId:t.value.actor.userId}],t.value.boot.stateBranchRoot);return l(a)?d(a.message):p(o.length>0?`Claimed ${n}, but somebody else claims it too, so it now resolves to neither of you`:`Claimed ${n}`,{contributor:s,email:n,contested:o})},qo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let n=Re(e.email),s=e.contributorId??t.value.actor.userId,o=t.value.state.emailLinks[_t(n,s)];if(!o||o.tombstoned)return d(`No such link: ${n} to ${s}`);if(!Gt(t.value.actor.userId,o))return d("Only whoever made a claim, or the contributor it names, may undo it");let a=S([{id:Jn(),action:"unlink.contributor.email",payload:{contributor:s,email:n},userId:t.value.actor.userId}],t.value.boot.stateBranchRoot);return l(a)?d(a.message):p(`Unclaimed ${n}`,{contributor:s,email:n})},Vo=async(e={})=>{let t=await M(e.repoRoot);if(l(t))return t;let n=B();if(l(n))return n;let{emailLinks:s,contributors:o}=n.value,a=new Map;for(let c of Object.values(s)){if(c.tombstoned)continue;let I=a.get(c.email)??new Set;I.add(c.contributor),a.set(c.email,I)}let r=[...a.entries()].map(([c,I])=>({email:c,contested:I.size>1,claimants:[...I].map(v=>D(v,o[v]?.name))})).sort((c,I)=>c.email.localeCompare(I.email)),i=G(),u=l(i)?[]:$t(s,i.value.userId),g=xt().gitEmail,f=g?tt(s,g).filter(c=>l(i)||c!==i.value.userId):[];return p("Listed contributor emails",{emails:r,mine:u,git:g?{email:g,linkedToMe:u.includes(g),heldByOthers:f.map(c=>D(c,o[c]?.name))}:null})},Yo=async(e={})=>{let t=await T(e.repoRoot);if(l(t))return t;let{userId:n,userName:s}=t.value.actor,o=le(t.value.boot.repoRoot),a=await We({repoRoot:t.value.boot.repoRoot,stateBranch:l(o)?void 0:o.value,names:[s,await pe(t.value.boot.repoRoot)],links:t.value.state.emailLinks});if(l(a))return a;let r=An(a.value),i=r.filter(u=>u.looksLikeYours);return p(r.length===0?"No unclaimed addresses in this history":`${r.length} unclaimed address(es) in this history, ${i.length>0?`${i.length} of which look like yours`:"none obviously yours"}. Show them to the user and link only the ones they confirm; each is a permanent event that replicates to every clone.`,{contributor:n,candidates:r,likely:i.length})};var ht=e=>{let t=on(e);return l(t)?d(t.message):p("Listed repos",{repos:t.value,claimedBytes:un(e),limit:Lt,allowLocal:Bt()})},Jo=async(e={})=>{let t=Ae(e.repoRoot);return l(t)?d(t.message):ht(t.value)},Qo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let{repoRoot:n}=t.value.boot,s=await cn({repoRoot:n,actorId:t.value.actor.userId,url:e.url,branches:e.branches,since:e.since,label:e.label,mode:e.previewOnly?"preview":e.confirm?"confirm":"auto"});if(l(s))return d(s.message);let o=ht(n);return l(o)?d(o.message):p(s.message,{...o.value,...s.value.kind==="preview"?{preview:s.value.preview}:{}})},Zo=async e=>{let t=await T(e.repoRoot);if(l(t))return t;let{repoRoot:n}=t.value.boot,s=rn({repoRoot:n,actorId:t.value.actor.userId,repo:e.repo});if(l(s))return d(s.message);let o=ht(n);return l(o)?d(o.message):p(s.message,o.value)},er=e=>(dn("repo"in e?e.repo:kt(e.url.trim())),p("Cancelled",null)),tr=async(e,t={},n=2e4)=>{if(l(e))return e;let s,o=await Promise.race([Qn(t),new Promise(a=>{s=setTimeout(()=>a(null),n)})]);return clearTimeout(s),o===null?p(`${e.message} \xB7 still fetching other repos; epiq_repo_list shows how they stand`,e.value):l(o)||o.value.length===0?e:p([e.message,ln(o.value)].filter(Boolean).join(" \xB7 "),{...e.value,repos:o.value})},Qn=async(e={})=>{let t=Ae(e.repoRoot);return l(t)?d(t.message):an({repoRoot:t.value,minIntervalMs:e.minIntervalMs})};var Zn=(e,t)=>{let n=0,s=0,o=null;for(let a of e){if(a.userId!==t)continue;a.action==="add.issue"&&n++,a.action==="add.issue.comment"&&s++;let r=Mt(a.id);if(l(r))continue;let i=r.value.getTime();(o===null||i<o)&&(o=i)}return{tickets:n,comments:s,joinedAt:o}};var nr=async(e={})=>{let t=await T(e.repoRoot);if(l(t))return t;let{userId:n,userName:s}=t.value.actor,o=Zn(t.value.state.eventLog,n),a=le(t.value.boot.repoRoot),r=await We({repoRoot:t.value.boot.repoRoot,stateBranch:l(a)?void 0:a.value,names:[s,await pe(t.value.boot.repoRoot)],links:t.value.state.emailLinks}),i=l(r)?[]:r.value.filter(u=>u.claimedBy.length===1&&u.claimedBy[0]===n);return p("Derived personal stats",{...o,scanned:!l(r),commits:i.reduce((u,g)=>u+g.commits,0),claimedEmails:i.length})};var es=e=>{if(e.length===0)return null;let t=Math.floor(e.length/2);return e.length%2===0?(e[t-1]+e[t])/2:e[t]};var sr=8,or=(e,t)=>{let n=new Date(e);return n.setHours(0,0,0,0),n.setDate(n.getDate()-(n.getDay()+6)%7),Array.from({length:t},(s,o)=>{let a=new Date(n);return a.setDate(n.getDate()-7*(t-1-o)),a.getTime()})},rr=e=>es([...e].sort((t,n)=>t-n)),ts=({boardId:e,lanes:t,formerLaneIds:n=[],tickets:s,now:o})=>{let a=new Map(t.map((E,x)=>[E.id,x])),r=new Set(n),i=E=>E!=null&&(a.has(E)||r.has(E)),g=s.map(E=>({ticket:E,visits:ft(E.log,E.createdAt)})).filter(({visits:E})=>E.some(x=>i(x.laneId))),f=E=>{let x=te(E);return x===null?null:Math.min(ye(x,o),o)},c=E=>{let x=E.flatMap(K=>{let $=a.get(K.laneId);return $===void 0?[]:[$]});return x.some((K,$)=>$>0&&K<x[$-1])},I=g.flatMap(({ticket:E,visits:x})=>{let K=E.log.findLast(be=>be.action==="close.issue");if(!K||i(E.parentNodeId))return[];let $=f(K),Ts=x.at(-2)?.laneId;if($===null||!i(Ts))return[];let Es=x.slice(0,-1).flatMap((be,ws)=>i(be.laneId)?[{laneId:be.laneId,ms:x[ws+1].enteredAt-be.enteredAt}]:[]);return[{closedAt:$,leadTime:$-E.createdAt,sentBack:c(x),stays:Es}]}),v=or(o,sr),h=v[0],m=I.filter(E=>E.closedAt>=h),b=v.map((E,x)=>{let K=v[x+1]??1/0;return{t:E,closed:m.filter($=>$.closedAt>=E&&$.closedAt<K).length}}),y=new Map;for(let{stays:E}of m)for(let{laneId:x,ms:K}of E)y.set(x,(y.get(x)??0)+K);let V=t.reduce((E,x)=>E+(y.get(x.id)??0),0),As=t.flatMap(E=>{let x=y.get(E.id)??0;return x<=0?[]:[{laneId:E.id,title:E.title,meanMs:x/m.length,share:x/V}]});return{boardId:e,throughput:b,filed:g.filter(({ticket:E,visits:x})=>E.createdAt>=h&&i(x[0]?.laneId)).length,closed:m.length,medianLeadTimeMs:rr(m.map(E=>E.leadTime)),sentBackShare:m.length===0?null:m.filter(E=>E.sentBack).length/m.length,laneTime:As}};var ir=e=>{let t=B();if(l(t))return t;let n=Object.values(t.value.nodes),s=n.find(r=>r.id===e.boardId);if(!s||s.isDeleted||!W(s))return d("Board not found");let o=n.filter(r=>Q(r)&&r.parentNodeId===s.id),a=o.filter(r=>!r.isDeleted).sort((r,i)=>r.rank.localeCompare(i.rank));return p("Derived board overview",ts({boardId:s.id,lanes:a,formerLaneIds:o.filter(r=>r.isDeleted).map(r=>r.id),tickets:n.filter(r=>!r.isDeleted).filter(_).map(r=>({id:r.id,parentNodeId:r.parentNodeId,log:r.log??[],createdAt:P(r.id)})),now:Date.now()}))};var q=e=>({path:e.path,sha:e.shas[e.shas.length-1]??""});var ar=e=>{let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)},ns=({commits:e,patch:t})=>{let n=e.map(r=>r.time),o=t.files.map(r=>({...q(r),changed:r.addedCount+r.removed})).reduce((r,i)=>r===null||i.changed>r.changed?i:r,null),a=t.insertions+t.deletions;return{commits:e.length,authors:[...new Set(e.map(r=>r.author))].sort(),firstCommitAt:n.length?Math.min(...n):null,lastCommitAt:n.length?Math.max(...n):null,files:t.files.length,filesAdded:t.files.filter(r=>r.status==="added").length,filesModified:t.files.filter(r=>r.status==="modified").length,filesDeleted:t.files.filter(r=>r.status==="deleted").length,binaryFiles:t.files.filter(r=>r.binary).length,directories:new Set(t.files.map(r=>ar(r.path))).size,insertions:t.insertions,deletions:t.deletions,net:t.insertions-t.deletions,largestFile:o,concentration:o&&a>0?o.changed/a:0,selfChurn:t.selfChurn,truncated:t.truncated}};var N={line:["//"],block:[["/*","*/"]]},j={line:["#"],block:[]},bt={line:["--"],block:[]},ve={line:[],block:[["<!--","-->"]]},lr={line:[],block:[]},R=(e,t)=>({name:e,comment:t}),Je=R("TypeScript",N),Qe=R("JavaScript",N),ss={ts:Je,tsx:Je,mts:Je,cts:Je,js:Qe,jsx:Qe,mjs:Qe,cjs:Qe,py:R("Python",{line:["#"],block:[['"""','"""']]}),rb:R("Ruby",{line:["#"],block:[["=begin","=end"]]}),go:R("Go",N),rs:R("Rust",N),java:R("Java",N),kt:R("Kotlin",N),swift:R("Swift",N),c:R("C",N),h:R("C",N),cc:R("C++",N),cpp:R("C++",N),hpp:R("C++",N),cs:R("C#",N),php:R("PHP",N),scala:R("Scala",N),dart:R("Dart",N),lua:R("Lua",bt),hs:R("Haskell",bt),sql:R("SQL",bt),ex:R("Elixir",j),exs:R("Elixir",j),pl:R("Perl",j),r:R("R",j),jl:R("Julia",j),sh:R("Shell",j),bash:R("Shell",j),zsh:R("Shell",j),vue:R("Vue",ve),svelte:R("Svelte",ve),html:R("HTML",ve),xml:R("XML",ve),md:R("Markdown",ve),mdx:R("Markdown",ve),css:R("CSS",{line:[],block:[["/*","*/"]]}),scss:R("CSS",N),less:R("CSS",N),yml:R("YAML",j),yaml:R("YAML",j),toml:R("TOML",j),ini:R("INI",j),json:R("JSON",lr)},dr="Other",os=e=>{let t=e.slice(e.lastIndexOf("/")+1),n=t.lastIndexOf(".");return n<=0?"":t.slice(n+1).toLowerCase()},ae=e=>ss[os(e)]?.name??dr,ke=e=>ss[os(e)]?.comment??null,ur=[/\.(test|spec)\.[a-z0-9]+$/i,/(^|\/)test_[^/]+\.py$/,/_test\.[a-z0-9]+$/i,/(^|\/)conftest\.py$/,/Tests?\.(java|kt|cs|scala)$/],cr=/(^|\/)(tests?|__tests__|spec|specs|e2e|src\/test|features)\//i,he=e=>cr.test(e)||ur.some(t=>t.test(e)),mr=/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|go\.sum|poetry\.lock|Gemfile\.lock|composer\.lock)$/,pr=/(^|\/)(node_modules|dist|build|out|target|vendor|coverage|\.next|__snapshots__)\//,fr=/(\.min\.(js|css)|\.map|\.snap|\.pb\.go|_pb2\.py)$/,z=e=>mr.test(e)||pr.test(e)||fr.test(e),rs=e=>/(^|\/)(package\.json|go\.mod|Cargo\.toml|requirements[^/]*\.txt|pyproject\.toml|Gemfile|composer\.json|pom\.xml|build\.gradle(\.kts)?)$/.test(e),is=e=>/(^|\/)\.github\/workflows\//.test(e)||/(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml|Makefile|Jenkinsfile|\.gitlab-ci\.yml)$/.test(e)||/\.tf$/.test(e),as=e=>/\.(md|mdx|rst|txt)$/i.test(e)||/(^|\/)docs?\//i.test(e),gr=/\b(it|test|describe|context|suite)\.skip\b|\bx(it|describe|test)\s*\(|@pytest\.mark\.skip|@unittest\.skip|\bt\.Skip\s*\(|@(Ignore|Disabled)\b/,Ir=/\b(it|test|describe|context|suite)\.only\b|\bf(it|describe|test)\s*\(/,ls=e=>gr.test(e),ds=e=>Ir.test(e);var us=/\b(TODO|FIXME|HACK|XXX)\b/,vr=/[;{}]\s*$|^\s*(const|let|var|function|def|class|if|for|while|return|import|export|await|print)\b.*[=(]/,yt=(e,t)=>{let n=e.trim();return n===""?"blank":t&&(t.line.some(s=>n.startsWith(s))||t.block.some(([s])=>n.startsWith(s))||t.block.some(([s])=>s==="/*")&&(n.startsWith("*")||n.startsWith("*/")))?"comment":"code"},hr=(e,t)=>{let n=e.trim();for(let s of[...t.line,...t.block.flat(),"*"])if(n.startsWith(s)){n=n.slice(s.length).trim();break}return n},cs=({patch:e,repoShareByLanguage:t})=>{let n=new Map,s=0,o=0,a=0,r=0,i=0,u=0;for(let f of e.files){if(f.binary||z(f.path))continue;let c=ke(f.path);if(!c||c.line.length===0&&c.block.length===0)continue;let I=ae(f.path),v=n.get(I)??{comment:0,code:0};for(let{text:h}of f.added){let m=yt(h,c);if(us.test(h)&&r++,m==="blank"){a++;continue}if(m==="comment"){s++,v.comment++,c&&vr.test(hr(h,c))&&u++;continue}o++,v.code++}for(let{text:h}of f.removedLines)us.test(h)&&i++;n.set(I,v)}let g=s+o;return{byLanguage:[...n.entries()].map(([f,c])=>({name:f,commentLines:c.comment,codeLines:c.code,share:c.comment+c.code===0?0:c.comment/(c.comment+c.code),repoShare:t?.get(f)??null})).sort((f,c)=>c.commentLines+c.codeLines-(f.commentLines+f.codeLines)),commentLines:s,codeLines:o,blankLines:a,share:g===0?0:s/g,todoLinesAdded:r,todoLinesRemoved:i,commentedOutCodeLines:u}};var br=/\bconsole\.(log|debug|dir)\s*\(|\bdebugger\b|^\s*print\s*\(|\bfmt\.Print(ln|f)?\s*\(|\bSystem\.out\.print|\bdbg!\s*\(/,Ze=6,Rt=10,yr=e=>{let t=0;for(let n of e){if(n.trim()===""||n.startsWith(" "))continue;let s=n.length-n.trimStart().length;s>0&&(t===0||s<t)&&(t=s)}return Math.min(Math.max(t,2),8)},Rr=(e,t)=>{let n=e.length-e.trimStart().length;if(n===0)return 0;let s=e.slice(0,n).split(" ").length-1;return s>0?s:Math.floor(n/t)},Ar=e=>{if(e.length<Ze*2)return 0;let t=new Map,n=new Array(e.length).fill(!1);for(let s=0;s+Ze<=e.length;s++){let o=e.slice(s,s+Ze);if(o.some(i=>i.text.length<3))continue;let a=o.map(i=>i.text).join(`
|
|
5
|
-
`),r=t.get(a);if(r===void 0){t.set(a,{...o[0],at:s});continue}if(r.file!==o[0]?.file)for(let i=0;i<Ze;i++)n[r.at+i]=!0,n[s+i]=!0}return n.filter(Boolean).length},ms=({patch:e})=>{let t=[],n=[],s=[],o=!1,a=0,r=0,i=null,u=[];for(let[g,f]of e.files.entries()){if(z(f.path)&&t.push(q(f)),rs(f.path)&&n.push(q(f)),is(f.path)&&s.push(q(f)),as(f.path)&&(o=!0),f.binary||z(f.path))continue;let c=f.added.map(h=>h.text),I=yr(c),v=f.status!=="deleted";for(let h of c){br.test(h)&&a++;let m=Rr(h,I);m>r&&(r=m,i=q(f)),v&&u.push({text:h.trim(),file:g})}u.push({text:" ",file:g})}return{generatedPaths:t.slice(0,Rt),dependencyManifests:n.slice(0,Rt),buildOrCiPaths:s.slice(0,Rt),docsTouched:o,debugPrintLinesAdded:a,maxIndentLevels:r,deepestFile:i,duplicatedLines:Ar(u)}};var ps=({patch:e,languagesBefore:t})=>{let n=new Map,s=0;for(let r of e.files){if(r.binary)continue;let i=r.addedCount+r.removed;if(z(r.path)){s+=i;continue}let u=ae(r.path),g=n.get(u)??{name:u,added:0,removed:0,addedInTests:0,share:0};g.added+=r.addedCount,g.removed+=r.removed,he(r.path)&&(g.addedInTests+=r.addedCount),n.set(u,g)}let o=[...n.values()].reduce((r,i)=>r+i.added+i.removed,0),a=[...n.values()].map(r=>({...r,share:o===0?0:(r.added+r.removed)/o})).sort((r,i)=>i.added+i.removed-(r.added+r.removed));return{languages:a,introduced:t===null?[]:a.filter(r=>!t.has(r.name)).map(r=>r.name),generatedLines:s}};var Tr=200,At=2e5,Er=5e4,wr=25,fs=64*1024*1024,Tt="",Sr=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/,xr=/^diff --git a\/(.+) b\/\1$/,gs=(e,t)=>e==="/dev/null"?null:e.startsWith(t)?e.slice(2):e,Is=(e,t)=>e===null?"added":t===null?"deleted":"modified",Cr=()=>({byPath:new Map,insertions:0,deletions:0,selfChurn:0,retainedLines:0}),Br=(e,t)=>{let n=e.byPath,s="",o=null,a=null,r=null,i=!1,u=0,g=(c,I)=>I==="modified"&&c==="added"?"added":I,f=(c,I)=>{let v=n.get(c);if(v)return v.entry.status=g(v.entry.status,I),v.entry.shas.includes(s)||v.entry.shas.push(s),v;let m={entry:{path:c,status:I,binary:!1,added:[],addedCount:0,removed:0,removedLines:[],shas:[s]},pendingByText:new Map};return n.set(c,m),m};for(let c of t.split(`
|
|
6
|
-
`)){if(c.startsWith(Tt)){s=c.slice(Tt.length).trim(),o=null,a=null,r=null,i=!1;continue}if(c.startsWith("diff --git ")){o=null,r=null,i=!0,a=xr.exec(c)?.[1]??null;continue}if(i&&c.startsWith("Binary files ")&&a){let[,v=""]=/^Binary files (.*) differ$/.exec(c)??[],[h="",m=""]=v.split(" and ");o=f(a,Is(h==="/dev/null"?null:h,m==="/dev/null"?null:m)),o.entry.binary=!0;continue}if(i&&c.startsWith("--- ")){r=gs(c.slice(4),"a/");continue}if(i&&c.startsWith("+++ ")){let v=gs(c.slice(4),"b/"),h=v??r??a;h&&(o=f(h,Is(r,v)));continue}let I=Sr.exec(c);if(I){u=Number(I[1]),i=!1;continue}if(o){if(c.startsWith("+")){let v=c.slice(1);e.insertions++,o.entry.addedCount++,e.retainedLines<At&&(o.entry.added.push({sha:s,line:u,text:v}),e.retainedLines++),o.pendingByText.size<Er&&o.pendingByText.set(v,(o.pendingByText.get(v)??0)+1),u++;continue}if(c.startsWith("-")){let v=c.slice(1);e.deletions++,o.entry.removed++,e.retainedLines<At&&(o.entry.removedLines.push({sha:s,line:0,text:v}),e.retainedLines++);let h=o.pendingByText.get(v)??0;h>0&&v.trim().length>2&&(e.selfChurn++,o.pendingByText.set(v,h-1))}}}},Lr=e=>({files:[...e.byPath.values()].map(t=>t.entry),insertions:e.insertions,deletions:e.deletions,selfChurn:e.selfChurn,retainedLines:e.retainedLines});var vs=async({repoRoot:e,shas:t,cwdOf:n=()=>e})=>{if(t.length===0)return p("No commits to scan",{files:[],insertions:0,deletions:0,selfChurn:0,scannedCommits:0,truncated:!1});let s=t.slice(0,Tr).reverse(),o=Cr(),a=0,r=0,i=!1,u=[];for(let f of s){let c=n(f),I=u[u.length-1];I&&I.cwd===c&&I.shas.length<wr?I.shas.push(f):u.push({cwd:c,shas:[f]})}for(let{cwd:f,shas:c}of u){let I=await Oe({cwd:f,maxOutput:Math.max(1,fs-a),keepPartial:!0,args:["-c","core.quotePath=false","show","--unified=0","--no-renames","--no-color",`--format=${Tt}%H`,...c]});if(l(I)){if(f!==e)continue;return d(I.message)}if(Br(o,I.value.stdout),a+=I.value.stdout.length,r+=c.length,I.value.truncated||a>fs){i=!0;break}}let g=Lr(o);return p("Scanned ticket patch",{files:g.files,insertions:g.insertions,deletions:g.deletions,selfChurn:g.selfChurn,scannedCommits:r,truncated:i||r<t.length||g.retainedLines>=At})};var kr=40,Nr=/^\d{6} blob ([0-9a-f]{40})\t(.+)$/,hs=async({repoRoot:e,sha:t})=>{let n=await Me({cwd:e,args:["-c","core.quotePath=false","ls-tree","-r",`${t}~1`]});if(n.exitCode!==0)return null;let s=new Set,o=new Map;for(let f of n.stdout.split(`
|
|
7
|
-
`)){let c=Nr.exec(f);if(!c)continue;let[,I="",v=""]=c;if(z(v))continue;let h=ae(v);if(s.add(h),he(v)||!ke(v))continue;let m=o.get(h)??[];m.length<kr&&(m.push({blob:I,path:v}),o.set(h,m))}let a=[...o.values()].flat(),r=await wt(a.map(f=>f.blob),e);if(l(r))return{languages:s,commentShareByLanguage:new Map};let i=r.value,u=new Map;for(let{blob:f,path:c}of a){let I=i.get(f);if(I===void 0)continue;let v=ke(c),h=ae(c),m=u.get(h)??{comment:0,code:0};for(let b of I.split(`
|
|
8
|
-
`)){let y=yt(b,v);y==="comment"&&m.comment++,y==="code"&&m.code++}u.set(h,m)}let g=new Map;for(let[f,c]of u){let I=c.comment+c.code;I>0&&g.set(f,c.comment/I)}return{languages:s,commentShareByLanguage:g}};var bs=({patch:e})=>{let t=0,n=0,s=[],o=[],a=0,r=0;for(let i of e.files)if(!(i.binary||z(i.path))&&he(i.path)){t+=i.addedCount,n+=i.removed,i.status==="added"&&s.push(q(i)),i.status==="deleted"&&o.push(q(i));for(let{text:u}of i.added)ls(u)&&a++,ds(u)&&r++}return{testLinesAdded:t,testLinesRemoved:n,addedTestFiles:s,deletedTestFiles:o,skippedTestLinesAdded:a,focusedTestLinesAdded:r}};var Pr=e=>e.reduce((t,n)=>t===null||n.time<t.time?n:t,null),ys=async({repoRoot:e,ref:t,commits:n})=>{let s=await tn(e);if(l(s))return d(s.message);let o=nn(s.value),a=new Map(n.map(c=>[c.sha,c.repo])),r=c=>o(a.get(c))??e,i=await vs({repoRoot:e,shas:n.map(c=>c.sha),cwdOf:r});if(l(i))return d(i.message);let u=i.value,g=Pr(n),f=g?await hs({repoRoot:r(g.sha),sha:g.sha}):null;return p("Derived issue stats",{ref:t,shape:ns({commits:n,patch:u}),languages:ps({patch:u,languagesBefore:f?.languages??null}),tests:bs({patch:u}),comments:cs({patch:u,repoShareByLanguage:f?.commentShareByLanguage??null}),flags:ms({patch:u})})};var Rs=e=>{if(l(e))return e;let t=Ge(),n=l(t)?{}:t.value.emailLinks,s=l(t)?{}:t.value.contributors,o=Wt(n),a=e.value.map(r=>({...r,authorIdentity:Rn({authorName:r.author,authorEmail:r.authorEmail,owners:o,registry:s})}));return p(e.message,a)};var Mr=32,Ne=new Map;var Dr=(e,t)=>{if(Ne.set(e,t),Ne.size>Mr){let n=Ne.keys().next();n.done||Ne.delete(n.value)}return t},nm=async(e={idOrRef:""})=>{let t=e.idOrRef.trim();if(!t)return d("idOrRef must not be empty");let n=t.length>7?w(t):t.toUpperCase(),s=De(e.repoRoot??process.cwd());if(l(s))return d(s.message);let o=s.value,a=Rs(await sn({repoRoot:o,ref:n,end:e.end}));if(l(a))return d(a.message);let r=a.value.map(f=>({sha:f.sha,...f.repo?{repo:f.repo}:{},time:f.time,author:f.authorIdentity?.resolved?f.authorIdentity.name:f.author,subject:f.subject})),i=[o,n,r.map(f=>`${f.sha}:${f.author}`).join(",")].join(" "),u=Ne.get(i);if(u)return p("Derived issue stats",u);let g=await ys({repoRoot:o,ref:n,commits:r});return l(g)?d(g.message):p("Derived issue stats",Dr(i,g.value))};export{ft as a,Fn as b,U as c,ui as d,Ks as e,ci as f,mi as g,Gn as h,pe as i,B as j,Js as k,Qs as l,no as m,so as n,oo as o,ao as p,uo as q,gt as r,mo as s,po as t,fo as u,go as v,Io as w,ho as x,bo as y,Ro as z,Ao as A,To as B,Eo as C,wo as D,So as E,xo as F,Co as G,Bo as H,Lo as I,ko as J,No as K,Po as L,Oo as M,Mo as N,Do as O,Fo as P,_o as Q,$o as R,Go as S,jo as T,Uo as U,Ho as V,zo as W,Ko as X,Xo as Y,qo as Z,Vo as _,Yo as $,nr as aa,Jo as ba,Qo as ca,Zo as da,er as ea,tr as fa,Qn as ga,es as ha,ir as ia,Rs as ja,nm as ka};
|
package/dist/server-CMCAPC5E.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{$ as Ie,B as Y,C as W,D as V,E as Z,F as ee,G as te,H as ie,I as oe,J as ne,K as se,L as re,M as ae,N as ce,O as le,P as de,Q as pe,R as me,S as he,T as ue,U as ge,V as fe,W as we,X as be,Y as ye,Z as _e,_ as ve,b as R,ba as qe,ca as ke,da as Se,fa as Re,i as O,k as D,ka as Te,l as G,m as $,p as B,t as F,u as H,v as z,w as K,x as X,y as J,z as Q}from"./chunk-ZPUSANPS.js";import{Kb as U,ab as S,b as N,ca as M,h as A,l as C,m as P,x as L}from"./chunk-VRDQK5QD.js";import{a as x}from"./chunk-WUCQWBQE.js";import{b as r,c as w,d as a}from"./chunk-5RIQL7P4.js";import{McpServer as Be}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Fe}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as e}from"zod";import{ulid as Oe}from"ulid";var Ee=[{name:"userName",question:"the name they want to appear under on the board"},{name:"preferredEditor",question:'the command that opens a file for editing, e.g. "vim", "nano" or "code --wait"'},{name:"autoSync",question:"whether the TUI and GUI should sync with the git remote on their own (true or false)"}],je=t=>t.trim().toLowerCase(),xe=async(t={})=>{let o=C();if(a(o))return r(o.message);let n=o.value,c=t.userName?.trim(),E=(process.env[x]??"").trim();if(c&&E&&je(c)===je(E))return r(`userName "${c}" is this agent's own identity. Pass the user's name, the one they want the TUI and GUI to write as.`);let p={userName:c||void 0,preferredEditor:t.preferredEditor?.trim()||void 0,autoSync:t.autoSync},g={userName:n.userName?.trim()||void 0,preferredEditor:n.preferredEditor?.trim()||void 0,autoSync:typeof n.autoSync=="boolean"?n.autoSync:void 0};for(let s of Ee){let d=p[s.name],f=g[s.name];if(!(d===void 0||f===void 0||d===f))return r(`This machine is already set up with ${s.name} ${JSON.stringify(f)}; epiq_project_init does not change it. Call again without ${s.name}, or let the user change it in the TUI with :config.`)}let l={};if(p.userName&&!g.userName&&(l.userName=p.userName),p.preferredEditor&&!g.preferredEditor&&(l.preferredEditor=p.preferredEditor),p.autoSync!==void 0&&g.autoSync===void 0&&(l.autoSync=p.autoSync),(l.userName||g.userName)&&!n.userId&&(l.userId=Oe()),Object.keys(l).length>0){let s=P(l);if(a(s))return r(s.message)}let I={...n,...l},q=Ee.filter(s=>{let d=I[s.name];return typeof d=="boolean"?!1:!d?.trim()});if(q.length>0){let s=q.map(_=>`${_.name} (${_.question})`).join("; "),d=q.some(_=>_.name==="userName")?await O(t.repoRoot??process.cwd()):null,f=d?` This repository's git user.name is ${JSON.stringify(d)} \u2014 offer it as the default for userName, and use it only if the user agrees.`:"";return r(`Setup incomplete. Ask the user for: ${s}.${f} Then call epiq_project_init again with the answers; what was given so far is saved.`)}let b={userId:I.userId??"",userName:I.userName??""};if(!b.userId||!b.userName)return r("Missing Epiq user id");let k=await U({cwd:t.repoRoot??process.cwd(),user:b});if(a(k))return k;let{defaultEvents:Ke,...y}=k.value,j=M({root:y.repoRoot});a(j)&&N.info(j.message);let Ue=y.warnings.length===0?"Project initialized":`Project initialized, with warnings: ${y.warnings.join(" ")}`;return w(Ue,{...y,user:b})};import v from"node:fs";import Ne from"node:path";var m=".claude/skills/epiq/SKILL.md",T=`---
|
|
3
|
-
name: epiq
|
|
4
|
-
description: Workflow for working an epiq issue board through the epiq MCP \u2014 take an identity, sync on demand, keep tickets small and their status, tags and comments current.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Epiq board workflow
|
|
8
|
-
|
|
9
|
-
- **Use the \`epiq_*\` MCP tools** for every board read and write \u2014 never the CLI, hand edits, or the state branch directly.
|
|
10
|
-
- **Never touch the state branch** \u2014 no checkout, no edits to its files by hand or by script. The event log is the system of record; a manual edit can corrupt history for good.
|
|
11
|
-
- Move tickets along the board with correct status
|
|
12
|
-
- **The MCP never syncs on its own:** call \`epiq_sync\` to pull or publish.
|
|
13
|
-
- **Take an identity before your first write** with \`epiq_actor_assume\`, e.g. \`claude/peter\`. Reuse one from \`epiq_contributor_list\` \u2014 names are permanent. If other agents may be running, ask which name is free, rather than just picking one.
|
|
14
|
-
- **One MCP server per session** \u2014 the name binds to the process; a restart forgets it. Every session needs a server process of its own, so agents and the human stay apart.
|
|
15
|
-
- **Keep tickets reasonably scoped**; put a small follow-up on its existing ticket instead of a new one.
|
|
16
|
-
- **Read a ticket's comments before starting.**
|
|
17
|
-
- **Board and lane descriptions describe team conventions** (\`boardDescription\`, \`laneDescription\` in responses): follow them unless they conflict with your user's instructions.
|
|
18
|
-
- **Picking up a ticket:** assign yourself and move it to the in-progress lane. Ask before taking one assigned to someone else.
|
|
19
|
-
- **Keep status, tags and description current**; reuse existing tags.
|
|
20
|
-
- **Comment** on deviations, blockers, and the outcome when done.
|
|
21
|
-
- **Prompt user for closing tickets and big decisions**
|
|
22
|
-
- **Park decisions that are the user's to make.** A design fork, a change with blast radius beyond its ticket, anything you'd want a second opinion on \u2014 file a ticket tagged \`human-input-needed\` naming the options and the trade-offs, then carry on with whatever doesn't depend on the answer.
|
|
23
|
-
- **Link commits** with an \`Epiq-Ref: <ref>\` line in the commit body. Use the \`ref\` from the MCP response; never derive it from the id. Several tickets go on one line, comma-separated. A subject starting with the ref also links, but puts the ref in everyone's history.
|
|
24
|
-
- *If you decide to take a new approach*, add a \`fork\` tag, and document the fork in a comment, also, update the description to reflect the new plan.
|
|
25
|
-
- **Attachments are permanent** in every clone (max 500 KB): use with moderation, make sure images are cropped and compressed. An oversized image is permanent, for everybody.
|
|
26
|
-
- **Be concise, use clear language.** Titles, descriptions, and comments should be scannable, easy to understand, not essays.
|
|
27
|
-
- **When a ticket is done, Document the outcome in a comment starting with "Solution:"**. Use that exact prefix as the comment's opening line.
|
|
28
|
-
- **The git user is the sole author of every commit you write.** Commit under the repo's configured user.name / user.email and nothing else: no Co-Authored-By: line, no Claude-Session: line, no \u{1F916} Generated with footer, and never an --author override naming Claude or a tool.
|
|
29
|
-
- On rebase or merge, make sure Epiq refs survive. Dropping them from commit messages breaks commit linking.
|
|
30
|
-
`;var Ae=async(t={})=>{let o=await A(t.repoRoot??process.cwd());if(a(o))return r(o.message);let n=Ne.join(o.value,m);if(v.existsSync(n)){if(v.readFileSync(n,"utf8")===T)return w("Skill already installed and up to date",{path:n,written:!1});if(!t.force)return r(`${m} already exists and differs from the bundled skill. Pass force:true to overwrite it.`)}try{v.mkdirSync(Ne.dirname(n),{recursive:!0}),v.writeFileSync(n,T,"utf8")}catch(c){return r(c instanceof Error?`Failed to write ${m}: ${c.message}`:`Failed to write ${m}`)}return w(`Installed skill at ${m}`,{path:n,written:!0})};var u=t=>({isError:a(t),content:[{type:"text",text:JSON.stringify(t,null,2)}]}),i=t=>o=>R(async()=>u(await t(o))),He="A board's or lane's description (boardDescription, laneDescription) holds the team's conventions for it; follow them unless they conflict with your user's instructions.",ze=()=>{let t=new Be({name:"epiq",version:"0.2.30"},{instructions:He});return t.registerTool("epiq_state_get",{description:"Get the full current Epiq state, including nodes and event log",inputSchema:e.object({repoRoot:e.string().optional()})},i(B)),t.registerTool("epiq_issue_list",{description:"List Epiq issues. Narrow with boardId, swimlaneId, tag, assignee or query (matched against title and description), and pass brief to get id, ref, title, swimlane, tag names and assignee names only \u2014 descriptions are the bulk of a board. Read one ticket with epiq_issue_get.",inputSchema:e.object({repoRoot:e.string().optional(),includeClosed:e.boolean().optional(),boardId:e.string().optional(),swimlaneId:e.string().optional(),tag:e.string().optional(),assignee:e.string().optional(),query:e.string().optional(),brief:e.boolean().optional()})},i(z)),t.registerTool("epiq_issue_get",{description:"Get one Epiq issue by its full id or its 7-character ref, with its comments in log order. Use this rather than listing the whole board when you already know which issue you want, and rather than epiq_state_get to read a thread.",inputSchema:e.object({idOrRef:e.string().min(1),repoRoot:e.string().optional()})},i(H)),t.registerTool("epiq_issue_stats",{description:"Code stats for one issue, derived from the commits whose subject carries its ref: how big the change is, how it is spread, and how much of it the ticket spent rewriting its own work. Reads git only \u2014 it never touches the board \u2014 so it is safe to call while other work is in flight. No commits carrying the ref reads as a change of zero size, which is not the same as no work: a commit only links if its subject opens with the ref.",inputSchema:e.object({idOrRef:e.string().min(1),repoRoot:e.string().optional()})},async o=>u(await Te(o))),t.registerTool("epiq_board_list",{description:"List Epiq boards",inputSchema:e.object({repoRoot:e.string().optional()})},i(V)),t.registerTool("epiq_board_create",{description:"Create an Epiq board. It comes out without swimlanes; add them with epiq_swimlane_create. Refused while time travelling.",inputSchema:e.object({repoRoot:e.string().optional(),title:e.string().min(1).max(300)})},i(Z)),t.registerTool("epiq_swimlane_list",{description:"List Epiq swimlanes",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().optional()})},i(te)),t.registerTool("epiq_swimlane_create",{description:"Create an Epiq swimlane on a board",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().min(1),title:e.string().min(1).max(300)})},i(ie)),t.registerTool("epiq_swimlane_title_edit",{description:"Edit an Epiq swimlane title",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1),title:e.string().min(1).max(300)})},i(oe)),t.registerTool("epiq_board_title_edit",{description:"Edit an Epiq board title. Refused while time travelling.",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().min(1),title:e.string().min(1).max(300)})},i(ee)),t.registerTool("epiq_swimlane_description_edit",{description:"Edit a swimlane's markdown description: the conventions for work in that lane. Empty clears it.",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1),description:e.string().max(S("swimlane"))})},i(G)),t.registerTool("epiq_board_description_edit",{description:"Edit a board's markdown description: the conventions for work on that board. Empty clears it. Refused while time travelling.",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().min(1),description:e.string().max(S("board"))})},i(D)),t.registerTool("epiq_swimlane_move",{description:"Move/reorder an Epiq swimlane, optionally to another board",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1),boardId:e.string().min(1),position:e.discriminatedUnion("at",[e.object({at:e.literal("start")}),e.object({at:e.literal("end")}),e.object({at:e.literal("before"),sibling:e.string().min(1)}),e.object({at:e.literal("after"),sibling:e.string().min(1)})]).optional()})},i(ne)),t.registerTool("epiq_swimlane_delete",{description:"Delete (archive) an Epiq swimlane. This also archives every issue contained in it.",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1)})},i(se)),t.registerTool("epiq_issue_create",{description:"Create an Epiq issue in a swimlane: parentId is the swimlane id (epiq_swimlane_list), never a board id. Optionally set description, tags, and assignees atomically in the same call instead of separate follow-up edits.",inputSchema:e.object({title:e.string().min(1).max(300),parentId:e.string().min(1),repoRoot:e.string().optional(),description:e.string().max(2e4).optional(),tagNames:e.array(e.string().max(60)).max(20).optional(),assigneeNames:e.array(e.string().max(80)).max(20).optional()})},i(K)),t.registerTool("epiq_issue_description_edit",{description:"Edit the markdown description of an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),description:e.string().max(2e4),repoRoot:e.string().optional()})},i(Y)),t.registerTool("epiq_issue_title_edit",{description:"Edit the title of an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),title:e.string().min(1).max(300),repoRoot:e.string().optional()})},i(W)),t.registerTool("epiq_issue_tag_add",{description:"Add a tag to an Epiq issue, or to many at once with issueIds, creating the tag if it does not exist",inputSchema:e.object({issueId:e.string().min(1).optional(),issueIds:e.array(e.string().min(1)).min(1).max(200).optional(),tagName:e.string().min(1).max(60),repoRoot:e.string().optional()})},i(re)),t.registerTool("epiq_issue_tag_remove",{description:"Remove a tag from an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),tagId:e.string().min(1),repoRoot:e.string().optional()})},i(le)),t.registerTool("epiq_contributor_list",{description:"List people who can be assigned: everyone who has authored an event (optionally scoped to one board) unioned with the contributor registry. Use these ids with epiq_issue_assignee_add rather than assigning by name.",inputSchema:e.object({boardId:e.string().min(1).optional(),repoRoot:e.string().optional()})},i(ue)),t.registerTool("epiq_contributor_remove",{description:"Remove an external contributor from the assignee suggestion lists. Their id and every reference to it survive, so existing assignments stay intact and the event log is untouched. Refused for anyone who has authored events, since their name is in the log regardless.",inputSchema:e.object({contributorId:e.string().min(1),repoRoot:e.string().optional()})},i(me)),t.registerTool("epiq_tag_remove",{description:"Delete a tag from the whole workspace. It disappears from every ticket, picker and filter, but its id and history stay in the event log, and the name is free for a new tag.",inputSchema:e.object({tagId:e.string().min(1),repoRoot:e.string().optional()})},i(ae)),t.registerTool("epiq_tag_restore",{description:"Put back a tag deleted with epiq_tag_remove, on every ticket that still carried it.",inputSchema:e.object({tagId:e.string().min(1),repoRoot:e.string().optional()})},i(ce)),t.registerTool("epiq_contributor_restore",{description:"Put a contributor removed with epiq_contributor_remove back into the suggestion lists, under the name they were created with.",inputSchema:e.object({contributorId:e.string().min(1),repoRoot:e.string().optional()})},i(he)),t.registerTool("epiq_issue_assignee_add",{description:"Assign a contributor to an Epiq issue. Pass self:true to assign yourself. Prefer assigneeId otherwise, which assigns a known contributor (from the registry or the event log) and fails if the id is unknown. assigneeName matches an existing contributor by name; to create somebody new from a name you must also pass createUnlinked, which adds them as an external (non-contributor) assignee.",inputSchema:e.object({issueId:e.string().min(1),assigneeId:e.string().min(1).optional(),self:e.boolean().optional(),assigneeName:e.string().min(1).max(80).optional(),createUnlinked:e.boolean().optional(),repoRoot:e.string().optional()})},i(pe)),t.registerTool("epiq_issue_assignee_remove",{description:"Remove an assignee from an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),assigneeId:e.string().min(1),repoRoot:e.string().optional()})},i(ge)),t.registerTool("epiq_issue_comment_add",{description:"Add a comment to an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),body:e.string().min(1).max(4e3),repoRoot:e.string().optional()})},i(fe)),t.registerTool("epiq_issue_attachment_add",{description:"Attach an image file to an Epiq issue. Returns `markdown` \u2014 paste it into a comment or description body to render the image inline.",inputSchema:e.object({issueId:e.string().min(1),filePath:e.string().min(1),name:e.string().min(1).max(200).optional(),repoRoot:e.string().optional()})},i($)),t.registerTool("epiq_issue_comment_delete",{description:"Delete a comment from an Epiq issue",inputSchema:e.object({commentId:e.string().min(1),repoRoot:e.string().optional()})},i(we)),t.registerTool("epiq_issue_comment_edit",{description:"Replace the body of one of your own comments on an Epiq issue",inputSchema:e.object({commentId:e.string().min(1),body:e.string().min(1).max(4e3),repoRoot:e.string().optional()})},i(be)),t.registerTool("epiq_issue_reopen",{description:"Reopen a closed Epiq issue, restoring it to its previous swimlane",inputSchema:e.object({issueId:e.string().min(1),repoRoot:e.string().optional()})},i(J)),t.registerTool("epiq_issue_close",{description:"Close an Epiq issue, or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:e.object({issueId:e.string().min(1).optional(),issueIds:e.array(e.string().min(1)).min(1).max(200).optional(),repoRoot:e.string().optional()})},i(X)),t.registerTool("epiq_issue_move",{description:"Move an Epiq issue to another swimlane (parentId is the swimlane id), or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:e.object({issueId:e.string().min(1).optional(),issueIds:e.array(e.string().min(1)).min(1).max(200).optional(),parentId:e.string().min(1),position:e.discriminatedUnion("at",[e.object({at:e.literal("start")}),e.object({at:e.literal("end")}),e.object({at:e.literal("before"),sibling:e.string().min(1)}),e.object({at:e.literal("after"),sibling:e.string().min(1)})]).optional(),repoRoot:e.string().optional()})},i(Q)),t.registerTool("epiq_actor_assume",{description:'Take a board identity for the rest of this session, so your writes are attributed to you rather than to the user. Pass the name you announced \u2014 the model provider, a slash, then a short human first name, e.g. "claude/peter". Takes effect on the very next write; no relaunch. A name the server was launched with wins, and re-assuming the same name is harmless. Reuse an existing agent identity (epiq_contributor_list) before inventing one: a name is permanent once it has authored anything.',inputSchema:e.object({name:e.string().min(1).max(80),repoRoot:e.string().optional()})},i(de)),t.registerTool("epiq_contributor_email_link",{description:"Bind a git author address to a contributor, so their commits and their board activity read as one person. Defaults to you; pass contributorId to link a colleague who does not use epiq, whose commits otherwise never resolve. The address the repository's git is configured with links itself on your first write, so this is for older addresses and for other people. An address two contributors claim resolves to neither, and the reply says so.",inputSchema:e.object({email:e.string().min(1).max(254),contributorId:e.string().min(1).optional(),repoRoot:e.string().optional()})},i(ye)),t.registerTool("epiq_contributor_email_unlink",{description:"Retract a link between a git address and a contributor. Allowed only to whoever wrote the link and to the contributor it names, so nobody can strip links that are neither theirs nor about them. Forward-only: the address stops resolving and the event stays in the log.",inputSchema:e.object({email:e.string().min(1).max(254),contributorId:e.string().min(1).optional(),repoRoot:e.string().optional()})},i(_e)),t.registerTool("epiq_contributor_email_suggest",{description:"Addresses in this repository's history that look like yours and nobody has claimed, for the user to confirm. Run it once after this feature reaches a board with history: the address git is configured with links itself, but older ones do not, and until they are linked those commits show a raw git name. Show the list and link only what the user confirms \u2014 each link is permanent and replicates to every clone.",inputSchema:e.object({repoRoot:e.string().optional()})},i(Ie)),t.registerTool("epiq_contributor_email_list",{description:"Every git address the board has bound to a contributor, and who holds it. An address with more than one claimant is flagged contested and resolves to none of them, which is the state nothing else reports.",inputSchema:e.object({repoRoot:e.string().optional()})},i(ve)),t.registerTool("epiq_project_init",{description:`Set up a new Epiq board in a git repository without the TUI. Runs in the repository at repoRoot (default: the current directory), which must have no uncommitted changes. The first time on a machine it also records the user's setup: ask the user for userName (how they want to appear on the board), preferredEditor (e.g. "vim" or "code --wait") and autoSync (whether the TUI and GUI sync with the remote on their own) and pass them here; called without them it fails naming what is still missing, keeping whatever was given. It fills in answers the machine lacks and refuses to change ones it has. Pass the user's name, never your own agent identity. Commits the state branch and .epiq/project.json and tries to push both; a push that fails is a warning, not an error. Afterwards the other tools work in that repository.`,inputSchema:e.object({repoRoot:e.string().optional(),userName:e.string().min(1).max(80).optional(),preferredEditor:e.string().min(1).max(200).optional(),autoSync:e.boolean().optional()})},i(xe)),t.registerTool("epiq_skill_install",{description:"Write the official Epiq workflow skill into the repository at .claude/skills/epiq/SKILL.md, so agents working there follow the same board rules. Run it after epiq_project_init, not before: the new file is an uncommitted change that init refuses. In a project that already has a board, run it any time. Refuses to overwrite a differing file unless force is true; an identical file is left alone.",inputSchema:e.object({repoRoot:e.string().optional(),force:e.boolean().optional()})},i(Ae)),t.registerTool("epiq_sync",{description:"Sync Epiq state with the configured Git remote (pull remote changes and push local ones), then fetch the repos connected with epiq_repo_connect. Other Epiq MCP tools only read and write local state and never sync automatically \u2014 call this on demand when you need to see or publish the latest remote changes.",inputSchema:e.object({repoRoot:e.string().optional()})},async o=>u(await Re(await R(()=>F(o)),o))),t.registerTool("epiq_repo_list",{description:"List the repos connected to the board, whose commits count as its own: each with this machine's clone status, size on disk and last fetch error, whether it is past the board's limit and so not fetched, and what all of them take on this machine.",inputSchema:e.object({repoRoot:e.string().optional()})},async o=>u(await qe(o))),t.registerTool("epiq_repo_connect",{description:"Connect another repo to the board by URL (https://, ssh://, git:// or user@host:path; never a local path, which nobody else could fetch), so commits there prefixed with a ticket's ref link to it; or change a connected repo's options. Connecting is a two-step, board-wide action: every contributor's epiq downloads the repo on their next sync. The first call clones it into a staging area and returns a preview (size, host, default branch, latest commit, how many commits name this board's tickets \u2014 none suggests the wrong repo) and writes nothing. Show the preview to the user; only once they agree, call again with confirm: true and the same options. Option changes to an already connected repo apply at once. branches: default (the default branch only) or all. since: how much history to clone \u2014 board (since the board was created, the default), all, or YYYY-MM-DD. label: what the repo is called on the board \u2014 its URL's basename unless set; empty goes back to the basename. Cloning uses your git credentials: ssh-agent or a credential helper must already work, since a passphrase prompt cannot be answered.",inputSchema:e.object({repoRoot:e.string().optional(),url:e.string().min(1).max(L),branches:e.enum(["default","all"]).optional(),since:e.string().max(20).optional(),label:e.string().max(24).optional(),confirm:e.boolean().optional()})},async o=>u(await ke(o))),t.registerTool("epiq_repo_disconnect",{description:"Disconnect a repo by its label (when no other repo shares it), id or URL, and delete this machine's clone of it.",inputSchema:e.object({repoRoot:e.string().optional(),repo:e.string().min(1).max(2e3)})},async o=>u(await Se(o))),t},St=async()=>{let t=ze(),o=new Fe;await t.connect(o)};export{He as MCP_INSTRUCTIONS,ze as createMcpServer,u as resultJson,St as startMcpServer};
|