tweakcc 1.1.4 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +4 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18,10 +18,10 @@ import{Box as e,Text as t,render as n,useInput as r,useStdout as i}from"ink";imp
18
18
  ╚██████╗╚██████╔╝██████╔╝███████╗
19
19
  ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝`);return t===-1?null:{startIndex:t-1,endIndex:t+495+1}}function ye(e,t){let n=ve(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 be(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 xe=(e,t)=>{let n=be(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},Se=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},Ce=(e,t)=>{let n=Se(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},we=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}},Te=(e,t)=>{let n=we(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},Ee=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]}},De=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]}},Oe=(e,t)=>{let n=Ee(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=De(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},ke=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+400),i=/=(\w+)\?([^={}?]+?)\+"…":(.+?)\+"…"/,a=r.match(i);return!a||a.index==null?(console.error(`patch: thinker format: failed to find formatMatch`),null):{fmtLocation:{startIndex:n.index+a.index,endIndex:n.index+a.index+a[0].length},cond:a[1],curVerb1:a[2],curVerb2:a[3]}},Ae=(e,t)=>{let n=ke(e);if(!n)return null;let{fmtLocation:r,cond:i,curVerb1:a,curVerb2:o}=n,s=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),c="`"+s.replace(/\{\}/g,"${"+a+`}`)+"`",l="`"+s.replace(/\{\}/g,"${"+o+`}`)+"`",u=`=${i}?${c}:${l}`,d=e.slice(0,r.startIndex)+u+e.slice(r.endIndex);return Q(e,d,u,r.startIndex,r.endIndex),d},je=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]}},Me=(e,t)=>{let n=je(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},Ne=e=>{let t=/\{flexWrap:"wrap",height:1,width:2\}/,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:n.index,endIndex:n.index+n[0].length}},Pe=(e,t)=>{let n=Ne(e);if(!n)return null;let r=`{flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i};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),c=e.slice(a,r),l=e.slice(r,i),u=e.slice(i,o),d=t.slice(a,r),f=t.slice(r,r+n.length),p=t.slice(r+n.length,s);H()&&(console.log(`
20
20
  --- Diff ---`),console.log(`OLD:`,c+`\x1b[31m${l}\x1b[0m`+u),console.log(`NEW:`,d+`\x1b[32m${f}\x1b[0m`+p),console.log(`--- End Diff ---
21
- `))}const Fe=async(e,t)=>{await pe(t);let n=await C.readFile(t.cliPath,{encoding:`utf8`}),r=null;if(e.settings.themes&&e.settings.themes.length>0&&(r=xe(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=>S.text(t.figletText.replace(`
22
- `,` `),t.figletFont,(t,n)=>{t?(console.error(`patch: figlet: failed to generate text`,t),e(``)):e(n||``)}))),(r=ye(n,i))&&(n=r)}return e.settings.thinkingVerbs&&((r=Oe(n,e.settings.thinkingVerbs.verbs))&&(n=r),(r=Ae(n,e.settings.thinkingVerbs.format))&&(n=r)),(r=Ce(n,e.settings.thinkingStyle.phases))&&(n=r),(r=Te(n,e.settings.thinkingStyle.updateInterval))&&(n=r),(r=Pe(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=r),(r=Me(n,e.settings.thinkingStyle.reverseMirror))&&(n=r),await C.writeFile(t.cliPath,n),await Z(e=>{e.changesApplied=!0})},$=s({settings:O,updateSettings:e=>{},changesApplied:!1});function Ie({startupCheckInfo:t}){let[n,i]=d({settings:O,changesApplied:!1,ccVersion:``,lastModified:``,ccInstallationDir:null});u(()=>{let e=async()=>{i(await de())};e()},[]);let a=c(e=>{e(n.settings),Z(e=>{e.settings=n.settings,e.changesApplied=!1}).then(e=>{i(e)})},[n]),[o,s]=d(null),[l,f]=d(null);u(()=>{t.wasUpdated&&t.oldVersion&&(f({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
21
+ `))}const Fe=e=>{let t=/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/,n=e.match(t);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let r=n[0],i=/verbose:[^,}]+/,a=r.match(i);if(!a||a.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let o=n.index+a.index,s=o+a[0].length;return{startIndex:o,endIndex:s}},Ie=e=>{let t=Fe(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return Q(e,r,n,t.startIndex,t.endIndex),r},Le=async(e,t)=>{await pe(t);let n=await C.readFile(t.cliPath,{encoding:`utf8`}),r=null;if(e.settings.themes&&e.settings.themes.length>0&&(r=xe(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=>S.text(t.figletText.replace(`
22
+ `,` `),t.figletFont,(t,n)=>{t?(console.error(`patch: figlet: failed to generate text`,t),e(``)):e(n||``)}))),(r=ye(n,i))&&(n=r)}return e.settings.thinkingVerbs&&((r=Oe(n,e.settings.thinkingVerbs.verbs))&&(n=r),(r=Ae(n,e.settings.thinkingVerbs.format))&&(n=r)),(r=Ce(n,e.settings.thinkingStyle.phases))&&(n=r),(r=Te(n,e.settings.thinkingStyle.updateInterval))&&(n=r),(r=Pe(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=r),(r=Me(n,e.settings.thinkingStyle.reverseMirror))&&(n=r),(r=Ie(n))&&(n=r),await C.writeFile(t.cliPath,n),await Z(e=>{e.changesApplied=!0})},$=s({settings:O,updateSettings:e=>{},changesApplied:!1});function Re({startupCheckInfo:t}){let[n,i]=d({settings:O,changesApplied:!1,ccVersion:``,lastModified:``,ccInstallationDir:null});u(()=>{let e=async()=>{i(await de())};e()},[]);let a=c(e=>{e(n.settings),Z(e=>{e.settings=n.settings,e.changesApplied=!1}).then(e=>{i(e)})},[n]),[o,s]=d(null),[l,f]=d(null);u(()=>{t.wasUpdated&&t.oldVersion&&(f({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
23
23
  (However, your customization are still remembered in ${A}.)
24
- 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(f(null),e){case D.THEMES:case D.LAUNCH_TEXT:case D.THINKING_VERBS:case D.THINKING_STYLE:s(e);break;case D.APPLY_CHANGES:t.ccInstInfo&&(f({message:`Applying patches...`,type:`info`}),Fe(n,t.ccInstInfo).then(e=>{i(e),f({message:`Customization patches applied successfully!`,type:`success`})}));break;case D.RESTORE_ORIGINAL:t.ccInstInfo&&pe(t.ccInstInfo).then(()=>{f({message:`Original Claude Code restored successfully!`,type:`success`}),a(()=>{})});break;case D.OPEN_CONFIG:W(A);break;case D.OPEN_CLI:t.ccInstInfo&&W(t.ccInstInfo.cliPath);break;case D.EXIT:process.exit(0)}},h=()=>{s(null)};return p($.Provider,{value:{settings:n.settings,updateSettings:a,changesApplied:n.changesApplied},children:p(e,{flexDirection:`column`,children:o===null?p(R,{onSubmit:m,notification:l}):o===D.THEMES?p(oe,{onBack:h}):o===D.LAUNCH_TEXT?p(se,{onBack:h}):o===D.THINKING_VERBS?p(ce,{onBack:h}):o===D.THINKING_STYLE?p(le,{onBack:h}):null})})}const Le=async()=>{let e=new a;e.name(`tweakcc`).description(`Command-line tool to customize your Claude Code theme colors, thinking verbs and more.`).version(`1.1.4`).option(`-d, --debug`,`enable debug mode`).option(`-a, --apply`,`apply saved customizations without interactive UI`),e.parse();let t=e.opts();if(t.debug&&U(),t.apply){console.log(T.cyan(`🔧 Applying saved customizations to Claude Code...`));try{let e=await de();(!e.settings||Object.keys(e.settings).length===0)&&(console.error(T.red(`❌ No saved customizations found in `+A)),process.exit(1));let t=await _e();(!t||!t.ccInstInfo)&&(console.error(T.red(`❌ Cannot find Claude Code's cli.js`)),console.error(T.yellow(`Searched at the following locations:`)),N.forEach(e=>console.error(T.gray(` - `+e))),process.exit(1)),console.log(T.gray(`📁 Found Claude Code at: ${t.ccInstInfo.cliPath}`)),console.log(T.gray(`📦 Version: ${t.ccInstInfo.version}`)),console.log(T.gray(`✓ Backup handled by startup check`)),console.log(T.cyan(`🎨 Applying customizations...`));try{await Fe(e,t.ccInstInfo),console.log(T.green(`✅ Customizations applied successfully!`)),console.log(T.gray(`💾 Configuration saved at: ${A}`))}catch(e){console.error(T.red(`❌ Failed to apply patches:`)),console.error(T.red(e instanceof Error?e.message:String(e))),e instanceof Error&&e.message.includes(`patch:`)&&(console.log(T.yellow(`⚠️ Some patches failed to apply, but the file was updated.`)),console.log(T.yellow(` This may happen if Claude Code was updated.`)),console.log(T.gray(` Run tweakcc interactively to review and update your customizations.`)))}process.exit(0)}catch(e){console.error(T.red(`❌ Unexpected error:`)),console.error(T.red(e instanceof Error?e.message:String(e))),process.exit(1)}}let r=await _e();r?n(p(Ie,{startupCheckInfo:r})):(console.error(`\x1b[31mCannot find Claude Code's cli.js -- do you have Claude Code installed?
24
+ 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(f(null),e){case D.THEMES:case D.LAUNCH_TEXT:case D.THINKING_VERBS:case D.THINKING_STYLE:s(e);break;case D.APPLY_CHANGES:t.ccInstInfo&&(f({message:`Applying patches...`,type:`info`}),Le(n,t.ccInstInfo).then(e=>{i(e),f({message:`Customization patches applied successfully!`,type:`success`})}));break;case D.RESTORE_ORIGINAL:t.ccInstInfo&&pe(t.ccInstInfo).then(()=>{f({message:`Original Claude Code restored successfully!`,type:`success`}),a(()=>{})});break;case D.OPEN_CONFIG:W(A);break;case D.OPEN_CLI:t.ccInstInfo&&W(t.ccInstInfo.cliPath);break;case D.EXIT:process.exit(0)}},h=()=>{s(null)};return p($.Provider,{value:{settings:n.settings,updateSettings:a,changesApplied:n.changesApplied},children:p(e,{flexDirection:`column`,children:o===null?p(R,{onSubmit:m,notification:l}):o===D.THEMES?p(oe,{onBack:h}):o===D.LAUNCH_TEXT?p(se,{onBack:h}):o===D.THINKING_VERBS?p(ce,{onBack:h}):o===D.THINKING_STYLE?p(le,{onBack:h}):null})})}const ze=async()=>{let e=new a;e.name(`tweakcc`).description(`Command-line tool to customize your Claude Code theme colors, thinking verbs and more.`).version(`1.2.0`).option(`-d, --debug`,`enable debug mode`).option(`-a, --apply`,`apply saved customizations without interactive UI`),e.parse();let t=e.opts();if(t.debug&&U(),t.apply){console.log(T.cyan(`🔧 Applying saved customizations to Claude Code...`));try{let e=await de();(!e.settings||Object.keys(e.settings).length===0)&&(console.error(T.red(`❌ No saved customizations found in `+A)),process.exit(1));let t=await _e();(!t||!t.ccInstInfo)&&(console.error(T.red(`❌ Cannot find Claude Code's cli.js`)),console.error(T.yellow(`Searched at the following locations:`)),N.forEach(e=>console.error(T.gray(` - `+e))),process.exit(1)),console.log(T.gray(`📁 Found Claude Code at: ${t.ccInstInfo.cliPath}`)),console.log(T.gray(`📦 Version: ${t.ccInstInfo.version}`)),console.log(T.gray(`✓ Backup handled by startup check`)),console.log(T.cyan(`🎨 Applying customizations...`));try{await Le(e,t.ccInstInfo),console.log(T.green(`✅ Customizations applied successfully!`)),console.log(T.gray(`💾 Configuration saved at: ${A}`))}catch(e){console.error(T.red(`❌ Failed to apply patches:`)),console.error(T.red(e instanceof Error?e.message:String(e))),e instanceof Error&&e.message.includes(`patch:`)&&(console.log(T.yellow(`⚠️ Some patches failed to apply, but the file was updated.`)),console.log(T.yellow(` This may happen if Claude Code was updated.`)),console.log(T.gray(` Run tweakcc interactively to review and update your customizations.`)))}process.exit(0)}catch(e){console.error(T.red(`❌ Unexpected error:`)),console.error(T.red(e instanceof Error?e.message:String(e))),process.exit(1)}}let r=await _e();r?n(p(Re,{startupCheckInfo:r})):(console.error(`\x1b[31mCannot find Claude Code's cli.js -- do you have Claude Code installed?
25
25
 
26
26
  Searched at the following locations:
27
27
  ${N.map(e=>`- `+e).join(`
@@ -41,4 +41,4 @@ Notes:
41
41
 
42
42
  - Don't specify the path to your Claude Code executable's directory. It needs to be the path
43
43
  to the folder that contains **cli.js**.
44
- \x1b[0m`),process.exit(1))};Le();
44
+ \x1b[0m`),process.exit(1))};ze();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tweakcc",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
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",