@lovek4d/kickflip 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTEXT.md +170 -118
- package/README.md +23 -14
- package/SKILL.md +40 -38
- package/bin/doctor.mjs +4 -4
- package/bin/install.mjs +3 -3
- package/bin/kickflip.mjs +34 -26
- package/bin/wait-events.mjs +2 -2
- package/board/arch-review.mjs +1 -1
- package/board/auto-review.mjs +2 -0
- package/board/bin/board.mjs +213 -74
- package/board/domain.mjs +8 -5
- package/board/finish.mjs +4 -0
- package/board/headless.mjs +4 -0
- package/board/merge3.mjs +1 -0
- package/board/on-host.mjs +1 -1
- package/board/permissions.mjs +2 -0
- package/board/public/app-arch.js +2 -2
- package/board/public/app-asks.js +39 -103
- package/board/public/app-banner.js +2 -2
- package/board/public/app-cards.js +166 -73
- package/board/public/app-core.js +2 -23
- package/board/public/app-header.js +12 -5
- package/board/public/app-lanes.js +201 -47
- package/board/public/app-needs.js +2 -1
- package/board/public/app-reader.js +174 -0
- package/board/public/app-snapshot.js +2 -2
- package/board/public/app-threads.js +53 -42
- package/board/public/app.html +4 -1
- package/board/public/app.js +78 -96
- package/board/public/attach.js +39 -3
- package/board/public/dialogs.js +59 -14
- package/board/public/hub-kit.js +9 -6
- package/board/public/hub.css +6 -18
- package/board/public/linear-key.js +6 -4
- package/board/public/log.html +48 -0
- package/board/public/new-task.js +121 -0
- package/board/public/prompts.js +9 -8
- package/board/public/prototype-kit.js +6 -6
- package/board/public/prototype-switcher.js +13 -5
- package/board/public/prototype.html +1 -0
- package/board/public/router.js +8 -7
- package/board/public/rules-editor.js +3 -4
- package/board/public/shell.js +24 -6
- package/board/public/sidebar.css +22 -1
- package/board/public/sidebar.js +64 -31
- package/board/public/style.css +245 -64
- package/board/public/toasts.js +2 -2
- package/board/public/ui-cards.js +205 -75
- package/board/public/ui-enums.js +6 -5
- package/board/public/ui-header.js +10 -10
- package/board/public/ui-hub.js +4 -4
- package/board/public/ui-markdown.js +1 -1
- package/board/public/ui-order.js +9 -6
- package/board/public/ui-page-header.js +10 -7
- package/board/public/ui-patch.js +53 -0
- package/board/public/ui-phase-bars.js +17 -0
- package/board/public/ui-prompts.js +8 -8
- package/board/public/ui-questions.js +61 -29
- package/board/public/ui-sidebar.js +54 -24
- package/board/public/ui-snapshot.js +20 -9
- package/board/public/ui-threads.js +40 -21
- package/board/public/ui.js +116 -18
- package/board/public/view-frame.js +2 -1
- package/board/public/view-hub-settings.js +25 -18
- package/board/public/view-hub.js +53 -12
- package/board/public/view-notes.js +1 -1
- package/board/public/view-questions.js +142 -62
- package/board/public/view-settings.js +189 -52
- package/board/review.mjs +1 -1
- package/board/server.mjs +20 -12
- package/board/store.mjs +15 -12
- package/board/tickets.mjs +3 -3
- package/board/worktree.mjs +21 -15
- package/docs/hub-session.md +4 -4
- package/hooks-plugin/hooks/codex-share-auto.mjs +1 -1
- package/hooks-plugin/hooks/watcher-stop.mjs +2 -2
- package/hub/board-repo.mjs +1 -1
- package/hub/boards.mjs +4 -4
- package/hub/close-board.mjs +1 -1
- package/hub/front-door.mjs +20 -0
- package/hub/github.mjs +4 -4
- package/hub/home.mjs +1 -1
- package/hub/hub.mjs +11 -14
- package/hub/incoming.mjs +2 -0
- package/hub/linear.mjs +2 -2
- package/hub/live.mjs +2 -2
- package/hub/new-board.mjs +2 -2
- package/hub/owner-checks.mjs +1 -0
- package/hub/permission-denied-hook.mjs +2 -0
- package/hub/pr-report.mjs +3 -1
- package/hub/presence.mjs +1 -1
- package/hub/prompts.mjs +1 -1
- package/hub/push.mjs +2 -2
- package/hub/readiness.mjs +2 -2
- package/hub/repos.mjs +3 -3
- package/hub/restart-board.mjs +1 -1
- package/hub/schedule.mjs +1 -1
- package/hub/sessions.mjs +2 -2
- package/hub/sw.js +1 -1
- package/hub/try.mjs +8 -4
- package/hub/usage.mjs +3 -3
- package/hub/views.mjs +1 -1
- package/package.json +5 -1
- package/shared/card-prs.mjs +1 -0
- package/shared/colors.css +5 -4
- package/shared/fake-gh.mjs +59 -8
- package/shared/owner-check.mjs +3 -0
- package/shared/repos.mjs +1 -1
- package/shared/tailscale.mjs +1 -0
- package/shared/usage-gate.mjs +1 -1
- package/board/public/view-polling.js +0 -87
package/hub/views.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _=Object.defineProperty;var s=(e,t)=>_(e,"name",{value:t,configurable:!0});import{clock as c,holdLine as w,sendWords as H,snoozeEnd as f}from"./schedule.mjs";import{CHOICES as T,FOREVER as k,durationEnd as V,endOf as F}from"./duration.mjs";import{siteIcon as K}from"./icons.mjs";import{codexStatus as M}from"../shared/codex.mjs";const W=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capital"),b=s((e,t)=>`${e} ${t}${e===1?"":"s"}`,"plural"),h=s(e=>{const[t,n]=e.split(":").map(Number),o=new Date;return o.setHours(t,n,0,0),c(o,o)},"timeOfDay"),B=s(e=>`checks every ${e.every===1?"minute":`${e.every} min`} while you\u2019re ${e.present?"here":"away"}${e.low?", slower while GitHub\u2019s points are low":""}`,"cadenceLine"),G=s((e,t,n)=>`${B(t)}${e.hold?`; ${w(e.hold,n)}`:""}`,"nowLine"),S=s((e,t)=>e.hold?w(e.hold,t):"pushes go out after each check","deviceLine"),Z=s(e=>`${h(e.quiet.start)} \u2013 ${h(e.quiet.end)}${e.quiet.hold?" \xB7 pushes held":""}`,"quietSummary"),Q="checks every minute while you're here, every 5 when away",X=s((e,t)=>e.count?`${e.count} push${e.count===1?"":"es"} queued; next send ${H(e.nextFlushAt,t)}.`:"No pushes queued.","queuedLine");function Y({running:e=!1,nextAt:t,last:n=null},o){if(e)return"Checking GitHub now";const l=`Next check ${c(t,o)}`;if(!n)return l;const u=n.failed.length?"could not reach GitHub for every PR":n.watched?`${b(n.watched,"PR")}, ${n.changes.length?`${n.changes.length} changed`:"no change"}`:"no PRs watched";return`${l} \xB7 last ${c(new Date(n.at),o)}, ${u}`}s(Y,"pollLine");function j(e,t,n){return{title:W(G(e,t,n)),lines:[Y(t,n),X(e,n)],count:e.count}}s(j,"pollingNow");function J(e,t){const n={port:"down \xB7 not answering",files:"down \xB7 folder missing"}[e.serves]||"down \xB7 restarting";if(e.state!=="up")return{tone:e.state==="down"?"down":"wait",word:e.state==="down"?n:e.state,lines:[]};if(!t)return{tone:"ok",word:"up",lines:[]};const o=t.filter(r=>!r.ok),l=o.filter(r=>r.state==="broken"),u=t.find(r=>r.link==="events"),a=u?.listen==="asleep"||u?.listen==="waking"?u.listen:u?.ok?"listening":"not listening",d=l.length?`degraded \xB7 ${a}`:o.length?`up \xB7 ${a} \xB7 ${o.length} settling`:`up \xB7 ${a} \xB7 every link passes`;return{tone:o.length?"wait":"ok",word:d,lines:o.map(r=>({link:r.link,detail:`${r.state==="broken"?"":"settling: "}${r.detail}`}))}}s(J,"siteHealth");const A=[{value:"always",label:"Always on",description:s(()=>"Codex implements and reviews. Work pauses when it runs out.","description")},{value:"auto",label:"Auto",description:s(e=>`Codex implements and reviews, and ${e} takes over while it's out.`,"description")},{value:"off",label:"Off",description:s(e=>`${e} implements and reviews.`,"description")}],ee=s((e,t,n)=>({usable:t.usable,tag:t.usable?null:t.reason,share:e,choices:A.map(({value:o,label:l})=>({value:o,label:l,on:o===e})),description:t.usable?A.find(o=>o.value===e).description(q[n]):t.words,fix:t.fix}),"codexView"),q={opus:"Opus",sonnet:"Sonnet",auto:"Claude"},N=[{value:"opus",label:"Opus",description:"Always Opus. Auto would give small cards to Sonnet."},{value:"auto",label:"Auto",description:"Auto: small cards get Sonnet, the rest get Opus."},{value:"sonnet",label:"Sonnet",description:"Always Sonnet. Auto would give large cards to Opus."}],te=s(e=>({model:e,builder:q[e],choices:N.map(({value:t,label:n})=>({value:t,label:n,on:t===e})),description:N.find(t=>t.value===e).description}),"claudeView");function de({now:e,st:t,poll:n,sidebar:o,rows:l,links:u=new Map,code:a={},host:d="",rules:r=[],remembered:y=new Map,integrations:p=[],codexShare:R="off",claudeModel:x="auto",codex:U=M({installed:!1}),awake:O=null}){const $=new Set(o.sites.filter(i=>i.board).map(i=>i.route)),E=!!(a.running&&a.running===a.onDisk),z=E?` \xB7 runs the code in its files (${a.onDisk})`:"",D=s(i=>({route:i.route,title:i.title,icon:K(i.route,i),href:`/${encodeURIComponent(i.route)}/`,...J(i,u.get(i.route)),remembered:y.get(i.route)||[],restart:$.has(i.route)&&i.restart===!0}),"site"),I=[["Boards",l.filter(i=>$.has(i.route))],["Pages",l.filter(i=>!$.has(i.route))]].filter(([,i])=>i.length).map(([i,L])=>({label:i,sites:L.map(D)}));return{hub:{tone:o.hub.tone,word:o.hub.word,detail:`${o.hub.detail}${z}`,restart:!E},awake:O&&g(O,e,v),groups:I,integrations:p,usage:o.usage,pause:o.pause,codex:ee(R,U,x),claude:te(x),empty:l.length===0,polling:j(t,n,e),notifications:{on:t.settings.notifications.on,text:o.notifications.text,device:S(t,e)},hold:t.hold&&t.hold.why!=="off"?{text:`Notifications ${w(t.hold,e)}`,end:t.hold.why==="snoozed"}:null,rules:r.length?b(r.length,"rule"):"None yet",sites:b(l.length,"site"),host:d,total:o.total}}s(de,"hubView");const ce="That snooze ends in the past or more than 30 days on. Pick another time.",he="That keep awake ends in the past or more than 30 days on. Pick another time.",C="until you end it",v="until you turn it off",g=s((e,t,n)=>e===k?n:`until ${c(e,t)}`,"untilWords"),P=s((e,t)=>T.map(([n,o])=>({value:n,label:o,until:g(V(e,n),e,t)})),"durationChoices"),ne=s((e,t)=>e.on?F(e.snoozed_until,t):null,"snoozedUntil");function pe({now:e,st:t,rules:n=[],route:o={atMac:!1,desktops:0},linear:l={set:!1},awake:u={until:null,unsupported:null}}){const a=t.settings,d=a.notifications,r=ne(d,e),y=t.count?` The ${t.count} queued push${t.count===1?" is":"es are"} dropped now.`:"",p=r&&`Snoozed ${g(r,e,C)}`;return{snoozed:r?{title:p,summary:r===k?"Snoozed \xB7 forever":p}:null,device:S(t,e),on:{on:d.on,sub:d.on?"On. Turn off to drop every push, urgent ones too.":"Off. Every push is dropped, urgent ones too. Needs you and the badge still update.",confirm:`Turn off notifications? Every push is dropped until you turn them back on, urgent ones too.${y} Needs you and the badge still update.`},presence:d.on?o.atMac?o.desktops?{title:"At the host",sub:"Pushes go to the host only. Prompts, faults and urgent pushes still reach the phone."}:{title:"At the host",sub:"No notifications on the host, so pushes still go to the phone."}:{title:"Away from the host",sub:"Pushes go to every device. At the host means unlocked and used in the last 3 minutes."}:null,snooze:d.on&&!r?{choices:P(e,C)}:null,awake:{unsupported:u.unsupported,on:u.until?{title:`Keeping awake ${g(u.until,e,v)}`}:null,choices:u.unsupported||u.until?null:P(e,v),summary:u.unsupported||(u.until?u.until===k?"On \xB7 forever":`On until ${c(u.until,e)}`:"Off")},weekends:{on:d.weekends_off,sub:`Pushes wait from Friday ${h(a.quiet.start)} until Monday ${h(a.quiet.end)}. Urgent ones still go.`},quiet:se(a,e),rules:n,linear:oe(l)}}s(pe,"settingsView");const m={url:"https://linear.app/settings/account/security",label:"Linear \u203A Settings \u203A Security & access \u203A Personal API keys"};function oe(e){const t=e.workspace?`${e.workspace} workspace`:"";return e.set?e.refused?{set:!0,refused:!0,title:t||"Linear key",down:"doesn\u2019t work",sub:`Linear refused the key. Make a new one in ${m.label} and paste it here.`,keys:m,summary:t?`Key doesn\u2019t work \xB7 ${t}`:"Key doesn\u2019t work"}:{set:!0,title:t,sub:"Key \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",summary:`Key set \xB7 ${t}`}:{set:!1,title:"No key",sub:`Make a personal API key in ${m.label}, then paste it here.`,keys:m,summary:"No key"}}s(oe,"linearWords");function se(e,t){const n=e.quiet,[o,l]=[h(n.start),h(n.end)],u=f(t,"tonight",e),a=[["Snooze tonight",`Until ${c(u,t)}${n.hold?`, then quiet hours hold pushes until ${c(f(u,"morning",e),t)}`:""}.`],["Snooze morning",`Until ${c(f(t,"morning",e),t)}.`],["Snooze monday",`Until ${c(f(t,"monday",e),t)}.`],["Off on weekends",e.notifications.weekends_off?`Pushes wait from Friday ${o} until Monday ${l}.`:"Off."],["Daily wake",`Every board wakes once at ${l}, when quiet hours end.`]];return{start:n.start,end:n.end,summary:Z(e),hint:Q,hold:{on:n.hold,sub:n.hold?`Pushes queued after ${o} wait until ${l}. Urgent ones still go.`:"Off. Pushes go out all night."},reads:a.map(([d,r])=>({title:d,sub:r}))}}s(se,"quietView");function fe(e){return e?e.ok?{sent:e.sent,count:e.count,ok:!0,message:`Sent ${e.count} queued push${e.count===1?"":"es"}.`}:{sent:e.sent,count:e.count,ok:!1,message:"Could not send the queue. It stays queued for the next check."}:{sent:0,count:0,ok:!0,message:"Nothing was queued."}}s(fe,"flushView");export{he as AWAKE_REFUSED,Q as QUIET_HINT,ce as SNOOZE_REFUSED,B as cadenceLine,W as capital,P as durationChoices,fe as flushView,de as hubView,G as nowLine,b as plural,Y as pollLine,Z as quietSummary,pe as settingsView,J as siteHealth};
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovek4d/kickflip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Follow and steer Claude Code sessions from your phone.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lovek4d/kickflip.git"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"bin": {
|
|
8
12
|
"kickflip": "bin/kickflip.mjs"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var t=(r,e)=>s(r,"name",{value:e,configurable:!0});const a=/^(?:([\w.-]+\/[\w.-]+)#)?([1-9]\d*)$/,o=t(r=>Array.isArray(r?.prs)?r.prs:Number.isInteger(r?.pr)?[{number:r.pr}]:[],"storedPRs"),l=t((r,e)=>o(r).map(n=>({repo:n.repo||e,number:n.number})).filter(n=>n.repo),"cardPRs"),m=t(r=>o(r).length>0,"hasPR"),p=t(({repo:r,number:e})=>`${r}#${e}`,"prKeyOf"),x=t(({repo:r,number:e})=>`https://github.com/${r}/pull/${e}`,"prURL"),d=t((r,e)=>r.map(n=>n.repo&&n.repo!==e?p(n):`#${n.number}`).join(", "),"prNames");function R(r){const e=a.exec(String(r).trim());return e?{...e[1]?{repo:e[1]}:{},number:Number(e[2])}:null}t(R,"parsePRRef");const i=["MERGED","CLOSED"],u=t(r=>r.checks?.state==="fail"||!!r.failing?.length,"failing");function c(r){return r?.state?i.includes(r.state)?5:r.isDraft?1:u(r)?2:r.reviewDecision==="APPROVED"?4:3:0}t(c,"readiness");function h(r){if(!r.length)return-1;const e=r.map(c);return e.every(n=>n===5)?Math.max(0,r.findIndex(n=>n.state==="MERGED")):e.indexOf(Math.min(...e))}t(h,"leastReady");const E=t(r=>r.length>0&&r.every(e=>i.includes(e?.state))&&r.some(e=>e.state==="MERGED"),"allLanded");export{E as allLanded,l as cardPRs,m as hasPR,h as leastReady,R as parsePRRef,p as prKeyOf,d as prNames,x as prURL,o as storedPRs};
|
package/shared/colors.css
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
/* The one colour set for the hub and every board (docs/adr/
|
|
1
|
+
/* The one colour set for the hub and every board (docs/adr/2026-10-29-1639-one-colour-constants-file-shared-by-the-hub-and-every-board.md).
|
|
2
2
|
board/server.mjs serves it as colors.css and hub/hub.mjs as /_hub/colors.css, linked before each page's own CSS.
|
|
3
3
|
--accent is the one human blue: new messages, links, buttons, focus rings, the owner's bubble (--accent-soft) and
|
|
4
|
-
planner lines; --on-accent is the label on an accent fill (docs/adr/
|
|
4
|
+
planner lines; --on-accent is the label on an accent fill (docs/adr/2026-11-03-1627-one-human-blue.md). */
|
|
5
5
|
:root {
|
|
6
6
|
--bg: #fbfbfc; --panel: #ffffff; --line: #e6e6ea; --text: #1b1b1f; --muted: #6b6b76;
|
|
7
|
-
--accent: #2b6cb0; --accent-soft: #eef6ff; --on-accent: #ffffff; --ok: #1f9d55; --warn: #c27c0e; --bad: #d1435b;
|
|
7
|
+
--accent: #2b6cb0; --accent-soft: #eef6ff; --on-accent: #ffffff; --ok: #1f9d55; --warn: #c27c0e; --bad: #d1435b; --purple: #8250df;
|
|
8
8
|
--chip: #f1f1f4; --band: #f2f2f5; --claude: #fdf3e4;
|
|
9
9
|
--color-quiet: var(--muted); --color-info: var(--accent); --color-notice: var(--warn); --color-danger: var(--bad); --color-success: var(--ok);
|
|
10
|
+
--color-merged: var(--purple);
|
|
10
11
|
}
|
|
11
12
|
@media (prefers-color-scheme: dark) {
|
|
12
13
|
:root { --bg: #111114; --panel: #18181c; --line: #2a2a31; --text: #ececf1; --muted: #9a9aa6;
|
|
13
|
-
--accent: #6fa8e8; --accent-soft: #1b2533; --on-accent: #0b0b0e; --ok: #3ccf7f; --warn: #e3a33a; --bad: #f0687f;
|
|
14
|
+
--accent: #6fa8e8; --accent-soft: #1b2533; --on-accent: #0b0b0e; --ok: #3ccf7f; --warn: #e3a33a; --bad: #f0687f; --purple: #ab7df8;
|
|
14
15
|
--chip: #24242b; --band: #202026; --claude: #2d2416; }
|
|
15
16
|
}
|
package/shared/fake-gh.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).filter(Boolean).map(JSON.parse)}catch{return[]}},"jsonl"),
|
|
1
|
+
var p=Object.defineProperty;var t=(e,r)=>p(e,"name",{value:r,configurable:!0});import n from"node:fs";import l from"node:path";import{PR_VIEW_FIELDS as g}from"../hub/pr-report.mjs";const o=t((e,r,s,i)=>{const a=l.join(e,r,`${String(s).replace(/[/#]/g,"__")}.json`);n.mkdirSync(l.dirname(a),{recursive:!0}),n.writeFileSync(a,JSON.stringify(i))},"write"),w=t((e,r,s)=>o(e,"pr",r,s),"writePR"),x=t((e,r,s)=>o(e,"issue-comments",r,s),"writeIssueComments"),v=t((e,r,s)=>o(e,"review-comments",r,s),"writeReviewComments"),b=t((e,r,s)=>o(e,"reviews",r,s),"writeReviews"),S=t((e,r,s)=>o(e,"merge",r,s),"writeMerge"),_=t((e,r,s)=>o(e,"ready",r,s),"writeReady"),j=t((e,r)=>o(e,"","user",r),"writeUser"),R=t((e,r)=>o(e,"","accounts",r),"writeAccounts"),c=t((e,r)=>{try{return n.readFileSync(l.join(e,r),"utf8").trim().split(`
|
|
2
|
+
`).filter(Boolean).map(JSON.parse)}catch{return[]}},"jsonl"),f=t(e=>c(e,"calls.jsonl"),"calls"),O=t((e,r)=>o(e,"","rate",r),"writeRate"),N=t(e=>f(e).filter(r=>r[0]==="api"&&r[1]==="graphql").map(r=>[...r[3].matchAll(/repository\(owner: "([^"]+)", name: "([^"]+)"\) \{ pullRequest\(number: (\d+)\)/g)].map(([,s,i,a])=>`${s}/${i}#${a}`)),"queried"),k=t(e=>c(e,"tokens.jsonl"),"tokens");function E({head:e="abc1234567",failing:r=[],pending:s=0,...i}={}){return{state:"OPEN",isDraft:!1,reviewDecision:"REVIEW_REQUIRED",mergeable:"MERGEABLE",mergeStateStatus:"BLOCKED",headRefOid:e,statusCheckRollup:[...r.map(a=>({__typename:"CheckRun",name:a,status:"COMPLETED",conclusion:"FAILURE"})),...Array.from({length:s},(a,u)=>({__typename:"CheckRun",name:`ci-${u}`,status:"IN_PROGRESS",conclusion:""}))],...i}}t(E,"prView");function J(e){const r=l.join(e,"bin");return n.mkdirSync(r,{recursive:!0}),n.writeFileSync(l.join(r,"gh"),`#!${process.execPath}
|
|
3
3
|
const fs = require('node:fs');
|
|
4
4
|
const path = require('node:path');
|
|
5
5
|
const dir = ${JSON.stringify(e)};
|
|
@@ -7,6 +7,11 @@ const args = process.argv.slice(2);
|
|
|
7
7
|
fs.appendFileSync(path.join(dir, 'calls.jsonl'), JSON.stringify(args) + '\\n');
|
|
8
8
|
fs.appendFileSync(path.join(dir, 'tokens.jsonl'), JSON.stringify({ args, token: process.env.GH_TOKEN || null }) + '\\n');
|
|
9
9
|
const fail = () => { console.error('no fixture for: ' + args.join(' ')); process.exit(1); };
|
|
10
|
+
// The repo's own fixture for PR n, else the one for n in any repo.
|
|
11
|
+
const fixture = (folder, repo, n) => {
|
|
12
|
+
const own = path.join(dir, folder, repo.replace('/', '__') + '__' + n + '.json');
|
|
13
|
+
return fs.existsSync(own) ? own : path.join(dir, folder, n + '.json');
|
|
14
|
+
};
|
|
10
15
|
if (args.length === 4 && args[0] === 'auth' && args[1] === 'token' && args[2] === '-u') {
|
|
11
16
|
let accounts = {};
|
|
12
17
|
try { accounts = JSON.parse(fs.readFileSync(path.join(dir, 'accounts.json'), 'utf8')); } catch {}
|
|
@@ -25,18 +30,64 @@ if (args[0] === 'issue' && args.includes('--repo')) {
|
|
|
25
30
|
}
|
|
26
31
|
if (args.length === 6 && args[0] === 'pr' && args[1] === 'merge' && /^\\d+$/.test(args[2]) && args[3] === '--repo' && args[5] === '--squash') {
|
|
27
32
|
let refused = null;
|
|
28
|
-
try { refused = JSON.parse(fs.readFileSync(
|
|
33
|
+
try { refused = JSON.parse(fs.readFileSync(fixture('merge', args[4], args[2]), 'utf8')).error; } catch {}
|
|
29
34
|
if (refused) { console.error(refused); process.exit(1); }
|
|
30
35
|
process.exit(0);
|
|
31
36
|
}
|
|
37
|
+
if (args.length === 5 && args[0] === 'pr' && args[1] === 'ready' && /^\\d+$/.test(args[2]) && args[3] === '--repo') {
|
|
38
|
+
let refused = null;
|
|
39
|
+
try { refused = JSON.parse(fs.readFileSync(fixture('ready', args[4], args[2]), 'utf8')).error; } catch {}
|
|
40
|
+
if (refused) { console.error(refused); process.exit(1); }
|
|
41
|
+
console.log('\u2713 Pull request ' + args[4] + '#' + args[2] + ' is marked as "ready for review"');
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
// A comment or review-comment reply posted with gh api <endpoint> -f body=\u2026: answers the endpoint as its html_url.
|
|
45
|
+
if (args.length === 4 && args[0] === 'api' && args[2] === '-f' && args[3].startsWith('body=') && /^repos\\/[^/]+\\/[^/]+\\/(issues\\/\\d+\\/comments|pulls\\/\\d+\\/comments\\/\\d+\\/replies)$/.test(args[1])) {
|
|
46
|
+
console.log(JSON.stringify({ html_url: 'https://github.com/' + args[1].slice('repos/'.length) }));
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
// The hub's one GraphQL query (hub/pr-report.mjs fetchPRs), answered from the same fixtures as the REST calls: each
|
|
50
|
+
// aliased PR from its pr, issue-comments, review-comments and reviews fixtures, the viewer from user.json and the rate
|
|
51
|
+
// limit from rate.json. A PR without a fixture, or {fail: true}, comes back null with an error, as GitHub answers.
|
|
52
|
+
if (args.length === 4 && args[0] === 'api' && args[1] === 'graphql' && args[2] === '-f' && args[3].startsWith('query=')) {
|
|
53
|
+
const read = (file, fallback) => { try { return JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return fallback; } };
|
|
54
|
+
const rate = read(path.join(dir, 'rate.json'), { remaining: 4990, resetAt: '2026-10-23T12:00:00Z' });
|
|
55
|
+
if (rate.fail) fail();
|
|
56
|
+
const user = read(path.join(dir, 'user.json'), null);
|
|
57
|
+
const author = (u) => (u?.login ? (/\\[bot\\]$/.test(u.login) ? { __typename: 'Bot', login: u.login.replace(/\\[bot\\]$/, '') } : { __typename: 'User', login: u.login }) : null);
|
|
58
|
+
const list = (folder, repo, n) => { const v = read(fixture(folder, repo, n), []); return Array.isArray(v) ? v : []; };
|
|
59
|
+
const data = { viewer: user ? { login: user.login } : null, rateLimit: rate };
|
|
60
|
+
const errors = [];
|
|
61
|
+
for (const [, alias, owner, name, n] of args[3].matchAll(/(\\w+): repository\\(owner: "([^"]+)", name: "([^"]+)"\\) \\{ pullRequest\\(number: (\\d+)\\)/g)) {
|
|
62
|
+
const repo = owner + '/' + name;
|
|
63
|
+
const view = read(fixture('pr', repo, n), null);
|
|
64
|
+
if (!view || view.fail) { data[alias] = { pullRequest: null }; errors.push({ path: [alias, 'pullRequest'], message: 'Could not resolve to a PullRequest with the number of ' + n + '.' }); continue; }
|
|
65
|
+
const { statusCheckRollup = [], ...fields } = view;
|
|
66
|
+
data[alias] = { pullRequest: { ...fields,
|
|
67
|
+
commits: { nodes: [{ commit: { statusCheckRollup: { contexts: { nodes: statusCheckRollup } } } }] },
|
|
68
|
+
comments: { nodes: list('issue-comments', repo, n).map((c) => ({ databaseId: c.id, author: author(c.user), createdAt: c.created_at, body: c.body, url: c.html_url })) },
|
|
69
|
+
reviews: { nodes: list('reviews', repo, n).map((r) => ({ databaseId: r.id, author: author(r.user), submittedAt: r.submitted_at, body: r.body, state: r.state, url: r.html_url })) },
|
|
70
|
+
reviewThreads: { nodes: list('review-comments', repo, n).map((c) => ({ comments: { nodes: [{ databaseId: c.id, author: author(c.user), createdAt: c.created_at, body: c.body, url: c.html_url, path: c.path, line: c.line, replyTo: c.in_reply_to_id == null ? null : { databaseId: c.in_reply_to_id } }] } })) },
|
|
71
|
+
} };
|
|
72
|
+
}
|
|
73
|
+
console.log(JSON.stringify(errors.length ? { data, errors } : { data }));
|
|
74
|
+
if (errors.length) { console.error('gh: ' + errors[0].message); process.exit(1); }
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
// gh pr create --repo <repo> \u2026: answers the new PR's URL, numbered 100 plus the creates before it.
|
|
78
|
+
if (args[0] === 'pr' && args[1] === 'create' && args.includes('--repo')) {
|
|
79
|
+
const n = fs.readFileSync(path.join(dir, 'calls.jsonl'), 'utf8').split('\\n').filter((l) => l.startsWith('["pr","create"')).length;
|
|
80
|
+
console.log('https://github.com/' + args[args.indexOf('--repo') + 1] + '/pull/' + (99 + n));
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
32
83
|
let file;
|
|
33
84
|
let list = false;
|
|
34
|
-
if (args.length === 7 && args[0] === 'pr' && args[1] === 'view' && /^\\d+$/.test(args[2]) && args[3] === '--repo' && args[5] === '--json' && args[6] === ${JSON.stringify(
|
|
85
|
+
if (args.length === 7 && args[0] === 'pr' && args[1] === 'view' && /^\\d+$/.test(args[2]) && args[3] === '--repo' && args[5] === '--json' && args[6] === ${JSON.stringify(g)}) file = fixture('pr', args[4], args[2]);
|
|
35
86
|
else if (args.length === 2 && args[0] === 'api' && args[1] === 'user') file = path.join(dir, 'user.json');
|
|
36
87
|
else if (args.length === 4 && args[0] === 'api' && args[1] === '--paginate' && args[2] === '--slurp') {
|
|
37
|
-
const match = /^repos\\/[^/]+\\/[^/]
|
|
38
|
-
if (!match || (match[
|
|
39
|
-
file =
|
|
88
|
+
const match = /^repos\\/([^/]+\\/[^/]+)\\/(issues|pulls)\\/(\\d+)\\/(comments\\?since=.+|reviews)$/.exec(args[3]);
|
|
89
|
+
if (!match || (match[2] === 'issues' && match[4] === 'reviews')) process.exit(1);
|
|
90
|
+
file = fixture(match[4] === 'reviews' ? 'reviews' : match[2] === 'issues' ? 'issue-comments' : 'review-comments', match[1], match[3]);
|
|
40
91
|
list = true;
|
|
41
92
|
} else process.exit(1);
|
|
42
93
|
let value;
|
|
@@ -51,4 +102,4 @@ if (list) {
|
|
|
51
102
|
try { if (JSON.parse(value).fail) fail(); } catch {}
|
|
52
103
|
console.log(value);
|
|
53
104
|
}
|
|
54
|
-
`,{mode:493}),
|
|
105
|
+
`,{mode:493}),r}t(J,"fakeGh");export{f as calls,J as fakeGh,E as prView,N as queried,k as tokens,R as writeAccounts,x as writeIssueComments,S as writeMerge,w as writePR,O as writeRate,_ as writeReady,v as writeReviewComments,b as writeReviews,j as writeUser};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var h=Object.defineProperty;var r=(t,e)=>h(t,"name",{value:e,configurable:!0});import{execFile as m}from"node:child_process";const k=/^[\w.-]+\/[\w.-]+$/,A=/^(@[\w.-]+\/)?[\w.][\w.-]*$/,S=/^[\w.-]+(\/[\w.-]+)*$/,b=/^[\w-]+(\.[\w-]+)*$/,u=r(t=>{throw new Error(t)},"bad"),d=r(t=>k.test(t||"")?t:u(`"${t??""}" isn't a GitHub repo such as owner/name`),"repoOf"),p=r((t,e)=>t&&!t.startsWith("-")?t:u(`${e} is missing`),"plain"),l={tag:{usage:"tag <owner/repo> <pattern>",args:r(([t,e,...s])=>s.length?u("tag takes a repo and one pattern"):[d(t),p(e,"the tag pattern")],"args"),words:r(([t,e])=>`a ${e} tag on ${t}`,"words"),async run([t,e],{exec:s}){const n=await s("git",["ls-remote","--tags",`https://github.com/${t}.git`]),a=j(e),i=[...new Set(n.split(`
|
|
2
|
+
`).map(c=>c.split(" ")[1]?.replace(/^refs\/tags\//,"").replace(/\^\{\}$/,"")).filter(Boolean))].filter(c=>a.test(c)).sort(g).at(-1);return i?{passed:!0,found:`tag ${i} is on ${t}`}:{passed:!1}}},npm:{usage:"npm <package> <version-or-range>",args:r(([t,e,...s])=>s.length?u("npm takes a package and one version or range"):[A.test(t||"")?t:u(`"${t??""}" isn't an npm package name`),p(e,"the version or range")],"args"),words:r(([t,e])=>`${t}@${e} on npm`,"words"),async run([t,e],{exec:s}){const n=(await s("npm",["view",`${t}@${e}`,"version","--json"]).catch(i=>{if(/No match found for version/.test(`${i.stdout??""}${i.stderr??""}`))return"";throw i})).trim(),o=(n?[JSON.parse(n)].flat():[]).sort(g).at(-1);return o?{passed:!0,found:`${t}@${o} is on npm`}:{passed:!1}}},run:{usage:"run <owner/repo> <workflow>",args:r(([t,...e])=>[d(t),p(e.join(" "),"the workflow")],"args"),words:r(([t,e])=>`a passing ${e} run on ${t}`,"words"),async run([t,e],{exec:s,since:n}){const a=await s("gh",["run","list","--repo",t,"--workflow",e,"--status","success","--limit","20","--json","createdAt,url"]),o=JSON.parse(a||"[]").filter(i=>String(i.createdAt)>=n).sort((i,c)=>String(i.createdAt).localeCompare(String(c.createdAt))).at(-1);return o?{passed:!0,found:`${e} passed on ${t} (${o.url})`}:{passed:!1}}},gh:{usage:"gh <owner/repo> <api-path> <field>=<value>",args([t,e,s,...n]){n.length&&u("gh takes a repo, an API path and one field=value"),(!S.test(e||"")||e.split("/").includes(".."))&&u(`"${e??""}" isn't an API path under the repo, such as actions/permissions`);const[a,...o]=String(s??"").split("=");return(!b.test(a)||!o.length)&&u(`"${s??""}" isn't a field=value, such as enabled=true`),[d(t),e,s]},words:r(([t,e,s])=>`${e} reads ${s} on ${t}`,"words"),async run([t,e,s],{exec:n}){const[a,...o]=s.split("="),i=o.join("="),c=a.split(".").reduce((f,w)=>f?.[w],JSON.parse(await n("gh",["api",`repos/${t}/${e}`])));return c!==void 0&&String(c)===i?{passed:!0,found:`${e} reads ${s} on ${t}`}:{passed:!1}}},url:{usage:"url <http(s) address> [<status> | <text>]",args([t,...e]){let s;try{s=new URL(t)}catch{u(`"${t??""}" isn't a web address`)}return["http:","https:"].includes(s.protocol)||u("url takes an http or https address"),e.length?[t,e.join(" ")]:[t]},words:r(([t,e])=>e===void 0||/^\d{3}$/.test(e)?`${t} answers ${e??200}`:`${t} shows "${e}"`,"words"),async run([t,e],{fetchImpl:s}){const n=e!==void 0&&/^\d{3}$/.test(e)?Number(e):200,a=await s(t,{redirect:"follow",signal:AbortSignal.timeout(2e4)}),o=await a.text();return a.status!==n?{passed:!1}:n===200&&e!==void 0&&!/^\d{3}$/.test(e)?o.includes(e)?{passed:!0,found:`${t} shows "${e}"`}:{passed:!1}:{passed:!0,found:`${t} answered ${n}`}}}},$=Object.values(l).map(t=>t.usage);function E(t){const[e,...s]=String(t??"").trim().split(/\s+/).filter(Boolean);e||u(`--check takes "<name> <args>": ${$.join(", ")}`);const n=Object.hasOwn(l,e)?l[e]:u(`--check has no check "${e}"; it takes ${$.join(", ")}`);try{return{name:e,args:n.args(s)}}catch(a){return u(`--check ${n.usage}: ${a.message}`)}}r(E,"parseCheck");const C=r(({name:t,args:e})=>[t,...e].join(" "),"checkText"),I=r(({name:t,args:e})=>l[t].words(e),"checkWords");function N({name:t,args:e},{since:s,exec:n=v,fetchImpl:a=fetch}={}){return l[t].run(e,{since:s,exec:n,fetchImpl:a})}r(N,"runCheck");function v(t,e){return new Promise((s,n)=>{m(t,e,{timeout:6e4,maxBuffer:16*1024*1024,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},(a,o,i)=>{if(!a)return s(o);const c=String(i||"").trim().split(`
|
|
3
|
+
`).find(Boolean)?.replace(/^npm error /,"");n(Object.assign(new Error(`${t} ${e[0]} failed: ${c||a.message}`),{stdout:o,stderr:i}))})})}r(v,"execArgv");function j(t){return new RegExp(`^${t.split("").map(e=>e==="*"?".*":e==="?"?".":e.replace(/[.+^${}()|[\]\\]/g,"\\$&")).join("")}$`)}r(j,"globOf");function g(t,e){return t.localeCompare(e,"en",{numeric:!0})}r(g,"byVersion");export{$ as CHECK_USAGE,C as checkText,I as checkWords,E as parseCheck,N as runCheck};
|
package/shared/repos.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=Object.defineProperty;var r=(o,t)=>i(o,"name",{value:t,configurable:!0});import m from"node:os";import e from"node:path";import{fileURLToPath as p}from"node:url";const f=r(()=>e.resolve(e.dirname(p(import.meta.url)),".."),"cloneRoot"),n=r((o=m.homedir())=>e.join(o,".claude","kickflip","repos"),"reposDir");export{f as cloneRoot,n as reposDir};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.defineProperty;var s=(t,l)=>p(t,"name",{value:l,configurable:!0});import n from"node:fs";import f from"node:os";import a from"node:path";const m=a.join("Tailscale.app","Contents","MacOS","Tailscale"),r=s(t=>{try{return n.statSync(t).isFile()&&(n.accessSync(t,n.constants.X_OK),!0)}catch{return!1}},"isExecutable");function j({env:t=process.env,platform:l=process.platform,apps:e=["/Applications",a.join(f.homedir(),"Applications")]}={}){for(const i of(t.PATH||"").split(a.delimiter).filter(Boolean)){const o=a.join(i,"tailscale");if(r(o))return o}return l!=="darwin"?null:e.map(i=>a.join(i,m)).find(r)??null}s(j,"tailscaleBin");const c=s((t=process.platform)=>t==="darwin"?"brew install --cask tailscale-app":"curl -fsSL https://tailscale.com/install.sh | sh","tailscaleInstallCommand"),x=s((t=process.platform)=>t==="darwin"?`install Tailscale from https://tailscale.com/download, or ${c(t)}`:c(t),"tailscaleInstallHint");export{j as tailscaleBin,c as tailscaleInstallCommand,x as tailscaleInstallHint};
|
package/shared/usage-gate.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var S=Object.defineProperty;var o=(e,t)=>S(e,"name",{value:t,configurable:!0});import g from"node:os";import{usageReader as $}from"../hub/usage.mjs";import{readSettingsFile as
|
|
1
|
+
var S=Object.defineProperty;var o=(e,t)=>S(e,"name",{value:t,configurable:!0});import g from"node:os";import{usageReader as $}from"../hub/usage.mjs";import{readSettingsFile as h,writeSettingsFile as m,readCodexShare as A,readClaudeModel as D}from"../hub/push.mjs";import{codexStatus as N,codexStatusReader as M,effectiveCodexShare as O}from"./codex.mjs";const E=o(e=>Number.isInteger(e)&&e>=50&&e<=100&&e%5===0,"validPauseAt"),w=o(e=>Number(e),"timeOf"),G=["five_hour","seven_day"];function v({claude:e,codex:t,pauseAt:s=90,keepGoing:n,now:a=Date.now()}={}){const u=E(s)?s:90,r=o(f=>u===100?null:G.find(i=>{const c=f?.[i];return c?.state==="live"&&Number.isFinite(c.used_percentage)&&c.used_percentage>=u&&(!c.resets_at||Date.parse(c.resets_at)>w(a))})||null,"past"),l=o((f,i)=>({window:i,used:i?f[i].used_percentage:null,resets_at:i?f[i].resets_at:null}),"details"),d=r(e),p=l(e,d),C=d&&n?.window===d&&Math.abs(Date.parse(n.until)-Date.parse(p.resets_at))<=3e5&&w(a)<Date.parse(n.until),x=r(t);return{pause_at:u,state:d?C?"going":"paused":"normal",...p,codex:{past:!!x,...l(t,x)}}}o(v,"usageGate");const _=new Map;function k({home:e=g.homedir(),now:t=Date.now()}={}){let s=_.get(e);s||(s={now:w(t)},s.usage=$({home:e,now:o(()=>s.now,"now")}),s.codex=M({home:e,now:o(()=>s.now,"now")}),_.set(e,s)),s.now=w(t);const n=h(e);return v({...s.usage({codexShare:A(s.codex(),e)}),pauseAt:n.pauseAt,keepGoing:n.keepGoing,now:t})}o(k,"readUsageGate");function U(e,{home:t=g.homedir()}={}){if(!/^(?:50|55|60|65|70|75|80|85|90|95|100)$/.test(String(e)))throw Object.assign(new Error("pause-at takes 50..100 in steps of 5"),{status:400});m({...h(t),pauseAt:Number(e)},t)}o(U,"setPauseAt");function W(e,{home:t=g.homedir(),now:s=Date.now()}={}){if(!["on","off"].includes(e))throw Object.assign(new Error("keep-going takes on or off"),{status:400});const n=h(t);if(e==="on"){const a=k({home:t,now:s});if(a.state!=="paused")throw Object.assign(new Error("Nothing is paused."),{status:409});n.keepGoing={window:a.window,until:a.resets_at}}else delete n.keepGoing;m(n,t)}o(W,"setKeepGoing");const z=o(e=>{try{return["github-change","check-github","card-unblocked","overnight-triage","pr-review","owner-check-broken"].includes(JSON.parse(e).kind)}catch{return!1}},"heldUsageEvent");function B({home:e=g.homedir(),now:t=Date.now(),card:s={}}={}){const n=o(l=>{const{model:d,reason:p}=P(D(e),s);return{kind:"claude",model:d,reason:`${l} ${p}`}},"claude"),a=N({home:e});if(!a.usable)return n(a.words);const u=O(h(e).codexShare,a);if(u==="off")return n("Codex share is off.");const r=k({home:e,now:t});return r.codex.past?n(`Codex is at ${Math.round(r.codex.used)}%, past the ${r.pause_at}% line until ${r.codex.resets_at}.`):{kind:"codex",reason:`Codex share is ${u} and Codex is under the ${r.pause_at}% line.`}}o(B,"builderPick");const b={opus:"Opus",sonnet:"Sonnet"};function P(e,t){return e!=="auto"?{model:e,reason:`Claude model is ${b[e]}.`}:t.model?{model:t.model,reason:`Claude model is Auto and the card asks for Claude ${b[t.model]}.`}:t.size==="small"?{model:"sonnet",reason:"Claude model is Auto and the card is small."}:{model:"opus",reason:"Claude model is Auto and the card isn't small."}}o(P,"claudePick");const H=o(e=>`Work is paused: Claude's ${e.window==="five_hour"?"5-hour":"weekly"} usage is at ${Math.round(e.used)}%. Resumes at ${e.resets_at}. The owner can tap Keep going on the Hub page.`,"pauseReason");export{B as builderPick,z as heldUsageEvent,H as pauseReason,k as readUsageGate,W as setKeepGoing,U as setPauseAt,v as usageGate,E as validPauseAt};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// HubPolling, the editor inside Hub’s Polling modal (ADR 0075): the day’s windows, overnight hold
|
|
2
|
-
// and daily wakes, in hub/views.mjs pollingView's words from GET /_hub/api/polling. ?w= names the window shown,
|
|
3
|
-
// which a tap on the day bar changes in place. Each change posts to /_hub/settings/polling and saves at once.
|
|
4
|
-
(function () {
|
|
5
|
-
// The last data, which a return to the view paints at once.
|
|
6
|
-
let last = null;
|
|
7
|
-
const { esc } = HubUI;
|
|
8
|
-
const ACTION = '/_hub/settings/polling';
|
|
9
|
-
// Each change posts op and w, the shown window's start.
|
|
10
|
-
const form = (op, w, inner, attrs = '') => `<form method="post" action="${ACTION}"${attrs}>${op ? `<input type="hidden" name="op" value="${op}">` : ''}<input type="hidden" name="w" value="${esc(w)}">${inner}</form>`;
|
|
11
|
-
|
|
12
|
-
function dayBar(day, sel) {
|
|
13
|
-
const segs = day.segments.map((g) => `<a class="seg${g.w === sel ? ' sel' : ''}${g.held ? ' held' : ''}" href="${esc(AppRouter.urlOf({ kind: 'hub', hash: '#polling', w: g.w }))}" data-w="${esc(g.w)}" style="left:${g.left};width:${g.width};--k:${g.shade}"`
|
|
14
|
-
+ ` aria-label="${esc(g.aria)}"${g.w === sel ? ' aria-current="true"' : ''}>${g.label ? `<span>${esc(g.label)}</span>` : ''}</a>`).join('');
|
|
15
|
-
const pins = day.pins.map((p) => `<span class="pin" style="left:${p.left}" title="${esc(p.title)}" aria-hidden="true">▼</span>`).join('');
|
|
16
|
-
const ticks = ['12am', '6am', '12pm', '6pm', '12am'].map((t, i) => `<span style="left:${i * 25}%">${t}</span>`).join('');
|
|
17
|
-
const legend = ['<span><i style="background:var(--muted)"></i>darker checks more often</span>',
|
|
18
|
-
day.held && '<span><i style="background:repeating-linear-gradient(135deg,var(--muted) 0 3px,var(--chip) 3px 5px)"></i>pushes held</span>',
|
|
19
|
-
day.wakes && '<span style="color:var(--color-notice)">▼ wake</span>',
|
|
20
|
-
'<span><i style="background:var(--text);width:2px"></i>now</span>'].filter(Boolean).join('');
|
|
21
|
-
return `<div class="day">${pins}<span class="now" style="left:${day.now}" aria-hidden="true"></span><div class="bar">${segs}</div><div class="ticks" aria-hidden="true">${ticks}</div></div><div class="legend">${legend}</div>`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function html(d, sel, flash) {
|
|
25
|
-
const { row, tile, nowRow } = HubUI;
|
|
26
|
-
const w = d.windows.find((x) => x.from === sel);
|
|
27
|
-
const chips = w.every.map((c) => `<button class="btn${c.on ? '' : ' quiet'}" name="value" value="${c.minutes}"${c.on ? ' aria-pressed="true"' : ''}>${esc(c.label)}</button>`).join('');
|
|
28
|
-
const wakeChips = d.wakes.map((t) => `<button class="btn quiet" name="value" value="${esc(t.value)}" aria-label="Remove the ${esc(t.label)} wake">${esc(t.label)} ✕</button>`).join('');
|
|
29
|
-
return `${HubUI.flash(flash)}<h2 class="label" style="margin-top:4px">Now</h2>
|
|
30
|
-
<div class="group">${nowRow(d.now)}</div>
|
|
31
|
-
<h2 class="label" id="day">Your day</h2>
|
|
32
|
-
<div class="group"><div class="block">${dayBar(d.day, w.from)}</div></div>
|
|
33
|
-
<h2 class="label" id="window">${esc(w.range)}</h2>
|
|
34
|
-
<div class="group">
|
|
35
|
-
${form('from', w.from, `<label class="body"><span class="text title">Starts</span><input type="time" name="value" value="${esc(w.from)}" required data-autosave></label>`, ' class="row field"')}
|
|
36
|
-
${row({ title: 'Ends', trail: `<span class="val">${esc(w.ends)}</span>` })}
|
|
37
|
-
${form('every', w.from, `<span class="title">Checks every</span><span class="chips">${chips}</span><span class="sub" style="margin-top:6px">${esc(w.checks)}</span>`, ' class="block"')}
|
|
38
|
-
${form('', w.from, `<button class="btn quiet" name="op" value="split"${w.split ? '' : ' disabled'}>Split in two</button><button class="btn quiet danger" name="op" value="remove"${w.remove ? '' : ' disabled'}>Remove</button>`, ' class="block split"')}
|
|
39
|
-
</div>
|
|
40
|
-
<h2 class="label" id="quiet">Quiet times</h2>
|
|
41
|
-
<div class="group">${form('hold', w.from, `${tile('moon', '#6366f1')}<label class="body"><span class="text"><span class="title">Hold pushes overnight</span></span><input type="checkbox" name="value" value="on" class="toggle" data-submit${d.hold.on ? ' checked' : ''}></label>`, ' class="row field"')}</div>
|
|
42
|
-
<h2 class="label" id="wakes">Daily wakes</h2>
|
|
43
|
-
<div class="group"><div class="block"><div class="chips" style="margin-top:0">${wakeChips ? form('wake-remove', w.from, wakeChips) : ''}${form('wake-add', w.from, '<input type="time" name="value" required aria-label="New wake time"><button class="btn quiet">+ Add</button>', ' class="field"')}</div></div></div>`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
globalThis.HubPolling = {
|
|
47
|
-
create: (root, siteRoot, ctx) => BoardView.page(root, siteRoot, (B) => {
|
|
48
|
-
const main = root;
|
|
49
|
-
let sel = ctx.view?.w || null;
|
|
50
|
-
let flash = null;
|
|
51
|
-
const shown = () => (last.windows.some((x) => x.from === sel) ? sel : last.select);
|
|
52
|
-
const paint = () => { if (last) main.innerHTML = html(last, shown(), flash); };
|
|
53
|
-
// The shown window lives in the URL, so a reload or a shared link shows it too.
|
|
54
|
-
const select = (w) => {
|
|
55
|
-
sel = w;
|
|
56
|
-
history.replaceState(history.state, '', AppRouter.urlOf({ kind: 'hub', hash: '#polling', w }));
|
|
57
|
-
paint();
|
|
58
|
-
};
|
|
59
|
-
B.selectWindow = select;
|
|
60
|
-
B.on(root, 'click', (e) => {
|
|
61
|
-
const seg = e.target.closest?.('a.seg[data-w]');
|
|
62
|
-
if (!seg || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
select(seg.dataset.w);
|
|
65
|
-
});
|
|
66
|
-
const forms = HubKit.forms(B, {
|
|
67
|
-
answer(out, action) {
|
|
68
|
-
if (action === ACTION) { last = out; flash = null; select(out.select); }
|
|
69
|
-
else { flash = { text: out.message, error: !out.ok }; load(); }
|
|
70
|
-
ctx.changed?.();
|
|
71
|
-
ctx.sidebarChanged?.();
|
|
72
|
-
},
|
|
73
|
-
fail(message) { flash = { text: message, error: true }; paint(); },
|
|
74
|
-
});
|
|
75
|
-
const load = HubKit.live(B, {
|
|
76
|
-
url: () => `/_hub/api/polling${sel ? `?w=${encodeURIComponent(sel)}` : ''}`,
|
|
77
|
-
paint(d) {
|
|
78
|
-
if (!d) { if (!last) main.innerHTML = '<p class="note">Offline. Is the host awake?</p>'; return; }
|
|
79
|
-
last = d;
|
|
80
|
-
paint();
|
|
81
|
-
},
|
|
82
|
-
busy: () => forms.busy() || Boolean(root.querySelector('input:focus')),
|
|
83
|
-
});
|
|
84
|
-
paint();
|
|
85
|
-
}),
|
|
86
|
-
};
|
|
87
|
-
})();
|