@promptctl/cc-candybar 1.178.2 → 1.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ Run the install once to stage the runtime, then point `~/.claude/settings.json`
|
|
|
154
154
|
|
|
155
155
|
`just deploy` builds `dist/index.mjs` and stages the native binary at `bin/cc-candybar-native` — point your statusline command at that path. On a machine without cargo, `pnpm install && pnpm build` builds only the bundle — point your statusline at the committed `bin/cc-candybar` node entry instead. Either way the bar renders HEAD; the daemon watches the built bundle and respawns itself on rebuild.
|
|
156
156
|
|
|
157
|
-
`pnpm bar:web` serves the bar at http://127.0.0.1:7317/ in a browser terminal you can click: an isolated daemon (`--config my.json5` starts it from a copy of your config, `--ssh` shows the host segment). `pnpm site:build` builds the GitHub Pages version into `site/dist`, the same page with the daemon running inside it against a simulated machine (`site/`).
|
|
157
|
+
`pnpm bar:web` serves the bar at http://127.0.0.1:7317/ in a browser terminal you can click: an isolated daemon (`--config my.json5` starts it from a copy of your config, `--ssh` shows the host segment). `pnpm site:build` builds the GitHub Pages version into `site/dist`, the same page with the daemon running inside it against a simulated machine (`site/`). `pnpm site:dev` serves that page at http://127.0.0.1:8931/ (`--port` picks another) and reloads it whenever the sources or the page change.
|
|
158
158
|
|
|
159
159
|
### Config file
|
|
160
160
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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,{basename as s,dirname as c,isAbsolute as l,join as u,sep as d}from"node:path";import f,{closeSync as p,constants as m,existsSync as h,fstatSync as g,linkSync as _,openSync as v,readFileSync as y,readSync as b,rmSync as x,statSync as S,writeFileSync as C}from"node:fs";import ee,{createHash as w,createHmac as te,randomBytes as ne,randomUUID as T,timingSafeEqual as re}from"node:crypto";import E,{homedir as D}from"node:os";import ie from"node:net";import{spawn as O,spawnSync as ae}from"node:child_process";import{StringDecoder as oe}from"node:string_decoder";import{inspect as se,parseArgs as ce,types as le}from"node:util";import{clearInterval as ue,setImmediate as de,setInterval as fe}from"node:timers";import pe from"node:v8";import{open as me,readFile as he,readdir as ge,stat as _e}from"node:fs/promises";import{get as ve}from"node:https";import{setTimeout as ye}from"node:timers/promises";import{WriteStream as be}from"node:tty";import{createInterface as xe}from"node:readline";var Se=Object.create,Ce=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Te=Object.getOwnPropertyNames,Ee=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty,Oe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ke=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Te(t),a=0,o=i.length,s;a<o;a++)s=i[a],!De.call(e,s)&&s!==n&&Ce(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=we(t,s))||r.enumerable});return e},Ae=(e,t,n)=>(n=e==null?{}:Se(Ee(e)),ke(t||!e||!e.__esModule?Ce(n,`default`,{value:e,enumerable:!0}):n,e));const je=()=>!!process.env.CC_CANDYBAR_DEBUG;function Me(e){return je()?`[DEBUG] ${e()}\n`:``}function k(e,...t){je()&&console.error(`[DEBUG] ${e}`,...t)}function Ne(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const Pe=(e,t)=>k(t),Fe=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Ie(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Le(e){return Fe.test(e)?e:Ie(e)}function Re(e){return`${e.dir===void 0?``:`cd ${Le(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${Le(t)} `).join(``)}${[e.program,...e.args].map(Le).join(` `)}`}const ze=`cc-extra`;function Be(e){return o.join(o.dirname(e),ze,`src`,`bun-attach.js`)}function Ve(e){return o.join(o.dirname(e),`bun-graph.js`)}const He=`attach-preload.cjs`;function Ue(e){return o.join(o.dirname(e),He)}function We(e,t){return Re({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const Ge=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Ke(e,t){return t.isSymbolicLink()?Buffer.from(f.readlinkSync(e)):f.readFileSync(e)}function qe(e,t,n=Ge){return f.readdirSync(t).filter(n).sort().flatMap(n=>{let r=o.join(t,n),i=f.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?qe(e,r):[[o.relative(e,r).split(o.sep).join(`/`),Ke(r,i)]]})}function Je(e){let t=ee.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Ye(e){return Je(qe(e,e))}const Xe=[`Cargo.toml`,`Cargo.lock`,`src`];function Ze(e){return Je(qe(e,e,e=>Xe.includes(e)))}const Qe=e=>e.slice(0,7),$e=`1.
|
|
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,{basename as s,dirname as c,isAbsolute as l,join as u,sep as d}from"node:path";import f,{closeSync as p,constants as m,existsSync as h,fstatSync as g,linkSync as _,openSync as v,readFileSync as y,readSync as b,rmSync as x,statSync as S,writeFileSync as C}from"node:fs";import ee,{createHash as w,createHmac as te,randomBytes as ne,randomUUID as T,timingSafeEqual as re}from"node:crypto";import E,{homedir as D}from"node:os";import ie from"node:net";import{spawn as O,spawnSync as ae}from"node:child_process";import{StringDecoder as oe}from"node:string_decoder";import{inspect as se,parseArgs as ce,types as le}from"node:util";import{clearInterval as ue,setImmediate as de,setInterval as fe}from"node:timers";import pe from"node:v8";import{open as me,readFile as he,readdir as ge,stat as _e}from"node:fs/promises";import{get as ve}from"node:https";import{setTimeout as ye}from"node:timers/promises";import{WriteStream as be}from"node:tty";import{createInterface as xe}from"node:readline";var Se=Object.create,Ce=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Te=Object.getOwnPropertyNames,Ee=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty,Oe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ke=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Te(t),a=0,o=i.length,s;a<o;a++)s=i[a],!De.call(e,s)&&s!==n&&Ce(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=we(t,s))||r.enumerable});return e},Ae=(e,t,n)=>(n=e==null?{}:Se(Ee(e)),ke(t||!e||!e.__esModule?Ce(n,`default`,{value:e,enumerable:!0}):n,e));const je=()=>!!process.env.CC_CANDYBAR_DEBUG;function Me(e){return je()?`[DEBUG] ${e()}\n`:``}function k(e,...t){je()&&console.error(`[DEBUG] ${e}`,...t)}function Ne(e){let t=null;return([n,r])=>{r!==t&&(t=r,e(n,r))}}const Pe=(e,t)=>k(t),Fe=/^[A-Za-z0-9_./,:@%+-][A-Za-z0-9_./,:@%+=-]*$/;function Ie(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Le(e){return Fe.test(e)?e:Ie(e)}function Re(e){return`${e.dir===void 0?``:`cd ${Le(e.dir)} && `}${e.env.map(([e,t])=>`${e}=${Le(t)} `).join(``)}${[e.program,...e.args].map(Le).join(` `)}`}const ze=`cc-extra`;function Be(e){return o.join(o.dirname(e),ze,`src`,`bun-attach.js`)}function Ve(e){return o.join(o.dirname(e),`bun-graph.js`)}const He=`attach-preload.cjs`;function Ue(e){return o.join(o.dirname(e),He)}function We(e,t){return Re({...t,env:[...t.env,[`BUN_OPTIONS`,`--preload ${e.replace(/[\\\s]/g,`\\$&`)}`]]})}const Ge=e=>!e.startsWith(`.`)&&!e.endsWith(`~`);function Ke(e,t){return t.isSymbolicLink()?Buffer.from(f.readlinkSync(e)):f.readFileSync(e)}function qe(e,t,n=Ge){return f.readdirSync(t).filter(n).sort().flatMap(n=>{let r=o.join(t,n),i=f.lstatSync(r,{throwIfNoEntry:!1});return i===void 0?[]:i.isDirectory()?qe(e,r):[[o.relative(e,r).split(o.sep).join(`/`),Ke(r,i)]]})}function Je(e){let t=ee.createHash(`sha256`);for(let[n,r]of e)t.update(n).update(`\0`).update(r).update(`\0`);return t.digest(`hex`)}function Ye(e){return Je(qe(e,e))}const Xe=[`Cargo.toml`,`Cargo.lock`,`src`];function Ze(e){return Je(qe(e,e,e=>Xe.includes(e)))}const Qe=e=>e.slice(0,7),$e=`1.179.0`;function et(e){let t=o.dirname(o.dirname(e));return f.existsSync(o.join(t,`src`))?t:null}function tt(e){if(e===null)throw Error("this bundle carries no source digest (build via `pnpm build`, which stamps it)");return{version:$e,digest:e}}function nt(){return`901e9c7a3b6d41944ffeea1a781f8187e176a75c42bbf17bdcc79e9f537cb6cc`}function rt(e){let t=JSON.parse(f.readFileSync(o.join(e,`package.json`),`utf8`)),n=typeof t==`object`&&t?t.version:void 0;if(typeof n!=`string`)throw Error(`${o.join(e,`package.json`)} has no version string`);return n}function it(e,t){try{let n=et(i(e));if(n===null)return{kind:`not-source-checkout`};let r=t(),a=Ye(o.join(n,`src`));return a===r.digest?{kind:`current`,root:n,stamp:r}:{kind:`stale`,root:n,source:{version:rt(n),digest:a},running:r}}catch(e){return{kind:`unchecked`,reason:e.message}}}function at(e,t,n){let r=ot(e);f.mkdirSync(o.dirname(r),{recursive:!0});let i=`${r}.tmp`,a=n??f.statSync(r,{throwIfNoEntry:!1})?.mode;try{f.writeFileSync(i,t,a===void 0?{}:{mode:a}),f.renameSync(i,r)}catch(e){throw f.rmSync(i,{force:!0}),e}}function ot(e){return st(e).at(-1)}function st(e){let{hops:t,stopped:n}=ct(e);if(n!==null)throw n;return t}function ct(e){let t=[e];try{for(let e=0;e<ut;e++){let e=lt(t[t.length-1]);if(e===null)return{hops:t,stopped:null};t.push(e)}return{hops:t,stopped:Error(`${e}: more than ${ut} symbolic links`)}}catch(e){return{hops:t,stopped:e}}}function lt(e){try{return f.lstatSync(e).isSymbolicLink()?o.resolve(f.realpathSync(o.dirname(e)),f.readlinkSync(e)):null}catch(e){let{code:t}=e;if(t===`ENOENT`||t===`ENOTDIR`)return null;throw e}}const ut=40;function dt(e,t){let n=e[t];return n&&n.length>0?n:void 0}function ft(e=process.env){let t=dt(e,`XDG_STATE_HOME`)??o.join(E.homedir(),`.local`,`state`);return o.join(t,`cc-candybar`)}function pt(){let e=dt(process.env,`XDG_CACHE_HOME`)??o.join(E.homedir(),`.cache`);return o.join(e,`cc-candybar`)}function mt(){return ft()}function ht(){return process.env.CC_CANDYBAR_SOCKET||gt()}function gt(){let e=E.userInfo().uid;return o.join(`/tmp`,`cc-candybar-${e}`,`socket`)}function _t(e){f.mkdirSync(e,{recursive:!0,mode:448});let t=f.lstatSync(e);if(t.isSymbolicLink())throw Error(`directory is a symlink: ${e}`);if(!t.isDirectory())throw Error(`not a directory: ${e}`);let n=E.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 vt(e){_t(o.dirname(e));for(let t of[e,yt(e)])try{if(f.lstatSync(t).isSymbolicLink())throw Error(`path is a symlink: ${t}`)}catch(e){if(e.code!==`ENOENT`)throw e}}function yt(e){return`${e}.lease`}function bt(){return yt(ht())}function xt(e=process.env){return o.join(ft(e),`session-state.json`)}function St(){return o.join(ft(),`settings-history.json`)}function Ct(){let e=process.env.CC_CANDYBAR_DAEMON_REGISTRY_DIR;if(e)return e;let t=E.userInfo().uid;return o.join(`/tmp`,`cc-candybar-${t}`,`daemons`)}function wt(){return o.join(ft(),`spawn.lock`)}function Tt(){return o.join(ft(),`spawn.cooldown`)}function Et(){return o.join(ft(),`spawn.backoff`)}function Dt(){return o.join(ft(),`watch-probe`)}function Ot(e=process.env){return o.join(ft(e),`daemon.log`)}const kt=[`TERM_PROGRAM`,`TERM_PROGRAM_VERSION`,`TERM`,`ITERM_PROFILE`,`XDG_CONFIG_HOME`];function At(e){return Object.fromEntries(kt.flatMap(t=>{let n=e[t]??``;return n===``?[]:[[t,n]]}))}const jt=[`native`,`node`,`frames`];function Mt(e,t){return{kind:e,bundle:t,source:null}}const Nt=[`ansi`,`frame`],Pt=Object.keys({termCols:!0,termRows:!0,ssh:!0,tmux:!0,configEnv:!0,claudeConfigDir:!0,terminalEnv:!0,client:!0});function Ft(e){let t=Wt(e.termCols),n=Wt(e.termRows),r=A(e.ssh),i=Ht(e.tmux),a=Vt(e.configEnv),o=Vt(e.claudeConfigDir),s=Bt(e.terminalEnv),c=j(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 It(e,t){return Pt.filter(n=>e[n]!==void 0&&t[n]===void 0).map(t=>({hint:t,sent:e[t]}))}function Lt(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 Rt={unknown:e=>`Unknown flags: ${e}`,"no-value":e=>`${e} names no file — the bar renders with no ${e}`,positional:e=>`Unexpected arguments: ${e}`};function zt(e){let t=Object.keys(Rt).flatMap(t=>{let n=e.filter(e=>e.why===t).map(e=>e.arg);return n.length===0?[]:[Rt[t](n.join(`, `))]});return t.length===0?null:t.join(`
|
|
3
3
|
`)}function Bt(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n=kt.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 Vt(e){return typeof e==`string`&&o.isAbsolute(e)?e:void 0}function Ht(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 Ut=1e4;function Wt(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.floor(e);if(!(t<=0))return t>Ut?Ut:t}function A(e){return typeof e==`boolean`?e:void 0}function Gt(e){return typeof e==`string`&&e!==``&&e.length<=64?e:null}var Kt=class extends Error{constructor(e){super(e),this.name=`ProtocolError`}};function qt(e){return Jt(JSON.stringify(e))}function Jt(e){let t=Buffer.from(e,`utf8`),n=Buffer.alloc(4);return n.writeUInt32BE(t.length,0),Buffer.concat([n,t])}function Yt(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 Kt(`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 Kt(e instanceof Error?e.message:String(e));e instanceof Error&&(n.cause=e),t(n);return}}}}function Xt(e,t,n){return new Promise((r,i)=>{let a=!1,o=t=>{if(!a){a=!0,clearTimeout(s),e.off(`data`,c),e.off(`error`,l),e.off(`close`,u);try{t()}catch{}}},s=setTimeout(()=>{o(()=>{e.destroy(),i(Error(`TIMEOUT`))})},n-Date.now()),c=Yt(e=>o(()=>r(e)),e=>o(()=>i(e))),l=e=>o(()=>i(e)),u=()=>o(()=>i(Error(`socket closed before response`)));e.on(`data`,c),e.on(`error`,l),e.on(`close`,u),e.write(qt(t))})}function j(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let{kind:t,bundle:n,source:r}=e,i=Vt(n);return jt.includes(t)&&i!==void 0&&(r===null||typeof r==`string`&&r!==``)?{kind:t,bundle:i,source:r}:void 0}async function Zt(e,t,n){let r=null;try{r=await nn(ht(),t.connectMs);let i=Date.now()+t.budgetMs,a=e(i),o=await Xt(r,{v:3,...a},i);return en(a.kind,o,n)}catch(e){return tn(e)}finally{r&&r.destroy()}}function Qt(e,t){return typeof e==`string`?e:t}function $t(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0?e:0}function en(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=Qt(r.error,`(no error message)`);switch(r.code){case`VERSION_MISMATCH`:return{kind:`permanent`,cause:`version_mismatch`,clientV:3,daemonV:$t(r.daemonV)};case`TIMEOUT`:return{kind:`transient`,cause:`timeout`,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 tn(e){if(e instanceof Kt||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 t===`CONNECT_TIMEOUT`||t===`TIMEOUT`?{kind:`transient`,cause:`timeout`,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 nn(e,t){return new Promise((n,r)=>{let i=ie.createConnection({path:e}),a=setTimeout(()=>{i.destroy(),r(Error(`CONNECT_TIMEOUT`))},t);i.once(`connect`,()=>{clearTimeout(a),n(i)}),i.once(`error`,e=>{clearTimeout(a),r(e)})})}function rn(e){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}`}}const an={connectMs:50,budgetMs:150},on={connectMs:50,budgetMs:200};function sn(e){let t=e.output;return typeof t==`string`?t:void 0}function cn(e){return en(`render`,e,sn)}function ln(e,t,n,r){return Zt(i=>({kind:`render`,hookData:e,args:t,cwd:n,deadline:i,...r}),an,sn)}function un(e,t){return Zt(()=>({kind:`pane-session`,socket:e,pane:t}),on,e=>`paneSession`in e?e.paneSession:void 0)}function dn(e,t){return Zt(()=>({kind:`click`,verb:e,value:t,clientVersion:$e}),on,sn)}function fn(e,t){return le.isNativeError(e)?e.code===`ENOENT`&&t!==void 0&&!h(t)?`working directory does not exist: ${t}`:e.message:String(e)}const pn={"click.pbcopy":1e3,"click.open":1e3,"doctor.tmux":1e3,"doctor.font":1e3,"doctor.process":1e3,"claude-input.type":1e3};function mn(e,t){let n=pn[t];if(n===void 0)return{allowed:!0};let r=e.get(t);if(r===void 0)return{allowed:!0};let i=Date.now()-r;return i>=n?{allowed:!0}:{allowed:!1,minIntervalMs:n,sinceLastMs:i}}function hn(e){return e.env??process.env}const gn=({reason:e})=>({ok:!1,reason:`aborted`,stdout:``,stderr:``,exitCode:null,signal:null,error:e instanceof Error?e.message:String(e)});function _n(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 ${n}ms ago`}}function vn(e,t){let n=t.finally(()=>e.ending.delete(n));return e.ending.add(n),n}function yn(e,t,n){let r=bn(e,t,n);return r===null?(e.lastStartAt.set(t,Date.now()),null):(e.scope.stats?.onRefused(t),r)}function bn(e,t,n){if(e.scope.signal.aborted)return gn(e.scope.signal);if(n?.aborted)return gn(n);let r=mn(e.lastStartAt,t);return r.allowed?null:_n(t,r.minIntervalMs,r.sinceLastMs)}const xn=`\$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 Sn(e,t){t!==e.fault&&(e.fault=t,e.scope.observeLifeline(t))}function Cn(e,t,n){e.lifeline?.process===t&&(e.lifeline=null,t.ref(),Sn(e,n))}function wn(e){return e.fault===null?[]:[{kind:`lifeline`,message:`programs launched now would outlive their launcher if it died: its launch lifeline ${e.fault}, and the next launch starts another`}]}function Tn(e){let{stats:t}=e.scope;t?.onStart(`lifeline`);let n=Date.now(),r;try{r=O(`awk`,[xn],{stdio:[`pipe`,`ignore`,`ignore`],detached:!0})}catch(r){return t?.onEnd(`lifeline`,Date.now()-n),Sn(e,`did not start: ${fn(r,void 0)}`),null}t?.onEnd(`lifeline`,Date.now()-n);let i=r.stdin;if(i==null)return r.once(`error`,t=>Sn(e,`did not start: ${t.message}`)),null;r.once(`spawn`,()=>{e.lifeline?.process===r&&Sn(e,null)}),r.once(`error`,t=>Cn(e,r,`failed: ${t.message}`)),r.once(`exit`,(t,n)=>Cn(e,r,`exited ${n??t}`)),i.on(`error`,t=>Cn(e,r,`pipe failed: ${t.message}`)),vn(e,new Promise(e=>r.once(`close`,e))),r.unref(),i.unref();for(let t of e.liveGroups)i.write(`+ ${t}\n`);return{process:r,pipe:i}}function En(e,t){e.liveGroups.add(t),e.lifeline??=Tn(e),e.lifeline?.pipe.write(`+ ${t}\n`)}function M(e,t){e.liveGroups.delete(t),e.lifeline?.pipe.write(`- ${t}\n`)}function Dn(e){let t=e.lifeline;e.lifeline=null,t?.process.ref(),t?.pipe.end()}function On(e,t){try{process.kill(-e,t)}catch(t){let n=t.code;if(n!==`ESRCH`&&!(n===`EPERM`&&!kn(e)))throw t}}function kn(e){try{return process.kill(e,0),!1}catch(e){return e.code===`EPERM`}}function An(e){let t=new oe(`utf8`),n=``,r=e=>{n+=t.write(e)};return e?.on(`data`,r),()=>{e?.off(`data`,r);let i=n+t.end();return n=``,i}}async function jn(e,t){let{stats:n}=e.scope,r=yn(e,t.category,t.signal);if(r!==null)return r;let i=Date.now();return n?.onStart(t.category),new Promise(r=>{let a;try{a=O(t.bin,t.args??[],{cwd:t.cwd,env:hn(t),stdio:[`pipe`,`pipe`,`pipe`],detached:!0})}catch(e){n?.onEnd(t.category,Date.now()-i),r({ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:fn(e,t.cwd)});return}let o=a.pid;o!==void 0&&En(e,o);let s=new Promise(e=>a.once(`exit`,e)),c=An(a.stdout),l=An(a.stderr),u=()=>({stdout:c(),stderr:l()}),d=!1,f=null,p=null,m=null,h=null,g=()=>S(`aborted`),_=()=>{t.signal?.removeEventListener(`abort`,g),e.inFlight.delete(g)},v=r=>{if(!d){d=!0,f&&clearTimeout(f),p&&clearTimeout(p),m&&clearTimeout(m),_(),o!==void 0&&M(e,o),n?.onEnd(t.category,Date.now()-i);for(let e of[a.stdout,a.stderr])e?.unref();r()}},y=e=>v(()=>r(e)),b=(n,r)=>{try{On(n,r)}catch(n){e.unreaped.set(a,t.category),s.then(()=>e.unreaped.delete(a)),y({ok:!1,reason:`signal-refused`,...u(),exitCode:null,signal:null,error:n instanceof Error?n.message:String(n)})}},x=()=>C(a.exitCode,a.signalCode);if(o!==void 0){let e=t=>{if(!d){if(Bn(o)){de(x);return}m=setTimeout(()=>e(Math.min(t*2,1e3)),t)}};s.then(()=>de(()=>e(25)))}let S=e=>{if((a.exitCode!==null||a.signalCode!==null)&&o!==void 0&&Bn(o)){h=e===`aborted`?e:null,de(x);return}h=e,f&&clearTimeout(f),_();let t=a.pid;t!==void 0&&(p=setTimeout(()=>{b(t,`SIGKILL`),s.then(()=>de(x))},250),b(t,`SIGTERM`))};a.on(`error`,e=>{y({ok:!1,reason:`spawn-error`,...u(),exitCode:null,signal:null,error:fn(e,t.cwd)})});let C=(e,t)=>{if(h!==null){y({ok:!1,reason:h,...u(),exitCode:e,signal:t});return}if(e===0){y({ok:!0,...u(),exitCode:e});return}y({ok:!1,reason:t?`signal`:`non-zero`,...u(),exitCode:e,signal:t})};a.on(`close`,C),t.timeoutMs&&t.timeoutMs>0&&(f=setTimeout(()=>S(`timeout`),t.timeoutMs)),t.signal?.addEventListener(`abort`,g,{once:!0}),e.inFlight.add(g),a.stdin?.on(`error`,()=>{}),a.stdin?.end(t.stdinInput)})}function Mn(e,t){let{stats:n}=e.scope,r=yn(e,t.category);if(r!==null)return r;let i=Date.now();n?.onStart(t.category);let a=[`pipe`,`pipe`,`pipe`];try{let e=ae(t.bin,t.args??[],{cwd:t.cwd,env:hn(t),input:t.stdinInput,timeout:t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:void 0,stdio:a,encoding:`utf8`});n?.onEnd(t.category,Date.now()-i);let r=typeof e.stdout==`string`?e.stdout:``,o=typeof e.stderr==`string`?e.stderr:``,s=e.error?.code;return e.error&&s!==`EPIPE`&&s!==`ECONNRESET`?{ok:!1,reason:s===`ETIMEDOUT`?`timeout`:`spawn-error`,stdout:r,stderr:o,exitCode:null,signal:e.signal??null,error:fn(e.error,t.cwd)}:e.status===0?{ok:!0,stdout:r,stderr:o,exitCode:e.status}:{ok:!1,reason:e.signal?`signal`:`non-zero`,stdout:r,stderr:o,exitCode:e.status,signal:e.signal??null}}catch(e){return n?.onEnd(t.category,Date.now()-i),{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:fn(e,t.cwd)}}}function Nn(e,t){let{stats:n}=e.scope,r=yn(e,t.category);if(r!==null)return r;let i=Date.now();n?.onStart(t.category);let a=Pn(t);return n?.onEnd(t.category,Date.now()-i),a}function Pn(e){let t;try{t=O(e.bin,e.args??[],{cwd:e.cwd,env:hn(e),detached:!0,stdio:`ignore`})}catch(t){return{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:fn(t,e.cwd)}}return t.once(`error`,()=>{}),t.pid===void 0?{ok:!1,reason:`spawn-error`,stdout:``,stderr:``,exitCode:null,signal:null,error:`spawn(${e.bin}): no pid (binary not found or unexecutable)`}:(t.unref(),{ok:!0,stdout:``,stderr:``,exitCode:null})}const Fn=e=>e.kind===`exit`?`exit ${e.code}`:`timeout`;function In(e,t,n){let{stats:r}=e.scope,i=yn(e,t.category);if(i!==null)return{ok:!1,error:i.error};let a=Date.now();r?.onStart(t.category);let o;try{o=O(`/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:hn(t),detached:!0,stdio:[`pipe`,`ignore`,`ignore`]})}catch(e){return r?.onEnd(t.category,Date.now()-a),{ok:!1,error:fn(e,t.cwd)}}r?.onEnd(t.category,Date.now()-a),o.once(`error`,()=>{});let s=o.pid,c=o.stdin;return c.on(`error`,()=>{}),s===void 0?(c.destroy(),{ok:!1,error:`spawn(/bin/sh): no pid (shell not found or unexecutable)`}):(o.unref(),c.unref(),{ok:!0,pid:s,release:()=>c.end(`go
|
|
4
4
|
`),withdraw:()=>c.end()})}function Ln(e){let t;try{t=y(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 Rn(e,t){try{return process.kill(-e,t),!0}catch(e){let t=e.code;if(t===`ESRCH`||t===`EPERM`)return!1;throw e}}function zn(e){return Rn(e,0)}function Bn(e){try{return process.kill(-e,0),!1}catch(e){return e.code===`ESRCH`}}function Vn(e,t,n){let r=`${t}.${process.pid}`;try{C(r,`${Fn(n)}\n`)}catch(e){if(e.code===`ENOENT`)return{stands:!1,signalled:!1};throw e}let i=!0;try{_(r,t)}catch(e){if(e.code!==`EEXIST`)throw e;i=!1}finally{x(r,{force:!0})}let a=Rn(e,`SIGTERM`);return a&&setTimeout(()=>Rn(e,`SIGKILL`),250).unref(),{stands:i,signalled:a}}function Hn(e){let t={launch:e=>vn(n,jn(n,e)),launchSync:e=>Mn(n,e),launchDetachedSync:e=>Nn(n,e),launchJobSync:(e,t)=>In(n,e,t),lifelineWarnings:()=>wn(n),settled:async()=>(await Promise.all(n.ending),{unreaped:[...n.unreaped.values()]}),__lifelineForTest:()=>{let e=n.lifeline;return{pid:e?.process.pid,cut:()=>{e?.pipe.end(),e&&Cn(n,e.process,`cut by a test`)}}}},n={scope:{stats:null,observeLifeline:()=>t.lifelineWarnings().forEach(e=>process.emitWarning(e.message)),signal:new AbortController().signal,...e},lastStartAt:new Map,inFlight:new Set,liveGroups:new Set,lifeline:null,fault:null,ending:new Set,unreaped:new Map};return n.scope.signal.addEventListener(`abort`,()=>{n.inFlight.forEach(e=>e()),Dn(n)},{once:!0}),t}const Un=Hn({});let Wn=null;function Gn(){if(Wn!==null){try{f.closeSync(Wn.fd)}catch{}Wn=null}}async function Kn(e){let t=await f.promises.stat(e).catch(()=>null);if(Wn!==null&&Wn.path===e&&t!==null&&Wn.id===qn(t))return{held:Wn,size:t.size};Gn(),await f.promises.mkdir(o.dirname(e),{recursive:!0});let n=await new Promise((t,n)=>f.open(e,`a`,(e,r)=>e===null?t(r):n(e))),r=await new Promise((e,t)=>f.fstat(n,(n,r)=>n===null?e(r):t(n)));return Wn={path:e,fd:n,id:qn(r)},{held:Wn,size:r.size}}function qn(e){return`${e.dev}:${e.ino}`}function Jn(e,t){return new Promise((n,r)=>f.write(e,t,(e,t)=>e===null?n(t):r(e)))}async function Yn(e){for(let t=2;t>=1;t--)await f.promises.rename(`${e}.${t}`,`${e}.${t+1}`).catch(()=>{});await f.promises.rename(e,`${e}.1`).catch(()=>{})}let Xn=[],Zn=0,Qn=0,$n=0,er=null,tr=!1;const nr=[];let rr=!1,ir=!1;function ar(e,t){return`${new Date().toISOString()} [${e}] ${t}\n`}function or(e,t){let n=ar(e,t);if(ir||(ir=!0,process.on(`exit`,()=>{rr=!0,pr(!0,dr)})),Xn.push(n),Zn+=Buffer.byteLength(n),Zn>4194304){let e=0;for(;Zn>4194304/2&&e<Xn.length-1;){let t=Buffer.byteLength(Xn[e]);Zn-=t,$n+=t,e++}Xn.splice(0,e),Qn+=e}rr?pr(!0,dr):tr||cr()}function sr(){pr(!1,fr)}async function cr(){tr=!0;try{for(;Xn.length>0;){let e=lr();er={bytes:Buffer.from(e),state:{kind:`taken`}};try{await ur(Ot(),er)}catch(t){Gn(),er.state.kind!==`landed`&&hr(e,t)}finally{er=null}}}finally{tr=!1;for(let e of nr.splice(0))e()}}function lr(){let e=(Qn===0?``:ar(`warn`,`log: ${Qn} earlier line(s) dropped (${$n} bytes): more than 4194304 bytes were waiting for the disk`))+Xn.join(``);return Xn=[],Zn=0,Qn=0,$n=0,e}async function ur(e,t){let{held:n,size:r}=await Kn(e);if(t.state.kind===`landed`)return;let{bytes:i}=t,a=r+i.length;t.state={kind:`issued`,fd:n.fd,endsAt:a};for(let e=0;e<i.length;){let t=await Jn(n.fd,i.subarray(e));if(t===0)throw Error(`the disk took 0 bytes of a write`);e+=t}if(t.state={kind:`landed`},a>=5242880){Gn();let e=await f.promises.stat(n.path).catch(()=>null);e!==null&&qn(e)===n.id&&await Yn(n.path)}}const dr=1e3,fr=2e3;function pr(e,t){let n=er,r=Buffer.alloc(0);n!==null&&n.state.kind===`taken`&&(r=n.bytes,n.state={kind:`landed`});let i=null;if(n!==null&&n.state.kind===`issued`){let{fd:a,endsAt:o}=n.state;try{let s=mr(a,o,t);s<o&&e?(r=n.bytes.subarray(Math.max(0,s-(o-n.bytes.length))),n.state={kind:`landed`}):s<o&&(i={fd:a,endsAt:o})}catch(t){e&&(r=n.bytes,n.state={kind:`landed`}),hr(n.bytes.toString(),t)}}if(r.length===0&&Xn.length===0)return;let a=Buffer.concat([r,Buffer.from(lr())]);try{let e=Ot();f.mkdirSync(o.dirname(e),{recursive:!0}),f.appendFileSync(e,a),i!==null&&n!==null&&qn(f.fstatSync(i.fd))===qn(f.statSync(e))&&(n.state={kind:`issued`,fd:i.fd,endsAt:i.endsAt+a.length})}catch(e){hr(a.toString(),e)}}function mr(e,t,n){let r=performance.now()+n,i=new Int32Array(new SharedArrayBuffer(4));for(;;){let{size:n}=f.fstatSync(e);if(n>=t||performance.now()>=r)return n;Atomics.wait(i,0,0,1)}}function hr(e,t){try{process.stderr.write(`${e}cc-candybar: daemon.log unwritable: ${t.message}\n`)}catch{}}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=f.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(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptctl/cc-candybar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.179.0",
|
|
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",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"bar": "node --require ./scripts/version-stamp.cjs --import tsx scripts/drive-bar.ts",
|
|
31
31
|
"bar:web": "node --require ./scripts/version-stamp.cjs --import tsx scripts/bar-web.ts",
|
|
32
32
|
"site:build": "node site/build.mjs",
|
|
33
|
+
"site:dev": "node site/build.mjs --serve",
|
|
33
34
|
"bench": "node --require ./scripts/version-stamp.cjs --import tsx scripts/bench/index.ts",
|
|
34
35
|
"load-gate": "node --require ./scripts/version-stamp.cjs --import tsx scripts/load-gate.ts",
|
|
35
36
|
"check:protocol": "node scripts/check-protocol.mjs",
|
|
@@ -105,9 +106,9 @@
|
|
|
105
106
|
"typescript": "^5.0.0"
|
|
106
107
|
},
|
|
107
108
|
"optionalDependencies": {
|
|
108
|
-
"@promptctl/cc-candybar-darwin-arm64": "1.
|
|
109
|
-
"@promptctl/cc-candybar-darwin-x64": "1.
|
|
110
|
-
"@promptctl/cc-candybar-linux-arm64": "1.
|
|
111
|
-
"@promptctl/cc-candybar-linux-x64": "1.
|
|
109
|
+
"@promptctl/cc-candybar-darwin-arm64": "1.179.0",
|
|
110
|
+
"@promptctl/cc-candybar-darwin-x64": "1.179.0",
|
|
111
|
+
"@promptctl/cc-candybar-linux-arm64": "1.179.0",
|
|
112
|
+
"@promptctl/cc-candybar-linux-x64": "1.179.0"
|
|
112
113
|
}
|
|
113
114
|
}
|