tweakcc 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import{Box as e,Text as t,render as n,useInput as r,useStdout as i}from"ink";imp
5
5
  `);z(a);let s=Math.max(...i.map(e=>e.length)),c=Math.min(75,Math.max(50,Math.ceil(s/o*100)));V(c+5)}catch{z(`Error generating figlet text`),V(50)}else{let e=Math.floor(o*.6),t=H?W:g,n=t.split(`
6
6
  `),r=n.map(t=>t.length>e?t.substring(0,e-3)+`...`:t),i=r.join(`
7
7
  `);z(i);let a=Math.max(...r.map(e=>e.length)),s=Math.min(75,Math.max(50,Math.ceil(a/o*100)));V(s+5)}};return l(()=>{if(A){let e=E.filter(e=>e.toLowerCase().includes(A.toLowerCase()));k(e),I(0)}else{k(E);let e=E.indexOf(h);I(e>=0?e:0)}},[A,E]),l(()=>{if(!N){let e=O.indexOf(h);e>=0&&I(e)}},[h,O,N]),r((e,t)=>{if(H){t.return?(v(s===`figlet`?e=>{e.launchText.figletText=W}:e=>{e.launchText.customText=W}),U(!1)):t.escape?(G(s===`figlet`?m:g),U(!1)):t.backspace||t.delete?G(e=>e.slice(0,-1)):e&&G(t=>t+e);return}if(N){if(t.return)O.length>0&&v(e=>{e.launchText.figletFont=O[F]}),P(!1),j(``);else if(t.escape)P(!1),j(``);else if(t.backspace||t.delete)j(e=>e.slice(0,-1));else if(t.upArrow){let e=F>0?F-1:O.length-1;I(e),O.length>0&&v(t=>{t.launchText.figletFont=O[e]})}else if(t.downArrow){let e=F<O.length-1?F+1:0;I(e),O.length>0&&v(t=>{t.launchText.figletFont=O[e]})}else e&&e.match(/^[a-zA-Z0-9\s\-_]$/)&&j(t=>t+e);return}if(t.escape)n();else if(t.return)C===`text`&&(G(s===`figlet`?m:g),U(!0));else if(t.tab)t.shift?S(e=>e===0?y.length-1:e-1):S(e=>e===y.length-1?0:e+1);else if(t.upArrow){if(C===`method`){let e=w>0?w-1:1;T(e),v(t=>{t.launchText.method=e===0?`figlet`:`custom`})}else if(C===`font`&&s===`figlet`){let e=F>0?F-1:O.length-1;I(e),v(t=>{t.launchText.figletFont=O[e]})}}else if(t.downArrow){if(C===`method`){let e=w<1?w+1:0;T(e),v(t=>{t.launchText.method=e===0?`figlet`:`custom`})}else if(C===`font`&&s===`figlet`){let e=F<O.length-1?F+1:0;I(e),v(t=>{t.launchText.figletFont=O[e]})}}else e&&C===`font`&&s===`figlet`&&e.match(/^[a-zA-Z0-9]$/)&&(P(!0),j(e))}),p(e,{children:[p(e,{flexDirection:`column`,width:`${100-B}%`,children:[p(e,{marginBottom:1,flexDirection:`column`,children:[f(M,{children:`Setup banner`}),p(e,{flexDirection:`column`,children:[p(t,{dimColor:!0,children:[`enter to `,C===`text`?`edit text`:`save`]}),f(t,{dimColor:!0,children:`esc to go back`}),f(t,{dimColor:!0,children:`tab to switch sections`})]})]}),f(e,{children:p(t,{children:[f(t,{color:C===`method`?`yellow`:void 0,children:C===`method`?`❯ `:` `}),f(t,{bold:!0,color:C===`method`?`yellow`:void 0,children:`Method`})]})}),C===`method`&&p(t,{dimColor:!0,children:[` `,`select one of `,O.length,` Figlet fonts or enter your own text`]}),f(e,{marginLeft:2,marginBottom:1,children:p(e,{flexDirection:`column`,children:[p(t,{color:w===0?`cyan`:`white`,children:[w===0?`❯ `:` `,`Figlet`]}),p(t,{color:w===1?`cyan`:`white`,children:[w===1?`❯ `:` `,`Custom`]})]})}),p(e,{flexDirection:`column`,children:[p(t,{children:[f(t,{color:C===`text`?`yellow`:void 0,children:C===`text`?`❯ `:` `}),f(t,{bold:!0,color:C===`text`?`yellow`:void 0,children:`Text`})]}),C===`text`&&(H?p(t,{dimColor:!0,children:[` `,`esc to save`]}):p(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{borderStyle:`round`,borderColor:H?`yellow`:`gray`,children:f(t,{children:H?W:s===`figlet`?m:g})})}),s===`figlet`&&p(d,{children:[f(e,{children:p(e,{flexDirection:`column`,children:[p(t,{children:[f(t,{color:C===`font`?`yellow`:void 0,children:C===`font`?`❯ `:` `}),f(t,{bold:!0,color:C===`font`?`yellow`:void 0,children:`Font`})]}),C===`font`&&p(t,{dimColor:!0,children:[` `,`type to filter`]}),f(t,{children:N&&p(t,{color:`gray`,dimColor:!0,children:[` `,`(filtering: “`,A,`”)`]})})]})}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,F-4),n=Math.min(O.length,e+8),r=Math.max(0,n-8),i=O.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return p(t,{color:F===i?`cyan`:void 0,children:[F===i?`❯ `:` `,e]},e)}),n<O.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,O.length-n,` more below`]})]})})()})})]})]}),p(e,{width:`${B}%`,flexDirection:`column`,children:[f(e,{marginBottom:1,children:f(t,{bold:!0,children:`Preview`})}),p(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:[p(e,{flexDirection:`column`,marginBottom:1,children:[f(t,{color:J,children:`╭──────────────────────────╮`}),p(t,{children:[f(t,{color:J,children:`│ ✻`}),` Welcome to Claude Code`,` `,f(t,{color:J,children:`│`})]}),f(t,{color:J,children:`╰──────────────────────────╯`})]}),L.split(`
