@lovek4d/kickflip 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTEXT.md +29 -17
- package/SKILL.md +12 -8
- package/bin/event-lines.mjs +1 -0
- package/bin/kickflip.mjs +7 -7
- package/bin/wait-events.mjs +2 -2
- package/board/agents.mjs +2 -2
- package/board/arch-review.mjs +1 -1
- package/board/bin/board.mjs +46 -32
- package/board/domain.mjs +7 -7
- package/board/finish.mjs +4 -4
- package/board/headless.mjs +8 -9
- package/board/onboarding.mjs +1 -1
- package/board/prototype-page.mjs +1 -1
- package/board/public/app-arch.js +2 -2
- package/board/public/app-banner.js +1 -1
- package/board/public/app-cards.js +13 -4
- package/board/public/app-lanes.js +2 -2
- package/board/public/app-needs.js +107 -26
- package/board/public/app-reader.js +52 -42
- package/board/public/app-threads.js +2 -2
- package/board/public/app.html +1 -1
- package/board/public/app.js +22 -12
- package/board/public/progress-review.js +4 -4
- package/board/public/prototype-kit.js +25 -11
- package/board/public/prototype-switcher.js +47 -32
- package/board/public/prototype.html +7 -4
- package/board/public/router.js +34 -6
- package/board/public/shell.js +19 -13
- package/board/public/sidebar.css +2 -2
- package/board/public/style.css +58 -11
- package/board/public/ui-cards.js +44 -27
- package/board/public/ui-enums.js +10 -1
- package/board/public/ui-links.js +1 -1
- package/board/public/ui-order.js +8 -5
- package/board/public/ui-progress-bar.js +6 -7
- package/board/public/ui-questions.js +18 -3
- package/board/public/ui-sidebar.js +3 -2
- package/board/public/ui-threads.js +10 -12
- package/board/public/ui.js +4 -2
- package/board/public/view-notes.js +1 -1
- package/board/public/view-questions.js +18 -2
- package/board/public/view-settings.js +60 -28
- package/board/server.mjs +19 -20
- package/board/stop.mjs +1 -1
- package/board/store.mjs +25 -25
- package/board/tickets.mjs +1 -1
- package/board/transcript.mjs +4 -2
- package/hub/home.mjs +1 -1
- package/hub/hub.mjs +6 -6
- package/hub/try.mjs +6 -6
- package/hub/upgrade.mjs +1 -1
- package/package.json +1 -1
- package/shared/tailscale.mjs +1 -1
package/board/domain.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var Gt=Object.defineProperty;var l=(e,t)=>Gt(e,"name",{value:t,configurable:!0});import{routeRecord as A}from"../hub/routes.mjs";import Qt from"node:fs";import{ticketBadge as ct,ticketIn as Vt}from"./tickets.mjs";import{prLinks as Ht,reviewLinks as Xt,reviewTime as Yt,reviewersOf as zt}from"./review.mjs";import{remoteFromInput as Jt}from"../hub/repos.mjs";import{reviewsOf as Zt,reviewNeeds as en,reviewActions as tn}from"./auto-review.mjs";import{cardPRs as nn,hasPR as et,leastReady as on,prKeyOf as sn,prURL as rn}from"../shared/card-prs.mjs";import ut from"node:vm";import{checkWords as an,parseCheck as ln}from"../shared/owner-check.mjs";import{buildScriptOf as dn}from"./build-script.mjs";const tt=ut.createContext({});for(const e of["ui-enums.js","ui-order.js"])ut.runInContext(Qt.readFileSync(new URL(`./public/${e}`,import.meta.url),"utf8"),tt);const{BUTTON:oe,ACTION_KIND:q,BUILDER_KIND:be,PR_STATE:Z}=tt.BoardUI,{laneOrder:cn}=tt.BoardUI,un=["item-message","mark-ready","grill-more","prototype-request","visual-request","reask-request"],pt="question-reopen",ts=Object.freeze({todo:"Todo",progress:"In Progress",review:"In Review",done:"Done"}),Se="move",ft=10*6e4,pn=5*6e4,gt="build-refused",Ie=Object.freeze({ask:"builder-ask",answer:"builder-answer"}),fn=864e5,pe=l(e=>e.lane==="done"||e.lane==="asks","closedLane"),gn=l(e=>`wave:${e}`,"waveFold"),kt=7*fn,mt=l((e,t)=>({id:e,url:t?.workspace?`https://linear.app/${t.workspace}/issue/${e}`:null}),"linearRef"),kn=l((e,t)=>String(e).replace(/^S(\d+)$/,`${t||"INT"}-$1`),"internalRef"),Ke=l((e,t,n)=>Vt(n,t.ticket)?t.ticket:e.internal===!0?kn(t.id,n?.prefix):t.id,"refOf"),mn=l((e,t,n,s)=>ct(e||(t?{source:"internal",prefix:"INT"}:null),n,s)||(t?{id:String(t),url:null,source:null}:null),"ticketOf");function wn(e,t,n,s,r,a,u,d,p){return!a&&(e.lane==="done"||t?.state==="MERGED"||t?.state==="CLOSED")?"done":(n||s)&&!d?"progress":r?"review":t?.state==="OPEN"?t.checks?.state==="fail"&&(!t.isDraft||u)?"progress":"review":t||p?"progress":"todo"}l(wn,"laneOf");const hn="Lander",wt=l(e=>e.kind!==be.install&&e.label!==hn,"changesCode");function yn(e,t){return e?.state==="MERGED"||t?Z.merged:e?.state==="CLOSED"?Z.closed:e?.state==="OPEN"?e.isDraft?Z.draft:Z.open:null}l(yn,"prStateOf");const ht=l(e=>e.pr?.status===Z.closed,"unlanded"),bn=l(e=>e.some(t=>t.kind==="work")&&e.every(t=>t.lane==="done"),"finishedOf");function nt(e){const t=yt(e);return t?.done&&t.handed_back?t.handed_back:null}l(nt,"handedBackAt");const yt=l(e=>e.filter(t=>t?.started&&te(t)&&t.kind!==be.install).sort((t,n)=>String(t.started).localeCompare(String(n.started))).at(-1),"newestBuild");function Sn(e,t,n){return Object.fromEntries(e.map(s=>{const r=A(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"?A(n,s.name):null,github:s.github||null}]}))}l(Sn,"reviewOf");function vn(e,t,n,s,r,a,{held:u,needsApproval:d}){return n?.kind===be.install?"builder":s?"checking":n?"builder":u&&e==="review"?"merge":r&&e==="review"?"owner":e==="review"&&t?.state==="OPEN"&&t.isDraft?a?"ci":"ready":e==="review"?bt(t,d)?"merge":"reviewers":null}l(vn,"waitsOnOf");const bt=l((e,t)=>e?.reviewDecision==="APPROVED"||!t&&!["REVIEW_REQUIRED","CHANGES_REQUESTED"].includes(e?.reviewDecision),"reviewed"),qe=/(^|\/)prototype-[\w-]+\.html/,xn={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"},On=l(e=>`Verified: tap Merge to land it on ${e}`,"heldNext"),$n="Fix the failing CI",St="Tap Done once it is settled",En=["status","agent","ask-link","command",Se,Ie.answer],vt=l(e=>(e.who==="claude"||e.via==="github")&&!En.includes(e.kind),"countsUnread"),An=/^(?:Not merged yet: |Lander launched headless )/;function Bn({slug:e,wave:t,it:n,order:s,prs:r,repo:a,remote:u,base:d,builder:p,reachedPhase:f,agents:g,worktree:c,eta:h,thread:m,events:x,working:S,said:L,askedAt:_,topicItems:P,prSlack:T,boardReviewers:K,now:E,bumpedAt:C,holdAsk:i,closedAt:y,mergeAt:B,autoMerge:ke,skipDraft:re,tickets:U}){const V=r.map(w=>({repo:w.repo,number:w.number,url:rn(w),...w.gh||w.kept||{},status:yn(w.gh,w.merged_at)})),W=on(r.map(w=>w.gh)),N=r[W]?.gh||null,H=V[W]?.status??null,X=n.lane||null,Ne=!!y&&String(y)>String(n.lane_at||"");Ne&&(n={...n,lane:"done",closed_at:y,reopened_at:void 0});const F=[n.closed_at,...r.flatMap(w=>[w.merged_at,w.gh?.mergedAt])].filter(Boolean).map(String).sort().pop()||null,j=String(F||""),Ce=V.length>0&&V.every(w=>w.status===Z.closed),G=(n.lane==="done"||n.reopened_at||H===Z.merged)&&!Ce&&([...L.filter(w=>w.kind==="item-message").map(w=>w.ts),..._].map(String).filter(w=>w>j).sort().pop()||n.reopened_at)||void 0,me=n.owner_step&&!Ne?String(n.owner_step):null,Ye=(n.lane==="done"||H===Z.merged)&&!Ce;G&&(n={...n,next:void 0});const $e=nt(g),ze=!!G&&L.some(w=>String(w.ts)>j&&(w.state==="waiting"||w.state==="working")),we=`${e}/${n.id}`,Q=zt(t,K),ne=Object.fromEntries(Object.entries(Xt(t,n,we,P,Ht(T,r))).map(([w,J])=>[w,Yt(J.ts)])),ae=Object.values(ne).filter(Boolean).sort()[0]||null,Te=[...m.map(w=>w.ts),...x.map(w=>w.ts)].sort().pop()||null,Ee=[...m.filter(w=>vt({...w,who:w.who||"claude"})).map(w=>w.ts),...x.map(w=>w.reply?.at)].filter(Boolean).sort(),Y=!et(n)&&n.pushed?.branch?{branch:n.pushed.branch,at:n.pushed.at||null,host:u?.host||null}:null,z=!et(n)&&n.merge_ready?.branch?{branch:n.merge_ready.branch,at:n.merge_ready.at||null,base:d}:null,Ae=!!n.rebase_run&&N?.state==="OPEN",le=(n.rebased||[]).at(-1),Be=g.filter(w=>w.started&&!w.done&&te(w)),Le=!!$e&&wt(yt(g));let R=wn(n,N,Be.some(wt),Le,Y||z,!!G,re,Ae,Be.length>0||!!$e);G&&R==="todo"&&(R="progress");const Je=R==="review"&&!!ae&&E-Date.parse(ae)>kt,Re=!!me&&Ye&&R==="done";Re&&(R="review");let D=vn(R,N,p,!!$e&&R!=="done",Y,re,{held:z,needsApproval:Q.length>0});const Ze=D==="builder"&&N?.state==="OPEN"&&!N.isDraft,ie=R==="progress"&&!D&&N?.state==="OPEN"&&(!N.isDraft||re),de=Re||!!G&&R==="progress"&&!D&&!ie&&!ze;de&&(D="owner");const he=i&&String(i.ts)>String(n.held_at||""),_e=R==="todo"&&(he?!!i.data.hold:!!n.held),Pe=_e&&(he?i.data.until:n.pick_up_at)||null,je=R==="todo"||R==="progress",Ue=g.filter(te).map(w=>String(w.started||"")).filter(Boolean).sort()[0]||"",o=C&&!(Ue&&String(C)<Ue),k=m.filter(w=>(w.who||"claude")==="claude"&&!["status","command",Se].includes(w.kind)&&!An.test(w.text||"")).map(w=>String(w.ts)).sort().pop()||"",b=[B,z&&n.merge_ready.tapped].filter(Boolean).map(String).sort().pop(),v=D==="merge"&&!!b&&b>k,O=m.filter(w=>w.kind==="status"&&String(w.ts)>String(b)).sort((w,J)=>String(w.ts).localeCompare(String(J.ts))).at(-1),M=O?.text.startsWith("Waiting for ")?`${Ge.merging} \xB7 ${O.text[0].toLowerCase()}${O.text.slice(1)}`:Ge.merging,I=m.filter(w=>!["status",Se].includes(w.kind)).sort((w,J)=>String(w.ts).localeCompare(String(J.ts))).at(-1),ce=R==="todo"&&I?.kind===gt?I.text:null,ue=G||g.filter(te).map(w=>w.started).filter(Boolean).map(String).sort().pop()||null,We=N?.reviewDecision==="APPROVED",Fe=Y&&D==="owner"?`merge ${Y.branch} into ${d}`:z&&D==="merge"?v?M:On(d):D==="merge"&&!ke?v?M:(We?Ge:ot).waiting:D==="merge"&&!We?ot.auto:xn[D],ye=H===Z.draft?`Review draft PR #${V[W].number}`:null,Me=!Ae&&le?.to&&le.to===N?.headRefOid?`Rebased onto ${le.base||d}, pushed${N.mergeable==="MERGEABLE"?" \xB7 PR is clean again":""}`:null,$=Ae&&D==="checking"?g.flatMap(w=>w.calls).sort((w,J)=>String(w.at).localeCompare(String(J.at))).at(-1)?.text??null:null;return{key:we,kind:"work",order:s,wave:e,waveTitle:t.title||e,id:n.id,ref:Ke(t,n,U),title:n.title,storedLane:X,created:n.created||null,reviewSince:n.review_since||ae||n.merge_ready?.at||n.pushed?.at||n.created||null,progressSince:ue,closedAt:R==="done"?F:null,internal:t.internal===!0,repo:t.internal===!0&&!t.repo?null:a,lane:R,waitsOn:D,builder:D==="checking"?null:p,reachedPhase:f,agents:g,worktree:c??null,eta:h,working:S,reopened:!!G,awaitsDone:de,ownerStep:de?me:null,ownerCheck:de&&me&&n.owner_check?{words:an(ln(n.owner_check.check)),broken:n.owner_check.broken||null}:null,stagedAt:R==="todo"&&n.state==="staging"&&n.staged_at||null,roundAt:n.round_at||null,deps:n.deps||[],blockedUntil:n.blocked_until||null,blockReason:n.block_reason||null,held:_e,heldUntil:Pe,risky:!!n.risky,bumpable:je,bumpedAt:je&&o?C:null,holdable:R!=="done",hasNotes:!!(n.plan||String(n.notes||"").trim()),finishable:R!=="done",merging:v,refusal:ce,manualSteps:n.manual_steps||[],fromAsk:n.from_ask||null,unfiled:!!n.unfiled,next:Ze||R==="done"||D==="checking"?null:ie?$n:Me||Fe||n.next||ye||null,rebaseFailed:$,branch:n.branch||N?.headRefName||Y?.branch||null,pushed:R==="done"||Re?null:Y,mergeReady:R==="review"?z:null,stale:R!=="done"&&(Je||!!p?.stale),stalled:n.stalled?.reason||null,landStopped:R==="review"&&z&&n.merge_ready.stopped&&String(n.merge_ready.stopped)>String(n.merge_ready.tapped||"")?{words:Et("land"),at:n.merge_ready.stopped}:null,ticket:U?.source==="linear"&&!n.ticket&&n.linear?.length?null:mn(U,n.ticket,n.ticket||(t.internal?Ke(t,n,U):n.linear?.[0]),{repo:a,key:we}),ticketSource:U?.source||null,linear:(n.linear||[]).map(w=>U?.source==="linear"&&ct(U,w,{key:we,repo:a})||mt(w,U)),pr:V[W]||null,prs:V,reviewers:Q.map(w=>w.name),review:Sn(Q,N||r[W]?.kept,ne),inReviewSince:ae,threadCount:m.length+x.length,lastTs:Te,othersAt:Ee,grilling:At("grill",x,g,_),prototyping:At("prototype",x,g,_),state:n.state||null,updatedAt:N?.mergedAt||N?.updatedAt||r[W]?.merged_at||p?.at||Te||null,ask:null,fold:null,action:null,install:R==="done"?null:_n(n.install,N),waitFacts:Rn(n,{agents:g,thread:m,events:x,refusedAt:ce?I.ts:null})}}l(Bn,"workItem");function Rn(e,{agents:t,thread:n,events:s,refusedAt:r}){const a=new Set(n.filter(f=>f.kind===Ie.answer).map(f=>f.ask)),u=n.filter(f=>f.kind===Ie.ask&&!a.has(f.ask)).sort((f,g)=>String(f.ts).localeCompare(String(g.ts)))[0],d=l(f=>s.filter(g=>rt(g,f)).pop()?.ts||null,"requestAt"),p=n.filter(f=>(f.who||"claude")==="claude"&&!["status","agent","command",Se,gt].includes(f.kind)).map(f=>f.ts);return{handedBackAt:nt(t),next:e.next||null,ask:u?{at:u.ts,text:u.text}:null,grillAt:d("grill"),prototypeAt:d("prototype"),refusedAt:r,unverified:t.some(f=>f.calls.some(g=>!f.verified||String(g.at)>String(f.verified.at))),writes:[...p,...t.flatMap(f=>[f.verified?.at,f.started])].filter(Boolean).map(String).sort()}}l(Rn,"waitFactsOf");function _n(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))}}l(_n,"installOf");function Mn(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",!bt(e,t)&&`review: ${String(e.reviewDecision||"none").toLowerCase().replace(/_/g," ")}`,n==="fail"&&`failing: ${r?.length?r.join(", "):"a check"}`,n==="pending"&&`pending: ${s?se(s,"check"):"checks"}`,e.mergeStateStatus!=="CLEAN"&&`merge state: ${String(e.mergeStateStatus||"unknown").toLowerCase()}`].filter(Boolean)}l(Mn,"mergeBlockers");const In=l((e,t)=>!Mn(e,{needsApproval:t}).length,"mergeable");function qn(e,t,n){if(pe(e))return null;const s=`#item=${encodeURIComponent(e.key)}`;if(e.stalled)return{kind:q.stalled,url:s,label:`stalled: ${e.stalled}`};if(Dn(e)){const r=t.get(e.questions.first);return qe.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 ${se(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||St}: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)||In(r,e.reviewers.length>0))?{kind:q.merge,url:s,label:"Merge"}:null}l(qn,"actionOf");const Dn=l(e=>!!(e.questions&&e.questions.state!=="resolved"&&e.questions.open>0),"asking"),st=new Set([q.pick,q.questions]);function xt(e){return e.questions?oe.openQuestions:null}l(xt,"actionButtonOf");const Nn=l(e=>e.kind==="work"&&e.lane==="todo"&&!e.action&&!e.unpicked,"buildableOf"),Cn=l((e,t)=>/^item:/.test(e.topic||"")&&qe.test(e.url||"")&&!(e.options||[]).some(n=>n.id===t),"picksNoTake");function Tn(e,t){const n=e.filter(a=>a.topic===`item:${t}`),r=[...n.filter(a=>qe.test(a.url||"")).flatMap(a=>a.answers.map(u=>({q:a,a:u,again:Cn(a,u.choice)}))),...n.filter(a=>a.request).map(a=>({q:a,a:a.request,again:!0}))].sort((a,u)=>String(a.a.ts).localeCompare(String(u.a.ts))).at(-1);return r?.again?{id:r.q.id,note:r.a.note.replace(/\s+/g," ").trim()}:null}l(Tn,"noTakePicked");const Ln="Prototype again",Pn=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}),jn="Merges once unblocked",Un=l(e=>`Blocked ${[e.blockedBy.length&&`by ${e.blockedBy.map(t=>t.ref).join(", ")}`,e.blockedUntil&&`until ${e.blockedUntil}`].filter(Boolean).join(" and ")}`,"mergeBlockedWords");function Wn(e,t,n){if(e.action=qn(e,t,n),e.mergeBlocked=e.action?.kind===q.merge&&e.blocked?Un(e):null,e.mergeBlocked&&Object.assign(e,{action:null,next:jn}),e.action?.kind===q.questions&&e.questions.fromAsks){Object.assign(e,{action:null,waitsOn:"owner",next:e.action.label,actionButton:xt(e),resolvedBy:null});return}e.awaitsDone&&=!e.action,e.awaitsDone||Object.assign(e,{ownerStep:null,ownerCheck:null}),e.actionButton=xt(e),e.resolvedBy=Pn[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||St,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"&&st.has(e.action.kind)?"todo":"review";Object.assign(e,{lane:r,waitsOn:e.waitsOn==="ready"?"ready":"owner",next:e.action.label}),r==="review"&&Object.assign(e,{bumpable:!1,bumpedAt:null})}l(Wn,"placeOwnerWait");const Ot=l((e,t)=>e?e!=="todo":t.some(te),"started"),$t="none set yet";function ns(e,t){const n=t.filter(s=>s?.started);return e.next||et(e)||e.pushed||e.held||e.lane==="done"||nt(n)?!1:!n.some(s=>!s.done)&&Ot(e.lane,n)}l(ns,"owesNext");function Fn(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}`}l(Fn,"askedLabel");function Kn(e,t,n,s,r,a,u){const d=t.find(y=>y.kind==="ask"&&y.eventId===e.id),p=d.files,f=(d.text||"").trim().split(`
|
|
2
|
-
`)[0]||
|
|
3
|
-
\u2192 `)},"actionText"),
|
|
4
|
-
\u2192 ${
|
|
1
|
+
var Kt=Object.defineProperty;var l=(e,t)=>Kt(e,"name",{value:t,configurable:!0});import{routeRecord as B}from"../hub/routes.mjs";import Gt from"node:fs";import{ticketBadge as pt,ticketIn as Qt}from"./tickets.mjs";import{prLinks as Ht,reviewLinks as Vt,reviewTime as Xt,reviewersOf as Yt}from"./review.mjs";import{remoteFromInput as zt}from"../hub/repos.mjs";import{reviewsOf as Jt,reviewNeeds as Zt,reviewActions as en}from"./auto-review.mjs";import{cardPRs as tn,hasPR as et,leastReady as nn,prKeyOf as sn,prURL as on}from"../shared/card-prs.mjs";import ft from"node:vm";import{checkWords as rn,parseCheck as an}from"../shared/owner-check.mjs";import{buildScriptOf as ln}from"./build-script.mjs";const tt=ft.createContext({});for(const e of["ui-enums.js","ui-order.js"])ft.runInContext(Gt.readFileSync(new URL(`./public/${e}`,import.meta.url),"utf8"),tt);const{BUTTON:le,ACTION_KIND:N,BUILDER_KIND:pe,PR_STATE:H,PHASES:gt}=tt.BoardUI,{laneOrder:dn}=tt.BoardUI,cn=["item-message","mark-ready","grill-more","prototype-request","visual-request","reask-request"],kt="question-reopen",lo=Object.freeze({todo:"Todo",progress:"In Progress",review:"In Review",done:"Done"}),Oe="move",un=10*6e4,pn=5*6e4,mt="build-refused",Ne=Object.freeze({ask:"builder-ask",answer:"builder-answer"}),fn=864e5,fe=l(e=>e.lane==="done"||e.lane==="asks","closedLane"),gn=l(e=>`wave:${e}`,"waveFold"),wt=7*fn,ht=l((e,t)=>({id:e,url:t?.workspace?`https://linear.app/${t.workspace}/issue/${e}`:null}),"linearRef"),kn=l((e,t)=>String(e).replace(/^S(\d+)$/,`${t||"INT"}-$1`),"internalRef"),Ge=l((e,t,n)=>Qt(n,t.ticket)?t.ticket:e.internal===!0?kn(t.id,n?.prefix):t.id,"refOf"),mn=l((e,t,n,s)=>pt(e||(t?{source:"internal",prefix:"INT"}:null),n,s)||(t?{id:String(t),url:null,source:null}:null),"ticketOf");function wn(e,t,n,s,r,a,d,c,p){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||p?"progress":"todo"}l(wn,"laneOf");const Qe="Lander",yt=l(e=>e.kind!==pe.install&&e.label!==Qe,"changesCode");function hn(e,t){return e?.state==="MERGED"||t?H.merged:e?.state==="CLOSED"?H.closed:e?.state==="OPEN"?e.isDraft?H.draft:H.open:null}l(hn,"prStateOf");const bt=l(e=>e.pr?.status===H.closed,"unlanded"),yn=l(e=>e.some(t=>t.kind==="work")&&e.every(t=>t.lane==="done"),"finishedOf");function nt(e){const t=St(e);return t?.done&&t.handed_back?t.handed_back:null}l(nt,"handedBackAt");const St=l(e=>e.filter(t=>t?.started&&te(t)&&t.kind!==pe.install).sort((t,n)=>String(t.started).localeCompare(String(n.started))).at(-1),"newestBuild");function bn(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}]}))}l(bn,"reviewOf");function Sn(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"?vt(t,c)?"merge":"reviewers":null}l(Sn,"waitsOnOf");const vt=l((e,t)=>e?.reviewDecision==="APPROVED"||!t&&!["REVIEW_REQUIRED","CHANGES_REQUESTED"].includes(e?.reviewDecision),"reviewed"),De=/(^|\/)prototype-[\w-]+\.html/,vn={reviewers:"Waiting for PR reviewers",merge:"Approved, merges once CI and the merge state allow",ci:"Marked ready for review once CI passes"},He={waiting:"Approved, Merge shows once CI and the merge state allow",ready:"Approved and green: tap Merge",merging:"Merging"},st={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"},On=l(e=>`Verified: tap Merge to land it on ${e}`,"heldNext"),xn="Fix the failing CI",Ot="Tap Done once it is settled",$n=["status","agent","ask-link","command",Oe,Ne.answer],xt=l(e=>(e.who==="claude"||e.via==="github")&&!$n.includes(e.kind),"countsUnread"),An=/^(?:Not merged yet: |Lander launched headless )/;function En({slug:e,wave:t,it:n,order:s,prs:r,repo:a,remote:d,base:c,builder:p,reachedPhase:f,agents:g,worktree:u,eta:h,thread:S,events:_,working:v,said:T,askedAt:D,topicItems:R,prSlack:C,boardReviewers:U,now:m,bumpedAt:A,holdAsk:i,closedAt:E,mergeAt:y,autoMerge:ne,skipDraft:de,tickets:F}){const V=r.map(w=>({repo:w.repo,number:w.number,url:on(w),...w.gh||w.kept||{},status:hn(w.gh,w.merged_at)})),K=nn(r.map(w=>w.gh)),L=r[K]?.gh||null,X=V[K]?.status??null,Y=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(w=>[w.merged_at,w.gh?.mergedAt])].filter(Boolean).map(String).sort().pop()||null,j=String(W||""),Le=V.length>0&&V.every(w=>w.status===H.closed),G=(n.lane==="done"||n.reopened_at||X===H.merged)&&!Le&&([...T.filter(w=>w.kind==="item-message").map(w=>w.ts),...D].map(String).filter(w=>w>j).sort().pop()||n.reopened_at)||void 0,me=n.owner_step&&!Te?String(n.owner_step):null,Ye=(n.lane==="done"||X===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=nt(g),ze=!!G&&T.some(w=>String(w.ts)>j&&(w.state==="waiting"||w.state==="working")),Q=`${e}/${n.id}`,z=Yt(t,U),_e=Object.fromEntries(Object.entries(Vt(t,n,Q,R,Ht(C,r))).map(([w,Z])=>[w,Xt(Z.ts)])),we=Object.values(_e).filter(Boolean).sort()[0]||null,he=[...S.map(w=>w.ts),..._.map(w=>w.ts)].sort().pop()||null,je=[...S.filter(w=>xt({...w,who:w.who||"claude"})).map(w=>w.ts),..._.map(w=>w.reply?.at)].filter(Boolean).sort(),J=!et(n)&&n.pushed?.branch?{branch:n.pushed.branch,at:n.pushed.at||null,host:d?.host||null}:null,se=!et(n)&&n.merge_ready?.branch?{branch:n.merge_ready.branch,at:n.merge_ready.at||null,base:c}:null,oe=!!n.rebase_run&&L?.state==="OPEN",ye=(n.rebased||[]).at(-1),Re=g.filter(w=>w.started&&!w.done&&te(w)),Ue=!!Be&&yt(St(g));let M=wn(n,L,Re.some(yt),Ue,J||se,!!G,de,oe,Re.length>0||!!Be);G&&M==="todo"&&(M="progress");const Je=M==="review"&&!!we&&m-Date.parse(we)>wt,re=!!me&&Ye&&M==="done";re&&(M="review");let P=Sn(M,L,p,!!Be&&M!=="done",J,de,{held:se,needsApproval:z.length>0});const be=P==="builder"&&L?.state==="OPEN"&&!L.isDraft,Me=M==="progress"&&!P&&L?.state==="OPEN"&&(!L.isDraft||de),ae=re||!!G&&M==="progress"&&!P&&!Me&&!ze&&!Pe;ae&&(P="owner");const qe=i&&String(i.ts)>String(n.held_at||""),Ie=M==="todo"&&(qe?!!i.data.hold:!!n.held),Ze=Ie&&(qe?i.data.until:n.pick_up_at)||null,We=M!=="done",o=!!A&&!(j&&String(A)<=j),k=S.filter(w=>(w.who||"claude")==="claude"&&!["status","command",Oe].includes(w.kind)&&!An.test(w.text||"")).map(w=>String(w.ts)).sort().pop()||"",b=[y,se&&n.merge_ready.tapped].filter(Boolean).map(String).sort().pop(),O=P==="merge"&&!!b&&b>k,x=S.filter(w=>w.kind==="status"&&String(w.ts)>String(b)).sort((w,Z)=>String(w.ts).localeCompare(String(Z.ts))).at(-1),q=x?.text.startsWith("Waiting for ")?`${He.merging} \xB7 ${x.text[0].toLowerCase()}${x.text.slice(1)}`:He.merging,I=S.filter(w=>!["status",Oe].includes(w.kind)).sort((w,Z)=>String(w.ts).localeCompare(String(Z.ts))).at(-1),ce=M==="todo"&&I?.kind===mt?I.text:null,ue=G||g.filter(te).map(w=>w.started).filter(Boolean).map(String).sort().pop()||null,Fe=L?.reviewDecision==="APPROVED",Ke=J&&P==="owner"?`merge ${J.branch} into ${c}`:se&&P==="merge"?O?q:On(c):P==="merge"&&!ne?O?q:(Fe?He:st).waiting:P==="merge"&&!Fe?st.auto:vn[P],Se=X===H.draft?`Review draft PR #${V[K].number}`:null,ve=!oe&&ye?.to&&ye.to===L?.headRefOid?`Rebased onto ${ye.base||c}, pushed${L.mergeable==="MERGEABLE"?" \xB7 PR is clean again":""}`:null,$=oe&&P==="checking"?g.flatMap(w=>w.calls).sort((w,Z)=>String(w.at).localeCompare(String(Z.at))).at(-1)?.text??null:null;return{key:Q,kind:"work",order:s,wave:e,waveTitle:t.title||e,id:n.id,ref:Ge(t,n,F),title:n.title,storedLane:Y,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:P,builder:P==="checking"?null:p,reachedPhase:f,agents:g,worktree:u??null,eta:h,working:v,reopened:!!G,awaitsDone:ae,ownerStep:ae?me:null,ownerCheck:ae&&me&&n.owner_check?{words:rn(an(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:Ie,heldUntil:Ze,risky:!!n.risky,bumpable:We,bumpedAt:We&&o?A:null,bumpedOut:n.bumped_out?{key:n.bumped_out.by,at:n.bumped_out.at}: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"||P==="checking"?null:Me?xn:ve||Ke||n.next||Se||null,rebaseFailed:$,branch:n.branch||L?.headRefName||J?.branch||null,pushed:M==="done"||re?null:J,mergeReady:M==="review"?se:null,stale:M!=="done"&&(Je||!!p?.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:Bt("land"),at:n.merge_ready.stopped}:null,ticket:F?.source==="linear"&&!n.ticket&&n.linear?.length?null:mn(F,n.ticket,n.ticket||(t.internal?Ge(t,n,F):n.linear?.[0]),{repo:a,key:Q}),ticketSource:F?.source||null,linear:(n.linear||[]).map(w=>F?.source==="linear"&&pt(F,w,{key:Q,repo:a})||ht(w,F)),pr:V[K]||null,prs:V,reviewers:z.map(w=>w.name),review:bn(z,L||r[K]?.kept,_e),inReviewSince:we,threadCount:S.length+_.length,lastTs:he,othersAt:je,grilling:_t("grill",_,g,D),prototyping:_t("prototype",_,g,D),storedPhase:n.phase||null,phase:null,updatedAt:L?.mergedAt||L?.updatedAt||r[K]?.merged_at||p?.at||he||null,ask:null,fold:null,action:null,install:M==="done"?null:_n(n.install,L),waitFacts:Bn(n,{agents:g,thread:S,events:_,refusedAt:ce?I.ts:null})}}l(En,"workItem");function Bn(e,{agents:t,thread:n,events:s,refusedAt:r}){const a=new Set(n.filter(f=>f.kind===Ne.answer).map(f=>f.ask)),d=n.filter(f=>f.kind===Ne.ask&&!a.has(f.ask)).sort((f,g)=>String(f.ts).localeCompare(String(g.ts)))[0],c=l(f=>s.filter(g=>rt(g,f)).pop()?.ts||null,"requestAt"),p=n.filter(f=>(f.who||"claude")==="claude"&&!["status","agent","command",Oe,mt].includes(f.kind)).map(f=>f.ts);return{handedBackAt:nt(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:[...p,...t.flatMap(f=>[f.verified?.at,f.started])].filter(Boolean).map(String).sort()}}l(Bn,"waitFactsOf");function _n(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))}}l(_n,"installOf");function Rn(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",!vt(e,t)&&`review: ${String(e.reviewDecision||"none").toLowerCase().replace(/_/g," ")}`,n==="fail"&&`failing: ${r?.length?r.join(", "):"a check"}`,n==="pending"&&`pending: ${s?ie(s,"check"):"checks"}`,e.mergeStateStatus!=="CLEAN"&&`merge state: ${String(e.mergeStateStatus||"unknown").toLowerCase()}`].filter(Boolean)}l(Rn,"mergeBlockers");const Mn=l((e,t)=>!Rn(e,{needsApproval:t}).length,"mergeable");function qn(e,t,n){if(fe(e))return null;const s=`#selectedCard=${encodeURIComponent(e.key)}`;if(e.stalled)return{kind:N.stalled,url:s,label:`stalled: ${e.stalled}`};if(In(e)){const r=t.get(e.questions.first);return De.test(r?.url||"")?{kind:N.pick,url:`questions.html#${r.id}`,label:"Prototypes ready: pick a take"}:{kind:N.questions,url:`questions.html#${e.questions.first}`,label:`Answer ${ie(e.questions.open,"question")}`}}return e.waitsOn==="ready"?{kind:N.ready,url:e.pr.url,label:`Review draft PR #${e.pr.number}`}:e.kind==="ask"&&e.waitsOn==="owner"?{kind:N.done,url:s,label:e.next||Ot}:e.waitsOn==="merge"&&e.manualSteps.length&&!e.mergeReady?{kind:N.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)||Mn(r,e.reviewers.length>0))?{kind:N.merge,url:s,label:"Merge"}:null}l(qn,"actionOf");const In=l(e=>!!(e.questions&&e.questions.state!=="resolved"&&e.questions.open>0),"asking"),ot=new Set([N.pick,N.questions]);function $t(e){return e.questions?le.openQuestions:null}l($t,"actionButtonOf");const Nn=l(e=>e.kind==="work"&&e.lane==="todo"&&!e.action&&!e.unpicked,"buildableOf"),Dn=l((e,t)=>/^item:/.test(e.topic||"")&&De.test(e.url||"")&&!(e.options||[]).some(n=>n.id===t),"picksNoTake");function Cn(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:Dn(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}l(Cn,"noTakePicked");const Tn="Prototype again",Ln=Object.freeze({[N.pick]:le.openQuestions,[N.questions]:le.openQuestions,[N.ready]:le.github,[N.steps]:le.github,[N.merge]:le.merge,[N.done]:le.done,[N.stalled]:le.reply}),Pn="Merges once unblocked",jn=l(e=>`Blocked ${[e.blockedBy.length&&`by ${e.blockedBy.map(t=>t.ref).join(", ")}`,e.blockedUntil&&`until ${e.blockedUntil}`].filter(Boolean).join(" and ")}`,"mergeBlockedWords");function Un(e,t,n){if(e.action=qn(e,t,n),e.mergeBlocked=e.action?.kind===N.merge&&e.blocked?jn(e):null,e.mergeBlocked&&Object.assign(e,{action:null,next:Pn}),e.action?.kind===N.questions&&e.questions.fromAsks){Object.assign(e,{action:null,waitsOn:"owner",next:e.action.label,actionButton:$t(e),resolvedBy:null});return}e.awaitsDone&&=!e.action,e.awaitsDone||Object.assign(e,{ownerStep:null,ownerCheck:null}),e.actionButton=$t(e),e.resolvedBy=Ln[e.action?.kind]||null,e.action?.kind===N.merge&&!e.mergeReady&&(e.next=(e.pr?.reviewDecision==="APPROVED"?He:st).ready),e.awaitsDone&&Object.assign(e,{lane:"review",next:e.ownerStep||Ot,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"&&ot.has(e.action.kind)?"todo":"review";Object.assign(e,{lane:r,waitsOn:e.waitsOn==="ready"?"ready":"owner",next:e.action.label})}l(Un,"placeOwnerWait");const At=l((e,t)=>e?e!=="todo":t.some(te),"started"),Et="none set yet";function io(e,t){const n=t.filter(s=>s?.started);return e.next||et(e)||e.pushed||e.held||e.lane==="done"||nt(n)?!1:!n.some(s=>!s.done)&&At(e.lane,n)}l(io,"owesNext");function Wn(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}`}l(Wn,"askedLabel");function Fn(e,t,n,s,r,a,d,c){const p=t.find(y=>y.kind==="ask"&&y.eventId===e.id),f=p.files,g=c||(p.text||"").trim().split(`
|
|
2
|
+
`)[0]||f.map(y=>y.name).join(", ")||"Ask",u=p.state==="replied"||p.state==="answered",h=r?.state==="progress"&&!(String(a||"")>String(r.at||"")),S=!h&&(!!r||!!a),_=u&&!S&&!h&&d.open>0,v=u&&!S&&!h&&!_&&d.answered>0,T=S||u&&!h&&!_&&!v,D=u&&!s&&!r?.moved&&[...t.filter(y=>y.who==="claude"&&y.kind!=="ask-link"&&y.kind!=="status"&&y.kind!=="command").map(y=>y.ts),...t.map(y=>y.reply?.at)].filter(Boolean).sort().pop()||null,R=T||h||_||v,C=t.some(y=>y.who==="love"&&y.kind!=="ask"&&(y.state==="waiting"||y.state==="working")),U=t.filter(y=>y.who==="love"&&y.kind==="item-message").flatMap(Ce).filter(([,y])=>y==="waiting"||y==="working").map(([y])=>y),m=R?"answered":p.state,A=R?null:n||null,i=[...t.filter(xt).map(y=>y.ts),...t.map(y=>y.reply?.at)].filter(Boolean).sort(),E=[...t.map(y=>y.ts),...i,...h?[r.at]:[]].filter(Boolean).sort().pop();return{key:`ask:${e.id}`,kind:"ask",order:0,wave:null,waveTitle:null,id:e.id,ref:R?Wn(e.ts):"New",isNew:!R,title:g,storedLane:null,internal:!1,repo:null,lane:h?"progress":T?"asks":"todo",waitsOn:h&&!C?"owner":null,builder:null,agents:[],eta:null,working:t.some(y=>Ce(y).some(([,ne])=>ne==="working")),deps:[],held:!1,risky:!1,bumpable:!R,bumpedAt:A,manualSteps:[],fromAsk:null,from:null,next:h&&r.next||null,hasNotes:!1,branch:null,finishable:R&&!T,linear:[],pr:null,prs:[],reviewers:[],review:{},inReviewSince:null,reviewSince:null,progressSince:h&&r.at||null,closedAt:null,threadCount:t.length,lastTs:E,othersAt:R?i:[],grilling:!1,prototyping:!1,created:e.ts,updatedAt:R?E:e.ts,ask:{eventId:e.id,state:m,askedAt:e.ts,bumpedAt:A,edited:!!p.edited,canEdit:!R,text:p.text,files:f,answerAt:D,from:p.from||null,owed:U},fold:null,action:null}}l(Fn,"askItem");const ge="visual",xe="helper",Kn=new Set(["grill","prototype",ge]),ee=l(e=>Kn.has(e.kind),"plans"),te=l(e=>!ee(e),"builds"),Gn={grill:"grilling",prototype:"prototyping"},Qn=l((e,t)=>`${e} ${t} by orchestrator`,"orchestratorDid"),Bt=l(e=>Qn(e,"stopped"),"stoppedWords"),Hn={grill:"grill-more",prototype:"prototype-request"},rt=l((e,t)=>e.kind===Hn[t]&&!e.data?.question,"isRequest");function _t(e,t,n,s){if(n.some(a=>a.kind===e&&a.started&&!a.done))return!0;const r=t.filter(a=>rt(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)))}l(_t,"planningOf");const co=30*6e4;function uo(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&&rt(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}l(uo,"prototypeWaits");function at(e={},t=!1){return Object.entries(e).filter(([n,s])=>s&&typeof s=="object"&&(t||!n.startsWith("past-"))).map(([n,s])=>({name:n,kind:Rt(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.kind===xe?{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))}l(at,"agentsOf");function lt(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}l(lt,"worktreeOf");function Vn(e,t=[]){const n=e.filter(te).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}l(Vn,"reachedPhaseOf");function Xn(e,t=[],n,s=null,r=null,a=!1){const d=e.filter(m=>m.started&&!m.done&&m.kind!==ge),c=d.every(ee),p=c?d:d.filter(te),f=p.map(m=>String(m.started||"")).sort()[0];if(f===void 0)return null;const g=t.filter(m=>m.kind==="status"&&String(m.ts)>=f&&(c||!m.planner)).sort((m,A)=>String(m.ts).localeCompare(String(A.ts))).pop(),u=p.filter(m=>m.kind!==xe).at(-1),h=p.some(m=>m.kind===pe.install)?pe.install:u?Rt(u.kind):"claude",S=c?null:p.find(m=>m.stopped&&String(m.stopped.at)>=String(m.started))?.stopped,_=g?.ts||f,v=S?S.at:s!==null&&s>Date.parse(_)?new Date(s).toISOString():_,T=g?g.phase||g.planner?g.text.replace(": "," \xB7 "):g.text||null:c?Gn[h]:null,D=n-Date.parse(v),R=!c&&!S&&r==="held",C=c||R?null:S?!1:r,U=R?!1:C===null?D>=un:!C;return{progress:T,phase:g?.phase||null,at:_,kind:h,planner:c,silentSince:v,stale:U,alive:C,held:R,quiet:C===!0&&!a&&D>=pn,stopped:S?Bt(S.run):null}}l(Xn,"builderOf");const it={opus:"Claude Opus",sonnet:"Claude Sonnet",codex:"Codex"},Yn=l(({model:e,kind:t})=>it[e]||it[t]||(t==="claude"?it.opus:null),"modelName"),Rt=l(e=>e==="opus"||e==="sonnet"?"claude":e,"providerOf");function $e(e){const t=Yn(e),{kind:n}=e,s=e.label?.replace(/\bbuilder\b/,"implementer").replace(/\bBuilder\b/,"Implementer"),r=l(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"}l($e,"agentName");const Mt=l((e,t)=>!!e.resolved&&(!e.resolved_at||String(e.resolved_at)>=String(t)),"resolvedSince");function zn(e,t,n=[],s=[],r=[]){const a=t.filter(v=>v.data?.id===e.id),d=a[a.length-1]||null,c=r.filter(v=>v.data?.question===e.id).at(-1),p=l((v,...T)=>!!v&&T.every(D=>String(v.ts)>String(D||"")),"after"),f=!!(e.resolved&&e.resolved_at&&d&&String(d.ts)>e.resolved_at),g=n.filter(v=>v.data?.question===e.id&&p(v,d?.ts,c?.ts)).at(-1),u=p(c,d?.ts,g?.ts,e.resolved_at),h=e.resolved&&!f&&!u,S=h?s.filter(v=>v.data?.question===e.id&&String(v.ts)>String(e.resolved_at||"")).at(-1):null,_=u?"open":h?"resolved":g?"requested":d?d.reply?"replied":"answered":"open";return{...e,state:_,reopened:u,request:g?{id:g.id,ts:g.ts,note:g.data.note||"",choice:g.data.choice||null}:null,reask:S?{id:S.id,ts:S.ts}:null,answers:a.map(v=>({ts:v.ts,choice:v.data.choice||null,note:v.data.note||"",files:v.data.files||[],reply:v.reply,acted:Mt(e,v.ts)}))}}l(zn,"ownerQuestion");const ke=l(e=>e.round??(De.test(e.url||"")?1:0),"roundOf");function Jn(e,t){const n=l((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)}l(Jn,"roundSettledBy");function Zn(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=Jn(e,n);return s?{n,state:"closed",take:s.choice}:e.some(r=>ke(r)===n&&r.state!=="resolved")?{n,state:"back"}:null}l(Zn,"roundState");function es(e){const t=e.filter(n=>De.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}l(es,"prototypesOf");const Ae=l((e,t,n)=>{const s=e.get(t);s?s.push(n):e.set(t,[n])},"add"),Ee=l((e,t)=>{const n=new Map;for(const s of e)Ae(n,t(s),s);return n},"groupBy");function ts(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)||[],p=l(u=>c.filter(h=>h.state===u).length,"count"),f=c.every(u=>u.state==="resolved")||n.has(d.id)&&!p("open"),g=c.length&&f?"resolved":"open";return{...d,state:g,questions:c.map(u=>u.id),open:p("open"),answered:p("answered"),replied:p("replied"),resolved:p("resolved"),round:Zn(c)}}).filter(d=>d.questions.length)}l(ts,"ownerTopics");const Ve={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"},qt={"grill-more":"grill","prototype-request":"prototype","visual-request":"visual","reask-request":"reask"},It={"mark-ready":"Mark ready",...Object.fromEntries(Object.entries(qt).map(([e,t])=>[e,Ve[t]]))},ns=["grill-more","prototype-request","visual-request"],ss="answers submitted",Nt={reply:"Reply",build:"Implement"},os=l(e=>Nt[e.data.intent],"intentLabel"),rs=l((e,t)=>{if(e.kind!=="prototype-request"||!t.has(e.data.question))return e.data.text||(e.data.files?.length?"":B(It,e.kind))||"";const n=t.get(e.data.question),s=(n.options||[]).find(r=>r.id===e.data.choice);return[Ct(t,n),s&&`${s.id}. ${s.label}`,e.data.note].filter(Boolean).join(`
|
|
3
|
+
\u2192 `)},"actionText"),Dt=l((e,t)=>[...e.keys()].indexOf(t)+1,"numberOf"),Ct=l((e,t)=>`Question ${Dt(e,t.id)} \xB7 ${t.question}`,"numbered"),as="question reopened",Xe=l(e=>e.data?.shared_by?.login?{by:e.data.shared_by.name||e.data.shared_by.login}:{},"byOf"),ls=l((e,t)=>{const n=t.get(e.card);return{...e,text:`${Ve[e.command]} ${n?`${n.ref}: ${n.title}`:e.card}`,link:`#selectedCard=${encodeURIComponent(e.card)}`}},"linkLine"),Tt=l(e=>({kind:"command",command:e,request:!0,mark:Ve[e]}),"commandLine"),is=l((e,t)=>{if(e.kind==="item-message")return Nt[e.data.intent]?{status:os(e)}:{};const n={request:!0,command:qt[e.kind]};return ns.includes(e.kind)?(e.data.question?t.has(e.data.question):String(e.data.text||"").trim()||e.data.files?.length)?{status:It[e.kind]}:n:e.kind==="reask-request"?n:{}},"requestOf"),dt=l(e=>[...e.filter(t=>t.who==="claude"&&!["status","agent","command",Oe,Ne.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 Lt(e,t={}){const n=new Map,s=new Map;for(const u of t.items||[])Ae(n,u.topic,u),s.set(u.id,u.topic);const r=new Map,a=new Map,d=new Map,c=new Map,p=new Map,f=new Map,g=new Map;e.forEach((u,h)=>{g.set(u,h),u.data?.key&&cn.includes(u.kind)&&Ae(r,u.data.key,u),u.kind==="owner-answer"&&s.has(u.data?.id)&&Ae(a,s.get(u.data.id),u),u.kind===kt&&s.has(u.data?.question)&&Ae(d,s.get(u.data.question),u),u.kind==="ask"&&c.set(u.id,u)});for(const u of e.filter(h=>h.kind==="ask-edited").sort((h,S)=>String(h.ts).localeCompare(String(S.ts)))){p.set(u.data?.id,u.data?.text);for(const h of u.data?.files||[])Ae(f,u.data?.id,h)}return{byKey:r,answers:a,reopens:d,asks:c,edits:p,editFiles:f,questions:n,order:g}}l(Lt,"threadIndex");const ct=l((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"),ds=/; its log is \S*\/\.claude\/kickflip\/logs\/([^/\s]+\.log)\.$/,cs=l(e=>{const t=!e.log&&typeof e.text=="string"?ds.exec(e.text):null;return t?{...e,text:`${e.text.slice(0,t.index)}.`,log:t[1]}:e},"withLog");function us(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:$e(n),run:ut(e,n),running:!n.done}:{}}l(us,"agentOfLine");function ut(e,t){return t.label!==Qe?t.started:e.filter(n=>te(n)&&n.label!==Qe&&n.started&&String(n.started)<String(t.started)).pop()?.started??t.started}l(ut,"sectionOf");function Pt(e,{lines:t=[],events:n=[],owner:s={},working:r={},fromAsk:a=null,links:d=[],agents:c={},moved:p=[],cards:f=new Map,index:g=Lt(n,s)}){const u=e.startsWith("ask:")?[e.slice(4)]:[a,...p].filter(Boolean),h=[...new Set([e,...u.map(i=>`ask:${i}`)])],S=new Map((g.questions.get(`item:${e}`)||[]).map(i=>[i.id,i])),_=g.answers.get(`item:${e}`)||[],v=new Set([...S.values()].map(i=>i.round_of).filter(Boolean)),T=at(c,!0).filter(te).map(i=>String(i.started||"")).filter(Boolean),D=new Set(_.filter(i=>Mt(S.get(i.data.id),i.ts)||v.has(i.data.id)||T.some(E=>E>String(i.ts))).map(i=>i.id)),R=at(c,!0),C=[...R.flatMap(i=>[...i.started?[{ts:i.started,who:"claude",kind:"agent",text:`${$e(i)} started`,agent:$e(i),run:ut(R,i),finished:!1,eta:i.done?null:i.eta,...i.log?{log:i.log}:{},...ee(i)?{planner:!0}:{}}]:[],...i.done?[{ts:i.done,who:"claude",kind:"agent",text:`${$e(i)} finished`,agent:$e(i),run:ut(R,i),finished:!0,eta:null,...ee(i)?{planner:!0}:{}}]:[],...i.calls.length?[{ts:i.done||i.calls.at(-1).at,who:"claude",kind:"calls",text:$e(i),calls:i.calls.map(E=>E.text),verified:i.verified}]:[]]),...t.map(cs).map(i=>i.card?ls(i,f):i).map(i=>({ts:i.ts,who:i.who||"claude",...i.log?{log:i.log}:{},...i.kind==="status"?{kind:"status",...i.planner?{planner:!0}:{},...us(R,i)}:{},...i.kind===ge||i.kind===Oe?{kind:i.kind}:{},...i.command?Tt(i.command):{},...i.card?{card:i.card}:{},...Object.values(Ne).includes(i.kind)?{kind:i.kind,ask:i.ask}:{},text:i.text||"",html:i.html||null,link:i.link||null,via:i.via||null,...i.by?{by:i.by}:{}})),...ct(g,h.map(i=>g.byKey.get(i))).map(i=>({ts:i.ts,who:"love",via:"site",kind:i.kind,text:rs(i,S),files:i.data.files||[],eventId:i.id,reply:i.reply,...is(i,S),...Xe(i)})),..._.map(i=>{const E=[i.data.label||i.data.choice,i.data.note].filter(Boolean).join(" \xB7 ");return{ts:i.ts,who:"love",via:"questions",kind:i.kind,text:`${Ct(S,S.get(i.data.id))}
|
|
4
|
+
\u2192 ${E}`,files:i.data.files||[],eventId:i.id,reply:i.reply,status:ss,...Xe(i)}}),...(g.reopens.get(`item:${e}`)||[]).map(i=>({ts:i.ts,who:"love",kind:i.kind,request:!0,mark:as,text:`Question ${Dt(S,i.data.question)} was reopened`,...Xe(i)})),...ct(g,[...new Set(u)].map(i=>g.asks.has(i)?[g.asks.get(i)]:[])).flatMap(i=>[{ts:i.ts,who:"love",via:"ask",kind:i.kind,text:i.data?.text||"",files:i.data?.files||[],eventId:i.id,reply:i.reply,...p.includes(i.id)?{moved:!0}:{},...Xe(i),...typeof i.data?.from?.title=="string"?{from:i.data.from.title}:{}},...i.data?.quick===!0?[{ts:i.ts,who:"love",...Tt("implement"),text:Ve.implement}]:[],...d.map(E=>({ts:i.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((i,E)=>String(i.ts).localeCompare(String(E.ts))),U=dt(C),{edits:m,editFiles:A}=g;for(const i of C){if(!i.eventId)continue;(i.kind==="ask"||i.kind==="item-message")&&typeof m.get(i.eventId)=="string"&&Object.assign(i,{text:m.get(i.eventId),edited:!0,files:[...i.files,...A.get(i.eventId)||[]]});const E=i.kind==="ask"&&(d.length>0||!!i.moved);i.state=i.reply?"replied":E||D.has(i.eventId)||U>String(i.ts)?"answered":B(r,i.eventId)?"working":"waiting",i.canDelete=i.kind==="item-message"&&(i.state==="working"||i.state==="waiting"),i.canEdit=i.canDelete}return ps(C)}l(Pt,"threadOf");const jt=["waiting","working","answered","replied"];function ps(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)=>Lt.indexOf(r)-Lt.indexOf(a))[0],reply:void 0,answers:s.map(r=>({eventId:r.eventId,state:r.state,reply:r.reply,text:r.text}))}]})}l(go,"foldSubmits");const De=l(e=>(e.answers||[e]).filter(t=>t.eventId).map(t=>[t.eventId,t.state]),"stateEntries");function ko(e,t,n,s,r,a){const u=l((c,h)=>{const m=a.filter(S=>S.kind==="wave-triage"&&S.data?.[c]===h).pop(),x=r.filter(S=>S.topic===`${c}:${h}`&&(S.state==="open"||S.state==="answered")).length;return{running:!!(m&&!m.reply),questions:x}},"triageOf"),d=new Map(s.map(c=>[c.key,c])),p=l(c=>c.filter(h=>h.lane==="done"&&!ht(h)).length,"merged"),f=n.map(c=>({l:c,cards:c.keys.map(h=>d.get(h)).filter(Boolean)})).map(c=>({...c,open:!c.l.finished_at&&c.cards.some(h=>h.lane!=="done")})).sort((c,h)=>Number(c.open)-Number(h.open));for(const{l:c,cards:h}of f)for(const m of h)m.lineup={slug:c.slug,title:c.title};const g=f.filter(c=>c.open).map(({l:c,cards:h})=>({kind:"lineup",slug:c.slug,title:c.title,goal:c.goal,keys:h.map(m=>m.key),phases:c.phases.map(m=>m.filter(x=>d.has(x))).filter(m=>m.length),next:mo(h),merged:p(h),total:h.length,triage:u("lineup",c.slug)}));return e.fromWaves?[...g,...t.filter(c=>!c.finished).map(c=>({w:c,cards:s.filter(h=>h.wave===c.slug&&h.kind!=="ask")})).filter(({cards:c})=>c.length).map(({w:c,cards:h})=>({kind:"wave",slug:c.slug,title:c.title,goal:null,keys:h.map(m=>m.key),phases:null,next:null,merged:p(h),total:h.length,triage:u("wave",c.slug)}))]:g}l(ko,"waveBandsOf");function mo(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.state||"not ready";return{key:n.key,ref:n.ref,ready:s,word:r}}l(mo,"nextOf");function rs(e,t,n,s){const r=e.waveBands.find(c=>c.kind==="lineup"&&c.slug===t);if(!r)return null;const a=new Map(e.items.map(c=>[c.key,c.lane])),u=r.keys.filter(c=>a.get(c)==="todo"),d=u.indexOf(n),p=d+s;if(d<0||p<0||p>=u.length)return null;[u[d],u[p]]=[u[p],u[d]];let f=0;const g=r.keys.map(c=>a.get(c)==="todo"?u[f++]:c);return f=0,r.phases.map(c=>g.slice(f,f+=c.length))}l(rs,"lineupMoved");const wo=l(e=>e.phases||e.items.map(t=>[t]),"lineupPhases");function as(e){const{owner:t={},topicItems:n={},events:s=[],threads:r={},prs:a={},working:u={}}=e,d=e.now??Date.now(),p=Ct(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])),c=l((o,k)=>new Map(s.filter(b=>b.kind===o).sort((b,v)=>String(b.ts).localeCompare(String(v.ts))).map(b=>[b.data?.[k],b.ts])),"latest"),h=c("ask-bump","id"),m=c("card-unbump","key"),x=new Map([...c("card-bump","key")].filter(([o,k])=>!(String(m.get(o)||"")>String(k)))),S=c("card-done","key"),L=c("card-merge","key"),_=e.autoMerge===!0,P=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])),K=new Map,E=new Map(e.waves.flatMap(({slug:o,wave:k})=>k.items.map(b=>[`${o}/${b.id}`,{ref:Ke(k,b,P),title:b.title}]))),C=e.askLinks||{},i=new Map;for(const[o,k]of Object.entries(C))g.has(o)&&i.set(k,[...i.get(k)||[],o]);const y=[],B=[],ke=new Map,re=new Map,U=new Map,V=new Map,W=e.github?null:Jt(e.remote);for(const{slug:o,wave:k,agents:b={}}of e.waves){const v=e.github||k.repo||null;y.push({slug:o,title:k.title||o,status:k.status||null,internal:!!k.internal,finished:!1,reviewers:(k.reviewers||[]).map(O=>O.name)}),k.items.forEach((O,M)=>{const I=`${o}/${O.id}`,ce=(i.get(I)||[]).filter($=>$!==O.from_ask),ue=[O.from_ask,...ce].filter($=>g.has($)),We=new Set(ue.map($=>`ask:${$}`)),Fe=[...A(r,I)||[],...ue.flatMap($=>A(r,`ask:${$}`)||[])];O.from_ask&&K.set(O.from_ask,[...K.get(O.from_ask)||[],{key:I,ref:Ke(k,O,P),became:!0}]);const ye=Tt(I,{lines:Fe,events:s,owner:t,working:u,fromAsk:O.from_ask||null,moved:ce,cards:E,index:p});for(const $ of ye)for(const[w,J]of De($))ke.set(w,J);re.set(I,it(ye)),B.push(Bn({slug:o,wave:k,it:O,order:M,repo:v,remote:W,base:e.branch||"main",prs:nn(O,v).map($=>({...$,gh:A(a,sn($))||null})),...($=>({agents:$,builder:Yn($,A(r,I),d,e.moved?.[at(A(b,O.id))]??null,A(e.alive,I)??null,!!e.commandRunning?.[at(A(b,O.id))]),reachedPhase:Xn($,A(r,I)),eta:$.map(w=>w.eta).filter(Boolean).sort().pop()||null}))(Ve(A(b,O.id))),worktree:at(A(b,O.id))??O.worktree?.path??null,thread:Fe,events:[...dt(p,[I,...We].map($=>p.byKey.get($))),...ue.map($=>g.get($))],working:ye.some($=>De($).some(([,w])=>w==="working")),said:ye.filter($=>$.who==="love"&&($.kind==="item-message"||$.kind==="owner-answer")),askedAt:(p.questions.get(`item:${I}`)||[]).filter($=>$.asked_at).map($=>$.asked_at),topicItems:n,prSlack:e.prSlack||{},boardReviewers:e.reviewers||[],now:d,bumpedAt:x.get(I),holdAsk:T.get(I),closedAt:S.get(I),mergeAt:L.get(I),autoMerge:_,skipDraft:e.skipDraft===!0,tickets:P}));const Me=B[B.length-1];V.set(I,{parent:O.parent?jt(o,O.parent):null,related:(O.related||[]).map($=>jt(o,$))}),Me.lane==="done"&&U.set(I,Me.closedAt||String(Me.updatedAt||""))})}const N=new Map(B.map(o=>[o.key,o])),H=new Map,X=e.try||{},Ne=e.autoBuild===!0,F=["web","app"].includes(X.kind)?X.kind:e.waves.some(({wave:o})=>o.items.some(k=>k.install?.url))?"app":"web";for(const o of B){if(o.kind!=="work"||o.lane==="done")continue;const k=A(X.cards,o.key)||{},b=k.head||o.pr?.headRefOid,v=F==="web"?k.sha:o.install?.sha,O=o.builder?.kind===be.install?"running":k.state||(F==="app"&&o.install?"ready":null);o.try={kind:F,state:O,stale:!!(v&&b&&!String(b).toLowerCase().startsWith(String(v).toLowerCase())),url:F==="web"?null:o.install?.url||null,port:F==="web"&&O==="ready"&&k.https||null,sha:v||null,changes:k.ahead>0,script:k.script===!0,autoBuild:Ne}}const j=X.main,Ce=j?.script&&j.sha?{slug:j.slug,branch:j.branch||"main",sha:j.sha.slice(0,7),at:j.at,kind:F,state:j.state||null,url:F==="web"?null:e.main?.install?.url||null,port:F==="web"&&j.state==="ready"&&j.https||null,pull:X.pull?{running:X.pull.running===!0,error:X.pull.error||null}:null,script:dn(j.target)}:null,G=e.askProgress||{},me=c("ask-done","id"),Ye=Oe(s.filter(o=>o.kind==="owner-answer"),o=>o.data?.id),$e=Oe(s.filter(o=>o.kind==="prototype-request"),o=>o.data?.question),ze=Oe(s.filter(o=>o.kind==="reask-request"),o=>o.data?.question),we=Oe(s.filter(o=>o.kind===pt),o=>o.data?.question),Q=(t.items||[]).map(o=>Jn(o,Ye.get(o.id)||[],$e.get(o.id)||[],ze.get(o.id)||[],we.get(o.id)||[])),ne=new Map(Q.map(o=>[o.id,o])),ae=Oe(Q,o=>o.topic),Te=l(o=>{const k=ae.get(o)||[];return{open:k.filter(b=>b.state==="open").length,answered:k.filter(b=>b.state==="answered").length}},"pendingOn");for(const o of g.values()){const k=`ask:${o.id}`,b=N.get(A(C,o.id)),v=[...K.get(o.id)||[]],O=b&&!v.some(I=>I.key===b.key);if(O&&v.push({key:b.key,ref:b.ref,title:b.title,became:!1,folded:!0}),v.length&&!O){H.set(k,v[0].key);continue}if(!O&&A(C,o.id)){H.set(k,A(C,o.id));continue}const M=Tt(k,{lines:A(r,k)||[],events:s,working:u,links:v,index:p});for(const I of M)for(const[ce,ue]of De(I))ke.set(ce,ue);re.set(k,it(M)),B.push(Kn(o,M,h.get(o.id),v.length>0||!!A(C,o.id),A(G,o.id),me.get(o.id),Te(`item:${k}`)))}for(const o of y){const k=B.filter(b=>b.wave===o.slug);if(o.finished=bn(k),o.finished)for(const b of k)b.lane==="done"&&(b.fold=gn(o.slug))}for(const o of B)o.lineup=null;const Ee=new Set((t.topics||[]).map(o=>o.id)),Y=e.waves.flatMap(({slug:o,wave:k})=>(k.lineups||[]).map(b=>{const v=wo(b).map(O=>O.map(M=>`${o}/${M}`));return{...b,phases:v,keys:v.flat()}})),z=l(()=>no([...t.topics||[],...B.filter(o=>!Ee.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}:{}})),...Y.filter(o=>!Ee.has(`lineup:${o.slug}`)).map(o=>({id:`lineup:${o.slug}`,title:o.title,summary:"Wave triage."})),...(e.fromWaves?y:[]).filter(o=>!Ee.has(`wave:${o.slug}`)).map(o=>({id:`wave:${o.slug}`,title:o.title,summary:"Wave triage."}))],Q,new Set(B.filter(pe).map(o=>`item:${o.key}`))),"topicsOf"),Ae=new Map(z().map(o=>[o.id,o]));for(const o of B){const k=Ae.get(`item:${o.key}`);if(!k){o.questions=null,o.prototypes=null;continue}const b=k.questions.filter(M=>ne.get(M)?.state!=="resolved"),v=k.questions.find(M=>ne.get(M)?.state==="open")||b[0]||k.questions[0],O=k.questions.map(M=>ne.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:v,askedAt:O.map(M=>M.asked_at).filter(Boolean).sort(),fromAsks:O.length>0&&O.every(M=>M.ask)},o.prototypes=to(k.questions.map(M=>ne.get(M)))}const le=new Map(B.map(o=>[o.key,o]));for(const o of B){const k=o.kind==="work"&&o.lane!=="done";o.blockedBy=k?o.deps.map(v=>le.get(String(v).includes("/")?v:`${o.wave}/${v}`)).filter(v=>v&&v.lane!=="done"&&!v.reopened).map(Pt):[],o.blockedUntil=k?o.blockedUntil??null:null,o.blockReason=k?o.blockReason??null:null,o.blocked=o.blockedBy.length>0||!!o.blockedUntil,Wn(o,ne,_),o.lane==="todo"&&o.kind==="work"&&!o.held&&Ot(o.storedLane,o.agents)&&(o.lane="progress"),o.unpicked=o.kind==="work"&&o.lane==="todo"&&!!Tn(Q,o.key),o.unpicked&&(o.state="prototyping"),o.unpicked&&!o.action&&(o.next=Ln),o.buildable=Nn(o);const b=o.kind==="work"&&o.lane==="todo";o.unsorted=b&&(!!o.fromAsk||o.unfiled)&&!o.state,o.ready=b&&o.state==="ready"&&!o.blocked&&!o.action,o.staging=b&&o.state==="staging"}bo(B,le,V);const Be=new Map((t.items||[]).map(o=>[o.id,o.topic])),Le=l(o=>o.kind==="owner-answer"?Be.has(o.data?.id)?/^item:(.+)$/.exec(Be.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=l(o=>{const k=Le(o);return H.get(k)||k},"cardOf"),Je=l(o=>{const k=o.startsWith("ask:")?o.slice(4):null,b=k&&A(G,k)?.state==="done"?A(G,k).at:null;return[S.get(o),k&&me.get(k),b,U.get(o)].filter(Boolean).sort().pop()||""},"closedAt"),Re=l(o=>{const k=R(o);return k===null?!o.reply:!le.has(k)||!(Je(k)<String(A(u,o.id)))?!1:ke.has(o.id)?ke.get(o.id)==="working":!o.reply&&!H.has(Le(o))&&!(String(re.get(k)||"")>String(o.ts))},"unanswered"),D=s.filter(o=>A(u,o.id)&&Re(o)).map(o=>({id:o.id,kind:o.kind,key:R(o),data:o.data,since:A(u,o.id)}));for(const o of B)o.working=D.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=So[o.lane](o)||(o.lane==="review"?null:o.updatedAt)||null;for(const o of B){if(o.kind!=="work")continue;const k=(ae.get(`item:${o.key}`)||[]).filter(v=>v.state==="answered").map(v=>v.answers.at(-1).ts).sort().pop(),b=D.filter(v=>v.key===o.key).map(v=>String(v.since)).sort()[0];o.orchestrator=!o.stalled&&(["progress","todo"].includes(o.lane)||o.waitsOn==="checking"||o.lane==="review"&&o.stale)?jo(o,o.waitFacts,{answeredAt:k,workingSince:b}):null,delete o.waitFacts}qo(B,s),B.sort(cn);const Ze=ko(e,y,Y,B,Q,s),ie=z(),de=Zt({on:e.autoReview,incoming:e.incoming,records:e.reviewRecords,events:s,now:d,refs:new Map(B.filter(o=>o.kind==="work").map(o=>[o.key,o.ref]))}),he=[...xo(B,ie,Q),...en(de)],_e=new Map(he.filter(o=>o.questions).map((o,k)=>[o.topic||`item:${o.key}`,k])),Pe=l(o=>_e.get(o.id)??_e.size,"rankOf");ie.sort((o,k)=>Pe(o)-Pe(k));const je=new Set(he.filter(o=>o.questions&&o.progress).map(o=>`item:${o.key}`));for(const o of ie)je.has(o.id)&&(o.progress=!0);const Ue=B.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 ho({kind:F,main:Ce,remote:W&&{host:W.host,name:`${W.host}/${W.path}`},waves:y,waveBands:Ze,items:B,moved:Object.fromEntries(H),answers:Ue,owner:Q,ownerTopics:ie,reviews:de,needs:he,working:D.length,workingOn:D,checks:vo(e,d)},e)}l(as,"buildBoard");function ho(e,{listen:t,prompts:n}={}){const s=[...$o(n),...e.needs];return{...e,needs:s,needsSummary:Eo(s),checks:{...e.checks,watcher:{listening:"running",asleep:"asleep",waking:"waking"}[t]||"stopped"}}}l(ho,"withHub");const Pt=l(e=>({key:e.key,ref:e.ref}),"linkOf"),jt=l((e,t)=>String(t).includes("/")?String(t):`${e}/${t}`,"linkKey"),yo=l((e,t)=>e.ref.localeCompare(t.ref,void 0,{numeric:!0}),"byRef");function bo(e,t,n){const s=new Map,r=new Map,a=new Map,u=l((p,f,g)=>p.set(f,[...p.get(f)||[],g]),"add");for(const[p,f]of n){f.parent&&u(s,f.parent,p);for(const g of f.related)g!==p&&(u(r,p,g),u(r,g,p))}for(const p of e)for(const f of p.blockedBy||[])u(a,f.key,p.key);const d=l((p=[])=>[...new Set(p)].map(f=>t.get(f)).filter(Boolean).map(Pt).sort(yo),"cards");for(const p of e){const f=n.get(p.key)?.parent;p.parent=f?{key:f,ref:t.get(f)?.ref||f.slice(f.indexOf("/")+1)}:null,p.children=d(s.get(p.key)),p.related=d(r.get(p.key)),p.waitsOnIt=d(a.get(p.key))}}l(bo,"linkCards");const So={todo:l(e=>e.created,"todo"),progress:l(e=>e.progressSince,"progress"),review:l(e=>e.reviewSince,"review"),done:l(e=>e.closedAt,"done"),asks:l(e=>e.ask.answerAt,"asks")},se=l((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural");function vo({checked:e,watcher:t,replyAt:n,threads:s={},working:r={},waves:a=[]},u){const d=Number(e?.every)||30,f=[n,t?.since,...Object.values(r),...Object.values(s).flat().filter(c=>(c.who||"claude")==="claude").map(c=>c.ts),...a.flatMap(c=>Object.values(c.agents||{}).flatMap(h=>Object.values(h||{})).map(h=>h?.done||h?.started))].filter(c=>typeof c=="string"&&!Number.isNaN(Date.parse(c))).reduce((c,h)=>c&&Date.parse(c)>Date.parse(h)?c:h,null),g=!!e?.idle;return{at:e?.at||null,every:g?null:d,idle:g,late:!g&&!!e?.at&&u-Date.parse(e.at)>2*d*6e4,claudeAt:f}}l(vo,"checksOf");function xo(e,t,n){const s=new Set(e.map(d=>d.questions?.topic).filter(Boolean)),r=l(d=>d.find(p=>n.find(f=>f.id===p)?.state==="open")||d[0],"firstOpen"),a=t.filter(d=>d.state!=="resolved"&&d.open>0&&!s.has(d.id)).map(d=>{const p=`questions.html#${r(d.questions)}`,f=/^(?:lineup|wave):(.+)$/.exec(d.id)?.[1]||null;return{kind:"Question",title:d.title,text:`${d.title} \xB7 ${se(d.open,"question")}`,url:p,topic:d.id,band:f,questions:{open:d.open,url:p},ready:null,since:n.filter(g=>g.topic===d.id&&g.state==="open").map(g=>g.asked_at).filter(Boolean).sort()[0]||null}}),u=e.map(d=>{const p=d.questions&&d.questions.state!=="resolved"&&d.questions.open>0?{open:d.questions.open,url:`questions.html#${d.questions.first}`}:null,f=d.waitsOn==="ready"?d.pr.url:null,g=!p&&!f&&d.action?{label:d.action.label,url:d.action.url}:null;if(!p&&!f&&!g)return null;const c=`${d.ref}: ${d.title}`,h=[c,p&&se(p.open,"question"),f&&"Ready on GitHub",g?.label].filter(Boolean).join(" \xB7 ");return{kind:p?"Question":f?"Tap Ready":"Action needed",title:c,text:h,url:`#item=${encodeURIComponent(d.key)}`,key:d.key,questions:p,ready:f,action:g,since:d.created||null,progress:d.lane==="progress"}}).filter(Boolean);return[...a,...u].sort(Oo)}l(xo,"needsOf");const Oo=l((e,t)=>!!t.progress-!!e.progress||(e.since&&t.since?e.since.localeCompare(t.since):!!t.since-!!e.since),"oldestFirst");function $o(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}})}l($o,"promptLines");function Eo(e){const t=e.filter(a=>a.prompt).length,n=e.reduce((a,u)=>a+(u.questions?.open||0),0),s=e.filter(a=>a.ready).length,r=e.filter(a=>a.review).length;return[t&&se(t,"prompt"),n&&se(n,"question"),s&&`${se(s,"draft")} waiting on Ready`,r&&`${se(r,"review")} held`].filter(Boolean).join(" \xB7 ")}l(Eo,"needsSummary");function ls(e){const t=l((...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))}}l(ls,"needsAnswer");const Ao=l(e=>e.buildable&&e.state==="ready"&&!e.held&&!e.blocked,"pullableCard"),Bo=10;function Ro(e,{cap:t=Bo,pulled:n=[]}={}){const s=e.filter(m=>!pe(m)),r=l((m,x)=>m.started&&!m.done&&te(m)&&!(m.kind===Qe&&!m.writes)&&!(m.waits&&x.some(S=>S.name===m.waits&&!S.done)),"counts"),a=s.filter(m=>!m.stalled).reduce((m,x)=>m+(x.agents||[]).filter((S,L,_)=>r(S,_)).length,0),u=s.filter(m=>Ao(m)&&!m.working).map(m=>m.key),d=s.filter(m=>n.includes(m.key)&&(u.includes(m.key)||m.buildable&&m.working)).map(m=>m.key),p=s.flatMap(m=>(m.agents||[]).filter(x=>x.kind===Qe&&!x.started&&!x.done).map(x=>({key:m.key,name:x.name,writes:x.writes}))),f=Math.max(0,t-a-d.length),g=p.filter(m=>m.writes),c=[...p.filter(m=>!m.writes),...g.slice(0,f)].map(({key:m,name:x})=>({key:m,name:x})),h=u.filter(m=>!d.includes(m)).slice(0,Math.max(0,f-g.length));return{idle:!a&&!s.some(m=>m.waitsOn==="checking"),pullable:u,waiting:d,pulls:h,helpers:c}}l(Ro,"pullOf");function is(e,t,n){return e.filter(s=>s.kind==="work"&&!pe(s)&&s.waitsOn!=="checking"&&!(s.agents||[]).some(r=>r.started&&!r.done)).flatMap(s=>{const r=(s.prs||[]).find(u=>u.state==="OPEN"&&u.mergeable==="CONFLICTING"&&u.repo===s.repo&&u.headRefOid),a=r&&`${r.headRefOid}@${n}`;return r&&A(t,s.key)!==a?[{key:s.key,pr:r.number,branch:r.headRefName,conflict:a}]:[]})}l(is,"rebasesDue");const _o=3;function ds(e,{cap:t=_o}={}){const n=e.filter(a=>!pe(a)),s=n.filter(a=>(a.agents||[]).some(u=>ee(u)&&u.started&&!u.done)).length;return n.filter(a=>a.buildable&&!["ready","staging"].includes(a.state)&&!a.unsorted&&!a.blocked&&!a.held&&!a.working&&!a.grilling&&!a.prototyping&&!a.questions&&!(a.agents||[]).some(u=>ee(u)&&u.kind!==fe)).slice(0,Math.max(0,t-s)).map(a=>a.key)}l(ds,"arrivalsOf");function cs(e){return e.filter(t=>t.kind==="work"&&t.lane==="todo"&&t.roundAt&&["grilling","prototyping"].includes(t.state)&&!(t.agents||[]).some(n=>ee(n)&&n.kind!==fe&&n.started&&(String(n.started)>=String(t.roundAt)||!n.done))).map(t=>({key:t.key,kind:t.state==="grilling"?"grill":"prototype"}))}l(cs,"roundsDue");const Mo=l(e=>`${fe}-${e.id}`,"visualAgent");function us(e,t){const n=[];for(const s of e){const r=s.agents||[];if(r.some(d=>d.kind===fe&&d.started&&!d.done))continue;const a=new Set(r.map(d=>d.name)),u=t.find(d=>d.kind==="visual-request"&&d.data?.key===s.key&&!a.has(Mo(d)));u&&n.push({key:s.key,request:u})}return n}l(us,"visualsDue");const Ut=l(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 Wt(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}l(Wt,"unsorted");function Ft(e,t){const n=new Map(e.map(r=>[r.key,r])),s=new Set(t.filter(r=>r.kind==="intake-handoff").map(r=>r.data?.event));return t.flatMap(r=>{const a=Ut(r);return a&&!s.has(r.id)&&Wt(n,r,a)?[{event:r.id,key:a,kind:r.kind}]:[]})}l(Ft,"intakeOpen");function ps(e,t,n){return Object.values(n).some(s=>!s.ended)?null:Ft(e,t).find(s=>!A(n,s.event))??null}l(ps,"intakeDue");const Io=ft;function fs(e,t){return Object.entries(e).filter(([,n])=>!n.ended&&t-Date.parse(n.at)>=Io).map(([n])=>n)}l(fs,"intakeHung");function gs(e,t,n){return Ft(e,t).filter(s=>A(n,s.event)?.ended)}l(gs,"intakeStranded");function qo(e,t){const n=new Map(e.map(r=>[r.key,r])),s=new Map(t.map(r=>[r.id,r]));for(const r of t.filter(a=>a.kind==="intake-handoff")){const a=s.get(r.data?.event),u=a&&Ut(a);!u||!Wt(n,a,u)||(n.get(u).orchestrator={kind:"intake",since:String(r.ts),picked:null,next:`Sort what intake triage handed you: ${r.data.text}`})}}l(qo,"intakeWaits");function Do(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
|
-
`)}l(
|
|
6
|
+
`),files:s.flatMap(r=>r.files),state:s.map(r=>r.state).sort((r,a)=>jt.indexOf(r)-jt.indexOf(a))[0],reply:void 0,answers:s.map(r=>({eventId:r.eventId,state:r.state,reply:r.reply,text:r.text}))}]})}l(ps,"foldSubmits");const Ce=l(e=>(e.answers||[e]).filter(t=>t.eventId).map(t=>[t.eventId,t.state]),"stateEntries");function fs(e,t,n,s,r,a){const d=l((u,h)=>{const S=a.filter(v=>v.kind==="wave-triage"&&v.data?.[u]===h).pop(),_=r.filter(v=>v.topic===`${u}:${h}`&&(v.state==="open"||v.state==="answered")).length;return{running:!!(S&&!S.reply),questions:_}},"triageOf"),c=new Map(s.map(u=>[u.key,u])),p=l(u=>u.filter(h=>h.lane==="done"&&!bt(h)).length,"merged"),f=n.map(u=>({l:u,cards:u.keys.map(h=>c.get(h)).filter(Boolean)})).map(u=>({...u,open:!u.l.finished_at&&u.cards.some(h=>h.lane!=="done")})).sort((u,h)=>Number(u.open)-Number(h.open));for(const{l:u,cards:h}of f)for(const S of h)S.lineup={slug:u.slug,title:u.title};const g=f.filter(u=>u.open).map(({l:u,cards:h})=>({kind:"lineup",slug:u.slug,title:u.title,goal:u.goal,keys:h.map(S=>S.key),phases:u.phases.map(S=>S.filter(_=>c.has(_))).filter(S=>S.length),next:gs(h),merged:p(h),total:h.length,triage:d("lineup",u.slug)}));return e.fromWaves?[...g,...t.filter(u=>!u.finished).map(u=>({w:u,cards:s.filter(h=>h.wave===u.slug&&h.kind!=="ask")})).filter(({cards:u})=>u.length).map(({w:u,cards:h})=>({kind:"wave",slug:u.slug,title:u.title,goal:null,keys:h.map(S=>S.key),phases:null,next:null,merged:p(h),total:h.length,triage:d("wave",u.slug)}))]:g}l(fs,"waveBandsOf");function gs(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}}l(gs,"nextOf");function po(e,t,n,s){const r=e.waveBands.find(u=>u.kind==="lineup"&&u.slug===t);if(!r)return null;const a=new Map(e.items.map(u=>[u.key,u.lane])),d=r.keys.filter(u=>a.get(u)==="todo"),c=d.indexOf(n),p=c+s;if(c<0||p<0||p>=d.length)return null;[d[c],d[p]]=[d[p],d[c]];let f=0;const g=r.keys.map(u=>a.get(u)==="todo"?d[f++]:u);return f=0,r.phases.map(u=>g.slice(f,f+=u.length))}l(po,"lineupMoved");const ks=l(e=>e.phases||e.items.map(t=>[t]),"lineupSteps");function fo(e){const{owner:t={},topicItems:n={},events:s=[],threads:r={},prs:a={},working:d={}}=e,c=e.now??Date.now(),p=Lt(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])),u=l((o,k)=>new Map(s.filter(b=>b.kind===o).sort((b,O)=>String(b.ts).localeCompare(String(O.ts))).map(b=>[b.data?.[k],b.ts])),"latest"),h=u("ask-bump","id"),S=u("card-unbump","key"),_=new Map([...u("card-bump","key")].filter(([o,k])=>!(String(S.get(o)||"")>String(k)))),v=u("card-done","key"),T=u("card-merge","key"),D=e.autoMerge===!0,R=e.tickets,C=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])),U=new Map,m=new Map(e.waves.flatMap(({slug:o,wave:k})=>k.items.map(b=>[`${o}/${b.id}`,{ref:Ge(k,b,R),title:b.title}]))),A=e.askLinks||{},i=new Map;for(const[o,k]of Object.entries(A))g.has(o)&&i.set(k,[...i.get(k)||[],o]);const E=[],y=[],ne=new Map,de=new Map,F=new Map,V=new Map,K=e.github?null:zt(e.remote);for(const{slug:o,wave:k,agents:b={}}of e.waves){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(x=>x.name)}),k.items.forEach((x,q)=>{const I=`${o}/${x.id}`,ce=(i.get(I)||[]).filter($=>$!==x.from_ask),ue=[x.from_ask,...ce].filter($=>g.has($)),Fe=new Set(ue.map($=>`ask:${$}`)),Ke=[...B(r,I)||[],...ue.flatMap($=>B(r,`ask:${$}`)||[])];x.from_ask&&U.set(x.from_ask,[...U.get(x.from_ask)||[],{key:I,ref:Ge(k,x,R),became:!0}]);const Se=Pt(I,{lines:Ke,events:s,owner:t,working:d,fromAsk:x.from_ask||null,moved:ce,cards:m,index:p});for(const $ of Se)for(const[w,Z]of Ce($))ne.set(w,Z);de.set(I,dt(Se)),y.push(En({slug:o,wave:k,it:x,order:q,repo:O,remote:K,base:e.branch||"main",prs:tn(x,O).map($=>({...$,gh:B(a,sn($))||null})),...($=>({agents:$,builder:Xn($,B(r,I),c,e.moved?.[lt(B(b,x.id))]??null,B(e.alive,I)??null,!!e.commandRunning?.[lt(B(b,x.id))]),reachedPhase:Vn($,B(r,I)),eta:$.map(w=>w.eta).filter(Boolean).sort().pop()||null}))(at(B(b,x.id))),worktree:lt(B(b,x.id))??x.worktree?.path??null,thread:Ke,events:[...ct(p,[I,...Fe].map($=>p.byKey.get($))),...ue.map($=>g.get($))],working:Se.some($=>Ce($).some(([,w])=>w==="working")),said:Se.filter($=>$.who==="love"&&($.kind==="item-message"||$.kind==="owner-answer")),askedAt:(p.questions.get(`item:${I}`)||[]).filter($=>$.asked_at).map($=>$.asked_at),topicItems:n,prSlack:e.prSlack||{},boardReviewers:e.reviewers||[],now:c,bumpedAt:_.get(I),holdAsk:C.get(I),closedAt:v.get(I),mergeAt:T.get(I),autoMerge:D,skipDraft:e.skipDraft===!0,tickets:R}));const ve=y[y.length-1];g.has(x.from_ask)&&(ve.created=g.get(x.from_ask).ts),V.set(I,{parent:x.parent?Wt(o,x.parent):null,related:(x.related||[]).map($=>Wt(o,$))}),ve.lane==="done"&&F.set(I,ve.closedAt||String(ve.updatedAt||""))})}const L=new Map(y.map(o=>[o.key,o])),X=new Map,Y=e.try||{},Te=e.autoBuild===!0,W=["web","app"].includes(Y.kind)?Y.kind:e.waves.some(({wave:o})=>o.items.some(k=>k.install?.url))?"app":"web";for(const o of y){if(o.kind!=="work"||o.lane==="done")continue;const k=B(Y.cards,o.key)||{},b=k.head||o.pr?.headRefOid,O=W==="web"?k.sha:o.install?.sha,x=o.builder?.kind===pe.install?"running":k.state||(W==="app"&&o.install?"ready":null);o.try={kind:W,state:x,stale:!!(O&&b&&!String(b).toLowerCase().startsWith(String(O).toLowerCase())),url:W==="web"?null:o.install?.url||null,port:W==="web"&&x==="ready"&&k.https||null,sha:O||null,changes:k.ahead>0,script:k.script===!0,autoBuild:Te}}const j=Y.main,Le=j?.script&&j.sha?{slug:j.slug,branch:j.branch||"main",sha:j.sha.slice(0,7),at:j.at,kind:W,state:j.state||null,url:W==="web"?null:e.main?.install?.url||null,port:W==="web"&&j.state==="ready"&&j.https||null,pull:Y.pull?{running:Y.pull.running===!0,error:Y.pull.error||null}:null,script:ln(j.target)}:null,G=e.askProgress||{},me=u("ask-done","id"),Ye=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),ze=Ee(s.filter(o=>o.kind===kt),o=>o.data?.question),Q=(t.items||[]).map(o=>zn(o,Ye.get(o.id)||[],Pe.get(o.id)||[],Be.get(o.id)||[],ze.get(o.id)||[])),z=new Map(Q.map(o=>[o.id,o])),_e=Ee(Q,o=>o.topic),we=l(o=>{const k=_e.get(o)||[];return{open:k.filter(b=>b.state==="open").length,answered:k.filter(b=>b.state==="answered").length}},"pendingOn");for(const o of g.values()){const k=`ask:${o.id}`,b=L.get(B(A,o.id)),O=[...U.get(o.id)||[]],x=b&&!O.some(I=>I.key===b.key);if(x&&O.push({key:b.key,ref:b.ref,title:b.title,became:!1,folded:!0}),O.length&&!x){X.set(k,O[0].key);continue}if(!x&&B(A,o.id)){X.set(k,B(A,o.id));continue}const q=Pt(k,{lines:B(r,k)||[],events:s,working:d,links:O,index:p});for(const I of q)for(const[ce,ue]of Ce(I))ne.set(ce,ue);de.set(k,dt(q)),y.push(Fn(o,q,h.get(o.id),O.length>0||!!B(A,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=y.filter(b=>b.wave===o.slug);if(o.finished=yn(k),o.finished)for(const b of k)b.lane==="done"&&(b.fold=gn(o.slug))}for(const o of y)o.lineup=null;const he=new Set((t.topics||[]).map(o=>o.id)),je=e.waves.flatMap(({slug:o,wave:k})=>(k.lineups||[]).map(b=>{const O=ks(b).map(x=>x.map(q=>`${o}/${q}`));return{...b,phases:O,keys:O.flat()}})),J=l(()=>ts([...t.topics||[],...y.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(`lineup:${o.slug}`)).map(o=>({id:`lineup:${o.slug}`,title:o.title,summary:"Wave triage."})),...(e.fromWaves?E:[]).filter(o=>!he.has(`wave:${o.slug}`)).map(o=>({id:`wave:${o.slug}`,title:o.title,summary:"Wave triage."}))],Q,new Set(y.filter(fe).map(o=>`item:${o.key}`))),"topicsOf"),se=new Map(J().map(o=>[o.id,o]));for(const o of y){const k=se.get(`item:${o.key}`);if(!k){o.questions=null,o.prototypes=null;continue}const b=k.questions.filter(q=>z.get(q)?.state!=="resolved"),O=k.questions.find(q=>z.get(q)?.state==="open")||b[0]||k.questions[0],x=k.questions.map(q=>z.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:x.map(q=>q.asked_at).filter(Boolean).sort(),fromAsks:x.length>0&&x.every(q=>q.ask)},o.prototypes=es(k.questions.map(q=>z.get(q)))}const oe=new Map(y.map(o=>[o.key,o]));for(const o of y){const k=o.kind==="work"&&o.lane!=="done";o.blockedBy=k?o.deps.map(O=>oe.get(String(O).includes("/")?O:`${o.wave}/${O}`)).filter(O=>O&&O.lane!=="done"&&!O.reopened).map(Ut):[],o.blockedUntil=k?o.blockedUntil??null:null,o.blockReason=k?o.blockReason??null:null,o.blocked=o.blockedBy.length>0||!!o.blockedUntil,Un(o,z,D),o.lane==="todo"&&o.kind==="work"&&!o.held&&At(o.storedLane,o.agents)&&(o.lane="progress"),o.unpicked=o.kind==="work"&&o.lane==="todo"&&!!Cn(Q,o.key),o.kind==="work"&&(o.phase=js(o)),o.unpicked&&!o.action&&(o.next=Tn),o.buildable=Nn(o);const b=o.kind==="work"&&o.lane==="todo";if(o.unsorted=b&&(!!o.fromAsk||o.unfiled)&&!o.filedHeld&&o.phase==="new",o.ready=b&&o.phase==="ready"&&!o.blocked&&!o.action,o.staging=b&&o.phase==="staging",o.kind==="work"){const O=o.bumpedOut&&oe.get(o.bumpedOut.key);o.bumpedOut=b&&o.bumpedOut?{...o.bumpedOut,ref:O?.ref??o.bumpedOut.key.split("/").pop()}:null,o.hostHeld=!!e.hostBusy&&o.ready&&!!o.bumpedAt&&!o.held}}hs(y,oe,V);const ye=new Map((t.items||[]).map(o=>[o.id,o.topic])),Re=l(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=l(o=>{const k=Re(o);return X.get(k)||k},"cardOf"),M=l(o=>{const k=o.startsWith("ask:")?o.slice(4):null,b=k&&B(G,k)?.state==="done"?B(G,k).at:null;return[v.get(o),k&&me.get(k),b,F.get(o)].filter(Boolean).sort().pop()||""},"closedAt"),Je=l(o=>{const k=Ue(o);return k===null?!o.reply:!oe.has(k)||!(M(k)<String(B(d,o.id)))?!1:ne.has(o.id)?ne.get(o.id)==="working":!o.reply&&!X.has(Re(o))&&!(String(de.get(k)||"")>String(o.ts))},"unanswered"),re=s.filter(o=>B(d,o.id)&&Je(o)).map(o=>({id:o.id,kind:o.kind,key:Ue(o),data:o.data,since:B(d,o.id)}));for(const o of y)o.working=re.some(k=>k.key===o.key),o.kind==="work"&&o.lane==="progress"&&!o.builder&&!o.next&&o.waitsOn!=="checking"&&!o.working&&(o.next=Et),o.sortAt=ys[o.lane](o)||(o.lane==="review"?null:o.updatedAt)||null;for(const o of y){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(),b=re.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))?Gs(o,o.waitFacts,{answeredAt:k,workingSince:b}):null,delete o.waitFacts}Ns(y,s,d),Ds(y,e.screening||{}),y.sort(dn);const P=fs(e,E,je,y,Q,s),be=J(),Me=Jt({on:e.autoReview,incoming:e.incoming,records:e.reviewRecords,events:s,now:c,refs:new Map(y.filter(o=>o.kind==="work").map(o=>[o.key,o.ref]))}),ae=[...Ss(y,be,Q),...Zt(Me)],qe=new Map(ae.filter(o=>o.questions).map((o,k)=>[o.topic||`item:${o.key}`,k])),Ie=l(o=>qe.get(o.id)??qe.size,"rankOf");be.sort((o,k)=>Ie(o)-Ie(k));const Ze=new Set(ae.filter(o=>o.questions&&o.progress).map(o=>`item:${o.key}`));for(const o of be)Ze.has(o.id)&&(o.progress=!0);const We=y.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 ms({kind:W,main:Le,remote:K&&{host:K.host,name:`${K.host}/${K.path}`},waves:E,waveBands:P,items:y,moved:Object.fromEntries(X),answers:We,owner:Q,ownerTopics:be,reviews:Me,needs:ae,working:re.length,workingOn:re,checks:bs(e,c)},e)}l(fo,"buildBoard");function ms(e,{listen:t,prompts:n}={}){const s=[...Os(n),...e.needs];return{...e,needs:s,needsSummary:xs(s),checks:{...e.checks,watcher:{listening:"running",asleep:"asleep",waking:"waking"}[t]||"stopped"}}}l(ms,"withHub");const Ut=l(e=>({key:e.key,ref:e.ref}),"linkOf"),Wt=l((e,t)=>String(t).includes("/")?String(t):`${e}/${t}`,"linkKey"),ws=l((e,t)=>e.ref.localeCompare(t.ref,void 0,{numeric:!0}),"byRef");function hs(e,t,n){const s=new Map,r=new Map,a=new Map,d=l((p,f,g)=>p.set(f,[...p.get(f)||[],g]),"add");for(const[p,f]of n){f.parent&&d(s,f.parent,p);for(const g of f.related)g!==p&&(d(r,p,g),d(r,g,p))}for(const p of e)for(const f of p.blockedBy||[])d(a,f.key,p.key);const c=l((p=[])=>[...new Set(p)].map(f=>t.get(f)).filter(Boolean).map(Ut).sort(ws),"cards");for(const p of e){const f=n.get(p.key)?.parent;p.parent=f?{key:f,ref:t.get(f)?.ref||f.slice(f.indexOf("/")+1)}:null,p.children=c(s.get(p.key)),p.related=c(r.get(p.key)),p.waitsOnIt=c(a.get(p.key))}}l(hs,"linkCards");const ys={todo:l(e=>e.created,"todo"),progress:l(e=>e.progressSince,"progress"),review:l(e=>e.reviewSince,"review"),done:l(e=>e.closedAt,"done"),asks:l(e=>e.ask.answerAt,"asks")},ie=l((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural");function bs({checked:e,watcher:t,replyAt:n,threads:s={},working:r={},waves:a=[]},d){const c=Number(e?.every)||30,f=[n,t?.since,...Object.values(r),...Object.values(s).flat().filter(u=>(u.who||"claude")==="claude").map(u=>u.ts),...a.flatMap(u=>Object.values(u.agents||{}).flatMap(h=>Object.values(h||{})).map(h=>h?.done||h?.started))].filter(u=>typeof u=="string"&&!Number.isNaN(Date.parse(u))).reduce((u,h)=>u&&Date.parse(u)>Date.parse(h)?u:h,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}}l(bs,"checksOf");function Ss(e,t,n){const s=new Set(e.map(c=>c.questions?.topic).filter(Boolean)),r=l(c=>c.find(p=>n.find(f=>f.id===p)?.state==="open")||c[0],"firstOpen"),a=t.filter(c=>c.state!=="resolved"&&c.open>0&&!s.has(c.id)).map(c=>{const p=`questions.html#${r(c.questions)}`,f=/^(?:lineup|wave):(.+)$/.exec(c.id)?.[1]||null;return{kind:"Question",title:c.title,text:`${c.title} \xB7 ${ie(c.open,"question")}`,url:p,topic:c.id,band:f,questions:{open:c.open,url:p},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 p=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=!p&&!f&&c.action?{label:c.action.label,url:c.action.url}:null;if(!p&&!f&&!g)return null;const u=`${c.ref}: ${c.title}`,h=[u,p&&ie(p.open,"question"),f&&"Ready on GitHub",g?.label].filter(Boolean).join(" \xB7 ");return{kind:p?"Question":f?"Tap Ready":"Action needed",title:u,text:h,url:`#selectedCard=${encodeURIComponent(c.key)}`,key:c.key,questions:p,ready:f,action:g,since:c.created||null,progress:c.lane==="progress"}}).filter(Boolean);return[...a,...d].sort(vs)}l(Ss,"needsOf");const vs=l((e,t)=>!!t.progress-!!e.progress||(e.since&&t.since?e.since.localeCompare(t.since):!!t.since-!!e.since),"oldestFirst");function Os(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}})}l(Os,"promptLines");function xs(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&&ie(t,"prompt"),n&&ie(n,"question"),s&&`${ie(s,"draft")} waiting on Ready`,r&&`${ie(r,"review")} held`].filter(Boolean).join(" \xB7 ")}l(xs,"needsSummary");function go(e){const t=l((...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))}}l(go,"needsAnswer");const $s=l(e=>e.buildable&&e.phase==="ready"&&!e.held&&!e.blocked,"pullableCard"),As=10;function Es(e,{cap:t=As,pulled:n=[],hold:s=[],taken:r=0}={}){const a=e.filter(m=>!fe(m)),d=l((m,A)=>m.started&&!m.done&&te(m)&&!(m.kind===xe&&!m.writes)&&!(m.waits&&A.some(i=>i.name===m.waits&&!i.done)),"counts"),c=a.filter(m=>!m.stalled).reduce((m,A)=>m+(A.agents||[]).filter((i,E,y)=>d(i,y)).length,0),p=a.filter(m=>$s(m)&&!m.working).map(m=>m.key),f=a.filter(m=>n.includes(m.key)&&(p.includes(m.key)||m.buildable&&m.working)).map(m=>m.key),g=a.flatMap(m=>(m.agents||[]).filter(A=>A.kind===xe&&!A.started&&!A.done).map(A=>({key:m.key,name:A.name,writes:A.writes}))),u=Math.max(0,t-c-f.length-r),h=g.filter(m=>m.writes),S=[...g.filter(m=>!m.writes),...h.slice(0,u)].map(({key:m,name:A})=>({key:m,name:A})),_=Math.max(0,u-h.length),v=new Set(a.filter(m=>m.bumpedAt).map(m=>m.key)),T=p.filter(m=>!f.includes(m)&&!s.includes(m)),D=T.filter(m=>v.has(m)),R=[...D,...T.filter(m=>!v.has(m)).slice(0,Math.max(0,_-D.length))],C=D.slice(_),U=Bs(a,d).slice(0,C.length).map((m,A)=>({key:m,by:C[A]}));return{idle:!c&&!a.some(m=>m.waitsOn==="checking"),pullable:p,waiting:f,pulls:R,helpers:S,bumpOuts:U,pastCap:C,free:u}}l(Es,"pullOf");function Bs(e,t){const n=l(s=>{const r=s.agents||[],a=r.filter(p=>t(p,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!==xe&&d.pid&&d.label!==Qe&&!r.some(p=>p.kind===xe&&p.started&&!p.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)}l(Bs,"bumpOutsOf");function ko(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}]:[]})}l(ko,"rebasesDue");const _s=3;function mo(e,{cap:t=_s}={}){const n=e.filter(d=>!fe(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!==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)}l(mo,"arrivalsOf");function wo(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!==ge&&n.started&&(String(n.started)>=String(t.roundAt)||!n.done))).map(t=>({key:t.key,kind:t.phase==="grilling"?"grill":"prototype"}))}l(wo,"roundsDue");const Rs=l(e=>`${ge}-${e.id}`,"visualAgent");function ho(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(Rs(c)));d&&n.push({key:s.key,request:d})}return n}l(ho,"visualsDue");const Ms=l(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 qs(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}l(qs,"unsorted");const Is={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 Ns(e,t,n){const s=new Map(e.map(a=>[a.key,a])),r=new Set;for(const a of t){const d=Ms(a);!d||r.has(d)||!qs(s,a,d)||(r.add(d),s.get(d).orchestrator={kind:"intake",since:String(a.ts),picked:B(n,a.id)||null,next:Is[a.kind]})}}l(Ns,"intakeWaits");function Ds(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`})}}l(Ds,"screenWaits");function Cs(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
|
+
`)}l(Cs,"todoOf");function yo(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
|
-
${
|
|
10
|
+
${Cs(e)}`}}l(yo,"triageOf");const Ts=100,Ls=["key","kind","id","ref","title","lane","phase","wave","waveTitle","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=l(e=>Object.fromEntries(Ls.filter(t=>t in e).map(t=>[t,e[t]])),"slimDone");function So(e,t=Ts){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.wave}/${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"))}l(So,"archivedOf");const Ps={ready:"draft",ci:"draft",reviewers:"reviewers",merge:"merge"};function js(e){return e.lane==="todo"?e.unpicked?"prototyping":gt.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":Ps[e.waitsOn]??null:e.storedLane==="done"&>.done.includes(e.storedPhase)?e.storedPhase:e.prs.some(t=>t.status===H.merged)?"merged":"closed"}l(js,"phaseOf");function vo(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:Us(t,n)}]})}l(vo,"movesOf");function Us(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"}l(Us,"moveWhy");const Ws=l(e=>e.startsWith("ask:")?`ask-${e.slice(4)}`:`item-${e}`,"pushTag");function Oo(e){const t=l(a=>e.owner.filter(d=>d.topic===a&&d.state==="open").map(({id:d,question:c})=>({id:d,question:c})),"open"),n=[N.ready,N.merge],s=e.items.filter(a=>a.action).map(a=>{const d=ot.has(a.action.kind)?t(a.questions.topic):[];return{tag:Ws(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:N.questions,title:a.text,body:d[0]?.question||a.title,url:a.url,now:!0,questions:d}});return[...s,...r,...en(e.reviews)]}l(Oo,"ownerActions");function xo(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&&!Es(e.items,{pulled:t}).waiting.length}l(xo,"strictlyIdle");const Fs="item stall it with the reason when it can't go on",Ft="restart it once from its worktree with a thread line; if the restarted run goes stale too, item stall it with the reason",Ks='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 Gs(e,t,{answeredAt:n,workingSince:s}){const r=l(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:Ks}:n?{kind:"answer",since:n,next:"Act on the owner's answer"}:ot.has(e.action?.kind)?null:e.builder?.stopped?{kind:"stale",since:e.builder.silentSince,next:`${e.builder.stopped}: ${Ft}, 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 ${Ft}`}:e.lane==="review"&&e.stale?{kind:"stale",since:new Date(Date.parse(e.inReviewSince)+wt).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 ${Fs}`}: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===Et&&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),p=[t.writes.find(f=>f>c),s].filter(Boolean).sort()[0]||null;return{kind:d.kind,since:c,picked:p,next:d.next,...d.daily?{daily:!0}:{}}}l(Gs,"orchestratorWaitOf");const $o=l((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 Ao(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)]}l(Ao,"orchestratorWaits");const Eo=30*6e4,Qs=15*6e4,Hs=60*6e4,Vs=1440*6e4;function Bo(e,t,n){const s=n.toISOString(),r=[],a=[];return{waits:t.map(c=>{const p=e.find(u=>u.key===c.key&&u.kind===c.kind&&u.since===c.since);if(!p)return c.picked||r.push(c.key),{...c,bumped:s};const f=c.picked?[c.picked,p.bumped].filter(Boolean).sort().pop():p.bumped||c.since,g=n-Date.parse(f)>=(c.picked?c.daily?Vs:Hs:Qs);return g&&a.push({key:c.key,ref:c.ref,kind:c.kind,since:c.since,next:c.next}),{...c,bumped:g?s:p.bumped||c.since,...p.pushed?{pushed:!0}:{}}}),added:r,again:a}}l(Bo,"waitsStep");function _o(e,t){const n=l(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("; ")}`}l(_o,"waitsAgainLine");const Xs=15;function Ro(e,{idle:t,now:n}){const s=n.toISOString(),r=e.last||s;return t?e.since?e.pushed||n-Date.parse(e.since)<Xs*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}}l(Ro,"idleStep");function Mo(e,t){const n=l(p=>String(p.closedAt||"")>t,"after"),s=e.filter(p=>p.kind==="work"&&p.lane==="done"&&!bt(p)&&n(p)),r=new Map;for(const p of e)p.lineup&&r.set(p.lineup.slug,[...r.get(p.lineup.slug)||[],p]);const a=[...r.values()].filter(p=>p.every(f=>f.lane==="done")&&p.some(n)).map(p=>p[0].lineup.title),d=s.slice(0,3).map(p=>p.ref).join(", ")+(s.length>3?` and ${s.length-3} more`:"");return[s.length&&`${s.length} ${s.length===1?"card":"cards"} landed: ${d}`,...a.map(p=>`${p} finished`)].filter(Boolean).join(" \xB7 ")||"Nothing closed since the last idle notification."}l(Mo,"idleSummary");export{N as ACTION_KIND,It as ACTION_LABELS,ss as ANSWERS_SUBMITTED,Ne as BUILDER_ASK,pe as BUILDER_KIND,pn as BUILDER_QUIET_AFTER,un as BUILDER_STALE_AFTER,mt as BUILD_REFUSED,le as BUTTON,Ve as COMMANDS,Vs as DAILY_REWAKE_AFTER,Ls as DONE_FIELDS,Ts as DONE_KEPT,xe as HELPER,Xs as IDLE_MINUTES,Nt as INTENT_LABELS,cn as ITEM_EVENTS,Qe as LANDER,lo as LANES,As as MAX_IMPLEMENTERS,_s as MAX_PLANNERS,Oe as MOVE,Et as NO_NEXT,Eo as ORCHESTRATOR_PUSH_AFTER,gt as PHASES,Hs as PICKED_REWAKE_AFTER,Gn as PLANNER_WORD,Tn as PROTOTYPE_AGAIN,co as PROTOTYPE_WAIT,H as PR_STATE,kt as QUESTION_REOPEN,Qs as REWAKE_AFTER,ge as VISUAL,So as archivedOf,mo as arrivalsOf,fo as buildBoard,te as builds,nt as handedBackAt,Ro as idleStep,Mo as idleSummary,po as lineupMoved,ks as lineupSteps,Rn as mergeBlockers,Yn as modelName,vo as movesOf,go as needsAnswer,Cn as noTakePicked,Qn as orchestratorDid,Ao as orchestratorWaits,io as owesNext,Oo as ownerActions,zn as ownerQuestion,Dn as picksNoTake,ee as plans,uo as prototypeWaits,Rt as providerOf,Es as pullOf,Ws as pushTag,ko as rebasesDue,Ge as refOf,ke as roundOf,Jn as roundSettledBy,wo as roundsDue,bo as slimDone,Ce as stateEntries,Bt as stoppedWords,xo as strictlyIdle,Lt as threadIndex,Pt as threadOf,Cs as todoOf,yo as triageOf,$o as triageWaitOf,bt as unlanded,Rs as visualAgent,ho as visualsDue,_o as waitsAgainLine,Bo as waitsStep,gn as waveFold,ms as withHub};
|
package/board/finish.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var D=Object.defineProperty;var
|
|
2
|
-
`)[0];if(/^rebasing .+ conflicts in |^tests failed in /.test(i)){await r.appendThread(t,a,{text:`Not merged yet: ${i}. A lander fixes it and lands it.`});try{await
|
|
3
|
-
${s.stderr||""}`,f=(s.status===0||/already exists/.test(w))&&/\/pull\/(\d+)/.exec(w)?.[1];f||$(`could not open a draft PR for ${
|
|
4
|
-
`)[0]}`);const T=await r.setItem(t,a,{pr:Number(f)});return await r.appendThread(t,a,{text:d}),{said:`draft PR #${f} opened`,lines:T.lines}}
|
|
1
|
+
var D=Object.defineProperty;var c=(t,a)=>D(t,"name",{value:a,configurable:!0});import H from"node:fs";import M from"node:path";import{spawnSync as I}from"node:child_process";import*as r from"./store.mjs";import{builderRepo as v,git as h,joiningLand as N,landInTurn as P,passTests as j,syncBase as x,worktreesDir as q}from"./worktree.mjs";import{readPermissions as F}from"./permissions.mjs";import{launchBuilder as L}from"./headless.mjs";import{boardAt as A}from"../hub/boards.mjs";import{boardRepo as B}from"../hub/board-repo.mjs";const $=c(t=>{throw new r.BoardError(t)},"fail"),W=c(t=>typeof t=="string"&&t.trim()?t.trim():$("--text must be non-empty text"),"said");async function C(t,a,{text:e,ownerStep:n,check:o,repo:i,onWait:d,merge:m=!1}){const l=a.split("/")[1],u=await r.recordedWorktree(t,a),{repo:p,base:b,remote:s}=v(t,{repo:i??u?.repo}),w={path:u?.path??M.join(q(),l),branch:u?.branch??l,repo:M.resolve(p),base:b},f=await r.cardName(t,a),T=await r.readBoardSettings(t),g=s?B(A(t).route).github:null;if(s&&(!g||T.prs))return z(t,a,{...w,ref:f,text:W(e)});const R=await N(f,()=>V(t,a,{tree:w,ref:f,base:b,remote:s,repo:p,settings:T,text:e,ownerStep:n,check:o,onWait:d}),{merge:m});return R.joined?await r.isFinished(t,a)?{said:"landed and done",lines:[]}:C(t,a,{text:e,ownerStep:n,check:o,repo:i,onWait:d,merge:m}):R}c(C,"finishCard");async function V(t,a,{tree:e,ref:n,base:o,remote:i,repo:d,settings:m,text:l,ownerStep:u,check:p,onWait:b}){const s=m.auto_merge||!!(await r.heldMerge(t,a))?.tapped,w=s&&await r.blockWords(t,a);w&&$(`${n} is blocked ${w}, so it can't land; it lands once nothing blocks it`),await r.checkClose(t,a,l,u,p),await r.checkCallsVerified(t,a),i&&(x(e.repo,o),h(e.repo,"branch","--unset-upstream",e.branch)),s&&await r.landingLine(t,a);const f={site:t,key:a,first:await r.landFirst(t,a)};if(await P({...e,ref:n},{hold:!s,onWait:b,queue:f,sync:c(()=>i&&x(e.repo,o),"sync")}),!s){const g=await r.setItem(t,a,{mergeReady:e.branch,ownerStep:u,check:p});return await r.appendThread(t,a,{text:l}),{said:"verified; waits for your Merge",lines:g.lines}}const T=await r.setItem(t,a,{done:!0,landed:!0,text:l,ownerStep:u,check:p});return{said:u===void 0?"landed and done":`landed; waits on the owner step "${u.trim()}"`,lines:[...T.lines,...await _(t,a,d,o)]}}c(V,"landCard");async function S(t,a,{launch:e=L}={}){(await r.heldMerge(t,a))?.tapped||$(`${a} isn't waiting on a Merge tap`);try{const{base:o}=v(t,{repo:(await r.recordedWorktree(t,a))?.repo}),i=c(d=>r.appendThread(t,a,{text:`Waiting for ${d} to land`,kind:"status"}),"onWait");return await C(t,a,{text:`Landed on ${o} on your Merge.`,onWait:i,merge:!0})}catch(o){if(!(o instanceof r.BoardError))throw o;const i=o.message.split(`
|
|
2
|
+
`)[0];if(/^rebasing .+ conflicts in |^tests failed in /.test(i)){await r.appendThread(t,a,{text:`Not merged yet: ${i}. A lander fixes it and lands it.`});try{await e(t,{key:a,model:await r.builderModel(t,a)},{lander:!0})}catch(d){await r.appendThread(t,a,{text:`Couldn't launch the lander headless (${d.message}); land it with board.mjs land ${a}.`})}}else await r.appendThread(t,a,{text:`Not merged: ${i}. Tap Merge again.`});throw o}}c(S,"landHeld");async function _(t,a,e,n){if(!(await F(e)).pushMain)return[];const o=h(e,"push","--quiet","origin",n);if(o.ok)return[`pushed ${n} to origin`];const i=`${n} didn't reach origin: ${o.err}; push it with git -C ${e} push origin ${n}`;return await r.appendThread(t,a,{text:`Landed, but ${i}`}),[`landed, but ${i}`]}c(_,"pushBase");async function z(t,a,{path:e,branch:n,base:o,ref:i,text:d}){await r.checkCallsVerified(t,a),H.existsSync(e)||$(`no worktree at ${e}`),h(e,"status","--porcelain").out&&$(`${e} has uncommitted changes; commit them there first`),Number(h(e,"rev-list","--count",`refs/remotes/origin/${o}..HEAD`).out)===0&&$(`${n} has no commits beyond ${o}; nothing to send for review`),await j(e,{outcome:"nothing was pushed"});const{github:m}=B(A(t).route),l=m?await r.cardPR(t,a):null,u=l?h(e,"rev-parse",`refs/remotes/origin/${n}`).out:null,p=l?h(e,"push","--quiet",`--force-with-lease=refs/heads/${n}:${u}`,"origin",`HEAD:refs/heads/${n}`):h(e,"push","--quiet","origin",`HEAD:refs/heads/${n}`);if(p.ok||$(`could not push ${n} to origin: ${p.err}`),l){const g=c(E=>Number(h(e,"rev-list","--count",`refs/remotes/origin/${o}..${E}`).out),"ahead");await r.recordRebase(t,a,{from:u,to:h(e,"rev-parse","HEAD").out,replayed:g("HEAD")<=g(u)});const R=await r.setItem(t,a,{pr:l});return await r.appendThread(t,a,{text:d}),{said:`pushed ${n} to PR #${l}`,lines:R.lines}}if(!m){const g=await r.setItem(t,a,{pushed:n});return await r.appendThread(t,a,{text:d}),{said:`pushed ${n} for its merge`,lines:g.lines}}const{title:b}=await r.briefFacts(t,a),s=I("gh",["pr","create","--draft","--repo",m,"--base",o,"--head",n,"--title",`${i}: ${b}`,"--body",d],{cwd:e,encoding:"utf8"}),w=`${s.stdout||""}
|
|
3
|
+
${s.stderr||""}`,f=(s.status===0||/already exists/.test(w))&&/\/pull\/(\d+)/.exec(w)?.[1];f||$(`could not open a draft PR for ${n}: ${(s.stderr||s.error?.message||`gh exited ${s.status}`).trim().split(`
|
|
4
|
+
`)[0]}`);const T=await r.setItem(t,a,{pr:Number(f)});return await r.appendThread(t,a,{text:d}),{said:`draft PR #${f} opened`,lines:T.lines}}c(z,"sendForReview");export{C as finishCard,S as landHeld};
|
package/board/headless.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}
|
|
3
|
-
`)}
|
|
4
|
-
`)}
|
|
5
|
-
`)}
|
|
6
|
-
`)}
|
|
7
|
-
`)}
|
|
8
|
-
`)
|
|
9
|
-
`).map(o=>/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/.exec(o)).filter(Boolean).map(([,o,i,h,m])=>({pid:Number(o),ppid:Number(i),pgid:Number(h),args:m})),n=new Set(d.filter(o=>t.includes(o.pgid)).map(o=>o.pid));for(let o=!0;o;){o=!1;for(const i of d)!n.has(i.pid)&&n.has(i.ppid)&&(n.add(i.pid),o=!0)}const r=d.find(o=>o.pid===process.pid)?.pgid,s=d.filter(o=>n.has(o.pid)&&o.pgid>1&&o.pgid!==r),u=[...new Set(s.map(o=>o.pgid))],p=l(o=>{for(const i of u)try{process.kill(-i,o)}catch{}},"signal");p("SIGTERM");const f=Date.now()+e;for(;s.some(o=>A(o.pid))&&Date.now()<f;)await new Promise(o=>setTimeout(o,50));return s.some(o=>A(o.pid))&&p("SIGKILL"),s.map(({pid:o,args:i})=>({pid:o,args:i}))}l(Se,"stopRuns");const A=l(t=>{try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},"pidAlive");async function Ae(t,e,{launch:a,handBack:d,alive:n=A,held:r=l(()=>!1,"held"),stopped:s=new Set,limitedUntil:u=l(()=>null,"limitedUntil"),atLimit:p=l(async()=>{},"atLimit"),now:f=Date.now()}){const o={};for(const[i,h]of Object.entries(t)){if(!e.has(i))continue;if(s.has(i)){o[i]={...h,handedBack:!0};continue}if(h.pid!==null&&n(h.pid)||h.handedBack){o[i]=h;continue}const m={key:i,...h.kind?{kind:h.kind}:{},...h.model?{model:h.model}:{}},c=h.pid!==null?u(h):null;if(c){await p(m,c),o[i]={...h,pid:null,until:c};continue}if(r(h.kind??"claude")||h.until&&f<Date.parse(h.until)){o[i]=h;continue}if(h.pid!==null&&h.relaunched){await d(m),o[i]={...h,handedBack:!0};continue}const{key:g,...$}=m;o[i]={...$,...await a(m),relaunched:h.pid!==null||!!h.relaunched}}return o}l(Ae,"reviveBuilders");const H=l((t,e)=>x.join(V.homedir(),".claude","kickflip","logs",`${e}-${t}-${new Date().toISOString().replace(/[:.]/g,"-")}.log`),"logFile");async function We(t,{key:e,kind:a="claude",model:d,agent:n="main",text:r,files:s,question:u,note:p,choice:f,task:o,writes:i,worktree:h},{lander:m=!1}={}){const c=await Z(t,e),g=P(t)?.route??x.basename(t),$=[...C(),...await Y(t)].map(K=>K.text),{base:w,repo:k}=M(t),v=re({kind:a}),R=a===te,W=!v&&!R&&!m&&c.rebasePR!==null,q=a===ne,D=v?k:R?h??c.worktree??k:c.worktree,y={...c,route:g,base:w,repo:k,rules:$,kind:a,agent:n,text:r,files:s,question:u,note:p,choice:f,task:o,writes:i,cwd:D,pr:c.rebasePR},U=q?"Visual agent":R?`Helper ${n}`:v?"Planner":m?"Lander":W?"Rebase run":"Builder",G=q?ce(y):R?ue(y):v?le(y):m?he(y):W?de(y):ie(y),I=await B({kind:v||R?"claude":a,model:d,cwd:D,site:t,prompt:G,log:H(e.split("/")[1],U.split(" ")[0].toLowerCase())});return await ee(t,e,I.sessionId,I.pid,n,x.basename(I.log)),I}l(We,"launchBuilder");export{ae as BOARD_CLI,ie as builderBrief,ue as helperBrief,pe as intakeBrief,he as landerBrief,We as launchBuilder,je as launchIntake,we as launchedAgents,A as pidAlive,le as plannerBrief,de as rebaseBrief,Ae as reviveBuilders,Ne as stopAgents,Se as stopRuns,ce as visualBrief};
|
|
1
|
+
var F=Object.defineProperty;var d=(t,e)=>F(t,"name",{value:e,configurable:!0});import Y from"node:os";import S from"node:path";import{fileURLToPath as E}from"node:url";import{launchAgent as H}from"./agents.mjs";import{processStarts as L,ps as G}from"../hub/live.mjs";import{boardAt as K}from"../hub/boards.mjs";import{readHubRules as U}from"../hub/rules.mjs";import{builderRepo as _}from"./worktree.mjs";import{BoardError as V,briefFacts as Q,readBoardRules as X,recordSession as z}from"./store.mjs";import{HELPER as J,plans as Z,VISUAL as ee}from"./domain.mjs";const te=E(new URL("./bin/board.mjs",import.meta.url)),g=d(t=>`node ${te} --site ${t}`,"cli"),P=d(t=>`git -c core.commentChar=';' rebase ${t}`,"rebase"),oe="a draft .md of your own outside the board's data folder (such as in /tmp)",re=d((t,e,s)=>`\`${t} item notes ${e} --heading "${s}" --file <draft.md>\``,"notesCommand"),R=d((t,e="Rules from the hub and this board:")=>t.length?[e,...t.map(s=>`- ${s}`),""]:[],"ruleLines"),T=d(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"),x=d(t=>`The card's thread, which holds the owner's messages (who: love): ${t}. Read it live.`,"threadLine"),W=d(({route:t,key:e,worktree:s,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 \`${P(h)}\` in ${s}, 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"),D=d(({route:t,key:e})=>`\`${g(t)} builder done ${e} --text "<what you checked>"\``,"finishCommand"),ne=d((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 se({route:t,key:e,ref:s,title:h,notes:r,thread:l,worktree:a,base:u,rules:c=[],links:p=[]}){const o=g(t);return[`You are the headless builder for card ${s} (${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.`,...ne(o,e),"",r?`Spec: the card's notes, ${r}, 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.",`${x(l)} 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.`,"",...T(p),...R(c),"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 "${s}: <what the card now does>".`,"",`To finish, run ${D({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.",...W({route:t,key:e,worktree:a,base:u}),"","Never push."].join(`
|
|
2
|
+
`)}d(se,"builderBrief");function ae({route:t,key:e,ref:s,title:h,thread:r,worktree:l,base:a,answers:u=[]}){const c=g(t);return[`You are the headless lander for card ${s} (${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 ${l}, never restart the hub or a board server, and never push.`,"",`1. Run \`${c} builder start ${e} --kind build --label Lander --phase landing --progress "taking up the verified build"\`. If it refuses, stop.`,`2. Report progress with \`${c} 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(p=>`- ${p.ask} "${p.question}": ${p.answer}`)]:[],"",x(r),"",`To finish, run ${D({route:t,key:e})}.`,...W({route:t,key:e,worktree:l,base:a}),"","Never push."].join(`
|
|
3
|
+
`)}d(ae,"landerBrief");function ie({route:t,key:e,ref:s,title:h,thread:r,worktree:l,base:a,pr:u}){const c=g(t);return[`You are the headless rebase run for card ${s} (${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 ${l}, 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 \`${P(`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.`,"",x(r),"",`To finish, run ${D({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
|
+
`)}d(ie,"rebaseBrief");function he({route:t,key:e,ref:s,title:h,notes:r,thread:l,kind:a,repo:u,rules:c=[],links:p=[],text:o,files:i=[],question:n,note:f,choice:m}){const w=g(t),b=a==="grill";return[`You are the headless ${b?"grill":"prototype"} planner for card ${s} (${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 ${b?"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: ${r?`the card's notes, ${r}, all sections, where later sections override earlier ones; `:"the card has no notes file yet; "}its thread, ${l}, 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.`,b?`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, its context listing each proposed card with its title, its scope and the files it touches, and which cards build side by side and which after another; 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 ${b?"grill":"prototype"}, writing: "${o}"`]:[],...i.length?[` The owner attached: ${i.map(I=>I.path).join(", ")}.`]:[],...n?[` The owner asked for prototypes of question ${n}${f?`, noting "${f}"`:""}${m?`, leaning to option ${m}`:""}: draw that question's next round, its question naming round_of ${n}.`]:[],`5. Record what you learned in the card's notes, naming each answered question's id: write it in ${oe}, then run ${re(w,e,`${b?"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.`,...b?[`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.`]:[],"",...T(p),...R(c,"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
|
+
`)}d(he,"plannerBrief");function de({route:t,key:e,ref:s,title:h,notes:r,thread:l,repo:a,agent:u,rules:c=[],links:p=[],text:o,files:i=[]}){const n=g(t);return[`You are the headless visual agent for card ${s} (${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 \`${n} builder start ${e} --kind visual --agent ${u}\`. If it refuses, stop.`,`2. Gather what the page needs: ${r?`the card's notes, ${r}; `:""}its thread, ${l}, 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 \`${n} 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.","",...T(p),...R(c,"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 \`${n} builder done ${e} --agent ${u}\`.`,"","Never push."].join(`
|
|
6
|
+
`)}d(de,"visualBrief");function le({route:t,key:e,ref:s,title:h,notes:r,thread:l,agent:a,task:u,writes:c,cwd:p,rules:o=[],links:i=[]}){const n=g(t);return[`You are the headless helper ${a} on card ${s} (${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.`,c?`Work only in ${p}, your own worktree, branched from the card's: commit your work there with \`git -c core.commentChar=';' commit -F <file>\`, the subject "${s}: <what it does>". The card's builder merges your branch, so leave nothing uncommitted.`:`Read and run in ${p}; change no files there and commit nothing.`,"","The task:",u,"",`1. Run \`${n} builder start ${e} --kind helper --agent ${a}\`. If it refuses, stop.`,`2. Report progress with \`${n} 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.",r?` The card's notes, for context: ${r}.`:"",` ${x(l)}`,"",...T(i),...R(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 \`${n} builder done ${e} --agent ${a} --text "<your hand-back: what you did or found, ${c?"what you committed, ":""}and any decision you made>"\`.`,"","Never push."].filter((f,m,w)=>f!==""||w[m-1]!=="").join(`
|
|
7
|
+
`)}d(le,"helperBrief");const ce=6e4;function ue(t,{starts:e=L}={}){const s=t.filter(r=>r.pid&&r.at).map(r=>r.pid),h=s.length&&e(s)||new Map;return t.filter(r=>{const l=h.get(r.pid);return l!==void 0&&l<=Date.parse(r.at)&&l>=Date.parse(r.at)-ce})}d(ue,"launchedAgents");function xe(t,{starts:e=L,kill:s=d((r,l)=>process.kill(-r,l),"kill"),killAfter:h=5e3}={}){const r=ue(t,{starts:e});for(const{pid:l}of r){try{s(l,"SIGTERM")}catch{continue}setTimeout(()=>{try{s(l,"SIGKILL")}catch{}},h).unref()}return r.length}d(xe,"stopAgents");async function Ie(t,{grace:e=5e3}={}){const s=G(["-A","-o","pid=,ppid=,pgid=,args="]);if(s===null)throw new V("ps gave no answer, so nothing was stopped; run it again");const h=s.split(`
|
|
8
|
+
`).map(o=>/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/.exec(o)).filter(Boolean).map(([,o,i,n,f])=>({pid:Number(o),ppid:Number(i),pgid:Number(n),args:f})),r=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)!r.has(i.pid)&&r.has(i.ppid)&&(r.add(i.pid),o=!0)}const l=h.find(o=>o.pid===process.pid)?.pgid,a=h.filter(o=>r.has(o.pid)&&o.pgid>1&&o.pgid!==l),u=[...new Set(a.map(o=>o.pgid))],c=d(o=>{for(const i of u)try{process.kill(-i,o)}catch{}},"signal");c("SIGTERM");const p=Date.now()+e;for(;a.some(o=>j(o.pid))&&Date.now()<p;)await new Promise(o=>setTimeout(o,50));return a.some(o=>j(o.pid))&&c("SIGKILL"),a.map(({pid:o,args:i})=>({pid:o,args:i}))}d(Ie,"stopRuns");const j=d(t=>{try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},"pidAlive");async function qe(t,e,{launch:s,handBack:h,alive:r=j,held:l=d(()=>!1,"held"),stopped:a=new Set,limitedUntil:u=d(()=>null,"limitedUntil"),atLimit:c=d(async()=>{},"atLimit"),now:p=Date.now()}){const o={};for(const[i,n]of Object.entries(t)){if(!e.has(i))continue;if(a.has(i)){o[i]={...n,handedBack:!0};continue}if(n.pid!==null&&r(n.pid)||n.handedBack){o[i]=n;continue}const f={key:i,...n.kind?{kind:n.kind}:{},...n.model?{model:n.model}:{}},m=n.pid!==null?u(n):null;if(m){await c(f,m),o[i]={...n,pid:null,until:m};continue}if(l(n.kind??"claude")||n.until&&p<Date.parse(n.until)){o[i]=n;continue}if(n.pid!==null&&n.relaunched){await h(f),o[i]={...n,handedBack:!0};continue}const{key:w,...b}=f;o[i]={...b,...await s(f),relaunched:n.pid!==null||!!n.relaunched}}return o}d(qe,"reviveBuilders");const pe=d((t,e)=>S.join(Y.homedir(),".claude","kickflip","logs",`${e}-${t}-${new Date().toISOString().replace(/[:.]/g,"-")}.log`),"logFile");async function Se(t,{key:e,kind:s="claude",model:h,agent:r="main",text:l,files:a,question:u,note:c,choice:p,task:o,writes:i,worktree:n},{lander:f=!1}={}){const m=await Q(t,e),w=K(t)?.route??S.basename(t),b=[...U(),...await X(t)].map(O=>O.text),{base:I,repo:q}=_(t),y=Z({kind:s}),v=s===J,A=!y&&!v&&!f&&m.rebasePR!==null,N=s===ee,B=y?q:v?n??m.worktree??q:m.worktree,$={...m,route:w,base:I,repo:q,rules:b,kind:s,agent:r,text:l,files:a,question:u,note:c,choice:p,task:o,writes:i,cwd:B,pr:m.rebasePR},C=N?"Visual agent":v?`Helper ${r}`:y?"Planner":f?"Lander":A?"Rebase run":"Builder",M=N?de($):v?le($):y?he($):f?ae($):A?ie($):se($),k=await H({kind:y||v?"claude":s,model:h,cwd:B,site:t,prompt:M,log:pe(e.split("/")[1],C.split(" ")[0].toLowerCase())});return await z(t,e,k.sessionId,k.pid,r,S.basename(k.log)),k}d(Se,"launchBuilder");export{te as BOARD_CLI,se as builderBrief,le as helperBrief,ae as landerBrief,Se as launchBuilder,ue as launchedAgents,j as pidAlive,he as plannerBrief,ie as rebaseBrief,qe as reviveBuilders,xe as stopAgents,Ie as stopRuns,de as visualBrief};
|