epiq 1.13.1 → 1.14.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.
- package/dist/Index-LDGDOFWA.js +16 -0
- package/dist/{args-Y5YFYS72.js → args-R7R2SBPG.js} +1 -1
- package/dist/chunk-3A5BVO43.js +2 -0
- package/dist/chunk-C4V7IKIG.js +110 -0
- package/dist/chunk-KQQQ5HBS.js +8 -0
- package/dist/gui/main.js +161 -147
- package/dist/index.js +1 -1
- package/dist/mcp.js +1 -1
- package/dist/server-GPNBR24F.js +31 -0
- package/dist/{virtual-nodes-COSSGT2L.js → virtual-nodes-QB7VWWF2.js} +1 -1
- package/package.json +2 -1
- package/readme.md +17 -7
- package/dist/Index-NH5R5ZCJ.js +0 -16
- package/dist/chunk-7JJFQ6UF.js +0 -8
- package/dist/chunk-HM2XGJT6.js +0 -109
- package/dist/chunk-ON2KLPMG.js +0 -2
- package/dist/server-2COW5M6S.js +0 -30
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.env.NODE_ENV||="production";await import("./Index-
|
|
2
|
+
process.env.NODE_ENV||="production";await import("./Index-LDGDOFWA.js");
|
package/dist/mcp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.env.EPIQ_MCP="true";process.env.NODE_ENV||="production";console.log=console.error;console.info=console.error;console.debug=console.error;console.warn=console.error;var{applyActorNameArgument:r}=await import("./actor-env-F6R6NBSD.js"),{isFail:s}=await import("./result-types-RM3ASLV3.js"),{parseMcpArgs:t}=await import("./args-
|
|
2
|
+
process.env.EPIQ_MCP="true";process.env.NODE_ENV||="production";console.log=console.error;console.info=console.error;console.debug=console.error;console.warn=console.error;var{applyActorNameArgument:r}=await import("./actor-env-F6R6NBSD.js"),{isFail:s}=await import("./result-types-RM3ASLV3.js"),{parseMcpArgs:t}=await import("./args-R7R2SBPG.js"),e=t(process.argv.slice(2));e.kind==="error"&&(console.error(e.message),process.exit(1));e.kind==="print"&&(process.stdout.write(e.text),process.exit(0));if(e.kind==="name"){let o=r(e.name,"The name argument");s(o)&&(console.error(o.message),process.exit(1))}var{setVirtualNodesEnabled:n}=await import("./virtual-nodes-QB7VWWF2.js");n(!1);var{startMcpServer:a}=await import("./server-GPNBR24F.js");await a();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{$ as Ie,B as Y,C as W,D as V,E as Z,F as ee,G as te,H as ie,I as oe,J as ne,K as se,L as re,M as ae,N as ce,O as le,P as de,Q as me,R as pe,S as he,T as ue,U as ge,V as fe,W as we,X as be,Y as ye,Z as _e,_ as ve,b as R,ba as ke,ca as qe,da as Se,fa as Re,i as D,k as G,ka as Te,l as O,m as $,p as B,t as F,u as H,v as K,w as z,x as X,y as J,z as Q}from"./chunk-KQQQ5HBS.js";import{Kb as U,ab as S,b as N,ca as M,h as A,l as C,m as P,x as L}from"./chunk-C4V7IKIG.js";import{a as x}from"./chunk-WUCQWBQE.js";import{b as r,c as w,d as a}from"./chunk-5RIQL7P4.js";import{McpServer as Be}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Fe}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as e}from"zod";import{ulid as De}from"ulid";var Ee=[{name:"userName",question:"the name they want to appear under on the board"},{name:"preferredEditor",question:'the command that opens a file for editing, e.g. "vim", "nano" or "code --wait"'},{name:"autoSync",question:"whether the TUI and GUI should sync with the git remote on their own (true or false)"}],je=t=>t.trim().toLowerCase(),xe=async(t={})=>{let o=C();if(a(o))return r(o.message);let n=o.value,c=t.userName?.trim(),E=(process.env[x]??"").trim();if(c&&E&&je(c)===je(E))return r(`userName "${c}" is this agent's own identity. Pass the user's name, the one they want the TUI and GUI to write as.`);let m={userName:c||void 0,preferredEditor:t.preferredEditor?.trim()||void 0,autoSync:t.autoSync},g={userName:n.userName?.trim()||void 0,preferredEditor:n.preferredEditor?.trim()||void 0,autoSync:typeof n.autoSync=="boolean"?n.autoSync:void 0};for(let s of Ee){let d=m[s.name],f=g[s.name];if(!(d===void 0||f===void 0||d===f))return r(`This machine is already set up with ${s.name} ${JSON.stringify(f)}; epiq_project_init does not change it. Call again without ${s.name}, or let the user change it in the TUI with :config.`)}let l={};if(m.userName&&!g.userName&&(l.userName=m.userName),m.preferredEditor&&!g.preferredEditor&&(l.preferredEditor=m.preferredEditor),m.autoSync!==void 0&&g.autoSync===void 0&&(l.autoSync=m.autoSync),(l.userName||g.userName)&&!n.userId&&(l.userId=De()),Object.keys(l).length>0){let s=P(l);if(a(s))return r(s.message)}let I={...n,...l},k=Ee.filter(s=>{let d=I[s.name];return typeof d=="boolean"?!1:!d?.trim()});if(k.length>0){let s=k.map(_=>`${_.name} (${_.question})`).join("; "),d=k.some(_=>_.name==="userName")?await D(t.repoRoot??process.cwd()):null,f=d?` This repository's git user.name is ${JSON.stringify(d)} \u2014 offer it as the default for userName, and use it only if the user agrees.`:"";return r(`Setup incomplete. Ask the user for: ${s}.${f} Then call epiq_project_init again with the answers; what was given so far is saved.`)}let b={userId:I.userId??"",userName:I.userName??""};if(!b.userId||!b.userName)return r("Missing Epiq user id");let q=await U({cwd:t.repoRoot??process.cwd(),user:b});if(a(q))return q;let{defaultEvents:ze,...y}=q.value,j=M({root:y.repoRoot});a(j)&&N.info(j.message);let Ue=y.warnings.length===0?"Project initialized":`Project initialized, with warnings: ${y.warnings.join(" ")}`;return w(Ue,{...y,user:b})};import v from"node:fs";import Ne from"node:path";var p=".claude/skills/epiq/SKILL.md",T=`---
|
|
3
|
+
name: epiq
|
|
4
|
+
description: Workflow for working an epiq issue board through the epiq MCP \u2014 take an identity, sync on demand, keep tickets small and their status, tags and comments current.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Epiq board workflow
|
|
8
|
+
|
|
9
|
+
- **Use the \`epiq_*\` MCP tools** for every board read and write \u2014 never the CLI, hand edits, or the state branch directly.
|
|
10
|
+
- Never edit the state branch directly. Don't check it out, don't write to its worktree, don't touch the event log or any file under it by hand or by script \u2014 go through the MCP for every read and write. The event log is the system of record: an edit made outside it bypasses validation and ordering, and can corrupt history in ways no later fix can undo.
|
|
11
|
+
- Keep the status column current as work progresses (move tickets along the board with correct status)
|
|
12
|
+
- **Sync is on demand:** call \`epiq_sync\` to pull or publish; nothing else does.
|
|
13
|
+
- **Take an identity before your first write:** \`provider/name\` (e.g. \`claude/peter\`), set with \`epiq_actor_assume\`. Reuse one from \`epiq_contributor_list\` \u2014 names are permanent. If other agents may be running, ask which name is free, rather than just picking one.
|
|
14
|
+
- Break work into small, reasonably scoped tickets.
|
|
15
|
+
- **One MCP server per session** \u2014 the name binds to the process; a restart forgets it. epiq_actor_assume binds the name to the server process it is called on, so two sessions on one server \u2014 or a session on the user's own instance \u2014 would sign every write with whichever name was assumed last, and the log would fold them into one contributor. Every session therefore needs a server process of its own.
|
|
16
|
+
- **Keep tickets small**; put a small follow-up on its existing ticket instead of a new one.
|
|
17
|
+
- **Read a ticket's comments before starting.**
|
|
18
|
+
- **Board and lane descriptions are the team's conventions** (\`boardDescription\`, \`laneDescription\` in responses): follow them unless they conflict with your user's instructions.
|
|
19
|
+
- **Picking up a ticket:** assign yourself and move it to the in-progress lane. Ask before taking one assigned to someone else.
|
|
20
|
+
- **Keep status, tags and description current**; reuse existing tags.
|
|
21
|
+
- **Comment** on deviations, blockers, and the outcome when done.
|
|
22
|
+
- **Prompt user for closing tickets and big decisions**
|
|
23
|
+
- **Park decisions that are the user's to make.** A design fork, a change with blast radius beyond its ticket, anything you'd want a second opinion on - file a ticket tagged human-input-needed naming the options and the trade-offs, then carry on with whatever doesn't depend on the answer.
|
|
24
|
+
- **Link commits** with an \`Epiq-Ref: <ref>\` line in the commit body, using the \`ref\` from the MCP response \u2014 never derive the ref from the id. Several tickets go on one line, comma-separated. A subject starting with the ref also links, but keeps the ref in the shared history.
|
|
25
|
+
- *If a you decide to take a new approach*, add a "fork" tag, and document the fork in a comment, also, update the description to reflect the new plan.
|
|
26
|
+
- **Attachments are permanent** in every clone (max 500 KB): only when a picture is needed, make sure images are cropped and compressed. An oversized image is permanent, for everybody \u2014 the same reason the text limits exist.
|
|
27
|
+
- **Be concise.** Titles, descriptions, and comments should be scannable, not essays.
|
|
28
|
+
- **When a ticket is done, Document the outcome in a comment starting with "Solution:"**. Use that exact prefix as the comment's opening line.
|
|
29
|
+
- **The git user is the sole author of every commit you write.** Commit under the repo's configured user.name / user.email and nothing else: no Co-Authored-By: line, no Claude-Session: line, no \u{1F916} Generated with footer, and never an --author override naming Claude or a tool.
|
|
30
|
+
- Always rebase onto the target, never merge into it. Rebase the branch onto the target first, then integrate with a rebase merge \u2014 gh pr merge --rebase, never --merge. Main stays a flat sequence of commits that each still name their tickets, which is what the commit\u2194ticket linking reads. A merge commit adds a subject carrying no ref and buries the branch's commits behind it.
|
|
31
|
+
`;var Ae=async(t={})=>{let o=await A(t.repoRoot??process.cwd());if(a(o))return r(o.message);let n=Ne.join(o.value,p);if(v.existsSync(n)){if(v.readFileSync(n,"utf8")===T)return w("Skill already installed and up to date",{path:n,written:!1});if(!t.force)return r(`${p} already exists and differs from the bundled skill. Pass force:true to overwrite it.`)}try{v.mkdirSync(Ne.dirname(n),{recursive:!0}),v.writeFileSync(n,T,"utf8")}catch(c){return r(c instanceof Error?`Failed to write ${p}: ${c.message}`:`Failed to write ${p}`)}return w(`Installed skill at ${p}`,{path:n,written:!0})};var u=t=>({isError:a(t),content:[{type:"text",text:JSON.stringify(t,null,2)}]}),i=t=>o=>R(async()=>u(await t(o))),He="A board's or lane's description (boardDescription, laneDescription) holds the team's conventions for it; follow them unless they conflict with your user's instructions.",Ke=()=>{let t=new Be({name:"epiq",version:"0.2.30"},{instructions:He});return t.registerTool("epiq_state_get",{description:"Get the full current Epiq state, including nodes and event log",inputSchema:e.object({repoRoot:e.string().optional()})},i(B)),t.registerTool("epiq_issue_list",{description:"List Epiq issues. Narrow with boardId, swimlaneId, tag, assignee or query (matched against title and description), and pass brief to get id, ref, title, swimlane, tag names and assignee names only \u2014 descriptions are the bulk of a board. Read one ticket with epiq_issue_get.",inputSchema:e.object({repoRoot:e.string().optional(),includeClosed:e.boolean().optional(),boardId:e.string().optional(),swimlaneId:e.string().optional(),tag:e.string().optional(),assignee:e.string().optional(),query:e.string().optional(),brief:e.boolean().optional()})},i(K)),t.registerTool("epiq_issue_get",{description:"Get one Epiq issue by its full id or its 7-character ref, with its comments in log order. Use this rather than listing the whole board when you already know which issue you want, and rather than epiq_state_get to read a thread.",inputSchema:e.object({idOrRef:e.string().min(1),repoRoot:e.string().optional()})},i(H)),t.registerTool("epiq_issue_stats",{description:"Code stats for one issue, derived from the commits whose subject carries its ref: how big the change is, how it is spread, and how much of it the ticket spent rewriting its own work. Reads git only \u2014 it never touches the board \u2014 so it is safe to call while other work is in flight. No commits carrying the ref reads as a change of zero size, which is not the same as no work: a commit only links if its subject opens with the ref.",inputSchema:e.object({idOrRef:e.string().min(1),repoRoot:e.string().optional()})},async o=>u(await Te(o))),t.registerTool("epiq_board_list",{description:"List Epiq boards",inputSchema:e.object({repoRoot:e.string().optional()})},i(V)),t.registerTool("epiq_board_create",{description:"Create an Epiq board. It comes out without swimlanes; add them with epiq_swimlane_create. Refused while time travelling.",inputSchema:e.object({repoRoot:e.string().optional(),title:e.string().min(1).max(300)})},i(Z)),t.registerTool("epiq_swimlane_list",{description:"List Epiq swimlanes",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().optional()})},i(te)),t.registerTool("epiq_swimlane_create",{description:"Create an Epiq swimlane on a board",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().min(1),title:e.string().min(1).max(300)})},i(ie)),t.registerTool("epiq_swimlane_title_edit",{description:"Edit an Epiq swimlane title",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1),title:e.string().min(1).max(300)})},i(oe)),t.registerTool("epiq_board_title_edit",{description:"Edit an Epiq board title. Refused while time travelling.",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().min(1),title:e.string().min(1).max(300)})},i(ee)),t.registerTool("epiq_swimlane_description_edit",{description:"Edit a swimlane's markdown description: the conventions for work in that lane. Empty clears it.",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1),description:e.string().max(S("swimlane"))})},i(O)),t.registerTool("epiq_board_description_edit",{description:"Edit a board's markdown description: the conventions for work on that board. Empty clears it. Refused while time travelling.",inputSchema:e.object({repoRoot:e.string().optional(),boardId:e.string().min(1),description:e.string().max(S("board"))})},i(G)),t.registerTool("epiq_swimlane_move",{description:"Move/reorder an Epiq swimlane, optionally to another board",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1),boardId:e.string().min(1),position:e.discriminatedUnion("at",[e.object({at:e.literal("start")}),e.object({at:e.literal("end")}),e.object({at:e.literal("before"),sibling:e.string().min(1)}),e.object({at:e.literal("after"),sibling:e.string().min(1)})]).optional()})},i(ne)),t.registerTool("epiq_swimlane_delete",{description:"Delete (archive) an Epiq swimlane. This also archives every issue contained in it.",inputSchema:e.object({repoRoot:e.string().optional(),swimlaneId:e.string().min(1)})},i(se)),t.registerTool("epiq_issue_create",{description:"Create an Epiq issue in a swimlane: parentId is the swimlane id (epiq_swimlane_list), never a board id. Optionally set description, tags, and assignees atomically in the same call instead of separate follow-up edits.",inputSchema:e.object({title:e.string().min(1).max(300),parentId:e.string().min(1),repoRoot:e.string().optional(),description:e.string().max(2e4).optional(),tagNames:e.array(e.string().max(60)).max(20).optional(),assigneeNames:e.array(e.string().max(80)).max(20).optional()})},i(z)),t.registerTool("epiq_issue_description_edit",{description:"Edit the markdown description of an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),description:e.string().max(2e4),repoRoot:e.string().optional()})},i(Y)),t.registerTool("epiq_issue_title_edit",{description:"Edit the title of an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),title:e.string().min(1).max(300),repoRoot:e.string().optional()})},i(W)),t.registerTool("epiq_issue_tag_add",{description:"Add a tag to an Epiq issue, or to many at once with issueIds, creating the tag if it does not exist",inputSchema:e.object({issueId:e.string().min(1).optional(),issueIds:e.array(e.string().min(1)).min(1).max(200).optional(),tagName:e.string().min(1).max(60),repoRoot:e.string().optional()})},i(re)),t.registerTool("epiq_issue_tag_remove",{description:"Remove a tag from an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),tagId:e.string().min(1),repoRoot:e.string().optional()})},i(le)),t.registerTool("epiq_contributor_list",{description:"List people who can be assigned: everyone who has authored an event (optionally scoped to one board) unioned with the contributor registry. Use these ids with epiq_issue_assignee_add rather than assigning by name.",inputSchema:e.object({boardId:e.string().min(1).optional(),repoRoot:e.string().optional()})},i(ue)),t.registerTool("epiq_contributor_remove",{description:"Remove an external contributor from the assignee suggestion lists. Their id and every reference to it survive, so existing assignments stay intact and the event log is untouched. Refused for anyone who has authored events, since their name is in the log regardless.",inputSchema:e.object({contributorId:e.string().min(1),repoRoot:e.string().optional()})},i(pe)),t.registerTool("epiq_tag_remove",{description:"Delete a tag from the whole workspace. It disappears from every ticket, picker and filter, but its id and history stay in the event log, and the name is free for a new tag.",inputSchema:e.object({tagId:e.string().min(1),repoRoot:e.string().optional()})},i(ae)),t.registerTool("epiq_tag_restore",{description:"Put back a tag deleted with epiq_tag_remove, on every ticket that still carried it.",inputSchema:e.object({tagId:e.string().min(1),repoRoot:e.string().optional()})},i(ce)),t.registerTool("epiq_contributor_restore",{description:"Put a contributor removed with epiq_contributor_remove back into the suggestion lists, under the name they were created with.",inputSchema:e.object({contributorId:e.string().min(1),repoRoot:e.string().optional()})},i(he)),t.registerTool("epiq_issue_assignee_add",{description:"Assign a contributor to an Epiq issue. Pass self:true to assign yourself. Prefer assigneeId otherwise, which assigns a known contributor (from the registry or the event log) and fails if the id is unknown. assigneeName matches an existing contributor by name; to create somebody new from a name you must also pass createUnlinked, which adds them as an external (non-contributor) assignee.",inputSchema:e.object({issueId:e.string().min(1),assigneeId:e.string().min(1).optional(),self:e.boolean().optional(),assigneeName:e.string().min(1).max(80).optional(),createUnlinked:e.boolean().optional(),repoRoot:e.string().optional()})},i(me)),t.registerTool("epiq_issue_assignee_remove",{description:"Remove an assignee from an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),assigneeId:e.string().min(1),repoRoot:e.string().optional()})},i(ge)),t.registerTool("epiq_issue_comment_add",{description:"Add a comment to an Epiq issue",inputSchema:e.object({issueId:e.string().min(1),body:e.string().min(1).max(4e3),repoRoot:e.string().optional()})},i(fe)),t.registerTool("epiq_issue_attachment_add",{description:"Attach an image file to an Epiq issue. Returns `markdown` \u2014 paste it into a comment or description body to render the image inline.",inputSchema:e.object({issueId:e.string().min(1),filePath:e.string().min(1),name:e.string().min(1).max(200).optional(),repoRoot:e.string().optional()})},i($)),t.registerTool("epiq_issue_comment_delete",{description:"Delete a comment from an Epiq issue",inputSchema:e.object({commentId:e.string().min(1),repoRoot:e.string().optional()})},i(we)),t.registerTool("epiq_issue_comment_edit",{description:"Replace the body of one of your own comments on an Epiq issue",inputSchema:e.object({commentId:e.string().min(1),body:e.string().min(1).max(4e3),repoRoot:e.string().optional()})},i(be)),t.registerTool("epiq_issue_reopen",{description:"Reopen a closed Epiq issue, restoring it to its previous swimlane",inputSchema:e.object({issueId:e.string().min(1),repoRoot:e.string().optional()})},i(J)),t.registerTool("epiq_issue_close",{description:"Close an Epiq issue, or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:e.object({issueId:e.string().min(1).optional(),issueIds:e.array(e.string().min(1)).min(1).max(200).optional(),repoRoot:e.string().optional()})},i(X)),t.registerTool("epiq_issue_move",{description:"Move an Epiq issue to another swimlane (parentId is the swimlane id), or many at once with issueIds \u2014 one call, an outcome per ticket",inputSchema:e.object({issueId:e.string().min(1).optional(),issueIds:e.array(e.string().min(1)).min(1).max(200).optional(),parentId:e.string().min(1),position:e.discriminatedUnion("at",[e.object({at:e.literal("start")}),e.object({at:e.literal("end")}),e.object({at:e.literal("before"),sibling:e.string().min(1)}),e.object({at:e.literal("after"),sibling:e.string().min(1)})]).optional(),repoRoot:e.string().optional()})},i(Q)),t.registerTool("epiq_actor_assume",{description:'Take a board identity for the rest of this session, so your writes are attributed to you rather than to the user. Pass the name you announced \u2014 the model provider, a slash, then a short human first name, e.g. "claude/peter". Takes effect on the very next write; no relaunch. A name the server was launched with wins, and re-assuming the same name is harmless. Reuse an existing agent identity (epiq_contributor_list) before inventing one: a name is permanent once it has authored anything.',inputSchema:e.object({name:e.string().min(1).max(80),repoRoot:e.string().optional()})},i(de)),t.registerTool("epiq_contributor_email_link",{description:"Bind a git author address to a contributor, so their commits and their board activity read as one person. Defaults to you; pass contributorId to link a colleague who does not use epiq, whose commits otherwise never resolve. The address the repository's git is configured with links itself on your first write, so this is for older addresses and for other people. An address two contributors claim resolves to neither, and the reply says so.",inputSchema:e.object({email:e.string().min(1).max(254),contributorId:e.string().min(1).optional(),repoRoot:e.string().optional()})},i(ye)),t.registerTool("epiq_contributor_email_unlink",{description:"Retract a link between a git address and a contributor. Allowed only to whoever wrote the link and to the contributor it names, so nobody can strip links that are neither theirs nor about them. Forward-only: the address stops resolving and the event stays in the log.",inputSchema:e.object({email:e.string().min(1).max(254),contributorId:e.string().min(1).optional(),repoRoot:e.string().optional()})},i(_e)),t.registerTool("epiq_contributor_email_suggest",{description:"Addresses in this repository's history that look like yours and nobody has claimed, for the user to confirm. Run it once after this feature reaches a board with history: the address git is configured with links itself, but older ones do not, and until they are linked those commits show a raw git name. Show the list and link only what the user confirms \u2014 each link is permanent and replicates to every clone.",inputSchema:e.object({repoRoot:e.string().optional()})},i(Ie)),t.registerTool("epiq_contributor_email_list",{description:"Every git address the board has bound to a contributor, and who holds it. An address with more than one claimant is flagged contested and resolves to none of them, which is the state nothing else reports.",inputSchema:e.object({repoRoot:e.string().optional()})},i(ve)),t.registerTool("epiq_project_init",{description:`Set up a new Epiq board in a git repository without the TUI. Runs in the repository at repoRoot (default: the current directory), which must have no uncommitted changes. The first time on a machine it also records the user's setup: ask the user for userName (how they want to appear on the board), preferredEditor (e.g. "vim" or "code --wait") and autoSync (whether the TUI and GUI sync with the remote on their own) and pass them here; called without them it fails naming what is still missing, keeping whatever was given. It fills in answers the machine lacks and refuses to change ones it has. Pass the user's name, never your own agent identity. Commits the state branch and .epiq/project.json and tries to push both; a push that fails is a warning, not an error. Afterwards the other tools work in that repository.`,inputSchema:e.object({repoRoot:e.string().optional(),userName:e.string().min(1).max(80).optional(),preferredEditor:e.string().min(1).max(200).optional(),autoSync:e.boolean().optional()})},i(xe)),t.registerTool("epiq_skill_install",{description:"Write the official Epiq workflow skill into the repository at .claude/skills/epiq/SKILL.md, so agents working there follow the same board rules. Run it after epiq_project_init, not before: the new file is an uncommitted change that init refuses. In a project that already has a board, run it any time. Refuses to overwrite a differing file unless force is true; an identical file is left alone.",inputSchema:e.object({repoRoot:e.string().optional(),force:e.boolean().optional()})},i(Ae)),t.registerTool("epiq_sync",{description:"Sync Epiq state with the configured Git remote (pull remote changes and push local ones), then fetch the repos connected with epiq_repo_connect. Other Epiq MCP tools only read and write local state and never sync automatically \u2014 call this on demand when you need to see or publish the latest remote changes.",inputSchema:e.object({repoRoot:e.string().optional()})},async o=>u(await Re(await R(()=>F(o)),o))),t.registerTool("epiq_repo_list",{description:"List the repos connected to the board, whose commits count as its own: each with this machine's clone status, size on disk and last fetch error, whether it is past the board's limit and so not fetched, and what all of them take on this machine.",inputSchema:e.object({repoRoot:e.string().optional()})},async o=>u(await ke(o))),t.registerTool("epiq_repo_connect",{description:"Connect another repo to the board by URL (https://, ssh://, git:// or user@host:path; never a local path, which nobody else could fetch), so commits there prefixed with a ticket's ref link to it; or change a connected repo's options. Connecting is a two-step, board-wide action: every contributor's epiq downloads the repo on their next sync. The first call clones it into a staging area and returns a preview (size, host, default branch, latest commit, how many commits name this board's tickets \u2014 none suggests the wrong repo) and writes nothing. Show the preview to the user; only once they agree, call again with confirm: true and the same options. Option changes to an already connected repo apply at once. branches: default (the default branch only) or all. since: how much history to clone \u2014 board (since the board was created, the default), all, or YYYY-MM-DD. label: what the repo is called on the board \u2014 its URL's basename unless set; empty goes back to the basename. Cloning uses your git credentials: ssh-agent or a credential helper must already work, since a passphrase prompt cannot be answered.",inputSchema:e.object({repoRoot:e.string().optional(),url:e.string().min(1).max(L),branches:e.enum(["default","all"]).optional(),since:e.string().max(20).optional(),label:e.string().max(24).optional(),confirm:e.boolean().optional()})},async o=>u(await qe(o))),t.registerTool("epiq_repo_disconnect",{description:"Disconnect a repo by its label (when no other repo shares it), id or URL, and delete this machine's clone of it.",inputSchema:e.object({repoRoot:e.string().optional(),repo:e.string().min(1).max(2e3)})},async o=>u(await Se(o))),t},St=async()=>{let t=Ke(),o=new Fe;await t.connect(o)};export{He as MCP_INSTRUCTIONS,Ke as createMcpServer,u as resultJson,St as startMcpServer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{kc as a,lc as b,mc as c,nc as d,oc as e,pc as f}from"./chunk-C4V7IKIG.js";import"./chunk-WUCQWBQE.js";import"./chunk-5RIQL7P4.js";export{e as areVirtualNodesEnabled,a as createOrUpdateVirtualField,b as createOrUpdateVirtualFieldList,c as materializeTicketVirtualNodes,f as materializeVirtualNodes,d as setVirtualNodesEnabled};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epiq",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "EPIQ - ergonomic, distributed CLI-first issue tracker TUI ready for the agentic era",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"test:coverage": "vitest run --coverage --exclude \"source/test/e2e/**\" --exclude \"source/test/e2e-collab/**\"",
|
|
47
47
|
"test:containers": "sh source/scripts/test-containers.sh",
|
|
48
48
|
"stress": "sh source/scripts/stress.sh",
|
|
49
|
+
"stress:ci": "STRESS_EVENTS=400000 STRESS_SERVE=false STRESS_CHECK=true NODE_OPTIONS=--max-old-space-size=4096 tsx source/test/stress/run.ts",
|
|
49
50
|
"test:collab": "docker run --rm -v \"$PWD\":/app:ro -v /app/node_modules -w /app epiq-e2e npm run test:collab:ci",
|
|
50
51
|
"test:collab:ci": "vitest run --maxWorkers=3 source/test/e2e-collab/",
|
|
51
52
|
"test:e2e:ci": "export IS_CI=true EPIQ_E2E_TIMEOUT_SCALE=${EPIQ_E2E_TIMEOUT_SCALE:-2} && ([ -n \"${EPIQ_SKIP_BUILD:-}\" ] || npm run build:npm) && vitest run --maxWorkers=4 source/test/e2e/",
|
package/readme.md
CHANGED
|
@@ -16,20 +16,26 @@ Agents now run whole sprints unattended. Because state is an event log, you can
|
|
|
16
16
|
|
|
17
17
|
## Code, linked to tickets
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Link a commit to a ticket with an `Epiq-Ref:` line in its body, naming the ticket's ref:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
git commit -m "
|
|
22
|
+
git commit -m "fix the parser" -m "Epiq-Ref: 1YRTG8T"
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
One line can name several tickets (`Epiq-Ref: 1YRTG8T, 4KQ2M7D`), it can sit anywhere in the body, and its case does not matter. Prefixing the subject with the ref works too:
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
```
|
|
28
|
+
git commit -m "1YRTG8T fix the parser"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Linking makes a commit show up in the ticket's Code tab, with its message. You can comment on selected lines, and also file a new ticket straight from the selection. The MCP exposes the ref as a `ref` property agents can refer to.
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+

|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
How you merge decides whether the link survives:
|
|
36
|
+
|
|
37
|
+
- **Epiq-Ref lines** survive a squash merge that keeps the squashed messages in its body, as git's and GitHub's default messages do, so every ticket they name stays linked. A rebase or merge commit keeps them as they are.
|
|
38
|
+
- **Subject prefixes** need the commits to land as they are: rebase-merge them. Squashing _within_ one ticket's commits is fine as long as the result keeps the prefix; do not squash commits carrying different prefixes into one.
|
|
33
39
|
|
|
34
40
|
### Commits from other repos
|
|
35
41
|
|
|
@@ -158,6 +164,10 @@ Every process — your TUI, your GUI, each agent's MCP server - writes as your u
|
|
|
158
164
|
|
|
159
165
|
That agent then shows up in the contributor list, assigns itself rather than you, and authors its own events. This can be useful when tracing many agents at the same time. Consider reusing names instead of inventing one per session, or the registry fills with single-run identities.
|
|
160
166
|
|
|
167
|
+
### Board and lane rules
|
|
168
|
+
|
|
169
|
+
A board's or a lane's description holds its conventions: "tests before review", "one ticket per PR". The MCP hands them to agents where they apply. Assuming an identity returns the board rules, getting or moving a ticket returns its lane's, and creating one returns both. Agents are told to follow them unless they conflict with their user's instructions. Write them with `epiq_board_description_edit` and `epiq_swimlane_description_edit`, in the board's or the lane's panel in the GUI, or with `edit description` on a selected lane or board in the TUI.
|
|
170
|
+
|
|
161
171
|
### Other MCP clients
|
|
162
172
|
|
|
163
173
|
For clients that are configured by hand, add the following to the client's MCP config file — note this is **not** the same as Claude Code's `~/.claude.json`; Claude Desktop uses `claude_desktop_config.json`:
|
package/dist/Index-NH5R5ZCJ.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as Y}from"./chunk-ON2KLPMG.js";import{$ as Pe,A as Xr,C as zr,D as Qr,F as Zr,G as en,H as tn,I as on,J as rn,K as nn,M as sn,O as an,P as ln,R as mn,S as cn,T as Tt,U as Ct,V as dn,W as un,X as pn,Y as ro,Z as no,_ as fn,a as Br,aa as io,b as de,ba as gn,c as ie,ca as yn,d as Lr,e as Rr,ea as hn,f as jr,fa as so,g as Dr,ga as Et,h as _r,i as Or,j as Gr,k as $r,l as Fr,m as Ur,o as Hr,p as wt,q as ee,r as It,t as kr,u as Wr,v as Vr,w as Kr,x as Yr,y as qr,z as Jr}from"./chunk-7JJFQ6UF.js";import{$ as Yo,$b as $e,Ab as xt,Bb as fr,Cb as gr,Db as bt,E as to,Eb as yr,Fb as hr,G as $o,Gb as xr,Ia as Xo,Ja as zo,Jb as br,Ka as Qo,Kb as Sr,L as Fo,La as pt,Lb as vr,Mb as wr,Oa as ft,P as Uo,Pa as Zo,Q as Ho,Qb as Ir,Rb as oo,Sb as Tr,T as lt,Tb as St,U as Ie,Ub as vt,V as ko,Vb as Cr,Wb as Er,X as U,Xa as er,Xb as Q,Y as Wo,Ya as tr,Yb as Ee,Z as Vo,Za as or,_ as Ko,_a as rr,_b as _,a as Bo,aa as mt,ab as nr,b as nt,ba as Oe,bb as ir,bc as Pr,c as it,cb as ne,cc as Ar,da as ct,db as sr,dc as Nr,ea as dt,eb as ar,ec as q,fb as x,g as st,gb as lr,hb as gt,ia as ut,j as Lo,ja as qo,k as oe,kb as Ce,kc as Mr,l as Ro,mb as mr,n as we,nb as ce,o as re,p as jo,q as _e,qa as Ge,r as a,ra as Jo,rb as yt,s as Do,sb as ht,t as _o,u as Oo,v as Go,w as eo,wb as cr,x as at,xa as me,xb as dr,yb as ur,za as Te,zb as pr}from"./chunk-HM2XGJT6.js";import{f as rt,g as Mo}from"./chunk-WUCQWBQE.js";import{b as $,c as T,d as h,e as F}from"./chunk-5RIQL7P4.js";import z from"chalk";import{render as pl}from"ink";import fl from"meow";import gl from"react";import Zi from"node:os";import es from"node:path";import Fe from"chalk";var Pt=["\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 "];var At=" ",Sn=Fe.hex(a.secondary2),xn=Fe.hex(a.gray),ts=()=>{let t=Pt[0].length+Pt.length*2;return Pt.map((o,n)=>Array.from(o).map((s,u)=>{let[r,f,y]=_o((u+n*2)/t);return Fe.rgb(r,f,y)(s)}).join(""))},os=e=>{let t=Zi.homedir();return e===t||e.startsWith(t+es.sep)?"~"+e.slice(t.length):e},bn=(e,t)=>`${At}${Fe.hex(a.accent)("\u279C")} ${Sn(e.padEnd(9))}${t}`,ao=({url:e,repoRoot:t,version:o,reused:n})=>["",...ts().map(s=>At+s),"",`${At}${Sn("gui")} ${xn(`\xB7 v${o}`)}`,"",bn("Local",Fe.hex(a.accent).bold(e)),bn("Project",os(t)),"",At+xn(n?"already running for this project \xB7 opened in your browser":"press ctrl+c to stop"),""].join(`
|
|
3
|
-
`);import{spawn as rs}from"node:child_process";import Ue from"node:process";var vn=(e=Ue.platform,t=Ue.env)=>e==="darwin"||e==="win32"||!!(t.DISPLAY||t.WAYLAND_DISPLAY||t.BROWSER),wn=e=>{let t=Ue.platform==="darwin"?"open":Ue.platform==="win32"?"cmd":"xdg-open",o=Ue.platform==="win32"?["/c","start","",e]:[e];try{let n=rs(t,o,{detached:!0,stdio:"ignore"});n.on("error",s=>{logger.info(`[gui] could not open a browser: ${s.message}`)}),n.unref()}catch(n){logger.info(`[gui] could not open a browser: ${String(n)}`)}};import{readFile as Xn,stat as $s}from"node:fs/promises";import{createHash as Fs}from"node:crypto";import Us from"node:http";import xe from"node:path";import{fileURLToPath as Hs}from"node:url";import ns from"node:fs";import In from"node:path";var He=Number(process.env.EPIQ_GUI_PORT)||3710,lo="/api/instance",mo="epiq",Nt=e=>{try{return ns.realpathSync(In.resolve(e))}catch{return In.resolve(e)}},is=e=>{let t=e;return typeof t=="object"&&t!==null&&t.app===mo&&typeof t.repoRoot=="string"&&typeof t.version=="string"&&typeof t.pid=="number"},Tn=async(e,t=500)=>{let o=new AbortController,n=setTimeout(()=>o.abort(),t);try{let s=await fetch(`http://127.0.0.1:${e}${lo}`,{signal:o.signal});if(!s.ok)return null;let u=await s.json();return is(u)?u:null}catch{return null}finally{clearTimeout(n)}};var ss=6e4,Cn=e=>{let t,o=!1,n=!1,s=0,u=()=>{let g=Ro();return h(g)?(nt.error(g.message),null):g.value},r=()=>{let g=u();if(!g)return!1;let l=we();return h(l)?!1:!!g.autoSync&&Ir(l.value)===null},f=()=>{let g=Bo(u()?.autoSyncDebounceMs);return Math.max(0,g-(Date.now()-s))},y=async()=>{if(!(o||n)&&r()){n=!0,s=Date.now();try{await de(async()=>{if(ie().mode!=="live")return!1;let l=await It({repoRoot:e.project.repoRoot});return await e.publisher.publishIfLogMoved(),!h(l)})&&e.onReposFetch?.(ss)}finally{n=!1,p()}}};function p(){o||!r()||n||t||(t=setTimeout(()=>{t=void 0,y()},f()))}return p(),{queueSync:p,reschedule:()=>{t&&(clearTimeout(t),t=void 0),p()},dispose:()=>{o=!0,t&&clearTimeout(t)}}};var Mt=(e,t)=>{let o,n=!1,s=async()=>{let u=Date.now();try{await e()}catch(r){logger.error("[watch] check threw",r)}n||(o=setTimeout(s,Math.max(t,Date.now()-u)))};return o=setTimeout(s,t),()=>{n=!0,o&&clearTimeout(o)}};var as=/^(```|~~~)[^\n]*\n[\s\S]*?\n\1[ \t]*$/gm,ls=/^(?:```|~~~)[\s\S]*$/m,ms=/^[ \t]*\|?[ \t]*:?-{2,}:?[ \t]*(?:\|[ \t]*:?-{2,}:?[ \t]*)*\|?[ \t]*$/gm,cs=/^[ \t]*\|.*$/gm,ds=/!\[[^\]]*\]\([^)]*\)/g,us=/\[([^\]]*)\]\([^)]*\)/g,ps=/^[ \t]*(?:[#>]+[ \t]*|[-*+][ \t]+|\d+[.)][ \t]+)/gm,fs=/^[ \t]*(?:-{3,}|\*{3,}|_{3,})[ \t]*$/gm,gs=/[*`~]/g,ys=/(?<![0-9A-Za-z])_|_(?![0-9A-Za-z])/g,hs=e=>Ko(e.replace(as," ").replace(ls," ").replace(ds," ").replace(us,"$1").replace(fs," ").replace(ms," ").replace(cs,t=>t.replaceAll("|"," ")).replace(ps,"").replace(gs,"").replace(ys,"")),xs=.5,En=(e,t)=>{if(t<=0)return"";let o=hs(e);if(o.length<=t)return o;let n="\u2026",s=t-n.length;if(s<=0)return n.slice(0,t);let u=o.slice(0,s),r=u.lastIndexOf(" ");return`${(r>=s*xs?u.slice(0,r):u).trimEnd()}${n}`};var bs=e=>({...e,boards:(e.boards??[]).map(t=>({...t,swimlanes:(t.swimlanes??[]).map(o=>({...o,issues:(o.issues??[]).map(n=>({...n,description:""}))}))})),commentsByIssueId:Object.fromEntries(Object.entries(e.commentsByIssueId??{}).filter(([,t])=>t.length>0).map(([t,o])=>[t,o.map(n=>({...n,body:""}))])),attachmentsByIssueId:Object.fromEntries(Object.entries(e.attachmentsByIssueId??{}).filter(([,t])=>t.length>0))}),he=e=>h(e)?e:T(e.message,bs(e.value)),Ss=(e,t)=>(e.boards??[]).flatMap(o=>o.swimlanes??[]).flatMap(o=>o.issues??[]).find(o=>o.id===t),Pn=(e,t)=>{let o=Ss(e,t);return{issueId:t,description:o?.description??"",comments:e.commentsByIssueId?.[t]??[]}},vs=280,An=(e,t)=>({issueId:e,excerpt:En(t,vs)});var ws=1e3,Nn=e=>{let t=oe(e.repoRoot);if(h(t))return null;let o=st({repoRoot:t.value});return h(o)?null:o.value},Mn=e=>{let t=()=>{let r=Nn(e.project);return r===null?null:Ge(r)},o=()=>{let r=Qo(e.project.repoRoot);return h(r)?null:JSON.stringify([r.value.live,r.value.overLimit])},n=o(),s=t();return{publishIfLogMoved:async()=>{let r=Nn(e.project);if(r===null||await pt(r))return;let f=Ge(r);if(f===s)return;s=f;let y=he(await ee({repoRoot:e.project.repoRoot}));if(h(y))return;ce({type:"state",payload:y});let p=o();p!==null&&p!==n&&(n=p,ce({type:"repos:changed"}))}}},Bn=(e,t=ws)=>Mt(()=>de(async()=>{ie().mode==="live"&&await e.publishIfLogMoved()}),t);var Is=new Set(["127.0.0.1","[::1]","localhost","epiq.localhost"]),co=(e,t)=>{if(!e)return!1;if(e==="null")return!0;let o;try{o=new URL(e)}catch{return!0}return o.protocol!=="http:"||o.port!==String(t)?!0:!Is.has(o.hostname)},Ln=(e,t)=>e.method==="GET"||e.method==="HEAD"?null:co(e.origin,t)?{status:403,message:"Cross-origin request"}:e.method==="POST"&&!(e.contentType??"").toLowerCase().startsWith("application/json")?{status:415,message:"Expected content-type: application/json"}:null;import{WebSocketServer as Ds}from"ws";var Cs=new RegExp(`^[0-9A-Z]{${7}}$`),Es=e=>{let t=e.indexOf(" ");if(t===-1)return null;let o=e.slice(0,t).toUpperCase();return Cs.test(o)?o:null},Ps=e=>{let t={};for(let o of e){let n=Es(o.subject);if(!n)continue;let s=t[n]??={commits:0,insertions:0,deletions:0};s.commits++,s.insertions+=o.insertions,s.deletions+=o.deletions}return t},Rn=async(e={})=>{let t=await ft({repoRoot:e.repoRoot});return h(t)?t:T("Collected diff stats by ref",Ps(t.value))};var As="Filed here",jn=(e,t)=>e.set(t,(e.get(t)??0)+1),Dn=(e,t,o)=>[...e.entries()].map(([n,s])=>({laneId:n,title:n===null?As:o(n),count:s,share:t===0?0:s/t})).sort((n,s)=>s.count-n.count||n.title.localeCompare(s.title)),_n=(e,t,o)=>{let n=new Map,s=new Map,u=0,r=0;for(let f of t)for(let[y,p]of f.entries()){if(p!==e)continue;u++,jn(n,f[y-1]??null);let g=f[y+1];g!==void 0&&(r++,jn(s,g))}return{arrived:u,departed:r,arrivesFrom:Dn(n,u,o),movesOnTo:Dn(s,r,o)}};var On=e=>{if(e.length===0)return null;let t=Math.floor(e.length/2);return e.length%2===0?(e[t-1]+e[t])/2:e[t]};var ke=1440*60*1e3,Ns=({laneIds:e,journeys:t,now:o,days:n})=>{let s=o-(n-1)*ke,u=new Map(e.map(r=>[r,Array.from({length:n},()=>[])]));for(let r of t)for(let[f,y]of r.entries()){let p=u.get(y.laneId);if(!p)continue;let g=r[f+1]?.enteredAt,l=Math.max(0,Math.ceil((y.enteredAt-s)/ke)),d=g===void 0?n-1:Math.min(n-1,Math.ceil((g-s)/ke)-1);for(let m=l;m<=d;m++)p[m].push(s+m*ke-y.enteredAt)}return Object.fromEntries([...u].map(([r,f])=>[r,f.map((y,p)=>({t:s+p*ke,median:On(y.sort((g,l)=>g-l)),count:y.length}))]))},Gn=({laneId:e,journeys:t,now:o,days:n})=>Ns({laneIds:[e],journeys:t,now:o,days:n})[e];var Ms=40,Bs=30,Ls=()=>({tickets:0,commits:0,insertions:0,deletions:0}),Rs=async(e,t)=>{let o=Ls();for(let n of t.slice(0,Ms)){let s=await Et({repoRoot:e,idOrRef:me(n)});h(s)||s.value.shape.commits===0||(o.tickets++,o.commits+=s.value.shape.commits,o.insertions+=s.value.shape.insertions,o.deletions+=s.value.shape.deletions)}return o},$n=async e=>{let t=Gr();if(h(t))return t;let{nodes:o}=t.value;if(!o[e.swimlaneId])return $("Swimlane not found");let s=Object.values(o).filter(lt),u=s.map(y=>Br(y.log??[],to(y.id))),r=_n(e.swimlaneId,u.map(y=>y.map(p=>p.laneId)),y=>o[y]?.title??"Elsewhere"),f=s.filter(y=>y.parentNodeId===e.swimlaneId).map(y=>y.id);return T("Derived swimlane stats",{swimlaneId:e.swimlaneId,createdAt:to(e.swimlaneId),...r,stayTrend:Gn({laneId:e.swimlaneId,journeys:u,now:Date.now(),days:Bs}),code:await Rs(e.repoRoot,f)})};var Fn=new Set(["sync","email:link","email:unlink","repo:connect","repo:disconnect","issues:create","board:create","board:edit:title","swimlane:create","swimlane:edit:title","swimlane:delete","swimlane:move","issues:move","issue:close","issue:reopen","issue:edit:title","issue:edit:description","issue:tag:add","issue:tag:remove","contributor:remove","tag:remove","issue:assignee:add","issue:assignee:remove","issue:comment:add","issue:comment:delete"]);var Un=e=>{let t=Oe({exclude:e});return h(t)?[]:t.value.map(o=>({projectId:o.projectId,name:mt(o.root),root:o.root,lastOpenedAt:o.lastOpenedAt}))},Hn=e=>{let t=Oe();if(h(t))return $(t.message);let o=t.value.find(n=>n.root===e);return o?T("Resolved recent project",o.root):$(`Not a recent project: ${e}`)};import{z as c}from"zod";var I=c.string().min(1),kn=c.discriminatedUnion("at",[c.object({at:c.literal("start")}),c.object({at:c.literal("end")}),c.object({at:c.literal("before"),sibling:I}),c.object({at:c.literal("after"),sibling:I})]),We=c.number().finite(),v=(e,t)=>c.object({type:c.literal(e),payload:t}),ue=e=>c.object({type:c.literal(e)}),js=c.discriminatedUnion("type",[ue("state:get"),ue("issues:list"),ue("sync"),ue("time-travel:live"),ue("diff-stats:get"),v("project:open",c.object({root:c.string().min(1)})),v("issues:create",c.object({title:c.string(),parentId:I,description:c.string().optional(),tagNames:c.array(c.string()).optional()})),v("board:create",c.object({title:c.string()})),v("board:edit:title",c.object({boardId:I,title:c.string()})),v("swimlane:create",c.object({title:c.string(),boardId:I})),v("swimlane:edit:title",c.object({swimlaneId:I,title:c.string()})),v("swimlane:delete",c.object({swimlaneId:I})),v("swimlane:move",c.object({swimlaneId:I,boardId:I,position:kn.optional()})),v("issues:move",c.object({issueId:I,parentId:I,position:kn.optional()})),v("issue:edit:title",c.object({issueId:I,title:c.string()})),v("issue:edit:description",c.object({issueId:I,description:c.string()})),v("issue:tag:add",c.object({issueId:I,tagName:c.string()})),v("issue:tag:remove",c.object({issueId:I,tagId:I})),v("contributor:remove",c.object({contributorId:I})),v("tag:remove",c.object({tagId:I})),c.object({type:c.literal("contributors:get"),payload:c.object({boardId:I.optional()}).optional()}),v("issue:assignee:add",c.object({issueId:I,assigneeId:I.optional(),assigneeName:c.string().optional(),createUnlinked:c.boolean().optional()})),v("issue:assignee:remove",c.object({issueId:I,assigneeId:I})),v("issue:close",c.object({issueId:I})),v("issue:reopen",c.object({issueId:I})),v("issue:comment:add",c.object({issueId:I,body:c.string()})),v("issue:comment:delete",c.object({issueId:I,commentId:I})),v("issue:comment:edit",c.object({issueId:I,commentId:I,body:c.string()})),v("issue:get",c.object({issueId:I})),v("issue:preview:get",c.object({issueId:I})),c.object({type:c.literal("timeline:get"),payload:c.object({start:We.optional(),end:We.optional(),boardId:I.optional(),requestId:c.number().finite().optional()}).optional()}),c.object({type:c.literal("commits:get"),payload:c.object({start:We.optional(),end:We.optional(),requestId:c.number().finite().optional()}).optional()}),v("time-travel:scrub",c.object({targetTime:We})),v("time-travel:checkout-event",c.object({eventId:c.string().min(1)})),v("commit:inspect",c.object({sha:c.string(),repo:c.string().max(80).optional()})),ue("repos:get"),v("repo:preview",c.object({url:c.string().min(1).max(at),branches:c.enum(["default","all"]).optional(),since:c.string().max(20).optional(),label:c.string().max(24).optional()})),v("repo:preview:cancel",c.union([c.object({repo:c.string().min(1).max(80)}),c.object({url:c.string().min(1).max(at)})])),v("repo:connect",c.object({url:c.string().min(1).max(at),branches:c.enum(["default","all"]).optional(),since:c.string().max(20).optional(),label:c.string().max(24).optional()})),v("repo:disconnect",c.object({repo:c.string().min(1).max(2e3)})),c.object({type:c.literal("emails:get")}),v("email:link",c.object({email:c.string().min(1).max(254),contributorId:c.string().min(1).optional()})),v("email:unlink",c.object({email:c.string().min(1).max(254),contributorId:c.string().min(1).optional()})),v("commit:diff:get",c.object({sha:c.string(),repo:c.string().max(80).optional()})),v("issue:commits:get",c.object({issueId:I})),v("issue:squashed-diff:get",c.object({issueId:I})),v("issue:stats:get",c.object({issueId:I})),v("swimlane:stats:get",c.object({swimlaneId:I})),ue("me:stats:get"),ue("settings:get"),v("settings:set",c.object({autoSync:c.boolean().optional(),autoSyncIntervalMs:c.number().finite().optional()}))]);var Wn=e=>{let t=js.safeParse(e);return t.success?{ok:!0,message:t.data}:{ok:!1,error:`Invalid message: ${t.error.issues.map(n=>`${n.path.join(".")||"<root>"}: ${n.message}`).join(", ")}`}};var _s=1024*1024,uo=()=>{ce({type:"state",payload:he(wt())})},Vn=()=>{ce({type:"repos:changed"})},po=async(e,t)=>{Os(await hn({repoRoot:e,minIntervalMs:t}))},Os=e=>{h(e)||(e.value.some(t=>t.changed)&&Vn(),e.value.some(t=>t.changed||!t.ok)&&ce({type:"repos:fetched"}))},b=(e,t)=>{e.send(JSON.stringify(t))},Ve=async(e,t)=>{let o=he(await ee({repoRoot:t}));return h(o)&&o.message===Lo?b(e,{type:"state:unavailable",payload:{message:o.message,repoRoot:t,recentProjects:Un(t)}}):b(e,{type:"state",payload:o})},Gs=async(e,t)=>{let o=()=>b(e,{type:"state",payload:he(wt())});if(ie().mode!=="live")return o();let n=await ee({repoRoot:t});return ie().mode!=="live"?o():b(e,{type:"state",payload:he(n)})},L=async(e,t,o,n,s)=>{if(b(e,{type:n,payload:s}),h(s))return b(e,{type:"failed",payload:s.message});o(),Gs(e,t)},Kn=(e,t,{onStateChanged:o,onSyncSettingsChanged:n,getPort:s})=>{new Ds({server:e,path:"/ws",maxPayload:_s,verifyClient:r=>!co(r.origin,s())}).on("connection",r=>{mr(r),r.on("message",async f=>{let y=async l=>{let{type:d}=l,m=t.repoRoot;if(d==="project:open"){let i=Hn(l.payload.root);return b(r,{type:"project:open:result",payload:i}),h(i)?void 0:(t.repoRoot=i.value,Ve(r,i.value))}if(d==="timeline:get"){let{requestId:i,...S}=l.payload??{};return b(r,{type:"timeline",requestId:i,payload:await Lr({repoRoot:m,...S})})}if(d==="issue:get"){let i=l.payload?.issueId,S=wt(),G=qr(i);return b(r,{type:"issue",payload:h(S)?S:T("Issue detail",{...Pn(S.value,i),history:h(G)?[]:G.value})})}if(d==="issue:preview:get"){let{issueId:i}=l.payload,S=Hr(i);return b(r,{type:"issue:preview:result",payload:{issueId:i,result:h(S)?S:T("Issue preview",An(i,S.value))}})}if(d==="commits:get"){let{requestId:i,...S}=l.payload??{};return b(r,{type:"commits",requestId:i,payload:so(await ft({repoRoot:m,...S}))})}if(d==="emails:get")return b(r,{type:"emails",payload:await ro({repoRoot:m}),suggestions:await no({repoRoot:m})});if(d==="email:link"||d==="email:unlink"){let S=await(d==="email:link"?un:pn)({repoRoot:m,...l.payload});return b(r,{type:"emails",payload:await ro({repoRoot:m}),suggestions:await no({repoRoot:m}),lastAction:h(S)?{ok:!1,message:S.message}:{ok:!0,message:S.message}}),L(r,m,o,`${d}:result`,S)}if(d==="me:stats:get")return b(r,{type:"me:stats",payload:await fn({repoRoot:m})});if(d==="settings:get")return b(r,{type:"settings",payload:oo()});if(d==="settings:set"){let i=Tr({enabled:l.payload.autoSync,intervalMs:l.payload.autoSyncIntervalMs});return h(i)||n(),b(r,{type:"settings",payload:h(i)?oo():i,lastAction:h(i)?{ok:!1,message:i.message}:{ok:!0,message:i.message}})}if(d==="commit:inspect")return b(r,{type:"commit:inspect:result",payload:await rr({repoRoot:m,sha:l.payload.sha,repo:l.payload.repo})});if(d==="commit:diff:get"){let{sha:i,repo:S}=l.payload;return b(r,{type:"commit:diff:result",payload:{sha:i,repo:S,result:await tr({repoRoot:m,sha:i,repo:S})}})}if(d==="repos:get"){let i=await er(m);return b(r,{type:"repos",payload:await Pe({repoRoot:m}),own:i})}if(d==="repo:preview"){let i=await io({repoRoot:m,...l.payload,previewOnly:!0});return b(r,{type:"repos",for:d,url:l.payload.url.trim(),payload:h(i)?await Pe({repoRoot:m}):i,preview:h(i)?null:i.value.preview??null,lastAction:{ok:!h(i),message:i.message}})}if(d==="repo:preview:cancel")return yn(l.payload),b(r,{type:"repos",for:d,payload:await Pe({repoRoot:m}),preview:null});if(d==="repo:connect"||d==="repo:disconnect"){let i=d==="repo:connect"?await io({repoRoot:m,...l.payload,confirm:!0}):await gn({repoRoot:m,...l.payload});return b(r,{type:"repos",for:d,payload:h(i)?await Pe({repoRoot:m}):i,preview:null,lastAction:{ok:!h(i),message:i.message}}),h(i)?b(r,{type:`${d}:result`,payload:i}):(!h(i)&&i.message!==Xo&&!i.message.startsWith(zo)&&Vn(),L(r,m,o,`${d}:result`,i))}if(d==="issue:commits:get"){let{issueId:i}=l.payload;return b(r,{type:"issue:commits:result",payload:{issueId:i,result:so(await Zo({repoRoot:m,ref:me(i)}))}})}if(d==="issue:squashed-diff:get"){let{issueId:i}=l.payload;return b(r,{type:"issue:squashed-diff:result",payload:{issueId:i,result:await or({repoRoot:m,ref:me(i)})}})}if(d==="issue:stats:get"){let{issueId:i}=l.payload;return b(r,{type:"issue:stats:result",payload:{issueId:i,result:await Et({repoRoot:m,idOrRef:me(i)})}})}if(d==="diff-stats:get")return b(r,{type:"diff-stats",payload:await Rn({repoRoot:m})});if(d==="swimlane:stats:get"){let{swimlaneId:i}=l.payload;return b(r,{type:"swimlane:stats:result",payload:{swimlaneId:i,result:await $n({repoRoot:m,swimlaneId:i})}})}if(d==="time-travel:scrub"){let i=await Rr({repoRoot:m,targetTime:l.payload.targetTime});return b(r,{type:"time-travel:result",payload:i}),h(i)?void 0:uo()}if(d==="time-travel:checkout-event"){let i=await jr({repoRoot:m,eventId:l.payload.eventId});return b(r,{type:"time-travel:result",payload:i}),h(i)?void 0:uo()}if(d==="time-travel:live"){let i=await Dr({repoRoot:m});return b(r,{type:"time-travel:result",payload:i}),h(i)?void 0:uo()}if(d==="state:get")return Ve(r,m);if(d==="sync"){let i=await It({repoRoot:m});return b(r,{type:"sync:result",payload:i}),o(),h(i)||po(m),Ve(r,m)}if(d==="issue:comment:add"){let i=await Tt({repoRoot:m,...l.payload});return L(r,m,o,"issue:comment:add:result",i)}if(d==="issue:comment:edit"){let i=await dn({repoRoot:m,...l.payload});return L(r,m,o,"issue:comment:edit:result",i)}if(d==="issue:comment:delete"){let i=await Ct({repoRoot:m,...l.payload});return b(r,{type:"issue:comment:delete:result",payload:i}),h(i)?b(r,{type:"failed",payload:i.message}):(o(),Ve(r,m))}if(d==="issue:edit:description"){let i=await Jr({repoRoot:m,...l.payload});return L(r,m,o,"issue:edit:description:result",i)}if(d==="issue:edit:title"){let i=await Xr({repoRoot:m,...l.payload});return L(r,m,o,"issue:edit:title:result",i)}if(d==="issue:tag:add"){let i=await rn({repoRoot:m,...l.payload});return L(r,m,o,"issue:tag:add:result",i)}if(d==="issue:tag:remove"){let i=await sn({repoRoot:m,...l.payload});return L(r,m,o,"issue:tag:remove:result",i)}if(d==="contributor:remove"){let i=await ln({repoRoot:m,...l.payload});return L(r,m,o,"contributor:remove:result",i)}if(d==="tag:remove"){let i=await nn({repoRoot:m,...l.payload});return L(r,m,o,"tag:remove:result",i)}if(d==="contributors:get")return b(r,{type:"contributors",boardId:l.payload?.boardId,payload:await mn({repoRoot:m,...l.payload})});if(d==="issue:assignee:add"){let i=await an({repoRoot:m,...l.payload});return L(r,m,o,"issue:assignee:add:result",i)}if(d==="issue:assignee:remove"){let i=await cn({repoRoot:m,...l.payload});return L(r,m,o,"issue:assignee:remove:result",i)}if(d==="issues:list")return b(r,{type:"issues",payload:await kr({repoRoot:m})});if(d==="issues:create"){let i=await Wr({...l.payload,repoRoot:m});return b(r,{type:"issues:create:result",payload:i}),h(i)?ce({type:"failed",payload:i.message}):(o(),Ve(r,m))}if(d==="board:create"){let i=await zr({...l.payload,repoRoot:m});return L(r,m,o,"board:create:result",i)}if(d==="board:edit:title"){let i=await Qr({...l.payload,repoRoot:m});return L(r,m,o,"board:edit:title:result",i)}if(d==="swimlane:create"){let i=await Zr({...l.payload,repoRoot:m});return L(r,m,o,"swimlane:create:result",i)}if(d==="swimlane:edit:title"){let i=await en({...l.payload,repoRoot:m});return L(r,m,o,"swimlane:edit:title:result",i)}if(d==="swimlane:delete"){let i=await on({...l.payload,repoRoot:m});return L(r,m,o,"swimlane:delete:result",i)}if(d==="swimlane:move"){if(!l.payload.position)return b(r,{type:"error",message:"Missing move position"});let i=await tn({...l.payload,repoRoot:m});return L(r,m,o,"swimlane:move:result",i)}if(d==="issues:move"){if(!l.payload.position)return b(r,{type:"error",message:"Missing move position"});let i=await Yr({...l.payload,repoRoot:m});return L(r,m,o,"issues:move:result",i)}if(d==="issue:close"){let i=await Vr({repoRoot:m,issueId:l.payload.issueId});return L(r,m,o,"issue:close:result",i)}if(d==="issue:reopen"){let i=await Kr({repoRoot:m,issueId:l.payload.issueId});return L(r,m,o,"issue:reopen:result",i)}return b(r,{type:"error",message:"Unknown message type"})},p,g=async l=>{if(p!=="repo:connect"&&p!=="repo:disconnect"&&p!=="repo:preview")return b(r,{type:"error",message:l});b(r,{type:"repos",for:p,payload:await Pe({repoRoot:t.repoRoot}),preview:null,lastAction:{ok:!1,message:l}}),p!=="repo:preview"&&b(r,{type:`${p}:result`,payload:$(l)})};try{let l=JSON.parse(f.toString());p=l?.type;let d=Wn(l);if(!d.ok)return await g(d.error);let m=d.message;return Fn.has(m.type)?await de(async()=>ie().mode!=="live"?b(r,{type:"failed",payload:"Read-only while viewing history"}):y(m)):await y(m)}catch(l){return g(l instanceof Error?l.message:String(l))}})})};var ks=xe.dirname(Hs(import.meta.url)),Ws=process.env.IS_LOCAL==="true"?xe.resolve(process.cwd(),"dist/gui"):xe.join(ks,"gui"),Bt,Vs=async()=>(Bt===void 0&&(Bt=await import("node:sea").catch(()=>null)),Bt?.isSea()?Bt:null),M=(e,t,o)=>{e.writeHead(t,{"content-type":"application/json"}),e.end(JSON.stringify(o))},Ks=e=>M(e,409,{isError:!0,message:"Read-only while viewing history"}),Lt=(e,t)=>de(async()=>ie().mode!=="live"?Ks(e):t()),Yn=async(e,t=1024*1024)=>new Promise((o,n)=>{let s=[],u=0;e.on("data",r=>{if(u+=r.length,u>t){e.destroy(),n(new Error("Request body too large"));return}s.push(r)}),e.on("end",()=>{let r=Buffer.concat(s).toString("utf8");try{o(r?JSON.parse(r):{})}catch{n(new Error("Invalid JSON body"))}}),e.on("error",n)}),Ys=2*1024*1024,qs={png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp"},Js=e=>e.endsWith(".html")?"text/html; charset=utf-8":e.endsWith(".js")?"text/javascript; charset=utf-8":e.endsWith(".css")?"text/css; charset=utf-8":e.endsWith(".json")?"application/json; charset=utf-8":e.endsWith(".ico")?"image/x-icon":"application/octet-stream",qn=new Map,Xs=e=>`"${Fs("sha1").update(e).digest("base64url")}"`,zs=async e=>{try{let{size:t,mtimeMs:o}=await $s(e);return`${t}:${o}`}catch{return null}},Qs=e=>{try{return decodeURIComponent(e)}catch{return null}},Jn=async(e,t,o)=>{let n=e==="/"?"/index.html":Qs(e);if(n===null)return M(o,404,{isError:!0,message:"Not found"});let s=n.replace(/^\/+/,""),u=xe.resolve(Ws),r=xe.resolve(u,s),f=xe.relative(u,r);if(f.startsWith("..")||xe.isAbsolute(f))return M(o,403,{isError:!0,message:"Forbidden"});let y=await Vs(),p=y?"sea":await zs(r),g=p===null?void 0:qn.get(f),l=g&&g.stamp===p?g.etag:null;if(l&&t.headers["if-none-match"]===l)return o.writeHead(304,{etag:l,"cache-control":"no-cache"}),o.end();try{let d=y?Buffer.from(y.getAsset(`gui/${f}`)):await Xn(r),m=l??Xs(d);return p!==null&&qn.set(f,{stamp:p,etag:m}),o.writeHead(200,{"content-type":Js(r),etag:m,"cache-control":"no-cache"}),o.end(d)}catch{return M(o,404,{isError:!0,message:`Not found: ${s}`})}},Zs=async(e,t=He)=>new Promise((o,n)=>{let s=u=>{let r=y=>{if(e.off("listening",f),y.code==="EADDRINUSE"&&u===t){e.removeListener("error",r),s(0);return}n(y)},f=()=>{e.off("error",r);let y=e.address();if(!y||typeof y=="string"){n(new Error("Unable to resolve address"));return}o(y.port)};e.once("error",r),e.once("listening",f),e.listen(u,"127.0.0.1")};s(t)}),zn=async e=>{Mr(!1);let t=0,o={repoRoot:e.repoRoot},n=Us.createServer((p,g)=>{s(p,g).catch(l=>(logger.error(`[gui] ${p.method} ${p.url}: ${l instanceof Error?l.message:String(l)}`),g.headersSent?g.end():M(g,500,{isError:!0,message:"Internal error"})))});async function s(p,g){let l=new URL(p.url??"/","http://127.0.0.1"),d=Ln({method:p.method,origin:p.headers.origin,contentType:p.headers["content-type"]},t);if(d)return M(g,d.status,{isError:!0,message:d.message});if(p.method==="GET"&&l.pathname===lo)return M(g,200,{app:mo,repoRoot:Nt(o.repoRoot),version:Y,pid:process.pid});if(l.pathname==="/api/state")return M(g,200,await ee({repoRoot:o.repoRoot}));if(p.method==="POST"&&l.pathname==="/api/comments")try{let m=await Yn(p);if(!m.issueId||!m.body?.trim())return M(g,400,{isError:!0,message:"Missing issueId or body"});let i=m.issueId,S=m.body;return await Lt(g,async()=>{let G=await Tt({repoRoot:o.repoRoot,issueId:i,body:S});return h(G)?M(g,400,{isError:!0,message:G.message}):M(g,200,await ee({repoRoot:o.repoRoot}))})}catch(m){return M(g,400,{isError:!0,message:m instanceof Error?m.message:"Unable to add comment"})}if(p.method==="POST"&&l.pathname==="/api/attachments")try{let m=await Yn(p,Ys);if(!m.issueId||!m.dataBase64)return M(g,400,{isError:!0,message:"Missing issueId or dataBase64"});let i=m.issueId,S=m.dataBase64,G=m.name??"";return await Lt(g,async()=>{let D=await $r({repoRoot:o.repoRoot,issueId:i,name:G,dataBase64:S});return h(D)?M(g,400,{isError:!0,message:D.message}):M(g,200,{...await ee({repoRoot:o.repoRoot}),attachment:D.value})})}catch(m){return M(g,400,{isError:!0,message:m instanceof Error?m.message:"Unable to add attachment"})}if(p.method==="DELETE"&&l.pathname.startsWith("/api/attachments/")){let m=decodeURIComponent(l.pathname.replace("/api/attachments/",""));return m?Lt(g,async()=>{let i=await Fr({repoRoot:o.repoRoot,attachmentId:m});return h(i)?M(g,400,{isError:!0,message:i.message}):M(g,200,await ee({repoRoot:o.repoRoot}))}):M(g,400,{isError:!0,message:"Missing attachment id"})}if(p.method==="GET"&&l.pathname.startsWith("/media/")){let m=decodeURIComponent(l.pathname.replace("/media/","")),i=await Ur({repoRoot:o.repoRoot,fileName:m});if(h(i))return M(g,404,{isError:!0,message:i.message});try{let S=await Xn(i.value.filePath);return g.writeHead(200,{"content-type":qs[i.value.ext]??"application/octet-stream","cache-control":"public, max-age=31536000, immutable"}),g.end(S)}catch{return M(g,404,{isError:!0,message:"Attachment blob not found"})}}if(p.method==="DELETE"&&l.pathname.startsWith("/api/comments/")){let m=decodeURIComponent(l.pathname.replace("/api/comments/",""));return m?Lt(g,async()=>{let i=await Ct({repoRoot:o.repoRoot,commentId:m});return h(i)?M(g,400,{isError:!0,message:i.message}):M(g,200,await ee({repoRoot:o.repoRoot}))}):M(g,400,{isError:!0,message:"Missing comment id"})}return l.pathname.startsWith("/board/")||l.pathname==="/log"?Jn("/",p,g):Jn(l.pathname,p,g)}try{t=await Zs(n)}catch(p){return $(p instanceof Error?`Unable to start GUI server: ${p.message}`:`Unable to start GUI server: ${String(p)}`)}let u=Mn({project:o}),r=Cn({project:o,publisher:u,onReposFetch:p=>po(o.repoRoot,p)}),f=Bn(u);Kn(n,o,{onStateChanged:()=>r.queueSync(),onSyncSettingsChanged:()=>r.reschedule(),getPort:()=>t}),n.on("close",()=>{r.dispose(),f()});let y=n.address();return!y||typeof y=="string"?(n.close(),$("Unable to resolve GUI server address")):T("Started GUI server",{url:`http://epiq.localhost:${y.port}${e.boardId?`/board/${e.boardId}`:""}`,server:n})};var Qn=async e=>{let t=f=>{e.open!==!1&&vn()&&wn(f)},o=rt({});if(h(o))return $(o.message);let n=we();F(n)&&_e(n.value);let s=await Tn(He);if(s&&s.repoRoot===Nt(e.repoRoot)){let f=`http://127.0.0.1:${He}`;return console.log(ao({url:f,repoRoot:e.repoRoot,version:Y,reused:!0})),t(f),T("Reused running GUI",{url:f})}let u=await zn({repoRoot:e.repoRoot,boardId:""});if(h(u))return u;let{url:r}=u.value;return console.log(ao({url:r,repoRoot:e.repoRoot,version:Y,reused:!1})),t(r),T("Started GUI",{url:r})};import{Box as le}from"ink";import N from"react";import{Box as fo,Text as Ke}from"ink";import te,{useEffect as ea,useMemo as ta}from"react";import{ulid as oa}from"ulid";var Zn=({text:e,match:t,color:o,highlightColor:n=a.secondary,dimColor:s=!1})=>{if(!t)return te.createElement(Ke,{color:o,dimColor:s},e);let u=e.toLowerCase(),r=t.toLowerCase(),f=u.indexOf(r);return f===-1?te.createElement(Ke,{color:o,dimColor:s},e):te.createElement(Ke,{color:o,dimColor:s},e.slice(0,f),te.createElement(Ke,{backgroundColor:n,bold:!0},e.slice(f,f+t.length)),e.slice(f+t.length))},ei=oa(),ra=e=>`${e}`,na=e=>{let{pendingNavTarget:t}=hr();if(!t)return[];let{breadCrumb:o,contextNode:n,selectedNode:s}=t,u=new Set(qo(ut.NONE,{breadCrumb:o,contextNode:n,readOnly:Q().readOnly,selectedNode:s}));return[...new Set(Object.values(ut))].filter(r=>r!=="move").filter(r=>r.length>0).filter(r=>r!==ut.PALETTE).map(r=>{let f=ur(r),y=Cr.find(p=>p.intent===f);return{command:r,description:y?.description??`[${r}] Run command`,isAvailable:u.has(r)}}).filter(r=>r.command.toLowerCase().startsWith(e)||e.length>=2&&r.description.toLowerCase().includes(e)).sort((r,f)=>r.isAvailable!==f.isAvailable?r.isAvailable?-1:1:r.command.localeCompare(f.command))},ia=e=>Te.text({id:ei,parentNodeId:e,rank:"000000",name:"Command Palette",readonly:!0,isVirtual:!0}),sa=(e,t,o)=>Te.text({id:ra(e.command),parentNodeId:o,rank:String(t).padStart(6,"0"),name:e.command,disabled:!e.isAvailable,readonly:!0,isVirtual:!0}),go=[],aa=e=>{ti();let t=q.createNode(ia(Q().rootNodeId));h(t)||!Ie(t.value)||(go=[t.value,...e.map((o,n)=>sa(o,n,ei)).map(q.createNode).filter(F).map(({value:o})=>o).filter(Ie)],Ce.navigate({contextNode:t.value,selectedIndex:0}))},ti=()=>{let e=go.map(t=>t.id);go=[];for(let t of e)q.deleteNode(t)};function oi({width:e,height:t}){let n=ar().value.trim().toLowerCase(),s=ta(()=>na(n),[n]);ea(()=>(aa(s),()=>{ti()}),[s]);let u=Q().selectedIndex;return te.createElement(fo,{flexDirection:"column",width:e,height:t-2},te.createElement(xt,{height:t-4,itemHeight:3,selectedIndex:u},s.map((r,f)=>{let y=f===u,p=r.isAvailable?a.accent:a.secondary2,g=r.isAvailable?"":"[unavailable] ";return te.createElement(fo,{key:r.command,flexDirection:"column",paddingX:1,borderLeft:!1,borderBottom:!1,borderRight:!1,borderColor:a.secondary,borderStyle:"single"},te.createElement(Ke,{color:p,dimColor:!r.isAvailable},y?"\u276F ":" ",te.createElement(Zn,{text:Yo(r.command),match:n,color:p,dimColor:!r.isAvailable})),te.createElement(fo,{paddingLeft:2},te.createElement(Zn,{text:g+r.description,match:n.length>=2?n:"",color:y&&r.isAvailable?a.primary:a.secondary2,dimColor:!r.isAvailable})))})))}import{Box as wa}from"ink";import Dt from"react";import qe from"chalk";import{Box as Ye,Text as si}from"ink";import be,{useEffect as ai,useMemo as la,useState as li}from"react";var Ae=["\u2803","\u2806","\u2830","\u2818"],ri=120,ni=({isPalette:e,isPending:t,frame:o})=>{if(t){let n=(o%Ae.length+Ae.length)%Ae.length;return Ae[n]}return e?"?":":"},ii=({infoMessage:e,isPending:t})=>t&&e.includes(ir)?"":e;var mi=qe.hex(a.secondary),ma=qe.inverse,ca=qe.inverse.hex(a.secondary2),da={hint:"",hints:[],overlap:0,remainder:""},di=({value:e,command:t})=>{if(!t)return null;let o=e.trimStart(),s=e.length-o.length;return e.slice(s,s+t.length)!==t?null:{start:s,end:s+t.length}},ua=({command:e,modifier:t})=>{if(!t)return null;if(e==="tag"||e==="assign"){let o=Do(t);return{bg:n=>qe.bgHex(o).black(n),bgCursor:n=>qe.bgHex(o).inverse.black(n)}}return eo(t)},pa=({value:e,command:t,modifier:o})=>{if(!t||!o)return null;let n=di({value:e,command:t});if(!n)return null;let u=e.slice(n.end).match(/^\s*/)?.[0].length??0,r=n.end+u;return e.slice(r,r+o.length)!==o?null:{start:r,end:r+o.length}},ci=()=>({value:ne.value,cursorPosition:ne.cursorPosition,commandIsPending:ne.commandIsPending,autoCompletion:ne.commandMeta.autoCompletion??da,infoMessage:ne.commandMeta.infoMessage,validationStatus:ne.commandMeta.validity,command:ne.commandMeta.command,inputString:ne.commandMeta.inputString,modifier:ne.commandMeta.modifier}),fa=(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,ui=({width:e,mode:t})=>{let[o,n]=li(ci());ai(()=>{let B=()=>{let C=ci();n(w=>fa(w,C)?w:C)},E=sr(B);return B(),()=>{E()}},[]);let{value:s,cursorPosition:u,infoMessage:r,commandIsPending:f,autoCompletion:y,command:p,modifier:g,validationStatus:l}=o,d=f&&l===nr.Invalid,m=ii({infoMessage:r,isPending:f}),[i,S]=li(0);ai(()=>{if(!f){S(0);return}let B=setInterval(()=>{S(E=>(E+1)%Ae.length)},ri);return()=>{clearInterval(B)}},[f]);let G=ni({isPalette:t===U.PALETTE,isPending:f,frame:i}),D=la(()=>{let B=Math.max(0,Math.min(u,s.length)),E=di({value:s,command:p}),C=pa({value:s,command:p,modifier:g}),w=p?eo(p):null,W=ua({command:p,modifier:g}),ve=(V,K)=>{let Qt=E&&K>=E.start&&K<E.end,Zt=C&&K>=C.start&&K<C.end;return Qt&&w?w.fg(V):Zt&&W?W.bg(V):V},je=(V,K)=>{let Qt=E&&K>=E.start&&K<E.end,Zt=C&&K>=C.start&&K<C.end;return Qt&&w?w.fgCursor(V):Zt&&W?W.bgCursor(V):ma(V)},ye=s.slice(0,B),Z=s[B]??" ",De=B<s.length?s.slice(B+1):"",ot=Array.from(ye).map((V,K)=>ve(V,K)).join(""),Ao=je(Z,B),No=Array.from(De).map((V,K)=>ve(V,B+1+K)).join("");if(y.hint){let V=y.hint[y.overlap]??Z;Ao=ca(V),No=mi(y.remainder.slice(1)+De)}return ot+Ao+No},[s,u,y,p,g]);return be.createElement(Ye,{flexDirection:"column",justifyContent:"flex-start"},be.createElement(Ye,{flexDirection:"column",paddingX:1,borderColor:a.secondary,borderStyle:"round",width:e},be.createElement(Ye,{height:1,flexWrap:"nowrap"},be.createElement(Ye,{flexShrink:0},be.createElement(si,{wrap:"truncate-start"},mi(G),D)),m&&be.createElement(Ye,{flexShrink:1,minWidth:0},be.createElement(si,{wrap:"truncate",color:d?a.red:a.secondary2},` ${m} `)))))};import{Box as ga,Text as Je}from"ink";import Ne from"react";var pi=" ",ya=({keys:e,label:t})=>e.length+1+t.length,ha=(e,t)=>{let o=[],n=0;for(let s of e){let r=(o.length>0?pi.length:0)+ya(s);if(n+r>t-4)break;o.push(s),n+=r}return o},fi=({width:e,availableHints:t})=>{let o=ha(t,e);return Ne.createElement(ga,{width:e,borderStyle:"round",borderColor:a.secondary,paddingX:1},o.length?Ne.createElement(Je,{wrap:"truncate"},o.map(({keys:s,label:u},r)=>Ne.createElement(Je,{key:`${s}-${u}`},r>0?pi:"",Ne.createElement(Je,{color:a.accent},s),Ne.createElement(Je,{color:a.secondary2}," ",u)))):Ne.createElement(Je,{color:a.secondary2},"\xA0"))};import{Box as xa,Text as Rt}from"ink";import Xe,{useEffect as ba,useRef as Me,useState as Sa}from"react";var va=40,jt=.3,yo="\u2500",gi=1,yi=16,hi=({width:e})=>{let{replay:t}=_(),o=t!==null,n=t?Math.min(1,Math.max(0,t.progress)):0,u=Math.max(4,e-6),r=u*gi,[f,y]=Sa(0),p=Me(n);p.current=n;let g=Me(0),l=Me(0),d=Me(0),m=Me(0),i=Me(0);if(ba(()=>{if(!o){g.current=0,d.current=0,m.current=0,i.current=0,y(0);return}g.current=p.current,l.current=Date.now(),d.current=p.current;let E=setInterval(()=>{let C=Date.now(),w=p.current;if(w!==d.current){let Z=w-d.current,De=C-l.current;if(Z<0)m.current=0,i.current=0;else if(Z>0&&De>0){let ot=Z/De;m.current=m.current===0?ot:m.current*(1-jt)+ot*jt,i.current=i.current===0?Z:i.current*(1-jt)+Z*jt}g.current=w,l.current=C,d.current=w}let W=C-l.current,ve=Math.min(i.current,m.current*W),je=Math.min(1,g.current+ve),ye=Math.round(je*r);y(Z=>Z===ye?Z:ye)},va);return()=>clearInterval(E)},[o,r]),!t)return null;let S=E=>{let C=u>1?E/(u-1):0,w=Math.round(C*(yi-1))/(yi-1);return Go(w)},G=Math.min(u,Math.floor(f/gi)),D=[];for(let E=0;E<G;E++){let C=S(E),w=D[D.length-1];w&&w.color===C?w.text+=yo:D.push({text:yo,color:C})}let B=yo.repeat(Math.max(0,u-G));return Xe.createElement(xa,{width:e,borderStyle:"round",borderColor:a.secondary,paddingX:1,columnGap:1},Xe.createElement(Rt,{color:a.secondary2},"\u25B6"),Xe.createElement(Rt,null,D.map((E,C)=>Xe.createElement(Rt,{key:C,color:E.color},E.text)),Xe.createElement(Rt,{color:a.secondary,dimColor:!0},B)))};var ze=({width:e,mode:t,availableHints:o})=>{let{timeMode:n}=_(),s=t===U.COMMAND_LINE||t===U.PALETTE;return Dt.createElement(wa,null,s?Dt.createElement(ui,{width:e,mode:t}):n==="replay"?Dt.createElement(hi,{width:e}):Dt.createElement(fi,{width:e,mode:t,availableHints:o}))};import{Box as pe,Text as Be}from"ink";import H,{useEffect as Ia,useMemo as Ta}from"react";import{ulid as xi}from"ulid";var Ot=xi(),Ca=()=>[...new Set([...Q().availableActions].map(e=>e.description).filter(e=>e!==void 0))].map(Er).filter(e=>e!==null).sort(({keys:e},{keys:t})=>e.length===1&&t.length!==1?-1:e.length!==1&&t.length===1?1:e.localeCompare(t,void 0,{sensitivity:"base"})).map(({keys:e,label:t})=>({keys:e,action:t})),Ea=e=>Te.text({id:Ot,parentNodeId:e,rank:"000000",name:"Help",isVirtual:!0,readonly:!0}),Pa=(e,t,o)=>Te.text({id:xi(),parentNodeId:o,rank:String(t).padStart(6,"0"),name:e.keys,readonly:!0,isVirtual:!0}),_t=[],bi=()=>{let e=_t.filter(o=>o.id!==Ot).map(o=>o.id),t=_t.filter(o=>o.id===Ot).map(o=>o.id);_t=[];for(let o of[...e,...t])q.deleteNode(o)},Aa=e=>{bi();let t=q.createNode(Ea(Q().rootNodeId));if(h(t)||!Ie(t.value))return logger.error("Could not attach help nodes");_t=[t.value,...e.map((o,n)=>Pa(o,n,Ot)).map(q.createNode).filter(F).map(({value:o})=>o).filter(Ie)],Ce.navigate({contextNode:t.value,selectedIndex:0})},Si=({width:e,height:t})=>{let o=Ta(()=>Ca(),[]);Ia(()=>(Aa(o),()=>{bi()}),[o]);let n=Q().selectedIndex;return H.createElement(pe,{flexDirection:"column",marginTop:3,borderColor:a.secondary,borderStyle:"round",width:e,height:t-2},H.createElement(pe,{paddingX:1,justifyContent:"center"},H.createElement(Be,{color:a.accent},"Help"),H.createElement(Be,{dimColor:!0}," \u2014 navigate with arrows/hjkl, press q to close")),H.createElement(pe,{paddingX:1,marginTop:1},H.createElement(pe,{width:20,justifyContent:"flex-end"},H.createElement(Be,{color:a.secondary},"Key(s)")),H.createElement(pe,{flexGrow:1,width:40,paddingLeft:2},H.createElement(Be,{color:a.secondary},"Action"))),H.createElement(xt,{height:t-7,itemHeight:1,selectedIndex:n},o.map(({keys:s,action:u},r)=>{let f=r===n;return H.createElement(pe,{paddingX:1,key:`${s}-${u}-${r}`,flexDirection:"row"},H.createElement(pe,{width:20,justifyContent:"flex-end"},H.createElement(Be,{color:a.accent},s)),H.createElement(pe,{flexGrow:1,width:40,paddingLeft:2},H.createElement(Be,{color:f?a.primary:a.secondary2},u)))})))};import{Box as Le,Text as k}from"ink";import P,{useEffect as Na,useState as ho}from"react";var Gt=({index:e,email:t,note:o,noteColor:n})=>P.createElement(Le,null,P.createElement(k,{color:a.accent},e===void 0?" ":` ${e}.`),P.createElement(k,null," ",t),o&&P.createElement(k,{color:n??a.secondary2},` ${o}`)),vi=({height:e})=>{let[t,o]=ho([]),[n,s]=ho([]),[u,r]=ho(null),{userName:f,gitEmail:y,gitName:p,userId:g}=re();return Na(()=>{let l=!0;return(async()=>{let m=Ee(),i=oe(process.cwd());if(h(m)||h(i)||!g)return;let S=m.value.emailLinks,G=Ho(S,g);o(G.map(C=>({email:C,others:Uo(S,C).filter(w=>w!==g).map(w=>m.value.contributors[w]?.name??w)})));let D=it(i.value),B=await St({repoRoot:i.value,stateBranch:h(D)?void 0:D.value,names:[f,p],links:S});if(!l)return;if(h(B)){r(B.message);return}let E=vt(B.value);ct(E.map(C=>C.email)),s(E)})(),()=>{l=!1}},[g,f,p,y]),P.createElement(Le,{height:e-4,flexDirection:"column",paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:a.secondary,rowGap:1},P.createElement(Le,null,P.createElement(k,{color:a.accent,bold:!0},f??"Not configured"),P.createElement(k,{color:a.secondary2}," on this board")),u&&P.createElement(k,{color:a.red},u),P.createElement(Le,{flexDirection:"column"},P.createElement(k,{color:a.secondary2},"CLAIMED"),t.length===0?P.createElement(Gt,{email:"Nothing claimed \u2014 your commits show the name git signed them with.",note:""}):t.map(l=>P.createElement(Gt,{key:l.email,email:l.email,note:l.others.length>0?`CONTESTED: also ${l.others.join(", ")}, resolves to nobody`:l.email===y?"your git identity here":void 0,noteColor:l.others.length>0?a.yellow:void 0}))),P.createElement(Le,{flexDirection:"column"},P.createElement(k,{color:a.secondary2},"UNCLAIMED IN THIS HISTORY"),n.length===0?P.createElement(Gt,{email:"Nothing left to claim here."}):n.map(l=>P.createElement(Gt,{key:l.email,email:l.email,note:`${l.commits} commit${l.commits===1?"":"s"} as ${l.names.join(", ")||"unknown"}`}))),P.createElement(Le,{flexDirection:"column"},P.createElement(k,{color:a.secondary2},P.createElement(k,{color:a.accent},"[enter]")," writes a claim for the first into the command line, to confirm or change."),P.createElement(k,{color:a.secondary2},P.createElement(k,{color:a.accent},":config emails")," claims by address,",P.createElement(k,{color:a.accent}," :config emails-unclaim "),"gives one back."),P.createElement(k,{color:a.secondary2},P.createElement(k,{color:a.accent},"[esc]")," to close")))};import Ma from"chalk";import{Box as Se,Text as O}from"ink";import A from"react";var Ba=8,La=()=>{let e=Oe({exclude:process.cwd()});return h(e)?[]:e.value.slice(0,Ba)},wi=({width:e,height:t})=>{let o=La();return A.createElement(Se,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:a.secondary,rowGap:1},A.createElement(O,{color:a.accent,bold:!0},"Initialize project"),A.createElement(O,null,`This folder is not an ${Ma.hex(a.accent)("epiq")} project yet.`),A.createElement(O,{color:a.primary},"To start tracking issues here, we need to initialize a new",A.createElement(O,{color:a.primary,backgroundColor:a.secondary}," .epiq/project.json "),"file in this repository."),A.createElement(Se,{marginTop:1,flexDirection:"column"},A.createElement(Se,null,A.createElement(O,{color:a.accent}," "),A.createElement(O,{color:a.primary},"Type "),A.createElement(O,{backgroundColor:a.secondary}," :init "))),A.createElement(Se,{marginTop:1},A.createElement(O,{color:a.secondary2},"This will create, commit and push "),A.createElement(O,{color:a.primary,backgroundColor:a.secondary}," .epiq/project.json ")),o.length>0&&A.createElement(Se,{marginTop:1,flexDirection:"column"},A.createElement(O,{color:a.accent,bold:!0},"Or open a recent project"),o.map((n,s)=>A.createElement(Se,{key:n.projectId},A.createElement(O,{color:a.accent},` ${s+1} `),A.createElement(O,{color:a.primary},mt(n.root)),A.createElement(O,{color:a.secondary2},` ${n.root}`))),A.createElement(Se,{marginTop:1},A.createElement(O,{color:a.accent}," "),A.createElement(O,{color:a.primary},"Type "),A.createElement(O,{backgroundColor:a.secondary}," :open 1 "),A.createElement(O,{color:a.secondary2}," or "),A.createElement(O,{backgroundColor:a.secondary}," :open <path> "))))};import{Box as Ft,Text as X}from"ink";import R from"react";import{Box as $t,Text as ae}from"ink";import J,{useEffect as Ra,useState as Ii}from"react";var Ti=()=>{let[e,t]=Ii(null),[o,n]=Ii(null);return Ra(()=>{let s=!0;return(async()=>{let r=Ee(),f=oe(process.cwd());if(h(r)||h(f))return;let y=it(f.value),{userName:p,gitName:g}=re(),l=await St({repoRoot:f.value,stateBranch:h(y)?void 0:y.value,names:[p,g],links:r.value.emailLinks});if(!s)return;if(h(l)){n(l.message);return}let d=vt(l.value);ct(d.map(m=>m.email)),t(d)})(),()=>{s=!1}},[]),o?J.createElement($t,{marginTop:1},J.createElement(ae,{color:a.red},o)):e===null?null:e.length===0?J.createElement($t,{marginTop:1},J.createElement(ae,{color:a.secondary2},"No unclaimed addresses in this history \u2014 type",J.createElement(ae,{color:a.accent}," :config emails none "),"to move on.")):J.createElement($t,{flexDirection:"column",marginTop:1},e.map(s=>J.createElement(ae,{key:s.email},J.createElement(ae,{color:a.accent}," \xB7 "),J.createElement(ae,null,s.email),J.createElement(ae,{color:a.secondary2},` ${s.commits} commit${s.commits===1?"":"s"} as ${s.names.join(", ")||"unknown"}`))),J.createElement($t,{marginTop:1},J.createElement(ae,{color:a.secondary2},"Claim yours by address, or",J.createElement(ae,{color:a.accent}," none "),"to skip.")))};var ja=({isDone:e,command:t,value:o,verb:n="Type",hint:s})=>R.createElement(Ft,null,R.createElement(X,{color:a.accent,dimColor:e},e?" \u2714 ":" "),R.createElement(X,{dimColor:e},n," "),R.createElement(X,{backgroundColor:a.secondary,dimColor:e}," "+t+" "),o!==void 0&&R.createElement(R.Fragment,null,R.createElement(X,{dimColor:e}," "),R.createElement(X,{color:a.secondary,dimColor:e},"<"+o+">")),s),Da=(e,t)=>e.length===0?void 0:Vo(e.join(", "),Math.max(12,t-34)),_a=e=>{if(typeof e=="string")return e;if(typeof e=="boolean")return e?"on":"off"};function xo({width:e,height:t}){let{isSetPreferredEditor:o,isSetUserName:n,userName:s,preferredEditor:u,autoSync:r,isSetAutoSync:f,isSetEmails:y,claimedEmails:p,emailSetupDeclined:g}=dt(),l=[{key:"username",done:n,command:":config username",value:s,message:"First, choose your username."},{key:"editor",done:o,command:":config editor",value:u,message:"Nice. Now pick your editor."},{key:"autosync",done:f,command:":config autosync",value:r,message:"Almost there. Configure auto sync."},{key:"emails",done:y,command:":config emails",value:g?"declined":Da(p,e),message:"Last one. Claim the git addresses whose commits are yours, so the board calls them by your name."}],d=l.findIndex(i=>!i.done),m=d===-1?void 0:l[d];return R.createElement(Ft,{height:t-4,flexDirection:"column",width:e,paddingTop:1,paddingLeft:2,borderStyle:"round",borderColor:a.secondary,rowGap:1},R.createElement(X,{color:a.accent,bold:!0},"Welcome! \u{1F539}"),R.createElement(X,null,"Let's get you started - it's a breeze."),R.createElement(X,{color:a.secondary2},"Remember - you can always search available commands by typing:",R.createElement(X,{color:a.accent}," ? ")),m&&R.createElement(X,{color:a.secondary2},m.message),R.createElement(Ft,{flexDirection:"column"},l.map((i,S)=>{if(!(d===-1||S<=d))return null;let D=S===d,B=D&&d===0;return R.createElement(Ft,{key:i.key,flexDirection:"column",marginBottom:1},R.createElement(ja,{isDone:i.done,command:B?":config us":i.command,value:i.done?_a(i.value):void 0,verb:D&&!B?"Waiting:":"Type",hint:B?R.createElement(X,{color:a.secondary2}," then ",R.createElement(X,{color:a.accent},"tab")," to auto-complete ",R.createElement(X,{backgroundColor:a.secondary},` ${i.command.split(" ").pop()} `)):void 0}),i.key==="emails"&&!i.done&&R.createElement(Ti,null))})))}import Vt from"chalk";import{Box as Ze,Text as Re}from"ink";import j from"react";import{Box as Ut,Text as Ci}from"ink";import fe from"react";import Oa from"chalk";var Ga=e=>(q.getTag(e)?.name??"").length+3,$a=e=>{let t=q.getContributor(e);return(t?t.name:"").length+3},Ei=({width:e})=>{let{viewMode:t}=re(),o=_(),{breadCrumb:n,contextNode:s,selectedIndex:u,renderedChildrenIndex:r}=o,f=r[s.id]?.[u],y=Ar(f?.id??s.id,"TICKET"),p=F(y)?y.value:void 0,g=(p?.props.tags??[]).filter(w=>q.getTag(w)),l=p?.props.assignees??[],d=p?.parentNodeId?!Nr(s.id,p.parentNodeId)&&t==="dense":!1,m=n.map((w,W)=>{let ve=W===n.length-1,je=gt(w.id),ye=ve?je?.[u]?.title:void 0;return`${W?" / ":""}${w.title??""}${ye?` \u25B8 ${ye}`:""}`}).join(""),i=p?q.getCommentsByIssue(p.id):[],S=i.length?String(i.length).length+11:0,G=d?g.reduce((w,W)=>w+Ga(W),0)+l.reduce((w,W)=>w+$a(W),0)+S:0,D=f?.id!=null&&!(t==="wide"&<(f)),B=Math.max(0,e-G),E=m.substring(0,B)+(D?Oa.hex(a.secondary2).dim(` ${me(f.id)}`):""),C=d?[...g.map(w=>fe.createElement(Ut,{key:`tag-${w}`,paddingLeft:1},fe.createElement(gr,{id:w}))),...l.map(w=>fe.createElement(Ut,{key:`assignee-${w}`,paddingLeft:1},fe.createElement(fr,{id:w}))),i.length?fe.createElement(Ut,{key:"comments",paddingLeft:1},fe.createElement(Ci,{color:a.accent},"[",i.length," comment",i.length===1?"":"s","]")):null]:[];return fe.createElement(Ut,{overflow:"hidden",justifyContent:"flex-start",alignItems:"flex-start"},fe.createElement(Ci,{color:a.secondary2},E),C)};import{Box as Fa,Text as Pi}from"ink";import Ht from"react";var Ua=({filters:e})=>Ht.createElement(Fa,{columnGap:1},Ht.createElement(Pi,{color:"red"},"APPLIED FILTERS:"),e.map(({value:t,target:o,operator:n})=>Ht.createElement(Pi,{backgroundColor:"black",color:"white"},` ${o}${n}"${t}" `))),Ai=Ht.memo(Ua);import{Box as Ha,Text as kt}from"ink";import Qe from"react";function Ni(){let{eventLog:e,unappliedEvents:t}=_(),o=e.at(-1)?.id,n=$o(o??""),s=F(n)?bt(n.value):"INVALID DATE";return Qe.createElement(Ha,{paddingLeft:1},Qe.createElement(kt,{backgroundColor:a.accent,color:a.secondary}," Readonly "),Qe.createElement(kt,{color:a.accent}," "+t.length+" edits ago at "+s+"."),Qe.createElement(kt,{color:a.accent}," Resume with "),Qe.createElement(kt,{backgroundColor:a.accent,color:a.secondary}," ",":peek now"," "))}import{Box as ka,Text as bo}from"ink";import Wt from"react";function Mi(){let{replay:e}=_();if(!e)return null;let{appliedCount:t,totalCount:o,currentTime:n}=e;return Wt.createElement(ka,{paddingRight:2,columnGap:1,justifyContent:"flex-end"},Wt.createElement(bo,{backgroundColor:a.accent,color:a.secondary}," \u25B6 REPLAY "),Wt.createElement(bo,{color:a.secondary2},bt(new Date(n))),Wt.createElement(bo,{color:a.accent},`${t}/${o} edits`))}import So from"chalk";import{Box as Wa,Text as Bi}from"ink";import vo,{useEffect as Va,useState as Ka}from"react";var Ya=["#4c567a","#9d7cd8","#7aa2f7","#7dcfff","#9d7cd8"],qa=150,Li=12,Ja=.36;function Ri({syncStatus:e,autoSync:t}){let[o,n]=Ka(0);Va(()=>{if(e.status!=="syncing"){n(0);return}let f=0,y=setInterval(()=>{f+=1;let p=(Math.sin(f*Ja)+1)/2,g=Math.round(p*(Li-1));n(l=>l===g?l:g)},qa);return()=>clearInterval(y)},[e.status]);let s={synced:" ",failed:"---",offline:"off",syncing:"...",pending:"idle"},r={synced:a.secondary2,failed:a.yellow,offline:a.secondary2,pending:a.secondary2,syncing:Oo(Ya,o/(Li-1))??""}[e.status];return vo.createElement(Wa,null,vo.createElement(Bi,null,So.hex(a.secondary2).dim(t?"Sync (auto): ":"Sync: ")),vo.createElement(Bi,null,So.hex(r)("\u25CF")+So.hex(a.secondary2).dim(` ${s[e.status].padEnd(4)} `)))}import Gi from"chalk";import{Text as $i}from"ink";import Fi,{useEffect as Za,useState as el}from"react";import wo from"chalk";var Xa="https://registry.npmjs.org/epiq/latest",Io=null,ji=0,za=1e3*60*60*24,Di=e=>e.replace(/^v/,""),Qa=(e,t)=>{let o=Di(e).split(".").map(Number),n=Di(t).split(".").map(Number);for(let s=0;s<Math.max(o.length,n.length);s++){let u=o[s]??0,r=n[s]??0;if(u>r)return 1;if(u<r)return-1}return 0},_i=async e=>{if(process.env.IS_CI==="true")return{current:"1.2.3",latest:"1.2.3",updateAvailable:!1};if(Io&&Date.now()-ji<za)return Io;try{let t=await fetch(Xa);if(!t.ok)throw new Error(`Failed to fetch latest version: ${t.status}`);let n=(await t.json()).version??null,s={current:e,latest:n,updateAvailable:n?Qa(n,e)>0:!1};return Io=s,ji=Date.now(),s}catch{return{current:e,latest:null,updateAvailable:!1}}},Oi=(e,t)=>{let o=e.split("."),n=t.split("."),s=n.findIndex((u,r)=>u!=o[r]);return n.map((u,r)=>r>=s?wo.hex(a.accent).dim(u):wo.hex(a.secondary).dim(u)).join(wo.hex(a.secondary2).dim("."))};function Ui(){let[e,t]=el({current:Y,latest:null,updateAvailable:!1});return Za(()=>{let o=!0;return _i(Y).then(n=>{o&&t(n)}),()=>{o=!1}},[]),!e.updateAvailable||!e.latest?Fi.createElement($i,{dimColor:!0,color:a.secondary2},Y+" "):Fi.createElement($i,null,Gi.hex(a.secondary2).dim(Y),Gi.hex(a.accent).dim(" \u2197 "),Oi(Y,e.latest))}function et({filters:e,hideBreadCrumb:t=!1}){let{timeMode:o,syncStatus:n,mode:s,replay:u}=_(),{userName:r,preferredEditor:f,autoSync:y}=re(),p=64,g=process.stdout.columns-p-8,l=t||o==="replay",d=u?Wo(u.currentLabel,Math.max(0,g)):"";return j.createElement(Ze,{justifyContent:"space-between",flexDirection:"row","max-width":process.stdout.columns-40,overflow:"hidden"},o==="replay"?j.createElement(Ze,{paddingLeft:1},j.createElement(Re,{color:a.secondary2},d)):l?j.createElement(Re,null," "):s===U.PALETTE?j.createElement(Ze,null,j.createElement(Re,{color:a.accent},"Command Palette"),j.createElement(Re,{dimColor:!0,color:a.secondary2}," ","- search, select and press enter")):j.createElement(Ze,{paddingLeft:1},e.length>0?j.createElement(Ai,{filters:e}):j.createElement(Ei,{width:g})),o==="live"?j.createElement(Ze,{columnGap:1,paddingRight:2,"max-width":p,overflow:"hidden",justifyContent:"flex-end"},j.createElement(Ri,{autoSync:!!y,syncStatus:n}),j.createElement(Re,null,Vt.hex(a.secondary2).dim("Mode: ")+Vt.hex(a.secondary2).dim(s.padEnd(8," "))," "),j.createElement(Hi,{icon:"@",value:r}),j.createElement(Hi,{icon:"\u276F",value:f}),j.createElement(Ui,null)):"",o==="peek"?j.createElement(Ni,null):"",o==="replay"?j.createElement(Mi,null):"")}function Hi({icon:e,value:t}){return j.createElement(Re,null,Vt.dim(e)+Vt.hex(a.accent)(` ${t??"-"} `))}import{Box as tl,Text as ol}from"ink";import tt from"react";import{Box as Kt,Text as To}from"ink";import ge from"react";function Co(){let e=_(),t=e.nodes[e.rootNodeId],s=process.stdout.rows-1-3,u=process.stdout.columns||120,r=t?.id?$e(t?.id):[];return ge.createElement(Kt,{flexDirection:"column",height:s,padding:1,borderStyle:"round",borderColor:a.secondary,width:u},ge.createElement(Kt,{padding:1,paddingTop:0,paddingBottom:0},ge.createElement(To,null,"Select a board:")),ge.createElement(Kt,{padding:1,flexDirection:"column"},r.map((f,y)=>{let p=e.contextNode.context==="WORKSPACE"&&e.selectedIndex===y,l=$e(f.id).flatMap(({id:d})=>gt(d)).length;return ge.createElement(Kt,{key:f.id??y},ge.createElement(To,{color:p?a.accent:a.secondary2},ge.createElement(pr,{isSelected:p})),ge.createElement(To,{color:p?a.accent:a.secondary2},f.title," (",l," issues)",f.readonly?" \u{1F512}":""))})))}var rl=({contextNode:e,selectedIndex:t,breadCrumb:o,mode:n,viewMode:s,height:u,width:r})=>{let{renderedChildrenIndex:f}=_(),y=o.find(({context:d})=>d==="BOARD"),l=u-1-3;return tt.createElement(tl,{flexDirection:"row"},e.context==="WORKSPACE"?tt.createElement(Co,null):y?tt.createElement(yr,{height:l,width:r,swimlanes:(f[y.id]??[]).filter(d=>d!==void 0&&ko(d)),contextNode:e,selectedIndex:t,breadCrumb:o,viewMode:s,mode:n}):tt.createElement(ol,null))},ki=tt.memo(rl);import{useEffect as nl}from"react";var il=e=>{nl(()=>{if(!e)return;let t,o=!1,n=()=>{if(o)return;let{autoSyncIntervalMs:s,userName:u,preferredEditor:r}=re();r&&u&&s&&(t=setTimeout(()=>{if(o)return;let{readOnly:f,mode:y}=Q();y==="default"&&!f&&dr(),n()},s))};return n(),()=>{o=!0,t&&clearTimeout(t)}},[e])},Wi=({autoSync:e})=>(il(e),null);import{useEffect as sl}from"react";var Vi=()=>{let e=oe(process.cwd());return h(e)?T("No project here",null):st({repoRoot:e.value})},Ki=async()=>{let e=Vi();if(h(e))return $(e.message);if(e.value===null)return T("No project here",null);let t=e.value,o=await pt(t);if(!Pr())return T("State not initialized",null);let n=Ee();if(h(n))return T("State not initialized",null);let{mode:s,readOnly:u,timeMode:r,syncStatus:f,selectedNode:y,contextNode:p}=n.value;if(br())return T("Project loading",null);let g=Vi();return h(g)||g.value!==t?T("Project changed",null):s!==U.DEFAULT||u||r!=="live"?T("Skipped while not on the live board",null):y?.isVirtual||p?.isVirtual?T("Skipped on a virtual node",null):f?.status==="syncing"?T("Sync in progress",null):o?T("Worktree held by a sync",null):Ge(t)===Jo(t)?T("Log unchanged",null):(nt.debug("[watch] event log moved, reloading state"),cr(t))};var al=1e3,Yi=()=>(sl(()=>Mt(Ki,al),[]),null);function Eo({width:e,height:t}){let o=_(),{autoSync:n,viewMode:s}=jo(),u=o.filters;if(o.mode===U.HELP)return N.createElement(le,{flexDirection:"column"},N.createElement(Si,{width:e,height:t}));if(o.mode===U.IDENTITY)return N.createElement(le,{flexDirection:"column"},N.createElement(vi,{width:e,height:t}));if(o.mode===U.PALETTE)return N.createElement(le,{flexDirection:"column"},N.createElement(et,{filters:u}),N.createElement(oi,{width:e,height:t-2}),N.createElement(ze,{width:e,mode:o.mode,availableHints:o.availableHints}));let{isSetupDone:r}=dt(),f=!r,y=r&&!o.hasProjectDefinition;if(f)return N.createElement(le,{flexDirection:"column"},N.createElement(le,{flexDirection:"column"},N.createElement(et,{hideBreadCrumb:!0,filters:u}),N.createElement(xo,{height:t,width:e})),N.createElement(ze,{width:e,mode:o.mode,availableHints:[]}));if(y)return N.createElement(le,{flexDirection:"column"},N.createElement(le,{flexDirection:"column"},N.createElement(et,{hideBreadCrumb:!0,filters:u}),N.createElement(wi,{height:t,width:e})),N.createElement(ze,{width:e,mode:o.mode,availableHints:[]}));let p=Fo(o.breadCrumb??[],"BOARD");if(F(p)){let g=p.value.id,l=$e(g).length,d=3,m=Math.floor(e/d),i=Math.floor(e/Math.max(l,1));e=Math.min(i,m)*Math.max(l,d)}return N.createElement(le,{flexDirection:"column"},N.createElement(Wi,{autoSync:n}),N.createElement(Yi,null),N.createElement(le,{flexDirection:"column"},N.createElement(et,{filters:u}),N.createElement(ki,{width:e,height:t,contextNode:o.contextNode,selectedIndex:o.selectedIndex,breadCrumb:o.breadCrumb,viewMode:s??"dense",mode:o.mode})),N.createElement(ze,{width:e,mode:o.mode,availableHints:o.availableHints}))}import ll from"readline";var Yt,qt,se,ml=new Set([x.MoveCursorLeft,x.EraseInputWord,x.MoveCursorLeftOfWord,x.MoveCursorRight,x.MoveCursorRightOfWord,x.NavToPreviousContainer,x.NavToNextContainer,x.NavPreviousItem,x.NavNextItem,x.NavPreviousItemJump,x.NavNextItemJump,x.SetViewDense,x.SetViewWide,x.Confirm,x.Exit,x.Yank,x.InitCommandLine,x.InitCommandPalette,x.ExitCommandLine,x.CaptureInput,x.EraseInput,x.EraseInputWord,x.HideHelp,x.ViewHelp,x.SetViewDense,x.SetViewWide,x.GetLastCommandFromHistory,x.GetNextCommandFromHistory,x.AutoCompleteCommand]),cl=new Set([x.NavPreviousItem,x.NavNextItem,x.NavPreviousItemJump,x.NavNextItemJump,x.NavToPreviousContainer,x.NavToNextContainer,x.Confirm,x.Exit,x.InitCommandPalette,x.InitMove,x.MoveNextItem,x.MovePreviousItem,x.MoveNextItemJump,x.MovePreviousItemJump,x.MoveToNextContainer,x.MoveToPreviousContainer,x.Delete,x.AddItem,x.EditTitle,x.EditDescription,x.ConfirmMove,x.Edit,x.ViewHelp,x.Yank]),qi=async e=>{if(e.ctrl&&e.name==="c")return Ce.exit();let{actionIndex:t,mode:o,readOnly:n,timeMode:s}=Q(),u=lr(e,o);if(!u||n&&!ml.has(u)||s==="replay"&&o===U.DEFAULT&&cl.has(u))return;let r=t[o]?.[u];if(r?.action)try{await r.action(r,e)}catch(f){logger.error(f)}},dl=()=>async function(t,o){o.name!=="escape"&&(se&&(clearTimeout(se),se=void 0),await qi(o))},ul=()=>async function(t){if(t.length===1&&t[0]===27){se&&clearTimeout(se),se=setTimeout(()=>{qi({name:"escape",ctrl:!1,meta:!1,shift:!1,sequence:"\x1B"}),se=void 0},25);return}se&&(clearTimeout(se),se=void 0)};function Ji(){Yt&&process.stdin.removeListener("keypress",Yt),qt&&process.stdin.removeListener("data",qt),Yt=dl(),qt=ul(),ll.emitKeypressEvents(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.on("data",qt),process.stdin.on("keypress",Yt)}async function Xi(){try{let e=rt({});if(h(e))return yt(0,e.message);let t=we();F(t)&&_e(t.value);let o=oe(process.cwd());_e({gitEmail:await _r(process.cwd()),gitName:await Or(process.cwd())});let n=F(o)?await Sr(o.value):wr();if(h(n))return n;let s=Po();return h(s)?yt(6,s.message):(Ji(),F(o)&&vr(o.value),T("Booted Epiq",void 0))}catch(e){return yt(0,ht(e))}}xr();var yl=`${z.bold("Epiq CLI")}
|
|
4
|
-
|
|
5
|
-
${z.dim("Boot in directory:")}
|
|
6
|
-
${z.cyan("$ epiq")}
|
|
7
|
-
|
|
8
|
-
${z.dim("Launch GUI:")}
|
|
9
|
-
${z.cyan("$ epiq gui")}
|
|
10
|
-
${z.cyan("$ epiq gui --no-open")} ${z.dim("no browser")}
|
|
11
|
-
|
|
12
|
-
${z.dim("Act as somebody other than the configured user:")}
|
|
13
|
-
${z.cyan("$ epiq --as claude")}
|
|
14
|
-
`,zt=fl(yl,{importMeta:import.meta,version:Y,flags:{init:{type:"boolean",default:!1},as:{type:"string"},open:{type:"boolean",default:!0}}}),Jt=zt.input[0];Jt&&Jt!=="gui"&&(console.error(z.red(`Unknown command: ${Jt}`)),process.exit(1));if(zt.flags.as!==void 0){let e=Mo(zt.flags.as,"--as");h(e)&&(console.error(z.red(e.message)),process.exit(1))}var zi=process.stdout.columns||120,Qi=process.stdout.rows||20,Xt=null,hl=e=>{try{return Xt?(Xt.rerender(e),T("Rerendered app",void 0)):(Xt=pl(e),T("Rendered app",void 0))}catch(t){return $(`Unable to render app: ${ht(t)}`)}},Po=()=>hl(gl.createElement(Eo,{width:zi,height:Qi}));process.stdout.on("resize",()=>{if(zi=process.stdout.columns||120,Qi=process.stdout.rows||20,!Xt)return;let e=Po();h(e)&&logger.info(`[boot:resize] ${e.message}`)});if(Jt==="gui"){let e=await Qn({repoRoot:process.cwd(),open:zt.flags.open});h(e)&&(console.error(z.red(`Failed to start Epiq GUI:
|
|
15
|
-
${e.message}`)),process.exitCode=1)}else{console.clear();let e=await Xi();h(e)&&(logger.info(e.message),console.error(z.red(`Failed to boot Epiq:
|
|
16
|
-
${e.message}`)),process.exitCode=1)}export{Po as renderApp};
|
package/dist/chunk-7JJFQ6UF.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{$a as N,A as ht,Aa as qe,B as bt,Ba as oe,C as yt,Ca as Gt,D as Rt,Da as ne,E as O,Ea as Y,F as At,Fa as Wt,G as Tt,Ga as jt,H as we,Ha as S,I as Et,Ib as rs,J as P,K as xe,M as me,Ma as Ut,N as St,Na as Ht,Nb as is,O as wt,Ob as Ye,P as He,Pa as zt,Pb as as,Q as xt,Qa as Kt,R as Ct,Ra as Xt,S as Lt,Sa as qt,T as $,Ta as Yt,Tb as ke,Ua as Vt,Ub as ls,V as Ce,Va as Jt,W as se,Wa as Qt,Xb as ds,Yb as Pe,Zb as Ve,_ as w,ac as Je,b as Ae,bc as Ne,c as te,ca as Bt,d as Te,e as Ee,ec as M,f as mt,fa as x,fc as us,g as H,ga as kt,gc as cs,ha as Pt,i as pt,ib as re,jb as fe,k as Se,ka as Nt,la as ze,lb as ie,ma as Le,n as q,na as Ot,o as ft,oa as Mt,ob as Zt,pa as pe,pb as es,q as Ue,qa as Be,qb as ts,ra as Ft,s as gt,sa as _t,ta as Ke,tb as ss,ua as Xe,ub as os,va as R,vb as ns,wa as Dt,xa as T,y as It,ya as $t,z as vt}from"./chunk-HM2XGJT6.js";import{g as ct}from"./chunk-WUCQWBQE.js";import{b as d,c as m,d as l}from"./chunk-5RIQL7P4.js";var oo=e=>e.payload??{},Qe=e=>{let t=new Map,s={},o=new Set,n=new Set,a=new Set;for(let r of e){let{id:i,name:u}=oo(r);if(i)switch(r.action){case"create.contributor":case"create.tag":t.set(i,u??""),o.add(i),n.delete(i);break;case"rename.contributor":u!==void 0&&o.has(i)&&!n.has(i)&&t.set(i,u);break;case"tombstone.contributor":o.has(i)&&(t.set(i,xe),n.add(i));break;case"restore.contributor":case"restore.tag":u!==void 0&&o.has(i)&&(t.set(i,u),n.delete(i));break;case"add.board":u!==void 0&&(t.set(i,u),a.add(i));break;case"add.swimlane":u!==void 0&&(t.set(i,u),a.add(i),s[i]=u);break;case"edit.title":u!==void 0&&a.has(i)&&(t.set(i,u),i in s&&(s[i]=u));break;default:break}}return{byId:t,lanes:s}};var no=e=>{let t=new Map,s=new Map;for(let o of e){let n=o.payload;!n?.id||!n.parent||(o.action==="move.node"&&t.set(o.id,s.get(n.id)),s.set(n.id,n.parent))}return t},ps=e=>{let t=e.payload;return e.action==="tombstone.tag"||e.action==="restore.tag"?t?.id:t?.tag},ro=e=>{let t=new Set,s=new Map;for(let o of e){let n=o.payload,a=n?.id;a&&(o.action==="add.issue"&&t.add(a),n.parent&&s.set(a,n.parent))}return{issueIds:t,parentById:s}},io=(e,{issueIds:t,parentById:s})=>{let o=e.payload;if(o?.issue)return o.issue;let n=new Set,a=o?.id;for(;a!==void 0&&!n.has(a);){if(t.has(a))return a;n.add(a),a=s.get(a)}return null},ao=new Set(["add.issue.comment","edit.issue.comment","delete.issue.comment"]),lo=e=>ao.has(e.action)?e.payload?.id??null:null,uo=new Set(["add.issue","move.node","close.issue","reopen.issue"]),co=(e,t)=>{let s=new Map;return e.map((o,n)=>{let a=t[n]??null;if(a===null)return{lane:null,laneBefore:null};let r=o.payload,i=null;if(uo.has(o.action)&&r?.id===a&&r.parent){let u=s.get(a);u!==void 0&&u!==r.parent&&(i=u),s.set(a,r.parent)}return{lane:s.get(a)??null,laneBefore:i}})},ms=90,mo=e=>{let t=e.trim().split(`
|
|
3
|
-
`)[0]?.trim()??"";return t.length>ms?`${t.slice(0,ms).trimEnd()}\u2026`:t},po=(e,t,s)=>{let o=e.payload,n=ps(e),a=e.action?us(e.action):"";if(o?.md!==void 0){let i=mo(o.md);return i?`${a}: ${i}`:a}if(e.action==="move.node"&&o?.parent){let i=t.get(o.parent);return i?s.get(e.id)===o.parent?`Moved within ${i}`:`Moved to ${i}`:a}if(bt(e.action))return[a,yt(e)].filter(Boolean).join(" ");let r=n!==void 0?t.get(n)??"":o?.assignee!==void 0?t.get(o.assignee)??"":o?.email!==void 0?o.email:o?.name!==void 0?`"${o.name}"`:"";return[a,r].filter(Boolean).join(" ")},Ze=(e,t)=>e?P(e,t.get(e)):null,fo=(e,t)=>{let s=e.payload;return{actor:Ze(e.userId,t),tag:Ze(ps(e),t),assignee:Ze(s?.assignee,t)}},fs=e=>{let t=new Map,s=new Set,o=n=>{let a=new Set,r=n;for(;r&&!a.has(r);){if(s.has(r))return r;a.add(r),r=t.get(r)}return null};return e.map(n=>{let a=n.payload,r=a?.id;if(!r)return null;n.action==="add.board"&&s.add(r);let i=n.action==="close.issue"?o(r):null,u=a.parent??a.issue;return u&&t.set(r,u),i!==null?i:s.has(r)?r:o(r)})},gs=e=>go.has(e),go=new Set(["create.contributor","rename.contributor","tombstone.contributor","restore.contributor","link.contributor.user","link.contributor.email","unlink.contributor.email","connect.repo","edit.repo","disconnect.repo"]),Is=(e,t)=>{let s=fs(e);return e.filter((o,n)=>s[n]===t)},Io=(e,t=new Map)=>{let s=new Map([...t,...Qe(e).byId]),o=no(e),n=ro(e),a=e.map(p=>io(p,n)),r=co(e,a),i=fs(e),u=At(e.map(p=>we(p)));return e.flatMap((p,c)=>{let I=u[c]??null;return I===null?[]:[{id:p.id,t:I,action:p.action,label:po(p,s,o),issue:a[c]??null,target:lo(p),...r[c],board:i[c]??null,...fo(p,s)}]}).sort((p,c)=>p.t-c.t)},vo=e=>{let t=new Map;for(let o of e){if(o.issue===null||o.lane===null)continue;let n=t.get(o.issue)??[],a=n[n.length-1];(a===void 0||a.lane!==o.lane)&&(n.push({t:o.t,lane:o.lane,board:o.board}),t.set(o.issue,n))}let s=new Map;for(let[o,n]of t){let a=n[n.length-1];s.set(o,{changes:n,from:n[0].t,closedFrom:a.lane===x?a.t:null})}return s},ho=(e,t)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>1;e[n].t<t?s=n+1:o=n}return e[s-1]},vs=(e,t,s)=>{let o={};for(let[n,a]of e){if(a.from>=t||a.closedFrom!==null&&a.closedFrom<t)continue;let r=ho(a.changes,t);r===void 0||r.lane===x||s&&r.board!==s||(o[n]=r.lane)}return o},bo=e=>Qe(e).lanes,ge=null,hs=e=>{let t=Be(e);if(ge&&ge.root===e&&ge.signature===t)return m("Timeline entries, cached",ge.index);let s=Y(e);if(l(s))return d(s.message);let o=Io(s.value,ne(e)),n={entries:o,lanes:vo(o),laneNames:bo(s.value)};return ge={root:e,signature:t,index:n},m("Timeline entries, built",n)};var bs=1e5,yo=2e4,Oe=null,ys=Promise.resolve(),As=e=>{let t=ys.then(e,e);return ys=t.then(()=>{},()=>{}),t},Me=e=>{let t=pe(e);return l(t)?t:H({repoRoot:t.value})},j=()=>{if(!Ne())return{mode:"live",asOfTime:null};let{timeMode:e}=ds();return e==="live"?{mode:"live",asOfTime:null}:{mode:"scrub",asOfTime:Oe}},Rs=(e,t)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>1;e[n].t<t?s=n+1:o=n}return s},Nr=async(e={})=>{let t=Me(e.repoRoot);if(l(t))return d(t.message);let s=hs(t.value);if(l(s))return d(s.message);let o=s.value.entries,n=Date.now(),a=e.end??n,r=e.start??o[0]?.t??a;if(a<=r)return m("Empty time window",{bucketMs:0,buckets:[],capped:!1,events:[],lanesAtStart:{},laneNames:s.value.laneNames,closedLane:x,earliest:r,latest:a});let i=Rs(o,r),u=Rs(o,a),g=o.slice(i,u).filter(f=>!e.boardId||f.board===e.boardId||gs(f.action)),p=g.map(f=>f.t),c=Math.max(1,Math.ceil((a-r)/bs)),I=new Map;for(let f of p){let b=Math.min(bs-1,Math.floor((f-r)/c)),E=r+b*c;I.set(E,(I.get(E)??0)+1)}let v=[...I.entries()].sort(([f],[b])=>f-b).map(([f,b])=>({t:f,count:b})),h=g.length>yo;return m("Computed event timeline",{bucketMs:c,buckets:v,capped:h,events:h?[]:g,lanesAtStart:vs(s.value.lanes,r,e.boardId),laneNames:s.value.laneNames,closedLane:x,earliest:r,latest:a})},Ts=e=>{let t=Y(e);if(l(t))return d(t.message);let s=Je();if(l(s))return d(s.message);Oe=null;let o=qe(t.value),{fatal:n,skipped:a}=Ke(o);return n.length>0?d(n.map(r=>r.message).join(", ")):(Xe(a),Ve({readOnly:!1,readOnlyReason:void 0,timeMode:"live",unappliedEvents:[],replay:null}),m("Restored live state",!0))},Ro=(e,t)=>{Oe=null;let s=Ts(e);return l(s)?d(`${t} (recovery to live also failed: ${s.message})`):d(t)},Ao=e=>As(async()=>{let t=Me(e.repoRoot);if(l(t))return d(t.message);let s=Wt(t.value,e.targetTime);if(l(s))return d(s.message);let{appliedEvents:o,unappliedEvents:n}=s.value,a=Je();if(l(a))return a;let r=qe(o),{fatal:i,skipped:u}=Ke(r);return i.length>0?Ro(t.value,i.map(g=>g.message).join(", ")):(Xe(u),Ve({readOnly:!0,timeMode:"peek",unappliedEvents:n,replay:null}),Oe=e.targetTime,m("Checked out historical state",{asOfTime:e.targetTime}))}),Or=async e=>{let t=Me(e.repoRoot);if(l(t))return d(t.message);let s=jt(t.value);if(l(s))return d(s.message);let o=s.value.get(e.eventId)??null;return o===null?d("Event not found in the log"):Ao({repoRoot:e.repoRoot,targetTime:o+1})},Mr=(e={})=>As(async()=>{let t=Me(e.repoRoot);if(l(t))return d(t.message);let s=Ts(t.value);return l(s)?d(s.message):m("Returned to live state",!0)});import wo from"node:fs";import xo from"node:path";import{ulid as tt}from"ulid";import Eo from"node:fs";var Es=new Map,To=3e4,Ss=async e=>{let t=Es.get(e);if(t&&Date.now()-t.readAt<To)return{name:t.name,email:t.email};let s=await Ee({args:["config","--get-regexp","^user\\.(name|email)$"],cwd:e}),o=null,n=null;if(s.exitCode===0)for(let a of(s.stdout??"").split(`
|
|
4
|
-
`)){let r=a.indexOf(" ");if(r===-1)continue;let i=a.slice(0,r),u=a.slice(r+1);i==="user.name"&&(o=u.trim()||null),i==="user.email"&&(n=me(u)||null)}return Es.set(e,{name:o,email:n,readAt:Date.now()}),{name:o,email:n}},ws=async e=>(await Ss(e)).email,ae=async e=>(await Ss(e)).name;var V=e=>{let t=Se(e??process.cwd());return l(t)?d(t.message):m("Resolved Epiq repo root",t.value)},Fe=null,So=async(e,t)=>{let s=V(e);if(l(s))return s;let o=H({repoRoot:s.value});if(l(o))return d(o.message);let n=te(s.value);if(l(n))return d(n.message);if(!(Fe!==null&&Fe.repoRoot===s.value&&Fe.stateBranchRoot===o.value&&Eo.existsSync(pt(o.value)))){let c=await ss({repoRoot:s.value,stateBranchName:n.value});if(l(c))return d(c.message);let I=await os({repoRoot:s.value,stateBranchRoot:o.value,stateBranchName:n.value});if(l(I))return d(I.message);Fe={repoRoot:s.value,stateBranchRoot:o.value}}if(t?.pull??!1){let c=await Te({cwd:o.value,args:["pull","--ff-only"]});l(c)&&Ae.info(3,c.message)}let r={repoRoot:s.value,stateBranchRoot:o.value},i=q();l(i)||Ue(i.value),Ue({gitEmail:await ws(s.value),gitName:await ae(s.value)});let u=Be(o.value);if(Ft(o.value)===u&&Ne()&&j().mode==="live")return m("Booted Epiq state, unchanged",r);let g=oe(o.value);if(l(g))return d(g.message);let p=ie(g.value.events,g.value.unreadable);return l(p)?d(p.message):(_t(o.value,u),m("Booted Epiq state",r))},F=()=>{let e=q();return l(e)?d(e.message):e.value.userId?e.value.userName?m("Resolved actor",{userId:e.value.userId,userName:e.value.userName}):d("Unable to retrieve user name"):d("Unable to retrieve user id")},C=()=>{let e=Pe();return l(e)?d(e.message):e},k=e=>So(e,{pull:!1}),A=async e=>{let t=await k(e);if(l(t))return t;let s=F();if(l(s))return s;let o=C();return l(o)?o:m("Booted",{boot:t.value,actor:s.value,state:o.value})};var L=e=>{let t=C();if(l(t))return t;let s=t.value.nodes[e];return!s||s.isDeleted?d("Issue not found"):$(s)?s.readonly?d("Issue is readonly"):m("Found issue",s):d("Target must be an issue")},z=e=>{let t=C();if(l(t))return t;let s=t.value.nodes[e];return!s||s.isDeleted?d("Swimlane not found"):Ce(s)?s.readonly?d("Swimlane is readonly"):m("Found swimlane",s):d("Target must be a swimlane")},et=e=>{let t=C();if(l(t))return t;let s=t.value.nodes[e];return!s||s.isDeleted?d("Board not found"):se(s)?s.readonly?d("Board is readonly"):m("Found board",s):d("Target must be a board")};var Co=e=>{if(e.filePath)try{return m("Read attachment file",{data:wo.readFileSync(e.filePath),name:e.name??xo.basename(e.filePath)})}catch(t){return d(`Unable to read ${e.filePath}: ${t instanceof Error?t.message:String(t)}`)}return e.dataBase64?m("Decoded attachment data",{data:Buffer.from(e.dataBase64,"base64"),name:e.name??"image"}):d("Provide either filePath or dataBase64")},_e=()=>{let e=q();return l(e)?ze:e.value.attachmentMaxKb??ze},Lo=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;let o=Co(e);if(l(o))return o;let n=Ot(t.value.boot.stateBranchRoot,o.value.data,_e());if(l(n))return n;let a=w(o.value.name).trim()||"image",r=tt(),i={id:tt(),...R(t.value.actor),action:"add.issue.attachment",payload:{id:r,issue:e.issueId,author:t.value.actor.userId,hash:n.value.hash,ext:n.value.ext,name:a,bytes:n.value.bytes}},u=S([i],t.value.boot.stateBranchRoot);if(l(u))return d(u.message);let g=Le(n.value.hash,n.value.ext);return m("Added issue attachment",{id:r,issueId:e.issueId,fileName:g,bytes:n.value.bytes,markdown:Nt(a,g)})},Bo=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.eventLog.find(i=>i.action==="add.issue.attachment"&&i.payload.id===e.attachmentId);if(!s)return d("Unable to resolve attachment");if(s.payload.author!==t.value.actor.userId)return d("You can only delete your own attachments");let o=L(s.payload.issue);if(l(o))return o;if(t.value.state.eventLog.some(i=>i.action==="delete.issue.attachment"&&i.payload.id===e.attachmentId))return m("Attachment already deleted",{id:e.attachmentId,issueId:s.payload.issue});let a={id:tt(),...R(t.value.actor),action:"delete.issue.attachment",payload:{id:e.attachmentId,issue:s.payload.issue}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):m("Deleted issue attachment",{id:e.attachmentId,issueId:s.payload.issue})},ko=async e=>{let t=await k(e.repoRoot);return l(t)?t:Mt(t.value.stateBranchRoot,e.fileName,_e())};var Po=e=>{switch(e.action){case"add.issue":case"move.node":case"close.issue":case"reopen.issue":return e.payload.parent;default:return null}},No=(e,t)=>{let s=[];for(let o of e){let n=Po(o);if(n===null||n===s.at(-1)?.laneId)continue;let a=we(o);s.push({laneId:n,enteredAt:a===null?t:Rt(a)})}return s},Ie=(e,t)=>No(e,t).at(-1)?.enteredAt??t;var Oo=e=>{let t=M.getNode(e);if(!t)return[];let s=new Set;t.parentNodeId&&s.add(t.parentNodeId);for(let o of t.log??[]){let n=o.payload;n.id===e&&n.parent&&s.add(n.parent)}return[...s]},ve=e=>{let t=new Set;e.parentNodeId&&t.add(e.parentNodeId);for(let o of e.log??[]){let n=o.payload;n.id===e.id&&n.parent&&t.add(n.parent)}let s=new Set;for(let o of t)for(let n of Oo(o))s.add(n);return[...s]},J=e=>kt(e).map(t=>P(t.id,t.name)),xs=e=>M.getCommentsByIssue(e).sort((t,s)=>t.id<s.id?-1:t.id>s.id?1:0).map(t=>({id:t.id,author:Et(t.authorId,M.getContributor(t.authorId)?.name),createdAt:O(t.id),body:t.md})),Q=e=>Pt(e).map(({id:t,name:s})=>P(t,s));var Mo=async(e={})=>{let t=await k(e.repoRoot);if(l(t))return t;let s=C();return l(s)?s:m("Retrieved Epiq state",{root:t.value.repoRoot,stateBranchRoot:t.value.stateBranchRoot,nodes:s.value.nodes,rootNodeId:s.value.rootNodeId,contextNode:s.value.contextNode,selectedIndex:s.value.selectedIndex,eventLog:s.value.eventLog})},Fo=365*24*60*60*1e3,_o=e=>{let t=C();if(l(t))return t;let s=t.value.nodes[e];return m("Issue description",s&&$(s)&&!s.isDeleted?s.props.description??"":"")},st=()=>{let e=C();if(l(e))return e;let t=j(),s=t.mode!=="live",o=Object.values(e.value.nodes),n=o.filter(f=>se(f)&&!f.isDeleted),a=Date.now()-Fo,r=new Map,i=new Map;for(let f of o)if(!f.isDeleted){if(Ce(f)&&f.parentNodeId){let b=r.get(f.parentNodeId)??[];b.push(f),r.set(f.parentNodeId,b)}if($(f)&&f.parentNodeId){if(f.parentNodeId===x&&O(f.id)<a)continue;let b=i.get(f.parentNodeId)??[];b.push(f),i.set(f.parentNodeId,b)}}let u=new Set;for(let f of i.values())for(let b of f)u.add(b.id);let g=q();if(l(g))return g;let p={},c=M.getCommentsGroupedByIssue();for(let f of o.filter($))f.isDeleted||!u.has(f.id)||(p[f.id]=(c.get(f.id)??[]).map(b=>{let E=M.getContributor(b.authorId);return{id:b.id,issueId:b.issue,body:b.md,author:P(b.authorId,E?.name),createdAt:O(b.id)}}));let I=new Map;for(let f of e.value.eventLog)f.action==="add.issue.attachment"&&I.set(f.payload.id,f.payload.author);let v={},h=M.getAttachmentsGroupedByIssue();for(let f of o.filter($))f.isDeleted||!u.has(f.id)||(v[f.id]=(h.get(f.id)??[]).map(b=>({id:b.id,issueId:b.issue,name:b.name,fileName:Le(b.hash,b.ext),bytes:b.bytes,createdAt:O(b.id),canDelete:I.get(b.id)===g.value.userId})));return m("Retrieved Epiq GUI state",{boards:n.sort((f,b)=>f.rank.localeCompare(b.rank)).map(f=>({id:f.id,ref:T(f.id),title:f.title,readonly:!!f.readonly||s,swimlanes:(r.get(f.id)??[]).sort((b,E)=>b.rank.localeCompare(E.rank)).map(b=>({id:b.id,title:b.title,readonly:!!b.readonly||s,issues:(i.get(b.id)??[]).sort((E,X)=>E.rank.localeCompare(X.rank)).map(E=>({id:E.id,ref:T(E.id),title:w(E.title),description:E.props.description??"",createdAt:O(E.id),enteredLaneAt:Ie(E.log??[],O(E.id)),readonly:!!E.readonly||s,tags:J(E),assignees:Q(E),parentNodeId:E.parentNodeId,isClosed:E.parentNodeId===x,boardIds:ve(E)})),parentNodeId:b.parentNodeId}))})),tags:M.getTags().map(f=>({...f,...P(f.id,f.name)})),contributors:Object.values(e.value.contributors).map(f=>({...f,...P(f.id,f.name)})),user:{id:g.value.userId??"",name:g.value.userName??"",color:gt(g.value.userName??"")},commentsByIssueId:p,attachmentsByIssueId:v,attachmentMaxKb:_e(),timeTravel:t})},Cs=null,Do=e=>{if(e===Cs)return;let t=Bt({root:e});if(l(t)){Ae.info(t.message);return}Cs=e},$o=async(e={})=>{if(j().mode!=="live")return st();let t=await k(e.repoRoot);return l(t)?t:(Do(t.value.repoRoot),st())},Go=async(e={})=>{Zt();let t=V(e.repoRoot);if(l(t))return d("Sync failed");let s=F();if(l(s))return s;let o=await ns({cwd:t.value,ownEventFileName:Dt(s.value)});return l(o)?(ts(o.message),o):(es(),m("Synced",o.value))};import{ulid as _}from"ulid";var he=e=>{let t=[...new Set([...e.issueIds??[],...e.issueId?[e.issueId]:[]])];return t.length?m("Resolved targets",t):d("Provide issueId or issueIds")},le=(e,t)=>{let s=t.done.length,o=`${e} ${s} issue${s===1?"":"s"}`+(t.failed.length?`, ${t.failed.length} failed`:"");return s?m(o,t):d(`${o}: ${t.failed.map(n=>`${n.ref} ${n.reason}`).join("; ")}`)},be=(e,t)=>{let s={done:[],failed:[]};for(let o of e){let n=t(o);l(n)?s.failed.push({id:o,ref:T(o),reason:n.message}):s.done.push({id:o,ref:T(o)})}return s};var Wo=async e=>{let t=await k(e.repoRoot);if(l(t))return t;let s=C();if(l(s))return s;let o=e.idOrRef.trim();if(!o)return d("Provide an issue id or ref");let n=Object.values(s.value.nodes).filter($).filter(u=>!u.isDeleted),a=n.find(u=>u.id===o),r=a?[a]:n.filter(u=>$t(u.id,o));if(r.length===0)return d(`No issue matches "${o}"`);if(r.length>1)return d(`"${o}" matches ${r.length} issues: ${r.map(u=>`${T(u.id)} (${w(u.title)})`).join(", ")}. Use a full ref or id.`);let i=r[0];return m("Found issue",{id:i.id,ref:T(i.id),title:w(i.title),description:i.props.description??"",createdAt:O(i.id),enteredLaneAt:Ie(i.log??[],O(i.id)),parentNodeId:i.parentNodeId,isClosed:i.parentNodeId===x,boardIds:ve(i),readonly:!!i.readonly,tags:J(i),assignees:Q(i),comments:xs(i.id)})},ks=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();async function jo(e){let t=await k(e.repoRoot);if(l(t))return t;let s=C();if(l(s))return s;let o=s.value.nodes,n=e.query?.trim().toLowerCase(),a=Object.values(o).filter($).filter(i=>!i.isDeleted).filter(i=>e.includeClosed||i.parentNodeId!==x).filter(i=>e.boardId?(i.parentNodeId?o[i.parentNodeId]:void 0)?.parentNodeId===e.boardId:!0).filter(i=>!e.swimlaneId||i.parentNodeId===e.swimlaneId).filter(i=>!e.tag||J(i).some(u=>ks(u.name,e.tag))).filter(i=>!e.assignee||Q(i).some(u=>ks(u.name,e.assignee))).filter(i=>!n||i.title.toLowerCase().includes(n)||(i.props.description??"").toLowerCase().includes(n)),r=i=>w((i.parentNodeId?o[i.parentNodeId]?.title:void 0)??"");return e.brief?m("Listed issues",a.map(i=>({id:i.id,ref:T(i.id),title:w(i.title),swimlane:r(i),tags:J(i).map(u=>u.name),assignees:Q(i).map(u=>u.name)}))):m("Listed issues",a.map(i=>({id:i.id,ref:T(i.id),title:w(i.title),description:i.props.description??"",createdAt:O(i.id),enteredLaneAt:Ie(i.log??[],O(i.id)),parentNodeId:i.parentNodeId,isClosed:i.parentNodeId===x,boardIds:ve(i),readonly:!!i.readonly,tags:J(i),assignees:Q(i)})))}var Uo=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=w(e.title);if(!s)return d("Issue title cannot be empty");let o=e.description??"",n=N("Issue title",s,300)??N("Issue description",o,2e4);if(n)return d(n);if((e.tagNames?.length??0)>20)return d(`Cannot set more than ${20} tags at once`);if((e.assigneeNames?.length??0)>20)return d(`Cannot set more than ${20} assignees at once`);let a=z(e.parentId);if(l(a))return a;let r=fe(e.parentId,t.value.actor,t.value.boot.stateBranchRoot);if(l(r))return r;let i=rs({name:s,parent:e.parentId,user:t.value.actor,rank:r.value});if(l(i))return i;let u=[...i.value],g=u.find(v=>v.action==="add.issue")?.payload.id;if(!g)return d("Unable to determine created issue id");o&&u.push({id:_(),...R(t.value.actor),action:"edit.description",payload:{id:g,md:o}});let p=[];for(let v of e.tagNames??[]){let h=w(v).trim();if(!h||p.some(X=>X.name===h))continue;let f=N("Tag name",h,60);if(f)return d(f);let b=M.findTagByName(h),E=b?.id??_();b||u.push({id:_(),...R(t.value.actor),action:"create.tag",payload:{id:E,name:h}}),u.push({id:_(),...R(t.value.actor),action:"add.issue.tag",payload:{id:g,tag:E}}),p.push({id:E,name:h})}let c=[];for(let v of e.assigneeNames??[]){let h=w(v).trim();if(!h||c.some(X=>X.name===h))continue;let f=N("Assignee name",h,80);if(f)return d(f);let b=Object.values(t.value.state.contributors).find(X=>X.name===h),E=b?.id??_();b||u.push({id:_(),...R(t.value.actor),action:"create.contributor",payload:{id:E,name:h}}),u.push({id:_(),...R(t.value.actor),action:"add.issue.assignee",payload:{id:g,assignee:E}}),c.push({id:E,name:h})}let I=S(u,t.value.boot.stateBranchRoot);return l(I)?d(I.message):m("Created issue",{id:g,ref:T(g),title:s,parentId:e.parentId,description:o,tags:p,assignees:c})},Ho=(e,t,s)=>{let o=L(e);if(l(o))return o;let n=re(x,e,{at:"end"},t,s);if(l(n))return n;let a={id:_(),...R(t),action:"close.issue",payload:{id:e,parent:x,rank:n.value}},r=S([a],s);return l(r)?d(r.message):m("Closed issue",{id:e,ref:T(e)})};async function zo(e){let t=await k(e.repoRoot);if(l(t))return t;let s=F();if(l(s))return s;let o=he(e);if(l(o))return o;let n=a=>Ho(a,s.value,t.value.stateBranchRoot);return e.issueIds?le("Closed",be(o.value,n)):n(o.value[0])}var Ko=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.nodes[e.issueId];if(!s||s.isDeleted)return d("Issue not found");if(!$(s))return d("Target must be an issue");if(s.parentNodeId!==x)return d("Issue is not closed");let o=is(s);if(!o)return d("Unable to resolve previous parent from issue history");if(o===x)return d("Previous parent resolves to closed swimlane");let n=z(o);if(l(n))return n;let a=n.value,r=re(a.id,s.id,{at:"end"},t.value.actor,t.value.boot.stateBranchRoot);if(l(r))return r;let i={id:_(),...R(t.value.actor),action:"reopen.issue",payload:{id:s.id,parent:a.id,rank:r.value}},u=S([i],t.value.boot.stateBranchRoot);return l(u)?d(u.message):m("Reopened issue",{id:s.id,ref:T(s.id),parentId:a.id})},Xo=(e,t,s,o)=>{let n=L(e);if(l(n))return n;let a=z(t.parentId);if(l(a))return a;let r=re(t.parentId,e,t.position??{at:"end"},s,o);if(l(r))return r;let i={id:_(),...R(s),action:"move.node",payload:{id:e,parent:t.parentId,rank:r.value}},u=S([i],o);return l(u)?d(u.message):m("Moved issue",{id:e,ref:T(e),parentId:t.parentId})};async function qo(e){let t=V(e.repoRoot);if(l(t))return t;let s=F();if(l(s))return s;let o=H({repoRoot:t.value});if(l(o))return o;let n=oe(o.value);if(l(n))return n;let a=ie(n.value.events,n.value.unreadable);if(l(a))return a;let r=he(e);if(l(r))return r;let i=u=>Xo(u,e,s.value,o.value);return e.issueIds?le("Moved",be(r.value,i)):i(r.value[0])}var Yo=e=>{let t=C();if(l(t))return t;let s=t.value.nodes[e];return s?m("Read issue history",(s.log??[]).map(o=>({id:o.id,t:O(o.id),action:o.action,label:cs(o),...o.action==="move.node"?{parentId:o.payload.parent}:{},actor:P(o.userId,t.value.contributors[o.userId]?.name)}))):d("Issue not found")},Vo=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;let o=s.value,n=N("Issue description",e.description,2e4);if(n)return d(n);let a=o.props.description??"";if(a===e.description)return m("No changes made",{id:e.issueId,ref:T(e.issueId),description:a});let r={id:_(),...R(t.value.actor),action:"edit.description",payload:{id:e.issueId,md:e.description}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):m("Edited issue description",{id:e.issueId,ref:T(e.issueId),description:e.description})},Jo=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;let o=s.value,n=w(e.title);if(!n.trim())return d("Issue title cannot be empty");let a=N("Issue title",n,300);if(a)return d(a);if(o.title===n)return m("No changes made",{id:e.issueId,ref:T(e.issueId),title:n});let r={id:_(),...R(t.value.actor),action:"edit.title",payload:{id:e.issueId,name:n}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):m("Edited issue title",{id:e.issueId,ref:T(e.issueId),title:n})};import{ulid as K}from"ulid";var Qo=async(e={})=>{let t=await k(e.repoRoot);if(l(t))return t;let s=C();if(l(s))return s;let o=Object.values(s.value.nodes).filter(n=>n.context==="BOARD"&&!n.isDeleted).map(n=>({id:n.id,ref:T(n.id),title:n.title,parentId:n.parentNodeId,readonly:!!n.readonly}));return m("Listed boards",o)},Zo=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.nodes[t.value.state.rootNodeId];if(!s)return d("Workspace not found");if(j().mode!=="live")return d("Cannot add a board while time travelling");let o=w(e.title);if(!o.trim())return d("Board title cannot be empty");let n=N("Board title",o,300);if(n)return d(n);let a=fe(s.id,t.value.actor,t.value.boot.stateBranchRoot);if(l(a))return a;let r=K(),i={id:K(),...R(t.value.actor),action:"add.board",payload:{id:r,name:o,parent:s.id,rank:a.value}},u=S([i],t.value.boot.stateBranchRoot);return l(u)?d(u.message):m("Created board",{id:r,ref:T(r),title:o})},en=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.nodes[e.boardId];if(!s||s.isDeleted)return d("Board not found");if(!se(s))return d("Edit target must be a board");if(s.readonly)return d("Cannot edit readonly board");if(j().mode!=="live")return d("Cannot rename a board while time travelling");let o=w(e.title);if(!o.trim())return d("Board title cannot be empty");let n=N("Board title",o,300);if(n)return d(n);if(s.title===o)return m("No changes made",{id:e.boardId,ref:T(e.boardId),title:o});let a={id:K(),...R(t.value.actor),action:"edit.title",payload:{id:e.boardId,name:o}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):m("Edited board title",{id:e.boardId,ref:T(e.boardId),title:o})},tn=async(e={})=>{let t=await k(e.repoRoot);if(l(t))return t;let s=C();if(l(s))return s;let o=Object.values(s.value.nodes).filter(n=>n.context==="SWIMLANE"&&!n.isDeleted).filter(n=>!e.boardId||n.parentNodeId===e.boardId).map(n=>({id:n.id,title:n.title,boardId:n.parentNodeId,isClosed:n.id===x,readonly:!!n.readonly}));return m("Listed swimlanes",o)},sn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=et(e.boardId);if(l(s))return s;if(j().mode!=="live")return d("Cannot add a swimlane while time travelling");let o=w(e.title);if(!o.trim())return d("Swimlane title cannot be empty");let n=N("Swimlane title",o,300);if(n)return d(n);let a=fe(e.boardId,t.value.actor,t.value.boot.stateBranchRoot);if(l(a))return a;let r=K(),i={id:K(),...R(t.value.actor),action:"add.swimlane",payload:{id:r,name:o,parent:e.boardId,rank:a.value}},u=S([i],t.value.boot.stateBranchRoot);return l(u)?d(u.message):m("Created swimlane",{id:r,ref:T(r),title:o,boardId:e.boardId})},on=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=z(e.swimlaneId);if(l(s))return s;let o=s.value,n=w(e.title);if(!n.trim())return d("Swimlane title cannot be empty");let a=N("Swimlane title",n,300);if(a)return d(a);if(o.title===n)return m("No changes made",{id:e.swimlaneId,ref:T(e.swimlaneId),title:n});let r={id:K(),...R(t.value.actor),action:"edit.title",payload:{id:e.swimlaneId,name:n}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):m("Edited swimlane title",{id:e.swimlaneId,ref:T(e.swimlaneId),title:n})},nn=async e=>{let t=V(e.repoRoot);if(l(t))return t;let s=F();if(l(s))return s;let o=H({repoRoot:t.value});if(l(o))return o;let n=oe(o.value);if(l(n))return n;let a=ie(n.value.events,n.value.unreadable);if(l(a))return a;let r=z(e.swimlaneId);if(l(r))return r;let i=et(e.boardId);if(l(i))return i;let u=re(e.boardId,e.swimlaneId,e.position??{at:"end"},s.value,o.value);if(l(u))return u;let g={id:K(),...R(s.value),action:"move.node",payload:{id:e.swimlaneId,parent:e.boardId,rank:u.value}},p=S([g],o.value);return l(p)?d(p.message):m("Moved swimlane",{id:e.swimlaneId,ref:T(e.swimlaneId),boardId:e.boardId})},rn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=z(e.swimlaneId);if(l(s))return s;let o={id:K(),...R(t.value.actor),action:"delete.node",payload:{id:e.swimlaneId}},n=S([o],t.value.boot.stateBranchRoot);return l(n)?d(n.message):m("Deleted swimlane",{id:e.swimlaneId,ref:T(e.swimlaneId)})};import{ulid as de}from"ulid";async function an(e){let t=await k(e.repoRoot);if(l(t))return t;let s=F();if(l(s))return s;let o=he(e);if(l(o))return o;let n=w(e.tagName).trim();if(!n)return d("Tag name cannot be empty");let a=N("Tag name",n,60);if(a)return d(a);let r=be(o.value,L);if(!e.issueIds&&r.failed[0])return d(r.failed[0].reason);if(r.done.length===0)return d(le("Tagged",r).message);let i=M.findTagByName(n),u=i?.id??de(),g=[...i?[]:[{id:de(),...R(s.value),action:"create.tag",payload:{id:u,name:n}}],...r.done.map(({id:v})=>({id:de(),...R(s.value),action:"add.issue.tag",payload:{id:v,tag:u}}))],p=S(g,t.value.stateBranchRoot);if(l(p))return d(p.message);let c={id:u,name:n};if(!e.issueIds)return m("Added issue tag",{...r.done[0],tag:c});let I=le("Tagged",r);return l(I)?I:m(I.message,{...I.value,tag:c})}var ln=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.tags[e.tagId];if(!s)return d("Tag not found");if(s.tombstoned)return d("Tag is already deleted");let o=[{id:de(),...R(t.value.actor),action:"tombstone.tag",payload:{id:e.tagId}}],n=S(o,t.value.boot.stateBranchRoot);return l(n)?d(n.message):m("Deleted tag",{id:s.id,name:s.name})},dn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.tags[e.tagId];if(!s)return d("Tag not found");if(!s.tombstoned)return d("Tag is not deleted");if(M.findTagByName(s.name))return d(`Cannot restore: another tag is already named "${s.name}"`);let o=[{id:de(),...R(t.value.actor),action:"restore.tag",payload:{id:e.tagId,name:s.name}}],n=S(o,t.value.boot.stateBranchRoot);return l(n)?d(n.message):m("Restored tag",{id:s.id,name:s.name})},un=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;if(!t.value.state.tags[e.tagId])return d("Tag not found");let o={id:de(),...R(t.value.actor),action:"remove.issue.tag",payload:{id:e.issueId,tag:e.tagId}},n=S([o],t.value.boot.stateBranchRoot);return l(n)?d(n.message):m("Removed issue tag",{id:e.issueId,ref:T(e.issueId),tagId:e.tagId})};import{ulid as U}from"ulid";var cn=async e=>{let t=ct(e.name,"name");if(l(t))return d(t.message);let s=await A(e.repoRoot);if(l(s))return s;let o=s.value.actor,n=!!s.value.state.contributors[o.userId];if(!n){let a=S([{id:U(),...R(o),action:"create.contributor",payload:{id:o.userId,name:o.userName}}],s.value.boot.stateBranchRoot);if(l(a))return d(a.message)}return m(`Assumed ${o.userName}`,{...o,registered:!n})},Ns=async(e,t)=>{let s=ne(e).get(t);return s===void 0?void 0:{id:t,name:s}},mn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;let o=e.self?t.value.actor.userId:e.assigneeId;if(o){let v=t.value.state.contributors[o],h=v?void 0:await Ns(t.value.boot.stateBranchRoot,o);if(!v&&!h)return d("Unknown assignee id");let f=v??h,b=[...v?[]:[{id:U(),...R(t.value.actor),action:"create.contributor",payload:{id:f.id,name:f.name}}],{id:U(),...R(t.value.actor),action:"add.issue.assignee",payload:{id:e.issueId,assignee:f.id}}],E=S(b,t.value.boot.stateBranchRoot);return l(E)?d(E.message):m("Added issue assignee",{id:e.issueId,ref:T(e.issueId),assignee:{id:f.id,name:f.name}})}let n=w(e.assigneeName??"").trim();if(!n)return d("Provide assigneeId, self or assigneeName");let a=N("Assignee name",n,80);if(a)return d(a);let r=Ye({events:t.value.state.eventLog??[],registry:t.value.state.contributors,logFileNames:ne(t.value.boot.stateBranchRoot)}).filter(v=>v.name===n);if(r.length>1)return d(`"${n}" matches ${r.length} contributors (${r.map(({id:v})=>v).join(", ")}). Assign by assigneeId to choose.`);let i=r[0];if(!i&&!e.createUnlinked)return d(`No contributor named "${n}". Assign by id, or pass createUnlinked to add them as an external assignee.`);let u=i?.id??U(),g=i?.name??n,c=[...!!t.value.state.contributors[u]?[]:[{id:U(),...R(t.value.actor),action:"create.contributor",payload:{id:u,name:g}}],{id:U(),...R(t.value.actor),action:"add.issue.assignee",payload:{id:e.issueId,assignee:u}}],I=S(c,t.value.boot.stateBranchRoot);return l(I)?d(I.message):m("Added issue assignee",{id:e.issueId,ref:T(e.issueId),assignee:{id:u,name:g}})},pn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;if(!t.value.state.contributors[e.contributorId])return d("Contributor not found");if(await Ns(t.value.boot.stateBranchRoot,e.contributorId))return d("Cannot remove a contributor who has authored events \u2014 their name appears throughout the log");let n=[{id:U(),...R(t.value.actor),action:"tombstone.contributor",payload:{id:e.contributorId}}],a=S(n,t.value.boot.stateBranchRoot);return l(a)?d(a.message):m("Tombstoned contributor",{id:e.contributorId,name:xe})},fn=async(e,t)=>{let s=Y(e);if(l(s))return;let o;for(let n of s.value){if(n.action!=="create.contributor")continue;let a=n.payload;a.id===t&&a.name&&(o=a.name)}return o},gn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.contributors[e.contributorId];if(!s)return d("Contributor not found");if(!s.tombstoned)return d("Contributor is not tombstoned");let o=await fn(t.value.boot.stateBranchRoot,e.contributorId);if(!o)return d("Cannot restore this contributor \u2014 no original name found in the event log");let n=[{id:U(),...R(t.value.actor),action:"restore.contributor",payload:{id:e.contributorId,name:o}}],a=S(n,t.value.boot.stateBranchRoot);return l(a)?d(a.message):m("Restored contributor",{id:e.contributorId,name:o})},In=async(e={})=>{let t=await A(e.repoRoot);if(l(t))return t;let s=Y(t.value.boot.stateBranchRoot);if(l(s))return d(s.message);let o=e.boardId?Is(s.value,e.boardId):s.value,n=new Set,a=Gt(t.value.boot.stateBranchRoot);if(l(a))return d(a.message);for(let u of a.value)u.userId&&n.add(u.userId);let r=t.value.state.contributors,i=Ye({events:o,registry:r,logFileNames:ne(t.value.boot.stateBranchRoot)}).map(({id:u,name:g,isExternal:p})=>({...P(u,g),isSelf:u===t.value.actor.userId,isExternal:p,isRemoved:r[u]?.tombstoned===!0,hasAuthoredAnywhere:n.has(u)}));return m("Listed board contributors",i)},vn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;if(!t.value.state.contributors[e.assigneeId])return d("Assignee not found");let o={id:U(),...R(t.value.actor),action:"remove.issue.assignee",payload:{id:e.issueId,assignee:e.assigneeId}},n=S([o],t.value.boot.stateBranchRoot);return l(n)?d(n.message):m("Removed issue assignee",{id:e.issueId,ref:T(e.issueId),assigneeId:e.assigneeId})};import{ulid as $e}from"ulid";var hn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=L(e.issueId);if(l(s))return s;let o=e.body.trim();if(!o)return d("Comment cannot be empty");if(o.length>4e3)return d(`Comment cannot exceed ${4e3} characters (got ${o.length})`);let n=$e(),a={id:$e(),...R(t.value.actor),action:"add.issue.comment",payload:{id:n,issue:e.issueId,md:o,author:t.value.actor.userId}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):m("Added issue comment",{id:n,issueId:e.issueId,body:o})},bn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.eventLog.find(i=>i.action==="add.issue.comment"&&i.payload.id===e.commentId);if(!s)return d("Unable to resolve comment");if(s.payload.author!==t.value.actor.userId)return d("You can only delete your own comments");let o=L(s.payload.issue);if(l(o))return o;if(t.value.state.eventLog.some(i=>i.action==="delete.issue.comment"&&i.payload.id===e.commentId))return m("Comment already deleted",{id:e.commentId,issueId:s.payload.issue});let a={id:$e(),...R(t.value.actor),action:"delete.issue.comment",payload:{id:e.commentId,issue:s.payload.issue}},r=S([a],t.value.boot.stateBranchRoot);return l(r)?d(r.message):m("Deleted issue comment",{id:e.commentId,issueId:s.payload.issue})},yn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=t.value.state.eventLog.find(u=>u.action==="add.issue.comment"&&u.payload.id===e.commentId);if(!s)return d("Unable to resolve comment");if(s.payload.author!==t.value.actor.userId)return d("You can only edit your own comments");let o=L(s.payload.issue);if(l(o))return o;if(t.value.state.eventLog.some(u=>u.action==="delete.issue.comment"&&u.payload.id===e.commentId))return d("Comment was deleted");let a=e.body.trim();if(!a)return d("Comment cannot be empty");if(a.length>4e3)return d(`Comment cannot exceed ${4e3} characters (got ${a.length})`);let r={id:$e(),...R(t.value.actor),action:"edit.issue.comment",payload:{id:e.commentId,issue:s.payload.issue,md:a}},i=S([r],t.value.boot.stateBranchRoot);return l(i)?d(i.message):m("Edited issue comment",{id:e.commentId,issueId:s.payload.issue,body:a})};import{ulid as Os}from"ulid";var Rn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;if(!St(e.email))return d(`Not an email address: ${e.email}`);let s=me(e.email),o=e.contributorId??t.value.actor.userId;if(!t.value.state.contributors[o])return d(`Unknown contributor: ${o}`);let n=He(t.value.state.emailLinks,s);if(n.includes(o))return m(`${s} is already yours`,{contributor:o,email:s,contested:n.filter(r=>r!==o)});let a=S([{id:Os(),action:"link.contributor.email",payload:{contributor:o,email:s},userId:t.value.actor.userId}],t.value.boot.stateBranchRoot);return l(a)?d(a.message):m(n.length>0?`Claimed ${s}, but somebody else claims it too, so it now resolves to neither of you`:`Claimed ${s}`,{contributor:o,email:s,contested:n})},An=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let s=me(e.email),o=e.contributorId??t.value.actor.userId,n=t.value.state.emailLinks[wt(s,o)];if(!n||n.tombstoned)return d(`No such link: ${s} to ${o}`);if(!Lt(t.value.actor.userId,n))return d("Only whoever made a claim, or the contributor it names, may undo it");let a=S([{id:Os(),action:"unlink.contributor.email",payload:{contributor:o,email:s},userId:t.value.actor.userId}],t.value.boot.stateBranchRoot);return l(a)?d(a.message):m(`Unclaimed ${s}`,{contributor:o,email:s})},Tn=async(e={})=>{let t=await k(e.repoRoot);if(l(t))return t;let s=C();if(l(s))return s;let{emailLinks:o,contributors:n}=s.value,a=new Map;for(let c of Object.values(o)){if(c.tombstoned)continue;let I=a.get(c.email)??new Set;I.add(c.contributor),a.set(c.email,I)}let r=[...a.entries()].map(([c,I])=>({email:c,contested:I.size>1,claimants:[...I].map(v=>P(v,n[v]?.name))})).sort((c,I)=>c.email.localeCompare(I.email)),i=F(),u=l(i)?[]:xt(o,i.value.userId),g=ft().gitEmail,p=g?He(o,g).filter(c=>l(i)||c!==i.value.userId):[];return m("Listed contributor emails",{emails:r,mine:u,git:g?{email:g,linkedToMe:u.includes(g),heldByOthers:p.map(c=>P(c,n[c]?.name))}:null})},En=async(e={})=>{let t=await A(e.repoRoot);if(l(t))return t;let{userId:s,userName:o}=t.value.actor,n=te(t.value.boot.repoRoot),a=await ke({repoRoot:t.value.boot.repoRoot,stateBranch:l(n)?void 0:n.value,names:[o,await ae(t.value.boot.repoRoot)],links:t.value.state.emailLinks});if(l(a))return a;let r=ls(a.value),i=r.filter(u=>u.looksLikeYours);return m(r.length===0?"No unclaimed addresses in this history":`${r.length} unclaimed address(es) in this history, ${i.length>0?`${i.length} of which look like yours`:"none obviously yours"}. Show them to the user and link only the ones they confirm; each is a permanent event that replicates to every clone.`,{contributor:s,candidates:r,likely:i.length})};var rt=e=>{let t=Kt(e);return l(t)?d(t.message):m("Listed repos",{repos:t.value,claimedBytes:Jt(e),limit:vt,allowLocal:It()})},Sn=async(e={})=>{let t=pe(e.repoRoot);return l(t)?d(t.message):rt(t.value)},wn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let{repoRoot:s}=t.value.boot,o=await Qt({repoRoot:s,actorId:t.value.actor.userId,url:e.url,branches:e.branches,since:e.since,label:e.label,mode:e.previewOnly?"preview":e.confirm?"confirm":"auto"});if(l(o))return d(o.message);let n=rt(s);return l(n)?d(n.message):m(o.message,{...n.value,...o.value.kind==="preview"?{preview:o.value.preview}:{}})},xn=async e=>{let t=await A(e.repoRoot);if(l(t))return t;let{repoRoot:s}=t.value.boot,o=Xt({repoRoot:s,actorId:t.value.actor.userId,repo:e.repo});if(l(o))return d(o.message);let n=rt(s);return l(n)?d(n.message):m(o.message,n.value)},Cn=e=>(Vt("repo"in e?e.repo:ht(e.url.trim())),m("Cancelled",null)),Ln=async(e,t={},s=2e4)=>{if(l(e))return e;let o,n=await Promise.race([Ms(t),new Promise(a=>{o=setTimeout(()=>a(null),s)})]);return clearTimeout(o),n===null?m(`${e.message} \xB7 still fetching other repos; epiq_repo_list shows how they stand`,e.value):l(n)||n.value.length===0?e:m([e.message,Yt(n.value)].filter(Boolean).join(" \xB7 "),{...e.value,repos:n.value})},Ms=async(e={})=>{let t=pe(e.repoRoot);return l(t)?d(t.message):qt({repoRoot:t.value,minIntervalMs:e.minIntervalMs})};var Fs=(e,t)=>{let s=0,o=0,n=null;for(let a of e){if(a.userId!==t)continue;a.action==="add.issue"&&s++,a.action==="add.issue.comment"&&o++;let r=Tt(a.id);if(l(r))continue;let i=r.value.getTime();(n===null||i<n)&&(n=i)}return{tickets:s,comments:o,joinedAt:n}};var Bn=async(e={})=>{let t=await A(e.repoRoot);if(l(t))return t;let{userId:s,userName:o}=t.value.actor,n=Fs(t.value.state.eventLog,s),a=te(t.value.boot.repoRoot),r=await ke({repoRoot:t.value.boot.repoRoot,stateBranch:l(a)?void 0:a.value,names:[o,await ae(t.value.boot.repoRoot)],links:t.value.state.emailLinks}),i=l(r)?[]:r.value.filter(u=>u.claimedBy.length===1&&u.claimedBy[0]===s);return m("Derived personal stats",{...n,scanned:!l(r),commits:i.reduce((u,g)=>u+g.commits,0),claimedEmails:i.length})};var W=e=>({path:e.path,sha:e.shas[e.shas.length-1]??""});var kn=e=>{let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)},_s=({commits:e,patch:t})=>{let s=e.map(r=>r.time),n=t.files.map(r=>({...W(r),changed:r.addedCount+r.removed})).reduce((r,i)=>r===null||i.changed>r.changed?i:r,null),a=t.insertions+t.deletions;return{commits:e.length,authors:[...new Set(e.map(r=>r.author))].sort(),firstCommitAt:s.length?Math.min(...s):null,lastCommitAt:s.length?Math.max(...s):null,files:t.files.length,filesAdded:t.files.filter(r=>r.status==="added").length,filesModified:t.files.filter(r=>r.status==="modified").length,filesDeleted:t.files.filter(r=>r.status==="deleted").length,binaryFiles:t.files.filter(r=>r.binary).length,directories:new Set(t.files.map(r=>kn(r.path))).size,insertions:t.insertions,deletions:t.deletions,net:t.insertions-t.deletions,largestFile:n,concentration:n&&a>0?n.changed/a:0,selfChurn:t.selfChurn,truncated:t.truncated}};var B={line:["//"],block:[["/*","*/"]]},D={line:["#"],block:[]},it={line:["--"],block:[]},ue={line:[],block:[["<!--","-->"]]},Pn={line:[],block:[]},y=(e,t)=>({name:e,comment:t}),Ge=y("TypeScript",B),We=y("JavaScript",B),Ds={ts:Ge,tsx:Ge,mts:Ge,cts:Ge,js:We,jsx:We,mjs:We,cjs:We,py:y("Python",{line:["#"],block:[['"""','"""']]}),rb:y("Ruby",{line:["#"],block:[["=begin","=end"]]}),go:y("Go",B),rs:y("Rust",B),java:y("Java",B),kt:y("Kotlin",B),swift:y("Swift",B),c:y("C",B),h:y("C",B),cc:y("C++",B),cpp:y("C++",B),hpp:y("C++",B),cs:y("C#",B),php:y("PHP",B),scala:y("Scala",B),dart:y("Dart",B),lua:y("Lua",it),hs:y("Haskell",it),sql:y("SQL",it),ex:y("Elixir",D),exs:y("Elixir",D),pl:y("Perl",D),r:y("R",D),jl:y("Julia",D),sh:y("Shell",D),bash:y("Shell",D),zsh:y("Shell",D),vue:y("Vue",ue),svelte:y("Svelte",ue),html:y("HTML",ue),xml:y("XML",ue),md:y("Markdown",ue),mdx:y("Markdown",ue),css:y("CSS",{line:[],block:[["/*","*/"]]}),scss:y("CSS",B),less:y("CSS",B),yml:y("YAML",D),yaml:y("YAML",D),toml:y("TOML",D),ini:y("INI",D),json:y("JSON",Pn)},Nn="Other",$s=e=>{let t=e.slice(e.lastIndexOf("/")+1),s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},ee=e=>Ds[$s(e)]?.name??Nn,ye=e=>Ds[$s(e)]?.comment??null,On=[/\.(test|spec)\.[a-z0-9]+$/i,/(^|\/)test_[^/]+\.py$/,/_test\.[a-z0-9]+$/i,/(^|\/)conftest\.py$/,/Tests?\.(java|kt|cs|scala)$/],Mn=/(^|\/)(tests?|__tests__|spec|specs|e2e|src\/test|features)\//i,ce=e=>Mn.test(e)||On.some(t=>t.test(e)),Fn=/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|Cargo\.lock|go\.sum|poetry\.lock|Gemfile\.lock|composer\.lock)$/,_n=/(^|\/)(node_modules|dist|build|out|target|vendor|coverage|\.next|__snapshots__)\//,Dn=/(\.min\.(js|css)|\.map|\.snap|\.pb\.go|_pb2\.py)$/,G=e=>Fn.test(e)||_n.test(e)||Dn.test(e),Gs=e=>/(^|\/)(package\.json|go\.mod|Cargo\.toml|requirements[^/]*\.txt|pyproject\.toml|Gemfile|composer\.json|pom\.xml|build\.gradle(\.kts)?)$/.test(e),Ws=e=>/(^|\/)\.github\/workflows\//.test(e)||/(^|\/)(Dockerfile|docker-compose[^/]*\.ya?ml|Makefile|Jenkinsfile|\.gitlab-ci\.yml)$/.test(e)||/\.tf$/.test(e),js=e=>/\.(md|mdx|rst|txt)$/i.test(e)||/(^|\/)docs?\//i.test(e),$n=/\b(it|test|describe|context|suite)\.skip\b|\bx(it|describe|test)\s*\(|@pytest\.mark\.skip|@unittest\.skip|\bt\.Skip\s*\(|@(Ignore|Disabled)\b/,Gn=/\b(it|test|describe|context|suite)\.only\b|\bf(it|describe|test)\s*\(/,Us=e=>$n.test(e),Hs=e=>Gn.test(e);var zs=/\b(TODO|FIXME|HACK|XXX)\b/,Wn=/[;{}]\s*$|^\s*(const|let|var|function|def|class|if|for|while|return|import|export|await|print)\b.*[=(]/,at=(e,t)=>{let s=e.trim();return s===""?"blank":t&&(t.line.some(o=>s.startsWith(o))||t.block.some(([o])=>s.startsWith(o))||t.block.some(([o])=>o==="/*")&&(s.startsWith("*")||s.startsWith("*/")))?"comment":"code"},jn=(e,t)=>{let s=e.trim();for(let o of[...t.line,...t.block.flat(),"*"])if(s.startsWith(o)){s=s.slice(o.length).trim();break}return s},Ks=({patch:e,repoShareByLanguage:t})=>{let s=new Map,o=0,n=0,a=0,r=0,i=0,u=0;for(let p of e.files){if(p.binary||G(p.path))continue;let c=ye(p.path);if(!c||c.line.length===0&&c.block.length===0)continue;let I=ee(p.path),v=s.get(I)??{comment:0,code:0};for(let{text:h}of p.added){let f=at(h,c);if(zs.test(h)&&r++,f==="blank"){a++;continue}if(f==="comment"){o++,v.comment++,c&&Wn.test(jn(h,c))&&u++;continue}n++,v.code++}for(let{text:h}of p.removedLines)zs.test(h)&&i++;s.set(I,v)}let g=o+n;return{byLanguage:[...s.entries()].map(([p,c])=>({name:p,commentLines:c.comment,codeLines:c.code,share:c.comment+c.code===0?0:c.comment/(c.comment+c.code),repoShare:t?.get(p)??null})).sort((p,c)=>c.commentLines+c.codeLines-(p.commentLines+p.codeLines)),commentLines:o,codeLines:n,blankLines:a,share:g===0?0:o/g,todoLinesAdded:r,todoLinesRemoved:i,commentedOutCodeLines:u}};var Un=/\bconsole\.(log|debug|dir)\s*\(|\bdebugger\b|^\s*print\s*\(|\bfmt\.Print(ln|f)?\s*\(|\bSystem\.out\.print|\bdbg!\s*\(/,je=6,lt=10,Hn=e=>{let t=0;for(let s of e){if(s.trim()===""||s.startsWith(" "))continue;let o=s.length-s.trimStart().length;o>0&&(t===0||o<t)&&(t=o)}return Math.min(Math.max(t,2),8)},zn=(e,t)=>{let s=e.length-e.trimStart().length;if(s===0)return 0;let o=e.slice(0,s).split(" ").length-1;return o>0?o:Math.floor(s/t)},Kn=e=>{if(e.length<je*2)return 0;let t=new Map,s=new Array(e.length).fill(!1);for(let o=0;o+je<=e.length;o++){let n=e.slice(o,o+je);if(n.some(i=>i.text.length<3))continue;let a=n.map(i=>i.text).join(`
|
|
5
|
-
`),r=t.get(a);if(r===void 0){t.set(a,{...n[0],at:o});continue}if(r.file!==n[0]?.file)for(let i=0;i<je;i++)s[r.at+i]=!0,s[o+i]=!0}return s.filter(Boolean).length},Xs=({patch:e})=>{let t=[],s=[],o=[],n=!1,a=0,r=0,i=null,u=[];for(let[g,p]of e.files.entries()){if(G(p.path)&&t.push(W(p)),Gs(p.path)&&s.push(W(p)),Ws(p.path)&&o.push(W(p)),js(p.path)&&(n=!0),p.binary||G(p.path))continue;let c=p.added.map(h=>h.text),I=Hn(c),v=p.status!=="deleted";for(let h of c){Un.test(h)&&a++;let f=zn(h,I);f>r&&(r=f,i=W(p)),v&&u.push({text:h.trim(),file:g})}u.push({text:" ",file:g})}return{generatedPaths:t.slice(0,lt),dependencyManifests:s.slice(0,lt),buildOrCiPaths:o.slice(0,lt),docsTouched:n,debugPrintLinesAdded:a,maxIndentLevels:r,deepestFile:i,duplicatedLines:Kn(u)}};var qs=({patch:e,languagesBefore:t})=>{let s=new Map,o=0;for(let r of e.files){if(r.binary)continue;let i=r.addedCount+r.removed;if(G(r.path)){o+=i;continue}let u=ee(r.path),g=s.get(u)??{name:u,added:0,removed:0,addedInTests:0,share:0};g.added+=r.addedCount,g.removed+=r.removed,ce(r.path)&&(g.addedInTests+=r.addedCount),s.set(u,g)}let n=[...s.values()].reduce((r,i)=>r+i.added+i.removed,0),a=[...s.values()].map(r=>({...r,share:n===0?0:(r.added+r.removed)/n})).sort((r,i)=>i.added+i.removed-(r.added+r.removed));return{languages:a,introduced:t===null?[]:a.filter(r=>!t.has(r.name)).map(r=>r.name),generatedLines:o}};var Xn=200,dt=2e5,qn=5e4,Yn=25,Ys=64*1024*1024,ut="",Vn=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/,Jn=/^diff --git a\/(.+) b\/\1$/,Vs=(e,t)=>e==="/dev/null"?null:e.startsWith(t)?e.slice(2):e,Js=(e,t)=>e===null?"added":t===null?"deleted":"modified",Qn=()=>({byPath:new Map,insertions:0,deletions:0,selfChurn:0,retainedLines:0}),Zn=(e,t)=>{let s=e.byPath,o="",n=null,a=null,r=null,i=!1,u=0,g=(c,I)=>I==="modified"&&c==="added"?"added":I,p=(c,I)=>{let v=s.get(c);if(v)return v.entry.status=g(v.entry.status,I),v.entry.shas.includes(o)||v.entry.shas.push(o),v;let f={entry:{path:c,status:I,binary:!1,added:[],addedCount:0,removed:0,removedLines:[],shas:[o]},pendingByText:new Map};return s.set(c,f),f};for(let c of t.split(`
|
|
6
|
-
`)){if(c.startsWith(ut)){o=c.slice(ut.length).trim(),n=null,a=null,r=null,i=!1;continue}if(c.startsWith("diff --git ")){n=null,r=null,i=!0,a=Jn.exec(c)?.[1]??null;continue}if(i&&c.startsWith("Binary files ")&&a){let[,v=""]=/^Binary files (.*) differ$/.exec(c)??[],[h="",f=""]=v.split(" and ");n=p(a,Js(h==="/dev/null"?null:h,f==="/dev/null"?null:f)),n.entry.binary=!0;continue}if(i&&c.startsWith("--- ")){r=Vs(c.slice(4),"a/");continue}if(i&&c.startsWith("+++ ")){let v=Vs(c.slice(4),"b/"),h=v??r??a;h&&(n=p(h,Js(r,v)));continue}let I=Vn.exec(c);if(I){u=Number(I[1]),i=!1;continue}if(n){if(c.startsWith("+")){let v=c.slice(1);e.insertions++,n.entry.addedCount++,e.retainedLines<dt&&(n.entry.added.push({sha:o,line:u,text:v}),e.retainedLines++),n.pendingByText.size<qn&&n.pendingByText.set(v,(n.pendingByText.get(v)??0)+1),u++;continue}if(c.startsWith("-")){let v=c.slice(1);e.deletions++,n.entry.removed++,e.retainedLines<dt&&(n.entry.removedLines.push({sha:o,line:0,text:v}),e.retainedLines++);let h=n.pendingByText.get(v)??0;h>0&&v.trim().length>2&&(e.selfChurn++,n.pendingByText.set(v,h-1))}}}},er=e=>({files:[...e.byPath.values()].map(t=>t.entry),insertions:e.insertions,deletions:e.deletions,selfChurn:e.selfChurn,retainedLines:e.retainedLines});var Qs=async({repoRoot:e,shas:t,cwdOf:s=()=>e})=>{if(t.length===0)return m("No commits to scan",{files:[],insertions:0,deletions:0,selfChurn:0,scannedCommits:0,truncated:!1});let o=t.slice(0,Xn).reverse(),n=Qn(),a=0,r=0,i=!1,u=[];for(let p of o){let c=s(p),I=u[u.length-1];I&&I.cwd===c&&I.shas.length<Yn?I.shas.push(p):u.push({cwd:c,shas:[p]})}for(let{cwd:p,shas:c}of u){let I=await Te({cwd:p,maxOutput:Math.max(1,Ys-a),keepPartial:!0,args:["-c","core.quotePath=false","show","--unified=0","--no-renames","--no-color",`--format=${ut}%H`,...c]});if(l(I)){if(p!==e)continue;return d(I.message)}if(Zn(n,I.value.stdout),a+=I.value.stdout.length,r+=c.length,I.value.truncated||a>Ys){i=!0;break}}let g=er(n);return m("Scanned ticket patch",{files:g.files,insertions:g.insertions,deletions:g.deletions,selfChurn:g.selfChurn,scannedCommits:r,truncated:i||r<t.length||g.retainedLines>=dt})};var tr=40,sr=/^\d{6} blob ([0-9a-f]{40})\t(.+)$/,Zs=async({repoRoot:e,sha:t})=>{let s=await Ee({cwd:e,args:["-c","core.quotePath=false","ls-tree","-r",`${t}~1`]});if(s.exitCode!==0)return null;let o=new Set,n=new Map;for(let p of s.stdout.split(`
|
|
7
|
-
`)){let c=sr.exec(p);if(!c)continue;let[,I="",v=""]=c;if(G(v))continue;let h=ee(v);if(o.add(h),ce(v)||!ye(v))continue;let f=n.get(h)??[];f.length<tr&&(f.push({blob:I,path:v}),n.set(h,f))}let a=[...n.values()].flat(),r=await mt(a.map(p=>p.blob),e);if(l(r))return{languages:o,commentShareByLanguage:new Map};let i=r.value,u=new Map;for(let{blob:p,path:c}of a){let I=i.get(p);if(I===void 0)continue;let v=ye(c),h=ee(c),f=u.get(h)??{comment:0,code:0};for(let b of I.split(`
|
|
8
|
-
`)){let E=at(b,v);E==="comment"&&f.comment++,E==="code"&&f.code++}u.set(h,f)}let g=new Map;for(let[p,c]of u){let I=c.comment+c.code;I>0&&g.set(p,c.comment/I)}return{languages:o,commentShareByLanguage:g}};var eo=({patch:e})=>{let t=0,s=0,o=[],n=[],a=0,r=0;for(let i of e.files)if(!(i.binary||G(i.path))&&ce(i.path)){t+=i.addedCount,s+=i.removed,i.status==="added"&&o.push(W(i)),i.status==="deleted"&&n.push(W(i));for(let{text:u}of i.added)Us(u)&&a++,Hs(u)&&r++}return{testLinesAdded:t,testLinesRemoved:s,addedTestFiles:o,deletedTestFiles:n,skippedTestLinesAdded:a,focusedTestLinesAdded:r}};var or=e=>e.reduce((t,s)=>t===null||s.time<t.time?s:t,null),to=async({repoRoot:e,ref:t,commits:s})=>{let o=await Ut(e);if(l(o))return d(o.message);let n=Ht(o.value),a=new Map(s.map(c=>[c.sha,c.repo])),r=c=>n(a.get(c))??e,i=await Qs({repoRoot:e,shas:s.map(c=>c.sha),cwdOf:r});if(l(i))return d(i.message);let u=i.value,g=or(s),p=g?await Zs({repoRoot:r(g.sha),sha:g.sha}):null;return m("Derived issue stats",{ref:t,shape:_s({commits:s,patch:u}),languages:qs({patch:u,languagesBefore:p?.languages??null}),tests:eo({patch:u}),comments:Ks({patch:u,repoShareByLanguage:p?.commentShareByLanguage??null}),flags:Xs({patch:u})})};var so=e=>{if(l(e))return e;let t=Pe(),s=l(t)?{}:t.value.emailLinks,o=l(t)?{}:t.value.contributors,n=Ct(s),a=e.value.map(r=>({...r,authorIdentity:as({authorName:r.author,authorEmail:r.authorEmail,owners:n,registry:o})}));return m(e.message,a)};var rr=32,Re=new Map;var ir=(e,t)=>{if(Re.set(e,t),Re.size>rr){let s=Re.keys().next();s.done||Re.delete(s.value)}return t},ju=async(e={idOrRef:""})=>{let t=e.idOrRef.trim();if(!t)return d("idOrRef must not be empty");let s=t.length>7?T(t):t.toUpperCase(),o=Se(e.repoRoot??process.cwd());if(l(o))return d(o.message);let n=o.value,a=so(await zt({repoRoot:n,ref:s}));if(l(a))return d(a.message);let r=a.value.map(p=>({sha:p.sha,...p.repo?{repo:p.repo}:{},time:p.time,author:p.authorIdentity?.resolved?p.authorIdentity.name:p.author,subject:p.subject})),i=[n,s,r.map(p=>`${p.sha}:${p.author}`).join(",")].join(" "),u=Re.get(i);if(u)return m("Derived issue stats",u);let g=await to({repoRoot:n,ref:s,commits:r});return l(g)?d(g.message):m("Derived issue stats",ir(i,g.value))};export{No as a,As as b,j as c,Nr as d,Ao as e,Or as f,Mr as g,ws as h,ae as i,C as j,Lo as k,Bo as l,ko as m,Mo as n,_o as o,st as p,$o as q,Go as r,Wo as s,jo as t,Uo as u,zo as v,Ko as w,qo as x,Yo as y,Vo as z,Jo as A,Qo as B,Zo as C,en as D,tn as E,sn as F,on as G,nn as H,rn as I,an as J,ln as K,dn as L,un as M,cn as N,mn as O,pn as P,gn as Q,In as R,vn as S,hn as T,bn as U,yn as V,Rn as W,An as X,Tn as Y,En as Z,Bn as _,Sn as $,wn as aa,xn as ba,Cn as ca,Ln as da,Ms as ea,so as fa,ju as ga};
|