@lovek4d/kickflip 0.1.0 → 0.3.1
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 +177 -78
- package/README.md +46 -5
- package/SKILL.md +58 -37
- package/bin/doctor.mjs +4 -3
- package/bin/install.mjs +3 -3
- package/bin/kickflip.mjs +87 -32
- package/bin/statusline.mjs +4 -3
- package/bin/wait-events.mjs +2 -2
- package/board/arch-review.mjs +5 -0
- package/board/bin/agent.mjs +1 -1
- package/board/bin/board.mjs +241 -69
- package/board/bin/builder-stop-hook.mjs +4 -3
- package/board/domain.mjs +5 -3
- package/board/on-host.mjs +1 -0
- package/board/public/app-arch.js +75 -0
- package/board/public/app-asks.js +33 -14
- package/board/public/app-cards.js +242 -49
- package/board/public/app-core.js +39 -5
- package/board/public/app-header.js +24 -6
- package/board/public/app-lanes.js +76 -26
- package/board/public/app-needs.js +1 -0
- package/board/public/app-snapshot.js +45 -11
- package/board/public/app-threads.js +13 -11
- package/board/public/app.html +4 -1
- package/board/public/app.js +131 -20
- package/board/public/dialogs.js +114 -116
- package/board/public/hub-kit.js +19 -2
- package/board/public/hub.css +24 -18
- package/board/public/linear-key.js +141 -0
- package/board/public/router.js +6 -3
- package/board/public/rules-editor.js +1 -1
- package/board/public/shell.js +1 -1
- package/board/public/sidebar.css +31 -11
- package/board/public/sidebar.js +88 -16
- package/board/public/style.css +141 -46
- package/board/public/toasts.js +6 -4
- package/board/public/ui-cards.js +102 -37
- package/board/public/ui-header.js +17 -8
- package/board/public/ui-hub.js +30 -12
- package/board/public/ui-links.js +18 -10
- package/board/public/ui-order.js +18 -0
- package/board/public/ui-page-header.js +4 -2
- package/board/public/ui-questions.js +37 -16
- package/board/public/ui-sidebar.js +49 -11
- package/board/public/ui-snapshot.js +15 -9
- package/board/public/ui-threads.js +25 -16
- package/board/public/ui.js +23 -11
- package/board/public/view-hub-settings.js +46 -30
- package/board/public/view-hub.js +64 -13
- package/board/public/view-notes.js +7 -4
- package/board/public/view-polling.js +3 -3
- package/board/public/view-questions.js +42 -22
- package/board/public/view-settings.js +90 -35
- package/board/review.mjs +1 -0
- package/board/server.mjs +12 -7
- package/board/store.mjs +14 -6
- package/board/tickets.mjs +3 -3
- package/board/worktree.mjs +14 -13
- package/docs/hub-session.md +3 -3
- package/hooks-plugin/hooks/codex-share-auto.mjs +7 -5
- package/hooks-plugin/hooks/watcher-stop.mjs +41 -0
- package/hub/awake.mjs +1 -0
- package/hub/board-repo.mjs +1 -1
- package/hub/boards.mjs +4 -4
- package/hub/close-board.mjs +1 -1
- package/hub/duration.mjs +1 -0
- package/hub/github.mjs +4 -5
- package/hub/home.mjs +1 -1
- package/hub/hub.mjs +12 -10
- package/hub/linear.mjs +2 -2
- package/hub/new-board.mjs +2 -2
- package/hub/pr-report.mjs +1 -0
- package/hub/push.mjs +2 -2
- package/hub/readiness.mjs +2 -0
- package/hub/repos.mjs +3 -2
- package/hub/restart-board.mjs +1 -0
- package/hub/routes.mjs +1 -1
- package/hub/schedule.mjs +1 -1
- package/hub/sessions.mjs +2 -2
- package/hub/shell.mjs +2 -1
- package/hub/slack.mjs +2 -0
- package/hub/stream.mjs +12 -12
- package/hub/sw.js +1 -1
- package/hub/trust.mjs +2 -0
- package/hub/try.mjs +4 -3
- package/hub/upgrade.mjs +1 -0
- package/hub/usage.mjs +3 -3
- package/hub/views.mjs +1 -1
- package/package.json +1 -1
- package/shared/colors.css +7 -5
- package/shared/fake-gh.mjs +54 -0
- package/shared/service.mjs +16 -16
- package/shared/skills.mjs +2 -0
- package/shared/usage-gate.mjs +1 -1
- package/starter/public/claude.js +3 -2
- package/bin/web-ts.mjs +0 -2
package/bin/doctor.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)[0]:
|
|
3
|
-
`)),{
|
|
1
|
+
var Y=Object.defineProperty;var u=(o,l)=>Y(o,"name",{value:l,configurable:!0});import w from"node:fs";import V from"node:os";import L from"node:path";import{isTryPort as R}from"../hub/try.mjs";import{githubGitArgv as Z,gitReachFault as tt}from"../hub/repos.mjs";import{buildsLocally as et,isBoardSite as st}from"../hub/boards.mjs";import{cloneRoot as it}from"../shared/repos.mjs";import{codexStatus as ot}from"../shared/codex.mjs";import{REVIEW_SKILLS as nt,SKILLS_SOURCE as rt,addCommand as at,skillsState as lt,updateCommand as ct}from"../shared/skills.mjs";import{hubService as ut,runCommand as ft}from"../shared/service.mjs";import{inspectLinks as dt,ownsStatusLine as ht,hasWatcherStop as mt,hubStatus as gt,tailscaleState as pt,runInstall as kt}from"./install.mjs";const a="kickflip doctor --fix",X={ok:"ok",fixable:"fixable",yours:"yours",optional:"optional",note:"note"},g=u(o=>`'${o.replaceAll("'","'\\''")}'`,"quote"),bt={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"}},$t="cli/cli",yt=15e3;async function xt({home:o=V.homedir(),cloneRoot:l=it(),port:r=Number(process.env.KICKFLIP_HUB_PORT||4500),uid:S=process.getuid(),env:f=process.env,run:P=ft,platform:p=process.platform,username:j=V.userInfo().username,fetch:b=globalThis.fetch}={}){const c=bt[p==="darwin"?"darwin":"other"],K=[];let C;const i=u((t,e,s,n=null)=>K.push({group:C,item:t,state:e,detail:s,fix:e==="ok"||e==="note"?null:n}),"add"),d=u((t,e,s=null,n=void 0)=>{try{return P(t,e,{env:s?{...f,...s}:f,...n&&{timeout:n}})}catch(m){return{status:1,error:m.message}}},"execute"),F=u((t,e,s,n,m="not on this session\u2019s PATH")=>{const _=d(e,s),G=_.status===0;return i(t,G?"ok":"yours",G?(_.stdout||"installed").trim().split(`
|
|
2
|
+
`)[0]:m,n),G},"installed");C="prereqs";const q=F("git","git",["--version"],c.git);F("node on Claude\u2019s PATH","node",["--version"],`add ${g(L.dirname(process.execPath))} to PATH in your shell profile, then restart Claude Code`,`not on this session\u2019s PATH (${f.PATH||"empty"})`);const D=F("gh","gh",["--version"],c.gh),O=D&&d("gh",["auth","status"]).status===0;if(i("gh signed in",O?"ok":"yours",O?"signed in":D?"not signed in":"needs gh","gh auth login"),q){const t=O?d("gh",["repo","list","--limit","1","--json","nameWithOwner","--jq",".[0].nameWithOwner"]):null,e=t?.status===0&&t.stdout.trim()||$t,s=d("git",Z(["ls-remote",`https://github.com/${e}.git`,"HEAD"]),{GIT_TERMINAL_PROMPT:"0"});i("GitHub clone",s.status===0?"ok":"yours",s.status===0?`git reaches ${e} over https`:`git can\u2019t reach ${e} over https: ${s.error}`,O?"gh auth refresh -h github.com, then kickflip doctor":"check this machine reaches https://github.com, then kickflip doctor")}else i("GitHub clone","yours","needs git",c.git);const $=await pt({run:u((t,e)=>d(t,e),"run"),platform:p,uid:S,username:j,port:r});for(const t of $.prereqs)i(t.item,t.state,t.detail,t.fix);const M=d("tmux",["-V"]);i("tmux",M.status===0?"ok":"optional",M.status===0?(M.stdout||"installed").trim().split(`
|
|
3
|
+
`)[0]:"not installed; a hub board\u2019s session (kickflip join --hub, kickflip hub) runs in it",c.tmux);const N=ot({home:o,env:f,platform:p});i("Codex",N.usable?"ok":"optional",N.usable?"installed and logged in":`${N.reason}; Codex builds and reviews need it`,N.fix);const h=lt({home:o,run:d,gh:O});h.missing.length?i("mattpocock skills","optional",`${h.missing.join(", ")} not installed; architecture reviews need ${h.missing.length===1?"it":"them"}`,at(h.missing)):h.stale.length?i("mattpocock skills","optional",`${h.stale.join(", ")} out of date with ${rt}`,ct(h.stale)):i("mattpocock skills","ok",`${nt.join(", ")} installed${h.checked?" and current":""}`),C="setup";const U=["kickflip skill link","kickflip-hooks link","~/.claude/statusline.sh"];for(const[t,e]of dt({home:o,cloneRoot:l}).entries())if(e.refusal){const s=w.lstatSync(e.link);i(U[t],"yours",s.isSymbolicLink()?`links to ${w.readlinkSync(e.link)}, not kickflip`:`a real ${s.isDirectory()?"folder":"file"}, not kickflip\u2019s link`,`${s.isSymbolicLink()?`rm ${g(e.link)}`:`mv ${g(e.link)} ${g(e.link+".backup")}`} && ${a}`)}else i(U[t],e.created||e.replaced?"fixable":"ok",`${e.created?"missing":e.replaced?"needs relinking":"linked"} -> ${e.target}`,a);const v=L.join(o,".claude","settings.json");let k={},T;try{if(k=JSON.parse(w.readFileSync(v,"utf8")),!k||typeof k!="object"||Array.isArray(k))throw new Error("not a settings object")}catch(t){t.code!=="ENOENT"&&(T=t.message)}const E="settings.json statusLine";T?i(E,"yours",`unreadable: ${T}`,`repair the JSON in ${g(v)}, then ${a}`):Object.hasOwn(k,"statusLine")?ht(k.statusLine,o)?i(E,"ok","runs ~/.claude/statusline.sh"):i(E,"yours","another tool\u2019s status line is selected",`remove statusLine from ${g(v)}, then ${a}`):i(E,"fixable","missing",a);const J="settings.json watcher Stop hook";T?i(J,"yours",`unreadable: ${T}`,`repair the JSON in ${g(v)}, then ${a}`):mt(k)?i(J,"ok","runs hooks-plugin/hooks/watcher-stop.mjs"):i(J,"fixable","missing; a board session can end a turn with no live watcher or a message left Working on it",a);const y=ut({platform:p,home:o,uid:S,env:f,run:P}),B=y.status();i(y.item,B.running?"ok":y.manager?"fixable":"yours",B.detail,y.manager?a:`run ${y.restartCommand} under a service manager of your own`);for(const t of y.notes())i(t.item,t.state,t.detail,t.fix);C="hub";const A=await gt({port:r,fetch:b});i("hub",A?"ok":"fixable",`${A?"running":"not running"} on 127.0.0.1:${r}`,a);const{serveConfig:W}=$;i($.root.item,$.root.state,$.root.detail,$.root.fix);let x=A?.sites;if(!x){const t=L.join(o,".claude","kickflip","manifest.json");try{const e=JSON.parse(w.readFileSync(t,"utf8"));x=Object.entries(e.sites||{}).map(([s,n])=>({...n,route:s,state:"hub not running"}))}catch(e){e.code!=="ENOENT"&&i("site manifest","yours",e.message,`repair the JSON in ${g(t)}`),x=[]}}let I={};try{I=JSON.parse(w.readFileSync(L.join(o,".claude","kickflip","manifest.json"),"utf8"))}catch{}const H=new Map,z=[...Object.entries(I.sites||{}),...Object.entries(I.closed||{}).map(([t,e])=>[t,e.site]),...x.map(t=>[t.route,t])];for(const[t,e]of z){if(!e?.dir)continue;let s;try{s=JSON.parse(w.readFileSync(L.join(e.dir,"data","try.json"),"utf8"))}catch{continue}R(s.main_port)&&H.set(Number(s.main_port),`/${t} main`),R(s.main?.https)&&H.set(Number(s.main.https),`/${t} main`);for(const[n,m]of Object.entries(s.cards||{}))R(m.https)&&H.set(Number(m.https),`/${t} ${n}`)}const Q=Object.keys(W?.TCP||{}).filter(R).sort((t,e)=>t-e);i("try ports","ok",Q.map(t=>{const s=Object.entries(W.Web||{}).find(([n])=>n.endsWith(`:${t}`))?.[1]?.Handlers?.["/"]?.Proxy||W.TCP[t].TCPForward||"HTTPS";return`${t} \u2192 ${s} (${H.get(Number(t))||"unknown"})`}).join("; ")||"none"),x.length||i("sites","ok","none");for(const t of x){const e=t.port?`port ${t.port}`:`files ${t.dir}`,s=`${t.state} ${e} owner ${t.owner?.label||t.owner?.session||"-"} ${t.title||""}`.trimEnd();t.state==="up"?i("/"+t.route,"ok",s):A?t.serves==="port"?i("/"+t.route,"note",`${s}; its session runs this server, not the hub`):t.serves==="files"?i("/"+t.route,"note",`${s}; its folder is missing`):i("/"+t.route,"note",`${s}; the hub restarts it, see kickflip logs ${t.route}`):i("/"+t.route,"fixable",s,a)}if(q)for(const[t,e]of Object.entries(I.sites||{})){const s=e?.owner?.repo;if(!st(e)||et(e)||!s)continue;const n=d("git",["-C",s,"ls-remote","--exit-code","origin","HEAD"],{GIT_TERMINAL_PROMPT:"0"},yt),{error:m,hint:_}=tt(n.error,{github:e.github||"",repo:s});i(`/${t} repo`,n.status===0?"ok":"yours",n.status===0?`git reaches ${e.github||"origin"} from ${s}`:`git can\u2019t reach ${e.github||"origin"} from ${s}: ${m}`,_)}return K}u(xt,"doctorReport");function wt(o){const l=Math.max(...Object.values(X).map(r=>r.length));return o.flatMap(r=>[`${X[r.state].padEnd(l)} ${r.item}: ${r.detail}`,...r.fix?[`${" ".repeat(l+1)}\u2192 ${r.fix}`]:[]])}u(wt,"doctorLines");async function Ht({fix:o=!1,dryRun:l=!1,json:r=!1,write:S=console.log,error:f=console.error,install:P=kt,...p}={}){let j=!1;if(o){try{await P({...p,dryRun:l,log:r?f:S})}catch(c){j=!0,f("kickflip: "+c.message)}if(l)return{items:[],exitCode:j?1:0}}const b=await xt(p);return S(r?JSON.stringify({items:b},null,2):wt(b).join(`
|
|
4
|
+
`)),{items:b,exitCode:j||b.some(c=>c.state==="fixable"||c.state==="yours")?1:0}}u(Ht,"runDoctor");export{wt as doctorLines,xt as doctorReport,Ht as runDoctor};
|
package/bin/install.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`));const m=
|
|
3
|
-
`,{mode:r,flag:"wx"}),
|
|
1
|
+
var R=Object.defineProperty;var y=(e,s)=>R(e,"name",{value:s,configurable:!0});import o from"node:fs";import v from"node:os";import n from"node:path";import{SKILLS_SOURCE as I,addArgv as W,addCommand as H,missingSkills as C}from"../shared/skills.mjs";import{cloneRoot as O}from"../shared/repos.mjs";import{hubService as J,runCommand as _}from"../shared/service.mjs";const M=y(()=>o.existsSync("/opt/homebrew/bin/node")?"/opt/homebrew/bin/node":process.execPath,"nodeBin"),ot=y((e,s,t=O())=>`${M()} ${n.join(t,"bin","wait-events.mjs")} ${e} ${s}`,"watcherCommand");function q(e,{home:s=v.homedir(),skillsDir:t=n.join(s,".claude","skills"),cloneRoot:r=O()}={}){if(typeof e!="string"||!n.isAbsolute(e))return e;const a=n.relative(r,e);if(a===".."||a.startsWith(`..${n.sep}`)||n.isAbsolute(a))return e;const c=n.resolve(t,"kickflip");let l=!1;try{l=o.realpathSync(c)===o.realpathSync(r)}catch{}return l?n.join(c,a):e}y(q,"storedPath");function D({home:e=v.homedir(),skillsDir:s=n.join(e,".claude","skills"),cloneRoot:t=O()}={}){const r=o.realpathSync(t),a=[["kickflip",r],["kickflip-hooks",n.join(r,"hooks-plugin")]].map(([u,f])=>{if(!o.statSync(f,{throwIfNoEntry:!1})?.isDirectory())throw new Error(`not a directory: ${f}`);const h=u==="kickflip"?f:n.resolve(s,"kickflip","hooks-plugin"),k=n.resolve(s,u),m=o.lstatSync(k,{throwIfNoEntry:!1});let j;if(m){let g;try{g=o.realpathSync(k)}catch(b){if(b.code!=="ENOENT")throw b}m.isSymbolicLink()?g!==o.realpathSync(f)&&(j=`refusing to replace link ${k} -> ${o.readlinkSync(k)}; remove that link explicitly, then rerun kickflip doctor --fix`):(!m.isDirectory()||g!==o.realpathSync(f))&&(j=`refusing to replace real path ${k}; move it aside explicitly, then rerun kickflip doctor --fix`)}return{link:k,target:h,created:!m,...j?{refusal:j}:{}}}),c=n.join(r,"bin","statusline.mjs");if(!o.statSync(c,{throwIfNoEntry:!1})?.isFile())throw new Error(`not a file: ${c}`);const l=n.join(e,".claude","statusline.sh"),w=n.resolve(s,"kickflip","bin","statusline.mjs"),i=o.lstatSync(l,{throwIfNoEntry:!1});let S=!1,p;if(i)if(!i.isSymbolicLink())p=`refusing to replace real path ${l}; move it aside explicitly, then rerun kickflip doctor --fix`;else{let u;try{u=o.realpathSync(l)}catch(m){if(m.code!=="ENOENT")throw m}const f=n.join(e,".claude","kickflip","sites");let h=f;try{h=o.realpathSync(f)}catch{}const k=!!u&&[f,h].some(m=>u.startsWith(m+n.sep));u&&u!==o.realpathSync(c)&&!k&&(p=`refusing to replace link ${l} -> ${o.readlinkSync(l)}; remove that link explicitly, then rerun kickflip doctor --fix`),S=k||n.resolve(n.dirname(l),o.readlinkSync(l))!==w||!u}return a.push({link:l,target:w,created:!i,...S?{replaced:!0}:{},...p?{refusal:p}:{}}),a}y(D,"inspectLinks");function B({home:e=v.homedir(),skillsDir:s=n.join(e,".claude","skills"),cloneRoot:t=O(),dryRun:r=!1}={}){const a=D({home:e,skillsDir:s,cloneRoot:t}),c=a.find(l=>l.refusal);if(c)throw new Error(c.refusal);if(r)return a;o.mkdirSync(s,{recursive:!0}),o.mkdirSync(n.join(e,".claude"),{recursive:!0});for(const{link:l,target:w,created:i,replaced:S}of a)S&&o.unlinkSync(l),(i||S)&&o.symlinkSync(w,l,l===n.join(e,".claude","statusline.sh")?"file":"dir");return a}y(B,"installLinks");function z(e,s=v.homedir()){const t=n.join(s,".claude","statusline.sh"),r=[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"&&r.includes(e.command)}y(z,"ownsStatusLine");const F='node "$HOME/.claude/skills/kickflip/hooks-plugin/hooks/watcher-stop.mjs"',G=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 Q({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 r=await t.json();return Array.isArray(r?.sites)?r:null}catch{return null}}y(Q,"hubStatus");function K(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(K,"tailscaleRoot");const P=y((e=process.platform)=>e==="darwin"?"brew install --cask tailscale":"curl -fsSL https://tailscale.com/install.sh | sh","tailscaleInstallHint");async function it({run:e=_,platform:s=process.platform,uid:t=process.getuid(),username:r=v.userInfo().username,port:a=Number(process.env.KICKFLIP_HUB_PORT||4500)}={}){const c=y(async $=>{try{return await e("tailscale",$)}catch(E){return{status:1,error:E.message}}},"execute"),l=y($=>{try{return $.status===0?JSON.parse($.stdout):null}catch{return null}},"json"),w=await c(["version"]),i=w.status===0,S=i?l(await c(["status","--json"])):null,p=S?.BackendState==="Running",u=S?.Self?.DNSName?.replace(/\.$/,"")||"",f=i&&s==="linux"&&t!==0,h=f?l(await c(["debug","prefs"]))?.OperatorUser:null,k=i?l(await c(["serve","status","--json"])):null,m=K(k);let j=!1;try{const $=new URL(m.root);j=$.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes($.hostname)&&Number($.port)===a&&$.pathname==="/"&&!$.search&&!$.hash}catch{}const g=y(($,E,d,x,A="yours")=>({item:$,state:E?"ok":A,detail:d,fix:E?null:x}),"entry"),b=[g("Tailscale",i,i?(w.stdout||"installed").trim().split(`
|
|
2
|
+
`)[0]:"not on this session\u2019s PATH",P(s)),g("Tailscale signed in",p,p?`signed in${u?" as "+u:""}`:i?"not connected":"needs Tailscale","tailscale up")];f&&b.push(g("Tailscale operator",h===r,h===r?r:`${h||"none"} (expected ${r})`,"sudo tailscale set --operator=$USER"));const N=m.paths.filter($=>$!=="/"),L=g("tailscale /",j,`${m.root||"nothing"}${j?"":` (expected the hub on ${a})`}${N.length?"; other mounts: "+N.join(", "):""}`,p?"kickflip doctor --fix":i?"tailscale up":P(s),p?"fixable":"yours");return{installed:i,signedIn:p,dns:u,operatorChecked:f,operator:h,username:r,pointsAtHub:j,prereqs:b,root:L,serveConfig:k}}y(it,"tailscaleState");async function rt({home:e=v.homedir(),cloneRoot:s=O(),port:t=Number(process.env.KICKFLIP_HUB_PORT||4500),uid:r=process.getuid(),env:a=process.env,run:c=_,platform:l=process.platform,wait:w=y(u=>new Promise(f=>setTimeout(f,u)),"wait"),fetch:i=globalThis.fetch,dryRun:S=!1,log:p=console.log}={}){const u=n.join(e,".claude","kickflip"),f=J({platform:l,home:e,uid:r,env:a,run:c});if(S){try{for(const{link:x,target:A,created:T,replaced:U}of B({home:e,cloneRoot:s,dryRun:S}))p(`would ${T||U?"link":"check"} ${x} -> ${A}`)}catch(x){p(`would refuse: ${x.message}`)}p(`would merge statusLine and the watcher Stop hook and remove stale hooks in ${n.join(e,".claude","settings.json")}`);const d=C(e);d.length&&p(`would add ${d.join(", ")} from ${I} with ${H(d)}`);for(const x of await f.install(null,{wait:w,dryRun:S}))p(x);p(`would map tailscale / to the hub on ${t} and remove old site mounts`);return}for(const{link:d,target:x,created:A,replaced:T}of B({home:e,cloneRoot:s}))p(`${A||T?"linked":"checked"} ${d} -> ${x}`);for(const d of V({home:e}))p(d);const h=C(e);if(h.length){const d=c("npx",W(h),{env:a,timeout:3e5});p(d.status===0?`added ${h.join(", ")} from ${I}`:`could not add ${h.join(", ")} from ${I}: ${d.error}; run ${H(h)}`)}const k=M(),m=q(n.join(s,"hub","hub.mjs"),{home:e,cloneRoot:s});o.mkdirSync(u,{recursive:!0});const j=n.join(u,"hub.log"),g=f.definition({node:k,entry:m,state:u,port:t,log:j});for(const d of await f.install(g,{wait:w}))p(d);let b=!1;for(let d=0;d<30&&!b;d++)await w(300),b=!!await Q({port:t,fetch:i});if(!b)throw new Error("hub did not start; see "+j);const N=c("tailscale",["serve","--bg",String(t)],{env:a});if(N.status!==0)throw new Error(N.error||"tailscale serve failed");const L=c("tailscale",["serve","status","--json"],{env:a});let $;try{$=JSON.parse(L.stdout)}catch{return}let E={};try{E=JSON.parse(o.readFileSync(n.join(u,"manifest.json"),"utf8")).sites||{}}catch(d){if(d.code!=="ENOENT")throw d}for(const d of K($).paths)d!=="/"&&Object.hasOwn(E,d.replace(/^\//,"").replace(/\/$/,""))&&c("tailscale",["serve","--https=443","--set-path="+d,"off"],{env:a})}y(rt,"runInstall");function V({home:e=v.homedir()}={}){const s=n.join(e,".claude","settings.json");let t={},r=384;try{t=JSON.parse(o.readFileSync(s,"utf8")),r=o.statSync(s).mode}catch(i){if(i.code!=="ENOENT")throw i}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`not a settings object: ${s}`);const a=[];let c=!1;const l=n.join(e,".claude","statusline.sh");if(Object.hasOwn(t,"statusLine"))z(t.statusLine,e)||a.push(`kept existing statusLine in ${s}; it points elsewhere`);else{const i=/^[\w/.-]+$/.test(l)?l:`'${l.replaceAll("'","'\\''")}'`;t.statusLine={type:"command",command:i},c=!0,a.push(`set statusLine in ${s} -> ${i}`)}if(!G(t)){const i=t.hooks&&typeof t.hooks=="object"?t.hooks:{};t.hooks={...i,Stop:[...Array.isArray(i.Stop)?i.Stop:[],{hooks:[{type:"command",command:F}]}]},c=!0,a.push(`added the watcher Stop hook to ${s} -> ${F}`)}const w=n.join(e,".claude","hooks","no-paths.py");if(!o.existsSync(w)&&t.hooks&&typeof t.hooks=="object"){const i=y(u=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escape"),S=[w,"~/.claude/hooks/no-paths.py","$HOME/.claude/hooks/no-paths.py","${HOME}/.claude/hooks/no-paths.py"].map(i).join("|"),p=new RegExp(`^\\s*(?:exec\\s+)?(?:(?:/usr/bin/env\\s+)?(?:[^\\s]+/)?python(?:\\d+(?:\\.\\d+)*)?(?:\\s+-[^\\s]+)*\\s+)?(?:"(?:${S})"|'(?:${S})'|(?:${S}))(?=$|\\s)`);for(const[u,f]of Object.entries(t.hooks))Array.isArray(f)&&(t.hooks[u]=f.flatMap(h=>{if(!Array.isArray(h?.hooks))return[h];const k=h.hooks.filter(m=>m?.type!=="command"||typeof m.command!="string"||!p.test(m.command)?!0:(a.push(`removed stale hook ${u}: ${m.command}`),c=!0,!1));return k.length===h.hooks.length?[h]:k.length?[{...h,hooks:k}]:[]}))}if(c){o.mkdirSync(n.dirname(s),{recursive:!0});const i=`${s}.${process.pid}.${Date.now()}.tmp`;try{o.writeFileSync(i,JSON.stringify(t,null,2)+`
|
|
3
|
+
`,{mode:r,flag:"wx"}),o.renameSync(i,s)}finally{try{o.unlinkSync(i)}catch{}}}return a}y(V,"installClaudeSettings");function at({home:e=v.homedir(),skillsDir:s=n.join(e,".claude","skills"),cloneRoot:t=O()}={}){const r=n.join(e,".claude","statusline.sh");if(!o.lstatSync(r,{throwIfNoEntry:!1})?.isSymbolicLink())return!1;let c=n.resolve(n.dirname(r),o.readlinkSync(r))===n.resolve(s,"kickflip","bin","statusline.mjs");try{c||=o.realpathSync(r)===o.realpathSync(n.join(t,"bin","statusline.mjs"))}catch{}return c?(o.unlinkSync(r),!0):!1}y(at,"uninstallStatusLine");export{F as WATCHER_STOP,G as hasWatcherStop,Q as hubStatus,D as inspectLinks,V as installClaudeSettings,B as installLinks,M as nodeBin,z as ownsStatusLine,rt as runInstall,q as storedPath,P as tailscaleInstallHint,K as tailscaleRoot,it as tailscaleState,at as uninstallStatusLine,ot as watcherCommand};
|
package/bin/kickflip.mjs
CHANGED
|
@@ -3,25 +3,37 @@
|
|
|
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
|
|
6
|
+
// --fix runs init's steps, then reports again. --json prints {items:[{group,item,state,detail,fix}]}.
|
|
7
7
|
// Exit 1 when anything is fixable or yours
|
|
8
|
-
// kickflip join
|
|
9
|
-
//
|
|
8
|
+
// kickflip join [--name <board name>] [--hub]
|
|
9
|
+
// run in a git repo's folder: adds it as a board (docs/adr/0143-kickflip-join-adds-the-current-repository-as-a-board.md).
|
|
10
|
+
// Asks for the board name, default the folder's name; with no terminal to ask in, --name is needed. The name
|
|
11
|
+
// 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; the board's builders branch from the folder's local main and
|
|
13
|
+
// land there (`local: true`). Marks the folder trusted for Claude Code, then starts the board's session in
|
|
14
|
+
// the background as `start` does, or with --hub flags the board as the hub board, starts its session in
|
|
15
|
+
// 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 and offers to restart its session
|
|
17
|
+
// Every other join names its site with --name <name>, which gives its title and its route as above (any characters,
|
|
18
|
+
// other than letters and digits, become dashes). A name that is the route itself keeps the site's title.
|
|
19
|
+
// kickflip join --name <name> (--port <n> | --dir <folder> [--cmd '<json array>' [--port <n>]])
|
|
20
|
+
// [--description <d>] [--icon <key>] [--color <css hex>]
|
|
10
21
|
// a plain page: no session, owner, watcher or needs (docs/adr/0087-a-page-joins-without-a-session.md).
|
|
11
22
|
// --port forwards /<route>/ to a server the session already runs, which reads Down while it doesn't
|
|
12
23
|
// answer; --dir alone has the hub serve the folder's files; --cmd has the hub run that command in --dir
|
|
13
24
|
// (default the cwd) on --port or a free one. Prints {route, url, serves, port|dir, answering?, hub}.
|
|
14
|
-
// A rejoin
|
|
15
|
-
//
|
|
16
|
-
// kickflip join <route> --session <id> [--watch [<file,file>]] [--label <name>] [--title <t>] [--description <d>]
|
|
25
|
+
// A rejoin passes --port, --dir or --cmd again. Exit 3 when a session owns the route
|
|
26
|
+
// kickflip join --name <name> --session <id> [--watch [<file,file>]] [--label <name>] [--description <d>]
|
|
17
27
|
// [--dir <path>] [--cmd '<json array>'] [--port <n>]
|
|
18
28
|
// [--filter <regex>] [--template board [--items <waves|file>]] [--force]
|
|
19
29
|
// [--icon <key>] [--color <css hex>] [--repo <dir>] [--model <m>] [--hub | --no-hub]
|
|
20
30
|
// a site with an owning session: events, the watcher, Needs you. --watch is optional with --session;
|
|
21
31
|
// with files it watches those (relative to the dir) in place of data/events.jsonl
|
|
22
|
-
// --hub makes this board the hub board, as `set --hub` does; a join without either keeps the flag
|
|
32
|
+
// --hub makes this board the hub board, as `set --hub` does; a join without either keeps the flag.
|
|
33
|
+
// The hub board's session runs in the foreground in tmux (`hub`); every other board's in the background
|
|
23
34
|
// --template board runs the shared board (../board/server.mjs) from the site dir,
|
|
24
|
-
// writing its board.json; --items is "waves" (default) or a wave.json-format file
|
|
35
|
+
// writing its board.json; --items is "waves" (default) or a wave.json-format file, made with no
|
|
36
|
+
// items when missing.
|
|
25
37
|
// It then runs handshake, unless this session already answered the board's hello, and
|
|
26
38
|
// asks the hub for one poll (as poll-now --keep-queue), so the board's GitHub link passes
|
|
27
39
|
// without waiting for the next slot. Prints poll: "reached this board", or why not
|
|
@@ -37,7 +49,7 @@
|
|
|
37
49
|
// kickflip start <route> [--repo <dir>] [--model <m>] [--prompt <text>]
|
|
38
50
|
// starts a background session (`claude --bg`, auto mode, worktree isolation off) in --repo, else
|
|
39
51
|
// the route's recorded folder, else the cwd, named after the board, whose first prompt is
|
|
40
|
-
// `/kickflip <
|
|
52
|
+
// `/kickflip --name '<board name>'` plus --prompt. Records it as the route's owner, or in `starting` until a
|
|
41
53
|
// join takes it up when the route has no site yet. Prints {route, session, confirmed, repo, argv, output}
|
|
42
54
|
// kickflip resume <route>
|
|
43
55
|
// `claude --resume <id> --bg` for the route's recorded session in its folder, prompting it to rejoin
|
|
@@ -45,36 +57,52 @@
|
|
|
45
57
|
// {route, session, previous, confirmed, repo, argv, output}. Exit 1 when no session or folder is recorded
|
|
46
58
|
// kickflip close <route> --name <board title>
|
|
47
59
|
// stops its session, closes builder records and removes the site; keeps its folder and open PRs.
|
|
48
|
-
// --name must match the board title exactly.
|
|
60
|
+
// --name must match the board title exactly.
|
|
49
61
|
// kickflip reopen <route>
|
|
50
62
|
// restores the closed board's manifest entry and resumes its recorded session
|
|
63
|
+
// kickflip export <route> [--out <file>]
|
|
64
|
+
// writes one .tgz (default ./kickflip-<route>.tgz, never over an existing file) holding the board's
|
|
65
|
+
// folder, without its watcher cursors and watcher record; its manifest entry with only EXPORT_KEYS below,
|
|
66
|
+
// dropping its folder, port, command, owner session and restart times; the owner's label and model;
|
|
67
|
+
// settings.json's EXPORT_SETTINGS; and a README.md of the import steps. No other hub file and no key
|
|
68
|
+
// goes in. Refuses a site that isn't a board, a board whose cards live outside its folder, and a board
|
|
69
|
+
// with an open builder record. Prints {route, file, entry, dropped, settings}
|
|
70
|
+
// kickflip import <file>
|
|
71
|
+
// unpacks an export's board into ~/.claude/kickflip/sites/<route>/, adds its manifest entry with a free
|
|
72
|
+
// port and this host's board server, and writes its settings over this host's for those keys. A hub
|
|
73
|
+
// flag is kept only when no other site has it. Refuses a route this host has open, closed or starting,
|
|
74
|
+
// or whose folder exists. Prints {route, dir, port, settings, hub, join}: `join` is the line a fresh
|
|
75
|
+
// session runs to take the board over
|
|
51
76
|
// kickflip hub [--repo <dir>]
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
77
|
+
// attaches this terminal to the hub board's tmux session (tmux attach; switch-client inside tmux).
|
|
78
|
+
// With none running, the hub board's session starts in it first, in the foreground: its recorded
|
|
79
|
+
// session resumed in its recorded folder and model, or in --repo when no folder is recorded; with no
|
|
80
|
+
// owner, a fresh session in --repo (default cwd) that joins the board with --hub. Points it to
|
|
81
|
+
// docs/hub-session.md. While the tmux session runs, nothing else starts
|
|
82
|
+
// (docs/adr/0147-boards-run-in-the-background-and-the-hub-board-in-tmux.md).
|
|
83
|
+
// Exit 2 when no board has the hub flag (`set --hub`), 3 while its session is live outside tmux;
|
|
84
|
+
// otherwise keeps tmux's exit code
|
|
56
85
|
// kickflip sessions [--json]
|
|
57
86
|
// one line per board: route, session id, live (background or terminal) or not, folder
|
|
58
87
|
// kickflip handshake <route>
|
|
59
88
|
// tests a board's hub links (../hub/boards.mjs handshake): appends a `hello` event, which the
|
|
60
|
-
// owning session answers
|
|
61
|
-
// until the
|
|
89
|
+
// owning session's watcher answers when it prints it. The board shows a setup checklist
|
|
90
|
+
// until the watcher answered and the hub's GitHub check reached it. Prints {route, hello}
|
|
62
91
|
// kickflip set <route> [--icon <key>] [--color <hex>] [--hub | --no-hub]
|
|
63
92
|
// changes an existing site's icon or color without joining; '' clears one. --hub makes the board the
|
|
64
|
-
// hub board, whose session `hub`
|
|
93
|
+
// hub board, whose session runs in tmux and `hub` attaches to (`hub: true` in its entry), clearing the flag from any other
|
|
65
94
|
// site; --no-hub clears it. Exit 2 for --hub on a site that isn't a board
|
|
66
95
|
// kickflip leave <route> [--session <id>] [--force]
|
|
67
96
|
// removes the entry and keeps its files; --session (or --force) only for a route a session owns
|
|
68
97
|
// kickflip restart <route>
|
|
69
98
|
// kickflip logs <route> [--lines <n>]
|
|
70
|
-
// kickflip
|
|
71
|
-
//
|
|
72
|
-
// the kickflip ones (./install.mjs migrateHome), then links the running package or clone, hooks plugin
|
|
99
|
+
// kickflip init [--dry-run] | uninstall
|
|
100
|
+
// init is the first-run name for doctor --fix. It links the running package or clone, hooks plugin
|
|
73
101
|
// and status line, configures Claude settings, starts the hub's service in place of the running one (../shared/service.mjs:
|
|
74
|
-
// a launchd login item on macOS
|
|
102
|
+
// a launchd login item on macOS; a systemd user unit on Linux),
|
|
75
103
|
// and maps Tailscale / to the hub.
|
|
76
104
|
// Conflicting skill links and real paths are refused. A dangling status-line link can be replaced.
|
|
77
|
-
// --dry-run prints what
|
|
105
|
+
// --dry-run prints what init would move, link and start, and changes nothing.
|
|
78
106
|
// uninstall stops the hub and removes its service, kickflip's status-line link and Tailscale /;
|
|
79
107
|
// Claude settings and skill links are kept
|
|
80
108
|
// kickflip update
|
|
@@ -88,8 +116,8 @@
|
|
|
88
116
|
// can fix. A push without one is refused (exit 2): news stays on the board.
|
|
89
117
|
// The push queues, replacing a queued one with the same
|
|
90
118
|
// --tag, and goes out after the hub's next GitHub check on the polling interval
|
|
91
|
-
// (/_hub/settings/polling) or when a
|
|
92
|
-
// queued
|
|
119
|
+
// (/_hub/settings/polling) or when a GitHub tick ends (board.mjs checked); a board's
|
|
120
|
+
// several queued pushes go as one summary. --now sends at once unless pushes are held
|
|
93
121
|
// (overnight, snoozed or the weekend), and queues if no device takes it; it is for questions,
|
|
94
122
|
// steps only the owner can run and prototypes. --urgent sends at once through
|
|
95
123
|
// those holds, for a production fault. While notifications are off every push is dropped, urgent ones too.
|
|
@@ -97,7 +125,7 @@
|
|
|
97
125
|
// kickflip polling
|
|
98
126
|
// prints {every, until, next, held, held_until, held_why, notifications}: the current polling
|
|
99
127
|
// window's minutes, when it ends, the next check, whether pushes are held now, until when
|
|
100
|
-
// ("never" while off) and why (off, snoozed, weekend or overnight), and the notifications settings
|
|
128
|
+
// ("never" while off, "forever" while snoozed until ended) and why (off, snoozed, weekend or overnight), and the notifications settings
|
|
101
129
|
// kickflip notifications [on | off | snooze <length> | unsnooze | weekends on|off]
|
|
102
130
|
// sets the Hub page's Notifications controls and prints them; off drops the queued pushes.
|
|
103
131
|
// A snooze length is a hub/schedule.mjs snoozeEnd choice. Without a change it only prints them
|
|
@@ -107,7 +135,7 @@
|
|
|
107
135
|
// builders take over until it resets.
|
|
108
136
|
// always (Always on): the same past the pause line; while Codex is out of usage, that work pauses until a
|
|
109
137
|
// usage-reset check succeeds.
|
|
110
|
-
// off:
|
|
138
|
+
// off: Claude builds and reviews. While Codex isn't installed or logged in, the setting reads off and a change is refused.
|
|
111
139
|
// kickflip usage-gate [pause-at <50..100> | keep-going | stop]
|
|
112
140
|
// prints {pause_at, state, window, used, resets_at, codex: {past, window, used, resets_at}}; a read exits 0.
|
|
113
141
|
// pause-at saves the line in steps of 5 (default 90, 100 Off); keep-going lifts the current Claude pause
|
|
@@ -117,9 +145,36 @@
|
|
|
117
145
|
// checked.json, then the queue unless --keep-queue) and prints its result
|
|
118
146
|
// Exit codes: 0 ok, 1 error, 2 bad usage, 3 route owned by another session (join/leave), or its recorded session is
|
|
119
147
|
// live (start/resume/hub). hub passes through claude's exit code.
|
|
120
|
-
var
|
|
121
|
-
`)
|
|
122
|
-
`).
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
148
|
+
var ve=Object.defineProperty;var h=(e,t)=>ve(e,"name",{value:t,configurable:!0});import w from"node:fs";import u from"node:path";import D from"node:os";import se from"node:net";import Oe from"node:readline/promises";import{execFileSync as oe,spawnSync as M}from"node:child_process";import{fileURLToPath as xe}from"node:url";import{ICON_KEYS as ie}from"../hub/icons.mjs";import{liveSessions as re}from"../hub/live.mjs";import{isBoardSite as L,writeManifest as O}from"../hub/boards.mjs";import{joinName as _e,routeFromName as F,routeRecord as g,validRoute as C}from"../hub/routes.mjs";import{githubFromOrigin as Ne}from"../hub/repos.mjs";import{uninstallStatusLine as Te,storedPath as Ie,nodeBin as K,watcherCommand as Fe}from"./install.mjs";import{hubService as ae}from"../shared/service.mjs";import{runDoctor as Ce}from"./doctor.mjs";import{cloneRoot as Ee}from"../shared/repos.mjs";const j=Ee(),x=u.join(D.homedir(),".claude","kickflip"),Re=u.join(x,"manifest.json"),ce=u.join(x,"logs"),T=Number(process.env.KICKFLIP_HUB_PORT||4500),G=4600,Be=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,[U,...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 p=h(e=>console.log(typeof e=="string"?e:JSON.stringify(e,null,2)),"out");class I extends Error{static{h(this,"Exit")}constructor(t,n){super(t),this.code=n}}const i=h((e,t=1)=>{throw new I(e,t)},"fail");function W(){s.icon&&!ie.includes(s.icon)&&i(`--icon takes one of: ${ie.join(", ")}`,2),s.color&&!Be.test(s.color)&&i("--color takes a CSS hex color, such as #3b82f6",2)}h(W,"checkLook");function Y(e){for(const t of["icon","color"])s[t]===""?delete e[t]:s[t]!==void 0&&(e[t]=s[t])}h(Y,"applyLook");const de=h(()=>s.hub&&s["no-hub"]&&i("pass --hub or --no-hub, not both",2),"checkHub"),le=h(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){L(n)||le(t);for(const[r,d]of Object.entries(e.sites))r!==t&&d?.hub&&delete d.hub;n.hub=!0}}h(X,"applyHub");function k(){try{const e=JSON.parse(w.readFileSync(Re,"utf8"));return e.sites||={},e}catch(e){if(e.code==="ENOENT")return{version:1,sites:{}};i("manifest unreadable: "+e.message)}}h(k,"readManifest");const ue=h(e=>{try{return JSON.parse(w.readFileSync(e,"utf8"))}catch{return null}},"readJSON"),E=h(()=>import(u.join(j,"hub","sessions.mjs")),"sessionsModule");async function P(e){const{SessionError:t}=await E();try{return await e()}catch(n){throw n instanceof t&&i(n.message,n.reason==="live"?3:n.reason==="hub"?2:1),n}}h(P,"sessionCall");async function fe(e){const{handshake:t}=await import(u.join(j,"hub","boards.mjs"));try{return await t(e,k())}catch(n){return i(n.message,2)}}h(fe,"runHandshake");async function Ae(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(d){return`not run (${d.message})`}if(!n.ok)return`not run (the hub answered ${n.status})`;const r=await n.json();if(r.checked?.includes(e))return"reached this board";if(r.failed?.length)return`missed this board: ${r.failed[0]}`}return"missed this board"}h(Ae,"pollFor");async function _(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}}h(_,"withLock");function he(e){return new Promise(t=>{const n=se.connect({port:e,host:"127.0.0.1"}),r=h(d=>{n.destroy(),t(d)},"done");n.setTimeout(500,()=>r(!1)),n.on("connect",()=>r(!0)),n.on("error",()=>r(!1))})}h(he,"connects");function De(e){return new Promise(t=>{const n=se.createServer();n.once("error",()=>t(!1)),n.listen(e,"0.0.0.0",()=>n.close(()=>t(!0)))})}h(De,"bindable");async function H(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 he(n)&&await De(n))return n;i("no free port found from "+G)}h(H,"freePort");function Le(){try{return(JSON.parse(oe("tailscale",["status","--json"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]})).Self?.DNSName||"").replace(/\.$/,"")}catch{return""}}h(Le,"tailnetHost");const Z=h(e=>{const t=Le();return t?`https://${t}/${e}/`:`http://127.0.0.1:${T}/${e}/`},"siteUrl");async function J(){try{return await(await fetch(`http://127.0.0.1:${T}/_hub/status.json`,{signal:AbortSignal.timeout(1500)})).json()}catch{return null}}h(J,"hubStatus");const pe=h(e=>{try{return w.statSync(e).isDirectory()}catch{return!1}},"isFolder"),Pe=h(e=>{try{return w.realpathSync(e)}catch{return null}},"realPath");function me(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}}h(me,"named");function we(e,{title:t,items:n,tickets:r}){w.mkdirSync(u.join(e,"data"),{recursive:!0});const d=u.join(e,"board.json"),a=w.existsSync(d)?JSON.parse(w.readFileSync(d,"utf8")):{};a.title=t,a.items=Ie(n||a.items||"waves"),r&&(a.tickets=r),w.writeFileSync(d,JSON.stringify(a,null,2)+`
|
|
149
|
+
`);const o=a.items==="waves"?null:u.resolve(e,a.items);return o&&!w.existsSync(o)&&(w.mkdirSync(u.dirname(o),{recursive:!0}),w.writeFileSync(o,JSON.stringify({title:a.title,items:[]},null,2)+`
|
|
150
|
+
`)),[K(),u.join(j,"board","server.mjs"),e]}h(we,"boardFiles");async function Q(e,t){const{startSession:n,withSessionLock:r}=await E();return r(e,async()=>{const d=await P(()=>n(e,{manifest:k(),...t}));return await _(async()=>{const a=k(),o={session:d.session,label:d.name,since:new Date().toISOString(),repo:d.repo,...d.model?{model:d.model}:{}};g(a.sites,e)?(a.sites[e].owner=o,a.sites[e].updated=o.since):a.starting={...a.starting,[e]:{...g(a.starting,e),...o}},await O(a)}),d})}h(Q,"startRecorded");async function z(e){const{hubSession:t}=await E(),n=await P(()=>t({manifest:k(),repo:e}));process.exitCode=n.status}h(z,"openHub");const V=h((e,...t)=>{const n=M("git",["-C",e,...t],{encoding:"utf8"});return n.status===0?n.stdout.trim():null},"git"),ge=h(()=>!!(process.stdin.isTTY&&process.stdout.isTTY),"canAsk");async function be(e){const t=Oe.createInterface({input:process.stdin,output:process.stdout});try{return(await t.question(e)).trim()}catch(n){throw n.code==="ABORT_ERR"&&i("stopped at the prompt; nothing changed"),n}finally{t.close()}}h(be,"ask");const ye=h((e,t)=>!!(g(e.sites,t)||g(e.starting,t)||g(e.closed,t)),"taken");function He(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.":ye(k(),F(e))?`/${F(e)} is taken; pick another name.`:null}h(He,"nameProblem");const ke="--template board --items data/wave.json";async function Je(){const e=V(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 J()||i("the hub is not running; run kickflip init to set it up, then kickflip join here again");const n=Object.entries(k().sites).find(([,f])=>L(f)&&f.owner?.repo&&Pe(f.owner.repo)===t);if(n)return ze(...n);const r=u.basename(t).replace(/[^A-Za-z0-9]+/g," ").trim();let d=s.name?.trim();for(d===void 0&&!ge()&&i('join needs --name "<Board name>" when it has no terminal to ask in',2);;){d===void 0&&(d=await be(`Board name${r?` (${r})`:""}: `)||r);const f=He(d);if(!f)break;s.name!==void 0&&i(f,2),p(f),d=void 0}const a=d.replace(/\s+/g," "),o=F(a),m=V(t,"remote","get-url","origin"),l=m?Ne(m):null,c=V(t,"symbolic-ref","--quiet","--short","HEAD"),{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 _(async()=>{const f=k();ye(f,o)&&i(`/${o} is taken; pick another name`,2);const y=u.join(x,"sites",o),$=new Date().toISOString(),v={dir:y,port:await H(f),cmd:we(y,{title:a,items:"data/wave.json"}),watch:["data/events.jsonl"],title:a,local:!0,...l?{github:l}:{},...c?{branch:c}:{},owner:{repo:t},created:$,updated:$};f.sites={...f.sites,[o]:v},X(f,o,v),await O(f)}),p(`Made ${a} at ${Z(o)}, working in ${t}${l?` (${l})`:""}.`),s.hub)return p("It is the hub board, so its session runs in tmux, attached here."),z(t);try{await Q(o,{repo:t,prompt:ke})}catch(f){throw f instanceof I&&i(`${f.message}
|
|
151
|
+
The board is made; run kickflip join here again to start its session.`,f.code),f}p("Its session is starting in the background, and joins the board shortly.")}h(Je,"joinFolder");async function ze(e,t){const n=t.title||e;p(`This folder already has a board: ${n} (/${e}).`),ge()||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 r=(await be("Restart its session? (Y/n) ")).toLowerCase();if(r&&!"yes".startsWith(r))return;if(!t.owner.session)return t.hub===!0?z(t.owner.repo):(await Q(e,{repo:t.owner.repo,prompt:ke}),p("Its session is starting in the background."));const d=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)}),a=await d.json();if(d.ok||i(a.error),p(`Restarted ${n}'s session.`),t.hub===!0)return z(t.owner.repo)}h(ze,"restartFolderBoard");const ee=["title","description","icon","color","created","watch","filter","hub","github","remote","branch","local"],Se=["notifications","polling","codexShare"],R="kickflip-board",qe=/^(\.watch-cursor-.*\.json|watcher\.json)$/,B=h((e,t)=>Object.fromEntries(t.filter(n=>e[n]!==void 0).map(n=>[n,e[n]])),"pick"),q=h(e=>/^[\w@%+=:,./-]+$/.test(e)?e:`'${String(e).replace(/'/g,"'\\''")}'`,"shellQuote");function je(e){const t=M("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()}`)}h(je,"tar");function Me(e,t){const n=e.entry.title||e.route,r=Object.keys(e.settings).map(d=>({notifications:"Notifications",polling:"Polling",codexShare:"Codex share"})[d]);return`# Moving ${n} (/${e.route}) to another machine
|
|
152
|
+
|
|
153
|
+
Exported from ${e.from} at ${e.exported_at}. This bundle holds the board's folder and manifest entry${r.length?`, and the hub's ${r.length>1?`${r.slice(0,-1).join(", ")} and ${r.at(-1)}`:r[0]} settings, which import writes over the new machine's`:""}.
|
|
154
|
+
|
|
155
|
+
## On the new machine
|
|
156
|
+
|
|
157
|
+
1. Install Git, Node 22+, Claude Code, gh and Tailscale, and turn on HTTPS certificates for the tailnet.
|
|
158
|
+
2. Run \`npm i -g @lovek4d/kickflip\`, then \`kickflip init\`, and fix what its report marks yours.
|
|
159
|
+
3. Run \`kickflip import ${t}\`. It refuses when /${e.route} already exists there.
|
|
160
|
+
4. Start a fresh Claude Code session in the folder the board works in, and have it run the \`join\` line the import prints, with its own session id. \`--force\` takes the board over.
|
|
161
|
+
5. Once the board answers there, stop its session on the old machine and run \`kickflip leave ${e.route} --force\` there, so only one session acts on its cards. Its files stay on the old machine.
|
|
162
|
+
|
|
163
|
+
## Set up again
|
|
164
|
+
|
|
165
|
+
The bundle carries no secret and nothing tied to the old machine. Set these up on the new machine:
|
|
166
|
+
|
|
167
|
+
- GitHub sign-in: \`gh auth login\`.
|
|
168
|
+
- Linear API key: Hub \u2192 Linear.
|
|
169
|
+
- Slack: Claude's Slack connector in the new session, and the hub's Slack identity with \`board.mjs slack set --self-dm <D\u2026> --user <U\u2026>\`.
|
|
170
|
+
- Codex: \`codex login\`, if Codex builds.
|
|
171
|
+
- Notifications: open the Hub page on each phone and tap Turn on.
|
|
172
|
+
- Other hub settings, such as the pause line and Rules for every board, stay on the old machine.
|
|
173
|
+
|
|
174
|
+
Manifest fields left out, which the new machine sets itself: ${e.dropped.length?e.dropped.join(", "):"none"}.
|
|
175
|
+
`}h(Me,"exportReadme");async function Ke(){W();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(l=>typeof l=="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&&!pe(n)&&i(`--dir ${n} is not a folder`,2);const{route:r,title:d}=me(l=>g(k().sites,l)),a=await _(async()=>{const l=k();g(l.closed,r)&&i("That board is closed; use kickflip reopen "+r,2),g(l.starting,r)&&i(`/${r} is a board that is starting; pick another route`,2);const c=g(l.sites,r);if(c?.owner?.session)throw p({error:"owned",route:r,owner:c.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=c?{...c}:{created:b};delete f.watch,delete f.filter;{const y=t?{cmd:t,dir:n||c?.dir||process.cwd(),port:e??(c?.cmd?c.port:void 0)??await H(l)}:e!==void 0?{port:e,...n?{dir:n}:{}}:{dir:n};for(const $ of["cmd","dir","port","cwd","env"])delete f[$];Object.assign(f,y)}return f.title=d,s.description&&(f.description=s.description),Y(f),f.updated=b,l.sites={...l.sites,[r]:f},await O(l),f}),o=a.cmd?"cmd":a.port?"port":"files",m=await J();p({route:r,url:Z(r),serves:o,...a.port?{port:a.port}:{},...a.dir?{dir:a.dir}:{},...o==="port"?{answering:await he(a.port)}:{},hub:m?"running":"NOT running: run `kickflip doctor --fix`"})}h(Ke,"joinPage");const te={async doctor(){s["dry-run"]&&!s.fix&&i("--dry-run needs --fix",2);const{exitCode:e}=await Ce({fix:!!s.fix,dryRun:!!s["dry-run"],json:!!s.json});process.exitCode=e},async join(){if(s._.length&&i(`join takes no route: --name "<name>" gives the title and the route, as in kickflip join --name ${q(s._[0])}`,2),s.title!==void 0&&i('join takes no --title: --name "<name>" gives the title and the route',2),!s.session){const o=["port","dir","cmd"].some(l=>s[l]!==void 0),m=["watch","template","filter","label","model","repo","force","items",...o?["hub"]:[]].find(l=>s[l]!==void 0);return m&&i(`--${m} needs --session <id> (this session's id)`,2),o?Ke():Je()}const{route:e,title:t}=me(o=>g(k().sites,o));s.template&&s.template!=="board"&&i('--template takes "board"',2),W(),de();const n=await _(async()=>{const o=k();g(o.closed,e)&&i("That board is closed; use kickflip reopen "+e,2);const m=new Date().toISOString(),l=g(o.sites,e);if(l?.owner?.session&&l.owner.session!==s.session&&!s.force)throw p({error:"owned",route:e,owner:l.owner,hint:"ask the user, then rerun with --force to take it over"}),new I("",3);s.hub&&s.template!=="board"&&!L({dir:"",cmd:s.cmd?JSON.parse(s.cmd):l?.cmd})&&le(e);const c=l?{...l}:{};let b=!1;if(l||(c.dir=u.resolve(s.dir||u.join(x,"sites",e)),(!w.existsSync(c.dir)||w.readdirSync(c.dir).length===0)&&!s.cmd&&!s.template&&(w.cpSync(u.join(j,"starter"),c.dir,{recursive:!0}),b=!0),c.port=s.port?Number(s.port):await H(o),c.cmd=s.cmd?JSON.parse(s.cmd):[K(),u.join(c.dir,"server.mjs")],c.watch=["data/events.jsonl"],c.created=m),s.dir&&l&&(c.dir=u.resolve(s.dir)),s.port&&l&&(c.port=Number(s.port)),s.cmd&&l&&(c.cmd=JSON.parse(s.cmd)),s.template==="board"){const N=g(o.starting,e),$e=!l&&N?.tickets&&(!N.session||N.session===s.session)?N.tickets:void 0;c.cmd=we(c.dir,{title:t,items:s.items,tickets:$e}),b=!l}c.title=t,s.description&&(c.description=s.description),typeof s.watch=="string"&&(c.watch=s.watch.split(",").map(N=>N.trim()).filter(Boolean)),s.filter!==void 0&&(c.filter=s.filter||void 0),Y(c),X(o,e,c);const f=l?.owner&&l.owner.session!==s.session?l.owner:null,y=g(o.starting,e)?.session===s.session?g(o.starting,e):null,$=g(o.starting,e);!l&&($?.github||$?.remote)&&(!$.session||$.session===s.session)&&($.github?c.github=$.github:c.remote=$.remote,c.branch=$.branch);const v=l?.owner?.session===s.session?l.owner:null,A=v||y||f;c.owner={...v||{session:s.session,since:m},label:s.label||A?.label||"",repo:s.repo?u.resolve(s.repo):(c.github||c.remote)&&A?.repo||re().get(s.session)?.cwd||A?.repo||process.cwd()};const ne=s.model||A?.model;return ne&&(c.owner.model=ne),g(o.starting,e)&&(delete o.starting[e],Object.keys(o.starting).length||delete o.starting),c.updated=m,o.sites={...o.sites,[e]:c},await O(o),{route:e,created:b,previousOwner:f,site:c}}),r=await J();let d,a;if(s.template==="board"){const o=ue(u.join(n.site.dir,"data","handshake.json"));d=o?.ack&&o.hello?.session===s.session?"answered before":await fe(e),a=r?await Ae(e):"not run (the hub is not running)"}p({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(ce,e+".log"),watcher:Fe(e,s.session,j),hub:r?"running":"NOT running: run `kickflip doctor --fix`",...d?{handshake:d}:{},...a?{poll:a}:{}})},async handshake(){const e=s._[0];e||i("handshake needs a route",2),p(await fe(e))},async leave(){const e=s._[0];e||i("leave needs a route",2),await _(async()=>{const t=k(),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 p({error:"owned",route:e,owner:n.owner}),new I("",3);delete t.sites[e],await O(t),p({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 Q(e,{repo:s.repo,model:s.model,prompt:s.prompt});p({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 E();p(await P(()=>t(e,{manifest:k()})))},async close(){const{closeBoard:e}=await import("../hub/close-board.mjs");try{p(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{p(await P(()=>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(k().sites,e)||i("no site at /"+e);L(n)||i(`/${e} is not a board; export moves a board`,2);const r=w.realpathSync(n.dir),{itemSources:d,openBoardBuilders:a}=await import("../board/store.mjs"),o=(await d(r)).find(y=>u.relative(r,y.file).startsWith(".."));o&&i(`/${e}'s cards live outside its folder (${o.file}); export moves only a board whose board.json items is a file in its folder`);const m=await a(r);m.length&&i(`a builder is open on /${e}: ${m.map(y=>`${y.key} (${y.label})`).join(", ")}; export once it is done`);const{readSettingsFile:l}=await import("../hub/push.mjs"),c=B(n,ee),b={kickflip_export:1,route:e,exported_at:new Date().toISOString(),from:D.hostname(),entry:c,owner:B(n.owner||{},["label","model"]),settings:B(l(),Se),dropped:Object.keys(n).filter(y=>!ee.includes(y))},f=w.mkdtempSync(u.join(D.tmpdir(),"kickflip-export-"));try{const y=u.join(f,R),$=u.join(r,"data");w.cpSync(r,u.join(y,"site"),{recursive:!0,filter:h(v=>!(u.dirname(v)===$&&qe.test(u.basename(v))),"filter")}),w.writeFileSync(u.join(y,"export.json"),JSON.stringify(b,null,2)+`
|
|
176
|
+
`),w.writeFileSync(u.join(y,"README.md"),Me(b,u.basename(t))),je(["-czf",t,"-C",f,R])}finally{w.rmSync(f,{recursive:!0,force:!0})}p({route:e,file:t,entry:Object.keys(c),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(x,{recursive:!0});const t=w.mkdtempSync(u.join(x,".import-"));try{je(["-xzf",e,"-C",t]);const n=ue(u.join(t,R,"export.json"));(n?.kickflip_export!==1||!C(n.route)||!pe(u.join(t,R,"site")))&&i(`${e} is not a kickflip export`,2);const{route:r}=n,d=u.join(x,"sites",r),a=await _(async()=>{const c=k();(g(c.sites,r)||g(c.closed,r)||g(c.starting,r))&&i(`/${r} already exists on this host; import never replaces a board`),w.existsSync(d)&&i(`${d} already exists; import never replaces a board's folder`);const b=B(n.entry||{},ee);b.hub&&Object.values(c.sites).some(y=>y?.hub)&&delete b.hub;const f={...b,dir:d,port:await H(c),cmd:[K(),u.join(j,"board","server.mjs"),d],updated:new Date().toISOString()};return w.mkdirSync(u.dirname(d),{recursive:!0}),w.renameSync(u.join(t,R,"site"),d),c.sites={...c.sites,[r]:f},await O(c),f}),o=B(n.settings||{},Se);if(Object.keys(o).length){const{readSettingsFile:c,writeSettingsFile:b}=await import("../hub/push.mjs");b({...c(),...o})}const{label:m,model:l}=n.owner||{};p({route:r,dir:d,port:a.port,settings:Object.keys(o),hub:a.hub===!0,join:`kickflip join --name ${q(_e(r,a.title))} --session <this session's id> --watch --template board${m?` --label ${q(m)}`:""}${l?` --model ${q(l)}`:""} --force`})}finally{w.rmSync(t,{recursive:!0,force:!0})}},async sessions(){const{sessionOf:e}=await E(),{listBoards:t}=await import(u.join(j,"hub","boards.mjs")),n=k(),r=re(),a=[...t(n).map(o=>o.route),...Object.keys(n.starting||{}).filter(o=>!g(n.sites,o))].map(o=>{const m=e(n,o),l=m&&r.get(m.session);return{route:o,session:m?.session||null,live:l?l.kind==="bg"?"background":"terminal":null,repo:m?.repo||null,starting:!g(n.sites,o)}});if(s.json)return p(a);if(!a.length)return p("no boards");for(const o of a)p(`/${o.route} ${o.session||"no session"} ${o.live?`live (${o.live})`:"not live"} ${o.repo||"no folder"}${o.starting?" (starting: not joined yet)":""}`)},async hub(){await z(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),W(),de(),await _(async()=>{const t=k(),n=g(t.sites,e)||i("no site at /"+e);Y(n),X(t,e,n),n.updated=new Date().toISOString(),await O(t),p({route:e,icon:n.icon??null,color:n.color??null,hub:n.hub===!0})})},async restart(){const e=s._[0];await _(async()=>{const t=k();g(t.sites,e)||i("no site at /"+e),t.sites[e].restart_at=Date.now(),await O(t)}),p(`restarting /${e}; the hub picks it up within 2 seconds`)},async logs(){const e=s._[0],t=u.join(ce,e+".log");w.existsSync(t)||i("no log yet for /"+e);const n=Number(s.lines||40);p(w.readFileSync(t,"utf8").split(`
|
|
177
|
+
`).slice(-n-1).join(`
|
|
178
|
+
`))},async init(){s.fix=!0,await te.doctor()},async update(){w.existsSync(u.join(j,".git"))&&i(`${j} is a clone; update it with git pull`,2);const e=M("npm",["i","-g","@lovek4d/kickflip@latest"],{stdio:"inherit"});e.status!==0&&i(`npm update failed${e.error?": "+e.error.message:""}`);const t=ae(),n=t.restart();n&&i(`update finished but the hub did not restart: ${n}; run ${t.restartCommand}`),p("updated kickflip and restarted the hub")},async uninstall(){Te()&&p(`removed ${u.join(D.homedir(),".claude","statusline.sh")}`);const e=ae();e.remove();try{oe("tailscale",["serve","--https=443","--set-path=/","off"],{stdio:"ignore"})}catch{}p(`hub stopped and removed from ${e.manager??"the host"}; tailscale / unmapped. The manifest and sites are kept in ${x}`)},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:r,holdLine:d}=await import(u.join(j,"hub","schedule.mjs"));s.now&&s.urgent&&i("pass --now or --urgent, not both",2);const a=await e({title:s.title,body:s.body||"",url:s.url||"/",tag:s.tag},{kind:s.kind,urgent:!!s.urgent,immediate:!!s.now});if(a.noDevice&&i("no device has turned on notifications; open Hub \u2192 Notifications (/_hub/#notifications) in the Home Screen app and tap Turn on",3),a.dropped)return p("dropped (notifications are off on the Hub page)");if(a.queued){const{count:o,replaced:m,nextFlushAt:l,hold:c,sendFailed:b}=a.queued,f=s.now?c?`${d(c)}; `:b?"no device took it now; ":"":"";p(`queued (${f}${o} in queue${m?"; replaced the queued push with this tag":""}); next send ${r(l)}${l instanceof Date?` (${l.toISOString()})`:""}`),await J()||p("warning: the hub is not running, so the queue goes out only once it runs");return}p(a.sent),a.sent.some(o=>o.status>=200&&o.status<300)||i("every push was refused",1),p(s.urgent?"sent (urgent)":"sent")},async polling(){const{readSettings:e}=await import(u.join(j,"hub","push.mjs")),{windowAt:t,nextSlot:n,hold:r}=await import(u.join(j,"hub","schedule.mjs")),d=new Date,a=e(),o=t(d,a),m=r(d,a);p({every:o.every_minutes,until:o.endsAt.toISOString(),next:n(d,a).toISOString(),held:m!==null,held_until:m?m.until instanceof Date?m.until.toISOString():m.until:null,held_why:m?.why??null,notifications:a.notifications})},async notifications(){const{setNotifications:e,readSettings:t}=await import(u.join(j,"hub","push.mjs")),[n,r]=s._,a=n===void 0?null:n==="on"||n==="off"?{on:n==="on"}:n==="weekends"?{weekends_off:h((m,l)=>m==="on"?!0:m==="off"?!1:i(`${l} takes on or off`,2),"onOff")(r,"weekends")}:n==="snooze"?{snooze:r||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(!a)return p(t().notifications);let o;try{o=await e(a)}catch(m){throw m.status===400&&i(m.message,2),m}p(o.dropped?{...o.notifications,dropped:o.dropped}:o.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 p(t());try{p(n(S[0]))}catch(r){throw r.status===400&&i(r.message,2),r.status===409&&i(r.message),r}},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)),p(e())}catch(r){throw r.status&&i(r.message,r.status===400?2:1),r}},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)}`),p(await e.json())}};if(!te[U]){const e=w.readFileSync(xe(import.meta.url),"utf8").split(`
|
|
179
|
+
`).slice(1);p(e.slice(0,e.findIndex(t=>!t.startsWith("//"))).map(t=>t.replace(/^\/\/ ?/,"")).join(`
|
|
180
|
+
`)),process.exit(U?2:0)}try{await te[U]()}catch(e){if(!(e instanceof I))throw e;e.message&&console.error("kickflip: "+e.message),process.exit(e.code)}
|
package/bin/statusline.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var d=Object.defineProperty;var s=(e,t)=>d(e,"name",{value:t,configurable:!0});import
|
|
3
|
-
`,{mode:384}),
|
|
4
|
-
`,()
|
|
2
|
+
var d=Object.defineProperty;var s=(e,t)=>d(e,"name",{value:t,configurable:!0});import o from"node:fs";import m from"node:os";import f from"node:path";import{execFileSync as h}from"node:child_process";process.stdout.on("error",()=>{});function _(e){if(!e)return"";const t=s((...r)=>h("git",["-C",e,...r],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,env:{...process.env,GIT_OPTIONAL_LOCKS:"0"}}).trim(),"git");try{if(t("rev-parse","--is-inside-work-tree")!=="true")return"";const r=t("symbolic-ref","--short","HEAD");try{t("diff","--quiet"),t("diff","--cached","--quiet")}catch{return r+"*"}return r}catch{return""}}s(_,"branchOf");function g(e){if(!e)return"";const t=m.homedir(),r=e===t?"~":e.startsWith(t+"/")?"~"+e.slice(t.length):e,n=r.split("/");return n.length>2?n.slice(-2).join("/"):r}s(g,"shortDir");function S(e){if(e==null||e==="")return null;const t=typeof e=="number"||/^\d+(\.\d+)?$/.test(String(e)),r=Number(e),n=t?r>1e12?r:r*1e3:Date.parse(String(e));return Number.isFinite(n)&&Number.isFinite(new Date(n).getTime())?new Date(n).toISOString():null}s(S,"isoOf");function y(e){if(!e||typeof e!="object")return null;const t=e.used_percentage;return{used_percentage:t==null||t===""||!Number.isFinite(Number(t))?null:Number(t),resets_at:S(e.resets_at),resets_at_raw:e.resets_at??null}}s(y,"windowOf");function b(e){const t=e.rate_limits;if(!t||typeof t!="object"||Array.isArray(t))return;const r=f.join(m.homedir(),".claude","kickflip","usage.json");let n={};try{const u=JSON.parse(o.readFileSync(r,"utf8"));u&&typeof u=="object"&&!Array.isArray(u)&&(n=u)}catch{}const a={five_hour:y(t.five_hour),seven_day:y(t.seven_day),at:new Date().toISOString(),...e.session_id?{session:e.session_id}:{}};o.mkdirSync(f.dirname(r),{recursive:!0});const c=`${r}.${process.pid}.tmp`;try{o.writeFileSync(c,JSON.stringify({...n,claude:a},null,2)+`
|
|
3
|
+
`,{mode:384}),o.renameSync(c,r)}finally{try{o.unlinkSync(c)}catch{}}}s(b,"saveUsage");function N(e,t){const r=e.session_id;if(t==null||typeof r!="string"||!/^[\w-]+$/.test(r))return;const n=f.join(m.homedir(),".claude","kickflip","context"),a=f.join(n,`${r}.json`);o.mkdirSync(n,{recursive:!0});const c=`${a}.${process.pid}.tmp`;try{o.writeFileSync(c,JSON.stringify({percent:t,at:new Date().toISOString()})+`
|
|
4
|
+
`,{mode:384}),o.renameSync(c,a)}finally{try{o.unlinkSync(c)}catch{}}}s(N,"saveContext");try{const e=JSON.parse(o.readFileSync(0,"utf8"));if(e&&typeof e=="object"&&!Array.isArray(e)){const t=typeof e.cwd=="string"?e.cwd:"",r=typeof e.model?.display_name=="string"?e.model.display_name:"",n=s(i=>i==null||i===""||!Number.isFinite(Number(i))?null:Math.floor(Number(i)),"percent"),a=n(e.context_window?.used_percentage),c=[["5h",e.rate_limits?.five_hour],["7d",e.rate_limits?.seven_day]].map(([i,l])=>[i,n(l?.used_percentage)]).filter(([,i])=>i!=null).map(([i,l])=>`${i}: ${l}%`).join(" / "),u=s((i,l)=>i.filter(Boolean).join(l),"join"),p=u([u([g(t),_(t)]," "),u([r,a==null?"":`${a}% ctx`]," / "),c]," \xB7 ");process.stdout.write(p+`
|
|
5
|
+
`,()=>{try{b(e)}catch{}try{N(e,a)}catch{}})}}catch{}process.exitCode=0;
|
package/bin/wait-events.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`).filter(Boolean)}catch{}
|
|
2
|
+
var A=Object.defineProperty;var o=(e,r)=>A(e,"name",{value:r,configurable:!0});import c from"node:fs";import f from"node:path";import I from"node:os";import{routeRecord as g}from"../hub/routes.mjs";import{readHubRules as L,rulesOf as R,ruleLines as q}from"../hub/rules.mjs";import{boardAt as D,linksOf as H,hubLink as U}from"../hub/boards.mjs";import{ackHello as _,cardName as G,markWorking as P,settingsLines as W,settingsOf as K,WORKING_KINDS as Q}from"../board/store.mjs";import{readUsageGate as F,heldUsageEvent as B}from"../shared/usage-gate.mjs";const[J,$]=process.argv.slice(2);(!J||!$)&&(console.error("usage: wait-events.mjs <route> <session-id>"),process.exit(2));const C=f.join(I.homedir(),".claude","kickflip","manifest.json");function x(){try{return g(JSON.parse(c.readFileSync(C,"utf8")).sites,J)||null}catch{return}}o(x,"site");function O(e){const r=e.filter?new RegExp(e.filter):null,n=Object.create(null);for(const d of e.watch||["data/events.jsonl"]){let s=[];try{s=c.readFileSync(f.resolve(e.dir,d),"utf8").split(`
|
|
3
|
+
`).filter(Boolean)}catch{}n[d]=r?s.filter(i=>r.test(i)):s}return n}o(O,"matching");const M=`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: name cards by label (#96), never "below", "above", "here" or "this session".`,E={ask:o(e=>`new task ${e.id} received`,"ask"),"owner-answer":o(e=>`answer received to question ${e.data?.id}`,"owner-answer"),hello:o(e=>`hello ${e.id} from the hub answered`,"hello"),"todo-triage":o(e=>`Todo triage ${e.data?.date} asked: the board was idle`,"todo-triage")},T={"item-message":o(e=>`message received from ${e}'s thread`,"item-message"),"card-build":o(e=>`build started on ${e}`,"card-build"),"card-merge":o(e=>`merge asked on ${e}`,"card-merge"),"card-done":o(e=>`${e} marked done`,"card-done"),"card-bump":o(e=>`${e} bumped`,"card-bump"),"ask-bump":o(e=>`${e} bumped`,"ask-bump"),"ask-edited":o(e=>`${e} edited`,"ask-edited"),"ask-done":o(e=>`${e} marked done`,"ask-done"),"ask-withdrawn":o(e=>`${e} deleted`,"ask-withdrawn"),"card-hold":o((e,r)=>`${e} ${r.data?.hold?"held":"resumed"}`,"card-hold"),"card-unblocked":o(e=>`${e} unblocked`,"card-unblocked"),"card-pull":o(e=>`${e} pulled in`,"card-pull"),"card-plan":o(e=>`plan asked on ${e}`,"card-plan"),"prototype-request":o(e=>`prototype asked on ${e}`,"prototype-request")};async function z(e,r){let n;try{n=JSON.parse(r)}catch{return null}if(typeof n?.kind!="string")return null;const d=typeof n.data?.key=="string"?n.data.key:n.kind.startsWith("ask-")&&typeof n.data?.id=="string"?`ask:${n.data.id}`:null,s=d&&await G(e,d).catch(()=>d);return g(E,n.kind)?E[n.kind](n):s&&g(T,n.kind)?T[n.kind](s,n):s?`${n.kind} on ${s}`:`${n.kind} received`}o(z,"plainLine");const y=x();y||(console.log("site-removed"),process.exit(0));const h=f.resolve(y.dir,"data",`.watch-cursor-${$}.json`),S=f.resolve(y.dir,"data","watcher.json");try{c.mkdirSync(f.dirname(h),{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 m;try{m=JSON.parse(c.readFileSync(h,"utf8"))}catch{}for(m||(m=Object.fromEntries(Object.entries(O(y)).map(([e,r])=>[e,r.length])),c.mkdirSync(f.dirname(h),{recursive:!0}),c.writeFileSync(h,JSON.stringify(m)));;){await new Promise(s=>setTimeout(s,2e3));const e=x();if(e===void 0)continue;e===null&&(console.log("site-removed"),process.exit(0)),e.owner?.session&&e.owner.session!==$&&(console.log("handed-over "+JSON.stringify(e.owner)),process.exit(0));const r=o(s=>Object.fromEntries(Object.entries(s).map(([i,k])=>[i,[...g(m.$usageHeld,i)||[],...k.slice(g(m,i)||0)]])),"pending"),n=o((s,i)=>i.state!=="paused"||!B(s),"eligible"),d=F();if(Object.values(r(O(e))).some(s=>s.some(i=>n(i,d)))){await new Promise(t=>setTimeout(t,2e3));const s=O(e),i=F(),k=r(s);if(!Object.values(k).some(t=>t.some(a=>n(a,i))))continue;const b=Object.create(null),v=[],j=[];for(const[t,a]of Object.entries(k)){b[t]=a.filter(p=>!n(p,i));for(const p of a.filter(w=>n(w,i))){console.log(`event ${t} ${p}`);const w=await z(e.dir,p);w&&console.log(w);try{const u=JSON.parse(p);Q.includes(u.kind)&&typeof u.id=="string"&&v.push(u.id),u.kind==="hello"&&typeof u.id=="string"&&j.push(u.id)}catch{}}}let l=null;try{l=JSON.parse(c.readFileSync(f.resolve(e.dir,"board.json"),"utf8"))}catch(t){t.code!=="ENOENT"&&(l={})}if(l&&await P(e.dir,v).catch(t=>console.log(`working marks not written (${t.message})`)),l)for(const t of j)await _(e.dir,t).catch(a=>console.log(`hello ${t} not answered (${a.message})`));if(l)for(const t of q(L(),R(l)))console.log(`rule ${t}`);if(l)for(const t of W(K(l)))console.log(t);l&&console.log(M),i.state==="paused"&&console.log(`usage paused ${i.resets_at} ${i.window} ${i.used}%`);try{const t=l&&D(e.dir);if(t)for(const a of[...H(t,{listen:"listening"}),U()])a.ok||console.log(`link ${a.link} ${a.detail}`)}catch(t){console.log(`link registry could not check the links (${t.message})`)}const N=Object.fromEntries(Object.entries(s).map(([t,a])=>[t,a.length]));Object.values(b).some(t=>t.length)&&(N.$usageHeld=b),c.writeFileSync(h,JSON.stringify(N)),process.exit(0)}}
|
|
@@ -0,0 +1,5 @@
|
|
|
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}`,cards: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
|
+
`),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
|
+
|
|
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};
|