@lovek4d/kickflip 0.7.1 → 0.7.2

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/board/domain.mjs CHANGED
@@ -1,10 +1,10 @@
1
- var Qt=Object.defineProperty;var i=(e,t)=>Qt(e,"name",{value:t,configurable:!0});import{routeRecord as B}from"../hub/routes.mjs";import Ht from"node:fs";import{ticketBadge as ft,ticketIn as Vt}from"./tickets.mjs";import{prLinks as Xt,reviewLinks as Yt,reviewTime as zt,reviewersOf as Jt}from"./review.mjs";import{remoteFromInput as Zt}from"../hub/repos.mjs";import{reviewsOf as en,reviewNeeds as tn,reviewActions as nn}from"./auto-review.mjs";import{cardPRs as sn,hasPR as tt,leastReady as on,prKeyOf as rn,prURL as an}from"../shared/card-prs.mjs";import gt from"node:vm";import{checkWords as ln,parseCheck as dn}from"../shared/owner-check.mjs";import{buildScriptOf as cn}from"./build-script.mjs";import{HUB as Ge,hubLineOf as kt}from"./hub-lines.mjs";const nt=gt.createContext({});for(const e of["ui-enums.js","ui-order.js"])gt.runInContext(Ht.readFileSync(new URL(`./public/${e}`,import.meta.url),"utf8"),nt);const{BUTTON:ae,ACTION_KIND:D,BUILDER_KIND:pe,PR_STATE:H,PHASES:mt}=nt.BoardUI,{laneOrder:un}=nt.BoardUI,pn=["item-message","mark-ready","grill-more","prototype-request","visual-request","reask-request"],wt="question-reopen",go=Object.freeze({todo:"Todo",progress:"In Progress",review:"In Review",done:"Done"}),xe="move",fn=10*6e4,gn=5*6e4,ht="build-refused",De=Object.freeze({ask:"builder-ask",answer:"builder-answer"}),kn=864e5,fe=i(e=>e.lane==="done"||e.lane==="asks","closedLane"),mn=i(e=>`file:${e}`,"fileFold"),yt=7*kn,bt=i((e,t)=>({id:e,url:t?.workspace?`https://linear.app/${t.workspace}/issue/${e}`:null}),"linearRef"),wn=i((e,t)=>String(e).replace(/^S(\d+)$/,`${t||"INT"}-$1`),"internalRef"),Qe=i((e,t,n)=>Vt(n,t.ticket)?t.ticket:e.internal===!0?wn(t.id,n?.prefix):t.id,"refOf"),hn=i((e,t,n,s)=>ft(e||(t?{source:"internal",prefix:"INT"}:null),n,s)||(t?{id:String(t),url:null,source:null}:null),"ticketOf");function yn(e,t,n,s,r,a,d,c,u){return!a&&(e.lane==="done"||t?.state==="MERGED"||t?.state==="CLOSED")?"done":(n||s)&&!c?"progress":r?"review":t?.state==="OPEN"?t.checks?.state==="fail"&&(!t.isDraft||d)?"progress":"review":t||u?"progress":"todo"}i(yn,"laneOf");const He="Lander",St=i(e=>e.kind!==pe.install&&e.label!==He,"changesCode");function bn(e,t){return e?.state==="MERGED"||t?H.merged:e?.state==="CLOSED"?H.closed:e?.state==="OPEN"?e.isDraft?H.draft:H.open:null}i(bn,"prStateOf");const vt=i(e=>e.pr?.status===H.closed,"unlanded"),Sn=i(e=>e.some(t=>t.kind==="work")&&e.every(t=>t.lane==="done"),"finishedOf");function st(e){const t=xt(e);return t?.done&&t.handed_back?t.handed_back:null}i(st,"handedBackAt");const xt=i(e=>e.filter(t=>t?.started&&V(t)&&t.kind!==pe.install).sort((t,n)=>String(t.started).localeCompare(String(n.started))).at(-1),"newestBuild");function vn(e,t,n){return Object.fromEntries(e.map(s=>{const r=B(t?.reviews,s.github),a=r==="APPROVED"?"approved":r==="CHANGES_REQUESTED"?"changes":Object.hasOwn(n,s.name)?"sent":"unsent";return[s.name,{state:a,since:a==="sent"?B(n,s.name):null,github:s.github||null}]}))}i(vn,"reviewOf");function xn(e,t,n,s,r,a,{held:d,needsApproval:c}){return n?.kind===pe.install?"builder":s?"checking":n?"builder":d&&e==="review"?"merge":r&&e==="review"?"owner":e==="review"&&t?.state==="OPEN"&&t.isDraft?a?"ci":"ready":e==="review"?Ot(t,c)?"merge":"reviewers":null}i(xn,"waitsOnOf");const Ot=i((e,t)=>e?.reviewDecision==="APPROVED"||!t&&!["REVIEW_REQUIRED","CHANGES_REQUESTED"].includes(e?.reviewDecision),"reviewed"),Ce=/(^|\/)prototype-[\w-]+\.html/,On={reviewers:"Waiting for PR reviewers",merge:"Approved, merges once CI and the merge state allow",ci:"Marked ready for review once CI passes"},Ve={waiting:"Approved, Merge shows once CI and the merge state allow",ready:"Approved and green: tap Merge",merging:"Merging"},ot={auto:"Ready, merges once CI and the merge state allow",waiting:"Ready, Merge shows once CI and the merge state allow",ready:"Ready and green: tap Merge"},$n=i(e=>`Verified: tap Merge to land it on ${e}`,"heldNext"),An="Fix the failing CI",$t="Tap Done once it is settled",En=["status","agent","ask-link","command",xe,De.answer],At=i(e=>(e.who==="claude"||e.via==="github")&&!En.includes(e.kind)&&(e.kind!==Ge||kt(e).fault),"countsUnread"),Bn=["lander-handoff","land-waiting"];function _n({slug:e,itemFile:t,it:n,order:s,prs:r,repo:a,remote:d,base:c,builder:u,reachedPhase:f,agents:g,worktree:p,eta:w,thread:v,events:R,working:x,said:N,askedAt:C,topicItems:_,prSlack:T,boardReviewers:P,now:y,bumpedAt:b,holdAsk:l,closedAt:E,mergeAt:h,autoMerge:ne,skipDraft:ie,tickets:F}){const X=r.map(m=>({repo:m.repo,number:m.number,url:an(m),...m.gh||m.kept||{},status:bn(m.gh,m.merged_at)})),K=on(r.map(m=>m.gh)),L=r[K]?.gh||null,Y=X[K]?.status??null,z=n.lane||null,Te=!!E&&String(E)>String(n.lane_at||"");Te&&(n={...n,lane:"done",closed_at:E,reopened_at:void 0});const W=[n.closed_at,...r.flatMap(m=>[m.merged_at,m.gh?.mergedAt])].filter(Boolean).map(String).sort().pop()||null,U=String(W||""),Le=X.length>0&&X.every(m=>m.status===H.closed),G=(n.lane==="done"||n.reopened_at||Y===H.merged)&&!Le&&([...N.filter(m=>m.kind==="item-message").map(m=>m.ts),...C].map(String).filter(m=>m>U).sort().pop()||n.reopened_at)||void 0,me=n.owner_step&&!Te?String(n.owner_step):null,ze=(n.lane==="done"||Y===H.merged)&&!Le,Pe=!!G&&!!n.next&&String(n.next_at||"")>String(n.reopened_at||W||"");G&&!Pe&&(n={...n,next:void 0});const Be=st(g),Je=!!G&&N.some(m=>String(m.ts)>U&&(m.state==="waiting"||m.state==="working")),Q=`${e}/${n.id}`,J=Jt(t,P),_e=Object.fromEntries(Object.entries(Yt(t,n,Q,_,Xt(T,r))).map(([m,ee])=>[m,zt(ee.ts)])),we=Object.values(_e).filter(Boolean).sort()[0]||null,he=[...v.map(m=>m.ts),...R.map(m=>m.ts)].sort().pop()||null,je=[...v.filter(m=>At({...m,who:m.who||"claude"})).map(m=>m.ts),...R.map(m=>m.reply?.at)].filter(Boolean).sort(),Z=!tt(n)&&n.pushed?.branch?{branch:n.pushed.branch,at:n.pushed.at||null,host:d?.host||null}:null,se=!tt(n)&&n.merge_ready?.branch?{branch:n.merge_ready.branch,at:n.merge_ready.at||null,base:c}:null,de=!!n.rebase_run&&L?.state==="OPEN",ye=(n.rebased||[]).at(-1),Re=g.filter(m=>m.started&&!m.done&&V(m)),Ue=!!Be&&St(xt(g));let M=yn(n,L,Re.some(St),Ue,Z||se,!!G,ie,de,Re.length>0||!!Be);G&&M==="todo"&&(M="progress");const Ze=M==="review"&&!!we&&y-Date.parse(we)>yt,oe=!!me&&ze&&M==="done";oe&&(M="review");let j=xn(M,L,u,!!Be&&M!=="done",Z,ie,{held:se,needsApproval:J.length>0});const be=j==="builder"&&L?.state==="OPEN"&&!L.isDraft,Me=M==="progress"&&!j&&L?.state==="OPEN"&&(!L.isDraft||ie),re=oe||!!G&&M==="progress"&&!j&&!Me&&!Je&&!Pe;re&&(j="owner");const Ie=l&&String(l.ts)>String(n.held_at||""),qe=M==="todo"&&(Ie?!!l.data.hold:!!n.held),et=qe&&(Ie?l.data.until:n.pick_up_at)||null,We=M!=="done",o=!!b&&!(U&&String(b)<=U),k=v.filter(m=>(m.who||"claude")==="claude"&&!["status","command",xe].includes(m.kind)&&!Bn.includes(m.line)).map(m=>String(m.ts)).sort().pop()||"",S=[h,se&&n.merge_ready.tapped].filter(Boolean).map(String).sort().pop(),O=j==="merge"&&!!S&&S>k,$=v.filter(m=>(m.kind==="status"||m.kind===Ge)&&String(m.ts)>String(S)).sort((m,ee)=>String(m.ts).localeCompare(String(ee.ts))).at(-1),q=$?.line==="land-waiting"?`${Ve.merging} \xB7 ${$.text[0].toLowerCase()}${$.text.slice(1)}`:Ve.merging,I=v.filter(m=>!["status",xe].includes(m.kind)).sort((m,ee)=>String(m.ts).localeCompare(String(ee.ts))).at(-1),ce=M==="todo"&&I?.line===ht?I.text:null,ue=G||g.filter(V).map(m=>m.started).filter(Boolean).map(String).sort().pop()||null,Fe=L?.reviewDecision==="APPROVED",Ke=Z&&j==="owner"?`merge ${Z.branch} into ${c}`:se&&j==="merge"?O?q:$n(c):j==="merge"&&!ne?O?q:(Fe?Ve:ot).waiting:j==="merge"&&!Fe?ot.auto:On[j],Se=Y===H.draft?`Review draft PR #${X[K].number}`:null,ve=!de&&ye?.to&&ye.to===L?.headRefOid?`Rebased onto ${ye.base||c}, pushed${L.mergeable==="MERGEABLE"?" \xB7 PR is clean again":""}`:null,A=de&&j==="checking"?g.flatMap(m=>m.calls).sort((m,ee)=>String(m.at).localeCompare(String(ee.at))).at(-1)?.text??null:null;return{key:Q,kind:"work",order:s,file:e,fileTitle:t.title||e,id:n.id,ref:Qe(t,n,F),title:n.title,storedLane:z,created:n.created||null,reviewSince:n.review_since||we||n.merge_ready?.at||n.pushed?.at||n.created||null,progressSince:ue,closedAt:M==="done"?W:null,internal:t.internal===!0,repo:t.internal===!0&&!t.repo?null:a,lane:M,waitsOn:j,builder:j==="checking"?null:u,reachedPhase:f,agents:g,worktree:p??null,eta:w,working:x,reopened:!!G,awaitsDone:re,ownerStep:re?me:null,ownerCheck:re&&me&&n.owner_check?{words:ln(dn(n.owner_check.check)),broken:n.owner_check.broken||null}:null,stagedAt:M==="todo"&&n.phase==="staging"&&n.staged_at||null,roundAt:n.round_at||null,deps:n.deps||[],blockedUntil:n.blocked_until||null,blockReason:n.block_reason||null,held:qe,heldUntil:et,risky:!!n.risky,bumpable:We,bumpedAt:We&&o?b:null,holdable:M!=="done",hasNotes:!!(n.plan||String(n.notes||"").trim()),finishable:M!=="done",merging:O,refusal:ce,manualSteps:n.manual_steps||[],fromAsk:n.from_ask||null,unfiled:!!n.unfiled,filedHeld:!!n.filed_held,next:be||M==="done"||j==="checking"?null:Me?An:ve||Ke||n.next||Se||null,rebaseFailed:A,branch:n.branch||L?.headRefName||Z?.branch||null,pushed:M==="done"||oe?null:Z,mergeReady:M==="review"?se:null,stale:M!=="done"&&(Ze||!!u?.stale),stalled:n.stalled?.reason||null,landStopped:M==="review"&&se&&n.merge_ready.stopped&&String(n.merge_ready.stopped)>String(n.merge_ready.tapped||"")?{words:Rt("land"),at:n.merge_ready.stopped}:null,ticket:F?.source==="linear"&&!n.ticket&&n.linear?.length?null:hn(F,n.ticket,n.ticket||(t.internal?Qe(t,n,F):n.linear?.[0]),{repo:a,key:Q}),ticketSource:F?.source||null,linear:(n.linear||[]).map(m=>F?.source==="linear"&&ft(F,m,{key:Q,repo:a})||bt(m,F)),pr:X[K]||null,prs:X,reviewers:J.map(m=>m.name),review:vn(J,L||r[K]?.kept,_e),inReviewSince:we,threadCount:v.length+R.length,lastTs:he,othersAt:je,grilling:Mt("grill",R,g,C),prototyping:Mt("prototype",R,g,C),storedPhase:n.phase||null,phase:null,updatedAt:L?.mergedAt||L?.updatedAt||r[K]?.merged_at||u?.at||he||null,ask:null,fold:null,action:null,install:M==="done"?null:Mn(n.install,L),waitFacts:Rn(n,{agents:g,thread:v,events:R,refusedAt:ce?I.ts:null})}}i(_n,"workItem");function Rn(e,{agents:t,thread:n,events:s,refusedAt:r}){const a=new Set(n.filter(f=>f.kind===De.answer).map(f=>f.ask)),d=n.filter(f=>f.kind===De.ask&&!a.has(f.ask)).sort((f,g)=>String(f.ts).localeCompare(String(g.ts)))[0],c=i(f=>s.filter(g=>at(g,f)).pop()?.ts||null,"requestAt"),u=n.filter(f=>(f.who||"claude")==="claude"&&!["status","agent","command",xe].includes(f.kind)&&f.line!==ht).map(f=>f.ts);return{handedBackAt:st(t),next:e.next||null,ask:d?{at:d.ts,text:d.text}:null,grillAt:c("grill"),prototypeAt:c("prototype"),refusedAt:r,unblockedAt:e.unblocked_at||null,unverified:t.some(f=>f.calls.some(g=>!f.verified||String(g.at)>String(f.verified.at))),writes:[...u,...t.flatMap(f=>[f.verified?.at,f.started])].filter(Boolean).map(String).sort()}}i(Rn,"waitFactsOf");function Mn(e,t){if(!e?.url)return null;const n=e.sha?String(e.sha).toLowerCase():null,s=t?.headRefOid?String(t.headRefOid).toLowerCase():null;return{url:e.url,label:e.label||null,builtAt:e.built_at||null,sha:n,older:!!(n&&s&&!s.startsWith(n))}}i(Mn,"installOf");function In(e,{needsApproval:t=!0}={}){if(e?.state!=="OPEN")return[`PR is ${String(e?.state||"unknown").toLowerCase()}`];const{state:n,pending:s,failing:r}=e.checks||{};return[e.isDraft&&"it is a draft",!Ot(e,t)&&`review: ${String(e.reviewDecision||"none").toLowerCase().replace(/_/g," ")}`,n==="fail"&&`failing: ${r?.length?r.join(", "):"a check"}`,n==="pending"&&`pending: ${s?le(s,"check"):"checks"}`,e.mergeStateStatus!=="CLEAN"&&`merge state: ${String(e.mergeStateStatus||"unknown").toLowerCase()}`].filter(Boolean)}i(In,"mergeBlockers");const qn=i((e,t)=>!In(e,{needsApproval:t}).length,"mergeable");function Dn(e,t,n){if(fe(e))return null;const s=`#selectedCard=${encodeURIComponent(e.key)}`;if(e.stalled)return{kind:D.stalled,url:s,label:`stalled: ${e.stalled}`};if(Cn(e)){const r=t.get(e.questions.first);return Ce.test(r?.url||"")?{kind:D.pick,url:`questions.html#${r.id}`,label:"Prototypes ready: pick a take"}:{kind:D.questions,url:`questions.html#${e.questions.first}`,label:`Answer ${le(e.questions.open,"question")}`}}return e.waitsOn==="ready"?{kind:D.ready,url:e.pr.url,label:`Review draft PR #${e.pr.number}`}:e.kind==="ask"&&e.waitsOn==="owner"?{kind:D.done,url:s,label:e.next||$t}:e.waitsOn==="merge"&&e.manualSteps.length&&!e.mergeReady?{kind:D.steps,url:s,label:"Run the manual steps, then merge"}:e.waitsOn==="merge"&&(!n||e.mergeReady)&&!e.merging&&e.prs.every(r=>["MERGED","CLOSED"].includes(r.state)||qn(r,e.reviewers.length>0))?{kind:D.merge,url:s,label:"Merge"}:null}i(Dn,"actionOf");const Cn=i(e=>!!(e.questions&&e.questions.state!=="resolved"&&e.questions.open>0),"asking"),rt=new Set([D.pick,D.questions]);function Et(e){return e.questions?ae.openQuestions:null}i(Et,"actionButtonOf");const Nn=i(e=>e.kind==="work"&&e.lane==="todo"&&!e.action&&!e.unpicked,"buildableOf"),Tn=i((e,t)=>/^item:/.test(e.topic||"")&&Ce.test(e.url||"")&&!(e.options||[]).some(n=>n.id===t),"picksNoTake");function Ln(e,t){const n=e.filter(a=>a.topic===`item:${t}`),r=[...n.filter(a=>Ce.test(a.url||"")).flatMap(a=>a.answers.map(d=>({q:a,a:d,again:Tn(a,d.choice)}))),...n.filter(a=>a.request).map(a=>({q:a,a:a.request,again:!0}))].sort((a,d)=>String(a.a.ts).localeCompare(String(d.a.ts))).at(-1);return r?.again?{id:r.q.id,note:r.a.note.replace(/\s+/g," ").trim()}:null}i(Ln,"noTakePicked");const Pn="Prototype again",jn=Object.freeze({[D.pick]:ae.openQuestions,[D.questions]:ae.openQuestions,[D.ready]:ae.github,[D.steps]:ae.github,[D.merge]:ae.merge,[D.done]:ae.done,[D.stalled]:ae.reply}),Un="Merges once unblocked",Wn=i(e=>`Blocked ${[e.blockedBy.length&&`by ${e.blockedBy.map(t=>t.ref).join(", ")}`,e.blockedUntil&&`until ${e.blockedUntil}`].filter(Boolean).join(" and ")}`,"mergeBlockedWords");function Fn(e,t,n){if(e.action=Dn(e,t,n),e.mergeBlocked=e.action?.kind===D.merge&&e.blocked?Wn(e):null,e.mergeBlocked&&Object.assign(e,{action:null,next:Un}),e.action?.kind===D.questions&&e.questions.fromAsks){Object.assign(e,{action:null,waitsOn:"owner",next:e.action.label,actionButton:Et(e),resolvedBy:null});return}e.awaitsDone&&=!e.action,e.awaitsDone||Object.assign(e,{ownerStep:null,ownerCheck:null}),e.actionButton=Et(e),e.resolvedBy=jn[e.action?.kind]||null,e.action?.kind===D.merge&&!e.mergeReady&&(e.next=(e.pr?.reviewDecision==="APPROVED"?Ve:ot).ready),e.awaitsDone&&Object.assign(e,{lane:"review",next:e.ownerStep||$t,bumpable:!1,bumpedAt:null});const s=e.lane==="todo"||e.waitsOn==="ready"||e.lane==="progress"&&e.waitsOn==="owner";if(!e.action||!s||e.stalled)return;const r=e.lane==="todo"&&rt.has(e.action.kind)?"todo":"review";Object.assign(e,{lane:r,waitsOn:e.waitsOn==="ready"?"ready":"owner",next:e.action.label})}i(Fn,"placeOwnerWait");const Bt=i((e,t)=>e?e!=="todo":t.some(V),"started"),_t="none set yet";function ko(e,t){const n=t.filter(s=>s?.started);return e.next||tt(e)||e.pushed||e.held||e.lane==="done"||st(n)?!1:!n.some(s=>!s.done)&&Bt(e.lane,n)}i(ko,"owesNext");function Kn(e,t=new Date){const n=new Date(e),s=n.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return n.toDateString()===t.toDateString()?s:`${n.getMonth()+1}/${n.getDate()} ${s}`}i(Kn,"askedLabel");function Gn(e,t,n,s,r,a,d,c){const u=t.find(h=>h.kind==="ask"&&h.eventId===e.id),f=u.files,g=c||(u.text||"").trim().split(`
2
- `)[0]||f.map(h=>h.name).join(", ")||"Ask",p=u.state==="replied"||u.state==="answered",w=r?.state==="progress"&&!(String(a||"")>String(r.at||"")),v=!w&&(!!r||!!a),R=p&&!v&&!w&&d.open>0,x=p&&!v&&!w&&!R&&d.answered>0,N=v||p&&!w&&!R&&!x,C=p&&!s&&!r?.moved&&[...t.filter(h=>h.who==="claude"&&h.kind!=="ask-link"&&h.kind!=="status"&&h.kind!=="command").map(h=>h.ts),...t.map(h=>h.reply?.at)].filter(Boolean).sort().pop()||null,_=N||w||R||x,T=t.some(h=>h.who==="love"&&h.kind!=="ask"&&(h.state==="waiting"||h.state==="working")),P=t.filter(h=>h.who==="love"&&h.kind==="item-message").flatMap(Ne).filter(([,h])=>h==="waiting"||h==="working").map(([h])=>h),y=_?"answered":u.state,b=_?null:n||null,l=[...t.filter(At).map(h=>h.ts),...t.map(h=>h.reply?.at)].filter(Boolean).sort(),E=[...t.map(h=>h.ts),...l,...w?[r.at]:[]].filter(Boolean).sort().pop();return{key:`ask:${e.id}`,kind:"ask",order:0,file:null,fileTitle:null,id:e.id,ref:_?Kn(e.ts):"New",isNew:!_,title:g,storedLane:null,internal:!1,repo:null,lane:w?"progress":N?"asks":"todo",waitsOn:w&&!T?"owner":null,builder:null,agents:[],eta:null,working:t.some(h=>Ne(h).some(([,ne])=>ne==="working")),deps:[],held:!1,risky:!1,bumpable:!_,bumpedAt:b,manualSteps:[],fromAsk:null,from:null,next:w&&r.next||null,hasNotes:!1,branch:null,finishable:_&&!N,linear:[],pr:null,prs:[],reviewers:[],review:{},inReviewSince:null,reviewSince:null,progressSince:w&&r.at||null,closedAt:null,threadCount:t.length,lastTs:E,othersAt:_?l:[],grilling:!1,prototyping:!1,created:e.ts,updatedAt:_?E:e.ts,ask:{eventId:e.id,state:y,askedAt:e.ts,bumpedAt:b,edited:!!u.edited,canEdit:!_,text:u.text,files:f,answerAt:C,from:u.from||null,owed:P},fold:null,action:null}}i(Gn,"askItem");const ge="visual",Oe="helper",Qn=new Set(["grill","prototype",ge]),te=i(e=>Qn.has(e.kind),"plans"),V=i(e=>!te(e),"builds"),Hn={grill:"grilling",prototype:"prototyping"},Vn=i((e,t)=>`${e} ${t} by orchestrator`,"orchestratorDid"),Rt=i(e=>Vn(e,"stopped"),"stoppedWords"),Xn={grill:"grill-more",prototype:"prototype-request"},at=i((e,t)=>e.kind===Xn[t]&&!e.data?.question,"isRequest");function Mt(e,t,n,s){if(n.some(a=>a.kind===e&&a.started&&!a.done))return!0;const r=t.filter(a=>at(a,e)).pop();return!!(r&&!r.reply&&!s.some(a=>String(a)>String(r.ts))&&!n.some(a=>a.kind===e&&a.done&&String(a.started)>=String(r.ts)))}i(Mt,"planningOf");const mo=30*6e4;function wo(e,t){const n=[];for(const s of e.items){if(fe(s)||(s.agents||[]).some(a=>a.kind==="prototype"&&a.started&&!a.done))continue;const r=s.prototyping&&t.filter(a=>a.data?.key===s.key&&at(a,"prototype")).pop();r&&n.push({key:s.key,request:r.id,since:r.ts});for(const a of e.owner.filter(d=>d.topic===`item:${s.key}`&&d.state==="requested"))n.push({key:s.key,request:a.request.id,question:a.id,since:a.request.ts})}return n}i(wo,"prototypeWaits");function lt(e={},t=!1){return Object.entries(e).filter(([n,s])=>s&&typeof s=="object"&&(t||!n.startsWith("past-"))).map(([n,s])=>({name:n,kind:It(s.kind)||null,model:s.model||(s.kind==="opus"||s.kind==="sonnet"?s.kind:null),label:s.label||null,started:s.started||null,eta:s.done?null:s.eta||null,done:s.done||null,log:s.session?.log||null,pid:s.session?.pid??null,calls:Array.isArray(s.calls)?s.calls:[],verified:s.verified||null,stopped:s.stopped||null,handed_back:s.handed_back||null,...s.pause?{pause:s.pause}:{},...s.kind===Oe?{writes:!!s.writes,requested:s.requested||null}:{},...s.waits?{waits:s.waits}:{}})).sort((n,s)=>String(n.started||"").localeCompare(String(s.started||""))||n.name.localeCompare(s.name))}i(lt,"agentsOf");function it(e={}){return Object.values(e).filter(t=>t?.worktree?.path).sort((t,n)=>String(t.started||"").localeCompare(String(n.started||""))).at(-1)?.worktree.path??null}i(it,"worktreeOf");function Yn(e,t=[]){const n=e.filter(V).map(s=>String(s.started||"")).filter(Boolean).sort().pop();return n===void 0?null:t.filter(s=>s.kind==="status"&&s.phase&&!s.planner&&String(s.ts)>=n).sort((s,r)=>String(s.ts).localeCompare(String(r.ts))).pop()?.phase||null}i(Yn,"reachedPhaseOf");function zn(e,t=[],n,s=null,r=null,a=!1){const d=e.filter(b=>b.started&&!b.done&&b.kind!==ge),c=d.every(te),u=c?d:d.filter(V),f=u.map(b=>String(b.started||"")).sort()[0];if(f===void 0)return null;const g=t.filter(b=>b.kind==="status"&&String(b.ts)>=f&&(c||!b.planner)).sort((b,l)=>String(b.ts).localeCompare(String(l.ts))).pop(),p=u.filter(b=>b.kind!==Oe).at(-1),w=u.some(b=>b.kind===pe.install)?pe.install:p?It(p.kind):"claude",v=c?null:u.find(b=>b.stopped&&String(b.stopped.at)>=String(b.started))?.stopped,R=g?.ts||f,x=v?v.at:s!==null&&s>Date.parse(R)?new Date(s).toISOString():R,N=g?g.phase||g.planner?g.text.replace(": "," \xB7 "):g.text||null:c?Hn[w]:null,C=n-Date.parse(x),_=c?null:u.find(b=>b.pause)?.pause??null,T=!c&&!v&&(r==="held"||!!_?.paused),P=c||T?null:v?!1:r,y=T?!1:P===null?C>=fn:!P;return{progress:N,phase:g?.phase||null,at:R,kind:w,planner:c,silentSince:x,stale:y,alive:P,held:T,quiet:!!_||P===!0&&!a&&C>=gn,stopped:v?Rt(v.run):null,..._?{pause:{cause:_.cause,words:_.words,paused:!!_.paused}}:{}}}i(zn,"builderOf");const ho={blocked:["nothing blocks it","nothing blocks it"],held:["you unhold it","unheld"],usage:["the usage pause lifts","the usage pause lifted"],bumped:["a slot frees","a slot freed"]},Jn=15*6e4,Zn=i(e=>(e.agents||[]).find(t=>t.name==="main"&&t.started&&!t.done&&V(t))??null,"mainBuild"),es=i((e,t,n,{now:s,usageHeld:r})=>e.blocked||e.held||r(n??"claude")||!!(t.until&&s<Date.parse(t.until)),"stillPaused");function yo(e,{now:t=Date.now(),usageHeld:n}){const s={ask:[],drop:[],stop:[],resume:[]},r=[];for(const a of e){if(a.kind!=="work"||a.lane!=="progress")continue;const d=Zn(a);if(!d)continue;const{pause:c}=d;if(!c){a.builder?.phase!=="landing"&&n(d.kind??"claude")&&s.ask.push(a.key);continue}const u=es(a,c,d.kind,{now:t,usageHeld:n});if(c.paused){u||r.push({key:a.key,at:c.paused});continue}!u&&c.cause!=="bumped"?s.drop.push(a.key):t-Date.parse(c.at)>=Jn&&s.stop.push(a.key)}return s.resume=r.sort((a,d)=>String(a.at).localeCompare(String(d.at))).map(a=>a.key),s}i(yo,"pauseWork");const dt={opus:"Claude Opus",sonnet:"Claude Sonnet",codex:"Codex"},ts=i(({model:e,kind:t})=>dt[e]||dt[t]||(t==="claude"?dt.opus:null),"modelName"),It=i(e=>e==="opus"||e==="sonnet"?"claude":e,"providerOf");function $e(e){const t=ts(e),{kind:n}=e,s=e.label?.replace(/\bbuilder\b/,"implementer").replace(/\bBuilder\b/,"Implementer"),r=i(d=>d[0].toLowerCase()+d.slice(1),"lower");if(t&&te(e))return`${t} ${n}`;if(t)return`${t} ${r(s?.replace(/^(?:claude\s+)?(?:opus|sonnet|codex)\b\s*/i,"")||"implementer")}`;const a=n?n[0].toUpperCase()+n.slice(1):"";return a?s?s.toLowerCase().includes(n.toLowerCase())?s:`${a} ${r(s)}`:a:s||"Implementer"}i($e,"agentName");const qt=i((e,t)=>!!e.resolved&&(!e.resolved_at||String(e.resolved_at)>=String(t)),"resolvedSince");function ns(e,t,n=[],s=[],r=[]){const a=t.filter(x=>x.data?.id===e.id),d=a[a.length-1]||null,c=r.filter(x=>x.data?.question===e.id).at(-1),u=i((x,...N)=>!!x&&N.every(C=>String(x.ts)>String(C||"")),"after"),f=!!(e.resolved&&e.resolved_at&&d&&String(d.ts)>e.resolved_at),g=n.filter(x=>x.data?.question===e.id&&u(x,d?.ts,c?.ts)).at(-1),p=u(c,d?.ts,g?.ts,e.resolved_at),w=e.resolved&&!f&&!p,v=w?s.filter(x=>x.data?.question===e.id&&String(x.ts)>String(e.resolved_at||"")).at(-1):null,R=p?"open":w?"resolved":g?"requested":d?d.reply?"replied":"answered":"open";return{...e,state:R,reopened:p,request:g?{id:g.id,ts:g.ts,note:g.data.note||"",choice:g.data.choice||null}:null,reask:v?{id:v.id,ts:v.ts}:null,answers:a.map(x=>({ts:x.ts,choice:x.data.choice||null,note:x.data.note||"",files:x.data.files||[],reply:x.reply,acted:qt(e,x.ts)}))}}i(ns,"ownerQuestion");const ke=i(e=>e.round??(Ce.test(e.url||"")?1:0),"roundOf");function ss(e,t){const n=i((s,r)=>s.confirm_of||(s.options||[]).some(a=>a.id===r.choice),"settles");return e.filter(s=>ke(s)===t&&s.answers.length).map(s=>[s,s.answers.at(-1)]).filter(([s,r])=>n(s,r)).map(([,s])=>s).sort((s,r)=>String(s.ts).localeCompare(String(r.ts))).at(-1)}i(ss,"roundSettledBy");function os(e){const t=e.find(r=>r.request&&!e.some(a=>ke(a)>ke(r)));if(t)return{n:ke(t)+1,state:"making"};const n=Math.max(0,...e.map(ke));if(!n)return null;const s=ss(e,n);return s?{n,state:"closed",take:s.choice}:e.some(r=>ke(r)===n&&r.state!=="resolved")?{n,state:"back"}:null}i(os,"roundState");function rs(e){const t=e.filter(n=>Ce.test(n.url||"")).map(n=>({n:ke(n),q:n.id,url:n.url,confirm:!!n.confirm_of,state:n.state})).sort((n,s)=>n.n-s.n);return t.length?{open:t.some(n=>n.state==="open"),rounds:t}:null}i(rs,"prototypesOf");const Ae=i((e,t,n)=>{const s=e.get(t);s?s.push(n):e.set(t,[n])},"add"),Ee=i((e,t)=>{const n=new Map;for(const s of e)Ae(n,t(s),s);return n},"groupBy");function as(e,t,n=new Set){const s=new Set(e.map(d=>d.id)),r=[...e];t.some(d=>!s.has(d.topic))&&r.push({id:"",title:"Other"});const a=Ee(t,d=>s.has(d.topic)?d.topic:"");return r.map(d=>{const c=a.get(d.id)||[],u=i(p=>c.filter(w=>w.state===p).length,"count"),f=c.every(p=>p.state==="resolved")||n.has(d.id)&&!u("open"),g=c.length&&f?"resolved":"open";return{...d,state:g,questions:c.map(p=>p.id),open:u("open"),answered:u("answered"),replied:u("replied"),resolved:u("resolved"),round:os(c)}}).filter(d=>d.questions.length)}i(as,"ownerTopics");const Xe={implement:"Implementation requested",prototype:"Prototype requested",grill:"Grill requested",visual:"Visual requested",reask:"Re-ask requested",hold:"Held",resume:"Resumed",done:"Marked done",staged:"Marked as staging",readied:"Marked as ready",related:"Related to",unrelated:"Unrelated from",followup:"Follow-up","followup-of":"Follow-up of"},Dt={"grill-more":"grill","prototype-request":"prototype","visual-request":"visual","reask-request":"reask"},Ct={"mark-ready":"Mark ready",...Object.fromEntries(Object.entries(Dt).map(([e,t])=>[e,Xe[t]]))},ls=["grill-more","prototype-request","visual-request"],is="answers submitted",Nt={reply:"Reply",build:"Implement"},ds=i(e=>Nt[e.data.intent],"intentLabel"),cs=i((e,t)=>{if(e.kind!=="prototype-request"||!t.has(e.data.question))return e.data.text||(e.data.files?.length?"":B(Ct,e.kind))||"";const n=t.get(e.data.question),s=(n.options||[]).find(r=>r.id===e.data.choice);return[Lt(t,n),s&&`${s.id}. ${s.label}`,e.data.note].filter(Boolean).join(`
3
- \u2192 `)},"actionText"),Tt=i((e,t)=>[...e.keys()].indexOf(t)+1,"numberOf"),Lt=i((e,t)=>`Question ${Tt(e,t.id)} \xB7 ${t.question}`,"numbered"),us="question reopened",Ye=i(e=>e.data?.shared_by?.login?{by:e.data.shared_by.name||e.data.shared_by.login}:{},"byOf"),ps=i((e,t)=>{const n=t.get(e.card);return{...e,text:`${Xe[e.command]} ${n?`${n.ref}: ${n.title}`:e.card}`,link:`#selectedCard=${encodeURIComponent(e.card)}`}},"linkLine"),Pt=i(e=>({kind:"command",command:e,request:!0,mark:Xe[e]}),"commandLine"),fs=i((e,t)=>{if(e.kind==="item-message")return Nt[e.data.intent]?{status:ds(e)}:{};const n={request:!0,command:Dt[e.kind]};return ls.includes(e.kind)?(e.data.question?t.has(e.data.question):String(e.data.text||"").trim()||e.data.files?.length)?{status:Ct[e.kind]}:n:e.kind==="reask-request"?n:{}},"requestOf"),ct=i(e=>[...e.filter(t=>t.who==="claude"&&!["status","agent","command",xe,De.answer].includes(t.kind)).map(t=>t.ts),...e.filter(t=>t.kind==="ask").map(t=>t.reply?.at)].filter(Boolean).map(String).sort().pop()||"","claudeAtOf");function jt(e,t={}){const n=new Map,s=new Map;for(const p of t.items||[])Ae(n,p.topic,p),s.set(p.id,p.topic);const r=new Map,a=new Map,d=new Map,c=new Map,u=new Map,f=new Map,g=new Map;e.forEach((p,w)=>{g.set(p,w),p.data?.key&&pn.includes(p.kind)&&Ae(r,p.data.key,p),p.kind==="owner-answer"&&s.has(p.data?.id)&&Ae(a,s.get(p.data.id),p),p.kind===wt&&s.has(p.data?.question)&&Ae(d,s.get(p.data.question),p),p.kind==="ask"&&c.set(p.id,p)});for(const p of e.filter(w=>w.kind==="ask-edited").sort((w,v)=>String(w.ts).localeCompare(String(v.ts)))){u.set(p.data?.id,p.data?.text);for(const w of p.data?.files||[])Ae(f,p.data?.id,w)}return{byKey:r,answers:a,reopens:d,asks:c,edits:u,editFiles:f,questions:n,order:g}}i(jt,"threadIndex");const ut=i((e,t)=>{const n=t.filter(s=>s?.length);return n.length>1?n.flat().sort((s,r)=>e.order.get(s)-e.order.get(r)):[...n[0]||[]]},"inLogOrder"),gs=/; its log is \S*\/\.claude\/kickflip\/logs\/([^/\s]+\.log)\.$/,ks=i(e=>{const t=!e.log&&typeof e.text=="string"?gs.exec(e.text):null;return t?{...e,text:`${e.text.slice(0,t.index)}.`,log:t[1]}:e},"withLog");function ms(e,t){const n=t.run?e.find(s=>s.started===t.run):e.filter(s=>te(s)===!!t.planner&&s.started&&String(s.started)<=String(t.ts)&&(!s.done||String(t.ts)<=String(s.done))).pop();return n?{agent:$e(n),run:pt(e,n),running:!n.done}:{}}i(ms,"agentOfLine");function pt(e,t){return t.label!==He?t.started:e.filter(n=>V(n)&&n.label!==He&&n.started&&String(n.started)<String(t.started)).pop()?.started??t.started}i(pt,"sectionOf");function Ut(e,{lines:t=[],events:n=[],owner:s={},working:r={},fromAsk:a=null,links:d=[],agents:c={},moved:u=[],cards:f=new Map,index:g=jt(n,s)}){const p=e.startsWith("ask:")?[e.slice(4)]:[a,...u].filter(Boolean),w=[...new Set([e,...p.map(l=>`ask:${l}`)])],v=new Map((g.questions.get(`item:${e}`)||[]).map(l=>[l.id,l])),R=g.answers.get(`item:${e}`)||[],x=new Set([...v.values()].map(l=>l.round_of).filter(Boolean)),N=lt(c,!0).filter(V).map(l=>String(l.started||"")).filter(Boolean),C=new Set(R.filter(l=>qt(v.get(l.data.id),l.ts)||x.has(l.data.id)||N.some(E=>E>String(l.ts))).map(l=>l.id)),_=lt(c,!0),T=[..._.flatMap(l=>[...l.started?[{ts:l.started,who:"claude",kind:"agent",text:`${$e(l)} started`,agent:$e(l),run:pt(_,l),finished:!1,eta:l.done?null:l.eta,...l.log?{log:l.log}:{},...te(l)?{planner:!0}:{}}]:[],...l.done?[{ts:l.done,who:"claude",kind:"agent",text:`${$e(l)} finished`,agent:$e(l),run:pt(_,l),finished:!0,eta:null,...te(l)?{planner:!0}:{}}]:[],...l.calls.length?[{ts:l.done||l.calls.at(-1).at,who:"claude",kind:"calls",text:$e(l),calls:l.calls.map(E=>E.text),verified:l.verified}]:[]]),...t.map(ks).map(l=>l.card?ps(l,f):l).map(l=>({ts:l.ts,who:l.who||"claude",...l.log?{log:l.log}:{},...l.kind==="status"?{kind:"status",...l.planner?{planner:!0}:{},...ms(_,l)}:{},...l.kind===ge||l.kind===xe?{kind:l.kind}:{},...l.kind===Ge?{kind:Ge,line:l.line,...kt(l)}:{},...l.command?Pt(l.command):{},...l.card?{card:l.card}:{},...Object.values(De).includes(l.kind)?{kind:l.kind,ask:l.ask}:{},text:l.text||"",html:l.html||null,link:l.link||null,via:l.via||null,...l.by?{by:l.by}:{}})),...ut(g,w.map(l=>g.byKey.get(l))).map(l=>({ts:l.ts,who:"love",via:"site",kind:l.kind,text:cs(l,v),files:l.data.files||[],eventId:l.id,reply:l.reply,...fs(l,v),...Ye(l)})),...R.map(l=>{const E=[l.data.label||l.data.choice,l.data.note].filter(Boolean).join(" \xB7 ");return{ts:l.ts,who:"love",via:"questions",kind:l.kind,text:`${Lt(v,v.get(l.data.id))}
4
- \u2192 ${E}`,files:l.data.files||[],eventId:l.id,reply:l.reply,status:is,...Ye(l)}}),...(g.reopens.get(`item:${e}`)||[]).map(l=>({ts:l.ts,who:"love",kind:l.kind,request:!0,mark:us,text:`Question ${Tt(v,l.data.question)} was reopened`,...Ye(l)})),...ut(g,[...new Set(p)].map(l=>g.asks.has(l)?[g.asks.get(l)]:[])).flatMap(l=>[{ts:l.ts,who:"love",via:"ask",kind:l.kind,text:l.data?.text||"",files:l.data?.files||[],eventId:l.id,reply:l.reply,...u.includes(l.id)?{moved:!0}:{},...Ye(l),...typeof l.data?.from?.title=="string"?{from:l.data.from.title}:{}},...l.data?.quick===!0?[{ts:l.ts,who:"love",...Pt("implement"),text:Xe.implement}]:[],...d.map(E=>({ts:l.ts,who:"claude",kind:"ask-link",text:E.folded?`Moved to ${E.ref}: ${E.title}`:`${E.became?"Became":"Added to"} ${E.ref}`,link:`#selectedCard=${encodeURIComponent(E.key)}`,html:null,via:null}))])].sort((l,E)=>String(l.ts).localeCompare(String(E.ts))),P=ct(T),{edits:y,editFiles:b}=g;for(const l of T){if(!l.eventId)continue;(l.kind==="ask"||l.kind==="item-message")&&typeof y.get(l.eventId)=="string"&&Object.assign(l,{text:y.get(l.eventId),edited:!0,files:[...l.files,...b.get(l.eventId)||[]]});const E=l.kind==="ask"&&(d.length>0||!!l.moved);l.state=l.reply?"replied":E||C.has(l.eventId)||P>String(l.ts)?"answered":B(r,l.eventId)?"working":"waiting",l.canDelete=l.kind==="item-message"&&(l.state==="working"||l.state==="waiting"),l.canEdit=l.canDelete}return ws(T)}i(Ut,"threadOf");const Wt=["waiting","working","answered","replied"];function ws(e){const t=new Map;for(const n of e)n.kind==="owner-answer"&&t.set(n.ts,[...t.get(n.ts)||[],n]);return e.flatMap(n=>{if(n.kind!=="owner-answer")return[n];const s=t.get(n.ts);return s.length===1?[n]:s[0]!==n?[]:[{...n,text:s.map(r=>r.text).join(`
1
+ var Ht=Object.defineProperty;var i=(e,t)=>Ht(e,"name",{value:t,configurable:!0});import{routeRecord as E}from"../hub/routes.mjs";import Vt from"node:fs";import{ticketBadge as ft,ticketIn as Xt}from"./tickets.mjs";import{prLinks as Yt,reviewLinks as zt,reviewTime as Jt,reviewersOf as Zt}from"./review.mjs";import{remoteFromInput as en}from"../hub/repos.mjs";import{reviewsOf as tn,reviewNeeds as nn,reviewActions as sn}from"./auto-review.mjs";import{cardPRs as on,hasPR as et,leastReady as rn,prKeyOf as an,prURL as ln}from"../shared/card-prs.mjs";import gt from"node:vm";import{checkWords as dn,parseCheck as cn}from"../shared/owner-check.mjs";import{buildScriptOf as un}from"./build-script.mjs";import{HUB as Fe,hubLineOf as kt}from"./hub-lines.mjs";const tt=gt.createContext({});for(const e of["ui-enums.js","ui-order.js"])gt.runInContext(Vt.readFileSync(new URL(`./public/${e}`,import.meta.url),"utf8"),tt);const{BUTTON:oe,ACTION_KIND:q,BUILDER_KIND:ce,PR_STATE:H,PHASES:mt}=tt.BoardUI,{laneOrder:pn}=tt.BoardUI,fn=["item-message","mark-ready","grill-more","prototype-request","visual-request","reask-request"],wt="question-reopen",ko=Object.freeze({todo:"Todo",progress:"In Progress",review:"In Review",done:"Done"}),Se="move",gn=10*6e4,kn=5*6e4,ht="build-refused",qe=Object.freeze({ask:"builder-ask",answer:"builder-answer"}),mn=864e5,ue=i(e=>e.lane==="done","closedLane"),wn=i(e=>`file:${e}`,"fileFold"),yt=7*mn,bt=i((e,t)=>({id:e,url:t?.workspace?`https://linear.app/${t.workspace}/issue/${e}`:null}),"linearRef"),hn=i(e=>String(e).replace(/^S(\d+)$/,"INT-$1"),"internalRef"),nt=i((e,t,n)=>Xt(n,t.ticket)?t.ticket:e.internal===!0?hn(t.id):t.id,"refOf"),yn=i((e,t,n)=>ft(e,t,n)||(t?{id:String(t),url:null,source:null}:null),"ticketOf");function bn(e,t,n,s,r,a,d,c,u){return!a&&(e.lane==="done"||t?.state==="MERGED"||t?.state==="CLOSED")?"done":(n||s)&&!c?"progress":r?"review":t?.state==="OPEN"?t.checks?.state==="fail"&&(!t.isDraft||d)?"progress":"review":t||u?"progress":"todo"}i(bn,"laneOf");const Ke="Lander",St=i(e=>e.kind!==ce.install&&e.label!==Ke,"changesCode");function Sn(e,t){return e?.state==="MERGED"||t?H.merged:e?.state==="CLOSED"?H.closed:e?.state==="OPEN"?e.isDraft?H.draft:H.open:null}i(Sn,"prStateOf");const vt=i(e=>e.pr?.status===H.closed,"unlanded"),vn=i(e=>e.some(t=>t.kind==="work")&&e.every(t=>t.lane==="done"),"finishedOf");function st(e){const t=xt(e);return t?.done&&t.handed_back?t.handed_back:null}i(st,"handedBackAt");const xt=i(e=>e.filter(t=>t?.started&&V(t)&&t.kind!==ce.install).sort((t,n)=>String(t.started).localeCompare(String(n.started))).at(-1),"newestBuild");function xn(e,t,n){return Object.fromEntries(e.map(s=>{const r=E(t?.reviews,s.github),a=r==="APPROVED"?"approved":r==="CHANGES_REQUESTED"?"changes":Object.hasOwn(n,s.name)?"sent":"unsent";return[s.name,{state:a,since:a==="sent"?E(n,s.name):null,github:s.github||null}]}))}i(xn,"reviewOf");function On(e,t,n,s,r,a,{held:d,needsApproval:c}){return n?.kind===ce.install?"builder":s?"checking":n?"builder":d&&e==="review"?"merge":r&&e==="review"?"owner":e==="review"&&t?.state==="OPEN"&&t.isDraft?a?"ci":"ready":e==="review"?Ot(t,c)?"merge":"reviewers":null}i(On,"waitsOnOf");const Ot=i((e,t)=>e?.reviewDecision==="APPROVED"||!t&&!["REVIEW_REQUIRED","CHANGES_REQUESTED"].includes(e?.reviewDecision),"reviewed"),De=/(^|\/)prototype-[\w-]+\.html/,$n={reviewers:"Waiting for PR reviewers",merge:"Approved, merges once CI and the merge state allow",ci:"Marked ready for review once CI passes"},Ge={waiting:"Approved, Merge shows once CI and the merge state allow",ready:"Approved and green: tap Merge",merging:"Merging"},ot={auto:"Ready, merges once CI and the merge state allow",waiting:"Ready, Merge shows once CI and the merge state allow",ready:"Ready and green: tap Merge"},An=i(e=>`Verified: tap Merge to land it on ${e}`,"heldNext"),En="Fix the failing CI",$t="Tap Done once it is settled",Bn=["status","agent","ask-link","command",Se,qe.answer],At=i(e=>(e.who==="claude"||e.via==="github")&&!Bn.includes(e.kind)&&(e.kind!==Fe||kt(e).fault),"countsUnread"),_n=["lander-handoff","land-waiting"];function Rn({slug:e,itemFile:t,it:n,order:s,prs:r,repo:a,remote:d,base:c,builder:u,reachedPhase:g,agents:m,worktree:p,eta:w,thread:x,events:_,working:O,said:N,askedAt:D,topicItems:B,prSlack:T,boardReviewers:P,now:y,bumpedAt:b,holdAsk:l,closedAt:A,mergeAt:h,autoMerge:te,skipDraft:ae,tickets:G}){const X=r.map(f=>({repo:f.repo,number:f.number,url:ln(f),...f.gh||f.kept||{},status:Sn(f.gh,f.merged_at)})),F=rn(r.map(f=>f.gh)),L=r[F]?.gh||null,Y=X[F]?.status??null,z=n.lane||null,Ne=!!A&&String(A)>String(n.lane_at||"");Ne&&(n={...n,lane:"done",closed_at:A,reopened_at:void 0});const U=[n.closed_at,...r.flatMap(f=>[f.merged_at,f.gh?.mergedAt])].filter(Boolean).map(String).sort().pop()||null,j=String(U||""),Te=X.length>0&&X.every(f=>f.status===H.closed),K=(n.lane==="done"||n.reopened_at||Y===H.merged)&&!Te&&([...N.filter(f=>f.kind==="item-message").map(f=>f.ts),...D].map(String).filter(f=>f>j).sort().pop()||n.reopened_at)||void 0,ge=n.owner_step&&!Ne?String(n.owner_step):null,Ve=(n.lane==="done"||Y===H.merged)&&!Te,Le=!!K&&!!n.next&&String(n.next_at||"")>String(n.reopened_at||U||"");K&&!Le&&(n={...n,next:void 0});const Ae=st(m),Xe=!!K&&N.some(f=>String(f.ts)>j&&(f.state==="waiting"||f.state==="working")),Q=`${e}/${n.id}`,J=Zt(t,P),Ee=Object.fromEntries(Object.entries(zt(t,n,Q,B,Yt(T,r))).map(([f,W])=>[f,Jt(W.ts)])),ke=Object.values(Ee).filter(Boolean).sort()[0]||null,me=[...x.map(f=>f.ts),..._.map(f=>f.ts)].sort().pop()||null,Be=[...x.filter(f=>At({...f,who:f.who||"claude"})).map(f=>f.ts),..._.map(f=>f.reply?.at)].filter(Boolean).sort(),Z=!et(n)&&n.pushed?.branch?{branch:n.pushed.branch,at:n.pushed.at||null,host:d?.host||null}:null,ne=!et(n)&&n.merge_ready?.branch?{branch:n.merge_ready.branch,at:n.merge_ready.at||null,base:c}:null,le=!!n.rebase_run&&L?.state==="OPEN",_e=(n.rebased||[]).at(-1),Re=m.filter(f=>f.started&&!f.done&&V(f)),Pe=!!Ae&&St(xt(m));let R=bn(n,L,Re.some(St),Pe,Z||ne,!!K,ae,le,Re.length>0||!!Ae);K&&R==="todo"&&(R="progress");const Ye=R==="review"&&!!ke&&y-Date.parse(ke)>yt,Me=!!ge&&Ve&&R==="done";Me&&(R="review");let C=On(R,L,u,!!Ae&&R!=="done",Z,ae,{held:ne,needsApproval:J.length>0});const ze=C==="builder"&&L?.state==="OPEN"&&!L.isDraft,ie=R==="progress"&&!C&&L?.state==="OPEN"&&(!L.isDraft||ae),de=Me||!!K&&R==="progress"&&!C&&!ie&&!Xe&&!Le;de&&(C="owner");const we=l&&String(l.ts)>String(n.held_at||""),Ie=R==="todo"&&(we?!!l.data.hold:!!n.held),je=Ie&&(we?l.data.until:n.pick_up_at)||null,Ue=R!=="done",Je=!!b&&!(j&&String(b)<=j),o=x.filter(f=>(f.who||"claude")==="claude"&&!["status","command",Se].includes(f.kind)&&!_n.includes(f.line)).map(f=>String(f.ts)).sort().pop()||"",k=[h,ne&&n.merge_ready.tapped].filter(Boolean).map(String).sort().pop(),S=C==="merge"&&!!k&&k>o,$=x.filter(f=>(f.kind==="status"||f.kind===Fe)&&String(f.ts)>String(k)).sort((f,W)=>String(f.ts).localeCompare(String(W.ts))).at(-1),v=$?.line==="land-waiting"?`${Ge.merging} \xB7 ${$.text[0].toLowerCase()}${$.text.slice(1)}`:Ge.merging,M=x.filter(f=>!["status",Se].includes(f.kind)).sort((f,W)=>String(f.ts).localeCompare(String(W.ts))).at(-1),I=R==="todo"&&M?.line===ht?M.text:null,he=K||m.filter(V).map(f=>f.started).filter(Boolean).map(String).sort().pop()||null,se=L?.reviewDecision==="APPROVED",Ze=Z&&C==="owner"?`merge ${Z.branch} into ${c}`:ne&&C==="merge"?S?v:An(c):C==="merge"&&!te?S?v:(se?Ge:ot).waiting:C==="merge"&&!se?ot.auto:$n[C],We=Y===H.draft?`Review draft PR #${X[F].number}`:null,ye=!le&&_e?.to&&_e.to===L?.headRefOid?`Rebased onto ${_e.base||c}, pushed${L.mergeable==="MERGEABLE"?" \xB7 PR is clean again":""}`:null,be=le&&C==="checking"?m.flatMap(f=>f.calls).sort((f,W)=>String(f.at).localeCompare(String(W.at))).at(-1)?.text??null:null;return{key:Q,kind:"work",order:s,file:e,fileTitle:t.title||e,id:n.id,ref:nt(t,n,G),title:n.title,storedLane:z,created:n.created||null,reviewSince:n.review_since||ke||n.merge_ready?.at||n.pushed?.at||n.created||null,progressSince:he,closedAt:R==="done"?U:null,internal:t.internal===!0,repo:t.internal===!0&&!t.repo?null:a,lane:R,waitsOn:C,builder:C==="checking"?null:u,reachedPhase:g,agents:m,worktree:p??null,eta:w,working:O,reopened:!!K,awaitsDone:de,ownerStep:de?ge:null,ownerCheck:de&&ge&&n.owner_check?{words:dn(cn(n.owner_check.check)),broken:n.owner_check.broken||null}:null,stagedAt:R==="todo"&&n.phase==="staging"&&n.staged_at||null,roundAt:n.round_at||null,deps:n.deps||[],blockedUntil:n.blocked_until||null,blockReason:n.block_reason||null,held:Ie,heldUntil:je,risky:!!n.risky,bumpable:Ue,bumpedAt:Ue&&Je?b:null,holdable:R!=="done",hasNotes:!!(n.plan||String(n.notes||"").trim()),finishable:R!=="done",merging:S,refusal:I,manualSteps:n.manual_steps||[],fromAsk:n.from_ask||null,unfiled:!!n.unfiled,filedHeld:!!n.filed_held,next:ze||R==="done"||C==="checking"?null:ie?En:ye||Ze||n.next||We||null,rebaseFailed:be,branch:n.branch||L?.headRefName||Z?.branch||null,pushed:R==="done"||Me?null:Z,mergeReady:R==="review"?ne:null,stale:R!=="done"&&(Ye||!!u?.stale),stalled:n.stalled?.reason||null,landStopped:R==="review"&&ne&&n.merge_ready.stopped&&String(n.merge_ready.stopped)>String(n.merge_ready.tapped||"")?{words:Rt("land"),at:n.merge_ready.stopped}:null,ticket:G?.source==="linear"&&!n.ticket&&n.linear?.length?null:yn(G,n.ticket,{repo:a}),ticketSource:G?.source||null,linear:(n.linear||[]).map(f=>G?.source==="linear"&&ft(G,f,{repo:a})||bt(f,G)),pr:X[F]||null,prs:X,reviewers:J.map(f=>f.name),review:xn(J,L||r[F]?.kept,Ee),inReviewSince:ke,threadCount:x.length+_.length,lastTs:me,othersAt:Be,grilling:Mt("grill",_,m,D),prototyping:Mt("prototype",_,m,D),storedPhase:n.phase||null,phase:null,updatedAt:L?.mergedAt||L?.updatedAt||r[F]?.merged_at||u?.at||me||null,ask:null,fold:null,action:null,install:R==="done"?null:In(n.install,L),waitFacts:Mn(n,{agents:m,thread:x,events:_,refusedAt:I?M.ts:null})}}i(Rn,"workItem");function Mn(e,{agents:t,thread:n,events:s,refusedAt:r}){const a=new Set(n.filter(g=>g.kind===qe.answer).map(g=>g.ask)),d=n.filter(g=>g.kind===qe.ask&&!a.has(g.ask)).sort((g,m)=>String(g.ts).localeCompare(String(m.ts)))[0],c=i(g=>s.filter(m=>at(m,g)).pop()?.ts||null,"requestAt"),u=n.filter(g=>(g.who||"claude")==="claude"&&!["status","agent","command",Se].includes(g.kind)&&g.line!==ht).map(g=>g.ts);return{handedBackAt:st(t),next:e.next||null,ask:d?{at:d.ts,text:d.text}:null,grillAt:c("grill"),prototypeAt:c("prototype"),refusedAt:r,unblockedAt:e.unblocked_at||null,unverified:t.some(g=>g.calls.some(m=>!g.verified||String(m.at)>String(g.verified.at))),writes:[...u,...t.flatMap(g=>[g.verified?.at,g.started])].filter(Boolean).map(String).sort()}}i(Mn,"waitFactsOf");function In(e,t){if(!e?.url)return null;const n=e.sha?String(e.sha).toLowerCase():null,s=t?.headRefOid?String(t.headRefOid).toLowerCase():null;return{url:e.url,label:e.label||null,builtAt:e.built_at||null,sha:n,older:!!(n&&s&&!s.startsWith(n))}}i(In,"installOf");function qn(e,{needsApproval:t=!0}={}){if(e?.state!=="OPEN")return[`PR is ${String(e?.state||"unknown").toLowerCase()}`];const{state:n,pending:s,failing:r}=e.checks||{};return[e.isDraft&&"it is a draft",!Ot(e,t)&&`review: ${String(e.reviewDecision||"none").toLowerCase().replace(/_/g," ")}`,n==="fail"&&`failing: ${r?.length?r.join(", "):"a check"}`,n==="pending"&&`pending: ${s?re(s,"check"):"checks"}`,e.mergeStateStatus!=="CLEAN"&&`merge state: ${String(e.mergeStateStatus||"unknown").toLowerCase()}`].filter(Boolean)}i(qn,"mergeBlockers");const Dn=i((e,t)=>!qn(e,{needsApproval:t}).length,"mergeable");function Cn(e,t,n){if(ue(e))return null;const s=`#selectedCard=${encodeURIComponent(e.key)}`;if(e.stalled)return{kind:q.stalled,url:s,label:`stalled: ${e.stalled}`};if(Nn(e)){const r=t.get(e.questions.first);return De.test(r?.url||"")?{kind:q.pick,url:`questions.html#${r.id}`,label:"Prototypes ready: pick a take"}:{kind:q.questions,url:`questions.html#${e.questions.first}`,label:`Answer ${re(e.questions.open,"question")}`}}return e.waitsOn==="ready"?{kind:q.ready,url:e.pr.url,label:`Review draft PR #${e.pr.number}`}:e.kind==="ask"&&e.waitsOn==="owner"?{kind:q.done,url:s,label:e.next||$t}:e.waitsOn==="merge"&&e.manualSteps.length&&!e.mergeReady?{kind:q.steps,url:s,label:"Run the manual steps, then merge"}:e.waitsOn==="merge"&&(!n||e.mergeReady)&&!e.merging&&e.prs.every(r=>["MERGED","CLOSED"].includes(r.state)||Dn(r,e.reviewers.length>0))?{kind:q.merge,url:s,label:"Merge"}:null}i(Cn,"actionOf");const Nn=i(e=>!!(e.questions&&e.questions.state!=="resolved"&&e.questions.open>0),"asking"),rt=new Set([q.pick,q.questions]);function Et(e){return e.questions?oe.openQuestions:null}i(Et,"actionButtonOf");const Tn=i(e=>e.kind==="work"&&e.lane==="todo"&&!e.action&&!e.unpicked,"buildableOf"),Ln=i((e,t)=>/^item:/.test(e.topic||"")&&De.test(e.url||"")&&!(e.options||[]).some(n=>n.id===t),"picksNoTake");function Pn(e,t){const n=e.filter(a=>a.topic===`item:${t}`),r=[...n.filter(a=>De.test(a.url||"")).flatMap(a=>a.answers.map(d=>({q:a,a:d,again:Ln(a,d.choice)}))),...n.filter(a=>a.request).map(a=>({q:a,a:a.request,again:!0}))].sort((a,d)=>String(a.a.ts).localeCompare(String(d.a.ts))).at(-1);return r?.again?{id:r.q.id,note:r.a.note.replace(/\s+/g," ").trim()}:null}i(Pn,"noTakePicked");const jn="Prototype again",Un=Object.freeze({[q.pick]:oe.openQuestions,[q.questions]:oe.openQuestions,[q.ready]:oe.github,[q.steps]:oe.github,[q.merge]:oe.merge,[q.done]:oe.done,[q.stalled]:oe.reply}),Wn="Merges once unblocked",Fn=i(e=>`Blocked ${[e.blockedBy.length&&`by ${e.blockedBy.map(t=>t.ref).join(", ")}`,e.blockedUntil&&`until ${e.blockedUntil}`].filter(Boolean).join(" and ")}`,"mergeBlockedWords");function Kn(e,t,n){if(e.action=Cn(e,t,n),e.mergeBlocked=e.action?.kind===q.merge&&e.blocked?Fn(e):null,e.mergeBlocked&&Object.assign(e,{action:null,next:Wn}),e.action?.kind===q.questions&&e.questions.fromAsks){Object.assign(e,{action:null,waitsOn:"owner",next:e.action.label,actionButton:Et(e),resolvedBy:null});return}e.awaitsDone&&=!e.action,e.awaitsDone||Object.assign(e,{ownerStep:null,ownerCheck:null}),e.actionButton=Et(e),e.resolvedBy=Un[e.action?.kind]||null,e.action?.kind===q.merge&&!e.mergeReady&&(e.next=(e.pr?.reviewDecision==="APPROVED"?Ge:ot).ready),e.awaitsDone&&Object.assign(e,{lane:"review",next:e.ownerStep||$t,bumpable:!1,bumpedAt:null});const s=e.lane==="todo"||e.waitsOn==="ready"||e.lane==="progress"&&e.waitsOn==="owner";if(!e.action||!s||e.stalled)return;const r=e.lane==="todo"&&rt.has(e.action.kind)?"todo":"review";Object.assign(e,{lane:r,waitsOn:e.waitsOn==="ready"?"ready":"owner",next:e.action.label})}i(Kn,"placeOwnerWait");const Bt=i((e,t)=>e?e!=="todo":t.some(V),"started"),_t="none set yet";function mo(e,t){const n=t.filter(s=>s?.started);return e.next||et(e)||e.pushed||e.held||e.lane==="done"||st(n)?!1:!n.some(s=>!s.done)&&Bt(e.lane,n)}i(mo,"owesNext");function Gn(e,t=new Date){const n=new Date(e),s=n.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return n.toDateString()===t.toDateString()?s:`${n.getMonth()+1}/${n.getDate()} ${s}`}i(Gn,"askedLabel");function Qn(e,t,n,s,r,a,d,c){const u=t.find(h=>h.kind==="ask"&&h.eventId===e.id),g=u.files,m=c||(u.text||"").trim().split(`
2
+ `)[0]||g.map(h=>h.name).join(", ")||"Ask",p=u.state==="replied"||u.state==="answered",w=r?.state==="progress"&&!(String(a||"")>String(r.at||"")),x=!w&&(!!r||!!a),_=p&&!x&&!w&&d.open>0,O=p&&!x&&!w&&!_&&d.answered>0,N=x||p&&!w&&!_&&!O,D=p&&!s&&!r?.moved&&[...t.filter(h=>h.who==="claude"&&h.kind!=="ask-link"&&h.kind!=="status"&&h.kind!=="command").map(h=>h.ts),...t.map(h=>h.reply?.at)].filter(Boolean).sort().pop()||null,B=N||w||_||O,T=t.some(h=>h.who==="love"&&h.kind!=="ask"&&(h.state==="waiting"||h.state==="working")),P=t.filter(h=>h.who==="love"&&h.kind==="item-message").flatMap(Ce).filter(([,h])=>h==="waiting"||h==="working").map(([h])=>h),y=B?"answered":u.state,b=B?null:n||null,l=[...t.filter(At).map(h=>h.ts),...t.map(h=>h.reply?.at)].filter(Boolean).sort(),A=[...t.map(h=>h.ts),...l,...w?[r.at]:[]].filter(Boolean).sort().pop();return{key:`ask:${e.id}`,kind:"ask",order:0,file:null,fileTitle:null,id:e.id,ref:B?Gn(e.ts):"New",isNew:!B,title:m,storedLane:null,internal:!1,repo:null,lane:w?"progress":N?"done":"todo",waitsOn:w&&!T?"owner":null,builder:null,agents:[],eta:null,working:t.some(h=>Ce(h).some(([,te])=>te==="working")),deps:[],held:!1,risky:!1,bumpable:!B,bumpedAt:b,manualSteps:[],fromAsk:null,from:null,next:w&&r.next||null,hasNotes:!1,branch:null,finishable:B&&!N,linear:[],pr:null,prs:[],reviewers:[],review:{},inReviewSince:null,reviewSince:null,progressSince:w&&r.at||null,closedAt:null,threadCount:t.length,lastTs:A,othersAt:B?l:[],grilling:!1,prototyping:!1,created:e.ts,updatedAt:B?A:e.ts,ask:{eventId:e.id,state:y,askedAt:e.ts,bumpedAt:b,edited:!!u.edited,canEdit:!B,text:u.text,files:g,answerAt:D,from:u.from||null,owed:P},fold:null,action:null}}i(Qn,"askItem");const pe="visual",ve="helper",Hn=new Set(["grill","prototype",pe]),ee=i(e=>Hn.has(e.kind),"plans"),V=i(e=>!ee(e),"builds"),Vn={grill:"grilling",prototype:"prototyping"},Xn=i((e,t)=>`${e} ${t} by orchestrator`,"orchestratorDid"),Rt=i(e=>Xn(e,"stopped"),"stoppedWords"),Yn={grill:"grill-more",prototype:"prototype-request"},at=i((e,t)=>e.kind===Yn[t]&&!e.data?.question,"isRequest");function Mt(e,t,n,s){if(n.some(a=>a.kind===e&&a.started&&!a.done))return!0;const r=t.filter(a=>at(a,e)).pop();return!!(r&&!r.reply&&!s.some(a=>String(a)>String(r.ts))&&!n.some(a=>a.kind===e&&a.done&&String(a.started)>=String(r.ts)))}i(Mt,"planningOf");const wo=30*6e4;function ho(e,t){const n=[];for(const s of e.items){if(ue(s)||(s.agents||[]).some(a=>a.kind==="prototype"&&a.started&&!a.done))continue;const r=s.prototyping&&t.filter(a=>a.data?.key===s.key&&at(a,"prototype")).pop();r&&n.push({key:s.key,request:r.id,since:r.ts});for(const a of e.owner.filter(d=>d.topic===`item:${s.key}`&&d.state==="requested"))n.push({key:s.key,request:a.request.id,question:a.id,since:a.request.ts})}return n}i(ho,"prototypeWaits");function lt(e={},t=!1){return Object.entries(e).filter(([n,s])=>s&&typeof s=="object"&&(t||!n.startsWith("past-"))).map(([n,s])=>({name:n,kind:It(s.kind)||null,model:s.model||(s.kind==="opus"||s.kind==="sonnet"?s.kind:null),label:s.label||null,started:s.started||null,eta:s.done?null:s.eta||null,done:s.done||null,log:s.session?.log||null,pid:s.session?.pid??null,calls:Array.isArray(s.calls)?s.calls:[],verified:s.verified||null,stopped:s.stopped||null,handed_back:s.handed_back||null,...s.pause?{pause:s.pause}:{},...s.kind===ve?{writes:!!s.writes,requested:s.requested||null}:{},...s.waits?{waits:s.waits}:{}})).sort((n,s)=>String(n.started||"").localeCompare(String(s.started||""))||n.name.localeCompare(s.name))}i(lt,"agentsOf");function it(e={}){return Object.values(e).filter(t=>t?.worktree?.path).sort((t,n)=>String(t.started||"").localeCompare(String(n.started||""))).at(-1)?.worktree.path??null}i(it,"worktreeOf");function zn(e,t=[]){const n=e.filter(V).map(s=>String(s.started||"")).filter(Boolean).sort().pop();return n===void 0?null:t.filter(s=>s.kind==="status"&&s.phase&&!s.planner&&String(s.ts)>=n).sort((s,r)=>String(s.ts).localeCompare(String(r.ts))).pop()?.phase||null}i(zn,"reachedPhaseOf");function Jn(e,t=[],n,s=null,r=null,a=!1){const d=e.filter(b=>b.started&&!b.done&&b.kind!==pe),c=d.every(ee),u=c?d:d.filter(V),g=u.map(b=>String(b.started||"")).sort()[0];if(g===void 0)return null;const m=t.filter(b=>b.kind==="status"&&String(b.ts)>=g&&(c||!b.planner)).sort((b,l)=>String(b.ts).localeCompare(String(l.ts))).pop(),p=u.filter(b=>b.kind!==ve).at(-1),w=u.some(b=>b.kind===ce.install)?ce.install:p?It(p.kind):"claude",x=c?null:u.find(b=>b.stopped&&String(b.stopped.at)>=String(b.started))?.stopped,_=m?.ts||g,O=x?x.at:s!==null&&s>Date.parse(_)?new Date(s).toISOString():_,N=m?m.phase||m.planner?m.text.replace(": "," \xB7 "):m.text||null:c?Vn[w]:null,D=n-Date.parse(O),B=c?null:u.find(b=>b.pause)?.pause??null,T=!c&&!x&&(r==="held"||!!B?.paused),P=c||T?null:x?!1:r,y=T?!1:P===null?D>=gn:!P;return{progress:N,phase:m?.phase||null,at:_,kind:w,planner:c,silentSince:O,stale:y,alive:P,held:T,quiet:!!B||P===!0&&!a&&D>=kn,stopped:x?Rt(x.run):null,...B?{pause:{cause:B.cause,words:B.words,paused:!!B.paused}}:{}}}i(Jn,"builderOf");const yo={blocked:["nothing blocks it","nothing blocks it"],held:["you unhold it","unheld"],usage:["the usage pause lifts","the usage pause lifted"],bumped:["a slot frees","a slot freed"]},Zn=15*6e4,es=i(e=>(e.agents||[]).find(t=>t.name==="main"&&t.started&&!t.done&&V(t))??null,"mainBuild"),ts=i((e,t,n,{now:s,usageHeld:r})=>e.blocked||e.held||r(n??"claude")||!!(t.until&&s<Date.parse(t.until)),"stillPaused");function bo(e,{now:t=Date.now(),usageHeld:n}){const s={ask:[],drop:[],stop:[],resume:[]},r=[];for(const a of e){if(a.kind!=="work"||a.lane!=="progress")continue;const d=es(a);if(!d)continue;const{pause:c}=d;if(!c){a.builder?.phase!=="landing"&&n(d.kind??"claude")&&s.ask.push(a.key);continue}const u=ts(a,c,d.kind,{now:t,usageHeld:n});if(c.paused){u||r.push({key:a.key,at:c.paused});continue}!u&&c.cause!=="bumped"?s.drop.push(a.key):t-Date.parse(c.at)>=Zn&&s.stop.push(a.key)}return s.resume=r.sort((a,d)=>String(a.at).localeCompare(String(d.at))).map(a=>a.key),s}i(bo,"pauseWork");const dt={opus:"Claude Opus",sonnet:"Claude Sonnet",codex:"Codex"},ns=i(({model:e,kind:t})=>dt[e]||dt[t]||(t==="claude"?dt.opus:null),"modelName"),It=i(e=>e==="opus"||e==="sonnet"?"claude":e,"providerOf");function xe(e){const t=ns(e),{kind:n}=e,s=e.label?.replace(/\bbuilder\b/,"implementer").replace(/\bBuilder\b/,"Implementer"),r=i(d=>d[0].toLowerCase()+d.slice(1),"lower");if(t&&ee(e))return`${t} ${n}`;if(t)return`${t} ${r(s?.replace(/^(?:claude\s+)?(?:opus|sonnet|codex)\b\s*/i,"")||"implementer")}`;const a=n?n[0].toUpperCase()+n.slice(1):"";return a?s?s.toLowerCase().includes(n.toLowerCase())?s:`${a} ${r(s)}`:a:s||"Implementer"}i(xe,"agentName");const qt=i((e,t)=>!!e.resolved&&(!e.resolved_at||String(e.resolved_at)>=String(t)),"resolvedSince");function ss(e,t,n=[],s=[],r=[]){const a=t.filter(O=>O.data?.id===e.id),d=a[a.length-1]||null,c=r.filter(O=>O.data?.question===e.id).at(-1),u=i((O,...N)=>!!O&&N.every(D=>String(O.ts)>String(D||"")),"after"),g=!!(e.resolved&&e.resolved_at&&d&&String(d.ts)>e.resolved_at),m=n.filter(O=>O.data?.question===e.id&&u(O,d?.ts,c?.ts)).at(-1),p=u(c,d?.ts,m?.ts,e.resolved_at),w=e.resolved&&!g&&!p,x=w?s.filter(O=>O.data?.question===e.id&&String(O.ts)>String(e.resolved_at||"")).at(-1):null,_=p?"open":w?"resolved":m?"requested":d?d.reply?"replied":"answered":"open";return{...e,state:_,reopened:p,request:m?{id:m.id,ts:m.ts,note:m.data.note||"",choice:m.data.choice||null}:null,reask:x?{id:x.id,ts:x.ts}:null,answers:a.map(O=>({ts:O.ts,choice:O.data.choice||null,note:O.data.note||"",files:O.data.files||[],reply:O.reply,replies:O.replies,acted:qt(e,O.ts)}))}}i(ss,"ownerQuestion");const fe=i(e=>e.round??(De.test(e.url||"")?1:0),"roundOf");function os(e,t){const n=i((s,r)=>s.confirm_of||(s.options||[]).some(a=>a.id===r.choice),"settles");return e.filter(s=>fe(s)===t&&s.answers.length).map(s=>[s,s.answers.at(-1)]).filter(([s,r])=>n(s,r)).map(([,s])=>s).sort((s,r)=>String(s.ts).localeCompare(String(r.ts))).at(-1)}i(os,"roundSettledBy");function rs(e){const t=e.find(r=>r.request&&!e.some(a=>fe(a)>fe(r)));if(t)return{n:fe(t)+1,state:"making"};const n=Math.max(0,...e.map(fe));if(!n)return null;const s=os(e,n);return s?{n,state:"closed",take:s.choice}:e.some(r=>fe(r)===n&&r.state!=="resolved")?{n,state:"back"}:null}i(rs,"roundState");function as(e){const t=e.filter(n=>De.test(n.url||"")).map(n=>({n:fe(n),q:n.id,url:n.url,confirm:!!n.confirm_of,state:n.state})).sort((n,s)=>n.n-s.n);return t.length?{open:t.some(n=>n.state==="open"),rounds:t}:null}i(as,"prototypesOf");const Oe=i((e,t,n)=>{const s=e.get(t);s?s.push(n):e.set(t,[n])},"add"),$e=i((e,t)=>{const n=new Map;for(const s of e)Oe(n,t(s),s);return n},"groupBy");function ls(e,t,n=new Set){const s=new Set(e.map(d=>d.id)),r=[...e];t.some(d=>!s.has(d.topic))&&r.push({id:"",title:"Other"});const a=$e(t,d=>s.has(d.topic)?d.topic:"");return r.map(d=>{const c=a.get(d.id)||[],u=i(p=>c.filter(w=>w.state===p).length,"count"),g=c.every(p=>p.state==="resolved")||n.has(d.id)&&!u("open"),m=c.length&&g?"resolved":"open";return{...d,state:m,questions:c.map(p=>p.id),open:u("open"),answered:u("answered"),replied:u("replied"),resolved:u("resolved"),round:rs(c)}}).filter(d=>d.questions.length)}i(ls,"ownerTopics");const Qe={implement:"Implementation requested",prototype:"Prototype requested",grill:"Grill requested",visual:"Visual requested",reask:"Re-ask requested",hold:"Held",resume:"Resumed",done:"Marked done",staged:"Marked as staging",readied:"Marked as ready",related:"Related to",unrelated:"Unrelated from",followup:"Follow-up","followup-of":"Follow-up of"},Dt={"grill-more":"grill","prototype-request":"prototype","visual-request":"visual","reask-request":"reask"},Ct={"mark-ready":"Mark ready",...Object.fromEntries(Object.entries(Dt).map(([e,t])=>[e,Qe[t]]))},is=["grill-more","prototype-request","visual-request"],ds="answers submitted",Nt={reply:"Reply",build:"Implement"},cs=i(e=>Nt[e.data.intent],"intentLabel"),us=i((e,t)=>{if(e.kind!=="prototype-request"||!t.has(e.data.question))return e.data.text||(e.data.files?.length?"":E(Ct,e.kind))||"";const n=t.get(e.data.question),s=(n.options||[]).find(r=>r.id===e.data.choice);return[Lt(t,n),s&&`${s.id}. ${s.label}`,e.data.note].filter(Boolean).join(`
3
+ \u2192 `)},"actionText"),Tt=i((e,t)=>[...e.keys()].indexOf(t)+1,"numberOf"),Lt=i((e,t)=>`Question ${Tt(e,t.id)} \xB7 ${t.question}`,"numbered"),ps="question reopened",He=i(e=>e.data?.shared_by?.login?{by:e.data.shared_by.name||e.data.shared_by.login}:{},"byOf"),fs=i((e,t)=>{const n=t.get(e.card);return{...e,text:`${Qe[e.command]} ${n?`${n.ref}: ${n.title}`:e.card}`,link:`#selectedCard=${encodeURIComponent(e.card)}`}},"linkLine"),Pt=i(e=>({kind:"command",command:e,request:!0,mark:Qe[e]}),"commandLine"),gs=i((e,t)=>{if(e.kind==="item-message")return Nt[e.data.intent]?{status:cs(e)}:{};const n={request:!0,command:Dt[e.kind]};return is.includes(e.kind)?(e.data.question?t.has(e.data.question):String(e.data.text||"").trim()||e.data.files?.length)?{status:Ct[e.kind]}:n:e.kind==="reask-request"?n:{}},"requestOf"),ct=i(e=>[...e.filter(t=>t.who==="claude"&&!["status","agent","command",Se,qe.answer].includes(t.kind)).map(t=>t.ts),...e.filter(t=>t.kind==="ask").map(t=>t.reply?.at)].filter(Boolean).map(String).sort().pop()||"","claudeAtOf");function jt(e,t={}){const n=new Map,s=new Map;for(const p of t.items||[])Oe(n,p.topic,p),s.set(p.id,p.topic);const r=new Map,a=new Map,d=new Map,c=new Map,u=new Map,g=new Map,m=new Map;e.forEach((p,w)=>{m.set(p,w),p.data?.key&&fn.includes(p.kind)&&Oe(r,p.data.key,p),p.kind==="owner-answer"&&s.has(p.data?.id)&&Oe(a,s.get(p.data.id),p),p.kind===wt&&s.has(p.data?.question)&&Oe(d,s.get(p.data.question),p),p.kind==="ask"&&c.set(p.id,p)});for(const p of e.filter(w=>w.kind==="ask-edited").sort((w,x)=>String(w.ts).localeCompare(String(x.ts)))){u.set(p.data?.id,p.data?.text);for(const w of p.data?.files||[])Oe(g,p.data?.id,w)}return{byKey:r,answers:a,reopens:d,asks:c,edits:u,editFiles:g,questions:n,order:m}}i(jt,"threadIndex");const ut=i((e,t)=>{const n=t.filter(s=>s?.length);return n.length>1?n.flat().sort((s,r)=>e.order.get(s)-e.order.get(r)):[...n[0]||[]]},"inLogOrder"),ks=/; its log is \S*\/\.claude\/kickflip\/logs\/([^/\s]+\.log)\.$/,ms=i(e=>{const t=!e.log&&typeof e.text=="string"?ks.exec(e.text):null;return t?{...e,text:`${e.text.slice(0,t.index)}.`,log:t[1]}:e},"withLog");function ws(e,t){const n=t.run?e.find(s=>s.started===t.run):e.filter(s=>ee(s)===!!t.planner&&s.started&&String(s.started)<=String(t.ts)&&(!s.done||String(t.ts)<=String(s.done))).pop();return n?{agent:xe(n),run:pt(e,n),running:!n.done}:{}}i(ws,"agentOfLine");function pt(e,t){return t.label!==Ke?t.started:e.filter(n=>V(n)&&n.label!==Ke&&n.started&&String(n.started)<String(t.started)).pop()?.started??t.started}i(pt,"sectionOf");function Ut(e,{lines:t=[],events:n=[],owner:s={},working:r={},fromAsk:a=null,links:d=[],agents:c={},moved:u=[],cards:g=new Map,index:m=jt(n,s)}){const p=e.startsWith("ask:")?[e.slice(4)]:[a,...u].filter(Boolean),w=[...new Set([e,...p.map(l=>`ask:${l}`)])],x=new Map((m.questions.get(`item:${e}`)||[]).map(l=>[l.id,l])),_=m.answers.get(`item:${e}`)||[],O=new Set([...x.values()].map(l=>l.round_of).filter(Boolean)),N=lt(c,!0).filter(V).map(l=>String(l.started||"")).filter(Boolean),D=new Set(_.filter(l=>qt(x.get(l.data.id),l.ts)||O.has(l.data.id)||N.some(A=>A>String(l.ts))).map(l=>l.id)),B=lt(c,!0),T=[...B.flatMap(l=>[...l.started?[{ts:l.started,who:"claude",kind:"agent",text:`${xe(l)} started`,agent:xe(l),run:pt(B,l),finished:!1,eta:l.done?null:l.eta,...l.log?{log:l.log}:{},...ee(l)?{planner:!0}:{}}]:[],...l.done?[{ts:l.done,who:"claude",kind:"agent",text:`${xe(l)} finished`,agent:xe(l),run:pt(B,l),finished:!0,eta:null,...ee(l)?{planner:!0}:{}}]:[],...l.calls.length?[{ts:l.done||l.calls.at(-1).at,who:"claude",kind:"calls",text:xe(l),calls:l.calls.map(A=>A.text),verified:l.verified}]:[]]),...t.map(ms).map(l=>l.card?fs(l,g):l).map(l=>({ts:l.ts,who:l.who||"claude",...l.log?{log:l.log}:{},...l.kind==="status"?{kind:"status",...l.planner?{planner:!0}:{},...ws(B,l)}:{},...l.kind===pe||l.kind===Se?{kind:l.kind}:{},...l.kind===Fe?{kind:Fe,line:l.line,...kt(l)}:{},...l.command?Pt(l.command):{},...l.card?{card:l.card}:{},...Object.values(qe).includes(l.kind)?{kind:l.kind,ask:l.ask}:{},text:l.text||"",html:l.html||null,link:l.link||null,via:l.via||null,...l.by?{by:l.by}:{}})),...ut(m,w.map(l=>m.byKey.get(l))).map(l=>({ts:l.ts,who:"love",via:"site",kind:l.kind,text:us(l,x),files:l.data.files||[],eventId:l.id,reply:l.reply,replies:l.replies,...gs(l,x),...He(l)})),..._.map(l=>{const A=[l.data.label||l.data.choice,l.data.note].filter(Boolean).join(" \xB7 ");return{ts:l.ts,who:"love",via:"questions",kind:l.kind,text:`${Lt(x,x.get(l.data.id))}
4
+ \u2192 ${A}`,files:l.data.files||[],eventId:l.id,reply:l.reply,replies:l.replies,status:ds,...He(l)}}),...(m.reopens.get(`item:${e}`)||[]).map(l=>({ts:l.ts,who:"love",kind:l.kind,request:!0,mark:ps,text:`Question ${Tt(x,l.data.question)} was reopened`,...He(l)})),...ut(m,[...new Set(p)].map(l=>m.asks.has(l)?[m.asks.get(l)]:[])).flatMap(l=>[{ts:l.ts,who:"love",via:"ask",kind:l.kind,text:l.data?.text||"",files:l.data?.files||[],eventId:l.id,reply:l.reply,replies:l.replies,...u.includes(l.id)?{moved:!0}:{},...He(l),...typeof l.data?.from?.title=="string"?{from:l.data.from.title}:{}},...l.data?.quick===!0?[{ts:l.ts,who:"love",...Pt("implement"),text:Qe.implement}]:[],...d.map(A=>({ts:l.ts,who:"claude",kind:"ask-link",text:A.folded?`Moved to ${A.ref}: ${A.title}`:`${A.became?"Became":"Added to"} ${A.ref}`,link:`#selectedCard=${encodeURIComponent(A.key)}`,html:null,via:null}))])].sort((l,A)=>String(l.ts).localeCompare(String(A.ts))),P=ct(T),{edits:y,editFiles:b}=m;for(const l of T){if(!l.eventId)continue;(l.kind==="ask"||l.kind==="item-message")&&typeof y.get(l.eventId)=="string"&&Object.assign(l,{text:y.get(l.eventId),edited:!0,files:[...l.files,...b.get(l.eventId)||[]]});const A=l.kind==="ask"&&(d.length>0||!!l.moved);l.state=l.reply?"replied":A||D.has(l.eventId)||P>String(l.ts)?"answered":E(r,l.eventId)?"working":"waiting",l.canDelete=l.kind==="item-message"&&(l.state==="working"||l.state==="waiting"),l.canEdit=l.canDelete}return hs(T)}i(Ut,"threadOf");const Wt=["waiting","working","answered","replied"];function hs(e){const t=new Map;for(const n of e)n.kind==="owner-answer"&&t.set(n.ts,[...t.get(n.ts)||[],n]);return e.flatMap(n=>{if(n.kind!=="owner-answer")return[n];const s=t.get(n.ts);return s.length===1?[n]:s[0]!==n?[]:[{...n,text:s.map(r=>r.text).join(`
5
5
 
6
- `),files:s.flatMap(r=>r.files),state:s.map(r=>r.state).sort((r,a)=>Wt.indexOf(r)-Wt.indexOf(a))[0],reply:void 0,answers:s.map(r=>({eventId:r.eventId,state:r.state,reply:r.reply,text:r.text}))}]})}i(ws,"foldSubmits");const Ne=i(e=>(e.answers||[e]).filter(t=>t.eventId).map(t=>[t.eventId,t.state]),"stateEntries");function hs(e,t,n,s,r,a){const d=i((p,w)=>{const v=a.filter(x=>x.kind==="wave-triage"&&x.data?.[p]===w).pop(),R=r.filter(x=>x.topic===`${p}:${w}`&&(x.state==="open"||x.state==="answered")).length;return{running:!!(v&&!v.reply),questions:R}},"triageOf"),c=new Map(s.map(p=>[p.key,p])),u=i(p=>p.filter(w=>w.lane==="done"&&!vt(w)).length,"merged"),f=n.map(p=>({l:p,cards:p.keys.map(w=>c.get(w)).filter(Boolean)})).map(p=>({...p,open:!p.l.finished_at&&p.cards.some(w=>w.lane!=="done")})).sort((p,w)=>Number(p.open)-Number(w.open));for(const{l:p,cards:w}of f)for(const v of w)v.wave={slug:p.slug,title:p.title};const g=f.filter(p=>p.open).map(({l:p,cards:w})=>({kind:"wave",slug:p.slug,title:p.title,goal:p.goal,keys:w.map(v=>v.key),next:ys(w),merged:u(w),total:w.length,triage:d("wave",p.slug)}));return e.fromWaves?[...g,...t.filter(p=>!p.finished).map(p=>({w:p,cards:s.filter(w=>w.file===p.slug&&w.kind!=="ask")})).filter(({cards:p})=>p.length).map(({w:p,cards:w})=>({kind:"file",slug:p.slug,title:p.title,goal:null,keys:w.map(v=>v.key),next:null,merged:u(w),total:w.length,triage:d("file",p.slug)}))]:g}i(hs,"waveBandsOf");function ys(e){const t=e.filter(a=>a.lane==="todo"),n=t.find(a=>a.ready&&a.buildable)||t[0];if(!n)return null;const s=n.ready&&n.buildable,r=s?"ready":n.held?"held":n.blockedBy.length?`waits on ${n.blockedBy.map(a=>a.ref).join(", ")}`:n.blockedUntil?`blocked until ${n.blockedUntil}`:n.action?"needs you":n.phase==="new"?"not ready":n.phase;return{key:n.key,ref:n.ref,ready:s,word:r}}i(ys,"nextOf");const bs=i(e=>e.items||e.phases.flat(),"waveItems");function bo(e){const{owner:t={},topicItems:n={},events:s=[],threads:r={},prs:a={},working:d={}}=e,c=e.now??Date.now(),u=jt(s,t),f=new Set(s.filter(o=>o.kind==="ask-withdrawn"&&!o.data?.key).map(o=>o.data?.id)),g=new Map(s.filter(o=>o.kind==="ask"&&!f.has(o.id)).map(o=>[o.id,o])),p=i((o,k)=>new Map(s.filter(S=>S.kind===o).sort((S,O)=>String(S.ts).localeCompare(String(O.ts))).map(S=>[S.data?.[k],S.ts])),"latest"),w=p("ask-bump","id"),v=p("card-unbump","key"),R=new Map([...p("card-bump","key")].filter(([o,k])=>!(String(v.get(o)||"")>String(k)))),x=p("card-done","key"),N=p("card-merge","key"),C=e.autoMerge===!0,_=e.tickets,T=new Map(s.filter(o=>o.kind==="card-hold").sort((o,k)=>String(o.ts).localeCompare(String(k.ts))).map(o=>[o.data?.key,o])),P=new Map,y=new Map(e.files.flatMap(({slug:o,itemFile:k})=>k.items.map(S=>[`${o}/${S.id}`,{ref:Qe(k,S,_),title:S.title}]))),b=e.askLinks||{},l=new Map;for(const[o,k]of Object.entries(b))g.has(o)&&l.set(k,[...l.get(k)||[],o]);const E=[],h=[],ne=new Map,ie=new Map,F=new Map,X=new Map,K=e.github?null:Zt(e.remote);for(const{slug:o,itemFile:k,agents:S={}}of e.files){const O=e.github||k.repo||null;E.push({slug:o,title:k.title||o,status:k.status||null,internal:!!k.internal,finished:!1,reviewers:(k.reviewers||[]).map($=>$.name)}),k.items.forEach(($,q)=>{const I=`${o}/${$.id}`,ce=(l.get(I)||[]).filter(A=>A!==$.from_ask),ue=[$.from_ask,...ce].filter(A=>g.has(A)),Fe=new Set(ue.map(A=>`ask:${A}`)),Ke=[...B(r,I)||[],...ue.flatMap(A=>B(r,`ask:${A}`)||[])];$.from_ask&&P.set($.from_ask,[...P.get($.from_ask)||[],{key:I,ref:Qe(k,$,_),became:!0}]);const Se=Ut(I,{lines:Ke,events:s,owner:t,working:d,fromAsk:$.from_ask||null,moved:ce,cards:y,index:u});for(const A of Se)for(const[m,ee]of Ne(A))ne.set(m,ee);ie.set(I,ct(Se)),h.push(_n({slug:o,itemFile:k,it:$,order:q,repo:O,remote:K,base:e.branch||"main",prs:sn($,O).map(A=>({...A,gh:B(a,rn(A))||null})),...(A=>({agents:A,builder:zn(A,B(r,I),c,e.moved?.[it(B(S,$.id))]??null,B(e.alive,I)??null,!!e.commandRunning?.[it(B(S,$.id))]),reachedPhase:Yn(A,B(r,I)),eta:A.map(m=>m.eta).filter(Boolean).sort().pop()||null}))(lt(B(S,$.id))),worktree:it(B(S,$.id))??$.worktree?.path??null,thread:Ke,events:[...ut(u,[I,...Fe].map(A=>u.byKey.get(A))),...ue.map(A=>g.get(A))],working:Se.some(A=>Ne(A).some(([,m])=>m==="working")),said:Se.filter(A=>A.who==="love"&&(A.kind==="item-message"||A.kind==="owner-answer")),askedAt:(u.questions.get(`item:${I}`)||[]).filter(A=>A.asked_at).map(A=>A.asked_at),topicItems:n,prSlack:e.prSlack||{},boardReviewers:e.reviewers||[],now:c,bumpedAt:R.get(I),holdAsk:T.get(I),closedAt:x.get(I),mergeAt:N.get(I),autoMerge:C,skipDraft:e.skipDraft===!0,tickets:_}));const ve=h[h.length-1];g.has($.from_ask)&&(ve.created=g.get($.from_ask).ts),X.set(I,{parent:$.parent?Kt(o,$.parent):null,related:($.related||[]).map(A=>Kt(o,A))}),ve.lane==="done"&&F.set(I,ve.closedAt||String(ve.updatedAt||""))})}const L=new Map(h.map(o=>[o.key,o])),Y=new Map,z=e.try||{},Te=e.autoBuild===!0,W=["web","app"].includes(z.kind)?z.kind:e.files.some(({itemFile:o})=>o.items.some(k=>k.install?.url))?"app":"web";for(const o of h){if(o.kind!=="work"||o.lane==="done")continue;const k=B(z.cards,o.key)||{},S=k.head||o.pr?.headRefOid,O=W==="web"?k.sha:o.install?.sha,$=o.builder?.kind===pe.install?"running":k.state||(W==="app"&&o.install?"ready":null);o.try={kind:W,state:$,stale:!!(O&&S&&!String(S).toLowerCase().startsWith(String(O).toLowerCase())),url:W==="web"?null:o.install?.url||null,port:W==="web"&&$==="ready"&&k.https||null,sha:O||null,changes:k.ahead>0,script:k.script===!0,autoBuild:Te}}const U=z.main,Le=U?.script&&U.sha?{slug:U.slug,branch:U.branch||"main",sha:U.sha.slice(0,7),at:U.at,kind:W,state:U.state||null,url:W==="web"?null:e.main?.install?.url||null,port:W==="web"&&U.state==="ready"&&U.https||null,pull:z.pull?{running:z.pull.running===!0,error:z.pull.error||null}:null,script:cn(U.target)}:null,G=e.askProgress||{},me=p("ask-done","id"),ze=Ee(s.filter(o=>o.kind==="owner-answer"),o=>o.data?.id),Pe=Ee(s.filter(o=>o.kind==="prototype-request"),o=>o.data?.question),Be=Ee(s.filter(o=>o.kind==="reask-request"),o=>o.data?.question),Je=Ee(s.filter(o=>o.kind===wt),o=>o.data?.question),Q=(t.items||[]).map(o=>ns(o,ze.get(o.id)||[],Pe.get(o.id)||[],Be.get(o.id)||[],Je.get(o.id)||[])),J=new Map(Q.map(o=>[o.id,o])),_e=Ee(Q,o=>o.topic),we=i(o=>{const k=_e.get(o)||[];return{open:k.filter(S=>S.state==="open").length,answered:k.filter(S=>S.state==="answered").length}},"pendingOn");for(const o of g.values()){const k=`ask:${o.id}`,S=L.get(B(b,o.id)),O=[...P.get(o.id)||[]],$=S&&!O.some(I=>I.key===S.key);if($&&O.push({key:S.key,ref:S.ref,title:S.title,became:!1,folded:!0}),O.length&&!$){Y.set(k,O[0].key);continue}if(!$&&B(b,o.id)){Y.set(k,B(b,o.id));continue}const q=Ut(k,{lines:B(r,k)||[],events:s,working:d,links:O,index:u});for(const I of q)for(const[ce,ue]of Ne(I))ne.set(ce,ue);ie.set(k,ct(q)),h.push(Gn(o,q,w.get(o.id),O.length>0||!!B(b,o.id),B(G,o.id),me.get(o.id),we(`item:${k}`),B(e.askTitles||{},o.id)))}for(const o of E){const k=h.filter(S=>S.file===o.slug);if(o.finished=Sn(k),o.finished)for(const S of k)S.lane==="done"&&(S.fold=mn(o.slug))}for(const o of h)o.wave=null;const he=new Set((t.topics||[]).map(o=>o.id)),je=e.files.flatMap(({slug:o,itemFile:k})=>(k.waves||[]).map(S=>({...S,keys:bs(S).map(O=>`${o}/${O}`)}))),Z=i(()=>as([...t.topics||[],...h.filter(o=>!he.has(`item:${o.key}`)).map(o=>({id:`item:${o.key}`,card:o.key,title:`${o.ref}: ${o.title}`,...o.kind==="ask"?{askedAt:o.ask.askedAt}:{}})),...je.filter(o=>!he.has(`wave:${o.slug}`)).map(o=>({id:`wave:${o.slug}`,title:o.title,summary:"Wave triage."})),...(e.fromWaves?E:[]).filter(o=>!he.has(`file:${o.slug}`)).map(o=>({id:`file:${o.slug}`,title:o.title,summary:"Wave triage."}))],Q,new Set(h.filter(fe).map(o=>`item:${o.key}`))),"topicsOf"),se=new Map(Z().map(o=>[o.id,o]));for(const o of h){const k=se.get(`item:${o.key}`);if(!k){o.questions=null,o.prototypes=null;continue}const S=k.questions.filter(q=>J.get(q)?.state!=="resolved"),O=k.questions.find(q=>J.get(q)?.state==="open")||S[0]||k.questions[0],$=k.questions.map(q=>J.get(q)).filter(q=>q?.state==="open");o.questions={topic:k.id,state:k.state,open:k.open,answered:k.answered,replied:k.replied,resolved:k.resolved,first:O,askedAt:$.map(q=>q.asked_at).filter(Boolean).sort(),fromAsks:$.length>0&&$.every(q=>q.ask)},o.prototypes=rs(k.questions.map(q=>J.get(q)))}const de=new Map(h.map(o=>[o.key,o]));for(const o of h){const k=o.kind==="work"&&o.lane!=="done";o.blockedBy=k?o.deps.map(O=>de.get(String(O).includes("/")?O:`${o.file}/${O}`)).filter(O=>O&&O.lane!=="done"&&!O.reopened).map(Ft):[],o.blockedUntil=k?o.blockedUntil??null:null,o.blockReason=k?o.blockReason??null:null,o.blocked=o.blockedBy.length>0||!!o.blockedUntil,Fn(o,J,C),o.lane==="todo"&&o.kind==="work"&&!o.held&&Bt(o.storedLane,o.agents)&&(o.lane="progress"),o.unpicked=o.kind==="work"&&o.lane==="todo"&&!!Ln(Q,o.key),o.kind==="work"&&(o.phase=Gs(o)),o.unpicked&&!o.action&&(o.next=Pn),o.buildable=Nn(o);const S=o.kind==="work"&&o.lane==="todo";o.unsorted=S&&(!!o.fromAsk||o.unfiled)&&!o.filedHeld&&o.phase==="new",o.ready=S&&o.phase==="ready"&&!o.blocked&&!o.action,o.staging=S&&o.phase==="staging",o.kind==="work"&&(o.hostHeld=!!e.hostBusy&&o.ready&&!!o.bumpedAt&&!o.held)}xs(h,de,X);const ye=new Map((t.items||[]).map(o=>[o.id,o.topic])),Re=i(o=>o.kind==="owner-answer"?ye.has(o.data?.id)?/^item:(.+)$/.exec(ye.get(o.data.id))?.[1]||null:"":o.kind==="ask"?`ask:${o.id}`:o.data?.key||(o.kind.startsWith("ask-")&&o.data?.id?`ask:${o.data.id}`:null),"ownCardOf"),Ue=i(o=>{const k=Re(o);return Y.get(k)||k},"cardOf"),M=i(o=>{const k=o.startsWith("ask:")?o.slice(4):null,S=k&&B(G,k)?.state==="done"?B(G,k).at:null;return[x.get(o),k&&me.get(k),S,F.get(o)].filter(Boolean).sort().pop()||""},"closedAt"),Ze=i(o=>{const k=Ue(o);return k===null?!o.reply:!de.has(k)||!(M(k)<String(B(d,o.id)))?!1:ne.has(o.id)?ne.get(o.id)==="working":!o.reply&&!Y.has(Re(o))&&!(String(ie.get(k)||"")>String(o.ts))},"unanswered"),oe=s.filter(o=>B(d,o.id)&&Ze(o)).map(o=>({id:o.id,kind:o.kind,key:Ue(o),data:o.data,since:B(d,o.id)}));for(const o of h)o.working=oe.some(k=>k.key===o.key),o.kind==="work"&&o.lane==="progress"&&!o.builder&&!o.next&&o.waitsOn!=="checking"&&!o.working&&(o.next=_t),o.sortAt=Os[o.lane](o)||(o.lane==="review"?null:o.updatedAt)||null;for(const o of h){if(o.kind!=="work")continue;const k=(_e.get(`item:${o.key}`)||[]).filter(O=>O.state==="answered").map(O=>O.answers.at(-1).ts).sort().pop(),S=oe.filter(O=>O.key===o.key).map(O=>String(O.since)).sort()[0];o.orchestrator=!o.stalled&&(["progress","todo"].includes(o.lane)||o.waitsOn==="checking"||o.lane==="review"&&(o.stale||o.waitFacts.unblockedAt))?Ys(o,o.waitFacts,{answeredAt:k,workingSince:S}):null,delete o.waitFacts}Ps(h,s,d),js(h,e.screening||{}),h.sort(un);const j=hs(e,E,je,h,Q,s),be=Z(),Me=en({on:e.autoReview,incoming:e.incoming,records:e.reviewRecords,events:s,now:c,refs:new Map(h.filter(o=>o.kind==="work").map(o=>[o.key,o.ref]))}),re=[...As(h,be,Q),...tn(Me)],Ie=new Map(re.filter(o=>o.questions).map((o,k)=>[o.topic||`item:${o.key}`,k])),qe=i(o=>Ie.get(o.id)??Ie.size,"rankOf");be.sort((o,k)=>qe(o)-qe(k));const et=new Set(re.filter(o=>o.questions&&o.progress).map(o=>`item:${o.key}`));for(const o of be)et.has(o.id)&&(o.progress=!0);const We=h.filter(o=>o.ask?.answerAt).sort((o,k)=>k.ask.answerAt.localeCompare(o.ask.answerAt)).map(o=>({key:o.key,id:o.id,text:o.title,at:o.ask.answerAt}));return Ss({kind:W,main:Le,remote:K&&{host:K.host,name:`${K.host}/${K.path}`},itemFiles:E,waveBands:j,items:h,moved:Object.fromEntries(Y),answers:We,owner:Q,ownerTopics:be,reviews:Me,needs:re,working:oe.length,workingOn:oe,checks:$s(e,c)},e)}i(bo,"buildBoard");function Ss(e,{listen:t,prompts:n}={}){const s=[...Bs(n),...e.needs];return{...e,needs:s,needsSummary:_s(s),checks:{...e.checks,watcher:{listening:"running",asleep:"asleep",waking:"waking"}[t]||"stopped"}}}i(Ss,"withHub");const Ft=i(e=>({key:e.key,ref:e.ref}),"linkOf"),Kt=i((e,t)=>String(t).includes("/")?String(t):`${e}/${t}`,"linkKey"),vs=i((e,t)=>e.ref.localeCompare(t.ref,void 0,{numeric:!0}),"byRef");function xs(e,t,n){const s=new Map,r=new Map,a=new Map,d=i((u,f,g)=>u.set(f,[...u.get(f)||[],g]),"add");for(const[u,f]of n){f.parent&&d(s,f.parent,u);for(const g of f.related)g!==u&&(d(r,u,g),d(r,g,u))}for(const u of e)for(const f of u.blockedBy||[])d(a,f.key,u.key);const c=i((u=[])=>[...new Set(u)].map(f=>t.get(f)).filter(Boolean).map(Ft).sort(vs),"cards");for(const u of e){const f=n.get(u.key)?.parent;u.parent=f?{key:f,ref:t.get(f)?.ref||f.slice(f.indexOf("/")+1)}:null,u.children=c(s.get(u.key)),u.related=c(r.get(u.key)),u.waitsOnIt=c(a.get(u.key))}}i(xs,"linkCards");const Os={todo:i(e=>e.created,"todo"),progress:i(e=>e.progressSince,"progress"),review:i(e=>e.reviewSince,"review"),done:i(e=>e.closedAt,"done"),asks:i(e=>e.ask.answerAt,"asks")},le=i((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural");function $s({checked:e,watcher:t,replyAt:n,threads:s={},working:r={},files:a=[]},d){const c=Number(e?.every)||30,f=[n,t?.since,...Object.values(r),...Object.values(s).flat().filter(p=>(p.who||"claude")==="claude").map(p=>p.ts),...a.flatMap(p=>Object.values(p.agents||{}).flatMap(w=>Object.values(w||{})).map(w=>w?.done||w?.started))].filter(p=>typeof p=="string"&&!Number.isNaN(Date.parse(p))).reduce((p,w)=>p&&Date.parse(p)>Date.parse(w)?p:w,null),g=!!e?.idle;return{at:e?.at||null,every:g?null:c,idle:g,late:!g&&!!e?.at&&d-Date.parse(e.at)>2*c*6e4,claudeAt:f}}i($s,"checksOf");function As(e,t,n){const s=new Set(e.map(c=>c.questions?.topic).filter(Boolean)),r=i(c=>c.find(u=>n.find(f=>f.id===u)?.state==="open")||c[0],"firstOpen"),a=t.filter(c=>c.state!=="resolved"&&c.open>0&&!s.has(c.id)).map(c=>{const u=`questions.html#${r(c.questions)}`,f=/^(?:wave|file):(.+)$/.exec(c.id)?.[1]||null;return{kind:"Question",title:c.title,text:`${c.title} \xB7 ${le(c.open,"question")}`,url:u,topic:c.id,band:f,questions:{open:c.open,url:u},ready:null,since:n.filter(g=>g.topic===c.id&&g.state==="open").map(g=>g.asked_at).filter(Boolean).sort()[0]||null}}),d=e.map(c=>{const u=c.questions&&c.questions.state!=="resolved"&&c.questions.open>0?{open:c.questions.open,url:`questions.html#${c.questions.first}`}:null,f=c.waitsOn==="ready"?c.pr.url:null,g=!u&&!f&&c.action?{label:c.action.label,url:c.action.url}:null;if(!u&&!f&&!g)return null;const p=`${c.ref}: ${c.title}`,w=[p,u&&le(u.open,"question"),f&&"Ready on GitHub",g?.label].filter(Boolean).join(" \xB7 ");return{kind:u?"Question":f?"Tap Ready":"Action needed",title:p,text:w,url:`#selectedCard=${encodeURIComponent(c.key)}`,key:c.key,questions:u,ready:f,action:g,since:c.created||null,progress:c.lane==="progress"}}).filter(Boolean);return[...a,...d].sort(Es)}i(As,"needsOf");const Es=i((e,t)=>!!t.progress-!!e.progress||(e.since&&t.since?e.since.localeCompare(t.since):!!t.since-!!e.since),"oldestFirst");function Bs(e=[]){return e.map(t=>{const n=t.questions?.length?`Question: ${t.questions.map(s=>s.question).join(" \xB7 ")}`:`${t.tool}: ${t.detail||t.action}`;return{kind:"Prompt",title:n,text:n,url:"",prompt:t}})}i(Bs,"promptLines");function _s(e){const t=e.filter(a=>a.prompt).length,n=e.reduce((a,d)=>a+(d.questions?.open||0),0),s=e.filter(a=>a.ready).length,r=e.filter(a=>a.review).length;return[t&&le(t,"prompt"),n&&le(n,"question"),s&&`${le(s,"draft")} waiting on Ready`,r&&`${le(r,"review")} held`].filter(Boolean).join(" \xB7 ")}i(_s,"needsSummary");function So(e){const t=i((...n)=>e.items.filter(s=>n.includes(s.lane)).length,"count");return{items:e.needs.map(({kind:n,text:s,url:r})=>({kind:n,text:s,url:r})),working:e.working,summary:e.needsSummary,lanes:{review:t("review"),progress:t("progress"),todo:t("todo")},building:e.items.some(n=>(n.agents||[]).some(s=>!s.done))}}i(So,"needsAnswer");const Rs=i(e=>e.buildable&&e.phase==="ready"&&!e.held&&!e.blocked,"pullableCard"),Ms=10;function Is(e,{cap:t=Ms,pulled:n=[],hold:s=[],taken:r=0}={}){const a=e.filter(y=>!fe(y)),d=i((y,b)=>y.started&&!y.done&&V(y)&&!(y.kind===Oe&&!y.writes)&&!y.pause?.paused&&!(y.waits&&b.some(l=>l.name===y.waits&&!l.done)),"counts"),c=a.filter(y=>!y.stalled).reduce((y,b)=>y+(b.agents||[]).filter((l,E,h)=>d(l,h)).length,0),u=a.filter(y=>Rs(y)&&!y.working).map(y=>y.key),f=a.filter(y=>n.includes(y.key)&&(u.includes(y.key)||y.buildable&&y.working)).map(y=>y.key),g=a.flatMap(y=>(y.agents||[]).filter(b=>b.kind===Oe&&!b.started&&!b.done).map(b=>({key:y.key,name:b.name,writes:b.writes}))),p=Math.max(0,t-c-f.length-r),w=g.filter(y=>y.writes),v=[...g.filter(y=>!y.writes),...w.slice(0,p)].map(({key:y,name:b})=>({key:y,name:b})),R=Math.max(0,p-w.length),x=new Set(a.filter(y=>y.bumpedAt).map(y=>y.key)),N=u.filter(y=>!f.includes(y)&&!s.includes(y)),C=N.filter(y=>x.has(y)),_=[...C,...N.filter(y=>!x.has(y)).slice(0,Math.max(0,R-C.length))],T=C.slice(R),P=qs(a,d).slice(0,T.length).map((y,b)=>({key:y,by:T[b]}));return{idle:!c&&!a.some(y=>y.waitsOn==="checking"),pullable:u,waiting:f,pulls:_,helpers:v,bumpOuts:P,pastCap:T,free:p}}i(Is,"pullOf");function qs(e,t){const n=i(s=>{const r=s.agents||[],a=r.filter(u=>t(u,r)),[d]=a;return s.lane==="progress"&&!s.bumpedAt&&!s.stalled&&s.waitsOn!=="checking"&&s.builder?.phase!=="landing"&&!(s.prs||[]).length&&!s.pushed&&!s.mergeReady&&a.length===1&&d.kind!==Oe&&d.pid&&d.label!==He&&!d.pause&&!r.some(u=>u.kind===Oe&&u.started&&!u.done)?String(d.started):null},"newest");return e.map(s=>({key:s.key,at:n(s)})).filter(s=>s.at).sort((s,r)=>r.at.localeCompare(s.at)).map(s=>s.key)}i(qs,"bumpOutsOf");function vo(e,t,n){return e.filter(s=>s.kind==="work"&&!fe(s)&&s.waitsOn!=="checking"&&!(s.agents||[]).some(r=>r.started&&!r.done)).flatMap(s=>{const r=(s.prs||[]).find(d=>d.state==="OPEN"&&d.mergeable==="CONFLICTING"&&d.repo===s.repo&&d.headRefOid),a=r&&`${r.headRefOid}@${n}`;return r&&B(t,s.key)!==a?[{key:s.key,pr:r.number,branch:r.headRefName,conflict:a}]:[]})}i(vo,"rebasesDue");const Ds=3;function xo(e,{cap:t=Ds}={}){const n=e.filter(d=>!fe(d)),s=n.filter(d=>(d.agents||[]).some(c=>te(c)&&c.started&&!c.done)).length,r=n.filter(d=>d.buildable&&!["ready","staging"].includes(d.phase)&&!d.unsorted&&!d.blocked&&!d.held&&!d.working&&!d.grilling&&!d.prototyping&&!d.questions&&!(d.agents||[]).some(c=>te(c)&&c.kind!==ge)),a=r.filter(d=>d.bumpedAt);return[...a,...r.filter(d=>!d.bumpedAt).slice(0,Math.max(0,t-s-a.length))].map(d=>d.key)}i(xo,"arrivalsOf");function Oo(e){return e.filter(t=>t.kind==="work"&&t.lane==="todo"&&t.roundAt&&["grilling","prototyping"].includes(t.phase)&&!(t.agents||[]).some(n=>te(n)&&n.kind!==ge&&n.started&&(String(n.started)>=String(t.roundAt)||!n.done))).map(t=>({key:t.key,kind:t.phase==="grilling"?"grill":"prototype"}))}i(Oo,"roundsDue");const Cs=i(e=>`${ge}-${e.id}`,"visualAgent");function $o(e,t){const n=[];for(const s of e){const r=s.agents||[];if(r.some(c=>c.kind===ge&&c.started&&!c.done))continue;const a=new Set(r.map(c=>c.name)),d=t.find(c=>c.kind==="visual-request"&&c.data?.key===s.key&&!a.has(Cs(c)));d&&n.push({key:s.key,request:d})}return n}i($o,"visualsDue");const Ns=i(e=>e.kind==="ask"?`ask:${e.id}`:e.kind==="card-added"?e.data?.key??null:e.kind==="item-message"&&String(e.data?.key||"").startsWith("ask:")?e.data.key:null,"intakeKeyOf");function Ts(e,t,n){const s=e.get(n);return s?t.kind==="ask"?s.isNew:t.kind==="card-added"?s.kind==="work"&&s.unfiled:(s.ask?.owed||[]).includes(t.id):!1}i(Ts,"unsorted");const Ls={ask:"Sort the new task: file it with item add --from-ask, fold it with item relate-ask, or answer it with reply","item-message":"Answer the owner's message in the ask's thread: reply to it","card-added":"Link and file the card an agent added: item notes, then item set --relate and --phase"};function Ps(e,t,n){const s=new Map(e.map(a=>[a.key,a])),r=new Set;for(const a of t){const d=Ns(a);!d||r.has(d)||!Ts(s,a,d)||(r.add(d),s.get(d).orchestrator={kind:"intake",since:String(a.ts),picked:B(n,a.id)||null,next:Ls[a.kind]})}}i(Ps,"intakeWaits");function js(e,t){for(const n of e){const s=B(t,n.key);s&&(n.orchestrator={kind:"screen",since:s.since,picked:null,next:`Screen the grill's questions ${s.ids.join(", ")}: question settle <id> --note for each the board already answers, then question publish ${n.key}; left 15 minutes unscreened, they reach the owner as they are`})}}i(js,"screenWaits");function Us(e){return e.filter(t=>t.lane==="todo"||t.lane==="review"&&t.stale).map(t=>JSON.stringify([t.key,t.title,t.deps||[]])).sort().join(`
7
- `)}i(Us,"todoOf");function Ao(e){const t=e.filter(s=>s.kind==="work"&&s.lane!=="done"&&s.questions?.open>0),n=t.map(s=>JSON.stringify([s.key,s.questions.open,s.questions.askedAt||[]])).sort().join(`
6
+ `),files:s.flatMap(r=>r.files),state:s.map(r=>r.state).sort((r,a)=>Wt.indexOf(r)-Wt.indexOf(a))[0],reply:void 0,answers:s.map(r=>({eventId:r.eventId,state:r.state,reply:r.reply,replies:r.replies,text:r.text}))}]})}i(hs,"foldSubmits");const Ce=i(e=>(e.answers||[e]).filter(t=>t.eventId).map(t=>[t.eventId,t.state]),"stateEntries");function ys(e,t,n,s,r,a){const d=i((p,w)=>{const x=a.filter(O=>O.kind==="wave-triage"&&O.data?.[p]===w).pop(),_=r.filter(O=>O.topic===`${p}:${w}`&&(O.state==="open"||O.state==="answered")).length;return{running:!!(x&&!x.reply),questions:_}},"triageOf"),c=new Map(s.map(p=>[p.key,p])),u=i(p=>p.filter(w=>w.lane==="done"&&!vt(w)).length,"merged"),g=n.map(p=>({l:p,cards:p.keys.map(w=>c.get(w)).filter(Boolean)})).map(p=>({...p,open:!p.l.finished_at&&p.cards.some(w=>w.lane!=="done")})).sort((p,w)=>Number(p.open)-Number(w.open));for(const{l:p,cards:w}of g)for(const x of w)x.wave={slug:p.slug,title:p.title};const m=g.filter(p=>p.open).map(({l:p,cards:w})=>({kind:"wave",slug:p.slug,title:p.title,goal:p.goal,keys:w.map(x=>x.key),next:bs(w),merged:u(w),total:w.length,triage:d("wave",p.slug)}));return e.fromWaves?[...m,...t.filter(p=>!p.finished).map(p=>({w:p,cards:s.filter(w=>w.file===p.slug&&w.kind!=="ask")})).filter(({cards:p})=>p.length).map(({w:p,cards:w})=>({kind:"file",slug:p.slug,title:p.title,goal:null,keys:w.map(x=>x.key),next:null,merged:u(w),total:w.length,triage:d("file",p.slug)}))]:m}i(ys,"waveBandsOf");function bs(e){const t=e.filter(a=>a.lane==="todo"),n=t.find(a=>a.ready&&a.buildable)||t[0];if(!n)return null;const s=n.ready&&n.buildable,r=s?"ready":n.held?"held":n.blockedBy.length?`waits on ${n.blockedBy.map(a=>a.ref).join(", ")}`:n.blockedUntil?`blocked until ${n.blockedUntil}`:n.action?"needs you":n.phase==="new"?"not ready":n.phase;return{key:n.key,ref:n.ref,ready:s,word:r}}i(bs,"nextOf");const Ss=i(e=>e.items||e.phases.flat(),"waveItems");function So(e){const{owner:t={},topicItems:n={},events:s=[],threads:r={},prs:a={},working:d={}}=e,c=e.now??Date.now(),u=jt(s,t),g=new Set(s.filter(o=>o.kind==="ask-withdrawn"&&!o.data?.key).map(o=>o.data?.id)),m=new Map(s.filter(o=>o.kind==="ask"&&!g.has(o.id)).map(o=>[o.id,o])),p=i((o,k)=>new Map(s.filter(S=>S.kind===o).sort((S,$)=>String(S.ts).localeCompare(String($.ts))).map(S=>[S.data?.[k],S.ts])),"latest"),w=p("ask-bump","id"),x=p("card-unbump","key"),_=new Map([...p("card-bump","key")].filter(([o,k])=>!(String(x.get(o)||"")>String(k)))),O=p("card-done","key"),N=p("card-merge","key"),D=e.autoMerge===!0,B=e.tickets,T=new Map(s.filter(o=>o.kind==="card-hold").sort((o,k)=>String(o.ts).localeCompare(String(k.ts))).map(o=>[o.data?.key,o])),P=new Map,y=new Map(e.files.flatMap(({slug:o,itemFile:k})=>k.items.map(S=>[`${o}/${S.id}`,{ref:nt(k,S,B),title:S.title}]))),b=e.askLinks||{},l=new Map;for(const[o,k]of Object.entries(b))m.has(o)&&l.set(k,[...l.get(k)||[],o]);const A=[],h=[],te=new Map,ae=new Map,G=new Map,X=new Map,F=e.github?null:en(e.remote);for(const{slug:o,itemFile:k,agents:S={}}of e.files){const $=e.github||k.repo||null;A.push({slug:o,title:k.title||o,status:k.status||null,internal:!!k.internal,finished:!1,reviewers:(k.reviewers||[]).map(v=>v.name)}),k.items.forEach((v,M)=>{const I=`${o}/${v.id}`,he=(l.get(I)||[]).filter(f=>f!==v.from_ask),se=[v.from_ask,...he].filter(f=>m.has(f)),Ze=new Set(se.map(f=>`ask:${f}`)),We=[...E(r,I)||[],...se.flatMap(f=>E(r,`ask:${f}`)||[])];v.from_ask&&P.set(v.from_ask,[...P.get(v.from_ask)||[],{key:I,ref:nt(k,v,B),became:!0}]);const ye=Ut(I,{lines:We,events:s,owner:t,working:d,fromAsk:v.from_ask||null,moved:he,cards:y,index:u});for(const f of ye)for(const[W,Qt]of Ce(f))te.set(W,Qt);ae.set(I,ct(ye)),h.push(Rn({slug:o,itemFile:k,it:v,order:M,repo:$,remote:F,base:e.branch||"main",prs:on(v,$).map(f=>({...f,gh:E(a,an(f))||null})),...(f=>({agents:f,builder:Jn(f,E(r,I),c,e.moved?.[it(E(S,v.id))]??null,E(e.alive,I)??null,!!e.commandRunning?.[it(E(S,v.id))]),reachedPhase:zn(f,E(r,I)),eta:f.map(W=>W.eta).filter(Boolean).sort().pop()||null}))(lt(E(S,v.id))),worktree:it(E(S,v.id))??v.worktree?.path??null,thread:We,events:[...ut(u,[I,...Ze].map(f=>u.byKey.get(f))),...se.map(f=>m.get(f))],working:ye.some(f=>Ce(f).some(([,W])=>W==="working")),said:ye.filter(f=>f.who==="love"&&(f.kind==="item-message"||f.kind==="owner-answer")),askedAt:(u.questions.get(`item:${I}`)||[]).filter(f=>f.asked_at).map(f=>f.asked_at),topicItems:n,prSlack:e.prSlack||{},boardReviewers:e.reviewers||[],now:c,bumpedAt:_.get(I),holdAsk:T.get(I),closedAt:O.get(I),mergeAt:N.get(I),autoMerge:D,skipDraft:e.skipDraft===!0,tickets:B}));const be=h[h.length-1];m.has(v.from_ask)&&(be.created=m.get(v.from_ask).ts),X.set(I,{parent:v.parent?Kt(o,v.parent):null,related:(v.related||[]).map(f=>Kt(o,f))}),be.lane==="done"&&G.set(I,be.closedAt||String(be.updatedAt||""))})}const L=new Map(h.map(o=>[o.key,o])),Y=new Map,z=e.try||{},Ne=e.autoBuild===!0,U=["web","app"].includes(z.kind)?z.kind:e.files.some(({itemFile:o})=>o.items.some(k=>k.install?.url))?"app":"web";for(const o of h){if(o.kind!=="work"||o.lane==="done")continue;const k=E(z.cards,o.key)||{},S=k.head||o.pr?.headRefOid,$=U==="web"?k.sha:o.install?.sha,v=o.builder?.kind===ce.install?"running":k.state||(U==="app"&&o.install?"ready":null);o.try={kind:U,state:v,stale:!!($&&S&&!String(S).toLowerCase().startsWith(String($).toLowerCase())),url:U==="web"?null:o.install?.url||null,port:U==="web"&&v==="ready"&&k.https||null,sha:$||null,changes:k.ahead>0,script:k.script===!0,autoBuild:Ne}}const j=z.main,Te=j?.script&&j.sha?{slug:j.slug,branch:j.branch||"main",sha:j.sha.slice(0,7),at:j.at,kind:U,state:j.state||null,url:U==="web"?null:e.main?.install?.url||null,port:U==="web"&&j.state==="ready"&&j.https||null,pull:z.pull?{running:z.pull.running===!0,error:z.pull.error||null}:null,script:un(j.target)}:null,K=e.askProgress||{},ge=p("ask-done","id"),Ve=$e(s.filter(o=>o.kind==="owner-answer"),o=>o.data?.id),Le=$e(s.filter(o=>o.kind==="prototype-request"),o=>o.data?.question),Ae=$e(s.filter(o=>o.kind==="reask-request"),o=>o.data?.question),Xe=$e(s.filter(o=>o.kind===wt),o=>o.data?.question),Q=(t.items||[]).map(o=>ss(o,Ve.get(o.id)||[],Le.get(o.id)||[],Ae.get(o.id)||[],Xe.get(o.id)||[])),J=new Map(Q.map(o=>[o.id,o])),Ee=$e(Q,o=>o.topic),ke=i(o=>{const k=Ee.get(o)||[];return{open:k.filter(S=>S.state==="open").length,answered:k.filter(S=>S.state==="answered").length}},"pendingOn");for(const o of m.values()){const k=`ask:${o.id}`,S=L.get(E(b,o.id)),$=[...P.get(o.id)||[]],v=S&&!$.some(I=>I.key===S.key);if(v&&$.push({key:S.key,ref:S.ref,title:S.title,became:!1,folded:!0}),$.length&&!v){Y.set(k,$[0].key);continue}if(!v&&E(b,o.id)){Y.set(k,E(b,o.id));continue}const M=Ut(k,{lines:E(r,k)||[],events:s,working:d,links:$,index:u});for(const I of M)for(const[he,se]of Ce(I))te.set(he,se);ae.set(k,ct(M)),h.push(Qn(o,M,w.get(o.id),$.length>0||!!E(b,o.id),E(K,o.id),ge.get(o.id),ke(`item:${k}`),E(e.askTitles||{},o.id)))}for(const o of A){const k=h.filter(S=>S.file===o.slug);if(o.finished=vn(k),o.finished)for(const S of k)S.lane==="done"&&(S.fold=wn(o.slug))}for(const o of h)o.wave=null;const me=new Set((t.topics||[]).map(o=>o.id)),Be=e.files.flatMap(({slug:o,itemFile:k})=>(k.waves||[]).map(S=>({...S,keys:Ss(S).map($=>`${o}/${$}`)}))),Z=i(()=>ls([...t.topics||[],...h.filter(o=>!me.has(`item:${o.key}`)).map(o=>({id:`item:${o.key}`,card:o.key,title:`${o.ref}: ${o.title}`,...o.kind==="ask"?{askedAt:o.ask.askedAt}:{}})),...Be.filter(o=>!me.has(`wave:${o.slug}`)).map(o=>({id:`wave:${o.slug}`,title:o.title,summary:"Wave triage."})),...(e.fromWaves?A:[]).filter(o=>!me.has(`file:${o.slug}`)).map(o=>({id:`file:${o.slug}`,title:o.title,summary:"Wave triage."}))],Q,new Set(h.filter(ue).map(o=>`item:${o.key}`))),"topicsOf"),ne=new Map(Z().map(o=>[o.id,o]));for(const o of h){const k=ne.get(`item:${o.key}`);if(!k){o.questions=null,o.prototypes=null;continue}const S=k.questions.filter(M=>J.get(M)?.state!=="resolved"),$=k.questions.find(M=>J.get(M)?.state==="open")||S[0]||k.questions[0],v=k.questions.map(M=>J.get(M)).filter(M=>M?.state==="open");o.questions={topic:k.id,state:k.state,open:k.open,answered:k.answered,replied:k.replied,resolved:k.resolved,first:$,askedAt:v.map(M=>M.asked_at).filter(Boolean).sort(),fromAsks:v.length>0&&v.every(M=>M.ask)},o.prototypes=as(k.questions.map(M=>J.get(M)))}const le=new Map(h.map(o=>[o.key,o])),_e=new Map(Be.map(o=>[`wave:${o.slug}`,o.keys]));for(const o of h){const k=o.kind==="work"&&o.lane!=="done",S=new Set(o.deps.flatMap(v=>_e.get(v)||[String(v).includes("/")?v:`${o.file}/${v}`]));o.blockedBy=k?[...S].map(v=>le.get(v)).filter(v=>v&&v.lane!=="done"&&!v.reopened).map(Ft):[],o.blockedUntil=k?o.blockedUntil??null:null,o.blockReason=k?o.blockReason??null:null,o.blocked=o.blockedBy.length>0||!!o.blockedUntil,Kn(o,J,D),o.lane==="todo"&&o.kind==="work"&&!o.held&&Bt(o.storedLane,o.agents)&&(o.lane="progress"),o.unpicked=o.kind==="work"&&o.lane==="todo"&&!!Pn(Q,o.key),o.kind==="work"&&(o.phase=Qs(o)),o.unpicked&&!o.action&&(o.next=jn),o.buildable=Tn(o);const $=o.kind==="work"&&o.lane==="todo";o.unsorted=$&&(!!o.fromAsk||o.unfiled)&&!o.filedHeld&&o.phase==="new",o.ready=$&&o.phase==="ready"&&!o.blocked&&!o.action,o.staging=$&&o.phase==="staging",o.kind==="work"&&(o.hostHeld=!!e.hostBusy&&o.ready&&!!o.bumpedAt&&!o.held)}Os(h,le,X);const Re=new Map((t.items||[]).map(o=>[o.id,o.topic])),Pe=i(o=>o.kind==="owner-answer"?Re.has(o.data?.id)?/^item:(.+)$/.exec(Re.get(o.data.id))?.[1]||null:"":o.kind==="ask"?`ask:${o.id}`:o.data?.key||(o.kind.startsWith("ask-")&&o.data?.id?`ask:${o.data.id}`:null),"ownCardOf"),R=i(o=>{const k=Pe(o);return Y.get(k)||k},"cardOf"),Ye=i(o=>{const k=o.startsWith("ask:")?o.slice(4):null,S=k&&E(K,k)?.state==="done"?E(K,k).at:null;return[O.get(o),k&&ge.get(k),S,G.get(o)].filter(Boolean).sort().pop()||""},"closedAt"),Me=i(o=>{const k=R(o);return k===null?!o.reply:!le.has(k)||!(Ye(k)<String(E(d,o.id)))?!1:te.has(o.id)?te.get(o.id)==="working":!o.reply&&!Y.has(Pe(o))&&!(String(ae.get(k)||"")>String(o.ts))},"unanswered"),C=s.filter(o=>E(d,o.id)&&Me(o)).map(o=>({id:o.id,kind:o.kind,key:R(o),data:o.data,since:E(d,o.id)}));for(const o of h)o.working=C.some(k=>k.key===o.key),o.kind==="work"&&o.lane==="progress"&&!o.builder&&!o.next&&o.waitsOn!=="checking"&&!o.working&&(o.next=_t),o.sortAt=$s[o.lane](o)||(o.lane==="review"?null:o.updatedAt)||null;for(const o of h){if(o.kind!=="work")continue;const k=(Ee.get(`item:${o.key}`)||[]).filter($=>$.state==="answered").map($=>$.answers.at(-1).ts).sort().pop(),S=C.filter($=>$.key===o.key).map($=>String($.since)).sort()[0];o.orchestrator=!o.stalled&&(["progress","todo"].includes(o.lane)||o.waitsOn==="checking"||o.lane==="review"&&(o.stale||o.waitFacts.unblockedAt))?zs(o,o.waitFacts,{answeredAt:k,workingSince:S}):null,delete o.waitFacts}js(h,s,d),Us(h,e.screening||{}),h.sort(pn);const ze=ys(e,A,Be,h,Q,s),ie=Z(),de=tn({on:e.autoReview,incoming:e.incoming,records:e.reviewRecords,events:s,now:c,refs:new Map(h.filter(o=>o.kind==="work").map(o=>[o.key,o.ref]))}),we=[...Es(h,ie,Q),...nn(de)],Ie=new Map(we.filter(o=>o.questions).map((o,k)=>[o.topic||`item:${o.key}`,k])),je=i(o=>Ie.get(o.id)??Ie.size,"rankOf");ie.sort((o,k)=>je(o)-je(k));const Ue=new Set(we.filter(o=>o.questions&&o.progress).map(o=>`item:${o.key}`));for(const o of ie)Ue.has(o.id)&&(o.progress=!0);const Je=h.filter(o=>o.ask?.answerAt).sort((o,k)=>k.ask.answerAt.localeCompare(o.ask.answerAt)).map(o=>({key:o.key,id:o.id,text:o.title,at:o.ask.answerAt}));return vs({kind:U,main:Te,remote:F&&{host:F.host,name:`${F.host}/${F.path}`},itemFiles:A,waveBands:ze,items:h,moved:Object.fromEntries(Y),answers:Je,owner:Q,ownerTopics:ie,reviews:de,needs:we,working:C.length,workingOn:C,checks:As(e,c)},e)}i(So,"buildBoard");function vs(e,{listen:t,prompts:n}={}){const s=[..._s(n),...e.needs];return{...e,needs:s,needsSummary:Rs(s),checks:{...e.checks,watcher:{listening:"running",asleep:"asleep",waking:"waking"}[t]||"stopped"}}}i(vs,"withHub");const Ft=i(e=>({key:e.key,ref:e.ref}),"linkOf"),Kt=i((e,t)=>String(t).includes("/")?String(t):`${e}/${t}`,"linkKey"),xs=i((e,t)=>e.ref.localeCompare(t.ref,void 0,{numeric:!0}),"byRef");function Os(e,t,n){const s=new Map,r=new Map,a=new Map,d=i((u,g,m)=>u.set(g,[...u.get(g)||[],m]),"add");for(const[u,g]of n){g.parent&&d(s,g.parent,u);for(const m of g.related)m!==u&&(d(r,u,m),d(r,m,u))}for(const u of e)for(const g of u.blockedBy||[])d(a,g.key,u.key);const c=i((u=[])=>[...new Set(u)].map(g=>t.get(g)).filter(Boolean).map(Ft).sort(xs),"cards");for(const u of e){const g=n.get(u.key)?.parent;u.parent=g?{key:g,ref:t.get(g)?.ref||g.slice(g.indexOf("/")+1)}:null,u.children=c(s.get(u.key)),u.related=c(r.get(u.key)),u.waitsOnIt=c(a.get(u.key))}}i(Os,"linkCards");const $s={todo:i(e=>e.created,"todo"),progress:i(e=>e.progressSince,"progress"),review:i(e=>e.reviewSince,"review"),done:i(e=>e.kind==="ask"?e.ask.answerAt:e.closedAt,"done")},re=i((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural");function As({checked:e,watcher:t,replyAt:n,threads:s={},working:r={},files:a=[]},d){const c=Number(e?.every)||30,g=[n,t?.since,...Object.values(r),...Object.values(s).flat().filter(p=>(p.who||"claude")==="claude").map(p=>p.ts),...a.flatMap(p=>Object.values(p.agents||{}).flatMap(w=>Object.values(w||{})).map(w=>w?.done||w?.started))].filter(p=>typeof p=="string"&&!Number.isNaN(Date.parse(p))).reduce((p,w)=>p&&Date.parse(p)>Date.parse(w)?p:w,null),m=!!e?.idle;return{at:e?.at||null,every:m?null:c,idle:m,late:!m&&!!e?.at&&d-Date.parse(e.at)>2*c*6e4,claudeAt:g}}i(As,"checksOf");function Es(e,t,n){const s=new Set(e.map(c=>c.questions?.topic).filter(Boolean)),r=i(c=>c.find(u=>n.find(g=>g.id===u)?.state==="open")||c[0],"firstOpen"),a=t.filter(c=>c.state!=="resolved"&&c.open>0&&!s.has(c.id)).map(c=>{const u=`questions.html#${r(c.questions)}`,g=/^(?:wave|file):(.+)$/.exec(c.id)?.[1]||null;return{kind:"Question",title:c.title,text:`${c.title} \xB7 ${re(c.open,"question")}`,url:u,topic:c.id,band:g,questions:{open:c.open,url:u},ready:null,since:n.filter(m=>m.topic===c.id&&m.state==="open").map(m=>m.asked_at).filter(Boolean).sort()[0]||null}}),d=e.map(c=>{const u=c.questions&&c.questions.state!=="resolved"&&c.questions.open>0?{open:c.questions.open,url:`questions.html#${c.questions.first}`}:null,g=c.waitsOn==="ready"?c.pr.url:null,m=!u&&!g&&c.action?{label:c.action.label,url:c.action.url}:null;if(!u&&!g&&!m)return null;const p=`${c.ref}: ${c.title}`,w=[p,u&&re(u.open,"question"),g&&"Ready on GitHub",m?.label].filter(Boolean).join(" \xB7 ");return{kind:u?"Question":g?"Tap Ready":"Action needed",title:p,text:w,url:`#selectedCard=${encodeURIComponent(c.key)}`,key:c.key,questions:u,ready:g,action:m,since:c.created||null,progress:c.lane==="progress"}}).filter(Boolean);return[...a,...d].sort(Bs)}i(Es,"needsOf");const Bs=i((e,t)=>!!t.progress-!!e.progress||(e.since&&t.since?e.since.localeCompare(t.since):!!t.since-!!e.since),"oldestFirst");function _s(e=[]){return e.map(t=>{const n=t.questions?.length?`Question: ${t.questions.map(s=>s.question).join(" \xB7 ")}`:`${t.tool}: ${t.detail||t.action}`;return{kind:"Prompt",title:n,text:n,url:"",prompt:t}})}i(_s,"promptLines");function Rs(e){const t=e.filter(a=>a.prompt).length,n=e.reduce((a,d)=>a+(d.questions?.open||0),0),s=e.filter(a=>a.ready).length,r=e.filter(a=>a.review).length;return[t&&re(t,"prompt"),n&&re(n,"question"),s&&`${re(s,"draft")} waiting on Ready`,r&&`${re(r,"review")} held`].filter(Boolean).join(" \xB7 ")}i(Rs,"needsSummary");function vo(e){const t=i((...n)=>e.items.filter(s=>n.includes(s.lane)).length,"count");return{items:e.needs.map(({kind:n,text:s,url:r})=>({kind:n,text:s,url:r})),working:e.working,summary:e.needsSummary,lanes:{review:t("review"),progress:t("progress"),todo:t("todo")},building:e.items.some(n=>(n.agents||[]).some(s=>!s.done))}}i(vo,"needsAnswer");const Ms=i(e=>e.buildable&&e.phase==="ready"&&!e.held&&!e.blocked,"pullableCard"),Is=10;function qs(e,{cap:t=Is,pulled:n=[],hold:s=[],taken:r=0}={}){const a=e.filter(y=>!ue(y)),d=i((y,b)=>y.started&&!y.done&&V(y)&&!(y.kind===ve&&!y.writes)&&!y.pause?.paused&&!(y.waits&&b.some(l=>l.name===y.waits&&!l.done)),"counts"),c=a.filter(y=>!y.stalled).reduce((y,b)=>y+(b.agents||[]).filter((l,A,h)=>d(l,h)).length,0),u=a.filter(y=>Ms(y)&&!y.working).map(y=>y.key),g=a.filter(y=>n.includes(y.key)&&(u.includes(y.key)||y.buildable&&y.working)).map(y=>y.key),m=a.flatMap(y=>(y.agents||[]).filter(b=>b.kind===ve&&!b.started&&!b.done).map(b=>({key:y.key,name:b.name,writes:b.writes}))),p=Math.max(0,t-c-g.length-r),w=m.filter(y=>y.writes),x=[...m.filter(y=>!y.writes),...w.slice(0,p)].map(({key:y,name:b})=>({key:y,name:b})),_=Math.max(0,p-w.length),O=new Set(a.filter(y=>y.bumpedAt).map(y=>y.key)),N=u.filter(y=>!g.includes(y)&&!s.includes(y)),D=N.filter(y=>O.has(y)),B=[...D,...N.filter(y=>!O.has(y)).slice(0,Math.max(0,_-D.length))],T=D.slice(_),P=Ds(a,d).slice(0,T.length).map((y,b)=>({key:y,by:T[b]}));return{idle:!c&&!a.some(y=>y.waitsOn==="checking"),pullable:u,waiting:g,pulls:B,helpers:x,bumpOuts:P,pastCap:T,free:p}}i(qs,"pullOf");function Ds(e,t){const n=i(s=>{const r=s.agents||[],a=r.filter(u=>t(u,r)),[d]=a;return s.lane==="progress"&&!s.bumpedAt&&!s.stalled&&s.waitsOn!=="checking"&&s.builder?.phase!=="landing"&&!(s.prs||[]).length&&!s.pushed&&!s.mergeReady&&a.length===1&&d.kind!==ve&&d.pid&&d.label!==Ke&&!d.pause&&!r.some(u=>u.kind===ve&&u.started&&!u.done)?String(d.started):null},"newest");return e.map(s=>({key:s.key,at:n(s)})).filter(s=>s.at).sort((s,r)=>r.at.localeCompare(s.at)).map(s=>s.key)}i(Ds,"bumpOutsOf");function xo(e,t,n){return e.filter(s=>s.kind==="work"&&!ue(s)&&s.waitsOn!=="checking"&&!(s.agents||[]).some(r=>r.started&&!r.done)).flatMap(s=>{const r=(s.prs||[]).find(d=>d.state==="OPEN"&&d.mergeable==="CONFLICTING"&&d.repo===s.repo&&d.headRefOid),a=r&&`${r.headRefOid}@${n}`;return r&&E(t,s.key)!==a?[{key:s.key,pr:r.number,branch:r.headRefName,conflict:a}]:[]})}i(xo,"rebasesDue");const Cs=3;function Oo(e,{cap:t=Cs}={}){const n=e.filter(d=>!ue(d)),s=n.filter(d=>(d.agents||[]).some(c=>ee(c)&&c.started&&!c.done)).length,r=n.filter(d=>d.buildable&&!["ready","staging"].includes(d.phase)&&!d.unsorted&&!d.blocked&&!d.held&&!d.working&&!d.grilling&&!d.prototyping&&!d.questions&&!(d.agents||[]).some(c=>ee(c)&&c.kind!==pe)),a=r.filter(d=>d.bumpedAt);return[...a,...r.filter(d=>!d.bumpedAt).slice(0,Math.max(0,t-s-a.length))].map(d=>d.key)}i(Oo,"arrivalsOf");function $o(e){return e.filter(t=>t.kind==="work"&&t.lane==="todo"&&t.roundAt&&["grilling","prototyping"].includes(t.phase)&&!(t.agents||[]).some(n=>ee(n)&&n.kind!==pe&&n.started&&(String(n.started)>=String(t.roundAt)||!n.done))).map(t=>({key:t.key,kind:t.phase==="grilling"?"grill":"prototype"}))}i($o,"roundsDue");const Ns=i(e=>`${pe}-${e.id}`,"visualAgent");function Ao(e,t){const n=[];for(const s of e){const r=s.agents||[];if(r.some(c=>c.kind===pe&&c.started&&!c.done))continue;const a=new Set(r.map(c=>c.name)),d=t.find(c=>c.kind==="visual-request"&&c.data?.key===s.key&&!a.has(Ns(c)));d&&n.push({key:s.key,request:d})}return n}i(Ao,"visualsDue");const Ts=i(e=>e.kind==="ask"?`ask:${e.id}`:e.kind==="card-added"?e.data?.key??null:e.kind==="item-message"&&String(e.data?.key||"").startsWith("ask:")?e.data.key:null,"intakeKeyOf");function Ls(e,t,n){const s=e.get(n);return s?t.kind==="ask"?s.isNew:t.kind==="card-added"?s.kind==="work"&&s.unfiled:(s.ask?.owed||[]).includes(t.id):!1}i(Ls,"unsorted");const Ps={ask:"Sort the new task: file it with item add --from-ask, fold it with item relate-ask, or answer it with reply","item-message":"Answer the owner's message in the ask's thread: reply to it","card-added":"Link and file the card an agent added: item notes, then item set --relate and --phase"};function js(e,t,n){const s=new Map(e.map(a=>[a.key,a])),r=new Set;for(const a of t){const d=Ts(a);!d||r.has(d)||!Ls(s,a,d)||(r.add(d),s.get(d).orchestrator={kind:"intake",since:String(a.ts),picked:E(n,a.id)||null,next:Ps[a.kind]})}}i(js,"intakeWaits");function Us(e,t){for(const n of e){const s=E(t,n.key);s&&(n.orchestrator={kind:"screen",since:s.since,picked:null,next:`Screen the grill's questions ${s.ids.join(", ")}: question settle <id> --note for each the board already answers, then question publish ${n.key}; left 15 minutes unscreened, they reach the owner as they are`})}}i(Us,"screenWaits");function Ws(e){return e.filter(t=>t.lane==="todo"||t.lane==="review"&&t.stale).map(t=>JSON.stringify([t.key,t.title,t.deps||[]])).sort().join(`
7
+ `)}i(Ws,"todoOf");function Eo(e){const t=e.filter(s=>s.kind==="work"&&s.lane!=="done"&&s.questions?.open>0),n=t.map(s=>JSON.stringify([s.key,s.questions.open,s.questions.askedAt||[]])).sort().join(`
8
8
  `);return{waiting:t.map(s=>s.key),seen:`${n}
9
9
  --
10
- ${Us(e)}`}}i(Ao,"triageOf");const Ws=100,Fs=["key","kind","id","ref","title","lane","phase","file","fileTitle","fold","internal","ticket","ticketSource","linear","pr","prs","review","reviewers","risky","sortAt","threadCount","othersAt","hasNotes","questions","prototypes","next","ask","action","actionButton","builder","working","waitsOn","reachedPhase","grilling","refusal","install","parent","children","related","waitsOnIt","blockedBy","ready","finishable","reopened","manualSteps","branch","worktree"],Eo=i(e=>Object.fromEntries(Fs.filter(t=>t in e).map(t=>[t,e[t]])),"slimDone");function Bo(e,t=Ws){const n=new Set((e.waveBands||[]).flatMap(r=>r.keys)),s=new Set(e.items.filter(r=>r.lane!=="done").flatMap(r=>[...(r.deps||[]).map(a=>String(a).includes("/")?String(a):`${r.file}/${a}`),r.parent?.key,...(r.children||[]).map(a=>a.key),...(r.related||[]).map(a=>a.key)]));return e.items.filter(r=>r.lane==="done"&&r.kind==="work").sort((r,a)=>String(a.closedAt||"").localeCompare(String(r.closedAt||""))).slice(t).filter(r=>r.storedLane==="done"&&!r.reopened&&!n.has(r.key)&&!s.has(r.key)&&(!r.questions||r.questions.state==="resolved"))}i(Bo,"archivedOf");const Ks={ready:"draft",ci:"draft",reviewers:"reviewers",merge:"merge"};function Gs(e){return e.lane==="todo"?e.unpicked?"prototyping":mt.todo.includes(e.storedPhase)?e.storedPhase:e.storedLane&&e.storedLane!=="todo"?"ready":"new":e.lane==="progress"?e.waitsOn==="checking"?"checking":e.builder&&!e.builder.planner&&e.builder.kind!==pe.install&&e.builder.phase||e.reachedPhase||"reading":e.lane==="review"?e.stale?"stale":e.waitsOn==="owner"&&e.pushed?"merge":Ks[e.waitsOn]??null:e.storedLane==="done"&&mt.done.includes(e.storedPhase)?e.storedPhase:e.prs.some(t=>t.status===H.merged)?"merged":"closed"}i(Gs,"phaseOf");function _o(e){return e.items.filter(t=>t.kind==="work").flatMap(t=>{const n=t.lane;return n==="done"||t.storedLane==="done"&&!t.reopened?[]:n===t.storedLane&&(n==="todo"||t.phase===t.storedPhase)?[]:[{key:t.key,to:n,phase:t.phase,why:Qs(t,n),from:{lane:t.storedLane,phase:t.storedPhase}}]})}i(_o,"movesOf");function Qs(e,t){return t==="todo"?e.held?"it is held":e.blocked?"it is blocked":"nothing builds it":e.reopened&&t==="progress"?"a message or question reopened it":t==="progress"?e.waitsOn==="checking"?"its build handed back for a check":e.builder?"a build started":"Claude acts next":e.next||"it waits on review"}i(Qs,"moveWhy");const Hs=i(e=>e.startsWith("ask:")?`ask-${e.slice(4)}`:`item-${e}`,"pushTag");function Ro(e){const t=i(a=>e.owner.filter(d=>d.topic===a&&d.state==="open").map(({id:d,question:c})=>({id:d,question:c})),"open"),n=[D.ready,D.merge],s=e.items.filter(a=>a.action).map(a=>{const d=rt.has(a.action.kind)?t(a.questions.topic):[];return{tag:Hs(a.key),kind:a.action.kind,title:`${a.ref}: ${a.action.label}`,body:d[0]?.question||a.title,url:d.length?a.action.url:`#selectedCard=${encodeURIComponent(a.key)}`,now:!n.includes(a.action.kind),questions:d}}),r=e.needs.filter(a=>a.topic).map(a=>{const d=t(a.topic);return{tag:`topic-${a.topic}`,kind:D.questions,title:a.text,body:d[0]?.question||a.title,url:a.url,now:!0,questions:d}});return[...s,...r,...nn(e.reviews)]}i(Ro,"ownerActions");function Mo(e,{pulled:t=[]}={}){return!e.items.filter(r=>!fe(r)).some(r=>r.waitsOn==="checking"||r.grilling||r.prototyping||(r.agents||[]).some(a=>!a.done))&&!e.working&&!Is(e.items,{pulled:t}).waiting.length}i(Mo,"strictlyIdle");const Vs="item stall it with the reason when it can't go on",Gt="restart it once from its worktree with a thread line; if the restarted run goes stale too, item stall it with the reason",Xs='Judge the staged card against the whole board: item set --phase ready --text "<what you checked>", or --phase grilling or prototyping for another round; where its notes answer a split question Split as proposed, file the split instead';function Ys(e,t,{answeredAt:n,workingSince:s}){const r=i(f=>e.agents.some(g=>g.kind===f&&g.started&&!g.done),"running"),a=[e.progressSince,...e.agents.map(f=>f.done)].filter(Boolean).map(String).sort().pop()||null,d=t.ask?{kind:"ask",since:t.ask.at,next:`Answer the builder's ask: ${t.ask.text}`}:e.staging?{kind:"staging",since:e.stagedAt,next:Xs}:n?{kind:"answer",since:n,next:"Act on the owner's answer"}:rt.has(e.action?.kind)?null:e.builder?.stopped?{kind:"stale",since:e.builder.silentSince,next:`${e.builder.stopped}: ${Gt}, or drop the card`}:e.builder?.stale?{kind:"stale",since:e.builder.silentSince,next:`Find out why the builder went silent, then finish its run or ${Gt}`}:e.lane==="review"&&e.stale?{kind:"stale",since:new Date(Date.parse(e.inReviewSince)+yt).toISOString(),daily:!0,next:`Find out why the review went stale and fix what you can: rebase, CI, comments; if only a reviewer owes it, a thread line naming who; or ${Vs}`}:e.waitsOn==="checking"?t.unverified?{kind:"calls",since:t.handedBackAt,next:t.next||"Verify the builder's judgment calls"}:{kind:"checking",since:t.handedBackAt,next:t.next||"Land the checked build"}:e.grilling&&t.grillAt&&!r("grill")?{kind:"grill",since:t.grillAt,next:"Start the grill asked for"}:e.prototyping&&t.prototypeAt&&!r("prototype")?{kind:"prototype",since:t.prototypeAt,next:"Draw the prototype asked for"}:e.refusal&&t.refusedAt?{kind:"refused",since:t.refusedAt,next:e.refusal}:e.next===_t&&a?{kind:"unowned",since:a,next:"Start a builder on it, or set its Next"}:t.unblockedAt&&e.lane!=="todo"&&!e.builder&&!e.blocked&&!t.writes.some(f=>f>t.unblockedAt)?{kind:"unblocked",since:t.unblockedAt,next:"Its block ended: act on what it waited for, or set its Next"}:null;if(!d?.since)return null;const c=String(d.since),u=[t.writes.find(f=>f>c),s].filter(Boolean).sort()[0]||null;return{kind:d.kind,since:c,picked:u,next:d.next,...d.daily?{daily:!0}:{}}}i(Ys,"orchestratorWaitOf");const Io=i((e,t=null)=>({key:e.id,ref:e.data.date,title:`Overnight triage ${e.data.date}`,kind:"triage",since:e.ts,picked:t,next:`Run the overnight triage and reply: board.mjs reply ${e.id}`}),"triageWaitOf");function qo(e){const t=e.items.filter(n=>n.orchestrator).map(n=>({key:n.key,ref:n.ref,title:n.title,...n.orchestrator,bumpedAt:n.bumpedAt||null}));return[...t.filter(n=>n.bumpedAt).sort((n,s)=>n.bumpedAt.localeCompare(s.bumpedAt)),...t.filter(n=>!n.bumpedAt)]}i(qo,"orchestratorWaits");const Do=30*6e4,zs=15*6e4,Js=60*6e4,Zs=1440*6e4;function Co(e,t,n){const s=n.toISOString(),r=[],a=[];return{waits:t.map(c=>{const u=e.find(p=>p.key===c.key&&p.kind===c.kind&&p.since===c.since);if(!u)return c.picked||r.push(c.key),{...c,bumped:s};const f=c.picked?[c.picked,u.bumped].filter(Boolean).sort().pop():u.bumped||c.since,g=n-Date.parse(f)>=(c.picked?c.daily?Zs:Js:zs);return g&&a.push({key:c.key,ref:c.ref,kind:c.kind,since:c.since,next:c.next}),{...c,bumped:g?s:u.bumped||c.since,...u.pushed?{pushed:!0}:{}}}),added:r,again:a}}i(Co,"waitsStep");function No(e,t){const n=i(s=>{const r=Math.floor((t-Date.parse(s))/6e4),a=Math.floor(r/60),d=r%60;return a?`${a}h${d?` ${d}m`:""}`:`${d}m`},"age");return`still waiting on you: ${e.map(s=>`${s.ref} ${s.kind} for ${n(s.since)}: ${s.next}`).join("; ")}`}i(No,"waitsAgainLine");const eo=15;function To(e,{idle:t,now:n}){const s=n.toISOString(),r=e.last||s;return t?e.since?e.pushed||n-Date.parse(e.since)<eo*6e4?{state:{...e,last:r},push:!1}:{state:{last:s,since:e.since,pushed:!0},push:!0}:{state:{last:r,since:s},push:!1}:{state:{last:r},push:!1}}i(To,"idleStep");function Lo(e,t){const n=i(u=>String(u.closedAt||"")>t,"after"),s=e.filter(u=>u.kind==="work"&&u.lane==="done"&&!vt(u)&&n(u)),r=new Map;for(const u of e)u.wave&&r.set(u.wave.slug,[...r.get(u.wave.slug)||[],u]);const a=[...r.values()].filter(u=>u.every(f=>f.lane==="done")&&u.some(n)).map(u=>u[0].wave.title),d=s.slice(0,3).map(u=>u.ref).join(", ")+(s.length>3?` and ${s.length-3} more`:"");return[s.length&&`${s.length} ${s.length===1?"card":"cards"} landed: ${d}`,...a.map(u=>`${u} finished`)].filter(Boolean).join(" \xB7 ")||"Nothing closed since the last idle notification."}i(Lo,"idleSummary");export{D as ACTION_KIND,Ct as ACTION_LABELS,is as ANSWERS_SUBMITTED,De as BUILDER_ASK,pe as BUILDER_KIND,gn as BUILDER_QUIET_AFTER,fn as BUILDER_STALE_AFTER,ht as BUILD_REFUSED,ae as BUTTON,Xe as COMMANDS,Zs as DAILY_REWAKE_AFTER,Fs as DONE_FIELDS,Ws as DONE_KEPT,Oe as HELPER,eo as IDLE_MINUTES,Nt as INTENT_LABELS,pn as ITEM_EVENTS,He as LANDER,go as LANES,Ms as MAX_IMPLEMENTERS,Ds as MAX_PLANNERS,xe as MOVE,_t as NO_NEXT,Do as ORCHESTRATOR_PUSH_AFTER,ho as PAUSE_CLEARS,Jn as PAUSE_HARD_STOP,mt as PHASES,Js as PICKED_REWAKE_AFTER,Hn as PLANNER_WORD,Pn as PROTOTYPE_AGAIN,mo as PROTOTYPE_WAIT,H as PR_STATE,wt as QUESTION_REOPEN,zs as REWAKE_AFTER,ge as VISUAL,Bo as archivedOf,xo as arrivalsOf,bo as buildBoard,V as builds,mn as fileFold,st as handedBackAt,To as idleStep,Lo as idleSummary,In as mergeBlockers,ts as modelName,_o as movesOf,So as needsAnswer,Ln as noTakePicked,Vn as orchestratorDid,qo as orchestratorWaits,ko as owesNext,Ro as ownerActions,ns as ownerQuestion,yo as pauseWork,Tn as picksNoTake,te as plans,wo as prototypeWaits,It as providerOf,Is as pullOf,Hs as pushTag,vo as rebasesDue,Qe as refOf,ke as roundOf,ss as roundSettledBy,Oo as roundsDue,Eo as slimDone,Ne as stateEntries,Rt as stoppedWords,Mo as strictlyIdle,jt as threadIndex,Ut as threadOf,Us as todoOf,Ao as triageOf,Io as triageWaitOf,vt as unlanded,Cs as visualAgent,$o as visualsDue,No as waitsAgainLine,Co as waitsStep,bs as waveItems,Ss as withHub};
10
+ ${Ws(e)}`}}i(Eo,"triageOf");const Fs=100,Ks=["key","kind","id","ref","title","lane","phase","file","fileTitle","fold","internal","ticket","ticketSource","linear","pr","prs","review","reviewers","risky","sortAt","threadCount","othersAt","hasNotes","questions","prototypes","next","ask","action","actionButton","builder","working","waitsOn","reachedPhase","grilling","refusal","install","parent","children","related","waitsOnIt","blockedBy","ready","finishable","reopened","manualSteps","branch","worktree"],Bo=i(e=>Object.fromEntries(Ks.filter(t=>t in e).map(t=>[t,e[t]])),"slimDone");function _o(e,t=Fs){const n=new Set((e.waveBands||[]).flatMap(r=>r.keys)),s=new Set(e.items.filter(r=>r.lane!=="done").flatMap(r=>[...(r.deps||[]).map(a=>String(a).includes("/")?String(a):`${r.file}/${a}`),r.parent?.key,...(r.children||[]).map(a=>a.key),...(r.related||[]).map(a=>a.key)]));return e.items.filter(r=>r.lane==="done"&&r.kind==="work").sort((r,a)=>String(a.closedAt||"").localeCompare(String(r.closedAt||""))).slice(t).filter(r=>r.storedLane==="done"&&!r.reopened&&!n.has(r.key)&&!s.has(r.key)&&(!r.questions||r.questions.state==="resolved"))}i(_o,"archivedOf");const Gs={ready:"draft",ci:"draft",reviewers:"reviewers",merge:"merge"};function Qs(e){return e.lane==="todo"?e.unpicked?"prototyping":mt.todo.includes(e.storedPhase)?e.storedPhase:e.storedLane&&e.storedLane!=="todo"?"ready":"new":e.lane==="progress"?e.waitsOn==="checking"?"checking":e.builder&&!e.builder.planner&&e.builder.kind!==ce.install&&e.builder.phase||e.reachedPhase||"reading":e.lane==="review"?e.stale?"stale":e.waitsOn==="owner"&&e.pushed?"merge":Gs[e.waitsOn]??null:e.storedLane==="done"&&mt.done.includes(e.storedPhase)?e.storedPhase:e.prs.some(t=>t.status===H.merged)?"merged":"closed"}i(Qs,"phaseOf");function Ro(e){return e.items.filter(t=>t.kind==="work").flatMap(t=>{const n=t.lane;return n==="done"||t.storedLane==="done"&&!t.reopened?[]:n===t.storedLane&&(n==="todo"||t.phase===t.storedPhase)?[]:[{key:t.key,to:n,phase:t.phase,why:Hs(t,n),from:{lane:t.storedLane,phase:t.storedPhase}}]})}i(Ro,"movesOf");function Hs(e,t){return t==="todo"?e.held?"it is held":e.blocked?"it is blocked":"nothing builds it":e.reopened&&t==="progress"?"a message or question reopened it":t==="progress"?e.waitsOn==="checking"?"its build handed back for a check":e.builder?"a build started":"Claude acts next":e.next||"it waits on review"}i(Hs,"moveWhy");const Vs=i(e=>e.startsWith("ask:")?`ask-${e.slice(4)}`:`item-${e}`,"pushTag");function Mo(e){const t=i(a=>e.owner.filter(d=>d.topic===a&&d.state==="open").map(({id:d,question:c})=>({id:d,question:c})),"open"),n=[q.ready,q.merge],s=e.items.filter(a=>a.action).map(a=>{const d=rt.has(a.action.kind)?t(a.questions.topic):[];return{tag:Vs(a.key),kind:a.action.kind,title:`${a.ref}: ${a.action.label}`,body:d[0]?.question||a.title,url:d.length?a.action.url:`#selectedCard=${encodeURIComponent(a.key)}`,now:!n.includes(a.action.kind),questions:d}}),r=e.needs.filter(a=>a.topic).map(a=>{const d=t(a.topic);return{tag:`topic-${a.topic}`,kind:q.questions,title:a.text,body:d[0]?.question||a.title,url:a.url,now:!0,questions:d}});return[...s,...r,...sn(e.reviews)]}i(Mo,"ownerActions");function Io(e,{pulled:t=[]}={}){return!e.items.filter(r=>!ue(r)).some(r=>r.waitsOn==="checking"||r.grilling||r.prototyping||(r.agents||[]).some(a=>!a.done))&&!e.working&&!qs(e.items,{pulled:t}).waiting.length}i(Io,"strictlyIdle");const Xs="item stall it with the reason when it can't go on",Gt="restart it once from its worktree with a thread line; if the restarted run goes stale too, item stall it with the reason",Ys='Judge the staged card against the whole board: item set --phase ready --text "<what you checked>", or --phase grilling or prototyping for another round; where its notes answer a split question Split as proposed, file the split instead';function zs(e,t,{answeredAt:n,workingSince:s}){const r=i(g=>e.agents.some(m=>m.kind===g&&m.started&&!m.done),"running"),a=[e.progressSince,...e.agents.map(g=>g.done)].filter(Boolean).map(String).sort().pop()||null,d=t.ask?{kind:"ask",since:t.ask.at,next:`Answer the builder's ask: ${t.ask.text}`}:e.staging?{kind:"staging",since:e.stagedAt,next:Ys}:n?{kind:"answer",since:n,next:"Act on the owner's answer"}:rt.has(e.action?.kind)?null:e.builder?.stopped?{kind:"stale",since:e.builder.silentSince,next:`${e.builder.stopped}: ${Gt}, or drop the card`}:e.builder?.stale?{kind:"stale",since:e.builder.silentSince,next:`Find out why the builder went silent, then finish its run or ${Gt}`}:e.lane==="review"&&e.stale?{kind:"stale",since:new Date(Date.parse(e.inReviewSince)+yt).toISOString(),daily:!0,next:`Find out why the review went stale and fix what you can: rebase, CI, comments; if only a reviewer owes it, a thread line naming who; or ${Xs}`}:e.waitsOn==="checking"?t.unverified?{kind:"calls",since:t.handedBackAt,next:t.next||"Verify the builder's judgment calls"}:{kind:"checking",since:t.handedBackAt,next:t.next||"Land the checked build"}:e.grilling&&t.grillAt&&!r("grill")?{kind:"grill",since:t.grillAt,next:"Start the grill asked for"}:e.prototyping&&t.prototypeAt&&!r("prototype")?{kind:"prototype",since:t.prototypeAt,next:"Draw the prototype asked for"}:e.refusal&&t.refusedAt?{kind:"refused",since:t.refusedAt,next:e.refusal}:e.next===_t&&a?{kind:"unowned",since:a,next:"Start a builder on it, or set its Next"}:t.unblockedAt&&e.lane!=="todo"&&!e.builder&&!e.blocked&&!t.writes.some(g=>g>t.unblockedAt)?{kind:"unblocked",since:t.unblockedAt,next:"Its block ended: act on what it waited for, or set its Next"}:null;if(!d?.since)return null;const c=String(d.since),u=[t.writes.find(g=>g>c),s].filter(Boolean).sort()[0]||null;return{kind:d.kind,since:c,picked:u,next:d.next,...d.daily?{daily:!0}:{}}}i(zs,"orchestratorWaitOf");const qo=i((e,t=null)=>({key:e.id,ref:e.data.date,title:`Overnight triage ${e.data.date}`,kind:"triage",since:e.ts,picked:t,next:`Run the overnight triage and reply: board.mjs reply ${e.id}`}),"triageWaitOf");function Do(e){const t=e.items.filter(n=>n.orchestrator).map(n=>({key:n.key,ref:n.ref,title:n.title,...n.orchestrator,bumpedAt:n.bumpedAt||null}));return[...t.filter(n=>n.bumpedAt).sort((n,s)=>n.bumpedAt.localeCompare(s.bumpedAt)),...t.filter(n=>!n.bumpedAt)]}i(Do,"orchestratorWaits");const Co=30*6e4,Js=15*6e4,Zs=60*6e4,eo=1440*6e4;function No(e,t,n){const s=n.toISOString(),r=[],a=[];return{waits:t.map(c=>{const u=e.find(p=>p.key===c.key&&p.kind===c.kind&&p.since===c.since);if(!u)return c.picked||r.push(c.key),{...c,bumped:s};const g=c.picked?[c.picked,u.bumped].filter(Boolean).sort().pop():u.bumped||c.since,m=n-Date.parse(g)>=(c.picked?c.daily?eo:Zs:Js);return m&&a.push({key:c.key,ref:c.ref,kind:c.kind,since:c.since,next:c.next}),{...c,bumped:m?s:u.bumped||c.since,...u.pushed?{pushed:!0}:{}}}),added:r,again:a}}i(No,"waitsStep");function To(e,t){const n=i(s=>{const r=Math.floor((t-Date.parse(s))/6e4),a=Math.floor(r/60),d=r%60;return a?`${a}h${d?` ${d}m`:""}`:`${d}m`},"age");return`still waiting on you: ${e.map(s=>`${s.ref} ${s.kind} for ${n(s.since)}: ${s.next}`).join("; ")}`}i(To,"waitsAgainLine");const to=15;function Lo(e,{idle:t,now:n}){const s=n.toISOString(),r=e.last||s;return t?e.since?e.pushed||n-Date.parse(e.since)<to*6e4?{state:{...e,last:r},push:!1}:{state:{last:s,since:e.since,pushed:!0},push:!0}:{state:{last:r,since:s},push:!1}:{state:{last:r},push:!1}}i(Lo,"idleStep");function Po(e,t){const n=i(u=>String(u.closedAt||"")>t,"after"),s=e.filter(u=>u.kind==="work"&&u.lane==="done"&&!vt(u)&&n(u)),r=new Map;for(const u of e)u.wave&&r.set(u.wave.slug,[...r.get(u.wave.slug)||[],u]);const a=[...r.values()].filter(u=>u.every(g=>g.lane==="done")&&u.some(n)).map(u=>u[0].wave.title),d=s.slice(0,3).map(u=>u.ref).join(", ")+(s.length>3?` and ${s.length-3} more`:"");return[s.length&&`${s.length} ${s.length===1?"card":"cards"} landed: ${d}`,...a.map(u=>`${u} finished`)].filter(Boolean).join(" \xB7 ")||"Nothing closed since the last idle notification."}i(Po,"idleSummary");export{q as ACTION_KIND,Ct as ACTION_LABELS,ds as ANSWERS_SUBMITTED,qe as BUILDER_ASK,ce as BUILDER_KIND,kn as BUILDER_QUIET_AFTER,gn as BUILDER_STALE_AFTER,ht as BUILD_REFUSED,oe as BUTTON,Qe as COMMANDS,eo as DAILY_REWAKE_AFTER,Ks as DONE_FIELDS,Fs as DONE_KEPT,ve as HELPER,to as IDLE_MINUTES,Nt as INTENT_LABELS,fn as ITEM_EVENTS,Ke as LANDER,ko as LANES,Is as MAX_IMPLEMENTERS,Cs as MAX_PLANNERS,Se as MOVE,_t as NO_NEXT,Co as ORCHESTRATOR_PUSH_AFTER,yo as PAUSE_CLEARS,Zn as PAUSE_HARD_STOP,mt as PHASES,Zs as PICKED_REWAKE_AFTER,Vn as PLANNER_WORD,jn as PROTOTYPE_AGAIN,wo as PROTOTYPE_WAIT,H as PR_STATE,wt as QUESTION_REOPEN,Js as REWAKE_AFTER,pe as VISUAL,_o as archivedOf,Oo as arrivalsOf,So as buildBoard,V as builds,wn as fileFold,st as handedBackAt,Lo as idleStep,Po as idleSummary,qn as mergeBlockers,ns as modelName,Ro as movesOf,vo as needsAnswer,Pn as noTakePicked,Xn as orchestratorDid,Do as orchestratorWaits,mo as owesNext,Mo as ownerActions,ss as ownerQuestion,bo as pauseWork,Ln as picksNoTake,ee as plans,ho as prototypeWaits,It as providerOf,qs as pullOf,Vs as pushTag,xo as rebasesDue,nt as refOf,fe as roundOf,os as roundSettledBy,$o as roundsDue,Bo as slimDone,Ce as stateEntries,Rt as stoppedWords,Io as strictlyIdle,jt as threadIndex,Ut as threadOf,Ws as todoOf,Eo as triageOf,qo as triageWaitOf,vt as unlanded,Ns as visualAgent,Ao as visualsDue,To as waitsAgainLine,No as waitsStep,Ss as waveItems,vs as withHub};
@@ -1,8 +1,8 @@
1
- var z=Object.defineProperty;var l=(t,e)=>z(t,"name",{value:e,configurable:!0});import Q from"node:os";import{BRIEF_LINE_LIMIT as X}from"./hub-lines.mjs";import k from"node:path";import{fileURLToPath as J}from"node:url";import{launchAgent as P}from"./agents.mjs";import{processStarts as W,ps as Z}from"../hub/live.mjs";import{boardAt as C}from"../hub/boards.mjs";import{readHubRules as ee}from"../hub/rules.mjs";import{builderRepo as M}from"./worktree.mjs";import{appendStatus as te,BoardError as oe,briefFacts as L,readBoardRules as re,recordedSession as ne,recordSession as O}from"./store.mjs";import{HELPER as se,plans as ae,VISUAL as ie}from"./domain.mjs";const he=J(new URL("./bin/board.mjs",import.meta.url)),g=l(t=>`node ${he} --site ${t}`,"cli"),E=l(t=>`git -c core.commentChar=';' rebase ${t}`,"rebase"),de="a draft .md of your own outside the board's data folder (such as in /tmp)",le=l((t,e,r)=>`\`${t} item notes ${e} --heading "${r}" --file <draft.md>\``,"notesCommand"),T=l((t,e="Rules from the hub and this board:")=>t.length?[e,...t.map(r=>`- ${r}`),""]:[],"ruleLines"),x=l(t=>t.length?["Related cards: read their notes for context; don't build their scope.",...t.map(e=>`- ${e.ref} "${e.title}" (${e.relation}, ${e.lane}): ${e.notes?`notes ${e.notes}`:"no notes"}, thread ${e.thread}`),""]:[],"linkLines"),I=l(t=>`The card's thread, which holds the owner's messages (who: love): ${t}. Read it live.`,"threadLine"),F=l(({route:t,key:e,worktree:r,base:h})=>[`- With no unverified calls, done finishes the card itself: it rebases onto ${h}, reruns the full test suite, fast-forwards ${h} and closes the card (on a board with pull requests it pushes the branch and opens a draft PR instead; with Auto-merge off it stops before the fast-forward, and the card waits for the owner's Merge).`,`- On a conflict it undoes its rebase and names the files: run \`${E(h)}\` in ${r}, resolve each conflict keeping both sides' intent, continue with \`git -c core.commentChar=';' rebase --continue\`, rerun the tests, and run done again.`,"- On failing tests, fix them, commit, and run done again.","- While another card is landing, done waits its turn and then lands; leave it running.","- Once a reviewer has the card's PR link, done refuses without `--updated \"<what changed>\"`, which goes in that link's Slack thread, or `--updated none` for a change only to comments, names, docs or tests.",`- Finishing never goes to the orchestrator. If done refuses for a reason you can't fix, record it with \`${g(t)} builder call ${e} "<why>"\` and run done again: with the call it hands the card back.`],"finishSteps"),B=l(({route:t,key:e})=>`\`${g(t)} builder done ${e} --text "<what you checked>"\``,"finishCommand"),ce=l((t,e)=>[`5. To run a separate part of the work in parallel, ask the board for a helper: \`${t} agent launch ${e} --name <short-name> --task "<the whole task, with the files and what to hand back>"\`, adding --writes when it changes code or runs tests (it gets its own worktree off your branch, and waits for a free implementer slot). Then \`${t} agent wait ${e} --name <short-name>\`, which prints its hand-back; it returns within 10 minutes, so run it again while it says still running, and do the task yourself if it says the helper exited. Merge a writing helper's work with \`${t} agent merge ${e} --name <short-name>\` before you test and finish.`],"helperSteps");function ue({route:t,key:e,ref:r,title:h,notes:n,thread:d,worktree:a,base:u,rules:p=[],links:c=[]}){const o=g(t);return[`You are the headless builder for card ${r} (${e}, "${h}") on the kickflip board /${t}. The board launched you; nobody watches this session, so never wait on a person. Work only in ${a}. Never restart the hub or a board server, and never push.`,"",`1. Run \`${o} builder start ${e} --kind build\`. If it refuses, stop.`,`2. Report progress with \`${o} builder progress ${e} --phase reading|building|testing|checking|landing "<plain, 80 characters or fewer>"\`, at least every 10 minutes. The board adds the phase word; don't start the text with it. The phases:`," - reading: the notes and the code, until the first test is written."," - building: the tests and the code, the ADR and docs, and the commit."," - testing: the full suite run before you finish."," - checking: your own review of the diff before you hand back; the Orchestrator's review of your calls continues on the same 4th bar."," - landing: set by the finish step itself; you never report it.",`3. Decide, record the call (step 4) and carry on: the orchestrator reviews your calls after the build. Ask it only when you are blocked, meaning every way forward would likely be thrown away: the spec contradicts itself or the code, a rule needs the owner's go before code is written, or the answer is a fact only the orchestrator has. Then run \`${o} builder ask ${e} "<question>"\`, do any work the answer can't change, and wait with \`${o} builder asks ${e} --wait\`, which returns within 10 minutes, so run it again while it says still waiting. If no answer comes in 30 minutes, record the question as a call, "Question: <question>", and hand back.`,`4. Record each judgment call the notes leave open with \`${o} builder call ${e} "<call>"\` instead of guessing silently or asking. A problem you find outside your card is a call "Found: <what>" for the orchestrator to file at review; ask about it at once only when it stalls other cards' builds or lands.`,...ce(o,e),"",n?`Spec: the card's notes, ${n}, all sections, where later sections override earlier ones.`:"The card has no notes file: build from its title, and record what you had to decide as calls.",`${I(d)} Read it with the notes: a message of the owner's is an instruction, but where it contradicts the notes, the notes win; that contradiction counts as blocked (step 3), so ask with \`${o} builder ask ${e} "<question>"\` and wait as step 3 says. Read the thread again in checking, before you finish, for anything the owner wrote during the build.`,"",...x(c),...T(p),"Write tests first, and run the full suite once, in the foreground, at the end. Where the repo keeps ADRs, write one named with a timestamp: docs/adr/YYYY-MM-DD-HHMM-<slug>.md.",`Commit with \`git -c core.commentChar=';' commit -F <file>\`, the subject "${r}: <what the card now does>".`,"",`To finish, run ${B({route:t,key:e})}.`,"- If you recorded a judgment call, it hands the card back for the orchestrator to verify your calls; stop there: the orchestrator's verification finishes the card.",...F({route:t,key:e,worktree:a,base:u}),"","Never push."].join(`
2
- `)}l(ue,"builderBrief");function Y({route:t,key:e,ref:r,title:h,thread:n,worktree:d,base:a,answers:u=[],resumed:p=!1,why:c}){const o=g(t);return[p?`The board resumes you, the builder of card ${r} (${e}, "${h}") on the kickflip board /${t}, to land your build: ${c??"the orchestrator verified your judgment calls"}, and it waits only to land. Nobody watches this session, so never wait on a person. Work only in ${d}, never restart the hub or a board server, and never push.`:`You are the headless lander for card ${r} (${e}, "${h}") on the kickflip board /${t}. Its build is done and the orchestrator verified its judgment calls; it waits only to land. Nobody watches this session, so never wait on a person. Work only in ${d}, never restart the hub or a board server, and never push.`,"",`1. Run \`${o} builder start ${e} --kind build --label Lander --phase landing --progress "taking up the verified build"\`. If it refuses, stop.`,`2. Report progress with \`${o} builder progress ${e} --phase landing "<plain, 80 characters or fewer>"\`. The board adds the phase word; don't start the text with it.`,...u.length?["3. The owner answered the builder's deferred asks. Where an answer changes the build, change it, with its tests, and commit:",...u.map(i=>`- ${i.ask} "${i.question}": ${i.answer}`)]:[],"",I(n),"",`To finish, run ${B({route:t,key:e})}.`,...F({route:t,key:e,worktree:d,base:a}),"","Never push."].join(`
3
- `)}l(Y,"landerBrief");function H({route:t,key:e,ref:r,title:h,thread:n,worktree:d,base:a,pr:u,resumed:p=!1}){const c=g(t);return[...p?[`The board resumes you, the builder of card ${r}, for this run: the lines below are your brief for it.`]:[],`You are the headless rebase run for card ${r} (${e}, "${h}") on the kickflip board /${t}. Its PR #${u} conflicts with ${a}; rebase its branch onto ${a} so the PR is clean again. Nobody watches this session, so never wait on a person. Work only in ${d}, never restart the hub or a board server, and never push.`,"",`1. Run \`${c} builder start ${e} --kind build --label Rebase --phase building --progress "Rebase run started \xB7 fetching ${a}"\`. If it refuses, stop.`,`2. Run \`git fetch origin\`, then \`${E(`origin/${a}`)}\`. Resolve each conflict keeping both sides' intent, \`git add\` it and continue with \`git -c core.commentChar=';' rebase --continue\`. Report each step with \`${c} builder progress ${e} --phase building "<line>"\`, the board adds the phase word, in these words: "Rebasing onto ${a} \xB7 resolving <n> files", then "Rebasing onto ${a} \xB7 suite running".`,"3. Run the full test suite once, in the foreground. Fix what the rebase broke, and commit each fix with `git -c core.commentChar=';' commit -F <file>`. A push with commits of its own is no longer rebase-only, so a merge after an approval won't count it as trivial.",`4. If a conflict or a failing test is past what you can resolve with confidence, run \`git -c core.commentChar=';' rebase --abort\` if a rebase is under way, record it with \`${c} builder call ${e} "Rebase failed in <the files or tests> \xB7 <why>"\`, and run the finish step: with the call it hands the card to the orchestrator.`,"",I(n),"",`To finish, run ${B({route:t,key:e})}, the text saying what you resolved. It reruns the suite and pushes the branch to PR #${u} with --force-with-lease; the PR stays as it is.`,"- If it refuses because someone pushed to the branch since your fetch, fetch and rebase again (step 2), then run done again.","- On failing tests, fix them, commit, and run done again.","","Never push."].join(`
4
- `)}l(H,"rebaseBrief");function pe({route:t,key:e,ref:r,title:h,notes:n,thread:d,kind:a,repo:u,rules:p=[],links:c=[],text:o,files:i=[],question:s,note:f,choice:b}){const w=g(t),m=a==="grill";return[`You are the headless ${m?"grill":"prototype"} planner for card ${r} (${e}, "${h}") on the kickflip board /${t}. The board launched you; nobody watches this session, so never wait on a person: the owner answers on the board, and a later planner or builder picks up from their answers. Read and run in ${u}; write no output code ${m?"there":`in ${u} itself`}, never restart the hub or a board server, and never push.`,"",`1. Run \`${w} builder start ${e} --kind ${a}\`. If it refuses, stop.`,`2. Gather the context yourself: ${n?`the card's notes, ${n}, all sections, where later sections override earlier ones; `:"the card has no notes file yet; "}its thread, ${d}, the repo's docs/adr and CONTEXT.md, and the cards its notes and thread link.`,`3. Report progress with \`${w} builder progress ${e} "<plain, 80 characters or fewer>"\` at least every 10 minutes.`,m?`4. Find every decision the card leaves open: read the code it touches and answer what the code answers yourself. Post each decision left as a question for the owner with \`${w} question add --file <json>\` on topic item:${e}, one per decision, your recommendation first. Once you finish, the orchestrator screens them before the owner sees them, settling the ones the board already answers and passing the owner the rest. Invoke the grilling skill with the Skill tool and run it as one round: its questions go to the board with question add, never into the chat, and you never wait for an answer; after the round, finish. (With no Skill tool, follow this step as written.) When the code shows the card has separable parts, each a build of its own, propose splitting it into a wave of smaller cards as one question ahead of the prototype question: its options "Split as proposed" and "Keep as one card", your recommendation first. Slice it as ~/.claude/skills/to-tickets/SKILL.md step 3, "Draft vertical slices", says (read that step; you can't invoke the skill, and skip its quiz and publish steps). The first card is the thinnest end-to-end path. The question's context lists each proposed card with its title, its scope, the files it touches and the earlier proposed cards it waits on, or none: a card waits on an earlier one only when it builds on that card or shares its seam (the same function, component, CLI command or doc paragraph); sharing only a file waits on nothing. Write the same breakdown in your notes section. On Split the orchestrator files the cards when the card stages; never file them yourself. End every grill with one more question, "Prototype round first?", whose options are yes and no, with "prototype_gate": true in its \`question add --file\` entry: once the owner has answered every question the board moves the card to prototyping on yes, or to staging on no, so nothing else moves it. Recommend yes when the card changes the hub's or a board's UI, no otherwise. Ask it even when it is your only question.`:`4. Build the round in situ, in the board's base prototype worktree: run \`${w} prototype base\`, which makes it or moves it to main and prints its path, whether its build script is there and the listener a page loads. When the build script is missing, write one there that serves the app and prints "port <n>" (board/build-script.mjs). Add one page to the worktree, at a path no other round uses, built from the repo's real components, helpers and scripts fed mock data, fully interactive; it reads the take from ?variant= and the state from ?state=, and loads the listener so \`KickflipPrototype.on((take, state) => \u2026)\` re-renders it in place when the viewer switches. Record it with \`${w} prototype add <topic> --card ${e} --served <path> --take <K>:<label> \u2026 --state <key>:<label> \u2026\`, one take per option and one state for each state that matters to the question, then post one question whose url opens prototype-<topic>.html with \`${w} question add --file <json>\` on topic item:${e}, never asking in the chat. Only a repo whose app can't be served as a web page keeps take files: \`${w} prototype add <topic> --card ${e} --take <K>:<label> \u2026\`, one take file per option built from the board's real components fed fake data. Invoke the prototype skill with the Skill tool for this step. (With no Skill tool, follow this step as written.)`,...o?[` The owner asked for this ${m?"grill":"prototype"}, writing: "${o}"`]:[],...i.length?[` The owner attached: ${i.map(q=>q.path).join(", ")}.`]:[],...s?[` The owner asked for prototypes of question ${s}${f?`, noting "${f}"`:""}${b?`, leaning to option ${b}`:""}: draw that question's next round, its question naming round_of ${s}.`]:[],`5. Record what you learned in the card's notes, naming each answered question's id: write it in ${de}, then run ${le(w,e,`${m?"Grill":"Prototype"} (<MM/DD>)`)}, which appends it as a section. The notes file is read-only; never write into it. Anything you leave open becomes a question with question add, never only a line in the notes, so the card can't go ready past it. A question's text is one line of at most ${X} characters (question add refuses a longer one); put the detail in its context and the options' details, which take markdown.`,...m?[`6. Where the owner asked for prototypes, or a rule here wants a UI prototype first, end the card \`${w} item set ${e} --phase prototyping\` instead and skip the prototype question. Otherwise the prototype question is what moves the card on: never set it ready yourself, and never leave a Next that asks the owner to mark it ready.`]:[],"",...x(c),...T(p,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${w} builder done ${e} --text "<what you asked>"\`.`,"","Never push."].join(`
5
- `)}l(pe,"plannerBrief");function fe({route:t,key:e,ref:r,title:h,notes:n,thread:d,repo:a,agent:u,rules:p=[],links:c=[],text:o,files:i=[]}){const s=g(t);return[`You are the headless visual agent for card ${r} (${e}, "${h}") on the kickflip board /${t}. The owner asked, in the card's thread, for a visual: one HTML page that answers in a visual way, such as a diagram, a flow or a comparison. It is not a prototype or a grill: no question, no takes. The board launched you; nobody watches this session, so never wait on a person. Read and run in ${a}; write no code there, never restart the hub or a board server, and never push.`,"",`1. Run \`${s} builder start ${e} --kind visual --agent ${u}\`. If it refuses, stop.`,`2. Gather what the page needs: ${n?`the card's notes, ${n}; `:""}its thread, ${d}, and the code or docs it is about.`,o?` The owner wrote: "${o}"`:" The owner typed nothing: draw what the thread was last discussing.",...i.length?[` The owner attached: ${i.map(f=>f.path).join(", ")}.`]:[],"3. Write one HTML file outside the repo, such as in a temporary folder. Keep its own CSS and script inline; it may load a library such as Mermaid or D3 from a CDN. Make it read well at phone width (390px) and on a desktop, in the dark and the light theme (prefers-color-scheme).",`4. Place it with \`${s} visual add ${e} --file <page.html> --title "<what it shows>"\`, which copies it to the board and links it in the thread.`,"","Write nothing else: no notes, questions, card state, Next or progress lines.","",...x(c),...T(p,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${s} builder done ${e} --agent ${u}\`.`,"","Never push."].join(`
6
- `)}l(fe,"visualBrief");function we({route:t,key:e,ref:r,title:h,notes:n,thread:d,agent:a,task:u,writes:p,cwd:c,rules:o=[],links:i=[]}){const s=g(t);return[`You are the headless helper ${a} on card ${r} (${e}, "${h}") on the kickflip board /${t}. Another agent working on the card asked the board for you to do one task beside it, and waits on your hand-back. Nobody watches this session, so never wait on a person. Never restart the hub or a board server, and never push.`,p?`Work only in ${c}, your own worktree, branched from the card's: commit your work there with \`git -c core.commentChar=';' commit -F <file>\`, the subject "${r}: <what it does>". The card's builder merges your branch, so leave nothing uncommitted.`:`Read and run in ${c}; change no files there and commit nothing.`,"","The task:",u,"",`1. Run \`${s} builder start ${e} --kind helper --agent ${a}\`. If it refuses, stop.`,`2. Report progress with \`${s} builder progress ${e} --agent ${a} --phase reading|building|testing|checking "<plain, 80 characters or fewer>"\` at least every 10 minutes; the board adds your name and the phase word.`,"3. Do only the task. Don't ask the orchestrator or the owner, record no judgment calls and post no questions: put any decision you had to make in your hand-back.",n?` The card's notes, for context: ${n}.`:"",` ${I(d)}`,"",...x(i),...T(o,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${s} builder done ${e} --agent ${a} --text "<your hand-back: what you did or found, ${p?"what you committed, ":""}and any decision you made>"\`.`,"","Never push."].filter((f,b,w)=>f!==""||w[b-1]!=="").join(`
7
- `)}l(we,"helperBrief");const be=6e4;function me(t,{starts:e=W}={}){const r=t.filter(n=>n.pid&&n.at).map(n=>n.pid),h=r.length&&e(r)||new Map;return t.filter(n=>{const d=h.get(n.pid);return d!==void 0&&d<=Date.parse(n.at)&&d>=Date.parse(n.at)-be})}l(me,"launchedAgents");function Ne(t,{starts:e=W,kill:r=l((n,d)=>process.kill(-n,d),"kill"),killAfter:h=5e3}={}){const n=me(t,{starts:e});for(const{pid:d}of n){try{r(d,"SIGTERM")}catch{continue}setTimeout(()=>{try{r(d,"SIGKILL")}catch{}},h).unref()}return n.length}l(Ne,"stopAgents");async function je(t,{grace:e=5e3}={}){const r=Z(["-A","-o","pid=,ppid=,pgid=,args="]);if(r===null)throw new oe("ps gave no answer, so nothing was stopped; run it again");const h=r.split(`
8
- `).map(o=>/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/.exec(o)).filter(Boolean).map(([,o,i,s,f])=>({pid:Number(o),ppid:Number(i),pgid:Number(s),args:f})),n=new Set(h.filter(o=>t.includes(o.pgid)).map(o=>o.pid));for(let o=!0;o;){o=!1;for(const i of h)!n.has(i.pid)&&n.has(i.ppid)&&(n.add(i.pid),o=!0)}const d=h.find(o=>o.pid===process.pid)?.pgid,a=h.filter(o=>n.has(o.pid)&&o.pgid>1&&o.pgid!==d),u=[...new Set(a.map(o=>o.pgid))],p=l(o=>{for(const i of u)try{process.kill(-i,o)}catch{}},"signal");p("SIGTERM");const c=Date.now()+e;for(;a.some(o=>N(o.pid))&&Date.now()<c;)await new Promise(o=>setTimeout(o,50));return a.some(o=>N(o.pid))&&p("SIGKILL"),a.map(({pid:o,args:i})=>({pid:o,args:i}))}l(je,"stopRuns");const N=l(t=>{try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},"pidAlive");async function Ae(t,e,{launch:r,handBack:h,alive:n=N,held:d=l(()=>!1,"held"),stopped:a=new Set,paused:u=new Set,limitedUntil:p=l(()=>null,"limitedUntil"),atLimit:c=l(async()=>{},"atLimit")}){const o={};for(const[i,s]of Object.entries(t)){if(!e.has(i))continue;if(a.has(i)){o[i]={...s,handedBack:!0};continue}if(u.has(i)||s.pid!==null&&n(s.pid)||s.handedBack){o[i]=s;continue}const f={key:i,...s.kind?{kind:s.kind}:{},...s.model?{model:s.model}:{}},b=s.pid!==null?p(s):null;if(b){await c(f,b),o[i]={...s,pid:null};continue}if(d(s.kind??"claude")){o[i]=s;continue}if(s.pid!==null&&s.relaunched){await h(f),o[i]={...s,handedBack:!0};continue}const{key:w,...m}=f;o[i]={...m,...await r(f),relaunched:s.pid!==null||!!s.relaunched}}return o}l(Ae,"reviveBuilders");const K=l((t,e)=>k.join(Q.homedir(),".claude","kickflip","logs",`${e}-${t}-${new Date().toISOString().replace(/[:.]/g,"-")}.log`),"logFile");async function ge(t,{key:e,kind:r="claude",model:h,agent:n="main",text:d,files:a,question:u,note:p,choice:c,task:o,writes:i,worktree:s},{lander:f=!1}={}){const b=await L(t,e),w=C(t)?.route??k.basename(t),m=[...ee(),...await re(t)].map(V=>V.text),{base:q,repo:S}=M(t),y=ae({kind:r}),v=r===se,j=!y&&!v&&!f&&b.rebasePR!==null,A=r===ie,D=y?S:v?s??b.worktree??S:b.worktree,$={...b,route:w,base:q,repo:S,rules:m,kind:r,agent:n,text:d,files:a,question:u,note:p,choice:c,task:o,writes:i,cwd:D,pr:b.rebasePR},G=A?"Visual agent":v?`Helper ${n}`:y?"Planner":f?"Lander":j?"Rebase run":"Builder",U=A?fe($):v?we($):y?pe($):f?Y($):j?H($):ue($),R=await P({kind:y||v?"claude":r,model:h,cwd:D,site:t,prompt:U,log:K(e.split("/")[1],G.split(" ")[0].toLowerCase())});return await O(t,e,R.sessionId,R.pid,n,k.basename(R.log)),R}l(ge,"launchBuilder");const De=l(({ref:t,worktree:e,cleared:r})=>`The board paused your build of card ${t}, and the pause has cleared: ${r}. Carry on where you stopped, in ${e}, following your brief as before. Your builder record is still open, so don't run builder start again.`,"resumeBrief");async function _(t,{key:e,kind:r="claude",model:h,session:n,brief:d,fresh:a=!1,freshLaunch:u={}}){if(r!=="claude"||!n||a)return{...await ge(t,{key:e,kind:r,model:h},u),resumed:!1};const p=await L(t,e),c=await P({kind:r,model:h,cwd:n.worktree??p.worktree,site:t,prompt:d(p),resume:n.id,log:K(e.split("/")[1],"builder")});return await O(t,e,c.sessionId??n.id,c.pid,"main",k.basename(c.log)),{...c,resumed:!0}}l(_,"resumeBuilder");async function Pe(t,{key:e,kind:r="claude",model:h},{why:n,fresh:d=!1}={}){const a=await ne(t,e),u=await L(t,e),p=u.rebasePR!==null,c=a&&(!p||a.worktree===u.worktree)?a:null,o=C(t)?.route??k.basename(t),{base:i}=M(t),s=l(w=>(p?H:Y)({...w,route:o,base:i,pr:w.rebasePR,why:n,resumed:!0}),"brief"),f={lander:!p};let b;try{b=await _(t,{key:e,kind:r,model:h,session:c,brief:s,fresh:d,freshLaunch:f})}catch(w){if(!c)throw w;b=await _(t,{key:e,kind:r,model:h,session:null,brief:s,freshLaunch:f})}return b.resumed&&await te(t,e,"builder-resumed-to-land",{session:b.sessionId??c.id}),b}l(Pe,"landByBuilder");export{he as BOARD_CLI,ue as builderBrief,we as helperBrief,Pe as landByBuilder,Y as landerBrief,ge as launchBuilder,me as launchedAgents,N as pidAlive,pe as plannerBrief,H as rebaseBrief,De as resumeBrief,_ as resumeBuilder,Ae as reviveBuilders,Ne as stopAgents,je as stopRuns,fe as visualBrief};
1
+ var z=Object.defineProperty;var l=(t,e)=>z(t,"name",{value:e,configurable:!0});import Q from"node:os";import{BRIEF_LINE_LIMIT as X}from"./hub-lines.mjs";import T from"node:path";import{fileURLToPath as J}from"node:url";import{launchAgent as P}from"./agents.mjs";import{processStarts as W,ps as Z}from"../hub/live.mjs";import{boardAt as C}from"../hub/boards.mjs";import{readHubRules as ee}from"../hub/rules.mjs";import{builderRepo as M}from"./worktree.mjs";import{appendStatus as te,BoardError as oe,briefFacts as L,readBoardRules as re,recordedSession as ne,recordSession as O}from"./store.mjs";import{HELPER as se,plans as ae,VISUAL as ie}from"./domain.mjs";const he=J(new URL("./bin/board.mjs",import.meta.url)),$=l(t=>`node ${he} --site ${t}`,"cli"),E=l(t=>`git -c core.commentChar=';' rebase ${t}`,"rebase"),de="a draft .md of your own outside the board's data folder (such as in /tmp)",le=l((t,e,r)=>`\`${t} item notes ${e} --heading "${r}" --file <draft.md>\``,"notesCommand"),I=l((t,e="Rules from the hub and this board:")=>t.length?[e,...t.map(r=>`- ${r}`),""]:[],"ruleLines"),q=l(t=>t.length?["Related cards: read their notes for context; don't build their scope.",...t.map(e=>`- ${e.ref} "${e.title}" (${e.relation}, ${e.lane}): ${e.notes?`notes ${e.notes}`:"no notes"}, thread ${e.thread}`),""]:[],"linkLines"),S=l(t=>`The card's thread, which holds the owner's messages (who: love): ${t}. Read it live.`,"threadLine"),F=l(({route:t,key:e,worktree:r,base:h})=>[`- With no unverified calls, done finishes the card itself: it rebases onto ${h}, reruns the full test suite, fast-forwards ${h} and closes the card (on a board with pull requests it pushes the branch and opens a draft PR instead; with Auto-merge off it stops before the fast-forward, and the card waits for the owner's Merge).`,`- On a conflict it undoes its rebase and names the files: run \`${E(h)}\` in ${r}, resolve each conflict keeping both sides' intent, continue with \`git -c core.commentChar=';' rebase --continue\`, rerun the tests, and run done again.`,"- On failing tests, fix them, commit, and run done again.","- While another card is landing, done waits its turn and then lands; leave it running.","- Once a reviewer has the card's PR link, done refuses without `--updated \"<what changed>\"`, which goes in that link's Slack thread, or `--updated none` for a change only to comments, names, docs or tests.",`- Finishing never goes to the orchestrator. If done refuses for a reason you can't fix, record it with \`${$(t)} builder call ${e} "<why>"\` and run done again: with the call it hands the card back.`],"finishSteps"),j=l(({route:t,key:e})=>`\`${$(t)} builder done ${e} --text "<what you checked>"\``,"finishCommand"),ce=l((t,e)=>[`5. To run a separate part of the work in parallel, ask the board for a helper: \`${t} agent launch ${e} --name <short-name> --task "<the whole task, with the files and what to hand back>"\`, adding --writes when it changes code or runs tests (it gets its own worktree off your branch, and waits for a free implementer slot). Then \`${t} agent wait ${e} --name <short-name>\`, which prints its hand-back; it returns within 10 minutes, so run it again while it says still running, and do the task yourself if it says the helper exited. Merge a writing helper's work with \`${t} agent merge ${e} --name <short-name>\` before you test and finish.`],"helperSteps");function ue({route:t,key:e,ref:r,title:h,notes:n,thread:d,worktree:a,base:u,rules:p=[],links:c=[]}){const o=$(t);return[`You are the headless builder for card ${r} (${e}, "${h}") on the kickflip board /${t}. The board launched you; nobody watches this session, so never wait on a person. Work only in ${a}. Never restart the hub or a board server, and never push.`,"",`1. Run \`${o} builder start ${e} --kind build\`. If it refuses, stop.`,`2. Report progress with \`${o} builder progress ${e} --phase reading|building|testing|checking|landing "<plain, 80 characters or fewer>"\`, at least every 10 minutes. The board adds the phase word; don't start the text with it. The phases:`," - reading: the notes and the code, until the first test is written."," - building: the tests and the code, the ADR and docs, and the commit."," - testing: the full suite run before you finish."," - checking: your own review of the diff before you hand back; the Orchestrator's review of your calls continues on the same 4th bar."," - landing: set by the finish step itself; you never report it.",`3. Decide, record the call (step 4) and carry on: the orchestrator reviews your calls after the build. Ask it only when you are blocked, meaning every way forward would likely be thrown away: the spec contradicts itself or the code, a rule needs the owner's go before code is written, or the answer is a fact only the orchestrator has. Then run \`${o} builder ask ${e} "<question>"\`, do any work the answer can't change, and wait with \`${o} builder asks ${e} --wait\`, which returns within 10 minutes, so run it again while it says still waiting. If no answer comes in 30 minutes, record the question as a call, "Question: <question>", and hand back.`,`4. Record each judgment call the notes leave open with \`${o} builder call ${e} "<call>"\` instead of guessing silently or asking. A problem you find outside your card is a call "Found: <what>" for the orchestrator to file at review; ask about it at once only when it stalls other cards' builds or lands.`,...ce(o,e),"",n?`Spec: the card's notes, ${n}, all sections, where later sections override earlier ones.`:"The card has no notes file: build from its title, and record what you had to decide as calls.",`${S(d)} Read it with the notes: a message of the owner's is an instruction, but where it contradicts the notes, the notes win; that contradiction counts as blocked (step 3), so ask with \`${o} builder ask ${e} "<question>"\` and wait as step 3 says. Read the thread again in checking, before you finish, for anything the owner wrote during the build.`,"",...q(c),...I(p),"Write tests first, and run the full suite once, in the foreground, at the end. Where the repo keeps ADRs, write one named with a timestamp: docs/adr/YYYY-MM-DD-HHMM-<slug>.md.",`Commit with \`git -c core.commentChar=';' commit -F <file>\`, the subject "${r}: <what the card now does>".`,"",`To finish, run ${j({route:t,key:e})}.`,"- If you recorded a judgment call, it hands the card back for the orchestrator to verify your calls; stop there: the orchestrator's verification finishes the card.",...F({route:t,key:e,worktree:a,base:u}),"","Never push."].join(`
2
+ `)}l(ue,"builderBrief");function Y({route:t,key:e,ref:r,title:h,thread:n,worktree:d,base:a,answers:u=[],resumed:p=!1,why:c}){const o=$(t);return[p?`The board resumes you, the builder of card ${r} (${e}, "${h}") on the kickflip board /${t}, to land your build: ${c??"the orchestrator verified your judgment calls"}, and it waits only to land. Nobody watches this session, so never wait on a person. Work only in ${d}, never restart the hub or a board server, and never push.`:`You are the headless lander for card ${r} (${e}, "${h}") on the kickflip board /${t}. Its build is done and the orchestrator verified its judgment calls; it waits only to land. Nobody watches this session, so never wait on a person. Work only in ${d}, never restart the hub or a board server, and never push.`,"",`1. Run \`${o} builder start ${e} --kind build --label Lander --phase landing --progress "taking up the verified build"\`. If it refuses, stop.`,`2. Report progress with \`${o} builder progress ${e} --phase landing "<plain, 80 characters or fewer>"\`. The board adds the phase word; don't start the text with it.`,...u.length?["3. The owner answered the builder's deferred asks. Where an answer changes the build, change it, with its tests, and commit:",...u.map(i=>`- ${i.ask} "${i.question}": ${i.answer}`)]:[],"",S(n),"",`To finish, run ${j({route:t,key:e})}.`,...F({route:t,key:e,worktree:d,base:a}),"","Never push."].join(`
3
+ `)}l(Y,"landerBrief");function _({route:t,key:e,ref:r,title:h,thread:n,worktree:d,base:a,pr:u,resumed:p=!1}){const c=$(t);return[...p?[`The board resumes you, the builder of card ${r}, for this run: the lines below are your brief for it.`]:[],`You are the headless rebase run for card ${r} (${e}, "${h}") on the kickflip board /${t}. Its PR #${u} conflicts with ${a}; rebase its branch onto ${a} so the PR is clean again. Nobody watches this session, so never wait on a person. Work only in ${d}, never restart the hub or a board server, and never push.`,"",`1. Run \`${c} builder start ${e} --kind build --label Rebase --phase building --progress "Rebase run started \xB7 fetching ${a}"\`. If it refuses, stop.`,`2. Run \`git fetch origin\`, then \`${E(`origin/${a}`)}\`. Resolve each conflict keeping both sides' intent, \`git add\` it and continue with \`git -c core.commentChar=';' rebase --continue\`. Report each step with \`${c} builder progress ${e} --phase building "<line>"\`, the board adds the phase word, in these words: "Rebasing onto ${a} \xB7 resolving <n> files", then "Rebasing onto ${a} \xB7 suite running".`,"3. Run the full test suite once, in the foreground. Fix what the rebase broke, and commit each fix with `git -c core.commentChar=';' commit -F <file>`. A push with commits of its own is no longer rebase-only, so a merge after an approval won't count it as trivial.",`4. If a conflict or a failing test is past what you can resolve with confidence, run \`git -c core.commentChar=';' rebase --abort\` if a rebase is under way, record it with \`${c} builder call ${e} "Rebase failed in <the files or tests> \xB7 <why>"\`, and run the finish step: with the call it hands the card to the orchestrator.`,"",S(n),"",`To finish, run ${j({route:t,key:e})}, the text saying what you resolved. It reruns the suite and pushes the branch to PR #${u} with --force-with-lease; the PR stays as it is.`,"- If it refuses because someone pushed to the branch since your fetch, fetch and rebase again (step 2), then run done again.","- On failing tests, fix them, commit, and run done again.","","Never push."].join(`
4
+ `)}l(_,"rebaseBrief");function pe({route:t,key:e,ref:r,title:h,notes:n,thread:d,kind:a,repo:u,rules:p=[],links:c=[],text:o,files:i=[],question:s,note:f,choice:w,ticketQuestion:b=!1}){const m=$(t),g=a==="grill";return[`You are the headless ${g?"grill":"prototype"} planner for card ${r} (${e}, "${h}") on the kickflip board /${t}. The board launched you; nobody watches this session, so never wait on a person: the owner answers on the board, and a later planner or builder picks up from their answers. Read and run in ${u}; write no output code ${g?"there":`in ${u} itself`}, never restart the hub or a board server, and never push.`,"",`1. Run \`${m} builder start ${e} --kind ${a}\`. If it refuses, stop.`,`2. Gather the context yourself: ${n?`the card's notes, ${n}, all sections, where later sections override earlier ones; `:"the card has no notes file yet; "}its thread, ${d}, the repo's docs/adr and CONTEXT.md, and the cards its notes and thread link.`,`3. Report progress with \`${m} builder progress ${e} "<plain, 80 characters or fewer>"\` at least every 10 minutes.`,g?`4. Find every decision the card leaves open: read the code it touches and answer what the code answers yourself. Post each decision left as a question for the owner with \`${m} question add --file <json>\` on topic item:${e}, one per decision, your recommendation first. Once you finish, the orchestrator screens them before the owner sees them, settling the ones the board already answers and passing the owner the rest. Invoke the grilling skill with the Skill tool and run it as one round: its questions go to the board with question add, never into the chat, and you never wait for an answer; after the round, finish. (With no Skill tool, follow this step as written.) When the code shows the card has separable parts, each a build of its own, propose splitting it into a wave of smaller cards as one question ahead of the prototype question: its options "Split as proposed" and "Keep as one card", your recommendation first. Slice it as ~/.claude/skills/to-tickets/SKILL.md step 3, "Draft vertical slices", says (read that step; you can't invoke the skill, and skip its quiz and publish steps). The first card is the thinnest end-to-end path. The question's context lists each proposed card with its title, its scope, the files it touches and the earlier proposed cards it waits on, or none: a card waits on an earlier one only when it builds on that card or shares its seam (the same function, component, CLI command or doc paragraph); sharing only a file waits on nothing. Write the same breakdown in your notes section. On Split the orchestrator files the cards when the card stages; never file them yourself.`+(b?' This card is a task, with no ticket yet: just before the prototype question, ask "Create a ticket for this task?", whose options are yes and no, with "ticket_gate": true in its `question add --file` entry; the board makes the ticket from the card\'s title and notes the moment the owner answers yes. Recommend yes when the task lands code, no when it lands nothing (a publish, a setting, a one-off run).':"")+' End every grill with one more question, "Prototype round first?", whose options are yes and no, with "prototype_gate": true in its `question add --file` entry: once the owner has answered every question the board moves the card to prototyping on yes, or to staging on no, so nothing else moves it. Recommend yes when the card changes the hub\'s or a board\'s UI, no otherwise. Ask it even when it is your only question.':`4. Invoke the prototype skill with the Skill tool and build the round as take files, one per option: record them with \`${m} prototype add <topic> --card ${e} --take <K>:<label> \u2026\`, write the take files it prints, built from the repo's existing components, helpers and scripts fed mock data (the prototype template loads the board's scripts, so a take reuses the board's components; a hub-page take reuses them by path or copy), each take showing the states it needs inside itself, then post one question whose url opens prototype-<topic>.html with \`${m} question add --file <json>\` on topic item:${e}, never asking in the chat. Build in situ only where one of the board's rules asks for it: then, run \`${m} prototype base\`, which makes it or moves it to main and prints its path, whether its build script is there and the listener a page loads. When the build script is missing, write one there that serves the app and prints "port <n>" (board/build-script.mjs). Add one page to the worktree, at a path no other round uses, built from the repo's real components, helpers and scripts fed mock data, fully interactive; it reads the take from ?variant= and the state from ?state=, and loads the listener so \`KickflipPrototype.on((take, state) => \u2026)\` re-renders it in place when the viewer switches. Record it with \`${m} prototype add <topic> --card ${e} --served <path> --take <K>:<label> \u2026 --state <key>:<label> \u2026\`, one take per option and one state for each state that matters to the question, then post one question whose url opens prototype-<topic>.html with \`${m} question add --file <json>\` on topic item:${e}, never asking in the chat. (With no Skill tool, follow this step as written.)`,...o?[` The owner asked for this ${g?"grill":"prototype"}, writing: "${o}"`]:[],...i.length?[` The owner attached: ${i.map(v=>v.path).join(", ")}.`]:[],...s?[` The owner asked for prototypes of question ${s}${f?`, noting "${f}"`:""}${w?`, leaning to option ${w}`:""}: draw that question's next round, its question naming round_of ${s}.`]:[],`5. Record what you learned in the card's notes, naming each answered question's id: write it in ${de}, then run ${le(m,e,`${g?"Grill":"Prototype"} (<MM/DD>)`)}, which appends it as a section. The notes file is read-only; never write into it. Anything you leave open becomes a question with question add, never only a line in the notes, so the card can't go ready past it. A question's text is one line of at most ${X} characters (question add refuses a longer one); put the detail in its context and the options' details, which take markdown.`,...g?[`6. Where the owner asked for prototypes, or a rule here wants a UI prototype first, end the card \`${m} item set ${e} --phase prototyping\` instead and skip the prototype question. Otherwise the prototype question is what moves the card on: never set it ready yourself, and never leave a Next that asks the owner to mark it ready.`]:[],"",...q(c),...I(p,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${m} builder done ${e} --text "<what you asked>"\`.`,"","Never push."].join(`
5
+ `)}l(pe,"plannerBrief");function fe({route:t,key:e,ref:r,title:h,notes:n,thread:d,repo:a,agent:u,rules:p=[],links:c=[],text:o,files:i=[]}){const s=$(t);return[`You are the headless visual agent for card ${r} (${e}, "${h}") on the kickflip board /${t}. The owner asked, in the card's thread, for a visual: one HTML page that answers in a visual way, such as a diagram, a flow or a comparison. It is not a prototype or a grill: no question, no takes. The board launched you; nobody watches this session, so never wait on a person. Read and run in ${a}; write no code there, never restart the hub or a board server, and never push.`,"",`1. Run \`${s} builder start ${e} --kind visual --agent ${u}\`. If it refuses, stop.`,`2. Gather what the page needs: ${n?`the card's notes, ${n}; `:""}its thread, ${d}, and the code or docs it is about.`,o?` The owner wrote: "${o}"`:" The owner typed nothing: draw what the thread was last discussing.",...i.length?[` The owner attached: ${i.map(f=>f.path).join(", ")}.`]:[],"3. Write one HTML file outside the repo, such as in a temporary folder. Keep its own CSS and script inline; it may load a library such as Mermaid or D3 from a CDN. Make it read well at phone width (390px) and on a desktop, in the dark and the light theme (prefers-color-scheme).",`4. Place it with \`${s} visual add ${e} --file <page.html> --title "<what it shows>"\`, which copies it to the board and links it in the thread.`,"","Write nothing else: no notes, questions, card state, Next or progress lines.","",...q(c),...I(p,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${s} builder done ${e} --agent ${u}\`.`,"","Never push."].join(`
6
+ `)}l(fe,"visualBrief");function we({route:t,key:e,ref:r,title:h,notes:n,thread:d,agent:a,task:u,writes:p,cwd:c,rules:o=[],links:i=[]}){const s=$(t);return[`You are the headless helper ${a} on card ${r} (${e}, "${h}") on the kickflip board /${t}. Another agent working on the card asked the board for you to do one task beside it, and waits on your hand-back. Nobody watches this session, so never wait on a person. Never restart the hub or a board server, and never push.`,p?`Work only in ${c}, your own worktree, branched from the card's: commit your work there with \`git -c core.commentChar=';' commit -F <file>\`, the subject "${r}: <what it does>". The card's builder merges your branch, so leave nothing uncommitted.`:`Read and run in ${c}; change no files there and commit nothing.`,"","The task:",u,"",`1. Run \`${s} builder start ${e} --kind helper --agent ${a}\`. If it refuses, stop.`,`2. Report progress with \`${s} builder progress ${e} --agent ${a} --phase reading|building|testing|checking "<plain, 80 characters or fewer>"\` at least every 10 minutes; the board adds your name and the phase word.`,"3. Do only the task. Don't ask the orchestrator or the owner, record no judgment calls and post no questions: put any decision you had to make in your hand-back.",n?` The card's notes, for context: ${n}.`:"",` ${S(d)}`,"",...q(i),...I(o,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${s} builder done ${e} --agent ${a} --text "<your hand-back: what you did or found, ${p?"what you committed, ":""}and any decision you made>"\`.`,"","Never push."].filter((f,w,b)=>f!==""||b[w-1]!=="").join(`
7
+ `)}l(we,"helperBrief");const me=6e4;function be(t,{starts:e=W}={}){const r=t.filter(n=>n.pid&&n.at).map(n=>n.pid),h=r.length&&e(r)||new Map;return t.filter(n=>{const d=h.get(n.pid);return d!==void 0&&d<=Date.parse(n.at)&&d>=Date.parse(n.at)-me})}l(be,"launchedAgents");function Be(t,{starts:e=W,kill:r=l((n,d)=>process.kill(-n,d),"kill"),killAfter:h=5e3}={}){const n=be(t,{starts:e});for(const{pid:d}of n){try{r(d,"SIGTERM")}catch{continue}setTimeout(()=>{try{r(d,"SIGKILL")}catch{}},h).unref()}return n.length}l(Be,"stopAgents");async function Ne(t,{grace:e=5e3}={}){const r=Z(["-A","-o","pid=,ppid=,pgid=,args="]);if(r===null)throw new oe("ps gave no answer, so nothing was stopped; run it again");const h=r.split(`
8
+ `).map(o=>/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/.exec(o)).filter(Boolean).map(([,o,i,s,f])=>({pid:Number(o),ppid:Number(i),pgid:Number(s),args:f})),n=new Set(h.filter(o=>t.includes(o.pgid)).map(o=>o.pid));for(let o=!0;o;){o=!1;for(const i of h)!n.has(i.pid)&&n.has(i.ppid)&&(n.add(i.pid),o=!0)}const d=h.find(o=>o.pid===process.pid)?.pgid,a=h.filter(o=>n.has(o.pid)&&o.pgid>1&&o.pgid!==d),u=[...new Set(a.map(o=>o.pgid))],p=l(o=>{for(const i of u)try{process.kill(-i,o)}catch{}},"signal");p("SIGTERM");const c=Date.now()+e;for(;a.some(o=>B(o.pid))&&Date.now()<c;)await new Promise(o=>setTimeout(o,50));return a.some(o=>B(o.pid))&&p("SIGKILL"),a.map(({pid:o,args:i})=>({pid:o,args:i}))}l(Ne,"stopRuns");const B=l(t=>{try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},"pidAlive");async function Ae(t,e,{launch:r,handBack:h,alive:n=B,held:d=l(()=>!1,"held"),stopped:a=new Set,paused:u=new Set,limitedUntil:p=l(()=>null,"limitedUntil"),atLimit:c=l(async()=>{},"atLimit")}){const o={};for(const[i,s]of Object.entries(t)){if(!e.has(i))continue;if(a.has(i)){o[i]={...s,handedBack:!0};continue}if(u.has(i)||s.pid!==null&&n(s.pid)||s.handedBack){o[i]=s;continue}const f={key:i,...s.kind?{kind:s.kind}:{},...s.model?{model:s.model}:{}},w=s.pid!==null?p(s):null;if(w){await c(f,w),o[i]={...s,pid:null};continue}if(d(s.kind??"claude")){o[i]=s;continue}if(s.pid!==null&&s.relaunched){await h(f),o[i]={...s,handedBack:!0};continue}const{key:b,...m}=f;o[i]={...m,...await r(f),relaunched:s.pid!==null||!!s.relaunched}}return o}l(Ae,"reviveBuilders");const H=l((t,e)=>T.join(Q.homedir(),".claude","kickflip","logs",`${e}-${t}-${new Date().toISOString().replace(/[:.]/g,"-")}.log`),"logFile");async function ge(t,{key:e,kind:r="claude",model:h,agent:n="main",text:d,files:a,question:u,note:p,choice:c,task:o,writes:i,worktree:s},{lander:f=!1}={}){const w=await L(t,e),b=C(t)?.route??T.basename(t),m=[...ee(),...await re(t)].map(V=>V.text),{base:g,repo:v}=M(t),k=ae({kind:r}),R=r===se,N=!k&&!R&&!f&&w.rebasePR!==null,A=r===ie,D=k?v:R?s??w.worktree??v:w.worktree,y={...w,route:b,base:g,repo:v,rules:m,kind:r,agent:n,text:d,files:a,question:u,note:p,choice:c,task:o,writes:i,cwd:D,pr:w.rebasePR},G=A?"Visual agent":R?`Helper ${n}`:k?"Planner":f?"Lander":N?"Rebase run":"Builder",U=A?fe(y):R?we(y):k?pe(y):f?Y(y):N?_(y):ue(y),x=await P({kind:k||R?"claude":r,model:h,cwd:D,site:t,prompt:U,log:H(e.split("/")[1],G.split(" ")[0].toLowerCase())});return await O(t,e,x.sessionId,x.pid,n,T.basename(x.log)),x}l(ge,"launchBuilder");const De=l(({ref:t,worktree:e,cleared:r})=>`The board paused your build of card ${t}, and the pause has cleared: ${r}. Carry on where you stopped, in ${e}, following your brief as before. Your builder record is still open, so don't run builder start again.`,"resumeBrief");async function K(t,{key:e,kind:r="claude",model:h,session:n,brief:d,fresh:a=!1,freshLaunch:u={}}){if(r!=="claude"||!n||a)return{...await ge(t,{key:e,kind:r,model:h},u),resumed:!1};const p=await L(t,e),c=await P({kind:r,model:h,cwd:n.worktree??p.worktree,site:t,prompt:d(p),resume:n.id,log:H(e.split("/")[1],"builder")});return await O(t,e,c.sessionId??n.id,c.pid,"main",T.basename(c.log)),{...c,resumed:!0}}l(K,"resumeBuilder");async function Pe(t,{key:e,kind:r="claude",model:h},{why:n,fresh:d=!1}={}){const a=await ne(t,e),u=await L(t,e),p=u.rebasePR!==null,c=a&&(!p||a.worktree===u.worktree)?a:null,o=C(t)?.route??T.basename(t),{base:i}=M(t),s=l(b=>(p?_:Y)({...b,route:o,base:i,pr:b.rebasePR,why:n,resumed:!0}),"brief"),f={lander:!p};let w;try{w=await K(t,{key:e,kind:r,model:h,session:c,brief:s,fresh:d,freshLaunch:f})}catch(b){if(!c)throw b;w=await K(t,{key:e,kind:r,model:h,session:null,brief:s,freshLaunch:f})}return w.resumed&&await te(t,e,"builder-resumed-to-land",{session:w.sessionId??c.id}),w}l(Pe,"landByBuilder");export{he as BOARD_CLI,ue as builderBrief,we as helperBrief,Pe as landByBuilder,Y as landerBrief,ge as launchBuilder,be as launchedAgents,B as pidAlive,pe as plannerBrief,_ as rebaseBrief,De as resumeBrief,K as resumeBuilder,Ae as reviveBuilders,Be as stopAgents,Ne as stopRuns,fe as visualBrief};
@@ -1 +1 @@
1
- var b=Object.defineProperty;var t=(e,o)=>b(e,"name",{value:o,configurable:!0});import w from"node:os";const h=100,P=2e3,$=/(?:~|\/)[^\s:;,()'"]*\/([^\s:;,()'"/]+)/g;function r(e,o,a=""){const d=h-e.length-a.length;let l=String(o??"").split(w.homedir()).join("~").replace(/\s+/g," ").trim();return l.length>d&&(l=l.replace($,"\u2026/$1")),l.length<=d?e+l+a:`${e}${l.slice(0,d-1).trimEnd()}\u2026${a.replace(/^\./,"")}`}t(r,"fit");const i="Held",m="Resumed",k="Blocked",s="Fault",c="move",g="questions",u="Implementation requested",f="Prototype requested",n="Marked done",y="prototype",x="owner/a-long-repo-name#10000",v="Wed, 11/30, 12:00 PM",p={"host-busy":{mark:i,text:t(()=>"Host is busy, work will resume when the host recovers","text")},"planner-held":{mark:i,text:t(({kind:e})=>`The ${e} waits and starts when the hold lifts.`,"text"),longest:{kind:y}},paused:{mark:i,text:t(({phase:e,words:o,clear:a})=>r(`Paused${e?` at ${e}`:""}: `,o,`. It resumes once ${a}.`),"text"),longest:{phase:"building",clear:"the usage pause lifts"}},"run-stopped":{mark:i,text:t(({words:e})=>e,"text"),longest:{words:"build stopped by orchestrator"}},"land-moved-first":{mark:c,text:t(({words:e})=>e,"text"),longest:{words:"land moved first by orchestrator"}},"builder-stopped":{mark:i,text:t(()=>"Stopped its builder.","text")},"land-waiting":{mark:i,text:t(({card:e})=>r("Waiting for ",e," to land"),"text")},resumed:{mark:m,text:t(({clear:e})=>`Resumed: ${e}.`,"text"),longest:{clear:"the usage pause lifted"}},"hold-ended":{mark:m,text:t(({at:e})=>`Resumed: its hold until ${e} ended.`,"text"),longest:{at:v}},unblocked:{mark:m,text:t(({lifted:e})=>r("Unblocked: ",e,"."),"text")},"unblocked-done":{mark:m,text:t(({card:e})=>r("Unblocked: ",e," is done."),"text")},"blocked-pausing":{mark:k,text:t(({blocked:e})=>r("Blocked ",e,": its builder pauses at its next stopping point and it stays In Progress."),"text")},"blocked-stays":{mark:k,text:t(({blocked:e})=>r("Blocked ",e,": it stays In Progress."),"text")},"cant-start-yet":{mark:k,text:t(({names:e})=>r("Can\u2019t start yet: waits on ",e,". Bumped to the top of Todo."),"text")},"merge-blocked":{mark:k,text:t(({blocked:e})=>r("Not merged: blocked ",e,"."),"text")},pulled:{mark:u,text:t(()=>"Pulled in: an implementer slot was free.","text")},"helper-asked":{mark:u,text:t(({agent:e,writes:o})=>r("Asked for helper ",e,o?", which writes code":""),"text"),longest:{writes:!0}},"arch-review":{mark:u,text:t(({card:e})=>r("Started an architecture review of ",e,"; its report becomes the notes"),"text")},"prototype-after":{mark:f,text:t(()=>"Prototype round asked: it moves to prototyping once every question is answered.","text")},"prototype-round":{mark:f,text:t(()=>"You asked for a prototype round, so the board moved the card to prototyping.","text")},"new-question":{mark:g,text:t(()=>"A new question on it, so it is grilling until you answer.","text")},"screen-timeout":{mark:g,text:t(()=>"Questions passed to you unscreened: the orchestrator didn\u2019t screen them in 15 minutes.","text")},"ask-moved":{mark:c,text:t(({board:e})=>r("Moved to ",e,"."),"text")},"pr-found":{mark:c,text:t(({pr:e,branch:o})=>r(`Found PR #${e} on branch `,o,"."),"text"),longest:{pr:1e5}},"ci-passed":{mark:n,text:t(({pr:e})=>`CI passed, so PR #${e} is marked ready for review.`,"text"),longest:{pr:1e5}},"worktree-remade":{mark:c,text:t(()=>"Remade its leftover worktree: it held no commits or changes.","text")},merged:{mark:n,text:t(({words:e})=>r("",e),"text")},"already-merged":{mark:n,text:t(({prs:e,many:o})=>r(`PR${o?"s":""} `,e,` ${o?"were":"was"} already merged.`),"text"),longest:{many:!0}},"ask-moved-closed":{mark:n,text:t(({board:e})=>r("Closed: its ask moved to ",e,"."),"text")},"check-passed":{mark:n,text:t(({found:e})=>r("Check passed: ",e,". Closed."),"text")},"findings-settled":{mark:n,text:t(({filed:e})=>r("Every finding is settled: ",e?`filed ${e}`:"none filed","."),"text")},"branch-merged":{mark:n,text:t(({branch:e,into:o,host:a})=>r("",`${e} is merged into ${o} on ${a}`,", so this card is Done."),"text")},"branch-gone":{mark:n,text:t(({branch:e,host:o})=>r("",`${e} is gone from ${o}`,", so this card is Done."),"text")},"prs-closed":{mark:n,text:t(({prs:e})=>r("Closed: ",e," closed unmerged."),"text"),longest:{prs:`${x}, ${x}`}},"landed-on-merge":{mark:n,text:t(({base:e})=>r("Landed on ",e," on your Merge."),"text")},"lander-handoff":{mark:u,text:t(({why:e})=>r("Not merged yet: ",e,". Its builder resumes to fix it and land it."),"text")},"builder-resumed-to-land":{mark:u,text:t(({session:e})=>r("Builder resumed to land, session ",e),"text")},"build-refused":{mark:s,fault:!0,text:t(({why:e})=>r("Couldn't start implementing: ",e),"text")},"planner-failed":{mark:s,fault:!0,text:t(({kind:e,error:o})=>r(`Couldn't start the ${e}: `,o),"text"),longest:{kind:"visual agent"}},"helper-failed":{mark:s,fault:!0,text:t(({name:e,error:o})=>r(`Couldn't start helper ${e}: `,o),"text"),longest:{name:"a-helper-name-of-24-char"}},"exited-twice":{mark:s,fault:!0,text:t(()=>"Its builder exited twice unfinished; it reads stopped until the orchestrator takes it up.","text")},"resume-failed":{mark:s,fault:!0,text:t(({error:e})=>r("Couldn't resume the builder headless: ",e),"text")},"relaunch-failed":{mark:s,fault:!0,text:t(({error:e})=>r("Couldn't relaunch the builder headless: ",e),"text")},"lander-failed":{mark:s,fault:!0,text:t(({error:e})=>r("Couldn't launch the lander; land it by hand: ",e),"text")},"rebase-failed":{mark:s,fault:!0,text:t(({pr:e,error:o})=>r(`PR #${e} conflicts, but the rebase run couldn't start: `,o),"text"),longest:{pr:1e5}},"rebase-launch-failed":{mark:s,fault:!0,text:t(({error:e})=>r("Couldn't launch the rebase run; it reads stopped: ",e),"text")},"merge-refused":{mark:s,fault:!0,text:t(({why:e})=>r("Not merged: ",e,"."),"text")},"land-failed":{mark:s,fault:!0,text:t(({why:e})=>r("Not merged: ",e,". Tap Merge again."),"text")},"push-failed":{mark:s,fault:!0,text:t(({base:e,error:o})=>r(`Landed, but ${e} didn't reach origin: `,o),"text"),longest:{base:"a-long-base-branch"}},"answers-failed":{mark:s,fault:!0,text:t(({what:e,error:o})=>r(`Answers recorded, but ${e} failed: `,o),"text"),longest:{what:"writing them into its notes"}},"notes-missing":{mark:s,fault:!0,text:t(()=>"Its notes file was missing, so the board started a new one.","text")},"notes-shared":{mark:s,fault:!0,text:t(({card:e})=>r("It shared its notes file with ",e,", so the board gave it its own copy."),"text")},"check-broken":{mark:s,fault:!0,text:t(({error:e})=>r("The owner step's check can't run, so it stopped: ",e),"text")},"run-failed":{mark:s,fault:!0,text:t(({kind:e,code:o,why:a})=>r(`${e} failed (exit ${o})`,a?`: ${a}`:""),"text"),longest:{kind:"Serve",code:255}}};function C(e,o={}){const a=p[e];if(!a)throw new Error(`no status line kind "${e}"`);const d=a.text(o);if(!d||d.length>h)throw new Error(`the "${e}" status line runs to ${d.length} characters, past ${h}: ${d}`);return d}t(C,"hubText");const T=t(e=>({mark:p[e.line]?.mark||"",fault:!!p[e.line]?.fault}),"hubLineOf"),R="hub";export{h as BRIEF_LINE_LIMIT,R as HUB,p as HUB_LINES,P as MESSAGE_LIMIT,r as fit,T as hubLineOf,C as hubText};
1
+ var b=Object.defineProperty;var t=(e,o)=>b(e,"name",{value:o,configurable:!0});import w from"node:os";const h=100,P=2e3,$=/(?:~|\/)[^\s:;,()'"]*\/([^\s:;,()'"/]+)/g;function r(e,o,s=""){const d=h-e.length-s.length;let l=String(o??"").split(w.homedir()).join("~").replace(/\s+/g," ").trim();return l.length>d&&(l=l.replace($,"\u2026/$1")),l.length<=d?e+l+s:`${e}${l.slice(0,d-1).trimEnd()}\u2026${s.replace(/^\./,"")}`}t(r,"fit");const i="Held",c="Resumed",u="Blocked",a="Fault",m="move",g="questions",k="Implementation requested",x="Prototype requested",n="Marked done",y="prototype",f="owner/a-long-repo-name#10000",v="Wed, 11/30, 12:00 PM",p={"host-busy":{mark:i,text:t(()=>"Host is busy, work will resume when the host recovers","text")},"planner-held":{mark:i,text:t(({kind:e})=>`The ${e} waits and starts when the hold lifts.`,"text"),longest:{kind:y}},paused:{mark:i,text:t(({phase:e,words:o,clear:s})=>r(`Paused${e?` at ${e}`:""}: `,o,`. It resumes once ${s}.`),"text"),longest:{phase:"building",clear:"the usage pause lifts"}},"run-stopped":{mark:i,text:t(({words:e})=>e,"text"),longest:{words:"build stopped by orchestrator"}},"land-moved-first":{mark:m,text:t(({words:e})=>e,"text"),longest:{words:"land moved first by orchestrator"}},"builder-stopped":{mark:i,text:t(()=>"Stopped its builder.","text")},"land-waiting":{mark:i,text:t(({card:e})=>r("Waiting for ",e," to land"),"text")},resumed:{mark:c,text:t(({clear:e})=>`Resumed: ${e}.`,"text"),longest:{clear:"the usage pause lifted"}},"hold-ended":{mark:c,text:t(({at:e})=>`Resumed: its hold until ${e} ended.`,"text"),longest:{at:v}},unblocked:{mark:c,text:t(({lifted:e})=>r("Unblocked: ",e,"."),"text")},"unblocked-done":{mark:c,text:t(({card:e})=>r("Unblocked: ",e," is done."),"text")},"blocked-pausing":{mark:u,text:t(({blocked:e})=>r("Blocked ",e,": its builder pauses at its next stopping point and it stays In Progress."),"text")},"blocked-stays":{mark:u,text:t(({blocked:e})=>r("Blocked ",e,": it stays In Progress."),"text")},"cant-start-yet":{mark:u,text:t(({names:e})=>r("Can\u2019t start yet: waits on ",e,". Bumped to the top of Todo."),"text")},"split-moved":{mark:u,text:t(({card:e,to:o})=>r("Split: ",`${e} became ${o}`,", so it waits on those now."),"text")},"merge-blocked":{mark:u,text:t(({blocked:e})=>r("Not merged: blocked ",e,"."),"text")},pulled:{mark:k,text:t(()=>"Pulled in: an implementer slot was free.","text")},"helper-asked":{mark:k,text:t(({agent:e,writes:o})=>r("Asked for helper ",e,o?", which writes code":""),"text"),longest:{writes:!0}},"arch-review":{mark:k,text:t(({card:e})=>r("Started an architecture review of ",e,"; its report becomes the notes"),"text")},"prototype-after":{mark:x,text:t(()=>"Prototype round asked: it moves to prototyping once every question is answered.","text")},"prototype-round":{mark:x,text:t(()=>"You asked for a prototype round, so the board moved the card to prototyping.","text")},"ticket-made":{mark:m,text:t(({ticket:e})=>r("You asked for a ticket, so the board made ",e,"."),"text")},"new-question":{mark:g,text:t(()=>"A new question on it, so it is grilling until you answer.","text")},"screen-timeout":{mark:g,text:t(()=>"Questions passed to you unscreened: the orchestrator didn\u2019t screen them in 15 minutes.","text")},"ask-moved":{mark:m,text:t(({board:e})=>r("Moved to ",e,"."),"text")},"pr-found":{mark:m,text:t(({pr:e,branch:o})=>r(`Found PR #${e} on branch `,o,"."),"text"),longest:{pr:1e5}},"ci-passed":{mark:n,text:t(({pr:e})=>`CI passed, so PR #${e} is marked ready for review.`,"text"),longest:{pr:1e5}},"worktree-remade":{mark:m,text:t(()=>"Remade its leftover worktree: it held no commits or changes.","text")},merged:{mark:n,text:t(({words:e})=>r("",e),"text")},"already-merged":{mark:n,text:t(({prs:e,many:o})=>r(`PR${o?"s":""} `,e,` ${o?"were":"was"} already merged.`),"text"),longest:{many:!0}},"ask-moved-closed":{mark:n,text:t(({board:e})=>r("Closed: its ask moved to ",e,"."),"text")},"check-passed":{mark:n,text:t(({found:e})=>r("Check passed: ",e,". Closed."),"text")},"findings-settled":{mark:n,text:t(({filed:e})=>r("Every finding is settled: ",e?`filed ${e}`:"none filed","."),"text")},"branch-merged":{mark:n,text:t(({branch:e,into:o,host:s})=>r("",`${e} is merged into ${o} on ${s}`,", so this card is Done."),"text")},"branch-gone":{mark:n,text:t(({branch:e,host:o})=>r("",`${e} is gone from ${o}`,", so this card is Done."),"text")},"prs-closed":{mark:n,text:t(({prs:e})=>r("Closed: ",e," closed unmerged."),"text"),longest:{prs:`${f}, ${f}`}},"landed-on-merge":{mark:n,text:t(({base:e})=>r("Landed on ",e," on your Merge."),"text")},"lander-handoff":{mark:k,text:t(({why:e})=>r("Not merged yet: ",e,". Its builder resumes to fix it and land it."),"text")},"builder-resumed-to-land":{mark:k,text:t(({session:e})=>r("Builder resumed to land, session ",e),"text")},"build-refused":{mark:a,fault:!0,text:t(({why:e})=>r("Couldn't start implementing: ",e),"text")},"planner-failed":{mark:a,fault:!0,text:t(({kind:e,error:o})=>r(`Couldn't start the ${e}: `,o),"text"),longest:{kind:"visual agent"}},"helper-failed":{mark:a,fault:!0,text:t(({name:e,error:o})=>r(`Couldn't start helper ${e}: `,o),"text"),longest:{name:"a-helper-name-of-24-char"}},"exited-twice":{mark:a,fault:!0,text:t(()=>"Its builder exited twice unfinished; it reads stopped until the orchestrator takes it up.","text")},"resume-failed":{mark:a,fault:!0,text:t(({error:e})=>r("Couldn't resume the builder headless: ",e),"text")},"relaunch-failed":{mark:a,fault:!0,text:t(({error:e})=>r("Couldn't relaunch the builder headless: ",e),"text")},"lander-failed":{mark:a,fault:!0,text:t(({error:e})=>r("Couldn't launch the lander; land it by hand: ",e),"text")},"rebase-failed":{mark:a,fault:!0,text:t(({pr:e,error:o})=>r(`PR #${e} conflicts, but the rebase run couldn't start: `,o),"text"),longest:{pr:1e5}},"rebase-launch-failed":{mark:a,fault:!0,text:t(({error:e})=>r("Couldn't launch the rebase run; it reads stopped: ",e),"text")},"merge-refused":{mark:a,fault:!0,text:t(({why:e})=>r("Not merged: ",e,"."),"text")},"land-failed":{mark:a,fault:!0,text:t(({why:e})=>r("Not merged: ",e,". Tap Merge again."),"text")},"push-failed":{mark:a,fault:!0,text:t(({base:e,error:o})=>r(`Landed, but ${e} didn't reach origin: `,o),"text"),longest:{base:"a-long-base-branch"}},"answers-failed":{mark:a,fault:!0,text:t(({what:e,error:o})=>r(`Answers recorded, but ${e} failed: `,o),"text"),longest:{what:"writing them into its notes"}},"notes-missing":{mark:a,fault:!0,text:t(()=>"Its notes file was missing, so the board started a new one.","text")},"notes-shared":{mark:a,fault:!0,text:t(({card:e})=>r("It shared its notes file with ",e,", so the board gave it its own copy."),"text")},"check-broken":{mark:a,fault:!0,text:t(({error:e})=>r("The owner step's check can't run, so it stopped: ",e),"text")},"run-failed":{mark:a,fault:!0,text:t(({kind:e,code:o,why:s})=>r(`${e} failed (exit ${o})`,s?`: ${s}`:""),"text"),longest:{kind:"Serve",code:255}}};function C(e,o={}){const s=p[e];if(!s)throw new Error(`no status line kind "${e}"`);const d=s.text(o);if(!d||d.length>h)throw new Error(`the "${e}" status line runs to ${d.length} characters, past ${h}: ${d}`);return d}t(C,"hubText");const T=t(e=>({mark:p[e.line]?.mark||"",fault:!!p[e.line]?.fault}),"hubLineOf"),R="hub";export{h as BRIEF_LINE_LIMIT,R as HUB,p as HUB_LINES,P as MESSAGE_LIMIT,r as fit,T as hubLineOf,C as hubText};