tweakcc 1.2.2 → 1.2.3
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 +3 -5
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
`tweakcc` is a lightweight, interactive CLI tool that lets you personalize your Claude Code interface.
|
|
8
8
|
|
|
9
|
+
<img src="./assets/demo.gif" alt="Animated GIF demonstrating running `npx tweakcc`, creating a new theme, changing all of Claude Code's UI colors to purple, chaning the thinking format from 'verb + ellipsis' to 'Claude is 'verb', chaning the generating spinner style to a 50m glow animation, applying the changes, running Claude, and using '/config' to switch to the new theme, and sending a message to see the new thinking verb format" width="800">
|
|
10
|
+
|
|
9
11
|
- Create **custom themes** with a graphical HSL/RGB color picker
|
|
10
12
|
- Add custom **thinking verbs** that will show while Claude's working
|
|
11
13
|
- Create custom **thinking spinner animations** with different speeds and phases
|
|
@@ -27,15 +29,11 @@ $ npx tweakcc
|
|
|
27
29
|
$ pnpm dlx tweakcc
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
Demo:
|
|
31
|
-
|
|
32
|
-
<img alt="Animated GIF demonstrating launching tweakcc, creating a new theme, changing its colors, applying the customimations, launching Claude Code, and selecting and trying out the new theme" src="./assets/themes-demo.gif" width="600">
|
|
33
|
-
|
|
34
32
|
## How it works
|
|
35
33
|
|
|
36
34
|
`tweakcc` works by patching the Claude Code's minified `cli.js` file. When you update your Claude Code installation, your customizations will be overwritten, but they're remembered in your `~/.tweakcc/config.js` configuration file, so they can be reapplied by just rerunning the tool.
|
|
37
35
|
|
|
38
|
-
Works with Claude Code 1.0.
|
|
36
|
+
Works with Claude Code 1.0.96
|
|
39
37
|
|
|
40
38
|
## Running
|
|
41
39
|
|
package/dist/index.js
CHANGED
|
@@ -16,12 +16,12 @@ 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 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=/" Welcome to ",[$\w]+\.createElement\([^,]+,\{bold:!0\},"Claude Code"\),"!"/,n=e.match(t);if(n&&n.index!==void 0){let e=n[0].indexOf(`"Claude Code"`);if(e!==-1)return{startIndex:n.index+e,endIndex:n.index+e+13}}return null}function xe(e,t){let n=be(e);if(!n)return console.error(`patch: welcome message: failed to find location`),null;let r=`"${t}"`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i}function Se(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,
|
|
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=/" Welcome to ",[$\w]+\.createElement\([^,]+,\{bold:!0\},"Claude Code"\),"!"/,n=e.match(t);if(n&&n.index!==void 0){let e=n[0].indexOf(`"Claude Code"`);if(e!==-1)return{startIndex:n.index+e,endIndex:n.index+e+13}}return null}function xe(e,t){let n=be(e);if(!n)return console.error(`patch: welcome message: failed to find location`),null;let r=`"${t}"`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Q(e,i,r,n.startIndex,n.endIndex),i}function Se(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,identifiers:[n[1].trim()]},objArr:{startIndex:a.index,endIndex:a.index+a[0].length},obj:{startIndex:o.index,endIndex:o.index+o[0].length}}}const Ce=(e,t)=>{let n=Se(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.identifiers?.[0]}){\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},we=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},Te=(e,t)=>{let n=we(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},Ee=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}},De=(e,t)=>{let n=Ee(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},Oe=e=>{let t=/[\w$]+\(\(\)=>\{if\(![\w$]+\)\{[\w$]+\(\d+\);return\}[\w$]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error(`patch: spinner no-freeze: failed to find wholeMatch`),null;let r=/if\(![\w$]+\)\{[\w$]+\(\d+\);return\}/,i=n[0].match(r);if(!i||i.index===void 0)return console.error(`patch: spinner no-freeze: failed to find freeze condition`),null;let a=n.index+i.index,o=a+i[0].length;return{startIndex:a,endIndex:o}},ke=e=>{let t=Oe(e);if(!t)return null;let n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return Q(e,n,``,t.startIndex,t.endIndex),n},Ae=e=>{let t=/([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s,n=e.match(t);return!n||n.index==null?(console.error(`patch: thinker verbs: failed to find verbsMatch`),null):{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1]]}},je=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):{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1]]}},Me=(e,t)=>{let n=Ae(e);if(!n)return null;let r=n,i=r.identifiers?.[0],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=je(o);if(!s)return null;let c=s,l=c.identifiers?.[0],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},Ne=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+600),i=/([$\w]+)(=\(([^;]{1,200}?)\)\+"…")/,a=r.match(i);return!a||a.index==null?(console.error(`patch: thinker format: failed to find formatMatch`),null):{startIndex:n.index+a.index+a[1].length,endIndex:n.index+a.index+a[1].length+a[2].length,identifiers:[a[3]]}},Pe=(e,t)=>{let n=Ne(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o="`"+i.replace(/\{\}/g,"${"+a+`}`)+"`",s=`=${o}`,c=e.slice(0,r.startIndex)+s+e.slice(r.endIndex);return Q(e,c,s,r.startIndex,r.endIndex),c},Fe=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,identifiers:[n[1]]}},Ie=(e,t)=>{let n=Fe(e);if(!n)return null;let r=n.identifiers?.[0],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},Le=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}},Re=(e,t)=>{let n=Le(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
|
|
22
|
-
`,` `),t.figletFont,(t,n)=>{t?(console.error(`patch: figlet: failed to generate text`,t),e(``)):e(n||``)}))),(r=ye(n,i))&&(n=r);let a=t.method===`custom`?t.customText:t.figletText;a&&(r=xe(n,a))&&(n=r)}return e.settings.thinkingVerbs&&((r=
|
|
21
|
+
`))}const ze=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}},Be=e=>{let t=ze(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},Ve=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=Ce(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);let a=t.method===`custom`?t.customText:t.figletText;a&&(r=xe(n,a))&&(n=r)}return e.settings.thinkingVerbs&&((r=Me(n,e.settings.thinkingVerbs.verbs))&&(n=r),(r=Pe(n,e.settings.thinkingVerbs.format))&&(n=r)),(r=Te(n,e.settings.thinkingStyle.phases))&&(n=r),(r=De(n,e.settings.thinkingStyle.updateInterval))&&(n=r),(r=Re(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=r),(r=Ie(n,e.settings.thinkingStyle.reverseMirror))&&(n=r),(r=Be(n))&&(n=r),(r=ke(n))&&(n=r),await C.writeFile(t.cliPath,n),await Z(e=>{e.changesApplied=!0})},$=s({settings:O,updateSettings:e=>{},changesApplied:!1});function He({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=>{let t=JSON.parse(JSON.stringify(n.settings));e(t),i(e=>({...e,settings:t,changesApplied:!1})),Z(e=>{e.settings=t,e.changesApplied=!1})},[n.settings]),[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`}),
|
|
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`}),Ve(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 Ue=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.3`).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 Ve(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(He,{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))};
|
|
44
|
+
\x1b[0m`),process.exit(1))};Ue();
|