@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/bin/doctor.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)[0]:
|
|
3
|
-
`)[0]:"not installed; a hub board\u2019s session (kickflip join --hub, kickflip hub) runs in it",c.tmux);const
|
|
4
|
-
`)),{items:
|
|
1
|
+
var it=Object.defineProperty;var d=(n,u)=>it(n,"name",{value:u,configurable:!0});import k from"node:fs";import q from"node:os";import p from"node:path";import{isTryPort as J}from"../hub/try.mjs";import{githubGitArgv as nt,gitReachFault as rt}from"../hub/repos.mjs";import{buildsLocally as at,isBoardSite as lt}from"../hub/boards.mjs";import{cloneRoot as Q,reposDir as ct}from"../shared/repos.mjs";import{codexStatus as ut}from"../shared/codex.mjs";import{REVIEW_SKILLS as ft,SKILLS_SOURCE as dt,addCommand as ht,skillsState as mt,updateCommand as pt}from"../shared/skills.mjs";import{hubService as gt,runCommand as kt}from"../shared/service.mjs";import{tailscaleBin as bt}from"../shared/tailscale.mjs";import{inspectLinks as $t,ownsStatusLine as yt,hasWatcherStop as wt,hubStatus as xt,tailscaleState as St,runInstall as jt}from"./install.mjs";const h="kickflip doctor --fix",Y={ok:"ok",fixable:"fixable",yours:"yours",optional:"optional",note:"note"},y=d(n=>`'${n.replaceAll("'","'\\''")}'`,"quote"),Ot={darwin:{git:"xcode-select --install",gh:"brew install gh",tmux:"brew install tmux"},other:{git:"sudo apt install git",gh:"sudo apt install gh",tmux:"sudo apt install tmux"}},Ct="cli/cli",Tt=15e3,Z=d(n=>{try{return k.realpathSync(n)}catch{return null}},"realPath"),tt=d(n=>n.length?`${n.map(u=>`/${u}`).join(", ")} ${n.length>1?"use":"uses"} it`:"","usedBy");function et({home:n=q.homedir(),cloneRoot:u=Q()}={}){let a={};try{a=JSON.parse(k.readFileSync(p.join(n,".claude","kickflip","manifest.json"),"utf8"))}catch{}const w=[...Object.entries(a.sites||{}).map(([i,r])=>[i,r?.owner?.repo]),...Object.entries(a.closed||{}).map(([i,r])=>[i,r?.site?.owner?.repo]),...Object.entries(a.starting||{}).map(([i,r])=>[i,r?.repo])].map(([i,r])=>[i,r&&Z(r)]).filter(([,i])=>i),f=`${p.sep}.repos${p.sep}`,C=new Set([Z(p.join(u,".repos")),...w.map(([,i])=>i.includes(f)?i.slice(0,i.indexOf(f)+f.length-1):null)].filter(Boolean)),g=[],x=d(i=>{for(const r of k.readdirSync(i,{withFileTypes:!0})){if(!r.isDirectory())continue;const c=p.join(i,r.name);k.existsSync(p.join(c,".git"))?g.push(c):x(c)}},"walk");for(const i of C)x(i);return g.sort().map(i=>({clone:i,routes:[...new Set(w.filter(([,r])=>r===i||r.startsWith(i+p.sep)).map(([r])=>r))]}))}d(et,"oldBoardClones");async function Nt({home:n=q.homedir(),cloneRoot:u=Q(),port:a=Number(process.env.KICKFLIP_HUB_PORT||4500),uid:w=process.getuid(),env:f=process.env,run:C=kt,platform:g=process.platform,username:x=q.userInfo().username,fetch:i=globalThis.fetch,tailscale:r=bt({env:f,platform:g})}={}){const c=Ot[g==="darwin"?"darwin":"other"],v=[];let m;const s=d((t,e,o,l=null)=>v.push({group:m,item:t,state:e,detail:o,fix:e==="ok"||e==="note"?null:l}),"add"),b=d((t,e,o=null,l=void 0)=>{try{return C(t,e,{env:o?{...f,...o}:f,...l&&{timeout:l}})}catch(j){return{status:1,error:j.message}}},"execute"),M=d((t,e,o,l,j="not on this session\u2019s PATH")=>{const F=b(e,o),K=F.status===0;return s(t,K?"ok":"yours",K?(F.stdout||"installed").trim().split(`
|
|
2
|
+
`)[0]:j,l),K},"installed");m="prereqs";const U=M("git","git",["--version"],c.git);M("node on Claude\u2019s PATH","node",["--version"],`add ${y(p.dirname(process.execPath))} to PATH in your shell profile, then restart Claude Code`,`not on this session\u2019s PATH (${f.PATH||"empty"})`);const V=M("gh","gh",["--version"],c.gh),L=V&&b("gh",["auth","status"]).status===0;if(s("gh signed in",L?"ok":"yours",L?"signed in":V?"not signed in":"needs gh","gh auth login"),U){const t=L?b("gh",["repo","list","--limit","1","--json","nameWithOwner","--jq",".[0].nameWithOwner"]):null,e=t?.status===0&&t.stdout.trim()||Ct,o=b("git",nt(["ls-remote",`https://github.com/${e}.git`,"HEAD"]),{GIT_TERMINAL_PROMPT:"0"});s("GitHub clone",o.status===0?"ok":"yours",o.status===0?`git reaches ${e} over https`:`git can\u2019t reach ${e} over https: ${o.error}`,L?"gh auth refresh -h github.com, then kickflip doctor":"check this machine reaches https://github.com, then kickflip doctor")}else s("GitHub clone","yours","needs git",c.git);const T=await St({run:d((t,e)=>b(t,e),"run"),platform:g,uid:w,username:x,port:a,tailscale:r});for(const t of T.prereqs)s(t.item,t.state,t.detail,t.fix);const B=b("tmux",["-V"]);s("tmux",B.status===0?"ok":"optional",B.status===0?(B.stdout||"installed").trim().split(`
|
|
3
|
+
`)[0]:"not installed; a hub board\u2019s session (kickflip join --hub, kickflip hub) runs in it",c.tmux);const A=ut({home:n,env:f,platform:g});s("Codex",A.usable?"ok":"optional",A.usable?"installed and logged in":`${A.reason}; Codex builds and reviews need it`,A.fix);const S=mt({home:n,run:b,gh:L});S.missing.length?s("mattpocock skills","optional",`${S.missing.join(", ")} not installed; architecture reviews need ${S.missing.length===1?"it":"them"}`,ht(S.missing)):S.stale.length?s("mattpocock skills","optional",`${S.stale.join(", ")} out of date with ${dt}`,pt(S.stale)):s("mattpocock skills","ok",`${ft.join(", ")} installed${S.checked?" and current":""}`),m="setup";const X=["kickflip skill link","kickflip-hooks link","~/.claude/statusline.sh"];for(const[t,e]of $t({home:n,cloneRoot:u}).entries())if(e.refusal){const o=k.lstatSync(e.link);s(X[t],"yours",o.isSymbolicLink()?`links to ${k.readlinkSync(e.link)}, not kickflip`:`a real ${o.isDirectory()?"folder":"file"}, not kickflip\u2019s link`,`${o.isSymbolicLink()?`rm ${y(e.link)}`:`mv ${y(e.link)} ${y(e.link+".backup")}`} && ${h}`)}else s(X[t],e.created||e.replaced?"fixable":"ok",`${e.created?"missing":e.replaced?"needs relinking":"linked"} -> ${e.target}`,h);const E=p.join(n,".claude","settings.json");let $={},O;try{if($=JSON.parse(k.readFileSync(E,"utf8")),!$||typeof $!="object"||Array.isArray($))throw new Error("not a settings object")}catch(t){t.code!=="ENOENT"&&(O=t.message)}const I="settings.json statusLine";O?s(I,"yours",`unreadable: ${O}`,`repair the JSON in ${y(E)}, then ${h}`):Object.hasOwn($,"statusLine")?yt($.statusLine,n)?s(I,"ok","runs ~/.claude/statusline.sh"):s(I,"yours","another tool\u2019s status line is selected",`remove statusLine from ${y(E)}, then ${h}`):s(I,"fixable","missing",h);const W="settings.json watcher Stop hook";O?s(W,"yours",`unreadable: ${O}`,`repair the JSON in ${y(E)}, then ${h}`):wt($)?s(W,"ok","runs hooks-plugin/hooks/watcher-stop.mjs"):s(W,"fixable","missing; a board session can end a turn with no live watcher or a message left Working on it",h);const D="settings.json autoCompactEnabled";O?s(D,"yours",`unreadable: ${O}`,`repair the JSON in ${y(E)}, then ${h}`):$.autoCompactEnabled===!0?s(D,"ok","on"):s(D,"fixable",`${Object.hasOwn($,"autoCompactEnabled")?"off":"not set"}; a board session that fills its context stops answering`,h);const N=gt({platform:g,home:n,uid:w,env:f,run:C}),z=N.status();s(N.item,z.running?"ok":N.manager?"fixable":"yours",z.detail,N.manager?h:`run ${N.restartCommand} under a service manager of your own`);for(const t of N.notes())s(t.item,t.state,t.detail,t.fix);m="hub";const H=await xt({port:a,fetch:i});s("hub",H?"ok":"fixable",`${H?"running":"not running"} on 127.0.0.1:${a}`,h);const{serveConfig:G}=T;s(T.root.item,T.root.state,T.root.detail,T.root.fix);let P=H?.sites;if(!P){const t=p.join(n,".claude","kickflip","manifest.json");try{const e=JSON.parse(k.readFileSync(t,"utf8"));P=Object.entries(e.sites||{}).map(([o,l])=>({...l,route:o,state:"hub not running"}))}catch(e){e.code!=="ENOENT"&&s("site manifest","yours",e.message,`repair the JSON in ${y(t)}`),P=[]}}let _={};try{_=JSON.parse(k.readFileSync(p.join(n,".claude","kickflip","manifest.json"),"utf8"))}catch{}const R=new Map,st=[...Object.entries(_.sites||{}),...Object.entries(_.closed||{}).map(([t,e])=>[t,e.site]),...P.map(t=>[t.route,t])];for(const[t,e]of st){if(!e?.dir)continue;let o;try{o=JSON.parse(k.readFileSync(p.join(e.dir,"data","try.json"),"utf8"))}catch{continue}J(o.main_port)&&R.set(Number(o.main_port),`/${t} main`),J(o.main?.https)&&R.set(Number(o.main.https),`/${t} main`);for(const[l,j]of Object.entries(o.cards||{}))J(j.https)&&R.set(Number(j.https),`/${t} ${l}`)}const ot=Object.keys(G?.TCP||{}).filter(J).sort((t,e)=>t-e);s("try ports","ok",ot.map(t=>{const o=Object.entries(G.Web||{}).find(([l])=>l.endsWith(`:${t}`))?.[1]?.Handlers?.["/"]?.Proxy||G.TCP[t].TCPForward||"HTTPS";return`${t} \u2192 ${o} (${R.get(Number(t))||"unknown"})`}).join("; ")||"none"),P.length||s("sites","ok","none");for(const t of P){const e=t.port?`port ${t.port}`:`files ${t.dir}`,o=`${t.state} ${e} owner ${t.owner?.label||t.owner?.session||"-"} ${t.title||""}`.trimEnd();t.state==="up"?s("/"+t.route,"ok",o):H?t.serves==="port"?s("/"+t.route,"note",`${o}; its session runs this server, not the hub`):t.serves==="files"?s("/"+t.route,"note",`${o}; its folder is missing`):s("/"+t.route,"note",`${o}; the hub restarts it, see kickflip logs ${t.route}`):s("/"+t.route,"fixable",o,h)}if(U)for(const[t,e]of Object.entries(_.sites||{})){const o=e?.owner?.repo;if(!lt(e)||at(e)||!o)continue;const l=b("git",["-C",o,"ls-remote","--exit-code","origin","HEAD"],{GIT_TERMINAL_PROMPT:"0"},Tt),{error:j,hint:F}=rt(l.error,{github:e.github||"",repo:o});s(`/${t} repo`,l.status===0?"ok":"yours",l.status===0?`git reaches ${e.github||"origin"} from ${o}`:`git can\u2019t reach ${e.github||"origin"} from ${o}: ${j}`,F)}for(const{clone:t,routes:e}of et({home:n,cloneRoot:u}))s("old board clone","optional",[`${t} is in an old place`,`board clones now live in ${ct(n)}`,tt(e)].filter(Boolean).join("; "),h);return v}d(Nt,"doctorReport");function Pt(n){const u=Math.max(...Object.values(Y).map(a=>a.length));return n.flatMap(a=>[`${Y[a.state].padEnd(u)} ${a.item}: ${a.detail}`,...a.fix?[`${" ".repeat(u+1)}\u2192 ${a.fix}`]:[]])}d(Pt,"doctorLines");async function Dt({fix:n=!1,dryRun:u=!1,json:a=!1,write:w=console.log,error:f=console.error,install:C=jt,ask:g,...x}={}){let i=!1;if(n){const c=a?f:w;try{await C({...x,dryRun:u,log:c})}catch(m){i=!0,f("kickflip: "+m.message)}const v=et(x);if(u){for(const{clone:m}of v)c(`would ask to remove the old board clone ${m}`);return{items:[],exitCode:i?1:0}}for(const{clone:m,routes:s}of g?v:[]){const b=await g(`Remove the old board clone ${m}? ${s.length?`${tt(s)}. `:""}(y/N) `);/^y(es)?$/i.test(b.trim())&&(k.rmSync(m,{recursive:!0,force:!0}),c(`removed ${m}`))}}const r=await Nt(x);return w(a?JSON.stringify({items:r},null,2):Pt(r).join(`
|
|
4
|
+
`)),{items:r,exitCode:i||r.some(c=>c.state==="fixable"||c.state==="yours")?1:0}}d(Dt,"runDoctor");export{Pt as doctorLines,Nt as doctorReport,et as oldBoardClones,Dt as runDoctor};
|
package/bin/install.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)[0]
|
|
3
|
-
`,{mode:
|
|
1
|
+
var W=Object.defineProperty;var y=(e,s)=>W(e,"name",{value:s,configurable:!0});import o from"node:fs";import E from"node:os";import n from"node:path";import{SKILLS_SOURCE as I,addArgv as D,addCommand as M,missingSkills as P}from"../shared/skills.mjs";import{cloneRoot as N}from"../shared/repos.mjs";import{hubService as q,runCommand as _}from"../shared/service.mjs";import{tailscaleBin as B,tailscaleInstallHint as C}from"../shared/tailscale.mjs";const U=y(()=>o.existsSync("/opt/homebrew/bin/node")?"/opt/homebrew/bin/node":process.execPath,"nodeBin"),at=y((e,s,t=N())=>`${U()} ${n.join(t,"bin","wait-events.mjs")} ${e} ${s}`,"watcherCommand");function z(e,{home:s=E.homedir(),skillsDir:t=n.join(s,".claude","skills"),cloneRoot:i=N()}={}){if(typeof e!="string"||!n.isAbsolute(e))return e;const a=n.relative(i,e);if(a===".."||a.startsWith(`..${n.sep}`)||n.isAbsolute(a))return e;const c=n.resolve(t,"kickflip");let r=!1;try{r=o.realpathSync(c)===o.realpathSync(i)}catch{}return r?n.join(c,a):e}y(z,"storedPath");function G({home:e=E.homedir(),skillsDir:s=n.join(e,".claude","skills"),cloneRoot:t=N()}={}){const i=o.realpathSync(t),a=[["kickflip",i],["kickflip-hooks",n.join(i,"hooks-plugin")]].map(([l,f])=>{if(!o.statSync(f,{throwIfNoEntry:!1})?.isDirectory())throw new Error(`not a directory: ${f}`);const h=l==="kickflip"?f:n.resolve(s,"kickflip","hooks-plugin"),d=n.resolve(s,l),k=o.lstatSync(d,{throwIfNoEntry:!1});let b;if(k){let j;try{j=o.realpathSync(d)}catch(g){if(g.code!=="ENOENT")throw g}k.isSymbolicLink()?j!==o.realpathSync(f)&&(b=`refusing to replace link ${d} -> ${o.readlinkSync(d)}; remove that link explicitly, then rerun kickflip doctor --fix`):(!k.isDirectory()||j!==o.realpathSync(f))&&(b=`refusing to replace real path ${d}; move it aside explicitly, then rerun kickflip doctor --fix`)}return{link:d,target:h,created:!k,...b?{refusal:b}:{}}}),c=n.join(i,"bin","statusline.mjs");if(!o.statSync(c,{throwIfNoEntry:!1})?.isFile())throw new Error(`not a file: ${c}`);const r=n.join(e,".claude","statusline.sh"),S=n.resolve(s,"kickflip","bin","statusline.mjs"),u=o.lstatSync(r,{throwIfNoEntry:!1});let m=!1,w;if(u)if(!u.isSymbolicLink())w=`refusing to replace real path ${r}; move it aside explicitly, then rerun kickflip doctor --fix`;else{let l;try{l=o.realpathSync(r)}catch(k){if(k.code!=="ENOENT")throw k}const f=n.join(e,".claude","kickflip","sites");let h=f;try{h=o.realpathSync(f)}catch{}const d=!!l&&[f,h].some(k=>l.startsWith(k+n.sep));l&&l!==o.realpathSync(c)&&!d&&(w=`refusing to replace link ${r} -> ${o.readlinkSync(r)}; remove that link explicitly, then rerun kickflip doctor --fix`),m=d||n.resolve(n.dirname(r),o.readlinkSync(r))!==S||!l}return a.push({link:r,target:S,created:!u,...m?{replaced:!0}:{},...w?{refusal:w}:{}}),a}y(G,"inspectLinks");function F({home:e=E.homedir(),skillsDir:s=n.join(e,".claude","skills"),cloneRoot:t=N(),dryRun:i=!1}={}){const a=G({home:e,skillsDir:s,cloneRoot:t}),c=a.find(r=>r.refusal);if(c)throw new Error(c.refusal);if(i)return a;o.mkdirSync(s,{recursive:!0}),o.mkdirSync(n.join(e,".claude"),{recursive:!0});for(const{link:r,target:S,created:u,replaced:m}of a)m&&o.unlinkSync(r),(u||m)&&o.symlinkSync(S,r,r===n.join(e,".claude","statusline.sh")?"file":"dir");return a}y(F,"installLinks");function Q(e,s=E.homedir()){const t=n.join(s,".claude","statusline.sh"),i=[t,`"${t}"`,`'${t.replaceAll("'","'\\''")}'`,"~/.claude/statusline.sh","$HOME/.claude/statusline.sh",'"$HOME/.claude/statusline.sh"',"${HOME}/.claude/statusline.sh",'"${HOME}/.claude/statusline.sh"'];return e?.type==="command"&&i.includes(e.command)}y(Q,"ownsStatusLine");const K='node "$HOME/.claude/skills/kickflip/hooks-plugin/hooks/watcher-stop.mjs"',V=y(e=>(Array.isArray(e?.hooks?.Stop)?e.hooks.Stop:[]).some(s=>Array.isArray(s?.hooks)&&s.hooks.some(t=>t?.type==="command"&&/\/hooks-plugin\/hooks\/watcher-stop\.mjs\b/.test(t.command))),"hasWatcherStop");async function X({port:e=Number(process.env.KICKFLIP_HUB_PORT||4500),fetch:s=globalThis.fetch}={}){try{const t=await s(`http://127.0.0.1:${e}/_hub/status.json`,{signal:AbortSignal.timeout(1500)});if(!t.ok)return null;const i=await t.json();return Array.isArray(i?.sites)?i:null}catch{return null}}y(X,"hubStatus");function R(e){const s=Object.entries(e?.Web||{}).filter(([t])=>!/:\d+$/.test(t)||t.endsWith(":443")).flatMap(([,t])=>Object.entries(t.Handlers||{}));return{root:s.find(([t])=>t==="/")?.[1]?.Proxy||null,paths:[...new Set(s.map(([t])=>t))]}}y(R,"tailscaleRoot");function ct(e,{run:s=_,platform:t=process.platform,tailscale:i=B({platform:t})}={}){if(!i)throw new Error(`Tailscale isn't installed on this host; ${C(t)}`);const a=s(i,["status","--json"]);let c=null;try{c=a.status===0?JSON.parse(a.stdout):null}catch{}if(c?.BackendState!=="Running")throw new Error("Tailscale isn't running on this host; start it, or run tailscale up");const r=c.Self?.DNSName?.replace(/\.$/,"")||"";if(!r||!c.CertDomains?.includes(r))throw new Error("HTTPS isn't on for this tailnet; turn on HTTPS Certificates on the DNS page of the Tailscale admin console");return`https://${r}/${e?e+"/":""}`}y(ct,"tailnetUrl");async function lt({run:e=_,platform:s=process.platform,uid:t=process.getuid(),username:i=E.userInfo().username,port:a=Number(process.env.KICKFLIP_HUB_PORT||4500),tailscale:c=B({platform:s})}={}){const r=y(async $=>{try{return await e(c,$)}catch(v){return{status:1,error:v.message}}},"execute"),S=y($=>{try{return $.status===0?JSON.parse($.stdout):null}catch{return null}},"json"),u=c?await r(["version"]):null,m=u?.status===0,w=m?S(await r(["status","--json"])):null,l=w?.BackendState==="Running",f=w?.Self?.DNSName?.replace(/\.$/,"")||"",h=m&&s==="linux"&&t!==0,d=h?S(await r(["debug","prefs"]))?.OperatorUser:null,k=m?S(await r(["serve","status","--json"])):null,b=R(k);let j=!1;try{const $=new URL(b.root);j=$.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes($.hostname)&&Number($.port)===a&&$.pathname==="/"&&!$.search&&!$.hash}catch{}const g=y(($,v,p,x,A="yours")=>({item:$,state:v?"ok":A,detail:p,fix:v?null:x}),"entry"),O=[g("Tailscale",m,m?`${(u.stdout||"installed").trim().split(`
|
|
2
|
+
`)[0]} (${c})`:`not on this session\u2019s PATH${s==="darwin"?" or in Applications":""}`,C(s)),g("Tailscale signed in",l,l?`signed in${f?" as "+f:""}`:m?"not connected":"needs Tailscale","tailscale up")];h&&O.push(g("Tailscale operator",d===i,d===i?i:`${d||"none"} (expected ${i})`,"sudo tailscale set --operator=$USER"));const T=b.paths.filter($=>$!=="/"),L=g("tailscale /",j,`${b.root||"nothing"}${j?"":` (expected the hub on ${a})`}${T.length?"; other mounts: "+T.join(", "):""}`,l?"kickflip doctor --fix":m?"tailscale up":C(s),l?"fixable":"yours");return{installed:m,signedIn:l,dns:f,operatorChecked:h,operator:d,username:i,pointsAtHub:j,prereqs:O,root:L,serveConfig:k}}y(lt,"tailscaleState");async function ut({home:e=E.homedir(),cloneRoot:s=N(),port:t=Number(process.env.KICKFLIP_HUB_PORT||4500),uid:i=process.getuid(),env:a=process.env,run:c=_,platform:r=process.platform,tailscale:S=B({env:a,platform:r}),wait:u=y(f=>new Promise(h=>setTimeout(h,f)),"wait"),fetch:m=globalThis.fetch,dryRun:w=!1,log:l=console.log}={}){const f=n.join(e,".claude","kickflip"),h=q({platform:r,home:e,uid:i,env:a,run:c});if(w){try{for(const{link:x,target:A,created:H,replaced:J}of F({home:e,cloneRoot:s,dryRun:w}))l(`would ${H||J?"link":"check"} ${x} -> ${A}`)}catch(x){l(`would refuse: ${x.message}`)}l(`would merge statusLine and the watcher Stop hook, turn on autoCompactEnabled and remove stale hooks in ${n.join(e,".claude","settings.json")}`);const p=P(e);p.length&&l(`would add ${p.join(", ")} from ${I} with ${M(p)}`);for(const x of await h.install(null,{wait:u,dryRun:w}))l(x);l(`would map tailscale / to the hub on ${t} and remove old site mounts`);return}for(const{link:p,target:x,created:A,replaced:H}of F({home:e,cloneRoot:s}))l(`${A||H?"linked":"checked"} ${p} -> ${x}`);for(const p of Y({home:e}))l(p);const d=P(e);if(d.length){const p=c("npx",D(d),{env:a,timeout:3e5});l(p.status===0?`added ${d.join(", ")} from ${I}`:`could not add ${d.join(", ")} from ${I}: ${p.error}; run ${M(d)}`)}const k=U(),b=z(n.join(s,"hub","hub.mjs"),{home:e,cloneRoot:s});o.mkdirSync(f,{recursive:!0});const j=n.join(f,"hub.log"),g=h.definition({node:k,entry:b,state:f,port:t,log:j});for(const p of await h.install(g,{wait:u}))l(p);let O=!1;for(let p=0;p<30&&!O;p++)await u(300),O=!!await X({port:t,fetch:m});if(!O)throw new Error("hub did not start; see "+j);if(!S)return l(`skipped mapping tailscale / to the hub: Tailscale isn't installed on this host; ${C(r)}`);const T=c(S,["serve","--bg",String(t)],{env:a});if(T.status!==0)throw new Error(T.error||"tailscale serve failed");const L=c(S,["serve","status","--json"],{env:a});let $;try{$=JSON.parse(L.stdout)}catch{return}let v={};try{v=JSON.parse(o.readFileSync(n.join(f,"manifest.json"),"utf8")).sites||{}}catch(p){if(p.code!=="ENOENT")throw p}for(const p of R($).paths)p!=="/"&&Object.hasOwn(v,p.replace(/^\//,"").replace(/\/$/,""))&&c(S,["serve","--https=443","--set-path="+p,"off"],{env:a})}y(ut,"runInstall");function Y({home:e=E.homedir()}={}){const s=n.join(e,".claude","settings.json");let t={},i=384;try{t=JSON.parse(o.readFileSync(s,"utf8")),i=o.statSync(s).mode}catch(u){if(u.code!=="ENOENT")throw u}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`not a settings object: ${s}`);const a=[];let c=!1;const r=n.join(e,".claude","statusline.sh");if(Object.hasOwn(t,"statusLine"))Q(t.statusLine,e)||a.push(`kept existing statusLine in ${s}; it points elsewhere`);else{const u=/^[\w/.-]+$/.test(r)?r:`'${r.replaceAll("'","'\\''")}'`;t.statusLine={type:"command",command:u},c=!0,a.push(`set statusLine in ${s} -> ${u}`)}if(!V(t)){const u=t.hooks&&typeof t.hooks=="object"?t.hooks:{};t.hooks={...u,Stop:[...Array.isArray(u.Stop)?u.Stop:[],{hooks:[{type:"command",command:K}]}]},c=!0,a.push(`added the watcher Stop hook to ${s} -> ${K}`)}t.autoCompactEnabled!==!0&&(t.autoCompactEnabled=!0,c=!0,a.push(`turned on autoCompactEnabled in ${s}`));const S=n.join(e,".claude","hooks","no-paths.py");if(!o.existsSync(S)&&t.hooks&&typeof t.hooks=="object"){const u=y(l=>l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escape"),m=[S,"~/.claude/hooks/no-paths.py","$HOME/.claude/hooks/no-paths.py","${HOME}/.claude/hooks/no-paths.py"].map(u).join("|"),w=new RegExp(`^\\s*(?:exec\\s+)?(?:(?:/usr/bin/env\\s+)?(?:[^\\s]+/)?python(?:\\d+(?:\\.\\d+)*)?(?:\\s+-[^\\s]+)*\\s+)?(?:"(?:${m})"|'(?:${m})'|(?:${m}))(?=$|\\s)`);for(const[l,f]of Object.entries(t.hooks))Array.isArray(f)&&(t.hooks[l]=f.flatMap(h=>{if(!Array.isArray(h?.hooks))return[h];const d=h.hooks.filter(k=>k?.type!=="command"||typeof k.command!="string"||!w.test(k.command)?!0:(a.push(`removed stale hook ${l}: ${k.command}`),c=!0,!1));return d.length===h.hooks.length?[h]:d.length?[{...h,hooks:d}]:[]}))}if(c){o.mkdirSync(n.dirname(s),{recursive:!0});const u=`${s}.${process.pid}.${Date.now()}.tmp`;try{o.writeFileSync(u,JSON.stringify(t,null,2)+`
|
|
3
|
+
`,{mode:i,flag:"wx"}),o.renameSync(u,s)}finally{try{o.unlinkSync(u)}catch{}}}return a}y(Y,"installClaudeSettings");function dt({home:e=E.homedir(),skillsDir:s=n.join(e,".claude","skills"),cloneRoot:t=N()}={}){const i=n.join(e,".claude","statusline.sh");if(!o.lstatSync(i,{throwIfNoEntry:!1})?.isSymbolicLink())return!1;let c=n.resolve(n.dirname(i),o.readlinkSync(i))===n.resolve(s,"kickflip","bin","statusline.mjs");try{c||=o.realpathSync(i)===o.realpathSync(n.join(t,"bin","statusline.mjs"))}catch{}return c?(o.unlinkSync(i),!0):!1}y(dt,"uninstallStatusLine");export{K as WATCHER_STOP,V as hasWatcherStop,X as hubStatus,G as inspectLinks,Y as installClaudeSettings,F as installLinks,U as nodeBin,Q as ownsStatusLine,ut as runInstall,z as storedPath,ct as tailnetUrl,R as tailscaleRoot,lt as tailscaleState,dt as uninstallStatusLine,at as watcherCommand};
|
package/bin/kickflip.mjs
CHANGED
|
@@ -3,22 +3,25 @@
|
|
|
3
3
|
// kickflip doctor [--fix [--dry-run]] [--json]
|
|
4
4
|
// one line per prereq, installed piece, the hub, Tailscale / and each site (./doctor.mjs): ok,
|
|
5
5
|
// fixable (by --fix), yours (with the command to run), optional or note. Changes nothing.
|
|
6
|
-
// --fix runs init's steps,
|
|
6
|
+
// --fix runs init's steps, asks in a terminal whether to remove each board clone left in an old place
|
|
7
|
+
// (outside ~/.claude/kickflip/repos), then reports again. --json prints {items:[{group,item,state,detail,fix}]}
|
|
8
|
+
// and asks nothing.
|
|
7
9
|
// Exit 1 when anything is fixable or yours
|
|
8
10
|
// kickflip join [--name <board name>] [--hub]
|
|
9
|
-
// run in a git repo's folder: adds it as a board (docs/adr/
|
|
11
|
+
// run in a git repo's folder: adds it as a board (docs/adr/2026-11-03-0248-kickflip-join-adds-the-current-repository-as-a-board.md).
|
|
10
12
|
// Asks for the board name, default the folder's name; with no terminal to ask in, --name is needed. The name
|
|
11
13
|
// takes letters, digits and spaces, and gives the route, lowercased with dashes for spaces. Records the
|
|
12
|
-
// folder's origin as `github` and its branch
|
|
13
|
-
// land there (`local: true`). Marks the folder trusted for Claude Code, then starts the board's session in
|
|
14
|
+
// folder's origin as `github` and its default branch (origin's, else the checked-out one); the board's
|
|
15
|
+
// builders branch from the folder's local copy of that branch and land there (`local: true`). Marks the folder trusted for Claude Code, then starts the board's session in
|
|
14
16
|
// the background as `start` does, or with --hub flags the board as the hub board, starts its session in
|
|
15
17
|
// the foreground in tmux and attaches this terminal to it, as `hub` does. Refuses a folder outside git (exit 2), and exits 1 while the hub isn't
|
|
16
|
-
// running. A folder that already has a board names it
|
|
18
|
+
// running. A folder that already has a board names it, records its default branch again when that
|
|
19
|
+
// changed, saying so, and offers to restart its session
|
|
17
20
|
// Every other join names its site with --name <name>, which gives its title and its route as above (any characters,
|
|
18
21
|
// other than letters and digits, become dashes). A name that is the route itself keeps the site's title.
|
|
19
22
|
// kickflip join --name <name> (--port <n> | --dir <folder> [--cmd '<json array>' [--port <n>]])
|
|
20
23
|
// [--description <d>] [--icon <key>] [--color <css hex>]
|
|
21
|
-
// a plain page: no session, owner, watcher or needs (docs/adr/
|
|
24
|
+
// a plain page: no session, owner, watcher or needs (docs/adr/2026-11-01-1446-a-page-joins-without-a-session.md).
|
|
22
25
|
// --port forwards /<route>/ to a server the session already runs, which reads Down while it doesn't
|
|
23
26
|
// answer; --dir alone has the hub serve the folder's files; --cmd has the hub run that command in --dir
|
|
24
27
|
// (default the cwd) on --port or a free one. Prints {route, url, serves, port|dir, answering?, hub}.
|
|
@@ -79,7 +82,7 @@
|
|
|
79
82
|
// session resumed in its recorded folder and model, or in --repo when no folder is recorded; with no
|
|
80
83
|
// owner, a fresh session in --repo (default cwd) that joins the board with --hub. Points it to
|
|
81
84
|
// docs/hub-session.md. While the tmux session runs, nothing else starts
|
|
82
|
-
// (docs/adr/
|
|
85
|
+
// (docs/adr/2026-11-03-0313-boards-run-in-the-background-and-the-hub-board-in-tmux.md).
|
|
83
86
|
// Exit 2 when no board has the hub flag (`set --hub`), 3 while its session is live outside tmux;
|
|
84
87
|
// otherwise keeps tmux's exit code
|
|
85
88
|
// kickflip sessions [--json]
|
|
@@ -94,6 +97,10 @@
|
|
|
94
97
|
// site; --no-hub clears it. Exit 2 for --hub on a site that isn't a board
|
|
95
98
|
// kickflip leave <route> [--session <id>] [--force]
|
|
96
99
|
// removes the entry and keeps its files; --session (or --force) only for a route a session owns
|
|
100
|
+
// kickflip url [route]
|
|
101
|
+
// prints the hub's HTTPS address on the tailnet, the one to open on the phone, or with a route that
|
|
102
|
+
// site's (./install.mjs tailnetUrl). Exit 1 when Tailscale isn't installed or running, or HTTPS isn't on for the tailnet,
|
|
103
|
+
// 2 for a route with no site
|
|
97
104
|
// kickflip restart <route>
|
|
98
105
|
// kickflip logs <route> [--lines <n>]
|
|
99
106
|
// kickflip init [--dry-run] | uninstall
|
|
@@ -108,24 +115,25 @@
|
|
|
108
115
|
// kickflip update
|
|
109
116
|
// installs @lovek4d/kickflip@latest globally with npm, then restarts the hub.
|
|
110
117
|
// A clone refuses (exit 2); update it with git pull
|
|
111
|
-
// kickflip push --kind action|prompt|fault --title <t> [--body <b>] [--url </route/path>] [--tag <tag>]
|
|
118
|
+
// kickflip push --kind action|prompt|fault|reminder --title <t> [--body <b>] [--url </route/path>] [--tag <tag>]
|
|
112
119
|
// [--now | --urgent]
|
|
113
120
|
// notify every device that turned on notifications on the Hub page; a tap opens --url.
|
|
114
121
|
// --kind says what waits on the owner (../hub/push.mjs PUSH_KINDS): action, a card's Action needed
|
|
115
122
|
// appearing or changing; prompt, a background session's prompt; fault, something only the owner
|
|
116
|
-
// can fix. A push without one is refused (exit 2):
|
|
123
|
+
// can fix; reminder, a push the owner asked for in words. A push without one is refused (exit 2):
|
|
124
|
+
// news stays on the board.
|
|
117
125
|
// The push queues, replacing a queued one with the same
|
|
118
|
-
// --tag, and goes out after the hub's next GitHub check
|
|
119
|
-
//
|
|
126
|
+
// --tag, and goes out after the hub's next GitHub check, every minute while the owner is here
|
|
127
|
+
// and every 5 while away, or when a GitHub tick ends (board.mjs checked); a board's
|
|
120
128
|
// several queued pushes go as one summary. --now sends at once unless pushes are held
|
|
121
|
-
// (
|
|
129
|
+
// (quiet hours, snoozed or the weekend), and queues if no device takes it; it is for questions,
|
|
122
130
|
// steps only the owner can run and prototypes. --urgent sends at once through
|
|
123
131
|
// those holds, for a production fault. While notifications are off every push is dropped, urgent ones too.
|
|
124
132
|
// Prints "sent", "queued" with the next send time, or "dropped". Exit 3 when no device has turned them on.
|
|
125
|
-
// kickflip
|
|
126
|
-
// prints {
|
|
127
|
-
//
|
|
128
|
-
// (
|
|
133
|
+
// kickflip quiet
|
|
134
|
+
// prints {quiet, held, held_until, held_why, notifications}: quiet hours {start, end, hold}, whether
|
|
135
|
+
// pushes are held now, until when ("never" while off, "forever" while snoozed until ended) and why
|
|
136
|
+
// (off, snoozed, weekend or overnight), and the notifications settings
|
|
129
137
|
// kickflip notifications [on | off | snooze <length> | unsnooze | weekends on|off]
|
|
130
138
|
// sets the Hub page's Notifications controls and prints them; off drops the queued pushes.
|
|
131
139
|
// A snooze length is a hub/schedule.mjs snoozeEnd choice. Without a change it only prints them
|
|
@@ -145,12 +153,12 @@
|
|
|
145
153
|
// checked.json, then the queue unless --keep-queue) and prints its result
|
|
146
154
|
// Exit codes: 0 ok, 1 error, 2 bad usage, 3 route owned by another session (join/leave), or its recorded session is
|
|
147
155
|
// live (start/resume/hub). hub passes through claude's exit code.
|
|
148
|
-
var
|
|
149
|
-
`);const
|
|
150
|
-
`)),[
|
|
151
|
-
The board is made; run kickflip join here again to start its session.`,f.code),f}
|
|
156
|
+
var xe=Object.defineProperty;var p=(e,t)=>xe(e,"name",{value:t,configurable:!0});import w from"node:fs";import u from"node:path";import L from"node:os";import ie from"node:net";import _e from"node:readline/promises";import{execFileSync as re,spawnSync as K}from"node:child_process";import{fileURLToPath as Ne}from"node:url";import{ICON_KEYS as ae}from"../hub/icons.mjs";import{liveSessions as ce}from"../hub/live.mjs";import{isBoardSite as P,writeManifest as v}from"../hub/boards.mjs";import{joinName as Te,routeFromName as F,routeRecord as g,validRoute as C}from"../hub/routes.mjs";import{defaultBranch as Ie,githubFromOrigin as Fe}from"../hub/repos.mjs";import{uninstallStatusLine as Ce,storedPath as Re,nodeBin as U,watcherCommand as Ee,tailnetUrl as Be}from"./install.mjs";import{hubService as de}from"../shared/service.mjs";import{tailscaleBin as ue}from"../shared/tailscale.mjs";import{runDoctor as De}from"./doctor.mjs";import{cloneRoot as Le}from"../shared/repos.mjs";const j=Le(),_=u.join(L.homedir(),".claude","kickflip"),Pe=u.join(_,"manifest.json"),le=u.join(_,"logs"),T=Number(process.env.KICKFLIP_HUB_PORT||4500),G=4600,Ae=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,[W,...S]=process.argv.slice(2),s=Object.assign(Object.create(null),{_:[]});for(let e=0;e<S.length;e++){const t=S[e];if(t.startsWith("--")){const n=t.slice(2);n==="fix"||n==="force"||n==="json"||n==="urgent"||n==="now"||n==="keep-queue"||n==="hub"||n==="no-hub"||n==="dry-run"||n==="watch"&&(e+1>=S.length||S[e+1].startsWith("--"))?s[n]=!0:s[n]=S[++e]}else s._.push(t)}const h=p(e=>console.log(typeof e=="string"?e:JSON.stringify(e,null,2)),"out");class I extends Error{static{p(this,"Exit")}constructor(t,n){super(t),this.code=n}}const i=p((e,t=1)=>{throw new I(e,t)},"fail");function Y(){s.icon&&!ae.includes(s.icon)&&i(`--icon takes one of: ${ae.join(", ")}`,2),s.color&&!Ae.test(s.color)&&i("--color takes a CSS hex color, such as #3b82f6",2)}p(Y,"checkLook");function Q(e){for(const t of["icon","color"])s[t]===""?delete e[t]:s[t]!==void 0&&(e[t]=s[t])}p(Q,"applyLook");const fe=p(()=>s.hub&&s["no-hub"]&&i("pass --hub or --no-hub, not both",2),"checkHub"),he=p(e=>i(`/${e} is not a board; only a board can be the hub board`,2),"notBoard");function X(e,t,n){if(s["no-hub"]&&delete n.hub,!!s.hub){P(n)||he(t);for(const[o,l]of Object.entries(e.sites))o!==t&&l?.hub&&delete l.hub;n.hub=!0}}p(X,"applyHub");function y(){try{const e=JSON.parse(w.readFileSync(Pe,"utf8"));return e.sites||={},e}catch(e){if(e.code==="ENOENT")return{version:1,sites:{}};i("manifest unreadable: "+e.message)}}p(y,"readManifest");const pe=p(e=>{try{return JSON.parse(w.readFileSync(e,"utf8"))}catch{return null}},"readJSON"),R=p(()=>import(u.join(j,"hub","sessions.mjs")),"sessionsModule");async function A(e){const{SessionError:t}=await R();try{return await e()}catch(n){throw n instanceof t&&i(n.message,n.reason==="live"?3:n.reason==="hub"?2:1),n}}p(A,"sessionCall");async function me(e){const{handshake:t}=await import(u.join(j,"hub","boards.mjs"));try{return await t(e,y())}catch(n){return i(n.message,2)}}p(me,"runHandshake");async function Je(e){for(let t=0;t<2;t++){let n;try{n=await fetch(`http://127.0.0.1:${T}/_hub/poll`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({flush:!1}),signal:AbortSignal.timeout(5*6e4)})}catch(l){return`not run (${l.message})`}if(!n.ok)return`not run (the hub answered ${n.status})`;const o=await n.json();if(o.checked?.includes(e))return"reached this board";if(o.failed?.length)return`missed this board: ${o.failed[0]}`}return"missed this board"}p(Je,"pollFor");async function O(e){const{withManifestLock:t}=await import(u.join(j,"hub","boards.mjs"));try{return await t(e)}catch(n){throw n.code==="ELOCKED"&&i(n.message),n}}p(O,"withLock");function we(e){return new Promise(t=>{const n=ie.connect({port:e,host:"127.0.0.1"}),o=p(l=>{n.destroy(),t(l)},"done");n.setTimeout(500,()=>o(!1)),n.on("connect",()=>o(!0)),n.on("error",()=>o(!1))})}p(we,"connects");function He(e){return new Promise(t=>{const n=ie.createServer();n.once("error",()=>t(!1)),n.listen(e,"0.0.0.0",()=>n.close(()=>t(!0)))})}p(He,"bindable");async function J(e){const t=new Set([...Object.values(e.sites),...Object.values(e.closed||{}).map(n=>n.site)].map(n=>n?.port));for(let n=G;n<G+400;n++)if(!t.has(n)&&!await we(n)&&await He(n))return n;i("no free port found from "+G)}p(J,"freePort");function qe(){const e=ue();if(!e)return"";try{return(JSON.parse(re(e,["status","--json"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]})).Self?.DNSName||"").replace(/\.$/,"")}catch{return""}}p(qe,"tailnetHost");const Z=p(e=>{const t=qe();return t?`https://${t}/${e}/`:`http://127.0.0.1:${T}/${e}/`},"siteUrl");async function H(){try{return await(await fetch(`http://127.0.0.1:${T}/_hub/status.json`,{signal:AbortSignal.timeout(1500)})).json()}catch{return null}}p(H,"hubStatus");const ge=p(e=>{try{return w.statSync(e).isDirectory()}catch{return!1}},"isFolder"),ze=p(e=>{try{return w.realpathSync(e)}catch{return null}},"realPath");function be(e=t=>{}){(typeof s.name!="string"||!s.name.trim())&&i('join needs --name "<name>": the board or page name, which gives its route',2);const t=s.name.trim().replace(/\s+/g," "),n=F(t);return C(n)||i(`--name "${t}" needs a letter or digit for its route`,2),{route:n,title:t===n&&e(n)?.title||t}}p(be,"named");function ye(e,{title:t,items:n,tickets:o}){w.mkdirSync(u.join(e,"data"),{recursive:!0});const l=u.join(e,"board.json"),c=w.existsSync(l)?JSON.parse(w.readFileSync(l,"utf8")):{};c.title=t,c.items=Re(n||c.items||"waves"),o&&(c.tickets=o),w.writeFileSync(l,JSON.stringify(c,null,2)+`
|
|
157
|
+
`);const r=c.items==="waves"?null:u.resolve(e,c.items);return r&&!w.existsSync(r)&&(w.mkdirSync(u.dirname(r),{recursive:!0}),w.writeFileSync(r,JSON.stringify({title:c.title,items:[]},null,2)+`
|
|
158
|
+
`)),[U(),u.join(j,"board","server.mjs"),e]}p(ye,"boardFiles");async function V(e,t){const{startSession:n,withSessionLock:o}=await R();return o(e,async()=>{const l=await A(()=>n(e,{manifest:y(),...t}));return await O(async()=>{const c=y(),r={session:l.session,label:l.name,since:new Date().toISOString(),repo:l.repo,...l.model?{model:l.model}:{}};g(c.sites,e)?(c.sites[e].owner=r,c.sites[e].updated=r.since):c.starting={...c.starting,[e]:{...g(c.starting,e),...r}},await v(c)}),l})}p(V,"startRecorded");async function q(e){const{hubSession:t}=await R(),n=await A(()=>t({manifest:y(),repo:e}));process.exitCode=n.status}p(q,"openHub");const ke=p((e,...t)=>{const n=K("git",["-C",e,...t],{encoding:"utf8"});return n.status===0?n.stdout.trim():null},"git"),ee=p(()=>!!(process.stdin.isTTY&&process.stdout.isTTY),"canAsk");async function te(e,t="stopped at the prompt; nothing changed"){const n=_e.createInterface({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()}catch(o){throw o.code==="ABORT_ERR"&&i(t),o}finally{n.close()}}p(te,"ask");const Se=p((e,t)=>!!(g(e.sites,t)||g(e.starting,t)||g(e.closed,t)),"taken");function Me(e){return!/^[A-Za-z0-9 ]+$/.test(e)||!C(F(e))?"A board name takes letters, digits and spaces, up to 41 characters of route.":Se(y(),F(e))?`/${F(e)} is taken; pick another name.`:null}p(Me,"nameProblem");const je="--template board --items data/wave.json";async function Ke(){const e=ke(process.cwd(),"rev-parse","--show-toplevel");e||i(`${process.cwd()} is not in a git repo; run kickflip join in the folder of the repo to add as a board`,2);const t=w.realpathSync(e);await H()||i("the hub is not running; run kickflip init to set it up, then kickflip join here again");const n=Object.entries(y().sites).find(([,f])=>P(f)&&f.owner?.repo&&ze(f.owner.repo)===t),o=await Ie(t);if(n)return Ue(...n,o);const l=u.basename(t).replace(/[^A-Za-z0-9]+/g," ").trim();let c=s.name?.trim();for(c===void 0&&!ee()&&i('join needs --name "<Board name>" when it has no terminal to ask in',2);;){c===void 0&&(c=await te(`Board name${l?` (${l})`:""}: `)||l);const f=Me(c);if(!f)break;s.name!==void 0&&i(f,2),h(f),c=void 0}const r=c.replace(/\s+/g," "),m=F(r),d=ke(t,"remote","get-url","origin"),a=d?Fe(d):null,{trustFolder:b}=await import("../hub/trust.mjs");try{b(t)}catch(f){i(`Couldn't trust this folder for Claude Code: ${f.message}`)}if(await O(async()=>{const f=y();Se(f,m)&&i(`/${m} is taken; pick another name`,2);const k=u.join(_,"sites",m),$=new Date().toISOString(),x={dir:k,port:await J(f),cmd:ye(k,{title:r,items:"data/wave.json"}),watch:["data/events.jsonl"],title:r,local:!0,...a?{github:a}:{},...o?{branch:o}:{},owner:{repo:t},created:$,updated:$};f.sites={...f.sites,[m]:x},X(f,m,x),await v(f)}),h(`Made ${r} at ${Z(m)}, working in ${t}${a?` (${a})`:""}.`),s.hub)return h("It is the hub board, so its session runs in tmux, attached here."),q(t);try{await V(m,{repo:t,prompt:je})}catch(f){throw f instanceof I&&i(`${f.message}
|
|
159
|
+
The board is made; run kickflip join here again to start its session.`,f.code),f}h("Its session is starting in the background, and joins the board shortly.")}p(Ke,"joinFolder");async function Ue(e,t,n){const o=t.title||e;h(`This folder already has a board: ${o} (/${e}).`),n&&n!==t.branch&&(await O(async()=>{const m=y();Object.assign(g(m.sites,e),{branch:n,updated:new Date().toISOString()}),await v(m)}),h(`Its branch is now ${n}${t.branch?` (it was ${t.branch})`:""}.`)),ee()||i(t.hub===!0?"Open its session with kickflip hub.":"Run kickflip join in a terminal to restart its session, or tap Restart on its row of the Hub page.");const l=(await te("Restart its session? (Y/n) ")).toLowerCase();if(l&&!"yes".startsWith(l))return;if(!t.owner.session)return t.hub===!0?q(t.owner.repo):(await V(e,{repo:t.owner.repo,prompt:je}),h("Its session is starting in the background."));const c=await fetch(`http://127.0.0.1:${T}/_hub/restart-board`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({route:e}),signal:AbortSignal.timeout(5*6e4)}),r=await c.json();if(c.ok||i(r.error),h(`Restarted ${o}'s session.`),t.hub===!0)return q(t.owner.repo)}p(Ue,"restartFolderBoard");const ne=["title","description","icon","color","created","watch","filter","hub","github","remote","branch","local"],$e=["notifications","quiet","codexShare"],E="kickflip-board",Ge=/^(\.watch-cursor-.*\.json|watcher\.json)$/,B=p((e,t)=>Object.fromEntries(t.filter(n=>e[n]!==void 0).map(n=>[n,e[n]])),"pick"),z=p(e=>/^[\w@%+=:,./-]+$/.test(e)?e:`'${String(e).replace(/'/g,"'\\''")}'`,"shellQuote");function ve(e){const t=K("tar",e[0]==="-czf"?["--no-xattrs",...e]:e,{encoding:"utf8",env:{...process.env,COPYFILE_DISABLE:"1"}});t.status!==0&&i(`tar ${e[0]} failed: ${(t.stderr||t.error?.message||"").trim()}`)}p(ve,"tar");function We(e,t){const n=e.entry.title||e.route,o=Object.keys(e.settings).map(l=>({notifications:"Notifications",quiet:"Quiet hours",codexShare:"Codex share"})[l]);return`# Moving ${n} (/${e.route}) to another machine
|
|
152
160
|
|
|
153
|
-
Exported from ${e.from} at ${e.exported_at}. This bundle holds the board's folder and manifest entry${
|
|
161
|
+
Exported from ${e.from} at ${e.exported_at}. This bundle holds the board's folder and manifest entry${o.length?`, and the hub's ${o.length>1?`${o.slice(0,-1).join(", ")} and ${o.at(-1)}`:o[0]} settings, which import writes over the new machine's`:""}.
|
|
154
162
|
|
|
155
163
|
## On the new machine
|
|
156
164
|
|
|
@@ -172,9 +180,9 @@ The bundle carries no secret and nothing tied to the old machine. Set these up o
|
|
|
172
180
|
- Other hub settings, such as the pause line and Rules for every board, stay on the old machine.
|
|
173
181
|
|
|
174
182
|
Manifest fields left out, which the new machine sets itself: ${e.dropped.length?e.dropped.join(", "):"none"}.
|
|
175
|
-
`}
|
|
176
|
-
`),w.writeFileSync(u.join(
|
|
183
|
+
`}p(We,"exportReadme");async function Ye(){Y();const e=s.port===void 0?void 0:Number(s.port);e!==void 0&&!(Number.isInteger(e)&&e>0&&e<65536)&&i("--port takes a port number",2),e===T&&i(`--port ${e} is the hub's own port`,2);let t;if(s.cmd!==void 0){try{t=JSON.parse(s.cmd)}catch{t=null}(!Array.isArray(t)||!t.length||!t.every(d=>typeof d=="string"))&&i(`--cmd takes a JSON array of strings, such as '["/abs/node","/abs/server.mjs"]'`,2)}const n=s.dir===void 0?void 0:u.resolve(s.dir);n!==void 0&&!t&&e===void 0&&!ge(n)&&i(`--dir ${n} is not a folder`,2);const{route:o,title:l}=be(d=>g(y().sites,d)),c=await O(async()=>{const d=y();g(d.closed,o)&&i("That board is closed; use kickflip reopen "+o,2),g(d.starting,o)&&i(`/${o} is a board that is starting; pick another route`,2);const a=g(d.sites,o);if(a?.owner?.session)throw h({error:"owned",route:o,owner:a.owner,hint:"a session owns this route: pick another route, or that session leaves it first"}),new I("",3);const b=new Date().toISOString(),f=a?{...a}:{created:b};delete f.watch,delete f.filter;{const k=t?{cmd:t,dir:n||a?.dir||process.cwd(),port:e??(a?.cmd?a.port:void 0)??await J(d)}:e!==void 0?{port:e,...n?{dir:n}:{}}:{dir:n};for(const $ of["cmd","dir","port","cwd","env"])delete f[$];Object.assign(f,k)}return f.title=l,s.description&&(f.description=s.description),Q(f),f.updated=b,d.sites={...d.sites,[o]:f},await v(d),f}),r=c.cmd?"cmd":c.port?"port":"files",m=await H();h({route:o,url:Z(o),serves:r,...c.port?{port:c.port}:{},...c.dir?{dir:c.dir}:{},...r==="port"?{answering:await we(c.port)}:{},hub:m?"running":"NOT running: run `kickflip doctor --fix`"})}p(Ye,"joinPage");const se={async doctor(){s["dry-run"]&&!s.fix&&i("--dry-run needs --fix",2);const e=ee()&&!s.json?n=>te(n,"stopped at the prompt; the clones not yet answered are kept"):void 0,{exitCode:t}=await De({fix:!!s.fix,dryRun:!!s["dry-run"],json:!!s.json,ask:e});process.exitCode=t},async join(){if(s._.length&&i(`join takes no route: --name "<name>" gives the title and the route, as in kickflip join --name ${z(s._[0])}`,2),s.title!==void 0&&i('join takes no --title: --name "<name>" gives the title and the route',2),!s.session){const r=["port","dir","cmd"].some(d=>s[d]!==void 0),m=["watch","template","filter","label","model","repo","force","items",...r?["hub"]:[]].find(d=>s[d]!==void 0);return m&&i(`--${m} needs --session <id> (this session's id)`,2),r?Ye():Ke()}const{route:e,title:t}=be(r=>g(y().sites,r));s.template&&s.template!=="board"&&i('--template takes "board"',2),Y(),fe();const n=await O(async()=>{const r=y();g(r.closed,e)&&i("That board is closed; use kickflip reopen "+e,2);const m=new Date().toISOString(),d=g(r.sites,e);if(d?.owner?.session&&d.owner.session!==s.session&&!s.force)throw h({error:"owned",route:e,owner:d.owner,hint:"ask the user, then rerun with --force to take it over"}),new I("",3);s.hub&&s.template!=="board"&&!P({dir:"",cmd:s.cmd?JSON.parse(s.cmd):d?.cmd})&&he(e);const a=d?{...d}:{};let b=!1;if(d||(a.dir=u.resolve(s.dir||u.join(_,"sites",e)),(!w.existsSync(a.dir)||w.readdirSync(a.dir).length===0)&&!s.cmd&&!s.template&&(w.cpSync(u.join(j,"starter"),a.dir,{recursive:!0}),b=!0),a.port=s.port?Number(s.port):await J(r),a.cmd=s.cmd?JSON.parse(s.cmd):[U(),u.join(a.dir,"server.mjs")],a.watch=["data/events.jsonl"],a.created=m),s.dir&&d&&(a.dir=u.resolve(s.dir)),s.port&&d&&(a.port=Number(s.port)),s.cmd&&d&&(a.cmd=JSON.parse(s.cmd)),s.template==="board"){const N=g(r.starting,e),Oe=!d&&N?.tickets&&(!N.session||N.session===s.session)?N.tickets:void 0;a.cmd=ye(a.dir,{title:t,items:s.items,tickets:Oe}),b=!d}a.title=t,s.description&&(a.description=s.description),typeof s.watch=="string"&&(a.watch=s.watch.split(",").map(N=>N.trim()).filter(Boolean)),s.filter!==void 0&&(a.filter=s.filter||void 0),Q(a),X(r,e,a);const f=d?.owner&&d.owner.session!==s.session?d.owner:null,k=g(r.starting,e)?.session===s.session?g(r.starting,e):null,$=g(r.starting,e);!d&&($?.github||$?.remote)&&(!$.session||$.session===s.session)&&($.github?a.github=$.github:a.remote=$.remote,a.branch=$.branch);const x=d?.owner?.session===s.session?d.owner:null,D=x||k||f;a.owner={...x||{session:s.session,since:m},label:s.label||D?.label||"",repo:s.repo?u.resolve(s.repo):(a.github||a.remote)&&D?.repo||ce()?.get(s.session)?.cwd||D?.repo||process.cwd()};const oe=s.model||D?.model;oe&&(a.owner.model=oe);const M=g(r.starting,e);return M&&(r.starting[e]={...M,joined_at:M.joined_at||m}),a.updated=m,r.sites={...r.sites,[e]:a},await v(r),{route:e,created:b,previousOwner:f,site:a}}),o=await H();let l,c;if(s.template==="board"){const r=pe(u.join(n.site.dir,"data","handshake.json"));l=r?.ack&&r.hello?.session===s.session?"answered before":await me(e),c=o?await Je(e):"not run (the hub is not running)"}h({route:e,url:Z(e),dir:n.site.dir,port:n.site.port,owner:n.site.owner,createdFromStarter:n.created,previousOwner:n.previousOwner,log:u.join(le,e+".log"),watcher:Ee(e,s.session,j),hub:o?"running":"NOT running: run `kickflip doctor --fix`",...l?{handshake:l}:{},...c?{poll:c}:{}})},async handshake(){const e=s._[0];e||i("handshake needs a route",2),h(await me(e))},async leave(){const e=s._[0];e||i("leave needs a route",2),await O(async()=>{const t=y(),n=g(t.sites,e);if(n||i("no site at /"+e),n.owner?.session&&!s.session&&!s.force&&i("a session owns /"+e+"; leave needs --session <id>, or --force",2),n.owner?.session&&n.owner.session!==s.session&&!s.force)throw h({error:"owned",route:e,owner:n.owner}),new I("",3);delete t.sites[e],await v(t),h({left:e,filesKept:n.dir})})},async start(){const e=s._[0];C(e)||i("start needs a route: lowercase letters, digits and dashes",2);const t=await V(e,{repo:s.repo,model:s.model,prompt:s.prompt});h({route:t.route,session:t.session,confirmed:t.confirmed,repo:t.repo,argv:t.argv,output:t.output})},async resume(){const e=s._[0];e||i("resume needs a route",2);const{resumeSession:t}=await R();h(await A(()=>t(e,{manifest:y()})))},async close(){const{closeBoard:e}=await import("../hub/close-board.mjs");try{h(await e(s._[0],s.name))}catch(t){i(t.message,t.status?2:1)}},async reopen(){const{reopenBoard:e}=await import("../hub/close-board.mjs");try{h(await A(()=>e(s._[0])))}catch(t){throw t.status&&i(t.message,2),t}},async export(){const e=s._[0];C(e)||i("export needs a route: lowercase letters, digits and dashes",2);const t=u.resolve(s.out||`kickflip-${e}.tgz`);w.existsSync(t)&&i(`${t} already exists; pass another --out`,2);const n=g(y().sites,e)||i("no site at /"+e);P(n)||i(`/${e} is not a board; export moves a board`,2);const o=w.realpathSync(n.dir),{itemSources:l,openBoardBuilders:c}=await import("../board/store.mjs"),r=(await l(o)).find(k=>u.relative(o,k.file).startsWith(".."));r&&i(`/${e}'s cards live outside its folder (${r.file}); export moves only a board whose board.json items is a file in its folder`);const m=await c(o);m.length&&i(`a builder is open on /${e}: ${m.map(k=>`${k.key} (${k.label})`).join(", ")}; export once it is done`);const{readSettingsFile:d}=await import("../hub/push.mjs"),a=B(n,ne),b={kickflip_export:1,route:e,exported_at:new Date().toISOString(),from:L.hostname(),entry:a,owner:B(n.owner||{},["label","model"]),settings:B(d(),$e),dropped:Object.keys(n).filter(k=>!ne.includes(k))},f=w.mkdtempSync(u.join(L.tmpdir(),"kickflip-export-"));try{const k=u.join(f,E),$=u.join(o,"data");w.cpSync(o,u.join(k,"site"),{recursive:!0,filter:p(x=>!(u.dirname(x)===$&&Ge.test(u.basename(x))),"filter")}),w.writeFileSync(u.join(k,"export.json"),JSON.stringify(b,null,2)+`
|
|
184
|
+
`),w.writeFileSync(u.join(k,"README.md"),We(b,u.basename(t))),ve(["-czf",t,"-C",f,E])}finally{w.rmSync(f,{recursive:!0,force:!0})}h({route:e,file:t,entry:Object.keys(a),dropped:b.dropped,settings:Object.keys(b.settings)})},async import(){s._[0]||i("import needs the file kickflip export wrote",2);const e=u.resolve(s._[0]);w.existsSync(e)||i(`no file at ${e}`,2),w.mkdirSync(_,{recursive:!0});const t=w.mkdtempSync(u.join(_,".import-"));try{ve(["-xzf",e,"-C",t]);const n=pe(u.join(t,E,"export.json"));(n?.kickflip_export!==1||!C(n.route)||!ge(u.join(t,E,"site")))&&i(`${e} is not a kickflip export`,2);const{route:o}=n,l=u.join(_,"sites",o),c=await O(async()=>{const a=y();(g(a.sites,o)||g(a.closed,o)||g(a.starting,o))&&i(`/${o} already exists on this host; import never replaces a board`),w.existsSync(l)&&i(`${l} already exists; import never replaces a board's folder`);const b=B(n.entry||{},ne);b.hub&&Object.values(a.sites).some(k=>k?.hub)&&delete b.hub;const f={...b,dir:l,port:await J(a),cmd:[U(),u.join(j,"board","server.mjs"),l],updated:new Date().toISOString()};return w.mkdirSync(u.dirname(l),{recursive:!0}),w.renameSync(u.join(t,E,"site"),l),a.sites={...a.sites,[o]:f},await v(a),f}),r=B(n.settings||{},$e);if(Object.keys(r).length){const{readSettingsFile:a,writeSettingsFile:b}=await import("../hub/push.mjs");b({...a(),...r})}const{label:m,model:d}=n.owner||{};h({route:o,dir:l,port:c.port,settings:Object.keys(r),hub:c.hub===!0,join:`kickflip join --name ${z(Te(o,c.title))} --session <this session's id> --watch --template board${m?` --label ${z(m)}`:""}${d?` --model ${z(d)}`:""} --force`})}finally{w.rmSync(t,{recursive:!0,force:!0})}},async sessions(){const{sessionOf:e}=await R(),{listBoards:t}=await import(u.join(j,"hub","boards.mjs")),n=y(),o=ce(),c=[...t(n).map(r=>r.route),...Object.keys(n.starting||{}).filter(r=>!g(n.sites,r))].map(r=>{const m=e(n,r),d=m&&o?.get(m.session),a=m?o?d?d.kind==="bg"?"background":"terminal":null:"unknown":null;return{route:r,session:m?.session||null,live:a,repo:m?.repo||null,starting:!g(n.sites,r)}});if(s.json)return h(c);if(!c.length)return h("no boards");for(const r of c)h(`/${r.route} ${r.session||"no session"} ${r.live==="unknown"?"live unknown (ps gave no answer)":r.live?`live (${r.live})`:"not live"} ${r.repo||"no folder"}${r.starting?" (starting: not joined yet)":""}`)},async hub(){await q(s.repo)},async set(){const e=s._[0];e||i("set needs a route",2),s.icon===void 0&&s.color===void 0&&!s.hub&&!s["no-hub"]&&i("set needs --icon, --color, --hub or --no-hub",2),Y(),fe(),await O(async()=>{const t=y(),n=g(t.sites,e)||i("no site at /"+e);Q(n),X(t,e,n),n.updated=new Date().toISOString(),await v(t),h({route:e,icon:n.icon??null,color:n.color??null,hub:n.hub===!0})})},async restart(){const e=s._[0];await O(async()=>{const t=y();g(t.sites,e)||i("no site at /"+e),t.sites[e].restart_at=Date.now(),await v(t)}),h(`restarting /${e}; the hub picks it up within 2 seconds`)},async url(){const e=s._[0];e&&!g(y().sites,e)&&i("no site at /"+e,2);try{h(Be(e))}catch(t){i(t.message)}},async logs(){const e=s._[0],t=u.join(le,e+".log");w.existsSync(t)||i("no log yet for /"+e);const n=Number(s.lines||40);h(w.readFileSync(t,"utf8").split(`
|
|
177
185
|
`).slice(-n-1).join(`
|
|
178
|
-
`))},async init(){s.fix=!0,await
|
|
179
|
-
`).slice(1);
|
|
180
|
-
`)),process.exit(
|
|
186
|
+
`))},async init(){s.fix=!0,await se.doctor()},async update(){w.existsSync(u.join(j,".git"))&&i(`${j} is a clone; update it with git pull`,2);const e=K("npm",["i","-g","@lovek4d/kickflip@latest"],{stdio:"inherit"});e.status!==0&&i(`npm update failed${e.error?": "+e.error.message:""}`);const t=de(),n=t.restart();n&&i(`update finished but the hub did not restart: ${n}; run ${t.restartCommand}`),h("updated kickflip and restarted the hub")},async uninstall(){Ce()&&h(`removed ${u.join(L.homedir(),".claude","statusline.sh")}`);const e=de();e.remove();const t=ue();if(t)try{re(t,["serve","--https=443","--set-path=/","off"],{stdio:"ignore"})}catch{}h(`hub stopped and removed from ${e.manager??"the host"}${t?"; tailscale / unmapped":""}. The manifest and sites are kept in ${_}`)},async push(){const{deliver:e,pushKindError:t}=await import(u.join(j,"hub","push.mjs")),n=t(s.kind);n&&i(n,2),s.title||i("push needs --title",2),s.url&&!s.url.startsWith("/")&&i("--url is a path on the hub, such as /<route>/page.html",2);const{sendWords:o,holdLine:l}=await import(u.join(j,"hub","schedule.mjs"));s.now&&s.urgent&&i("pass --now or --urgent, not both",2);const c=await e({title:s.title,body:s.body||"",url:s.url||"/",tag:s.tag},{kind:s.kind,urgent:!!s.urgent,immediate:!!s.now});if(c.noDevice&&i("no device has turned on notifications; open Hub \u2192 Notifications (/_hub/#notifications) in the Home Screen app and tap Turn on",3),c.dropped)return h("dropped (notifications are off on the Hub page)");if(c.queued){const{count:r,replaced:m,nextFlushAt:d,hold:a,sendFailed:b}=c.queued,f=s.now?a?`${l(a)}; `:b?"no device took it now; ":"":"";h(`queued (${f}${r} in queue${m?"; replaced the queued push with this tag":""}); next send ${o(d)}${d instanceof Date?` (${d.toISOString()})`:""}`),await H()||h("warning: the hub is not running, so the queue goes out only once it runs");return}h(c.sent),c.sent.some(r=>r.status>=200&&r.status<300)||i("every push was refused",1),h(s.urgent?"sent (urgent)":"sent")},async quiet(){const{readSettings:e}=await import(u.join(j,"hub","push.mjs")),{hold:t}=await import(u.join(j,"hub","schedule.mjs")),n=e(),o=t(new Date,n);h({quiet:n.quiet,held:o!==null,held_until:o?o.until instanceof Date?o.until.toISOString():o.until:null,held_why:o?.why??null,notifications:n.notifications})},async notifications(){const{setNotifications:e,readSettings:t}=await import(u.join(j,"hub","push.mjs")),[n,o]=s._,c=n===void 0?null:n==="on"||n==="off"?{on:n==="on"}:n==="weekends"?{weekends_off:p((m,d)=>m==="on"?!0:m==="off"?!1:i(`${d} takes on or off`,2),"onOff")(o,"weekends")}:n==="snooze"?{snooze:o||i("snooze takes a length: <n>m, <n>h, <n>d, <n>w, tonight, morning, monday, forever or a date and time",2)}:n==="unsnooze"?{snooze:"off"}:i("notifications takes on, off, snooze <length>, unsnooze, or weekends on|off",2);if(!c)return h(t().notifications);let r;try{r=await e(c)}catch(m){throw m.status===400&&i(m.message,2),m}h(r.dropped?{...r.notifications,dropped:r.dropped}:r.notifications)},async"codex-share"(){(S.length>1||S.length&&s._.length!==1)&&i("codex-share takes auto, always, or off",2);const{readCodexShare:t,setCodexShare:n}=await import(u.join(j,"hub","push.mjs"));if(!S.length)return h(t());try{h(n(S[0]))}catch(o){throw o.status===400&&i(o.message,2),o.status===409&&i(o.message),o}},async"usage-gate"(){const{readUsageGate:e,setPauseAt:t,setKeepGoing:n}=await import("../shared/usage-gate.mjs");try{S.length&&(S[0]==="pause-at"&&S.length===2?t(S[1]):S[0]==="keep-going"&&S.length===1?n("on"):S[0]==="stop"&&S.length===1?n("off"):i("usage-gate takes pause-at <50..100>, keep-going, or stop",2)),h(e())}catch(o){throw o.status&&i(o.message,o.status===400?2:1),o}},async"poll-now"(){let e;try{e=await fetch(`http://127.0.0.1:${T}/_hub/poll`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({flush:!s["keep-queue"]}),signal:AbortSignal.timeout(10*6e4)})}catch(t){i("the hub is not running: "+t.message)}e.ok||i(`the hub answered ${e.status}: ${(await e.text()).slice(0,200)}`),h(await e.json())}};if(!se[W]){const e=w.readFileSync(Ne(import.meta.url),"utf8").split(`
|
|
187
|
+
`).slice(1);h(e.slice(0,e.findIndex(t=>!t.startsWith("//"))).map(t=>t.replace(/^\/\/ ?/,"")).join(`
|
|
188
|
+
`)),process.exit(W?2:0)}try{await se[W]()}catch(e){if(!(e instanceof I))throw e;e.message&&console.error("kickflip: "+e.message),process.exit(e.code)}
|
package/bin/wait-events.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`).filter(Boolean)}catch{}
|
|
2
|
+
var q=Object.defineProperty;var s=(e,o)=>q(e,"name",{value:o,configurable:!0});import c from"node:fs";import f from"node:path";import L from"node:os";import{routeRecord as m}from"../hub/routes.mjs";import{readHubRules as P,rulesOf as D,ruleLines as G}from"../hub/rules.mjs";import{boardAt as H,linksOf as U,hubLink as W,stopPreviousWatcher as _}from"../hub/boards.mjs";import{parentOf as J,sessionGone as K}from"../hub/live.mjs";import{ackHello as Q,cardName as B,markWorking as C,settingsLines as M,settingsOf as z,WORKING_KINDS as V}from"../board/store.mjs";import{readUsageGate as E,heldUsageEvent as X}from"../shared/usage-gate.mjs";const[O,g]=process.argv.slice(2);(!O||!g)&&(console.error("usage: wait-events.mjs <route> <session-id>"),process.exit(2));const Y=f.join(L.homedir(),".claude","kickflip","manifest.json");function A(){try{return m(JSON.parse(c.readFileSync(Y,"utf8")).sites,O)||null}catch{return}}s(A,"site");function v(e){const o=e.filter?new RegExp(e.filter):null,t=Object.create(null);for(const l of e.watch||["data/events.jsonl"]){let r=[];try{r=c.readFileSync(f.resolve(e.dir,l),"utf8").split(`
|
|
3
|
+
`).filter(Boolean)}catch{}t[l]=o?r.filter(i=>o.test(i)):r}return t}s(v,"matching");const Z=`quiet The owner doesn't read this session's terminal. Answer a prompt typed in it in full. A wake, a task notification or a builder's result is not one: write no text of your own, since board.mjs and this watcher print one line for each thing done. Talk and questions go on the board, never AskUserQuestion; only a failure the board can't show, such as the hub being down, gets one line here. Each message to the owner stands alone in its card's thread: name cards by label (#96), and a pointer such as "above" or "here" must make sense in that thread, never point into this session.`,I={ask:s(e=>`new task ${e.id} received`,"ask"),"owner-answer":s(e=>`answer received to question ${e.data?.id}`,"owner-answer"),hello:s(e=>`hello ${e.id} from the hub answered`,"hello"),"overnight-triage":s(e=>`Overnight triage ${e.data?.date} asked: ${e.data?.cards?.length} cards wait on your answers`,"overnight-triage"),"pr-review":s(e=>`review asked on PR #${e.data?.pr}: the board was idle`,"pr-review"),"orchestrator-waits":s(e=>`waiting on you now: ${(e.data?.added||[]).join(", ")}`,"orchestrator-waits"),"review-answer":s(e=>`${e.data?.answer==="skip"?"skip":"post"} answered on the review of PR #${e.data?.pr}`,"review-answer")},R={"item-message":s(e=>`message received from ${e}'s thread`,"item-message"),"card-merge":s(e=>`merge asked on ${e}`,"card-merge"),"card-done":s(e=>`${e} marked done`,"card-done"),"card-bump":s(e=>`${e} bumped`,"card-bump"),"ask-bump":s(e=>`${e} bumped`,"ask-bump"),"ask-edited":s(e=>`${e} edited`,"ask-edited"),"ask-done":s(e=>`${e} marked done`,"ask-done"),"ask-withdrawn":s(e=>`${e} deleted`,"ask-withdrawn"),"card-hold":s((e,o)=>`${e} ${o.data?.hold?"held":"resumed"}`,"card-hold"),"card-unblocked":s(e=>`${e} unblocked`,"card-unblocked"),"prototype-request":s(e=>`prototype asked on ${e}`,"prototype-request"),"reask-request":s(e=>`question asked again on ${e}`,"reask-request"),"builder-ask":s((e,o)=>`${o.data?.ask} from ${e}'s builder: ${o.data?.text}`,"builder-ask"),"owner-check-broken":s((e,o)=>`${e}'s owner-step check can't run: ${o.data?.error}`,"owner-check-broken")};async function ee(e,o){let t;try{t=JSON.parse(o)}catch{return null}if(typeof t?.kind!="string")return null;const l=typeof t.data?.key=="string"?t.data.key:t.kind.startsWith("ask-")&&typeof t.data?.id=="string"?`ask:${t.data.id}`:null,r=l&&await B(e,l).catch(()=>l);return m(I,t.kind)?I[t.kind](t):r&&m(R,t.kind)?R[t.kind](r,t):r?`${t.kind} on ${r}`:`${t.kind} received`}s(ee,"plainLine");function te(e){let o=[];try{o=JSON.parse(c.readFileSync(f.resolve(e,"data","orchestrator-waits.json"),"utf8")).waits||[]}catch{}return o.map(t=>`waits ${t.kind} ${t.ref} ${t.key} since ${t.since}${t.picked?`, picked up ${t.picked}`:""}: ${t.next}`)}s(te,"waitLines");const k=A();k||(console.log("site-removed"),process.exit(0));const w=f.resolve(k.dir,"data",`.watch-cursor-${g}.json`),S=f.resolve(k.dir,"data","watcher.json"),j=[process.ppid,J(process.ppid)],T=s(()=>{j[1]??=J(j[0]),K(g,j)&&process.exit(0)},"orphaned");_(k.dir,O,g);try{c.mkdirSync(f.dirname(w),{recursive:!0}),c.writeFileSync(S,JSON.stringify({pid:process.pid,since:new Date().toISOString()}))}catch{}process.on("exit",()=>{try{const e=JSON.parse(c.readFileSync(S,"utf8"));e.pid===process.pid&&c.writeFileSync(S,JSON.stringify({...e,exited_at:new Date().toISOString()}))}catch{}});let p;try{p=JSON.parse(c.readFileSync(w,"utf8"))}catch{}for(p||(p=Object.fromEntries(Object.entries(v(k)).map(([e,o])=>[e,o.length])),c.mkdirSync(f.dirname(w),{recursive:!0}),c.writeFileSync(w,JSON.stringify(p)));;){await new Promise(r=>setTimeout(r,2e3));const e=A();if(e===void 0)continue;e===null&&(console.log("site-removed"),process.exit(0)),e.owner?.session&&e.owner.session!==g&&(console.log("handed-over "+JSON.stringify(e.owner)),process.exit(0)),T();const o=s(r=>Object.fromEntries(Object.entries(r).map(([i,$])=>[i,[...m(p.$usageHeld,i)||[],...$.slice(m(p,i)||0)]])),"pending"),t=s((r,i)=>i.state!=="paused"||!X(r),"eligible"),l=E();if(Object.values(o(v(e))).some(r=>r.some(i=>t(i,l)))){await new Promise(n=>setTimeout(n,2e3)),T();const r=v(e),i=E(),$=o(r);if(!Object.values($).some(n=>n.some(a=>t(a,i))))continue;const b=Object.create(null),N=[],x=[];for(const[n,a]of Object.entries($)){b[n]=a.filter(h=>!t(h,i));for(const h of a.filter(y=>t(y,i))){console.log(`event ${n} ${h}`);const y=await ee(e.dir,h);y&&console.log(y);try{const u=JSON.parse(h);V.includes(u.kind)&&typeof u.id=="string"&&N.push(u.id),u.kind==="hello"&&typeof u.id=="string"&&x.push(u.id)}catch{}}}let d=null;try{d=JSON.parse(c.readFileSync(f.resolve(e.dir,"board.json"),"utf8"))}catch(n){n.code!=="ENOENT"&&(d={})}if(d&&await C(e.dir,N).catch(n=>console.log(`working marks not written (${n.message})`)),d)for(const n of x)await Q(e.dir,n).catch(a=>console.log(`hello ${n} not answered (${a.message})`));if(d)for(const n of te(e.dir))console.log(n);if(d)for(const n of G(P(),D(d)))console.log(`rule ${n}`);if(d)for(const n of M(z(d)))console.log(n);d&&console.log(Z),i.state==="paused"&&console.log(`usage paused ${i.resets_at} ${i.window} ${i.used}%`);try{const n=d&&H(e.dir);if(n)for(const a of[...U(n,{listen:"listening"}),W()])a.ok||console.log(`link ${a.link} ${a.detail}`)}catch(n){console.log(`link registry could not check the links (${n.message})`)}const F=Object.fromEntries(Object.entries(r).map(([n,a])=>[n,a.length]));Object.values(b).some(n=>n.length)&&(F.$usageHeld=b),c.writeFileSync(w,JSON.stringify(F)),process.exit(0)}}
|
package/board/arch-review.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var I=Object.defineProperty;var r=(e,n)=>I(e,"name",{value:n,configurable:!0});import v from"node:fs/promises";import L from"node:os";import g from"node:path";import{boardRepo as q}from"../hub/board-repo.mjs";import{samePath as J}from"../hub/boards.mjs";import{cloneRoot as P}from"../shared/repos.mjs";import{readUsageGate as T,pauseReason as U}from"../shared/usage-gate.mjs";import{reviewWaits as W}from"../shared/skills.mjs";import{BoardError as O,addItem as x,appendThread as _,boardConfig as K,cardName as N,changeLineup as Q,createLineup as G,itemSources as F,parseKey as H,readJSON as A,resolveQuestion as E,setItem as M,startBuilder as X,topicQuestions as B,wavesDir as R}from"./store.mjs";const $=r(e=>g.join(e,"data","arch-reviews.json"),"recordsFile"),C=r(async e=>(await A($(e),{reviews:[]})).reviews||[],"readReviews"),z={paths:["hub/","board/","shared/","CONTEXT.md","docs/adr/"],data:["~/.claude/kickflip/manifest.json","~/.claude/kickflip/sites/*/data/wave.json","~/.claude/kickflip/sites/*/data/owner.json","~/.claude/kickflip/sites/*/data/events.jsonl"]},V=r(({github:e,repo:n})=>(e?e.split("/").pop():g.basename(n||""))||"this repo","repoName");function pe(e,n,s,{repo:d,waits:h}){const p=new Map(n.map(a=>[a.key,a])),o=r(a=>{const u=p.get(a.key);if(!u)return null;const t=r(i=>i.key!==a.key&&(a.lineup?i.lineup?.slug===a.wave:i.wave===a.wave),"inWave"),c=u.lane!=="done";return{key:a.key,ref:u.ref,wave:a.title,at:a.at,open:c,running:c&&!u.questions,findings:s.filter(i=>i.topic===`item:${a.key}`&&!i.round_of&&!i.confirm_of).length,built:n.filter(i=>t(i)&&i.lane==="done"&&i.status!=="dropped").length}},"view");return{repo:d,waits:h,last:[...e].reverse().map(o).find(Boolean)||null}}r(pe,"archOf");const Y=r(e=>e.toLocaleDateString("en-CA").replaceAll("-",""),"stampOf"),Z=r(e=>e.toLocaleDateString("en-US",{month:"short",day:"numeric"}),"dayOf");async function D(e,n){let s=e;for(let d=2;await n(s);d++)s=`${e}-${d}`;return s}r(D,"freeSlug");const ee=r(e=>{throw new O(e)},"fail"),te=r(e=>v.stat(e).then(()=>!0,()=>!1),"exists");async function fe(e,n,{now:s=new Date,home:d=L.homedir()}={}){const h=W(d);if(h)throw Object.assign(new O(h),{status:409});const p=T({home:d});if(p.state==="paused")throw Object.assign(new O(U(p)),{status:409});const o=q(n.route),a=V(o),u=`Architecture ${Z(s)}`,t=`arch-${Y(s)}`,c=await F(e),i=(await K(e)).items==="waves";let f,w=null,l;if(i){f=await D(t,S=>te(g.join(R(),S)));const y=g.join(R(),f,"wave.json");await v.mkdir(g.dirname(y),{recursive:!0}),await v.writeFile(y,JSON.stringify({title:u,...o.github?{repo:o.github}:{},items:[]},null,2)+`
|
|
2
|
-
`),l=(await x(e,`${f}/audit`,{title:`Architecture review of ${a}`})).key}else{const[y]=c,S=(await Promise.all(c.map(async b=>(await A(b.file,{}))?.lineups||[]))).flat();w=await D(t,b=>c.some(j=>j.slug===b)||S.some(j=>j.slug===b)),f=y.slug,l=(await x(e,f,{title:`Architecture review of ${a}`})).key}w&&await G(e,w,{title:u,goal:`Act on the architecture review of ${a}`,
|
|
2
|
+
`),l=(await x(e,`${f}/audit`,{title:`Architecture review of ${a}`})).key}else{const[y]=c,S=(await Promise.all(c.map(async b=>(await A(b.file,{}))?.lineups||[]))).flat();w=await D(t,b=>c.some(j=>j.slug===b)||S.some(j=>j.slug===b)),f=y.slug,l=(await x(e,f,{title:`Architecture review of ${a}`})).key}w&&await G(e,w,{title:u,goal:`Act on the architecture review of ${a}`,phases:[l],note:`${await N(e,l)} is the audit of ${a}: its Notes are the report, and it asks one question per finding. Each finding you don't skip becomes a card after it, built from the option you pick.`}),await X(e,l,{label:"Architecture review"}),await _(e,l,{text:`Started an architecture review of ${a}. Its report becomes this card's Notes, with one question per finding.`});const k=await C(e);k.push({key:l,wave:w||f,lineup:!!w,title:u,repo:o.repo,at:s.toISOString()}),await v.mkdir(g.dirname($(e)),{recursive:!0}),await v.writeFile($(e)+".tmp",JSON.stringify({reviews:k},null,2)+`
|
|
3
3
|
`),await v.rename($(e)+".tmp",$(e));const m={key:l,repo:o.repo,github:o.github||null,branch:o.branch||null,wave:w||f,lineup:!!w,...o.repo&&J(o.repo,P())?{scope:z}:{}};return{key:l,data:m}}r(fe,"startReview");async function we(e,n){const s=(await C(e)).find(t=>t.key===n)||ee(`${n} is not an architecture review's audit card`),{wave:d}=H(n),{asked:h}=await B(e,`item:${n}`),p=[];for(const t of h.filter(c=>c.state==="answered")){const c=t.answers.at(-1),i=t.options.find(m=>m.id===c.choice);if(!i)continue;if(i.id==="skip"||i.label==="Skip"){await E(e,t.id,"Skipped."),p.push(`skipped: ${t.id}`);continue}const f=[i.detail,...(i.practice||[]).map(m=>`- ${m}`),c.note.trim()&&`Owner's note: ${c.note.trim()}`,`From the finding: ${t.question}`].filter(Boolean).join(`
|
|
4
4
|
|
|
5
5
|
`),w=(await A((await F(e)).find(m=>m.slug===d).file,{items:[]})).items.at(-1)?.id,l=await x(e,d,{title:i.label,notes:f,...s.lineup?{}:{deps:w}});s.lineup&&await Q(e,s.wave,{add:l.key});const k=await N(e,l.key);await E(e,t.id,`Filed as ${k}.`),p.push(`filed: ${k} from ${t.id}`,...l.lines||[])}const o=(await B(e,`item:${n}`)).asked.filter(t=>t.state!=="resolved");if(o.length)return{lines:[...p,`waiting: ${o.map(t=>t.id).join(", ")}`]};const a=(await B(e,`item:${n}`)).asked.filter(t=>/^Filed as /.test(t.resolved||"")).map(t=>t.resolved.slice(9,-1)),u=await M(e,n,{status:"done",text:a.length?`Every finding is settled: filed ${a.join(", ")}.`:"Every finding is settled: none filed."});return{lines:[...p,...u.lines,`closed: ${await N(e,n)}`]}}r(we,"fileFindings");export{z as HUB_SCOPE,pe as archOf,we as fileFindings,C as readReviews,V as repoName,fe as startReview};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var k=Object.defineProperty;var s=(n,r)=>k(n,"name",{value:r,configurable:!0});const B=864e5,g={needs:0,reviewing:1,posted:2},f=s((n,r,u)=>n.filter(a=>a.kind===r&&a.data?.pr===u).sort((a,m)=>String(a.ts).localeCompare(String(m.ts))).at(-1),"newest");function D({on:n,incoming:r,records:u={},events:a=[],refs:m=new Map,now:S=Date.now()}){const h=new Map((r?.prs||[]).map(e=>[e.number,e])),d=s((e,t,i,l)=>({number:e.number,title:e.title,author:e.author,url:e.url,asked:!!e.asked,touches:(e.touches||[]).map(p=>({key:p,ref:m.get(p)||p})),state:i,at:l,text:t?.text||null,reviewUrl:t?.review_url||null}),"card"),o=[],w=[];for(const e of h.values()){const t=u[e.number],i=f(a,"pr-review",e.number),l=t?.state==="needs"&&f(a,"review-answer",e.number);l&&String(l.ts)>String(t.at)?o.push(d(e,t,"reviewing",l.ts)):i&&i.data.head===e.head&&!(t?.head===e.head&&String(t.at)>String(i.ts))?o.push(d(e,t,"reviewing",i.ts)):(t&&o.push(d(e,t,t.state,t.at)),(!t||t.state==="posted"&&t.head!==e.head)&&w.push(e))}const v=s(e=>e.state==="posted"&&S-Date.parse(e.at)>864e5,"old"),$=[...o.filter(v).map(e=>({...e,open:!0})),...Object.values(u).filter(e=>!h.has(e.number)).map(e=>({...d(e,e,e.state,e.at),open:!1}))].sort((e,t)=>String(t.at).localeCompare(String(e.at))),b=o.filter(e=>!v(e)).sort((e,t)=>g[e.state]-g[t.state]||String(t.at).localeCompare(String(e.at)));w.sort((e,t)=>+!!t.asked-+!!e.asked||e.number-t.number);const x=o.some(e=>e.state==="reviewing");return{on:!!n,shown:!!n||b.length>0,at:r?.at||null,repo:r?.repo||null,cards:b,earlier:$,waiting:w.length,due:n&&!x&&w[0]||null}}s(D,"reviewsOf");const c=s(n=>n.cards.filter(r=>r.state==="needs"),"held"),A=s(n=>c(n).map(r=>({kind:"Review",title:`PR #${r.number} ${r.title}`,text:`PR #${r.number} ${r.title} \xB7 review held for you`,url:`#review=${r.number}`,review:r.number})),"reviewNeeds"),C=s(n=>c(n).map(r=>({tag:`review-${r.number}`,kind:"review",title:`PR #${r.number}: review held for you`,body:String(r.text||r.title).split(`
|
|
2
|
+
`)[0],url:`#review=${r.number}`,now:!0,questions:[]})),"reviewActions");export{C as reviewActions,A as reviewNeeds,D as reviewsOf};
|