tweakcc 3.2.3 → 3.2.4
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
CHANGED
|
@@ -113,6 +113,8 @@ node dist/index.js
|
|
|
113
113
|
|
|
114
114
|
## Related projects
|
|
115
115
|
|
|
116
|
+
- [**cc-mirror**](https://github.com/numman-ali/cc-mirror) - Create multiple isolated Claude Code variants with custom providers (Z.ai, MiniMax, OpenRouter, LiteLLM). Uses tweakcc to system prompts, customize themes, thinking styles, and toolsets.
|
|
117
|
+
|
|
116
118
|
Other tools for customizing Claude Code or adding functionality to it:
|
|
117
119
|
|
|
118
120
|
- [**clotilde**](https://github.com/fgrehm/clotilde) - Wrapper for Claude Code that adds powerful manual session naming, resuming, forking, and incognito (ephemeral) session management to Claude Code.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Box as e,Text as t,render as n,useInput as r}from"ink";import{Command as i}from"commander";import a from"chalk";import o,{Fragment as s,createContext as c,useCallback as l,useContext as u,useEffect as d,useMemo as f,useRef as p,useState as m}from"react";import*as h from"node:os";import g,{EOL as _}from"node:os";import v from"ink-link";import*as y from"node:fs/promises";import b from"node:fs/promises";import*as x from"node:fs";import S from"node:fs";import*as C from"node:path";import w from"node:path";import*as T from"fs";import*as E from"path";import D from"path";import*as O from"os";import*as k from"child_process";import*as A from"crypto";import ee from"gray-matter";import{Fragment as j,jsx as M,jsxs as N}from"react/jsx-runtime";import P from"process";import F from"which";import{WASMagic as te}from"wasmagic";import{globbySync as I}from"globby";let ne=null;async function L(){if(ne!==null)return ne;try{return await import(`node-lief`),ne=await import(`./nativeInstallation-D2TtDSDx.mjs`),ne}catch(e){return W(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&W(e),null}}async function re(e){let t=await L();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function ie(e,t,n){let r=await L();if(!r)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,t,n)}const ae=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},oe=(e,t)=>{let n=ae(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);V(i,r,n,e.startIndex,e.endIndex),i=r}return i};function R(e){let t=e.match(/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s);if(!t||t.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let n=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(n),a=e.match(r);return!i||i.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!a||a.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const z=(e,t)=>{let n=R(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),V(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),V(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),V(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},se=e=>{let t=e.match(/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/);return!t||t.index===void 0?(console.error(`patch: context limit: failed to find match`),null):t.index+t[0].indexOf(`{`)+1},ce=e=>{let t=se(e);if(!t)return null;let n=`if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},le=e=>{let t=e.indexOf(`bash:"bashBorder"`);if(t===-1)return console.error(`patch: input border: failed to find bash pattern`),null;let n=e.slice(t,t+500).match(/borderStyle:"[^"]*"/);return!n||n.index===void 0?(console.error(`patch: input border: failed to find border style pattern`),null):{startIndex:t+n.index,endIndex:t+n.index+n[0].length}},ue=(e,t)=>{let n=le(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return V(e,r,t,n.startIndex,n.endIndex),r}else return e},de=e=>{let t=e.match(/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/);if(!t||t.index===void 0)return console.error(`patch: spinner no-freeze: failed to find wholeMatch`),null;let n=t[0].match(/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/);if(!n||n.index===void 0)return console.error(`patch: spinner no-freeze: failed to find freeze condition`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},fe=e=>{let t=de(e);if(!t)return null;let n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return V(e,n,``,t.startIndex,t.endIndex),n},pe=e=>{let t=e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/);if(!t||t.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let n=e.slice(t.index,t.index+1e3).match(/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);return!n||n.index==null?(console.error(`patch: thinker format: failed to find formatMatch`),null):{startIndex:t.index+n.index+n[1].length,endIndex:t.index+n.index+n[1].length+n[2].length,identifiers:[n[3]]}},B=(e,t)=>{let n=pe(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o=`=${"`"+i.replace(/\{\}/g,"${"+a+`}`)+"`"}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);return V(e,s,o,r.startIndex,r.endIndex),s},me=e=>{let t=e.match(/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/);return!t||t.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},he=(e,t)=>{let n=me(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 V(e,a,i,n.startIndex,n.endIndex),a},ge=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},_e=(e,t)=>{let n=ge(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);V(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},ve=e=>{let t=e.match(/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/);if(!t||t.index==null)return console.error(`patch: thinker symbol speed: failed to find match`),null;let n=t[0],r=t[1],i=n.lastIndexOf(r),a=t.index+i;return{startIndex:a,endIndex:a+r.length}},ye=(e,t)=>{let n=ve(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,i,r,n.startIndex,n.endIndex),i},be=e=>{let t=e.match(/\{flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},xe=(e,t)=>{let n=be(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 V(e,i,r,n.startIndex,n.endIndex),i},Se=e=>{let t=e.match(/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s);return!t||t.index==null?(console.error(`patch: thinker verbs: failed to find verbsMatch`),null):{startIndex:t.index+1,endIndex:t.index+t[0].length,identifiers:[t[1]]}},Ce=e=>{let t=e.match(/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/);return!t||t.index==null?(console.error(`patch: thinker verbs: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},we=(e,t)=>{let n=Se(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);V(e,o,a,r.startIndex,r.endIndex);let s=Ce(o);if(!s)return null;let c=s,l=`function ${c.identifiers?.[0]}(){return ${i}.words}`,u=o.slice(0,c.startIndex)+l+o.slice(c.endIndex);return V(o,u,l,c.startIndex,c.endIndex),u},Te=e=>{let t=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground",color:"text"\},"> ",([$\w]+)\+" "\);/);return!t||t.index==null?(console.error(`patch: messageDisplayMatch: failed to find error message`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[3]]}},Ee=(e,t,n,r,i=!1,a=!1,o=!1,s=!1,c=!1,l=`none`,u=`rgb(255,255,255)`,d=0,f=0,p=!1)=>{let m=Te(e);if(!m)return console.error(`^ patch: userMessageDisplay: getUserMessageDisplayLocation returned null`),null;let h=_n(e);if(!h)return console.error(`^ patch: userMessageDisplay: failed to find chalk variable`),null;let g=En(e);if(!g)return console.error(`^ patch: userMessageDisplay: failed to find box component`),null;let _=``,v=[];n===`default`&&v.push(`color:"text"`),r===`default`&&v.push(`backgroundColor:"userMessageBackground"`);let y=v.length>0?`{${v.join(`,`)}}`:`{}`,b=[],x=l.startsWith(`topBottom`);if(l!==`none`){if(x){let e=``;l===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),b.push(`borderStyle:${e}`)}else b.push(`borderStyle:"${l}"`);let e=u.match(/\d+/g);e&&b.push(`borderColor:"rgb(${e.join(`,`)})"`)}d>0&&b.push(`paddingX:${d}`),f>0&&b.push(`paddingY:${f}`),p&&b.push(`alignSelf:"flex-start"`);let S=b.length>0?`{${b.join(`,`)}}`:`{}`,C=n!==`default`||r!==`default`&&r!==null||i||a||o||s||c;if(C){if(_=h,n!==`default`){let e=n.match(/\d+/g);e&&(_+=`.rgb(${e.join(`,`)})`)}if(r!==`default`&&r!==null){let e=r.match(/\d+/g);e&&(_+=`.bgRgb(${e.join(`,`)})`)}i&&(_+=`.bold`),a&&(_+=`.italic`),o&&(_+=`.underline`),s&&(_+=`.strikethrough`),c&&(_+=`.inverse`)}let[w,T,E]=m.identifiers,D=`"`+t.replace(/\{\}/g,`"+${E}+"`)+`"`,O=`
|
|
2
|
+
import{Box as e,Text as t,render as n,useInput as r}from"ink";import{Command as i}from"commander";import a from"chalk";import o,{Fragment as s,createContext as c,useCallback as l,useContext as u,useEffect as d,useMemo as f,useRef as p,useState as m}from"react";import*as h from"node:os";import g,{EOL as _}from"node:os";import v from"ink-link";import*as y from"node:fs/promises";import b from"node:fs/promises";import*as x from"node:fs";import S from"node:fs";import*as C from"node:path";import w from"node:path";import*as T from"fs";import*as E from"path";import D from"path";import*as O from"os";import*as k from"child_process";import*as A from"crypto";import ee from"gray-matter";import{Fragment as j,jsx as M,jsxs as N}from"react/jsx-runtime";import P from"process";import F from"which";import{WASMagic as te}from"wasmagic";import{globbySync as I}from"globby";let ne=null;async function L(){if(ne!==null)return ne;try{return await import(`node-lief`),ne=await import(`./nativeInstallation-DBmBL-fs.mjs`),ne}catch(e){return W(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&W(e),null}}async function re(e){let t=await L();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function ie(e,t,n){let r=await L();if(!r)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,t,n)}const ae=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},oe=(e,t)=>{let n=ae(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);V(i,r,n,e.startIndex,e.endIndex),i=r}return i};function R(e){let t=e.match(/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s);if(!t||t.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let n=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(n),a=e.match(r);return!i||i.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!a||a.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const z=(e,t)=>{let n=R(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),V(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),V(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),V(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},se=e=>{let t=e.match(/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/);return!t||t.index===void 0?(console.error(`patch: context limit: failed to find match`),null):t.index+t[0].indexOf(`{`)+1},ce=e=>{let t=se(e);if(!t)return null;let n=`if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},le=e=>{let t=e.indexOf(`bash:"bashBorder"`);if(t===-1)return console.error(`patch: input border: failed to find bash pattern`),null;let n=e.slice(t,t+500).match(/borderStyle:"[^"]*"/);return!n||n.index===void 0?(console.error(`patch: input border: failed to find border style pattern`),null):{startIndex:t+n.index,endIndex:t+n.index+n[0].length}},ue=(e,t)=>{let n=le(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return V(e,r,t,n.startIndex,n.endIndex),r}else return e},de=e=>{let t=e.match(/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/);if(!t||t.index===void 0)return console.error(`patch: spinner no-freeze: failed to find wholeMatch`),null;let n=t[0].match(/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/);if(!n||n.index===void 0)return console.error(`patch: spinner no-freeze: failed to find freeze condition`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},fe=e=>{let t=de(e);if(!t)return null;let n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return V(e,n,``,t.startIndex,t.endIndex),n},pe=e=>{let t=e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/);if(!t||t.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let n=e.slice(t.index,t.index+1e3).match(/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);return!n||n.index==null?(console.error(`patch: thinker format: failed to find formatMatch`),null):{startIndex:t.index+n.index+n[1].length,endIndex:t.index+n.index+n[1].length+n[2].length,identifiers:[n[3]]}},B=(e,t)=>{let n=pe(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o=`=${"`"+i.replace(/\{\}/g,"${"+a+`}`)+"`"}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);return V(e,s,o,r.startIndex,r.endIndex),s},me=e=>{let t=e.match(/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/);return!t||t.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},he=(e,t)=>{let n=me(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 V(e,a,i,n.startIndex,n.endIndex),a},ge=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},_e=(e,t)=>{let n=ge(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);V(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},ve=e=>{let t=e.match(/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/);if(!t||t.index==null)return console.error(`patch: thinker symbol speed: failed to find match`),null;let n=t[0],r=t[1],i=n.lastIndexOf(r),a=t.index+i;return{startIndex:a,endIndex:a+r.length}},ye=(e,t)=>{let n=ve(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,i,r,n.startIndex,n.endIndex),i},be=e=>{let t=e.match(/\{flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},xe=(e,t)=>{let n=be(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 V(e,i,r,n.startIndex,n.endIndex),i},Se=e=>{let t=e.match(/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s);return!t||t.index==null?(console.error(`patch: thinker verbs: failed to find verbsMatch`),null):{startIndex:t.index+1,endIndex:t.index+t[0].length,identifiers:[t[1]]}},Ce=e=>{let t=e.match(/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/);return!t||t.index==null?(console.error(`patch: thinker verbs: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},we=(e,t)=>{let n=Se(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);V(e,o,a,r.startIndex,r.endIndex);let s=Ce(o);if(!s)return null;let c=s,l=`function ${c.identifiers?.[0]}(){return ${i}.words}`,u=o.slice(0,c.startIndex)+l+o.slice(c.endIndex);return V(o,u,l,c.startIndex,c.endIndex),u},Te=e=>{let t=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground",color:"text"\},"> ",([$\w]+)\+" "\);/);return!t||t.index==null?(console.error(`patch: messageDisplayMatch: failed to find error message`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[3]]}},Ee=(e,t,n,r,i=!1,a=!1,o=!1,s=!1,c=!1,l=`none`,u=`rgb(255,255,255)`,d=0,f=0,p=!1)=>{let m=Te(e);if(!m)return console.error(`^ patch: userMessageDisplay: getUserMessageDisplayLocation returned null`),null;let h=yn(e);if(!h)return console.error(`^ patch: userMessageDisplay: failed to find chalk variable`),null;let g=On(e);if(!g)return console.error(`^ patch: userMessageDisplay: failed to find box component`),null;let _=``,v=[];n===`default`&&v.push(`color:"text"`),r===`default`&&v.push(`backgroundColor:"userMessageBackground"`);let y=v.length>0?`{${v.join(`,`)}}`:`{}`,b=[],x=l.startsWith(`topBottom`);if(l!==`none`){if(x){let e=``;l===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),b.push(`borderStyle:${e}`)}else b.push(`borderStyle:"${l}"`);let e=u.match(/\d+/g);e&&b.push(`borderColor:"rgb(${e.join(`,`)})"`)}d>0&&b.push(`paddingX:${d}`),f>0&&b.push(`paddingY:${f}`),p&&b.push(`alignSelf:"flex-start"`);let S=b.length>0?`{${b.join(`,`)}}`:`{}`,C=n!==`default`||r!==`default`&&r!==null||i||a||o||s||c;if(C){if(_=h,n!==`default`){let e=n.match(/\d+/g);e&&(_+=`.rgb(${e.join(`,`)})`)}if(r!==`default`&&r!==null){let e=r.match(/\d+/g);e&&(_+=`.bgRgb(${e.join(`,`)})`)}i&&(_+=`.bold`),a&&(_+=`.italic`),o&&(_+=`.underline`),s&&(_+=`.strikethrough`),c&&(_+=`.inverse`)}let[w,T,E]=m.identifiers,D=`"`+t.replace(/\{\}/g,`"+${E}+"`)+`"`,O=`
|
|
3
3
|
return ${w}.createElement(
|
|
4
4
|
${g},
|
|
5
5
|
${S},
|
|
@@ -8,9 +8,9 @@ return ${w}.createElement(
|
|
|
8
8
|
${y},
|
|
9
9
|
${C?_+`(`:``}${D}${C?`)`:``}
|
|
10
10
|
)
|
|
11
|
-
);`,k=e.slice(0,m.startIndex)+O+e.slice(m.endIndex);return V(e,k,O,m.startIndex,m.endIndex),k},De=e=>{let t=e.match(/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/);if(!t||t.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let n=t[0].match(/verbose:[^,}]+/);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},Oe=e=>{let t=De(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},ke=e=>{let t=e.match(/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/);if(!t||t.index===void 0)return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null;let n=t.index;return{startIndex:n,endIndex:n+t[0].length,identifiers:[t[1],t[2],t[3]]}},Ae=e=>{let t=ke(e);if(!t)return null;let n=`${t.identifiers[0]}${t.identifiers[1]}true${t.identifiers[2]}`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},je=e=>{let t=e.indexOf(`}.VERSION} (Claude Code)`);return t==-1?(console.error(`patch: patchesAppliedIndication: failed to find versionIndex`),null):{startIndex:0,endIndex:t+24}},Me=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern`),null;let n=t.index+t[0].length;return{startIndex:n,endIndex:n}},Ne=(e,t,n,r,i,a)=>{let o=e.match(/alignItems:"center",minHeight:9,?/);if(!o||o.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4`),null;let s=e.slice(0,o.index)+`minHeight:9,`+e.slice(o.index+o[0].length),c=Math.max(0,o.index-200),l=s.slice(c,o.index+12+2),u=Array.from(l.matchAll(/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g));if(u.length===0)return console.error(`patch: patchesAppliedIndication: failed to find createElement for PATCH 4`),null;let d=u[u.length-1],f=c+d.index+d[0].length,p=`${n}.createElement(${i}, null, ${a}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,m=s;s=s.slice(0,f)+p+s.slice(f),V(m,s,p,f,f);let h=1,g=f+p.length,_=-1;for(;g<s.length;){let e=s[g];if(e===`(`)h++;else if(e===`)`){if(h===1){_=g;break}h--}g++}if(_===-1)return console.error(`patch: patchesAppliedIndication: failed to find closing paren for PATCH 4`),null;let v=s;return s=s.slice(0,_)+`),`+s.slice(_),V(v,s,`),`,_,_),{content:s,closingParenIndex:_+2}},Pe=(e,t,n,r,i,a,o)=>{let s=4,c=t,l=-1;for(;c<e.length;){let t=e[c];if(t===`(`)s++;else if(t===`)`){if(s===1){l=c;break}s--}c++}if(l===-1)return console.error(`patch: patchesAppliedIndication: failed to find insertion point for PATCH 5`),null;let u=[];u.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of o)e=e.replace(`CHALK_VAR`,a),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {dimColor: true}, \` * ${e}\`)),`);u.push(`),`);let d=u.join(``),f=e,p=e.slice(0,l)+d+e.slice(l);return V(f,p,d,l,l),p},Fe=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3`),null;let n=Math.max(0,t.index-1500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/\}function ([$\w]+)\(/g));if(i.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let a=i[i.length-1][1],o=RegExp(`\\b([$\\w]+)\\.createElement\\(${H(a)},null\\),?`),s=e.match(o);if(!s||s.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let c=s.index+s[0].length;return{startIndex:c,endIndex:c}},Ie=(e,t,n,r=!0,i=!0)=>{let a=je(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=e.slice(0,a.endIndex)+o+e.slice(a.endIndex);V(e,s,o,a.endIndex,a.endIndex);let c=
|
|
12
|
-
`),i=s;s=s.slice(0,e.startIndex)+r+s.slice(e.endIndex),V(i,s,r,e.startIndex,e.endIndex)}let f=-1;if(r){let e=Ne(s,t,u,d,l,c);if(!e)return console.error(`patch: patchesAppliedIndication: patch 4 failed`),null;s=e.content,f=e.closingParenIndex}if(i){if(f===-1){let e=s.match(/alignItems:"center",minHeight:9,?/);if(!e||e.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find reference point for PATCH 5`),null;f=e.index+e[0].length}let e=Pe(s,f,u,d,l,c,n);if(!e)return console.error(`patch: patchesAppliedIndication: patch 5 failed`),null;s=e}return s};async function Le(e){let t=E.join(
|
|
13
|
-
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content.trim(),contentLineOffset:o}},Qe=(e,t)=>{let n=t||$e(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,i={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(i.variables=r),ee.stringify(n,i,{delimiters:[`<!--`,`-->`]})},$e=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++)if(r+=e[i],i<t.length){let e=t[i],a=n[String(e)]||`UNKNOWN_${e}`;r+=a}return r},et=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]||0,i=r[e]||0;if(t<i)return-1;if(t>i)return 1}return 0},tt=e=>E.join(
|
|
11
|
+
);`,k=e.slice(0,m.startIndex)+O+e.slice(m.endIndex);return V(e,k,O,m.startIndex,m.endIndex),k},De=e=>{let t=e.match(/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/);if(!t||t.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let n=t[0].match(/verbose:[^,}]+/);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},Oe=e=>{let t=De(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},ke=e=>{let t=e.match(/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/);if(!t||t.index===void 0)return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null;let n=t.index;return{startIndex:n,endIndex:n+t[0].length,identifiers:[t[1],t[2],t[3]]}},Ae=e=>{let t=ke(e);if(!t)return null;let n=`${t.identifiers[0]}${t.identifiers[1]}true${t.identifiers[2]}`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},je=e=>{let t=e.indexOf(`}.VERSION} (Claude Code)`);return t==-1?(console.error(`patch: patchesAppliedIndication: failed to find versionIndex`),null):{startIndex:0,endIndex:t+24}},Me=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern`),null;let n=t.index+t[0].length;return{startIndex:n,endIndex:n}},Ne=(e,t,n,r,i,a)=>{let o=e.match(/alignItems:"center",minHeight:9,?/);if(!o||o.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4`),null;let s=e.slice(0,o.index)+`minHeight:9,`+e.slice(o.index+o[0].length),c=Math.max(0,o.index-200),l=s.slice(c,o.index+12+2),u=Array.from(l.matchAll(/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g));if(u.length===0)return console.error(`patch: patchesAppliedIndication: failed to find createElement for PATCH 4`),null;let d=u[u.length-1],f=c+d.index+d[0].length,p=`${n}.createElement(${i}, null, ${a}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,m=s;s=s.slice(0,f)+p+s.slice(f),V(m,s,p,f,f);let h=1,g=f+p.length,_=-1;for(;g<s.length;){let e=s[g];if(e===`(`)h++;else if(e===`)`){if(h===1){_=g;break}h--}g++}if(_===-1)return console.error(`patch: patchesAppliedIndication: failed to find closing paren for PATCH 4`),null;let v=s;return s=s.slice(0,_)+`),`+s.slice(_),V(v,s,`),`,_,_),{content:s,closingParenIndex:_+2}},Pe=(e,t,n,r,i,a,o)=>{let s=4,c=t,l=-1;for(;c<e.length;){let t=e[c];if(t===`(`)s++;else if(t===`)`){if(s===1){l=c;break}s--}c++}if(l===-1)return console.error(`patch: patchesAppliedIndication: failed to find insertion point for PATCH 5`),null;let u=[];u.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of o)e=e.replace(`CHALK_VAR`,a),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {dimColor: true}, \` * ${e}\`)),`);u.push(`),`);let d=u.join(``),f=e,p=e.slice(0,l)+d+e.slice(l);return V(f,p,d,l,l),p},Fe=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3`),null;let n=Math.max(0,t.index-1500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/\}function ([$\w]+)\(/g));if(i.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let a=i[i.length-1][1],o=RegExp(`\\b([$\\w]+)\\.createElement\\(${H(a)},null\\),?`),s=e.match(o);if(!s||s.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let c=s.index+s[0].length;return{startIndex:c,endIndex:c}},Ie=(e,t,n,r=!0,i=!0)=>{let a=je(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=e.slice(0,a.endIndex)+o+e.slice(a.endIndex);V(e,s,o,a.endIndex,a.endIndex);let c=yn(e);if(!c)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let l=Dn(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let u=wn(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;let d=On(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find Box component`),null;if(r){let e=Me(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 2 failed`),null;let n=`, " ",${u}.createElement(${l}, null, ${c}.blue.bold('+ tweakcc v${t}'))`,r=s;s=s.slice(0,e.startIndex)+n+s.slice(e.endIndex),V(r,s,n,e.startIndex,e.endIndex)}if(i){let e=Fe(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 3 failed`),null;let t=[];t.push(`${u}.createElement(${d}, { flexDirection: "column" },`),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of n)e=e.replace(`CHALK_VAR`,c),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {dimColor: true}, \` * ${e}\`)),`);t.push(`),`);let r=t.join(`
|
|
12
|
+
`),i=s;s=s.slice(0,e.startIndex)+r+s.slice(e.endIndex),V(i,s,r,e.startIndex,e.endIndex)}let f=-1;if(r){let e=Ne(s,t,u,d,l,c);if(!e)return console.error(`patch: patchesAppliedIndication: patch 4 failed`),null;s=e.content,f=e.closingParenIndex}if(i){if(f===-1){let e=s.match(/alignItems:"center",minHeight:9,?/);if(!e||e.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find reference point for PATCH 5`),null;f=e.index+e[0].length}let e=Pe(s,f,u,d,l,c,n);if(!e)return console.error(`patch: patchesAppliedIndication: patch 5 failed`),null;s=e}return s};async function Le(e){let t=E.join(tr,`prompts-${e}.json`);try{let e=await y.readFile(t,`utf-8`);return JSON.parse(e)}catch{}let n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{let r=await fetch(n);if(!r.ok){let t;throw t=r.status===429?`Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.`:r.status===404?`Prompts file not found for Claude Code v${e}. This version was released within the past day or so and will be supported within a few hours.`:r.status>=500?`GitHub server error (${r.status}). Please try again later.`:`HTTP ${r.status}: ${r.statusText}`,Error(t)}let i=await r.json();try{await y.mkdir(tr,{recursive:!0}),await y.writeFile(t,JSON.stringify(i,null,2),`utf-8`)}catch(e){console.warn(`Failed to write to cache to ${t}: ${e}`)}return i}catch(t){if(t instanceof Error){if(t.message.includes(`Rate limit`)||t.message.includes(`not found`)||t.message.includes(`server error`)||t.message.includes(`HTTP`))throw t;let n=`Failed to download prompts for version ${e}: ${t.message}`;throw Error(n)}throw t}}const Re=()=>E.join(q,`systemPromptOriginalHashes.json`),ze=()=>E.join(q,`systemPromptAppliedHashes.json`),Be=(e,t)=>`${e}-${t}`,Ve=e=>A.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),He=async()=>{try{let e=await y.readFile(Re(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Ue=async e=>{await y.mkdir(q,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await y.writeFile(Re(),JSON.stringify(t,null,2),`utf8`)},We=async e=>{let t=await He(),n=0;for(let r of e.prompts){let e=Be(r.id,r.version);t[e]||(t[e]=Ve($e(r.pieces,r.identifiers,r.identifierMap)),n++)}return await Ue(t),n},Ge=async(e,t)=>(await He())[Be(e,t)],Ke=async()=>{try{let e=await y.readFile(ze(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},qe=async e=>{await y.mkdir(q,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await y.writeFile(ze(),JSON.stringify(t,null,2),`utf8`)},Je=async(e,t)=>{let n=await Ke();n[e]=t,await qe(n)},Ye=async()=>{let e=await Ke(),t={};for(let n of Object.keys(e))t[n]=null;await qe(t)},Xe=async e=>{try{let t=await Ke();if(Object.keys(t).length===0)return!1;let n=(await y.readdir(e)).filter(e=>e.endsWith(`.md`));for(let r of n){let n=t[r.replace(`.md`,``)];if(n==null)continue;let i=E.join(e,r),a=await y.readFile(i,`utf8`);if(Ve((await import(`gray-matter`)).default(a,{delimiters:[`<!--`,`-->`]}).content)!==n)return!0}return!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}},Ze=e=>{let t=ee(e,{delimiters:[`<!--`,`-->`]}),{name:n,description:r,ccVersion:i,variables:a}=t.data,o=0,s=e.indexOf(t.content);return s>=0&&(o=e.slice(0,s).split(`
|
|
13
|
+
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content.trim(),contentLineOffset:o}},Qe=(e,t)=>{let n=t||$e(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,i={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(i.variables=r),ee.stringify(n,i,{delimiters:[`<!--`,`-->`]})},$e=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++)if(r+=e[i],i<t.length){let e=t[i],a=n[String(e)]||`UNKNOWN_${e}`;r+=a}return r},et=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]||0,i=r[e]||0;if(t<i)return-1;if(t>i)return 1}return 0},tt=e=>E.join(er,`${e}.md`),nt=async e=>{try{return await y.access(tt(e)),!0}catch{return!1}},rt=async e=>{let t=tt(e);return Ze(await y.readFile(t,`utf-8`))},it=async(e,t)=>{let n=tt(e);await y.writeFile(n,t,`utf-8`)},at=async(e,t)=>{let n=tt(e),r=ee(await y.readFile(n,`utf-8`),{delimiters:[`<!--`,`-->`]}),i=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,a={name:r.data.name,description:r.data.description,ccVersion:r.data.ccVersion};i&&i.length>0&&(a.variables=i),await it(e,ee.stringify(r.content,a,{delimiters:[`<!--`,`-->`]}))},ot=(e,t)=>{let n=e=>e.split(/(\s+)/),r=n(e),i=n(t),a=r.length,o=i.length,s=Array(a+1).fill(0).map(()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)r[e-1]===i[t-1]?s[e][t]=s[e-1][t-1]+1:s[e][t]=Math.max(s[e-1][t],s[e][t-1]);let c=Array(a).fill(!1),l=Array(o).fill(!1),u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l[d-1]=!0,d--):u>0&&(c[u-1]=!0,u--);let f=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),p=``;for(let e=0;e<r.length;e++){let t=f(r[e]);p+=c[e]?`<mark>${t}</mark>`:t}let m=``;for(let e=0;e<i.length;e++){let t=f(i[e]);m+=l[e]?`<mark>${t}</mark>`:t}return{oldHtml:p,newHtml:m}},st=(e,t)=>{let n=e.length,r=t.length,i=Array(n+1).fill(0).map(()=>Array(r+1).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]+1:i[a][n]=Math.max(i[a-1][n],i[a][n-1]);let a=[],o=n,s=r,c=[];for(;o>0||s>0;)o>0&&s>0&&e[o-1]===t[s-1]?(c.unshift({type:`unchanged`,line:e[o-1],oldLineNo:o,newLineNo:s}),o--,s--):s>0&&(o===0||i[o][s-1]>=i[o-1][s])?(c.unshift({type:`added`,line:t[s-1],newLineNo:s}),s--):o>0&&(c.unshift({type:`removed`,line:e[o-1],oldLineNo:o}),o--);for(let e=0;e<c.length;e++){let t=c[e],n=c[e+1];if(t.type===`removed`&&n?.type===`added`){let r=ot(t.line,n.line);a.push({type:`modified`,line:t.line,oldLineNo:t.oldLineNo,newLineNo:n.newLineNo,oldHtml:r.oldHtml,newHtml:r.newHtml}),e++}else a.push(t)}return a},ct=async(e,t,n,r,i,a,o,s)=>{let c=n.split(`
|
|
14
14
|
`),l=r.split(`
|
|
15
15
|
`),u=i.split(`
|
|
16
16
|
`),d=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),f=st(c,l),p=st(c,u),m=``;for(let e of f){let t=d(e.line);if(e.type===`modified`){let t=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;m+=`<div class="line removed"><span class="line-num">${t}</span><span class="prefix">- </span>${e.oldHtml}</div>\n`,m+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${e.newHtml}</div>\n`}else if(e.type===`removed`){let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `;m+=`<div class="line removed"><span class="line-num">${n}</span><span class="prefix">- </span>${t}</div>\n`}else if(e.type===`added`){let n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;m+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${t}</div>\n`}else{let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,r=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;m+=`<div class="line unchanged"><span class="line-num">${n} ${r}</span><span class="prefix"> </span>${t}</div>\n`}}let h=``;for(let e of p){let t=d(e.line);if(e.type===`modified`){let t=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;h+=`<div class="line removed"><span class="line-num">${t}</span><span class="prefix">- </span>${e.oldHtml}</div>\n`,h+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${e.newHtml}</div>\n`}else if(e.type===`removed`){let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `;h+=`<div class="line removed"><span class="line-num">${n}</span><span class="prefix">- </span>${t}</div>\n`}else if(e.type===`added`){let n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;h+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${t}</div>\n`}else{let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,r=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;h+=`<div class="line unchanged"><span class="line-num">${n} ${r}</span><span class="prefix"> </span>${t}</div>\n`}}let g=`<!DOCTYPE html>
|
|
@@ -174,10 +174,10 @@ ${h} </div>
|
|
|
174
174
|
</div>
|
|
175
175
|
</div>
|
|
176
176
|
</body>
|
|
177
|
-
</html>`,_=E.join(
|
|
177
|
+
</html>`,_=E.join(er,`${e}.diff.html`);return await y.writeFile(_,g,`utf-8`),_},lt=async e=>{let t={id:e.id,name:e.name,description:e.description,action:`skipped`,newVersion:e.version};if(!await nt(e.id)){let n=Qe(e);return await it(e.id,n),t.action=`created`,t}let n=await rt(e.id);if(t.oldVersion=n.ccVersion,await at(e.id,e.identifierMap),n.ccVersion&&e.version){let r=et(n.ccVersion,e.version);if(r===0)return t.action=`skipped`,t;if(r!=0){let r=await Ge(e.id,n.ccVersion),i=Ve(n.content);if(!r||r!==i){t.action=`conflict`;let r=n.content;try{let t=(await Le(n.ccVersion)).prompts.find(t=>t.id===e.id);t&&(r=$e(t.pieces,t.identifiers,t.identifierMap))}catch{console.log(a.yellow(`Warning: Could not fetch old version ${n.ccVersion} for comparison. Using current file as baseline.`))}let i=$e(e.pieces,e.identifiers,e.identifierMap),o=tt(e.id);t.diffHtmlPath=await ct(e.id,e.name,r,n.content,i,n.ccVersion,e.version,o)}else{let n=Qe(e);await it(e.id,n),t.action=`updated`}}}return t},ut=async e=>{let t={ccVersion:e,results:[]},n=await Le(e);await We(n),await y.mkdir(er,{recursive:!0});for(let e of n.prompts)try{let n=await lt(e);t.results.push(n)}catch(t){throw console.log(a.red(`Failed to sync prompt ${e.id}:`)),t}return t};let dt=null,ft=null;const pt=async e=>{try{return dt=await Le(e),ft=e,{success:!0}}catch(e){return dt=null,ft=null,e instanceof Error?{success:!1,errorMessage:e.message}:{success:!1,errorMessage:`Unknown error occurred while downloading system prompts`}}},mt=e=>e.replace(/[^\x00-\x7F]/g,e=>{let t=`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`;return`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}|${t})`}),ht=e=>e.replace(/[^\x00-\x7F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),gt=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++){let a=e[i].replace(/<<CCVERSION>>/g,t);n&&(a=a.replace(/<<BUILD_TIME>>/g,n));let o=mt(a.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).replace(/\n/g,`(?:
|
|
178
178
|
|\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},_t=e=>{let t=new Map,n=0,r=1,i=1;for(let a=0;a<e.length;a++,i++){let o=e[a];if(o===`
|
|
179
179
|
`){r++,i=0;continue}let s=e[a+1];if(o===`$`&&s===`{`){n++,a++,i++;continue}if(n){o===`{`?n++:o===`}`&&n--;continue}if(o==="`"&&e[a-1]!==`\\`){let e=t.get(r)??[];e.push(i),t.set(r,e)}}return t},vt=(e,t,n,r)=>{let i=[],o=String(t),s=o.length,c=` `.repeat(s),l=r[0],u=r[r.length-1],d=l-1,f=n.length-u,p=n,m=r,h=``,g=``,_=0;if(d>30||f>30){let e=0,t=n.length,i=0;if(d>30){let t=d-30;e=t,i=-t;let n=`[${t} chars] ...`;h=a.dim(n),_=n.length}if(f>30){let e=f-30;t=n.length-e,g=a.dim(`... [${e} chars]`)}p=n.substring(e,t),m=r.map(e=>e+i)}i.push(`${a.red.bold(`error`)}${a.bold(`: system prompt file contains unescaped backtick`)}`),i.push(`${a.blue.bold(` `.repeat(s)+` -->`)} ${e}:${t}:${l}`),i.push(`${c} ${a.blue.bold(`|`)}`);let v=h+p+g;i.push(`${a.blue.bold(o)} ${a.blue.bold(`|`)} ${v}`);let y=_+m[0]-1,b=` `.repeat(y)+`^ unescaped backtick`;i.push(`${c} ${a.blue.bold(`|`)} ${a.red.bold(b)}`),i.push(`${c} ${a.blue.bold(`|`)}`),i.push(`${a.cyan.bold(`help`)}: add \`\\\` before the backtick to escape it`),i.push(`${c} ${a.blue.bold(`|`)}`);let x=[],S=0;for(let e of m)x.push(p.substring(S,e-1)),x.push(a.green(`\\`)+"`"),S=e;x.push(p.substring(S));let C=h+x.join(``)+g;i.push(`${a.blue.bold(o)} ${a.blue.bold(`|`)} ${C}`);let w=``,T=0;for(let e=0;e<m.length;e++){let t=m[e],n=_+t-1+T;w=w.padEnd(n,` `)+`+`,T++}return i.push(`${c} ${a.blue.bold(`|`)} ${a.green(w)}`),i.join(`
|
|
180
|
-
`)},yt=(e,t,n,r,i,a=!1,o)=>{let s={};for(let e=0;e<r.length;e++){let i=r[e],a=n[String(t[e])];a&&(s[a]=i)}let c=e,l=Object.entries(s).sort((e,t)=>t[0].length-e[0].length);for(let[e,t]of l){let n=RegExp(`\\b${e}\\b`,`g`);c=c.replace(n,()=>t)}return c=c.replace(/<<CCVERSION>>/g,i),o&&(c=c.replace(/<<BUILD_TIME>>/g,o)),a&&(c=ht(c)),c},bt=async(e,t=!1,n)=>{if(!dt||ft!==e)return[];let r=dt,i=[];for(let a of r.prompts){let r=gt(a.pieces,e,n),o=E.join(
|
|
180
|
+
`)},yt=(e,t,n,r,i,a=!1,o)=>{let s={};for(let e=0;e<r.length;e++){let i=r[e],a=n[String(t[e])];a&&(s[a]=i)}let c=e,l=Object.entries(s).sort((e,t)=>t[0].length-e[0].length);for(let[e,t]of l){let n=RegExp(`\\b${e}\\b`,`g`);c=c.replace(n,()=>t)}return c=c.replace(/<<CCVERSION>>/g,i),o&&(c=c.replace(/<<BUILD_TIME>>/g,o)),a&&(c=ht(c)),c},bt=async(e,t=!1,n)=>{if(!dt||ft!==e)return[];let r=dt,i=[];for(let a of r.prompts){let r=gt(a.pieces,e,n),o=E.join(er,`${a.id}.md`),s;try{s=await y.readFile(o,`utf8`)}catch(e){console.error(`Failed to read markdown file ${o}:`,e);continue}let c=Ze(s);i.push({promptId:a.id,prompt:c,regex:r,getInterpolatedContent:r=>{let i=r.slice(1);return yt(c.content,a.identifiers,a.identifierMap,i,e,t,n)},pieces:a.pieces,identifiers:a.identifiers,identifierMap:a.identifierMap})}return i},xt=e=>{let t=e.results.filter(e=>e.action===`created`),n=e.results.filter(e=>e.action===`updated`),r=e.results.filter(e=>e.action===`conflict`),i=e.results.filter(e=>e.action===`skipped`);if((t.length>0||n.length>0||r.length>0)&&i.length>0&&(console.log(a.dim(`Skipped ${i.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(a.bold.green(`Created ${t.length} new prompt file(s):`));for(let e of t)console.log(a.green(` ${er}/${e.id}.md`)),console.log(a.green.dim(` ${e.description}`));console.log()}if(n.length>0){console.log(a.bold.blue(`Updated ${n.length} system prompt file(s):`));for(let e of n)e.oldVersion?console.log(a.blue(` ${e.id}.md (${e.oldVersion} → ${e.newVersion})`)):console.log(a.blue(` ${e.id}.md (→ ${e.newVersion})`));console.log()}if(r.length>0){console.log(a.bold.yellow(`WARNING: Conflicts detected for ${r.length} system prompt file(s)`));for(let e of r)console.log(a.yellow(` ${e.id}.md (${e.oldVersion} → ${e.newVersion})`)),console.log(a.yellow(` Open the diff in your browser: ${e.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(a.green.bold(`New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.`)),console.log(a.green(`You can now customize the markdown files at ${er} in a text editor.`)),console.log(a.green(`Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts`)),console.log()),r.length>0){console.log(),console.log(`Review conflicts:`),console.log(` 1. Open the diff HTML files in your browser`),console.log(` 2. Verify your customizations are still appropriate`),console.log(` 3. Update your markdown files if needed`),console.log(a.bold.cyan(` 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:`));for(let e of r)console.log(a.yellow(` ${e.id}.md → `)+a.bold.magenta(e.newVersion));console.log(` 5. Delete the diff HTML files`),console.log()}},St=e=>/\\u[0-9a-fA-F]{4}/.test(e),Ct=e=>{let t=e.match(/\bBUILD_TIME:"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)"/);return t?t[1]:void 0},wt=e=>{let t=e.toString();return`new RegExp(${JSON.stringify(t.substring(1,t.length-1))}, ${JSON.stringify(t.match(/\/(\w*)$/)[1])})`},Tt=async(e,t,n)=>{let r=n??St(e);r&&W(`Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts`);let i=Ct(e);i&&W(`Extracted BUILD_TIME from cli.js: ${i}`);let o=await bt(t,r,i);W(`Loaded ${o.length} system prompts with regexes`);let s=0,c=0;for(let{promptId:t,prompt:n,regex:r,getInterpolatedContent:i,pieces:l,identifiers:u,identifierMap:d}of o){let o=new RegExp(r,`si`),f=e.match(o);if(f&&f.index!==void 0){let r=i(f),a=f.index,p=a>0?e[a-1]:``;if(p==="`"){let e=_t(r);if(e.size>0){let r=tt(t),i=n.content.split(`
|
|
181
181
|
`);for(let[t,a]of e){let e=t+(n.contentLineOffset||0),o=i[t-1]||``;console.log(vt(r,e,o,a)),console.log()}continue}}let m=$e(l,u,d).trim(),h=m.length,g=n.content.length;s+=h,c+=g,h!==g&&(G(`\n Character count difference for ${n.name}:`),G(` Original baseline: ${h} chars`),G(` User's version: ${g} chars`),G(` Difference: ${h-g} chars`),Math.abs(h-g)<200&&(G(`\n Original baseline content:\n${m}`),G(`\n User's content:\n${n.content}`))),G(`\nFound match for prompt: ${n.name}`),G(` Match location: index ${f.index}, length ${f[0].length}`),G(` Original content (first 100 chars): ${f[0].substring(0,100)}...`),G(` Replacement content (first 100 chars): ${r.substring(0,100)}...`),G(` Captured variables: ${f.slice(1).join(`, `)}`),G(` Content identical: ${f[0]===r}`);let _=e,v=f[0].length,y=r;p===`"`?(y=y.replace(/\n/g,`\\n`),y=y.replace(/"/g,`\\"`)):p===`'`&&(y=y.replace(/\n/g,`\\n`),y=y.replace(/'/g,`\\'`)),e=e.replace(o,()=>y),await Je(t,Ve(n.content)),V(_,e,y,a,a+v)}else{console.log(a.yellow(`Could not find system prompt "${n.name}" in cli.js (using regex ${wt(o)})`)),G(`\n Debug info for ${n.name}:`),G(` Regex pattern (first 200 chars): ${r.substring(0,200).replace(/\n/g,`\\n`)}...`),G(` Trying to match pattern in cli.js...`);try{G(` Partial match result: ${e.match(new RegExp(r.substring(0,100)))?`found partial`:`no match`}`)}catch{G(` Partial match failed (regex truncation issue)`)}}}let l=[],u=s-c;return u>0?l.push(`system prompts: \${CHALK_VAR.green('${u} fewer chars')} than original`):u<0&&l.push(`system prompts: \${CHALK_VAR.red('${Math.abs(u)} more chars')} than original`),{newContent:e,items:l}},Et=e=>{let t=e.match(/ensureServerStarted:([$\w]+)\b/);if(!t||t.index===void 0)return console.error(`patch: fixLspSupport: failed to find ensureServerStarted`),null;let n=Math.max(0,t.index-50),r=Math.min(e.length,t.index+50),i=e.slice(n,r),a=i.match(/sendRequest:([$\w]+)[,}]/);if(!a)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([n,r,i])}`),null;let o=a[1],s=Math.max(0,t.index-2e3),c=e.slice(s,t.index),l=RegExp(`async function ${H(o)}\\(([$\\w]+),`,`g`),u,d=null;for(;(u=l.exec(c))!==null;)d=u;if(!d)return console.error(`patch: fixLspSupport: failed to find async function ${o}`),null;let f=d[1],p=s+d.index,m=e.slice(p,t.index).match(/let ([$\w]+)=await [$\w]+\([$\w]+\);/);if(!m||m.index===void 0)return console.error(`patch: fixLspSupport: failed to find second line of sendRequest`),null;let h=m[1],g=p+m.index+m[0].length,_=e.slice(g,t.index),v=RegExp(`if\\(!${H(h)}\\)return;`),y=_.match(v);if(!y||y.index===void 0)return console.error(`patch: fixLspSupport: failed to find if(!serverVar)return; line`),null;let b=g+y.index+y[0].length;return{startIndex:b,endIndex:b,identifiers:[f,h]}},Dt=e=>{let t=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,n=/if\([$\w]+\.startupTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': startupTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,r=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,i=e,a=i;i=i.replace(t,``),i===a?console.warn(`patch: fixLspSupport: restartOnCrash validation not found`):V(a,i,``,0,0);let o=i;i=i.replace(n,``),i===o?console.warn(`patch: fixLspSupport: startupTimeout validation not found`):V(o,i,``,0,0);let s=i;i=i.replace(r,``),i===s?console.warn(`patch: fixLspSupport: shutdownTimeout validation not found`):V(s,i,``,0,0);let c=Et(i);if(!c||!c.identifiers)return null;let[l,u]=c.identifiers,d=`
|
|
182
182
|
const path = await import('path');
|
|
183
183
|
const ext = path.extname(${l}).toLowerCase();
|
|
@@ -342,7 +342,7 @@ ${h} </div>
|
|
|
342
342
|
} else {
|
|
343
343
|
return ${l}(${u});
|
|
344
344
|
}
|
|
345
|
-
}, [${l}, ${i}.toolset])`,m=e.slice(0,a)+p+e.slice(o);return V(e,m,p,a,o),m},Rt=(e,t)=>{let n=Ft(e);if(n===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let r=
|
|
345
|
+
}, [${l}, ${i}.toolset])`,m=e.slice(0,a)+p+e.slice(o);return V(e,m,p,a,o),m},Rt=(e,t)=>{let n=Ft(e);if(n===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let r=wn(e);if(!r)return console.error(`patch: toolsets: failed to find React variable`),null;let i=On(e);if(!i)return console.error(`patch: toolsets: failed to find Box component`),null;let a=Dn(e);if(!a)return console.error(`patch: toolsets: failed to find Text component`),null;let o=At(e);if(!o)return console.error(`patch: toolsets: failed to find Select component`),null;let s=jt(e);if(!s)return console.error(`patch: toolsets: failed to find Divider component`),null;let c=Nt(e);if(!c)return console.error(`patch: toolsets: failed to find app state getter`),null;let l=yn(e);if(!l)return console.error(`patch: toolsets: failed to find chalk variable`),null;let{appStateGetterFunction:u}=c,d=JSON.stringify(t.map(e=>e.name)),f=JSON.stringify(t.map(e=>({label:e.name,value:e.name,description:e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}: ${e.allowedTools.join(`, `)}`}))),p=`const toolsetComp = ({ onExit, input }) => {
|
|
346
346
|
const [state, setState] = ${u}();
|
|
347
347
|
|
|
348
348
|
// Handle command-line argument
|
|
@@ -406,7 +406,7 @@ ${h} </div>
|
|
|
406
406
|
${r}.createElement(${a}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
|
|
407
407
|
)
|
|
408
408
|
);
|
|
409
|
-
};`,m=e.slice(0,n)+p+e.slice(n);return V(e,m,p,n,n),m},zt=e=>{let t=e.match(/\{color:"bashBorder"\},"! for bash mode"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find bash mode pattern`),null;let n=Math.max(0,t.index-500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/function ([$\w]+)\(\{[^}]+\}\)\{/g));if(i.length===0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find function pattern`),null;let a=i[i.length-1];return a.index===void 0?(console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: match has no index`),null):n+a.index+a[0].length},Bt=e=>{let t=zt(e);if(t===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let n=Nt(e);if(!n)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter`),null;let{appStateGetterFunction:r}=n,i=`let[state]=${r}();`,a=e.slice(0,t)+i+e.slice(t);return V(e,a,i,t,t),a},Vt=e=>{let t=e.match(/([$\w]+)\((\w+)\)\.toLowerCase\(\)," on"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to find mode display pattern`),null;let n=t[1],r=t[2],i=t[0],a=`${n}(${r}).toLowerCase()," on [",state.toolset||"undefined","]"`,o=e.replace(i,a);return o===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(V(e,o,a,t.index,t.index+i.length),o)},Ht=e=>{let t=Array.from(e.matchAll(/"\? for shortcuts"/g)).at(-1);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'`),null;let n=t[0],r=`"? for shortcuts [",state.toolset||"undefined","]"`,i=e.replace(n,r);return i===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(V(e,i,r,t.index,t.index+n.length),i)},Ut=e=>{let t=
|
|
409
|
+
};`,m=e.slice(0,n)+p+e.slice(n);return V(e,m,p,n,n),m},zt=e=>{let t=e.match(/\{color:"bashBorder"\},"! for bash mode"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find bash mode pattern`),null;let n=Math.max(0,t.index-500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/function ([$\w]+)\(\{[^}]+\}\)\{/g));if(i.length===0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find function pattern`),null;let a=i[i.length-1];return a.index===void 0?(console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: match has no index`),null):n+a.index+a[0].length},Bt=e=>{let t=zt(e);if(t===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let n=Nt(e);if(!n)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter`),null;let{appStateGetterFunction:r}=n,i=`let[state]=${r}();`,a=e.slice(0,t)+i+e.slice(t);return V(e,a,i,t,t),a},Vt=e=>{let t=e.match(/([$\w]+)\((\w+)\)\.toLowerCase\(\)," on"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to find mode display pattern`),null;let n=t[1],r=t[2],i=t[0],a=`${n}(${r}).toLowerCase()," on [",state.toolset||"undefined","]"`,o=e.replace(i,a);return o===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(V(e,o,a,t.index,t.index+i.length),o)},Ht=e=>{let t=Array.from(e.matchAll(/"\? for shortcuts"/g)).at(-1);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'`),null;let n=t[0],r=`"? for shortcuts [",state.toolset||"undefined","]"`,i=e.replace(n,r);return i===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(V(e,i,r,t.index,t.index+n.length),i)},Ut=e=>{let t=wn(e);return t?kt(e,`, {
|
|
410
410
|
aliases: ["change-tools"],
|
|
411
411
|
type: "local-jsx",
|
|
412
412
|
name: "toolset",
|
|
@@ -420,7 +420,7 @@ ${h} </div>
|
|
|
420
420
|
userFacingName() {
|
|
421
421
|
return "toolset";
|
|
422
422
|
}
|
|
423
|
-
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},Wt=e=>{let t=e.match(/[\w$]+\([\w$]+,function\([\w$]+\)\{[\w$]+\("tengu_ext_at_mentioned",\{\}\);/);return!t||t.index===void 0?(console.error(`patch: findToolChangeComponentScope: failed to find tool change component scope`),null):t.index},Gt=e=>{let t=Wt(e);if(t===null)return null;let n=Nt(e);if(!n)return console.error(`patch: addSetStateFnAccessAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateGetterFunction:r}=n,i=`const [state, setState] = ${r}();`;return e.slice(0,t)+i+e.slice(t)},Kt=e=>{let t=e.match(/let [\w$]+=[\w$]+\([\w$]+,\{type:"setMode",mode:([\w$]+),destination:"session"\}\);/);return!t||t.index===void 0?(console.error(`patch: findModeChange: failed to find mode change location`),null):{index:t.index,modeVar:t[1]}},qt=(e,t,n)=>{let r=Kt(e);if(!r)return null;let{index:i,modeVar:a}=r,o=`if(${a}==="plan"){setState((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}else{setState((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}`;return e.slice(0,i)+o+e.slice(i)},Jt=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=It(r,n),r?(r=Lt(r,t),r?(r=Rt(r,t),r?(r=Ut(r),r?(r=Bt(r),r?(r=Vt(r),r?(r=Ht(r),r||(console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null)):(console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null)):(console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null)):(console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null)):(console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null)):(console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null)):(console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null)},Yt=e=>
|
|
423
|
+
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},Wt=e=>{let t=e.match(/[\w$]+\([\w$]+,function\([\w$]+\)\{[\w$]+\("tengu_ext_at_mentioned",\{\}\);/);return!t||t.index===void 0?(console.error(`patch: findToolChangeComponentScope: failed to find tool change component scope`),null):t.index},Gt=e=>{let t=Wt(e);if(t===null)return null;let n=Nt(e);if(!n)return console.error(`patch: addSetStateFnAccessAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateGetterFunction:r}=n,i=`const [state, setState] = ${r}();`;return e.slice(0,t)+i+e.slice(t)},Kt=e=>{let t=e.match(/let [\w$]+=[\w$]+\([\w$]+,\{type:"setMode",mode:([\w$]+),destination:"session"\}\);/);return!t||t.index===void 0?(console.error(`patch: findModeChange: failed to find mode change location`),null):{index:t.index,modeVar:t[1]}},qt=(e,t,n)=>{let r=Kt(e);if(!r)return null;let{index:i,modeVar:a}=r,o=`if(${a}==="plan"){setState((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}else{setState((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}`;return e.slice(0,i)+o+e.slice(i)},Jt=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=It(r,n),r?(r=Lt(r,t),r?(r=Rt(r,t),r?(r=Ut(r),r?(r=Bt(r),r?(r=Vt(r),r?(r=Ht(r),r||(console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null)):(console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null)):(console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null)):(console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null)):(console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null)):(console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null)):(console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null)},Yt=e=>wn(e)?kt(e,`, {
|
|
424
424
|
type: "local",
|
|
425
425
|
name: "title",
|
|
426
426
|
description: "Set the conversation title",
|
|
@@ -439,7 +439,7 @@ ${h} </div>
|
|
|
439
439
|
userFacingName() {
|
|
440
440
|
return "title";
|
|
441
441
|
},
|
|
442
|
-
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),Xt=e=>{let t=e.match(/class ([$\w]+)\{summaries;(?:customTitles;)?messages;(?:checkpoints;)?fileHistorySnapshots;/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findCustomNamingFunctionsLocation: failed to find class pattern`),null):t.index},Zt=e=>{let t=Xt(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=
|
|
442
|
+
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),Xt=e=>{let t=e.match(/class ([$\w]+)\{summaries;(?:customTitles;)?messages;(?:checkpoints;)?fileHistorySnapshots;/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findCustomNamingFunctionsLocation: failed to find class pattern`),null):t.index},Zt=e=>{let t=Xt(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=En(e),r=`
|
|
443
443
|
function getTweakccBaseDir() {
|
|
444
444
|
const { join: pathJoin } = ${n}('path');
|
|
445
445
|
const { homedir: osHomedir } = ${n}('os');
|
|
@@ -613,11 +613,11 @@ function onNewMessage(projectDir, projectSlug, msg) {
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
`,i=e.slice(0,t)+r+e.slice(t);return V(e,i,r,t,t),i},Qt=e=>{let t=e.match(/(if\(![$\w]+\.has\(([$\w]+)\.uuid\)\)\{)if\([$\w]+\.appendFileSync\(/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findAppendEntryInterceptorLocation: failed to find pattern`),null):{location:t.index+t[1].length,messageVar:t[2]}},$t=e=>{let t=Qt(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=
|
|
616
|
+
`,i=e.slice(0,t)+r+e.slice(t);return V(e,i,r,t,t),i},Qt=e=>{let t=e.match(/(if\(![$\w]+\.has\(([$\w]+)\.uuid\)\)\{)if\([$\w]+\.appendFileSync\(/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findAppendEntryInterceptorLocation: failed to find pattern`),null):{location:t.index+t[1].length,messageVar:t[2]}},$t=e=>{let t=Qt(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=En(e),{location:r,messageVar:i}=t,a=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
|
|
617
617
|
const projectDir = pathDirname(this.sessionFile);
|
|
618
618
|
const projectSlug = pathBasename(projectDir);
|
|
619
619
|
onNewMessage(projectDir, projectSlug, ${i});
|
|
620
|
-
`,o=e.slice(0,r)+a+e.slice(r);return V(e,o,a,r,r),o},en=e=>{let t=e.match(/if\([$\w]+\.has\(([$\w]+)\.uuid\)\)continue;/);if(!t||t.index===void 0)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find continue pattern`),null;let n=t[1],r=t.index+t[0].length-10,i=Math.max(0,t.index-200),a=e.substring(i,t.index).match(/for\(let [$\w]+ of ([$\w]+)\)try/);if(!a)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find loop pattern`),null;let o=a[1];return{orLocation:r,loopLocation:i+(a.index??0),messageVar:n,fileListVar:o}},tn=e=>{let t=en(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=
|
|
620
|
+
`,o=e.slice(0,r)+a+e.slice(r);return V(e,o,a,r,r),o},en=e=>{let t=e.match(/if\([$\w]+\.has\(([$\w]+)\.uuid\)\)continue;/);if(!t||t.index===void 0)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find continue pattern`),null;let n=t[1],r=t.index+t[0].length-10,i=Math.max(0,t.index-200),a=e.substring(i,t.index).match(/for\(let [$\w]+ of ([$\w]+)\)try/);if(!a)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find loop pattern`),null;let o=a[1];return{orLocation:r,loopLocation:i+(a.index??0),messageVar:n,fileListVar:o}},tn=e=>{let t=en(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=En(e),{orLocation:r,loopLocation:i,messageVar:a,fileListVar:o}=t,s=e,c=`const { readFileSync: fsReadFileSync } = ${n}('fs');
|
|
621
621
|
const tweakccSummaries = new Set();
|
|
622
622
|
for (const file of ${o}) {
|
|
623
623
|
const contents = fsReadFileSync(file, "utf8").trim();
|
|
@@ -632,40 +632,40 @@ for (const file of ${o}) {
|
|
|
632
632
|
if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
|
|
633
633
|
tweakccSummaries.add(obj.leafUuid);
|
|
634
634
|
}
|
|
635
|
-
`;s=s.slice(0,i)+c+s.slice(i),V(e,s,c,i,i);let l=r+c.length,u=`||tweakccSummaries.has(${a}.uuid)`,d=s.slice(0,l)+u+s.slice(l);return V(s,d,u,l,l),d},nn=e=>{let t=e.match(/description:"Rename the current conversation",isEnabled:\(\)=>!1,/);if(!t)return console.error(`patch: conversationTitle: enableRenameConversationCommand: failed to find pattern`),null;if(t.index===void 0)return console.error(`patch: conversationTitle: enableRenameConversationCommand: match.index is undefined`),null;let n=`description:"Rename the current conversation",isEnabled:()=>!0,`,r=e.replace(`description:"Rename the current conversation",isEnabled:()=>!1,`,n);return r===e?(console.error(`patch: conversationTitle: enableRenameConversationCommand: replacement failed`),null):(V(e,r,n,t.index,t.index+63),r)},rn=e=>{let t=e;if(t=Yt(t),!t)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(t=Zt(t),!t)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(t=$t(t),!t)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(t=tn(t),!t)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let n=nn(t);return n?t=n:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),t},an=e=>{let t=e.match(/,[$\w]+\.createElement\([$\w]+,\{isBeforeFirstMessage:!1\}\),/);return!t||t.index===void 0?(console.error(`patch: hideStartupBanner: failed to find startup banner createElement`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},on=e=>{let t=an(e);if(!t)return null;let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return V(e,n,`,`,t.startIndex,t.endIndex),n},sn=e=>{let t=e.match(/ctrl-g to edit prompt in /);if(!t||t.index===void 0)return console.error(`patch: hideCtrlGToEditPrompt: failed to find "ctrl-g to edit prompt in "`),null;let n=Math.max(0,t.index-150),r=e.slice(n,t.index),i=/:[$\w]+&&([$\w]+)\.createElement/g,a=null,o;for(;(o=i.exec(r))!==null;)a=o;if(!a)return console.error(`patch: hideCtrlGToEditPrompt: failed to find createElement pattern before ctrl-g text`),null;let s=a[1],c=n+a.index;return{startIndex:c,endIndex:c+(a[0].length-`${s}.createElement`.length),identifiers:[s]}},cn=e=>{let t=sn(e);if(!t)return null;if(!t.identifiers?.[0])return console.error(`patch: hideCtrlGToEditPrompt: reactVar not captured`),null;let n=`:false&&`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},ln=e=>{let t=[],n=0;for(;;){let r=e.indexOf(`▛███▜`,n);if(r===-1)break;let i=Math.max(0,r-2e3),a=e.slice(i,r),o=/function [$\w]+\(\)\{/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(s){let e=i+s.index+s[0].length;t.push(e)}else console.error(`patch: hideStartupClawd: failed to find function pattern before Clawd at position ${r}`);n=r+5}return t},un=e=>{let t=ln(e);if(t.length===0)return console.error(`patch: hideStartupClawd: no Clawd components found`),null;let n=[...t].sort((e,t)=>t-e),r=`return null;`,i=e;for(let e of n)i=i.slice(0,e)+r+i.slice(e);if(n.length>0){let t=n[n.length-1];V(e,i,r,t,t)}return i},dn=e=>{let t=e.match(/=25000,([\s\S]{0,100})<system-reminder>/);if(!t||t.index===void 0)return console.error(`patch: increaseFileReadLimit: failed to find 25000 token limit near system-reminder`),null;let n=t.index+1;return{startIndex:n,endIndex:n+5}},fn=e=>{let t=dn(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},pn=async e=>{if(!e.cliPath){W(`backupClijs: Skipping for native installation (no cliPath)`);return}await
|
|
635
|
+
`;s=s.slice(0,i)+c+s.slice(i),V(e,s,c,i,i);let l=r+c.length,u=`||tweakccSummaries.has(${a}.uuid)`,d=s.slice(0,l)+u+s.slice(l);return V(s,d,u,l,l),d},nn=e=>{let t=e.match(/description:"Rename the current conversation",isEnabled:\(\)=>!1,/);if(!t)return console.error(`patch: conversationTitle: enableRenameConversationCommand: failed to find pattern`),null;if(t.index===void 0)return console.error(`patch: conversationTitle: enableRenameConversationCommand: match.index is undefined`),null;let n=`description:"Rename the current conversation",isEnabled:()=>!0,`,r=e.replace(`description:"Rename the current conversation",isEnabled:()=>!1,`,n);return r===e?(console.error(`patch: conversationTitle: enableRenameConversationCommand: replacement failed`),null):(V(e,r,n,t.index,t.index+63),r)},rn=e=>{let t=e;if(t=Yt(t),!t)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(t=Zt(t),!t)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(t=$t(t),!t)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(t=tn(t),!t)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let n=nn(t);return n?t=n:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),t},an=e=>{let t=e.match(/,[$\w]+\.createElement\([$\w]+,\{isBeforeFirstMessage:!1\}\),/);return!t||t.index===void 0?(console.error(`patch: hideStartupBanner: failed to find startup banner createElement`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},on=e=>{let t=an(e);if(!t)return null;let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return V(e,n,`,`,t.startIndex,t.endIndex),n},sn=e=>{let t=e.match(/ctrl-g to edit prompt in /);if(!t||t.index===void 0)return console.error(`patch: hideCtrlGToEditPrompt: failed to find "ctrl-g to edit prompt in "`),null;let n=Math.max(0,t.index-150),r=e.slice(n,t.index),i=/:[$\w]+&&([$\w]+)\.createElement/g,a=null,o;for(;(o=i.exec(r))!==null;)a=o;if(!a)return console.error(`patch: hideCtrlGToEditPrompt: failed to find createElement pattern before ctrl-g text`),null;let s=a[1],c=n+a.index;return{startIndex:c,endIndex:c+(a[0].length-`${s}.createElement`.length),identifiers:[s]}},cn=e=>{let t=sn(e);if(!t)return null;if(!t.identifiers?.[0])return console.error(`patch: hideCtrlGToEditPrompt: reactVar not captured`),null;let n=`:false&&`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},ln=e=>{let t=[],n=0;for(;;){let r=e.indexOf(`▛███▜`,n);if(r===-1)break;let i=Math.max(0,r-2e3),a=e.slice(i,r),o=/function [$\w]+\(\)\{/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(s){let e=i+s.index+s[0].length;t.push(e)}else console.error(`patch: hideStartupClawd: failed to find function pattern before Clawd at position ${r}`);n=r+5}return t},un=e=>{let t=ln(e);if(t.length===0)return console.error(`patch: hideStartupClawd: no Clawd components found`),null;let n=[...t].sort((e,t)=>t-e),r=`return null;`,i=e;for(let e of n)i=i.slice(0,e)+r+i.slice(e);if(n.length>0){let t=n[n.length-1];V(e,i,r,t,t)}return i},dn=e=>{let t=e.match(/=25000,([\s\S]{0,100})<system-reminder>/);if(!t||t.index===void 0)return console.error(`patch: increaseFileReadLimit: failed to find 25000 token limit near system-reminder`),null;let n=t.index+1;return{startIndex:n,endIndex:n+5}},fn=e=>{let t=dn(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},pn=e=>{let t=e.match(/if\(([$\w]+)\.length>=\d+\)return`\$\{\1\}→\$\{([$\w]+)\}`;return`\$\{\1\.padStart\(\d+," "\)\}→\$\{\2\}`/);return!t||t.index===void 0?(console.error(`patch: suppressLineNumbers: failed to find line number formatter pattern`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2]]}},mn=e=>{let t=pn(e);if(!t)return null;let n=t.identifiers?.[1];if(!n)return console.error(`patch: suppressLineNumbers: content variable not captured`),null;let r=`return ${n}`,i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return V(e,i,r,t.startIndex,t.endIndex),i},hn=async e=>{if(!e.cliPath){W(`backupClijs: Skipping for native installation (no cliPath)`);return}await rr(),W(`Backing up cli.js to ${$n}`),await b.copyFile(e.cliPath,$n),await or(t=>{t.changesApplied=!1,t.ccVersion=e.version})},gn=async e=>{e.nativeInstallationPath&&(await rr(),W(`Backing up native binary to ${Y}`),await b.copyFile(e.nativeInstallationPath,Y),await or(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},_n=async e=>{if(!e.cliPath)return W(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;W(`Restoring cli.js from backup to ${e.cliPath}`);let t=await b.readFile($n);return await qn(e.cliPath,t,`restore`),await Ye(),await or(e=>{e.changesApplied=!1}),!0},vn=async e=>{if(!e.nativeInstallationPath)return W(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await Jn(Y))return W(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;W(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await b.readFile(Y);return await qn(e.nativeInstallationPath,t,`restore`),!0},V=(e,t,n,r,i)=>{if(!In())return;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);l!==f&&(G(`
|
|
636
636
|
--- Diff ---`),G(`OLD:`,c+`\x1b[31m${l}\x1b[0m`+u),G(`NEW:`,d+`\x1b[32m${f}\x1b[0m`+p),G(`--- End Diff ---
|
|
637
|
-
`))},H=e=>e.replace(/\$/g,`\\$`),_n=e=>{let t=Array.from(e.matchAll(/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},vn=e=>{let t=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(!t){console.log(`patch: getModuleLoaderFunction: failed to find module loader function`);return}return t[1]},yn=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},bn=e=>{let t=yn(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${H(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let U=null,xn=null;const Sn=e=>{if(U!=null)return U;let t=vn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),U=void 0;return}let n=yn(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),U=void 0;return}let r=RegExp(`\\b([$\\w]+)=${H(t)}\\(${H(n)}\\(\\),1\\)`),i=e.match(r);if(i)return U=i[1],U;let a=bn(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),U=void 0;return}let o=RegExp(`\\b([$\\w]+)=${H(t)}\\(${H(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),U=void 0;return}return U=s[1],U},Cn=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${H(n)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${n})`);return}return i[1]},wn=e=>{if(xn!=null)return xn;let t=Cn(e);return t?(xn=t,xn):(xn=`require`,xn)},Tn=e=>{let t=e.match(/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},En=e=>{let t=e.match(/\b([$\w]+)\.displayName="Box"/);if(!t){console.error(`patch: findBoxComponent: failed to find Box displayName`);return}let n=t[1],r=RegExp(`\\b([$\\w]+)=${H(n)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${n})`);return}return i[1]},Dn=async(e,t)=>{let n;if(t.nativeInstallationPath){await gn(t);let e=!1;try{await y.stat(Y),e=!0}catch{}let r=e?Y:t.nativeInstallationPath;W(`Extracting claude.js from ${e?`backup`:`native installation`}: ${r}`);let i=await re(r);if(!i)throw Error(`Failed to extract claude.js from native installation`);let a=C.join(q,`native-claudejs-orig.js`);x.writeFileSync(a,i),W(`Saved original extracted JS from native to: ${a}`),n=i.toString(`utf8`)}else{if(await hn(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);n=await y.readFile(t.cliPath,{encoding:`utf8`})}let r=[],i=await Tt(n,t.version);n=i.newContent,r.push(...i.items);let a=null;e.settings.themes&&e.settings.themes.length>0&&(a=z(n,e.settings.themes))&&(n=a),e.settings.thinkingVerbs&&((a=we(n,e.settings.thinkingVerbs.verbs))&&(n=a),(a=B(n,e.settings.thinkingVerbs.format))&&(n=a)),(a=_e(n,e.settings.thinkingStyle.phases))&&(n=a),(a=ye(n,e.settings.thinkingStyle.updateInterval))&&(n=a),(a=xe(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=a),(a=he(n,e.settings.thinkingStyle.reverseMirror))&&(n=a),e.settings.userMessageDisplay&&(a=Ee(n,e.settings.userMessageDisplay.format,e.settings.userMessageDisplay.foregroundColor,e.settings.userMessageDisplay.backgroundColor,e.settings.userMessageDisplay.styling.includes(`bold`),e.settings.userMessageDisplay.styling.includes(`italic`),e.settings.userMessageDisplay.styling.includes(`underline`),e.settings.userMessageDisplay.styling.includes(`strikethrough`),e.settings.userMessageDisplay.styling.includes(`inverse`),e.settings.userMessageDisplay.borderStyle,e.settings.userMessageDisplay.borderColor,e.settings.userMessageDisplay.paddingX,e.settings.userMessageDisplay.paddingY,e.settings.userMessageDisplay.fitBoxToContent))&&(n=a),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`&&(a=ue(n,e.settings.inputBox.removeBorder))&&(n=a),(a=Oe(n))&&(n=a),(a=fe(n))&&(n=a),(a=ce(n))&&(n=a),(a=An(n))&&(n=a),(a=oe(n,25))&&(n=a),(a=Ae(n))&&(n=a);let o=e.settings.misc?.showTweakccVersion??!0,s=e.settings.misc?.showPatchesApplied??!0;(a=Ie(n,`3.2.3`,r,o,s))&&(n=a),(a=Dt(n))&&(n=a),e.settings.toolsets&&e.settings.toolsets.length>0&&(a=Jt(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=a),e.settings.planModeToolset&&e.settings.defaultToolset&&((a=Gt(n))&&(n=a),(a=qt(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=a));let c=e.settings.misc?.enableConversationTitle??!0,l=t.version&&et(t.version,`2.0.64`)<0;if(c&&l&&(a=rn(n))&&(n=a),e.settings.misc?.hideStartupBanner&&(a=on(n))&&(n=a),e.settings.misc?.hideCtrlGToEditPrompt&&(a=cn(n))&&(n=a),e.settings.misc?.hideStartupClawd&&(a=un(n))&&(n=a),e.settings.misc?.increaseFileReadLimit&&(a=fn(n))&&(n=a),t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=C.join(q,`native-claudejs-patched.js`);x.writeFileSync(e,n,`utf8`),W(`Saved patched JS from native to: ${e}`);let r=Buffer.from(n,`utf8`);await ie(t.nativeInstallationPath,r,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await Gn(t.cliPath,n,`patch`)}return await ir(e=>{e.changesApplied=!0})},On=[{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],kn=e=>{let t=e.match(/\b([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-600),i=e.slice(r,t.index),a=RegExp(`function [$\\w]+\\(\\)\\{let ${H(n)}=.+?;`,`g`),o=null,s;for(;(s=a.exec(i))!==null;)o=s;return o?{insertionIndex:r+o.index+o[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${n}`),null)},An=e=>{let t=kn(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=On.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return V(e,a,i,n,n),a};let jn=!1,Mn=!1;const Nn=()=>jn,Pn=()=>Mn,Fn=()=>{jn=!0},In=()=>{Mn=!0,jn=!0},W=(e,...t)=>{Nn()&&console.log(e,...t)},G=(e,...t)=>{Pn()&&console.log(e,...t)};function Ln(){try{let e=E.join(O.homedir(),`.claude.json`);return JSON.parse(T.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Rn(){try{let e=E.join(O.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(T.readFileSync(e,`utf8`))?.claudeAiOauth?.subscriptionType||`unknown`){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`}}catch{}return`Claude API`}function zn(){try{let e=E.join(O.homedir(),`.claude`,`settings.json`),t=JSON.parse(T.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=On.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Bn(e){process.platform===`win32`?k.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?k.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():k.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function Vn(e){if(process.platform===`win32`)k.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)k.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=E.dirname(e);k.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function Hn(e){if(!e||typeof e!=`string`)return!1;let t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){let e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=255&&parseInt(n)<=255&&parseInt(r)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=360&&parseInt(n)<=100&&parseInt(r)<=100}}return!1}function Un(e){if(!Hn(e))return e;let t=e.trim();if(t.startsWith(`rgb(`))return t;if(t.startsWith(`#`)){let e=t.slice(1);return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgb(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)})`}if(t.startsWith(`hsl(`)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let t=parseInt(e[1])/360,n=parseInt(e[2])/100,r=parseInt(e[3])/100,i=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=r<.5?r*(1+n):r+n-r*n,o=2*r-a;return`rgb(${Math.round(i(o,a,t+1/3)*255)},${Math.round(i(o,a,t)*255)},${Math.round(i(o,a,t-1/3)*255)})`}}return e}async function Wn(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=A.createHash(t),o=T.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function Gn(e,t,n=`replace`){let r=493;try{r=(await b.stat(e)).mode,W(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){W(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await b.unlink(e),W(`[${n}] Unlinked ${e} to break hard links`)}catch(t){W(`[${n}] Could not unlink ${e}: ${t}`)}await b.writeFile(e,t),await b.chmod(e,r),W(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function Kn(e){try{return await b.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const qn=e=>e.startsWith(`~`)?E.join(O.homedir(),e.slice(1)):e,Jn=(e,t)=>{let n=e=>{let t=e.split(`.`).map(Number);return[t[0]||0,t[1]||0,t[2]||0]},r=n(e),i=n(t);return r[0]===i[0]?r[1]===i[1]?r[2]-i[2]:r[1]-i[1]:r[0]-i[0]},Yn=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)};async function Xn(){try{let e=await b.readFile(J,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=w.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await tr(),await b.writeFile(J,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const K={themes:[{name:`Dark mode`,id:`dark`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(253,93,177)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(235,159,127)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(147,165,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(177,195,255)`,permission:`rgb(177,185,249)`,permissionShimmer:`rgb(207,215,255)`,planMode:`rgb(72,150,140)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(177,185,249)`,remember:`rgb(177,185,249)`,background:`rgb(0,204,204)`,success:`rgb(78,186,101)`,error:`rgb(255,107,128)`,warning:`rgb(255,193,7)`,warningShimmer:`rgb(255,223,57)`,diffAdded:`rgb(34,92,43)`,diffRemoved:`rgb(122,41,54)`,diffAddedDimmed:`rgb(71,88,74)`,diffRemovedDimmed:`rgb(105,72,77)`,diffAddedWord:`rgb(56,166,96)`,diffRemovedWord:`rgb(179,89,107)`,diffAddedWordDimmed:`rgb(46,107,58)`,diffRemovedWordDimmed:`rgb(139,57,69)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(177,185,249)`,rate_limit_empty:`rgb(80,83,112)`}},{name:`Light mode`,id:`light`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(255,0,135)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(245,149,117)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(87,105,247)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(117,135,255)`,permission:`rgb(87,105,247)`,permissionShimmer:`rgb(137,155,255)`,planMode:`rgb(0,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(87,105,247)`,remember:`rgb(0,0,255)`,background:`rgb(0,153,153)`,success:`rgb(44,122,57)`,error:`rgb(171,43,63)`,warning:`rgb(150,108,30)`,warningShimmer:`rgb(200,158,80)`,diffAdded:`rgb(105,219,124)`,diffRemoved:`rgb(255,168,180)`,diffAddedDimmed:`rgb(199,225,203)`,diffRemovedDimmed:`rgb(253,210,216)`,diffAddedWord:`rgb(47,157,68)`,diffRemovedWord:`rgb(209,69,75)`,diffAddedWordDimmed:`rgb(144,194,156)`,diffRemovedWordDimmed:`rgb(232,165,173)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(240, 240, 240)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(87,105,247)`,rate_limit_empty:`rgb(39,47,111)`}},{name:`Light mode (ANSI colors only)`,id:`light-ansi`,colors:{autoAccept:`ansi:magenta`,bashBorder:`ansi:magenta`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blue`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blue`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyan`,ide:`ansi:blueBright`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:black`,inverseText:`ansi:white`,inactive:`ansi:blackBright`,subtle:`ansi:blackBright`,suggestion:`ansi:blue`,remember:`ansi:blue`,background:`ansi:cyan`,success:`ansi:green`,error:`ansi:red`,warning:`ansi:yellow`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:red`,blue_FOR_SUBAGENTS_ONLY:`ansi:blue`,green_FOR_SUBAGENTS_ONLY:`ansi:green`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellow`,purple_FOR_SUBAGENTS_ONLY:`ansi:magenta`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyan`,professionalBlue:`ansi:blueBright`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:white`,bashMessageBackgroundColor:`ansi:whiteBright`,memoryBackgroundColor:`ansi:white`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:black`}},{name:`Dark mode (ANSI colors only)`,id:`dark-ansi`,colors:{autoAccept:`ansi:magentaBright`,bashBorder:`ansi:magentaBright`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blueBright`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blueBright`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyanBright`,ide:`ansi:blue`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:whiteBright`,inverseText:`ansi:black`,inactive:`ansi:white`,subtle:`ansi:white`,suggestion:`ansi:blueBright`,remember:`ansi:blueBright`,background:`ansi:cyanBright`,success:`ansi:greenBright`,error:`ansi:redBright`,warning:`ansi:yellowBright`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:redBright`,blue_FOR_SUBAGENTS_ONLY:`ansi:blueBright`,green_FOR_SUBAGENTS_ONLY:`ansi:greenBright`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellowBright`,purple_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyanBright`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:blackBright`,bashMessageBackgroundColor:`ansi:black`,memoryBackgroundColor:`ansi:blackBright`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:white`}},{name:`Light mode (colorblind-friendly)`,id:`light-daltonized`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(0,102,204)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(51,102,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(101,152,255)`,permission:`rgb(51,102,255)`,permissionShimmer:`rgb(101,152,255)`,planMode:`rgb(51,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(51,102,255)`,remember:`rgb(51,102,255)`,background:`rgb(0,153,153)`,success:`rgb(0,102,153)`,error:`rgb(204,0,0)`,warning:`rgb(255,153,0)`,warningShimmer:`rgb(255,183,50)`,diffAdded:`rgb(153,204,255)`,diffRemoved:`rgb(255,204,204)`,diffAddedDimmed:`rgb(209,231,253)`,diffRemovedDimmed:`rgb(255,233,233)`,diffAddedWord:`rgb(51,102,204)`,diffRemovedWord:`rgb(153,51,51)`,diffAddedWordDimmed:`rgb(102,153,204)`,diffRemovedWordDimmed:`rgb(204,153,153)`,red_FOR_SUBAGENTS_ONLY:`rgb(204,0,0)`,blue_FOR_SUBAGENTS_ONLY:`rgb(0,102,204)`,green_FOR_SUBAGENTS_ONLY:`rgb(0,204,0)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,204,0)`,purple_FOR_SUBAGENTS_ONLY:`rgb(128,0,128)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,128,0)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,102,178)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(0,178,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(220, 220, 220)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(51,102,255)`,rate_limit_empty:`rgb(23,46,114)`}},{name:`Dark mode (colorblind-friendly)`,id:`dark-daltonized`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(51,153,255)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(153,204,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(183,224,255)`,permission:`rgb(153,204,255)`,permissionShimmer:`rgb(183,224,255)`,planMode:`rgb(102,153,153)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(153,204,255)`,remember:`rgb(153,204,255)`,background:`rgb(0,204,204)`,success:`rgb(51,153,255)`,error:`rgb(255,102,102)`,warning:`rgb(255,204,0)`,warningShimmer:`rgb(255,234,50)`,diffAdded:`rgb(0,68,102)`,diffRemoved:`rgb(102,0,0)`,diffAddedDimmed:`rgb(62,81,91)`,diffRemovedDimmed:`rgb(62,44,44)`,diffAddedWord:`rgb(0,119,179)`,diffRemovedWord:`rgb(179,0,0)`,diffAddedWordDimmed:`rgb(26,99,128)`,diffRemovedWordDimmed:`rgb(128,21,21)`,red_FOR_SUBAGENTS_ONLY:`rgb(255,102,102)`,blue_FOR_SUBAGENTS_ONLY:`rgb(102,178,255)`,green_FOR_SUBAGENTS_ONLY:`rgb(102,255,102)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,255,102)`,purple_FOR_SUBAGENTS_ONLY:`rgb(178,102,255)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,178,102)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,153,204)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(102,204,204)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(153,204,255)`,rate_limit_empty:`rgb(69,92,115)`}},{name:`Monochrome`,id:`monochrome`,colors:{autoAccept:`rgb(200,200,200)`,bashBorder:`rgb(180,180,180)`,claude:`rgb(255,255,255)`,claudeShimmer:`rgb(230,230,230)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(200,200,200)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(220,220,220)`,permission:`rgb(200,200,200)`,permissionShimmer:`rgb(220,220,220)`,planMode:`rgb(180,180,180)`,ide:`rgb(190,190,190)`,promptBorder:`rgb(160,160,160)`,promptBorderShimmer:`rgb(180,180,180)`,text:`rgb(255,255,255)`,inverseText:`rgb(40,40,40)`,inactive:`rgb(120,120,120)`,subtle:`rgb(100,100,100)`,suggestion:`rgb(200,200,200)`,remember:`rgb(200,200,200)`,background:`rgb(180,180,180)`,success:`rgb(220,220,220)`,error:`rgb(180,180,180)`,warning:`rgb(200,200,200)`,warningShimmer:`rgb(220,220,220)`,diffAdded:`rgb(90,90,90)`,diffRemoved:`rgb(60,60,60)`,diffAddedDimmed:`rgb(110,110,110)`,diffRemovedDimmed:`rgb(80,80,80)`,diffAddedWord:`rgb(200,200,200)`,diffRemovedWord:`rgb(80,80,80)`,diffAddedWordDimmed:`rgb(160,160,160)`,diffRemovedWordDimmed:`rgb(70,70,70)`,red_FOR_SUBAGENTS_ONLY:`rgb(200,200,200)`,blue_FOR_SUBAGENTS_ONLY:`rgb(180,180,180)`,green_FOR_SUBAGENTS_ONLY:`rgb(210,210,210)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(190,190,190)`,purple_FOR_SUBAGENTS_ONLY:`rgb(170,170,170)`,orange_FOR_SUBAGENTS_ONLY:`rgb(195,195,195)`,pink_FOR_SUBAGENTS_ONLY:`rgb(205,205,205)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(185,185,185)`,professionalBlue:`rgb(190,190,190)`,rainbow_red:`rgb(240,240,240)`,rainbow_orange:`rgb(230,230,230)`,rainbow_yellow:`rgb(220,220,220)`,rainbow_green:`rgb(210,210,210)`,rainbow_blue:`rgb(200,200,200)`,rainbow_indigo:`rgb(190,190,190)`,rainbow_violet:`rgb(180,180,180)`,rainbow_red_shimmer:`rgb(255,255,255)`,rainbow_orange_shimmer:`rgb(245,245,245)`,rainbow_yellow_shimmer:`rgb(235,235,235)`,rainbow_green_shimmer:`rgb(225,225,225)`,rainbow_blue_shimmer:`rgb(215,215,215)`,rainbow_indigo_shimmer:`rgb(205,205,205)`,rainbow_violet_shimmer:`rgb(195,195,195)`,clawd_body:`rgb(255,255,255)`,clawd_background:`rgb(40,40,40)`,userMessageBackground:`rgb(70,70,70)`,bashMessageBackgroundColor:`rgb(65,65,65)`,memoryBackgroundColor:`rgb(75,75,75)`,rate_limit_fill:`rgb(200,200,200)`,rate_limit_empty:`rgb(90,90,90)`}}],thinkingVerbs:{format:`{}… `,verbs:`Accomplishing.Actioning.Actualizing.Baking.Booping.Brewing.Calculating.Cerebrating.Channelling.Churning.Clauding.Coalescing.Cogitating.Combobulating.Computing.Concocting.Conjuring.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Deciphering.Deliberating.Determining.Discombobulating.Divining.Doing.Effecting.Elucidating.Enchanting.Envisioning.Finagling.Flibbertigibbeting.Forging.Forming.Frolicking.Generating.Germinating.Hatching.Herding.Honking.Ideating.Imagining.Incubating.Inferring.Manifesting.Marinating.Meandering.Moseying.Mulling.Musing.Mustering.Noodling.Percolating.Perusing.Philosophising.Pondering.Pontificating.Processing.Puttering.Puzzling.Reticulating.Ruminating.Scheming.Schlepping.Shimmying.Simmering.Smooshing.Spelunking.Spinning.Stewing.Sussing.Synthesizing.Thinking.Tinkering.Transmuting.Unfurling.Unravelling.Vibing.Wandering.Whirring.Wibbling.Wizarding.Working.Wrangling.Alchemizing.Animating.Architecting.Bamboozling.Beaming.Befuddling.Bewitching.Billowing.Bippity-bopping.Blanching.Boogieing.Boondoggling.Bootstrapping.Burrowing.Caching.Canoodling.Caramelizing.Cascading.Catapulting.Channeling.Choreographing.Compiling.Composing.Crystallizing.Cultivating.Deploying.Dilly-dallying.Discombobulating.Distilling.Doodling.Drizzling.Ebbing.Embellishing.Ensorcelling.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flowing.Flummoxing.Fluttering.Frosting.Gallivanting.Galloping.Garnishing.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hexing.Hibernating.Higgledy-piggleding.Hornswoggling.Hullaballooing.Hyperspacing.Illustrating.Improvising.Incanting.Indexing.Infusing.Ionizing.Jazzercising.Jiggery-pokerying.Jitterbugging.Julienning.Kerfuffling.Kneading.Leavening.Levitating.Linting.Lollygagging.Malarkeying.Metamorphosing.Migrating.Minifying.Misting.Moonwalking.Mystifying.Nebulizing.Nesting.Nucleating.Optimizing.Orbiting.Orchestrating.Osmosing.Parsing.Perambulating.Photosynthesizing.Pipelining.Poaching.Pollinating.Pouncing.Precipitating.Prestidigitating.Proofing.Propagating.Prowling.Quantumizing.Querying.Razzle-dazzling.Razzmatazzing.Recombobulating.Reducing.Refactoring.Rippling.Roosting.Sautéing.Scampering.Scurrying.Seasoning.Serializing.Shenaniganing.Skedaddling.Sketching.Skullduggering.Slithering.Sock-hopping.Spellbinding.Sprouting.Storyboarding.Sublimating.Swirling.Swooping.Symbioting.Syncopating.Teleporting.Tempering.Thaumaturging.Thundering.Tomfoolering.Topsy-turvying.Transfiguring.Transpiling.Twisting.Undulating.Validating.Vaporizing.Waddling.Warping.Whatchamacalliting.Whirlpooling.Whisking.Willy-nillying.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEditPrompt:!1,hideStartupClawd:!1,increaseFileReadLimit:!1},toolsets:[],defaultToolset:null,planModeToolset:null},q=(()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return qn(e);let t=w.join(g.homedir(),`.tweakcc`),n=w.join(g.homedir(),`.claude`,`tweakcc`),r=process.env.XDG_CONFIG_HOME;try{if(S.existsSync(t))return t}catch(e){W(`Failed to check if ${t} exists: ${e}`)}try{if(S.existsSync(n))return n}catch(e){W(`Failed to check if ${n} exists: ${e}`)}return r?w.join(r,`tweakcc`):t})(),J=w.join(q,`config.json`),Zn=w.join(q,`cli.js.backup`),Y=w.join(q,`native-binary.backup`),Qn=w.join(q,`system-prompts`),$n=w.join(q,`prompt-data-cache`),er=()=>{let e=q,t=g.homedir(),n=[w.join(t,`.tweakcc`),w.join(t,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?w.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return S.existsSync(t)&&t!==e}catch{return!1}});n.length>0&&(console.warn(a.yellow(`
|
|
637
|
+
`))},H=e=>e.replace(/\$/g,`\\$`),yn=e=>{let t=Array.from(e.matchAll(/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},bn=e=>{let t=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(!t){console.log(`patch: getModuleLoaderFunction: failed to find module loader function`);return}return t[1]},xn=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},Sn=e=>{let t=xn(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${H(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let U=null,Cn=null;const wn=e=>{if(U!=null)return U;let t=bn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),U=void 0;return}let n=xn(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),U=void 0;return}let r=RegExp(`\\b([$\\w]+)=${H(t)}\\(${H(n)}\\(\\),1\\)`),i=e.match(r);if(i)return U=i[1],U;let a=Sn(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),U=void 0;return}let o=RegExp(`\\b([$\\w]+)=${H(t)}\\(${H(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),U=void 0;return}return U=s[1],U},Tn=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${H(n)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${n})`);return}return i[1]},En=e=>{if(Cn!=null)return Cn;let t=Tn(e);return t?(Cn=t,Cn):(Cn=`require`,Cn)},Dn=e=>{let t=e.match(/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},On=e=>{let t=e.match(/\b([$\w]+)\.displayName="Box"/);if(!t){console.error(`patch: findBoxComponent: failed to find Box displayName`);return}let n=t[1],r=RegExp(`\\b([$\\w]+)=${H(n)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${n})`);return}return i[1]},kn=async(e,t)=>{let n;if(t.nativeInstallationPath){await vn(t);let e=!1;try{await y.stat(Y),e=!0}catch{}let r=e?Y:t.nativeInstallationPath;W(`Extracting claude.js from ${e?`backup`:`native installation`}: ${r}`);let i=await re(r);if(!i)throw Error(`Failed to extract claude.js from native installation`);let a=C.join(q,`native-claudejs-orig.js`);x.writeFileSync(a,i),W(`Saved original extracted JS from native to: ${a}`),n=i.toString(`utf8`)}else{if(await _n(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);n=await y.readFile(t.cliPath,{encoding:`utf8`})}let r=[],i=await Tt(n,t.version);n=i.newContent,r.push(...i.items);let a=null;e.settings.themes&&e.settings.themes.length>0&&(a=z(n,e.settings.themes))&&(n=a),e.settings.thinkingVerbs&&((a=we(n,e.settings.thinkingVerbs.verbs))&&(n=a),(a=B(n,e.settings.thinkingVerbs.format))&&(n=a)),(a=_e(n,e.settings.thinkingStyle.phases))&&(n=a),(a=ye(n,e.settings.thinkingStyle.updateInterval))&&(n=a),(a=xe(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=a),(a=he(n,e.settings.thinkingStyle.reverseMirror))&&(n=a),e.settings.userMessageDisplay&&(a=Ee(n,e.settings.userMessageDisplay.format,e.settings.userMessageDisplay.foregroundColor,e.settings.userMessageDisplay.backgroundColor,e.settings.userMessageDisplay.styling.includes(`bold`),e.settings.userMessageDisplay.styling.includes(`italic`),e.settings.userMessageDisplay.styling.includes(`underline`),e.settings.userMessageDisplay.styling.includes(`strikethrough`),e.settings.userMessageDisplay.styling.includes(`inverse`),e.settings.userMessageDisplay.borderStyle,e.settings.userMessageDisplay.borderColor,e.settings.userMessageDisplay.paddingX,e.settings.userMessageDisplay.paddingY,e.settings.userMessageDisplay.fitBoxToContent))&&(n=a),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`&&(a=ue(n,e.settings.inputBox.removeBorder))&&(n=a),(a=Oe(n))&&(n=a),(a=fe(n))&&(n=a),(a=ce(n))&&(n=a),(a=Mn(n))&&(n=a),(a=oe(n,25))&&(n=a),(a=Ae(n))&&(n=a);let o=e.settings.misc?.showTweakccVersion??!0,s=e.settings.misc?.showPatchesApplied??!0;(a=Ie(n,`3.2.4`,r,o,s))&&(n=a),(a=Dt(n))&&(n=a),e.settings.toolsets&&e.settings.toolsets.length>0&&(a=Jt(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=a),e.settings.planModeToolset&&e.settings.defaultToolset&&((a=Gt(n))&&(n=a),(a=qt(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=a));let c=e.settings.misc?.enableConversationTitle??!0,l=t.version&&et(t.version,`2.0.64`)<0;if(c&&l&&(a=rn(n))&&(n=a),e.settings.misc?.hideStartupBanner&&(a=on(n))&&(n=a),e.settings.misc?.hideCtrlGToEditPrompt&&(a=cn(n))&&(n=a),e.settings.misc?.hideStartupClawd&&(a=un(n))&&(n=a),e.settings.misc?.increaseFileReadLimit&&(a=fn(n))&&(n=a),e.settings.misc?.suppressLineNumbers&&(a=mn(n))&&(n=a),t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=C.join(q,`native-claudejs-patched.js`);x.writeFileSync(e,n,`utf8`),W(`Saved patched JS from native to: ${e}`);let r=Buffer.from(n,`utf8`);await ie(t.nativeInstallationPath,r,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await qn(t.cliPath,n,`patch`)}return await or(e=>{e.changesApplied=!0})},An=[{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],jn=e=>{let t=e.match(/\b([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-600),i=e.slice(r,t.index),a=RegExp(`function [$\\w]+\\(\\)\\{let ${H(n)}=.+?;`,`g`),o=null,s;for(;(s=a.exec(i))!==null;)o=s;return o?{insertionIndex:r+o.index+o[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${n}`),null)},Mn=e=>{let t=jn(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=An.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return V(e,a,i,n,n),a};let Nn=!1,Pn=!1;const Fn=()=>Nn,In=()=>Pn,Ln=()=>{Nn=!0},Rn=()=>{Pn=!0,Nn=!0},W=(e,...t)=>{Fn()&&console.log(e,...t)},G=(e,...t)=>{In()&&console.log(e,...t)};function zn(){try{let e=E.join(O.homedir(),`.claude.json`);return JSON.parse(T.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Bn(){try{let e=E.join(O.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(T.readFileSync(e,`utf8`))?.claudeAiOauth?.subscriptionType||`unknown`){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`}}catch{}return`Claude API`}function Vn(){try{let e=E.join(O.homedir(),`.claude`,`settings.json`),t=JSON.parse(T.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=An.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Hn(e){process.platform===`win32`?k.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?k.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():k.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function Un(e){if(process.platform===`win32`)k.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)k.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=E.dirname(e);k.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function Wn(e){if(!e||typeof e!=`string`)return!1;let t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){let e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=255&&parseInt(n)<=255&&parseInt(r)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=360&&parseInt(n)<=100&&parseInt(r)<=100}}return!1}function Gn(e){if(!Wn(e))return e;let t=e.trim();if(t.startsWith(`rgb(`))return t;if(t.startsWith(`#`)){let e=t.slice(1);return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgb(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)})`}if(t.startsWith(`hsl(`)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let t=parseInt(e[1])/360,n=parseInt(e[2])/100,r=parseInt(e[3])/100,i=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=r<.5?r*(1+n):r+n-r*n,o=2*r-a;return`rgb(${Math.round(i(o,a,t+1/3)*255)},${Math.round(i(o,a,t)*255)},${Math.round(i(o,a,t-1/3)*255)})`}}return e}async function Kn(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=A.createHash(t),o=T.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function qn(e,t,n=`replace`){let r=493;try{r=(await b.stat(e)).mode,W(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){W(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await b.unlink(e),W(`[${n}] Unlinked ${e} to break hard links`)}catch(t){W(`[${n}] Could not unlink ${e}: ${t}`)}await b.writeFile(e,t),await b.chmod(e,r),W(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function Jn(e){try{return await b.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const Yn=e=>e.startsWith(`~`)?E.join(O.homedir(),e.slice(1)):e,Xn=(e,t)=>{let n=e=>{let t=e.split(`.`).map(Number);return[t[0]||0,t[1]||0,t[2]||0]},r=n(e),i=n(t);return r[0]===i[0]?r[1]===i[1]?r[2]-i[2]:r[1]-i[1]:r[0]-i[0]},Zn=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)};async function Qn(){try{let e=await b.readFile(J,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=w.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await rr(),await b.writeFile(J,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const K={themes:[{name:`Dark mode`,id:`dark`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(253,93,177)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(235,159,127)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(147,165,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(177,195,255)`,permission:`rgb(177,185,249)`,permissionShimmer:`rgb(207,215,255)`,planMode:`rgb(72,150,140)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(177,185,249)`,remember:`rgb(177,185,249)`,background:`rgb(0,204,204)`,success:`rgb(78,186,101)`,error:`rgb(255,107,128)`,warning:`rgb(255,193,7)`,warningShimmer:`rgb(255,223,57)`,diffAdded:`rgb(34,92,43)`,diffRemoved:`rgb(122,41,54)`,diffAddedDimmed:`rgb(71,88,74)`,diffRemovedDimmed:`rgb(105,72,77)`,diffAddedWord:`rgb(56,166,96)`,diffRemovedWord:`rgb(179,89,107)`,diffAddedWordDimmed:`rgb(46,107,58)`,diffRemovedWordDimmed:`rgb(139,57,69)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(177,185,249)`,rate_limit_empty:`rgb(80,83,112)`}},{name:`Light mode`,id:`light`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(255,0,135)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(245,149,117)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(87,105,247)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(117,135,255)`,permission:`rgb(87,105,247)`,permissionShimmer:`rgb(137,155,255)`,planMode:`rgb(0,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(87,105,247)`,remember:`rgb(0,0,255)`,background:`rgb(0,153,153)`,success:`rgb(44,122,57)`,error:`rgb(171,43,63)`,warning:`rgb(150,108,30)`,warningShimmer:`rgb(200,158,80)`,diffAdded:`rgb(105,219,124)`,diffRemoved:`rgb(255,168,180)`,diffAddedDimmed:`rgb(199,225,203)`,diffRemovedDimmed:`rgb(253,210,216)`,diffAddedWord:`rgb(47,157,68)`,diffRemovedWord:`rgb(209,69,75)`,diffAddedWordDimmed:`rgb(144,194,156)`,diffRemovedWordDimmed:`rgb(232,165,173)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(240, 240, 240)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(87,105,247)`,rate_limit_empty:`rgb(39,47,111)`}},{name:`Light mode (ANSI colors only)`,id:`light-ansi`,colors:{autoAccept:`ansi:magenta`,bashBorder:`ansi:magenta`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blue`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blue`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyan`,ide:`ansi:blueBright`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:black`,inverseText:`ansi:white`,inactive:`ansi:blackBright`,subtle:`ansi:blackBright`,suggestion:`ansi:blue`,remember:`ansi:blue`,background:`ansi:cyan`,success:`ansi:green`,error:`ansi:red`,warning:`ansi:yellow`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:red`,blue_FOR_SUBAGENTS_ONLY:`ansi:blue`,green_FOR_SUBAGENTS_ONLY:`ansi:green`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellow`,purple_FOR_SUBAGENTS_ONLY:`ansi:magenta`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyan`,professionalBlue:`ansi:blueBright`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:white`,bashMessageBackgroundColor:`ansi:whiteBright`,memoryBackgroundColor:`ansi:white`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:black`}},{name:`Dark mode (ANSI colors only)`,id:`dark-ansi`,colors:{autoAccept:`ansi:magentaBright`,bashBorder:`ansi:magentaBright`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blueBright`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blueBright`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyanBright`,ide:`ansi:blue`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:whiteBright`,inverseText:`ansi:black`,inactive:`ansi:white`,subtle:`ansi:white`,suggestion:`ansi:blueBright`,remember:`ansi:blueBright`,background:`ansi:cyanBright`,success:`ansi:greenBright`,error:`ansi:redBright`,warning:`ansi:yellowBright`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:redBright`,blue_FOR_SUBAGENTS_ONLY:`ansi:blueBright`,green_FOR_SUBAGENTS_ONLY:`ansi:greenBright`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellowBright`,purple_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyanBright`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:blackBright`,bashMessageBackgroundColor:`ansi:black`,memoryBackgroundColor:`ansi:blackBright`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:white`}},{name:`Light mode (colorblind-friendly)`,id:`light-daltonized`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(0,102,204)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(51,102,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(101,152,255)`,permission:`rgb(51,102,255)`,permissionShimmer:`rgb(101,152,255)`,planMode:`rgb(51,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(51,102,255)`,remember:`rgb(51,102,255)`,background:`rgb(0,153,153)`,success:`rgb(0,102,153)`,error:`rgb(204,0,0)`,warning:`rgb(255,153,0)`,warningShimmer:`rgb(255,183,50)`,diffAdded:`rgb(153,204,255)`,diffRemoved:`rgb(255,204,204)`,diffAddedDimmed:`rgb(209,231,253)`,diffRemovedDimmed:`rgb(255,233,233)`,diffAddedWord:`rgb(51,102,204)`,diffRemovedWord:`rgb(153,51,51)`,diffAddedWordDimmed:`rgb(102,153,204)`,diffRemovedWordDimmed:`rgb(204,153,153)`,red_FOR_SUBAGENTS_ONLY:`rgb(204,0,0)`,blue_FOR_SUBAGENTS_ONLY:`rgb(0,102,204)`,green_FOR_SUBAGENTS_ONLY:`rgb(0,204,0)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,204,0)`,purple_FOR_SUBAGENTS_ONLY:`rgb(128,0,128)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,128,0)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,102,178)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(0,178,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(220, 220, 220)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(51,102,255)`,rate_limit_empty:`rgb(23,46,114)`}},{name:`Dark mode (colorblind-friendly)`,id:`dark-daltonized`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(51,153,255)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(153,204,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(183,224,255)`,permission:`rgb(153,204,255)`,permissionShimmer:`rgb(183,224,255)`,planMode:`rgb(102,153,153)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(153,204,255)`,remember:`rgb(153,204,255)`,background:`rgb(0,204,204)`,success:`rgb(51,153,255)`,error:`rgb(255,102,102)`,warning:`rgb(255,204,0)`,warningShimmer:`rgb(255,234,50)`,diffAdded:`rgb(0,68,102)`,diffRemoved:`rgb(102,0,0)`,diffAddedDimmed:`rgb(62,81,91)`,diffRemovedDimmed:`rgb(62,44,44)`,diffAddedWord:`rgb(0,119,179)`,diffRemovedWord:`rgb(179,0,0)`,diffAddedWordDimmed:`rgb(26,99,128)`,diffRemovedWordDimmed:`rgb(128,21,21)`,red_FOR_SUBAGENTS_ONLY:`rgb(255,102,102)`,blue_FOR_SUBAGENTS_ONLY:`rgb(102,178,255)`,green_FOR_SUBAGENTS_ONLY:`rgb(102,255,102)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,255,102)`,purple_FOR_SUBAGENTS_ONLY:`rgb(178,102,255)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,178,102)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,153,204)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(102,204,204)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(153,204,255)`,rate_limit_empty:`rgb(69,92,115)`}},{name:`Monochrome`,id:`monochrome`,colors:{autoAccept:`rgb(200,200,200)`,bashBorder:`rgb(180,180,180)`,claude:`rgb(255,255,255)`,claudeShimmer:`rgb(230,230,230)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(200,200,200)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(220,220,220)`,permission:`rgb(200,200,200)`,permissionShimmer:`rgb(220,220,220)`,planMode:`rgb(180,180,180)`,ide:`rgb(190,190,190)`,promptBorder:`rgb(160,160,160)`,promptBorderShimmer:`rgb(180,180,180)`,text:`rgb(255,255,255)`,inverseText:`rgb(40,40,40)`,inactive:`rgb(120,120,120)`,subtle:`rgb(100,100,100)`,suggestion:`rgb(200,200,200)`,remember:`rgb(200,200,200)`,background:`rgb(180,180,180)`,success:`rgb(220,220,220)`,error:`rgb(180,180,180)`,warning:`rgb(200,200,200)`,warningShimmer:`rgb(220,220,220)`,diffAdded:`rgb(90,90,90)`,diffRemoved:`rgb(60,60,60)`,diffAddedDimmed:`rgb(110,110,110)`,diffRemovedDimmed:`rgb(80,80,80)`,diffAddedWord:`rgb(200,200,200)`,diffRemovedWord:`rgb(80,80,80)`,diffAddedWordDimmed:`rgb(160,160,160)`,diffRemovedWordDimmed:`rgb(70,70,70)`,red_FOR_SUBAGENTS_ONLY:`rgb(200,200,200)`,blue_FOR_SUBAGENTS_ONLY:`rgb(180,180,180)`,green_FOR_SUBAGENTS_ONLY:`rgb(210,210,210)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(190,190,190)`,purple_FOR_SUBAGENTS_ONLY:`rgb(170,170,170)`,orange_FOR_SUBAGENTS_ONLY:`rgb(195,195,195)`,pink_FOR_SUBAGENTS_ONLY:`rgb(205,205,205)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(185,185,185)`,professionalBlue:`rgb(190,190,190)`,rainbow_red:`rgb(240,240,240)`,rainbow_orange:`rgb(230,230,230)`,rainbow_yellow:`rgb(220,220,220)`,rainbow_green:`rgb(210,210,210)`,rainbow_blue:`rgb(200,200,200)`,rainbow_indigo:`rgb(190,190,190)`,rainbow_violet:`rgb(180,180,180)`,rainbow_red_shimmer:`rgb(255,255,255)`,rainbow_orange_shimmer:`rgb(245,245,245)`,rainbow_yellow_shimmer:`rgb(235,235,235)`,rainbow_green_shimmer:`rgb(225,225,225)`,rainbow_blue_shimmer:`rgb(215,215,215)`,rainbow_indigo_shimmer:`rgb(205,205,205)`,rainbow_violet_shimmer:`rgb(195,195,195)`,clawd_body:`rgb(255,255,255)`,clawd_background:`rgb(40,40,40)`,userMessageBackground:`rgb(70,70,70)`,bashMessageBackgroundColor:`rgb(65,65,65)`,memoryBackgroundColor:`rgb(75,75,75)`,rate_limit_fill:`rgb(200,200,200)`,rate_limit_empty:`rgb(90,90,90)`}}],thinkingVerbs:{format:`{}… `,verbs:`Accomplishing.Actioning.Actualizing.Baking.Booping.Brewing.Calculating.Cerebrating.Channelling.Churning.Clauding.Coalescing.Cogitating.Combobulating.Computing.Concocting.Conjuring.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Deciphering.Deliberating.Determining.Discombobulating.Divining.Doing.Effecting.Elucidating.Enchanting.Envisioning.Finagling.Flibbertigibbeting.Forging.Forming.Frolicking.Generating.Germinating.Hatching.Herding.Honking.Ideating.Imagining.Incubating.Inferring.Manifesting.Marinating.Meandering.Moseying.Mulling.Musing.Mustering.Noodling.Percolating.Perusing.Philosophising.Pondering.Pontificating.Processing.Puttering.Puzzling.Reticulating.Ruminating.Scheming.Schlepping.Shimmying.Simmering.Smooshing.Spelunking.Spinning.Stewing.Sussing.Synthesizing.Thinking.Tinkering.Transmuting.Unfurling.Unravelling.Vibing.Wandering.Whirring.Wibbling.Wizarding.Working.Wrangling.Alchemizing.Animating.Architecting.Bamboozling.Beaming.Befuddling.Bewitching.Billowing.Bippity-bopping.Blanching.Boogieing.Boondoggling.Bootstrapping.Burrowing.Caching.Canoodling.Caramelizing.Cascading.Catapulting.Channeling.Choreographing.Compiling.Composing.Crystallizing.Cultivating.Deploying.Dilly-dallying.Discombobulating.Distilling.Doodling.Drizzling.Ebbing.Embellishing.Ensorcelling.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flowing.Flummoxing.Fluttering.Frosting.Gallivanting.Galloping.Garnishing.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hexing.Hibernating.Higgledy-piggleding.Hornswoggling.Hullaballooing.Hyperspacing.Illustrating.Improvising.Incanting.Indexing.Infusing.Ionizing.Jazzercising.Jiggery-pokerying.Jitterbugging.Julienning.Kerfuffling.Kneading.Leavening.Levitating.Linting.Lollygagging.Malarkeying.Metamorphosing.Migrating.Minifying.Misting.Moonwalking.Mystifying.Nebulizing.Nesting.Nucleating.Optimizing.Orbiting.Orchestrating.Osmosing.Parsing.Perambulating.Photosynthesizing.Pipelining.Poaching.Pollinating.Pouncing.Precipitating.Prestidigitating.Proofing.Propagating.Prowling.Quantumizing.Querying.Razzle-dazzling.Razzmatazzing.Recombobulating.Reducing.Refactoring.Rippling.Roosting.Sautéing.Scampering.Scurrying.Seasoning.Serializing.Shenaniganing.Skedaddling.Sketching.Skullduggering.Slithering.Sock-hopping.Spellbinding.Sprouting.Storyboarding.Sublimating.Swirling.Swooping.Symbioting.Syncopating.Teleporting.Tempering.Thaumaturging.Thundering.Tomfoolering.Topsy-turvying.Transfiguring.Transpiling.Twisting.Undulating.Validating.Vaporizing.Waddling.Warping.Whatchamacalliting.Whirlpooling.Whisking.Willy-nillying.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEditPrompt:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!0},toolsets:[],defaultToolset:null,planModeToolset:null},q=(()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return Yn(e);let t=w.join(g.homedir(),`.tweakcc`),n=w.join(g.homedir(),`.claude`,`tweakcc`),r=process.env.XDG_CONFIG_HOME;try{if(S.existsSync(t))return t}catch(e){W(`Failed to check if ${t} exists: ${e}`)}try{if(S.existsSync(n))return n}catch(e){W(`Failed to check if ${n} exists: ${e}`)}return r?w.join(r,`tweakcc`):t})(),J=w.join(q,`config.json`),$n=w.join(q,`cli.js.backup`),Y=w.join(q,`native-binary.backup`),er=w.join(q,`system-prompts`),tr=w.join(q,`prompt-data-cache`),nr=()=>{let e=q,t=g.homedir(),n=[w.join(t,`.tweakcc`),w.join(t,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?w.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return S.existsSync(t)&&t!==e}catch{return!1}});n.length>0&&(console.warn(a.yellow(`
|
|
638
638
|
Multiple configuration locations detected:`)),console.warn(a.gray(` Active: ${e}`)),console.warn(a.gray(` Other existing locations:`)),n.forEach(e=>{console.warn(a.gray(` - ${e}`))}),console.warn(a.gray(` Only the active location is used. To switch locations,`)),console.warn(a.gray(` move your config.json to the desired directory.
|
|
639
|
-
`)))},tr=async()=>{await b.mkdir(q,{recursive:!0}),await b.mkdir(Qn,{recursive:!0});let e=w.join(q,`.gitignore`);try{await b.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await b.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(_)+_)}};let nr=null;const rr=async()=>{let e={ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:K};try{W(`Reading config at ${J}`),er();let t=await b.readFile(J,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation),n.settings.inputBox||(n.settings.inputBox=K.inputBox),n.settings.toolsets||(n.settings.toolsets=K.toolsets),Object.hasOwn(n.settings,`defaultToolset`)||(n.settings.defaultToolset=K.defaultToolset),Object.hasOwn(n.settings,`planModeToolset`)||(n.settings.planModeToolset=K.planModeToolset);for(let e of K.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))n!==`colors`&&!Object.hasOwn(t,n)&&(t[n]=r);t.colors||={};for(let[n,r]of Object.entries(e.colors))Object.hasOwn(t.colors,n)||(t.colors[n]=r)}}for(let e of n?.settings?.themes||[]){if(K.themes.some(t=>t.id===e.id||t.name===e.name))continue;let t=K.themes[0];e.colors||={};for(let[n,r]of Object.entries(t.colors))Object.hasOwn(e.colors,n)||(e.colors[n]=r)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||K,n.settings.userMessageDisplay=K.userMessageDisplay),Yn(n),delete n.settings.launchText,await Xe(Qn)&&(n.changesApplied=!1),nr=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},ir=async e=>(W(`Updating config at ${J}`),nr||=await rr(),e(nr),nr.lastModified=new Date().toISOString(),await ar(nr),nr),ar=async e=>{try{e.lastModified=new Date().toISOString(),await tr(),await b.writeFile(J,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}};var X=({children:e,...n})=>N(t,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...n,children:[` `,e,` `]});const or=[`\x1B[?25l\x1B[0m \x1B[38;2;0;0;0m \x1B[38;2;252;130;0m▂\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▇\x1B[38;2;254;131;0m\x1B[48;2;252;130;0m▇\x1B[48;2;252;130;0m▇▇\x1B[48;2;252;130;0m▇\x1B[0m\x1B[38;2;252;130;0m▇\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▂ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;254;131;0m▗\x1B[38;2;254;131;0m▆\x1B[48;2;254;131;0m \x1B[38;2;254;132;0m╶ \x1B[0m\x1B[38;2;254;131;0m▆\x1B[38;2;254;131;0m▖ \x1B[0m`,` \x1B[7m\x1B[38;2;254;131;0m▘\x1B[0m\x1B[38;2;11;6;0m\x1B[48;2;254;131;0m \x1B[38;2;254;216;182m\x1B[48;2;254;136;12m▃\x1B[38;2;254;249;246m\x1B[48;2;254;143;29m▅\x1B[38;2;254;253;253m\x1B[48;2;254;143;40m▆\x1B[38;2;254;254;253m\x1B[48;2;254;152;68m▆▆▆\x1B[38;2;254;253;252m\x1B[48;2;254;141;34m▆\x1B[38;2;254;247;242m\x1B[48;2;254;140;24m▅\x1B[38;2;254;224;199m\x1B[48;2;254;140;20m▖\x1B[48;2;254;131;0m \x1B[0m\x1B[7m\x1B[38;2;254;131;0m▝\x1B[0m \x1B[0m`,`\x1B[7m\x1B[38;2;251;127;0m▌\x1B[0m\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[38;2;252;128;0m\x1B[48;2;254;131;0m▃\x1B[38;2;252;129;0m▂\x1B[38;2;253;130;0m▁\x1B[38;2;249;135;16m\x1B[48;2;253;226;202m▋\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┈\x1B[48;2;246;246;245m┈\x1B[38;2;47;47;47m\x1B[48;2;244;244;243m▂\x1B[38;2;112;112;112m\x1B[48;2;251;251;251m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m▁╌▝\x1B[38;2;254;254;253m\x1B[48;2;254;254;254m▋\x1B[38;2;254;254;254m\x1B[48;2;254;253;252m┈\x1B[38;2;252;209;168m\x1B[48;2;251;129;0m▍\x1B[38;2;253;129;0m\x1B[48;2;254;131;0m▂\x1B[38;2;252;128;0m▃\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[0m\x1B[38;2;251;127;0m▌\x1B[0m`,`\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▏\x1B[38;2;245;118;0m\x1B[48;2;248;122;0m▄\x1B[38;2;247;121;0m\x1B[48;2;247;122;0m┈\x1B[38;2;106;68;38m\x1B[48;2;245;123;2m▃\x1B[38;2;39;33;28m\x1B[48;2;211;109;6m▅\x1B[38;2;27;20;12m\x1B[48;2;237;237;237m▌\x1B[48;2;254;254;253m \x1B[38;2;90;90;89m\x1B[48;2;231;230;230m▝\x1B[38;2;215;215;214m\x1B[48;2;48;48;48m▁\x1B[38;2;203;203;202m\x1B[48;2;42;42;42m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┇╴\x1B[38;2;253;252;252m▂\x1B[38;2;251;250;250m\x1B[48;2;253;253;253m▃\x1B[38;2;249;249;248m\x1B[48;2;252;252;251m▄\x1B[38;2;249;248;248m\x1B[48;2;237;118;0m▍\x1B[38;2;246;121;0m\x1B[48;2;250;125;0m▄\x1B[38;2;246;119;0m\x1B[48;2;249;124;0m▄\x1B[38;2;245;118;0m\x1B[48;2;248;123;0m▄\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▉\x1B[0m`,`\x1B[38;2;238;108;0m\x1B[48;2;237;109;0m▏\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;233;109;2m\x1B[48;2;125;73;29m▇\x1B[38;2;225;104;1m\x1B[48;2;50;32;18m▄\x1B[38;2;62;29;2m\x1B[48;2;239;237;237m▌\x1B[38;2;254;253;253m\x1B[48;2;254;254;254m┻\x1B[38;2;254;254;253m▊\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;253;253;252m▂\x1B[38;2;251;251;251m\x1B[48;2;254;253;253m▃\x1B[38;2;249;249;249m\x1B[48;2;252;252;252m▄\x1B[38;2;247;247;247m\x1B[48;2;250;250;250m▄\x1B[38;2;245;245;244m\x1B[48;2;248;248;248m▄\x1B[38;2;243;243;242m\x1B[48;2;246;246;245m▄\x1B[38;2;243;242;242m\x1B[48;2;230;109;0m▍\x1B[38;2;239;111;0m\x1B[48;2;243;116;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;237;108;0m\x1B[48;2;238;108;0m▉\x1B[0m`,`\x1B[7m\x1B[38;2;231;98;0m▌\x1B[0m\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[38;2;231;99;0m\x1B[48;2;235;105;0m▄\x1B[38;2;232;100;0m\x1B[48;2;236;105;0m▄\x1B[38;2;232;101;0m\x1B[48;2;236;106;0m▄\x1B[38;2;223;99;0m\x1B[48;2;247;238;235m▌\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;252;252;251m▃\x1B[38;2;250;250;250m\x1B[48;2;253;253;252m▄\x1B[38;2;248;248;247m\x1B[48;2;251;251;250m▄\x1B[38;2;246;245;245m\x1B[48;2;249;248;248m▄\x1B[38;2;243;243;243m\x1B[48;2;246;246;246m▄\x1B[38;2;241;241;241m\x1B[48;2;244;244;244m▄\x1B[38;2;239;239;238m\x1B[48;2;242;242;242m▄\x1B[38;2;237;237;236m\x1B[48;2;240;240;239m▄\x1B[38;2;237;236;236m\x1B[48;2;223;99;0m▍\x1B[38;2;232;100;0m\x1B[48;2;236;106;0m▄\x1B[38;2;231;100;0m\x1B[48;2;235;105;0m▄\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[0m\x1B[38;2;231;98;0m▌\x1B[0m`,` \x1B[7m\x1B[38;2;224;89;0m▖\x1B[0m\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[38;2;225;90;0m\x1B[48;2;228;95;0m▄\x1B[38;2;225;91;0m\x1B[48;2;229;96;0m▄\x1B[38;2;217;90;1m\x1B[48;2;97;77;70m▌\x1B[38;2;70;70;70m\x1B[48;2;207;207;207m▆\x1B[38;2;66;65;65m\x1B[48;2;228;228;227m▄\x1B[38;2;66;66;66m\x1B[48;2;233;232;232m▂\x1B[38;2;169;169;169m\x1B[48;2;243;243;243m▁\x1B[38;2;240;239;239m\x1B[48;2;243;242;242m▄\x1B[38;2;238;237;237m\x1B[48;2;241;240;240m▄\x1B[38;2;235;235;235m\x1B[48;2;238;238;238m▄\x1B[38;2;233;233;233m\x1B[48;2;236;236;236m▄\x1B[38;2;231;231;230m\x1B[48;2;234;234;233m▄\x1B[38;2;231;230;230m\x1B[48;2;216;89;0m▍\x1B[38;2;225;90;0m\x1B[48;2;229;95;0m▄\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[0m\x1B[7m\x1B[38;2;224;89;0m▗\x1B[0m \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;217;80;0m▝\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m\x1B[48;2;221;86;0m▄\x1B[38;2;197;78;9m\x1B[48;2;66;66;65m▋\x1B[38;2;65;65;64m\x1B[48;2;60;60;60m▘\x1B[38;2;52;52;51m\x1B[48;2;56;56;56m▗\x1B[38;2;45;45;45m\x1B[48;2;50;50;49m▗\x1B[38;2;42;42;42m\x1B[48;2;46;46;46m┈\x1B[38;2;41;41;41m\x1B[48;2;203;202;202m▆\x1B[38;2;38;38;38m\x1B[48;2;218;218;218m▄\x1B[38;2;45;45;45m\x1B[48;2;221;221;221m▂\x1B[38;2;229;229;229m┊\x1B[38;2;225;225;225m\x1B[48;2;228;228;227m▄\x1B[38;2;225;224;224m\x1B[48;2;209;79;0m▍\x1B[0m\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m▘ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[7m\x1B[38;2;191;73;0m▆\x1B[38;2;191;73;0m▄\x1B[38;2;56;55;55m▃\x1B[38;2;46;46;46m▁\x1B[0m\x1B[38;2;20;20;20m\x1B[48;2;42;42;42m▁\x1B[38;2;36;36;36m\x1B[48;2;35;34;34m╴\x1B[38;2;23;23;23m\x1B[48;2;29;29;28m▁\x1B[38;2;10;10;10m\x1B[48;2;22;22;22m▁\x1B[0m\x1B[7m\x1B[38;2;15;15;15m▁\x1B[38;2;22;22;21m▃\x1B[38;2;154;154;154m▅\x1B[38;2;175;116;83m▇\x1B[0m\x1B[38;2;17;15;14m \x1B[0m`,`\x1B[?25h\x1B[0m`];var sr=()=>N(e,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[N(e,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[M(t,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),M(t,{children:` `}),N(t,{children:[`We've released `,M(t,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),N(t,{children:[`Download it and try it out for free!`,` `,M(v,{url:`https://piebald.ai/`,fallback:!1,children:M(t,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),M(t,{children:` `}),M(t,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),M(e,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:or.map((e,n)=>M(t,{children:e},n))})]});let Z=function(e){return e.APPLY_CHANGES=`*Apply customizations`,e.THEMES=`Themes`,e.THINKING_VERBS=`Thinking verbs`,e.THINKING_STYLE=`Thinking style`,e.USER_MESSAGE_DISPLAY=`User message display`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.VIEW_SYSTEM_PROMPTS=`View system prompts`,e.RESTORE_ORIGINAL=`Restore original Claude Code (preserves config.json)`,e.OPEN_CONFIG=`Open config.json`,e.OPEN_CLI=`Open Claude Code's cli.js`,e.EXIT=`Exit`,e}({});function cr({items:n,selectedIndex:i,onSelect:a,onSubmit:o}){return r((e,t)=>{t.upArrow?a(i>0?i-1:n.length-1):t.downArrow?a(i<n.length-1?i+1:0):t.return&&o(n[i].name)}),M(e,{flexDirection:`column`,children:n.map((n,r)=>M(e,{children:N(t,{children:[N(t,{bold:r===i,color:r===i?`cyan`:void 0,...r===i?n.selectedStyles??{}:n.styles??{},children:[r===i?`❯ `:` `,n.name]}),n.desc&&r===i&&N(t,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,n.desc]})]})},r))})}const lr=[{name:Z.THEMES,desc:`Modify Claude Code's built-in themes or create your own`},{name:Z.THINKING_VERBS,desc:`Customize the list of verbs that Claude Code uses when it's working`},{name:Z.THINKING_STYLE,desc:`Choose custom spinners`},{name:Z.USER_MESSAGE_DISPLAY,desc:`Customize how user messages are displayed`},{name:Z.MISC,desc:`Miscellaneous settings (input box border, etc.)`},{name:Z.TOOLSETS,desc:`Manage toolsets to control which tools are available`},{name:Z.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],ur=[{name:Z.RESTORE_ORIGINAL,desc:`Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)`},{name:Z.OPEN_CONFIG,desc:`Opens your tweakcc config file (${J})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var dr=({onSubmit:e})=>{let t=[...u($).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:`Required: Updates Claude Code in-place with your changes`,selectedStyles:{color:`green`}}],...lr,...ur],[n,r]=m(0);return M(cr,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const fr=()=>N(e,{flexDirection:`row`,children:[M(X,{children:`tweakcc`}),M(t,{children:` (by `}),M(v,{url:`https://piebald.ai`,fallback:!1,children:M(t,{color:`#ff8400`,bold:!0,children:`Piebald`})}),M(t,{children:`)`})]}),pr=()=>M(e,{children:N(t,{color:`yellow`,children:[`⭐ `,M(t,{bold:!0,children:`Star the repo at `}),M(v,{url:`https://github.com/Piebald-AI/tweakcc`,fallback:!1,children:M(t,{bold:!0,color:`cyan`,children:`https://github.com/Piebald-AI/tweakcc`})}),M(t,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),mr=({notification:n})=>M(e,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:M(t,{color:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,children:n.message})}),hr=({onSubmit:n,notification:r,configMigrated:i,showPiebaldAnnouncement:a})=>N(e,{flexDirection:`column`,gap:1,children:[i&&M(e,{children:M(t,{color:`blue`,bold:!0,children:"Note that in tweakcc v3.2.0+, `ccInstallationDir` config is deprecated. You are now migrated to `ccInstallationPath` which supports npm and native installs."})}),M(fr,{}),M(e,{children:N(t,{children:[M(t,{bold:!0,children:`Customize your Claude Code installation.`}),` `,N(t,{dimColor:!0,children:[`Settings will be saved to `,q.replace(h.homedir(),`~`),`/config.json.`]})]})}),M(a?sr:pr,{}),r&&M(mr,{notification:r}),M(dr,{onSubmit:n})]});function Q({color:e,backgroundColor:n,bold:r,dimColor:i,children:s}){let c=e?.startsWith(`ansi:`),l=n?.startsWith(`ansi:`);if(c||l){if(o.Children.toArray(s).some(e=>o.isValidElement(e)))return M(t,{children:s});let u=a;if(c){let t=e.slice(5);u=u[t]||u}if(l){let e=n.slice(5),t=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;u=u[t]||u}r&&(u=u.bold),i&&(u=u.dim);let d=o.Children.toArray(s).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return M(t,{children:u(d)})}return M(t,{color:e,backgroundColor:n,bold:r,dimColor:i,children:s})}function gr({text:e,nonShimmerColors:n,shimmerColors:r,shimmerWidth:i=3,updateDuration:a=50,restartPoint:o=10}){let[s,c]=m(0);return d(()=>{let t=setInterval(()=>{c(t=>{let n=t+1;return n>=e.length+o?-i:n})},a);return()=>clearInterval(t)},[e.length,o,a]),n.length===r.length?M(t,{children:e.split(``).map((a,o)=>{let c=o>=s&&o<s+i&&s<e.length,l=o%n.length;return M(t,{color:c?r[l]:n[l],children:a},o)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),M(t,{children:e}))}const _r=P.cwd();function vr({theme:n}){let{ccVersion:r}=u($);return N(e,{flexDirection:`column`,paddingLeft:1,children:[M(e,{marginBottom:1,children:N(t,{bold:!0,children:[`Preview: `,n.name]})}),M(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:N(e,{flexDirection:`column`,children:[N(e,{flexDirection:`column`,children:[N(t,{children:[M(Q,{color:n.colors.clawd_body,children:` ▐`}),M(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`▛███▜`}),N(t,{children:[M(Q,{color:n.colors.clawd_body,children:`▌ `}),` `,M(t,{bold:!0,children:`Claude Code`}),` `,r?`v${r}`:`v2.0.14`]})]}),N(t,{children:[M(Q,{color:n.colors.clawd_body,children:`▝▜`}),M(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`█████`}),M(Q,{color:n.colors.clawd_body,children:`▛▘`}),` `,zn(),` · `,Rn()]}),N(Q,{color:n.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,_r]}),N(t,{children:[N(Q,{color:n.colors.success,children:[`Login successful. Press`,` `]}),M(Q,{bold:!0,color:n.colors.success,children:`Enter`}),N(Q,{color:n.colors.success,children:[` `,`to continue…`]})]})]}),M(t,{children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),N(t,{children:[`│ 2`,` `,M(Q,{backgroundColor:n.colors.diffRemoved,color:n.colors.text,children:`- console.log("`}),M(Q,{backgroundColor:n.colors.diffRemovedWord,children:`Hello, World!`}),M(Q,{backgroundColor:n.colors.diffRemoved,children:`");`}),` `,`│`]}),N(t,{children:[`│ 2`,` `,M(Q,{backgroundColor:n.colors.diffAdded,color:n.colors.text,children:`+ console.log("`}),M(Q,{backgroundColor:n.colors.diffAddedWord,children:`Hello, Claude!`}),M(Q,{backgroundColor:n.colors.diffAdded,children:`");`}),` `,`│`]}),M(Q,{color:n.colors.warning,children:`╭─────────────────────────────────────────────╮`}),N(Q,{color:n.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),N(t,{children:[M(Q,{color:n.colors.warning,children:`│ `}),M(t,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),N(Q,{color:n.colors.warning,children:[` `,`│`]})]}),M(Q,{color:n.colors.bashBorder,children:`───────────────────────────────────────────────`}),N(t,{children:[M(Q,{color:n.colors.bashBorder,children:`!`}),M(t,{children:` ls`})]}),M(Q,{color:n.colors.promptBorder,children:`───────────────────────────────────────────────`}),M(t,{children:N(t,{children:[`> list the dir`,` `,M(gr,{text:`ultrathink`,nonShimmerColors:[n.colors.rainbow_red,n.colors.rainbow_orange,n.colors.rainbow_yellow,n.colors.rainbow_green,n.colors.rainbow_blue,n.colors.rainbow_indigo,n.colors.rainbow_violet],shimmerColors:[n.colors.rainbow_red_shimmer,n.colors.rainbow_orange_shimmer,n.colors.rainbow_yellow_shimmer,n.colors.rainbow_green_shimmer,n.colors.rainbow_blue_shimmer,n.colors.rainbow_indigo_shimmer,n.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),M(Q,{color:n.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[M(Q,{color:n.colors.planMode,children:`│ `}),N(Q,{color:n.colors.permission,children:[`Ready to code?`,` `]}),M(t,{children:`Here is Claude's plan:`}),N(Q,{color:n.colors.planMode,children:[` `,`│`]})]}),M(Q,{color:n.colors.permission,children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[M(Q,{color:n.colors.permission,children:`│ `}),M(t,{bold:!0,children:`Permissions:`}),` `,N(Q,{backgroundColor:n.colors.permission,color:n.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,M(Q,{color:n.colors.permission,children:`│`})]}),M(t,{children:`> list the dir`}),N(t,{children:[M(Q,{color:n.colors.error,children:`●`}),M(t,{children:` Update(__init__.py)`})]}),N(t,{children:[M(t,{children:` ⎿ `}),M(Q,{color:n.colors.error,children:`User rejected update to __init__.py`})]}),N(t,{children:[` `,`1`,` `,N(Q,{backgroundColor:n.colors.diffRemovedDimmed,children:[`- import`,` `]}),M(Q,{backgroundColor:n.colors.diffRemovedWordDimmed,children:`os`})]}),N(t,{children:[` `,`2`,` `,N(Q,{backgroundColor:n.colors.diffAddedDimmed,children:[`+ import`,` `]}),M(Q,{backgroundColor:n.colors.diffAddedWordDimmed,children:`random`})]}),N(t,{children:[M(Q,{color:n.colors.success,children:`●`}),M(t,{children:` List(.)`})]}),N(t,{children:[M(t,{children:`●`}),M(t,{children:` The directory `}),M(Q,{color:n.colors.permission,children:`C:\\Users\\user`}),N(t,{children:[` `,`contains `,M(t,{bold:!0,children:`123`}),` files.`]})]}),N(t,{children:[M(Q,{color:n.colors.claude,children:`✻ Th`}),M(Q,{color:n.colors.claudeShimmer,children:`ink`}),M(Q,{color:n.colors.claude,children:`ing… `}),M(t,{children:`(esc to interrupt)`})]}),M(t,{children:M(Q,{color:n.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),M(t,{children:M(Q,{color:n.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),M(t,{children:M(Q,{color:n.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function yr({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?M(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?M(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):M(Q,{color:r,bold:n,children:e})}function br({initialValue:n,onColorChange:i,onExit:a,colorKey:o,theme:c}){let l=Sr(n)||{h:0,s:50,l:50},u=xr(n)||{r:128,g:128,b:128},[f,p]=m(l),[h,g]=m(u),[_,v]=m(`hsl`),[y,b]=m(`h`),[x,S]=m(!1),[C,w]=m(!1);d(()=>{let e=Sr(n),t=xr(n);e&&t&&(S(!0),p(e),g(t),S(!1))},[n]),d(()=>{!x&&C&&i(`rgb(${h.r},${h.g},${h.b})`)},[f,h,x,C]),d(()=>{w(!0)},[]);let T=e=>{if(Hn(e)){let t=Un(e),n=Sr(t),r=xr(t);n&&r&&(S(!0),p(n),g(r),S(!1))}};r((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){T(e);return}t.return||t.escape?a():t.ctrl&&e===`a`?(v(e=>e===`hsl`?`rgb`:`hsl`),b(e=>_===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?b(_===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?b(_===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?E(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&E(t.shift||t.ctrl||t.meta?10:1)});let E=e=>{S(!0),_===`hsl`?p(t=>{let n={...t};y===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):y===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):y===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=O(n.h,n.s,n.l);return g({r,g:i,b:a}),n}):g(t=>{let n={...t};return y===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):y===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):y===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),p(D(n.r,n.g,n.b)),n}),S(!1)},D=(e,t,n)=>{let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===r?((i-a)/c+(i<a?6:0))/6:o===i?((a-r)/c+2)/6:((r-i)/c+4)/6),{h:Math.round(d*360),s:Math.round(u*100),l:Math.round(l*100)}},O=(e,t,n)=>{e/=360,t/=100,n/=100;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e*6%2-1)),a=n-r/2,o=0,s=0,c=0;return 0<=e&&e<1/6?(o=r,s=i,c=0):1/6<=e&&e<2/6?(o=i,s=r,c=0):2/6<=e&&e<3/6?(o=0,s=r,c=i):3/6<=e&&e<4/6?(o=0,s=i,c=r):4/6<=e&&e<5/6?(o=i,s=0,c=r):5/6<=e&&e<1&&(o=r,s=0,c=i),[Math.round((o+a)*255),Math.round((s+a)*255),Math.round((c+a)*255)]},k=()=>{let e=[],n=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let r=0;r<40;r++){let i=r/39*(n.length-1),a=Math.floor(i),o=Math.ceil(i),s=i-a,[c,l,u]=n[a],[d,f,p]=n[o],m=Math.round(c+(d-c)*s),h=Math.round(l+(f-l)*s),g=Math.round(u+(p-u)*s);e.push(M(t,{backgroundColor:`rgb(${m},${h},${g})`,children:` `},r))}return e},A=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,r,f.l);e.push(M(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},ee=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,f.s,r);e.push(M(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},P=()=>{let[e,t,n]=O(f.h,f.s,f.l);return`rgb(${e},${t},${n})`},F=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},te=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${r},${h.g},${h.b})`,children:` `},n))}return e},I=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${h.r},${r},${h.b})`,children:` `},n))}return e},ne=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${h.r},${h.g},${r})`,children:` `},n))}return e},L=(e,t)=>Math.round(e/t*39);return N(e,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[N(e,{flexDirection:`column`,children:[M(t,{bold:!0,children:`Color Picker`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),M(t,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),M(t,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),M(t,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),M(t,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),M(t,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),_===`hsl`?N(j,{children:[N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`h`?`yellow`:`white`,children:[y===`h`?`❯ `:` `,`Hue (`,f.h,`°):`]})}),M(e,{children:k().map((e,n)=>M(s,{children:n===L(f.h,360)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`s`?`yellow`:`white`,children:[y===`s`?`❯ `:` `,`Saturation (`,f.s,`%):`]})}),M(e,{children:A().map((e,n)=>M(s,{children:n===L(f.s,100)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`l`?`yellow`:`white`,children:[y===`l`?`❯ `:` `,`Lightness (`,f.l,`%):`]})}),M(e,{children:ee().map((e,n)=>M(s,{children:n===L(f.l,100)?M(t,{children:`|`}):e},n))})]})]}):N(j,{children:[N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`r`?`yellow`:`white`,children:[y===`r`?`❯ `:` `,`Red (`,h.r,`):`]})}),M(e,{children:te().map((e,n)=>M(s,{children:n===L(h.r,255)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`g`?`yellow`:`white`,children:[y===`g`?`❯ `:` `,`Green (`,h.g,`):`]})}),M(e,{children:I().map((e,n)=>M(s,{children:n===L(h.g,255)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`b`?`yellow`:`white`,children:[y===`b`?`❯ `:` `,`Blue (`,h.b,`):`]})}),M(e,{children:ne().map((e,n)=>M(s,{children:n===L(h.b,255)?M(t,{children:`|`}):e},n))})]})]}),N(e,{marginBottom:1,children:[M(t,{children:`Current: `}),M(t,{backgroundColor:P(),children:` `})]}),N(e,{flexDirection:`row`,justifyContent:`space-between`,children:[N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`Hex `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:F(h.r,h.g,h.b)}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:F(h.r,h.g,h.b)}):M(t,{color:P(),bold:!0,children:F(h.r,h.g,h.b)})]}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`RGB `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):M(t,{color:P(),bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`})]}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`HSL `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):M(t,{color:P(),bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`})]})]})]})}function xr(e){let t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};let n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){let e=n[1];return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}return null}function Sr(e){let t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){let e=parseInt(n[1])/255,t=parseInt(n[2])/255,r=parseInt(n[3])/255,i=Math.max(e,t,r),a=Math.min(e,t,r),o=i-a,s=(i+a)/2,c=0;o!==0&&(c=s>.5?o/(2-i-a):o/(i+a));let l=0;return o!==0&&(l=i===e?((t-r)/o+(t<r?6:0))/6:i===t?((r-e)/o+2)/6:((e-t)/o+4)/6),{h:Math.round(l*360),s:Math.round(c*100),l:Math.round(s*100)}}let r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){let e=r[1],t=parseInt(e.substr(0,2),16)/255,n=parseInt(e.substr(2,2),16)/255,i=parseInt(e.substr(4,2),16)/255,a=Math.max(t,n,i),o=Math.min(t,n,i),s=a-o,c=(a+o)/2,l=0;s!==0&&(l=c>.5?s/(2-a-o):s/(a+o));let u=0;return s!==0&&(u=a===t?((n-i)/s+(n<i?6:0))/6:a===n?((i-t)/s+2)/6:((t-n)/s+4)/6),{h:Math.round(u*360),s:Math.round(l*100),l:Math.round(c*100)}}return{h:0,s:50,l:50}}function Cr({onBack:n,themeId:i}){let{settings:{themes:a},updateSettings:o}=u($),[s,c]=m(i),d=a.find(e=>e.id===s)||a[0],[f,p]=m(`rgb`),[h,g]=m(0),[_,v]=m(null),[y,b]=m(null),[x,S]=m(``),[C,w]=m(``),T=l(e=>{o(t=>{let n=t.themes.findIndex(e=>e.id===s);n!==-1&&e(t.themes[n])})},[s,o]),E=e=>{if(h>=2&&Hn(e)){let t=Un(e),n=D[h-2];T(e=>{e.colors[n]=t})}};r((e,t)=>{if(_===null&&y===null){if(e.length>1&&!t.ctrl&&!t.meta){E(e);return}if(t.escape)n();else if(t.ctrl&&e===`a`)p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(t.upArrow)g(e=>Math.max(0,e-1));else if(t.downArrow)g(e=>Math.min(D.length+1,e+1));else if(t.return)if(h===0)b(`name`),S(d.name),w(d.name);else if(h===1)b(`id`),S(d.id),w(d.id);else{let e=h-2,t=D[e],n=d.colors[t];v(e),S(n),w(n)}}else if(_!==null)t.ctrl&&e===`a`&&p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(y!==null)if(t.return){if(y===`id`){let e=s;c(x),o(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=x)})}else T(e=>{e.name=x});b(null),S(``),w(``)}else t.escape?(b(null),S(``),w(``)):t.backspace||t.delete?S(e=>e.slice(0,-1)):e&&S(t=>t+e)});let D=Object.keys(d.colors),O=(e,t)=>{let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)return e;let r=parseInt(n[1]),i=parseInt(n[2]),a=parseInt(n[3]);switch(t){case`hex`:{let e=e=>e.toString(16).padStart(2,`0`);return`#${e(r)}${e(i)}${e(a)}`}case`hsl`:{let e=r/255,t=i/255,n=a/255,o=Math.max(e,t,n),s=Math.min(e,t,n),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===e?((t-n)/c+(t<n?6:0))/6:o===t?((n-e)/c+2)/6:((e-t)/c+4)/6),`hsl(${Math.round(d*360)}, ${Math.round(u*100)}%, ${Math.round(l*100)}%)`}case`rgb`:default:return e}},k=e=>({autoAccept:`Auto-accept edits mode indicator`,bashBorder:`Bash command border`,claude:`Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.`,claudeShimmer:`Color used for the shimmering effect on the thinking verb.`,claudeBlue_FOR_SYSTEM_SPINNER:`System spinner color (blue variant)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`System spinner shimmer color (blue variant)`,permission:`Permission prompt color`,permissionShimmer:`Permission prompt shimmer color`,planMode:`Plan mode indicator`,ide:`Color used for IDE-related messages.`,promptBorder:`Input prompt border color`,promptBorderShimmer:`Input prompt border shimmer color`,text:`Code color. Used in diffs.`,inverseText:`Inverse text color. Used for the text of tabs, where the background is filled in.`,inactive:`Inactive/dimmed text. Used for line numbers and less prominent text.`,subtle:`Subtle text. Used for help text and secondary information.`,suggestion:`Suggestion text color. Used for suggestions for theme names and various other things.`,remember:`Remember/note color. Used for various text relating to memories.`,background:`Background color for certain UI elements`,success:`Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).`,error:`Error indicator`,warning:`Warning indicator`,warningShimmer:`Warning shimmer color`,diffAdded:`Added diff background`,diffRemoved:`Removed diff background`,diffAddedDimmed:`Added diff background (dimmed)`,diffRemovedDimmed:`Removed diff background (dimmed)`,diffAddedWord:`Added word highlight`,diffRemovedWord:`Removed word highlight`,diffAddedWordDimmed:`Added word highlight (dimmed)`,diffRemovedWordDimmed:`Removed word highlight (dimmed)`,red_FOR_SUBAGENTS_ONLY:`Red color for sub agents`,blue_FOR_SUBAGENTS_ONLY:`Blue color for sub agents`,green_FOR_SUBAGENTS_ONLY:`Green color for sub agents`,yellow_FOR_SUBAGENTS_ONLY:`Yellow color for sub agents`,purple_FOR_SUBAGENTS_ONLY:`Purple color for sub agents`,orange_FOR_SUBAGENTS_ONLY:`Orange color for sub agents`,pink_FOR_SUBAGENTS_ONLY:`Pink color for sub agents`,cyan_FOR_SUBAGENTS_ONLY:`Cyan color for sub agents`,professionalBlue:`Professional blue color for business contexts?`,rainbow_red:`"ultrathink" rainbow - red`,rainbow_orange:`"ultrathink" rainbow - orange`,rainbow_yellow:`"ultrathink" rainbow - yellow`,rainbow_green:`"ultrathink" rainbow - green`,rainbow_blue:`"ultrathink" rainbow - blue`,rainbow_indigo:`"ultrathink" rainbow - indigo`,rainbow_violet:`"ultrathink" rainbow - violet`,rainbow_red_shimmer:`"ultrathink" rainbow (shimmer) - red`,rainbow_orange_shimmer:`"ultrathink" rainbow (shimmer) - orange`,rainbow_yellow_shimmer:`"ultrathink" rainbow (shimmer) - yellow`,rainbow_green_shimmer:`"ultrathink" rainbow (shimmer) - green`,rainbow_blue_shimmer:`"ultrathink" rainbow (shimmer) - blue`,rainbow_indigo_shimmer:`"ultrathink" rainbow (shimmer) - indigo`,rainbow_violet_shimmer:`"ultrathink" rainbow (shimmer) - violet`,clawd_body:`"Clawd" character body color`,clawd_background:`"Clawd" character background color`,userMessageBackground:`Background color for user messages`,bashMessageBackgroundColor:`Background color for bash command output`,memoryBackgroundColor:`Background color for memory/context information`,rate_limit_fill:`Rate limit indicator fill color`,rate_limit_empty:`Rate limit indicator empty/background color`})[e]||``,A=Math.max(...D.map(e=>e.length));return N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(X,{children:[`Editing theme “`,d.name,`” (`,d.id,`)`]})}),_===null&&y===null?N(j,{children:[N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`enter to edit theme name, id, or color`}),M(t,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),M(t,{dimColor:!0,children:`paste color from clipboard (when on color)`}),M(t,{dimColor:!0,children:`esc to go back`})]}),h<2?N(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[M(t,{bold:!0,children:h===0?`Theme Name`:`Theme ID`}),M(t,{children:h===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):N(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:d.colors[D[h-2]],flexDirection:`column`,paddingLeft:1,children:[M(yr,{colorKey:D[h-2],theme:d,bold:!0}),M(t,{children:k(D[h-2])})]}),N(e,{flexDirection:`column`,children:[N(e,{children:[M(t,{color:h===0?`yellow`:`white`,children:h===0?`❯ `:` `}),M(t,{bold:!0,children:`Name: `}),M(t,{children:d.name})]}),N(e,{marginBottom:1,children:[M(t,{color:h===1?`yellow`:`white`,children:h===1?`❯ `:` `}),M(t,{bold:!0,children:`ID: `}),M(t,{children:d.id})]}),(()=>{if(h<2)return N(j,{children:[D.slice(0,20).map((n,r)=>{let i=r+2;return N(e,{children:[M(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),M(e,{width:A+2,children:M(t,{children:M(yr,{colorKey:n,theme:d,bold:!0})})}),M(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),D.length>20&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let n=h-2,r=Math.max(0,n-10),i=Math.min(D.length,r+20),a=Math.max(0,i-20),o=D.slice(a,i);return N(j,{children:[a>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,a,` more above`]}),o.map((n,r)=>{let i=a+r+2;return N(e,{children:[M(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),M(e,{width:A+2,children:M(t,{children:M(yr,{colorKey:n,theme:d,bold:!0})})}),M(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),i<D.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-i,` more below`]})]})})()]})]}):y?N(e,{flexDirection:`column`,marginTop:1,children:[N(t,{children:[`Editing `,y===`name`?`theme name`:`theme ID`,`:`]}),M(e,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:M(t,{children:x})}),M(t,{dimColor:!0,children:`enter to save, esc to cancel`})]}):M(br,{initialValue:C,colorKey:D[_],theme:d,onColorChange:e=>{S(e),T(t=>{t.colors[D[_]]=e})},onExit:()=>{T(e=>{e.colors[D[_]]=x}),v(null),S(``),w(``)}})]}),M(e,{width:`50%`,children:M(vr,{theme:d})})]})}function wr(e){return e.map(e=>`${e.name} (${e.id})`)}function Tr({onBack:n}){let{settings:{themes:i},updateSettings:a}=u($),[o,s]=m(0),[c,l]=m(null),[d,f]=m(!0),p=()=>{let e={colors:{...(i[0]||K.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};a(t=>{t.themes.push(e)}),l(e.id),f(!1)},h=e=>{i.length<=1||(a(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),o>=i.length-1&&s(Math.max(0,i.length-2)))},g=()=>{a(e=>{e.themes=[...K.themes]}),s(0)};if(r((e,t)=>{if(t.escape)n();else if(t.upArrow)s(e=>Math.max(0,e-1));else if(t.downArrow)s(e=>Math.min(i.length-1,e+1));else if(t.return){let e=i[o];e&&(l(e.id),f(!1))}else if(e===`n`)p();else if(e===`d`){let e=i[o];e&&h(e.id)}else t.ctrl&&e===`r`&&g()},{isActive:d}),c)return M(Cr,{themeId:c,onBack:()=>{l(null),f(!0)}});let _=wr(i),v=i.find(e=>_[o]?.includes(`(${e.id})`))||i[0];return i.length===0?M(e,{children:N(e,{flexDirection:`column`,width:`100%`,children:[M(X,{children:`Themes`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new theme`}),M(t,{dimColor:!0,children:`esc to go back`})]}),M(t,{children:`No themes available!`})]})}):N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(X,{children:`Themes`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new theme`}),M(t,{dimColor:!0,children:`d to delete a theme`}),M(t,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),M(t,{dimColor:!0,children:`enter to edit theme`}),M(t,{dimColor:!0,children:`esc to go back`})]}),M(e,{flexDirection:`column`,children:_.map((e,n)=>N(t,{color:o===n?`yellow`:void 0,children:[o===n?`❯ `:` `,e]},n))})]}),M(e,{width:`50%`,children:M(vr,{theme:v})})]})}function Er({onBack:n}){let{settings:{thinkingVerbs:{format:i,verbs:a},themes:o},updateSettings:s}=u($),c=[`format`,`verbs`],[l,d]=m(0),f=c[l],[p,h]=m(0),[g,_]=m(!1),[v,y]=m(``),[b,x]=m(!1),[S,C]=m(!1),[w,T]=m(i),E=Ln(),D=(o.find(e=>e.id===E)||o.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return r((e,t)=>{if(S){t.return?(s(e=>{e.thinkingVerbs.format=w}),C(!1)):t.escape?(T(i),C(!1)):t.backspace||t.delete?T(e=>e.slice(0,-1)):e&&T(t=>t+e);return}if(g||b){t.return&&v.trim()?(b?(s(e=>{e.thinkingVerbs.verbs.push(v.trim())}),x(!1)):(s(e=>{e.thinkingVerbs.verbs[p]=v.trim()}),_(!1)),y(``)):t.escape?(y(``),_(!1),x(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&y(t=>t+e);return}t.escape?n():t.return?f===`format`&&(T(i),C(!0)):t.tab?t.shift?d(e=>e===0?c.length-1:e-1):d(e=>e===c.length-1?0:e+1):t.upArrow?f===`verbs`&&a.length>0&&h(e=>e>0?e-1:a.length-1):t.downArrow?f===`verbs`&&a.length>0&&h(e=>e<a.length-1?e+1:0):e===`e`&&f===`verbs`?a.length>0&&(y(a[p]),_(!0)):e===`d`&&f===`verbs`?a.length>1&&(s(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==p)}),p>=a.length-1&&h(Math.max(0,a.length-2))):e===`n`&&f===`verbs`?(x(!0),y(``)):t.ctrl&&e===`r`&&f===`verbs`&&(s(e=>{e.thinkingVerbs.verbs=[...K.thinkingVerbs.verbs]}),h(0))}),N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,flexDirection:`column`,children:[M(X,{children:`Thinking Verbs`}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:f===`format`?`enter to edit format`:`changes auto-saved`}),M(t,{dimColor:!0,children:`esc to go back`}),M(t,{dimColor:!0,children:`tab to switch sections`})]})]}),M(e,{marginBottom:1,children:M(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:f===`format`?`yellow`:void 0,children:f===`format`?`❯ `:` `}),M(t,{bold:!0,color:f===`format`?`yellow`:void 0,children:`Format`})]}),f===`format`&&(S?N(t,{dimColor:!0,children:[` `,`enter to save`]}):N(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:S?`yellow`:`gray`,children:M(t,{children:S?w:i})})}),M(e,{children:N(t,{children:[M(t,{color:f===`verbs`?`yellow`:void 0,children:f===`verbs`?`❯ `:` `}),M(t,{bold:!0,color:f===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),f===`verbs`&&M(e,{flexDirection:`column`,children:N(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),M(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,p-4),n=Math.min(a.length,e+8),r=Math.max(0,n-8),i=a.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return N(t,{color:f===`verbs`&&i===p?`cyan`:void 0,children:[f===`verbs`&&i===p?`❯ `:` `,e]},i)}),n<a.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),b&&N(e,{alignItems:`center`,children:[M(t,{color:`yellow`,children:`❯ `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:v})})]}),g&&N(e,{marginTop:1,alignItems:`center`,children:[M(t,{children:`Editing: `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:v})})]})]})})]}),N(e,{width:`50%`,flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,children:`Preview`})}),M(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:N(t,{children:[N(t,{color:D,children:[`✻ `,i.replace(/\{\}/g,a[p]),` `]}),M(t,{children:`(esc to interrupt)`})]})})]})]})}const Dr=[{name:`Default`,phases:K.thinkingStyle.phases,reverseMirror:K.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 Or({onBack:n}){let{settings:{thinkingStyle:{phases:i,updateInterval:a,reverseMirror:o},themes:s},updateSettings:c}=u($),l=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[f,p]=m(0),h=l[f],[g,_]=m(0),[v,y]=m(0),[b,x]=m(!1),[S,C]=m(``),[w,T]=m(!1),[E,D]=m(!1),[O,k]=m(a.toString()),[A,ee]=m(0),P=Ln(),F=(s.find(e=>e.id===P)||s.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;d(()=>{if(i.length>0){let e=o?[...i,...[...i].reverse().slice(1,-1)]:i,t=setInterval(()=>{ee(t=>(t+1)%e.length)},a);return()=>clearInterval(t)}},[i,a,o]),r((e,t)=>{if(E){if(t.return){let e=parseInt(O);!isNaN(e)&&e>0&&c(t=>{t.thinkingStyle.updateInterval=e}),D(!1)}else t.escape?(k(a.toString()),D(!1)):t.backspace||t.delete?k(e=>e.slice(0,-1)):e&&e.match(/^[0-9]$/)&&k(t=>t+e);return}if(b||w){if(t.return&&S.length){let e=w?[...i,S]:i.map((e,t)=>t===g?S:e);c(t=>{t.thinkingStyle.phases=e}),x(!1),C(``)}else t.escape?(C(``),x(!1),T(!1)):t.backspace||t.delete?C(e=>e.slice(0,-1)):e&&C(t=>t+e);return}if(t.escape)n();else if(t.return)if(h===`updateInterval`)k(a.toString()),D(!0);else if(h===`presets`){let e=Dr[v];c(t=>{t.thinkingStyle.phases=[...e.phases],t.thinkingStyle.reverseMirror=e.reverseMirror})}else h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(t.tab)t.shift?p(e=>e===0?l.length-1:e-1):p(e=>e===l.length-1?0:e+1);else if(t.upArrow)h===`phases`&&i.length>0?_(e=>e>0?e-1:i.length-1):h===`presets`&&y(e=>e>0?e-1:Dr.length-1);else if(t.downArrow)h===`phases`&&i.length>0?_(e=>e<i.length-1?e+1:0):h===`presets`&&y(e=>e<Dr.length-1?e+1:0);else if(e===` `)h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(e===`e`&&h===`phases`)i.length>0&&(C(i[g]),x(!0));else if(e===`a`&&h===`phases`)T(!0),C(``);else if(e===`d`&&h===`phases`)i.length>1&&(c(e=>{e.thinkingStyle.phases=i.filter((e,t)=>t!==g)}),g>=i.length&&_(Math.max(0,i.length-1)));else if(e===`w`&&h===`phases`){if(g>0){let e=[...i];[e[g-1],e[g]]=[e[g],e[g-1]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e-1)}}else if(e===`s`&&h===`phases`){if(g<i.length-1){let e=[...i];[e[g],e[g+1]]=[e[g+1],e[g]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e+1)}}else t.ctrl&&e===`r`&&(c(e=>{e.thinkingStyle=K.thinkingStyle}),_(0),y(0))});let te=o?`●`:`○`,I=(()=>o?[...i,...[...i].reverse().slice(1,-1)]:i)(),ne=I.length>0?I[A]:`·`;return M(e,{children:N(e,{flexDirection:`column`,width:`100%`,children:[N(e,{flexDirection:`row`,width:`100%`,children:[N(e,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[M(X,{children:`Thinking style`}),N(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:[`enter to`,` `,h===`updateInterval`?`edit interval`:h===`presets`?`apply preset`:`save`]}),M(t,{dimColor:!0,children:`esc to go back`}),M(t,{dimColor:!0,children:`tab to switch sections`})]})]}),N(e,{width:`50%`,flexDirection:`column`,children:[M(e,{children:M(t,{bold:!0,children:`Preview`})}),N(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[M(e,{width:(ne?.length??0)+1,children:M(t,{color:F,children:ne})}),N(t,{children:[M(t,{color:F,children:`Thinking… `}),M(t,{children:`(esc to interrupt)`})]})]})]})]}),N(e,{flexDirection:`row`,gap:4,children:[N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:h===`reverseMirror`?`yellow`:void 0,children:h===`reverseMirror`?`❯ `:` `}),M(t,{bold:!0,color:h===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),h===`reverseMirror`&&N(t,{dimColor:!0,children:[` `,`space to toggle`]}),M(e,{marginLeft:2,marginBottom:1,children:N(t,{children:[te,` `,o?`Enabled`:`Disabled`]})})]}),N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:h===`updateInterval`?`yellow`:void 0,children:h===`updateInterval`?`❯ `:` `}),M(t,{bold:!0,color:h===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),h===`updateInterval`&&(E?N(t,{dimColor:!0,children:[` `,`enter to save`]}):N(t,{dimColor:!0,children:[` `,`enter to edit`]})),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:M(t,{children:E?O:a})})})]})]}),M(e,{children:N(t,{children:[M(t,{color:h===`phases`?`yellow`:void 0,children:h===`phases`?`❯ `:` `}),M(t,{bold:!0,color:h===`phases`?`yellow`:void 0,children:`Phases`})]})}),h===`phases`&&M(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),M(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,g-4),n=Math.min(i.length,e+8),r=Math.max(0,n-8),a=i.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return N(t,{color:h===`phases`&&i===g?`cyan`:void 0,children:[h===`phases`&&i===g?`❯ `:` `,e]},i)}),n<i.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),w&&N(e,{children:[M(t,{color:`yellow`,children:`❯ `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:S})})]}),b&&N(e,{marginTop:1,children:[M(t,{children:`Editing: `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:S})})]})]})}),M(e,{children:N(t,{children:[M(t,{color:h===`presets`?`yellow`:void 0,children:h===`presets`?`❯ `:` `}),M(t,{bold:!0,color:h===`presets`?`yellow`:void 0,children:`Presets`})]})}),h===`presets`&&N(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,v-4),n=Math.min(Dr.length,e+8),r=Math.max(0,n-8),i=Dr.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return N(t,{color:h===`presets`&&i===v?`cyan`:void 0,children:[h===`presets`&&i===v?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<Dr.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,Dr.length-n,` more below`]})]})})()})}),M(e,{marginTop:1,children:M(t,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function kr(e,t){let n=p(!0);d(()=>{if(n.current){n.current=!1;return}return e()},t)}const Ar=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],jr=[{label:`none`,value:`none`},{label:`single`,value:`single`},{label:`double`,value:`double`},{label:`round`,value:`round`},{label:`bold`,value:`bold`},{label:`singleDouble`,value:`singleDouble`},{label:`doubleSingle`,value:`doubleSingle`},{label:`classic`,value:`classic`},{label:`topBottomSingle`,value:`topBottomSingle`},{label:`topBottomDouble`,value:`topBottomDouble`},{label:`topBottomBold`,value:`topBottomBold`}];function Mr({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(!1),[c,l]=m(!1),[d,f]=m(!1),[p,h]=m(()=>i.userMessageDisplay.format),[g,_]=m(()=>String(i.userMessageDisplay.paddingX)),[v,y]=m(()=>String(i.userMessageDisplay.paddingY)),[b,x]=m(i.userMessageDisplay.fitBoxToContent),[S,C]=m(0),[w,T]=m(()=>[...i.userMessageDisplay.styling]),[E,D]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[O,k]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:i.userMessageDisplay.foregroundColor),[A,ee]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[j,P]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[F,te]=m(()=>jr.findIndex(e=>e.value===i.userMessageDisplay.borderStyle)),[I,ne]=m(()=>i.userMessageDisplay.borderColor),[L,re]=m(null),[ie,ae]=m(``),oe=Ln(),R=i.themes?.find(e=>e.id===oe)||i.themes?.[0],[z,se]=m(`text`),ce=[`format`,`styling`,`foreground`,`background`],le=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[ue,de]=m(0),[fe,pe]=m(0),B=z===`text`?ce[ue]:le[fe],me=()=>{a(e=>{e.userMessageDisplay.format=p,e.userMessageDisplay.styling=[...w],e.userMessageDisplay.foregroundColor=E===`default`?`default`:O,e.userMessageDisplay.backgroundColor=A===`none`?null:A===`default`?`default`:j,e.userMessageDisplay.borderStyle=jr[F].value,e.userMessageDisplay.borderColor=I,e.userMessageDisplay.paddingX=parseInt(g)||0,e.userMessageDisplay.paddingY=parseInt(v)||0,e.userMessageDisplay.fitBoxToContent=b})},he=()=>{h(K.userMessageDisplay.format),T([...K.userMessageDisplay.styling]),D(`default`),k(`rgb(255,255,255)`),ee(`none`),P(`rgb(0,0,0)`),te(jr.findIndex(e=>e.value===K.userMessageDisplay.borderStyle)),ne(K.userMessageDisplay.borderColor),_(String(K.userMessageDisplay.paddingX)),y(String(K.userMessageDisplay.paddingY)),x(K.userMessageDisplay.fitBoxToContent),a(e=>{e.userMessageDisplay={...K.userMessageDisplay}})};kr(()=>{me()},[p,w,E,O,A,j,F,I,g,v,b]),r((e,t)=>{if(o){t.return?s(!1):t.escape?(h(i.userMessageDisplay.format),s(!1)):t.backspace||t.delete?h(e=>e.slice(0,-1)):e&&h(t=>t+e);return}if(c){t.return?l(!1):t.escape?(_(String(i.userMessageDisplay.paddingX)),l(!1)):t.backspace||t.delete?_(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&_(t=>t+e);return}if(d){t.return?f(!1):t.escape?(y(String(i.userMessageDisplay.paddingY)),f(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&y(t=>t+e);return}if(L===null){if(t.escape)n();else if(t.ctrl&&e===`r`)he();else if(t.leftArrow||t.rightArrow)se(e=>e===`text`?`border`:`text`);else if(t.tab)z===`text`?t.shift?de(e=>e===0?ce.length-1:e-1):de(e=>e===ce.length-1?0:e+1):t.shift?pe(e=>e===0?le.length-1:e-1):pe(e=>e===le.length-1?0:e+1);else if(t.return)B===`format`?s(!0):B===`paddingX`?l(!0):B===`paddingY`?f(!0):B===`foreground`?E===`custom`&&(ae(O),re(`foreground`)):B===`background`?A===`custom`&&(ae(j),re(`background`)):B===`borderColor`&&(ae(I),re(`border`));else if(t.upArrow)B===`styling`?C(e=>Math.max(0,e-1)):B===`borderStyle`?te(e=>e===0?jr.length-1:e-1):B===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):B===`background`&&ee(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!j||j===``)&&P(`rgb(0,0,0)`),t});else if(t.downArrow)B===`styling`?C(e=>Math.min(Ar.length-1,e+1)):B===`borderStyle`?te(e=>e===jr.length-1?0:e+1):B===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):B===`background`&&ee(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!j||j===``)&&P(`rgb(0,0,0)`),t});else if(e===` `)if(B===`styling`){let e=Ar[S].value;T(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else B===`fitBoxToContent`&&x(e=>!e)}});let ge=n=>{let r=E===`default`?R?.colors?.text:O,i=A===`none`?void 0:A===`default`?R?.colors?.userMessageBackground:j,a=jr[F].value,o=parseInt(g)||0,s=parseInt(v)||0,c=M(t,{bold:w.includes(`bold`),italic:w.includes(`italic`),underline:w.includes(`underline`),strikethrough:w.includes(`strikethrough`),inverse:w.includes(`inverse`),color:r,backgroundColor:i,children:n});if(a===`topBottomSingle`||a===`topBottomDouble`||a===`topBottomBold`){let r=a===`topBottomSingle`?`─`:a===`topBottomDouble`?`═`:`━`,i=n.length+o*2,l=r.repeat(i);return N(e,{flexDirection:`column`,children:[M(t,{color:I,children:l}),s>0&&M(e,{height:s}),M(e,{paddingX:o,children:c}),s>0&&M(e,{height:s}),M(t,{color:I,children:l})]})}else if(a!==`none`||o>0||s>0||b){let t=o>0||s>0?M(e,{paddingX:o,paddingY:s,children:c}):c,n={};return a!==`none`&&(n.borderStyle=a,n.borderColor=I),b?n.alignSelf=`flex-start`:n.flexGrow=1,a===`none`?t:M(e,{...n,children:t})}else return c};return L?M(br,{initialValue:ie,theme:R,onColorChange:e=>{L===`foreground`?k(e):L===`background`?P(e):L===`border`&&ne(e)},onExit:()=>{re(null),ae(``)}}):N(e,{flexDirection:`column`,children:[M(X,{children:`Customize how user messages are displayed`}),N(e,{flexDirection:`column`,marginBottom:1,children:[M(t,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),M(t,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),N(e,{flexDirection:`row`,gap:1,children:[N(e,{flexDirection:`column`,width:`50%`,borderStyle:z===`text`?`round`:`single`,borderColor:z===`text`?`yellow`:`gray`,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,color:z===`text`?`yellow`:void 0,children:`Text & Styling`})}),M(e,{children:N(t,{color:B===`format`?`yellow`:void 0,bold:B===`format`,children:[B===`format`?`❯ `:` `,`Format String`]})}),B===`format`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:o?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:o?`yellow`:`gray`,children:M(t,{children:p})})}),M(e,{children:N(t,{color:B===`styling`?`yellow`:void 0,bold:B===`styling`,children:[B===`styling`?`❯ `:` `,`Styling`]})}),B===`styling`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),M(e,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Ar.map((n,r)=>M(e,{children:N(t,{color:B===`styling`&&S===r?`cyan`:void 0,children:[B===`styling`&&S===r?`❯ `:` `,w.includes(n.value)?`●`:`○`,` `,n.label]})},n.value))}),N(e,{flexDirection:`row`,gap:1,marginBottom:1,children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(t,{color:B===`foreground`?`yellow`:void 0,bold:B===`foreground`,children:[B===`foreground`?`❯ `:` `,`Foreground`]})}),B===`foreground`&&M(e,{marginLeft:2,children:N(t,{dimColor:!0,children:[`up/down · `,E===`custom`?`enter`:``]})}),N(e,{marginLeft:2,flexDirection:`column`,children:[M(e,{children:N(t,{children:[E===`default`?`● `:`○ `,`Default`]})}),M(e,{children:N(t,{children:[E===`custom`?`● `:`○ `,`Custom`,E===`custom`&&`: `,E===`custom`&&M(t,{color:O,children:O})]})})]})]}),N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(t,{color:B===`background`?`yellow`:void 0,bold:B===`background`,children:[B===`background`?`❯ `:` `,`Background`]})}),B===`background`&&M(e,{marginLeft:2,children:N(t,{dimColor:!0,children:[`up/down · `,A===`custom`?`enter`:``]})}),N(e,{marginLeft:2,flexDirection:`column`,children:[M(e,{children:N(t,{children:[A===`default`?`● `:`○ `,`Default`]})}),M(e,{children:N(t,{children:[A===`none`?`● `:`○ `,`None`]})}),M(e,{children:N(t,{children:[A===`custom`?`● `:`○ `,`Custom`,A===`custom`&&`: `,A===`custom`&&M(t,{backgroundColor:j,children:j})]})})]})]})]})]}),N(e,{flexDirection:`column`,width:`50%`,borderStyle:z===`border`?`round`:`single`,borderColor:z===`border`?`yellow`:`gray`,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,color:z===`border`?`yellow`:void 0,children:`Border & Padding`})}),M(e,{children:N(t,{color:B===`borderStyle`?`yellow`:void 0,bold:B===`borderStyle`,children:[B===`borderStyle`?`❯ `:` `,`Border Style`]})}),B===`borderStyle`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`up/down to navigate`})}),N(e,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[M(e,{flexDirection:`column`,width:`50%`,children:jr.slice(0,6).map((n,r)=>M(e,{children:N(t,{color:B===`borderStyle`&&F===r?`cyan`:void 0,children:[B===`borderStyle`&&F===r?`❯ `:` `,F===r?`● `:`○ `,n.label]})},n.value))}),M(e,{flexDirection:`column`,width:`50%`,children:jr.slice(6).map((n,r)=>{let i=r+6;return M(e,{children:N(t,{color:B===`borderStyle`&&F===i?`cyan`:void 0,children:[B===`borderStyle`&&F===i?`❯ `:` `,F===i?`● `:`○ `,n.label]})},n.value)})})]}),M(e,{children:N(t,{color:B===`borderColor`?`yellow`:void 0,bold:B===`borderColor`,children:[B===`borderColor`?`❯ `:` `,`Border Color`]})}),B===`borderColor`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`enter to pick color`})}),M(e,{marginLeft:2,marginBottom:1,children:M(t,{color:I,children:I})}),N(e,{flexDirection:`row`,gap:1,children:[N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`paddingX`?`yellow`:void 0,bold:B===`paddingX`,children:[B===`paddingX`?`❯ `:` `,`Padding X`]})}),B===`paddingX`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:c?`enter/esc`:`enter`})}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:c?`yellow`:`gray`,children:M(t,{children:g})})})]}),N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`paddingY`?`yellow`:void 0,bold:B===`paddingY`,children:[B===`paddingY`?`❯ `:` `,`Padding Y`]})}),B===`paddingY`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:d?`enter/esc`:`enter`})}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:d?`yellow`:`gray`,children:M(t,{children:v})})})]}),N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`fitBoxToContent`?`yellow`:void 0,bold:B===`fitBoxToContent`,children:[B===`fitBoxToContent`?`❯ `:` `,b?`●`:`○`,` Fit box to content`]})}),B===`fitBoxToContent`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`space`})})]})]})]})]}),N(e,{flexDirection:`column`,marginTop:1,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,children:`Preview`})}),N(e,{flexDirection:`row`,gap:2,children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{marginBottom:1,children:M(t,{underline:!0,children:`Before (Claude Code default):`})}),M(e,{marginLeft:1,children:N(t,{backgroundColor:R?.colors?.userMessageBackground,color:R?.colors?.text,children:[` `,`> list the dir`,` `]})}),M(e,{marginLeft:1,marginTop:1,children:N(t,{children:[M(t,{color:R?.colors?.inactive||`#888888`,children:`●`}),M(t,{children:` The directory `}),M(t,{color:R?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),M(t,{children:` contains `}),M(t,{bold:!0,children:`123`}),M(t,{children:` files.`})]})})]}),N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{marginBottom:1,children:M(t,{underline:!0,children:`After (Your customization):`})}),M(e,{marginLeft:1,flexDirection:`row`,children:(()=>ge(p.replace(/\{\}/g,`list the dir`)))()}),M(e,{marginLeft:1,marginTop:1,children:N(t,{children:[M(t,{color:R?.colors?.inactive||`#888888`,children:`●`}),M(t,{children:` The directory `}),M(t,{color:R?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),M(t,{children:` contains `}),M(t,{bold:!0,children:`123`}),M(t,{children:` files.`})]})})]})]})]})]})}function Nr({onSubmit:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(0),c={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEditPrompt:!1,hideStartupClawd:!1,increaseFileReadLimit:!1},l=()=>{i.misc||={...c}},d=f(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>i.inputBox?.removeBorder??!1,toggle:()=>{a(e=>{e.inputBox||={removeBorder:!1},e.inputBox.removeBorder=!e.inputBox.removeBorder})}},{id:`showVersion`,title:`Show tweakcc version at startup`,description:`Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.`,getValue:()=>i.misc?.showTweakccVersion??!0,toggle:()=>{a(e=>{l(),e.misc.showTweakccVersion=!e.misc.showTweakccVersion})}},{id:`showPatches`,title:`Show patches applied indicator at startup`,description:`Shows the green "tweakcc patches are applied" indicator when starting Claude Code.`,getValue:()=>i.misc?.showPatchesApplied??!0,toggle:()=>{a(e=>{l(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>i.misc?.expandThinkingBlocks??!0,toggle:()=>{a(e=>{l(),e.misc.expandThinkingBlocks=!e.misc.expandThinkingBlocks})}},{id:`conversationTitle`,title:`Allow renaming sessions via /title`,description:`Enables /title and /rename commands for manually naming conversations.`,getValue:()=>i.misc?.enableConversationTitle??!0,toggle:()=>{a(e=>{l(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>i.misc?.hideStartupBanner??!1,toggle:()=>{a(e=>{l(),e.misc.hideStartupBanner=!e.misc.hideStartupBanner})}},{id:`hideCtrlG`,title:`Hide ctrl-g to edit prompt hint`,description:`Hides the "ctrl-g to edit prompt" hint shown during streaming.`,getValue:()=>i.misc?.hideCtrlGToEditPrompt??!1,toggle:()=>{a(e=>{l(),e.misc.hideCtrlGToEditPrompt=!e.misc.hideCtrlGToEditPrompt})}},{id:`hideClawd`,title:`Hide startup Clawd ASCII art`,description:`Hides the Clawd ASCII art character shown at startup.`,getValue:()=>i.misc?.hideStartupClawd??!1,toggle:()=>{a(e=>{l(),e.misc.hideStartupClawd=!e.misc.hideStartupClawd})}},{id:`increaseFileReadLimit`,title:`Increase file read token limit`,description:`Increases the maximum file read limit from 25,000 to 1,000,000 tokens.`,getValue:()=>i.misc?.increaseFileReadLimit??!1,toggle:()=>{a(e=>{l(),e.misc.increaseFileReadLimit=!e.misc.increaseFileReadLimit})}}],[i,a]),p=d.length,h=p-1,g=f(()=>o<4?0:Math.min(o-4+1,p-4),[o,p]),_=d.slice(g,g+4),v=g>0,y=g+4<p;return r((e,t)=>{t.return||t.escape?n():t.upArrow?s(e=>Math.max(0,e-1)):t.downArrow?s(e=>Math.min(h,e+1)):e===` `&&d[o]?.toggle()}),N(e,{flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(X,{children:`Miscellaneous Settings`})}),M(e,{marginBottom:1,children:M(t,{dimColor:!0,children:`Various tweaks and customizations. Press space to toggle settings, enter to go back.`})}),v&&M(e,{children:N(t,{dimColor:!0,children:[` ↑ `,g,` more above`]})}),_.map((n,r)=>{let i=g+r===o,a=n.getValue()?`☑`:`☐`;return N(e,{flexDirection:`column`,children:[M(e,{children:N(t,{children:[M(t,{color:i?`cyan`:void 0,children:i?`❯ `:` `}),M(t,{bold:!0,color:i?`cyan`:void 0,children:n.title})]})}),M(e,{children:N(t,{dimColor:!0,children:[` `,n.description]})}),M(e,{marginLeft:4,marginBottom:1,children:N(t,{children:[a,` `,n.getValue()?`Enabled`:`Disabled`]})})]},n.id)}),y&&M(e,{children:N(t,{dimColor:!0,children:[` `,`↓ `,p-g-4,` more below`]})}),M(e,{marginTop:1,children:N(t,{dimColor:!0,children:[`Item `,o+1,` of `,p]})})]})}const Pr=[`Task`,`Bash`,`Glob`,`Grep`,`Read`,`Edit`,`Write`,`NotebookEdit`,`WebFetch`,`WebSearch`,`BashOutput`,`KillShell`,`TodoWrite`,`AskUserQuestion`,`Skill`,`SlashCommand`,`EnterPlanMode`,`ExitPlanMode`,`LSP`];function Fr({toolsetIndex:n,onBack:i}){let{settings:a,updateSettings:o}=u($),s=a.toolsets[n],[c,l]=m(s?.name||`New Toolset`),[f,p]=m(s?.allowedTools||[]),[h,g]=m(!1),[_,v]=m(0);d(()=>{s&&o(e=>{let t=e.toolsets[n].name;e.toolsets[n].name=c,e.toolsets[n].allowedTools=f,t!==c&&(e.defaultToolset===t&&(e.defaultToolset=c),e.planModeToolset===t&&(e.planModeToolset=c))})},[c,f]);let y=e=>f===`*`?!0:f.includes(e),b=e=>{e===`All`?p(`*`):e===`None`?p([]):f===`*`?p(Pr.filter(t=>t!==e)):f.includes(e)?p(f.filter(t=>t!==e)):p([...f,e])};if(r((e,t)=>{if(h){t.return?g(!1):t.escape?(l(s?.name||`New Toolset`),g(!1)):t.backspace||t.delete?l(e=>e.slice(0,-1)):e&&e.length===1&&l(t=>t+e);return}if(t.escape)i();else if(t.upArrow)v(e=>Math.max(0,e-1));else if(t.downArrow)v(e=>Math.min(Pr.length+1,e+1));else if(e===` `||t.return)if(_===0)b(`All`);else if(_===1)b(`None`);else{let e=Pr[_-2];e&&b(e)}else e===`n`&&g(!0)}),!s)return M(e,{flexDirection:`column`,children:M(t,{color:`red`,children:`Toolset not found`})});let x=f===`*`,S=Array.isArray(f)&&f.length===0;return N(e,{flexDirection:`column`,children:[M(X,{children:`Edit Toolset`}),M(e,{marginBottom:1,flexDirection:`column`,children:M(t,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{bold:!0,children:`Name:`}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:h?`yellow`:`gray`,children:M(t,{children:c})})}),h&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{bold:!0,children:`Allowed Tools:`}),M(e,{marginLeft:2,children:N(t,{color:_===0?`cyan`:void 0,children:[_===0?`❯ `:` `,x?`●`:`○`,` All`]})}),M(e,{marginLeft:2,children:N(t,{color:_===1?`cyan`:void 0,children:[_===1?`❯ `:` `,S?`●`:`○`,` None`]})}),Pr.map((n,r)=>{let i=r+2;return M(e,{marginLeft:2,children:N(t,{color:_===i?`cyan`:void 0,children:[_===i?`❯ `:` `,y(n)?`◉`:`○`,` `,n]})},n)})]}),M(e,{borderStyle:`round`,padding:1,marginTop:1,children:N(e,{flexDirection:`column`,children:[M(t,{bold:!0,children:`Summary:`}),N(t,{children:[`Name: `,M(t,{color:`cyan`,children:c})]}),N(t,{children:[`Tools:`,` `,f===`*`?M(t,{color:`green`,children:`All tools (*)`}):f.length===0?M(t,{color:`red`,children:`No tools ([])`}):N(t,{color:`yellow`,children:[f.length,` selected`]})]})]})})]})}function Ir({onBack:n}){let{settings:{toolsets:i,defaultToolset:a,planModeToolset:o,themes:s},updateSettings:c}=u($),l=Ln(),d=s.find(e=>e.id===l)||s[0],f=K.themes[0],p=d?.colors.planMode||f.colors.planMode,h=d?.colors.autoAccept||f.colors.autoAccept,[g,_]=m(0),[v,y]=m(null),[b,x]=m(!0),S=()=>{let e={name:`New Toolset`,allowedTools:[]};c(t=>{t.toolsets.push(e)}),y(i.length),x(!1)},C=e=>{let t=i[e];c(n=>{n.toolsets.splice(e,1),n.defaultToolset===t.name&&(n.defaultToolset=null),n.planModeToolset===t.name&&(n.planModeToolset=null)}),g>=i.length-1&&_(Math.max(0,i.length-2))},w=e=>{let t=i[e];c(e=>{e.defaultToolset=t.name})},T=e=>{let t=i[e];c(e=>{e.planModeToolset=t.name})};if(r((e,t)=>{t.escape?n():t.upArrow?_(e=>Math.max(0,e-1)):t.downArrow?_(e=>Math.min(i.length-1,e+1)):t.return&&i.length>0?(y(g),x(!1)):e===`n`?S():e===`x`&&i.length>0?C(g):e===`d`&&i.length>0?w(g):e===`p`&&i.length>0&&T(g)},{isActive:b}),v!==null)return M(Fr,{toolsetIndex:v,onBack:()=>{y(null),x(!0)}});let E=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return N(e,{flexDirection:`column`,children:[M(X,{children:`Toolsets`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new toolset`}),i.length>0&&M(t,{dimColor:!0,children:`d to set as default toolset`}),i.length>0&&M(t,{dimColor:!0,children:`p to set as plan mode toolset`}),i.length>0&&M(t,{dimColor:!0,children:`x to delete a toolset`}),i.length>0&&M(t,{dimColor:!0,children:`enter to edit toolset`}),M(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?M(t,{children:`No toolsets created yet. Press n to create one.`}):M(e,{flexDirection:`column`,children:i.map((n,r)=>{let i=n.name===a,s=n.name===o,c=g===r,l;return c&&(l=`yellow`),N(e,{flexDirection:`row`,children:[N(t,{color:l,children:[c?`❯ `:` `,n.name,` `]}),N(t,{color:l,children:[`(`,E(n),`)`]}),i&&M(t,{color:h,children:` ⏵⏵ accept edits`}),s&&M(t,{color:p,children:` ⏸ plan mode`})]},r)})})]})}const $=c({settings:K,updateSettings:e=>{},changesApplied:!1,ccVersion:``});function Lr({startupCheckInfo:t,configMigrated:n}){let[i,a]=m({settings:K,changesApplied:!1,ccVersion:``,lastModified:``}),[o,s]=m(!1);d(()=>{(async()=>{let e=await rr();a(e),s(!e.hidePiebaldAnnouncement)})()},[]);let c=l(e=>{let t=JSON.parse(JSON.stringify(i.settings));e(t),a(e=>({...e,settings:t,changesApplied:!1})),ir(e=>{e.settings=t,e.changesApplied=!1})},[i.settings]),[u,f]=m(null),[p,h]=m(null);d(()=>{t.wasUpdated&&t.oldVersion&&(h({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
|
|
639
|
+
`)))},rr=async()=>{await b.mkdir(q,{recursive:!0}),await b.mkdir(er,{recursive:!0});let e=w.join(q,`.gitignore`);try{await b.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await b.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(_)+_)}};let ir=null;const ar=async()=>{let e={ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:K};try{W(`Reading config at ${J}`),nr();let t=await b.readFile(J,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation),n.settings.inputBox||(n.settings.inputBox=K.inputBox),n.settings.toolsets||(n.settings.toolsets=K.toolsets),Object.hasOwn(n.settings,`defaultToolset`)||(n.settings.defaultToolset=K.defaultToolset),Object.hasOwn(n.settings,`planModeToolset`)||(n.settings.planModeToolset=K.planModeToolset);for(let e of K.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))n!==`colors`&&!Object.hasOwn(t,n)&&(t[n]=r);t.colors||={};for(let[n,r]of Object.entries(e.colors))Object.hasOwn(t.colors,n)||(t.colors[n]=r)}}for(let e of n?.settings?.themes||[]){if(K.themes.some(t=>t.id===e.id||t.name===e.name))continue;let t=K.themes[0];e.colors||={};for(let[n,r]of Object.entries(t.colors))Object.hasOwn(e.colors,n)||(e.colors[n]=r)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||K,n.settings.userMessageDisplay=K.userMessageDisplay),Zn(n),delete n.settings.launchText,await Xe(er)&&(n.changesApplied=!1),ir=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},or=async e=>(W(`Updating config at ${J}`),ir||=await ar(),e(ir),ir.lastModified=new Date().toISOString(),await sr(ir),ir),sr=async e=>{try{e.lastModified=new Date().toISOString(),await rr(),await b.writeFile(J,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}};var X=({children:e,...n})=>N(t,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...n,children:[` `,e,` `]});const cr=[`\x1B[?25l\x1B[0m \x1B[38;2;0;0;0m \x1B[38;2;252;130;0m▂\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▇\x1B[38;2;254;131;0m\x1B[48;2;252;130;0m▇\x1B[48;2;252;130;0m▇▇\x1B[48;2;252;130;0m▇\x1B[0m\x1B[38;2;252;130;0m▇\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▂ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;254;131;0m▗\x1B[38;2;254;131;0m▆\x1B[48;2;254;131;0m \x1B[38;2;254;132;0m╶ \x1B[0m\x1B[38;2;254;131;0m▆\x1B[38;2;254;131;0m▖ \x1B[0m`,` \x1B[7m\x1B[38;2;254;131;0m▘\x1B[0m\x1B[38;2;11;6;0m\x1B[48;2;254;131;0m \x1B[38;2;254;216;182m\x1B[48;2;254;136;12m▃\x1B[38;2;254;249;246m\x1B[48;2;254;143;29m▅\x1B[38;2;254;253;253m\x1B[48;2;254;143;40m▆\x1B[38;2;254;254;253m\x1B[48;2;254;152;68m▆▆▆\x1B[38;2;254;253;252m\x1B[48;2;254;141;34m▆\x1B[38;2;254;247;242m\x1B[48;2;254;140;24m▅\x1B[38;2;254;224;199m\x1B[48;2;254;140;20m▖\x1B[48;2;254;131;0m \x1B[0m\x1B[7m\x1B[38;2;254;131;0m▝\x1B[0m \x1B[0m`,`\x1B[7m\x1B[38;2;251;127;0m▌\x1B[0m\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[38;2;252;128;0m\x1B[48;2;254;131;0m▃\x1B[38;2;252;129;0m▂\x1B[38;2;253;130;0m▁\x1B[38;2;249;135;16m\x1B[48;2;253;226;202m▋\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┈\x1B[48;2;246;246;245m┈\x1B[38;2;47;47;47m\x1B[48;2;244;244;243m▂\x1B[38;2;112;112;112m\x1B[48;2;251;251;251m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m▁╌▝\x1B[38;2;254;254;253m\x1B[48;2;254;254;254m▋\x1B[38;2;254;254;254m\x1B[48;2;254;253;252m┈\x1B[38;2;252;209;168m\x1B[48;2;251;129;0m▍\x1B[38;2;253;129;0m\x1B[48;2;254;131;0m▂\x1B[38;2;252;128;0m▃\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[0m\x1B[38;2;251;127;0m▌\x1B[0m`,`\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▏\x1B[38;2;245;118;0m\x1B[48;2;248;122;0m▄\x1B[38;2;247;121;0m\x1B[48;2;247;122;0m┈\x1B[38;2;106;68;38m\x1B[48;2;245;123;2m▃\x1B[38;2;39;33;28m\x1B[48;2;211;109;6m▅\x1B[38;2;27;20;12m\x1B[48;2;237;237;237m▌\x1B[48;2;254;254;253m \x1B[38;2;90;90;89m\x1B[48;2;231;230;230m▝\x1B[38;2;215;215;214m\x1B[48;2;48;48;48m▁\x1B[38;2;203;203;202m\x1B[48;2;42;42;42m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┇╴\x1B[38;2;253;252;252m▂\x1B[38;2;251;250;250m\x1B[48;2;253;253;253m▃\x1B[38;2;249;249;248m\x1B[48;2;252;252;251m▄\x1B[38;2;249;248;248m\x1B[48;2;237;118;0m▍\x1B[38;2;246;121;0m\x1B[48;2;250;125;0m▄\x1B[38;2;246;119;0m\x1B[48;2;249;124;0m▄\x1B[38;2;245;118;0m\x1B[48;2;248;123;0m▄\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▉\x1B[0m`,`\x1B[38;2;238;108;0m\x1B[48;2;237;109;0m▏\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;233;109;2m\x1B[48;2;125;73;29m▇\x1B[38;2;225;104;1m\x1B[48;2;50;32;18m▄\x1B[38;2;62;29;2m\x1B[48;2;239;237;237m▌\x1B[38;2;254;253;253m\x1B[48;2;254;254;254m┻\x1B[38;2;254;254;253m▊\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;253;253;252m▂\x1B[38;2;251;251;251m\x1B[48;2;254;253;253m▃\x1B[38;2;249;249;249m\x1B[48;2;252;252;252m▄\x1B[38;2;247;247;247m\x1B[48;2;250;250;250m▄\x1B[38;2;245;245;244m\x1B[48;2;248;248;248m▄\x1B[38;2;243;243;242m\x1B[48;2;246;246;245m▄\x1B[38;2;243;242;242m\x1B[48;2;230;109;0m▍\x1B[38;2;239;111;0m\x1B[48;2;243;116;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;237;108;0m\x1B[48;2;238;108;0m▉\x1B[0m`,`\x1B[7m\x1B[38;2;231;98;0m▌\x1B[0m\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[38;2;231;99;0m\x1B[48;2;235;105;0m▄\x1B[38;2;232;100;0m\x1B[48;2;236;105;0m▄\x1B[38;2;232;101;0m\x1B[48;2;236;106;0m▄\x1B[38;2;223;99;0m\x1B[48;2;247;238;235m▌\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;252;252;251m▃\x1B[38;2;250;250;250m\x1B[48;2;253;253;252m▄\x1B[38;2;248;248;247m\x1B[48;2;251;251;250m▄\x1B[38;2;246;245;245m\x1B[48;2;249;248;248m▄\x1B[38;2;243;243;243m\x1B[48;2;246;246;246m▄\x1B[38;2;241;241;241m\x1B[48;2;244;244;244m▄\x1B[38;2;239;239;238m\x1B[48;2;242;242;242m▄\x1B[38;2;237;237;236m\x1B[48;2;240;240;239m▄\x1B[38;2;237;236;236m\x1B[48;2;223;99;0m▍\x1B[38;2;232;100;0m\x1B[48;2;236;106;0m▄\x1B[38;2;231;100;0m\x1B[48;2;235;105;0m▄\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[0m\x1B[38;2;231;98;0m▌\x1B[0m`,` \x1B[7m\x1B[38;2;224;89;0m▖\x1B[0m\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[38;2;225;90;0m\x1B[48;2;228;95;0m▄\x1B[38;2;225;91;0m\x1B[48;2;229;96;0m▄\x1B[38;2;217;90;1m\x1B[48;2;97;77;70m▌\x1B[38;2;70;70;70m\x1B[48;2;207;207;207m▆\x1B[38;2;66;65;65m\x1B[48;2;228;228;227m▄\x1B[38;2;66;66;66m\x1B[48;2;233;232;232m▂\x1B[38;2;169;169;169m\x1B[48;2;243;243;243m▁\x1B[38;2;240;239;239m\x1B[48;2;243;242;242m▄\x1B[38;2;238;237;237m\x1B[48;2;241;240;240m▄\x1B[38;2;235;235;235m\x1B[48;2;238;238;238m▄\x1B[38;2;233;233;233m\x1B[48;2;236;236;236m▄\x1B[38;2;231;231;230m\x1B[48;2;234;234;233m▄\x1B[38;2;231;230;230m\x1B[48;2;216;89;0m▍\x1B[38;2;225;90;0m\x1B[48;2;229;95;0m▄\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[0m\x1B[7m\x1B[38;2;224;89;0m▗\x1B[0m \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;217;80;0m▝\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m\x1B[48;2;221;86;0m▄\x1B[38;2;197;78;9m\x1B[48;2;66;66;65m▋\x1B[38;2;65;65;64m\x1B[48;2;60;60;60m▘\x1B[38;2;52;52;51m\x1B[48;2;56;56;56m▗\x1B[38;2;45;45;45m\x1B[48;2;50;50;49m▗\x1B[38;2;42;42;42m\x1B[48;2;46;46;46m┈\x1B[38;2;41;41;41m\x1B[48;2;203;202;202m▆\x1B[38;2;38;38;38m\x1B[48;2;218;218;218m▄\x1B[38;2;45;45;45m\x1B[48;2;221;221;221m▂\x1B[38;2;229;229;229m┊\x1B[38;2;225;225;225m\x1B[48;2;228;228;227m▄\x1B[38;2;225;224;224m\x1B[48;2;209;79;0m▍\x1B[0m\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m▘ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[7m\x1B[38;2;191;73;0m▆\x1B[38;2;191;73;0m▄\x1B[38;2;56;55;55m▃\x1B[38;2;46;46;46m▁\x1B[0m\x1B[38;2;20;20;20m\x1B[48;2;42;42;42m▁\x1B[38;2;36;36;36m\x1B[48;2;35;34;34m╴\x1B[38;2;23;23;23m\x1B[48;2;29;29;28m▁\x1B[38;2;10;10;10m\x1B[48;2;22;22;22m▁\x1B[0m\x1B[7m\x1B[38;2;15;15;15m▁\x1B[38;2;22;22;21m▃\x1B[38;2;154;154;154m▅\x1B[38;2;175;116;83m▇\x1B[0m\x1B[38;2;17;15;14m \x1B[0m`,`\x1B[?25h\x1B[0m`];var lr=()=>N(e,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[N(e,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[M(t,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),M(t,{children:` `}),N(t,{children:[`We've released `,M(t,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),N(t,{children:[`Download it and try it out for free!`,` `,M(v,{url:`https://piebald.ai/`,fallback:!1,children:M(t,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),M(t,{children:` `}),M(t,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),M(e,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:cr.map((e,n)=>M(t,{children:e},n))})]});let Z=function(e){return e.APPLY_CHANGES=`*Apply customizations`,e.THEMES=`Themes`,e.THINKING_VERBS=`Thinking verbs`,e.THINKING_STYLE=`Thinking style`,e.USER_MESSAGE_DISPLAY=`User message display`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.VIEW_SYSTEM_PROMPTS=`View system prompts`,e.RESTORE_ORIGINAL=`Restore original Claude Code (preserves config.json)`,e.OPEN_CONFIG=`Open config.json`,e.OPEN_CLI=`Open Claude Code's cli.js`,e.EXIT=`Exit`,e}({});function ur({items:n,selectedIndex:i,onSelect:a,onSubmit:o}){return r((e,t)=>{t.upArrow?a(i>0?i-1:n.length-1):t.downArrow?a(i<n.length-1?i+1:0):t.return&&o(n[i].name)}),M(e,{flexDirection:`column`,children:n.map((n,r)=>M(e,{children:N(t,{children:[N(t,{bold:r===i,color:r===i?`cyan`:void 0,...r===i?n.selectedStyles??{}:n.styles??{},children:[r===i?`❯ `:` `,n.name]}),n.desc&&r===i&&N(t,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,n.desc]})]})},r))})}const dr=[{name:Z.THEMES,desc:`Modify Claude Code's built-in themes or create your own`},{name:Z.THINKING_VERBS,desc:`Customize the list of verbs that Claude Code uses when it's working`},{name:Z.THINKING_STYLE,desc:`Choose custom spinners`},{name:Z.USER_MESSAGE_DISPLAY,desc:`Customize how user messages are displayed`},{name:Z.MISC,desc:`Miscellaneous settings (input box border, etc.)`},{name:Z.TOOLSETS,desc:`Manage toolsets to control which tools are available`},{name:Z.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],fr=[{name:Z.RESTORE_ORIGINAL,desc:`Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)`},{name:Z.OPEN_CONFIG,desc:`Opens your tweakcc config file (${J})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var pr=({onSubmit:e})=>{let t=[...u($).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:`Required: Updates Claude Code in-place with your changes`,selectedStyles:{color:`green`}}],...dr,...fr],[n,r]=m(0);return M(ur,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const mr=()=>N(e,{flexDirection:`row`,children:[M(X,{children:`tweakcc`}),M(t,{children:` (by `}),M(v,{url:`https://piebald.ai`,fallback:!1,children:M(t,{color:`#ff8400`,bold:!0,children:`Piebald`})}),M(t,{children:`)`})]}),hr=()=>M(e,{children:N(t,{color:`yellow`,children:[`⭐ `,M(t,{bold:!0,children:`Star the repo at `}),M(v,{url:`https://github.com/Piebald-AI/tweakcc`,fallback:!1,children:M(t,{bold:!0,color:`cyan`,children:`https://github.com/Piebald-AI/tweakcc`})}),M(t,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),gr=({notification:n})=>M(e,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:M(t,{color:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,children:n.message})}),_r=({onSubmit:n,notification:r,configMigrated:i,showPiebaldAnnouncement:a})=>N(e,{flexDirection:`column`,gap:1,children:[i&&M(e,{children:M(t,{color:`blue`,bold:!0,children:"Note that in tweakcc v3.2.0+, `ccInstallationDir` config is deprecated. You are now migrated to `ccInstallationPath` which supports npm and native installs."})}),M(mr,{}),M(e,{children:N(t,{children:[M(t,{bold:!0,children:`Customize your Claude Code installation.`}),` `,N(t,{dimColor:!0,children:[`Settings will be saved to `,q.replace(h.homedir(),`~`),`/config.json.`]})]})}),M(a?lr:hr,{}),r&&M(gr,{notification:r}),M(pr,{onSubmit:n})]});function Q({color:e,backgroundColor:n,bold:r,dimColor:i,children:s}){let c=e?.startsWith(`ansi:`),l=n?.startsWith(`ansi:`);if(c||l){if(o.Children.toArray(s).some(e=>o.isValidElement(e)))return M(t,{children:s});let u=a;if(c){let t=e.slice(5);u=u[t]||u}if(l){let e=n.slice(5),t=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;u=u[t]||u}r&&(u=u.bold),i&&(u=u.dim);let d=o.Children.toArray(s).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return M(t,{children:u(d)})}return M(t,{color:e,backgroundColor:n,bold:r,dimColor:i,children:s})}function vr({text:e,nonShimmerColors:n,shimmerColors:r,shimmerWidth:i=3,updateDuration:a=50,restartPoint:o=10}){let[s,c]=m(0);return d(()=>{let t=setInterval(()=>{c(t=>{let n=t+1;return n>=e.length+o?-i:n})},a);return()=>clearInterval(t)},[e.length,o,a]),n.length===r.length?M(t,{children:e.split(``).map((a,o)=>{let c=o>=s&&o<s+i&&s<e.length,l=o%n.length;return M(t,{color:c?r[l]:n[l],children:a},o)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),M(t,{children:e}))}const yr=P.cwd();function br({theme:n}){let{ccVersion:r}=u($);return N(e,{flexDirection:`column`,paddingLeft:1,children:[M(e,{marginBottom:1,children:N(t,{bold:!0,children:[`Preview: `,n.name]})}),M(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:N(e,{flexDirection:`column`,children:[N(e,{flexDirection:`column`,children:[N(t,{children:[M(Q,{color:n.colors.clawd_body,children:` ▐`}),M(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`▛███▜`}),N(t,{children:[M(Q,{color:n.colors.clawd_body,children:`▌ `}),` `,M(t,{bold:!0,children:`Claude Code`}),` `,r?`v${r}`:`v2.0.14`]})]}),N(t,{children:[M(Q,{color:n.colors.clawd_body,children:`▝▜`}),M(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`█████`}),M(Q,{color:n.colors.clawd_body,children:`▛▘`}),` `,Vn(),` · `,Bn()]}),N(Q,{color:n.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,yr]}),N(t,{children:[N(Q,{color:n.colors.success,children:[`Login successful. Press`,` `]}),M(Q,{bold:!0,color:n.colors.success,children:`Enter`}),N(Q,{color:n.colors.success,children:[` `,`to continue…`]})]})]}),M(t,{children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),N(t,{children:[`│ 2`,` `,M(Q,{backgroundColor:n.colors.diffRemoved,color:n.colors.text,children:`- console.log("`}),M(Q,{backgroundColor:n.colors.diffRemovedWord,children:`Hello, World!`}),M(Q,{backgroundColor:n.colors.diffRemoved,children:`");`}),` `,`│`]}),N(t,{children:[`│ 2`,` `,M(Q,{backgroundColor:n.colors.diffAdded,color:n.colors.text,children:`+ console.log("`}),M(Q,{backgroundColor:n.colors.diffAddedWord,children:`Hello, Claude!`}),M(Q,{backgroundColor:n.colors.diffAdded,children:`");`}),` `,`│`]}),M(Q,{color:n.colors.warning,children:`╭─────────────────────────────────────────────╮`}),N(Q,{color:n.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),N(t,{children:[M(Q,{color:n.colors.warning,children:`│ `}),M(t,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),N(Q,{color:n.colors.warning,children:[` `,`│`]})]}),M(Q,{color:n.colors.bashBorder,children:`───────────────────────────────────────────────`}),N(t,{children:[M(Q,{color:n.colors.bashBorder,children:`!`}),M(t,{children:` ls`})]}),M(Q,{color:n.colors.promptBorder,children:`───────────────────────────────────────────────`}),M(t,{children:N(t,{children:[`> list the dir`,` `,M(vr,{text:`ultrathink`,nonShimmerColors:[n.colors.rainbow_red,n.colors.rainbow_orange,n.colors.rainbow_yellow,n.colors.rainbow_green,n.colors.rainbow_blue,n.colors.rainbow_indigo,n.colors.rainbow_violet],shimmerColors:[n.colors.rainbow_red_shimmer,n.colors.rainbow_orange_shimmer,n.colors.rainbow_yellow_shimmer,n.colors.rainbow_green_shimmer,n.colors.rainbow_blue_shimmer,n.colors.rainbow_indigo_shimmer,n.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),M(Q,{color:n.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[M(Q,{color:n.colors.planMode,children:`│ `}),N(Q,{color:n.colors.permission,children:[`Ready to code?`,` `]}),M(t,{children:`Here is Claude's plan:`}),N(Q,{color:n.colors.planMode,children:[` `,`│`]})]}),M(Q,{color:n.colors.permission,children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[M(Q,{color:n.colors.permission,children:`│ `}),M(t,{bold:!0,children:`Permissions:`}),` `,N(Q,{backgroundColor:n.colors.permission,color:n.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,M(Q,{color:n.colors.permission,children:`│`})]}),M(t,{children:`> list the dir`}),N(t,{children:[M(Q,{color:n.colors.error,children:`●`}),M(t,{children:` Update(__init__.py)`})]}),N(t,{children:[M(t,{children:` ⎿ `}),M(Q,{color:n.colors.error,children:`User rejected update to __init__.py`})]}),N(t,{children:[` `,`1`,` `,N(Q,{backgroundColor:n.colors.diffRemovedDimmed,children:[`- import`,` `]}),M(Q,{backgroundColor:n.colors.diffRemovedWordDimmed,children:`os`})]}),N(t,{children:[` `,`2`,` `,N(Q,{backgroundColor:n.colors.diffAddedDimmed,children:[`+ import`,` `]}),M(Q,{backgroundColor:n.colors.diffAddedWordDimmed,children:`random`})]}),N(t,{children:[M(Q,{color:n.colors.success,children:`●`}),M(t,{children:` List(.)`})]}),N(t,{children:[M(t,{children:`●`}),M(t,{children:` The directory `}),M(Q,{color:n.colors.permission,children:`C:\\Users\\user`}),N(t,{children:[` `,`contains `,M(t,{bold:!0,children:`123`}),` files.`]})]}),N(t,{children:[M(Q,{color:n.colors.claude,children:`✻ Th`}),M(Q,{color:n.colors.claudeShimmer,children:`ink`}),M(Q,{color:n.colors.claude,children:`ing… `}),M(t,{children:`(esc to interrupt)`})]}),M(t,{children:M(Q,{color:n.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),M(t,{children:M(Q,{color:n.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),M(t,{children:M(Q,{color:n.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function xr({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?M(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?M(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):M(Q,{color:r,bold:n,children:e})}function Sr({initialValue:n,onColorChange:i,onExit:a,colorKey:o,theme:c}){let l=wr(n)||{h:0,s:50,l:50},u=Cr(n)||{r:128,g:128,b:128},[f,p]=m(l),[h,g]=m(u),[_,v]=m(`hsl`),[y,b]=m(`h`),[x,S]=m(!1),[C,w]=m(!1);d(()=>{let e=wr(n),t=Cr(n);e&&t&&(S(!0),p(e),g(t),S(!1))},[n]),d(()=>{!x&&C&&i(`rgb(${h.r},${h.g},${h.b})`)},[f,h,x,C]),d(()=>{w(!0)},[]);let T=e=>{if(Wn(e)){let t=Gn(e),n=wr(t),r=Cr(t);n&&r&&(S(!0),p(n),g(r),S(!1))}};r((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){T(e);return}t.return||t.escape?a():t.ctrl&&e===`a`?(v(e=>e===`hsl`?`rgb`:`hsl`),b(e=>_===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?b(_===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?b(_===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?E(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&E(t.shift||t.ctrl||t.meta?10:1)});let E=e=>{S(!0),_===`hsl`?p(t=>{let n={...t};y===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):y===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):y===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=O(n.h,n.s,n.l);return g({r,g:i,b:a}),n}):g(t=>{let n={...t};return y===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):y===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):y===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),p(D(n.r,n.g,n.b)),n}),S(!1)},D=(e,t,n)=>{let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===r?((i-a)/c+(i<a?6:0))/6:o===i?((a-r)/c+2)/6:((r-i)/c+4)/6),{h:Math.round(d*360),s:Math.round(u*100),l:Math.round(l*100)}},O=(e,t,n)=>{e/=360,t/=100,n/=100;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e*6%2-1)),a=n-r/2,o=0,s=0,c=0;return 0<=e&&e<1/6?(o=r,s=i,c=0):1/6<=e&&e<2/6?(o=i,s=r,c=0):2/6<=e&&e<3/6?(o=0,s=r,c=i):3/6<=e&&e<4/6?(o=0,s=i,c=r):4/6<=e&&e<5/6?(o=i,s=0,c=r):5/6<=e&&e<1&&(o=r,s=0,c=i),[Math.round((o+a)*255),Math.round((s+a)*255),Math.round((c+a)*255)]},k=()=>{let e=[],n=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let r=0;r<40;r++){let i=r/39*(n.length-1),a=Math.floor(i),o=Math.ceil(i),s=i-a,[c,l,u]=n[a],[d,f,p]=n[o],m=Math.round(c+(d-c)*s),h=Math.round(l+(f-l)*s),g=Math.round(u+(p-u)*s);e.push(M(t,{backgroundColor:`rgb(${m},${h},${g})`,children:` `},r))}return e},A=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,r,f.l);e.push(M(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},ee=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,f.s,r);e.push(M(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},P=()=>{let[e,t,n]=O(f.h,f.s,f.l);return`rgb(${e},${t},${n})`},F=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},te=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${r},${h.g},${h.b})`,children:` `},n))}return e},I=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${h.r},${r},${h.b})`,children:` `},n))}return e},ne=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${h.r},${h.g},${r})`,children:` `},n))}return e},L=(e,t)=>Math.round(e/t*39);return N(e,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[N(e,{flexDirection:`column`,children:[M(t,{bold:!0,children:`Color Picker`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),M(t,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),M(t,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),M(t,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),M(t,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),M(t,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),_===`hsl`?N(j,{children:[N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`h`?`yellow`:`white`,children:[y===`h`?`❯ `:` `,`Hue (`,f.h,`°):`]})}),M(e,{children:k().map((e,n)=>M(s,{children:n===L(f.h,360)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`s`?`yellow`:`white`,children:[y===`s`?`❯ `:` `,`Saturation (`,f.s,`%):`]})}),M(e,{children:A().map((e,n)=>M(s,{children:n===L(f.s,100)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`l`?`yellow`:`white`,children:[y===`l`?`❯ `:` `,`Lightness (`,f.l,`%):`]})}),M(e,{children:ee().map((e,n)=>M(s,{children:n===L(f.l,100)?M(t,{children:`|`}):e},n))})]})]}):N(j,{children:[N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`r`?`yellow`:`white`,children:[y===`r`?`❯ `:` `,`Red (`,h.r,`):`]})}),M(e,{children:te().map((e,n)=>M(s,{children:n===L(h.r,255)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`g`?`yellow`:`white`,children:[y===`g`?`❯ `:` `,`Green (`,h.g,`):`]})}),M(e,{children:I().map((e,n)=>M(s,{children:n===L(h.g,255)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`b`?`yellow`:`white`,children:[y===`b`?`❯ `:` `,`Blue (`,h.b,`):`]})}),M(e,{children:ne().map((e,n)=>M(s,{children:n===L(h.b,255)?M(t,{children:`|`}):e},n))})]})]}),N(e,{marginBottom:1,children:[M(t,{children:`Current: `}),M(t,{backgroundColor:P(),children:` `})]}),N(e,{flexDirection:`row`,justifyContent:`space-between`,children:[N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`Hex `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:F(h.r,h.g,h.b)}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:F(h.r,h.g,h.b)}):M(t,{color:P(),bold:!0,children:F(h.r,h.g,h.b)})]}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`RGB `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):M(t,{color:P(),bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`})]}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`HSL `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):M(t,{color:P(),bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`})]})]})]})}function Cr(e){let t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};let n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){let e=n[1];return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}return null}function wr(e){let t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){let e=parseInt(n[1])/255,t=parseInt(n[2])/255,r=parseInt(n[3])/255,i=Math.max(e,t,r),a=Math.min(e,t,r),o=i-a,s=(i+a)/2,c=0;o!==0&&(c=s>.5?o/(2-i-a):o/(i+a));let l=0;return o!==0&&(l=i===e?((t-r)/o+(t<r?6:0))/6:i===t?((r-e)/o+2)/6:((e-t)/o+4)/6),{h:Math.round(l*360),s:Math.round(c*100),l:Math.round(s*100)}}let r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){let e=r[1],t=parseInt(e.substr(0,2),16)/255,n=parseInt(e.substr(2,2),16)/255,i=parseInt(e.substr(4,2),16)/255,a=Math.max(t,n,i),o=Math.min(t,n,i),s=a-o,c=(a+o)/2,l=0;s!==0&&(l=c>.5?s/(2-a-o):s/(a+o));let u=0;return s!==0&&(u=a===t?((n-i)/s+(n<i?6:0))/6:a===n?((i-t)/s+2)/6:((t-n)/s+4)/6),{h:Math.round(u*360),s:Math.round(l*100),l:Math.round(c*100)}}return{h:0,s:50,l:50}}function Tr({onBack:n,themeId:i}){let{settings:{themes:a},updateSettings:o}=u($),[s,c]=m(i),d=a.find(e=>e.id===s)||a[0],[f,p]=m(`rgb`),[h,g]=m(0),[_,v]=m(null),[y,b]=m(null),[x,S]=m(``),[C,w]=m(``),T=l(e=>{o(t=>{let n=t.themes.findIndex(e=>e.id===s);n!==-1&&e(t.themes[n])})},[s,o]),E=e=>{if(h>=2&&Wn(e)){let t=Gn(e),n=D[h-2];T(e=>{e.colors[n]=t})}};r((e,t)=>{if(_===null&&y===null){if(e.length>1&&!t.ctrl&&!t.meta){E(e);return}if(t.escape)n();else if(t.ctrl&&e===`a`)p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(t.upArrow)g(e=>Math.max(0,e-1));else if(t.downArrow)g(e=>Math.min(D.length+1,e+1));else if(t.return)if(h===0)b(`name`),S(d.name),w(d.name);else if(h===1)b(`id`),S(d.id),w(d.id);else{let e=h-2,t=D[e],n=d.colors[t];v(e),S(n),w(n)}}else if(_!==null)t.ctrl&&e===`a`&&p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(y!==null)if(t.return){if(y===`id`){let e=s;c(x),o(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=x)})}else T(e=>{e.name=x});b(null),S(``),w(``)}else t.escape?(b(null),S(``),w(``)):t.backspace||t.delete?S(e=>e.slice(0,-1)):e&&S(t=>t+e)});let D=Object.keys(d.colors),O=(e,t)=>{let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)return e;let r=parseInt(n[1]),i=parseInt(n[2]),a=parseInt(n[3]);switch(t){case`hex`:{let e=e=>e.toString(16).padStart(2,`0`);return`#${e(r)}${e(i)}${e(a)}`}case`hsl`:{let e=r/255,t=i/255,n=a/255,o=Math.max(e,t,n),s=Math.min(e,t,n),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===e?((t-n)/c+(t<n?6:0))/6:o===t?((n-e)/c+2)/6:((e-t)/c+4)/6),`hsl(${Math.round(d*360)}, ${Math.round(u*100)}%, ${Math.round(l*100)}%)`}case`rgb`:default:return e}},k=e=>({autoAccept:`Auto-accept edits mode indicator`,bashBorder:`Bash command border`,claude:`Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.`,claudeShimmer:`Color used for the shimmering effect on the thinking verb.`,claudeBlue_FOR_SYSTEM_SPINNER:`System spinner color (blue variant)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`System spinner shimmer color (blue variant)`,permission:`Permission prompt color`,permissionShimmer:`Permission prompt shimmer color`,planMode:`Plan mode indicator`,ide:`Color used for IDE-related messages.`,promptBorder:`Input prompt border color`,promptBorderShimmer:`Input prompt border shimmer color`,text:`Code color. Used in diffs.`,inverseText:`Inverse text color. Used for the text of tabs, where the background is filled in.`,inactive:`Inactive/dimmed text. Used for line numbers and less prominent text.`,subtle:`Subtle text. Used for help text and secondary information.`,suggestion:`Suggestion text color. Used for suggestions for theme names and various other things.`,remember:`Remember/note color. Used for various text relating to memories.`,background:`Background color for certain UI elements`,success:`Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).`,error:`Error indicator`,warning:`Warning indicator`,warningShimmer:`Warning shimmer color`,diffAdded:`Added diff background`,diffRemoved:`Removed diff background`,diffAddedDimmed:`Added diff background (dimmed)`,diffRemovedDimmed:`Removed diff background (dimmed)`,diffAddedWord:`Added word highlight`,diffRemovedWord:`Removed word highlight`,diffAddedWordDimmed:`Added word highlight (dimmed)`,diffRemovedWordDimmed:`Removed word highlight (dimmed)`,red_FOR_SUBAGENTS_ONLY:`Red color for sub agents`,blue_FOR_SUBAGENTS_ONLY:`Blue color for sub agents`,green_FOR_SUBAGENTS_ONLY:`Green color for sub agents`,yellow_FOR_SUBAGENTS_ONLY:`Yellow color for sub agents`,purple_FOR_SUBAGENTS_ONLY:`Purple color for sub agents`,orange_FOR_SUBAGENTS_ONLY:`Orange color for sub agents`,pink_FOR_SUBAGENTS_ONLY:`Pink color for sub agents`,cyan_FOR_SUBAGENTS_ONLY:`Cyan color for sub agents`,professionalBlue:`Professional blue color for business contexts?`,rainbow_red:`"ultrathink" rainbow - red`,rainbow_orange:`"ultrathink" rainbow - orange`,rainbow_yellow:`"ultrathink" rainbow - yellow`,rainbow_green:`"ultrathink" rainbow - green`,rainbow_blue:`"ultrathink" rainbow - blue`,rainbow_indigo:`"ultrathink" rainbow - indigo`,rainbow_violet:`"ultrathink" rainbow - violet`,rainbow_red_shimmer:`"ultrathink" rainbow (shimmer) - red`,rainbow_orange_shimmer:`"ultrathink" rainbow (shimmer) - orange`,rainbow_yellow_shimmer:`"ultrathink" rainbow (shimmer) - yellow`,rainbow_green_shimmer:`"ultrathink" rainbow (shimmer) - green`,rainbow_blue_shimmer:`"ultrathink" rainbow (shimmer) - blue`,rainbow_indigo_shimmer:`"ultrathink" rainbow (shimmer) - indigo`,rainbow_violet_shimmer:`"ultrathink" rainbow (shimmer) - violet`,clawd_body:`"Clawd" character body color`,clawd_background:`"Clawd" character background color`,userMessageBackground:`Background color for user messages`,bashMessageBackgroundColor:`Background color for bash command output`,memoryBackgroundColor:`Background color for memory/context information`,rate_limit_fill:`Rate limit indicator fill color`,rate_limit_empty:`Rate limit indicator empty/background color`})[e]||``,A=Math.max(...D.map(e=>e.length));return N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(X,{children:[`Editing theme “`,d.name,`” (`,d.id,`)`]})}),_===null&&y===null?N(j,{children:[N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`enter to edit theme name, id, or color`}),M(t,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),M(t,{dimColor:!0,children:`paste color from clipboard (when on color)`}),M(t,{dimColor:!0,children:`esc to go back`})]}),h<2?N(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[M(t,{bold:!0,children:h===0?`Theme Name`:`Theme ID`}),M(t,{children:h===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):N(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:d.colors[D[h-2]],flexDirection:`column`,paddingLeft:1,children:[M(xr,{colorKey:D[h-2],theme:d,bold:!0}),M(t,{children:k(D[h-2])})]}),N(e,{flexDirection:`column`,children:[N(e,{children:[M(t,{color:h===0?`yellow`:`white`,children:h===0?`❯ `:` `}),M(t,{bold:!0,children:`Name: `}),M(t,{children:d.name})]}),N(e,{marginBottom:1,children:[M(t,{color:h===1?`yellow`:`white`,children:h===1?`❯ `:` `}),M(t,{bold:!0,children:`ID: `}),M(t,{children:d.id})]}),(()=>{if(h<2)return N(j,{children:[D.slice(0,20).map((n,r)=>{let i=r+2;return N(e,{children:[M(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),M(e,{width:A+2,children:M(t,{children:M(xr,{colorKey:n,theme:d,bold:!0})})}),M(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),D.length>20&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let n=h-2,r=Math.max(0,n-10),i=Math.min(D.length,r+20),a=Math.max(0,i-20),o=D.slice(a,i);return N(j,{children:[a>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,a,` more above`]}),o.map((n,r)=>{let i=a+r+2;return N(e,{children:[M(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),M(e,{width:A+2,children:M(t,{children:M(xr,{colorKey:n,theme:d,bold:!0})})}),M(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),i<D.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-i,` more below`]})]})})()]})]}):y?N(e,{flexDirection:`column`,marginTop:1,children:[N(t,{children:[`Editing `,y===`name`?`theme name`:`theme ID`,`:`]}),M(e,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:M(t,{children:x})}),M(t,{dimColor:!0,children:`enter to save, esc to cancel`})]}):M(Sr,{initialValue:C,colorKey:D[_],theme:d,onColorChange:e=>{S(e),T(t=>{t.colors[D[_]]=e})},onExit:()=>{T(e=>{e.colors[D[_]]=x}),v(null),S(``),w(``)}})]}),M(e,{width:`50%`,children:M(br,{theme:d})})]})}function Er(e){return e.map(e=>`${e.name} (${e.id})`)}function Dr({onBack:n}){let{settings:{themes:i},updateSettings:a}=u($),[o,s]=m(0),[c,l]=m(null),[d,f]=m(!0),p=()=>{let e={colors:{...(i[0]||K.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};a(t=>{t.themes.push(e)}),l(e.id),f(!1)},h=e=>{i.length<=1||(a(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),o>=i.length-1&&s(Math.max(0,i.length-2)))},g=()=>{a(e=>{e.themes=[...K.themes]}),s(0)};if(r((e,t)=>{if(t.escape)n();else if(t.upArrow)s(e=>Math.max(0,e-1));else if(t.downArrow)s(e=>Math.min(i.length-1,e+1));else if(t.return){let e=i[o];e&&(l(e.id),f(!1))}else if(e===`n`)p();else if(e===`d`){let e=i[o];e&&h(e.id)}else t.ctrl&&e===`r`&&g()},{isActive:d}),c)return M(Tr,{themeId:c,onBack:()=>{l(null),f(!0)}});let _=Er(i),v=i.find(e=>_[o]?.includes(`(${e.id})`))||i[0];return i.length===0?M(e,{children:N(e,{flexDirection:`column`,width:`100%`,children:[M(X,{children:`Themes`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new theme`}),M(t,{dimColor:!0,children:`esc to go back`})]}),M(t,{children:`No themes available!`})]})}):N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(X,{children:`Themes`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new theme`}),M(t,{dimColor:!0,children:`d to delete a theme`}),M(t,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),M(t,{dimColor:!0,children:`enter to edit theme`}),M(t,{dimColor:!0,children:`esc to go back`})]}),M(e,{flexDirection:`column`,children:_.map((e,n)=>N(t,{color:o===n?`yellow`:void 0,children:[o===n?`❯ `:` `,e]},n))})]}),M(e,{width:`50%`,children:M(br,{theme:v})})]})}function Or({onBack:n}){let{settings:{thinkingVerbs:{format:i,verbs:a},themes:o},updateSettings:s}=u($),c=[`format`,`verbs`],[l,d]=m(0),f=c[l],[p,h]=m(0),[g,_]=m(!1),[v,y]=m(``),[b,x]=m(!1),[S,C]=m(!1),[w,T]=m(i),E=zn(),D=(o.find(e=>e.id===E)||o.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return r((e,t)=>{if(S){t.return?(s(e=>{e.thinkingVerbs.format=w}),C(!1)):t.escape?(T(i),C(!1)):t.backspace||t.delete?T(e=>e.slice(0,-1)):e&&T(t=>t+e);return}if(g||b){t.return&&v.trim()?(b?(s(e=>{e.thinkingVerbs.verbs.push(v.trim())}),x(!1)):(s(e=>{e.thinkingVerbs.verbs[p]=v.trim()}),_(!1)),y(``)):t.escape?(y(``),_(!1),x(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&y(t=>t+e);return}t.escape?n():t.return?f===`format`&&(T(i),C(!0)):t.tab?t.shift?d(e=>e===0?c.length-1:e-1):d(e=>e===c.length-1?0:e+1):t.upArrow?f===`verbs`&&a.length>0&&h(e=>e>0?e-1:a.length-1):t.downArrow?f===`verbs`&&a.length>0&&h(e=>e<a.length-1?e+1:0):e===`e`&&f===`verbs`?a.length>0&&(y(a[p]),_(!0)):e===`d`&&f===`verbs`?a.length>1&&(s(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==p)}),p>=a.length-1&&h(Math.max(0,a.length-2))):e===`n`&&f===`verbs`?(x(!0),y(``)):t.ctrl&&e===`r`&&f===`verbs`&&(s(e=>{e.thinkingVerbs.verbs=[...K.thinkingVerbs.verbs]}),h(0))}),N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,flexDirection:`column`,children:[M(X,{children:`Thinking Verbs`}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:f===`format`?`enter to edit format`:`changes auto-saved`}),M(t,{dimColor:!0,children:`esc to go back`}),M(t,{dimColor:!0,children:`tab to switch sections`})]})]}),M(e,{marginBottom:1,children:M(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:f===`format`?`yellow`:void 0,children:f===`format`?`❯ `:` `}),M(t,{bold:!0,color:f===`format`?`yellow`:void 0,children:`Format`})]}),f===`format`&&(S?N(t,{dimColor:!0,children:[` `,`enter to save`]}):N(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:S?`yellow`:`gray`,children:M(t,{children:S?w:i})})}),M(e,{children:N(t,{children:[M(t,{color:f===`verbs`?`yellow`:void 0,children:f===`verbs`?`❯ `:` `}),M(t,{bold:!0,color:f===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),f===`verbs`&&M(e,{flexDirection:`column`,children:N(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),M(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,p-4),n=Math.min(a.length,e+8),r=Math.max(0,n-8),i=a.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return N(t,{color:f===`verbs`&&i===p?`cyan`:void 0,children:[f===`verbs`&&i===p?`❯ `:` `,e]},i)}),n<a.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),b&&N(e,{alignItems:`center`,children:[M(t,{color:`yellow`,children:`❯ `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:v})})]}),g&&N(e,{marginTop:1,alignItems:`center`,children:[M(t,{children:`Editing: `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:v})})]})]})})]}),N(e,{width:`50%`,flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,children:`Preview`})}),M(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:N(t,{children:[N(t,{color:D,children:[`✻ `,i.replace(/\{\}/g,a[p]),` `]}),M(t,{children:`(esc to interrupt)`})]})})]})]})}const kr=[{name:`Default`,phases:K.thinkingStyle.phases,reverseMirror:K.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 Ar({onBack:n}){let{settings:{thinkingStyle:{phases:i,updateInterval:a,reverseMirror:o},themes:s},updateSettings:c}=u($),l=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[f,p]=m(0),h=l[f],[g,_]=m(0),[v,y]=m(0),[b,x]=m(!1),[S,C]=m(``),[w,T]=m(!1),[E,D]=m(!1),[O,k]=m(a.toString()),[A,ee]=m(0),P=zn(),F=(s.find(e=>e.id===P)||s.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;d(()=>{if(i.length>0){let e=o?[...i,...[...i].reverse().slice(1,-1)]:i,t=setInterval(()=>{ee(t=>(t+1)%e.length)},a);return()=>clearInterval(t)}},[i,a,o]),r((e,t)=>{if(E){if(t.return){let e=parseInt(O);!isNaN(e)&&e>0&&c(t=>{t.thinkingStyle.updateInterval=e}),D(!1)}else t.escape?(k(a.toString()),D(!1)):t.backspace||t.delete?k(e=>e.slice(0,-1)):e&&e.match(/^[0-9]$/)&&k(t=>t+e);return}if(b||w){if(t.return&&S.length){let e=w?[...i,S]:i.map((e,t)=>t===g?S:e);c(t=>{t.thinkingStyle.phases=e}),x(!1),C(``)}else t.escape?(C(``),x(!1),T(!1)):t.backspace||t.delete?C(e=>e.slice(0,-1)):e&&C(t=>t+e);return}if(t.escape)n();else if(t.return)if(h===`updateInterval`)k(a.toString()),D(!0);else if(h===`presets`){let e=kr[v];c(t=>{t.thinkingStyle.phases=[...e.phases],t.thinkingStyle.reverseMirror=e.reverseMirror})}else h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(t.tab)t.shift?p(e=>e===0?l.length-1:e-1):p(e=>e===l.length-1?0:e+1);else if(t.upArrow)h===`phases`&&i.length>0?_(e=>e>0?e-1:i.length-1):h===`presets`&&y(e=>e>0?e-1:kr.length-1);else if(t.downArrow)h===`phases`&&i.length>0?_(e=>e<i.length-1?e+1:0):h===`presets`&&y(e=>e<kr.length-1?e+1:0);else if(e===` `)h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(e===`e`&&h===`phases`)i.length>0&&(C(i[g]),x(!0));else if(e===`a`&&h===`phases`)T(!0),C(``);else if(e===`d`&&h===`phases`)i.length>1&&(c(e=>{e.thinkingStyle.phases=i.filter((e,t)=>t!==g)}),g>=i.length&&_(Math.max(0,i.length-1)));else if(e===`w`&&h===`phases`){if(g>0){let e=[...i];[e[g-1],e[g]]=[e[g],e[g-1]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e-1)}}else if(e===`s`&&h===`phases`){if(g<i.length-1){let e=[...i];[e[g],e[g+1]]=[e[g+1],e[g]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e+1)}}else t.ctrl&&e===`r`&&(c(e=>{e.thinkingStyle=K.thinkingStyle}),_(0),y(0))});let te=o?`●`:`○`,I=(()=>o?[...i,...[...i].reverse().slice(1,-1)]:i)(),ne=I.length>0?I[A]:`·`;return M(e,{children:N(e,{flexDirection:`column`,width:`100%`,children:[N(e,{flexDirection:`row`,width:`100%`,children:[N(e,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[M(X,{children:`Thinking style`}),N(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:[`enter to`,` `,h===`updateInterval`?`edit interval`:h===`presets`?`apply preset`:`save`]}),M(t,{dimColor:!0,children:`esc to go back`}),M(t,{dimColor:!0,children:`tab to switch sections`})]})]}),N(e,{width:`50%`,flexDirection:`column`,children:[M(e,{children:M(t,{bold:!0,children:`Preview`})}),N(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[M(e,{width:(ne?.length??0)+1,children:M(t,{color:F,children:ne})}),N(t,{children:[M(t,{color:F,children:`Thinking… `}),M(t,{children:`(esc to interrupt)`})]})]})]})]}),N(e,{flexDirection:`row`,gap:4,children:[N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:h===`reverseMirror`?`yellow`:void 0,children:h===`reverseMirror`?`❯ `:` `}),M(t,{bold:!0,color:h===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),h===`reverseMirror`&&N(t,{dimColor:!0,children:[` `,`space to toggle`]}),M(e,{marginLeft:2,marginBottom:1,children:N(t,{children:[te,` `,o?`Enabled`:`Disabled`]})})]}),N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:h===`updateInterval`?`yellow`:void 0,children:h===`updateInterval`?`❯ `:` `}),M(t,{bold:!0,color:h===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),h===`updateInterval`&&(E?N(t,{dimColor:!0,children:[` `,`enter to save`]}):N(t,{dimColor:!0,children:[` `,`enter to edit`]})),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:M(t,{children:E?O:a})})})]})]}),M(e,{children:N(t,{children:[M(t,{color:h===`phases`?`yellow`:void 0,children:h===`phases`?`❯ `:` `}),M(t,{bold:!0,color:h===`phases`?`yellow`:void 0,children:`Phases`})]})}),h===`phases`&&M(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),M(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,g-4),n=Math.min(i.length,e+8),r=Math.max(0,n-8),a=i.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return N(t,{color:h===`phases`&&i===g?`cyan`:void 0,children:[h===`phases`&&i===g?`❯ `:` `,e]},i)}),n<i.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),w&&N(e,{children:[M(t,{color:`yellow`,children:`❯ `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:S})})]}),b&&N(e,{marginTop:1,children:[M(t,{children:`Editing: `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:S})})]})]})}),M(e,{children:N(t,{children:[M(t,{color:h===`presets`?`yellow`:void 0,children:h===`presets`?`❯ `:` `}),M(t,{bold:!0,color:h===`presets`?`yellow`:void 0,children:`Presets`})]})}),h===`presets`&&N(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,v-4),n=Math.min(kr.length,e+8),r=Math.max(0,n-8),i=kr.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return N(t,{color:h===`presets`&&i===v?`cyan`:void 0,children:[h===`presets`&&i===v?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<kr.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,kr.length-n,` more below`]})]})})()})}),M(e,{marginTop:1,children:M(t,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function jr(e,t){let n=p(!0);d(()=>{if(n.current){n.current=!1;return}return e()},t)}const Mr=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Nr=[{label:`none`,value:`none`},{label:`single`,value:`single`},{label:`double`,value:`double`},{label:`round`,value:`round`},{label:`bold`,value:`bold`},{label:`singleDouble`,value:`singleDouble`},{label:`doubleSingle`,value:`doubleSingle`},{label:`classic`,value:`classic`},{label:`topBottomSingle`,value:`topBottomSingle`},{label:`topBottomDouble`,value:`topBottomDouble`},{label:`topBottomBold`,value:`topBottomBold`}];function Pr({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(!1),[c,l]=m(!1),[d,f]=m(!1),[p,h]=m(()=>i.userMessageDisplay.format),[g,_]=m(()=>String(i.userMessageDisplay.paddingX)),[v,y]=m(()=>String(i.userMessageDisplay.paddingY)),[b,x]=m(i.userMessageDisplay.fitBoxToContent),[S,C]=m(0),[w,T]=m(()=>[...i.userMessageDisplay.styling]),[E,D]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[O,k]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:i.userMessageDisplay.foregroundColor),[A,ee]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[j,P]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[F,te]=m(()=>Nr.findIndex(e=>e.value===i.userMessageDisplay.borderStyle)),[I,ne]=m(()=>i.userMessageDisplay.borderColor),[L,re]=m(null),[ie,ae]=m(``),oe=zn(),R=i.themes?.find(e=>e.id===oe)||i.themes?.[0],[z,se]=m(`text`),ce=[`format`,`styling`,`foreground`,`background`],le=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[ue,de]=m(0),[fe,pe]=m(0),B=z===`text`?ce[ue]:le[fe],me=()=>{a(e=>{e.userMessageDisplay.format=p,e.userMessageDisplay.styling=[...w],e.userMessageDisplay.foregroundColor=E===`default`?`default`:O,e.userMessageDisplay.backgroundColor=A===`none`?null:A===`default`?`default`:j,e.userMessageDisplay.borderStyle=Nr[F].value,e.userMessageDisplay.borderColor=I,e.userMessageDisplay.paddingX=parseInt(g)||0,e.userMessageDisplay.paddingY=parseInt(v)||0,e.userMessageDisplay.fitBoxToContent=b})},he=()=>{h(K.userMessageDisplay.format),T([...K.userMessageDisplay.styling]),D(`default`),k(`rgb(255,255,255)`),ee(`none`),P(`rgb(0,0,0)`),te(Nr.findIndex(e=>e.value===K.userMessageDisplay.borderStyle)),ne(K.userMessageDisplay.borderColor),_(String(K.userMessageDisplay.paddingX)),y(String(K.userMessageDisplay.paddingY)),x(K.userMessageDisplay.fitBoxToContent),a(e=>{e.userMessageDisplay={...K.userMessageDisplay}})};jr(()=>{me()},[p,w,E,O,A,j,F,I,g,v,b]),r((e,t)=>{if(o){t.return?s(!1):t.escape?(h(i.userMessageDisplay.format),s(!1)):t.backspace||t.delete?h(e=>e.slice(0,-1)):e&&h(t=>t+e);return}if(c){t.return?l(!1):t.escape?(_(String(i.userMessageDisplay.paddingX)),l(!1)):t.backspace||t.delete?_(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&_(t=>t+e);return}if(d){t.return?f(!1):t.escape?(y(String(i.userMessageDisplay.paddingY)),f(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&y(t=>t+e);return}if(L===null){if(t.escape)n();else if(t.ctrl&&e===`r`)he();else if(t.leftArrow||t.rightArrow)se(e=>e===`text`?`border`:`text`);else if(t.tab)z===`text`?t.shift?de(e=>e===0?ce.length-1:e-1):de(e=>e===ce.length-1?0:e+1):t.shift?pe(e=>e===0?le.length-1:e-1):pe(e=>e===le.length-1?0:e+1);else if(t.return)B===`format`?s(!0):B===`paddingX`?l(!0):B===`paddingY`?f(!0):B===`foreground`?E===`custom`&&(ae(O),re(`foreground`)):B===`background`?A===`custom`&&(ae(j),re(`background`)):B===`borderColor`&&(ae(I),re(`border`));else if(t.upArrow)B===`styling`?C(e=>Math.max(0,e-1)):B===`borderStyle`?te(e=>e===0?Nr.length-1:e-1):B===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):B===`background`&&ee(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!j||j===``)&&P(`rgb(0,0,0)`),t});else if(t.downArrow)B===`styling`?C(e=>Math.min(Mr.length-1,e+1)):B===`borderStyle`?te(e=>e===Nr.length-1?0:e+1):B===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):B===`background`&&ee(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!j||j===``)&&P(`rgb(0,0,0)`),t});else if(e===` `)if(B===`styling`){let e=Mr[S].value;T(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else B===`fitBoxToContent`&&x(e=>!e)}});let ge=n=>{let r=E===`default`?R?.colors?.text:O,i=A===`none`?void 0:A===`default`?R?.colors?.userMessageBackground:j,a=Nr[F].value,o=parseInt(g)||0,s=parseInt(v)||0,c=M(t,{bold:w.includes(`bold`),italic:w.includes(`italic`),underline:w.includes(`underline`),strikethrough:w.includes(`strikethrough`),inverse:w.includes(`inverse`),color:r,backgroundColor:i,children:n});if(a===`topBottomSingle`||a===`topBottomDouble`||a===`topBottomBold`){let r=a===`topBottomSingle`?`─`:a===`topBottomDouble`?`═`:`━`,i=n.length+o*2,l=r.repeat(i);return N(e,{flexDirection:`column`,children:[M(t,{color:I,children:l}),s>0&&M(e,{height:s}),M(e,{paddingX:o,children:c}),s>0&&M(e,{height:s}),M(t,{color:I,children:l})]})}else if(a!==`none`||o>0||s>0||b){let t=o>0||s>0?M(e,{paddingX:o,paddingY:s,children:c}):c,n={};return a!==`none`&&(n.borderStyle=a,n.borderColor=I),b?n.alignSelf=`flex-start`:n.flexGrow=1,a===`none`?t:M(e,{...n,children:t})}else return c};return L?M(Sr,{initialValue:ie,theme:R,onColorChange:e=>{L===`foreground`?k(e):L===`background`?P(e):L===`border`&&ne(e)},onExit:()=>{re(null),ae(``)}}):N(e,{flexDirection:`column`,children:[M(X,{children:`Customize how user messages are displayed`}),N(e,{flexDirection:`column`,marginBottom:1,children:[M(t,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),M(t,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),N(e,{flexDirection:`row`,gap:1,children:[N(e,{flexDirection:`column`,width:`50%`,borderStyle:z===`text`?`round`:`single`,borderColor:z===`text`?`yellow`:`gray`,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,color:z===`text`?`yellow`:void 0,children:`Text & Styling`})}),M(e,{children:N(t,{color:B===`format`?`yellow`:void 0,bold:B===`format`,children:[B===`format`?`❯ `:` `,`Format String`]})}),B===`format`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:o?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:o?`yellow`:`gray`,children:M(t,{children:p})})}),M(e,{children:N(t,{color:B===`styling`?`yellow`:void 0,bold:B===`styling`,children:[B===`styling`?`❯ `:` `,`Styling`]})}),B===`styling`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),M(e,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Mr.map((n,r)=>M(e,{children:N(t,{color:B===`styling`&&S===r?`cyan`:void 0,children:[B===`styling`&&S===r?`❯ `:` `,w.includes(n.value)?`●`:`○`,` `,n.label]})},n.value))}),N(e,{flexDirection:`row`,gap:1,marginBottom:1,children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(t,{color:B===`foreground`?`yellow`:void 0,bold:B===`foreground`,children:[B===`foreground`?`❯ `:` `,`Foreground`]})}),B===`foreground`&&M(e,{marginLeft:2,children:N(t,{dimColor:!0,children:[`up/down · `,E===`custom`?`enter`:``]})}),N(e,{marginLeft:2,flexDirection:`column`,children:[M(e,{children:N(t,{children:[E===`default`?`● `:`○ `,`Default`]})}),M(e,{children:N(t,{children:[E===`custom`?`● `:`○ `,`Custom`,E===`custom`&&`: `,E===`custom`&&M(t,{color:O,children:O})]})})]})]}),N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(t,{color:B===`background`?`yellow`:void 0,bold:B===`background`,children:[B===`background`?`❯ `:` `,`Background`]})}),B===`background`&&M(e,{marginLeft:2,children:N(t,{dimColor:!0,children:[`up/down · `,A===`custom`?`enter`:``]})}),N(e,{marginLeft:2,flexDirection:`column`,children:[M(e,{children:N(t,{children:[A===`default`?`● `:`○ `,`Default`]})}),M(e,{children:N(t,{children:[A===`none`?`● `:`○ `,`None`]})}),M(e,{children:N(t,{children:[A===`custom`?`● `:`○ `,`Custom`,A===`custom`&&`: `,A===`custom`&&M(t,{backgroundColor:j,children:j})]})})]})]})]})]}),N(e,{flexDirection:`column`,width:`50%`,borderStyle:z===`border`?`round`:`single`,borderColor:z===`border`?`yellow`:`gray`,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,color:z===`border`?`yellow`:void 0,children:`Border & Padding`})}),M(e,{children:N(t,{color:B===`borderStyle`?`yellow`:void 0,bold:B===`borderStyle`,children:[B===`borderStyle`?`❯ `:` `,`Border Style`]})}),B===`borderStyle`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`up/down to navigate`})}),N(e,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[M(e,{flexDirection:`column`,width:`50%`,children:Nr.slice(0,6).map((n,r)=>M(e,{children:N(t,{color:B===`borderStyle`&&F===r?`cyan`:void 0,children:[B===`borderStyle`&&F===r?`❯ `:` `,F===r?`● `:`○ `,n.label]})},n.value))}),M(e,{flexDirection:`column`,width:`50%`,children:Nr.slice(6).map((n,r)=>{let i=r+6;return M(e,{children:N(t,{color:B===`borderStyle`&&F===i?`cyan`:void 0,children:[B===`borderStyle`&&F===i?`❯ `:` `,F===i?`● `:`○ `,n.label]})},n.value)})})]}),M(e,{children:N(t,{color:B===`borderColor`?`yellow`:void 0,bold:B===`borderColor`,children:[B===`borderColor`?`❯ `:` `,`Border Color`]})}),B===`borderColor`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`enter to pick color`})}),M(e,{marginLeft:2,marginBottom:1,children:M(t,{color:I,children:I})}),N(e,{flexDirection:`row`,gap:1,children:[N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`paddingX`?`yellow`:void 0,bold:B===`paddingX`,children:[B===`paddingX`?`❯ `:` `,`Padding X`]})}),B===`paddingX`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:c?`enter/esc`:`enter`})}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:c?`yellow`:`gray`,children:M(t,{children:g})})})]}),N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`paddingY`?`yellow`:void 0,bold:B===`paddingY`,children:[B===`paddingY`?`❯ `:` `,`Padding Y`]})}),B===`paddingY`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:d?`enter/esc`:`enter`})}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:d?`yellow`:`gray`,children:M(t,{children:v})})})]}),N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`fitBoxToContent`?`yellow`:void 0,bold:B===`fitBoxToContent`,children:[B===`fitBoxToContent`?`❯ `:` `,b?`●`:`○`,` Fit box to content`]})}),B===`fitBoxToContent`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`space`})})]})]})]})]}),N(e,{flexDirection:`column`,marginTop:1,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,children:`Preview`})}),N(e,{flexDirection:`row`,gap:2,children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{marginBottom:1,children:M(t,{underline:!0,children:`Before (Claude Code default):`})}),M(e,{marginLeft:1,children:N(t,{backgroundColor:R?.colors?.userMessageBackground,color:R?.colors?.text,children:[` `,`> list the dir`,` `]})}),M(e,{marginLeft:1,marginTop:1,children:N(t,{children:[M(t,{color:R?.colors?.inactive||`#888888`,children:`●`}),M(t,{children:` The directory `}),M(t,{color:R?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),M(t,{children:` contains `}),M(t,{bold:!0,children:`123`}),M(t,{children:` files.`})]})})]}),N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{marginBottom:1,children:M(t,{underline:!0,children:`After (Your customization):`})}),M(e,{marginLeft:1,flexDirection:`row`,children:(()=>ge(p.replace(/\{\}/g,`list the dir`)))()}),M(e,{marginLeft:1,marginTop:1,children:N(t,{children:[M(t,{color:R?.colors?.inactive||`#888888`,children:`●`}),M(t,{children:` The directory `}),M(t,{color:R?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),M(t,{children:` contains `}),M(t,{bold:!0,children:`123`}),M(t,{children:` files.`})]})})]})]})]})]})}function Fr({onSubmit:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(0),c={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEditPrompt:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!0},l=()=>{i.misc||={...c}},d=f(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>i.inputBox?.removeBorder??!1,toggle:()=>{a(e=>{e.inputBox||={removeBorder:!1},e.inputBox.removeBorder=!e.inputBox.removeBorder})}},{id:`showVersion`,title:`Show tweakcc version at startup`,description:`Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.`,getValue:()=>i.misc?.showTweakccVersion??!0,toggle:()=>{a(e=>{l(),e.misc.showTweakccVersion=!e.misc.showTweakccVersion})}},{id:`showPatches`,title:`Show patches applied indicator at startup`,description:`Shows the green "tweakcc patches are applied" indicator when starting Claude Code.`,getValue:()=>i.misc?.showPatchesApplied??!0,toggle:()=>{a(e=>{l(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>i.misc?.expandThinkingBlocks??!0,toggle:()=>{a(e=>{l(),e.misc.expandThinkingBlocks=!e.misc.expandThinkingBlocks})}},{id:`conversationTitle`,title:`Allow renaming sessions via /title`,description:`Enables /title and /rename commands for manually naming conversations.`,getValue:()=>i.misc?.enableConversationTitle??!0,toggle:()=>{a(e=>{l(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>i.misc?.hideStartupBanner??!1,toggle:()=>{a(e=>{l(),e.misc.hideStartupBanner=!e.misc.hideStartupBanner})}},{id:`hideCtrlG`,title:`Hide ctrl-g to edit prompt hint`,description:`Hides the "ctrl-g to edit prompt" hint shown during streaming.`,getValue:()=>i.misc?.hideCtrlGToEditPrompt??!1,toggle:()=>{a(e=>{l(),e.misc.hideCtrlGToEditPrompt=!e.misc.hideCtrlGToEditPrompt})}},{id:`hideClawd`,title:`Hide startup Clawd ASCII art`,description:`Hides the Clawd ASCII art character shown at startup.`,getValue:()=>i.misc?.hideStartupClawd??!1,toggle:()=>{a(e=>{l(),e.misc.hideStartupClawd=!e.misc.hideStartupClawd})}},{id:`increaseFileReadLimit`,title:`Increase file read token limit`,description:`Increases the maximum file read limit from 25,000 to 1,000,000 tokens.`,getValue:()=>i.misc?.increaseFileReadLimit??!1,toggle:()=>{a(e=>{l(),e.misc.increaseFileReadLimit=!e.misc.increaseFileReadLimit})}},{id:`suppressLineNumbers`,title:`Suppress line numbers in file reads/edits`,description:`Removes line number prefixes from file content to reduce token usage.`,getValue:()=>i.misc?.suppressLineNumbers??!0,toggle:()=>{a(e=>{l(),e.misc.suppressLineNumbers=!e.misc.suppressLineNumbers})}}],[i,a]),p=d.length,h=p-1,g=f(()=>o<4?0:Math.min(o-4+1,p-4),[o,p]),_=d.slice(g,g+4),v=g>0,y=g+4<p;return r((e,t)=>{t.return||t.escape?n():t.upArrow?s(e=>Math.max(0,e-1)):t.downArrow?s(e=>Math.min(h,e+1)):e===` `&&d[o]?.toggle()}),N(e,{flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(X,{children:`Miscellaneous Settings`})}),M(e,{marginBottom:1,children:M(t,{dimColor:!0,children:`Various tweaks and customizations. Press space to toggle settings, enter to go back.`})}),v&&M(e,{children:N(t,{dimColor:!0,children:[` ↑ `,g,` more above`]})}),_.map((n,r)=>{let i=g+r===o,a=n.getValue()?`☑`:`☐`;return N(e,{flexDirection:`column`,children:[M(e,{children:N(t,{children:[M(t,{color:i?`cyan`:void 0,children:i?`❯ `:` `}),M(t,{bold:!0,color:i?`cyan`:void 0,children:n.title})]})}),M(e,{children:N(t,{dimColor:!0,children:[` `,n.description]})}),M(e,{marginLeft:4,marginBottom:1,children:N(t,{children:[a,` `,n.getValue()?`Enabled`:`Disabled`]})})]},n.id)}),y&&M(e,{children:N(t,{dimColor:!0,children:[` `,`↓ `,p-g-4,` more below`]})}),M(e,{marginTop:1,children:N(t,{dimColor:!0,children:[`Item `,o+1,` of `,p]})})]})}const Ir=[`Task`,`Bash`,`Glob`,`Grep`,`Read`,`Edit`,`Write`,`NotebookEdit`,`WebFetch`,`WebSearch`,`BashOutput`,`KillShell`,`TodoWrite`,`AskUserQuestion`,`Skill`,`SlashCommand`,`EnterPlanMode`,`ExitPlanMode`,`LSP`];function Lr({toolsetIndex:n,onBack:i}){let{settings:a,updateSettings:o}=u($),s=a.toolsets[n],[c,l]=m(s?.name||`New Toolset`),[f,p]=m(s?.allowedTools||[]),[h,g]=m(!1),[_,v]=m(0);d(()=>{s&&o(e=>{let t=e.toolsets[n].name;e.toolsets[n].name=c,e.toolsets[n].allowedTools=f,t!==c&&(e.defaultToolset===t&&(e.defaultToolset=c),e.planModeToolset===t&&(e.planModeToolset=c))})},[c,f]);let y=e=>f===`*`?!0:f.includes(e),b=e=>{e===`All`?p(`*`):e===`None`?p([]):f===`*`?p(Ir.filter(t=>t!==e)):f.includes(e)?p(f.filter(t=>t!==e)):p([...f,e])};if(r((e,t)=>{if(h){t.return?g(!1):t.escape?(l(s?.name||`New Toolset`),g(!1)):t.backspace||t.delete?l(e=>e.slice(0,-1)):e&&e.length===1&&l(t=>t+e);return}if(t.escape)i();else if(t.upArrow)v(e=>Math.max(0,e-1));else if(t.downArrow)v(e=>Math.min(Ir.length+1,e+1));else if(e===` `||t.return)if(_===0)b(`All`);else if(_===1)b(`None`);else{let e=Ir[_-2];e&&b(e)}else e===`n`&&g(!0)}),!s)return M(e,{flexDirection:`column`,children:M(t,{color:`red`,children:`Toolset not found`})});let x=f===`*`,S=Array.isArray(f)&&f.length===0;return N(e,{flexDirection:`column`,children:[M(X,{children:`Edit Toolset`}),M(e,{marginBottom:1,flexDirection:`column`,children:M(t,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{bold:!0,children:`Name:`}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:h?`yellow`:`gray`,children:M(t,{children:c})})}),h&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{bold:!0,children:`Allowed Tools:`}),M(e,{marginLeft:2,children:N(t,{color:_===0?`cyan`:void 0,children:[_===0?`❯ `:` `,x?`●`:`○`,` All`]})}),M(e,{marginLeft:2,children:N(t,{color:_===1?`cyan`:void 0,children:[_===1?`❯ `:` `,S?`●`:`○`,` None`]})}),Ir.map((n,r)=>{let i=r+2;return M(e,{marginLeft:2,children:N(t,{color:_===i?`cyan`:void 0,children:[_===i?`❯ `:` `,y(n)?`◉`:`○`,` `,n]})},n)})]}),M(e,{borderStyle:`round`,padding:1,marginTop:1,children:N(e,{flexDirection:`column`,children:[M(t,{bold:!0,children:`Summary:`}),N(t,{children:[`Name: `,M(t,{color:`cyan`,children:c})]}),N(t,{children:[`Tools:`,` `,f===`*`?M(t,{color:`green`,children:`All tools (*)`}):f.length===0?M(t,{color:`red`,children:`No tools ([])`}):N(t,{color:`yellow`,children:[f.length,` selected`]})]})]})})]})}function Rr({onBack:n}){let{settings:{toolsets:i,defaultToolset:a,planModeToolset:o,themes:s},updateSettings:c}=u($),l=zn(),d=s.find(e=>e.id===l)||s[0],f=K.themes[0],p=d?.colors.planMode||f.colors.planMode,h=d?.colors.autoAccept||f.colors.autoAccept,[g,_]=m(0),[v,y]=m(null),[b,x]=m(!0),S=()=>{let e={name:`New Toolset`,allowedTools:[]};c(t=>{t.toolsets.push(e)}),y(i.length),x(!1)},C=e=>{let t=i[e];c(n=>{n.toolsets.splice(e,1),n.defaultToolset===t.name&&(n.defaultToolset=null),n.planModeToolset===t.name&&(n.planModeToolset=null)}),g>=i.length-1&&_(Math.max(0,i.length-2))},w=e=>{let t=i[e];c(e=>{e.defaultToolset=t.name})},T=e=>{let t=i[e];c(e=>{e.planModeToolset=t.name})};if(r((e,t)=>{t.escape?n():t.upArrow?_(e=>Math.max(0,e-1)):t.downArrow?_(e=>Math.min(i.length-1,e+1)):t.return&&i.length>0?(y(g),x(!1)):e===`n`?S():e===`x`&&i.length>0?C(g):e===`d`&&i.length>0?w(g):e===`p`&&i.length>0&&T(g)},{isActive:b}),v!==null)return M(Lr,{toolsetIndex:v,onBack:()=>{y(null),x(!0)}});let E=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return N(e,{flexDirection:`column`,children:[M(X,{children:`Toolsets`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new toolset`}),i.length>0&&M(t,{dimColor:!0,children:`d to set as default toolset`}),i.length>0&&M(t,{dimColor:!0,children:`p to set as plan mode toolset`}),i.length>0&&M(t,{dimColor:!0,children:`x to delete a toolset`}),i.length>0&&M(t,{dimColor:!0,children:`enter to edit toolset`}),M(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?M(t,{children:`No toolsets created yet. Press n to create one.`}):M(e,{flexDirection:`column`,children:i.map((n,r)=>{let i=n.name===a,s=n.name===o,c=g===r,l;return c&&(l=`yellow`),N(e,{flexDirection:`row`,children:[N(t,{color:l,children:[c?`❯ `:` `,n.name,` `]}),N(t,{color:l,children:[`(`,E(n),`)`]}),i&&M(t,{color:h,children:` ⏵⏵ accept edits`}),s&&M(t,{color:p,children:` ⏸ plan mode`})]},r)})})]})}const $=c({settings:K,updateSettings:e=>{},changesApplied:!1,ccVersion:``});function zr({startupCheckInfo:t,configMigrated:n}){let[i,a]=m({settings:K,changesApplied:!1,ccVersion:``,lastModified:``}),[o,s]=m(!1);d(()=>{(async()=>{let e=await ar();a(e),s(!e.hidePiebaldAnnouncement)})()},[]);let c=l(e=>{let t=JSON.parse(JSON.stringify(i.settings));e(t),a(e=>({...e,settings:t,changesApplied:!1})),or(e=>{e.settings=t,e.changesApplied=!1})},[i.settings]),[u,f]=m(null),[p,h]=m(null);d(()=>{t.wasUpdated&&t.oldVersion&&(h({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
|
|
640
640
|
(However, your customization are still remembered in ${J}.)
|
|
641
|
-
Please reapply your changes below.`,type:`warning`}),c(()=>{}))},[]),r((e,t)=>{t.ctrl&&e===`c`&&process.exit(0),(e===`q`||t.escape)&&!u&&process.exit(0),e===`h`&&!u&&o&&(s(!1),
|
|
642
|
-
`)}function
|
|
641
|
+
Please reapply your changes below.`,type:`warning`}),c(()=>{}))},[]),r((e,t)=>{t.ctrl&&e===`c`&&process.exit(0),(e===`q`||t.escape)&&!u&&process.exit(0),e===`h`&&!u&&o&&(s(!1),or(e=>{e.hidePiebaldAnnouncement=!0}))},{isActive:!u});let g=e=>{switch(h(null),e){case Z.APPLY_CHANGES:t.ccInstInfo&&(h({message:`Applying patches...`,type:`info`}),kn(i,t.ccInstInfo).then(e=>{a(e),h({message:`Customization patches applied successfully!`,type:`success`})}));break;case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.MISC:case Z.TOOLSETS:f(e);break;case Z.VIEW_SYSTEM_PROMPTS:Hn(er);break;case Z.RESTORE_ORIGINAL:t.ccInstInfo&&(t.ccInstInfo.nativeInstallationPath?vn(t.ccInstInfo):_n(t.ccInstInfo)).then(()=>{h({message:`Original Claude Code restored successfully!`,type:`success`}),c(()=>{})});break;case Z.OPEN_CONFIG:Un(J);break;case Z.OPEN_CLI:t.ccInstInfo?.cliPath&&Un(t.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},_=()=>{f(null)};return M($.Provider,{value:{settings:i.settings,updateSettings:c,changesApplied:i.changesApplied,ccVersion:t.ccInstInfo?.version||``},children:M(e,{flexDirection:`column`,children:u===null?M(_r,{onSubmit:g,notification:p,configMigrated:n,showPiebaldAnnouncement:o}):u===Z.THEMES?M(Dr,{onBack:_}):u===Z.THINKING_VERBS?M(Or,{onBack:_}):u===Z.THINKING_STYLE?M(Ar,{onBack:_}):u===Z.USER_MESSAGE_DISPLAY?M(Pr,{onBack:_}):u===Z.MISC?M(Fr,{onSubmit:_}):u===Z.TOOLSETS?M(Rr,{onBack:_}):null})})}const Br=(()=>{let e=[],t=process.platform==`win32`?g.homedir().replace(/\\/g,`/`):g.homedir(),n=`node_modules/@anthropic-ai/claude-code`,r=(t,n=!1)=>{if(n)try{let n=I(t,{onlyFiles:!1});e.push({pattern:t,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?W(`Permission denied accessing: ${t} (${n.code})`):W(`Error expanding glob pattern "${t}": ${n instanceof Error?n.message:String(n)}`),e.push({pattern:t,isGlob:!0,expandedPaths:[]})}else e.push({pattern:t,isGlob:!1,expandedPaths:[t]})};return r(`${g.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform==`win32`?(r(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),r(`${t}/AppData/Roaming/npm/${n}`),r(`${t}/AppData/Roaming/nvm/*/${n}`,!0),r(`${t}/AppData/Local/Yarn/config/global/${n}`),r(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),r(`C:/nvm4w/nodejs/${n}`),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/AppData/Roaming/Yarn/config/global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/Bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0),r(`${t}/AppData/Local/mise/installs/node/*/${n}`,!0),r(`${t}/AppData/Local/mise/installs/npm-anthropic-ai-claude-code/*/${n}`,!0)):(process.platform==`darwin`&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/Library/Caches/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0)),r(`${t}/.local/lib/${n}`),r(`${t}/.local/share/${n}`),r(`${t}/.npm-global/lib/${n}`),r(`${t}/.npm-packages/lib/${n}`),r(`${t}/.npm/lib/${n}`),r(`${t}/npm/lib/${n}`),r(`/etc/${n}`),r(`/lib/${n}`),r(`/opt/node/lib/${n}`),r(`/usr/lib/${n}`),r(`/usr/local/lib/${n}`),r(`/usr/share/${n}`),r(`/var/lib/${n}`),r(`/opt/homebrew/lib/${n}`),r(`${t}/.linuxbrew/lib/${n}`),r(`${t}/.config/yarn/global/${n}`),r(`${t}/.yarn/global/${n}`),r(`${t}/.bun/install/global/${n}`),r(`${t}/.pnpm-global/${n}`),r(`${t}/.pnpm-global/*/${n}`,!0),r(`${t}/pnpm-global/${n}`),r(`${t}/pnpm-global/*/${n}`,!0),r(`${t}/.local/share/pnpm/global/${n}`),r(`${t}/.local/share/pnpm/global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/.local/share/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`/usr/local/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/lib/${n}`),r(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),r(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),r(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nodenv/versions/*/lib/${n}`,!0),r(`${t}/.nvs/*/lib/${n}`,!0),r(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0)),process.platform==`win32`&&e.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),e})().flatMap(e=>e.expandedPaths),Vr=(()=>{let e=process.platform===`win32`?g.homedir().replace(/\\/g,`/`):g.homedir(),t=[],n=(e,n=!1)=>{if(n)try{let n=I(e,{onlyFiles:!0});t.push({pattern:e,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?W(`Permission denied accessing: ${e} (${n.code})`):W(`Error expanding glob pattern "${e}": ${n instanceof Error?n.message:String(n)}`),t.push({pattern:e,isGlob:!0,expandedPaths:[]})}else t.push({pattern:e,isGlob:!1,expandedPaths:[e]})};return n(`${e}/.local/bin/claude`),n(`${e}/.local/share/claude/versions/*`,!0),process.platform===`win32`&&t.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),t})().flatMap(e=>e.expandedPaths);var Hr=class extends Error{constructor(e){super(e),this.name=`InstallationDetectionError`}};let Ur=null;async function Wr(){return Ur||=te.create(),Ur}async function Gr(e,t=4096){try{let n=await b.open(e,`r`);try{let e=Buffer.allocUnsafe(t),{bytesRead:r}=await n.read({buffer:e,position:0,length:t});return r<=0?null:e.subarray(0,r)}finally{await n.close()}}catch(e){return W(`Failed to read file prefix:`,e),null}}async function Kr(e){try{let t=await b.realpath(e);W(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await Gr(t);if(!n)return W(`resolvePathToInstallationType: Could not read file prefix`),null;let r=await Wr(),i=null;if(typeof r.detect==`function`&&(i=r.detect(n)||null),!i)return W(`resolvePathToInstallationType: WASMagic returned no mime type`),null;let a=i.toLowerCase();return W(`resolvePathToInstallationType: Detected mime type: ${a}`),a.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:a.startsWith(`text/`)?(W(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:t}}catch(e){return W(`resolvePathToInstallationType: Error:`,e),null}}async function qr(){try{let e=await F(`claude`);return W(`getClaudeFromPath: Found claude at ${e}`),e}catch{return W(`getClaudeFromPath: claude not found on PATH`),null}}function Jr(e){let t=/\bVERSION:"(\d+\.\d+\.\d+)"/g,n=new Map,r;for(;(r=t.exec(e))!==null;){let e=r[1];n.set(e,(n.get(e)||0)+1)}if(n.size===0)return null;let i=0,a;for(let[e,t]of n.entries())W(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&W(`Extracted version ${a} (${i} occurrences)`),a||null}async function Yr(e){let t=Jr(await b.readFile(e,`utf8`));if(!t)throw Error(`No VERSION strings found in JS file: ${e}`);return t}async function Xr(e){let t=await re(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}`);let n=Jr(t.toString(`utf8`));if(!n)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return n}function Zr(e){let t=D.basename(e).match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function Qr(e,t){let n=Zr(e);return n?(W(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?Yr(e):Xr(e)}async function $r(){let e=[],t=new Set;for(let n of Br){let r=D.join(n,`cli.js`);if(!t.has(r))try{if(await Jn(r)){W(`collectCandidates: Found cli.js at ${r}`);let n=await Yr(r);e.push({path:r,kind:`npm-based`,version:n}),t.add(r)}}catch(e){W(`collectCandidates: Error checking ${r}:`,e)}}for(let n of Vr)if(!t.has(n))try{if(await Jn(n)){W(`collectCandidates: Found native binary at ${n}`);let r=await Qr(n,`native-binary`);e.push({path:n,kind:`native-binary`,version:r}),t.add(n)}}catch(e){W(`collectCandidates: Error checking ${n}:`,e)}return[...e].sort((e,t)=>Xn(e.version,t.version))}function ei(e){return e.map(e=>` • ${e.path} (${e.kind}, v${e.version})`).join(`
|
|
642
|
+
`)}function ti(e){return` 2. Set ccInstallationPath in your config file (${J}):
|
|
643
643
|
|
|
644
644
|
{
|
|
645
645
|
"ccInstallationPath": "${e}"
|
|
646
|
-
}`}function
|
|
646
|
+
}`}function ni(e){return` 1. Set the TWEAKCC_CC_INSTALLATION_PATH environment variable:
|
|
647
647
|
|
|
648
|
-
export TWEAKCC_CC_INSTALLATION_PATH="${e}"`}function
|
|
648
|
+
export TWEAKCC_CC_INSTALLATION_PATH="${e}"`}function ri(e){let t=e[0]?.path||`/path/to/claude`;return`Multiple Claude Code installations found.
|
|
649
649
|
|
|
650
650
|
Found installations:
|
|
651
|
-
${
|
|
651
|
+
${ei(e)}
|
|
652
652
|
|
|
653
653
|
To specify which installation to use, either:
|
|
654
654
|
|
|
655
|
-
${
|
|
655
|
+
${ni(t)}
|
|
656
656
|
|
|
657
|
-
${
|
|
657
|
+
${ti(t)}`}function ii(){return`Could not find Claude Code installation.
|
|
658
658
|
|
|
659
659
|
To fix this, either:
|
|
660
660
|
|
|
661
|
-
${
|
|
661
|
+
${ni(`/path/to/claude`)}
|
|
662
662
|
|
|
663
|
-
${
|
|
663
|
+
${ti(`/path/to/claude`)}
|
|
664
664
|
|
|
665
665
|
3. Install Claude Code:
|
|
666
666
|
• npm install -g @anthropic-ai/claude-code
|
|
667
|
-
• Or download from https://claude.ai/download`}function
|
|
667
|
+
• Or download from https://claude.ai/download`}function ai(e,t,n,r){return t===`npm-based`?{cliPath:e,version:n,source:r}:{nativeInstallationPath:e,version:n,source:r}}async function oi(e,t){let n=process.env.TWEAKCC_CC_INSTALLATION_PATH?.trim();if(n&&n.length>0){if(W(`Checking TWEAKCC_CC_INSTALLATION_PATH: ${n}`),!await Jn(n))throw new Hr(`TWEAKCC_CC_INSTALLATION_PATH is set to '${n}' but file does not exist.`);let e=await Kr(n);if(!e)throw new Hr(`Unable to detect installation type from TWEAKCC_CC_INSTALLATION_PATH value '${n}'.\nExpected a Claude Code cli.js file or native binary.`);let t=await Qr(e.resolvedPath,e.kind);return Fn()&&e.kind===`npm-based`&&W(`SHA256 hash: ${await Kn(e.resolvedPath)}`),W(`Using Claude Code from TWEAKCC_CC_INSTALLATION_PATH: ${e.resolvedPath} (${e.kind}, v${t})`),ai(e.resolvedPath,e.kind,t,`env-var`)}if(e.ccInstallationPath){let t=e.ccInstallationPath;if(W(`Checking ccInstallationPath: ${t}`),!await Jn(t))throw new Hr(`ccInstallationPath is set to '${t}' but file does not exist.`);let n=await Kr(t);if(!n)throw new Hr(`Unable to detect installation type from configured ccInstallationPath '${t}'.\nExpected a Claude Code cli.js file or native binary.`);let r=await Qr(n.resolvedPath,n.kind);return Fn()&&n.kind===`npm-based`&&W(`SHA256 hash: ${await Kn(n.resolvedPath)}`),W(`Using Claude Code from ccInstallationPath: ${n.resolvedPath} (${n.kind}, v${r})`),ai(n.resolvedPath,n.kind,r,`config`)}let r=await qr();if(r){W(`Checking claude on PATH: ${r}`);let e=await Kr(r);if(!e)W(`Unable to detect installation type from 'claude' on PATH (${r}). Falling back to hardcoded search paths.`);else{let t=await Qr(e.resolvedPath,e.kind);return Fn()&&e.kind===`npm-based`&&W(`SHA256 hash: ${await Kn(e.resolvedPath)}`),W(`Using Claude Code from PATH: ${e.resolvedPath} (${e.kind}, v${t})`),ai(e.resolvedPath,e.kind,t,`path`)}}W(`Collecting candidates from hardcoded search paths...`);let i=await $r();if(i.length===0){if(t.interactive)return null;throw new Hr(ii())}if(i.length===1){let e=i[0];return W(`Using single candidate: ${e.path} (${e.kind}, v${e.version})`),ai(e.path,e.kind,e.version,`search-paths`)}if(!t.interactive)throw new Hr(ri(i));return{version:``,source:`search-paths`,_pendingCandidates:i}}function si(e){return e._pendingCandidates||null}async function ci(e){return W(`Saving selected installation to config: ${e.path}`),await or(t=>{t.ccInstallationPath=e.path}),ai(e.path,e.kind,e.version,`config`)}function li(){return ii()}async function ui(e){let t=await ar(),n=await oi(t,e);if(!n)return{startupCheckInfo:null,pendingCandidates:null};let r=si(n);return r?{startupCheckInfo:null,pendingCandidates:r}:{startupCheckInfo:await di(t,n),pendingCandidates:null}}async function di(e,t){if(!t)return null;if(t.version)try{xt(await ut(t.version))}catch{}let n=t.version,r=e.ccVersion,i=!1;await Jn($n)||(W(`startupCheck: ${$n} not found; backing up cli.js`),await hn(t),i=!0);let a=!1;return t.nativeInstallationPath&&!await Jn(Y)&&(W(`startupCheck: ${Y} not found; backing up native binary`),await gn(t),a=!0),n===r?{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}:(i||(W(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await b.unlink($n),await hn(t)),t.nativeInstallationPath&&!a&&(W(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await Jn(Y)&&await b.unlink(Y),await gn(t)),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t})}function fi({candidates:n,onSelect:i}){let[a,o]=m(0);return r((e,t)=>{t.escape?process.exit(0):t.upArrow?o(e=>e>0?e-1:n.length-1):t.downArrow?o(e=>e<n.length-1?e+1:0):t.return&&i(n[a])}),N(e,{flexDirection:`column`,children:[M(t,{bold:!0,color:`yellow`,children:`No claude executable was found in PATH, and multiple Claude Code installations were found. Please select one:`}),M(t,{children:` `}),n.map((n,r)=>N(e,{children:[N(t,{bold:r===a,color:r===a?`cyan`:void 0,children:[r===a?`❯ `:` `,n.path]}),N(t,{dimColor:!0,children:[` `,`(`,n.kind,`, v`,n.version,`)`]})]},n.path)),M(t,{children:` `}),N(t,{children:[`Your choice will be saved to`,` `,M(t,{color:`blue`,children:`ccInstallationPath`}),` in`,` `,N(t,{color:`blue`,children:[q.replace(h.homedir(),`~`),`/config.json`]}),`.`]}),M(t,{children:` `}),M(t,{dimColor:!0,children:`Use ↑↓ arrows to navigate, Enter to select, Esc to quit`})]})}const pi=async()=>{let e=new i;e.name(`tweakcc`).description(`Command-line tool to customize your Claude Code theme colors, thinking verbs and more.`).version(`3.2.4`).option(`-d, --debug`,`enable debug mode`).option(`-v, --verbose`,`enable verbose debug mode (includes diffs)`).option(`-a, --apply`,`apply saved customizations without interactive UI`),e.parse();let t=e.opts();t.verbose?Rn():t.debug&&Ln();let n=await Qn();if(t.apply){await mi();return}await hi(n)};async function mi(){console.log(`Applying saved customizations to Claude Code...`),console.log(`Configuration saved at: ${J}`);let e=await ar();(!e.settings||Object.keys(e.settings).length===0)&&(console.error(`No saved customizations found in `+J),process.exit(1));try{let t=await ui({interactive:!1});(!t.startupCheckInfo||!t.startupCheckInfo.ccInstInfo)&&(console.error(li()),process.exit(1));let{ccInstInfo:n}=t.startupCheckInfo;n.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${n.nativeInstallationPath}`):console.log(`Found Claude Code at: ${n.cliPath}`),console.log(`Version: ${n.version}`),console.log(`Loading system prompts...`);let r=await pt(n.version);r.success||(console.log(a.red(`
|
|
668
668
|
✖ Error downloading system prompts:`)),console.log(a.red(` ${r.errorMessage}`)),console.log(a.yellow(`
|
|
669
|
-
⚠ System prompts not available - skipping system prompt customizations`))),console.log(`Applying customizations...`),await
|
|
669
|
+
⚠ System prompts not available - skipping system prompt customizations`))),console.log(`Applying customizations...`),await kn(e,n),console.log(`Customizations applied successfully!`),process.exit(0)}catch(e){throw e instanceof Hr&&(console.error(a.red(`Error: ${e.message}`)),process.exit(1)),e}}async function hi(e){try{let t=await ui({interactive:!0});if(t.pendingCandidates){await gi(t.pendingCandidates,e);return}t.startupCheckInfo||(console.error(a.red(li())),process.exit(1)),await _i(t.startupCheckInfo,e)}catch(e){throw e instanceof Hr&&(console.error(a.red(`Error: ${e.message}`)),process.exit(1)),e}}async function gi(e,t){return new Promise((r,i)=>{let o=n(M(fi,{candidates:e,onSelect:async e=>{try{let n=await ci(e),i=await di(await ar(),n);i||(console.error(a.red(`Error: Failed to complete startup check after selection.`)),process.exit(1)),o.unmount(),await _i(i,t),r()}catch(e){i(e)}}}))})}async function _i(e,t){let r=await pt(e.ccInstInfo.version);r.success||(console.log(a.red(`
|
|
670
670
|
✖ Error downloading system prompts:`)),console.log(a.red(` ${r.errorMessage}`)),console.log(a.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
|
|
671
|
-
`))),n(M(
|
|
671
|
+
`))),n(M(zr,{startupCheckInfo:e,configMigrated:t}))}pi();export{Fn as n,W as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as e,t}from"./index.mjs";import n from"node:fs";import{execSync as r}from"node:child_process";import i from"node-lief";const a=Buffer.from(`
|
|
2
|
+
---- Bun! ----
|
|
3
|
+
`);function o(e,t){return e.subarray(t.offset,t.offset+t.length)}function s(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function c(e){return e.endsWith(`/claude`)||e===`claude`||e.endsWith(`/claude.exe`)||e===`claude.exe`}function l(e,t,n){let r=o(e,t.modulesPtr),i=Math.floor(r.length/36);for(let t=0;t<i;t++){let i=d(r,t*36),a=n(i,o(e,i.name).toString(`utf-8`),t);if(a!==void 0)return a}}function u(e){let t=0,n=e.readBigUInt64LE(t);t+=8;let r=s(e,t);t+=8;let i=e.readUInt32LE(t);return t+=4,{byteCount:n,modulesPtr:r,entryPointId:i,compileExecArgvPtr:s(e,t)}}function d(e,t){let n=t,r=s(e,n);n+=8;let i=s(e,n);n+=8;let a=s(e,n);n+=8;let o=s(e,n);n+=8;let c=e.readUInt8(n);n+=1;let l=e.readUInt8(n);n+=1;let u=e.readUInt8(n);return n+=1,{name:r,contents:i,sourcemap:a,bytecode:o,encoding:c,loader:l,moduleFormat:u,side:e.readUInt8(n)}}function f(e){if(e.length<32+a.length)throw Error(`BUN data is too small to contain trailer and offsets`);let n=e.length-a.length,r=e.subarray(n);if(t(`parseBunDataBlob: Expected trailer: ${a.toString(`hex`)}`),t(`parseBunDataBlob: Got trailer: ${r.toString(`hex`)}`),!r.equals(a))throw t(`Expected: ${a.toString(`hex`)}`),t(`Got: ${r.toString(`hex`)}`),Error(`BUN trailer bytes do not match trailer`);let i=e.length-32-a.length;return{bunOffsets:u(e.subarray(i,i+32)),bunData:e}}function p(e){if(e.length<4)throw Error(`Section data too small`);t(`extractBunDataFromSection: sectionData.length=${e.length}`);let n=e.readUInt32LE(0),r=4+n,i=e.length>=8?Number(e.readBigUInt64LE(0)):0,a=8+i;t(`extractBunDataFromSection: u32 header would give size=${n}, expected total=${r}`),t(`extractBunDataFromSection: u64 header would give size=${i}, expected total=${a}`);let o,s;if(e.length>=8&&a<=e.length&&a>=e.length-4096)o=8,s=i,t(`extractBunDataFromSection: detected u64 header format (Bun >= 1.3.4)`);else if(r<=e.length&&r>=e.length-4096)o=4,s=n,t(`extractBunDataFromSection: detected u32 header format (Bun < 1.3.4)`);else throw Error(`Cannot determine section header format: sectionData.length=${e.length}, u64 would expect ${a}, u32 would expect ${r}`);t(`extractBunDataFromSection: bunDataSize from header=${s}`);let c=e.subarray(o,o+s);t(`extractBunDataFromSection: bunDataContent.length=${c.length}`);let{bunOffsets:l,bunData:u}=f(c);return{bunOffsets:l,bunData:u,sectionHeaderSize:o}}function m(e){if(!e.hasOverlay)throw Error(`ELF binary has no overlay data`);let n=e.overlay;if(t(`extractBunDataFromELFOverlay: Overlay size=${n.length} bytes`),n.length<a.length+8+32)throw Error(`ELF overlay data is too small`);let r=n.readBigUInt64LE(n.length-8);if(t(`extractBunDataFromELFOverlay: Total byte count from tail=${r}`),r<4096n||r>2n**32n-1n)throw Error(`ELF total byte count is out of range: ${r}`);let i=n.length-8-a.length,o=n.subarray(i,n.length-8);if(t(`extractBunDataFromELFOverlay: Expected trailer: ${a.toString(`hex`)}`),t(`extractBunDataFromELFOverlay: Got trailer: ${o.toString(`hex`)}`),!o.equals(a))throw Error(`BUN trailer bytes do not match trailer`);let s=n.length-8-a.length-32,c=n.subarray(s,n.length-8-a.length),l=u(c);t(`extractBunDataFromELFOverlay: Offsets.byteCount=${l.byteCount}`);let d=typeof l.byteCount==`bigint`?l.byteCount:BigInt(l.byteCount);if(d>=r)throw Error(`ELF total byte count is out of range`);let f=8+a.length+32,p=n.length-f-Number(d),m=n.subarray(p,n.length-f);return t(`extractBunDataFromELFOverlay: Extracted ${m.length} bytes of data`),{bunOffsets:l,bunData:Buffer.concat([m,c,o])}}function h(e){let t=e.getSegment(`__BUN`);if(!t)throw Error(`__BUN segment not found`);let n=t.getSection(`__bun`);if(!n)throw Error(`__bun section not found`);return p(n.content)}function g(e){let t=e.sections().find(e=>e.name===`.bun`);if(!t)throw Error(`.bun section not found`);return p(t.content)}function _(e){switch(t(`getBunData: Binary format detected as ${e.format}`),e.format){case`MachO`:return h(e);case`PE`:return g(e);case`ELF`:return m(e);default:throw Error(`Unsupported binary format: ${e.format}`)}}function v(e){try{i.logging.disable();let{bunOffsets:n,bunData:r}=_(i.parse(e));return t(`extractClaudeJsFromNativeInstallation: Got bunData, size=${r.length} bytes`),l(r,n,(e,n,i)=>{if(t(`extractClaudeJsFromNativeInstallation: Module ${i}: ${n}`),!c(n))return;let a=o(r,e.contents);return t(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${a.length}`),a.length>0?a:void 0})||(t(`extractClaudeJsFromNativeInstallation: claude module not found in any module`),null)}catch(e){return t(`extractClaudeJsFromNativeInstallation: Error during extraction:`,e),null}}function y(e,t,n){let r=[],i=[];l(e,t,(t,a)=>{let s=o(e,t.name),l;l=n&&c(a)?n:o(e,t.contents);let u=o(e,t.sourcemap),d=o(e,t.bytecode);i.push({name:s,contents:l,sourcemap:u,bytecode:d,encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side}),r.push(s,l,u,d)});let s=0,u=[];for(let e of r)u.push({offset:s,length:e.length}),s+=e.length+1;let d=s,f=i.length*36;s+=f;let p=o(e,t.compileExecArgvPtr),m=s,h=p.length;s+=h+1;let g=s;s+=32;let _=s;s+=a.length;let v=Buffer.allocUnsafe(s);v.fill(0);let y=0;for(let{offset:e,length:t}of u)t>0&&r[y].copy(v,e,0,t),v[e+t]=0,y++;h>0&&(p.copy(v,m,0,h),v[m+h]=0);for(let e=0;e<i.length;e++){let t=i[e],n=e*4,r={name:{offset:u[n].offset,length:u[n].length},contents:{offset:u[n+1].offset,length:u[n+1].length},sourcemap:{offset:u[n+2].offset,length:u[n+2].length},bytecode:{offset:u[n+3].offset,length:u[n+3].length},encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side},a=d+e*36;v.writeUInt32LE(r.name.offset,a),v.writeUInt32LE(r.name.length,a+4),a+=8,v.writeUInt32LE(r.contents.offset,a),v.writeUInt32LE(r.contents.length,a+4),a+=8,v.writeUInt32LE(r.sourcemap.offset,a),v.writeUInt32LE(r.sourcemap.length,a+4),a+=8,v.writeUInt32LE(r.bytecode.offset,a),v.writeUInt32LE(r.bytecode.length,a+4),a+=8,v.writeUInt8(r.encoding,a),v.writeUInt8(r.loader,a+1),v.writeUInt8(r.moduleFormat,a+2),v.writeUInt8(r.side,a+3)}let b={byteCount:g,modulesPtr:{offset:d,length:f},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:m,length:h}},x=g,S=typeof b.byteCount==`bigint`?b.byteCount:BigInt(b.byteCount);return v.writeBigUInt64LE(S,x),x+=8,v.writeUInt32LE(b.modulesPtr.offset,x),v.writeUInt32LE(b.modulesPtr.length,x+4),x+=8,v.writeUInt32LE(b.entryPointId,x),x+=4,v.writeUInt32LE(b.compileExecArgvPtr.offset,x),v.writeUInt32LE(b.compileExecArgvPtr.length,x+4),a.copy(v,_),v}function b(e,t,r,i=!0){let a=t+`.tmp`;if(e.write(a),i){let e=n.statSync(r);n.chmodSync(a,e.mode)}try{n.renameSync(a,t)}catch(e){try{n.existsSync(a)&&n.unlinkSync(a)}catch{}throw e instanceof Error&&`code`in e&&(e.code===`ETXTBSY`||e.code===`EBUSY`||e.code===`EPERM`)?Error(`Cannot update the Claude executable while it is running.
|
|
4
|
+
Please close all Claude instances and try again.`):e}}function x(e,t=8){let n=Buffer.allocUnsafe(t+e.length);return t===8?n.writeBigUInt64LE(BigInt(e.length),0):n.writeUInt32LE(e.length,0),e.copy(n,t),n}function S(n,a,o,s,c){try{t(`repackMachO: Has code signature: ${n.hasCodeSignature}`),n.hasCodeSignature&&(t(`repackMachO: Removing code signature...`),n.removeSignature());let l=n.getSegment(`__BUN`);if(!l)throw Error(`__BUN segment not found`);let u=l.getSection(`__bun`);if(!u)throw Error(`__bun section not found`);let d=x(o,c);t(`repackMachO: Original section size: ${u.size}`),t(`repackMachO: Original segment fileSize: ${l.fileSize}`),t(`repackMachO: Original segment virtualSize: ${l.virtualSize}`),t(`repackMachO: New data size: ${d.length}`),t(`repackMachO: Using header size: ${c}`);let f=d.length-Number(u.size);if(f>0){let e=n.header.cpuType===i.MachO.Header.CPU_TYPE.ARM64,r=e?16384:4096,a=Math.ceil(f/r)*r;t(`repackMachO: CPU type: ${e?`ARM64`:`x86_64`}`),t(`repackMachO: Page size: ${r} bytes`),t(`repackMachO: Need to expand by ${f} bytes`),t(`repackMachO: Rounding up to page-aligned: ${a} bytes`);let o=n.extendSegment(l,a);if(t(`repackMachO: extendSegment returned: ${o}`),!o)throw Error(`Failed to extend __BUN segment`);t(`repackMachO: Section size after extend: ${u.size}`),t(`repackMachO: Segment fileSize after extend: ${l.fileSize}`),t(`repackMachO: Segment virtualSize after extend: ${l.virtualSize}`)}u.content=d,u.size=BigInt(d.length),t(`repackMachO: Final section size: ${u.size}`),t(`repackMachO: Writing modified binary to ${s}...`),b(n,s,a);try{t(`repackMachO: Re-signing binary with ad-hoc signature...`),r(`codesign -s - -f "${s}"`,{stdio:e()?`inherit`:`ignore`}),t(`repackMachO: Code signing completed successfully`)}catch(e){console.warn(`Warning: Failed to re-sign binary. The binary may not run correctly on macOS:`,e)}t(`repackMachO: Write completed successfully`)}catch(e){throw console.error(`repackMachO failed:`,e),e}}function C(e,n,r,i,a){try{let o=e.sections().find(e=>e.name===`.bun`);if(!o)throw Error(`.bun section not found`);let s=x(r,a);t(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),t(`repackPE: New data size: ${s.length}`),t(`repackPE: Using header size: ${a}`),o.content=s,o.virtualSize=BigInt(s.length),o.size=BigInt(s.length),t(`repackPE: Writing modified binary to ${i}...`),b(e,i,n,!1),t(`repackPE: Write completed successfully`)}catch(e){throw console.error(`repackPE failed:`,e),e}}function w(e,n,r,i){try{let a=Buffer.allocUnsafe(r.length+8);r.copy(a,0),a.writeBigUInt64LE(BigInt(r.length),r.length),t(`repackELF: Setting overlay data (${a.length} bytes)`),e.overlay=a,t(`repackELF: Writing modified binary to ${i}...`),b(e,i,n),t(`repackELF: Write completed successfully`)}catch(e){throw console.error(`repackELF failed:`,e),e}}function T(e,t,n){i.logging.disable();let r=i.parse(e),{bunOffsets:a,bunData:o,sectionHeaderSize:s}=_(r),c=y(o,a,t);switch(r.format){case`MachO`:if(!s)throw Error(`sectionHeaderSize is required for Mach-O binaries`);S(r,e,c,n,s);break;case`PE`:if(!s)throw Error(`sectionHeaderSize is required for PE binaries`);C(r,e,c,n,s);break;case`ELF`:w(r,e,c,n);break;default:throw Error(`Unsupported binary format: ${r.format}`)}}export{v as extractClaudeJsFromNativeInstallation,T as repackNativeInstallation};
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./index.mjs";import n from"node:fs";import{execSync as r}from"node:child_process";import i from"node-lief";const a=Buffer.from(`
|
|
2
|
-
---- Bun! ----
|
|
3
|
-
`);function o(e,t){return e.subarray(t.offset,t.offset+t.length)}function s(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function c(e){return e.endsWith(`/claude`)||e===`claude`||e.endsWith(`/claude.exe`)||e===`claude.exe`}function l(e,t,n){let r=o(e,t.modulesPtr),i=Math.floor(r.length/36);for(let t=0;t<i;t++){let i=d(r,t*36),a=n(i,o(e,i.name).toString(`utf-8`),t);if(a!==void 0)return a}}function u(e){let t=0,n=e.readBigUInt64LE(t);t+=8;let r=s(e,t);t+=8;let i=e.readUInt32LE(t);return t+=4,{byteCount:n,modulesPtr:r,entryPointId:i,compileExecArgvPtr:s(e,t)}}function d(e,t){let n=t,r=s(e,n);n+=8;let i=s(e,n);n+=8;let a=s(e,n);n+=8;let o=s(e,n);n+=8;let c=e.readUInt8(n);n+=1;let l=e.readUInt8(n);n+=1;let u=e.readUInt8(n);return n+=1,{name:r,contents:i,sourcemap:a,bytecode:o,encoding:c,loader:l,moduleFormat:u,side:e.readUInt8(n)}}function f(e){if(e.length<32+a.length)throw Error(`BUN data is too small to contain trailer and offsets`);let n=e.length-a.length,r=e.subarray(n);if(t(`parseBunDataBlob: Expected trailer: ${a.toString(`hex`)}`),t(`parseBunDataBlob: Got trailer: ${r.toString(`hex`)}`),!r.equals(a))throw t(`Expected: ${a.toString(`hex`)}`),t(`Got: ${r.toString(`hex`)}`),Error(`BUN trailer bytes do not match trailer`);let i=e.length-32-a.length;return{bunOffsets:u(e.subarray(i,i+32)),bunData:e}}function p(e){if(e.length<4)throw Error(`Section data too small`);t(`extractBunDataFromSection: sectionData.length=${e.length}`);let n=e.readUInt32LE(0);t(`extractBunDataFromSection: bunDataSize from header=${n}`);let r=e.subarray(4,4+n);t(`extractBunDataFromSection: bunDataContent.length=${r.length}`);let{bunOffsets:i,bunData:a}=f(r);return{bunOffsets:i,bunData:a}}function m(e){if(!e.hasOverlay)throw Error(`ELF binary has no overlay data`);let n=e.overlay;if(t(`extractBunDataFromELFOverlay: Overlay size=${n.length} bytes`),n.length<a.length+8+32)throw Error(`ELF overlay data is too small`);let r=n.readBigUInt64LE(n.length-8);if(t(`extractBunDataFromELFOverlay: Total byte count from tail=${r}`),r<4096n||r>2n**32n-1n)throw Error(`ELF total byte count is out of range: ${r}`);let i=n.length-8-a.length,o=n.subarray(i,n.length-8);if(t(`extractBunDataFromELFOverlay: Expected trailer: ${a.toString(`hex`)}`),t(`extractBunDataFromELFOverlay: Got trailer: ${o.toString(`hex`)}`),!o.equals(a))throw Error(`BUN trailer bytes do not match trailer`);let s=n.length-8-a.length-32,c=n.subarray(s,n.length-8-a.length),l=u(c);t(`extractBunDataFromELFOverlay: Offsets.byteCount=${l.byteCount}`);let d=typeof l.byteCount==`bigint`?l.byteCount:BigInt(l.byteCount);if(d>=r)throw Error(`ELF total byte count is out of range`);let f=8+a.length+32,p=n.length-f-Number(d),m=n.subarray(p,n.length-f);return t(`extractBunDataFromELFOverlay: Extracted ${m.length} bytes of data`),{bunOffsets:l,bunData:Buffer.concat([m,c,o])}}function h(e){let t=e.getSegment(`__BUN`);if(!t)throw Error(`__BUN segment not found`);let n=t.getSection(`__bun`);if(!n)throw Error(`__bun section not found`);return p(n.content)}function g(e){let t=e.sections().find(e=>e.name===`.bun`);if(!t)throw Error(`.bun section not found`);return p(t.content)}function _(e){switch(t(`getBunData: Binary format detected as ${e.format}`),e.format){case`MachO`:return h(e);case`PE`:return g(e);case`ELF`:return m(e);default:throw Error(`Unsupported binary format: ${e.format}`)}}function v(e){try{i.logging.disable();let{bunOffsets:n,bunData:r}=_(i.parse(e));return t(`extractClaudeJsFromNativeInstallation: Got bunData, size=${r.length} bytes`),l(r,n,(e,n,i)=>{if(t(`extractClaudeJsFromNativeInstallation: Module ${i}: ${n}`),!c(n))return;let a=o(r,e.contents);return t(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${a.length}`),a.length>0?a:void 0})||(t(`extractClaudeJsFromNativeInstallation: claude module not found in any module`),null)}catch(e){return t(`extractClaudeJsFromNativeInstallation: Error during extraction:`,e),null}}function y(e,t,n){let r=[],i=[];l(e,t,(t,a)=>{let s=o(e,t.name),l;l=n&&c(a)?n:o(e,t.contents);let u=o(e,t.sourcemap),d=o(e,t.bytecode);i.push({name:s,contents:l,sourcemap:u,bytecode:d,encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side}),r.push(s,l,u,d)});let s=0,u=[];for(let e of r)u.push({offset:s,length:e.length}),s+=e.length+1;let d=s,f=i.length*36;s+=f;let p=o(e,t.compileExecArgvPtr),m=s,h=p.length;s+=h+1;let g=s;s+=32;let _=s;s+=a.length;let v=Buffer.allocUnsafe(s);v.fill(0);let y=0;for(let{offset:e,length:t}of u)t>0&&r[y].copy(v,e,0,t),v[e+t]=0,y++;h>0&&(p.copy(v,m,0,h),v[m+h]=0);for(let e=0;e<i.length;e++){let t=i[e],n=e*4,r={name:{offset:u[n].offset,length:u[n].length},contents:{offset:u[n+1].offset,length:u[n+1].length},sourcemap:{offset:u[n+2].offset,length:u[n+2].length},bytecode:{offset:u[n+3].offset,length:u[n+3].length},encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side},a=d+e*36;v.writeUInt32LE(r.name.offset,a),v.writeUInt32LE(r.name.length,a+4),a+=8,v.writeUInt32LE(r.contents.offset,a),v.writeUInt32LE(r.contents.length,a+4),a+=8,v.writeUInt32LE(r.sourcemap.offset,a),v.writeUInt32LE(r.sourcemap.length,a+4),a+=8,v.writeUInt32LE(r.bytecode.offset,a),v.writeUInt32LE(r.bytecode.length,a+4),a+=8,v.writeUInt8(r.encoding,a),v.writeUInt8(r.loader,a+1),v.writeUInt8(r.moduleFormat,a+2),v.writeUInt8(r.side,a+3)}let b={byteCount:g,modulesPtr:{offset:d,length:f},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:m,length:h}},x=g,S=typeof b.byteCount==`bigint`?b.byteCount:BigInt(b.byteCount);return v.writeBigUInt64LE(S,x),x+=8,v.writeUInt32LE(b.modulesPtr.offset,x),v.writeUInt32LE(b.modulesPtr.length,x+4),x+=8,v.writeUInt32LE(b.entryPointId,x),x+=4,v.writeUInt32LE(b.compileExecArgvPtr.offset,x),v.writeUInt32LE(b.compileExecArgvPtr.length,x+4),a.copy(v,_),v}function b(e,t,r,i=!0){let a=t+`.tmp`;if(e.write(a),i){let e=n.statSync(r);n.chmodSync(a,e.mode)}try{n.renameSync(a,t)}catch(e){try{n.existsSync(a)&&n.unlinkSync(a)}catch{}throw e instanceof Error&&`code`in e&&(e.code===`ETXTBSY`||e.code===`EBUSY`||e.code===`EPERM`)?Error(`Cannot update the Claude executable while it is running.
|
|
4
|
-
Please close all Claude instances and try again.`):e}}function x(e){let t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function S(n,a,o,s){try{t(`repackMachO: Has code signature: ${n.hasCodeSignature}`),n.hasCodeSignature&&(t(`repackMachO: Removing code signature...`),n.removeSignature());let c=n.getSegment(`__BUN`);if(!c)throw Error(`__BUN segment not found`);let l=c.getSection(`__bun`);if(!l)throw Error(`__bun section not found`);let u=x(o);t(`repackMachO: Original section size: ${l.size}`),t(`repackMachO: Original segment fileSize: ${c.fileSize}`),t(`repackMachO: Original segment virtualSize: ${c.virtualSize}`),t(`repackMachO: New data size: ${u.length}`);let d=u.length-Number(l.size);if(d>0){let e=n.header.cpuType===i.MachO.Header.CPU_TYPE.ARM64,r=e?16384:4096,a=Math.ceil(d/r)*r;t(`repackMachO: CPU type: ${e?`ARM64`:`x86_64`}`),t(`repackMachO: Page size: ${r} bytes`),t(`repackMachO: Need to expand by ${d} bytes`),t(`repackMachO: Rounding up to page-aligned: ${a} bytes`);let o=n.extendSegment(c,a);if(t(`repackMachO: extendSegment returned: ${o}`),!o)throw Error(`Failed to extend __BUN segment`);t(`repackMachO: Section size after extend: ${l.size}`),t(`repackMachO: Segment fileSize after extend: ${c.fileSize}`),t(`repackMachO: Segment virtualSize after extend: ${c.virtualSize}`)}l.content=u,l.size=BigInt(u.length),t(`repackMachO: Final section size: ${l.size}`),t(`repackMachO: Writing modified binary to ${s}...`),b(n,s,a);try{t(`repackMachO: Re-signing binary with ad-hoc signature...`),r(`codesign -s - -f "${s}"`,{stdio:e()?`inherit`:`ignore`}),t(`repackMachO: Code signing completed successfully`)}catch(e){console.warn(`Warning: Failed to re-sign binary. The binary may not run correctly on macOS:`,e)}t(`repackMachO: Write completed successfully`)}catch(e){throw console.error(`repackMachO failed:`,e),e}}function C(e,n,r,i){try{let a=e.sections().find(e=>e.name===`.bun`);if(!a)throw Error(`.bun section not found`);let o=x(r);t(`repackPE: Original section size: ${a.size}, virtual size: ${a.virtualSize}`),t(`repackPE: New data size: ${o.length}`),a.content=o,a.virtualSize=BigInt(o.length),a.size=BigInt(o.length),t(`repackPE: Writing modified binary to ${i}...`),b(e,i,n,!1),t(`repackPE: Write completed successfully`)}catch(e){throw console.error(`repackPE failed:`,e),e}}function w(e,n,r,i){try{let a=Buffer.allocUnsafe(r.length+8);r.copy(a,0),a.writeBigUInt64LE(BigInt(r.length),r.length),t(`repackELF: Setting overlay data (${a.length} bytes)`),e.overlay=a,t(`repackELF: Writing modified binary to ${i}...`),b(e,i,n),t(`repackELF: Write completed successfully`)}catch(e){throw console.error(`repackELF failed:`,e),e}}function T(e,t,n){i.logging.disable();let r=i.parse(e),{bunOffsets:a,bunData:o}=_(r),s=y(o,a,t);switch(r.format){case`MachO`:S(r,e,s,n);break;case`PE`:C(r,e,s,n);break;case`ELF`:w(r,e,s,n);break;default:throw Error(`Unsupported binary format: ${r.format}`)}}export{v as extractClaudeJsFromNativeInstallation,T as repackNativeInstallation};
|