8
- `).map((e,n)=>f(t,{color:J,children:e},n)),f(e,{marginTop:1,children:f(t,{wrap:`truncate-end`,children:`Claude Code can now be used with your Claude subscription or billed based on API usage through your Console account.`})})]})]})]})}function te({onBack:n}){let{settings:{thinkingVerbs:{format:i,verbs:a},themes:o},updateSettings:s}=c($),l=[`format`,`verbs`],[m,h]=u(0),g=l[m],[_,v]=u(0),[y,b]=u(!1),[x,S]=u(``),[C,w]=u(!1),[E,D]=u(!1),[O,k]=u(i),A=R(),j=o.find(e=>e.id===A)||o.find(e=>e.id===`dark`),N=j?.colors.claude||`rgb(215,119,87)`;return r((e,t)=>{if(E){t.return?(s(e=>{e.thinkingVerbs.format=O}),D(!1)):t.escape?(k(i),D(!1)):t.backspace||t.delete?k(e=>e.slice(0,-1)):e&&k(t=>t+e);return}if(y||C){t.return&&x.trim()?(C?(s(e=>{e.thinkingVerbs.verbs.push(x.trim())}),w(!1)):(s(e=>{e.thinkingVerbs.verbs[_]=x.trim()}),b(!1)),S(``)):t.escape?(S(``),b(!1),w(!1)):t.backspace||t.delete?S(e=>e.slice(0,-1)):e&&S(t=>t+e);return}t.escape?n():t.return?g===`format`&&(k(i),D(!0)):t.tab?t.shift?h(e=>e===0?l.length-1:e-1):h(e=>e===l.length-1?0:e+1):t.upArrow?g===`verbs`&&a.length>0&&v(e=>e>0?e-1:a.length-1):t.downArrow?g===`verbs`&&a.length>0&&v(e=>e<a.length-1?e+1:0):e===`e`&&g===`verbs`?a.length>0&&(S(a[_]),b(!0)):e===`d`&&g===`verbs`?a.length>1&&(s(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==_)}),_>=a.length-1&&v(Math.max(0,a.length-2))):e===`n`&&g===`verbs`?(w(!0),S(``)):t.ctrl&&e===`r`&&g===`verbs`&&(s(e=>{e.thinkingVerbs.verbs=[...T.thinkingVerbs.verbs]}),v(0))}),p(e,{children:[p(e,{flexDirection:`column`,width:`50%`,children:[p(e,{marginBottom:1,flexDirection:`column`,children:[f(M,{children:`Thinking Verbs`}),p(e,{flexDirection:`column`,children:[f(t,{dimColor:!0,children:g===`format`?`enter to edit format`:`changes auto-saved`}),f(t,{dimColor:!0,children:`esc to go back`}),f(t,{dimColor:!0,children:`tab to switch sections`})]})]}),f(e,{marginBottom:1,children:f(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),p(e,{flexDirection:`column`,children:[p(t,{children:[f(t,{color:g===`format`?`yellow`:void 0,children:g===`format`?`❯ `:` `}),f(t,{bold:!0,color:g===`format`?`yellow`:void 0,children:`Format`})]}),g===`format`&&(E?p(t,{dimColor:!0,children:[` `,`enter to save`]}):p(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:f(t,{children:E?O:i})})}),f(e,{children:p(t,{children:[f(t,{color:g===`verbs`?`yellow`:void 0,children:g===`verbs`?`❯ `:` `}),f(t,{bold:!0,color:g===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),g===`verbs`&&f(e,{flexDirection:`column`,children:p(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),f(e,{marginLeft:2,marginBottom:1,children:p(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,_-4),n=Math.min(a.length,e+8),r=Math.max(0,n-8),i=a.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return p(t,{color:g===`verbs`&&i===_?`cyan`:void 0,children:[g===`verbs`&&i===_?`❯ `:` `,e]},i)}),n<a.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),C&&p(e,{alignItems:`center`,children:[f(t,{color:`yellow`,children:`❯ `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:x})})]}),y&&p(e,{marginTop:1,alignItems:`center`,children:[f(t,{children:`Editing: `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:x})})]})]})})]}),p(e,{width:`50%`,flexDirection:`column`,children:[f(e,{marginBottom:1,children:f(t,{bold:!0,children:`Preview`})}),f(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:p(t,{children:[p(t,{color:N,children:[`✻ `,i.replace(/\{\}/g,a[_]),` `]}),f(t,{color:j?.colors.secondaryText,children:`(10s · ↑ 456 tokens · esc to interrupt)`})]})})]})]})}const Y=[{name:`Default`,phases:T.thinkingStyle.phases,reverseMirror:T.thinkingStyle.reverseMirror},{name:`Basic`,phases:[`|`,`/`,`-`,`\\`],reverseMirror:!1},{name:`Braille`,phases:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],reverseMirror:!1},{name:`Circle`,phases:[`◐`,`◓`,`◑`,`◒`],reverseMirror:!1},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Clock`,phases:[`🕛`,`🕐`,`🕑`,`🕒`,`🕓`,`🕔`,`🕕`,`🕖`,`🕗`,`🕘`,`🕙`,`🕚`],reverseMirror:!1},{name:`Globe`,phases:[`🌍`,`🌎`,`🌏`],reverseMirror:!1},{name:`Arc`,phases:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`],reverseMirror:!1},{name:`Triangle`,phases:[`◤`,`◥`,`◢`,`◣`],reverseMirror:!1},{name:`Bouncing`,phases:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`],reverseMirror:!1},{name:`Dots`,phases:[`.`,`..`,`...`],reverseMirror:!1},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1}];function ne({onBack:n}){let{settings:{thinkingStyle:{phases:i,updateInterval:a,reverseMirror:o},themes:s},updateSettings:m}=c($),h=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[g,_]=u(0),v=h[g],[y,b]=u(0),[x,S]=u(0),[C,w]=u(!1),[E,D]=u(``),[O,k]=u(!1),[A,j]=u(!1),[N,P]=u(a.toString()),[F,I]=u(0),L=R(),z=s.find(e=>e.id===L)||s.find(e=>e.id===`dark`),B=z?.colors.claude||`rgb(215,119,87)`;l(()=>{if(i.length>0){let e=o?[...i,...[...i].reverse().slice(1,-1)]:i,t=setInterval(()=>{I(t=>(t+1)%e.length)},a);return()=>clearInterval(t)}},[i,a,o]),r((e,t)=>{if(A){if(t.return){let e=parseInt(N);!isNaN(e)&&e>0&&m(t=>{t.thinkingStyle.updateInterval=e}),j(!1)}else t.escape?(P(a.toString()),j(!1)):t.backspace||t.delete?P(e=>e.slice(0,-1)):e&&e.match(/^[0-9]$/)&&P(t=>t+e);return}if(C||O){if(t.return&&E.trim()){let e=O?[...i,E.trim()]:i.map((e,t)=>t===y?E.trim():e);m(t=>{t.thinkingStyle.phases=e}),w(!1),D(``)}else t.escape?(D(``),w(!1),k(!1)):t.backspace||t.delete?D(e=>e.slice(0,-1)):e&&D(t=>t+e);return}if(t.escape)n();else if(t.return)if(v===`updateInterval`)P(a.toString()),j(!0);else if(v===`presets`){let e=Y[x];m(t=>{t.thinkingStyle.phases=[...e.phases],t.thinkingStyle.reverseMirror=e.reverseMirror})}else v===`reverseMirror`&&m(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(t.tab)t.shift?_(e=>e===0?h.length-1:e-1):_(e=>e===h.length-1?0:e+1);else if(t.upArrow)v===`phases`&&i.length>0?b(e=>e>0?e-1:i.length-1):v===`presets`&&S(e=>e>0?e-1:Y.length-1);else if(t.downArrow)v===`phases`&&i.length>0?b(e=>e<i.length-1?e+1:0):v===`presets`&&S(e=>e<Y.length-1?e+1:0);else if(e===` `)v===`reverseMirror`&&m(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(e===`e`&&v===`phases`)i.length>0&&(D(i[y]),w(!0));else if(e===`a`&&v===`phases`)k(!0),D(``);else if(e===`d`&&v===`phases`)i.length>1&&(m(e=>{e.thinkingStyle.phases=i.filter((e,t)=>t!==y)}),y>=i.length&&b(Math.max(0,i.length-1)));else if(e===`w`&&v===`phases`){if(y>0){let e=[...i];[e[y-1],e[y]]=[e[y],e[y-1]],m(t=>{t.thinkingStyle.phases=e}),b(e=>e-1)}}else if(e===`s`&&v===`phases`){if(y<i.length-1){let e=[...i];[e[y],e[y+1]]=[e[y+1],e[y]],m(t=>{t.thinkingStyle.phases=e}),b(e=>e+1)}}else t.ctrl&&e===`r`&&(m(e=>{e.thinkingStyle=T.thinkingStyle}),b(0),S(0))});let V=o?`x`:` `,H=()=>o?[...i,...[...i].reverse().slice(1,-1)]:i,U=H(),W=U.length>0?U[F]:`·`;return p(e,{children:[p(e,{flexDirection:`column`,width:`50%`,children:[p(e,{marginBottom:1,flexDirection:`column`,children:[f(M,{children:`Thinking style`}),p(e,{flexDirection:`column`,children:[p(t,{dimColor:!0,children:[`enter to`,` `,v===`updateInterval`?`edit interval`:v===`presets`?`apply preset`:`save`]}),f(t,{dimColor:!0,children:`esc to go back`}),f(t,{dimColor:!0,children:`tab to switch sections`})]})]}),f(e,{children:p(t,{children:[f(t,{color:v===`reverseMirror`?`yellow`:void 0,children:v===`reverseMirror`?`❯ `:` `}),f(t,{bold:!0,color:v===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]})}),v===`reverseMirror`&&p(t,{dimColor:!0,children:[` `,`space to toggle`]}),f(e,{marginLeft:2,marginBottom:1,children:p(t,{children:[`[`,V,`] `,o?`Enabled`:`Disabled`]})}),p(e,{flexDirection:`column`,children:[p(t,{children:[f(t,{color:v===`updateInterval`?`yellow`:void 0,children:v===`updateInterval`?`❯ `:` `}),f(t,{bold:!0,color:v===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),v===`updateInterval`&&(A?p(t,{dimColor:!0,children:[` `,`enter to save`]}):p(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{borderStyle:`round`,borderColor:A?`yellow`:`gray`,children:f(t,{children:A?N:a})})}),f(e,{children:p(t,{children:[f(t,{color:v===`phases`?`yellow`:void 0,children:v===`phases`?`❯ `:` `}),f(t,{bold:!0,color:v===`phases`?`yellow`:void 0,children:`Phases`})]})}),v===`phases`&&f(e,{marginBottom:1,flexDirection:`column`,children:p(t,{dimColor:!0,children:[` `,`e to edit · a to add · d to delete · w to move up · s to move down`]})}),f(e,{marginLeft:2,marginBottom:1,children:p(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,y-4),n=Math.min(i.length,e+8),r=Math.max(0,n-8),a=i.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return p(t,{color:v===`phases`&&i===y?`cyan`:void 0,children:[v===`phases`&&i===y?`❯ `:` `,e]},i)}),n<i.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),O&&p(e,{children:[f(t,{color:`yellow`,children:`❯ `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:E})})]}),C&&p(e,{marginTop:1,children:[f(t,{children:`Editing: `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:E})})]})]})}),f(e,{children:p(t,{children:[f(t,{color:v===`presets`?`yellow`:void 0,children:v===`presets`?`❯ `:` `}),f(t,{bold:!0,color:v===`presets`?`yellow`:void 0,children:`Presets`})]})}),v===`presets`&&p(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,x-4),n=Math.min(Y.length,e+8),r=Math.max(0,n-8),i=Y.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return p(t,{color:v===`presets`&&i===x?`cyan`:void 0,children:[v===`presets`&&i===x?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<Y.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,Y.length-n,` more below`]})]})})()})}),f(e,{marginTop:1,children:f(t,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]}),p(e,{width:`50%`,flexDirection:`column`,children:[f(e,{marginBottom:1,children:f(t,{bold:!0,children:`Preview`})}),p(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:[p(t,{children:[p(t,{color:B,children:[W,` Thinking… `]}),f(t,{color:z?.colors.secondaryText,children:`(10s · ↑ 456 tokens · esc to interrupt)`})]}),p(e,{marginTop:1,flexDirection:`column`,children:[p(t,{dimColor:!0,children:[`Phases: `,i.join(``)]}),p(t,{dimColor:!0,children:[`Reverse-mirror: `,o?`Yes`:`No`]}),p(t,{dimColor:!0,children:[`Update interval: `,a,`ms`]})]})]})]})]})}const re=async()=>{await S.mkdir(E,{recursive:!0})},ie=async()=>{let e={ccVersion:``,ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:T};try{let t=await S.readFile(D,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation);for(let e of T.themes){let t=n?.settings?.themes.find(t=>t.id===e.id||t.name===e.name);if(t)for(let[n,r]of Object.entries(e))t.hasOwnProperty(n)||(t[n]=r)}return n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},X={settings:T,changesApplied:!1,ccVersion:``,lastModified:``,ccInstallationDir:null},Z=async e=>(e(X),X.lastModified=new Date().toISOString(),await ae(X),X),ae=async e=>{try{e.lastModified=new Date().toISOString(),await re(),await S.writeFile(D,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}},oe=async e=>(await S.copyFile(O,e.cliPath),await Z(e=>{e.changesApplied=!1}),!0),se=async e=>{e.ccInstallationDir&&A.unshift(e.ccInstallationDir);for(let e of A)try{let t=h.join(e,`cli.js`),n=h.join(e,`package.json`),r=JSON.parse(await S.readFile(n,`utf8`));return{cliPath:t,packageJsonPath:n,version:r.version}}catch{continue}return null},ce=async e=>{await re(),await S.copyFile(e.cliPath,O),await Z(t=>{t.changesApplied=!1,t.ccVersion=e.version})};async function le(e){try{return await S.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}async function ue(){let e=await ie(),t=await se(e);if(!t)return null;let n=t.version,r=e.ccVersion;return await le(O)||await ce(t),n===r?{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}:(await S.unlink(O),await ce(t),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t})}function de(e){let t=e.indexOf(` ██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗
8
+ `).map((e,n)=>f(t,{color:J,children:e},n)),f(e,{marginTop:1,children:f(t,{wrap:`truncate-end`,children:`Claude Code can now be used with your Claude subscription or billed based on API usage through your Console account.`})})]})]})]})}function te({onBack:n}){let{settings:{thinkingVerbs:{format:i,verbs:a},themes:o},updateSettings:s}=c($),l=[`format`,`verbs`],[m,h]=u(0),g=l[m],[_,v]=u(0),[y,b]=u(!1),[x,S]=u(``),[C,w]=u(!1),[E,D]=u(!1),[O,k]=u(i),A=R(),j=o.find(e=>e.id===A)||o.find(e=>e.id===`dark`),N=j?.colors.claude||`rgb(215,119,87)`;return r((e,t)=>{if(E){t.return?(s(e=>{e.thinkingVerbs.format=O}),D(!1)):t.escape?(k(i),D(!1)):t.backspace||t.delete?k(e=>e.slice(0,-1)):e&&k(t=>t+e);return}if(y||C){t.return&&x.trim()?(C?(s(e=>{e.thinkingVerbs.verbs.push(x.trim())}),w(!1)):(s(e=>{e.thinkingVerbs.verbs[_]=x.trim()}),b(!1)),S(``)):t.escape?(S(``),b(!1),w(!1)):t.backspace||t.delete?S(e=>e.slice(0,-1)):e&&S(t=>t+e);return}t.escape?n():t.return?g===`format`&&(k(i),D(!0)):t.tab?t.shift?h(e=>e===0?l.length-1:e-1):h(e=>e===l.length-1?0:e+1):t.upArrow?g===`verbs`&&a.length>0&&v(e=>e>0?e-1:a.length-1):t.downArrow?g===`verbs`&&a.length>0&&v(e=>e<a.length-1?e+1:0):e===`e`&&g===`verbs`?a.length>0&&(S(a[_]),b(!0)):e===`d`&&g===`verbs`?a.length>1&&(s(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==_)}),_>=a.length-1&&v(Math.max(0,a.length-2))):e===`n`&&g===`verbs`?(w(!0),S(``)):t.ctrl&&e===`r`&&g===`verbs`&&(s(e=>{e.thinkingVerbs.verbs=[...T.thinkingVerbs.verbs]}),v(0))}),p(e,{children:[p(e,{flexDirection:`column`,width:`50%`,children:[p(e,{marginBottom:1,flexDirection:`column`,children:[f(M,{children:`Thinking Verbs`}),p(e,{flexDirection:`column`,children:[f(t,{dimColor:!0,children:g===`format`?`enter to edit format`:`changes auto-saved`}),f(t,{dimColor:!0,children:`esc to go back`}),f(t,{dimColor:!0,children:`tab to switch sections`})]})]}),f(e,{marginBottom:1,children:f(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),p(e,{flexDirection:`column`,children:[p(t,{children:[f(t,{color:g===`format`?`yellow`:void 0,children:g===`format`?`❯ `:` `}),f(t,{bold:!0,color:g===`format`?`yellow`:void 0,children:`Format`})]}),g===`format`&&(E?p(t,{dimColor:!0,children:[` `,`enter to save`]}):p(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:f(t,{children:E?O:i})})}),f(e,{children:p(t,{children:[f(t,{color:g===`verbs`?`yellow`:void 0,children:g===`verbs`?`❯ `:` `}),f(t,{bold:!0,color:g===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),g===`verbs`&&f(e,{flexDirection:`column`,children:p(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),f(e,{marginLeft:2,marginBottom:1,children:p(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,_-4),n=Math.min(a.length,e+8),r=Math.max(0,n-8),i=a.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return p(t,{color:g===`verbs`&&i===_?`cyan`:void 0,children:[g===`verbs`&&i===_?`❯ `:` `,e]},i)}),n<a.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),C&&p(e,{alignItems:`center`,children:[f(t,{color:`yellow`,children:`❯ `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:x})})]}),y&&p(e,{marginTop:1,alignItems:`center`,children:[f(t,{children:`Editing: `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:x})})]})]})})]}),p(e,{width:`50%`,flexDirection:`column`,children:[f(e,{marginBottom:1,children:f(t,{bold:!0,children:`Preview`})}),f(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:p(t,{children:[p(t,{color:N,children:[`✻ `,i.replace(/\{\}/g,a[_]),` `]}),f(t,{color:j?.colors.secondaryText,children:`(10s · ↑ 456 tokens · esc to interrupt)`})]})})]})]})}const Y=[{name:`Default`,phases:T.thinkingStyle.phases,reverseMirror:T.thinkingStyle.reverseMirror},{name:`Basic`,phases:[`|`,`/`,`-`,`\\`],reverseMirror:!1},{name:`Braille`,phases:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],reverseMirror:!1},{name:`Circle`,phases:[`◐`,`◓`,`◑`,`◒`],reverseMirror:!1},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Clock`,phases:[`🕛`,`🕐`,`🕑`,`🕒`,`🕓`,`🕔`,`🕕`,`🕖`,`🕗`,`🕘`,`🕙`,`🕚`],reverseMirror:!1},{name:`Globe`,phases:[`🌍`,`🌎`,`🌏`],reverseMirror:!1},{name:`Arc`,phases:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`],reverseMirror:!1},{name:`Triangle`,phases:[`◤`,`◥`,`◢`,`◣`],reverseMirror:!1},{name:`Bouncing`,phases:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`],reverseMirror:!1},{name:`Dots`,phases:[`.`,`..`,`...`],reverseMirror:!1},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1}];function ne({onBack:n}){let{settings:{thinkingStyle:{phases:i,updateInterval:a,reverseMirror:o},themes:s},updateSettings:m}=c($),h=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[g,_]=u(0),v=h[g],[y,b]=u(0),[x,S]=u(0),[C,w]=u(!1),[E,D]=u(``),[O,k]=u(!1),[A,j]=u(!1),[N,P]=u(a.toString()),[F,I]=u(0),L=R(),z=s.find(e=>e.id===L)||s.find(e=>e.id===`dark`),B=z?.colors.claude||`rgb(215,119,87)`;l(()=>{if(i.length>0){let e=o?[...i,...[...i].reverse().slice(1,-1)]:i,t=setInterval(()=>{I(t=>(t+1)%e.length)},a);return()=>clearInterval(t)}},[i,a,o]),r((e,t)=>{if(A){if(t.return){let e=parseInt(N);!isNaN(e)&&e>0&&m(t=>{t.thinkingStyle.updateInterval=e}),j(!1)}else t.escape?(P(a.toString()),j(!1)):t.backspace||t.delete?P(e=>e.slice(0,-1)):e&&e.match(/^[0-9]$/)&&P(t=>t+e);return}if(C||O){if(t.return&&E.trim()){let e=O?[...i,E.trim()]:i.map((e,t)=>t===y?E.trim():e);m(t=>{t.thinkingStyle.phases=e}),w(!1),D(``)}else t.escape?(D(``),w(!1),k(!1)):t.backspace||t.delete?D(e=>e.slice(0,-1)):e&&D(t=>t+e);return}if(t.escape)n();else if(t.return)if(v===`updateInterval`)P(a.toString()),j(!0);else if(v===`presets`){let e=Y[x];m(t=>{t.thinkingStyle.phases=[...e.phases],t.thinkingStyle.reverseMirror=e.reverseMirror})}else v===`reverseMirror`&&m(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(t.tab)t.shift?_(e=>e===0?h.length-1:e-1):_(e=>e===h.length-1?0:e+1);else if(t.upArrow)v===`phases`&&i.length>0?b(e=>e>0?e-1:i.length-1):v===`presets`&&S(e=>e>0?e-1:Y.length-1);else if(t.downArrow)v===`phases`&&i.length>0?b(e=>e<i.length-1?e+1:0):v===`presets`&&S(e=>e<Y.length-1?e+1:0);else if(e===` `)v===`reverseMirror`&&m(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(e===`e`&&v===`phases`)i.length>0&&(D(i[y]),w(!0));else if(e===`a`&&v===`phases`)k(!0),D(``);else if(e===`d`&&v===`phases`)i.length>1&&(m(e=>{e.thinkingStyle.phases=i.filter((e,t)=>t!==y)}),y>=i.length&&b(Math.max(0,i.length-1)));else if(e===`w`&&v===`phases`){if(y>0){let e=[...i];[e[y-1],e[y]]=[e[y],e[y-1]],m(t=>{t.thinkingStyle.phases=e}),b(e=>e-1)}}else if(e===`s`&&v===`phases`){if(y<i.length-1){let e=[...i];[e[y],e[y+1]]=[e[y+1],e[y]],m(t=>{t.thinkingStyle.phases=e}),b(e=>e+1)}}else t.ctrl&&e===`r`&&(m(e=>{e.thinkingStyle=T.thinkingStyle}),b(0),S(0))});let V=o?`x`:` `,H=()=>o?[...i,...[...i].reverse().slice(1,-1)]:i,U=H(),W=U.length>0?U[F]:`·`;return p(e,{children:[p(e,{flexDirection:`column`,width:`50%`,children:[p(e,{marginBottom:1,flexDirection:`column`,children:[f(M,{children:`Thinking style`}),p(e,{flexDirection:`column`,children:[p(t,{dimColor:!0,children:[`enter to`,` `,v===`updateInterval`?`edit interval`:v===`presets`?`apply preset`:`save`]}),f(t,{dimColor:!0,children:`esc to go back`}),f(t,{dimColor:!0,children:`tab to switch sections`})]})]}),f(e,{children:p(t,{children:[f(t,{color:v===`reverseMirror`?`yellow`:void 0,children:v===`reverseMirror`?`❯ `:` `}),f(t,{bold:!0,color:v===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]})}),v===`reverseMirror`&&p(t,{dimColor:!0,children:[` `,`space to toggle`]}),f(e,{marginLeft:2,marginBottom:1,children:p(t,{children:[`[`,V,`] `,o?`Enabled`:`Disabled`]})}),p(e,{flexDirection:`column`,children:[p(t,{children:[f(t,{color:v===`updateInterval`?`yellow`:void 0,children:v===`updateInterval`?`❯ `:` `}),f(t,{bold:!0,color:v===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),v===`updateInterval`&&(A?p(t,{dimColor:!0,children:[` `,`enter to save`]}):p(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{borderStyle:`round`,borderColor:A?`yellow`:`gray`,children:f(t,{children:A?N:a})})}),f(e,{children:p(t,{children:[f(t,{color:v===`phases`?`yellow`:void 0,children:v===`phases`?`❯ `:` `}),f(t,{bold:!0,color:v===`phases`?`yellow`:void 0,children:`Phases`})]})}),v===`phases`&&f(e,{marginBottom:1,flexDirection:`column`,children:p(t,{dimColor:!0,children:[` `,`e to edit · a to add · d to delete · w to move up · s to move down`]})}),f(e,{marginLeft:2,marginBottom:1,children:p(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,y-4),n=Math.min(i.length,e+8),r=Math.max(0,n-8),a=i.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return p(t,{color:v===`phases`&&i===y?`cyan`:void 0,children:[v===`phases`&&i===y?`❯ `:` `,e]},i)}),n<i.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),O&&p(e,{children:[f(t,{color:`yellow`,children:`❯ `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:E})})]}),C&&p(e,{marginTop:1,children:[f(t,{children:`Editing: `}),f(e,{borderStyle:`round`,borderColor:`yellow`,children:f(t,{children:E})})]})]})}),f(e,{children:p(t,{children:[f(t,{color:v===`presets`?`yellow`:void 0,children:v===`presets`?`❯ `:` `}),f(t,{bold:!0,color:v===`presets`?`yellow`:void 0,children:`Presets`})]})}),v===`presets`&&p(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),f(e,{marginLeft:2,marginBottom:1,children:f(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,x-4),n=Math.min(Y.length,e+8),r=Math.max(0,n-8),i=Y.slice(r,n);return p(d,{children:[r>0&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return p(t,{color:v===`presets`&&i===x?`cyan`:void 0,children:[v===`presets`&&i===x?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<Y.length&&p(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,Y.length-n,` more below`]})]})})()})}),f(e,{marginTop:1,children:f(t,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]}),p(e,{width:`50%`,flexDirection:`column`,children:[f(e,{marginBottom:1,children:f(t,{bold:!0,children:`Preview`})}),p(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:[p(t,{children:[p(t,{color:B,children:[W,` Thinking… `]}),f(t,{color:z?.colors.secondaryText,children:`(10s · ↑ 456 tokens · esc to interrupt)`})]}),p(e,{marginTop:1,flexDirection:`column`,children:[p(t,{dimColor:!0,children:[`Phases: `,i.join(``)]}),p(t,{dimColor:!0,children:[`Reverse-mirror: `,o?`Yes`:`No`]}),p(t,{dimColor:!0,children:[`Update interval: `,a,`ms`]})]})]})]})]})}const re=async()=>{await S.mkdir(E,{recursive:!0})},ie=async()=>{let e={ccVersion:``,ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:T};try{let t=await S.readFile(D,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation);for(let e of T.themes){let t=n?.settings?.themes.find(t=>t.id===e.id||t.name===e.name);if(t)for(let[n,r]of Object.entries(e))Object.hasOwn(t,n)||(t[n]=r)}return n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},X={settings:T,changesApplied:!1,ccVersion:``,lastModified:``,ccInstallationDir:null},Z=async e=>(e(X),X.lastModified=new Date().toISOString(),await ae(X),X),ae=async e=>{try{e.lastModified=new Date().toISOString(),await re(),await S.writeFile(D,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}},oe=async e=>(await S.copyFile(O,e.cliPath),await Z(e=>{e.changesApplied=!1}),!0),se=async e=>{e.ccInstallationDir&&A.unshift(e.ccInstallationDir);for(let e of A)try{let t=h.join(e,`cli.js`),n=h.join(e,`package.json`),r=JSON.parse(await S.readFile(n,`utf8`));return{cliPath:t,packageJsonPath:n,version:r.version}}catch{continue}return null},ce=async e=>{await re(),await S.copyFile(e.cliPath,O),await Z(t=>{t.changesApplied=!1,t.ccVersion=e.version})};async function le(e){try{return await S.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}async function ue(){let e=await ie(),t=await se(e);if(!t)return null;let n=t.version,r=e.ccVersion;return await le(O)||await ce(t),r&&n!==r?(await S.unlink(O),await ce(t),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}}function de(e){let t=e.indexOf(` ██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗
9
9
  ██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝
10
10
  ██║ ██║ ███████║██║ ██║██║ ██║█████╗
11
11
  ██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝
@@ -16,7 +16,7 @@ import{Box as e,Text as t,render as n,useInput as r,useStdout as i}from"ink";imp
16
16
  ██║ ██║ ██║██║ ██║█████╗
17
17
  ██║ ██║ ██║██║ ██║██╔══╝
18
18
  ╚██████╗╚██████╔╝██████╔╝███████╗
19
- ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝`);return t===-1?null:{startIndex:t-1,endIndex:t+495+1}}function fe(e,t){let n=de(e);if(!n)return e;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i}function pe(e){let t=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,n=e.match(t);if(!n||n.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let r=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,i=/return\{(?:[\w$]+?:"(?:Dark|Light).+?",?)+\}/,a=e.match(r),o=e.match(i);return!a||a.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!o||o.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:n.index,endIndex:n.index+n[0].length,variableName:n[1].trim()},objArr:{startIndex:a.index,endIndex:a.index+a[0].length},obj:{startIndex:o.index,endIndex:o.index+o[0].length}}}const me=(e,t)=>{let n=pe(e);if(!n)return null;if(t.length===0)return e;let r=e,i=`return`+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),Q(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r;let a=JSON.stringify(t.map(e=>({label:e.name,value:e.id})));r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),Q(e,r,a,n.objArr.startIndex,n.objArr.endIndex),e=r;let o=`switch(${n.switchStatement.variableName}){\n`;return t.forEach(e=>{o+=`case"${e.id}":return${JSON.stringify(e.colors)};\n`}),o+=`default:return${JSON.stringify(t[0].colors)};\n}`,r=r.slice(0,n.switchStatement.startIndex)+o+r.slice(n.switchStatement.endIndex),Q(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},he=e=>{let t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g,r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},ge=(e,t)=>{let n=he(e);if(n.length===0)return null;let r=JSON.stringify(t),i=n.sort((e,t)=>t.startIndex-e.startIndex),a=e;for(let e=0;e<i.length;e++){let t=a.slice(0,i[e].startIndex)+r+a.slice(i[e].endIndex);Q(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},_e=e=>{let t=/[\w$]+\(\(\)=>\{if\(![\w$]+\)\{[\w$]+\(\d+\);return\}[\w$]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,n=e.match(t);if(!n||n.index==null)return console.error(`patch: thinker symbol speed: failed to find match`),null;let r=n[0],i=n[1],a=r.lastIndexOf(i),o=n.index+a,s=o+i.length;return{startIndex:o,endIndex:s}},ve=(e,t)=>{let n=_e(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i},ye=e=>{let t=/\b(\w+)\s*=\[\s*(?:"[A-Z][a-z]+ing",?\s*)+\]/s,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker verbs: failed to find verbsMatch`),null):{verbsLocation:{startIndex:n.index,endIndex:n.index+n[0].length},varName:n[1]}},be=e=>{let t=/createElement\(\w+,\{[\w:]+,spinnerVerbs:[$\w]+,/,n=e.match(t);if(!n||n.index==null)return console.error(`patch: thinker verbs: failed to find match`),null;let r=n[0].indexOf(`spinnerVerbs`);return{startIndex:n.index+r,endIndex:n.index+r+n[0].substring(r).length}},xe=(e,t)=>{let n=ye(e);if(!n)return null;let{verbsLocation:r,varName:i}=n,a=`${i}=${JSON.stringify(t)}`,o=e.slice(0,r.startIndex)+a+e.slice(r.endIndex);Q(e,o,a,r.startIndex,r.endIndex);let s=be(o);if(!s)return null;let c=`spinnerVerbs:${i},`,l=o.slice(0,s.startIndex)+c+o.slice(s.endIndex);return Q(o,l,c,s.startIndex,s.endIndex),l},Se=e=>{let t=/function \w+\(\{[\w:,]+spinnerVerbs:[$\w]+,/,n=e.match(t);if(!n||n.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let r=e.slice(n.index,n.index+300),i=/[$\w]+=([^=]+?)\+"…"/,a=r.match(i);if(!a||a.index==null)return console.error(`patch: thinker format: failed to find formatMatch`),null;let o=r.indexOf(`=`,a.index)+1;return{fmtLocation:{startIndex:n.index+o,endIndex:n.index+a.index+a[0].length},curVerb:a[1]}},Ce=(e,t)=>{let n=Se(e);if(!n)return null;let{fmtLocation:r,curVerb:i}=n,a="`"+t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\{\}/g,"${"+i+`}`)+"`",o=e.slice(0,r.startIndex)+a+e.slice(r.endIndex);return Q(e,o,a,r.startIndex,r.endIndex),o},we=e=>{let t=/=\s*\[\.\.\.(\w+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:n.index,endIndex:n.index+n[0].length,variableName:n[1]}},Te=(e,t)=>{let n=we(e);if(!n)return null;let r=n.variableName,i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return Q(e,a,i,n.startIndex,n.endIndex),a};function Q(e,t,n,r,i){let a=Math.max(0,r-20),o=Math.min(e.length,i+20),s=Math.min(t.length,r+n.length+20);e.slice(a,r),e.slice(r,i),e.slice(i,o),t.slice(a,r),t.slice(r,r+n.length),t.slice(r+n.length,s)}const Ee=async(e,t)=>{await oe(t);let n=await x.readFile(t.cliPath,{encoding:`utf8`}),r=null;if(e.settings.themes&&e.settings.themes.length>0&&(r=me(n,e.settings.themes))&&(n=r),e.settings.launchText){let t=e.settings.launchText,i=``;t.method===`custom`&&t.customText?i=t.customText:t.method===`figlet`&&t.figletText&&(i=await new Promise(e=>b.text(t.figletText.replace(`
19
+ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝`);return t===-1?null:{startIndex:t-1,endIndex:t+495+1}}function fe(e,t){let n=de(e);if(!n)return e;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i}function pe(e){let t=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,n=e.match(t);if(!n||n.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let r=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,i=/return\{(?:[\w$]+?:"(?:Dark|Light).+?",?)+\}/,a=e.match(r),o=e.match(i);return!a||a.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!o||o.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:n.index,endIndex:n.index+n[0].length,variableName:n[1].trim()},objArr:{startIndex:a.index,endIndex:a.index+a[0].length},obj:{startIndex:o.index,endIndex:o.index+o[0].length}}}const me=(e,t)=>{let n=pe(e);if(!n)return null;if(t.length===0)return e;let r=e,i=`return`+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),Q(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r;let a=JSON.stringify(t.map(e=>({label:e.name,value:e.id})));r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),Q(e,r,a,n.objArr.startIndex,n.objArr.endIndex),e=r;let o=`switch(${n.switchStatement.variableName}){\n`;return t.forEach(e=>{o+=`case"${e.id}":return${JSON.stringify(e.colors)};\n`}),o+=`default:return${JSON.stringify(t[0].colors)};\n}`,r=r.slice(0,n.switchStatement.startIndex)+o+r.slice(n.switchStatement.endIndex),Q(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},he=e=>{let t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g,r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},ge=(e,t)=>{let n=he(e);if(n.length===0)return null;let r=JSON.stringify(t),i=n.sort((e,t)=>t.startIndex-e.startIndex),a=e;for(let e=0;e<i.length;e++){let t=a.slice(0,i[e].startIndex)+r+a.slice(i[e].endIndex);Q(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},_e=e=>{let t=/[\w$]+\(\(\)=>\{if\(![\w$]+\)\{[\w$]+\(\d+\);return\}[\w$]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,n=e.match(t);if(!n||n.index==null)return console.error(`patch: thinker symbol speed: failed to find match`),null;let r=n[0],i=n[1],a=r.lastIndexOf(i),o=n.index+a,s=o+i.length;return{startIndex:o,endIndex:s}},ve=(e,t)=>{let n=_e(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i},ye=e=>{let t=/\b([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker verbs: failed to find verbsMatch`),null):{verbsLocation:{startIndex:n.index,endIndex:n.index+n[0].length},varName:n[1]}},be=e=>{let t=/function (\w+)\(\)\{return \w+\("tengu_spinner_words",\w+\)\.words\}/,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker verbs: failed to find match`),null):{useLocation:{startIndex:n.index,endIndex:n.index+n[0].length},funcName:n[1]}},xe=(e,t)=>{let n=ye(e);if(!n)return null;let{verbsLocation:r,varName:i}=n,a=`${i}=${JSON.stringify({words:t})}`,o=e.slice(0,r.startIndex)+a+e.slice(r.endIndex);Q(e,o,a,r.startIndex,r.endIndex);let s=be(o);if(!s)return null;let{useLocation:c,funcName:l}=s,u=`function ${l}(){return ${i}.words}`,d=o.slice(0,c.startIndex)+u+o.slice(c.endIndex);return Q(o,d,u,c.startIndex,c.endIndex),d},Se=e=>{let t=/spinnerTip:\w+,(?:\w+:\w+,)*overrideMessage:\w+,.{300}/,n=e.match(t);if(!n||n.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let r=e.slice(n.index,n.index+300),i=/[$\w]+=([^=]+?)\+"…"/,a=r.match(i);if(!a||a.index==null)return console.error(`patch: thinker format: failed to find formatMatch`),null;let o=r.indexOf(`=`,a.index)+1;return{fmtLocation:{startIndex:n.index+o,endIndex:n.index+a.index+a[0].length},curVerb:a[1]}},Ce=(e,t)=>{let n=Se(e);if(!n)return null;let{fmtLocation:r,curVerb:i}=n,a="`"+t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\{\}/g,"${"+i+`}`)+"`",o=e.slice(0,r.startIndex)+a+e.slice(r.endIndex);return Q(e,o,a,r.startIndex,r.endIndex),o},we=e=>{let t=/=\s*\[\.\.\.(\w+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:n.index,endIndex:n.index+n[0].length,variableName:n[1]}},Te=(e,t)=>{let n=we(e);if(!n)return null;let r=n.variableName,i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return Q(e,a,i,n.startIndex,n.endIndex),a};function Q(e,t,n,r,i){let a=Math.max(0,r-20),o=Math.min(e.length,i+20),s=Math.min(t.length,r+n.length+20);e.slice(a,r),e.slice(r,i),e.slice(i,o),t.slice(a,r),t.slice(r,r+n.length),t.slice(r+n.length,s)}const Ee=async(e,t)=>{await oe(t);let n=await x.readFile(t.cliPath,{encoding:`utf8`}),r=null;if(e.settings.themes&&e.settings.themes.length>0&&(r=me(n,e.settings.themes))&&(n=r),e.settings.launchText){let t=e.settings.launchText,i=``;t.method===`custom`&&t.customText?i=t.customText:t.method===`figlet`&&t.figletText&&(i=await new Promise(e=>b.text(t.figletText.replace(`
20
20
  `,` `),t.figletFont,(t,n)=>{t?(console.error(`patch: figlet: failed to generate text`,t),e(``)):e(n||``)}))),(r=fe(n,i))&&(n=r)}return e.settings.thinkingVerbs&&((r=xe(n,e.settings.thinkingVerbs.verbs))&&(n=r),(r=Ce(n,e.settings.thinkingVerbs.format))&&(n=r)),(r=ge(n,e.settings.thinkingStyle.phases))&&(n=r),(r=ve(n,e.settings.thinkingStyle.updateInterval))&&(n=r),(r=Te(n,e.settings.thinkingStyle.reverseMirror))&&(n=r),await x.writeFile(t.cliPath,n),await Z(e=>{e.changesApplied=!0})},$=o({settings:T,updateSettings:e=>{},changesApplied:!1});function De({startupCheckInfo:t}){let[n,i]=u({settings:T,changesApplied:!1,ccVersion:``,lastModified:``,ccInstallationDir:null});l(()=>{let e=async()=>{i(await ie())};e()},[]);let a=s(e=>{e(n.settings),Z(e=>{e.settings=n.settings,e.changesApplied=!1}).then(e=>{i(e)})},[n]),[o,c]=u(null),[d,p]=u(null);l(()=>{t.wasUpdated&&(p({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
21
21
  (However, your customization are still remembered in ${D}.)
22
22
  Please reapply your changes below.`,type:`warning`}),a(()=>{}))},[]),r((e,t)=>{(t.ctrl&&e===`c`||(e===`q`||t.escape)&&!o)&&process.exit(0)});let m=e=>{switch(p(null),e){case w.THEMES:case w.LAUNCH_TEXT:case w.THINKING_VERBS:case w.THINKING_STYLE:c(e);break;case w.APPLY_CHANGES:t.ccInstInfo&&(p({message:`Applying patches...`,type:`info`}),Ee(n,t.ccInstInfo).then(e=>{i(e),p({message:`Customization patches applied successfully!`,type:`success`})}));break;case w.RESTORE_ORIGINAL:t.ccInstInfo&&oe(t.ccInstInfo).then(()=>{p({message:`Original Claude Code restored successfully!`,type:`success`}),a(()=>{})});break;case w.OPEN_CONFIG:z(D);break;case w.OPEN_CLI:t.ccInstInfo&&z(t.ccInstInfo.cliPath);break;case w.EXIT:process.exit(0)}},h=()=>{c(null)};return f($.Provider,{value:{settings:n.settings,updateSettings:a,changesApplied:n.changesApplied},children:f(e,{flexDirection:`column`,children:o===null?f(F,{onSubmit:m,notification:d}):o===w.THEMES?f(ee,{onBack:h}):o===w.LAUNCH_TEXT?f(J,{onBack:h}):o===w.THINKING_VERBS?f(te,{onBack:h}):o===w.THINKING_STYLE?f(ne,{onBack:h}):null})})}const Oe=async()=>{let e=await ue();e?n(f(De,{startupCheckInfo:e})):(console.error(`\x1b[31mCannot find Claude Code's cli.js -- do you have Claude Code installed?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tweakcc",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "description": "Command-line tool to customize your Claude Code theme colors, thinking verbs and more.",
6
6
  "main": "dist/index.js",