@lovek4d/kickflip 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CONTEXT.md +47 -42
  2. package/README.md +1 -1
  3. package/SKILL.md +16 -16
  4. package/bin/kickflip.mjs +26 -17
  5. package/bin/wait-events.mjs +2 -2
  6. package/board/agents.mjs +2 -0
  7. package/board/bin/board.mjs +65 -18
  8. package/board/domain.mjs +7 -7
  9. package/board/finish.mjs +4 -4
  10. package/board/headless.mjs +5 -4
  11. package/board/on-host.mjs +1 -1
  12. package/board/public/app-asks.js +6 -6
  13. package/board/public/app-banner.js +7 -13
  14. package/board/public/app-cards.js +51 -27
  15. package/board/public/app-core.js +26 -8
  16. package/board/public/app-header.js +2 -1
  17. package/board/public/app-lanes.js +55 -23
  18. package/board/public/app-needs.js +129 -4
  19. package/board/public/app-reader.js +1 -1
  20. package/board/public/app-snapshot.js +6 -5
  21. package/board/public/app-threads.js +70 -59
  22. package/board/public/app.js +38 -8
  23. package/board/public/attach.js +2 -2
  24. package/board/public/dialogs.js +9 -39
  25. package/board/public/hub-kit.js +4 -2
  26. package/board/public/linear-key.js +46 -35
  27. package/board/public/new-task.js +17 -38
  28. package/board/public/prototype-kit.js +28 -3
  29. package/board/public/prototype-switcher.js +42 -107
  30. package/board/public/shell.js +7 -5
  31. package/board/public/sidebar.js +44 -5
  32. package/board/public/style.css +108 -37
  33. package/board/public/ui-cards.js +41 -30
  34. package/board/public/ui-header.js +2 -2
  35. package/board/public/ui-order.js +12 -10
  36. package/board/public/ui-questions.js +25 -38
  37. package/board/public/ui-sidebar.js +18 -12
  38. package/board/public/ui-threads.js +3 -3
  39. package/board/public/ui.js +40 -8
  40. package/board/public/view-hub-settings.js +11 -10
  41. package/board/public/view-hub.js +17 -3
  42. package/board/public/view-questions.js +142 -199
  43. package/board/public/view-settings.js +191 -72
  44. package/board/server.mjs +19 -20
  45. package/board/store.mjs +20 -15
  46. package/board/transcript.mjs +2 -0
  47. package/board/worktree.mjs +24 -20
  48. package/hooks-plugin/hooks/board-data-gate.mjs +50 -0
  49. package/hooks-plugin/hooks/hooks.json +9 -0
  50. package/hub/boards.mjs +4 -4
  51. package/hub/front-door.mjs +5 -5
  52. package/hub/github.mjs +3 -3
  53. package/hub/hub.mjs +11 -11
  54. package/hub/linear.mjs +1 -2
  55. package/hub/live.mjs +2 -2
  56. package/hub/locks.mjs +1 -1
  57. package/hub/pr-report.mjs +2 -2
  58. package/hub/presence.mjs +1 -1
  59. package/hub/push.mjs +2 -2
  60. package/hub/readiness.mjs +1 -2
  61. package/hub/review-send.mjs +1 -0
  62. package/hub/secrets.mjs +2 -0
  63. package/hub/self-restart.mjs +2 -0
  64. package/hub/sessions.mjs +2 -2
  65. package/hub/share.mjs +1 -0
  66. package/hub/slack.mjs +2 -2
  67. package/hub/stream.mjs +10 -13
  68. package/hub/try.mjs +6 -6
  69. package/hub/upgrade.mjs +1 -1
  70. package/hub/usage.mjs +3 -3
  71. package/hub/views.mjs +1 -1
  72. package/package.json +2 -1
  73. package/shared/audit.mjs +4 -0
  74. package/shared/fake-gh.mjs +17 -4
  75. package/shared/service.mjs +4 -4
  76. package/shared/usage-gate.mjs +1 -1
