epiq 0.1.8 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +15 -11
  2. package/package.json +9 -3
package/dist/cli.js CHANGED
@@ -1,14 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import{render as Gr}from"ink";import qr from"meow";import At from"react";import{Box as Or}from"ink";import je from"react";import{Box as Go,Text as hr}from"ink";import ee from"react";var I={WORKSPACE:"WORKSPACE",BOARD:"BOARD",SWIMLANE:"SWIMLANE",TICKET:"TICKET",FIELD:"FIELD",FIELD_LIST:"FIELD_LIST"};function Et(e){return e.context==="FIELD_LIST"}var bt=e=>e.context==="SWIMLANE";import{useSyncExternalStore as or}from"react";var d={DEFAULT:"default",MOVE:"move",HELP:"help",COMMAND_LINE:"command-line"};var gn=(e,t)=>e.ctrl&&e.name==="w"||e.meta&&e.name==="backspace"||t==="",xn=(e,t)=>e.meta&&e.name==="b"||t==="\x1Bb",Cn=(e,t)=>e.meta&&e.name==="f"||t==="\x1Bf",Tt=(e,t)=>{if(xn(e,e.sequence))return"MoveCursorLeftOfWord";if(Cn(e,e.sequence))return"MoveCursorRightOfWord";if(gn(e,e.sequence))return"EraseInputWord";switch(e.name){case"tab":return"autoCompleteCommand";case"up":return"getLastCommandFromHistory";case"down":return"getNextCommandFromHistory";case"left":return"MoveCursorLeft";case"right":return"MoveCursorRight";case"return":return"confirm";case"backspace":return t?"eraseInput":"exitCommandLine";case"escape":return"exitCommandLine";default:return"captureInput"}};function Ae(e,t){let o=Math.min(e.length,t.length),n=0;for(;n<o&&e[n]===t[n];)n++;return n}var St=(e,t)=>t<=0?"":e.length<=t?e:t<=3?"...".slice(0,t):e.slice(0,t-3)+"...",Ee=e=>typeof e!="string"?"":e.replace(/[\x00-\x08\x0B-\x1F\x7F]/g,"").replace(/[\r\n\t]/g," ").replace(/\s+/g," ").trim();var Mt=e=>{let t=new Map;for(let o of e)for(let n=1;n<=o.length;n++){let r=o.slice(0,n),i=t.get(r);i?i.push(o):t.set(r,[o])}return t},wt=(e,t)=>t?e.get(t)??[]:[];var Lt=new WeakMap,vn=e=>{let t=Lt.get(e);return t||(t=Mt(e),Lt.set(e,t)),t};var be=({wordList:e,inputToMatch:t,overlapThreshold:o=1})=>{let n=t.toLowerCase();return wt(vn(e),n).filter(i=>Ae(n,i)>=o)};var y={HELP:"help",RENAME:"rename",NEW:"new",DELETE:"delete",VIEW:"view",TAG:"tag",ASSIGN:"assign"},F={None:"none",Invalid:"invalid",Valid:"valid"},B={None:"none",Success:"success",Fail:"fail"},c=e=>({result:B.Fail,message:e,data:null}),f=(e,t)=>({result:B.Success,message:e,data:t}),Dt=()=>({result:B.None,message:"No result",data:null}),h=e=>e.result==="fail";var oe=24n,yn=oe*4n,Te=(1n<<yn)-1n,Nn=/^[0-9a-f]+$/;function Pt(e){if(!e||!Nn.test(e))throw new Error(`Invalid hex rank: ${e}`);return BigInt("0x"+e)}function Se(e,t=oe){if(e<0n)throw new Error("Negative rank not allowed");return e.toString(16).padStart(Number(t),"0")}function pe(e,t){if(!e&&!t)return Se(Te/2n,oe);let o=e?Pt(e):0n,n=t?Pt(t):Te;if(n<=o)return Se(Te/2n,oe);let r=(o+n)/2n;return r===o||r===n?"":Se(r,oe)}function U(){return Se(Te/2n,oe)}var v=e=>Object.values(l().nodes).filter(t=>!!t&&!t.isDeleted&&t.parentNodeId===e).sort((t,o)=>t.rank.localeCompare(o.rank)),Rt=(e,t)=>e.findIndex(o=>o.id===t),Xe=(e,t={type:"end"})=>{if(e.length===0)return f("Resolved rank",U());switch(t.type){case"start":{let o=e[0];return o?f("Resolved rank",pe(void 0,o.rank)):c("Unable to resolve first sibling")}case"end":{let o=e[e.length-1];return o?f("Resolved rank",pe(o.rank,void 0)):c("Unable to resolve last sibling")}case"before":{let o=Rt(e,t.siblingId);if(o<0)return c("Sibling not found");let n=o>0?e[o-1]:void 0,r=e[o];return r?f("Resolved rank",pe(n?.rank,r.rank)):c("Sibling not found")}case"after":{let o=Rt(e,t.siblingId);if(o<0)return c("Sibling not found");let n=e[o],r=o<e.length-1?e[o+1]:void 0;return n?f("Resolved rank",pe(n.rank,r?.rank)):c("Sibling not found")}}};var fe=(e,t)=>{let{nodes:o}=l(),n=o[e];if(!n)return c("Node not found");if(n.context===t)return f("Resolved ancestor node",n);let r=n.parentNodeId?o[n.parentNodeId]:void 0;for(;r;){if(r.context===t)return f("Resolved ancestor node",r);r=r.parentNodeId?o[r.parentNodeId]:void 0}return c(`No ancestor found for context: ${t}`)},kt=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],In=(e,t)=>{let{nodes:o}=l(),n=o[e];for(;n?.parentNodeId;){if(n.parentNodeId===t)return!0;n=o[n.parentNodeId]}return!1};function hn(e){return Ee(e).replace(/\s+/g," ").trim()}function Ft(e,t){if(!e)return[];let o=[],n=new Set,{renderedChildrenIndex:r}=l(),i=s=>{let a=r[s.id];if(s.title===t&&Et(s))for(let m of a??[]){if(!m)continue;let u=String(m.props?.value??m.title??""),C=hn(u),g=C.toLowerCase();C&&!n.has(g)&&(n.add(g),o.push(C))}for(let m of a??[])i(m)};return i(e),o.sort((s,a)=>s.localeCompare(a))}var x={editValue(e,t){let{nodes:o}=l(),n=o[e];if(!n)return c("Edit target node not found");let r={...n,props:{...n.props,value:t}};return x.updateNode(r),f("Issue description updated",{markdown:t})},getExistingTags(){let{rootNodeId:e,nodes:t}=l(),o=t[e];return o?Ft(o,"Tags"):[]},getExistingAssignees(){let{rootNodeId:e,nodes:t}=l(),o=t[e];return o?Ft(o,"Assignees"):[]},moveNode(e,t,o={type:"end"}){let{rootNodeId:n}=l(),r=this.getNode(e),i=this.getNode(t);if(!r)return c("Node not found");if(!i)return c("Target parent not found");if(n===e)return c("Cannot move root node");if(e===t)return c("Cannot move node into itself");if(In(t,e))return c("Cannot move node into its own descendant");let s=v(t).filter(u=>u.id!==e),a=Xe(s,o);if(h(a))return a;let m={...r,parentNodeId:t,rank:a.data};return this.updateNodeAndSelectInParent(m),f("Moved node successfully",m)},tombstoneNode(e){let{nodes:t,currentNodeId:o,rootNodeId:n}=l(),r=this.getNode(e);if(!r)return c("Node not found");if(n===e)return c("Cannot delete root node");let i=new Set,s=u=>{let C=t[u];if(!(!C||i.has(u))){i.add(u);for(let g of v(C.id))s(g.id)}};s(e);let a={...structuredClone(t)};for(let u of i){if(!a[u])return c("Unable to locate node to delete");a[u]={...a[u],isDeleted:!0}}if(!o)return c("Unable to delete undefined");let m=i.has(o)?r.parentNodeId:o;return E({nodes:a,currentNodeId:m}),f("Successfully tomb stoned",r)},createContributor(e){return K(t=>({...t,contributors:{...t.contributors,[e.id]:e}})),e},assign(e,t){let o=x.getContributor(t),n=x.getNode(e);if(!n||!o)return c("Unable assign contributor to issue");let r=v(n.id).find(a=>a?.title==="Assignees");if(!r)return c("Unable to locate assignees field");let i=kt(r.props.value),s=i.includes(t)?i:[...i,t];return x.updateNode({...r,props:{...r.props,value:s}}),o},createTag(e){return K(t=>({...t,tags:{...t.tags,[e.id]:e}})),e},tag(e,t){let o=x.getTag(t),n=x.getNode(e);if(!o)return c("Unable to add tag, missing tag");if(!n)return c("Unable to add tag, missing target");let r=v(n.id).find(({title:a})=>a==="Tags");if(!r)return c("Unable to locate tags field");let i=kt(r.props.value),s=i.includes(t)?i:[...i,t];return x.updateNode({...r,props:{...r.props,value:s}}),f("Tag added",o)},createNodeAtPosition(e,t={type:"end"}){if(!e.parentNodeId){let i={...e,rank:U()};return this.createNode(i),f("Created node",i)}let o=v(e.parentNodeId),n=Xe(o,t);if(h(n))return n;let r={...e,rank:n.data};return this.createNode(r),f("Created node",r)},createNode(e){return K(t=>({...t,nodes:{...t.nodes,[e.id]:e}})),e},updateNode(e){return K(t=>({...t,nodes:{...t.nodes,[e.id]:e}})),e},updateNodeAndSelectInParent(e){return K(t=>{let o={...t.nodes,[e.id]:e},n=Object.values(o).filter(r=>!r.isDeleted&&r.parentNodeId===e.parentNodeId).sort((r,i)=>r.rank.localeCompare(i.rank));return{...t,nodes:o,currentNodeId:e.parentNodeId,selectedIndex:n.findIndex(({id:r})=>r===e.id)}}),e},getContributor(e){return l().contributors[e]},getTag(e){return l().tags[e]},getNode(e){return l().nodes[e]},getSiblings:e=>Object.values(l().nodes).filter(t=>!t.isDeleted&&t.parentNodeId===e).sort((t,o)=>t.rank.localeCompare(o.rank))};var ne={urgent:"red",critical:"red",important:"red",blocker:"red",asap:"red",immediate:"red",fail:"red",failure:"red",broken:"red",bug:"red",error:"red",incident:"red",outage:"red",production:"red",crash:"red",security:"red",warning:"yellow",warn:"yellow",risky:"yellow",risk:"yellow",attention:"yellow",pending:"yellow",review:"yellow","needs-review":"yellow",qa:"yellow",testing:"yellow",test:"yellow",validate:"yellow",verification:"yellow",staging:"yellow",check:"yellow","follow-up":"yellow",followup:"yellow",waiting:"yellow",blocked:"yellow",hold:"yellow",done:"green",complete:"green",completed:"green",success:"green",ok:"green",stable:"green",resolved:"green",fixed:"green",closed:"green",merged:"green",released:"green",deployed:"green",approved:"green",verified:"green",working:"green",healthy:"green",pass:"green",passing:"green",info:"blue",information:"blue",note:"blue",docs:"blue",documentation:"blue",doc:"blue",guide:"blue",help:"blue",explanation:"blue",detail:"blue",details:"blue",context:"blue",design:"blue",discussion:"blue",proposal:"blue",idea:"blue",feature:"magenta",enhancement:"magenta",improvement:"magenta",refactor:"magenta",refactoring:"magenta",cleanup:"magenta",optimize:"magenta",optimization:"magenta",perf:"magenta",performance:"magenta",upgrade:"magenta",migration:"magenta",modernize:"magenta",debt:"magenta",todo:"cyan",next:"cyan",planned:"cyan",plan:"cyan",future:"cyan",backlog:"cyan",investigate:"cyan",explore:"cyan",prototype:"cyan"};var re=()=>({[y.DELETE]:["confirm"],[y.VIEW]:["dense","wide"],[y.TAG]:[...new Set([...Object.keys(ne),...x.getExistingTags()])],[y.ASSIGN]:x.getExistingAssignees(),[y.HELP]:[],[y.RENAME]:[],[y.NEW]:["issue","swimlane","board"]});var Ot=["frontend","backend","infrastructure","architecture","integration","configuration","implementation","application","deployment","environment","framework","platform","service","component","module","gateway","pipeline","containerization","orchestrator","exception","incident","defect","regression","degradation","malfunction","instability","intermittent","reproducibility","reproduction","investigation","triage","workaround","mitigation","remediation","optimization","stabilization","refinement","failure","outage","blocking","criticality","severity","escalation","diagnostics","analysis","resolution","corruption","inconsistency","validation","verification","authorization","authentication","confidentiality","availability","accessibility","reliability","compliance","governance","encryption","decryption","integrity","auditing","traceability","accountability","protection","privileges","permissions","dependency","orchestration","provisioning","synchronization","compatibility","incompatibility","interoperability","observability","instrumentation","telemetry","loadbalancing","discovery","registration","scheduling","coordination","distribution","isolation","virtualization","serialization","deserialization","initialization","instantiation","propagation","aggregation","consolidation","normalization","standardization","transformation","reconciliation","correlation","processing","indexing","partitioning","enrichment","validation","filtering","streaming","batching","concurrency","parallelism","contention","deadlock","throttling","ratelimiting","backpressure","fragmentation","saturation","exhaustion","partitioning","replication","redundancy","failover","deprecation","obsolescence","starvation","overload","underutilization","latency","throughput","refactoring","modularization","encapsulation","abstraction","extensibility","configurability","maintainability","recoverability","sustainability","readability","testability","debuggability","reusability","simplicity","consistency","performance","functionality","requirement","recommendation","improvement","enhancement","clarification","documentation","description","acceptance","criteria","estimation","prioritization","dependency","deliverable","milestone","iteration"];var An=Object.values(y),Bt=({inputToMatch:e,command:t,lastWord:o,target:n})=>{if(n==="command")return Qe(o,be({wordList:An,inputToMatch:e,overlapThreshold:1}));if(t&&n==="modifier"){let i=be({wordList:re()[t],inputToMatch:e,overlapThreshold:1});if(i)return Qe(o,i)}let r=be({wordList:Ot,inputToMatch:e,overlapThreshold:1});return r?Qe(o,r):{hint:"",hints:[],overlap:0,remainder:""}},Qe=(e,t)=>{let o=t[0]??"",n=o?o+" ":"",r=`${e} `,i=Ae(r.toLowerCase(),n.toLowerCase()),s=n.slice(i);return{hint:n,hints:t,overlap:i,remainder:s}};var Le=()=>({validity:F.Valid}),Ze=e=>({validity:F.Invalid,message:e}),we=e=>e.length===0,En=(e,t)=>{if(e.length<=t)return[...e];let o=[],n=new Set;for(;o.length<t;){let r=Math.floor(Math.random()*e.length);n.has(r)||(n.add(r),o.push(e[r]))}return o},Me=(e,t,o="",n=2)=>t.length?`${e}${En(t,n).map(r=>`"${r}"`).join(" or ")}${o}`:"",Ut=()=>Le(),bn=e=>({modifier:t})=>t===e?Le():Ze(we(t)?`to proceed, enter "${e}"`:void 0),Wt=({list:e,hint:t})=>({modifier:o})=>e.includes(o)?Le():Ze(we(o)?t:void 0),Vt=({hint:e})=>({modifier:t,inputString:o})=>we(t)&&we(o)?Ze(e):Le(),J=e=>re()[e],Tn={[y.NEW]:e=>Wt({list:J(y.NEW),hint:Me("",J(y.NEW),"",3)})(e),[y.HELP]:Ut,[y.RENAME]:Ut,[y.DELETE]:e=>bn(J(y.DELETE)[0]??"confirm")(e),[y.VIEW]:e=>Wt({list:J(y.VIEW),hint:Me("",J(y.VIEW))})(e),[y.TAG]:e=>Vt({hint:Me("provide tag name like ",J(y.TAG),", etc.")})(e),[y.ASSIGN]:e=>Vt({hint:Me("provide user name like ",J(y.ASSIGN),", etc.")})(e)},Ht=Object.fromEntries(Object.entries(Tn).map(([e,t])=>[e,{validate:(o,n,r)=>t({modifier:n,command:o,inputString:r})}]));var S={None:"none",ViewHelp:"view-help",Rename:"rename",Delete:"delete",SetView:"set-view",NewItem:"add-new-item",TagTicket:"ticket-tag",AssignUserToTicket:"ticket-assign-user"};var Kt=e=>Object.values(y).includes(e),_t=({command:e,modifier:t,inputString:o})=>{if(e){let{message:n,validity:r}=Ht[e].validate(e,t,o);return{command:e,modifier:t,infoMessage:n??"",inputString:o,validity:r}}return{validity:F.None,infoMessage:"",command:e,inputString:"",modifier:""}};var zt=e=>{let t=e.trimStart(),o=Mn(t),n=(o[0]??"").trimStart().trimEnd(),r=(o[1]??"").trimStart().trimEnd(),i=wn(e),s=Kt(n)?n:null,a=s!==null,m=n!=="",u=e.endsWith(" "),C=s?re()[s]:[],g=s&&C.includes(r)?r:"",N="word";o.length<=1?N="command":o.length===2&&(N="modifier");let A=Sn(t,s,g);return{raw:e,trimmedStart:t,words:o,firstWord:n,lastWord:i,hasCommand:m,command:s,isCommandKeyword:a,isLastWordCompleted:u,modifier:g,target:N,inputToMatch:i,inputString:A}},Sn=(e,t,o)=>{let n=e;return t&&n.startsWith(t)&&(n=n.slice(t.length)),n=n.replace(/^\s+/,""),o&&n.startsWith(o)&&(n=n.slice(o.length),n=n.replace(/^\s+/,"")),n},Mn=e=>e?e.split(/\s+/):[],wn=e=>e.trimEnd().split(/\s+/).at(-1)??"";var $t=" ",w={commandHistory:[],value:"",commandHistoryIndex:-1,autoCompletion:{hint:"",hints:[],remainder:"",overlap:0},cursorPosition:0,commandIsPending:!1,commandMeta:{command:null,modifier:"",infoMessage:"",inputString:"",validity:F.None}},et=new Set,jt=()=>{for(let e of et)e()},Gt=e=>(et.add(e),()=>et.delete(e)),_=e=>{let o=e(w),n=o.cursorPosition===o.value.length,r=zt(o.value);w={...o,commandMeta:_t(r),autoCompletion:n?Bt(r):{hint:"",hints:[],remainder:"",overlap:0}},jt()},qt=({message:e,result:t})=>{let o=structuredClone(w);o.commandMeta={...o.commandMeta,infoMessage:e??"",validity:t==="fail"?"invalid":"valid"},o.commandIsPending=!0,w=o,jt()},tt=e=>{_(t=>({...t,cursorPosition:Math.max(0,Math.min(t.value.length,t.cursorPosition+e))}))},ot=e=>{_(t=>{let{value:o,cursorPosition:n}=t,r=n;if(e==="left"){for(;r>0&&o[r-1]===" ";)r--;for(;r>0&&o[r-1]!==" ";)r--}else{for(;r<o.length&&o[r]!==" ";)r++;for(;r<o.length&&o[r]===" ";)r++}return{...t,cursorPosition:r}})},Jt=()=>{_(e=>{let t=e.value.slice(e.cursorPosition),o=Math.max(0,e.cursorPosition-1);return{...e,value:e.value.slice(0,o)+t,cursorPosition:o,commandIsPending:!1}})},Yt=()=>{_(e=>{let{value:t,cursorPosition:o}=e,n=o;for(;n>0&&t[n-1]===" ";)n--;for(;n>0&&t[n-1]!==" ";)n--;let r=t.slice(o);return{...e,value:t.slice(0,n)+r,cursorPosition:n,commandIsPending:!1}})},Y=e=>{_(t=>{let o=Math.max(0,Math.min(t.cursorPosition,t.value.length)),n=t.value.slice(0,o),r=t.value.slice(o),i=e(n,t.autoCompletion),s=i+r,a=Math.max(0,Math.min(i.length,s.length));return{...t,value:s,cursorPosition:a,commandIsPending:!1}})},Xt=()=>{_(e=>({...e,commandIsPending:!0}))},Qt=()=>{_(e=>({...e,commandHistory:[e.value,...e.commandHistory].slice(0,20),commandHistoryIndex:-1,commandIsPending:!1})),Ln()},Zt=()=>{_(e=>{let t=Math.min(e.commandHistoryIndex+1,e.commandHistory.length-1),o=e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:o,cursorPosition:o.length}})},eo=()=>{_(e=>{let t=Math.max(e.commandHistoryIndex-1,-1),o=t===-1?"":e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:o,cursorPosition:o.length}})},Ln=()=>Y(()=>""),$=()=>w,to=()=>{let[e,...t]=w.value.split($t);return t.join($t).trim()};function Dn(e){switch(e.name){case"up":case"down":case"left":case"right":return e.name;case"k":return"up";case"j":return"down";case"h":return"left";case"l":return"right";default:return null}}function Pn(e,t,o){let n=l().currentNode.childNavigationAcrossParents;switch(t){case"up":return e==="vertical"?o.prevItem:n?o.prevContainer:null;case"down":return e==="vertical"?o.nextItem:n?o.nextContainer:null;case"left":return e==="horizontal"?o.prevItem:n?o.prevContainer:null;case"right":return e==="horizontal"?o.nextItem:n?o.nextContainer:null}}function oo(e,t){let o=$();if(e.sequence===":"&&o.value==="")return"initCommandLine";if(t===d.MOVE)switch(e.name){case"m":case"return":return"paste"}if(t===d.COMMAND_LINE)return Tt(e,o.value);let n=Dn(e);if(n){let r=t===d.MOVE?{prevItem:"movePreviousItem",nextItem:"moveNextItem",prevContainer:"moveToPreviousContainer",nextContainer:"moveToNextContainer"}:{prevItem:"navPreviousItem",nextItem:"navNextItem",prevContainer:"navToPreviousContainer",nextContainer:"navToNextContainer"};return Pn(l().currentNode.childRenderAxis,n,r)}if(e.ctrl&&e.name==="c")return"exit";switch(e.name){case"i":return"edit";case"n":return"addItem";case"m":return"cut";case"d":return"Delete";case"e":case"return":return"confirm";case"space":return"confirm";case"v":return l().viewMode==="wide"?"SetViewDense":"SetViewWide";case"q":case"escape":return"exit";default:return null}}var X={workspace:(e,t)=>({id:e,title:t,rank:U(),isDeleted:!1,props:{},context:I.WORKSPACE,childRenderAxis:"vertical",parentNodeId:null}),board:(e,t,o)=>({id:e,title:t,rank:U(),isDeleted:!1,props:{},context:I.BOARD,childRenderAxis:"horizontal",parentNodeId:o}),swimlane:(e,t,o)=>({id:e,title:t,rank:U(),isDeleted:!1,props:{},context:I.SWIMLANE,childRenderAxis:"vertical",childNavigationAcrossParents:!0,parentNodeId:o}),field:(e,t,o,n)=>({id:e,title:t,rank:U(),isDeleted:!1,props:n,context:I.FIELD,childRenderAxis:"vertical",parentNodeId:o}),ticket:(e,t,o)=>({id:e,title:t,rank:U(),isDeleted:!1,props:{},context:I.TICKET,childRenderAxis:"vertical",parentNodeId:o})};var Rn={"init.workspace":e=>{let{id:t,name:o}=e.payload,n=X.workspace(t,o);return ro(n),x.createNodeAtPosition(n),f("Workspace initialized",n)},"add.workspace":e=>{let{id:t,name:o}=e.payload,n=X.workspace(t,o);return x.createNodeAtPosition(n),f("Added workspace",n)},"add.board":e=>{let{id:t,name:o,parentId:n}=e.payload,r=x.createNodeAtPosition(X.board(t,o,n));return h(r)?c("Unable to create board"):f("Added board",r.data)},"add.swimlane":e=>{let{id:t,name:o,parentId:n}=e.payload,r=x.createNodeAtPosition(X.swimlane(t,o,n));return h(r)?c("Unable to create swimlane"):f("Added swimlane",r.data)},"add.issue":e=>{let{id:t,name:o,parentId:n}=e.payload,r=x.createNodeAtPosition(X.ticket(t,o,n));return h(r)?c("Unable to create issue"):f("Added issue",r.data)},"add.field":e=>{let{id:t,name:o,parentId:n,value:r}=e.payload,i=x.createNodeAtPosition(X.field(t,o,n,{value:r}));return h(i)?c(`Unable to create field: ${o}`):f("Added field",i.data)},"edit.title":e=>{let{id:t,value:o}=e.payload,n=x.getNode(t);return n?(x.updateNode({...n,title:o}),f("Edited title",o)):c("Unable to locate node")},"delete.node":e=>{let{id:t}=e.payload;return x.tombstoneNode(t),f("Deleted node",t)},"tag.create":e=>{let{id:t,name:o}=e.payload,n=x.createTag({id:t,name:o});return f("Tag added",n.id)},"contributor.create":e=>{let{id:t,name:o}=e.payload,n=x.createContributor({id:t,name:o});return f("Contributor created",n.id)},"issue.tag":e=>{let{targetId:t,tagId:o}=e.payload;return x.tag(t,o),f("Issue tagged",o)},"issue.assign":e=>{let{contributorId:t,targetId:o}=e.payload;return x.assign(o,t),f("Assigned successfully",void 0)},"move.node":e=>{let{id:t,parentId:o,position:n}=e.payload,r=x.moveNode(t,o,n);return h(r)?c("Failed to move node"):f("Moved node",r.data.id)},"description.set":e=>{let{targetId:t,markdown:o}=e.payload,n=x.editValue(t,o);return h(n)?n:f("Set node value",n.data)}};function nt(e){let t=Rn[e.action];return t(e)}var no=e=>e.map(t=>nt(t));import io from"node:fs";import kn from"node:os";import so from"node:path";import{ulid as Fn}from"ulid";var On=".epiq",Bn="events",rt=e=>e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"unknown",ao=()=>{let e=process.env.EPIQ_ACTOR_ID;if(e?.trim())return rt(e);let t=process.env.GIT_AUTHOR_NAME||process.env.GIT_COMMITTER_NAME||process.env.USER||process.env.USERNAME;if(t?.trim())return rt(t);try{return rt(kn.userInfo().username)}catch{return"unknown"}},co=(e=process.cwd())=>so.join(e,On,Bn),Un=(e=process.cwd())=>{let t=ao();return so.join(co(e),`${t}.jsonl`)};function mo(e,t=process.cwd()){try{let o=ao(),n=co(t),r=Un(t);io.mkdirSync(n,{recursive:!0});let i={eventId:Fn(),actorId:o,event:e};return io.appendFileSync(r,`${JSON.stringify(i)}
3
- `,"utf8"),f("Event persisted",{path:r,entry:i})}catch(o){let n=o instanceof Error?o.message:"Unknown persist error";return c(`Failed to persist event: ${n}`)}}function D(e){let t=nt(e);if(t.result!==B.Success)return t;let o=mo(e);return o.result!==B.Success?c(o.message??"Failed to persist event"):t}function De(e){return e.map(t=>D(t))}var lo=()=>{let{currentNode:e,selectedIndex:t}=l(),n=v(e.id)[t];return n?f("Resolved selected child",n):c("Target node not found")};function it(e){let t=lo();if(h(t))return t;let{currentNode:o,nodes:n}=l();if(!o.parentNodeId)return c("Missing parent node id");let r=n[o.parentNodeId];if(!r)return c("Missing parent node");let i=v(r.id),s=i.findIndex(({id:m})=>m===o.id);if(s<0)return c("Current node not found among siblings");let a=i[s+e];return a?D({action:"move.node",payload:{id:t.data.id,parentId:a.id,position:{type:"end"}}}):c("Missing sibling node")}function st(e){let t=lo();if(h(t))return t;let{currentNode:o,selectedIndex:n}=l(),i=v(o.id)[n+e];return i?D({action:"move.node",payload:{id:t.data.id,parentId:o.id,position:{type:e===1?"after":"before",siblingId:i.id}}}):c("Missing sibling node")}var Pe=[{intent:"exit",mode:d.MOVE,description:"[esc] cancel",action:()=>{E({mode:d.DEFAULT})}},{intent:"cut",mode:d.DEFAULT,description:"[d] cut",action:()=>{l().selectedIndex!==-1&&E({mode:d.MOVE})}},{intent:"paste",mode:d.MOVE,action:()=>{E({mode:d.DEFAULT})}}],Re=[{intent:"movePreviousItem",mode:d.MOVE,action:()=>st(-1)},{intent:"moveNextItem",mode:d.MOVE,action:()=>st(1)}],uo=[{intent:"moveToNextContainer",mode:d.MOVE,action:()=>it(1)},{intent:"moveToPreviousContainer",mode:d.MOVE,action:()=>it(-1)}];var po={[I.WORKSPACE]:[...Pe,...Re],[I.BOARD]:[...Pe,...Re],[I.SWIMLANE]:[...Pe,...Re,...uo],[I.TICKET]:[],[I.FIELD]:[],[I.FIELD_LIST]:[]};import{spawnSync as jn}from"node:child_process";import Gn from"node:os";import Co from"node:path";import{ulid as qn}from"ulid";import{accessSync as Wn,copyFileSync as Vn,existsSync as ke,mkdirSync as fo,readdirSync as go,readFileSync as Hn,renameSync as Kn,rmSync as _n,statSync as xo,unlinkSync as zn,writeFileSync as $n}from"node:fs";import ie from"node:path";var j={writeToFile:(e,t)=>{try{let o=ie.dirname(e);ke(o)||fo(o,{recursive:!0});let n=typeof t=="string"?t:JSON.stringify(t,null,2);$n(e,n,"utf-8")}catch(o){logger.error(`Failed to write file at ${e}:`,o)}},readFile:e=>{try{return Hn(e,"utf-8")}catch(t){return logger.error(`Failed to read file at ${e}:`,t),null}},readFileJSON(e){try{let t=j.readFile(e);return t===null?null:JSON.parse(t)}catch(t){return logger.error(`Failed to read JSON at ${e}:`,t),null}},dirExists:e=>{try{return ke(e)&&xo(e).isDirectory()}catch{return!1}},async fileExists(e){try{return await Wn(e),!0}catch{return!1}},mkDir:e=>fo(e,{recursive:!0}),locateFolder:e=>{let t=process.cwd(),{root:o}=ie.parse(t);for(;;){let n=ie.join(t,e);try{if(ke(n)&&xo(n).isDirectory())return n}catch{logger.error(`Unable to locate folder ${e}`)}if(t===o)break;t=ie.dirname(t)}return null},readFirstJSON(e){try{if(!j.dirExists(e))return null;let t=go(e).filter(n=>n.endsWith(".json")).sort()[0];if(!t)return null;let o=ie.join(e,t);return j.readFileJSON(o)}catch(t){return logger.error(`Could not read first JSON in folder ${e}`,t),null}},listDir:e=>{try{return j.dirExists(e)?go(e):[]}catch(t){return logger.error(`Failed to list dir ${e}`,t),[]}},rmFile(e){try{zn(e)}catch(t){t?.code!=="ENOENT"&&logger.error(`Unable to remove file ${e}`)}},rmDir(e){try{_n(e,{recursive:!0,force:!0})}catch(t){t?.code!=="ENOENT"&&logger.error(`Unable to remove dir ${e}`)}},moveFile(e,t,o){if(this.mkDir(ie.dirname(t)),!o?.overwrite&&ke(t))throw new Error(`moveFile: destination exists: ${t}`);o?.overwrite&&this.rmFile(t);try{Kn(e,t)}catch(n){if(n?.code==="EXDEV"){Vn(e,t),this.rmFile(e);return}throw n}}};function Jn(){return process.env.VISUAL||process.env.EDITOR||"vi"}function vo(e){let t=Jn(),o=Co.join(Gn.tmpdir(),"epiq");j.mkDir(o);let n=Co.join(o,qn());j.writeToFile(n,e??"");let i=/(^|\/)code(-insiders)?$/.test(t)?`${t} --wait "${n}"`:`${t} "${n}"`,s=jn(i,{stdio:"inherit",shell:!0});if(s.error)return console.error("Editor failed:",s.error),c("Editor failed");let a=j.readFile(n);if(a==null)return c("Unable to read edited file");let m=a.replace(/\r?\n$/,"");return f("Successfully edited",m)}var M={exit(){process.exit(0)},enterChildNode(){let e=l(),t=e.currentNode,o=Math.max(0,e.selectedIndex),n=v(t.id)[o];!n||t.context==="FIELD"||M.navigate({currentNode:n,selectedIndex:v(n.id).length?0:-1})},enterParentNode(){let{currentNode:e,nodes:t}=l();if(!e.parentNodeId){logger.info("Missing parent node id");return}let o=t[e.parentNodeId];if(!o){logger.error("Parent not found");return}let n=v(o.id),r=n.findIndex(({id:s})=>s===e.id),i=n.length===0?-1:r>=0?r:0;M.navigate({currentNode:o,selectedIndex:i})},navigateToNextItem:()=>yo(1),navigateToPreviousItem:()=>yo(-1),navigateToNextContainer:()=>No(1),navigateToPreviousContainer:()=>No(-1),navigate:({currentNode:e=l().currentNode,selectedIndex:t})=>{E({currentNodeId:e.id,selectedIndex:t})}},yo=e=>{let t=l(),o=v(t.currentNode.id).length;if(o===0)return;let r=(Math.max(0,t.selectedIndex)+e+o)%o;M.navigate({selectedIndex:r})},No=e=>{let{currentNode:t,nodes:o,selectedIndex:n}=l();if(!t.childNavigationAcrossParents)return;if(!t.parentNodeId){logger.error("Missing parent node id");return}let r=o[t.parentNodeId];if(!t||!r)return;let i=v(r.id),s=i.findIndex(N=>N.id===t.id);if(s<0)return;let a=i.at(s+e)??i.at(0);if(!a)return;let m=v(a.id),u=Math.max(0,m.length-1),C=Math.min(Math.max(0,n),u),g=m.length?C:-1;M.navigate({currentNode:a,selectedIndex:g})};var Io=[{intent:"addItem",mode:d.DEFAULT,description:"[a] Add item",action:()=>{E({mode:d.COMMAND_LINE}),Y(()=>`${y.NEW} `)}},{intent:"Delete",mode:d.DEFAULT,description:"[d] delete",action:()=>{E({mode:d.COMMAND_LINE}),Y(()=>`${y.DELETE} `)}},{intent:"initCommandLine",mode:d.DEFAULT,description:"[:] Toggle command line",action:()=>E({mode:d.COMMAND_LINE})},{intent:"confirm",mode:d.DEFAULT,description:"[ENTER] Confirm/Enter context",action:M.enterChildNode},{intent:"exit",mode:d.DEFAULT,description:"[ESC/Q] Exit context",action:M.enterParentNode},{mode:d.DEFAULT,description:"[ARROWS/HJKL] Navigate"},{intent:"navPreviousItem",mode:d.DEFAULT,action:M.navigateToPreviousItem},{intent:"navNextItem",mode:d.DEFAULT,action:M.navigateToNextItem},{intent:"navToPreviousContainer",mode:d.DEFAULT,action:M.navigateToPreviousContainer},{intent:"navToNextContainer",mode:d.DEFAULT,action:M.navigateToNextContainer},{intent:"edit",mode:d.DEFAULT,action:()=>{let{currentNode:e}=l();if(!e)return c("No current node");let t=v(e.id).find(i=>i?.title==="Description");if(!t)return c("Description field not found");let o=t.props.value;if(typeof o!="string")return c("Description field is not a text field");let n=vo(o);if(logger.debug("editResult",n),h(n))return c("Failed to edit description");let r=n.data;return r===o?f("No changes made",void 0):D({action:"description.set",payload:{targetId:t.id,markdown:r}})}},{intent:"SetViewDense",mode:d.DEFAULT,action:()=>E({viewMode:"dense"})},{intent:"SetViewWide",mode:d.DEFAULT,action:()=>E({viewMode:"wide"})}];var ho=e=>{let{context:t}=l()?.currentNode;if(!t)return S.None;switch(e){case y.DELETE:return S.Delete;case y.HELP:return S.ViewHelp;case y.TAG:return S.TagTicket;case y.ASSIGN:return S.AssignUserToTicket;case y.VIEW:return S.SetView;case y.RENAME:return S.Rename;case y.NEW:return S.NewItem;default:return S.None}};import{ulid as Oe}from"ulid";import{monotonicFactory as Yn}from"ulid";var Fe=Yn(),Ao=({name:e,parentId:t})=>{let o=Fe(),n=Fe(),r=Fe(),i=Fe();return[{action:"add.issue",payload:{id:o,name:e,parentId:t}},{action:"add.field",payload:{id:n,name:"Description",parentId:o,value:""}},{action:"add.field",payload:{id:r,name:"Assignees",parentId:o,value:""}},{action:"add.field",payload:{id:i,name:"Tags",parentId:o,value:""}}]};var at=(e,t)=>{let o=e.find(n=>n.context===t);return o!==void 0?f("Found node",o):c("Unable to find node in breadcrumb")};var Xn=e=>Object.values(l().tags).find(t=>t.name===e),Qn=e=>Object.values(l().contributors).find(t=>t.name===e),Eo=[{intent:S.Delete,mode:d.COMMAND_LINE,action:()=>{let{currentNode:e,selectedIndex:t}=l(),o=v(e.id)[t];return o?D({action:"delete.node",payload:{id:o.id}}):c("Unable to resolve child to delete")},onSuccess:()=>E({mode:d.DEFAULT})},{intent:S.ViewHelp,mode:d.COMMAND_LINE,action:()=>(E({mode:d.HELP}),f("Viewing help",null))},{intent:S.NewItem,mode:d.COMMAND_LINE,action:(e,t)=>{if(!t.inputString)return c(`provide a name for your ${t.modifier}`);let o=n=>{let r=D(n);if(h(r))return r;let i=x.getNode(r.data.id);if(!i)return c("Created node not found");if(!i.parentNodeId)return r;let s=x.getNode(i.parentNodeId);return s?(M.navigate({currentNode:s,selectedIndex:x.getSiblings(i.parentNodeId).findIndex(({id:a})=>a===i.id)}),r):c("Parent node not found")};if(t.modifier==="board"){let{rootNodeId:n}=l(),r=x.getNode(n);return r?o({action:"add.board",payload:{id:Oe(),name:t.inputString,parentId:r.id}}):c("Workspace not found")}if(t.modifier==="swimlane"){let n=at(l().breadCrumb,"BOARD");return h(n)?c("Unable to add swimlane in this context"):o({action:"add.swimlane",payload:{id:Oe(),name:t.inputString,parentId:n.data.id}})}if(t.modifier==="issue"){let n=at(l().breadCrumb,"SWIMLANE");if(h(n))return c("Unable to add issue in this context");let r=De(Ao({name:t.inputString,parentId:n.data.id}));if(r.filter(h).length)return c("Issue create failed: "+r.filter(h).map(s=>s.message).join(", "));let[i]=r;if(!i||h(i))return c("Issue creation failed");M.navigate({currentNode:n.data,selectedIndex:x.getSiblings(i.data.parentNodeId).findIndex(({id:s})=>s===i.data.id)})}return Dt()},onSuccess:()=>E({mode:d.DEFAULT})},{intent:S.SetView,mode:d.COMMAND_LINE,action:()=>{let{commandMeta:e}=$();return e.validity===F.Invalid?c("Invalid command "+B):(K(t=>({...t,viewMode:e.modifier==="wide"?"wide":e.modifier==="dense"?"dense":t.viewMode})),f("View set",null))},onSuccess:()=>E({mode:d.DEFAULT})},{intent:S.Rename,mode:d.COMMAND_LINE,action:()=>{let{currentNode:e,selectedIndex:t}=l(),o=v(e.id)[t];if(!o)return c("Missing node");let n=to();return n?D({action:"edit.title",payload:{id:o.id,value:n}}):c("Provide a new name")},onSuccess:()=>E({mode:d.DEFAULT})},{intent:S.TagTicket,mode:d.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=$().commandMeta,o=e||t;if(!o)return c("Provide a tag");let{selectedIndex:n,currentNode:r}=l(),i=v(r.id)[n];if(!i)return c("Selection node not found");if(!fe(i.id,"TICKET").data)return c("Unable to tag issue in this context");let a=Xn(o),m=Oe();return a||(m=D({action:"tag.create",payload:{id:m,name:o}}).data),logger.debug("existingTag",a,m),m?D({action:"issue.tag",payload:{targetId:i.id,tagId:m}}):c("Unable to resolve tag id")},onSuccess:()=>E({mode:d.DEFAULT})},{intent:S.AssignUserToTicket,mode:d.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=$().commandMeta,o=e||t;if(!o)return c("Provide an assignee");let{selectedIndex:n,currentNode:r}=l(),i=v(r.id)[n];if(!i)return c("Selection node not found");let s=fe(i.id,"TICKET").data;if(!s)return c("Unable to tag issue in this context");let a=Qn(o),m=Oe();return a||(m=D({action:"contributor.create",payload:{id:m,name:o}}).data),m?D({action:"issue.assign",payload:{targetId:s.id,contributorId:m}}):c("Unable to resolve contributor id")},onSuccess:()=>E({mode:d.DEFAULT})}];var bo=(...e)=>{let{commandMeta:{command:t,validity:o,modifier:n,inputString:r}}=$();if(!t)return;let i=ho(t);if(Xt(),o===F.Invalid)return;let s=Eo.find(m=>m.intent===i),a=s?.action?.(s,{command:t,inputString:r,modifier:n});if(a&&a.result===B.Fail)return qt(a);Qt(),s?.onSuccess?.()};var To=[{intent:"viewHelp",mode:d.DEFAULT,action:()=>E({mode:d.HELP})},{intent:"exit",mode:d.HELP,action:()=>E({mode:d.DEFAULT})},{intent:"confirm",mode:d.COMMAND_LINE,action:(...e)=>{bo(...e)}},{intent:"MoveCursorLeft",mode:d.COMMAND_LINE,action:()=>{tt(-1)}},{intent:"MoveCursorRight",mode:d.COMMAND_LINE,action:()=>{tt(1)}},{intent:"MoveCursorLeftOfWord",mode:d.COMMAND_LINE,action:()=>ot("left")},{intent:"MoveCursorRightOfWord",mode:d.COMMAND_LINE,action:()=>ot("right")},{intent:"exitCommandLine",mode:d.COMMAND_LINE,action:()=>{E({mode:d.DEFAULT})}},{intent:"autoCompleteCommand",mode:d.COMMAND_LINE,action:()=>{Y((e,{remainder:t})=>t?e+t:e)}},{intent:"captureInput",mode:d.COMMAND_LINE,action:(e,{sequence:t})=>Y(o=>o+t)},{intent:"eraseInput",mode:d.COMMAND_LINE,action:()=>Jt()},{intent:"EraseInputWord",mode:d.COMMAND_LINE,action:()=>Yt()},{intent:"getLastCommandFromHistory",mode:d.COMMAND_LINE,action:()=>Zt()},{intent:"getNextCommandFromHistory",mode:d.COMMAND_LINE,action:()=>eo()}];var So="Press : for command line",Mo="HJKL (navigate)",wo="Q (exit)",Zn="I (edit)",Lo="E (enter)",er="M (move)",Do="HJKL (move issue)",tr="M (move confirm)",dt={[I.WORKSPACE]:[Mo],[I.BOARD]:[So],[I.BOARD+d.COMMAND_LINE]:[],[I.SWIMLANE]:[So,Mo,er],[I.TICKET+d.HELP]:[wo],[I.SWIMLANE+d.HELP]:[wo],[I.TICKET]:[Zn,Lo],[I.FIELD]:[],[I.SWIMLANE+d.MOVE]:[Do,tr],[I.TICKET+d.MOVE]:[Do,Lo]};function Po(e,t,o){let n=t[e];if(!n)return c("buildBreadCrumb(): current node not found");let r=[],i=n;for(;i&&(r.push(i),!(i.id===o||!i.parentNodeId));)i=t[i.parentNodeId];let s=r[r.length-1];return!s||s.id!==o?c("buildBreadCrumb(): node is not connected to root"):(r.reverse(),f("Breadcrumb built",r))}var Ro=e=>{let t={};for(let o of e)o.intent&&(t[o.mode]||(t[o.mode]={}),t[o.mode][o.intent]=o);return t};var Be,ct=new Set,ko=()=>{for(let e of ct)e()},nr=e=>(ct.add(e),()=>ct.delete(e));function Fo(e){let{currentNodeId:t,mode:o,rootNodeId:n,nodes:r}=e;if(!t)return c("derive(): currentNodeId is missing");if(!n)return c("derive(): rootNode is missing");if(!r[n])return c("derive(): unable to find root node");let s=r[t];if(!s)return logger.error("Unable to derive state, currentNode not found"),c("Unable to derive state, currentNode not found");let a=Po(t,r,n);if(h(a))return logger.error(a.message),a;let m=a.data,{context:u}=s,C=dt[u+o]??dt[u]??[],g=[...Io,...po[u]??[],...To],N=Ro(g);return f("Derived successfully",{...e,currentNode:s,breadCrumb:m,availableHints:C,availableActions:g,actionIndex:N,renderedChildrenIndex:rr(r)})}var l=()=>(Be||logger.error("State not initialized. Call initWorkspaceState() first."),Be);function ro(e){let t={tags:{},contributors:{},viewMode:"dense",mode:d.DEFAULT,nodes:{[e.id]:e},rootNodeId:e.id,currentNodeId:e.id,renderedChildrenIndex:{},selectedIndex:-1},o=Fo(t);if(h(o))return logger.error(o.message);Be=o.data,ko()}function K(e){let t=l(),o=e(t),n=Fo(o);if(h(n))return logger.error(n.message);Be=n.data,ko()}var E=e=>K(t=>({...t,...e}));var W=()=>or(nr,l,l),rr=e=>{let t={};for(let o of Object.values(e))!o.parentNodeId||o.isDeleted||((!o.parentNodeId||!t[o.parentNodeId])&&(t[o.parentNodeId]=[]),t[o.parentNodeId].push(o));for(let o of Object.keys(t))t[o].sort((n,r)=>{let i=e[n.id],s=e[r.id];return!i||!s?0:i.rank.localeCompare(s.rank)});return t};import{Box as We,Text as lt}from"ink";import Q from"react";var Ue={black:"black",red:"red",green:"green",yellow:"yellow",blue:"blue",cyan:"cyan",magenta:"magenta",white:"white",gray:"gray",grey:"grey",blackBright:"blackBright",redBright:"redBright",greenBright:"greenBright",yellowBright:"yellowBright",blueBright:"blueBright",cyanBright:"cyanBright",magentaBright:"magentaBright",whiteBright:"whiteBright"},mt={cyan:"#7DCFFF",cyanSoft:"#89DDFF",gray:"#C0CAF5",grayLight:"#9AA5CE",grayDark:"#565F89",blue:"#486aff"},p={accent:Ue.cyan,accent2:Ue.magenta,primary:Ue.white,secondary:Ue.gray};function ut(){let e=W(),t=e.nodes[e.rootNodeId],r=process.stdout.rows-1-3,i=process.stdout.columns||120,s=t?.id?v(t?.id):[];return Q.createElement(We,{flexDirection:"column",height:r,padding:1,borderStyle:"round",borderColor:p.secondary,width:i},Q.createElement(We,{padding:1,paddingTop:0,paddingBottom:0},Q.createElement(lt,null,"Select a board:")),Q.createElement(We,{padding:1,flexDirection:"column"},s.map((a,m)=>{let u=e.currentNode.context==="WORKSPACE"&&e.selectedIndex===m,g=v(a.id).flatMap(({id:N})=>v(N)).length;return Q.createElement(We,{key:a.id??m},Q.createElement(lt,{color:u?p.accent:p.secondary},u?"\u2E2C ":" "),Q.createElement(lt,{color:u?p.accent:p.secondary},a.title," (",g," issues)"))})))}import{Box as Nr}from"ink";import _e from"react";import{Box as gt,Text as xt}from"ink";import H from"react";import{Box as pt,Text as ir}from"ink";import Ve from"react";var Oo=({children:e=[],height:t,selectedIndex:o,itemHeight:n=1})=>{if(e.length===0)return null;let r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.ceil(n)),s=Math.max(1,Math.floor(r/i)),a=Math.max(0,Math.min(o,e.length-1)),m=Math.max(0,e.length-s),u=Math.min(m,Math.floor(a/s)*s),C=u+s,g=e.slice(u,C),N=e.length>s,A=r,b=N?Math.max(1,Math.floor(s/e.length*A)):A,T=Math.max(0,A-b),R=Math.max(1,e.length-s),O=N?Math.floor(u/R*T):0;return Ve.createElement(pt,{flexDirection:"row",height:r,width:"100%"},Ve.createElement(pt,{flexDirection:"column",flexGrow:1,height:r},g),Ve.createElement(pt,{flexDirection:"column",width:1,height:A},Array.from({length:A}).map((k,q)=>Ve.createElement(ir,{key:q,color:N&&q>=O&&q<O+b?p.accent:p.secondary},N?"\u2502":" "))))};import{Box as He,Text as gr}from"ink";import Z from"react";import{Text as dr}from"ink";import cr from"react";var sr=e=>{let t=0;for(let o=0;o<e.length;o++)t=e.charCodeAt(o)+((t<<5)-t),t|=0;return Math.abs(t)},ar=(e,t,o)=>{t/=100,o/=100;let n=(1-Math.abs(2*o-1))*t,r=e/60,i=n*(1-Math.abs(r%2-1)),s=0,a=0,m=0;r>=0&&r<1?(s=n,a=i):r>=1&&r<2?(s=i,a=n):r>=2&&r<3?(a=n,m=i):r>=3&&r<4?(a=i,m=n):r>=4&&r<5?(s=i,m=n):(s=n,m=i);let u=o-n/2,C=g=>Math.round((g+u)*255).toString(16).padStart(2,"0");return`#${C(s)}${C(a)}${C(m)}`},se=e=>{let o=sr(e)%360;return ar(o,65,45)};var mr=e=>e.toLowerCase().trim(),lr=(e,t=ne)=>{let o=mr(e);return t[o]?t[o]:se(o)},ae=({id:e})=>{let t=x.getContributor(e);if(t)return cr.createElement(dr,{color:lr(t.name)}," @"+t.name+" ")};import{Text as ur}from"ink";import pr from"react";var fr=e=>e.toLowerCase().trim(),ft=(e,t=ne)=>{let o=fr(e);return t[o]?t[o]:se(o)},de=({id:e})=>{let t=x.getTag(e);if(t)return pr.createElement(ur,{backgroundColor:ft(t.name),color:p.primary}," "+t.name+" ")};var Bo=({width:e,ticket:t,isSelected:o})=>{let n=e-12,r=St(Ee(t.title),n),i=v(t.id),s=u=>i.filter(C=>C.title===u&&Array.isArray(C.props.value)).flatMap(C=>C.props.value),a=s("Tags").map(x.getTag),m=s("Assignees").map(x.getContributor);return Z.createElement(He,{borderStyle:"round",width:e-6,height:4,flexDirection:"column",borderColor:o?p.accent:p.secondary,justifyContent:"space-between"},Z.createElement(He,{borderBottom:!0},Z.createElement(He,{paddingLeft:1,flexDirection:"column"},Z.createElement(gr,{color:p.primary},r))),Z.createElement(He,{flexDirection:"row",paddingLeft:1},a.map(u=>Z.createElement(de,{key:u?.id,id:u?.id??""})),m.map(u=>Z.createElement(ae,{key:u?.id,id:u?.id??""}))))};import{Box as ge,Text as xe}from"ink";import V from"react";var xr=(e,t)=>e.length>=t?e.slice(0,t-3)+"...":e,Uo=({width:e,ticket:t,isSelected:o,index:n,mode:r})=>{let i=v(t.id),s=b=>i.filter(T=>T.title===b&&Array.isArray(T.props.value)).flatMap(T=>T.props.value),a=s("Tags").map(x.getTag),m=s("Assignees").map(x.getContributor),u=1,C=a.reduce(b=>b+2+u,0),g=a.map((b,T)=>V.createElement(ge,{key:`${b}-${T}`,paddingRight:u},V.createElement(xe,{color:ft(b?.name??"")},"\u25A0"))),N=m.map((b,T)=>V.createElement(ge,{key:`${b}-${T}`,paddingRight:u},V.createElement(xe,{color:se(b?.name??"")},"@"+b?.name.at(0)))),A=o?p.accent:r===d.MOVE?p.secondary:p.primary;return V.createElement(ge,{borderBottom:!0,justifyContent:"space-between"},V.createElement(ge,null,o?V.createElement(xe,{color:A},"\u2E2C "):V.createElement(xe,{color:p.secondary},n+1+". "),V.createElement(xe,{color:A},xr(t.title,e-C-15))),V.createElement(ge,null,g,N))};var Cr=({swimlane:e,isSelected:t,width:o,height:n,isDense:r,isFocused:i,listSelectedIndex:s,mode:a})=>{let{renderedChildrenIndex:m}=W(),u=m[e.id]??[],C=`${e.title} (${u.length})`,g=3,N=r?1:4,A=n-g-(r?2:1),b=H.createElement(gt,{borderStyle:"round",borderColor:p.secondary,justifyContent:"flex-start",borderLeft:!1,borderTop:!1,borderRight:!1},H.createElement(xt,{bold:!0,color:t?p.accent:p.primary},t?"\u2E2C ":" "),H.createElement(xt,{bold:!0,color:t?p.accent:p.primary},C)),T=(R,O)=>{let k=i&&s===O;return r?H.createElement(Uo,{key:R.id,index:O,width:o,ticket:R,isSelected:k,mode:a}):H.createElement(Bo,{key:R.id,width:o,ticket:R,isSelected:k})};return H.createElement(gt,{flexDirection:"column",width:o,borderStyle:"round",borderColor:t?p.accent:p.secondary,paddingRight:1,paddingLeft:1,height:n},b,H.createElement(gt,{padding:r?1:0},u.length>0&&H.createElement(Oo,{selectedIndex:s,height:A,itemHeight:N},u.map(T)),i&&s===-1&&H.createElement(xt,{color:p.accent},"\u2E2C")))},Wo=H.memo(Cr);import{Box as yr}from"ink";import vt from"react";import{Box as Ct,Text as vr}from"ink";import ce from"react";var Vo=({items:e,title:t,selected:o})=>ce.createElement(Ct,{flexDirection:"column",paddingTop:1},ce.createElement(vr,{color:p.secondary}," "+t,":"),ce.createElement(Ct,{flexDirection:"row",borderStyle:"round",borderColor:o?p.accent:p.secondary,paddingLeft:1,paddingRight:1},e.map(n=>ce.createElement(Ct,{paddingRight:1},t==="Assignees"?ce.createElement(ae,{id:n}):t==="Tags"?ce.createElement(de,{id:n}):""))));import{Box as Ho,Text as Ko}from"ink";import Ke from"react";var _o=({field:e,selected:t})=>Ke.createElement(Ho,{flexDirection:"column",paddingTop:1},Ke.createElement(Ko,{color:t?p.primary:p.secondary}," "+e.title,":"),Ke.createElement(Ho,{flexDirection:"row",borderStyle:"round",borderColor:t?p.accent:p.secondary,paddingLeft:1,paddingRight:1},Ke.createElement(Ko,null,e.props.value||" ")));var zo=({ticket:e,height:t})=>{let{selectedIndex:o,currentNode:n}=W(),r=process.stdout.columns||120,i=n.id===e.id,s=v(e.id);return vt.createElement(yr,{width:r,flexDirection:"column",paddingTop:1,paddingLeft:1,paddingRight:1,minHeight:t},s.map((a,m)=>Array.isArray(a.props.value)?vt.createElement(Vo,{key:a.id,items:a.props.value,title:a.title,selected:i&&o===m}):vt.createElement(_o,{key:a.id,field:a,selected:i&&o===m})))};var Ir=({swimlanes:e,currentNode:t,selectedIndex:o,breadCrumb:n,mode:r,viewMode:i})=>{let s=t.context,a=s===I.TICKET||s===I.FIELD_LIST||s===I.FIELD,m=s===I.BOARD||s===I.SWIMLANE,u=s===I.TICKET?t:n.find(k=>k.context===I.TICKET),C=process.stdout.columns||120,g=Math.floor(C/3),N=Math.floor(C/Math.max(e.length,1)),A=Math.min(N,g),R=process.stdout.rows-1-3,O=i==="dense";return _e.createElement(Nr,{flexDirection:"row",height:R},m&&e.map((k,q)=>{let ue=t.id===k.id,he=ue?o:-1,L=t.context===I.BOARD&&o===q;return _e.createElement(Wo,{key:k.id,height:R,width:A,swimlane:k,isSelected:L,isDense:O,isFocused:ue,listSelectedIndex:he,mode:r})}),a&&u&&_e.createElement(zo,{height:R,ticket:u}))},$o=_e.memo(Ir);import{Box as ze,Text as yt}from"ink";import z from"react";var jo=()=>{let{breadCrumb:e,currentNode:t,selectedIndex:o,viewMode:n}=l(),r=v(t.id)[o],i=fe(r?.id??t.id,"TICKET").data,s=i?.id?v(i.id):[],a=C=>s.filter(g=>g.title===C&&Array.isArray(g.props.value)).flatMap(g=>g.props.value),m=a("Tags"),u=a("Assignees");return z.createElement(ze,null,e.map((C,g)=>{let N=g===e.length-1,A=v(C.id),b=N?A?.[o]?.title:void 0;return z.createElement(ze,{key:`${C.id??g}-${g}`},z.createElement(yt,{color:p.secondary},g?" / ":""),z.createElement(yt,{color:p.secondary},C.title??""),b?z.createElement(yt,{color:p.primary},` \u2E2C ${b}`):null,n==="dense"&&N?(m??[]).map(T=>z.createElement(ze,{key:`${T}`,paddingLeft:2},z.createElement(de,{id:T}))):null,n==="dense"&&N?(u??[]).map(T=>z.createElement(ze,{key:T,paddingLeft:2},z.createElement(ae,{id:T}))):null)}))};var Ar=({currentNode:e,selectedIndex:t,breadCrumb:o,mode:n,viewMode:r})=>{let{renderedChildrenIndex:i}=W(),s=o.find(({context:a})=>a==="BOARD");return ee.createElement(Go,{flexDirection:"column"},ee.createElement(jo,null),ee.createElement(Go,{flexDirection:"row"},e.context==="WORKSPACE"?ee.createElement(ut,null):s?ee.createElement($o,{swimlanes:(i[s.id]??[]).filter(a=>a!==void 0&&bt(a)),currentNode:e,selectedIndex:t,breadCrumb:o,viewMode:r,mode:n}):ee.createElement(hr,null)))},qo=ee.memo(Ar);import{Box as Nt,Text as tn}from"ink";import me from"react";import te from"chalk";import{Box as Jo,Text as Yo}from"ink";import $e,{useEffect as Er,useMemo as br,useState as Tr}from"react";var Sr=te.hex(mt.blue),Mr=te.white.bgGray,Xo=te.gray,wr=te.inverse,Lr=te.inverse.hex(mt.blue),Dr=te.inverse.green,Pr=te.inverse.gray,Rr={hint:"",hints:[],overlap:0,remainder:""},Zo=({value:e,command:t})=>{if(!t)return null;let o=e.trimStart(),r=e.length-o.length;return e.slice(r,r+t.length)!==t?null:{start:r,end:r+t.length}},kr=({value:e,command:t,modifier:o})=>{if(!t||!o)return null;let n=Zo({value:e,command:t});if(!n)return null;let i=e.slice(n.end).match(/^\s*/)?.[0].length??0,s=n.end+i;return e.slice(s,s+o.length)!==o?null:{start:s,end:s+o.length}},Qo=()=>({value:w.value,cursorPosition:w.cursorPosition,commandIsPending:w.commandIsPending,autoCompletion:w.autoCompletion??Rr,infoMessage:w.commandMeta.infoMessage,validationStatus:w.commandMeta.validity,command:w.commandMeta.command,inputString:w.commandMeta.inputString,modifier:w.commandMeta.modifier}),Fr=(e,t)=>e.value===t.value&&e.cursorPosition===t.cursorPosition&&e.commandIsPending===t.commandIsPending&&e.infoMessage===t.infoMessage&&e.autoCompletion.hint===t.autoCompletion.hint&&e.autoCompletion.overlap===t.autoCompletion.overlap&&e.autoCompletion.remainder===t.autoCompletion.remainder&&e.validationStatus===t.validationStatus&&e.command===t.command&&e.modifier===t.modifier&&e.inputString===t.inputString,en=({width:e})=>{let[t,o]=Tr(Qo());Er(()=>{let g=()=>{let A=Qo();o(b=>Fr(b,A)?b:A)},N=Gt(g);return g(),()=>{N()}},[]);let{value:n,cursorPosition:r,infoMessage:i,commandIsPending:s,autoCompletion:a,command:m,modifier:u}=t,C=br(()=>{let g=Math.max(0,Math.min(r,n.length)),N=Zo({value:n,command:m}),A=kr({value:n,command:m,modifier:u}),b=(L,P)=>{let qe=N&&P>=N.start&&P<N.end,Je=A&&P>=A.start&&P<A.end;return qe?Sr(L):Je?Mr(L):L},T=(L,P)=>{let qe=N&&P>=N.start&&P<N.end,Je=A&&P>=A.start&&P<A.end;return qe?Lr(L):Je?Dr(L):wr(L)},R=n.slice(0,g),O=n[g]??" ",k=g<n.length?n.slice(g+1):"",q=Array.from(R).map((L,P)=>b(L,P)).join(""),ue=T(O,g),he=Array.from(k).map((L,P)=>b(L,g+1+P)).join("");if(a.hint){let L=a.hint[a.overlap]??O;ue=Pr(L),he=Xo(a.remainder.slice(1)+k)}return Xo(":")+q+ue+he},[n,r,a,m,u]);return $e.createElement(Jo,{flexDirection:"column",paddingX:1,borderColor:p.secondary,borderStyle:"round",width:e},$e.createElement(Jo,null,$e.createElement(Yo,null,C),i&&$e.createElement(Yo,{color:s?"red":p.secondary},` ${i} `)))};var on=({width:e,mode:t,availableHints:o})=>me.createElement(Nt,null,t===d.COMMAND_LINE?me.createElement(en,{width:e}):me.createElement(Nt,{flexDirection:"column",paddingX:1,borderColor:p.secondary,borderStyle:"round",width:e},me.createElement(Nt,{flexDirection:"row"},o.map((n,r)=>me.createElement(tn,{key:n,color:p.secondary},(r?" | ":"")+n)),me.createElement(tn,null," "))));import{Box as le,Text as nn}from"ink";import G from"react";var rn=({width:e})=>G.createElement(le,{flexDirection:"column",marginTop:3,borderColor:p.secondary,borderStyle:"round",width:e,minHeight:19},G.createElement(le,{flexDirection:"column",width:e},l().mode===d.HELP?[{action:"",description:"[COMMAND] DESCRIPTION",mode:l().mode},...l().availableActions].filter(t=>!!t.description).map((t,o)=>{let[n,r]=t.description.split("]"),i=n?.replace("[",""),s=r?.trim();return G.createElement(le,{paddingLeft:1,key:o,flexDirection:"row"},G.createElement(le,{key:o,flexDirection:"row",paddingBottom:o?0:1},G.createElement(le,{flexGrow:1,width:30},G.createElement(nn,{color:o?p.primary:p.secondary},s)),G.createElement(le,{width:20},G.createElement(nn,{color:o?p.accent:p.secondary},i))))}):null));function Ce(){let e=W(),t=process.stdout.columns||120;return je.createElement(Or,{flexDirection:"column"},e.mode!==d.HELP&&je.createElement(qo,{currentNode:e.currentNode,selectedIndex:e.selectedIndex,breadCrumb:e.breadCrumb,viewMode:e.viewMode,mode:e.mode}),e.mode===d.HELP&&je.createElement(rn,{width:t}),e.mode!==d.HELP&&je.createElement(on,{width:t,mode:e.mode,availableHints:e.availableHints}))}import{monotonicFactory as Hr}from"ulid";import It from"node:fs";import sn from"node:path";var Br=".epiq",Ur="events",Wr=(e=process.cwd())=>sn.join(e,Br,Ur);function Vr(e=process.cwd()){let t=Wr(e);if(!It.existsSync(t))return[];let o=It.readdirSync(t).filter(r=>r.endsWith(".jsonl")).map(r=>sn.join(t,r)),n=[];for(let r of o){let i=It.readFileSync(r,"utf8");for(let s of i.split(`
4
- `)){let a=s.trim();a&&n.push(JSON.parse(a))}}return n.sort((r,i)=>r.eventId.localeCompare(i.eventId))}function an(e=process.cwd()){return Vr(e).map(({event:t})=>t)}var ve=Hr(),dn=()=>{let e=an(),t;if(e.length)t=no(e);else{let a=ve(),m=ve(),u=ve(),C=ve(),g=ve();t=De([{action:"init.workspace",payload:{id:a,name:"Workspace"}},{action:"add.board",payload:{id:m,name:"Default",parentId:a}},{action:"add.swimlane",payload:{id:u,name:"Todo",parentId:m}},{action:"add.swimlane",payload:{id:C,name:"Review",parentId:m}},{action:"add.swimlane",payload:{id:g,name:"Done",parentId:m}}])}let o=t.filter(h);if(o.length)throw new Error("Failed to materialize events on boot: "+o.map(a=>a.message??"Unknown error").join(", "));let n=Object.values(l().nodes).find(a=>a.context==="WORKSPACE");if(!n)throw logger.error("No workspace found in event log"),new Error("No workspace found in event log");let[r]=v(n.id),[i]=r?v(r.id):[],s=i??r??n;M.navigate({currentNode:s,selectedIndex:l().renderedChildrenIndex?.[s.id]?.length?0:-1})};var cn=()=>logger.info("initProject");import Kr from"readline";var Ge,_r=()=>async function(t,o){if(o.ctrl&&o.name==="c")return M.exit();let{actionIndex:n,mode:r}=l(),i=oo(o,r);if(!i)return;let s=n[r]?.[i];if(s?.action)try{await s.action(s,o)}catch(a){logger.error(a)}};function mn(){Ge&&process.stdin.removeListener("keypress",Ge),Ge=_r(),Kr.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.on("keypress",Ge)}import ye from"fs";import un from"path";import zr from"util";var pn=process.env.IS_LOCAL==="true",Ne=un.resolve(process.cwd(),".epiq","log","app.log"),ln=1e3;function $r(){if(!pn||!ye.existsSync(Ne))return;let t=ye.readFileSync(Ne,"utf8").split(`
5
- `);if(t[t.length-1]===""&&t.pop(),t.length<=ln)return;let o=t.slice(-ln).join(`
2
+ import Ve from"fs";import Mn from"path";import Mr from"util";var wn=process.env.IS_LOCAL==="true",Ke=Mn.resolve(process.cwd(),".epiq","log","epiq.log"),Tn=1e3;function wr(){if(!wn||!Ve.existsSync(Ke))return;let t=Ve.readFileSync(Ke,"utf8").split(`
3
+ `);if(t[t.length-1]===""&&t.pop(),t.length<=Tn)return;let n=t.slice(-Tn).join(`
6
4
  `)+`
7
- `;ye.writeFileSync(Ne,o,"utf8")}function ht(e,t,o=!1){if(!pn)return;let n=zr.format(...t),r=new Date,s=`[${o?r.toISOString().slice(11,19):r.toISOString()}] ${e} ${n}
8
- `;ye.mkdirSync(un.dirname(Ne),{recursive:!0}),ye.appendFileSync(Ne,s,"utf8"),$r()}var jr={info(...e){ht("[Info]",e,!1)},debug(...e){ht("->",e,!0)},error(...e){ht("[Error]",[...e,new Error().stack],!1)}};globalThis.logger=jr;var fn=qr(`
9
- View board in directory:
10
- $ epiq
5
+ `;Ve.writeFileSync(Ke,n,"utf8")}function Ut(e,t,n=!1){if(!wn)return;let o=Mr.format(...t),r=new Date,s=`[${n?r.toISOString().slice(11,19):r.toISOString()}] ${e} ${o}
6
+ `;Ve.mkdirSync(Mn.dirname(Ke),{recursive:!0}),Ve.appendFileSync(Ke,s,"utf8"),wr()}var Lr={info(...e){Ut("[Info]",e,!1)},debug(...e){Ut("->",e,!0)},error(...e){Ut("[Error]",[...e,new Error().stack],!1)}};globalThis.logger=Lr;import{render as Sr}from"ink";import $s from"meow";import et from"react";import{Box as Pt}from"ink";import X from"react";import{Box as Cs,Text as ys}from"ink";import Je from"react";var T={WORKSPACE:"WORKSPACE",BOARD:"BOARD",SWIMLANE:"SWIMLANE",TICKET:"TICKET",FIELD:"FIELD",FIELD_LIST:"FIELD_LIST",TEXT:"TEXT"};function he(e){return e.context==="TICKET"}function Ln(e){return e.context==="FIELD_LIST"}var Pn=e=>e.context==="SWIMLANE";import{useSyncExternalStore as Wi}from"react";var N={HELP:"help",NEW:"new",TAG:"tag",FILTER:"filter",ASSIGN:"assign",DELETE:"delete",RENAME:"rename",CLOSE_ISSUE:"close",RE_OPEN_ISSUE:"reopen",SET_EDITOR:"set:editor",SET_VIEW:"set:view",SET_USERNAME:"set:username",NONE:""},Q={None:"none",Invalid:"invalid",Valid:"valid"},Z={None:"none",Success:"success",Fail:"fail"},c=e=>({result:Z.Fail,message:e,data:null}),m=(e,t)=>({result:Z.Success,message:e,data:t}),Dn=()=>({result:Z.None,message:"No result",data:null}),x=e=>e.result==="fail",ue=e=>e.result==="success";var Se=24n,Pr=Se*4n,tt=(1n<<Pr)-1n,Dr=/^[0-9a-f]+$/;function Fn(e){if(!e||!Dr.test(e))throw new Error(`Invalid hex rank: ${e}`);return BigInt("0x"+e)}function nt(e,t=Se){if(e<0n)throw new Error("Negative rank not allowed");return e.toString(16).padStart(Number(t),"0")}function $e(e,t){if(!e&&!t)return nt(tt/2n,Se);let n=e?Fn(e):0n,o=t?Fn(t):tt;if(o<=n)return nt(tt/2n,Se);let r=(n+o)/2n;return r===n||r===o?"":nt(r,Se)}function G(){return nt(tt/2n,Se)}var H={workspace:(e,t)=>({id:e,title:t,rank:G(),isDeleted:!1,props:{},context:T.WORKSPACE,childRenderAxis:"vertical",parentNodeId:null,readonly:!0,log:[]}),board:(e,t,n,o=!1)=>({id:e,title:t,rank:G(),isDeleted:!1,props:{},context:T.BOARD,childRenderAxis:"horizontal",parentNodeId:n,readonly:o,log:[]}),swimlane:(e,t,n)=>({id:e,title:t,rank:G(),isDeleted:!1,props:{},context:T.SWIMLANE,childRenderAxis:"vertical",childNavigationAcrossParents:!0,parentNodeId:n,readonly:!1,log:[]}),field:(e,t,n,o={},r="horizontal")=>({id:e,title:t,rank:G(),isDeleted:!1,props:o,context:T.FIELD,childRenderAxis:r,parentNodeId:n,readonly:!1,log:[]}),ticket:(e,t,n)=>({id:e,title:t,rank:G(),isDeleted:!1,props:{},context:T.TICKET,childRenderAxis:"vertical",parentNodeId:n,readonly:!1,log:[]}),text:(e,t,n,o={})=>({id:e,title:t,rank:G(),isDeleted:!1,props:o,context:T.TEXT,childRenderAxis:"vertical",parentNodeId:n,readonly:!1,log:[]})};function ot(e,t){let n=Math.min(e.length,t.length),o=0;for(;o<n&&e[o]===t[o];)o++;return o}var rt=(e,t)=>t<=0?"":e.length<=t?e:t<=3?"...".slice(0,t):e.slice(0,t-3)+"...",it=e=>typeof e!="string"?"":e.replace(/[\x00-\x08\x0B-\x1F\x7F]/g,"").replace(/[\r\n\t]/g," ").replace(/\s+/g," ").trim();var P=e=>Object.values(f().nodes).filter(t=>!!t&&!t.isDeleted&&t.parentNodeId===e).sort((t,n)=>t.rank.localeCompare(n.rank)),Bn=(e,t)=>e.findIndex(n=>n.id===t),Wt=(e,t={at:"end"})=>{if(e.length===0)return m("Resolved rank",G());switch(t.at){case"start":{let n=e[0];return n?m("Resolved rank",$e(void 0,n.rank)):c("Unable to resolve first sibling")}case"end":{let n=e[e.length-1];return n?m("Resolved rank",$e(n.rank,void 0)):c("Unable to resolve last sibling")}case"before":{let n=Bn(e,t.sibling);if(n<0)return c("Sibling not found");let o=n>0?e[n-1]:void 0,r=e[n];return r?m("Resolved rank",$e(o?.rank,r.rank)):c("Sibling not found")}case"after":{let n=Bn(e,t.sibling);if(n<0)return c("Sibling not found");let o=e[n],r=n<e.length-1?e[n+1]:void 0;return o?m("Resolved rank",$e(o.rank,r?.rank)):c("Sibling not found")}}};var Te=(e,t)=>{let{nodes:n}=f(),o=n[e];if(!o)return c("Node not found");if(o.context===t)return m("Resolved ancestor node",o);let r=o.parentNodeId?n[o.parentNodeId]:void 0;for(;r;){if(r.context===t)return m("Resolved ancestor node",r);r=r.parentNodeId?n[r.parentNodeId]:void 0}return c(`No ancestor found for context: ${t}`)},_t=(e,t)=>{let{nodes:n}=f(),o=n[e];for(;o?.parentNodeId;){if(o.parentNodeId===t)return!0;o=n[o.parentNodeId]}return!1};function Fr(e){return it(e).replace(/\s+/g," ").trim()}function kn(e,t){if(!e)return[];let n=[],o=new Set,r=f(),{renderedChildrenIndex:i,tags:s,contributors:a}=r,d=l=>{let v=i[l.id];if(l.title===t&&Ln(l))for(let p of v??[]){if(!p)continue;let C=typeof p.props?.value=="string"?p.props.value:"",A=(t==="Tags"?s[C]?.name:t==="Assignees"?a[C]?.name:void 0)??p.title??String(p.props?.value??""),E=Fr(A),I=E.toLowerCase();E&&!o.has(I)&&(o.add(I),n.push(E))}for(let p of v??[])d(p)};return d(e),n.sort((l,v)=>l.localeCompare(v))}var Ht=(e,t)=>e?e.readonly?c({move:"Cannot move readonly node",rename:"Cannot rename readonly node",edit:"Cannot edit readonly node"}[t]):null:c("Node not found"),g={deleteNode(e){j(t=>{let n={...t.nodes};return delete n[e],{...t,nodes:n}})},editValue(e,t){let{nodes:n}=f(),o=n[e];if(!o)return c("Edit target node not found");let r=Ht(o,"edit");if(r)return r;let i={...o,props:{...o.props,value:t}};return g.updateNode(i),m("Issue description updated",{md:t})},renameNode(e,t){let n=this.getNode(e);if(!n)return c("Rename target node not found");let o=Ht(n,"rename");if(o)return o;let r={...n,title:t};return this.updateNode(r),m("Renamed node",r)},getExistingTags(){let{rootNodeId:e,nodes:t}=f(),n=t[e];return n?kn(n,"Tags"):[]},getExistingAssignees(){let{rootNodeId:e,nodes:t}=f(),n=t[e];return n?kn(n,"Assignees"):[]},getFieldByTitle(e,t){return P(e).find(n=>n.title===t)},moveNode({id:e,parentId:t,position:n={at:"end"},navigate:o=!0}){let{rootNodeId:r}=f(),i=this.getNode(e),s=this.getNode(t);if(!i)return c("Node not found");if(!s)return c("Target parent not found");if(r===e)return c("Cannot move root node");if(e===t)return c("Cannot move node into itself");let a=Ht(i,"move");if(a)return a;if(_t(t,e))return c("Cannot move node into its own descendant");let d=P(t).filter(p=>p.id!==e),l=Wt(d,n);if(x(l))return l;let v={...i,parentNodeId:t,rank:l.data};return o?this.updateNodeAndSelectInParent(v):this.updateNode(v),m("Moved node successfully",v)},tombstoneNode(e){let{nodes:t,currentNodeId:n,rootNodeId:o}=f(),r=this.getNode(e);if(!r)return c("Node not found");if(o===e)return c("Cannot delete root node");let i=new Set,s=l=>{let v=t[l];if(!(!v||i.has(l))){i.add(l);for(let p of P(v.id))s(p.id)}};s(e);let a={...structuredClone(t)};for(let l of i){if(!a[l])return c("Unable to locate node to delete");a[l]={...a[l],isDeleted:!0}}if(!n)return c("Unable to delete undefined");let d=i.has(n)?r.parentNodeId:n;return M({nodes:a,currentNodeId:d}),m("Successfully tomb stoned",r)},createContributor(e){let t=j(n=>({...n,contributors:{...n.contributors,[e.id]:e}}));return x(t)?c("Unable to create contributor"):m("Created contributor",e)},assign(e,t,n){let o=g.getContributor(t),r=g.getNode(e);if(!r||!o)return c("Unable assign contributor to issue");let i=this.getFieldByTitle(r.id,"Assignees");if(!i)return c("Unable to locate assignees field");if(P(i.id).some(d=>d.props?.value===t))return c("Contributor already assigned");let a=this.createNodeAtPosition(H.field(n,o.name,i.id,{value:t}));return x(a)?a:m("Assigned contributor",a.data)},createTag(e){let t=j(n=>({...n,tags:{...n.tags,[e.id]:e}}));return x(t)?c("Could not create tag"):m("Tag created",e)},tag(e,t,n){let o=g.getTag(t),r=g.getNode(e);if(!o)return c("Unable to add tag, missing tag");if(!r)return c("Unable to add tag, missing target");let i=this.getFieldByTitle(r.id,"Tags");if(!i)return c("Unable to locate tags field");if(P(i.id).some(d=>d.props?.value===t))return c("Tag already assigned");let a=this.createNodeAtPosition(H.field(n,o.name,i.id,{value:t}));return x(a)?a:m("Tag added",a.data)},createNodeAtPosition(e,t={at:"end"}){if(!e.parentNodeId){let i={...e,rank:G()};return this.createNode(i),m("Created node",i)}let n=P(e.parentNodeId),o=Wt(n,t);if(x(o))return o;let r={...e,rank:o.data};return this.createNode(r),m("Created node",r)},createNode(e){let t=j(n=>({...n,nodes:{...n.nodes,[e.id]:e}}));return x(t)?m("Node created",e):c("Unable to create node")},lockNode(e){let t=this.getNode(e);if(!t)return c("Failed to locate node");let n={...t,readonly:!0},o=j(r=>({...r,nodes:{...r.nodes,[e]:n}}));return x(o)?c(o.message):m("Locked node",n)},updateNode(e){let t=j(n=>({...n,nodes:{...n.nodes,[e.id]:e}}));return x(t)?m("Updated node",e):t},updateNodeAndSelectInParent(e){return j(t=>{let n={...t.nodes,[e.id]:e},o=Object.values(n).filter(r=>!r.isDeleted&&r.parentNodeId===e.parentNodeId).sort((r,i)=>r.rank.localeCompare(i.rank));return{...t,nodes:n,currentNodeId:e.parentNodeId,selectedIndex:o.findIndex(({id:r})=>r===e.id)}}),m("Updated and selected",e)},getContributor(e){return f().contributors[e]},getTag(e){return f().tags[e]},getNode(e){return f().nodes[e]},getSiblings:e=>Object.values(f().nodes).filter(t=>!t.isDeleted&&t.parentNodeId===e).sort((t,n)=>t.rank.localeCompare(n.rank))};var Rn=e=>{let t=e.log??[];for(let n=t.length-1;n>=0;n--){let o=t[n];if(o&&o.action==="close.issue"&&o.payload.id===e.id)return o.payload.parent}return null};var Br=["00KM6CZ900T7180RM46K0JAYNF","00JR3R8E00A1Z4X9FGP9DV0SM5"],[Me,st]=Br;var w=(e,t)=>c(`${t.split(".").join(" ")+" failed, "+e.toLowerCase()}`),kr={"init.workspace":({action:e,payload:t})=>{let{id:n,name:o}=t,r=H.workspace(n,o);Un(r);let i=g.createNodeAtPosition(r);return x(i)?w(i.message??"Failed to initialize workspace",e):m("Workspace initialized",{action:e,result:i.data})},"add.workspace":({action:e,payload:t})=>{let{id:n,name:o}=t,r=H.workspace(n,o),i=g.createNodeAtPosition(r);return x(i)?w(i.message??"Failed to add workspace",e):m("Added workspace",{action:e,result:i.data})},"add.board":({action:e,payload:t})=>{let{id:n,name:o,parent:r}=t,i=g.createNodeAtPosition(H.board(n,o,r));return x(i)?w(i.message??"Unable to create board",e):m("Added board",{action:e,result:i.data})},"add.swimlane":({action:e,payload:t})=>{let{id:n,name:o,parent:r}=t,i=g.createNodeAtPosition(H.swimlane(n,o,r));return x(i)?w(i.message??"Unable to create swimlane",e):m("Added swimlane",{action:e,result:i.data})},"add.issue":({action:e,payload:t})=>{let{id:n,name:o,parent:r}=t,i=g.createNodeAtPosition(H.ticket(n,o,r));return x(i)?w(i.message??"Unable to create issue",e):m("Added issue",{action:e,result:i.data})},"add.field":({action:e,payload:t})=>{let{id:n,name:o,parent:r,val:i}=t,s=g.createNodeAtPosition(H.field(n,o,r,{value:i},o.includes("Description")?"vertical":"horizontal"));return x(s)?w(s.message??`Unable to create field: ${o}`,e):m("Added field",{action:e,result:s.data})},"edit.title":({action:e,payload:t})=>{let{id:n,name:o}=t;if(!g.getNode(n))return w("Unable to locate node",e);let i=g.renameNode(n,o);return x(i)?w(i.message??"Unable to edit title",e):m("Edited title",{action:e,result:i.data})},"delete.node":({action:e,payload:t})=>{let{id:n}=t,o=g.tombstoneNode(n);return x(o)?w(o.message??"Unable to delete node",e):m("Deleted node",{action:e,result:o.data})},"create.tag":({action:e,payload:t})=>{let{id:n,name:o}=t,r=g.createTag({id:n,name:o});return x(r)?w(r.message??"Unable to create tag",e):m("Tag added",{action:e,result:r.data})},"create.contributor":({action:e,payload:t})=>{let{id:n,name:o}=t,r=g.createContributor({id:n,name:o});return x(r)?w(r.message??"Unable to create contributor",e):m("Contributor created",{action:e,result:r.data})},"tag.issue":({action:e,payload:t})=>{let{id:n,target:o,tagId:r}=t,i=g.tag(o,r,n);return x(i)?w(i.message??"Unable to tag issue",e):m("Issue tagged",{action:e,result:i.data})},"assign.issue":({action:e,payload:t})=>{let{id:n,contributor:o,target:r}=t,i=g.assign(r,o,n);return x(i)?w(i.message??"Unable to assign issue",e):m("Assigned successfully",{action:e,result:i.data})},"move.node":({action:e,payload:t})=>{let{id:n,parent:o,pos:r}=t,i=g.moveNode({id:n,parentId:o,position:r});return x(i)?w(i.message??"Failed to move node",e):m("Moved node",{action:e,result:i.data})},"edit.description":({action:e,payload:t})=>{let{id:n,md:o}=t,r=g.editValue(n,o);return x(r)?w(r.message??"Unable to edit description",e):m("Set node value",{action:e,result:r.data})},"close.issue":({action:e,payload:t})=>{let{id:n}=t,o=g.getNode(n);if(!o)return w("Unable to locate issue",e);if(!he(o))return w("Can only close issues",e);let r=g.getNode(Me);if(!r)return w("Unable to locate target swimlane",e);if(r.id===o.parentNodeId)return w("Cannot close closed issue",e);let s=g.moveNode({id:n,parentId:r.id,navigate:!1});return x(s)?w(s.message??"Unable to close issue",e):m("Issue closed",{action:e,result:s.data})},"reopen.issue":({action:e,payload:t})=>{let{id:n}=t,o=g.getNode(n);if(!o)return w("Unable to locate issue",e);if(!he(o))return w("Can only reopen issues",e);let r=g.getNode(Me);if(!r)return w("Unable to locate closed swimlane",e);if(!(o.parentNodeId===r.id))return w("Issue is not closed",e);let s=Rn(o);if(!s)return w("Unable to resolve previous parent from issue history",e);if(s===r.id)return w("Previous parent resolves to closed swimlane",e);if(!g.getNode(s))return w("Previous parent no longer exists",e);let d=g.moveNode({id:n,parentId:s,navigate:!1});return x(d)?w(d.message??"Unable to reopen issue",e):m("Issue reopened",{action:e,result:d.data})},"lock.node":({action:e,payload:t})=>{let{id:n}=t,o=g.lockNode(n);return x(o)?w(o.message??"Unable to lock node",e):m("Node locked",{action:e,result:o.data})}},Rr=(e,t)=>{let n=g.getNode(e);n&&g.updateNode({...n,log:[...n.log??[],t]})},Or=e=>{switch(e.action){case"init.workspace":case"add.workspace":case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"edit.title":case"lock.node":case"delete.node":case"move.node":case"close.issue":case"reopen.issue":case"edit.description":return[e.payload.id];case"tag.issue":case"assign.issue":return[e.payload.id,e.payload.target];case"create.tag":case"create.contributor":default:return[]}};function we(e){let t=kr[e.action],n=t(e);if(!x(n)){let o=[...new Set(Or(e))];for(let r of o)Rr(r,e)}return n}var On=e=>e.map(t=>we(t));import $n from"node:fs";import zr from"node:os";import jn from"node:path";import{decodeTime as jr,monotonicFactory as Gr}from"ulid";var at={preferredEditor:null,userName:null},pe=()=>at,ze=e=>(at={...at,...e},at);var Wn=e=>({action:e.action,payload:e.payload});import Vt from"node:fs";import Hn from"node:path";import{ulid as Ur}from"ulid";var Wr=".epiq",Hr="events",_r=(e=process.cwd())=>Hn.join(e,Wr,Hr),Vr=e=>{let t=Object.keys(e).filter(n=>n!=="id");return t.length!==1?c(`Invalid persisted event: expected exactly 1 action key, got ${t.length}`):m("Resolved persisted action",t[0])},Kr=e=>{let t=Vr(e);if(x(t))return c(t.message);let n=t.data;if(!n)return c("Action key is undefined");let o=e[n];return m("Decoded persisted event",{id:e.id[0]??Ur(),action:n,payload:o,userId:J()})};function _n(e=process.cwd()){let t=_r(e);if(!Vt.existsSync(t))return[];let n=Vt.readdirSync(t).filter(r=>r.endsWith(".jsonl")).map(r=>Hn.join(t,r)),o=[];for(let r of n){let i=Vt.readFileSync(r,"utf8");for(let s of i.split(`
7
+ `)){let a=s.trim();if(a)try{o.push(JSON.parse(a))}catch{}}}return $r(o)}function Vn(e=process.cwd()){return _n(e).map(Kr).filter(ue).map(({data:t})=>t)}function Kn(e=process.cwd()){return _n(e).at(-1)?.id[0]??null}var $r=e=>{let t=new Map(e.map(a=>[a.id[0],a])),n=new Map;for(let a of e){let d=a.id[1],l=n.get(d)??[];l.push(a),n.set(d,l)}for(let a of n.values())a.sort((d,l)=>{let[v]=d.id,[p]=l.id;return v.localeCompare(p)});let o=[],r=new Set,i=a=>{let d=n.get(a)??[];for(let l of d){let[v]=l.id;r.has(v)||(r.add(v),o.push(l),i(v))}};i(null);let s=[...e].filter(a=>{let[d]=a.id;return!r.has(d)}).sort((a,d)=>{let[l,v]=a.id,[p,C]=d.id,h=v===null||t.has(v),A=C===null||t.has(C);if(h&&!A)return-1;if(!h&&A)return 1;let E=(v??"").localeCompare(C??"");return E!==0?E:l.localeCompare(p)});return[...o,...s]};var zn=Gr(),qr=".epiq",Xr="events",Kt=e=>e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"unknown",J=()=>{let e=process.env.EPIQ_ACTOR_ID;if(e?.trim())return Kt(e);let t=pe().userName;if(t?.trim())return Kt(t);try{return Kt(zr.userInfo().username)}catch{return"unknown"}},Gn=(e=process.cwd())=>jn.join(e,qr,Xr),Jr=(e=process.cwd())=>{let t=J();return jn.join(Gn(e),`${t}.jsonl`)},Yr=(e,t)=>({[e.action]:e.payload,id:t});function qn(e,t=process.cwd()){try{let n=Gn(t),o=Jr(t);$n.mkdirSync(n,{recursive:!0});let r=Kn(t),i;if(r){let a=jr(r),d=Math.max(Date.now(),a+1);i=zn(d)}else i=zn();let s=Yr(Wn(e),[i,r]);return $n.appendFileSync(o,`${JSON.stringify(s)}
8
+ `,"utf8"),m("Event persisted",{path:o,entry:s})}catch(n){let o=n instanceof Error?n.message:"Unknown persist error";return c(`Failed to persist event: ${o}`)}}function U(e){let t=we(e);if(t.result!==Z.Success)return t;let n=qn(e);return x(n)?n:t}function dt(e){return e.map(t=>U(t))}var u={DEFAULT:"default",MOVE:"move",HELP:"help",COMMAND_LINE:"command-line"};var Qr=(e,t)=>e.ctrl&&e.name==="w"||e.meta&&e.name==="backspace"||t==="",Zr=(e,t)=>e.meta&&e.name==="b"||t==="\x1Bb",ei=(e,t)=>e.meta&&e.name==="f"||t==="\x1Bf",Xn=(e,t)=>{if(Zr(e,e.sequence))return"MoveCursorLeftOfWord";if(ei(e,e.sequence))return"MoveCursorRightOfWord";if(Qr(e,e.sequence))return"EraseInputWord";switch(e.name){case"tab":return"autoCompleteCommand";case"up":return"getLastCommandFromHistory";case"down":return"getNextCommandFromHistory";case"left":return"MoveCursorLeft";case"right":return"MoveCursorRight";case"return":return"confirm";case"backspace":return t?"eraseInput":"exitCommandLine";case"escape":return"exitCommandLine";default:return"captureInput"}};var Jn=e=>{let t=new Map;for(let n of e)for(let o=1;o<=n.length;o++){let r=n.slice(0,o),i=t.get(r);i?i.push(n):t.set(r,[n])}return t},Yn=(e,t)=>t?e.get(t)??[]:[];var Qn=new WeakMap,ti=e=>{let t=Qn.get(e);return t||(t=Jn(e),Qn.set(e,t)),t};var Zn=({wordList:e,inputToMatch:t,overlapThreshold:n=1})=>{let o=t.toLowerCase();return Yn(ti(e),o).filter(i=>ot(o,i)>=n)};var eo=({inputToMatch:e,lastWord:t},n)=>{if(t.endsWith(" "))return{hint:"",hints:[],overlap:0,remainder:""};let o=Zn({wordList:n,inputToMatch:e,overlapThreshold:1});return ni(t,o)},ni=(e,t)=>{let n=t[0]??"",o=ot(e.toLowerCase(),n.toLowerCase()),r=n?n+" ":"",i=r.slice(o);return{hint:r,hints:t,overlap:o,remainder:i}};var Le={urgent:"red",critical:"red",important:"red",blocker:"red",asap:"red",immediate:"red",fail:"red",failure:"red",broken:"red",bug:"red",error:"red",incident:"red",outage:"red",production:"red",crash:"red",security:"red",warning:"yellow",warn:"yellow",risky:"yellow",risk:"yellow",attention:"yellow",pending:"yellow",review:"yellow","needs-review":"yellow",qa:"yellow",testing:"yellow",test:"yellow",validate:"yellow",verification:"yellow",staging:"yellow",check:"yellow","follow-up":"yellow",followup:"yellow",waiting:"yellow",blocked:"yellow",hold:"yellow",done:"green",complete:"green",completed:"green",success:"green",ok:"green",stable:"green",resolved:"green",fixed:"green",closed:"green",merged:"green",released:"green",deployed:"green",approved:"green",verified:"green",working:"green",healthy:"green",pass:"green",passing:"green",info:"blue",information:"blue",note:"blue",docs:"blue",documentation:"blue",doc:"blue",guide:"blue",help:"blue",explanation:"blue",detail:"blue",details:"blue",context:"blue",design:"blue",discussion:"blue",proposal:"blue",idea:"blue",feature:"magenta",enhancement:"magenta",improvement:"magenta",refactor:"magenta",refactoring:"magenta",cleanup:"magenta",optimize:"magenta",optimization:"magenta",perf:"magenta",performance:"magenta",upgrade:"magenta",migration:"magenta",modernize:"magenta",debt:"magenta",todo:"cyan",next:"cyan",planned:"cyan",plan:"cyan",future:"cyan",backlog:"cyan",investigate:"cyan",explore:"cyan",prototype:"cyan"};var B=e=>({[N.FILTER]:["tag","assignee","description","title","clear"],[N.DELETE]:["confirm"],[N.RE_OPEN_ISSUE]:["confirm"],[N.CLOSE_ISSUE]:["confirm"],[N.SET_USERNAME]:[],[N.SET_VIEW]:["dense","wide"],[N.SET_EDITOR]:["vi","vim","nvim","nano","micro","emacs","hx","code","code-insiders","subl","notepad","notepad++","idea","webstorm","default","system","$EDITOR","$VISUAL"],[N.NONE]:[...new Set([...Object.values(N)])],[N.TAG]:[...new Set([...Object.keys(Le),...g.getExistingTags()])],[N.ASSIGN]:g.getExistingAssignees(),[N.HELP]:[],[N.RENAME]:[],[N.NEW]:["issue","swimlane","board"]})[e];import Pe from"chalk";var oi=e=>{let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t),t|=0;return Math.abs(t)},ri=(e,t,n)=>{t/=100,n/=100;let o=(1-Math.abs(2*n-1))*t,r=e/60,i=o*(1-Math.abs(r%2-1)),s=0,a=0,d=0;r>=0&&r<1?(s=o,a=i):r>=1&&r<2?(s=i,a=o):r>=2&&r<3?(a=o,d=i):r>=3&&r<4?(a=i,d=o):r>=4&&r<5?(s=i,d=o):(s=o,d=i);let l=n-o/2,v=p=>Math.round((p+l)*255).toString(16).padStart(2,"0");return`#${v(s)}${v(a)}${v(d)}`},De=e=>{let n=oi(e)%360;return ri(n,65,45)},lt=[[168,85,247],[34,211,238],[59,130,246]],zt=(e,t,n)=>e+(t-e)*n,ii=(e,t,n)=>[Math.round(zt(e[0],t[0],n)),Math.round(zt(e[1],t[1],n)),Math.round(zt(e[2],t[2],n))],to=e=>{let t=Math.max(0,Math.min(1,e)),n=lt.length-1,o=t*n,r=Math.min(Math.floor(o),n-1),i=o-r;return lt?ii(lt[r],lt[r+1],i):[0,0,0]},si=e=>{let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return t},je=e=>si(e.toLowerCase().trim())/4294967295,ai=e=>{let t=je(e),[n,o,r]=to(t);return{normal:i=>Pe.bgRgb(n,o,r).black(i),cursor:i=>Pe.bgRgb(n,o,r).white.bold(i)}},jt=e=>{let t=je(e),[n,o,r]=to(t);return{fg:i=>Pe.rgb(n,o,r)(i),fgCursor:i=>Pe.rgb(n,o,r).inverse(i),bg:i=>Pe.bgRgb(n,o,r).black(i),bgCursor:i=>Pe.bgRgb(n,o,r).white.bold(i)}},Gt=e=>ai(e).normal(` ${e} `);var ne=()=>({validity:Q.Valid,completionWordList:[]}),te=({message:e,completionWordList:t})=>({validity:Q.Invalid,message:e,completionWordList:t}),ct=e=>e.length===0,ee=({prefix:e="",wordList:t,postfix:n="",noOfHints:o=2,inputString:r})=>{let a=[...t.filter(Boolean).filter(l=>l.startsWith(r.trim()))].sort((l,v)=>je(l)-je(v)).slice(0,o).map(Gt),d=a.length>1?a.join(" "):"";return d?`${e}${d}${n}`:""},no=()=>ne(),qt=({modifier:e})=>{let t="confirm";return e===t?ne():te({message:ct(e)?`if you are certain, enter ${Gt(t)}`:"",completionWordList:[t]})},oo=({list:e,hint:t})=>({modifier:n})=>e.includes(n)?ne():te({message:ct(n)?t:"",completionWordList:[]}),ro=({hint:e})=>({modifier:t,inputString:n})=>ct(t)&&ct(n)?te({message:e,completionWordList:[]}):ne(),di={[N.FILTER]:e=>{if(e.modifier==="clear")return ne();let t=s=>B(N.FILTER).includes(s);if(!e.modifier||!t(e.modifier??""))return te({message:ee({wordList:B(N.FILTER),noOfHints:100,inputString:e.inputString}),completionWordList:B(N.FILTER)});let o=Object.values(f().tags).map(s=>s.name),r=Object.values(f().contributors).map(s=>s.name),i=e.modifier==="tag"?o:e.modifier==="assignee"?r:[];return e.inputString?i.length&&!i.includes(e.inputString.trim()??"")?te({message:ee({prefix:`existing ${e.modifier}s...`,wordList:i,noOfHints:10,inputString:e.inputString}),completionWordList:i}):ne():te({message:ee({prefix:"one of... ",wordList:i,noOfHints:10,inputString:e.inputString}),completionWordList:i})},[N.NONE]:e=>{let t=B(N.NONE);return e.command?ne():te({message:ee({prefix:"commands... ",wordList:t,noOfHints:100,inputString:e.inputString}),completionWordList:[]})},[N.NEW]:e=>oo({list:B(N.NEW),hint:ee({wordList:B(N.NEW),noOfHints:3,inputString:e.inputString})})(e),[N.HELP]:no,[N.RENAME]:no,[N.DELETE]:e=>qt(e),[N.CLOSE_ISSUE]:e=>qt(e),[N.RE_OPEN_ISSUE]:e=>qt(e),[N.TAG]:e=>ro({hint:ee({prefix:"tag name like... ",wordList:B(N.TAG),noOfHints:3,inputString:e.inputString})})(e),[N.ASSIGN]:e=>ro({hint:ee({wordList:B(N.ASSIGN),postfix:", etc.",noOfHints:3,inputString:e.inputString})})(e),[N.SET_EDITOR]:e=>{let t=B(N.SET_EDITOR);return e.modifier?ne():te({message:ee({wordList:t,noOfHints:100,inputString:e.inputString}),completionWordList:[]})},[N.SET_USERNAME]:e=>e.inputString?ne():te({message:"enter global username (must be unique in project for consistent logs)",completionWordList:[]}),[N.SET_VIEW]:e=>oo({list:B(N.SET_VIEW),hint:ee({wordList:B(N.SET_VIEW),noOfHints:3,inputString:e.inputString})})(e)},io=Object.fromEntries(Object.entries(di).map(([e,t])=>[e,{validate:(n,o,r)=>t({modifier:o,command:n,inputString:r})}]));var so=["frontend","backend","infrastructure","architecture","integration","configuration","implementation","application","deployment","environment","framework","platform","service","component","module","gateway","pipeline","containerization","orchestrator","exception","incident","defect","regression","degradation","malfunction","instability","intermittent","reproducibility","reproduction","investigation","triage","workaround","mitigation","remediation","optimization","stabilization","refinement","failure","outage","blocking","criticality","severity","escalation","diagnostics","analysis","resolution","corruption","inconsistency","validation","verification","authorization","authentication","confidentiality","availability","accessibility","reliability","compliance","governance","encryption","decryption","integrity","auditing","traceability","accountability","protection","privileges","permissions","dependency","orchestration","provisioning","synchronization","compatibility","incompatibility","interoperability","observability","instrumentation","telemetry","loadbalancing","discovery","registration","scheduling","coordination","distribution","isolation","virtualization","serialization","deserialization","initialization","instantiation","propagation","aggregation","consolidation","normalization","standardization","transformation","reconciliation","correlation","processing","indexing","partitioning","enrichment","validation","filtering","streaming","batching","concurrency","parallelism","contention","deadlock","throttling","ratelimiting","backpressure","fragmentation","saturation","exhaustion","partitioning","replication","redundancy","failover","deprecation","obsolescence","starvation","overload","underutilization","latency","throughput","refactoring","modularization","encapsulation","abstraction","extensibility","configurability","maintainability","recoverability","sustainability","readability","testability","debuggability","reusability","simplicity","consistency","performance","functionality","requirement","recommendation","improvement","enhancement","clarification","documentation","description","acceptance","criteria","estimation","prioritization","dependency","deliverable","milestone","iteration"];var L={None:"none",ViewHelp:"view-help",Rename:"rename",Delete:"delete",Filter:"filter",SetView:"set-view",SetEditor:"set-editor",SetUserName:"set-user-name",NewItem:"add-new-item",TagTicket:"ticket-tag",AssignUserToTicket:"ticket-assign-user",CloseIssue:"close-issue",ReopenIssue:"re-open-issue"};var ao=e=>Object.values(N).includes(e),lo=(e,t)=>{let n=e.command??"",{modifier:o,target:r,inputString:i}=e,{message:s,validity:a,completionWordList:d}=io[n].validate(n,o,i),l=r==="command"?Object.values(N):n&&e.target==="modifier"?B(n):so;return{validity:a,command:e.command,modifier:e.modifier,inputString:e.inputString,infoMessage:s??"",autoCompletion:t?eo(e,[...d,...l]):{hint:"",hints:[],remainder:"",overlap:0}}};var co=e=>{let t=e.trimStart(),n=ci(t),o=(n[0]??"").trimStart().trimEnd(),r=(n[1]??"").trimStart().trimEnd(),i=mi(e),s=ao(o)?o:null,a=s!==null,d=o!=="",l=e.endsWith(" "),v=s?B(s)??[]:[],p=s&&v.includes(r)?r:"",C="word";n.length<=1?C="command":n.length===2&&(C="modifier");let h=li(t,s,p);return{raw:e,trimmedStart:t,words:n,firstWord:o,lastWord:i,hasCommand:d,command:s,isCommandKeyword:a,isLastWordCompleted:l,modifier:p,target:C,inputToMatch:i,inputString:h}},li=(e,t,n)=>{let o=e;return t&&o.startsWith(t)&&(o=o.slice(t.length)),o=o.replace(/^\s+/,""),n&&o.startsWith(n)&&(o=o.slice(n.length),o=o.replace(/^\s+/,"")),o},ci=e=>e?e.split(/\s+/):[],mi=e=>e.trimEnd().split(/\s+/).at(-1)??"";var mo=" ",R={commandHistory:[],value:"",commandHistoryIndex:-1,cursorPosition:0,commandIsPending:!1,commandMeta:{command:null,modifier:"",infoMessage:"",inputString:"",validity:Q.None,autoCompletion:{hint:"",hints:[],remainder:"",overlap:0}}},Xt=new Set,uo=()=>{for(let e of Xt)e()},po=e=>(Xt.add(e),()=>Xt.delete(e)),oe=e=>{let n=e(R),o=co(n.value),r=n.cursorPosition===n.value.length;R={...n,commandMeta:lo(o,r)},uo()},Jt=({message:e,result:t})=>{let n=structuredClone(R);n.commandMeta={...n.commandMeta,infoMessage:e??"",validity:t==="fail"?"invalid":"valid"},n.commandIsPending=!0,R=n,uo()},Yt=e=>{oe(t=>({...t,cursorPosition:Math.max(0,Math.min(t.value.length,t.cursorPosition+e))}))},Qt=e=>{oe(t=>{let{value:n,cursorPosition:o}=t,r=o;if(e==="left"){for(;r>0&&n[r-1]===" ";)r--;for(;r>0&&n[r-1]!==" ";)r--}else{for(;r<n.length&&n[r]!==" ";)r++;for(;r<n.length&&n[r]===" ";)r++}return{...t,cursorPosition:r}})},fo=()=>{oe(e=>{let t=e.value.slice(e.cursorPosition),n=Math.max(0,e.cursorPosition-1);return{...e,value:e.value.slice(0,n)+t,cursorPosition:n,commandIsPending:!1}})},go=()=>{oe(e=>{let{value:t,cursorPosition:n}=e,o=n;for(;o>0&&t[o-1]===" ";)o--;for(;o>0&&t[o-1]!==" ";)o--;let r=t.slice(n);return{...e,value:t.slice(0,o)+r,cursorPosition:o,commandIsPending:!1}})},fe=e=>{oe(t=>{let n=Math.max(0,Math.min(t.cursorPosition,t.value.length)),o=t.value.slice(0,n),r=t.value.slice(n),i=e(o,t.commandMeta.autoCompletion),s=i+r,a=Math.max(0,Math.min(i.length,s.length));return{...t,value:s,cursorPosition:a,commandIsPending:!1}})},xo=()=>{oe(e=>({...e,commandIsPending:!0}))},vo=()=>{oe(e=>({...e,commandHistory:[e.value,...e.commandHistory].slice(0,20),commandHistoryIndex:-1,commandIsPending:!1})),ui()},Co=()=>{oe(e=>{let t=Math.min(e.commandHistoryIndex+1,e.commandHistory.length-1),n=e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:n,cursorPosition:n.length}})},yo=()=>{oe(e=>{let t=Math.max(e.commandHistoryIndex-1,-1),n=t===-1?"":e.commandHistory[t]??"";return{...e,commandHistoryIndex:t,value:n,cursorPosition:n.length}})},ui=()=>fe(()=>""),re=()=>R,mt=()=>{let[e,...t]=R.value.split(mo);return t.join(mo).trim()};function pi(e){switch(e.name){case"up":case"down":case"left":case"right":return e.name;case"k":return"up";case"j":return"down";case"h":return"left";case"l":return"right";default:return null}}function fi(e,t,n){let o=f().currentNode.childNavigationAcrossParents;switch(t){case"up":return e==="vertical"?n.prevItem:o?n.prevContainer:null;case"down":return e==="vertical"?n.nextItem:o?n.nextContainer:null;case"left":return e==="horizontal"?n.prevItem:o?n.prevContainer:null;case"right":return e==="horizontal"?n.nextItem:o?n.nextContainer:null}}function No(e,t){let n=re();if(e.sequence===":"&&n.value==="")return"initCommandLine";if(t===u.MOVE)switch(e.name){case"m":case"return":return"confirmMove"}if(t===u.COMMAND_LINE)return Xn(e,n.value);let o=pi(e);if(o){let r=t===u.MOVE?{prevItem:"movePreviousItem",nextItem:"moveNextItem",prevContainer:"moveToPreviousContainer",nextContainer:"moveToNextContainer"}:{prevItem:"navPreviousItem",nextItem:"navNextItem",prevContainer:"navToPreviousContainer",nextContainer:"navToNextContainer"};return fi(f().currentNode.childRenderAxis,o,r)}if(e.ctrl&&e.name==="c")return"exit";switch(e.name){case"e":return"edit";case"n":return"addItem";case"m":return"initMove";case"d":return"Delete";case"e":case"return":return"confirm";case"space":return"confirm";case"v":return f().viewMode==="wide"?"SetViewDense":"SetViewWide";case"q":case"escape":return"exit";default:return null}}import{ulid as ho}from"ulid";var Fe=null,Io=()=>structuredClone(Fe),ut=e=>Fe=e,Eo=()=>{let{currentNode:e,selectedIndex:t}=f(),o=b(e.id)[t];return o?m("Resolved selected child",o):c("Target node not found")};function Zt(e){let t=Eo();if(x(t))return t;let{currentNode:n,nodes:o}=f();if(!n.parentNodeId)return c("Missing parent node id");let r=o[n.parentNodeId];if(!r)return c("Missing parent node");let i=P(r.id),s=i.findIndex(({id:l})=>l===n.id);if(s<0)return c("Current node not found among siblings");let a=i[s+e];if(!a)return c("Missing sibling node");if(ut({id:ho(),userId:J(),action:"move.node",payload:{id:t.data.id,parent:a.id,pos:{at:"end"}}}),!Fe)return c("Could not materialize move state");let d=we(Fe);return x(d)?d:m("Node moved successfully",d.data)}function en(e){let t=Eo();if(x(t))return t;let{currentNode:n,selectedIndex:o}=f(),i=P(n.id)[o+e];if(!i)return c("Missing sibling node");if(ut({id:ho(),userId:J(),action:"move.node",payload:{id:t.data.id,parent:n.id,pos:{at:e===1?"after":"before",sibling:i.id}}}),!Fe)return c("Could not materialize move state");let s=we(Fe);return x(s)?s:m("Node moved successfully",s.data)}var pt=[{intent:"exit",mode:u.MOVE,description:"[<Esc>] exit context / cancel",action:()=>(M({mode:u.DEFAULT}),m("Cancelling move",null))},{intent:"initMove",mode:u.DEFAULT,description:"[m] move init/confirm",action:()=>f().selectedIndex===-1?c("No item selected"):(M({mode:u.MOVE}),m("Init movie succeeded",null))},{intent:"confirmMove",mode:u.MOVE,action:()=>{M({mode:u.DEFAULT});let e=Io();return e!==null&&U(e),ut(null),m("Pasting item",null)}}],ft=[{intent:"movePreviousItem",mode:u.MOVE,action:()=>en(-1)},{intent:"moveNextItem",mode:u.MOVE,action:()=>en(1)}],Ao=[{intent:"moveToNextContainer",mode:u.MOVE,action:()=>Zt(1)},{intent:"moveToPreviousContainer",mode:u.MOVE,action:()=>Zt(-1)}];var bo={[T.WORKSPACE]:[...pt,...ft],[T.BOARD]:[...pt,...ft],[T.SWIMLANE]:[...pt,...ft,...Ao],[T.TICKET]:[],[T.FIELD]:[],[T.FIELD_LIST]:[],[T.TEXT]:[]};import{ulid as Ti}from"ulid";import{spawnSync as Ii}from"node:child_process";import Ei from"node:os";import wo from"node:path";import{ulid as Ai}from"ulid";import{accessSync as gi,copyFileSync as xi,existsSync as gt,mkdirSync as So,readdirSync as To,readFileSync as vi,renameSync as Ci,rmSync as yi,statSync as Mo,unlinkSync as Ni,writeFileSync as hi}from"node:fs";import Be from"node:path";var $={writeToFile:(e,t)=>{try{let n=Be.dirname(e);gt(n)||So(n,{recursive:!0});let o=typeof t=="string"?t:JSON.stringify(t,null,2);hi(e,o,"utf-8")}catch(n){logger.error(`Failed to write file at ${e}:`,n)}},readFile:e=>{try{return vi(e,"utf-8")}catch(t){return logger.error(`Failed to read file at ${e}:`,t),null}},readFileJSON(e){try{let t=$.readFile(e);return t===null?null:JSON.parse(t)}catch(t){return logger.error(`Failed to read JSON at ${e}:`,t),null}},dirExists:e=>{try{return gt(e)&&Mo(e).isDirectory()}catch{return!1}},async fileExists(e){try{return await gi(e),!0}catch{return!1}},mkDir:e=>So(e,{recursive:!0}),locateFolder:e=>{let t=process.cwd(),{root:n}=Be.parse(t);for(;;){let o=Be.join(t,e);try{if(gt(o)&&Mo(o).isDirectory())return o}catch{logger.error(`Unable to locate folder ${e}`)}if(t===n)break;t=Be.dirname(t)}return null},readFirstJSON(e){try{if(!$.dirExists(e))return null;let t=To(e).filter(o=>o.endsWith(".json")).sort()[0];if(!t)return null;let n=Be.join(e,t);return $.readFileJSON(n)}catch(t){return logger.error(`Could not read first JSON in folder ${e}`,t),null}},listDir:e=>{try{return $.dirExists(e)?To(e):[]}catch(t){return logger.error(`Failed to list dir ${e}`,t),[]}},rmFile(e){try{Ni(e)}catch(t){t?.code!=="ENOENT"&&logger.error(`Unable to remove file ${e}`)}},rmDir(e){try{yi(e,{recursive:!0,force:!0})}catch(t){t?.code!=="ENOENT"&&logger.error(`Unable to remove dir ${e}`)}},moveFile(e,t,n){if(this.mkDir(Be.dirname(t)),!n?.overwrite&&gt(t))throw new Error(`moveFile: destination exists: ${t}`);n?.overwrite&&this.rmFile(t);try{Ci(e,t)}catch(o){if(o?.code==="EXDEV"){xi(e,t),this.rmFile(e);return}throw o}}};function bi(){let{preferredEditor:e}=pe(),t=[e,process.env.VISUAL,process.env.EDITOR,"vim","vi","nano"].filter(n=>!!n?.trim());return[...new Set(t)]}function Si(e,t){return/(^|\/)code(-insiders)?$/.test(e.trim())?`${e} --wait "${t}"`:`${e} "${t}"`}function Lo(e){let t=wo.join(Ei.tmpdir(),"epiq");$.mkDir(t);let n=wo.join(t,Ai());$.writeToFile(n,e??"");let o=bi();for(let r of o){let i=Si(r,n),s=Ii(i,{stdio:"inherit",shell:!0});if(!s.error&&s.status===0){let a=$.readFile(n);if(a==null)return c("Unable to read edited file");let d=a.replace(/\r?\n$/,"");return m("Successfully edited",d)}}return c("Unable to open editor")}var Ie=(e,t)=>{let n=e.find(o=>o.context===t);return n!==void 0?m("Found node",n):c("Unable to find node in breadcrumb")};var D={exit(){process.exit(0)},enterChildNode(){let e=f(),t=e.currentNode,n=Math.max(0,e.selectedIndex),o=b(t.id)[n];!o||t.context==="FIELD"||D.navigate({currentNode:o,selectedIndex:b(o.id).length?0:-1})},enterParentNode(){let{currentNode:e,nodes:t}=f();if(!e.parentNodeId){logger.info("Missing parent node id");return}let n=t[e.parentNodeId];if(!n){logger.error("Parent not found");return}let o=b(n.id),r=o.findIndex(({id:s})=>s===e.id),i=o.length===0?-1:r>=0?r:0;D.navigate({currentNode:n,selectedIndex:i})},navigateToNextItem:()=>Po(1),navigateToPreviousItem:()=>Po(-1),navigateToNextContainer:()=>Do(1),navigateToPreviousContainer:()=>Do(-1),navigate:({currentNode:e=f().currentNode,selectedIndex:t})=>{M({currentNodeId:e.id,selectedIndex:t})}},Po=e=>{let t=f(),n=b(t.currentNode.id).length;if(n===0)return;let r=(Math.max(0,t.selectedIndex)+e+n)%n;D.navigate({selectedIndex:r})},Do=e=>{let{currentNode:t,nodes:n,selectedIndex:o}=f();if(!t.childNavigationAcrossParents)return;if(!t.parentNodeId){logger.error("Missing parent node id");return}let r=n[t.parentNodeId];if(!t||!r)return;let i=b(r.id),s=i.findIndex(C=>C.id===t.id);if(s<0)return;let a=i.at(s+e)??i.at(0);if(!a)return;let d=b(a.id),l=Math.max(0,d.length-1),v=Math.min(Math.max(0,o),l),p=d.length?v:-1;D.navigate({currentNode:a,selectedIndex:p})};var Fo=[{intent:"addItem",mode:u.DEFAULT,description:"[n] new...",action:()=>(M({mode:u.COMMAND_LINE}),fe(()=>`${N.NEW} `),m("Adding new item",null))},{intent:"Delete",mode:u.DEFAULT,description:"[d] delete",action:()=>(M({mode:u.COMMAND_LINE}),fe(()=>`${N.DELETE} `),m("Deleting item",null))},{intent:"initCommandLine",mode:u.DEFAULT,description:"[:] focus command line",action:()=>(M({mode:u.COMMAND_LINE}),fe(()=>""),m("Entering command line mode",null))},{intent:"confirm",mode:u.DEFAULT,description:"[<Enter>] confirm/enter",action:()=>(D.enterChildNode(),m("Entering context",null))},{intent:"exit",mode:u.DEFAULT,description:"[q] exit context",action:()=>(D.enterParentNode(),m("Exiting context",null))},{intent:"navPreviousItem",mode:u.DEFAULT,description:"[arrows/hjkl] navigate",action:()=>(D.navigateToPreviousItem(),m("Navigating to previous item",null))},{intent:"navNextItem",mode:u.DEFAULT,action:()=>(D.navigateToNextItem(),m("Navigating to next item",null))},{intent:"navToPreviousContainer",mode:u.DEFAULT,action:()=>(D.navigateToPreviousContainer(),m("Navigating to previous container",null))},{intent:"navToNextContainer",mode:u.DEFAULT,action:()=>(D.navigateToNextContainer(),m("Navigating to next container",null))},{intent:"edit",mode:u.DEFAULT,action:()=>{let e=Ie(f().breadCrumb,"TICKET");if(x(e))return c("No issue node");let t=e.data,n=b(t.id).find(s=>s?.title==="Description");if(!n)return c("Description field not found");let o=n.props.value;if(typeof o!="string")return c("Description field is not a text field");let r=Lo(o);if(x(r))return c("Failed to edit description");let i=r.data;return i===o?m("No changes made",void 0):U({id:Ti(),action:"edit.description",userId:J(),payload:{id:n.id,md:i}})}},{intent:"SetViewDense",mode:u.DEFAULT,description:"[v] view change (wide/dense)",action:()=>(M({viewMode:"dense"}),m("View set",null))},{intent:"SetViewWide",mode:u.DEFAULT,action:()=>(M({viewMode:"wide"}),m("View set",null))}];var Bo=e=>{let{context:t}=f()?.currentNode;if(!t)return L.None;switch(e){case N.DELETE:return L.Delete;case N.HELP:return L.ViewHelp;case N.RE_OPEN_ISSUE:return L.ReopenIssue;case N.CLOSE_ISSUE:return L.CloseIssue;case N.TAG:return L.TagTicket;case N.ASSIGN:return L.AssignUserToTicket;case N.RENAME:return L.Rename;case N.NEW:return L.NewItem;case N.FILTER:return L.Filter;case N.SET_USERNAME:return L.SetUserName;case N.SET_EDITOR:return L.SetEditor;case N.SET_VIEW:return L.SetView;default:return L.None}};import{ulid as O}from"ulid";import{monotonicFactory as Mi,ulid as xt}from"ulid";var vt=Mi(),ko=({name:e,parent:t,userId:n})=>{let o=vt(),r=vt(),i=vt(),s=vt();return[{id:xt(),userId:n,action:"add.issue",payload:{id:o,parent:t,name:e}},{id:xt(),userId:n,action:"add.field",payload:{id:r,parent:o,name:"Description",val:""}},{id:xt(),userId:n,action:"add.field",payload:{id:i,parent:o,name:"Assignees"}},{id:xt(),userId:n,action:"add.field",payload:{id:s,parent:o,name:"Tags"}}]};import wi from"node:os";import Li from"node:path";var Pi=".epiqrc",Ct=()=>Li.join(wi.homedir(),Pi),Di=e=>{try{let t=JSON.parse(e);return m("Parsed config",t??{})}catch{return c("Invalid ~/.epiqrc JSON")}},tn=()=>{let e=Ct(),t=$.readFile(e);return t==null||t.trim()===""?m("No config found, using empty config",{}):Di(t)},nn=e=>{let t=Ct();try{return $.writeToFile(t,JSON.stringify(e,null,2)+`
9
+ `),m("Config written",null)}catch{return c("Unable to write ~/.epiqrc")}},on=e=>{let t=tn();if(x(t))return c("Failed to set preferred editor");let n={...t.data,...e};return nn(n)};var Fi=e=>Object.values(f().tags).find(t=>t.name===e),Bi=e=>Object.values(f().contributors).find(t=>t.name===e),q=()=>J(),Ro=[{intent:L.Delete,mode:u.COMMAND_LINE,action:()=>{let{currentNode:e,selectedIndex:t}=f(),n=b(e.id)[t];return n?U({id:O(),userId:q(),action:"delete.node",payload:{id:n.id}}):c("Unable to resolve child to delete")},onSuccess:()=>M({mode:u.DEFAULT})},{intent:L.Filter,mode:u.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=re().commandMeta,n=/(!=|=)/,[o,r]=e.split(n);if(!o||!(a=>B(N.FILTER).map(d=>d.split(n)[0]).includes(a))(o))return c("Invalid filter modifier");let s={target:o,operator:"=",value:t.trim()};return j(a=>({...a,filters:e==="clear"?[]:[...a.filters,s],mode:u.DEFAULT})),m("Viewing help",null)}},{intent:L.ViewHelp,mode:u.COMMAND_LINE,action:()=>(M({mode:u.HELP}),m("Viewing help",null))},{intent:L.CloseIssue,mode:u.COMMAND_LINE,action:()=>{let{currentNode:e,selectedIndex:t}=f(),n=b(e.id)[t];if(!n)return c("Unable to close issue, no target found");if(!n.parentNodeId)return c("No target parent found");if(!he(n))return c("Cannot close in this context");let o=U({id:O(),userId:q(),action:"close.issue",payload:{id:n.id,parent:n.parentNodeId}});return x(o)?o:m("Viewing help",null)}},{intent:L.ReopenIssue,mode:u.COMMAND_LINE,action:()=>{let{currentNode:e,selectedIndex:t}=f(),n=b(e.id)[t];if(!n)return c("Unable to reopen issue, no target found");let o=n.context==="TICKET"?m("Resolved ticket",n):Te(n.id,"TICKET");if(x(o))return c("Cannot reopen in this context");let r=o.data,i=U({id:O(),userId:q(),action:"reopen.issue",payload:{id:r.id}});return x(i)?i:m("Issue reopened",null)},onSuccess:()=>M({mode:u.DEFAULT})},{intent:L.SetUserName,mode:u.COMMAND_LINE,action:()=>{let e=mt()?.trim();if(!e)return c("No username provided");let t=on({userName:e});return x(t)?t:(ze({userName:e}),M({mode:u.DEFAULT}),m(`Username set to "${e}"`,null))}},{intent:L.SetEditor,mode:u.COMMAND_LINE,action:()=>{let e=mt()?.trim();if(!e)return c("No editor provided");let t=on({preferredEditor:e});return x(t)?t:(ze({preferredEditor:e}),M({mode:u.DEFAULT}),m(`Editor configuration set to "${e}"`,null))}},{intent:L.NewItem,mode:u.COMMAND_LINE,action:(e,t)=>{if(!t.inputString)return c(`provide a name for your ${t.modifier}`);let n=o=>{let r=U(o);if(x(r))return r;let i=g.getNode(r.data.result.id);if(!i)return c("Created node not found");if(!i.parentNodeId)return r;let s=g.getNode(i.parentNodeId);return s?(D.navigate({currentNode:s,selectedIndex:g.getSiblings(i.parentNodeId).findIndex(({id:a})=>a===i.id)}),r):c("Parent node not found")};if(t.modifier==="board"){let{rootNodeId:o}=f(),r=g.getNode(o);return r?n({id:O(),userId:q(),action:"add.board",payload:{id:O(),name:t.inputString,parent:r.id}}):c("Workspace not found")}if(t.modifier==="swimlane"){let o=Ie(f().breadCrumb,"BOARD");return x(o)?c("Unable to add swimlane in this context"):n({id:O(),userId:q(),action:"add.swimlane",payload:{id:O(),name:t.inputString,parent:o.data.id}})}if(t.modifier==="issue"){let o=Ie(f().breadCrumb,"SWIMLANE");if(x(o))return c("Unable to add issue in this context");let r=ko({name:t.inputString,parent:o.data.id,userId:q()}),i=dt(r);if(i.some(d=>x(d)))return c("Issue create failed: "+i.filter(x).map(d=>d.message).filter(Boolean).join(", "));let s=i[0];if(!s||x(s))return c("Issue creation failed");let a=r[0]?.payload.id;return a?(D.navigate({currentNode:o.data,selectedIndex:g.getSiblings(o.data.id).findIndex(({id:d})=>d===a)}),m("Issue created",null)):c("Unable to determine ticket id")}return Dn()},onSuccess:()=>M({mode:u.DEFAULT})},{intent:L.SetView,mode:u.COMMAND_LINE,action:()=>{let{commandMeta:e}=re();return e.validity===Q.Invalid?c("Invalid command "+Z):(j(t=>({...t,viewMode:e.modifier==="wide"?"wide":e.modifier==="dense"?"dense":t.viewMode})),m("View set",null))},onSuccess:()=>M({mode:u.DEFAULT})},{intent:L.Rename,mode:u.COMMAND_LINE,action:()=>{let{currentNode:e,selectedIndex:t}=f(),n=b(e.id)[t];if(!n)return c("Missing node");let o=mt();return o?U({id:O(),userId:q(),action:"edit.title",payload:{id:n.id,name:o}}):c("Provide a new name")},onSuccess:()=>M({mode:u.DEFAULT})},{intent:L.TagTicket,mode:u.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=re().commandMeta,n=e||t;if(!n)return c("Provide a tag");let{selectedIndex:o,currentNode:r}=f(),i=b(r.id)[o];if(!i)return c("Invalid tag target");let s=Te(i.id,"TICKET");if(x(s))return c("Unable to tag issue in this context");let a=s.data,d=Fi(n),l;if(d)l=d.id;else{let C=O(),h=U({id:O(),userId:q(),action:"create.tag",payload:{id:C,name:n}});if(x(h))return h;l=h.data.result.id}let v=g.getFieldByTitle(a.id,"Tags");return v?b(v.id).some(C=>C.props?.value===l)?c("Already tagged with that tag"):U({id:O(),userId:q(),action:"tag.issue",payload:{id:O(),target:a.id,tagId:l}}):c("Unable to locate tags field")},onSuccess:()=>M({mode:u.DEFAULT})},{intent:L.AssignUserToTicket,mode:u.COMMAND_LINE,action:()=>{let{modifier:e,inputString:t}=re().commandMeta,n=e||t;if(!n)return c("Provide an assignee");let{selectedIndex:o,currentNode:r}=f(),i=b(r.id)[o];if(!i)return c("Invalid assign target");let s=Te(i.id,"TICKET");if(x(s))return c("Unable to assign issue in this context");let a=s.data,d=Bi(n),l;if(d)l=d.id;else{let C=O(),h=U({id:O(),userId:q(),action:"create.contributor",payload:{id:C,name:n}});if(x(h))return h;l=h.data.result.id}let v=g.getFieldByTitle(a.id,"Assignees");return v?b(v.id).some(C=>C.props?.value===l)?c("Assignee already assigned"):U({id:O(),userId:q(),action:"assign.issue",payload:{id:O(),target:a.id,contributor:l}}):c("Unable to locate assignees field")},onSuccess:()=>M({mode:u.DEFAULT})}];var Oo=(...e)=>{let{commandMeta:{command:t,validity:n,modifier:o,inputString:r}}=re();if(!t)return;let i=Bo(t);if(xo(),n===Q.Invalid)return;let s=Ro.find(d=>d.intent===i);if(!s)return Jt({result:Z.Fail,message:"Command not found",data:null});let a=s.action(s,{command:t,inputString:r,modifier:o});if(x(a))return Jt(a);vo(),s?.onSuccess?.()};var Uo=[{intent:"viewHelp",mode:u.DEFAULT,action:()=>(M({mode:u.HELP}),m("Viewing help",null))},{intent:"exit",mode:u.HELP,action:()=>(M({mode:u.DEFAULT}),m("Exiting help",null))},{intent:"confirm",mode:u.COMMAND_LINE,action:(...e)=>(Oo(...e),m("Executing command",null))},{intent:"MoveCursorLeft",mode:u.COMMAND_LINE,action:()=>(Yt(-1),m("Moving cursor left",null))},{intent:"MoveCursorRight",mode:u.COMMAND_LINE,action:()=>(Yt(1),m("Moving cursor right",null))},{intent:"MoveCursorLeftOfWord",mode:u.COMMAND_LINE,action:()=>(Qt("left"),m("Moving cursor left of word",null))},{intent:"MoveCursorRightOfWord",mode:u.COMMAND_LINE,action:()=>(Qt("right"),m("Moving cursor right of word",null))},{intent:"exitCommandLine",mode:u.COMMAND_LINE,action:()=>(M({mode:u.DEFAULT}),m("Exiting command line",null))},{intent:"autoCompleteCommand",mode:u.COMMAND_LINE,action:()=>(fe((e,{remainder:t})=>t?e+t:e),m("Auto-completing command",null))},{intent:"captureInput",mode:u.COMMAND_LINE,action:(e,{sequence:t})=>(fe(n=>n+t),m("Capturing input",null))},{intent:"eraseInput",mode:u.COMMAND_LINE,action:()=>(fo(),m("Erasing input",null))},{intent:"EraseInputWord",mode:u.COMMAND_LINE,action:()=>(go(),m("Erasing input word",null))},{intent:"getLastCommandFromHistory",mode:u.COMMAND_LINE,action:()=>(Co(),m("Getting last command from history",null))},{intent:"getNextCommandFromHistory",mode:u.COMMAND_LINE,action:()=>(yo(),m("Getting next command from history",null))}];import ki from"chalk";var Ge={bg:"#1a1b26",fg:"#c0caf5",grayDark:"#2f344d",gray:"#4c567a",grayLight:"#7f8bb3",cyan:"#7dcfff",cyanSoft:"#89ddff",blue:"#7aa2f7",magenta:"#9d7cd8",magentaSoft:"#a890e8",green:"#9ece6a",yellow:"#e0af68",red:"#f7768e",white:"#ffffff"},y={accent:Ge.cyan,accent2:Ge.magenta,primary:Ge.white,secondary:Ge.grayDark,secondary2:Ge.grayLight};var yt=": for command line",Wo="q to exit",Ho=`${ki.hex(y.accent)("m")} to confirm`,rn={[T.WORKSPACE]:[yt],[T.BOARD]:[yt],[T.BOARD+u.COMMAND_LINE]:[yt],[T.SWIMLANE]:[yt],[T.TICKET+u.HELP]:[Wo],[T.SWIMLANE+u.HELP]:[Wo],[T.TICKET]:[],[T.FIELD]:[],[T.SWIMLANE+u.MOVE]:[Ho],[T.TICKET+u.MOVE]:[Ho]};var Nt=e=>e.trim().toLocaleLowerCase(),Ri=(e,t)=>{let n=g.getFieldByTitle(e,t);if(!n)return"";let o=n.props?.value;return typeof o=="string"?o:""},Oi=e=>{let{tags:t}=f(),n=g.getFieldByTitle(e,"Tags");return n?P(n.id).map(o=>{let r=o.props?.value;return typeof r=="string"?t[r]?.name:void 0}).filter(o=>!!o):[]},Ui=e=>{let{contributors:t}=f(),n=g.getFieldByTitle(e,"Assignees");return n?P(n.id).map(o=>{let r=o.props?.value;return typeof r=="string"?t[r]?.name:void 0}).filter(o=>!!o):[]},_o=(e,t)=>{let n=t.value;if(!n)return!0;switch(t.target){case"title":return Nt(e.title??"").includes(n);case"description":return Nt(Ri(e.id,"Description")).includes(n);case"tag":return Oi(e.id).map(Nt).some(a=>a.includes(n));case"assignee":return Ui(e.id).map(Nt).some(a=>a.includes(n));default:return!0}};function Vo(e,t,n){let o=t[e];if(!o)return c("buildBreadCrumb(): current node not found");let r=[],i=o;for(;i&&(r.push(i),!(i.id===n||!i.parentNodeId));)i=t[i.parentNodeId];let s=r[r.length-1];return!s||s.id!==n?c("buildBreadCrumb(): node is not connected to root"):(r.reverse(),m("Breadcrumb built",r))}var Ko=e=>{let t={};for(let n of e)n.intent&&(t[n.mode]||(t[n.mode]={}),t[n.mode][n.intent]=n);return t};var ht,sn=new Set,$o=()=>{for(let e of sn)e()},Hi=e=>(sn.add(e),()=>sn.delete(e));function zo(e){let{currentNodeId:t,mode:n,rootNodeId:o,nodes:r,filters:i}=e;if(!t)return c("derive(): currentNodeId is missing");if(!o)return c("derive(): rootNode is missing");if(!r[o])return c("derive(): unable to find root node");let a=r[t];if(!a)return logger.error("Unable to derive state, currentNode not found"),c("Unable to derive state, currentNode not found");let d=Vo(t,r,o);if(x(d))return logger.error(d.message),d;let l=d.data,{context:v}=a,p=rn[v+n]??rn[v]??[],C=[...Fo,...bo[v]??[],...Uo],h=Ko(C);return m("Derived successfully",{...e,currentNode:a,breadCrumb:l,availableHints:p,availableActions:C,actionIndex:h,renderedChildrenIndex:_i(r,i)})}var f=()=>(ht||logger.error("State not initialized. Call initWorkspaceState() first.",new Error().stack),ht);function Un(e){let t={filters:[],tags:{},contributors:{},viewMode:"dense",mode:u.DEFAULT,nodes:{[e.id]:e},rootNodeId:e.id,currentNodeId:e.id,renderedChildrenIndex:{},selectedIndex:-1},n=zo(t);return x(n)?n:(ht=n.data,$o(),m("State initialized",null))}function j(e){let t=f(),n=e(t),o=zo(n);return x(o)?c(o.message??"Unable to update state"):(ht=o.data,$o(),m("State updated",null))}var M=e=>j(t=>({...t,...e}));var k=()=>Wi(Hi,f,f),_i=(e,t)=>{let n={};for(let o of Object.values(e))he(o)&&t.length>0&&!t.every(r=>_o(o,r))||!o.parentNodeId||o.isDeleted||((!o.parentNodeId||!n[o.parentNodeId])&&(n[o.parentNodeId]=[]),n[o.parentNodeId].push(o));for(let o of Object.keys(n))n[o].sort((r,i)=>{let s=e[r.id],a=e[i.id];return!s||!a?0:s.rank.localeCompare(a.rank)});return n},b=e=>f().renderedChildrenIndex[e]??[];import{Box as It,Text as an}from"ink";import ge from"react";import{Text as jo}from"ink";import Go,{useEffect as Vi,useState as Ki}from"react";var qo={help:["\u25B8 ","\u25B8 ","\u25B8 "],default:["\u25B8 ","\u25B8 ","\u25B8 "],move:["\u2191 ","\u2192 ","\u2193 ","\u2190 "],"command-line":["\u276F ","\u276F ","\u276F "]},_=({isSelected:e,placeholder:t=" "})=>{let{mode:n}=k(),o=qo[n]??qo.default,[r,i]=Ki(o.length-1);return Vi(()=>{if(!e)return;let s=setInterval(()=>{i(a=>(a+1)%o.length)},800);return()=>clearInterval(s)},[e,o]),e?Go.createElement(jo,{color:y.accent,dimColor:r===1},o[r]):Go.createElement(jo,null,t)};function dn(){let e=k(),t=e.nodes[e.rootNodeId],r=process.stdout.rows-1-3,i=process.stdout.columns||120,s=t?.id?b(t?.id):[];return ge.createElement(It,{flexDirection:"column",height:r,padding:1,borderStyle:"round",borderColor:y.secondary,width:i},ge.createElement(It,{padding:1,paddingTop:0,paddingBottom:0},ge.createElement(an,null,"Select a board:")),ge.createElement(It,{padding:1,flexDirection:"column"},s.map((a,d)=>{let l=e.currentNode.context==="WORKSPACE"&&e.selectedIndex===d,p=b(a.id).flatMap(({id:C})=>P(C)).length;return ge.createElement(It,{key:a.id??d},ge.createElement(an,{color:l?y.accent:y.secondary},ge.createElement(_,{isSelected:l})),ge.createElement(an,{color:l?y.accent:y.secondary},a.title," (",p," issues)",a.readonly?" \u{1F512}":""))})))}import{Box as xs}from"ink";import Tt from"react";import{Box as mn,Text as ts}from"ink";import Y from"react";import{Box as ln,Text as $i}from"ink";import Et from"react";var At=({children:e=[],height:t,selectedIndex:n,itemHeight:o=1,scrollByOne:r=!1})=>{if(e.length===0)return null;let i=Math.max(1,Math.floor(t)),s=Math.max(1,Math.ceil(o)),a=Math.max(1,Math.floor(i/s)),d=Math.max(0,Math.min(n,e.length-1)),l=Math.max(0,e.length-a),v=r?Math.min(l,Math.max(0,d-a+1)):Math.min(l,Math.floor(d/a)*a),p=v+a,C=e.slice(v,p),h=e.length>a,A=i,E=h?Math.max(1,Math.floor(a/e.length*A)):A,I=Math.max(0,A-E),S=Math.max(1,e.length-a),z=h?Math.floor(v/S*I):0;return Et.createElement(ln,{flexDirection:"row",height:i,width:"100%"},Et.createElement(ln,{flexDirection:"column",flexGrow:1,height:i},C),Et.createElement(ln,{flexDirection:"column",width:1,height:A},Array.from({length:A}).map((_e,me)=>Et.createElement($i,{key:me,color:h&&me>=z&&me<z+E?y.accent:y.secondary},h?"\u2502":" "))))};import{Box as bt,Text as Qi}from"ink";import Ee from"react";import{Text as zi}from"ink";import ji from"react";var Gi=e=>e.toLowerCase().trim(),qi=(e,t=Le)=>{let n=Gi(e);return t[n]?t[n]:De(n)},ke=({id:e,isSelected:t})=>{let n=g.getContributor(e);if(n)return ji.createElement(zi,{underline:t,color:qi(n.name)},"@"+n.name)};import{Text as Xi}from"ink";import Ji from"react";var Yi=e=>e.toLowerCase().trim(),qe=(e,t=Le)=>{let n=Yi(e);return t[n]?t[n]:De(n)},Re=({id:e,isSelected:t})=>{let n=g.getTag(e);if(n)return Ji.createElement(Xi,{underline:t,backgroundColor:qe(n.name),color:y.primary}," "+n.name+" ")};var Xo=({width:e,ticket:t,isSelected:n})=>{let o=e-14,r=rt(it(t.title),o),i=b(t.id),s=l=>{let v=i.find(p=>p.title===l);return v?b(v.id).map(p=>typeof p.props?.value=="string"?p.props.value:"").filter(p=>!!p):[]},a=s("Tags").map(l=>g.getTag(l)).filter(l=>!!l),d=s("Assignees").map(l=>g.getContributor(l)).filter(l=>!!l);return Ee.createElement(bt,{borderStyle:"round",width:e-7,height:4,flexDirection:"column",borderColor:n?y.accent:y.secondary,justifyContent:"space-between"},Ee.createElement(bt,{borderBottom:!0},Ee.createElement(bt,{paddingLeft:1,flexDirection:"column"},Ee.createElement(Qi,{color:y.primary},r))),Ee.createElement(bt,{flexDirection:"row",paddingLeft:1},a.map(l=>Ee.createElement(Re,{key:l.id,id:l.id})),d.map(l=>Ee.createElement(ke,{key:l.id,id:l.id}))))};import Zi from"chalk";import{Box as Xe,Text as cn}from"ink";import ie from"react";var es=(e,t)=>e.length>=t?e.slice(0,t)+"...":e,Jo=({width:e,ticket:t,isSelected:n,index:o,mode:r})=>{let i=b(t.id),s=E=>{let I=i.find(S=>S.title===E);return I?b(I.id).map(S=>typeof S.props?.value=="string"?S.props.value:"").filter(S=>!!S):[]},a=s("Tags").map(E=>g.getTag(E)).filter(E=>!!E),d=s("Assignees").map(E=>g.getContributor(E)).filter(E=>!!E),l=1,v=a.length*(1+l),p=d.length*(2+l),C=a.map(E=>ie.createElement(Xe,{key:E.id,paddingRight:l},ie.createElement(cn,{color:qe(E.name)},"\u25A0"))),h=d.map(E=>ie.createElement(Xe,{key:E.id,paddingRight:l},ie.createElement(cn,{color:De(E.name)},"@"+E.name.at(0)))),A=n?y.accent:r===u.MOVE?y.secondary:y.primary;return ie.createElement(Xe,{borderBottom:!0,justifyContent:"space-between"},ie.createElement(Xe,null,ie.createElement(_,{isSelected:n,placeholder:Zi.dim.gray(o+1+" ")}),ie.createElement(cn,{wrap:"truncate",color:A},es(t.title,e-v-p-14),"v")),ie.createElement(Xe,null,C,h))};var ns=({swimlane:e,isSelected:t,width:n,height:o,isDense:r,isFocused:i,listSelectedIndex:s,mode:a})=>{let{renderedChildrenIndex:d}=k(),l=d[e.id]??[],v=`${e.title} (${l.length})`,p=3,C=r?1:4,h=o-p-(r?2:1),A=Y.createElement(mn,{borderStyle:"round",borderColor:y.secondary,justifyContent:"flex-start",borderLeft:!1,borderTop:!1,borderRight:!1},Y.createElement(_,{isSelected:t}),Y.createElement(ts,{bold:!0,color:t?y.accent:y.primary},v," ",e.readonly?"\u{1F512}":"")),E=(I,S)=>{let z=i&&s===S;return r?Y.createElement(Jo,{key:I.id,index:S,width:n,ticket:I,isSelected:z,mode:a}):Y.createElement(Xo,{key:I.id,width:n,ticket:I,isSelected:z})};return Y.createElement(mn,{flexDirection:"column",width:n,borderStyle:"round",borderColor:t?y.accent:y.secondary,paddingRight:1,paddingLeft:1,height:o},A,Y.createElement(mn,{padding:r?1:0},l.length>0&&Y.createElement(At,{selectedIndex:s,height:h,itemHeight:C},l.map(E)),Y.createElement(_,{isSelected:i&&s===-1})))},Yo=Y.memo(ns);import{Box as fn,Text as fs}from"ink";import xe,{useEffect as gn,useMemo as ir}from"react";import Oe from"chalk";import Zo from"string-width";import{decodeTime as os}from"ulid";var Qo=e=>{let t=Date.now()-e,n=[{label:"y",ms:1e3*60*60*24*365},{label:"mo",ms:1e3*60*60*24*30},{label:"w",ms:1e3*60*60*24*7},{label:"d",ms:1e3*60*60*24},{label:"h",ms:1e3*60*60},{label:"m",ms:1e3*60},{label:"s",ms:1e3}];for(let{label:o,ms:r}of n){let i=Math.floor(t/r);if(i>=1)return`${i}${o} ago`}return"just now"};var rs=(e,t)=>e+" ".repeat(Math.max(0,t-Zo(e))),is=(e,t)=>" ".repeat(Math.max(0,t-Zo(e)))+e,ss=e=>(()=>{let n={"add.issue":"Created with title","assign.issue":"Assigned to","close.issue":"Closed","delete.node":"Deleted","edit.title":"Changed title to","edit.description":"Changed description","reopen.issue":"Reopened","tag.issue":"Tagged with","lock.node":"Locked node","move.node":"Moved issue to"};return(r=>n[r]??(r.endsWith("e")?`${r}d`:`${r}ed`))(e)})(),as=e=>{switch(e.action){case"move.node":{let t=g.getNode(e.payload.parent);return t?`${Oe.bgBlack(` ${t.title} `)}`:"to unknown"}case"tag.issue":{let t=f().tags[e.payload.tagId];return t?Oe.bgHex(qe(t.name))(` ${t.name} `):"unknown tag"}case"assign.issue":{let t=f().contributors[e.payload.contributor];return t?Oe.bgBlack(` ${t.name} `):"unknown user"}case"add.board":case"add.swimlane":case"add.issue":case"add.field":case"create.tag":case"create.contributor":case"edit.title":return`"${"name"in e.payload?e.payload.name:""}"`;default:return""}},ds=e=>{let t=Qo(os(e));return Oe.gray(is(t,8))},ls=12,cs=e=>Oe.dim(rs(`${e}`,ls)),er=e=>{let t=ds(e.id),n=cs(e.userId),o=ss(e.action),r=as(e),i=Oe.dim("\u203A"),s=[o,r].filter(Boolean).join(" ");return`${n} ${t} ${i} ${s}`};import{Box as St,Text as ms}from"ink";import se from"react";var tr=({selectedIndex:e,parent:t,selected:n})=>{let{currentNode:o}=k(),{title:r}=t,i=b(t.id).map(s=>{let a=typeof s.props?.value=="string"?s.props.value:"";if(r==="Assignees")return g.getContributor(a)?.id;if(r==="Tags")return g.getTag(a)?.id}).filter(s=>!!s);return se.createElement(St,{alignItems:"center",paddingTop:1},se.createElement(St,{minWidth:12},se.createElement(_,{isSelected:n}),se.createElement(ms,{color:n?y.accent:y.secondary},r,":")),se.createElement(St,{flexDirection:"row",marginLeft:1,paddingRight:1},i.map((s,a)=>{let d=o.id===t.id&&a===e;return se.createElement(St,{key:`${r}-${s}`,paddingRight:2,minHeight:1},se.createElement(_,{isSelected:d}),r==="Assignees"?se.createElement(ke,{isSelected:d,id:s}):r==="Tags"?se.createElement(Re,{isSelected:d,id:s}):null)})))};import nr from"chalk";import{Box as un,Text as or}from"ink";import{marked as rr}from"marked";import us from"marked-terminal";import Ae,{useEffect as ps}from"react";var pn=({id:e,text:t,height:n,selected:o,maxWidth:r})=>{let{selectedIndex:i,currentNode:s}=k();rr.setOptions({renderer:new us});let a=p=>String(rr.parseInline(p)).replace(/\r?\n/g,""),d=typeof t=="string"?t.split(/\r?\n|\u2028|\u2029/):[];ps(()=>{let p=[];return d.forEach((C,h)=>{let A=H.text(`${h}`,`Line ${h+1}`,e,{value:C}),E=g.createNodeAtPosition(A);ue(E)&&p.push(E.data.id)}),()=>p.forEach(g.deleteNode)},[e,t]);let l="\u2029",v=d.map((p,C)=>Ae.createElement(or,{key:`${e}-${C}`},(s.id===e&&i===C?nr.cyan(`\u25B8 ${Array.from({length:String(C).length}).map(()=>" ").join("")}`):nr.dim.gray(`${C+1} `))+a(p.length?rt(p,r-10):l)));return Ae.createElement(un,{flexDirection:"column",paddingTop:1},Ae.createElement(un,null,Ae.createElement(_,{isSelected:o}),Ae.createElement(or,{color:o?y.accent:y.secondary},"Inline Editor (press e to edit)")),Ae.createElement(un,{flexDirection:"row",borderStyle:"round",borderColor:y.secondary,paddingLeft:1,paddingRight:1,marginLeft:1},Ae.createElement(At,{scrollByOne:!0,children:v,height:n-2,selectedIndex:i,itemHeight:1})))};var gs=e=>`${e}::log`,sr=({ticket:e,height:t})=>{let{selectedIndex:n,currentNode:o}=k(),r=process.stdout.columns||120,i=ir(()=>gs(e.id),[e.id]),s=ir(()=>[...e.log].reverse().map(er).join(`
10
+ `),[e.log]);gn(()=>{if(g.getNode(i))return;let S={...H.field(i,"Log",e.id,{value:s}),readonly:!0,childRenderAxis:"vertical"};return g.createNodeAtPosition(S),()=>{g.deleteNode(i)}},[i,e.id]),gn(()=>{let I=g.getNode(i);I&&I.props.value!==s&&g.updateNode({...I,props:{...I.props,value:s},childRenderAxis:"vertical",readonly:!0})},[i,s]);let a=o.id===e.id,d=o.id===i||o.parentNodeId===i;gn(()=>{d&&(n>=0||D.navigate({selectedIndex:0}))},[d,n]);let l=b(e.id);if(d){let I=g.getNode(i),z=t-3;return xe.createElement(fn,{width:r,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},I?xe.createElement(pn,{id:I.id,text:I.props.value??"",selected:!1,maxWidth:r,height:z}):null)}let v=l.reduce((I,S)=>S.title==="Assignees"||S.title==="Tags"||S.id===i?++I:I,0),p=2,C=v*1,A=t-3-C-p,E=(I,S)=>I.title==="Assignees"||I.title==="Tags"?xe.createElement(tr,{key:I.id,parent:I,selected:S,selectedIndex:n}):I.id===i?xe.createElement(fn,{key:I.id,paddingTop:1},xe.createElement(_,{isSelected:S}),xe.createElement(fs,{backgroundColor:y.secondary,color:S?y.accent:y.primary}," History \u203A\u203A ")):xe.createElement(pn,{key:I.id,id:I.id,text:I.props.value??"",selected:S,maxWidth:r,height:A});return xe.createElement(fn,{width:r,flexDirection:"column",paddingRight:1,paddingBottom:1,minHeight:t},l.map((I,S)=>E(I,a&&n===S)))};var vs=({swimlanes:e,currentNode:t,selectedIndex:n,breadCrumb:o,mode:r,viewMode:i,height:s,width:a})=>{let d=t.context,l=d===T.TICKET||d===T.FIELD_LIST||d===T.FIELD,v=d===T.BOARD||d===T.SWIMLANE,p=d===T.TICKET?t:o.find(I=>I.context===T.TICKET),C=Math.floor(a/3),h=Math.floor(a/Math.max(e.length,1)),A=Math.min(h,C),E=i==="dense";return Tt.createElement(xs,{flexDirection:"row",height:s},v&&e.map((I,S)=>{let z=t.id===I.id,_e=z?n:-1,me=t.context===T.BOARD&&n===S;return Tt.createElement(Yo,{key:I.id,height:s,width:A,swimlane:I,isSelected:me,isDense:E,isFocused:z,listSelectedIndex:_e,mode:r})}),l&&p&&Tt.createElement(sr,{height:s,ticket:p}))},ar=Tt.memo(vs);var Ns=({currentNode:e,selectedIndex:t,breadCrumb:n,mode:o,viewMode:r,height:i,width:s})=>{let{renderedChildrenIndex:a}=k(),d=n.find(({context:C})=>C==="BOARD"),p=i-1-3;return Je.createElement(Cs,{flexDirection:"row"},e.context==="WORKSPACE"?Je.createElement(dn,null):d?Je.createElement(ar,{height:p,width:s,swimlanes:(a[d.id]??[]).filter(C=>C!==void 0&&Pn(C)),currentNode:e,selectedIndex:t,breadCrumb:n,viewMode:r,mode:o}):Je.createElement(ys,null))},dr=Je.memo(Ns);import{Box as Cn,Text as fr}from"ink";import Ue from"react";import vn from"chalk";import{Box as xn,Text as lr}from"ink";import Ye,{useEffect as hs,useMemo as Is,useState as Es}from"react";var cr=vn.gray,As=vn.inverse,bs=vn.inverse.gray,Ss={hint:"",hints:[],overlap:0,remainder:""},ur=({value:e,command:t})=>{if(!t)return null;let n=e.trimStart(),r=e.length-n.length;return e.slice(r,r+t.length)!==t?null:{start:r,end:r+t.length}},Ts=({value:e,command:t,modifier:n})=>{if(!t||!n)return null;let o=ur({value:e,command:t});if(!o)return null;let i=e.slice(o.end).match(/^\s*/)?.[0].length??0,s=o.end+i;return e.slice(s,s+n.length)!==n?null:{start:s,end:s+n.length}},mr=()=>({value:R.value,cursorPosition:R.cursorPosition,commandIsPending:R.commandIsPending,autoCompletion:R.commandMeta.autoCompletion??Ss,infoMessage:R.commandMeta.infoMessage,validationStatus:R.commandMeta.validity,command:R.commandMeta.command,inputString:R.commandMeta.inputString,modifier:R.commandMeta.modifier}),Ms=(e,t)=>e.value===t.value&&e.cursorPosition===t.cursorPosition&&e.commandIsPending===t.commandIsPending&&e.infoMessage===t.infoMessage&&e.autoCompletion.hint===t.autoCompletion.hint&&e.autoCompletion.overlap===t.autoCompletion.overlap&&e.autoCompletion.remainder===t.autoCompletion.remainder&&e.validationStatus===t.validationStatus&&e.command===t.command&&e.modifier===t.modifier&&e.inputString===t.inputString,pr=({width:e})=>{let[t,n]=Es(mr());hs(()=>{let p=()=>{let h=mr();n(A=>Ms(A,h)?A:h)},C=po(p);return p(),()=>{C()}},[]);let{value:o,cursorPosition:r,infoMessage:i,commandIsPending:s,autoCompletion:a,command:d,modifier:l}=t,v=Is(()=>{let p=Math.max(0,Math.min(r,o.length)),C=ur({value:o,command:d}),h=Ts({value:o,command:d,modifier:l}),A=d?jt(d):null,E=l?jt(l):null,I=(V,K)=>{let Rt=C&&K>=C.start&&K<C.end,Ot=h&&K>=h.start&&K<h.end;return Rt&&A?A.fg(V):Ot&&E?E.bg(V):V},S=(V,K)=>{let Rt=C&&K>=C.start&&K<C.end,Ot=h&&K>=h.start&&K<h.end;return Rt&&A?A.fgCursor(V):Ot&&E?E.bgCursor(V):As(V)},z=o.slice(0,p),_e=o[p]??" ",me=p<o.length?o.slice(p+1):"",Tr=Array.from(z).map((V,K)=>I(V,K)).join(""),bn=S(_e,p),Sn=Array.from(me).map((V,K)=>I(V,p+1+K)).join("");if(a.hint){let V=a.hint[a.overlap]??_e;bn=bs(V),Sn=cr(a.remainder.slice(1)+me)}return cr(":")+Tr+bn+Sn},[o,r,a,d,l]);return Ye.createElement(xn,{flexDirection:"column",justifyContent:"flex-start"},Ye.createElement(xn,{flexDirection:"column",paddingX:1,borderColor:y.secondary,borderStyle:"round",width:e},Ye.createElement(xn,null,Ye.createElement(lr,null,v),i&&Ye.createElement(lr,{wrap:"truncate",color:s?"red":y.secondary},` ${i} `))))};var yn=({width:e,mode:t,availableHints:n})=>{let o=[],r=0;for(let i of n){let a=(o.length>0?" | ":"").length+i.length;if(r+a>e+2)break;o.push(i),r+=a}return Ue.createElement(Cn,null,t===u.COMMAND_LINE?Ue.createElement(pr,{width:e}):Ue.createElement(Cn,{flexDirection:"column",paddingX:1,borderColor:y.secondary,borderStyle:"round",width:e},Ue.createElement(Cn,{flexDirection:"row"},o.map((i,s)=>Ue.createElement(fr,{key:i,color:y.secondary},(s>0?" | ":"")+i)),Ue.createElement(fr,null," "))))};import{Box as We,Text as gr}from"ink";import ve from"react";var xr=({width:e})=>{let t=[...f().availableActions].map(n=>n.description).filter(n=>n!==void 0).map(n=>{let[o,r]=n.split("]"),i=o?.replace("[",""),s=r?.trim();return[i,s]}).filter(n=>n[0]!==void 0&&n[1]!==void 0).sort(([n],[o])=>n.length===1&&o.length!==1?-1:n.length!==1&&o.length===1?1:n.localeCompare(o,void 0,{sensitivity:"base"}));return t.unshift(["Key(s)","Action"]),ve.createElement(We,{flexDirection:"column",marginTop:3,borderColor:y.secondary,borderStyle:"round",width:e,minHeight:19},ve.createElement(We,{flexDirection:"column",width:e},f().mode===u.HELP?t.map(([n,o],r)=>ve.createElement(We,{paddingLeft:1,key:r,flexDirection:"row"},ve.createElement(We,{key:r,flexDirection:"row",paddingBottom:r?0:1},ve.createElement(We,{width:20,justifyContent:"flex-end"},ve.createElement(gr,{color:r?y.accent:y.secondary},n)),ve.createElement(We,{flexGrow:1,width:40,paddingLeft:2},ve.createElement(gr,{color:r?y.primary:y.secondary},o))))):null))};import{Box as He,Text as Ce}from"ink";import F from"react";var Mt=({isDone:e,command:t,value:n})=>F.createElement(He,null,F.createElement(Ce,{color:y.accent,dimColor:e},e?" \u2714 ":" "),F.createElement(Ce,{dimColor:e},"Type "),F.createElement(Ce,{backgroundColor:y.secondary,dimColor:e}," "+t+" "),n&&F.createElement(F.Fragment,null,F.createElement(Ce,{dimColor:e}," "),F.createElement(Ce,{color:y.secondary,dimColor:e},"<"+n+">")));function Nn({width:e,height:t,hasUserName:n,hasPreferredEditor:o,userName:r,preferredEditor:i}){let s=n&&o,a=n?o?null:":set:editor":":set:username";return F.createElement(He,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:y.secondary,rowGap:1},F.createElement(Ce,{color:y.accent,bold:!0},"Welcome! \u{1F539}"),!s&&F.createElement(Ce,{dimColor:!0},a===":set:username"?"First, choose your username.":"Nice. One more step."),F.createElement(He,{flexDirection:"column"},n&&F.createElement(He,{marginBottom:1},F.createElement(Mt,{isDone:!0,command:":set:username",value:r})),!n&&F.createElement(Mt,{isDone:!1,command:":set:username"}),n&&!o&&F.createElement(Mt,{isDone:!1,command:":set:editor"}),s&&F.createElement(He,null,F.createElement(Mt,{isDone:!0,command:":set:editor",value:i}))),F.createElement(He,{marginTop:1,flexDirection:"column"},s&&F.createElement(Ce,{color:"green"},"You are ready to go.")))}import Nr from"chalk";import{Box as In,Text as Ir}from"ink";import de from"react";import{Box as wt,Text as hn}from"ink";import ae from"react";var vr=()=>{let{breadCrumb:e,currentNode:t,selectedIndex:n,viewMode:o}=f(),r=P(t.id)[n],i=Te(r?.id??t.id,"TICKET"),s=ue(i)?i.data:void 0,a=s?.id?P(s.id):[],d=C=>{let h=a.find(A=>A.title===C);return h?P(h.id).map(A=>typeof A.props?.value=="string"?A.props.value:"").filter(A=>!!A):[]},l=d("Tags"),v=d("Assignees"),p=s?.parentNodeId?!_t(t.id,s?.parentNodeId)&&o==="dense":!1;return ae.createElement(wt,null,e.map((C,h)=>{let A=h===e.length-1,E=P(C.id),I=A?E?.[n]?.title:void 0;return ae.createElement(wt,{key:`${C.id}-${h}`},ae.createElement(hn,{color:y.secondary2},h?" / ":""),ae.createElement(hn,{color:y.secondary2},C.title??""),I?ae.createElement(hn,{color:y.primary},` \u25B8 ${I}`):null,p&&A?l.map(S=>ae.createElement(wt,{key:S,paddingLeft:2},ae.createElement(Re,{id:S}))):null,p&&A?v.map(S=>ae.createElement(wt,{key:S,paddingLeft:2},ae.createElement(ke,{id:S}))):null)}))};import{Box as ws,Text as Cr}from"ink";import Lt from"react";var Ls=({filters:e})=>Lt.createElement(ws,{columnGap:1},Lt.createElement(Cr,{color:"red"},"APPLIED FILTERS:"),e.map(({value:t,target:n,operator:o})=>Lt.createElement(Cr,{backgroundColor:"black",color:"white"},` ${n}${o}"${t}" `))),yr=Lt.memo(Ls);function En({filters:e,hideBreadCrumb:t=!1}){let{userName:n,preferredEditor:o}=pe();return de.createElement(In,{justifyContent:"space-between",flexDirection:"row"},t?de.createElement(Ir,null," "):de.createElement(In,{paddingLeft:1},e.length>0?de.createElement(yr,{filters:e}):de.createElement(vr,null)),de.createElement(In,{columnGap:1,paddingRight:2},de.createElement(hr,{icon:"@",value:n}),de.createElement(hr,{icon:"\u276F",value:o})))}function hr({icon:e,value:t}){return de.createElement(Ir,null,Nr.dim(e)+Nr.hex(y.accent2)(` ${t??"-"} `))}function Qe({width:e,height:t}){let n=k(),o=pe(),r=!!o.userName?.trim(),i=!!o.preferredEditor?.trim(),s=r&&i,a=k().filters,d=!o.userName||!o.preferredEditor;if(!s)return X.createElement(Pt,{flexDirection:"column"},X.createElement(Pt,{flexDirection:"column"},X.createElement(En,{hideBreadCrumb:d,filters:a}),X.createElement(Nn,{height:t,width:e,hasUserName:r,hasPreferredEditor:i,userName:o.userName??"",preferredEditor:o.preferredEditor??""})),X.createElement(yn,{width:e,mode:n.mode,availableHints:n.availableHints}));let l=Ie(f().breadCrumb??[],"BOARD");if(ue(l)){let v=l.data.id,p=b(v).length,C=3,h=Math.floor(e/C),A=Math.floor(e/Math.max(p,1));e=Math.min(A,h)*Math.max(p,C)}return X.createElement(Pt,{flexDirection:"column"},n.mode!==u.HELP&&X.createElement(Pt,{flexDirection:"column"},X.createElement(En,{filters:a}),X.createElement(dr,{width:e,height:t,currentNode:n.currentNode,selectedIndex:n.selectedIndex,breadCrumb:n.breadCrumb,viewMode:n.viewMode,mode:n.mode})),n.mode===u.HELP&&X.createElement(xr,{width:e}),n.mode!==u.HELP&&X.createElement(yn,{width:e,mode:n.mode,availableHints:n.availableHints}))}import{Box as be,Text as ye}from"ink";import W,{useEffect as Ps,useMemo as Ds,useState as Fs}from"react";var Bs=["\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557","\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551","\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551\u2584\u2584 \u2588\u2588\u2551","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D","\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2580\u2580\u255D "];function ks(e,t,n){return Math.min(n,Math.max(t,e))}function Rs(e,t){return W.createElement(ye,null,W.createElement(ye,{color:t%2===0?"cyan":"blue",bold:!0},e.slice(0,14)),W.createElement(ye,{color:t%2===0?"cyan":"blue",bold:!0},e.slice(14)))}function Os(e,t=28){if(e>=1)return"\u2588".repeat(t);let n=Math.floor(e*(t-1));return Array.from({length:t},(o,r)=>{let i=Math.abs(r-n);return i===0?"\u2588":i===1?"\u2593":i===2?"\u2592":i===3?"\u2591":r<n?"\u2500":"\xB7"}).join("")}function Dt({durationMs:e=3e3,slogan:t="Never leave the command line"}){let n=Math.max(1,e),[o,r]=Fs(0);Ps(()=>{let d=Date.now(),l=setInterval(()=>{let v=Date.now()-d;if(v>=n){r(n),clearInterval(l);return}r(v)},33);return()=>clearInterval(l)},[n]);let i=ks(o/n,0,1),s=Ds(()=>Os(i,28),[i]),a=`${Math.round(i*100)}%`;return W.createElement(be,{flexDirection:"column",alignItems:"center",justifyContent:"center",paddingX:4,paddingY:1},W.createElement(be,{flexDirection:"column",minWidth:42},W.createElement(be,{flexDirection:"column",marginBottom:1},Bs.map((d,l)=>W.createElement(be,{key:l,justifyContent:"center"},Rs(d,l)))),W.createElement(be,{justifyContent:"center",marginBottom:1},W.createElement(ye,{color:"gray"},t)),W.createElement(be,{justifyContent:"center",marginBottom:1},W.createElement(ye,{color:"cyan"},s.slice(0,10)),W.createElement(ye,{color:"blue"},s.slice(10,18)),W.createElement(ye,{color:"magenta"},s.slice(18))),W.createElement(be,{justifyContent:"center",marginBottom:1},W.createElement(ye,{color:"gray"},a))))}import Us from"readline";var Ft,Ws=()=>async function(t,n){if(n.ctrl&&n.name==="c")return D.exit();let{actionIndex:o,mode:r}=f(),i=No(n,r);if(!i)return;let s=o[r]?.[i];if(s?.action)try{await s.action(s,n)}catch(a){logger.error(a)}};function Er(){Ft&&process.stdin.removeListener("keypress",Ft),Ft=Ws(),Us.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.on("keypress",Ft)}import An from"chalk";import{monotonicFactory as Hs,ulid as le}from"ulid";var ce="system";function _s(){let e=Object.values(f().nodes).find(o=>o.context==="WORKSPACE");if(!e)throw new Error("No workspace found in event log");let[t]=b(e.id),[n]=t?b(t.id):[];return n??t??e}function Vs(){let e=_s(),t=f().renderedChildrenIndex?.[e.id]??[];D.navigate({currentNode:e,selectedIndex:t.length>0?0:-1})}var Ze=Hs();function Ks(){let e=Ze(),t=Ze(),n=Ze(),o=Ze(),r=Ze();return[{id:le(),userId:ce,action:"init.workspace",payload:{id:e,name:"Workspace"}},{id:le(),userId:ce,action:"add.board",payload:{id:t,name:"Default",parent:e}},{id:le(),userId:ce,action:"add.swimlane",payload:{id:n,name:"Todo",parent:t}},{id:le(),userId:ce,action:"add.swimlane",payload:{id:o,name:"Review",parent:t}},{id:le(),userId:ce,action:"add.swimlane",payload:{id:r,name:"Done",parent:t}},{id:le(),userId:ce,action:"add.board",payload:{id:st,name:"Closed",parent:e}},{id:le(),userId:ce,action:"add.swimlane",payload:{id:Me,name:"Closed",parent:st}},{id:le(),userId:ce,action:"lock.node",payload:{id:st}},{id:le(),userId:ce,action:"lock.node",payload:{id:Me}}]}function Ar(e){let n=(e.length===0?dt(Ks()):On(e)).filter(x);if(n.length>0)throw new Error([An.bold.red("Materializing failed"),"",...n.map((o,r)=>`${An.dim.gray(`${r+1}.`)} ${An.dim(o.message)}`),`
11
+ `].join(`
12
+ `));Vs()}var br=()=>{let e=Ct();if(!($.readFile(e)!==null)){let i=nn({});if(x(i))throw new Error("Unable to create ~/.epiqrc")}let n=tn();if(x(n))throw new Error("Unable to load settings");let{preferredEditor:o,userName:r}=n.data;ze({preferredEditor:o,userName:r})};$s(`
13
+ View board in directory:
14
+ $ epiq
11
15
 
12
- Init project in directory:
13
- $ epiq --init "Project Name"
14
- `,{importMeta:import.meta,flags:{init:{type:"string"}}}),Ie=null,Jr=()=>{Ie?Ie.rerender(At.createElement(Ce,null)):Ie=Gr(At.createElement(Ce,null))};process.stdout.on("resize",()=>{Ie&&Ie.rerender(At.createElement(Ce,null))});(()=>{if(console.clear(),fn.flags.init){cn();return}Object.keys(fn.flags).length||(dn(),Jr(),mn())})();
16
+ Init project in directory:
17
+ $ epiq --init "Project Name"
18
+ `,{importMeta:import.meta,flags:{init:{type:"string"}}});var Bt=process.stdout.columns||120,kt=process.stdout.rows||20,zs=5e3,js=600,Ne=null;function Gs(e){return new Promise(t=>setTimeout(t,e))}function qs(){if(!Ne){Ne=Sr(et.createElement(Qe,{width:Bt,height:kt}));return}Ne.rerender(et.createElement(Qe,{width:Bt,height:kt}))}function Xs(e){if(!Ne){Ne=Sr(et.createElement(Dt,{durationMs:e}));return}Ne.rerender(et.createElement(Dt,{durationMs:e}))}async function Js(){br();let e=Vn(),n=e.length===0?zs:js;n>0&&Xs(n);let o=Date.now();Ar(e);let r=Date.now()-o,i=Math.max(0,n-r);i>0&&await Gs(i),qs(),Er()}process.stdout.on("resize",()=>{Bt=process.stdout.columns||120,kt=process.stdout.rows||20,Ne&&Ne.rerender(et.createElement(Qe,{width:Bt,height:kt}))});(async()=>(console.clear(),await Js()))();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epiq",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "EPIQ - CLI based issue tracker",
@@ -12,10 +12,14 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "tsc --noEmit",
15
- "build:publish": "rm -rf ./dist && esbuild source/cli.tsx --bundle --packages=external --platform=node --format=esm --target=node18 --minify --outfile=dist/cli.js --banner:js='#!/usr/bin/env node'",
15
+ "build:npm": "rm -rf ./dist && esbuild source/cli.tsx --bundle --packages=external --platform=node --format=esm --target=node18 --minify --outfile=dist/cli.js --banner:js='#!/usr/bin/env node'",
16
+ "build:sea:bundle": "rm -rf ./dist && esbuild source/cli.tsx --bundle --platform=node --format=cjs --target=node18 --minify --outfile=dist/sea.cjs",
17
+ "build:sea": "node --build-sea sea-config.json",
18
+ "build:publish": "pnpm build:npm",
19
+ "build:binary": "pnpm build:sea:bundle && pnpm build:sea",
16
20
  "dev": "tsc --watch --noEmit",
17
21
  "dev:start": "IS_LOCAL=true tsx source/cli.tsx",
18
- "start": "IS_LOCAL=true node dist/cli.js",
22
+ "start": "IS_LOCAL=true tsx source/cli.tsx",
19
23
  "test": "prettier --check \"**/*.{ts,tsx}\" && vitest run",
20
24
  "prepack": "pnpm build:publish",
21
25
  "pack:check": "rm -f epiq-*.tgz && npm pack && FILE=$(ls -t epiq-*.tgz | head -n 1) && echo \"$FILE\" && tar -tf \"$FILE\"",
@@ -32,10 +36,12 @@
32
36
  "marked-terminal": "^7.3.0",
33
37
  "meow": "^14.1.0",
34
38
  "react": "^19.2.4",
39
+ "string-width": "^8.2.0",
35
40
  "ulid": "^3.0.2"
36
41
  },
37
42
  "devDependencies": {
38
43
  "@sindresorhus/tsconfig": "^3.0.1",
44
+ "@types/marked-terminal": "^6.1.1",
39
45
  "@types/node": "^25.5.0",
40
46
  "@types/react": "^18.0.32",
41
47
  "@vdemedes/prettier-config": "^2.0.1",