@promptctl/cc-candybar 1.184.0 → 1.184.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/dist/index.mjs +2 -2
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire as e}from"node:module";import t from"node:process";import{URL as n,URLSearchParams as r,fileURLToPath as i}from"node:url";import{json as a}from"node:stream/consumers";import o from"node:os";import s,{closeSync as c,constants as l,existsSync as u,fstatSync as d,linkSync as f,mkdtempSync as p,openSync as m,readFileSync as h,readSync as g,rmSync as _,statSync as v,writeFileSync as y}from"node:fs";import{StringDecoder as b}from"node:string_decoder";import{inspect as x,parseArgs as S,types as C}from"node:util";import{clearImmediate as w,setImmediate as T}from"node:timers";import{spawn as ee,spawnSync as te}from"node:child_process";import E,{basename as ne,dirname as D,isAbsolute as O,join as re,sep as k}from"node:path";import ie,{createHash as ae,createHmac as oe,randomBytes as se,randomUUID as ce,timingSafeEqual as le}from"node:crypto";import ue from"node:net";import de from"node:v8";import{open as fe,readFile as pe,readdir as me,stat as he}from"node:fs/promises";import{get as ge}from"node:https";import{WriteStream as _e}from"node:tty";import{createInterface as ve}from"node:readline";var ye=Object.create,be=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyNames,Ce=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty,Te=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Se(t),a=0,o=i.length,s;a<o;a++)s=i[a],!we.call(e,s)&&s!==n&&be(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=xe(t,s))||r.enumerable});return e},De=(e,t,n)=>(n=e==null?{}:ye(Ce(e)),Ee(t||!e||!e.__esModule?be(n,`default`,{value:e,enumerable:!0}):n,e));let Oe=!1;const ke=()=>Oe;function Ae(e){Oe=e}function je(e){return ke()?`[DEBUG] ${e()}\n`:``}function A(e,...t){ke()&&console.error(`[DEBUG] ${e}`,...t)}function Me(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const Ne=(e,t)=>A(t);function Pe(e,t){return Math.round(t-e)}function Fe(e,t){return Pe(t,e.monotonic())}const Ie={now:()=>Date.now(),monotonic:()=>performance.now(),after:(e,t,n)=>{let r=setTimeout(t,e);return n?.unref&&r.unref(),()=>clearTimeout(r)},every:(e,t,n)=>{let r=setInterval(t,e);return n?.unref&&r.unref(),()=>clearInterval(r)},defer:e=>{let t=T(e);return()=>w(t)}};function Le(e,t,n){return new Promise((r,i)=>{let a=()=>Object.assign(Error(`The operation was aborted`),{name:`AbortError`,code:`ABORT_ERR`,cause:n?.reason});if(n?.aborted){i(a());return}let o=()=>{s(),i(a())},s=e.after(t,()=>{n?.removeEventListener(`abort`,o),r()});n?.addEventListener(`abort`,o,{once:!0})})}function Re(e,t){let n=new AbortController;return e.after(t,()=>n.abort(new DOMException(`The operation was aborted due to timeout`,`TimeoutError`)),{unref:!0}),n.signal}function ze(e,t,n,r){return n<e.at+t?`held`:r===`request`&&!e.answered?`owed`:`over`}function Be(e,t){return!e.answered&&e.at===t.at&&e.text===t.text}const Ve=e=>e.getTime()/1e3,He=e=>new Date(e*1e3);function Ue(e,t){return C.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!u(t)?`working directory does not exist: ${t}`:e.message:String(e)}const We={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3};function Ge(e,t,n){let r=We[t];if(r===void 0)return{allowed:!0};let i=e.get(t);if(i===void 0)return{allowed:!0};let a=n-i;return a>=r?{allowed:!0}:{allowed:!1,minIntervalMs:r,sinceLastMs:a}}function Ke(e,t){return{...e.inherited,...t.envOverlay}}const qe=({reason:e})=>({ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)});function Je(e,t,n){return{ok:!1,reason:`rate-limited`,stdout:``,stderr:``,exitCode:null,signal:null,error:`rate-limited: ${e} min interval ${t}ms, last start ${Math.round(n)}ms ago`}}function Ye(e,t){let n=t.finally(()=>e.ending.delete(n));return e.ending.add(n),n}function Xe(e,t,n){let r=Ze(e,t,n);return r===null?(e.lastStartAt.set(t,e.scope.clock.monotonic()),null):(e.scope.stats?.onRefused(t),r)}function Ze(e,t,n){if(e.scope.signal.aborted)return qe(e.scope.signal);if(n?.aborted)return qe(n);let r=Ge(e.lastStartAt,t,e.scope.clock.monotonic());return r.allowed?null:Je(t,r.minIntervalMs,r.sinceLastMs)}const Qe=`\$1 == "+" { live[\$2] = 1; next } \$1 == "-" { delete live[\$2]; next } END { for (g in live) groups = groups " -" g; if (groups != "") system("kill -TERM" groups " 2>/dev/null; sleep ${250/1e3}; kill -KILL" groups " 2>/dev/null") }`;function $e(e,t){t!==e.fault&&(e.fault=t,e.scope.observeWarnings({kind:`lifeline`,fault:t}))}function et(e,t,n){e.lifeline?.process===t&&(e.lifeline=null,t.ref(),$e(e,n))}const tt=e=>`programs launched now would outlive their launcher if it died: its launch lifeline ${e}, and the next launch starts another`,nt=e=>e===`cut`?`output cut at the ${dt}-byte bound, so the program holding it now fails its writes`:`output failed to read`,rt=`a launched program's pipe outlived its launch: `;function it(e,t,n){let r=e.pipeEvent,i=new Map(r===null||r.answered?[]:r.counts),a=`${t}\0${n}`;i.set(a,(i.get(a)??0)+1),e.pipeEvent={text:`${rt}${[...i].map(([e,t])=>{let[n,r]=e.split(`\0`);return`${t}× ${r} ${nt(n)}`}).join(`; `)}`,at:e.scope.now(),answered:!1,counts:i},e.scope.observeWarnings({kind:`launch-pipes`,text:`${rt}${n} ${nt(t)}`})}function at(e,t){let n=e.pipeEvent;n===null||!Be(n,t)||(e.pipeEvent={...n,answered:!0})}function ot(e,t,n){let r=e.pipeEvent,i=r===null?`over`:ze(r,60,t,n);return[...e.fault===null?[]:[{kind:`lifeline`,message:tt(e.fault)}],...r===null||i===`over`?[]:[{kind:`launch-pipes`,message:r.text,event:r,hold:i}]]}function st(e){let{stats:t,clock:n}=e.scope;t?.onStart(`lifeline`);let r=n.monotonic(),i;try{i=e.spawner.spawn(`awk`,[Qe],{stdio:[`pipe`,`ignore`,`ignore`],detached:!0})}catch(i){return t?.onEnd(`lifeline`,Fe(n,r)),$e(e,`did not start: ${Ue(i,void 0)}`),null}t?.onEnd(`lifeline`,Fe(n,r));let a=i.stdin;if(a==null)return i.once(`error`,t=>$e(e,`did not start: ${t.message}`)),null;i.once(`spawn`,()=>{e.lifeline?.process===i&&$e(e,null)}),i.once(`error`,t=>et(e,i,`failed: ${t.message}`)),i.once(`exit`,(t,n)=>et(e,i,`exited ${n??t}`)),a.on(`error`,t=>et(e,i,`pipe failed: ${t.message}`)),Ye(e,new Promise(e=>i.once(`close`,e))),i.unref(),a.unref();for(let t of e.liveGroups)a.write(`+ ${t}\n`);return{process:i,pipe:a}}function ct(e,t){e.liveGroups.add(t),e.lifeline??=st(e),e.lifeline?.pipe.write(`+ ${t}\n`)}function lt(e,t){e.liveGroups.delete(t),e.lifeline?.pipe.write(`- ${t}\n`)}function ut(e){let t=e.lifeline;e.lifeline=null,t?.process.ref(),t?.pipe.end()}const dt=16*1024*1024,ft=`output exceeded ${dt} bytes`;function pt(e,t,n,r){let{stats:i}=e.scope,a=new b(`utf8`),o=``,s=0,c=0,l=r,u=`closed`;return n?.on(`error`,n=>{i?.onPipeError(t),l===null?it(e,`read-error`,t):l.failed(n)}),n?.on(`data`,r=>{if(l===null){if(c+=r.length,i?.onDrainRead(t,r.length),c<=16777216)return;u=`cut`,n.destroy(),it(e,`cut`,t);return}let d=Math.max(0,dt-s);o+=a.write(r.subarray(0,d)),s+=r.length,s>16777216&&l.full()}),{take:()=>{if(l===null)return``;l=null;let e=o+a.end();return o=``,e},drain:()=>{n===null||n.destroyed||n.readableEnded||mt(e,t,n,()=>u)}}}function mt(e,t,n,r){let{stats:i}=e.scope;if(e.scope.signal.aborted){n.destroy();return}n.once(`close`,()=>{e.drains.delete(n),i?.onDrainClose(t,r())}),n.unref(),e.drains.add(n),i?.onDrainOpen(t)}const ht=()=>`closed`;function gt(e,t){e.on(`error`,()=>{}),e.end(t)}async function _t(e,t){let{stats:n,clock:r}=e.scope,i=Xe(e,t.category,t.signal);if(i!==null)return i;let a=r.monotonic();return n?.onStart(t.category),new Promise(i=>{let{spawner:o}=e,s;try{s=o.spawn(t.bin,t.args??[],{cwd:t.cwd,env:Ke(e.scope,t),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(e){n?.onEnd(t.category,Fe(r,a)),i({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:Ue(e,t.cwd)});return}let c=s.pid;c!==void 0&&ct(e,c);let l=new Promise(e=>s.once(`exit`,e)),u=s.stdin;s.stdin=null;let d=null,f={full:()=>te(`output-limit`),failed:e=>{d??=e.message,te(`pipe-error`)}},p=pt(e,t.category,s.stdout,f),m=pt(e,t.category,s.stderr,f),h=()=>({stdout:p.take(),stderr:m.take()}),g=!1,_=null,v=null,y=null,b=null,x=()=>te(`aborted`),S=()=>{t.signal?.removeEventListener(`abort`,x),e.inFlight.delete(x)},C=i=>{g||(g=!0,_?.(),v?.(),y?.(),S(),c!==void 0&<(e,c),n?.onEnd(t.category,Fe(r,a)),s.off(`close`,ne),s.off(`error`,E),p.drain(),m.drain(),u!==null&&!u.destroyed&&!u.writableFinished&&mt(e,t.category,u,ht),i())},w=e=>C(()=>i(e)),T=(n,r)=>{try{o.signalGroup(n,r)}catch(n){e.unreaped.set(s,t.category),l.then(()=>e.unreaped.delete(s)),w({ok:!1,reason:`signal-refused`,...h(),exitCode:null,signal:null,error:n instanceof Error?n.message:String(n)})}},ee=()=>ne(s.exitCode,s.signalCode);if(c!==void 0){let e=t=>{if(!g){if(o.groupGone(c)){r.defer(ee);return}y=r.after(t,()=>e(Math.min(t*2,1e3)))}};l.then(()=>r.defer(()=>e(25)))}let te=e=>{if(b!==null)return;if((s.exitCode!==null||s.signalCode!==null)&&c!==void 0&&o.groupGone(c)){b=e===`timeout`?null:e,r.defer(ee);return}b=e,_?.(),S();let t=s.pid;t!==void 0&&(v=r.after(250,()=>{T(t,`SIGKILL`),l.then(()=>r.defer(ee))}),T(t,`SIGTERM`))},E=e=>{w({ok:!1,reason:`spawn-error`,...h(),exitCode:null,signal:null,error:Ue(e,t.cwd)})};s.on(`error`,E);let ne=(e,t)=>{if(b!==null){w({ok:!1,reason:b,...h(),exitCode:e,signal:t,...b===`output-limit`?{error:ft}:b===`pipe-error`?{error:`a pipe failed to read: ${d}`}:{}});return}if(e===0){w({ok:!0,...h(),exitCode:e});return}w({ok:!1,reason:t?`signal`:`non-zero`,...h(),exitCode:e,signal:t})};s.on(`close`,ne),t.timeoutMs&&t.timeoutMs>0&&(_=r.after(t.timeoutMs,()=>te(`timeout`))),t.signal?.addEventListener(`abort`,x,{once:!0}),e.inFlight.add(x),u!==null&>(u,t.stdinInput)})}function vt(e,t){let{stats:n,clock:r}=e.scope,i=Xe(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);try{let i=e.spawner.spawnSync(t.bin,t.args??[],{cwd:t.cwd,env:Ke(e.scope,t),input:t.stdinInput,timeout:t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:void 0,stdio:[`pipe`,`pipe`,`pipe`],encoding:`utf8`});n?.onEnd(t.category,Fe(r,a));let o=typeof i.stdout==`string`?i.stdout:``,s=typeof i.stderr==`string`?i.stderr:``,c=i.error?.code;return i.error&&c!==`EPIPE`&&c!==`ECONNRESET`?{ok:!1,reason:c===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:o,stderr:s,exitCode:null,signal:i.signal??null,error:Ue(i.error,t.cwd)}:i.status===0?{ok:!0,stdout:o,stderr:s,exitCode:i.status}:{ok:!1,reason:i.signal?`signal`:`non-zero`,stdout:o,stderr:s,exitCode:i.status,signal:i.signal??null}}catch(e){return n?.onEnd(t.category,Fe(r,a)),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:Ue(e,t.cwd)}}}function yt(e,t){let{stats:n,clock:r}=e.scope,i=Xe(e,t.category);if(i!==null)return i;let a=r.monotonic();n?.onStart(t.category);let o=bt(e,t);return n?.onEnd(t.category,Fe(r,a)),o}function bt(e,t){let n;try{n=e.spawner.spawn(t.bin,t.args??[],{cwd:t.cwd,env:Ke(e.scope,t),detached:!0,stdio:`ignore`})}catch(e){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:Ue(e,t.cwd)}}return n.once(`error`,()=>{}),n.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${t.bin}): no pid (binary not found or unexecutable)`}:(n.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}const xt=e=>e.kind===`exit`?`exit ${e.code}`:`timeout`;function St(e,t,n){let{stats:r,clock:i}=e.scope,a=Xe(e,t.category);if(a!==null)return{ok:!1,reason:a.reason,error:a.error};let o=i.monotonic();r?.onStart(t.category);let s;try{s=e.spawner.spawn(`/bin/sh`,[`-c`,`out=$1 err=$2 status=$3; shift 3; read go || exit 0; "$@" >"$out" 2>"$err" </dev/null; echo "exit $?" >"$status.$$" && ln "$status.$$" "$status"; rm -f "$status.$$"`,`sh`,n.stdout,n.stderr,n.status,t.bin,...t.args??[]],{cwd:t.cwd,env:Ke(e.scope,t),detached:!0,stdio:[`pipe`,`ignore`,`ignore`]})}catch(e){return r?.onEnd(t.category,Fe(i,o)),{ok:!1,reason:`spawn-error`,error:Ue(e,t.cwd)}}r?.onEnd(t.category,Fe(i,o)),s.once(`error`,()=>{});let c=s.pid,l=s.stdin;return l.on(`error`,()=>{}),c===void 0?(l.destroy(),{ok:!1,reason:`spawn-error`,error:`spawn(/bin/sh): no pid (shell not found or unexecutable)`}):(s.unref(),l.unref(),{ok:!0,pid:c,release:()=>l.end(`go
|
|
3
|
-
`),withdraw:()=>l.end()})}function Ct(e){let t;try{t=h(e,`utf8`).trim()}catch(e){if(e.code===`ENOENT`)return null;throw e}let n=/^exit (\d+)$/.exec(t);if(n)return{kind:`exit`,code:Number(n[1])};if(t===`timeout`)return{kind:`timeout`};throw Error(`${e}: not a job verdict: ${JSON.stringify(t)}`)}function wt(e,t,n,r,i){let a=`${r}.${process.pid}`;try{y(a,`${xt(i)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let o=!0;try{f(a,r)}catch(e){if(e.code!==`EEXIST`)throw e;o=!1}finally{_(a,{force:!0})}let s=e.signalJob(n,`SIGTERM`);return s&&t.after(250,()=>e.signalJob(n,`SIGKILL`),{unref:!0}),{stands:o,signalled:s}}function Tt(e,t,n){return Dt(e,t,n).launcher}function Et(e,t,n){let{launcher:r,state:i}=Dt(e,t,n);return{...r,launchSync:e=>vt(i,e)}}function Dt(e,t,n){let r={clock:t,launch:e=>Ye(i,_t(i,e)),launchDetachedSync:e=>yt(i,e),launchJobSync:(e,t)=>St(i,e,t),jobGroupAlive:e=>n.signalJob(e,0),endJob:(e,r,i)=>wt(n,t,e,r,i),launcherWarnings:(e,t)=>ot(i,e,t),answeredPipeEvent:e=>at(i,e),settled:async()=>(await Promise.all(i.ending),{unreaped:[...i.unreaped.values()]}),__lifelineForTest:()=>{let e=i.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&et(i,e.process,`cut by a test`)}}}},i={spawner:n,scope:{stats:null,observeWarnings:e=>{let t=e.kind===`launch-pipes`?e.text:e.fault===null?null:tt(e.fault);t!==null&&process.emitWarning(t)},signal:new AbortController().signal,now:()=>Ve(new Date(t.now())),...e,clock:t},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,pipeEvent:null,ending:new Set,unreaped:new Map,drains:new Set};return i.scope.signal.addEventListener(`abort`,()=>{i.inFlight.forEach(e=>e()),i.drains.forEach(e=>e.destroy()),ut(i)},{once:!0}),{launcher:r,state:i}}function Ot(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}const kt={spawn:(e,t,n)=>ee(e,t,n),spawnSync:(e,t,n)=>te(e,t,n),signalGroup:(e,t)=>{try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!Ot(e)))throw t}},groupGone:e=>{try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}},signalJob:(e,t)=>{try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}},At=(e,t)=>Tt(e,t,kt),jt=(e,t)=>Et(e,t,kt);function Mt(){let e={env:process.env,home:o.homedir(),tmp:o.tmpdir()},t=Ie;return{host:e,launcher:jt({inherited:process.env},t),clock:t}}const Nt=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Pt(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Ft(e){return Nt.test(e)?e:Pt(e)}function It(e){return`${e.dir===void 0?``:`cd ${Ft(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${Ft(t)} `).join(``)}${[e.program,...e.args].map(Ft).join(` `)}`}const Lt=`cc-extra`;function Rt(e){return E.join(E.dirname(e),Lt,`src`,`bun-attach.js`)}function zt(e){return E.join(E.dirname(e),`bun-graph.js`)}const Bt=`attach-preload.cjs`;function Vt(e){return E.join(E.dirname(e),Bt)}function Ht(e,t){return It({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const Ut=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function j(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function Wt(e,t,n=Ut){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=E.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Wt(e,r):[[E.relative(e,r).split(E.sep).join(`/`),j(r,i)]]})}function Gt(e){let t=ie.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Kt(e){return Gt(Wt(e,e))}const qt=[`Cargo.toml`,`Cargo.lock`,`src`];function Jt(e){return Gt(Wt(e,e,e=>qt.includes(e)))}const Yt=e=>e.slice(0,7),M=`1.184.
|
|
3
|
+
`),withdraw:()=>l.end()})}function Ct(e){let t;try{t=h(e,`utf8`).trim()}catch(e){if(e.code===`ENOENT`)return null;throw e}let n=/^exit (\d+)$/.exec(t);if(n)return{kind:`exit`,code:Number(n[1])};if(t===`timeout`)return{kind:`timeout`};throw Error(`${e}: not a job verdict: ${JSON.stringify(t)}`)}function wt(e,t,n,r,i){let a=`${r}.${process.pid}`;try{y(a,`${xt(i)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let o=!0;try{f(a,r)}catch(e){if(e.code!==`EEXIST`)throw e;o=!1}finally{_(a,{force:!0})}let s=e.signalJob(n,`SIGTERM`);return s&&t.after(250,()=>e.signalJob(n,`SIGKILL`),{unref:!0}),{stands:o,signalled:s}}function Tt(e,t,n){return Dt(e,t,n).launcher}function Et(e,t,n){let{launcher:r,state:i}=Dt(e,t,n);return{...r,launchSync:e=>vt(i,e)}}function Dt(e,t,n){let r={clock:t,launch:e=>Ye(i,_t(i,e)),launchDetachedSync:e=>yt(i,e),launchJobSync:(e,t)=>St(i,e,t),jobGroupAlive:e=>n.signalJob(e,0),endJob:(e,r,i)=>wt(n,t,e,r,i),launcherWarnings:(e,t)=>ot(i,e,t),answeredPipeEvent:e=>at(i,e),settled:async()=>(await Promise.all(i.ending),{unreaped:[...i.unreaped.values()]}),__lifelineForTest:()=>{let e=i.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&et(i,e.process,`cut by a test`)}}}},i={spawner:n,scope:{stats:null,observeWarnings:e=>{let t=e.kind===`launch-pipes`?e.text:e.fault===null?null:tt(e.fault);t!==null&&process.emitWarning(t)},signal:new AbortController().signal,now:()=>Ve(new Date(t.now())),...e,clock:t},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,pipeEvent:null,ending:new Set,unreaped:new Map,drains:new Set};return i.scope.signal.addEventListener(`abort`,()=>{i.inFlight.forEach(e=>e()),i.drains.forEach(e=>e.destroy()),ut(i)},{once:!0}),{launcher:r,state:i}}function Ot(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}const kt={spawn:(e,t,n)=>ee(e,t,n),spawnSync:(e,t,n)=>te(e,t,n),signalGroup:(e,t)=>{try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!Ot(e)))throw t}},groupGone:e=>{try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}},signalJob:(e,t)=>{try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}},At=(e,t)=>Tt(e,t,kt),jt=(e,t)=>Et(e,t,kt);function Mt(){let e={env:process.env,home:o.homedir(),tmp:o.tmpdir()},t=Ie;return{host:e,launcher:jt({inherited:process.env},t),clock:t}}const Nt=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Pt(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Ft(e){return Nt.test(e)?e:Pt(e)}function It(e){return`${e.dir===void 0?``:`cd ${Ft(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${Ft(t)} `).join(``)}${[e.program,...e.args].map(Ft).join(` `)}`}const Lt=`cc-extra`;function Rt(e){return E.join(E.dirname(e),Lt,`src`,`bun-attach.js`)}function zt(e){return E.join(E.dirname(e),`bun-graph.js`)}const Bt=`attach-preload.cjs`;function Vt(e){return E.join(E.dirname(e),Bt)}function Ht(e,t){return It({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const Ut=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function j(e,t){return t.isSymbolicLink()?Buffer.from(s.readlinkSync(e)):s.readFileSync(e)}function Wt(e,t,n=Ut){return s.readdirSync(t).filter(n).sort().flatMap(n=>{let r=E.join(t,n),i=s.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?Wt(e,r):[[E.relative(e,r).split(E.sep).join(`/`),j(r,i)]]})}function Gt(e){let t=ie.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Kt(e){return Gt(Wt(e,e))}const qt=[`Cargo.toml`,`Cargo.lock`,`src`];function Jt(e){return Gt(Wt(e,e,e=>qt.includes(e)))}const Yt=e=>e.slice(0,7),M=`1.184.1`;function Xt(e){let t=E.dirname(E.dirname(e));return s.existsSync(E.join(t,`src`))?t:null}function Zt(e){if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:M,digest:e}}function Qt(){return`07661ead6b531623a912f7db0161abcd5a293bdbfe9c0168b36915d2d9451586`}function $t(e){let t=JSON.parse(s.readFileSync(E.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${E.join(e,`package.json`)} has no version string`);return n}function en(e,t){try{let n=Xt(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Kt(E.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:$t(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function tn(e,t){let n=e[t];return n&&n.length>0?n:void 0}function nn(e){let t=tn(e.env,`XDG_STATE_HOME`)??E.join(e.home,`.local`,`state`);return E.join(t,`cc-candybar`)}function rn(e){let t=tn(e.env,`XDG_CACHE_HOME`)??E.join(e.home,`.cache`);return E.join(t,`cc-candybar`)}function an(e){return nn(e)}function on(e){return e.env.CC_CANDYBAR_SOCKET||sn()}function sn(){let e=o.userInfo().uid;return E.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function cn(e){s.mkdirSync(e,{recursive:!0,mode:448});let t=s.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=o.userInfo().uid;if(typeof n==`number`&&t.uid!==n)throw Error(`directory is not owned by uid ${n}: ${e} (owner uid=${t.uid})`);if(t.mode&63)throw Error(`directory has unsafe permissions: ${e} (mode=${(t.mode&511).toString(8)}, expected 0700)`)}function ln(e){cn(E.dirname(e));for(let t of[e,un(e)])try{if(s.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function un(e){return`${e}.lease`}function dn(e){return un(on(e))}function fn(e){return E.join(nn(e),`session-state.json`)}function pn(e){return E.join(nn(e),`settings-history.json`)}function mn(e){let t=e.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(t)return t;let n=o.userInfo().uid;return E.join(`/tmp`,`cc-candybar-${n}`,`daemons`)}function hn(e){return E.join(nn(e),`spawn.lock`)}function gn(e){return E.join(nn(e),`spawn.cooldown`)}function _n(e){return E.join(nn(e),`spawn.backoff`)}function vn(e){return E.join(nn(e),`watch-probe`)}function yn(e){return E.join(nn(e),`daemon.log`)}function bn(e){return{socket:on(e),lease:dn(e),state:nn(e),registry:mn(e),log:yn(e),sessionState:fn(e),settingsHistory:pn(e),watchProbe:vn(e),spawnBackoff:_n(e)}}function xn(e){let{env:t}=e,n=`/usr/local/share:/usr/share`,r=process.platform===`darwin`?`${E.join(tn(t,`HOMEBREW_PREFIX`)??`/opt/homebrew`,`share`)}:${n}`:n;return{home:e.home,configHome:tn(t,`XDG_CONFIG_HOME`)??E.join(e.home,`.config`),dataHome:tn(t,`XDG_DATA_HOME`)??E.join(e.home,`.local`,`share`),dataDirs:(tn(t,`XDG_DATA_DIRS`)??r).split(`:`).filter(e=>e!==``)}}function Sn(e,t,n){let r=Cn(e);s.mkdirSync(E.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??s.statSync(r,{throwIfNoEntry:!1})?.mode;try{s.writeFileSync(i,t,a===void 0?{}:{mode:a}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{force:!0}),e}}function Cn(e){return wn(e).at(-1)}function wn(e){let{hops:t,stopped:n}=Tn(e);if(n!==null)throw n;return t}function Tn(e){let t=[e];try{for(let e=0;e<En;e++){let e=N(t[t.length-1]);if(e===null)return{hops:t,stopped:null};t.push(e)}return{hops:t,stopped:Error(`${e}: more than ${En} symbolic links`)}}catch(e){return{hops:t,stopped:e}}}function N(e){try{return s.lstatSync(e).isSymbolicLink()?E.resolve(s.realpathSync(E.dirname(e)),s.readlinkSync(e)):null}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return null;throw e}}const En=40,Dn=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function On(e){return Object.fromEntries(Dn.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const kn=[`native`,`node`,`frames`];function An(e,t){return{kind:e,bundle:t,source:null}}const jn=[`ansi`,`frame`],Mn=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,terminalEnv:!0,client:!0});function Nn(e){let t=Hn(e.termCols),n=Hn(e.termRows),r=Un(e.ssh),i=Bn(e.tmux),a=zn(e.configEnv),o=zn(e.claudeConfigDir),s=Rn(e.terminalEnv),c=Qn(e.client);return{...t!==void 0&&{termCols:t},...n!==void 0&&{termRows:n},...r!==void 0&&{ssh:r},...i!==void 0&&{tmux:i},...a!==void 0&&{configEnv:a},...o!==void 0&&{claudeConfigDir:o},...s!==void 0&&{terminalEnv:s},...c!==void 0&&{client:c}}}function Pn(e,t){return Mn.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function Fn(e){return e.length===0?null:`Client hints refused: ${e.map(({hint:e,sent:t})=>`${e}=${JSON.stringify(t)}`).join(`, `)} — is the statusline client older than the daemon? Reinstall it (\`cc-candybar install\`, or \`just install-rust\` in a checkout).`}const In={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function Ln(e){let t=Object.keys(In).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[In[t](n.join(`, `))]});return t.length===0?null:t.join(`
|
|
4
4
|
`)}function Rn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=Dn.filter(e=>t[e]!==void 0);return n.every(e=>typeof t[e]==`string`&&t[e]!==``)?Object.fromEntries(n.map(e=>[e,t[e]])):void 0}function zn(e){return typeof e==`string`&&E.isAbsolute(e)?e:void 0}function Bn(e){if(e===null)return null;if(typeof e!=`object`)return;let{socket:t,pane:n,truecolor:r}=e;if(!(typeof t!=`string`||t===``)&&!(typeof n!=`string`||n===``)&&!(r!==null&&(typeof r!=`string`||r===``)))return{socket:t,pane:n,truecolor:r}}const Vn=1e4;function Hn(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>Vn?Vn:t}function Un(e){return typeof e==`boolean`?e:void 0}const Wn=new Set([...[],1]);function Gn(e){return typeof e==`object`&&e&&e.kind===`url`?{kind:`url`,frame:e}:{kind:`request`,req:e}}var Kn=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}},qn=class extends Error{constructor(e){super(e===`connect`?`CONNECT_TIMEOUT`:`TIMEOUT`),this.phase=e,this.name=`ClientTimeoutError`}};function Jn(e){return Yn(JSON.stringify(e))}function Yn(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Xn(e,t){let n=Buffer.alloc(0);return function(r){for(n=Buffer.concat([n,r]);n.length>=4;){let r=n.readUInt32BE(0);if(r>16777216){t(new Kn(`frame too large: ${r}`));return}if(n.length<4+r)return;let i=n.subarray(4,4+r);n=n.subarray(4+r);try{e(JSON.parse(i.toString(`utf8`)))}catch(e){let n=new Kn(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Zn(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=t=>{if(!o){o=!0,c(),e.off(`data`,l),e.off(`error`,u),e.off(`close`,d);try{t()}catch{}}},c=r.after(n-r.now(),()=>{s(()=>{e.destroy(),a(new qn(`deadline`))})}),l=Xn(e=>s(()=>i(e)),e=>s(()=>a(e))),u=e=>s(()=>a(e)),d=()=>s(()=>a(Error(`socket closed before response`)));e.on(`data`,l),e.on(`error`,u),e.on(`close`,d),e.write(Jn(t))})}function Qn(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=zn(n);return kn.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function $n(e,t,n,r){let i;try{i=await ar(on(e.host),n.connectMs,e.clock)}catch(e){return ir(e)}return er(i,e.clock,t,n,r)}async function er(e,t,n,r,i){try{let a=t.now()+r.budgetMs,o=n(a),s=await Zn(e,{v:3,...o},a,t);return rr(o.kind,s,i)}catch(e){return ir(e)}finally{e.destroy()}}function tr(e,t){return typeof e==`string`?e:t}function nr(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function rr(e,t,n){let r=t;if(r.ok===!0){let r=n(t);return r===void 0?{kind:`permanent`,cause:`malformed_response`,message:`ok response without payload for "${e}" request`}:{kind:`ok`,value:r}}let i=tr(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:nr(r.daemonV)};case`TIMEOUT`:return{kind:`busy`,phase:`deadline`,message:i};case`BAD_REQUEST`:return{kind:`permanent`,cause:`bad_request`,message:i};case`RENDER_FAILED`:return{kind:`permanent`,cause:`render_failed`,message:i};case`SWITCHED_OFF`:return{kind:`permanent`,cause:`switched_off`,message:i};default:return{kind:`permanent`,cause:`malformed_response`,message:`unknown error code: ${String(r.code)}`}}}function ir(e){if(e instanceof Kn||e instanceof SyntaxError)return{kind:`permanent`,cause:`malformed_response`,message:e instanceof Error?e.message:String(e)};let t=e instanceof Error?e.message:String(e);return e instanceof qn?{kind:`busy`,phase:e.phase,message:t}:t.includes(`ECONNREFUSED`)||t.includes(`ENOENT`)||t.includes(`ENOTSOCK`)?{kind:`transient`,cause:`unreachable`,message:t}:{kind:`transient`,cause:`io_error`,message:t}}function ar(e,t,n){return new Promise((r,i)=>{let a=ue.createConnection({path:e}),o=n.after(t,()=>{a.destroy(),i(new qn(`connect`))});a.once(`connect`,()=>{o(),r(a)}),a.once(`error`,e=>{o(),i(e)})})}function or(e){if(e.kind===`busy`)return`daemon busy (${e.message})`;if(e.kind===`transient`)return`daemon unavailable (${e.cause}: ${e.message})\nHint: daemon may not be running. Run \`cc-candybar\` once to spawn it.`;switch(e.cause){case`version_mismatch`:{let t=e.daemonV===0?`unknown`:`v${e.daemonV}`;return`daemon protocol mismatch (client v${e.clientV} ≠ daemon ${t})`}case`bad_request`:case`render_failed`:case`switched_off`:case`malformed_response`:return`daemon error (${e.cause}): ${e.message}`}}function sr(e){return e===void 0?{kind:`unstated`}:typeof e==`number`&&Number.isSafeInteger(e)&&e>0?{kind:`stated`,at:e}:{kind:`refused`,problem:`request 'deadline' is not epoch milliseconds: ${JSON.stringify(e)}`}}function cr(e,t,n){let r=e.kind===`stated`?n.monoMs+(e.at-n.epochMs):t+150-50,i=Math.min(r,t+200);return Math.round(i-60-n.monoMs)}const lr={connectMs:50,budgetMs:150},ur={connectMs:50,budgetMs:350};function dr(e){let t=e.output;return typeof t==`string`?t:void 0}function fr(e){return rr(`render`,e,dr)}function pr(e,t,n,r,i,a=lr){return $n(e,e=>({kind:`render`,hookData:t,args:n,cwd:r,deadline:e,...i}),a,dr)}function mr(e,t,n){return $n(e,()=>({kind:`pane-session`,socket:t,pane:n}),ur,e=>`paneSession`in e?e.paneSession:void 0)}function hr(e,t,n){return $n(e,()=>({kind:`click`,verb:t,value:n}),ur,dr)}const gr=5e3;async function _r(e){let t=[];for(let n of e){let e=await n.read();if(e.kind===`text`)return`# memory report from: ${n.name}\n${e.text}`;t.push(`# ${n.name}: unavailable — ${e.reason}`)}return[`# memory report: no probe answered`,...t.length>0?t:[`# no probe is known for this platform`]].join(`
|
|
5
5
|
`)}const vr=`/usr/bin/footprint`;function yr(e,t,n){return t===`darwin`?[Cr(e,vr,[`-p`,String(n)]),Cr(e,`/usr/bin/vmmap`,[`--summary`,String(n)])]:t===`linux`?[wr(`/proc/self/smaps_rollup`),wr(`/proc/self/status`)]:[]}function br(e,t,n){return t===`darwin`?xr(n,t=>e.launch({bin:vr,args:t,timeoutMs:gr,category:`limits.charge`})):async e=>({kind:`charged`,measure:`rss`,bytes:e})}function xr(e,t){return async n=>{let r=await t([`-p`,String(e),`--noCategories`,`-f`,`bytes`]);if(!r.ok)return{kind:`stand-in`,bytes:n,unread:`footprint ${r.reason}${r.error===void 0?``:`: ${r.error}`}${Tr(r.stderr)}`};let i=Sr(r.stdout);return i===null?{kind:`stand-in`,bytes:n,unread:`footprint printed no phys_footprint line`}:{kind:`charged`,measure:`phys_footprint`,bytes:i}}}function Sr(e){let t=/^\s*phys_footprint:\s+(\d+) B\s*$/m.exec(e);return t===null?null:Number(t[1])}function Cr(e,t,n){return{name:`${t} ${n.join(` `)}`,read:async()=>{let r=await e.launch({bin:t,args:[...n],timeoutMs:gr,category:`limits.memory-report`});return r.ok?r.stdout.trim().length>0?{kind:`text`,text:r.stdout}:{kind:`unavailable`,reason:`exited 0 but printed nothing`}:{kind:`unavailable`,reason:`${r.reason}${r.error===void 0?``:`: ${r.error}`}${Tr(r.stderr)}`}}}}function wr(e){return{name:e,read:async()=>{try{let t=s.readFileSync(e,`utf8`);return t.trim().length>0?{kind:`text`,text:t}:{kind:`unavailable`,reason:`empty file`}}catch(e){return{kind:`unavailable`,reason:e.message}}}}}function Tr(e){let t=e.split(`
|
|
6
6
|
`).map(e=>e.trim()).find(e=>e.length>0);return t===void 0?``:` (${t})`}const Er=`CC_CANDYBAR_RSS_LIMIT_MB`;function Dr(e){let t=e[Er];if(t===void 0)return 1024;let n=/^\d+$/.test(t)?Number(t):NaN;if(!Number.isSafeInteger(n)||n<=0)throw Error(`${Er} must be a positive integer (MB), got ${JSON.stringify(t)}`);return n}function Or(e){return Dr(e)*2}const kr=1024*1024,Ar=e=>Math.round(e/kr);function jr(e){return Dr(e)*kr}const Mr={memoryReport:{prefix:`memory-`,suffix:`.txt`},heapSnapshot:{prefix:`heap-`,suffix:`.heapsnapshot`}};function Nr(e,t){return e>t}function Pr(e,t){if(e.kind===`charged`)return e;let n=t.kind===`unmeasured`?0:t.charge.kind===`charged`?t.rss-t.charge.bytes:t.charge.gap;return{...e,bytes:e.bytes-n,gap:n}}const Fr=.75;function Ir(e,t){return e>t*Fr}function Lr(e,t,n){let{prefix:r,suffix:i}=Mr[t];return E.join(e,`${r}${n}${i}`)}function Rr(e){for(let t of Object.keys(Mr)){let{prefix:n,suffix:r}=Mr[t];if(e.startsWith(n)&&e.endsWith(r))return t}return null}function zr(e){let t=e.limitBytes??1024*kr,n=e.snapshotsKeep??3,r=!1,i={kind:`unmeasured`},a=null,o=!1,s;function c(){return a??=l().finally(()=>{a=null}),a}async function l(){if(r)return!0;let{rss:a,heapTotal:s}=e.memoryBytes(),c=Pr(await e.memoryCharge(a),i),l={kind:`measured`,charge:c,rss:a,heapTotal:s};if(i=l,e.log(`info`,`memory ${Hr(l,t)}`),o||c.bytes<=t)return!1;r=!0,e.log(`warn`,`${Br(c)} > limit ${Ar(t)} MB (rss ${Ar(a)} MB, v8 heap ${Ar(s)} MB); recording memory then shutting down`);let u=`${new Date(e.clock.now()).toISOString().replace(/[:.]/g,`-`)}-${e.pid}`;return await Ur(e.log,`memory report`,async()=>{let t=Lr(e.snapshotDir,`memoryReport`,u),n=await e.captureMemoryReport();o||(e.writeMemoryReport(t,n),e.log(`info`,`memory report written: ${t}`))}),o?(e.log(`info`,`daemon closed during the breach: no snapshot, no exit`),!1):(await Ur(e.log,`heap snapshot`,()=>{e.writeLogNow();let t=Lr(e.snapshotDir,`heapSnapshot`,u);e.log(`info`,`heap snapshot written: ${e.writeHeapSnapshot(t)}`)}),await Ur(e.log,`artifact rotation`,async()=>{for(let{artifacts:t}of Wr(e.listArtifacts()).slice(n))for(let n of Object.values(t))await Ur(e.log,`evicting ${n}`,()=>e.removeFile(n))}),e.shutdown(0),!0)}function u(){return i.kind===`measured`&&Ir(i.charge.bytes,t)?`${Br(i.charge)} approaching limit ${Ar(t)} MB (v8 heap ${Ar(i.heapTotal)} MB)`:null}function d(){let n;try{n={kind:`ok`,value:Wr(e.listArtifacts())}}catch(e){n={kind:`failed`,reason:e.message}}return{pid:e.pid,memory:i,limit:t,postMortems:n}}function f(t=6e4){let n=async()=>{try{if(await c())return}catch(t){e.log(`warn`,`memory check failed: ${t.message}`)}o||(s=e.clock.after(t,()=>void n(),{unref:!0}))};n()}function p(){o=!0,s?.()}return{check:c,describeNextRestart:u,serving:d,arm:f,disarm:p}}function Br(e){return e.kind===`charged`?`${e.measure} ${Ar(e.bytes)} MB`:`rss ${Ar(e.bytes+e.gap)} MB${e.gap===0?``:` less its last ${Ar(e.gap)} MB gap`} (standing in: ${e.unread})`}function Vr(e){return e.kind===`charged`?e.measure:`rss-stand-in`}function Hr({charge:e,rss:t,heapTotal:n},r){let i=e.kind===`stand-in`?` unread=${JSON.stringify(e.unread)} gap=${Ar(e.gap)}MB`:``;return`measure=${Vr(e)} charge=${Ar(e.bytes)}MB rss=${Ar(t)}MB heap=${Ar(n)}MB limit=${Ar(r)}MB${i}`}async function Ur(e,t,n){try{await n()}catch(n){e(`warn`,`${t} failed: ${n.message}`)}}function Wr(e){let t=new Map;for(let n of e){let e=E.basename(n),r=Rr(e);if(r===null)continue;let{prefix:i,suffix:a}=Mr[r],o=e.slice(i.length,e.length-a.length);t.set(o,{...t.get(o),[r]:n})}let n=Object.keys(Mr);return[...t].sort(([e],[t])=>Nr(e,t)?-1:1).map(([e,t])=>({identity:e,artifacts:Object.fromEntries(n.flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}))}function Gr(e,t,n,r={}){let i=n.snapshotDir;return{clock:n.clock,pid:process.pid,snapshotDir:i,log:n.log,memoryBytes:()=>{let e=process.memoryUsage();return{rss:e.rss,heapTotal:e.heapTotal}},memoryCharge:br(n.launcher,process.platform,process.pid),captureMemoryReport:()=>_r(yr(n.launcher,process.platform,process.pid)),writeMemoryReport:(e,t)=>s.writeFileSync(e,t,{mode:384}),writeHeapSnapshot:e=>de.writeHeapSnapshot(e),writeLogNow:n.writeLogNow,listArtifacts:()=>{let e;try{e=s.readdirSync(i)}catch(e){if(e.code===`ENOENT`)return[];throw e}return e.filter(e=>Rr(e)!==null).map(e=>E.join(i,e))},removeFile:e=>s.unlinkSync(e),shutdown:t,startedAtMs:e,...r}}function Kr(e,n={}){let{host:r,clock:i}=e;if(ci(r)!==null)return;let a=n.spawn??(()=>ui(e)),o=ai(r,i);if(o.kind===`contended`){let e=Jr(r,i);e!==null&&e>2e3&&(t.stderr.write(`cc-candybar: spawn-lock held ${e}ms (likely crashed holder) — spawning unlocked\n`),qr(r,i,a));return}if(o.kind===`error`){t.stderr.write(`cc-candybar: spawn-lock unavailable (${o.reason}) — spawning unlocked\n`),qr(r,i,a);return}try{qr(r,i,a)}finally{si()}}function qr(e,t,n){ti(e,t)&&Yr(n)}function Jr(e,t){try{let n=s.statSync(hn(e));return t.now()-n.mtimeMs}catch{return null}}function Yr(e){try{e()||t.stderr.write(`cc-candybar: daemon spawn returned false (unable to resolve script path?)
|
|
@@ -32,7 +32,7 @@ import{createRequire as e}from"node:module";import t from"node:process";import{U
|
|
|
32
32
|
`}function Ja(e,t,n){return e.split(`
|
|
33
33
|
`).join(`${n}${t}`)}function Ya(e,t,n){let[r,...i]=e,a=i.length===0?t:`{\n ${Ja(Ya(i,t,n),` `,`
|
|
34
34
|
`)}${n.trailingComma}\n}`;return`${n.key(r)}: ${a}`}function Xa(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}function Za(e,t){return e.lastIndexOf(`
|
|
35
|
-
`,t-1)+1}function Qa(e){return/^[ \t]*$/.test(e)}function $a(e,t){let n=Za(e,t);return/^[ \t]*/.exec(e.slice(n))[0]}function eo(e,t){return Qa(e.slice(Za(e,t),t))}const to=/(?:\/\/[^\n]*?)?(\r\n|\n|$)/y;function no(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e[n]===`,`?n+1:-1;for(r!==-1&&(n=r);n<e.length&&(e[n]===` `||e[n]===` `);)n++;to.lastIndex=n;let i=to.exec(e);if(i===null)return{commaEnd:r,line:null};let a=n+i[0].length;return{commaEnd:r,line:{at:a-i[1].length,next:a}}}function ro(e,t){let{commaEnd:n,line:r}=no(e,t.end);if(eo(e,t.start)&&r!==null)return Xa(e,Za(e,t.start),r.next,``);if(n!==-1){let r=n;for(;r<e.length&&e[r]===` `;)r++;return Xa(e,t.start,r,``)}let i=t.start;for(;i>0&&(e[i-1]===` `||e[i-1]===` `);)i--;return e[i-1]===`,`?Xa(e,i-1,t.end,``):Xa(e,t.start,t.end,``)}function io(e,t,n,r,i){let a=n.commaEnd!==-1,o=a?e:Xa(e,t.end,t.end,`,`),s=n.line.at+ +!a,c=qa(e);return Xa(o,s,s,`${c}${i}${Ja(r,i,c)}${a?`,`:``}`)}function ao(e,t,n,r){let i=t.kind===`object`?t.entries:t.elements,a=i[i.length-1],o=$a(e,t.span.start);if(a===void 0){let i=o+` `,a=qa(e);return Xa(e,t.span.start+1,t.span.end-1,`${a}${i}${Ja(n,i,a)}${r.trailingComma}${a}${o}`)}let{commaEnd:s,line:c}=no(e,a.span.end);if(eo(e,a.span.start)&&c!==null){let t=e.slice(Za(e,a.span.start),a.span.start);return io(e,a.span,{commaEnd:s,line:c},n,t)}let l=s===-1?a.span.end:s;return Xa(e,l,l,`${s===-1?`, `:` `}${n}${s===-1?``:`,`}`)}function oo(e,t,n,r){if(t.length===0)throw new Aa(`setValue needs a non-empty path`,0);if(/^\s*$/.test(e)){let i=qa(e);return`{${i} ${Ja(Ya(t,n,r),` `,i)}${r.trailingComma}${i}}${i}`}return so(e,Ia(e),t,n,r)}function so(e,t,n,r,i){let a=t;for(let t=0;t<n.length;t++){if(a.kind!==`object`)throw new Aa(`cannot set ${n.join(`.`)}: ${n.slice(0,t).join(`.`)||`the document`} is not an object`,a.span.start);let o=La(a,n[t]);if(o===void 0)return ao(e,a,Ya(n.slice(t),r,i),i);if(t===n.length-1){let t=$a(e,o.keySpan.start);return Xa(e,o.value.span.start,o.value.span.end,Ja(r,t,qa(e)))}a=o.value}throw new Aa(`unreachable: path exhausted`,0)}function co(e,t,n=0){if(t.length===0)throw new Aa(`deleteValue needs a non-empty path`,0);if(/^\s*$/.test(e))return e;let r=t.slice(0,-1),i=Ra(Ia(e),r),a=i===void 0?void 0:La(i,t[t.length-1]);if(a===void 0||i?.kind!==`object`)return e;let o=ro(e,a.span);return r.length>n&&i.entries.length===1?co(o,r,n):o}const lo=[`h`,`v`,`children`];function uo(e){if(e.kind===`string`)return e.value;if(e.kind!==`object`)return;let t=La(e,`seg`)?.value,n=La(e,`kind`)?.value,r=La(e,`name`)?.value,i=t?.kind===`string`?t.value:n?.kind===`string`&&n.value===`segment`&&r?.kind===`string`?r.value:void 0;if(i===void 0)return;let a=La(e,`id`)?.value;return a?.kind===`string`?a.value:i}function fo(e){return e.kind===`object`?lo.map(t=>La(e,t)?.value).filter(e=>e?.kind===`array`):[]}function po(e){let t=La(e,`rows`)?.value;return t?.kind===`object`?t.entries:null}function mo(e){if(e.kind!==`object`)return!0;let t=po(e);return t===null||t.length>0||e.entries.some(e=>e.key!==`rows`)}function*ho(e,t){yield{node:e,bareAt:t};for(let t of fo(e))for(let e of t.elements)yield*ho(e,null);for(let n of po(e)??[])yield*ho(n.value,t===null?null:[...t,`rows`,n.key])}function go(e,t){for(let{node:n}of ho(e,null))if(uo(n)===t)return!0;return!1}function _o(e,t,n){let r=Ra(Ia(e),t);if(r===void 0)return null;for(let{node:i,bareAt:a}of ho(r,t))if(uo(i)===n)return a===null?{text:e,ref:i}:_o(oo(e,a,`{ h: [${za(e,i)}] }`,Wa),t,n);return null}function vo(e,t,n){let r=_o(e,t,n);return r===null?null:ro(r.text,r.ref.span)}function yo(e,t,n,r,i){let a=_o(e,t,r);if(a===null)return null;let{text:o,ref:s}=a,c=n.id===void 0?JSON.stringify(n.seg):`{ seg: ${JSON.stringify(n.seg)}, id: ${JSON.stringify(n.id)} }`,{commaEnd:l,line:u}=no(o,s.span.end);if(eo(o,s.span.start)&&u!==null){let e=o.slice(Za(o,s.span.start),s.span.start);return i===`after`?io(o,s.span,{commaEnd:l,line:u},c,e):Xa(o,s.span.start,s.span.start,`${c},${qa(o)}${e}`)}let d=za(o,s),f=i===`before`?`${c}, ${d}`:`${d}, ${c}`;return Xa(o,s.span.start,s.span.end,f)}function bo(e,t,n,r,i){let a=_o(e,t,n);if(a===null)return null;let{text:o,ref:s}=a,c=`{ ${Ua(r)}: ${i} }`;return s.kind===`string`?Xa(o,s.span.start,s.span.end,`{ seg: ${JSON.stringify(s.value)}, settings: ${c} }`):La(s,`settings`)===void 0?so(o,s,[`settings`],c,Wa):so(o,s,[`settings`,r],i,Wa)}function F(e){return{kind:`ok`,value:e}}const I={kind:`absent`};function L(e){return{kind:`failed`,reason:e}}function xo(e,t){return e?.kind===`ok`?e.value:t}const So={kind:`pending`};function Co(e){return e===So}function wo(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}function To(e){if(!e)return``;try{return Eo(v(e))}catch{return``}}function Eo(e){return`${e.mtimeMs}:${e.size}`}const Do=new class{slots;head=null;tail=null;constructor(e){this.slots=e}async run(e){await this.acquire();try{return await e()}finally{this.release()}}async acquire(){if(this.slots>0){this.slots--;return}await new Promise(e=>{let t={wake:e,next:null};this.tail?this.tail.next=t:this.head=t,this.tail=t})}release(){let e=this.head;if(!e){this.slots++;return}this.head=e.next,this.head||(this.tail=null),e.wake()}}(8);function Oo(e){return((...t)=>Do.run(()=>e(...t)))}const ko=Oo(me),Ao=Oo(he),jo={reads:0,bytes:0,longLines:0,largestLine:0};function Mo(){return{...jo}}const No=[];function Po(e){No.length<8&&No.push(e)}async function Fo(e,t,n){return Do.run(async()=>{let r=No.pop()??Buffer.allocUnsafe(524288),i=await Lo(e,t,n,r);if(i.kind!==`ok`)return Po(r),i;let a=r;return F({...i.value,[Symbol.dispose]:()=>{a!==void 0&&Po(a),a=void 0}})})}function Io(e,t){try{var n=wo();return t(n.u(e).lines)}catch(e){n.e=e}finally{n.d()}}async function Lo(e,t,n,r){let i=null;try{i=await fe(e,`r`);let a=await i.stat(),{size:o,ino:s}=a,c=Eo(a),l=t!==void 0&&(s!==t.ino||o<t.offset),u=l||t===void 0?0:t.offset,d=l||n===void 0?o:Math.min(o,n),f=0,p=await Ro(i,r.subarray(0,d-u),u);f+=p.length;let m=p.lastIndexOf(10),h=u+p.length,g=p.length<Math.min(r.length,d-u);for(;m<0&&h<d&&!g;){let e=await Ro(i,r.subarray(0,d-h),h);f+=e.length;let t=e.indexOf(10);t>=0&&(m=h-u+t),g=e.length<Math.min(r.length,d-h),h+=e.length}let _=m+1,v=_>r.length?_:0,y=v>0?await Ro(i,Buffer.allocUnsafe(_),u):p.subarray(0,_);f+=v>0?y.length:0;let b=y.length===_;return jo.reads++,jo.bytes+=f,jo.longLines+=+(v>0),jo.largestLine=Math.max(jo.largestLine,v),F({lines:b?y:y.subarray(0,0),start:u,atEnd:!b||(v>0?u+_>=d:h>=d||g),size:o,stamp:c,ino:s,reset:l,longLine:v})}catch(t){return t.code===`ENOENT`?I:L(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await i?.close().catch(e=>{A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}}async function Ro(e,t,n){let r=0;for(;r<t.length;){let{bytesRead:i}=await e.read(t,r,t.length-r,n+r);if(i===0)break;r+=i}return t.subarray(0,r)}async function zo(e,t){return Do.run(async()=>{let n=null;try{n=await fe(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t);return F({buf:await Ro(n,Buffer.alloc(r-i),i),fromStart:i===0})}catch(t){return t.code===`ENOENT`?I:L(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function Bo(e,t){let n;try{n=m(e,l.O_RDONLY|l.O_NONBLOCK)}catch(e){let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`?I:L(e instanceof Error?e.message:String(e))}try{let e=d(n,{bigint:!0});if(!e.isFile())return L(`not a regular file`);let r=Number(e.size),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let e=g(n,a,o,a.length-o,i+o);if(e===0)break;o+=e}return F({buf:a.subarray(0,o),fromStart:i===0,file:`${e.dev}:${e.ino}`})}catch(e){return L(e instanceof Error?e.message:String(e))}finally{try{c(n)}catch(e){A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)}}}const Vo=`CLAUDE_CONFIG_DIR`;function Ho(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:E.resolve(t,n)}function Uo(e,t){return e??E.join(t,`.claude`)}function Wo(e){return E.join(e,`settings.json`)}function Go(e){let t=Bo(e,2**53-1);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`cannot read ${e}: ${t.reason}`);case`ok`:return{text:t.value.buf.toString(`utf8`),file:t.value.file}}}const Ko=(e,t)=>Error(`cannot read ${e}: ${oee(t)}`,{cause:t});function qo(e){return Go(e)?.text??``}function Jo(e){return Yo(e,qo(e))}function Yo(e,t){let n;try{if(/^\s*$/.test(t))return{};n=Ga.parse(t)}catch(t){throw Ko(e,t)}if(!Zo(n))throw Error(`cannot read ${e}: not a JSON object`);return n}function ree(e){switch(e){case`darwin`:return`/Library/Application Support/ClaudeCode`;case`win32`:return`C:\\Program Files\\ClaudeCode`;default:return`/etc/claude-code`}}const Xo=e=>E.join(e,`.claude`,`settings.local.json`);function iee(e){let t=E.join(e.managedDir,`managed-settings.d`),n=[...aee(t).reverse().map(e=>({scope:`managed`,path:E.join(t,e)})),{scope:`managed`,path:E.join(e.managedDir,`managed-settings.json`)},{scope:`project-local`,path:Xo(e.projectDir)},{scope:`project`,path:E.join(e.projectDir,`.claude`,`settings.json`)},{scope:`user`,path:e.userFile}].flatMap(e=>{let t=Go(e.path);if(t===null)return[];let n=Yo(e.path,t.text),{env:r={}}=n;if(!Zo(r))throw Error(`cannot read ${e.path}: \`env\` is not an object`);return[{source:{...e,settings:n,env:r},file:t.file}]}),r=n.find(e=>e.source.scope===`user`);return n.filter(e=>e.source.scope!==`project`||e.file!==r?.file).map(e=>e.source)}function aee(e){try{return s.readdirSync(e).filter(e=>!e.startsWith(`.`)&&e.endsWith(`.json`)).sort()}catch(t){if(t.code===`ENOENT`)return[];throw Ko(e,t)}}const Zo=e=>typeof e==`object`&&!!e&&!Array.isArray(e),oee=e=>e instanceof Error?e.message:String(e),see=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Qo(e){let t=see.exec(e);return t?{kind:`ok`,value:[Number(t[1]),Number(t[2]),Number(t[3])]}:{kind:`failed`,reason:`"${e}" is not a release version (expected MAJOR.MINOR.PATCH)`}}function $o(e){return e.join(`.`)}function cee([e,t,n],[r,i,a]){return e-r||t-i||n-a}const es=`@promptctl/cc-candybar`;async function ts(e,t,n,r){let i=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(i,{signal:Re(r,5e3)});if(!e.ok)return L(`registry responded ${e.status} for ${i}`);let n=await e.json();return typeof n.latest==`string`?Qo(n.latest):I}catch(e){return L(e instanceof Error?e.message:String(e))}}function ns(e,t){let n=Qo(e);if(n.kind===`failed`)return{kind:`unchecked`,installed:e,reason:n.reason};switch(t.kind){case`failed`:return{kind:`unchecked`,installed:e,reason:t.reason};case`absent`:return{kind:`unchecked`,installed:e,reason:"the registry lists no `latest` dist-tag"};case`ok`:{let e=cee(n.value,t.value);return e<0?{kind:`stale`,installed:n.value,latest:t.value}:e>0?{kind:`ahead`,installed:n.value,latest:t.value}:{kind:`current`,installed:n.value}}}}function rs(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${$o(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${$o(t.installed)} is newer than the registry's latest release (${$o(t.latest)}): an unpublished build.\n`};case`stale`:{let n=$o(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${$o(t.installed)} was staged, but the latest release is ${n}.\n pnpm's release-age gate (minimumReleaseAge) and its dlx cache can both\n resolve \`@latest\` to an older release without saying so.\n To install ${n} now, name it explicitly:\n pnpm dlx ${e}@${n} install\n`}}case`unchecked`:return{stream:`stderr`,text:`⚠ Could not check for a cc-candybar release newer than ${t.installed} (${t.reason}); the registry check was skipped.\n`}}}const is={"darwin-arm64":`@promptctl/cc-candybar-darwin-arm64`,"darwin-x64":`@promptctl/cc-candybar-darwin-x64`,"linux-x64":`@promptctl/cc-candybar-linux-x64`,"linux-arm64":`@promptctl/cc-candybar-linux-arm64`};function as(e,t){return`${e}-${t}`in is}const os=`cc-candybar-url-handler`,ss=[];function cs(e,t){return[e,...t].map(Ft).join(` `)}function ls(e){return E.join(e.home,`Applications`,`${Li}.app`)}function us(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function ds(e){return process.platform===`darwin`?E.join(e.home,`Library`,`Application Support`,`CCCandybar`):E.join(xn(e).dataHome,`cc-candybar`)}function fs(e){return E.join(e,`bin`,`cc-candybar`)}function ps(e){return E.join(e,`dist`,`index.mjs`)}function ms(e,t){let n=Xt(e);return Vt(n===null?ps(ds(t)):E.join(n,`dist`,`index.mjs`))}function hs(e){return E.join(e,`Contents`,`MacOS`,Li)}function gs(e){let t=Xt(e);if(t!==null){let e=E.join(t,`bin`,`cc-candybar-url-handler-native`);if(!s.existsSync(e))throw Error(`install: the URL handler app is not built at ${e}. Run \`just install-url-handler\` in the checkout.`);return e}let n=_s(e,`bin/${os}`);switch(n.kind){case`found`:return n.path;case`no-package`:throw Error(`install: no URL handler app ships for ${n.platform}; the scheme is macOS-only.`);case`missing`:throw Error(`install: the URL handler app was not found in ${n.pkgName} (bin/${os}). The optional platform package is missing or older than this release: reinstall the package.`)}}function _s(t,n){let r=`${process.platform}-${process.arch}`,i=is[r];if(i===void 0)return{kind:`no-package`,platform:r};try{return{kind:`found`,path:e(t).resolve(`${i}/${n}`)}}catch{return{kind:`missing`,pkgName:i}}}function vs(e){let t=_s(e,`bin/cc-candybar`);return t.kind===`found`?{kind:`native`,sourcePath:t.path}:{kind:`node-shim`,sourcePath:E.resolve(E.dirname(e),`..`,`bin`,`cc-candybar`)}}function ys(e,t){E.resolve(e)!==E.resolve(t)&&s.copyFileSync(e,t)}function bs(e,t){E.resolve(e)!==E.resolve(t)&&(s.rmSync(t,{recursive:!0,force:!0}),s.cpSync(e,t,{recursive:!0}))}function xs(e){let t=s.openSync(e,`r`);try{let n=Buffer.alloc(2),r=s.readSync(t,n,0,2,0);if(r<2)throw Error(`install: staged render entry at ${e} is truncated (${r} byte(s)). Re-run: pnpm dlx ${es}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{s.closeSync(t)}}function Ss(e,t){if(!s.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let n=vs(e);if(!s.existsSync(n.sourcePath))throw Error(`install: render entry not found at ${n.sourcePath}. Reinstall the package.`);let r=E.join(E.dirname(e),Lt);if(!s.existsSync(r))throw Error(`install: the attach launcher was not found at ${r}. Reinstall the package.`);let i=E.join(E.dirname(e),Bt);if(!s.existsSync(i))throw Error(`install: the attach preload was not found at ${i}. Reinstall the package.`);let a=ps(t),o=fs(t);s.mkdirSync(E.dirname(a),{recursive:!0}),s.mkdirSync(E.dirname(o),{recursive:!0}),ys(e,a),bs(r,E.join(E.dirname(a),Lt)),ys(i,E.join(E.dirname(a),Bt)),ys(n.sourcePath,o),s.chmodSync(o,493),s.rmSync(E.join(t,`url-handler.mjs`),{force:!0});let c=xs(o);return process.stdout.write(`Staged cc-candybar v${M} runtime at ${t}\n`+(c===`native`?` render entry: native binary (${process.platform}-${process.arch})\n`:` render entry: node shim (no native binary for ${process.platform}-${process.arch}; renders are correct but pay node startup)\n`)),{binPath:o,distPath:a,entryKind:c}}function Cs(){return[`<?xml version="1.0" encoding="UTF-8"?>`,`<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">`,`<plist version="1.0">`,`<dict>`,` <key>CFBundleIdentifier</key>`,` <string>com.cccandybar.url-handler</string>`,` <key>CFBundleName</key>`,` <string>${Li}</string>`,` <key>CFBundleDisplayName</key>`,` <string>cc-candybar</string>`,` <key>CFBundleExecutable</key>`,` <string>${Li}</string>`,` <key>CFBundlePackageType</key>`,` <string>APPL</string>`,` <key>CFBundleVersion</key>`,` <string>${M}</string>`,` <key>CFBundleShortVersionString</key>`,` <string>${M}</string>`,` <key>LSMinimumSystemVersion</key>`,` <string>12.0</string>`,` <key>LSUIElement</key>`,` <true/>`,` <key>CFBundleURLTypes</key>`,` <array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>cc-candybar click</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${Ii}</string>`,` </array>`,` </dict>`,` </array>`,`</dict>`,`</plist>`,``].join(`
|
|
35
|
+
`,t-1)+1}function Qa(e){return/^[ \t]*$/.test(e)}function $a(e,t){let n=Za(e,t);return/^[ \t]*/.exec(e.slice(n))[0]}function eo(e,t){return Qa(e.slice(Za(e,t),t))}const to=/(?:\/\/[^\n]*?)?(\r\n|\n|$)/y;function no(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e[n]===`,`?n+1:-1;for(r!==-1&&(n=r);n<e.length&&(e[n]===` `||e[n]===` `);)n++;to.lastIndex=n;let i=to.exec(e);if(i===null)return{commaEnd:r,line:null};let a=n+i[0].length;return{commaEnd:r,line:{at:a-i[1].length,next:a}}}function ro(e,t){let{commaEnd:n,line:r}=no(e,t.end);if(eo(e,t.start)&&r!==null)return Xa(e,Za(e,t.start),r.next,``);if(n!==-1){let r=n;for(;r<e.length&&e[r]===` `;)r++;return Xa(e,t.start,r,``)}let i=t.start;for(;i>0&&(e[i-1]===` `||e[i-1]===` `);)i--;return e[i-1]===`,`?Xa(e,i-1,t.end,``):Xa(e,t.start,t.end,``)}function io(e,t,n,r,i){let a=n.commaEnd!==-1,o=a?e:Xa(e,t.end,t.end,`,`),s=n.line.at+ +!a,c=qa(e);return Xa(o,s,s,`${c}${i}${Ja(r,i,c)}${a?`,`:``}`)}function ao(e,t,n,r){let i=t.kind===`object`?t.entries:t.elements,a=i[i.length-1],o=$a(e,t.span.start);if(a===void 0){let i=o+` `,a=qa(e);return Xa(e,t.span.start+1,t.span.end-1,`${a}${i}${Ja(n,i,a)}${r.trailingComma}${a}${o}`)}let{commaEnd:s,line:c}=no(e,a.span.end);if(eo(e,a.span.start)&&c!==null){let t=e.slice(Za(e,a.span.start),a.span.start);return io(e,a.span,{commaEnd:s,line:c},n,t)}let l=s===-1?a.span.end:s;return Xa(e,l,l,`${s===-1?`, `:` `}${n}${s===-1?``:`,`}`)}function oo(e,t,n,r){if(t.length===0)throw new Aa(`setValue needs a non-empty path`,0);if(/^\s*$/.test(e)){let i=qa(e);return`{${i} ${Ja(Ya(t,n,r),` `,i)}${r.trailingComma}${i}}${i}`}return so(e,Ia(e),t,n,r)}function so(e,t,n,r,i){let a=t;for(let t=0;t<n.length;t++){if(a.kind!==`object`)throw new Aa(`cannot set ${n.join(`.`)}: ${n.slice(0,t).join(`.`)||`the document`} is not an object`,a.span.start);let o=La(a,n[t]);if(o===void 0)return ao(e,a,Ya(n.slice(t),r,i),i);if(t===n.length-1){let t=$a(e,o.keySpan.start);return Xa(e,o.value.span.start,o.value.span.end,Ja(r,t,qa(e)))}a=o.value}throw new Aa(`unreachable: path exhausted`,0)}function co(e,t,n=0){if(t.length===0)throw new Aa(`deleteValue needs a non-empty path`,0);if(/^\s*$/.test(e))return e;let r=t.slice(0,-1),i=Ra(Ia(e),r),a=i===void 0?void 0:La(i,t[t.length-1]);if(a===void 0||i?.kind!==`object`)return e;let o=ro(e,a.span);return r.length>n&&i.entries.length===1?co(o,r,n):o}const lo=[`h`,`v`,`children`];function uo(e){if(e.kind===`string`)return e.value;if(e.kind!==`object`)return;let t=La(e,`seg`)?.value,n=La(e,`kind`)?.value,r=La(e,`name`)?.value,i=t?.kind===`string`?t.value:n?.kind===`string`&&n.value===`segment`&&r?.kind===`string`?r.value:void 0;if(i===void 0)return;let a=La(e,`id`)?.value;return a?.kind===`string`?a.value:i}function fo(e){return e.kind===`object`?lo.map(t=>La(e,t)?.value).filter(e=>e?.kind===`array`):[]}function po(e){let t=La(e,`rows`)?.value;return t?.kind===`object`?t.entries:null}function mo(e){if(e.kind!==`object`)return!0;let t=po(e);return t===null||t.length>0||e.entries.some(e=>e.key!==`rows`)}function*ho(e,t){yield{node:e,bareAt:t};for(let t of fo(e))for(let e of t.elements)yield*ho(e,null);for(let n of po(e)??[])yield*ho(n.value,t===null?null:[...t,`rows`,n.key])}function go(e,t){for(let{node:n}of ho(e,null))if(uo(n)===t)return!0;return!1}function _o(e,t,n){let r=Ra(Ia(e),t);if(r===void 0)return null;for(let{node:i,bareAt:a}of ho(r,t))if(uo(i)===n)return a===null?{text:e,ref:i}:_o(oo(e,a,`{ h: [${za(e,i)}] }`,Wa),t,n);return null}function vo(e,t,n){let r=_o(e,t,n);return r===null?null:ro(r.text,r.ref.span)}function yo(e,t,n,r,i){let a=_o(e,t,r);if(a===null)return null;let{text:o,ref:s}=a,c=n.id===void 0?JSON.stringify(n.seg):`{ seg: ${JSON.stringify(n.seg)}, id: ${JSON.stringify(n.id)} }`,{commaEnd:l,line:u}=no(o,s.span.end);if(eo(o,s.span.start)&&u!==null){let e=o.slice(Za(o,s.span.start),s.span.start);return i===`after`?io(o,s.span,{commaEnd:l,line:u},c,e):Xa(o,s.span.start,s.span.start,`${c},${qa(o)}${e}`)}let d=za(o,s),f=i===`before`?`${c}, ${d}`:`${d}, ${c}`;return Xa(o,s.span.start,s.span.end,f)}function bo(e,t,n,r,i){let a=_o(e,t,n);if(a===null)return null;let{text:o,ref:s}=a,c=`{ ${Ua(r)}: ${i} }`;return s.kind===`string`?Xa(o,s.span.start,s.span.end,`{ seg: ${JSON.stringify(s.value)}, settings: ${c} }`):La(s,`settings`)===void 0?so(o,s,[`settings`],c,Wa):so(o,s,[`settings`,r],i,Wa)}function F(e){return{kind:`ok`,value:e}}const I={kind:`absent`};function L(e){return{kind:`failed`,reason:e}}function xo(e,t){return e?.kind===`ok`?e.value:t}const So={kind:`pending`};function Co(e){return e===So}function wo(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}function To(e){if(!e)return``;try{return Eo(v(e))}catch{return``}}function Eo(e){return`${e.mtimeMs}:${e.size}`}const Do=new class{slots;head=null;tail=null;constructor(e){this.slots=e}async run(e){await this.acquire();try{return await e()}finally{this.release()}}async acquire(){if(this.slots>0){this.slots--;return}await new Promise(e=>{let t={wake:e,next:null};this.tail?this.tail.next=t:this.head=t,this.tail=t})}release(){let e=this.head;if(!e){this.slots++;return}this.head=e.next,this.head||(this.tail=null),e.wake()}}(8);function Oo(e){return((...t)=>Do.run(()=>e(...t)))}const ko=Oo(me),Ao=Oo(he),jo={reads:0,bytes:0,longLines:0,largestLine:0};function Mo(){return{...jo}}const No=[];function Po(e){No.length<8&&No.push(e)}async function Fo(e,t,n){return Do.run(async()=>{let r=No.pop()??Buffer.allocUnsafe(524288),i=await Lo(e,t,n,r);if(i.kind!==`ok`)return Po(r),i;let a=r;return F({...i.value,[Symbol.dispose]:()=>{a!==void 0&&Po(a),a=void 0}})})}function Io(e,t){try{var n=wo();return t(n.u(e).lines)}catch(e){n.e=e}finally{n.d()}}async function Lo(e,t,n,r){let i=null;try{i=await fe(e,`r`);let a=await i.stat(),{size:o,ino:s}=a,c=Eo(a),l=t!==void 0&&(s!==t.ino||o<t.offset),u=l||t===void 0?0:t.offset,d=l||n===void 0?o:Math.min(o,n),f=0,p=await Ro(i,r.subarray(0,d-u),u);f+=p.length;let m=p.lastIndexOf(10),h=u+p.length,g=p.length<Math.min(r.length,d-u);for(;m<0&&h<d&&!g;){let e=await Ro(i,r.subarray(0,d-h),h);f+=e.length;let t=e.indexOf(10);t>=0&&(m=h-u+t),g=e.length<Math.min(r.length,d-h),h+=e.length}let _=m+1,v=_>r.length?_:0,y=v>0?await Ro(i,Buffer.allocUnsafe(_),u):p.subarray(0,_);f+=v>0?y.length:0;let b=y.length===_;return jo.reads++,jo.bytes+=f,jo.longLines+=+(v>0),jo.largestLine=Math.max(jo.largestLine,v),F({lines:b?y:y.subarray(0,0),start:u,atEnd:!b||(v>0?u+_>=d:h>=d||g),size:o,stamp:c,ino:s,reset:l,longLine:v})}catch(t){return t.code===`ENOENT`?I:L(`readAppended ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await i?.close().catch(e=>{A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}}async function Ro(e,t,n){let r=0;for(;r<t.length;){let{bytesRead:i}=await e.read(t,r,t.length-r,n+r);if(i===0)break;r+=i}return t.subarray(0,r)}async function zo(e,t){return Do.run(async()=>{let n=null;try{n=await fe(e,`r`);let{size:r}=await n.stat(),i=Math.max(0,r-t);return F({buf:await Ro(n,Buffer.alloc(r-i),i),fromStart:i===0})}catch(t){return t.code===`ENOENT`?I:L(`readTail ${e}: ${t instanceof Error?t.message:String(t)}`)}finally{await n?.close().catch(e=>{A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)})}})}function Bo(e,t){let n;try{n=m(e,l.O_RDONLY|l.O_NONBLOCK)}catch(e){let{code:t}=e;return t===`ENOENT`||t===`ENOTDIR`?I:L(e instanceof Error?e.message:String(e))}try{let e=d(n,{bigint:!0});if(!e.isFile())return L(`not a regular file`);let r=Number(e.size),i=Math.max(0,r-t),a=Buffer.alloc(r-i),o=0;for(;o<a.length;){let e=g(n,a,o,a.length-o,i+o);if(e===0)break;o+=e}return F({buf:a.subarray(0,o),fromStart:i===0,file:`${e.dev}:${e.ino}`})}catch(e){return L(e instanceof Error?e.message:String(e))}finally{try{c(n)}catch(e){A(`transcript-fs: close failed: ${e instanceof Error?e.message:String(e)}`)}}}const Vo=`CLAUDE_CONFIG_DIR`;function Ho(e,t){let n=(e.CLAUDE_CONFIG_DIR??``).split(`,`)[0].trim();return n===``?void 0:E.resolve(t,n)}function Uo(e,t){return e??E.join(t,`.claude`)}function Wo(e){return E.join(e,`settings.json`)}function Go(e){let t=Bo(e,2**53-1);switch(t.kind){case`absent`:return null;case`failed`:throw Error(`cannot read ${e}: ${t.reason}`);case`ok`:return{text:t.value.buf.toString(`utf8`),file:t.value.file}}}const Ko=(e,t)=>Error(`cannot read ${e}: ${oee(t)}`,{cause:t});function qo(e){return Go(e)?.text??``}function Jo(e){return Yo(e,qo(e))}function Yo(e,t){let n;try{if(/^\s*$/.test(t))return{};n=Ga.parse(t)}catch(t){throw Ko(e,t)}if(!Zo(n))throw Error(`cannot read ${e}: not a JSON object`);return n}function ree(e){switch(e){case`darwin`:return`/Library/Application Support/ClaudeCode`;case`win32`:return`C:\\Program Files\\ClaudeCode`;default:return`/etc/claude-code`}}const Xo=e=>E.join(e,`.claude`,`settings.local.json`);function iee(e){let t=E.join(e.managedDir,`managed-settings.d`),n=[...aee(t).reverse().map(e=>({scope:`managed`,path:E.join(t,e)})),{scope:`managed`,path:E.join(e.managedDir,`managed-settings.json`)},{scope:`project-local`,path:Xo(e.projectDir)},{scope:`project`,path:E.join(e.projectDir,`.claude`,`settings.json`)},{scope:`user`,path:e.userFile}].flatMap(e=>{let t=Go(e.path);if(t===null)return[];let n=Yo(e.path,t.text),{env:r={}}=n;if(!Zo(r))throw Error(`cannot read ${e.path}: \`env\` is not an object`);return[{source:{...e,settings:n,env:r},file:t.file}]}),r=n.find(e=>e.source.scope===`user`);return n.filter(e=>e.source.scope!==`project`||e.file!==r?.file).map(e=>e.source)}function aee(e){try{return s.readdirSync(e).filter(e=>!e.startsWith(`.`)&&e.endsWith(`.json`)).sort()}catch(t){if(t.code===`ENOENT`)return[];throw Ko(e,t)}}const Zo=e=>typeof e==`object`&&!!e&&!Array.isArray(e),oee=e=>e instanceof Error?e.message:String(e),see=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;function Qo(e){let t=see.exec(e);return t?{kind:`ok`,value:[Number(t[1]),Number(t[2]),Number(t[3])]}:{kind:`failed`,reason:`"${e}" is not a release version (expected MAJOR.MINOR.PATCH)`}}function $o(e){return e.join(`.`)}function cee([e,t,n],[r,i,a]){return e-r||t-i||n-a}const es=`@promptctl/cc-candybar`;async function ts(e,t,n,r){let i=`${n}/-/package/${encodeURIComponent(e)}/dist-tags`;try{let e=await t(i,{signal:Re(r,5e3)});if(!e.ok)return L(`registry responded ${e.status} for ${i}`);let n=await e.json();return typeof n.latest==`string`?Qo(n.latest):I}catch(e){return L(e instanceof Error?e.message:String(e))}}function ns(e,t){let n=Qo(e);if(n.kind===`failed`)return{kind:`unchecked`,installed:e,reason:n.reason};switch(t.kind){case`failed`:return{kind:`unchecked`,installed:e,reason:t.reason};case`absent`:return{kind:`unchecked`,installed:e,reason:"the registry lists no `latest` dist-tag"};case`ok`:{let e=cee(n.value,t.value);return e<0?{kind:`stale`,installed:n.value,latest:t.value}:e>0?{kind:`ahead`,installed:n.value,latest:t.value}:{kind:`current`,installed:n.value}}}}function rs(e,t){switch(t.kind){case`current`:return{stream:`stdout`,text:`✓ cc-candybar ${$o(t.installed)} is the latest release.\n`};case`ahead`:return{stream:`stdout`,text:`cc-candybar ${$o(t.installed)} is newer than the registry's latest release (${$o(t.latest)}): an unpublished build.\n`};case`stale`:{let n=$o(t.latest);return{stream:`stderr`,text:`⚠ cc-candybar ${$o(t.installed)} was staged, but the latest release is ${n}.\n pnpm's release-age gate (minimumReleaseAge) and its dlx cache can both\n resolve \`@latest\` to an older release without saying so.\n To install ${n} now, name it explicitly:\n pnpm dlx ${e}@${n} install\n`}}case`unchecked`:return{stream:`stderr`,text:`⚠ Could not check for a cc-candybar release newer than ${t.installed} (${t.reason}); the registry check was skipped.\n`}}}const is={"darwin-arm64":`@promptctl/cc-candybar-darwin-arm64`,"darwin-x64":`@promptctl/cc-candybar-darwin-x64`,"linux-x64":`@promptctl/cc-candybar-linux-x64`,"linux-arm64":`@promptctl/cc-candybar-linux-arm64`};function as(e,t){return`${e}-${t}`in is}const os=`cc-candybar-url-handler`,ss=[];function cs(e,t){return[e,...t].map(Ft).join(` `)}function ls(e){return E.join(e.home,`Applications`,`${Li}.app`)}function us(){if(process.platform!==`darwin`)throw Error(`URL handler installation requires macOS (found platform: ${process.platform}).`)}function ds(e){return process.platform===`darwin`?E.join(e.home,`Library`,`Application Support`,`CCCandybar`):E.join(xn(e).dataHome,`cc-candybar`)}function fs(e){return E.join(e,`bin`,`cc-candybar`)}function ps(e){return E.join(e,`dist`,`index.mjs`)}function ms(e,t){let n=Xt(e);return Vt(n===null?ps(ds(t)):E.join(n,`dist`,`index.mjs`))}function hs(e){return E.join(e,`Contents`,`MacOS`,Li)}function gs(e){let t=Xt(e);if(t!==null){let e=E.join(t,`bin`,`cc-candybar-url-handler-native`);if(!s.existsSync(e))throw Error(`install: the URL handler app is not built at ${e}. Run \`just install-url-handler\` in the checkout.`);return e}let n=_s(e,`bin/${os}`);switch(n.kind){case`found`:return n.path;case`no-package`:throw Error(`install: no URL handler app ships for ${n.platform}; the scheme is macOS-only.`);case`missing`:throw Error(`install: the URL handler app was not found in ${n.pkgName} (bin/${os}). The optional platform package is missing or older than this release: reinstall the package.`)}}function _s(t,n){let r=`${process.platform}-${process.arch}`,i=is[r];if(i===void 0)return{kind:`no-package`,platform:r};try{return{kind:`found`,path:e(t).resolve(`${i}/${n}`)}}catch{return{kind:`missing`,pkgName:i}}}function vs(e){let t=_s(e,`bin/cc-candybar`);return t.kind===`found`?{kind:`native`,sourcePath:t.path}:{kind:`node-shim`,sourcePath:E.resolve(E.dirname(e),`..`,`bin`,`cc-candybar`)}}function ys(e,t){E.resolve(e)!==E.resolve(t)&&s.copyFileSync(e,t)}function bs(e,t){E.resolve(e)!==E.resolve(t)&&(s.rmSync(t,{recursive:!0,force:!0}),s.cpSync(e,t,{recursive:!0}))}function xs(e){let t=s.openSync(e,`r`);try{let n=Buffer.alloc(2),r=s.readSync(t,n,0,2,0);if(r<2)throw Error(`install: staged render entry at ${e} is truncated (${r} byte(s)). Re-run: pnpm dlx ${es}@latest install`);return n.toString(`latin1`)===`#!`?`node-shim`:`native`}finally{s.closeSync(t)}}function Ss(e,t){if(!s.existsSync(e))throw Error(`install: bundled dist not found at ${e}. Reinstall the package.`);let n=vs(e);if(!s.existsSync(n.sourcePath))throw Error(`install: render entry not found at ${n.sourcePath}. Reinstall the package.`);let r=E.join(E.dirname(e),Lt);if(!s.existsSync(r))throw Error(`install: the attach launcher was not found at ${r}. Reinstall the package.`);let i=E.join(E.dirname(e),Bt);if(!s.existsSync(i))throw Error(`install: the attach preload was not found at ${i}. Reinstall the package.`);let a=ps(t),o=fs(t);s.mkdirSync(E.dirname(a),{recursive:!0}),s.mkdirSync(E.dirname(o),{recursive:!0}),ys(e,a),bs(r,E.join(E.dirname(a),Lt)),ys(i,E.join(E.dirname(a),Bt)),ys(n.sourcePath,o),s.chmodSync(o,493),s.rmSync(E.join(t,`url-handler.mjs`),{force:!0});let c=xs(o);return process.stdout.write(`Staged cc-candybar v${M} runtime at ${t}\n`+(c===`native`?` render entry: native binary (${process.platform}-${process.arch})\n`:` render entry: node shim (no native binary for ${process.platform}-${process.arch}; renders are correct but pay node startup)\n`)),{binPath:o,distPath:a,entryKind:c}}function Cs(){return[`<?xml version="1.0" encoding="UTF-8"?>`,`<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">`,`<plist version="1.0">`,`<dict>`,` <key>CFBundleIdentifier</key>`,` <string>com.cccandybar.url-handler</string>`,` <key>CFBundleName</key>`,` <string>${Li}</string>`,` <key>CFBundleDisplayName</key>`,` <string>cc-candybar</string>`,` <key>CFBundleExecutable</key>`,` <string>${Li}</string>`,` <key>CFBundlePackageType</key>`,` <string>APPL</string>`,` <key>CFBundleVersion</key>`,` <string>${M}</string>`,` <key>CFBundleShortVersionString</key>`,` <string>${M}</string>`,` <key>LSMinimumSystemVersion</key>`,` <string>12.0</string>`,` <key>LSBackgroundOnly</key>`,` <true/>`,` <key>CFBundleURLTypes</key>`,` <array>`,` <dict>`,` <key>CFBundleURLName</key>`,` <string>cc-candybar click</string>`,` <key>CFBundleURLSchemes</key>`,` <array>`,` <string>${Ii}</string>`,` </array>`,` </dict>`,` </array>`,`</dict>`,`</plist>`,``].join(`
|
|
36
36
|
`)}function ws(e,{host:t,launcher:n}){let r=ls(t),i=`${r}.installing`,a=hs(i);process.stdout.write(`Building ${r}\n`),s.rmSync(i,{recursive:!0,force:!0});try{s.mkdirSync(E.dirname(a),{recursive:!0}),s.copyFileSync(e,a),s.chmodSync(a,493),s.writeFileSync(E.join(i,`Contents`,`Info.plist`),Cs());let t=n.launchSync({bin:`/usr/bin/codesign`,args:[`--force`,`--sign`,`-`,i],category:`install.codesign`});if(!t.ok)throw process.stderr.write(t.stderr),Error(`codesign failed (${t.reason})`);s.rmSync(r,{recursive:!0,force:!0}),s.renameSync(i,r)}catch(e){throw s.rmSync(i,{recursive:!0,force:!0}),e}let o=n.launchSync({bin:`/usr/bin/killall`,args:[Li],category:`install.killall`});if(!o.ok&&o.exitCode!==1)throw process.stderr.write(o.stderr),Error(`killall ${Li} failed (${o.reason})`);process.stdout.write(o.ok?`Quit the running ${Li}; the next click starts the new one\n`:`${Li} was not running\n`),process.stdout.write(`Registering ${Ii}:// with Launch Services\n`);let c=n.launchSync({bin:`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister`,args:[`-f`,r],category:`install.lsregister`});if(!c.ok)throw process.stderr.write(c.stderr),Error(`lsregister failed (${c.reason})`);process.stdout.write(`✓ ${Li}.app installed and registered.\n`),process.stdout.write(` Test: open '${Ii}://hello-world' && pbpaste\n`)}function Ts(e,t){us();let n=gs(e);Ss(e,ds(t.host)),ws(n,t)}async function Es(e,t){e||(process.stderr.write(`url-handle: missing URL argument.
|
|
37
37
|
`),process.exit(1));let n=wa(e);n.ok||(process.stderr.write(`url-handle: ${n.problem}\n`),process.exit(1));let r=await hr(t,n.verb,n.value);r.kind===`ok`&&process.exit(0);let i=Ds(r);i.kick&&Kr(t),process.stderr.write(i.stderr),process.exit(i.code)}function Ds(e){switch(e.kind){case`busy`:return{stderr:`url-handle: daemon busy (${e.message})\n`,code:+(e.phase===`connect`),kick:!1};case`transient`:return{stderr:`url-handle: daemon unavailable (${e.cause}: ${e.message})\n`,code:1,kick:!0};case`permanent`:return{stderr:Os(e)+`
|
|
38
38
|
`,code:1,kick:!1}}}function Os(e){switch(e.cause){case`version_mismatch`:return`url-handle: daemon rejected click (version mismatch: client v${e.clientV} ≠ daemon v${e.daemonV})`;case`bad_request`:return`url-handle: daemon rejected click (bad request: ${e.message})`;case`render_failed`:return`url-handle: daemon rejected click (handler failed: ${e.message})`;case`switched_off`:return`url-handle: daemon rejected click (switched off: ${e.message})`;case`malformed_response`:return`url-handle: daemon rejected click (malformed response: ${e.message})`}}function ks(){return`✓ install complete.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptctl/cc-candybar",
|
|
3
|
-
"version": "1.184.
|
|
3
|
+
"version": "1.184.1",
|
|
4
4
|
"description": "Statusline renderer for Claude Code — a JSON5-configurable DSL with daemon-cached data sources, byte-clean palette-aware composition, and OSC8 click verbs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -111,9 +111,9 @@
|
|
|
111
111
|
"yaml": "^2.9.1"
|
|
112
112
|
},
|
|
113
113
|
"optionalDependencies": {
|
|
114
|
-
"@promptctl/cc-candybar-darwin-arm64": "1.184.
|
|
115
|
-
"@promptctl/cc-candybar-darwin-x64": "1.184.
|
|
116
|
-
"@promptctl/cc-candybar-linux-arm64": "1.184.
|
|
117
|
-
"@promptctl/cc-candybar-linux-x64": "1.184.
|
|
114
|
+
"@promptctl/cc-candybar-darwin-arm64": "1.184.1",
|
|
115
|
+
"@promptctl/cc-candybar-darwin-x64": "1.184.1",
|
|
116
|
+
"@promptctl/cc-candybar-linux-arm64": "1.184.1",
|
|
117
|
+
"@promptctl/cc-candybar-linux-x64": "1.184.1"
|
|
118
118
|
}
|
|
119
119
|
}
|