package/board/domain.mjs CHANGED
@@ -1,8 +1,8 @@
1
- var ht=Object.defineProperty;var d=(e,t)=>ht(e,"name",{value:t,configurable:!0});import{routeRecord as q}from"../hub/routes.mjs";import yt from"node:fs";import{ticketBadge as Ye,ticketIn as St}from"./tickets.mjs";import{reviewLinks as vt,reviewTime as bt,reviewersOf as Ot}from"./review.mjs";import{remoteFromInput as xt}from"../hub/repos.mjs";import{reviewsOf as $t,reviewNeeds as At,reviewActions as Bt}from"./auto-review.mjs";import{cardPRs as Et,hasPR as Te,leastReady as qt,prKeyOf as _t,prURL as Rt}from"../shared/card-prs.mjs";import ze from"node:vm";import{checkWords as It,parseCheck as Dt}from"../shared/owner-check.mjs";const Le=ze.createContext({});for(const e of["ui-enums.js","ui-order.js"])ze.runInContext(yt.readFileSync(new URL(`./public/${e}`,import.meta.url),"utf8"),Le);const{BUTTON:Y,ACTION_KIND:R,BUILDER_KIND:Re,PR_STATE:oe}=Le.BoardUI,{laneOrder:Ct}=Le.BoardUI,Mt=["item-message","mark-ready","grill-more","prototype-request","reask-request"],rs=["planned","waiting","building","fixing","checking","held","merged","done","dropped"],Nt=30*6e4,Je="build-refused",Se=Object.freeze({ask:"builder-ask",answer:"builder-answer"}),Tt=864e5,de=d(e=>e.lane==="done"||e.lane==="asks","closedLane"),Lt=d(e=>`wave:${e}`,"waveFold"),Pt=7*Tt,Ze=d((e,t)=>({id:e,url:t?.workspace?`https://linear.app/${t.workspace}/issue/${e}`:null}),"linearRef"),jt=d((e,t)=>String(e).replace(/^S(\d+)$/,`${t||"INT"}-$1`),"internalRef"),Pe=d((e,t,s)=>St(s,t.ticket)?t.ticket:e.internal===!0?jt(t.id,s?.prefix):t.id,"refOf"),Ut=d((e,t,s,o)=>Ye(e||(t?{source:"internal",prefix:"INT"}:null),s,o)||(t?{id:String(t),url:null,source:null}:null),"ticketOf");function Wt(e,t,s,o,r,a){const p=(e.status||"").toLowerCase();return p==="merged"||p==="done"||p==="dropped"||!r&&(t?.state==="MERGED"||t?.state==="CLOSED")?"done":s||p==="checking"?"progress":o?"review":t?.state==="OPEN"?t.checks?.state==="fail"&&(!t.isDraft||a)?"progress":"review":t?"progress":"todo"}d(Wt,"laneOf");function Ft(e,t){return e?.state==="MERGED"||t.status==="merged"||t.merged_at?oe.merged:e?.state==="CLOSED"?oe.closed:e?.state==="OPEN"?e.isDraft?oe.draft:oe.open:null}d(Ft,"prStateOf");const je=d(e=>{const t=(e.status||"").toLowerCase();return t==="dropped"||e.pr?.state==="CLOSED"&&t!=="merged"&&t!=="done"},"droppedCard");function Kt(e){if(!e.some(o=>o.kind==="work")||e.some(o=>o.lane!=="done"))return null;const t=e.filter(o=>o.lane==="done"),s=t.filter(je).length;return{merged:t.length-s,dropped:s}}d(Kt,"finishedOf");function Qt(e,t,s){return Object.fromEntries(e.map(o=>{const r=q(t?.reviews,o.github),a=r==="APPROVED"?"approved":r==="CHANGES_REQUESTED"?"changes":Object.hasOwn(s,o.name)?"sent":"unsent";return[o.name,{state:a,since:a==="sent"?q(s,o.name):null,github:o.github||null}]}))}d(Qt,"reviewOf");function Gt(e,t,s,o,r,a,{held:p,needsApproval:c}){return s?.kind===Re.install?"builder":o==="checking"?"checking":s?"builder":p&&e==="review"?"merge":r&&e==="review"?"owner":e==="review"&&t?.state==="OPEN"&&t.isDraft?a?"ci":"ready":e==="review"||e==="stale"?et(t,c)?"merge":"reviewers":null}d(Gt,"waitsOnOf");const et=d((e,t)=>e?.reviewDecision==="APPROVED"||!t&&!["REVIEW_REQUIRED","CHANGES_REQUESTED"].includes(e?.reviewDecision),"reviewed"),Ie=/(^|\/)prototype-[\w-]+\.html/,Vt={reviewers:"Waiting for PR reviewers",merge:"Approved, merges once CI and the merge state allow",ci:"Marked ready for review once CI passes"},De={waiting:"Approved, Merge shows once CI and the merge state allow",ready:"Approved and green: tap Merge",merging:"Merging"},Ue={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"},Ht=d(e=>`Verified: tap Merge to land it on ${e}`,"heldNext"),Xt="Fix the failing CI",tt="Tap Done once it is settled",Yt=["status","agent","ask-link",Se.answer],nt=d(e=>(e.who==="claude"||e.via==="github")&&!Yt.includes(e.kind),"countsUnread"),zt=/^(?:Not merged yet: |Lander launched headless )/;function Jt({slug:e,wave:t,it:s,order:o,prs:r,repo:a,remote:p,base:c,builder:u,reachedPhase:f,agents:k,worktree:l,eta:h,thread:O,events:m,working:I,said:G,askedAt:_,topicItems:V,boardReviewers:H,now:U,bumpedAt:i,holdAsk:$,closedAt:S,mergeAt:B,autoMerge:re,skipDraft:Z,tickets:T}){const ee=r.map(w=>({repo:w.repo,number:w.number,url:Rt(w),...w.gh||{},status:Ft(w.gh,s)})),W=qt(r.map(w=>w.gh)),N=r[W]?.gh||null,F=ee[W]?.status??null,j=!!S&&String(S)>String(s.status_at||"");j&&s.status!=="merged"&&(s={...s,status:"done"});const Oe=[j&&S,s.status_at,s.merged_at,...r.map(w=>w.gh?.mergedAt)].filter(Boolean).map(String).sort().pop()||null,L=String(Oe||""),D=["done","merged"].includes(s.status)||F===oe.merged&&s.status!=="dropped"?[...G.filter(w=>w.kind==="item-message").map(w=>w.ts),..._].map(String).filter(w=>w>L).sort().pop():void 0,pe=s.owner_step&&!j&&s.status!=="dropped"?String(s.owner_step):null,fe=["done","merged"].includes(s.status)||F===oe.merged;D&&(s={...s,status:void 0,next:void 0});const xe=!!D&&G.some(w=>String(w.ts)>L&&(w.state==="waiting"||w.state==="working")),ae=`${e}/${s.id}`,ge=Ot(t,H),$e=Object.fromEntries(Object.entries(vt(t,s,ae,V)).map(([w,Q])=>[w,bt(Q.ts)])),P=Object.values($e).filter(Boolean).sort()[0]||null,te=[...O.map(w=>w.ts),...m.map(w=>w.ts)].sort().pop()||null,Ae=[...O.filter(w=>nt({...w,who:w.who||"claude"})).map(w=>w.ts),...m.map(w=>w.reply?.at)].filter(Boolean).sort(),X=!Te(s)&&s.pushed?.branch?{branch:s.pushed.branch,at:s.pushed.at||null,host:p?.host||null}:null,K=!Te(s)&&s.merge_ready?.branch?{branch:s.merge_ready.branch,at:s.merge_ready.at||null,base:c}:null;let A=Wt(s,N,k.some(w=>w.started&&!w.done&&z(w)),X||K,!!D,Z);D&&A==="todo"&&(A="progress"),A==="review"&&P&&U-Date.parse(P)>Pt&&(A="stale");const le=!!pe&&fe&&A==="done";le&&(A="review");let M=Gt(A,N,u,(s.status||"").toLowerCase(),X,Z,{held:K,needsApproval:ge.length>0});const ke=M==="builder"&&N?.state==="OPEN"&&!N.isDraft,me=A==="progress"&&!M&&N?.state==="OPEN"&&(!N.isDraft||Z),ne=le||!!D&&A==="progress"&&!M&&!me&&!xe;ne&&(M="owner");const we=$&&String($.ts)>String(s.held_at||""),Be=A==="todo"&&(we?!!$.data.hold:s.status==="held"||!!s.held),Ce=Be&&(we?$.data.until:s.pick_up_at)||null,se=A==="todo"||A==="progress",Ee=k.filter(z).map(w=>String(w.started||"")).filter(Boolean).sort()[0]||"",Me=i&&!(Ee&&String(i)<Ee),qe=O.filter(w=>(w.who||"claude")==="claude"&&w.kind!=="status"&&!zt.test(w.text||"")).map(w=>String(w.ts)).sort().pop()||"",ie=[B,K&&s.merge_ready.tapped].filter(Boolean).map(String).sort().pop(),he=M==="merge"&&!!ie&&ie>qe,ye=O.filter(w=>w.kind==="status"&&String(w.ts)>String(ie)).sort((w,Q)=>String(w.ts).localeCompare(String(Q.ts))).at(-1),n=ye?.text.startsWith("Waiting for ")?`${De.merging} \xB7 ${ye.text[0].toLowerCase()}${ye.text.slice(1)}`:De.merging,g=O.filter(w=>w.kind!=="status").sort((w,Q)=>String(w.ts).localeCompare(String(Q.ts))).at(-1),y=A==="todo"&&g?.kind===Je?g.text:null,x=D||k.filter(z).map(w=>w.started).filter(Boolean).map(String).sort().pop()||s.queued_at||["building","fixing","checking"].includes(String(s.status||"").toLowerCase())&&s.status_at||null,b=N?.reviewDecision==="APPROVED",E=X&&M==="owner"?`merge ${X.branch} into ${c}`:K&&M==="merge"?he?n:Ht(c):M==="merge"&&!re?he?n:(b?De:Ue).waiting:M==="merge"&&!b?Ue.auto:Vt[M],C=F===oe.draft?`Review draft PR #${ee[W].number}`:null;return{key:ae,kind:"work",order:o,wave:e,waveTitle:t.title||e,id:s.id,ref:Pe(t,s,T),title:s.title,status:s.status||null,created:s.created||null,reviewSince:s.review_since||P||s.merge_ready?.at||s.pushed?.at||s.created||null,progressSince:x,closedAt:A==="done"?Oe:null,internal:t.internal===!0,repo:t.internal===!0&&!t.repo?null:a,lane:A,waitsOn:M,builder:M==="checking"?null:u,reachedPhase:f,agents:k,worktree:l??null,eta:h,working:I,reopened:!!D,awaitsDone:ne,ownerStep:ne?pe:null,ownerCheck:ne&&pe&&s.owner_check?{words:It(Dt(s.owner_check.check)),broken:s.owner_check.broken||null}:null,queuedAt:A!=="done"&&s.queued_at||null,queued:!1,deps:s.deps||[],held:Be,heldUntil:Ce,risky:!!s.risky,bumpable:se,bumpedAt:se&&Me?i:null,holdable:A!=="done",hasNotes:!!(s.plan||String(s.notes||"").trim()),finishable:A!=="done",merging:he,refusal:y,manualSteps:s.manual_steps||[],fromAsk:s.from_ask||null,next:ke||A==="done"||M==="checking"?null:me?Xt:E||s.next||C||null,branch:s.branch||N?.headRefName||X?.branch||null,pushed:A==="done"||le?null:X,mergeReady:A==="review"?K:null,ticket:T?.source==="linear"&&!s.ticket&&s.linear?.length?null:Ut(T,s.ticket,s.ticket||(t.internal?Pe(t,s,T):s.linear?.[0]),{repo:a,key:ae}),ticketSource:T?.source||null,linear:(s.linear||[]).map(w=>T?.source==="linear"&&Ye(T,w,{key:ae,repo:a})||Ze(w,T)),pr:ee[W]||null,prs:ee,reviewers:ge.map(w=>w.name),review:Qt(ge,N,$e),inReviewSince:P,threadCount:O.length+m.length,lastTs:te,othersAt:Ae,grilling:lt("grill",m,k,_),prototyping:lt("prototype",m,k,_),state:s.state||null,updatedAt:N?.mergedAt||N?.updatedAt||s.merged_at||u?.at||te||null,ask:null,fold:null,action:null,install:A==="done"?null:en(s.install,N),waitFacts:Zt(s,{agents:k,thread:O,events:m,refusedAt:y?g.ts:null})}}d(Jt,"workItem");function Zt(e,{agents:t,thread:s,events:o,refusedAt:r}){const a=new Set(s.filter(f=>f.kind===Se.answer).map(f=>f.ask)),p=s.filter(f=>f.kind===Se.ask&&!a.has(f.ask)).sort((f,k)=>String(f.ts).localeCompare(String(k.ts)))[0],c=d(f=>o.filter(k=>Fe(k,f)).pop()?.ts||null,"requestAt"),u=s.filter(f=>(f.who||"claude")==="claude"&&!["status","agent",Je].includes(f.kind)).map(f=>f.ts);return{statusAt:e.status_at||null,next:e.next||null,ask:p?{at:p.ts,text:p.text}:null,grillAt:c("grill"),prototypeAt:c("prototype"),refusedAt:r,unverified:t.some(f=>f.calls.some(k=>!f.verified||String(k.at)>String(f.verified.at))),writes:[...u,...t.flatMap(f=>[f.verified?.at,f.started])].filter(Boolean).map(String).sort()}}d(Zt,"waitFactsOf");function en(e,t){if(!e?.url)return null;const s=e.sha?String(e.sha).toLowerCase():null,o=t?.headRefOid?String(t.headRefOid).toLowerCase():null;return{url:e.url,label:e.label||null,builtAt:e.built_at||null,sha:s,older:!!(s&&o&&!o.startsWith(s))}}d(en,"installOf");function tn(e,{needsApproval:t=!0}={}){if(e?.state!=="OPEN")return[`PR is ${String(e?.state||"unknown").toLowerCase()}`];const{state:s,pending:o,failing:r}=e.checks||{};return[e.isDraft&&"it is a draft",!et(e,t)&&`review: ${String(e.reviewDecision||"none").toLowerCase().replace(/_/g," ")}`,s==="fail"&&`failing: ${r?.length?r.join(", "):"a check"}`,s==="pending"&&`pending: ${o?J(o,"check"):"checks"}`,e.mergeStateStatus!=="CLEAN"&&`merge state: ${String(e.mergeStateStatus||"unknown").toLowerCase()}`].filter(Boolean)}d(tn,"mergeBlockers");const nn=d((e,t)=>!tn(e,{needsApproval:t}).length,"mergeable");function sn(e,t,s){if(e.held||de(e))return null;const o=`#item=${encodeURIComponent(e.key)}`;if(st(e)){const r=t.get(e.questions.first);return Ie.test(r?.url||"")?{kind:R.pick,url:`questions.html#${r.id}`,label:"Prototypes ready: pick a take"}:{kind:R.questions,url:`questions.html#${e.questions.first}`,label:`Answer ${J(e.questions.open,"question")}`}}return e.waitsOn==="ready"?{kind:R.ready,url:e.pr.url,label:`Review draft PR #${e.pr.number}`}:e.kind==="ask"&&e.waitsOn==="owner"?{kind:R.done,url:o,label:e.next||tt}:e.waitsOn==="merge"&&e.manualSteps.length&&!e.mergeReady?{kind:R.steps,url:o,label:"Run the manual steps, then merge"}:e.waitsOn==="merge"&&(!s||e.mergeReady)&&!e.merging&&e.prs.every(r=>["MERGED","CLOSED"].includes(r.state)||nn(r,e.reviewers.length>0))?{kind:R.merge,url:o,label:"Merge"}:null}d(sn,"actionOf");const st=d(e=>!!(e.questions&&e.questions.state!=="resolved"&&e.questions.open>0),"asking"),We=new Set([R.pick,R.questions]);function ot(e){return de(e)?null:st(e)?Y.openQuestions:e.action?.kind===R.done?Y.markDone:null}d(ot,"actionButtonOf");const on=d(e=>e.kind==="work"&&e.lane==="todo"&&!e.action&&!e.unpicked,"buildableOf"),rn=d((e,t)=>/^item:/.test(e.topic||"")&&Ie.test(e.url||"")&&!(e.options||[]).some(s=>s.id===t),"picksNoTake");function an(e,t){const s=e.filter(a=>a.topic===`item:${t}`),r=[...s.filter(a=>Ie.test(a.url||"")).flatMap(a=>a.answers.map(p=>({q:a,a:p,again:rn(a,p.choice)}))),...s.filter(a=>a.request).map(a=>({q:a,a:a.request,again:!0}))].sort((a,p)=>String(a.a.ts).localeCompare(String(p.a.ts))).at(-1);return r?.again?{id:r.q.id,note:r.a.note.replace(/\s+/g," ").trim()}:null}d(an,"noTakePicked");const ln="Prototype again",dn=Object.freeze({[R.pick]:Y.openQuestions,[R.questions]:Y.openQuestions,[R.ready]:Y.github,[R.steps]:Y.github,[R.merge]:Y.merge,[R.done]:Y.markDone});function un(e,t,s){if(e.action=sn(e,t,s),e.action?.kind===R.questions&&e.questions.fromAsks){Object.assign(e,{action:null,waitsOn:"owner",next:e.action.label,actionButton:ot(e),resolvedBy:null});return}e.awaitsDone&&=!e.action,e.awaitsDone||Object.assign(e,{ownerStep:null,ownerCheck:null}),e.actionButton=ot(e),e.resolvedBy=dn[e.action?.kind]||null,e.action?.kind===R.merge&&!e.mergeReady&&(e.next=(e.pr?.reviewDecision==="APPROVED"?De:Ue).ready),e.awaitsDone&&Object.assign(e,{lane:"review",next:e.ownerStep||tt,bumpable:!1,bumpedAt:null});const o=e.lane==="todo"||e.waitsOn==="ready"||e.lane==="progress"&&e.waitsOn==="owner";if(!e.action||!o)return;const r=e.lane==="todo"&&We.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})}d(un,"placeOwnerWait");const rt=d(e=>e.queuedAt||e.agents.some(z)||["building","fixing"].includes(String(e.status||"").toLowerCase()),"started"),at="none set yet";function as(e,t){const s=String(e.status||"").toLowerCase();if(e.next||Te(e)||e.pushed||e.held||e.queued_at||["held","checking","done","merged","dropped"].includes(s))return!1;const o=t.filter(r=>r?.started);return!o.some(r=>!r.done)&&rt({status:s,agents:o})}d(as,"owesNext");function cn(e,t=new Date){const s=new Date(e),o=s.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return s.toDateString()===t.toDateString()?o:`${s.getMonth()+1}/${s.getDate()} ${o}`}d(cn,"askedLabel");function pn(e,t,s,o,r,a,p){const c=t.find(S=>S.kind==="ask"&&S.eventId===e.id),u=c.files,f=(c.text||"").trim().split(`
2
- `)[0]||u.map(S=>S.name).join(", ")||"Ask",k=c.state==="replied"||c.state==="answered",l=r?.state==="progress"&&!(String(a||"")>String(r.at||"")),h=!l&&(!!r||!!a),O=k&&!h&&!l&&p.open>0,m=k&&!h&&!l&&!O&&p.answered>0,I=h||k&&!l&&!O&&!m,G=k&&!o&&!r?.moved&&[...t.filter(S=>S.who==="claude"&&S.kind!=="ask-link"&&S.kind!=="status").map(S=>S.ts),...t.map(S=>S.reply?.at)].filter(Boolean).sort().pop()||null,_=I||l||O||m,V=t.some(S=>S.who==="love"&&S.kind!=="ask"&&(S.state==="waiting"||S.state==="working")),H=_?"answered":c.state,U=_?null:s||null,i=[...t.filter(nt).map(S=>S.ts),...t.map(S=>S.reply?.at)].filter(Boolean).sort(),$=[...t.map(S=>S.ts),...i,...l?[r.at]:[]].filter(Boolean).sort().pop();return{key:`ask:${e.id}`,kind:"ask",order:0,wave:null,waveTitle:null,id:e.id,ref:_?cn(e.ts):"New",isNew:!_,title:f,status:null,internal:!1,repo:null,lane:l?"progress":I?"asks":"todo",waitsOn:l&&!V?"owner":null,builder:null,agents:[],eta:null,working:t.some(S=>S.state==="working"),deps:[],held:!1,risky:!1,bumpable:!_,bumpedAt:U,manualSteps:[],fromAsk:null,from:null,next:l&&r.next||null,hasNotes:!1,branch:null,finishable:_&&!I,linear:[],pr:null,prs:[],reviewers:[],review:{},inReviewSince:null,reviewSince:null,progressSince:l&&r.at||null,closedAt:null,threadCount:t.length,lastTs:$,othersAt:_?i:[],grilling:!1,prototyping:!1,created:e.ts,updatedAt:_?$:e.ts,ask:{eventId:e.id,state:H,askedAt:e.ts,bumpedAt:U,edited:!!c.edited,canEdit:!_,text:c.text,files:u,answerAt:G,from:c.from||null},fold:null,action:null}}d(pn,"askItem");const fn=new Set(["grill","prototype"]),ue=d(e=>fn.has(e.kind),"plans"),z=d(e=>!ue(e),"builds"),gn={grill:"preheating",prototype:"prototyping"},kn={grill:"grill-more",prototype:"prototype-request"},Fe=d((e,t)=>e.kind===kn[t]&&!e.data?.question,"isRequest");function lt(e,t,s,o){if(s.some(a=>a.kind===e&&a.started&&!a.done))return!0;const r=t.filter(a=>Fe(a,e)).pop();return!!(r&&!r.reply&&!o.some(a=>String(a)>String(r.ts))&&!s.some(a=>a.kind===e&&a.done&&String(a.started)>=String(r.ts)))}d(lt,"planningOf");const ls=30*6e4;function is(e,t){const s=[];for(const o of e.items){if(de(o)||(o.agents||[]).some(a=>a.kind==="prototype"&&a.started&&!a.done))continue;const r=o.prototyping&&t.filter(a=>a.data?.key===o.key&&Fe(a,"prototype")).pop();r&&s.push({key:o.key,request:r.id,since:r.ts});for(const a of e.owner.filter(p=>p.topic===`item:${o.key}`&&p.state==="requested"))s.push({key:o.key,request:a.request.id,question:a.id,since:a.request.ts})}return s}d(is,"prototypeWaits");function Ke(e={}){return Object.entries(e).filter(([,t])=>t&&typeof t=="object").map(([t,s])=>({name:t,kind:it(s.kind)||null,model:s.model||(s.kind==="opus"||s.kind==="sonnet"?s.kind:null),label:s.label||null,started:s.started||null,eta:s.done?null:s.eta||null,done:s.done||null,calls:Array.isArray(s.calls)?s.calls:[],verified:s.verified||null})).sort((t,s)=>String(t.started||"").localeCompare(String(s.started||""))||t.name.localeCompare(s.name))}d(Ke,"agentsOf");function mn(e={}){return Object.values(e).filter(t=>t?.worktree?.path).sort((t,s)=>String(t.started||"").localeCompare(String(s.started||""))).at(-1)?.worktree.path??null}d(mn,"worktreeOf");function wn(e,t=[]){const s=e.filter(z).map(o=>String(o.started||"")).filter(Boolean).sort().pop();return s===void 0?null:t.filter(o=>o.kind==="status"&&o.phase&&!o.planner&&String(o.ts)>=s).sort((o,r)=>String(o.ts).localeCompare(String(r.ts))).pop()?.phase||null}d(wn,"reachedPhaseOf");function hn(e,t=[],s){const o=e.filter(l=>l.started&&!l.done),r=o.every(ue),a=r?o:o.filter(z),p=a.map(l=>String(l.started||"")).sort()[0];if(p===void 0)return null;const c=t.filter(l=>l.kind==="status"&&String(l.ts)>=p&&(r||!l.planner)).sort((l,h)=>String(l.ts).localeCompare(String(h.ts))).pop(),u=a.some(l=>l.kind===Re.install)?Re.install:it(a.at(-1).kind),f=c?.ts||p;return{progress:c?c.phase||c.planner?c.text.replace(": "," \xB7 "):c.text||null:r?gn[u]:null,phase:c?.phase||null,at:f,kind:u,planner:r,silentSince:f,stalled:s-Date.parse(f)>=Nt}}d(hn,"builderOf");const Qe={opus:"Claude Opus",sonnet:"Claude Sonnet",codex:"Codex"},yn=d(({model:e,kind:t})=>Qe[e]||Qe[t]||(t==="claude"?Qe.opus:null),"modelName"),it=d(e=>e==="opus"||e==="sonnet"?"claude":e,"providerOf");function Ge(e){const t=yn(e),{kind:s}=e,o=e.label?.replace(/\bbuilder\b/,"implementer").replace(/\bBuilder\b/,"Implementer"),r=d(p=>p[0].toLowerCase()+p.slice(1),"lower");if(t&&ue(e))return`${t} ${s}`;if(t)return`${t} ${r(o?.replace(/^(?:claude\s+)?(?:opus|sonnet|codex)\b\s*/i,"")||"implementer")}`;const a=s?s[0].toUpperCase()+s.slice(1):"";return a?o?o.toLowerCase().includes(s.toLowerCase())?o:`${a} ${r(o)}`:a:o||"Implementer"}d(Ge,"agentName");const dt=d((e,t)=>!!e.resolved&&(!e.resolved_at||String(e.resolved_at)>=String(t)),"resolvedSince");function Sn(e,t,s=[],o=[]){const r=t.filter(l=>l.data?.id===e.id),a=r[r.length-1]||null,p=!!(e.resolved&&e.resolved_at&&a&&String(a.ts)>e.resolved_at),c=e.resolved&&!p,u=s.filter(l=>l.data?.question===e.id&&String(l.ts)>String(a?.ts||"")).at(-1),f=c?o.filter(l=>l.data?.question===e.id&&String(l.ts)>String(e.resolved_at||"")).at(-1):null,k=c?"resolved":u?"requested":a?a.reply?"replied":"answered":"open";return{...e,state:k,request:u?{id:u.id,ts:u.ts,note:u.data.note||"",choice:u.data.choice||null}:null,reask:f?{id:f.id,ts:f.ts}:null,answers:r.map(l=>({ts:l.ts,choice:l.data.choice||null,note:l.data.note||"",files:l.data.files||[],reply:l.reply,acted:dt(e,l.ts)}))}}d(Sn,"ownerQuestion");const ce=d(e=>e.round??(Ie.test(e.url||"")?1:0),"roundOf");function vn(e,t){const s=d((o,r)=>o.confirm_of||(o.options||[]).some(a=>a.id===r.choice),"settles");return e.filter(o=>ce(o)===t&&o.answers.length).map(o=>[o,o.answers.at(-1)]).filter(([o,r])=>s(o,r)).map(([,o])=>o).sort((o,r)=>String(o.ts).localeCompare(String(r.ts))).at(-1)}d(vn,"roundSettledBy");function bn(e){const t=e.find(r=>r.request&&!e.some(a=>ce(a)>ce(r)));if(t)return{n:ce(t)+1,state:"making"};const s=Math.max(0,...e.map(ce));if(!s)return null;const o=vn(e,s);return o?{n:s,state:"closed",take:o.choice}:e.some(r=>ce(r)===s&&r.state!=="resolved")?{n:s,state:"back"}:null}d(bn,"roundState");const ve=d((e,t,s)=>{const o=e.get(t);o?o.push(s):e.set(t,[s])},"add"),be=d((e,t)=>{const s=new Map;for(const o of e)ve(s,t(o),o);return s},"groupBy");function On(e,t,s=new Set){const o=new Set(e.map(p=>p.id)),r=[...e];t.some(p=>!o.has(p.topic))&&r.push({id:"",title:"Other"});const a=be(t,p=>o.has(p.topic)?p.topic:"");return r.map(p=>{const c=a.get(p.id)||[],u=d(l=>c.filter(h=>h.state===l).length,"count"),f=c.every(l=>l.state==="resolved")||s.has(p.id)&&!u("open"),k=c.length&&f?"resolved":"open";return{...p,state:k,questions:c.map(l=>l.id),open:u("open"),answered:u("answered"),replied:u("replied"),resolved:u("resolved"),round:bn(c)}}).filter(p=>p.questions.length)}d(On,"ownerTopics");const ut={"mark-ready":"Mark ready","grill-more":"grill requested","prototype-request":"prototype requested","reask-request":"re-ask requested"},xn="answers submitted",$n="quick build: no grill, as you asked",An=d((e,t)=>{if(e.kind!=="prototype-request"||!t.has(e.data.question))return e.data.text||(e.data.files?.length?"":q(ut,e.kind))||"";const s=t.get(e.data.question),o=(s.options||[]).find(r=>r.id===e.data.choice);return[s.question,o&&`${o.id}. ${o.label}`,e.data.note].filter(Boolean).join(`
3
- \u2192 `)},"actionText"),Bn=d((e,t)=>e.kind!=="grill-more"&&e.kind!=="prototype-request"?e.kind==="reask-request"?{request:!0}:{}:(e.data.question?t.has(e.data.question):String(e.data.text||"").trim()||e.data.files?.length)?{status:ut[e.kind]}:{request:!0},"requestOf"),Ve=d(e=>[...e.filter(t=>t.who==="claude"&&!["status","agent",Se.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 ct(e,t={}){const s=new Map,o=new Map;for(const k of t.items||[])ve(s,k.topic,k),o.set(k.id,k.topic);const r=new Map,a=new Map,p=new Map,c=new Map,u=new Map,f=new Map;e.forEach((k,l)=>{f.set(k,l),k.data?.key&&Mt.includes(k.kind)&&ve(r,k.data.key,k),k.kind==="owner-answer"&&o.has(k.data?.id)&&ve(a,o.get(k.data.id),k),k.kind==="ask"&&p.set(k.id,k)});for(const k of e.filter(l=>l.kind==="ask-edited").sort((l,h)=>String(l.ts).localeCompare(String(h.ts)))){c.set(k.data?.id,k.data?.text);for(const l of k.data?.files||[])ve(u,k.data?.id,l)}return{byKey:r,answers:a,asks:p,edits:c,editFiles:u,questions:s,order:f}}d(ct,"threadIndex");const He=d((e,t)=>{const s=t.filter(o=>o?.length);return s.length>1?s.flat().sort((o,r)=>e.order.get(o)-e.order.get(r)):[...s[0]||[]]},"inLogOrder"),En=/; its log is \S*\/\.claude\/kickflip\/logs\/([^/\s]+\.log)\.$/,qn=d(e=>{const t=!e.log&&typeof e.text=="string"?En.exec(e.text):null;return t?{...e,text:`${e.text.slice(0,t.index)}.`,log:t[1]}:e},"withLog");function pt(e,{lines:t=[],events:s=[],owner:o={},working:r={},fromAsk:a=null,links:p=[],agents:c={},moved:u=[],index:f=ct(s,o)}){const k=e.startsWith("ask:")?[e.slice(4)]:[a,...u].filter(Boolean),l=[...new Set([e,...k.map(i=>`ask:${i}`)])],h=new Map((f.questions.get(`item:${e}`)||[]).map(i=>[i.id,i])),O=f.answers.get(`item:${e}`)||[],m=new Set([...h.values()].map(i=>i.round_of).filter(Boolean)),I=Ke(c).filter(z).map(i=>String(i.started||"")).filter(Boolean),G=new Set(O.filter(i=>dt(h.get(i.data.id),i.ts)||m.has(i.data.id)||I.some($=>$>String(i.ts))).map(i=>i.id)),_=[...Ke(c).flatMap(i=>[...i.started?[{ts:i.started,who:"claude",kind:"agent",text:`${Ge(i)} started`,finished:!1,eta:i.done?null:i.eta,...ue(i)?{planner:!0}:{}}]:[],...i.done?[{ts:i.done,who:"claude",kind:"agent",text:`${Ge(i)} finished`,finished:!0,eta:null,...ue(i)?{planner:!0}:{}}]:[],...i.calls.length?[{ts:i.done||i.calls.at(-1).at,who:"claude",kind:"calls",text:Ge(i),calls:i.calls.map($=>$.text),verified:i.verified}]:[]]),...t.map(qn).map(i=>({ts:i.ts,who:i.who||"claude",...i.log?{log:i.log}:{},...i.kind==="status"?{kind:"status",...i.planner?{planner:!0}:{}}:{},...Object.values(Se).includes(i.kind)?{kind:i.kind,ask:i.ask}:{},text:i.text||"",html:i.html||null,link:i.link||null,via:i.via||null})),...He(f,l.map(i=>f.byKey.get(i))).map(i=>({ts:i.ts,who:"love",via:"site",kind:i.kind,text:An(i,h),files:i.data.files||[],eventId:i.id,reply:i.reply,...Bn(i,h)})),...O.map(i=>{const $=[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:`${h.get(i.data.id).question}
4
- \u2192 ${$}`,files:i.data.files||[],eventId:i.id,reply:i.reply,status:xn}}),...He(f,[...new Set(k)].map(i=>f.asks.has(i)?[f.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,...u.includes(i.id)?{moved:!0}:{},...typeof i.data?.from?.title=="string"?{from:i.data.from.title}:{}},...i.data?.quick===!0?[{ts:i.ts,who:"love",kind:"quick-build",request:!0,text:$n}]:[],...p.map($=>({ts:i.ts,who:"claude",kind:"ask-link",text:`${$.became?"Became":"Added to"} ${$.ref}`,link:`#item=${encodeURIComponent($.key)}`,html:null,via:null}))])].sort((i,$)=>String(i.ts).localeCompare(String($.ts))),V=Ve(_),{edits:H,editFiles:U}=f;for(const i of _){if(!i.eventId)continue;(i.kind==="ask"||i.kind==="item-message")&&typeof H.get(i.eventId)=="string"&&Object.assign(i,{text:H.get(i.eventId),edited:!0,files:[...i.files,...U.get(i.eventId)||[]]});const $=i.kind==="ask"&&(p.length>0||!!i.moved);i.state=i.reply?"replied":$||G.has(i.eventId)||V>String(i.ts)?"answered":q(r,i.eventId)?"working":"waiting",i.canDelete=i.kind==="item-message"&&(i.state==="working"||i.state==="waiting"),i.canEdit=i.canDelete}return _}d(pt,"threadOf");function _n(e,t,s,o,r,a){const p=d((l,h)=>{const O=a.filter(I=>I.kind==="wave-triage"&&I.data?.[l]===h).pop(),m=r.filter(I=>I.topic===`${l}:${h}`&&(I.state==="open"||I.state==="answered")).length;return{running:!!(O&&!O.reply),questions:m}},"triageOf"),c=new Map(o.map(l=>[l.key,l])),u=d(l=>l.filter(h=>h.lane==="done"&&!je(h)).length,"merged"),f=s.map(l=>({l,cards:l.keys.map(h=>c.get(h)).filter(Boolean)})).map(l=>({...l,open:!l.l.finished_at&&l.cards.some(h=>h.lane!=="done")})).sort((l,h)=>Number(l.open)-Number(h.open));for(const{l,cards:h}of f)for(const O of h)O.lineup={slug:l.slug,title:l.title};const k=f.filter(l=>l.open).map(({l,cards:h})=>({kind:"lineup",slug:l.slug,title:l.title,goal:l.goal,keys:h.map(O=>O.key),phases:l.phases.map(O=>O.filter(m=>c.has(m))).filter(O=>O.length),next:Rn(h),merged:u(h),total:h.length,triage:p("lineup",l.slug)}));return e.fromWaves?[...k,...t.filter(l=>!l.finished).map(l=>({w:l,cards:o.filter(h=>h.wave===l.slug&&h.kind!=="ask")})).filter(({cards:l})=>l.length).map(({w:l,cards:h})=>({kind:"wave",slug:l.slug,title:l.title,goal:null,keys:h.map(O=>O.key),phases:null,next:null,merged:u(h),total:h.length,triage:p("wave",l.slug)}))]:k}d(_n,"waveBandsOf");function Rn(e){const t=e.filter(a=>a.lane==="todo"),s=t.find(a=>a.ready&&a.buildable)||t[0];if(!s)return null;const o=s.ready&&s.buildable,r=o?"ready":s.held?"held":s.blockedBy.length?`waits on ${s.blockedBy.map(a=>a.ref).join(", ")}`:s.action?"needs you":s.unsorted?"new":s.state||"not ready";return{key:s.key,ref:s.ref,ready:o,word:r}}d(Rn,"nextOf");function ds(e,t,s,o){const r=e.waveBands.find(l=>l.kind==="lineup"&&l.slug===t);if(!r)return null;const a=new Map(e.items.map(l=>[l.key,l.lane])),p=r.keys.filter(l=>a.get(l)==="todo"),c=p.indexOf(s),u=c+o;if(c<0||u<0||u>=p.length)return null;[p[c],p[u]]=[p[u],p[c]];let f=0;const k=r.keys.map(l=>a.get(l)==="todo"?p[f++]:l);return f=0,r.phases.map(l=>k.slice(f,f+=l.length))}d(ds,"lineupMoved");const In=d(e=>e.phases||e.items.map(t=>[t]),"lineupPhases");function us(e){const{owner:t={},topicItems:s={},events:o=[],threads:r={},prs:a={},working:p={}}=e,c=e.now??Date.now(),u=ct(o,t),f=new Set(o.filter(n=>n.kind==="ask-withdrawn"&&!n.data?.key).map(n=>n.data?.id)),k=new Map(o.filter(n=>n.kind==="ask"&&!f.has(n.id)).map(n=>[n.id,n])),l=d((n,g)=>new Map(o.filter(y=>y.kind===n).sort((y,x)=>String(y.ts).localeCompare(String(x.ts))).map(y=>[y.data?.[g],y.ts])),"latest"),h=l("ask-bump","id"),O=l("card-unbump","key"),m=new Map([...l("card-bump","key")].filter(([n,g])=>!(String(O.get(n)||"")>String(g)))),I=l("card-done","key"),G=l("card-merge","key"),_=e.autoMerge===!0,V=e.tickets,H=new Map(o.filter(n=>n.kind==="card-hold").sort((n,g)=>String(n.ts).localeCompare(String(g.ts))).map(n=>[n.data?.key,n])),U=new Map,i=e.askLinks||{},$=new Map;for(const[n,g]of Object.entries(i))k.has(n)&&$.set(g,[...$.get(g)||[],n]);const S=[],B=[],re=new Map,Z=new Map,T=new Map,ee=new Map,W=e.github?null:xt(e.remote);for(const{slug:n,wave:g,agents:y={}}of e.waves){const x=e.github||g.repo||null;S.push({slug:n,title:g.title||n,status:g.status||null,internal:!!g.internal,finished:null,reviewers:(g.reviewers||[]).map(b=>b.name)}),g.items.forEach((b,E)=>{const C=`${n}/${b.id}`,w=($.get(C)||[]).filter(v=>v!==b.from_ask),Q=[b.from_ask,...w].filter(v=>k.has(v)),mt=new Set(Q.map(v=>`ask:${v}`)),Xe=[...q(r,C)||[],...Q.flatMap(v=>q(r,`ask:${v}`)||[])];b.from_ask&&U.set(b.from_ask,[...U.get(b.from_ask)||[],{key:C,ref:Pe(g,b,V),became:!0}]);const _e=pt(C,{lines:Xe,events:o,owner:t,working:p,fromAsk:b.from_ask||null,moved:w,index:u});for(const v of _e)v.eventId&&re.set(v.eventId,v.state);Z.set(C,Ve(_e)),B.push(Jt({slug:n,wave:g,it:b,order:E,repo:x,remote:W,base:e.branch||"main",prs:Et(b,x).map(v=>({...v,gh:q(a,_t(v))||null})),...(v=>({agents:v,builder:hn(v,q(r,C),c),reachedPhase:wn(v,q(r,C)),eta:v.map(wt=>wt.eta).filter(Boolean).sort().pop()||null}))(Ke(q(y,b.id))),worktree:mn(q(y,b.id)),thread:Xe,events:[...He(u,[C,...mt].map(v=>u.byKey.get(v))),...Q.map(v=>k.get(v))],working:_e.some(v=>v.state==="working"),said:_e.filter(v=>v.who==="love"&&(v.kind==="item-message"||v.kind==="owner-answer")),askedAt:(u.questions.get(`item:${C}`)||[]).filter(v=>v.asked_at).map(v=>v.asked_at),topicItems:s,boardReviewers:e.reviewers||[],now:c,bumpedAt:m.get(C),holdAsk:H.get(C),closedAt:I.get(C),mergeAt:G.get(C),autoMerge:_,skipDraft:e.skipDraft===!0,tickets:V}));const Ne=B[B.length-1];ee.set(C,{parent:b.parent?gt(n,b.parent):null,related:(b.related||[]).map(v=>gt(n,v))}),Ne.lane==="done"&&T.set(C,Ne.closedAt||String(Ne.updatedAt||""))})}const N=new Map(B.map(n=>[n.key,n])),F=new Map,j=e.try||{},Oe=e.autoBuild===!0,L=["web","app"].includes(j.kind)?j.kind:e.waves.some(({wave:n})=>n.items.some(g=>g.install?.url))?"app":"web";for(const n of B){if(n.kind!=="work"||n.lane==="done")continue;const g=q(j.cards,n.key)||{},y=g.head||n.pr?.headRefOid,x=L==="web"?g.sha:n.install?.sha,b=n.builder?.kind===Re.install?"running":g.state||(L==="app"&&n.install?"ready":null);n.try={kind:L,state:b,stale:!!(x&&y&&!String(y).toLowerCase().startsWith(String(x).toLowerCase())),url:L==="web"?null:n.install?.url||null,port:L==="web"&&b==="ready"&&g.https||null,sha:x||null,changes:g.ahead>0,script:g.script===!0,autoBuild:Oe}}const D=j.main,pe=D?.script&&D.sha?{slug:D.slug,branch:D.branch||"main",sha:D.sha.slice(0,7),at:D.at,kind:L,state:D.state||null,url:L==="web"?null:e.main?.install?.url||null,port:L==="web"&&D.state==="ready"&&D.https||null,pull:j.pull?{running:j.pull.running===!0,error:j.pull.error||null}:null}:null,fe=e.askProgress||{},xe=l("ask-done","id"),ae=be(o.filter(n=>n.kind==="owner-answer"),n=>n.data?.id),ge=be(o.filter(n=>n.kind==="prototype-request"),n=>n.data?.question),$e=be(o.filter(n=>n.kind==="reask-request"),n=>n.data?.question),P=(t.items||[]).map(n=>Sn(n,ae.get(n.id)||[],ge.get(n.id)||[],$e.get(n.id)||[])),te=new Map(P.map(n=>[n.id,n])),Ae=be(P,n=>n.topic),X=d(n=>{const g=Ae.get(n)||[];return{open:g.filter(y=>y.state==="open").length,answered:g.filter(y=>y.state==="answered").length}},"pendingOn");for(const n of k.values()){const g=`ask:${n.id}`,y=N.get(q(i,n.id)),x=[...U.get(n.id)||[]];if(y&&!x.some(E=>E.key===y.key)&&x.push({key:y.key,ref:y.ref,became:!1}),x.length){F.set(g,x[0].key);continue}if(q(i,n.id)){F.set(g,q(i,n.id));continue}const b=pt(g,{lines:q(r,g)||[],events:o,working:p,links:x,index:u});for(const E of b)E.eventId&&re.set(E.eventId,E.state);Z.set(g,Ve(b)),B.push(pn(n,b,h.get(n.id),x.length>0||!!q(i,n.id),q(fe,n.id),xe.get(n.id),X(`item:${g}`)))}for(const n of S){const g=B.filter(y=>y.wave===n.slug);if(n.finished=Kt(g),n.finished)for(const y of g)y.lane==="done"&&(y.fold=Lt(n.slug))}for(const n of B)n.lineup=null;const K=new Set((t.topics||[]).map(n=>n.id)),A=e.waves.flatMap(({slug:n,wave:g})=>(g.lineups||[]).map(y=>{const x=In(y).map(b=>b.map(E=>`${n}/${E}`));return{...y,phases:x,keys:x.flat()}})),le=d(()=>On([...t.topics||[],...B.filter(n=>!K.has(`item:${n.key}`)).map(n=>({id:`item:${n.key}`,card:n.key,title:`${n.ref}: ${n.title}`,...n.kind==="ask"?{askedAt:n.ask.askedAt}:{},summary:"Questions about this work item."})),...A.filter(n=>!K.has(`lineup:${n.slug}`)).map(n=>({id:`lineup:${n.slug}`,title:n.title,summary:"Wave triage."})),...(e.fromWaves?S:[]).filter(n=>!K.has(`wave:${n.slug}`)).map(n=>({id:`wave:${n.slug}`,title:n.title,summary:"Wave triage."}))],P,new Set(B.filter(de).map(n=>`item:${n.key}`))),"topicsOf"),M=new Map(le().map(n=>[n.id,n]));for(const n of B){const g=M.get(`item:${n.key}`);if(!g){n.questions=null;continue}const y=g.questions.filter(E=>te.get(E)?.state!=="resolved"),x=g.questions.find(E=>te.get(E)?.state==="open")||y[0]||g.questions[0],b=g.questions.map(E=>te.get(E)).filter(E=>E?.state==="open");n.questions={topic:g.id,state:g.state,open:g.open,answered:g.answered,replied:g.replied,resolved:g.resolved,first:x,askedAt:b.map(E=>E.asked_at).filter(Boolean).sort(),fromAsks:b.length>0&&b.every(E=>E.ask)}}const ke=new Map(B.map(n=>[n.key,n]));for(const n of B){n.blockedBy=n.kind!=="work"||n.lane==="done"?[]:n.deps.map(y=>ke.get(String(y).includes("/")?y:`${n.wave}/${y}`)).filter(y=>y&&y.lane!=="done"&&!y.reopened).map(ft),un(n,te,_),n.lane==="todo"&&n.kind==="work"&&!n.held&&rt(n)&&(n.lane="progress"),n.unpicked=n.kind==="work"&&n.lane==="todo"&&!!an(P,n.key),n.unpicked&&(n.state="prototyping"),n.unpicked&&!n.action&&(n.next=ln),n.buildable=on(n);const g=n.kind==="work"&&n.lane==="todo";n.unsorted=g&&!!n.fromAsk&&!n.state,n.ready=g&&n.state==="ready"&&!n.blockedBy.length&&!n.action}Mn(B,ke,ee);const me=new Map((t.items||[]).map(n=>[n.id,n.topic])),ne=d(n=>n.kind==="owner-answer"?me.has(n.data?.id)?/^item:(.+)$/.exec(me.get(n.data.id))?.[1]||null:"":n.kind==="ask"?`ask:${n.id}`:n.data?.key||(n.kind.startsWith("ask-")&&n.data?.id?`ask:${n.data.id}`:null),"ownCardOf"),we=d(n=>{const g=ne(n);return F.get(g)||g},"cardOf"),Be=d(n=>{const g=n.startsWith("ask:")?n.slice(4):null,y=g&&q(fe,g)?.state==="done"?q(fe,g).at:null;return[I.get(n),g&&xe.get(g),y,T.get(n)].filter(Boolean).sort().pop()||""},"closedAt"),Ce=d(n=>{const g=we(n);return g===null?!n.reply:!ke.has(g)||!(Be(g)<String(q(p,n.id)))?!1:re.has(n.id)?re.get(n.id)==="working":!n.reply&&!F.has(ne(n))&&!(String(Z.get(g)||"")>String(n.ts))},"unanswered"),se=o.filter(n=>q(p,n.id)&&Ce(n)).map(n=>({id:n.id,kind:n.kind,key:we(n),data:n.data,since:q(p,n.id)})),Ee=e.autoPull===!0;for(const n of B)n.working=se.some(g=>g.key===n.key),n.kind==="work"&&(n.lane==="progress"&&n.queuedAt||Ee&&n.lane==="todo"&&kt(n))&&Object.assign(n,{lane:"todo",queued:!0}),n.kind==="work"&&n.lane==="progress"&&!n.builder&&!n.next&&n.waitsOn!=="checking"&&!n.working&&!n.queued&&(n.next=at),n.sortAt=(n.queued?n.queuedAt||n.created:Nn[n.lane](n))||(["review","stale"].includes(n.lane)?null:n.updatedAt)||null;for(const n of B){if(n.kind!=="work")continue;const g=(Ae.get(`item:${n.key}`)||[]).filter(x=>x.state==="answered").map(x=>x.answers.at(-1).ts).sort().pop(),y=se.filter(x=>x.key===n.key).map(x=>String(x.since)).sort()[0];n.orchestrator=["progress","todo"].includes(n.lane)?Vn(n,n.waitFacts,{answeredAt:g,workingSince:y}):null,delete n.waitFacts}B.sort(Ct);const Me=_n(e,S,A,B,P,o),qe=le(),ie=$t({on:e.autoReview,incoming:e.incoming,records:e.reviewRecords,events:o,now:c,refs:new Map(B.filter(n=>n.kind==="work").map(n=>[n.key,n.ref]))}),he=[...Ln(B,qe,P),...At(ie)],ye=B.filter(n=>n.ask?.answerAt).sort((n,g)=>g.ask.answerAt.localeCompare(n.ask.answerAt)).map(n=>({key:n.key,id:n.id,text:n.title,at:n.ask.answerAt}));return Dn({kind:L,main:pe,remote:W&&{host:W.host,name:`${W.host}/${W.path}`},waves:S,waveBands:Me,items:B,moved:Object.fromEntries(F),answers:ye,owner:P,ownerTopics:qe,reviews:ie,needs:he,working:se.length,workingOn:se,checks:Tn(e,c)},e)}d(us,"buildBoard");function Dn(e,{listen:t,prompts:s}={}){const o=[...Pn(s),...e.needs];return{...e,needs:o,needsSummary:jn(o),checks:{...e.checks,watcher:{listening:"running",asleep:"asleep",waking:"waking"}[t]||"stopped"}}}d(Dn,"withHub");const ft=d(e=>({key:e.key,ref:e.ref}),"linkOf"),gt=d((e,t)=>String(t).includes("/")?String(t):`${e}/${t}`,"linkKey"),Cn=d((e,t)=>e.ref.localeCompare(t.ref,void 0,{numeric:!0}),"byRef");function Mn(e,t,s){const o=new Map,r=new Map,a=new Map,p=d((u,f,k)=>u.set(f,[...u.get(f)||[],k]),"add");for(const[u,f]of s){f.parent&&p(o,f.parent,u);for(const k of f.related)k!==u&&(p(r,u,k),p(r,k,u))}for(const u of e)for(const f of u.blockedBy||[])p(a,f.key,u.key);const c=d((u=[])=>[...new Set(u)].map(f=>t.get(f)).filter(Boolean).map(ft).sort(Cn),"cards");for(const u of e){const f=s.get(u.key)?.parent;u.parent=f?{key:f,ref:t.get(f)?.ref||f.slice(f.indexOf("/")+1)}:null,u.children=c(o.get(u.key)),u.related=c(r.get(u.key)),u.waitsOnIt=c(a.get(u.key))}}d(Mn,"linkCards");const Nn={todo:d(e=>e.created,"todo"),progress:d(e=>e.progressSince,"progress"),review:d(e=>e.reviewSince,"review"),stale:d(e=>e.reviewSince,"stale"),done:d(e=>e.closedAt,"done"),asks:d(e=>e.ask.answerAt,"asks")},J=d((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural");function Tn({checked:e,watcher:t,replyAt:s,threads:o={},working:r={},waves:a=[]},p){const c=Number(e?.every)||30,f=[s,t?.since,...Object.values(r),...Object.values(o).flat().filter(l=>(l.who||"claude")==="claude").map(l=>l.ts),...a.flatMap(l=>Object.values(l.agents||{}).flatMap(h=>Object.values(h||{})).map(h=>h?.done||h?.started))].filter(l=>typeof l=="string"&&!Number.isNaN(Date.parse(l))).reduce((l,h)=>l&&Date.parse(l)>Date.parse(h)?l:h,null),k=!!e?.idle;return{at:e?.at||null,every:k?null:c,idle:k,late:!k&&!!e?.at&&p-Date.parse(e.at)>2*c*6e4,claudeAt:f}}d(Tn,"checksOf");function Ln(e,t,s){const o=new Set(e.map(c=>c.questions?.topic).filter(Boolean)),r=d(c=>c.find(u=>s.find(f=>f.id===u)?.state==="open")||c[0],"firstOpen"),a=t.filter(c=>c.state!=="resolved"&&c.open>0&&!o.has(c.id)).map(c=>{const u=`questions.html#${r(c.questions)}`,f=/^(?:lineup|wave):(.+)$/.exec(c.id)?.[1]||null;return{kind:"Question",title:c.title,text:`${c.title} \xB7 ${J(c.open,"question")}`,url:u,topic:c.id,band:f,questions:{open:c.open,url:u},ready:null}}),p=e.filter(c=>!c.held).map(c=>{const u=c.questions&&c.questions.state!=="resolved"&&c.questions.open>0?{open:c.questions.open,url:`questions.html#${c.questions.first}`}:null,f=c.waitsOn==="ready"?c.pr.url:null,k=!u&&!f&&c.action?{label:c.action.label,url:c.action.url}:null;if(!u&&!f&&!k)return null;const l=`${c.ref}: ${c.title}`,h=[l,u&&J(u.open,"question"),f&&"Ready on GitHub",k?.label].filter(Boolean).join(" \xB7 ");return{kind:u?"Question":f?"Tap Ready":"Action needed",title:l,text:h,url:`#item=${encodeURIComponent(c.key)}`,key:c.key,questions:u,ready:f,action:k}}).filter(Boolean);return[...a,...p]}d(Ln,"needsOf");function Pn(e=[]){return e.map(t=>{const s=t.questions?.length?`Question: ${t.questions.map(o=>o.question).join(" \xB7 ")}`:`${t.tool}: ${t.detail||t.action}`;return{kind:"Prompt",title:s,text:s,url:"",prompt:t}})}d(Pn,"promptLines");function jn(e){const t=e.filter(a=>a.prompt).length,s=e.reduce((a,p)=>a+(p.questions?.open||0),0),o=e.filter(a=>a.ready).length,r=e.filter(a=>a.review).length;return[t&&J(t,"prompt"),s&&J(s,"question"),o&&`${J(o,"draft")} waiting on Ready`,r&&`${J(r,"review")} held`].filter(Boolean).join(" \xB7 ")}d(jn,"needsSummary");function cs(e){const t=d((...s)=>e.items.filter(o=>s.includes(o.lane)).length,"count");return{items:e.needs.map(({kind:s,text:o,url:r})=>({kind:s,text:o,url:r})),working:e.working,summary:e.needsSummary,lanes:{review:t("review","stale"),progress:t("progress"),todo:t("todo")},building:e.items.some(s=>(s.agents||[]).some(o=>!o.done))}}d(cs,"needsAnswer");const kt=d(e=>e.buildable&&e.state==="ready"&&!e.held&&!e.unsorted&&!e.blockedBy.length&&!e.questions?.open&&!e.questions?.answered&&!e.grilling&&!e.prototyping,"queueable"),Un=10;function Wn(e,{cap:t=Un,pulled:s=[]}={}){const o=e.filter(m=>!de(m)),r=d(m=>(m.agents||[]).filter(I=>!I.done),"running"),a=o.filter(m=>m.waitsOn==="checking"||r(m).some(z)).length,p=o.filter(m=>kt(m)&&!m.working).map(m=>m.key),c=o.filter(m=>s.includes(m.key)&&(p.includes(m.key)||m.buildable&&m.working)).map(m=>m.key),u=d(m=>m.queued&&m.queuedAt&&!m.blockedBy.length,"tapped"),f=o.filter(m=>u(m)||p.includes(m.key)&&!c.includes(m.key)).slice(0,Math.max(0,t-a-c.length)),k=f.filter(u).map(m=>m.key),l=f.filter(m=>!u(m)).map(m=>m.key),O=o.some(m=>m.grilling||m.prototyping||r(m).some(ue))?[]:o.filter(m=>(m.buildable||m.unpicked&&!m.action)&&m.state!=="ready"&&!m.held&&!m.questions?.open&&!m.questions?.answered&&!m.working).map(m=>m.key);return{idle:!a,pullable:p,waiting:c,starts:k,pulls:l,plannable:O}}d(Wn,"pullOf");function Fn(e){return e.filter(t=>t.lane==="todo"&&(!t.queued||t.buildable)||t.lane==="stale").map(t=>JSON.stringify([t.key,t.title,t.deps||[]])).sort().join(`
5
- `)}d(Fn,"todoOf");function ps(e){const t=e.filter(o=>o.kind==="work"&&o.lane!=="done"&&o.questions?.open>0),s=t.map(o=>JSON.stringify([o.key,o.questions.open,o.questions.askedAt||[]])).sort().join(`
6
- `);return{waiting:t.map(o=>o.key),seen:`${s}
1
+ var Ot=Object.defineProperty;var i=(e,t)=>Ot(e,"name",{value:t,configurable:!0});import{routeRecord as $}from"../hub/routes.mjs";import xt from"node:fs";import{ticketBadge as Ze,ticketIn as $t}from"./tickets.mjs";import{reviewLinks as At,reviewTime as Et,reviewersOf as Bt}from"./review.mjs";import{remoteFromInput as Rt}from"../hub/repos.mjs";import{reviewsOf as _t,reviewNeeds as It,reviewActions as qt}from"./auto-review.mjs";import{cardPRs as Mt,hasPR as je,leastReady as Dt,prKeyOf as Ct,prURL as Nt}from"../shared/card-prs.mjs";import et from"node:vm";import{checkWords as Tt,parseCheck as Lt}from"../shared/owner-check.mjs";const Ue=et.createContext({});for(const e of["ui-enums.js","ui-order.js"])et.runInContext(xt.readFileSync(new URL(`./public/${e}`,import.meta.url),"utf8"),Ue);const{BUTTON:Y,ACTION_KIND:M,BUILDER_KIND:De,PR_STATE:re}=Ue.BoardUI,{laneOrder:Pt}=Ue.BoardUI,jt=["item-message","mark-ready","grill-more","prototype-request","reask-request"],fs=["waiting","building","fixing","checking","held","merged","done","dropped"],Ut=10*6e4,Ft=5*6e4,tt="build-refused",be=Object.freeze({ask:"builder-ask",answer:"builder-answer"}),Wt=864e5,z=i(e=>e.lane==="done"||e.lane==="asks","closedLane"),Gt=i(e=>`wave:${e}`,"waveFold"),nt=7*Wt,st=i((e,t)=>({id:e,url:t?.workspace?`https://linear.app/${t.workspace}/issue/${e}`:null}),"linearRef"),Kt=i((e,t)=>String(e).replace(/^S(\d+)$/,`${t||"INT"}-$1`),"internalRef"),Fe=i((e,t,n)=>$t(n,t.ticket)?t.ticket:e.internal===!0?Kt(t.id,n?.prefix):t.id,"refOf"),Qt=i((e,t,n,o)=>Ze(e||(t?{source:"internal",prefix:"INT"}:null),n,o)||(t?{id:String(t),url:null,source:null}:null),"ticketOf");function Vt(e,t,n,o,r,a,u){const p=(e.status||"").toLowerCase();return p==="merged"||p==="done"||p==="dropped"||!r&&(t?.state==="MERGED"||t?.state==="CLOSED")?"done":(n||p==="checking")&&!u?"progress":o?"review":t?.state==="OPEN"?t.checks?.state==="fail"&&(!t.isDraft||a)?"progress":"review":t?"progress":"todo"}i(Vt,"laneOf");function Ht(e,t){return e?.state==="MERGED"||t.status==="merged"||t.merged_at?re.merged:e?.state==="CLOSED"?re.closed:e?.state==="OPEN"?e.isDraft?re.draft:re.open:null}i(Ht,"prStateOf");const We=i(e=>{const t=(e.status||"").toLowerCase();return t==="dropped"||e.pr?.state==="CLOSED"&&t!=="merged"&&t!=="done"},"droppedCard");function Xt(e){if(!e.some(o=>o.kind==="work")||e.some(o=>o.lane!=="done"))return null;const t=e.filter(o=>o.lane==="done"),n=t.filter(We).length;return{merged:t.length-n,dropped:n}}i(Xt,"finishedOf");function Yt(e,t,n){return Object.fromEntries(e.map(o=>{const r=$(t?.reviews,o.github),a=r==="APPROVED"?"approved":r==="CHANGES_REQUESTED"?"changes":Object.hasOwn(n,o.name)?"sent":"unsent";return[o.name,{state:a,since:a==="sent"?$(n,o.name):null,github:o.github||null}]}))}i(Yt,"reviewOf");function zt(e,t,n,o,r,a,{held:u,needsApproval:p}){return n?.kind===De.install?"builder":o==="checking"?"checking":n?"builder":u&&e==="review"?"merge":r&&e==="review"?"owner":e==="review"&&t?.state==="OPEN"&&t.isDraft?a?"ci":"ready":e==="review"||e==="stale"?ot(t,p)?"merge":"reviewers":null}i(zt,"waitsOnOf");const ot=i((e,t)=>e?.reviewDecision==="APPROVED"||!t&&!["REVIEW_REQUIRED","CHANGES_REQUESTED"].includes(e?.reviewDecision),"reviewed"),Ce=/(^|\/)prototype-[\w-]+\.html/,Jt={reviewers:"Waiting for PR reviewers",merge:"Approved, merges once CI and the merge state allow",ci:"Marked ready for review once CI passes"},Ne={waiting:"Approved, Merge shows once CI and the merge state allow",ready:"Approved and green: tap Merge",merging:"Merging"},Ge={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"},Zt=i(e=>`Verified: tap Merge to land it on ${e}`,"heldNext"),en="Fix the failing CI",rt="Tap Done once it is settled",tn=["status","agent","ask-link",be.answer],at=i(e=>(e.who==="claude"||e.via==="github")&&!tn.includes(e.kind),"countsUnread"),nn=/^(?:Not merged yet: |Lander launched headless )/;function sn({slug:e,wave:t,it:n,order:o,prs:r,repo:a,remote:u,base:p,builder:f,reachedPhase:g,agents:c,worktree:l,eta:w,thread:b,events:D,working:q,said:L,askedAt:R,topicItems:I,boardReviewers:G,now:K,bumpedAt:d,holdAsk:x,closedAt:y,mergeAt:A,autoMerge:le,skipDraft:ee,tickets:P}){const te=r.map(k=>({repo:k.repo,number:k.number,url:Nt(k),...k.gh||{},status:Ht(k.gh,n)})),Q=Dt(r.map(k=>k.gh)),C=r[Q]?.gh||null,V=te[Q]?.status??null,W=!!y&&String(y)>String(n.status_at||"");W&&n.status!=="merged"&&(n={...n,status:"done"});const $e=[W&&y,n.status_at,n.merged_at,...r.map(k=>k.gh?.mergedAt)].filter(Boolean).map(String).sort().pop()||null,j=String($e||""),N=["done","merged"].includes(n.status)||V===re.merged&&n.status!=="dropped"?[...L.filter(k=>k.kind==="item-message").map(k=>k.ts),...R].map(String).filter(k=>k>j).sort().pop():void 0,me=n.owner_step&&!W&&n.status!=="dropped"?String(n.owner_step):null,ke=["done","merged"].includes(n.status)||V===re.merged;N&&(n={...n,status:void 0,next:void 0});const Ae=!!N&&L.some(k=>String(k.ts)>j&&(k.state==="waiting"||k.state==="working")),ie=`${e}/${n.id}`,we=Bt(t,G),Ee=Object.fromEntries(Object.entries(At(t,n,ie,I)).map(([k,F])=>[k,Et(F.ts)])),U=Object.values(Ee).filter(Boolean).sort()[0]||null,ne=[...b.map(k=>k.ts),...D.map(k=>k.ts)].sort().pop()||null,Be=[...b.filter(k=>at({...k,who:k.who||"claude"})).map(k=>k.ts),...D.map(k=>k.reply?.at)].filter(Boolean).sort(),X=!je(n)&&n.pushed?.branch?{branch:n.pushed.branch,at:n.pushed.at||null,host:u?.host||null}:null,H=!je(n)&&n.merge_ready?.branch?{branch:n.merge_ready.branch,at:n.merge_ready.at||null,base:p}:null,de=!!n.rebase_run&&C?.state==="OPEN",ce=(n.rebased||[]).at(-1);let E=Vt(n,C,c.some(k=>k.started&&!k.done&&J(k)),X||H,!!N,ee,de);N&&E==="todo"&&(E="progress"),E==="review"&&U&&K-Date.parse(U)>nt&&(E="stale");const se=!!me&&ke&&E==="done";se&&(E="review");let T=zt(E,C,f,(n.status||"").toLowerCase(),X,ee,{held:H,needsApproval:we.length>0});const Re=T==="builder"&&C?.state==="OPEN"&&!C.isDraft,he=E==="progress"&&!T&&C?.state==="OPEN"&&(!C.isDraft||ee),ue=se||!!N&&E==="progress"&&!T&&!he&&!Ae;ue&&(T="owner");const _e=x&&String(x.ts)>String(n.held_at||""),oe=E==="todo"&&(_e?!!x.data.hold:n.status==="held"||!!n.held),Te=oe&&(_e?x.data.until:n.pick_up_at)||null,pe=E==="todo"||E==="progress",ye=c.filter(J).map(k=>String(k.started||"")).filter(Boolean).sort()[0]||"",Ie=d&&!(ye&&String(d)<ye),qe=b.filter(k=>(k.who||"claude")==="claude"&&k.kind!=="status"&&!nn.test(k.text||"")).map(k=>String(k.ts)).sort().pop()||"",fe=[A,H&&n.merge_ready.tapped].filter(Boolean).map(String).sort().pop(),Se=T==="merge"&&!!fe&&fe>qe,s=b.filter(k=>k.kind==="status"&&String(k.ts)>String(fe)).sort((k,F)=>String(k.ts).localeCompare(String(F.ts))).at(-1),m=s?.text.startsWith("Waiting for ")?`${Ne.merging} \xB7 ${s.text[0].toLowerCase()}${s.text.slice(1)}`:Ne.merging,h=b.filter(k=>k.kind!=="status").sort((k,F)=>String(k.ts).localeCompare(String(F.ts))).at(-1),O=E==="todo"&&h?.kind===tt?h.text:null,S=N||c.filter(J).map(k=>k.started).filter(Boolean).map(String).sort().pop()||n.implement_at||["building","fixing","checking"].includes(String(n.status||"").toLowerCase())&&n.status_at||null,_=C?.reviewDecision==="APPROVED",B=X&&T==="owner"?`merge ${X.branch} into ${p}`:H&&T==="merge"?Se?m:Zt(p):T==="merge"&&!le?Se?m:(_?Ne:Ge).waiting:T==="merge"&&!_?Ge.auto:Jt[T],Me=V===re.draft?`Review draft PR #${te[Q].number}`:null,ve=!de&&ce?.to&&ce.to===C?.headRefOid?`Rebased onto ${ce.base||p}, pushed${C.mergeable==="MERGEABLE"?" \xB7 PR is clean again":""}`:null,Le=de&&T==="checking"?c.flatMap(k=>k.calls).sort((k,F)=>String(k.at).localeCompare(String(F.at))).at(-1)?.text??null:null;return{key:ie,kind:"work",order:o,wave:e,waveTitle:t.title||e,id:n.id,ref:Fe(t,n,P),title:n.title,status:n.status||null,created:n.created||null,reviewSince:n.review_since||U||n.merge_ready?.at||n.pushed?.at||n.created||null,progressSince:S,closedAt:E==="done"?$e:null,internal:t.internal===!0,repo:t.internal===!0&&!t.repo?null:a,lane:E,waitsOn:T,builder:T==="checking"?null:f,reachedPhase:g,agents:c,worktree:l??null,eta:w,working:q,reopened:!!N,awaitsDone:ue,ownerStep:ue?me:null,ownerCheck:ue&&me&&n.owner_check?{words:Tt(Lt(n.owner_check.check)),broken:n.owner_check.broken||null}:null,implementAt:E!=="done"&&n.implement_at||null,deps:n.deps||[],held:oe,heldUntil:Te,risky:!!n.risky,bumpable:pe,bumpedAt:pe&&Ie?d:null,holdable:E!=="done",hasNotes:!!(n.plan||String(n.notes||"").trim()),finishable:E!=="done",merging:Se,refusal:O,manualSteps:n.manual_steps||[],fromAsk:n.from_ask||null,unfiled:!!n.unfiled,next:Re||E==="done"||T==="checking"?null:he?en:ve||B||n.next||Me||null,rebaseFailed:Le,branch:n.branch||C?.headRefName||X?.branch||null,pushed:E==="done"||se?null:X,mergeReady:E==="review"?H:null,ticket:P?.source==="linear"&&!n.ticket&&n.linear?.length?null:Qt(P,n.ticket,n.ticket||(t.internal?Fe(t,n,P):n.linear?.[0]),{repo:a,key:ie}),ticketSource:P?.source||null,linear:(n.linear||[]).map(k=>P?.source==="linear"&&Ze(P,k,{key:ie,repo:a})||st(k,P)),pr:te[Q]||null,prs:te,reviewers:we.map(k=>k.name),review:Yt(we,C,Ee),inReviewSince:U,threadCount:b.length+D.length,lastTs:ne,othersAt:Be,grilling:ut("grill",D,c,R),prototyping:ut("prototype",D,c,R),state:n.state||null,updatedAt:C?.mergedAt||C?.updatedAt||n.merged_at||f?.at||ne||null,ask:null,fold:null,action:null,install:E==="done"?null:rn(n.install,C),waitFacts:on(n,{agents:c,thread:b,events:D,refusedAt:O?h.ts:null})}}i(sn,"workItem");function on(e,{agents:t,thread:n,events:o,refusedAt:r}){const a=new Set(n.filter(g=>g.kind===be.answer).map(g=>g.ask)),u=n.filter(g=>g.kind===be.ask&&!a.has(g.ask)).sort((g,c)=>String(g.ts).localeCompare(String(c.ts)))[0],p=i(g=>o.filter(c=>Qe(c,g)).pop()?.ts||null,"requestAt"),f=n.filter(g=>(g.who||"claude")==="claude"&&!["status","agent",tt].includes(g.kind)).map(g=>g.ts);return{statusAt:e.status_at||null,next:e.next||null,ask:u?{at:u.ts,text:u.text}:null,grillAt:p("grill"),prototypeAt:p("prototype"),refusedAt:r,unverified:t.some(g=>g.calls.some(c=>!g.verified||String(c.at)>String(g.verified.at))),writes:[...f,...t.flatMap(g=>[g.verified?.at,g.started])].filter(Boolean).map(String).sort()}}i(on,"waitFactsOf");function rn(e,t){if(!e?.url)return null;const n=e.sha?String(e.sha).toLowerCase():null,o=t?.headRefOid?String(t.headRefOid).toLowerCase():null;return{url:e.url,label:e.label||null,builtAt:e.built_at||null,sha:n,older:!!(n&&o&&!o.startsWith(n))}}i(rn,"installOf");function an(e,{needsApproval:t=!0}={}){if(e?.state!=="OPEN")return[`PR is ${String(e?.state||"unknown").toLowerCase()}`];const{state:n,pending:o,failing:r}=e.checks||{};return[e.isDraft&&"it is a draft",!ot(e,t)&&`review: ${String(e.reviewDecision||"none").toLowerCase().replace(/_/g," ")}`,n==="fail"&&`failing: ${r?.length?r.join(", "):"a check"}`,n==="pending"&&`pending: ${o?Z(o,"check"):"checks"}`,e.mergeStateStatus!=="CLEAN"&&`merge state: ${String(e.mergeStateStatus||"unknown").toLowerCase()}`].filter(Boolean)}i(an,"mergeBlockers");const ln=i((e,t)=>!an(e,{needsApproval:t}).length,"mergeable");function dn(e,t,n){if(z(e))return null;const o=`#item=${encodeURIComponent(e.key)}`;if(lt(e)){const r=t.get(e.questions.first);return Ce.test(r?.url||"")?{kind:M.pick,url:`questions.html#${r.id}`,label:"Prototypes ready: pick a take"}:{kind:M.questions,url:`questions.html#${e.questions.first}`,label:`Answer ${Z(e.questions.open,"question")}`}}return e.waitsOn==="ready"?{kind:M.ready,url:e.pr.url,label:`Review draft PR #${e.pr.number}`}:e.kind==="ask"&&e.waitsOn==="owner"?{kind:M.done,url:o,label:e.next||rt}:e.waitsOn==="merge"&&e.manualSteps.length&&!e.mergeReady?{kind:M.steps,url:o,label:"Run the manual steps, then merge"}:e.waitsOn==="merge"&&(!n||e.mergeReady)&&!e.merging&&e.prs.every(r=>["MERGED","CLOSED"].includes(r.state)||ln(r,e.reviewers.length>0))?{kind:M.merge,url:o,label:"Merge"}:null}i(dn,"actionOf");const lt=i(e=>!!(e.questions&&e.questions.state!=="resolved"&&e.questions.open>0),"asking"),Ke=new Set([M.pick,M.questions]);function it(e){return z(e)?null:lt(e)?Y.openQuestions:e.action?.kind===M.done?Y.markDone:null}i(it,"actionButtonOf");const cn=i(e=>e.kind==="work"&&e.lane==="todo"&&!e.action&&!e.unpicked,"buildableOf"),un=i((e,t)=>/^item:/.test(e.topic||"")&&Ce.test(e.url||"")&&!(e.options||[]).some(n=>n.id===t),"picksNoTake");function pn(e,t){const n=e.filter(a=>a.topic===`item:${t}`),r=[...n.filter(a=>Ce.test(a.url||"")).flatMap(a=>a.answers.map(u=>({q:a,a:u,again:un(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}i(pn,"noTakePicked");const fn="Prototype again",gn=Object.freeze({[M.pick]:Y.openQuestions,[M.questions]:Y.openQuestions,[M.ready]:Y.github,[M.steps]:Y.github,[M.merge]:Y.merge,[M.done]:Y.markDone});function mn(e,t,n){if(e.action=dn(e,t,n),e.action?.kind===M.questions&&e.questions.fromAsks){Object.assign(e,{action:null,waitsOn:"owner",next:e.action.label,actionButton:it(e),resolvedBy:null});return}e.awaitsDone&&=!e.action,e.awaitsDone||Object.assign(e,{ownerStep:null,ownerCheck:null}),e.actionButton=it(e),e.resolvedBy=gn[e.action?.kind]||null,e.action?.kind===M.merge&&!e.mergeReady&&(e.next=(e.pr?.reviewDecision==="APPROVED"?Ne:Ge).ready),e.awaitsDone&&Object.assign(e,{lane:"review",next:e.ownerStep||rt,bumpable:!1,bumpedAt:null});const o=e.lane==="todo"||e.waitsOn==="ready"||e.lane==="progress"&&e.waitsOn==="owner";if(!e.action||!o)return;const r=e.lane==="todo"&&Ke.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})}i(mn,"placeOwnerWait");const dt=i(e=>e.implementAt||e.agents.some(J)||["building","fixing"].includes(String(e.status||"").toLowerCase()),"started"),ct="none set yet";function gs(e,t){const n=String(e.status||"").toLowerCase();if(e.next||je(e)||e.pushed||e.held||e.implement_at||["held","checking","done","merged","dropped"].includes(n))return!1;const o=t.filter(r=>r?.started);return!o.some(r=>!r.done)&&dt({status:n,agents:o})}i(gs,"owesNext");function kn(e,t=new Date){const n=new Date(e),o=n.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return n.toDateString()===t.toDateString()?o:`${n.getMonth()+1}/${n.getDate()} ${o}`}i(kn,"askedLabel");function wn(e,t,n,o,r,a,u){const p=t.find(y=>y.kind==="ask"&&y.eventId===e.id),f=p.files,g=(p.text||"").trim().split(`
2
+ `)[0]||f.map(y=>y.name).join(", ")||"Ask",c=p.state==="replied"||p.state==="answered",l=r?.state==="progress"&&!(String(a||"")>String(r.at||"")),w=!l&&(!!r||!!a),b=c&&!w&&!l&&u.open>0,D=c&&!w&&!l&&!b&&u.answered>0,q=w||c&&!l&&!b&&!D,L=c&&!o&&!r?.moved&&[...t.filter(y=>y.who==="claude"&&y.kind!=="ask-link"&&y.kind!=="status").map(y=>y.ts),...t.map(y=>y.reply?.at)].filter(Boolean).sort().pop()||null,R=q||l||b||D,I=t.some(y=>y.who==="love"&&y.kind!=="ask"&&(y.state==="waiting"||y.state==="working")),G=R?"answered":p.state,K=R?null:n||null,d=[...t.filter(at).map(y=>y.ts),...t.map(y=>y.reply?.at)].filter(Boolean).sort(),x=[...t.map(y=>y.ts),...d,...l?[r.at]:[]].filter(Boolean).sort().pop();return{key:`ask:${e.id}`,kind:"ask",order:0,wave:null,waveTitle:null,id:e.id,ref:R?kn(e.ts):"New",isNew:!R,title:g,status:null,internal:!1,repo:null,lane:l?"progress":q?"asks":"todo",waitsOn:l&&!I?"owner":null,builder:null,agents:[],eta:null,working:t.some(y=>y.state==="working"),deps:[],held:!1,risky:!1,bumpable:!R,bumpedAt:K,manualSteps:[],fromAsk:null,from:null,next:l&&r.next||null,hasNotes:!1,branch:null,finishable:R&&!q,linear:[],pr:null,prs:[],reviewers:[],review:{},inReviewSince:null,reviewSince:null,progressSince:l&&r.at||null,closedAt:null,threadCount:t.length,lastTs:x,othersAt:R?d:[],grilling:!1,prototyping:!1,created:e.ts,updatedAt:R?x:e.ts,ask:{eventId:e.id,state:G,askedAt:e.ts,bumpedAt:K,edited:!!p.edited,canEdit:!R,text:p.text,files:f,answerAt:L,from:p.from||null},fold:null,action:null}}i(wn,"askItem");const hn=new Set(["grill","prototype"]),ae=i(e=>hn.has(e.kind),"plans"),J=i(e=>!ae(e),"builds"),yn={grill:"grilling",prototype:"prototyping"},Sn={grill:"grill-more",prototype:"prototype-request"},Qe=i((e,t)=>e.kind===Sn[t]&&!e.data?.question,"isRequest");function ut(e,t,n,o){if(n.some(a=>a.kind===e&&a.started&&!a.done))return!0;const r=t.filter(a=>Qe(a,e)).pop();return!!(r&&!r.reply&&!o.some(a=>String(a)>String(r.ts))&&!n.some(a=>a.kind===e&&a.done&&String(a.started)>=String(r.ts)))}i(ut,"planningOf");const ms=30*6e4;function ks(e,t){const n=[];for(const o of e.items){if(z(o)||(o.agents||[]).some(a=>a.kind==="prototype"&&a.started&&!a.done))continue;const r=o.prototyping&&t.filter(a=>a.data?.key===o.key&&Qe(a,"prototype")).pop();r&&n.push({key:o.key,request:r.id,since:r.ts});for(const a of e.owner.filter(u=>u.topic===`item:${o.key}`&&u.state==="requested"))n.push({key:o.key,request:a.request.id,question:a.id,since:a.request.ts})}return n}i(ks,"prototypeWaits");function Ve(e={}){return Object.entries(e).filter(([,t])=>t&&typeof t=="object").map(([t,n])=>({name:t,kind:pt(n.kind)||null,model:n.model||(n.kind==="opus"||n.kind==="sonnet"?n.kind:null),label:n.label||null,started:n.started||null,eta:n.done?null:n.eta||null,done:n.done||null,calls:Array.isArray(n.calls)?n.calls:[],verified:n.verified||null})).sort((t,n)=>String(t.started||"").localeCompare(String(n.started||""))||t.name.localeCompare(n.name))}i(Ve,"agentsOf");function He(e={}){return Object.values(e).filter(t=>t?.worktree?.path).sort((t,n)=>String(t.started||"").localeCompare(String(n.started||""))).at(-1)?.worktree.path??null}i(He,"worktreeOf");function vn(e,t=[]){const n=e.filter(J).map(o=>String(o.started||"")).filter(Boolean).sort().pop();return n===void 0?null:t.filter(o=>o.kind==="status"&&o.phase&&!o.planner&&String(o.ts)>=n).sort((o,r)=>String(o.ts).localeCompare(String(r.ts))).pop()?.phase||null}i(vn,"reachedPhaseOf");function bn(e,t=[],n,o=null,r=null,a=!1){const u=e.filter(I=>I.started&&!I.done),p=u.every(ae),f=p?u:u.filter(J),g=f.map(I=>String(I.started||"")).sort()[0];if(g===void 0)return null;const c=t.filter(I=>I.kind==="status"&&String(I.ts)>=g&&(p||!I.planner)).sort((I,G)=>String(I.ts).localeCompare(String(G.ts))).pop(),l=f.some(I=>I.kind===De.install)?De.install:pt(f.at(-1).kind),w=c?.ts||g,b=o!==null&&o>Date.parse(w)?new Date(o).toISOString():w,D=c?c.phase||c.planner?c.text.replace(": "," \xB7 "):c.text||null:p?yn[l]:null,q=n-Date.parse(b),L=p?null:r,R=L===null?q>=Ut:!L;return{progress:D,phase:c?.phase||null,at:w,kind:l,planner:p,silentSince:b,stalled:R,alive:L,quiet:L===!0&&!a&&q>=Ft}}i(bn,"builderOf");const Xe={opus:"Claude Opus",sonnet:"Claude Sonnet",codex:"Codex"},On=i(({model:e,kind:t})=>Xe[e]||Xe[t]||(t==="claude"?Xe.opus:null),"modelName"),pt=i(e=>e==="opus"||e==="sonnet"?"claude":e,"providerOf");function Ye(e){const t=On(e),{kind:n}=e,o=e.label?.replace(/\bbuilder\b/,"implementer").replace(/\bBuilder\b/,"Implementer"),r=i(u=>u[0].toLowerCase()+u.slice(1),"lower");if(t&&ae(e))return`${t} ${n}`;if(t)return`${t} ${r(o?.replace(/^(?:claude\s+)?(?:opus|sonnet|codex)\b\s*/i,"")||"implementer")}`;const a=n?n[0].toUpperCase()+n.slice(1):"";return a?o?o.toLowerCase().includes(n.toLowerCase())?o:`${a} ${r(o)}`:a:o||"Implementer"}i(Ye,"agentName");const ft=i((e,t)=>!!e.resolved&&(!e.resolved_at||String(e.resolved_at)>=String(t)),"resolvedSince");function xn(e,t,n=[],o=[]){const r=t.filter(l=>l.data?.id===e.id),a=r[r.length-1]||null,u=!!(e.resolved&&e.resolved_at&&a&&String(a.ts)>e.resolved_at),p=e.resolved&&!u,f=n.filter(l=>l.data?.question===e.id&&String(l.ts)>String(a?.ts||"")).at(-1),g=p?o.filter(l=>l.data?.question===e.id&&String(l.ts)>String(e.resolved_at||"")).at(-1):null,c=p?"resolved":f?"requested":a?a.reply?"replied":"answered":"open";return{...e,state:c,request:f?{id:f.id,ts:f.ts,note:f.data.note||"",choice:f.data.choice||null}:null,reask:g?{id:g.id,ts:g.ts}:null,answers:r.map(l=>({ts:l.ts,choice:l.data.choice||null,note:l.data.note||"",files:l.data.files||[],reply:l.reply,acted:ft(e,l.ts)}))}}i(xn,"ownerQuestion");const ge=i(e=>e.round??(Ce.test(e.url||"")?1:0),"roundOf");function $n(e,t){const n=i((o,r)=>o.confirm_of||(o.options||[]).some(a=>a.id===r.choice),"settles");return e.filter(o=>ge(o)===t&&o.answers.length).map(o=>[o,o.answers.at(-1)]).filter(([o,r])=>n(o,r)).map(([,o])=>o).sort((o,r)=>String(o.ts).localeCompare(String(r.ts))).at(-1)}i($n,"roundSettledBy");function An(e){const t=e.find(r=>r.request&&!e.some(a=>ge(a)>ge(r)));if(t)return{n:ge(t)+1,state:"making"};const n=Math.max(0,...e.map(ge));if(!n)return null;const o=$n(e,n);return o?{n,state:"closed",take:o.choice}:e.some(r=>ge(r)===n&&r.state!=="resolved")?{n,state:"back"}:null}i(An,"roundState");const Oe=i((e,t,n)=>{const o=e.get(t);o?o.push(n):e.set(t,[n])},"add"),xe=i((e,t)=>{const n=new Map;for(const o of e)Oe(n,t(o),o);return n},"groupBy");function En(e,t,n=new Set){const o=new Set(e.map(u=>u.id)),r=[...e];t.some(u=>!o.has(u.topic))&&r.push({id:"",title:"Other"});const a=xe(t,u=>o.has(u.topic)?u.topic:"");return r.map(u=>{const p=a.get(u.id)||[],f=i(l=>p.filter(w=>w.state===l).length,"count"),g=p.every(l=>l.state==="resolved")||n.has(u.id)&&!f("open"),c=p.length&&g?"resolved":"open";return{...u,state:c,questions:p.map(l=>l.id),open:f("open"),answered:f("answered"),replied:f("replied"),resolved:f("resolved"),round:An(p)}}).filter(u=>u.questions.length)}i(En,"ownerTopics");const gt={"mark-ready":"Mark ready","grill-more":"grill requested","prototype-request":"prototype requested","reask-request":"re-ask requested"},Bn="answers submitted",Rn="quick build: no grill",mt={reply:"Reply",build:"Implement"},kt=i(e=>mt[e.data.intent],"intentLabel"),wt=i(e=>e.kind==="item-message"&&!String(e.data.text||"").trim()&&!e.data.files?.length,"bareMessage"),_n=i((e,t)=>{if(wt(e)&&e.data.intent==="build")return kt(e);if(e.kind!=="prototype-request"||!t.has(e.data.question))return e.data.text||(e.data.files?.length?"":$(gt,e.kind))||"";const n=t.get(e.data.question),o=(n.options||[]).find(r=>r.id===e.data.choice);return[n.question,o&&`${o.id}. ${o.label}`,e.data.note].filter(Boolean).join(`
3
+ \u2192 `)},"actionText"),In=i((e,t)=>e.kind==="item-message"?wt(e)&&e.data.intent==="build"?{request:!0}:mt[e.data.intent]?{status:kt(e)}:{}:e.kind!=="grill-more"&&e.kind!=="prototype-request"?e.kind==="reask-request"?{request:!0}:{}:(e.data.question?t.has(e.data.question):String(e.data.text||"").trim()||e.data.files?.length)?{status:gt[e.kind]}:{request:!0},"requestOf"),ze=i(e=>[...e.filter(t=>t.who==="claude"&&!["status","agent",be.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 ht(e,t={}){const n=new Map,o=new Map;for(const c of t.items||[])Oe(n,c.topic,c),o.set(c.id,c.topic);const r=new Map,a=new Map,u=new Map,p=new Map,f=new Map,g=new Map;e.forEach((c,l)=>{g.set(c,l),c.data?.key&&jt.includes(c.kind)&&Oe(r,c.data.key,c),c.kind==="owner-answer"&&o.has(c.data?.id)&&Oe(a,o.get(c.data.id),c),c.kind==="ask"&&u.set(c.id,c)});for(const c of e.filter(l=>l.kind==="ask-edited").sort((l,w)=>String(l.ts).localeCompare(String(w.ts)))){p.set(c.data?.id,c.data?.text);for(const l of c.data?.files||[])Oe(f,c.data?.id,l)}return{byKey:r,answers:a,asks:u,edits:p,editFiles:f,questions:n,order:g}}i(ht,"threadIndex");const Je=i((e,t)=>{const n=t.filter(o=>o?.length);return n.length>1?n.flat().sort((o,r)=>e.order.get(o)-e.order.get(r)):[...n[0]||[]]},"inLogOrder"),qn=/; its log is \S*\/\.claude\/kickflip\/logs\/([^/\s]+\.log)\.$/,Mn=i(e=>{const t=!e.log&&typeof e.text=="string"?qn.exec(e.text):null;return t?{...e,text:`${e.text.slice(0,t.index)}.`,log:t[1]}:e},"withLog");function yt(e,{lines:t=[],events:n=[],owner:o={},working:r={},fromAsk:a=null,links:u=[],agents:p={},moved:f=[],index:g=ht(n,o)}){const c=e.startsWith("ask:")?[e.slice(4)]:[a,...f].filter(Boolean),l=[...new Set([e,...c.map(d=>`ask:${d}`)])],w=new Map((g.questions.get(`item:${e}`)||[]).map(d=>[d.id,d])),b=g.answers.get(`item:${e}`)||[],D=new Set([...w.values()].map(d=>d.round_of).filter(Boolean)),q=Ve(p).filter(J).map(d=>String(d.started||"")).filter(Boolean),L=new Set(b.filter(d=>ft(w.get(d.data.id),d.ts)||D.has(d.data.id)||q.some(x=>x>String(d.ts))).map(d=>d.id)),R=[...Ve(p).flatMap(d=>[...d.started?[{ts:d.started,who:"claude",kind:"agent",text:`${Ye(d)} started`,finished:!1,eta:d.done?null:d.eta,...ae(d)?{planner:!0}:{}}]:[],...d.done?[{ts:d.done,who:"claude",kind:"agent",text:`${Ye(d)} finished`,finished:!0,eta:null,...ae(d)?{planner:!0}:{}}]:[],...d.calls.length?[{ts:d.done||d.calls.at(-1).at,who:"claude",kind:"calls",text:Ye(d),calls:d.calls.map(x=>x.text),verified:d.verified}]:[]]),...t.map(Mn).map(d=>({ts:d.ts,who:d.who||"claude",...d.log?{log:d.log}:{},...d.kind==="status"?{kind:"status",...d.planner?{planner:!0}:{}}:{},...Object.values(be).includes(d.kind)?{kind:d.kind,ask:d.ask}:{},text:d.text||"",html:d.html||null,link:d.link||null,via:d.via||null})),...Je(g,l.map(d=>g.byKey.get(d))).map(d=>({ts:d.ts,who:"love",via:"site",kind:d.kind,text:_n(d,w),files:d.data.files||[],eventId:d.id,reply:d.reply,...In(d,w)})),...b.map(d=>{const x=[d.data.label||d.data.choice,d.data.note].filter(Boolean).join(" \xB7 ");return{ts:d.ts,who:"love",via:"questions",kind:d.kind,text:`${w.get(d.data.id).question}
4
+ \u2192 ${x}`,files:d.data.files||[],eventId:d.id,reply:d.reply,status:Bn}}),...Je(g,[...new Set(c)].map(d=>g.asks.has(d)?[g.asks.get(d)]:[])).flatMap(d=>[{ts:d.ts,who:"love",via:"ask",kind:d.kind,text:d.data?.text||"",files:d.data?.files||[],eventId:d.id,reply:d.reply,...f.includes(d.id)?{moved:!0}:{},...typeof d.data?.from?.title=="string"?{from:d.data.from.title}:{}},...d.data?.quick===!0?[{ts:d.ts,who:"love",kind:"quick-build",request:!0,text:Rn}]:[],...u.map(x=>({ts:d.ts,who:"claude",kind:"ask-link",text:x.folded?`Moved to ${x.ref}: ${x.title}`:`${x.became?"Became":"Added to"} ${x.ref}`,link:`#item=${encodeURIComponent(x.key)}`,html:null,via:null}))])].sort((d,x)=>String(d.ts).localeCompare(String(x.ts))),I=ze(R),{edits:G,editFiles:K}=g;for(const d of R){if(!d.eventId)continue;(d.kind==="ask"||d.kind==="item-message")&&typeof G.get(d.eventId)=="string"&&Object.assign(d,{text:G.get(d.eventId),edited:!0,files:[...d.files,...K.get(d.eventId)||[]]});const x=d.kind==="ask"&&(u.length>0||!!d.moved);d.state=d.reply?"replied":x||L.has(d.eventId)||I>String(d.ts)?"answered":$(r,d.eventId)?"working":"waiting",d.canDelete=d.kind==="item-message"&&(d.state==="working"||d.state==="waiting"),d.canEdit=d.canDelete}return R}i(yt,"threadOf");function Dn(e,t,n,o,r,a){const u=i((l,w)=>{const b=a.filter(q=>q.kind==="wave-triage"&&q.data?.[l]===w).pop(),D=r.filter(q=>q.topic===`${l}:${w}`&&(q.state==="open"||q.state==="answered")).length;return{running:!!(b&&!b.reply),questions:D}},"triageOf"),p=new Map(o.map(l=>[l.key,l])),f=i(l=>l.filter(w=>w.lane==="done"&&!We(w)).length,"merged"),g=n.map(l=>({l,cards:l.keys.map(w=>p.get(w)).filter(Boolean)})).map(l=>({...l,open:!l.l.finished_at&&l.cards.some(w=>w.lane!=="done")})).sort((l,w)=>Number(l.open)-Number(w.open));for(const{l,cards:w}of g)for(const b of w)b.lineup={slug:l.slug,title:l.title};const c=g.filter(l=>l.open).map(({l,cards:w})=>({kind:"lineup",slug:l.slug,title:l.title,goal:l.goal,keys:w.map(b=>b.key),phases:l.phases.map(b=>b.filter(D=>p.has(D))).filter(b=>b.length),next:Cn(w),merged:f(w),total:w.length,triage:u("lineup",l.slug)}));return e.fromWaves?[...c,...t.filter(l=>!l.finished).map(l=>({w:l,cards:o.filter(w=>w.wave===l.slug&&w.kind!=="ask")})).filter(({cards:l})=>l.length).map(({w:l,cards:w})=>({kind:"wave",slug:l.slug,title:l.title,goal:null,keys:w.map(b=>b.key),phases:null,next:null,merged:f(w),total:w.length,triage:u("wave",l.slug)}))]:c}i(Dn,"waveBandsOf");function Cn(e){const t=e.filter(a=>a.lane==="todo"),n=t.find(a=>a.ready&&a.buildable)||t[0];if(!n)return null;const o=n.ready&&n.buildable,r=o?"ready":n.held?"held":n.blockedBy.length?`waits on ${n.blockedBy.map(a=>a.ref).join(", ")}`:n.action?"needs you":n.unsorted?"new":n.state||"not ready";return{key:n.key,ref:n.ref,ready:o,word:r}}i(Cn,"nextOf");function ws(e,t,n,o){const r=e.waveBands.find(l=>l.kind==="lineup"&&l.slug===t);if(!r)return null;const a=new Map(e.items.map(l=>[l.key,l.lane])),u=r.keys.filter(l=>a.get(l)==="todo"),p=u.indexOf(n),f=p+o;if(p<0||f<0||f>=u.length)return null;[u[p],u[f]]=[u[f],u[p]];let g=0;const c=r.keys.map(l=>a.get(l)==="todo"?u[g++]:l);return g=0,r.phases.map(l=>c.slice(g,g+=l.length))}i(ws,"lineupMoved");const Nn=i(e=>e.phases||e.items.map(t=>[t]),"lineupPhases");function hs(e){const{owner:t={},topicItems:n={},events:o=[],threads:r={},prs:a={},working:u={}}=e,p=e.now??Date.now(),f=ht(o,t),g=new Set(o.filter(s=>s.kind==="ask-withdrawn"&&!s.data?.key).map(s=>s.data?.id)),c=new Map(o.filter(s=>s.kind==="ask"&&!g.has(s.id)).map(s=>[s.id,s])),l=i((s,m)=>new Map(o.filter(h=>h.kind===s).sort((h,O)=>String(h.ts).localeCompare(String(O.ts))).map(h=>[h.data?.[m],h.ts])),"latest"),w=l("ask-bump","id"),b=l("card-unbump","key"),D=new Map([...l("card-bump","key")].filter(([s,m])=>!(String(b.get(s)||"")>String(m)))),q=l("card-done","key"),L=l("card-merge","key"),R=e.autoMerge===!0,I=e.tickets,G=new Map(o.filter(s=>s.kind==="card-hold").sort((s,m)=>String(s.ts).localeCompare(String(m.ts))).map(s=>[s.data?.key,s])),K=new Map,d=e.askLinks||{},x=new Map;for(const[s,m]of Object.entries(d))c.has(s)&&x.set(m,[...x.get(m)||[],s]);const y=[],A=[],le=new Map,ee=new Map,P=new Map,te=new Map,Q=e.github?null:Rt(e.remote);for(const{slug:s,wave:m,agents:h={}}of e.waves){const O=e.github||m.repo||null;y.push({slug:s,title:m.title||s,status:m.status||null,internal:!!m.internal,finished:null,reviewers:(m.reviewers||[]).map(S=>S.name)}),m.items.forEach((S,_)=>{const B=`${s}/${S.id}`,Me=(x.get(B)||[]).filter(v=>v!==S.from_ask),ve=[S.from_ask,...Me].filter(v=>c.has(v)),Le=new Set(ve.map(v=>`ask:${v}`)),k=[...$(r,B)||[],...ve.flatMap(v=>$(r,`ask:${v}`)||[])];S.from_ask&&K.set(S.from_ask,[...K.get(S.from_ask)||[],{key:B,ref:Fe(m,S,I),became:!0}]);const F=yt(B,{lines:k,events:o,owner:t,working:u,fromAsk:S.from_ask||null,moved:Me,index:f});for(const v of F)v.eventId&&le.set(v.eventId,v.state);ee.set(B,ze(F)),A.push(sn({slug:s,wave:m,it:S,order:_,repo:O,remote:Q,base:e.branch||"main",prs:Mt(S,O).map(v=>({...v,gh:$(a,Ct(v))||null})),...(v=>({agents:v,builder:bn(v,$(r,B),p,e.moved?.[He($(h,S.id))]??null,$(e.alive,B)??null,!!e.commandRunning?.[He($(h,S.id))]),reachedPhase:vn(v,$(r,B)),eta:v.map(bt=>bt.eta).filter(Boolean).sort().pop()||null}))(Ve($(h,S.id))),worktree:He($(h,S.id))??S.worktree?.path??null,thread:k,events:[...Je(f,[B,...Le].map(v=>f.byKey.get(v))),...ve.map(v=>c.get(v))],working:F.some(v=>v.state==="working"),said:F.filter(v=>v.who==="love"&&(v.kind==="item-message"||v.kind==="owner-answer")),askedAt:(f.questions.get(`item:${B}`)||[]).filter(v=>v.asked_at).map(v=>v.asked_at),topicItems:n,boardReviewers:e.reviewers||[],now:p,bumpedAt:D.get(B),holdAsk:G.get(B),closedAt:q.get(B),mergeAt:L.get(B),autoMerge:R,skipDraft:e.skipDraft===!0,tickets:I}));const Pe=A[A.length-1];te.set(B,{parent:S.parent?vt(s,S.parent):null,related:(S.related||[]).map(v=>vt(s,v))}),Pe.lane==="done"&&P.set(B,Pe.closedAt||String(Pe.updatedAt||""))})}const C=new Map(A.map(s=>[s.key,s])),V=new Map,W=e.try||{},$e=e.autoBuild===!0,j=["web","app"].includes(W.kind)?W.kind:e.waves.some(({wave:s})=>s.items.some(m=>m.install?.url))?"app":"web";for(const s of A){if(s.kind!=="work"||s.lane==="done")continue;const m=$(W.cards,s.key)||{},h=m.head||s.pr?.headRefOid,O=j==="web"?m.sha:s.install?.sha,S=s.builder?.kind===De.install?"running":m.state||(j==="app"&&s.install?"ready":null);s.try={kind:j,state:S,stale:!!(O&&h&&!String(h).toLowerCase().startsWith(String(O).toLowerCase())),url:j==="web"?null:s.install?.url||null,port:j==="web"&&S==="ready"&&m.https||null,sha:O||null,changes:m.ahead>0,script:m.script===!0,autoBuild:$e}}const N=W.main,me=N?.script&&N.sha?{slug:N.slug,branch:N.branch||"main",sha:N.sha.slice(0,7),at:N.at,kind:j,state:N.state||null,url:j==="web"?null:e.main?.install?.url||null,port:j==="web"&&N.state==="ready"&&N.https||null,pull:W.pull?{running:W.pull.running===!0,error:W.pull.error||null}:null}:null,ke=e.askProgress||{},Ae=l("ask-done","id"),ie=xe(o.filter(s=>s.kind==="owner-answer"),s=>s.data?.id),we=xe(o.filter(s=>s.kind==="prototype-request"),s=>s.data?.question),Ee=xe(o.filter(s=>s.kind==="reask-request"),s=>s.data?.question),U=(t.items||[]).map(s=>xn(s,ie.get(s.id)||[],we.get(s.id)||[],Ee.get(s.id)||[])),ne=new Map(U.map(s=>[s.id,s])),Be=xe(U,s=>s.topic),X=i(s=>{const m=Be.get(s)||[];return{open:m.filter(h=>h.state==="open").length,answered:m.filter(h=>h.state==="answered").length}},"pendingOn");for(const s of c.values()){const m=`ask:${s.id}`,h=C.get($(d,s.id)),O=[...K.get(s.id)||[]],S=h&&!O.some(B=>B.key===h.key);if(S&&O.push({key:h.key,ref:h.ref,title:h.title,became:!1,folded:!0}),O.length&&!S){V.set(m,O[0].key);continue}if(!S&&$(d,s.id)){V.set(m,$(d,s.id));continue}const _=yt(m,{lines:$(r,m)||[],events:o,working:u,links:O,index:f});for(const B of _)B.eventId&&le.set(B.eventId,B.state);ee.set(m,ze(_)),A.push(wn(s,_,w.get(s.id),O.length>0||!!$(d,s.id),$(ke,s.id),Ae.get(s.id),X(`item:${m}`)))}for(const s of y){const m=A.filter(h=>h.wave===s.slug);if(s.finished=Xt(m),s.finished)for(const h of m)h.lane==="done"&&(h.fold=Gt(s.slug))}for(const s of A)s.lineup=null;const H=new Set((t.topics||[]).map(s=>s.id)),de=e.waves.flatMap(({slug:s,wave:m})=>(m.lineups||[]).map(h=>{const O=Nn(h).map(S=>S.map(_=>`${s}/${_}`));return{...h,phases:O,keys:O.flat()}})),ce=i(()=>En([...t.topics||[],...A.filter(s=>!H.has(`item:${s.key}`)).map(s=>({id:`item:${s.key}`,card:s.key,title:`${s.ref}: ${s.title}`,...s.kind==="ask"?{askedAt:s.ask.askedAt}:{}})),...de.filter(s=>!H.has(`lineup:${s.slug}`)).map(s=>({id:`lineup:${s.slug}`,title:s.title,summary:"Wave triage."})),...(e.fromWaves?y:[]).filter(s=>!H.has(`wave:${s.slug}`)).map(s=>({id:`wave:${s.slug}`,title:s.title,summary:"Wave triage."}))],U,new Set(A.filter(z).map(s=>`item:${s.key}`))),"topicsOf"),E=new Map(ce().map(s=>[s.id,s]));for(const s of A){const m=E.get(`item:${s.key}`);if(!m){s.questions=null;continue}const h=m.questions.filter(_=>ne.get(_)?.state!=="resolved"),O=m.questions.find(_=>ne.get(_)?.state==="open")||h[0]||m.questions[0],S=m.questions.map(_=>ne.get(_)).filter(_=>_?.state==="open");s.questions={topic:m.id,state:m.state,open:m.open,answered:m.answered,replied:m.replied,resolved:m.resolved,first:O,askedAt:S.map(_=>_.asked_at).filter(Boolean).sort(),fromAsks:S.length>0&&S.every(_=>_.ask)}}const se=new Map(A.map(s=>[s.key,s]));for(const s of A){s.blockedBy=s.kind!=="work"||s.lane==="done"?[]:s.deps.map(h=>se.get(String(h).includes("/")?h:`${s.wave}/${h}`)).filter(h=>h&&h.lane!=="done"&&!h.reopened).map(St),mn(s,ne,R),s.lane==="todo"&&s.kind==="work"&&!s.held&&dt(s)&&(s.lane="progress"),s.unpicked=s.kind==="work"&&s.lane==="todo"&&!!pn(U,s.key),s.unpicked&&(s.state="prototyping"),s.unpicked&&!s.action&&(s.next=fn),s.buildable=cn(s);const m=s.kind==="work"&&s.lane==="todo";s.unsorted=m&&(!!s.fromAsk||s.unfiled)&&!s.state,s.ready=m&&s.state==="ready"&&!s.blockedBy.length&&!s.action}Pn(A,se,te);const T=new Map((t.items||[]).map(s=>[s.id,s.topic])),Re=i(s=>s.kind==="owner-answer"?T.has(s.data?.id)?/^item:(.+)$/.exec(T.get(s.data.id))?.[1]||null:"":s.kind==="ask"?`ask:${s.id}`:s.data?.key||(s.kind.startsWith("ask-")&&s.data?.id?`ask:${s.data.id}`:null),"ownCardOf"),he=i(s=>{const m=Re(s);return V.get(m)||m},"cardOf"),ue=i(s=>{const m=s.startsWith("ask:")?s.slice(4):null,h=m&&$(ke,m)?.state==="done"?$(ke,m).at:null;return[q.get(s),m&&Ae.get(m),h,P.get(s)].filter(Boolean).sort().pop()||""},"closedAt"),_e=i(s=>{const m=he(s);return m===null?!s.reply:!se.has(m)||!(ue(m)<String($(u,s.id)))?!1:le.has(s.id)?le.get(s.id)==="working":!s.reply&&!V.has(Re(s))&&!(String(ee.get(m)||"")>String(s.ts))},"unanswered"),oe=o.filter(s=>$(u,s.id)&&_e(s)).map(s=>({id:s.id,kind:s.kind,key:he(s),data:s.data,since:$(u,s.id)}));for(const s of A)s.working=oe.some(m=>m.key===s.key),s.kind==="work"&&s.lane==="progress"&&!s.builder&&!s.next&&s.waitsOn!=="checking"&&!s.working&&!s.implementAt&&(s.next=ct),s.sortAt=jn[s.lane](s)||(["review","stale"].includes(s.lane)?null:s.updatedAt)||null;for(const s of A){if(s.kind!=="work")continue;const m=(Be.get(`item:${s.key}`)||[]).filter(O=>O.state==="answered").map(O=>O.answers.at(-1).ts).sort().pop(),h=oe.filter(O=>O.key===s.key).map(O=>String(O.since)).sort()[0];s.orchestrator=["progress","todo","stale"].includes(s.lane)||s.waitsOn==="checking"||s.lane==="review"&&s.builder?.stalled?ts(s,s.waitFacts,{answeredAt:m,workingSince:h}):null,delete s.waitFacts}A.sort(Pt);const Te=Dn(e,y,de,A,U,o),pe=ce(),ye=_t({on:e.autoReview,incoming:e.incoming,records:e.reviewRecords,events:o,now:p,refs:new Map(A.filter(s=>s.kind==="work").map(s=>[s.key,s.ref]))}),Ie=[...Fn(A,pe,U),...It(ye)],qe=new Map(Ie.filter(s=>s.questions).map((s,m)=>[s.topic||`item:${s.key}`,m])),fe=i(s=>qe.get(s.id)??qe.size,"rankOf");pe.sort((s,m)=>fe(s)-fe(m));const Se=A.filter(s=>s.ask?.answerAt).sort((s,m)=>m.ask.answerAt.localeCompare(s.ask.answerAt)).map(s=>({key:s.key,id:s.id,text:s.title,at:s.ask.answerAt}));return Tn({kind:j,main:me,remote:Q&&{host:Q.host,name:`${Q.host}/${Q.path}`},waves:y,waveBands:Te,items:A,moved:Object.fromEntries(V),answers:Se,owner:U,ownerTopics:pe,reviews:ye,needs:Ie,working:oe.length,workingOn:oe,checks:Un(e,p)},e)}i(hs,"buildBoard");function Tn(e,{listen:t,prompts:n}={}){const o=[...Gn(n),...e.needs];return{...e,needs:o,needsSummary:Kn(o),checks:{...e.checks,watcher:{listening:"running",asleep:"asleep",waking:"waking"}[t]||"stopped"}}}i(Tn,"withHub");const St=i(e=>({key:e.key,ref:e.ref}),"linkOf"),vt=i((e,t)=>String(t).includes("/")?String(t):`${e}/${t}`,"linkKey"),Ln=i((e,t)=>e.ref.localeCompare(t.ref,void 0,{numeric:!0}),"byRef");function Pn(e,t,n){const o=new Map,r=new Map,a=new Map,u=i((f,g,c)=>f.set(g,[...f.get(g)||[],c]),"add");for(const[f,g]of n){g.parent&&u(o,g.parent,f);for(const c of g.related)c!==f&&(u(r,f,c),u(r,c,f))}for(const f of e)for(const g of f.blockedBy||[])u(a,g.key,f.key);const p=i((f=[])=>[...new Set(f)].map(g=>t.get(g)).filter(Boolean).map(St).sort(Ln),"cards");for(const f of e){const g=n.get(f.key)?.parent;f.parent=g?{key:g,ref:t.get(g)?.ref||g.slice(g.indexOf("/")+1)}:null,f.children=p(o.get(f.key)),f.related=p(r.get(f.key)),f.waitsOnIt=p(a.get(f.key))}}i(Pn,"linkCards");const jn={todo:i(e=>e.created,"todo"),progress:i(e=>e.progressSince,"progress"),review:i(e=>e.reviewSince,"review"),stale:i(e=>e.reviewSince,"stale"),done:i(e=>e.closedAt,"done"),asks:i(e=>e.ask.answerAt,"asks")},Z=i((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural");function Un({checked:e,watcher:t,replyAt:n,threads:o={},working:r={},waves:a=[]},u){const p=Number(e?.every)||30,g=[n,t?.since,...Object.values(r),...Object.values(o).flat().filter(l=>(l.who||"claude")==="claude").map(l=>l.ts),...a.flatMap(l=>Object.values(l.agents||{}).flatMap(w=>Object.values(w||{})).map(w=>w?.done||w?.started))].filter(l=>typeof l=="string"&&!Number.isNaN(Date.parse(l))).reduce((l,w)=>l&&Date.parse(l)>Date.parse(w)?l:w,null),c=!!e?.idle;return{at:e?.at||null,every:c?null:p,idle:c,late:!c&&!!e?.at&&u-Date.parse(e.at)>2*p*6e4,claudeAt:g}}i(Un,"checksOf");function Fn(e,t,n){const o=new Set(e.map(p=>p.questions?.topic).filter(Boolean)),r=i(p=>p.find(f=>n.find(g=>g.id===f)?.state==="open")||p[0],"firstOpen"),a=t.filter(p=>p.state!=="resolved"&&p.open>0&&!o.has(p.id)).map(p=>{const f=`questions.html#${r(p.questions)}`,g=/^(?:lineup|wave):(.+)$/.exec(p.id)?.[1]||null;return{kind:"Question",title:p.title,text:`${p.title} \xB7 ${Z(p.open,"question")}`,url:f,topic:p.id,band:g,questions:{open:p.open,url:f},ready:null,since:n.filter(c=>c.topic===p.id&&c.state==="open").map(c=>c.asked_at).filter(Boolean).sort()[0]||null}}),u=e.map(p=>{const f=p.questions&&p.questions.state!=="resolved"&&p.questions.open>0?{open:p.questions.open,url:`questions.html#${p.questions.first}`}:null,g=p.waitsOn==="ready"?p.pr.url:null,c=!f&&!g&&p.action?{label:p.action.label,url:p.action.url}:null;if(!f&&!g&&!c)return null;const l=`${p.ref}: ${p.title}`,w=[l,f&&Z(f.open,"question"),g&&"Ready on GitHub",c?.label].filter(Boolean).join(" \xB7 ");return{kind:f?"Question":g?"Tap Ready":"Action needed",title:l,text:w,url:`#item=${encodeURIComponent(p.key)}`,key:p.key,questions:f,ready:g,action:c,since:p.created||null}}).filter(Boolean);return[...a,...u].sort(Wn)}i(Fn,"needsOf");const Wn=i((e,t)=>e.since&&t.since?e.since.localeCompare(t.since):!!t.since-!!e.since,"oldestFirst");function Gn(e=[]){return e.map(t=>{const n=t.questions?.length?`Question: ${t.questions.map(o=>o.question).join(" \xB7 ")}`:`${t.tool}: ${t.detail||t.action}`;return{kind:"Prompt",title:n,text:n,url:"",prompt:t}})}i(Gn,"promptLines");function Kn(e){const t=e.filter(a=>a.prompt).length,n=e.reduce((a,u)=>a+(u.questions?.open||0),0),o=e.filter(a=>a.ready).length,r=e.filter(a=>a.review).length;return[t&&Z(t,"prompt"),n&&Z(n,"question"),o&&`${Z(o,"draft")} waiting on Ready`,r&&`${Z(r,"review")} held`].filter(Boolean).join(" \xB7 ")}i(Kn,"needsSummary");function ys(e){const t=i((...n)=>e.items.filter(o=>n.includes(o.lane)).length,"count");return{items:e.needs.map(({kind:n,text:o,url:r})=>({kind:n,text:o,url:r})),working:e.working,summary:e.needsSummary,lanes:{review:t("review","stale"),progress:t("progress"),todo:t("todo")},building:e.items.some(n=>(n.agents||[]).some(o=>!o.done))}}i(ys,"needsAnswer");const Qn=i(e=>e.buildable&&e.state==="ready"&&!e.held&&!e.unsorted&&!e.blockedBy.length&&!e.questions?.open&&!e.questions?.answered&&!e.grilling&&!e.prototyping,"pullableCard"),Vn=10;function Hn(e,{cap:t=Vn,pulled:n=[]}={}){const o=e.filter(c=>!z(c)),r=i(c=>(c.agents||[]).filter(l=>!l.done),"running"),a=o.filter(c=>c.waitsOn==="checking"||r(c).some(J)).length,u=o.filter(c=>Qn(c)&&!c.working).map(c=>c.key),p=o.filter(c=>n.includes(c.key)&&(u.includes(c.key)||c.buildable&&c.working)).map(c=>c.key),f=o.filter(c=>c.implementAt&&c.state==="ready"&&!c.blockedBy.length).map(c=>c.key),g=u.filter(c=>!p.includes(c)).slice(0,Math.max(0,t-a-p.length-f.length));return{idle:!a,pullable:u,waiting:p,starts:f,pulls:g}}i(Hn,"pullOf");function Ss(e,t,n){return e.filter(o=>o.kind==="work"&&!z(o)&&o.waitsOn!=="checking"&&!(o.agents||[]).some(r=>r.started&&!r.done)).flatMap(o=>{const r=(o.prs||[]).find(u=>u.state==="OPEN"&&u.mergeable==="CONFLICTING"&&u.repo===o.repo&&u.headRefOid),a=r&&`${r.headRefOid}@${n}`;return r&&$(t,o.key)!==a?[{key:o.key,pr:r.number,branch:r.headRefName,conflict:a}]:[]})}i(Ss,"rebasesDue");const Xn=3;function vs(e,{cap:t=Xn}={}){const n=e.filter(a=>!z(a)),o=n.filter(a=>(a.agents||[]).some(u=>ae(u)&&u.started&&!u.done)).length;return n.filter(a=>a.buildable&&a.state!=="ready"&&!a.unsorted&&!a.blockedBy.length&&!a.held&&!a.working&&!a.grilling&&!a.prototyping&&!a.questions&&!(a.agents||[]).some(ae)).slice(0,Math.max(0,t-o)).map(a=>a.key)}i(vs,"arrivalsOf");function Yn(e){return e.filter(t=>t.lane==="todo"||t.lane==="stale").map(t=>JSON.stringify([t.key,t.title,t.deps||[]])).sort().join(`
5
+ `)}i(Yn,"todoOf");function bs(e){const t=e.filter(o=>o.kind==="work"&&o.lane!=="done"&&o.questions?.open>0),n=t.map(o=>JSON.stringify([o.key,o.questions.open,o.questions.askedAt||[]])).sort().join(`
6
+ `);return{waiting:t.map(o=>o.key),seen:`${n}
7
7
  --
8
- ${Fn(e)}`}}d(ps,"triageOf");const Kn=100,Qn=["key","kind","id","ref","title","lane","status","wave","waveTitle","fold","internal","ticket","ticketSource","linear","pr","prs","review","reviewers","risky","sortAt","threadCount","othersAt","hasNotes","questions","next","ask","action","actionButton","builder","working","waitsOn","reachedPhase","grilling","refusal","install","parent","children","related","waitsOnIt","blockedBy","ready","finishable","reopened","manualSteps","branch","worktree"],fs=d(e=>Object.fromEntries(Qn.filter(t=>t in e).map(t=>[t,e[t]])),"slimDone");function gs(e,t=Kn){const s=new Set((e.waveBands||[]).flatMap(r=>r.keys)),o=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=>["done","merged","dropped"].includes(r.status)&&!s.has(r.key)&&!o.has(r.key)&&(!r.questions||r.questions.state==="resolved"))}d(gs,"archivedOf");const Gn=d(e=>e.startsWith("ask:")?`ask-${e.slice(4)}`:`item-${e}`,"pushTag");function ks(e){const t=d(a=>e.owner.filter(p=>p.topic===a&&p.state==="open").map(({id:p,question:c})=>({id:p,question:c})),"open"),s=[R.ready,R.merge],o=e.items.filter(a=>a.action).map(a=>{const p=We.has(a.action.kind)?t(a.questions.topic):[];return{tag:Gn(a.key),kind:a.action.kind,title:`${a.ref}: ${a.action.label}`,body:p[0]?.question||a.title,url:p.length?a.action.url:`#item=${encodeURIComponent(a.key)}`,now:!s.includes(a.action.kind),questions:p}}),r=e.needs.filter(a=>a.topic).map(a=>{const p=t(a.topic);return{tag:`topic-${a.topic}`,kind:R.questions,title:a.text,body:p[0]?.question||a.title,url:a.url,now:!0,questions:p}});return[...o,...r,...Bt(e.reviews)]}d(ks,"ownerActions");function ms(e,t){const s=e.owner.find(a=>a.id===t),o=/^item:([^/:]+\/[^/]+)$/.exec(s?.topic||"")?.[1],r=o&&e.items.find(a=>a.key===o);return!r||r.kind!=="work"||r.lane==="done"||r.held||r.blockedBy.length||r.action||r.unpicked||r.pr||r.pushed||![null,"planned","waiting"].includes(r.status)||r.agents.some(a=>!a.done)||e.owner.some(a=>a.topic===s.topic&&a.state==="open")?null:o}d(ms,"startedByAnswer");function ws(e,{pulled:t=[]}={}){return!e.items.filter(r=>!de(r)).some(r=>r.waitsOn==="checking"||r.grilling||r.prototyping||(r.agents||[]).some(a=>!a.done))&&!e.working&&!Wn(e.items,{pulled:t}).waiting.length}d(ws,"strictlyIdle");function Vn(e,t,{answeredAt:s,workingSince:o}){const r=d(f=>e.agents.some(k=>k.kind===f&&k.started&&!k.done),"running"),a=[e.progressSince,...e.agents.map(f=>f.done)].filter(Boolean).map(String).sort().pop()||null,p=t.ask?{kind:"ask",since:t.ask.at,next:`Answer the builder's ask: ${t.ask.text}`}:s?{kind:"answer",since:s,next:"Act on the owner's answer"}:We.has(e.action?.kind)?null:e.waitsOn==="checking"?t.unverified?{kind:"calls",since:t.statusAt,next:t.next||"Verify the builder's judgment calls"}:{kind:"checking",since:t.statusAt,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===at&&a?{kind:"unowned",since:a,next:"Start a builder on it, or set its Next"}:null;if(!p?.since)return null;const c=String(p.since),u=[t.writes.find(f=>f>c),o].filter(Boolean).sort()[0]||null;return{kind:p.kind,since:c,picked:u,next:p.next}}d(Vn,"orchestratorWaitOf");function hs(e){return e.items.filter(t=>t.orchestrator).map(t=>({key:t.key,ref:t.ref,title:t.title,...t.orchestrator}))}d(hs,"orchestratorWaits");const ys=30*6e4,Hn=15;function Ss(e,{idle:t,now:s}){const o=s.toISOString(),r=e.last||o;return t?e.since?e.pushed||s-Date.parse(e.since)<Hn*6e4?{state:{...e,last:r},push:!1}:{state:{last:o,since:e.since,pushed:!0},push:!0}:{state:{last:r,since:o},push:!1}:{state:{last:r},push:!1}}d(Ss,"idleStep");function vs(e,t){const s=d(u=>String(u.closedAt||"")>t,"after"),o=e.filter(u=>u.kind==="work"&&u.lane==="done"&&!je(u)&&s(u)),r=new Map;for(const u of e)u.lineup&&r.set(u.lineup.slug,[...r.get(u.lineup.slug)||[],u]);const a=[...r.values()].filter(u=>u.every(f=>f.lane==="done")&&u.some(s)).map(u=>u[0].lineup.title),p=o.slice(0,3).map(u=>u.ref).join(", ")+(o.length>3?` and ${o.length-3} more`:"");return[o.length&&`${o.length} ${o.length===1?"card":"cards"} landed: ${p}`,...a.map(u=>`${u} finished`)].filter(Boolean).join(" \xB7 ")||"Nothing closed since the last idle notification."}d(vs,"idleSummary");export{R as ACTION_KIND,Se as BUILDER_ASK,Re as BUILDER_KIND,Nt as BUILDER_STALLED_AFTER,Je as BUILD_REFUSED,Y as BUTTON,Qn as DONE_FIELDS,Kn as DONE_KEPT,Hn as IDLE_MINUTES,Mt as ITEM_EVENTS,rs as ITEM_STATUSES,Un as MAX_IMPLEMENTERS,at as NO_NEXT,ys as ORCHESTRATOR_PUSH_AFTER,gn as PLANNER_WORD,ln as PROTOTYPE_AGAIN,ls as PROTOTYPE_WAIT,oe as PR_STATE,gs as archivedOf,us as buildBoard,z as builds,Ss as idleStep,vs as idleSummary,ds as lineupMoved,In as lineupPhases,tn as mergeBlockers,yn as modelName,cs as needsAnswer,an as noTakePicked,hs as orchestratorWaits,as as owesNext,ks as ownerActions,Sn as ownerQuestion,rn as picksNoTake,ue as plans,is as prototypeWaits,it as providerOf,Wn as pullOf,Gn as pushTag,Pe as refOf,ce as roundOf,vn as roundSettledBy,fs as slimDone,ms as startedByAnswer,ws as strictlyIdle,ct as threadIndex,pt as threadOf,Fn as todoOf,ps as triageOf,Lt as waveFold,Dn as withHub};
8
+ ${Yn(e)}`}}i(bs,"triageOf");const zn=100,Jn=["key","kind","id","ref","title","lane","status","wave","waveTitle","fold","internal","ticket","ticketSource","linear","pr","prs","review","reviewers","risky","sortAt","threadCount","othersAt","hasNotes","questions","next","ask","action","actionButton","builder","working","waitsOn","reachedPhase","grilling","refusal","install","parent","children","related","waitsOnIt","blockedBy","ready","finishable","reopened","manualSteps","branch","worktree"],Os=i(e=>Object.fromEntries(Jn.filter(t=>t in e).map(t=>[t,e[t]])),"slimDone");function xs(e,t=zn){const n=new Set((e.waveBands||[]).flatMap(r=>r.keys)),o=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=>["done","merged","dropped"].includes(r.status)&&!n.has(r.key)&&!o.has(r.key)&&(!r.questions||r.questions.state==="resolved"))}i(xs,"archivedOf");const Zn=i(e=>e.startsWith("ask:")?`ask-${e.slice(4)}`:`item-${e}`,"pushTag");function $s(e){const t=i(a=>e.owner.filter(u=>u.topic===a&&u.state==="open").map(({id:u,question:p})=>({id:u,question:p})),"open"),n=[M.ready,M.merge],o=e.items.filter(a=>a.action).map(a=>{const u=Ke.has(a.action.kind)?t(a.questions.topic):[];return{tag:Zn(a.key),kind:a.action.kind,title:`${a.ref}: ${a.action.label}`,body:u[0]?.question||a.title,url:u.length?a.action.url:`#item=${encodeURIComponent(a.key)}`,now:!n.includes(a.action.kind),questions:u}}),r=e.needs.filter(a=>a.topic).map(a=>{const u=t(a.topic);return{tag:`topic-${a.topic}`,kind:M.questions,title:a.text,body:u[0]?.question||a.title,url:a.url,now:!0,questions:u}});return[...o,...r,...qt(e.reviews)]}i($s,"ownerActions");function As(e,t){const n=e.owner.find(a=>a.id===t),o=/^item:([^/:]+\/[^/]+)$/.exec(n?.topic||"")?.[1],r=o&&e.items.find(a=>a.key===o);return!r||r.kind!=="work"||r.lane==="done"||r.held||r.blockedBy.length||r.action||r.unpicked||r.pr||r.pushed||![null,"waiting"].includes(r.status)||r.agents.some(a=>!a.done)||e.owner.some(a=>a.topic===n.topic&&a.state==="open")?null:o}i(As,"startedByAnswer");function Es(e,{pulled:t=[]}={}){return!e.items.filter(r=>!z(r)).some(r=>r.waitsOn==="checking"||r.grilling||r.prototyping||(r.agents||[]).some(a=>!a.done))&&!e.working&&!Hn(e.items,{pulled:t}).waiting.length}i(Es,"strictlyIdle");const es="Fold the Implement message into the notes, then item set --state ready to start the build";function ts(e,t,{answeredAt:n,workingSince:o}){const r=i(g=>e.agents.some(c=>c.kind===g&&c.started&&!c.done),"running"),a=[e.progressSince,...e.agents.map(g=>g.done)].filter(Boolean).map(String).sort().pop()||null,u=t.ask?{kind:"ask",since:t.ask.at,next:`Answer the builder's ask: ${t.ask.text}`}:n?{kind:"answer",since:n,next:"Act on the owner's answer"}:e.implementAt?e.state==="ready"?null:{kind:"implement",since:e.implementAt,next:es}:Ke.has(e.action?.kind)?null:e.builder?.stalled?{kind:"stalled",since:e.builder.silentSince,next:"Find out why the builder went silent or stopped, then restart or finish its run"}:e.lane==="stale"&&e.inReviewSince?{kind:"stale",since:new Date(Date.parse(e.inReviewSince)+nt).toISOString(),next:"Find out why the review went stale and fix what you can: rebase, CI, comments, a silent reviewer"}:e.waitsOn==="checking"?t.unverified?{kind:"calls",since:t.statusAt,next:t.next||"Verify the builder's judgment calls"}:{kind:"checking",since:t.statusAt,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===ct&&a?{kind:"unowned",since:a,next:"Start a builder on it, or set its Next"}:null;if(!u?.since)return null;const p=String(u.since),f=[t.writes.find(g=>g>p),o].filter(Boolean).sort()[0]||null;return{kind:u.kind,since:p,picked:f,next:u.next}}i(ts,"orchestratorWaitOf");function Bs(e){return e.items.filter(t=>t.orchestrator).map(t=>({key:t.key,ref:t.ref,title:t.title,...t.orchestrator}))}i(Bs,"orchestratorWaits");const Rs=30*6e4,ns=15;function _s(e,{idle:t,now:n}){const o=n.toISOString(),r=e.last||o;return t?e.since?e.pushed||n-Date.parse(e.since)<ns*6e4?{state:{...e,last:r},push:!1}:{state:{last:o,since:e.since,pushed:!0},push:!0}:{state:{last:r,since:o},push:!1}:{state:{last:r},push:!1}}i(_s,"idleStep");function Is(e,t){const n=i(f=>String(f.closedAt||"")>t,"after"),o=e.filter(f=>f.kind==="work"&&f.lane==="done"&&!We(f)&&n(f)),r=new Map;for(const f of e)f.lineup&&r.set(f.lineup.slug,[...r.get(f.lineup.slug)||[],f]);const a=[...r.values()].filter(f=>f.every(g=>g.lane==="done")&&f.some(n)).map(f=>f[0].lineup.title),u=o.slice(0,3).map(f=>f.ref).join(", ")+(o.length>3?` and ${o.length-3} more`:"");return[o.length&&`${o.length} ${o.length===1?"card":"cards"} landed: ${u}`,...a.map(f=>`${f} finished`)].filter(Boolean).join(" \xB7 ")||"Nothing closed since the last idle notification."}i(Is,"idleSummary");export{M as ACTION_KIND,be as BUILDER_ASK,De as BUILDER_KIND,Ft as BUILDER_QUIET_AFTER,Ut as BUILDER_STALLED_AFTER,tt as BUILD_REFUSED,Y as BUTTON,Jn as DONE_FIELDS,zn as DONE_KEPT,ns as IDLE_MINUTES,jt as ITEM_EVENTS,fs as ITEM_STATUSES,Vn as MAX_IMPLEMENTERS,Xn as MAX_PLANNERS,ct as NO_NEXT,Rs as ORCHESTRATOR_PUSH_AFTER,yn as PLANNER_WORD,fn as PROTOTYPE_AGAIN,ms as PROTOTYPE_WAIT,re as PR_STATE,xs as archivedOf,vs as arrivalsOf,hs as buildBoard,J as builds,_s as idleStep,Is as idleSummary,ws as lineupMoved,Nn as lineupPhases,an as mergeBlockers,On as modelName,ys as needsAnswer,pn as noTakePicked,Bs as orchestratorWaits,gs as owesNext,$s as ownerActions,xn as ownerQuestion,un as picksNoTake,ae as plans,ks as prototypeWaits,pt as providerOf,Hn as pullOf,Zn as pushTag,Ss as rebasesDue,Fe as refOf,ge as roundOf,$n as roundSettledBy,Os as slimDone,As as startedByAnswer,Es as strictlyIdle,ht as threadIndex,yt as threadOf,Yn as todoOf,bs as triageOf,Gt as waveFold,Tn as withHub};
package/board/finish.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var N=Object.defineProperty;var u=(t,a)=>N(t,"name",{value:a,configurable:!0});import W from"node:fs";import x from"node:path";import{spawnSync as j}from"node:child_process";import*as n from"./store.mjs";import{builderRepo as M,git as b,joiningLand as v,landInTurn as A,passTests as E,syncBase as B,worktreesDir as D}from"./worktree.mjs";import{readPermissions as F}from"./permissions.mjs";import{launchBuilder as H}from"./headless.mjs";import{boardAt as C}from"../hub/boards.mjs";import{boardRepo as R}from"../hub/board-repo.mjs";const w=u(t=>{throw new n.BoardError(t)},"fail"),L=u(t=>typeof t=="string"&&t.trim()?t.trim():w("--text must be non-empty text"),"said");async function I(t,a,{text:r,ownerStep:o,check:e,repo:i,onWait:d}){const m=a.split("/")[1],p=await n.recordedWorktree(t,a),{repo:c,base:s,remote:l}=M(t,{repo:i??p?.repo}),h={path:p?.path??x.join(D(),m),branch:p?.branch??m,repo:x.resolve(c),base:s},f=await n.cardName(t,a),g=await n.readBoardSettings(t),$=l?R(C(t).route).github:null;if(l&&(!$||g.prs))return V(t,a,{...h,ref:f,text:L(r)});const T=await v(f,()=>P(t,a,{tree:h,ref:f,base:s,remote:l,repo:c,settings:g,text:r,ownerStep:o,check:e,onWait:d}));return T.joined?await n.isFinished(t,a)?{said:"landed and done",lines:[]}:I(t,a,{text:r,ownerStep:o,check:e,repo:i,onWait:d}):T}u(I,"finishCard");async function P(t,a,{tree:r,ref:o,base:e,remote:i,repo:d,settings:m,text:p,ownerStep:c,check:s,onWait:l}){await n.checkClose(t,a,p,c,s),await n.checkCallsVerified(t,a),i&&(B(r.repo,e),b(r.repo,"branch","--unset-upstream",r.branch));const h=u($=>n.appendThread(t,a,{text:`Waiting for the test slot: ${$} is running the suite`,kind:"status"}),"onWaitTests"),f=m.auto_merge||!!(await n.heldMerge(t,a))?.tapped;if(await A({...r,ref:o},{hold:!f,onWait:l,onWaitTests:h,sync:u(()=>i&&B(r.repo,e),"sync")}),!f){const $=await n.setItem(t,a,{mergeReady:r.branch,ownerStep:c,check:s});return await n.appendThread(t,a,{text:p}),{said:"verified; waits for your Merge",lines:$.lines}}const g=await n.setItem(t,a,{status:"done",text:p,ownerStep:c,check:s});return{said:c===void 0?"landed and done":`landed; waits on the owner step "${c.trim()}"`,lines:[...g.lines,...await q(t,a,d,e)]}}u(P,"landCard");async function Y(t,a,{launch:r=H}={}){(await n.heldMerge(t,a))?.tapped||w(`${a} isn't waiting on a Merge tap`);try{const{base:e}=M(t,{repo:(await n.recordedWorktree(t,a))?.repo}),i=u(d=>n.appendThread(t,a,{text:`Waiting for ${d} to land`,kind:"status"}),"onWait");return await I(t,a,{text:`Landed on ${e} on your Merge.`,onWait:i})}catch(e){if(!(e instanceof n.BoardError))throw e;const i=e.message.split(`
2
- `)[0];if(/^rebasing .+ conflicts in |^tests failed in /.test(i)){await n.appendThread(t,a,{text:`Not merged yet: ${i}. A lander fixes it and lands it.`});try{await r(t,{key:a,model:await n.builderModel(t,a)},{lander:!0})}catch(d){await n.appendThread(t,a,{text:`Couldn't launch the lander headless (${d.message}); land it with board.mjs land ${a}.`})}}else await n.appendThread(t,a,{text:`Not merged: ${i}. Tap Merge again.`});throw e}}u(Y,"landHeld");async function q(t,a,r,o){if(!(await F(r)).pushMain)return[];const e=b(r,"push","--quiet","origin",o);if(e.ok)return[`pushed ${o} to origin`];const i=`${o} didn't reach origin: ${e.err}; push it with git -C ${r} push origin ${o}`;return await n.appendThread(t,a,{text:`Landed, but ${i}`}),[`landed, but ${i}`]}u(q,"pushBase");async function V(t,a,{path:r,branch:o,base:e,ref:i,text:d}){await n.checkCallsVerified(t,a),W.existsSync(r)||w(`no worktree at ${r}`),b(r,"status","--porcelain").out&&w(`${r} has uncommitted changes; commit them there first`),Number(b(r,"rev-list","--count",`refs/remotes/origin/${e}..HEAD`).out)===0&&w(`${o} has no commits beyond ${e}; nothing to send for review`),await E(r,{outcome:"nothing was pushed"});const m=b(r,"push","--quiet","origin",`HEAD:refs/heads/${o}`);m.ok||w(`could not push ${o} to origin: ${m.err}`);const{github:p}=R(C(t).route);if(!p){const g=await n.setItem(t,a,{pushed:o});return await n.appendThread(t,a,{text:d}),{said:`pushed ${o} for its merge`,lines:g.lines}}const{title:c}=await n.briefFacts(t,a),s=j("gh",["pr","create","--draft","--repo",p,"--base",e,"--head",o,"--title",`${i}: ${c}`,"--body",d],{cwd:r,encoding:"utf8"}),l=`${s.stdout||""}
3
- ${s.stderr||""}`,h=(s.status===0||/already exists/.test(l))&&/\/pull\/(\d+)/.exec(l)?.[1];h||w(`could not open a draft PR for ${o}: ${(s.stderr||s.error?.message||`gh exited ${s.status}`).trim().split(`
4
- `)[0]}`);const f=await n.setItem(t,a,{pr:Number(h)});return await n.appendThread(t,a,{text:d}),{said:`draft PR #${h} opened`,lines:f.lines}}u(V,"sendForReview");export{I as finishCard,Y as landHeld};
1
+ var D=Object.defineProperty;var c=(t,a)=>D(t,"name",{value:a,configurable:!0});import H from"node:fs";import R from"node:path";import{spawnSync as I}from"node:child_process";import*as r from"./store.mjs";import{builderRepo as M,git as f,joiningLand as N,landInTurn as P,passTests as j,syncBase as v,worktreesDir as L}from"./worktree.mjs";import{readPermissions as q}from"./permissions.mjs";import{launchBuilder as F}from"./headless.mjs";import{boardAt as x}from"../hub/boards.mjs";import{boardRepo as A}from"../hub/board-repo.mjs";const T=c(t=>{throw new r.BoardError(t)},"fail"),W=c(t=>typeof t=="string"&&t.trim()?t.trim():T("--text must be non-empty text"),"said");async function B(t,a,{text:e,ownerStep:n,check:o,repo:i,onWait:s}){const h=a.split("/")[1],d=await r.recordedWorktree(t,a),{repo:p,base:l,remote:g}=M(t,{repo:i??d?.repo}),u={path:d?.path??R.join(L(),h),branch:d?.branch??h,repo:R.resolve(p),base:l},m=await r.cardName(t,a),w=await r.readBoardSettings(t),b=g?A(x(t).route).github:null;if(g&&(!b||w.prs))return z(t,a,{...u,ref:m,text:W(e)});const $=await N(m,()=>V(t,a,{tree:u,ref:m,base:l,remote:g,repo:p,settings:w,text:e,ownerStep:n,check:o,onWait:s}));return $.joined?await r.isFinished(t,a)?{said:"landed and done",lines:[]}:B(t,a,{text:e,ownerStep:n,check:o,repo:i,onWait:s}):$}c(B,"finishCard");async function V(t,a,{tree:e,ref:n,base:o,remote:i,repo:s,settings:h,text:d,ownerStep:p,check:l,onWait:g}){await r.checkClose(t,a,d,p,l),await r.checkCallsVerified(t,a),i&&(v(e.repo,o),f(e.repo,"branch","--unset-upstream",e.branch));const u=h.auto_merge||!!(await r.heldMerge(t,a))?.tapped;if(u&&await r.landingLine(t,a),await P({...e,ref:n},{hold:!u,onWait:g,sync:c(()=>i&&v(e.repo,o),"sync")}),!u){const w=await r.setItem(t,a,{mergeReady:e.branch,ownerStep:p,check:l});return await r.appendThread(t,a,{text:d}),{said:"verified; waits for your Merge",lines:w.lines}}const m=await r.setItem(t,a,{status:"done",text:d,ownerStep:p,check:l});return{said:p===void 0?"landed and done":`landed; waits on the owner step "${p.trim()}"`,lines:[...m.lines,...await _(t,a,s,o)]}}c(V,"landCard");async function S(t,a,{launch:e=F}={}){(await r.heldMerge(t,a))?.tapped||T(`${a} isn't waiting on a Merge tap`);try{const{base:o}=M(t,{repo:(await r.recordedWorktree(t,a))?.repo}),i=c(s=>r.appendThread(t,a,{text:`Waiting for ${s} to land`,kind:"status"}),"onWait");return await B(t,a,{text:`Landed on ${o} on your Merge.`,onWait:i})}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(s){await r.appendThread(t,a,{text:`Couldn't launch the lander headless (${s.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 q(e)).pushMain)return[];const o=f(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:s}){await r.checkCallsVerified(t,a),H.existsSync(e)||T(`no worktree at ${e}`),f(e,"status","--porcelain").out&&T(`${e} has uncommitted changes; commit them there first`),Number(f(e,"rev-list","--count",`refs/remotes/origin/${o}..HEAD`).out)===0&&T(`${n} has no commits beyond ${o}; nothing to send for review`),await j(e,{outcome:"nothing was pushed"});const{github:h}=A(x(t).route),d=h?await r.cardPR(t,a):null,p=d?f(e,"rev-parse",`refs/remotes/origin/${n}`).out:null,l=d?f(e,"push","--quiet",`--force-with-lease=refs/heads/${n}:${p}`,"origin",`HEAD:refs/heads/${n}`):f(e,"push","--quiet","origin",`HEAD:refs/heads/${n}`);if(l.ok||T(`could not push ${n} to origin: ${l.err}`),d){const $=c(E=>Number(f(e,"rev-list","--count",`refs/remotes/origin/${o}..${E}`).out),"ahead");await r.recordRebase(t,a,{from:p,to:f(e,"rev-parse","HEAD").out,replayed:$("HEAD")<=$(p)});const C=await r.setItem(t,a,{pr:d});return await r.appendThread(t,a,{text:s}),{said:`pushed ${n} to PR #${d}`,lines:C.lines}}if(!h){const $=await r.setItem(t,a,{pushed:n});return await r.appendThread(t,a,{text:s}),{said:`pushed ${n} for its merge`,lines:$.lines}}const{title:g}=await r.briefFacts(t,a),u=I("gh",["pr","create","--draft","--repo",h,"--base",o,"--head",n,"--title",`${i}: ${g}`,"--body",s],{cwd:e,encoding:"utf8"}),m=`${u.stdout||""}
3
+ ${u.stderr||""}`,w=(u.status===0||/already exists/.test(m))&&/\/pull\/(\d+)/.exec(m)?.[1];w||T(`could not open a draft PR for ${n}: ${(u.stderr||u.error?.message||`gh exited ${u.status}`).trim().split(`
4
+ `)[0]}`);const b=await r.setItem(t,a,{pr:Number(w)});return await r.appendThread(t,a,{text:s}),{said:`draft PR #${w} opened`,lines:b.lines}}c(z,"sendForReview");export{B as finishCard,S as landHeld};
@@ -1,4 +1,5 @@
1
- var q=Object.defineProperty;var d=(t,e)=>q(t,"name",{value:e,configurable:!0});import g from"node:fs";import A from"node:os";import $ from"node:path";import{spawn as O}from"node:child_process";import{fileURLToPath as L}from"node:url";import{claudeBin as N,inherited as P}from"../hub/sessions.mjs";import{boardAt as S}from"../hub/boards.mjs";import{readHubRules as F}from"../hub/rules.mjs";import{builderRepo as W}from"./worktree.mjs";import{appendThread as Y,briefFacts as D,readBoardRules as H}from"./store.mjs";import{modelName as M,plans as E}from"./domain.mjs";const _=L(new URL("./bin/board.mjs",import.meta.url)),b=d(t=>`node ${_} --site ${t}`,"cli"),K=d(t=>`git -c core.commentChar=';' rebase ${t}`,"rebase"),T=d(t=>t.length?["Rules from the hub and this board:",...t.map(e=>`- ${e}`),""]:[],"ruleLines"),j=d(({route:t,key:e,worktree:n,base:a})=>[`- With no unverified calls, done finishes the card itself: it rebases onto ${a}, reruns the full test suite, fast-forwards ${a} 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 \`${K(a)}\` in ${n}, 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.",`- Finishing never goes to the orchestrator. If done refuses for a reason you can't fix, record it with \`${b(t)} builder call ${e} "<why>"\` and run done again: with the call it hands the card back.`],"finishSteps"),B=d(({route:t,key:e})=>`\`${b(t)} builder done ${e} --text "<what you checked>"\``,"finishCommand");function U({route:t,key:e,ref:n,title:a,notes:c,worktree:i,base:s,rules:r=[]}){const o=b(t);return[`You are the headless builder for card ${n} (${e}, "${a}") on the kickflip board /${t}. The board launched you; nobody watches this session, so never wait on a person. Work only in ${i}. 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.`,`3. To ask the orchestrator something, run \`${o} builder ask ${e} "<question>"\` and carry on; read its replies with \`${o} builder asks ${e}\`. Never block on a reply.`,`4. Record each judgment call the notes leave open with \`${o} builder call ${e} "<call>"\` instead of guessing silently.`,"",c?`Spec: the card's notes, ${c}, 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.","",...T(r),"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 "${n}: <what the card now does>".`,"",`To finish, run ${B({route:t,key:e})}.`,"- If you recorded a judgment call, it hands the card back for the orchestrator to verify your calls; stop there: the orchestrator's verification finishes the card.",...j({route:t,key:e,worktree:i,base:s}),"","Never push."].join(`
2
- `)}d(U,"builderBrief");function X({route:t,key:e,ref:n,title:a,worktree:c,base:i,answers:s=[]}){const r=b(t);return[`You are the headless lander for card ${n} (${e}, "${a}") 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 ${c}, never restart the hub or a board server, and never push.`,"",`1. Run \`${r} builder start ${e} --kind build --label Lander\`. If it refuses, stop.`,`2. Report progress with \`${r} builder progress ${e} --phase landing "<plain, 80 characters or fewer>"\`.`,...s.length?["3. The owner answered the builder's deferred asks. Where an answer changes the build, change it, with its tests, and commit:",...s.map(o=>`- ${o.ask} "${o.question}": ${o.answer}`)]:[],"",`To finish, run ${B({route:t,key:e})}.`,...j({route:t,key:e,worktree:c,base:i}),"","Never push."].join(`
3
- `)}d(X,"landerBrief");function G({route:t,key:e,ref:n,title:a,notes:c,kind:i,repo:s,rules:r=[],text:o,files:u=[],question:l,note:p,choice:w}){const h=b(t),f=i==="grill";return[`You are the headless ${f?"grill":"prototype"} planner for card ${n} (${e}, "${a}") 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 ${s}; write no output code there, never restart the hub or a board server, and never push.`,"",`1. Run \`${h} builder start ${e} --kind ${i}\`. If it refuses, stop.`,`2. Gather the context yourself: ${c?`the card's notes, ${c}, all sections, where later sections override earlier ones; `:"the card has no notes file yet; "}its thread, in the board site's data/threads folder, the repo's docs/adr and CONTEXT.md, and the cards its notes and thread link.`,`3. Report progress with \`${h} builder progress ${e} "<plain, 80 characters or fewer>"\` at least every 10 minutes.`,f?`4. Follow the grilling skill: find every decision the card leaves open, and post each as a question for the owner with \`${h} question add --file <json>\` on topic item:${e}, one per decision, your recommendation first.`:`4. Follow the prototype skill: record the prototype with \`${h} prototype add <topic> --card ${e} --take <K>:<label> \u2026\`, write one take per option, built from the board's real components fed fake data, and post one question whose url opens it with \`${h} question add --file <json>\` on topic item:${e}.`,...o?[` The owner asked for this ${f?"grill":"prototype"}, writing: "${o}"`]:[],...u.length?[` The owner attached: ${u.map(m=>m.path).join(", ")}.`]:[],...l?[` The owner asked for prototypes of question ${l}${p?`, noting "${p}"`:""}${w?`, leaning to option ${w}`:""}: draw that question's next round, its question naming round_of ${l}.`]:[],`5. Record what you learned in the card's notes with \`${h} item set ${e} --notes-file <file.md>\`, naming each answered question's id.`,"",...T(r),`To finish, run \`${h} builder done ${e} --text "<what you asked>"\`.`,"","Never push."].join(`
4
- `)}d(G,"plannerBrief");const z=d(()=>process.env.KICKFLIP_CODEX||"codex","codexBin"),J=d(({kind:t,prompt:e,model:n,cwd:a})=>t==="codex"?["exec","--sandbox","danger-full-access","--cd",a,e]:["-p",e,"--permission-mode","auto","--model",n,"--output-format","stream-json","--verbose"],"agentArgs");function Q({kind:t="claude",bin:e=t==="codex"?z():N(),cwd:n,prompt:a,model:c,log:i}){g.mkdirSync($.dirname(i),{recursive:!0});const s=g.openSync(i,"a"),r=Object.fromEntries(Object.entries(process.env).filter(([o])=>!P(o)));return $.isAbsolute(e)&&(r.PATH=`${$.dirname(e)}:${r.PATH||""}`),new Promise((o,u)=>{const l=O(e,J({kind:t,prompt:a,model:c,cwd:n}),{cwd:n,env:r,detached:!0,stdio:["ignore",s,s]});l.once("spawn",()=>{g.closeSync(s),l.unref(),o({pid:l.pid,log:i})}),l.once("error",p=>{g.closeSync(s),u(p)})})}d(Q,"launchHeadless");const V=d(t=>{try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},"pidAlive");async function ue(t,e,{launch:n,handBack:a,alive:c=V}){const i={};for(const[s,r]of Object.entries(t)){if(!e.has(s))continue;if(r.pid!==null&&c(r.pid)){i[s]=r;continue}const o={key:s,...r.kind?{kind:r.kind}:{},...r.model?{model:r.model}:{}};if(r.pid!==null&&r.relaunched){await a(o);continue}const{key:u,...l}=o;i[s]={...l,...await n(o),relaunched:r.pid!==null}}return i}d(ue,"reviveBuilders");const Z=d((t,e)=>$.join(A.homedir(),".claude","kickflip","logs",`${e}-${t}-${new Date().toISOString().replace(/[:.]/g,"-")}.log`),"logFile");async function pe(t,{key:e,kind:n="claude",model:a,text:c,files:i,question:s,note:r,choice:o},{lander:u=!1}={}){const l=await D(t,e),p=S(t)?.route??$.basename(t),w=[...F(),...await H(t)].map(I=>I.text),{base:h,repo:f}=W(t),m=E({kind:n}),v={...l,route:p,base:h,repo:f,rules:w,kind:n,text:c,files:i,question:s,note:r,choice:o},x=n==="codex"?"codex":a||"opus",y=m?"Planner":u?"Lander":"Builder",R=m?f:l.worktree,C=m?G(v):u?X(v):U(v),k=await Q({kind:m?"claude":n,cwd:R,prompt:C,model:x,log:Z(e.split("/")[1],y.toLowerCase())});return await Y(t,e,{text:`${y} launched on ${M({kind:n,model:x})} in ${R}.`,log:$.basename(k.log)}),k}d(pe,"launchBuilder");export{_ as BOARD_CLI,U as builderBrief,X as landerBrief,pe as launchBuilder,Q as launchHeadless,V as pidAlive,G as plannerBrief,ue as reviveBuilders};
1
+ var P=Object.defineProperty;var d=(t,e)=>P(t,"name",{value:e,configurable:!0});import S from"node:os";import y from"node:path";import{fileURLToPath as A}from"node:url";import{launchAgent as B}from"./agents.mjs";import{processStarts as L}from"../hub/live.mjs";import{boardAt as O}from"../hub/boards.mjs";import{readHubRules as D}from"../hub/rules.mjs";import{builderRepo as M}from"./worktree.mjs";import{appendThread as Y,briefFacts as F,readBoardRules as _,recordSession as E}from"./store.mjs";import{modelName as U,plans as H}from"./domain.mjs";const G=A(new URL("./bin/board.mjs",import.meta.url)),b=d(t=>`node ${G} --site ${t}`,"cli"),I=d(t=>`git -c core.commentChar=';' rebase ${t}`,"rebase"),T=d((t,e="Rules from the hub and this board:")=>t.length?[e,...t.map(n=>`- ${n}`),""]:[],"ruleLines"),q=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.status}): ${e.notes||"no notes"}`),""]:[],"linkLines"),j=d(({route:t,key:e,worktree:n,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 \`${I(h)}\` in ${n}, 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.",`- Finishing never goes to the orchestrator. If done refuses for a reason you can't fix, record it with \`${b(t)} builder call ${e} "<why>"\` and run done again: with the call it hands the card back.`],"finishSteps"),R=d(({route:t,key:e})=>`\`${b(t)} builder done ${e} --text "<what you checked>"\``,"finishCommand");function K({route:t,key:e,ref:n,title:h,notes:i,worktree:s,base:a,rules:o=[],links:r=[]}){const l=b(t);return[`You are the headless builder for card ${n} (${e}, "${h}") on the kickflip board /${t}. The board launched you; nobody watches this session, so never wait on a person. Work only in ${s}. Never restart the hub or a board server, and never push.`,"",`1. Run \`${l} builder start ${e} --kind build\`. If it refuses, stop.`,`2. Report progress with \`${l} 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. To ask the orchestrator something, run \`${l} builder ask ${e} "<question>"\` and carry on; read its replies with \`${l} builder asks ${e}\`. Never block on a reply.`,`4. Record each judgment call the notes leave open with \`${l} builder call ${e} "<call>"\` instead of guessing silently.`,"",i?`Spec: the card's notes, ${i}, 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.","",...q(r),...T(o),"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 "${n}: <what the card now does>".`,"",`To finish, run ${R({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.",...j({route:t,key:e,worktree:s,base:a}),"","Never push."].join(`
2
+ `)}d(K,"builderBrief");function X({route:t,key:e,ref:n,title:h,worktree:i,base:s,answers:a=[]}){const o=b(t);return[`You are the headless lander for card ${n} (${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 ${i}, never restart the hub or a board server, and never push.`,"",`1. Run \`${o} builder start ${e} --kind build --label Lander --phase landing --progress "taking up the verified build"\`. If it refuses, stop.`,`2. Report progress with \`${o} builder progress ${e} --phase landing "<plain, 80 characters or fewer>"\`. The board adds the phase word; don't start the text with it.`,...a.length?["3. The owner answered the builder's deferred asks. Where an answer changes the build, change it, with its tests, and commit:",...a.map(r=>`- ${r.ask} "${r.question}": ${r.answer}`)]:[],"",`To finish, run ${R({route:t,key:e})}.`,...j({route:t,key:e,worktree:i,base:s}),"","Never push."].join(`
3
+ `)}d(X,"landerBrief");function z({route:t,key:e,ref:n,title:h,worktree:i,base:s,pr:a}){const o=b(t);return[`You are the headless rebase run for card ${n} (${e}, "${h}") on the kickflip board /${t}. Its PR #${a} conflicts with ${s}; rebase its branch onto ${s} so the PR is clean again. Nobody watches this session, so never wait on a person. Work only in ${i}, never restart the hub or a board server, and never push.`,"",`1. Run \`${o} builder start ${e} --kind build --label Rebase --phase building --progress "Rebase run started \xB7 fetching ${s}"\`. If it refuses, stop.`,`2. Run \`git fetch origin\`, then \`${I(`origin/${s}`)}\`. Resolve each conflict keeping both sides' intent, \`git add\` it and continue with \`git -c core.commentChar=';' rebase --continue\`. Report each step with \`${o} builder progress ${e} --phase building "<line>"\`, the board adds the phase word, in these words: "Rebasing onto ${s} \xB7 resolving <n> files", then "Rebasing onto ${s} \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 \`${o} 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.`,"",`To finish, run ${R({route:t,key:e})}, the text saying what you resolved. It reruns the suite and pushes the branch to PR #${a} 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(z,"rebaseBrief");function J({route:t,key:e,ref:n,title:h,notes:i,kind:s,repo:a,rules:o=[],links:r=[],text:l,files:p=[],question:f,note:m,choice:$}){const c=b(t),u=s==="grill";return[`You are the headless ${u?"grill":"prototype"} planner for card ${n} (${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 ${a}; write no output code there, never restart the hub or a board server, and never push.`,"",`1. Run \`${c} builder start ${e} --kind ${s}\`. If it refuses, stop.`,`2. Gather the context yourself: ${i?`the card's notes, ${i}, all sections, where later sections override earlier ones; `:"the card has no notes file yet; "}its thread, in the board site's data/threads folder, the repo's docs/adr and CONTEXT.md, and the cards its notes and thread link.`,`3. Report progress with \`${c} builder progress ${e} "<plain, 80 characters or fewer>"\` at least every 10 minutes.`,u?`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 \`${c} question add --file <json>\` on topic item:${e}, one per decision, your recommendation first. 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.) 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: the board moves the card to prototyping on yes, or to ready on no once the owner has answered the rest, 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. Record the prototype with \`${c} prototype add <topic> --card ${e} --take <K>:<label> \u2026\`, write one take per option as a page built from the board's real components fed fake data, and post one question whose url opens it with \`${c} question add --file <json>\` on topic item:${e}, never asking in the chat. Invoke the prototype skill with the Skill tool for this step. (With no Skill tool, follow this step as written.)`,...l?[` The owner asked for this ${u?"grill":"prototype"}, writing: "${l}"`]:[],...p.length?[` The owner attached: ${p.map(g=>g.path).join(", ")}.`]:[],...f?[` The owner asked for prototypes of question ${f}${m?`, noting "${m}"`:""}${$?`, leaning to option ${$}`:""}: draw that question's next round, its question naming round_of ${f}.`]:[],`5. Record what you learned in the card's notes with \`${c} item set ${e} --notes-file <file.md>\`, naming each answered question's id.`,...u?[`6. Where the owner asked for prototypes, or a rule here wants a UI prototype first, end the card \`${c} item set ${e} --state prototyping\` instead and skip the prototype question. Otherwise the prototype question is what moves the card on: never set it ready yourself, and never leave a Next that asks the owner to mark it ready.`]:[],"",...q(r),...T(o,"Rules from the hub and this board, written for the orchestrator: where one tells you to push, land, restart the hub or a board server, or do the orchestrator's work, it isn't yours; you never push or restart:"),`To finish, run \`${c} builder done ${e} --text "<what you asked>"\`.`,"","Never push."].join(`
5
+ `)}d(J,"plannerBrief");const Q=6e4;function ce(t,{starts:e=L,kill:n=d((i,s)=>process.kill(-i,s),"kill"),killAfter:h=5e3}={}){const i=t.filter(o=>o.pid&&o.at).map(o=>o.pid),s=i.length&&e(i)||new Map,a=t.filter(o=>{const r=s.get(o.pid);return r!==void 0&&r<=Date.parse(o.at)&&r>=Date.parse(o.at)-Q});for(const{pid:o}of a){try{n(o,"SIGTERM")}catch{continue}setTimeout(()=>{try{n(o,"SIGKILL")}catch{}},h).unref()}return a.length}d(ce,"stopAgents");const V=d(t=>{try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}},"pidAlive");async function ue(t,e,{launch:n,handBack:h,alive:i=V,held:s=d(()=>!1,"held")}){const a={};for(const[o,r]of Object.entries(t)){if(!e.has(o))continue;if(r.pid!==null&&i(r.pid)||s(r.kind??"claude")||r.handedBack){a[o]=r;continue}const l={key:o,...r.kind?{kind:r.kind}:{},...r.model?{model:r.model}:{}};if(r.pid!==null&&r.relaunched){await h(l),a[o]={...r,handedBack:!0};continue}const{key:p,...f}=l;a[o]={...f,...await n(l),relaunched:r.pid!==null}}return a}d(ue,"reviveBuilders");const Z=d((t,e)=>y.join(S.homedir(),".claude","kickflip","logs",`${e}-${t}-${new Date().toISOString().replace(/[:.]/g,"-")}.log`),"logFile");async function pe(t,{key:e,kind:n="claude",model:h,text:i,files:s,question:a,note:o,choice:r},{lander:l=!1}={}){const p=await F(t,e),f=O(t)?.route??y.basename(t),m=[...D(),...await _(t)].map(C=>C.text),{base:$,repo:c}=M(t),u=H({kind:n}),g=!u&&!l&&p.rebasePR!==null,v={...p,route:f,base:$,repo:c,rules:m,kind:n,text:i,files:s,question:a,note:o,choice:r,pr:p.rebasePR},k=u?"Planner":l?"Lander":g?"Rebase run":"Builder",x=u?c:p.worktree,N=u?J(v):l?X(v):g?z(v):K(v),w=await B({kind:u?"claude":n,model:h,cwd:x,site:t,prompt:N,log:Z(e.split("/")[1],k.split(" ")[0].toLowerCase())});w.sessionId&&await E(t,e,w.sessionId,w.pid);const W=w.sessionId?`, session ${w.sessionId}`:"";return await Y(t,e,{text:`${k} launched on ${U({kind:n,model:h})} in ${x}${W}.`,log:y.basename(w.log)}),w}d(pe,"launchBuilder");export{G as BOARD_CLI,K as builderBrief,X as landerBrief,pe as launchBuilder,V as pidAlive,J as plannerBrief,z as rebaseBrief,ue as reviveBuilders,ce as stopAgents};
package/board/on-host.mjs CHANGED
@@ -1 +1 @@
1
- var g=Object.defineProperty;var t=(e,r)=>g(e,"name",{value:r,configurable:!0});import w from"node:os";import{execFile as p}from"node:child_process";import{promisify as h}from"node:util";import{tailscaleBin as x}from"../shared/tailscale.mjs";const y=h(p),I=t(e=>String(e||"").trim().replace(/^::ffff:/,""),"bare"),c=t(()=>Object.values(w.networkInterfaces()).flat().map(e=>e.address),"interfaceAddresses");async function u(){const e=x();if(!e)return null;try{const{stdout:r}=await y(e,["status","--json"],{timeout:5e3}),{Self:s,User:n}=JSON.parse(r);return{login:n?.[s.UserID]?.LoginName,addresses:s.TailscaleIPs||[]}}catch{return null}}t(u,"tailnetNode");const f=t(e=>{const r=e.headers["x-forwarded-for"];return I(r?String(r).split(",").at(-1):e.socket.remoteAddress)},"clientOf");async function j(e,r={addresses:c,node:u}){const s=e.headers["x-forwarded-for"],n=f(e);if(r.addresses().includes(n))return!0;const o=e.headers["tailscale-user-login"];if(!s||!o)return!1;const a=await r.node();return!!a&&a.login===o&&a.addresses.includes(n)}t(j,"fromHost");function S(e={addresses:c,node:u},{now:r=Date.now,retryMs:s=5e3}={}){let n=null,o=null,a=-1/0;const m=t(()=>n||r()-a<s?n:(o||=e.node().then(i=>(o=null,i?.login?n=i.login:a=r(),n)),o),"ownerLogin");return async i=>{if(e.addresses().includes(f(i)))return"owner";const l=i.headers["tailscale-user-login"];if(!l)return"other";const d=await m();return d?d===l?"owner":"other":"unread"}}t(S,"ownerGate");const B=S();export{j as fromHost,B as hubGate,S as ownerGate};
1
+ var p=Object.defineProperty;var s=(e,n)=>p(e,"name",{value:n,configurable:!0});import w from"node:os";import{execFile as y}from"node:child_process";import{promisify as N}from"node:util";import{tailscaleBin as h}from"../shared/tailscale.mjs";const x=N(y),S=s(e=>String(e||"").trim().replace(/^::ffff:/,""),"bare"),f=s(()=>Object.values(w.networkInterfaces()).flat().map(e=>e.address),"interfaceAddresses");async function m(){const e=h();if(!e)return null;try{const{stdout:n}=await x(e,["status","--json"],{timeout:5e3}),{Self:o,User:r}=JSON.parse(n),t=r?.[o.UserID];return{login:t?.LoginName,name:t?.DisplayName||null,dnsName:String(o.DNSName||"").replace(/\.$/,"")||null,addresses:o.TailscaleIPs||[]}}catch{return null}}s(m,"tailnetNode");const g=s(e=>{const n=e.headers["x-forwarded-for"];return S(n?String(n).split(",").at(-1):e.socket.remoteAddress)},"clientOf");async function j(e,n={addresses:f,node:m}){const o=e.headers["x-forwarded-for"],r=g(e);if(n.addresses().includes(r))return!0;const t=e.headers["tailscale-user-login"];if(!o||!t)return!1;const a=await n.node();return!!a&&a.login===t&&a.addresses.includes(r)}s(j,"fromHost");function D(e={addresses:f,node:m},{now:n=Date.now,retryMs:o=5e3}={}){let r=null,t=null,a=-1/0;const l=s(()=>r||n()-a<o?r:(t||=e.node().then(i=>(t=null,i?.login?r=i:a=n(),r)),t),"ownerNode"),d=s(async i=>{if(e.addresses().includes(g(i)))return"owner";const c=i.headers["tailscale-user-login"];if(!c)return"other";const u=await l();return u?u.login===c?"owner":"other":"unread"},"gate");return d.node=async()=>l(),d}s(D,"ownerGate");const B=D();export{j as fromHost,B as hubGate,D as ownerGate};
@@ -3,15 +3,15 @@
3
3
  // docs/adr/2026-10-29-1639-the-plus-makes-a-new-card.md). Needs app-core.js and app-threads.js.
4
4
  BoardView.part((B) => {
5
5
  const { $, state, toast } = B;
6
- const { waitOn } = BoardUI;
6
+ const { waitOn, keyedSend } = BoardUI;
7
7
 
8
- // ⌘↵ (Ctrl+↵ off a Mac) sends a thread reply or an edit from its box; the ask's own is new-task.js's.
8
+ // ⌘↵ and ⌥↵ press a thread reply's or an edit's send buttons from its box (ui.js keyedSend); the ask's own are new-task.js's.
9
9
  B.on(B.root, 'keydown', (ev) => {
10
- if (ev.key !== 'Enter' || !(ev.metaKey || ev.ctrlKey) || ev.isComposing) return;
11
- const form = ev.target instanceof HTMLTextAreaElement ? ev.target.closest('form[data-reply], form.edit-form') : null;
12
- if (!form) return;
10
+ const form = ev.target.tagName === 'TEXTAREA' ? ev.target.closest('form[data-reply], form.edit-form') : null;
11
+ const button = form && keyedSend(ev, form);
12
+ if (!button) return;
13
13
  ev.preventDefault();
14
- form.requestSubmit();
14
+ form.requestSubmit(button);
15
15
  });
16
16
  BoardNewTask.wire(B);
17
17
 
@@ -1,18 +1,13 @@
1
- // The answer banner at the top of the board view: asks Claude answered without making work, whose answer this
2
- // browser hasn't seen (domain.mjs answers; docs/adr/2026-10-29-1639-every-ask-is-a-card.md). Needs app-core.js.
1
+ // The answer banner at the top of the board view: asks Claude answered without making work, whose answer came after the
2
+ // card's read mark (domain.mjs answers; docs/adr/2026-10-29-1639-every-ask-is-a-card.md,
3
+ // docs/adr/2026-11-05-0910-read-marks-live-on-the-board.md). Needs app-core.js.
3
4
  BoardView.part((B) => {
4
- const { $, store, state, seen, markSeen, plural, svg } = B;
5
+ const { $, state, seen, markSeen, markRead, plural, svg } = B;
5
6
  const { esc } = BoardUI;
6
- const DISMISSED = 'dismissedAnswers';
7
7
 
8
- function unseenAnswers(d) {
9
- const dismissed = Object.assign(Object.create(null), store.get(DISMISSED, {}));
10
- return (d.answers || []).filter((a) => seen[a.key] && a.at > seen[a.key] && !(dismissed[a.id] >= a.at));
11
- }
8
+ const unseenAnswers = (d) => (d.answers || []).filter((a) => seen[a.key] && a.at > seen[a.key]);
12
9
 
13
10
  function renderBanner(d) {
14
- // A New card seen before its answer counts the answer as new; one first seen in Done starts from now (app-core.js markSeen).
15
- for (const it of d.items) if (it.isNew) markSeen(it, true);
16
11
  const shown = unseenAnswers(d);
17
12
  const el = $('#answers');
18
13
  el.hidden = !shown.length;
@@ -28,10 +23,9 @@ BoardView.part((B) => {
28
23
  B.on($('#answers'), 'click', (ev) => {
29
24
  const d = state.board;
30
25
  if (!d) return;
26
+ // ✕ marks each answer shown read, on every device.
31
27
  if (ev.target.closest('.answer-dismiss')) {
32
- const dismissed = Object.assign(Object.create(null), store.get(DISMISSED, {}));
33
- for (const a of unseenAnswers(d)) dismissed[a.id] = a.at;
34
- store.set(DISMISSED, dismissed);
28
+ markRead(unseenAnswers(d).map((a) => [a.key, a.at]));
35
29
  renderBanner(d);
36
30
  return;
37
31
  }