tweakcc 3.4.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,671 +1,29 @@
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 j from"gray-matter";import{Fragment as M,jsx as N,jsxs as P}from"react/jsx-runtime";import F from"process";import I from"which";import{WASMagic as L}from"wasmagic";import{globbySync as R}from"globby";let z=null;async function B(){if(z!==null)return z;try{return await import(`node-lief`),z=await import(`./nativeInstallation-DBmBL-fs.mjs`),z}catch(e){return G(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&G(e),null}}async function ee(e){let t=await B();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function te(e,t,n){let r=await B();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 ne=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},re=(e,t)=>{let n=ne(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);U(i,r,n,e.startIndex,e.endIndex),i=r}return i};function ie(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 ae=(e,t)=>{let n=ie(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),U(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),U(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),U(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},oe=e=>{let t=e.match(/function ([$\w]+)\(([$\w,]+)\)\{if\([$\w]+\.includes\("\[(1m|2m)\]"\)\|\|[$\w]+\?\.includes\([$\w]+\)&&[$\w]+\([$\w]+\)\)return 1e6;return ([$\w]+)\}/);if(t&&t.index!==void 0)return t.index+t[0].indexOf(`{`)+1;let n=e.match(/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/);return n&&n.index!==void 0?n.index+n[0].indexOf(`{`)+1:(console.error(`patch: context limit: failed to find match`),null)},se=e=>{let t=oe(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 U(e,r,n,t,t),r},ce=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}},le=(e,t)=>{let n=ce(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return U(e,r,t,n.startIndex,n.endIndex),r}else return e},ue=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}},de=e=>{let t=ue(e);if(!t)return null;let n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return U(e,n,``,t.startIndex,t.endIndex),n},V=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]]}},H=(e,t)=>{let n=V(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 U(e,s,o,r.startIndex,r.endIndex),s},fe=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]]}},pe=(e,t)=>{let n=fe(e);if(!n)return null;let r=n.identifiers?.[0],i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return U(e,a,i,n.startIndex,n.endIndex),a},me=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},he=(e,t)=>{let n=me(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);U(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},ge=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}},_e=(e,t)=>{let n=ge(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return U(e,i,r,n.startIndex,n.endIndex),i},ve=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}},ye=(e,t)=>{let n=ve(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 U(e,i,r,n.startIndex,n.endIndex),i},be=e=>{let t=e.match(/[,;]([$\w]+)=\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]/s);if(t&&t.index!=null)return{startIndex:t.index+1,endIndex:t.index+t[0].length,identifiers:[t[1]]};let n=e.match(/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s);return n&&n.index!=null?{startIndex:n.index+1,endIndex:n.index+n[0].length,identifiers:[n[1],`old_format`]}:(console.error(`patch: thinker verbs: failed to find verbsMatch`),null)},xe=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]]}},Se=(e,t)=>{let n=be(e);if(!n)return null;let r=n,i=r.identifiers?.[0],a=r.identifiers?.[1]===`old_format`,o=a?`${i}=${JSON.stringify({words:t})}`:`${i}=${JSON.stringify(t)}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);if(U(e,s,o,r.startIndex,r.endIndex),a){let e=xe(s);if(!e)return null;let t=e,n=`function ${t.identifiers?.[0]}(){return ${i}.words}`,r=s.slice(0,t.startIndex)+n+s.slice(t.endIndex);return U(s,r,n,t.startIndex,t.endIndex),r}return s},Ce=e=>{let t=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground"\},([$\w]+)\.createElement\([$\w]+,\{color:"subtle"\},([$\w]+)\.pointer," "\),[$\w]+\.createElement\([$\w]+,\{color:"text"\},([$\w]+)\)\)/);if(t&&t.index!=null)return{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[5],`new_format`]};let n=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground",color:"text"\},"> ",([$\w]+)\+" "\);/);return n&&n.index!=null?{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1],n[2],n[3],`old_format`]}:(console.error(`patch: messageDisplayMatch: failed to find user message display pattern`),null)},we=(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=Ce(e);if(!m)return console.error(`^ patch: userMessageDisplay: getUserMessageDisplayLocation returned null`),null;let h=On(e);if(!h)return console.error(`^ patch: userMessageDisplay: failed to find chalk variable`),null;let g=Rn(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,D]=m.identifiers,O=`"`+t.replace(/\{\}/g,`"+${E}+"`)+`"`,k;k=`
3
- return ${w}.createElement(
4
- ${g},
5
- ${S},
6
- ${w}.createElement(
7
- ${T},
8
- ${y},
9
- ${C?_+`(`:``}${O}${C?`)`:``}
10
- )
11
- );`;let A=e.slice(0,m.startIndex)+k+e.slice(m.endIndex);return U(e,A,k,m.startIndex,m.endIndex),A},Te=e=>{let t=e.match(/else if\(([$\w]+)\.type==="solid"\)return ([$\w]+)\.createElement\(([$\w]+),\{key:([$\w]+),color:[$\w]+\.color\},[$\w]+\.createElement\([$\w]+,null,([$\w]+)\.text\)\);/);return!t||t.index===void 0?(console.error(`patch: inputPatternHighlighters: failed to find solid match renderer pattern`),null):{startIndex:t.index+t[0].length,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[3],t[4],t[5]]}},Ee=e=>{let t=e.match(/\b([$\w]+)\.push\(\{start:[$\w]+,end:[$\w]+\+[$\w]+\.length,style:\{type:"solid",color:"warning"\}/);return!t||t.index===void 0?(console.error(`patch: inputPatternHighlighters: failed to find match pushes pattern`),null):{index:t.index,rangesVar:t[1]}},De=(e,t)=>{let n=Math.max(0,t-100),r=e.slice(n,t),i=/\b[$\w]+=([$\w]+(?:\.default)?)\.useMemo\(/g,a=null,o;for(;(o=i.exec(r))!==null;)a=o;return a?a[1]:(console.error(`patch: inputPatternHighlighters: failed to find useMemo pattern`),null)},Oe=(e,t)=>{let n=Math.max(0,t-4e3),r=e.slice(n,t).match(/\binput:([$\w]+),/);return r?r[1]:(console.error(`patch: inputPatternHighlighters: failed to find input variable pattern`),null)},ke=(e,t)=>{let n=De(e,t);if(!n)return null;let r=Oe(e,t);if(!r)return null;let i=Math.max(0,t-500),a=e.slice(i,t),o=/\b[$\w]+=([$\w]+(?:\.default)?)\.useMemo\(\(\)=>\{[^}]*\},\[[^\]]*\]\),?/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(!s)return console.error(`patch: inputPatternHighlighters: failed to find useMemo insertion point`),null;let l=i+s.index+s[0].length;return{startIndex:l,endIndex:l,identifiers:[n,r]}},Ae=(e,t,n)=>{let r=Math.min(e.length,t+600),i=e.slice(t,r),a=RegExp(`return ${W(n)}}`),o=i.match(a);if(!o||o.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find return statement`),null;let s=t+o.index;return{startIndex:s,endIndex:s,identifiers:[n]}},je=(e,t)=>{let n=e;if(t.foregroundColor){let e=t.foregroundColor.match(/\d+/g);e&&(n+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor){let e=t.backgroundColor.match(/\d+/g);e&&(n+=`.bgRgb(${e.join(`,`)})`)}return t.styling.includes(`bold`)&&(n+=`.bold`),t.styling.includes(`italic`)&&(n+=`.italic`),t.styling.includes(`underline`)&&(n+=`.underline`),t.styling.includes(`strikethrough`)&&(n+=`.strikethrough`),t.styling.includes(`inverse`)&&(n+=`.inverse`),n},Me=(e,t)=>{let n=t.filter(e=>e.enabled);if(n.length===0)return null;let r=On(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i=e,a=Te(e);if(!a)return console.error(`^ patch: inputPatternHighlighters: solidLocation returned null`),null;let[o,s,c,l,u]=a.identifiers,d=`else if(${o}.type==="custom")return ${s}.createElement(${c},{key:${l}},${o}.fn(${o}.format.replace(/\\{MATCH\\}/g,${u}.text)));`;i=e.slice(0,a.startIndex)+d+e.slice(a.endIndex),U(e,i,d,a.startIndex,a.endIndex);let f=Ee(i);if(!f)return console.error(`^ patch: inputPatternHighlighters: matchPushes returned null`),null;let p=ke(i,f.index);if(!p)return console.error(`^ patch: inputPatternHighlighters: useMemoLocation returned null`),null;let[m,h]=p.identifiers,g=``;for(let e=0;e<n.length;e++){let t=n[e],r=t.regexFlags;r.includes(`g`)||(r+=`g`);let i=sr(new RegExp(t.regex,r));g+=`matchedTweakccReplacements${e}=${m}.useMemo(()=>{return[...${h}.matchAll(${i})].map(m=>({start:m.index,end:m.index+m[0].length}))},[${h}]),`}let _=i;i=i.slice(0,p.startIndex)+g+i.slice(p.endIndex),U(_,i,g,p.startIndex,p.endIndex);let v=Ee(i);if(!v)return console.error(`^ patch: inputPatternHighlighters: matchPushes2 returned null`),null;let y=Ae(i,v.index,v.rangesVar);if(!y)return console.error(`^ patch: inputPatternHighlighters: rangePushesLocation returned null`),null;let b=y.identifiers[0],x=``;for(let e=0;e<n.length;e++){let t=n[e],i=je(r,t),a=JSON.stringify(t.format);x+=`for(let matchedTweakccReplacement of matchedTweakccReplacements${e}){${b}.push({start:matchedTweakccReplacement.start,end:matchedTweakccReplacement.end,style:{type:"custom",fn:${i},format:${a}},priority:100})}`}let S=i;return i=i.slice(0,y.startIndex)+x+i.slice(y.endIndex),U(S,i,x,y.startIndex,y.endIndex),i},Ne=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}},Pe=e=>{let t=Ne(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return U(e,r,n,t.startIndex,t.endIndex),r},Fe=e=>{let t=e.match(/(case"thinking":)\{if\(![$\w]+&&![$\w]+\)return null;(return [$\w]+\.createElement\([$\w]+,\{addMargin:[$\w]+,param:[$\w]+,isTranscriptMode:)([$\w]+)(,verbose:[$\w]+,hideInTranscript:[$\w]+&&!\(![$\w]+\|\|[$\w]+===[$\w]+\)\})\)\}/);if(t&&t.index!==void 0){let e=t.index;return{startIndex:e,endIndex:e+t[0].length,identifiers:[t[1],t[2],t[4],`new_format`]}}let n=e.match(/(case"thinking":)if\([$\w!&]+\)return null;([$\w.]+\.createElement\([$\w]+,\{addMargin:[$\w]+,param:[$\w]+,isTranscriptMode:)([$\w]+)(,verbose:[$\w]+\s*\})\)/);if(n&&n.index!==void 0){let e=n.index;return{startIndex:e,endIndex:e+n[0].length,identifiers:[n[1],n[2],n[4]]}}return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null},Ie=e=>{let t=Fe(e);if(!t)return null;let n=t.identifiers[3]===`new_format`,r;r=n?`${t.identifiers[0]}{${t.identifiers[1]}true${t.identifiers[2]})}`:`${t.identifiers[0]}${t.identifiers[1]}true${t.identifiers[2]}`;let i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return U(e,i,r,t.startIndex,t.endIndex),i},Le=(e,t)=>{let n=e,r=!1;if(t.plan){let e=/(agentType\s*:\s*"Plan"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/,i=n.match(e);if(i){let a=n.replace(e,`$1${t.plan}$2`);a!==n&&(U(n,a,t.plan,i.index,i.index+i[0].length),n=a,r=!0)}}if(t.explore){let e=/(agentType\s*:\s*"Explore"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/,i=n.match(e);if(i){let a=n.replace(e,`$1${t.explore}$2`);a!==n&&(U(n,a,t.explore,i.index,i.index+i[0].length),n=a,r=!0)}}if(t.generalPurpose){let e=/(\b[$\w]+\s*=\s*\{agentType\s*:\s*"general-purpose"[\s\S]{0,2500}?)(\})/,i=n.match(e);if(i){let a=i[1],o=i[2],s;s=a.includes(`model:`)?a.replace(/(model\s*:\s*")[^"]+(")/,`$1${t.generalPurpose}$2`)+o:a+`${a.trim().endsWith(`,`)?``:`,`}model:"${t.generalPurpose}"`+o;let c=n.replace(e,s);c!==n&&(U(n,c,t.generalPurpose,i.index,i.index+i[0].length),n=c,r=!0)}}return r?n:null},Re=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}},ze=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}},Be=(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),U(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(_),U(v,s,`),`,_,_),{content:s,closingParenIndex:_+2}},Ve=(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 U(f,p,d,l,l),p},He=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\\(${W(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}},Ue=(e,t,n,r=!0,i=!0)=>{let a=Re(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);U(e,s,o,a.endIndex,a.endIndex);let c=On(e);if(!c)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let l=Ln(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let u=Pn(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;let d=Rn(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find Box component`),null;if(r){let e=ze(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),U(r,s,n,e.startIndex,e.endIndex)}if(i){let e=He(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),U(i,s,r,e.startIndex,e.endIndex)}let f=-1;if(r){let e=Be(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=Ve(s,f,u,d,l,c,n);if(!e)return console.error(`patch: patchesAppliedIndication: patch 5 failed`),null;s=e}return s};async function We(e){let t=E.join(vr,`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(vr,{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 Ge=()=>E.join(J,`systemPromptOriginalHashes.json`),Ke=()=>E.join(J,`systemPromptAppliedHashes.json`),qe=(e,t)=>`${e}-${t}`,Je=e=>A.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),Ye=async()=>{try{let e=await y.readFile(Ge(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Xe=async e=>{await y.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await y.writeFile(Ge(),JSON.stringify(t,null,2),`utf8`)},Ze=async e=>{let t=await Ye(),n=0;for(let r of e.prompts){let e=qe(r.id,r.version);t[e]||(t[e]=Je(ot(r.pieces,r.identifiers,r.identifierMap)),n++)}return await Xe(t),n},Qe=async(e,t)=>(await Ye())[qe(e,t)],$e=async()=>{try{let e=await y.readFile(Ke(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},et=async e=>{await y.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await y.writeFile(Ke(),JSON.stringify(t,null,2),`utf8`)},tt=async(e,t)=>{let n=await $e();n[e]=t,await et(n)},nt=async()=>{let e=await $e(),t={};for(let n of Object.keys(e))t[n]=null;await et(t)},rt=async e=>{try{let t=await $e();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(Je((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}},it=e=>{let t=j(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,contentLineOffset:o}},at=(e,t)=>{let n=t||ot(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),j.stringify(n,i,{delimiters:[`<!--`,`-->`]})},ot=(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},st=(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},ct=e=>E.join(_r,`${e}.md`),lt=async e=>{try{return await y.access(ct(e)),!0}catch{return!1}},ut=async e=>{let t=ct(e);return it(await y.readFile(t,`utf-8`))},dt=async(e,t)=>{let n=ct(e);await y.writeFile(n,t,`utf-8`)},ft=async(e,t)=>{let n=ct(e),r=j(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 dt(e,j.stringify(r.content,a,{delimiters:[`<!--`,`-->`]}))},pt=(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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`),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}},mt=(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=pt(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},ht=async(e,t,n,r,i,a,o,s)=>{let c=n.split(`
14
- `),l=r.split(`
15
- `),u=i.split(`
16
- `),d=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`),f=mt(c,l),p=mt(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>
17
- <html>
18
- <head>
19
- <meta charset="UTF-8">
20
- <title>Diff: ${d(t)} (${d(e)})</title>
21
- <style>
22
- body {
23
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
24
- margin: 0;
25
- padding: 20px;
26
- background: #f5f5f5;
27
- }
28
- .header {
29
- background: white;
30
- padding: 20px;
31
- border-radius: 8px;
32
- margin-bottom: 20px;
33
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
34
- }
35
- h1 {
36
- margin: 0 0 10px 0;
37
- color: #333;
38
- }
39
- .version-info {
40
- color: #666;
41
- font-size: 14px;
42
- }
43
- .warning {
44
- background: #fff3cd;
45
- border-left: 4px solid #ffc107;
46
- padding: 15px;
47
- margin-bottom: 20px;
48
- border-radius: 4px;
49
- }
50
- .warning code {
51
- background: rgba(0,0,0,0.1);
52
- padding: 2px 6px;
53
- border-radius: 3px;
54
- font-family: 'Consolas', 'Monaco', monospace;
55
- font-size: 13px;
56
- }
57
- .diff-panels {
58
- display: grid;
59
- grid-template-columns: 1fr 1fr;
60
- gap: 20px;
61
- margin-bottom: 20px;
62
- }
63
- .diff-container {
64
- background: white;
65
- border-radius: 8px;
66
- overflow: hidden;
67
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
68
- }
69
- .diff-header {
70
- background: #f8f9fa;
71
- padding: 12px 15px;
72
- font-weight: bold;
73
- border-bottom: 2px solid #dee2e6;
74
- font-family: 'Consolas', 'Monaco', monospace;
75
- font-size: 14px;
76
- }
77
- .diff-content {
78
- padding: 0;
79
- font-family: 'Consolas', 'Monaco', monospace;
80
- font-size: 13px;
81
- line-height: 1.5;
82
- overflow-x: auto;
83
- max-height: 600px;
84
- overflow-y: auto;
85
- }
86
- .line {
87
- padding: 2px 10px;
88
- white-space: pre-wrap;
89
- word-wrap: break-word;
90
- }
91
- .line .line-num {
92
- display: inline-block;
93
- min-width: 50px;
94
- margin-right: 10px;
95
- color: #6a737d;
96
- text-align: right;
97
- user-select: none;
98
- font-size: 12px;
99
- }
100
- .line .prefix {
101
- display: inline-block;
102
- width: 20px;
103
- font-weight: bold;
104
- user-select: none;
105
- }
106
- .removed {
107
- background: #ffebe9;
108
- color: #24292e;
109
- }
110
- .removed .prefix {
111
- color: #d73a49;
112
- }
113
- .added {
114
- background: #e6ffed;
115
- color: #24292e;
116
- }
117
- .added .prefix {
118
- color: #22863a;
119
- }
120
- .unchanged {
121
- background: #ffffff;
122
- color: #24292e;
123
- }
124
- .unchanged .prefix {
125
- color: #6a737d;
126
- }
127
- mark {
128
- background: rgba(255, 200, 0, 0.4);
129
- padding: 0;
130
- border-radius: 2px;
131
- }
132
- .removed mark {
133
- background: rgba(215, 58, 73, 0.3);
134
- }
135
- .added mark {
136
- background: rgba(34, 134, 58, 0.3);
137
- }
138
- @media (max-width: 1200px) {
139
- .diff-panels {
140
- grid-template-columns: 1fr;
141
- }
142
- }
143
- </style>
144
- </head>
145
- <body>
146
- <div class="header">
147
- <h1>${d(t)}</h1>
148
- <div class="version-info">
149
- <strong>Old Version:</strong> ${d(a)} →
150
- <strong>New Version:</strong> ${d(o)}
151
- </div>
152
- </div>
153
-
154
- <div class="warning">
155
- <strong>⚠️ Version Mismatch Warning</strong><br>
156
- Your customized prompt file is based on version ${d(a)},
157
- but Claude Code is now using version ${d(o)}.
158
- Review the differences below to understand both your customizations and the upstream changes.<br><br>
159
- <strong>File:</strong> <code>${d(s)}</code><br><br>
160
- When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${d(o)}</strong>.
161
- </div>
162
-
163
- <div class="diff-panels">
164
- <div class="diff-container">
165
- <div class="diff-header">Your Customizations (v${d(a)} → User)</div>
166
- <div class="diff-content">
167
- ${m} </div>
168
- </div>
169
-
170
- <div class="diff-container">
171
- <div class="diff-header">Upstream Changes (v${d(a)} → v${d(o)})</div>
172
- <div class="diff-content">
173
- ${h} </div>
174
- </div>
175
- </div>
176
- </body>
177
- </html>`,_=E.join(_r,`${e}.diff.html`);return await y.writeFile(_,g,`utf-8`),_},gt=async e=>{let t={id:e.id,name:e.name,description:e.description,action:`skipped`,newVersion:e.version};if(!await lt(e.id)){let n=at(e);return await dt(e.id,n),t.action=`created`,t}let n=await ut(e.id);if(t.oldVersion=n.ccVersion,await ft(e.id,e.identifierMap),n.ccVersion&&e.version){let r=st(n.ccVersion,e.version);if(r===0)return t.action=`skipped`,t;if(r!=0){let r=await Qe(e.id,n.ccVersion),i=Je(n.content);if(!r||r!==i){t.action=`conflict`;let r=n.content;try{let t=(await We(n.ccVersion)).prompts.find(t=>t.id===e.id);t&&(r=ot(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=ot(e.pieces,e.identifiers,e.identifierMap),o=ct(e.id);t.diffHtmlPath=await ht(e.id,e.name,r,n.content,i,n.ccVersion,e.version,o)}else{let n=at(e);await dt(e.id,n),t.action=`updated`}}}return t},_t=async e=>{let t={ccVersion:e,results:[]},n=await We(e);await Ze(n),await y.mkdir(_r,{recursive:!0});for(let e of n.prompts)try{let n=await gt(e);t.results.push(n)}catch(t){throw console.log(a.red(`Failed to sync prompt ${e.id}:`)),t}return t};let vt=null,yt=null;const bt=async e=>{try{return vt=await We(e),yt=e,{success:!0}}catch(e){return vt=null,yt=null,e instanceof Error?{success:!1,errorMessage:e.message}:{success:!1,errorMessage:`Unknown error occurred while downloading system prompts`}}},xt=e=>e.replace(/[^\x00-\x7F]/g,e=>{let t=`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`;return`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}|${t})`}),St=e=>e.replace(/[^\x00-\x7F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),Ct=(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=xt(a.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).replace(/\n/g,`(?:
178
- |\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},wt=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
- `){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},Tt=(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
- `)},Et=(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=St(c)),c},Dt=async(e,t=!1,n)=>{if(!vt||yt!==e)return[];let r=vt,i=[];for(let a of r.prompts){let r=Ct(a.pieces,e,n),o=E.join(_r,`${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=it(s);i.push({promptId:a.id,prompt:c,regex:r,getInterpolatedContent:r=>{let i=r.slice(1);return Et(c.content,a.identifiers,a.identifierMap,i,e,t,n)},pieces:a.pieces,identifiers:a.identifiers,identifierMap:a.identifierMap})}return i},Ot=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(` ${_r}/${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 ${_r} 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()}},kt=e=>/\\u[0-9a-fA-F]{4}/.test(e),At=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},jt=async(e,t,n)=>{let r=n??kt(e);r&&G(`Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts`);let i=At(e);i&&G(`Extracted BUILD_TIME from cli.js: ${i}`);let o=await Dt(t,r,i);G(`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=wt(r);if(e.size>0){let r=ct(t),i=n.content.split(`
181
- `);for(let[t,a]of e){let e=t+(n.contentLineOffset||0),o=i[t-1]||``;console.log(Tt(r,e,o,a)),console.log()}continue}}let m=ot(l,u,d).trim(),h=m.length,g=n.content.length;s+=h,c+=g,h!==g&&(K(`\n Character count difference for ${n.name}:`),K(` Original baseline: ${h} chars`),K(` User's version: ${g} chars`),K(` Difference: ${h-g} chars`),Math.abs(h-g)<200&&(K(`\n Original baseline content:\n${m}`),K(`\n User's content:\n${n.content}`))),K(`\nFound match for prompt: ${n.name}`),K(` Match location: index ${f.index}, length ${f[0].length}`),K(` Original content (first 100 chars): ${f[0].substring(0,100)}...`),K(` Replacement content (first 100 chars): ${r.substring(0,100)}...`),K(` Captured variables: ${f.slice(1).join(`, `)}`),K(` 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 tt(t,Je(n.content)),U(_,e,y,a,a+v)}else{console.log(a.yellow(`Could not find system prompt "${n.name}" in cli.js (using regex ${sr(o)})`)),K(`\n Debug info for ${n.name}:`),K(` Regex pattern (first 200 chars): ${r.substring(0,200).replace(/\n/g,`\\n`)}...`),K(` Trying to match pattern in cli.js...`);try{K(` Partial match result: ${e.match(new RegExp(r.substring(0,100)))?`found partial`:`no match`}`)}catch{K(` 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}},Mt=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 ${W(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\\(!${W(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]}},Nt=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`):U(a,i,``,0,0);let o=i;i=i.replace(n,``),i===o?console.warn(`patch: fixLspSupport: startupTimeout validation not found`):U(o,i,``,0,0);let s=i;i=i.replace(r,``),i===s?console.warn(`patch: fixLspSupport: shutdownTimeout validation not found`):U(s,i,``,0,0);let c=Mt(i);if(!c||!c.identifiers)return null;let[l,u]=c.identifiers,d=`
182
- const path = await import('path');
183
- const ext = path.extname(${l}).toLowerCase();
184
- const langMap = {
185
- '.ts': 'typescript',
186
- '.tsx': 'typescriptreact',
187
- '.js': 'javascript',
188
- '.jsx': 'javascriptreact',
189
- '.mjs': 'javascript',
190
- '.cjs': 'javascript',
191
- '.mts': 'typescript',
192
- '.cts': 'typescript',
193
- '.py': 'python',
194
- '.pyi': 'python',
195
- '.pyw': 'python',
196
- '.rs': 'rust',
197
- '.go': 'go',
198
- '.java': 'java',
199
- '.kt': 'kotlin',
200
- '.kts': 'kotlin',
201
- '.scala': 'scala',
202
- '.sc': 'scala',
203
- '.groovy': 'groovy',
204
- '.c': 'c',
205
- '.cpp': 'cpp',
206
- '.cc': 'cpp',
207
- '.cxx': 'cpp',
208
- '.c++': 'cpp',
209
- '.h': 'c',
210
- '.hpp': 'cpp',
211
- '.hh': 'cpp',
212
- '.hxx': 'cpp',
213
- '.h++': 'cpp',
214
- '.cs': 'csharp',
215
- '.csx': 'csharp',
216
- '.html': 'html',
217
- '.htm': 'html',
218
- '.css': 'css',
219
- '.scss': 'scss',
220
- '.sass': 'sass',
221
- '.less': 'less',
222
- '.php': 'php',
223
- '.phtml': 'php',
224
- '.php3': 'php',
225
- '.php4': 'php',
226
- '.php5': 'php',
227
- '.phps': 'php',
228
- '.rb': 'ruby',
229
- '.rbw': 'ruby',
230
- '.rake': 'ruby',
231
- '.gemspec': 'ruby',
232
- '.sh': 'shellscript',
233
- '.bash': 'shellscript',
234
- '.zsh': 'shellscript',
235
- '.fish': 'fish',
236
- '.swift': 'swift',
237
- '.m': 'objective-c',
238
- '.mm': 'objective-cpp',
239
- '.lua': 'lua',
240
- '.pl': 'perl',
241
- '.pm': 'perl',
242
- '.t': 'perl',
243
- '.pod': 'perl',
244
- '.r': 'r',
245
- '.R': 'r',
246
- '.rmd': 'rmd',
247
- '.Rmd': 'rmd',
248
- '.ex': 'elixir',
249
- '.exs': 'elixir',
250
- '.erl': 'erlang',
251
- '.hrl': 'erlang',
252
- '.hs': 'haskell',
253
- '.lhs': 'haskell',
254
- '.ml': 'ocaml',
255
- '.mli': 'ocaml',
256
- '.clj': 'clojure',
257
- '.cljs': 'clojure',
258
- '.cljc': 'clojure',
259
- '.edn': 'clojure',
260
- '.json': 'json',
261
- '.jsonc': 'jsonc',
262
- '.xml': 'xml',
263
- '.yaml': 'yaml',
264
- '.yml': 'yaml',
265
- '.toml': 'toml',
266
- '.ini': 'ini',
267
- '.cfg': 'ini',
268
- '.conf': 'conf',
269
- '.md': 'markdown',
270
- '.markdown': 'markdown',
271
- '.mdown': 'markdown',
272
- '.rst': 'restructuredtext',
273
- '.tex': 'latex',
274
- '.sql': 'sql',
275
- '.graphql': 'graphql',
276
- '.gql': 'graphql',
277
- '.dart': 'dart',
278
- '.jl': 'julia',
279
- '.zig': 'zig',
280
- '.nim': 'nim',
281
- '.nims': 'nim',
282
- '.cr': 'crystal',
283
- '.d': 'd',
284
- '.di': 'd',
285
- '.fs': 'fsharp',
286
- '.fsx': 'fsharp',
287
- '.fsi': 'fsharp',
288
- '.ps1': 'powershell',
289
- '.psm1': 'powershell',
290
- '.psd1': 'powershell',
291
- '.bat': 'bat',
292
- '.cmd': 'bat',
293
- '.mk': 'makefile',
294
- '.dockerfile': 'dockerfile',
295
- '.proto': 'proto',
296
- '.vhd': 'vhdl',
297
- '.vhdl': 'vhdl',
298
- '.v': 'verilog',
299
- '.sv': 'systemverilog',
300
- '.asm': 'asm',
301
- '.s': 'asm',
302
- '.f': 'fortran',
303
- '.f90': 'fortran',
304
- '.f95': 'fortran',
305
- '.cob': 'cobol',
306
- '.cbl': 'cobol',
307
- '.ada': 'ada',
308
- '.adb': 'ada',
309
- '.ads': 'ada',
310
- '.sol': 'solidity',
311
- '.vue': 'vue',
312
- '.svelte': 'svelte',
313
- '.astro': 'astro',
314
- '.tf': 'terraform',
315
- '.tfvars': 'terraform',
316
- '.prisma': 'prisma'
317
- };
318
- const languageId = langMap[ext] || 'plaintext';
319
- try {
320
- const fs = await import('fs/promises');
321
- const text = await fs.readFile(${l}, 'utf8');
322
- await ${u}.sendNotification('textDocument/didOpen', {
323
- textDocument: {
324
- uri: "file://" + ${l},
325
- languageId: languageId,
326
- version: 1,
327
- text: text
328
- }
329
- });
330
- } catch (openErr) { }
331
- `,f=i.slice(0,c.startIndex)+d+i.slice(c.endIndex);return U(i,f,d,c.startIndex,c.endIndex),f},Pt=e=>{let t=e.match(/=>\[([$a-zA-Z_][$\w]{1,2},){30}/);if(!t||t.index===void 0)return console.error(`patch: findSlashCommandListEndPosition: failed to find arrayStartPattern`),null;let n=e.indexOf(`[`,t.index);if(n===-1)return console.error(`patch: findSlashCommandListEndPosition: failed to find bracketIndex`),null;let r=1,i=n+1;for(;i<e.length&&r>0;){if(e[i]===`[`)r++;else if(e[i]===`]`&&(r--,r===0))return i;i++}return console.error(`patch: findSlashCommandListEndPosition: failed to find matching closing-bracket`),null},Ft=(e,t)=>{let n=Pt(e);if(n===null)return console.error(`patch: writeSlashCommandDefinition: failed to find slash command array end position`),null;let r=e.slice(0,n)+t+e.slice(n);return U(e,r,t,n,n),r},It=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g));if(t.length===0)return console.error(`patch: findSelectComponentName: failed to find selectPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},Lt=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g));if(t.length===0)return console.error(`patch: findDividerComponentName: failed to find dividerPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},Rt=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)\(\{(?:(?:commands|debug|initialPrompt|initialTools|initialMessages|initialCheckpoints|initialFileHistorySnapshots|mcpClients|dynamicMcpConfig|mcpCliEndpoint|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled|mainThreadAgentDefinition|disableSlashCommands):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g)).filter(e=>e[0].includes(`commands:`));if(t.length===0)return console.error(`patch: getMainAppComponentBodyStart: failed to find appComponentPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n.index===void 0?(console.error(`patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch`),null):n.index+n[0].length},zt=e=>{let t=Rt(e);if(t===null)return console.error(`patch: getAppStateVarAndGetterFunction: failed to find bodyStart`),null;let n=e.slice(t,t+500).match(/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/);return n?{appStateVar:n[1],appStateGetterFunction:n[2]}:(console.error(`patch: getAppStateVarAndGetterFunction: failed to find statePattern`),null)},Bt=e=>{let t=Rt(e);if(t===null)return console.error(`patch: getToolFetchingUseMemoLocation: failed to find bodyStart`),null;let n=e.slice(t,t+2e3).match(/(?:let |,)([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4(?:,[$\w]+)?\]\)/);if(!n||n.index===void 0)return console.error(`patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern`),null;let r=t+n.index,i=r+n[0].length,a=n[0].startsWith(`,`);return{startIndex:r,endIndex:i,outputVarName:n[1],reactVarName:n[2],toolFilterFunction:n[3],toolPermissionContextVar:n[4],needsSemicolonPrefix:a}},Vt=e=>{let t=Pt(e);if(t===null)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd`),null;let n=1,r=t;for(;r>=0&&n>0;){if(e[r]===`}`)n++;else if(e[r]===`{`&&(n--,n===0))break;r--}if(r<0)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace`),null;for(;r>=0&&e[r]!==`;`;)r--;return r<0?(console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon`),null):r+1},Ht=(e,t)=>{let n=Array.from(e.matchAll(/thinkingEnabled:([$\w]+)\(\)/g));if(n.length===0)return console.error(`patch: toolsets: failed to find thinkingEnabled pattern`),null;let r=[];for(let e of n)if(e.index!==void 0){let t=e.index+e[0].length;r.push({index:t})}r.sort((e,t)=>t.index-e.index);let i=e,a=`,toolset:${t?JSON.stringify(t):`undefined`}`;for(let e of r)i=i.slice(0,e.index)+a+i.slice(e.index);return i===e?(console.error(`patch: toolsets: failed to modify app state initialization`),null):i},Ut=(e,t)=>{let n=Bt(e);if(!n)return console.error(`patch: toolsets: failed to find tool fetching useMemo location`),null;let r=zt(e);if(!r)return console.error(`patch: toolsets: failed to find app state info`),null;let{appStateVar:i}=r,{startIndex:a,endIndex:o,outputVarName:s,reactVarName:c,toolFilterFunction:l,toolPermissionContextVar:u,needsSemicolonPrefix:d}=n,f=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),p=`${d?`;`:``}let ${s} = ${c}.useMemo(() => {
332
- const toolsets = ${f};
333
- if (toolsets.hasOwnProperty(${i}.toolset)) {
334
- const allowedTools = toolsets[${i}.toolset];
335
- if (allowedTools === "*") {
336
- return ${l}(${u});
337
- } else {
338
- return ${l}(${u}).filter(toolDef =>
339
- allowedTools.includes(toolDef.name)
340
- );
341
- }
342
- } else {
343
- return ${l}(${u});
344
- }
345
- }, [${l}, ${i}.toolset])`,m=e.slice(0,a)+p+e.slice(o);return U(e,m,p,a,o),m},Wt=(e,t)=>{let n=Vt(e);if(n===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let r=Pn(e);if(!r)return console.error(`patch: toolsets: failed to find React variable`),null;let i=Rn(e);if(!i)return console.error(`patch: toolsets: failed to find Box component`),null;let a=Ln(e);if(!a)return console.error(`patch: toolsets: failed to find Text component`),null;let o=It(e);if(!o)return console.error(`patch: toolsets: failed to find Select component`),null;let s=Lt(e);if(!s)return console.error(`patch: toolsets: failed to find Divider component`),null;let c=zt(e);if(!c)return console.error(`patch: toolsets: failed to find app state getter`),null;let l=On(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
- const [state, setState] = ${u}();
347
-
348
- // Handle command-line argument
349
- if (input !== "" && input != null) {
350
- if (!${d}.includes(input)) {
351
- onExit(${l}.red(\`\${${l}.bold(input)} is not a valid toolset. Valid toolsets: ${t.map(e=>e.name).join(`, `)}\`));
352
- return;
353
- } else {
354
- setState(prev => ({ ...prev, toolset: input }));
355
- onExit(\`Toolset changed to \${${l}.bold(input)}\`);
356
- return;
357
- }
358
- }
359
-
360
- // Render interactive UI
361
- return ${r}.createElement(
362
- ${i},
363
- { flexDirection: "column" },
364
- ${r}.createElement(${s}, { dividerColor: "permission" }),
365
- ${r}.createElement(
366
- ${i},
367
- { paddingX: 1, marginBottom: 1, flexDirection: "column" },
368
- ${r}.createElement(${i}, null,
369
- ${r}.createElement(${a}, { bold: true, color: "remember" }, "Select toolset")
370
- ),
371
- ${r}.createElement(${i}, null,
372
- ${r}.createElement(${a}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
373
- ),
374
- ${r}.createElement(${i}, { marginBottom: 1 },
375
- ${r}.createElement(${a}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
376
- ),
377
- ${r}.createElement(${i}, null,
378
- ${r}.createElement(${a}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
379
- ),
380
- ${r}.createElement(${i}, { marginBottom: 1 },
381
- ${r}.createElement(${a}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
382
- ),
383
- ${r}.createElement(${i}, null,
384
- ${r}.createElement(${a}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc. "),
385
- ${r}.createElement(${a}, { dimColor: true }, "Run "),
386
- ${r}.createElement(${a}, { color: "permission" }, "npx tweakcc"),
387
- ${r}.createElement(${a}, { dimColor: true }, " to manage them.")
388
- ),
389
- ${r}.createElement(${i}, { marginBottom: 1 },
390
- ${r}.createElement(${a}, { color: "permission" }, "https://github.com/Piebald-AI/tweakcc")
391
- ),
392
- ${r}.createElement(${i}, { marginBottom: 1 },
393
- ${r}.createElement(${a}, null, "Current toolset: "),
394
- ${r}.createElement(${a}, { bold: true }, state.toolset || "undefined")
395
- ),
396
- ${r}.createElement(${i}, { marginBottom: 1 },
397
- ${r}.createElement(${o}, {
398
- options: ${f},
399
- onChange: (input) => {
400
- setState(prev => ({ ...prev, toolset: input }));
401
- onExit(\`Toolset changed to \${${l}.bold(input)}\`);
402
- },
403
- onCancel: () => onExit(\`Toolset not changed (left as \${${l}.bold(state.toolset)})\`)
404
- })
405
- ),
406
- ${r}.createElement(${a}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
407
- )
408
- );
409
- };`,m=e.slice(0,n)+p+e.slice(n);return U(e,m,p,n,n),m},Gt=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},Kt=e=>{let t=Gt(e);if(t===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let n=zt(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 U(e,a,i,t,t),a},qt=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):(U(e,o,a,t.index,t.index+i.length),o)},Jt=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):(U(e,i,r,t.index,t.index+n.length),i)},Yt=e=>{let t=Pn(e);return t?Ft(e,`, {
410
- aliases: ["change-tools"],
411
- type: "local-jsx",
412
- name: "toolset",
413
- description: "Select a toolset (managed by tweakcc)",
414
- argumentHint: "[toolset-name]",
415
- isEnabled: () => true,
416
- isHidden: false,
417
- async call(onExit, ctx, input) {
418
- return ${t}.createElement(toolsetComp, { onExit, input });
419
- },
420
- userFacingName() {
421
- return "toolset";
422
- }
423
- }`):(console.error(`patch: toolsets: failed to find React variable`),null)},Xt=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},Zt=e=>{let t=Xt(e);if(t===null)return null;let n=zt(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)},Qt=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]}},$t=(e,t,n)=>{let r=Qt(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)},en=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=Ht(r,n),r?(r=Ut(r,t),r?(r=Wt(r,t),r?(r=Yt(r),r?(r=Kt(r),r?(r=qt(r),r?(r=Jt(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)},tn=e=>Pn(e)?Ft(e,`, {
424
- type: "local",
425
- name: "title",
426
- description: "Set the conversation title",
427
- isEnabled: () => !0,
428
- isHidden: !1,
429
- async call(A, B, I) {
430
- if (!A)
431
- throw new Error("Please specify a conversation title.");
432
- CUR_CONVERSATION_TITLE = A;
433
- setTerminalTitleOverride(A);
434
- return {
435
- type: "text",
436
- value: \`Conversation title set to \\x1b[1m\${A}\\x1b[0m\`,
437
- }
438
- },
439
- userFacingName() {
440
- return "title";
441
- },
442
- }`):(console.error(`patch: conversationTitle: failed to find React variable`),null),nn=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},rn=e=>{let t=nn(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=In(e),r=`
443
- function getTweakccBaseDir() {
444
- const { join: pathJoin } = ${n}('path');
445
- const { homedir: osHomedir } = ${n}('os');
446
- const { statSync: fsStatSync, mkdirSync: fsMkdirSync } = ${n}('fs');
447
- // Prioritize ~/.tweakcc which is the original and default. Only respect
448
- // XDG_CONFIG_HOME if it doesn't exist.
449
- let dir;
450
- let homedirTweakcc = pathJoin(osHomedir(), ".tweakcc");
451
- try {
452
- if (fsStatSync(homedirTweakcc).isDirectory()) {
453
- dir = homedirTweakcc;
454
- }
455
- } catch (e) {
456
- if (e.code == "ENOENT") {
457
- // Doesn't exist. Move on and see if the XDG one exists.
458
- } else {
459
- throw new Error('cannot stat ' + homedirTweakcc + ': ' + e);
460
- }
461
- }
462
-
463
- // Try XDG.
464
- if (process.env.XDG_CONFIG_HOME) {
465
- // XDG_CONFIG_HOME is set. If it's set and ~/.tweakcc doesn't exist, prefer it.
466
- const xdgTweakcc = pathJoin(process.env.XDG_CONFIG_HOME, "tweakcc");
467
- dir = xdgTweakcc;
468
- }
469
-
470
- // Create the dir.
471
- fsMkdirSync(dir, { recursive: true });
472
- return dir;
473
- }
474
-
475
- const findSummaryEntryForLeafUuid = (filePath, messageUuid) => {
476
- const { readFileSync: fsReadFileSync, statSync: fsStatSync } = ${n}('fs');
477
- // Optimization: skip files that are certain to not be tweakcc summary files (which only contain 1 small line).
478
- if (fsStatSync(filePath).size > 1000) {
479
- return null;
480
- }
481
- const lines = fsReadFileSync(filePath, "utf8")
482
- .split("\\n")
483
- .map((l) => JSON.parse(l.trim()));
484
- for (const line of lines) {
485
- if (line.type == "summary" && line.uuid == messageUuid) {
486
- return line;
487
- }
488
- }
489
- return null;
490
- };
491
-
492
- const getSummaryFileForLeafMessage = (
493
- projectDirectory,
494
- projectSlug,
495
- messageUuid
496
- ) => {
497
- const { join: pathJoin } = ${n}('path');
498
- const { readFileSync: fsReadFileSync, readdirSync: fsReaddirSync } = ${n}('fs');
499
- try {
500
- // File contains the uuid
501
- const summaryFileId = fsReadFileSync(
502
- pathJoin(getTweakccBaseDir(), "named-sessions", projectSlug, messageUuid),
503
- "utf8"
504
- ).trim();
505
- return pathJoin(projectDirectory, summaryFileId + '.jsonl');
506
- } catch (e) {
507
- // File not found or can't be accessed, etc. Ignore.
508
- }
509
-
510
- // Just read each file and try to find it.
511
- for (const file of fsReaddirSync(projectDirectory)) {
512
- try {
513
- const pth = pathJoin(projectDirectory, file);
514
- const summaryObj = findSummaryEntryForLeafUuid(pth);
515
- if (summaryObj != null && summaryObj.tweakcc != null) {
516
- // It needs to be a tweakcc one.
517
- return pth;
518
- }
519
- } catch {}
520
- }
521
-
522
- // It doesn't exist.
523
- return null;
524
- };
525
-
526
- const setTerminalTitleOverride = (title) => {
527
- process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE = 1;
528
- if (process.platform === "win32") process.title = 'Claude: ' + title;
529
- else process.stdout.write('\\x1B]0;Claude: ' + title + '\\x07');
530
- };
531
-
532
- let CUR_CONVERSATION_TITLE = "";
533
- function onNewMessage(projectDir, projectSlug, msg) {
534
- const { join: pathJoin } = ${n}('path');
535
- const { readFileSync: fsReadFileSync, writeFileSync: fsWriteFileSync, mkdirSync: fsMkdirSync, renameSync: fsRenameSync } = ${n}('fs');
536
- const { randomUUID: cryptoRandomUUID } = ${n}('crypto');
537
- const tweakcc = getTweakccBaseDir();
538
-
539
- if (msg.parentUuid) {
540
- const path = getSummaryFileForLeafMessage(
541
- projectDir,
542
- projectSlug,
543
- msg.parentUuid
544
- );
545
- if (path) {
546
- // There's an old file. Update it to the new file.
547
- const summaryObj = findSummaryEntryForLeafUuid(path);
548
- summaryObj.leafUuid = msg.uuid;
549
- if (CUR_CONVERSATION_TITLE != "") {
550
- summaryObj.summary = CUR_CONVERSATION_TITLE;
551
- } else {
552
- CUR_CONVERSATION_TITLE = summaryObj.summary;
553
- }
554
- setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
555
- fsWriteFileSync(path, JSON.stringify(summaryObj));
556
-
557
- // Update the cache; it points from message ID to summary file ID.
558
- fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
559
- recursive: true,
560
- });
561
- const oldPath = pathJoin(
562
- tweakcc,
563
- "named-sessions",
564
- projectSlug,
565
- msg.parentUuid
566
- );
567
- const newPath = pathJoin(
568
- tweakcc,
569
- "named-sessions",
570
- projectSlug,
571
- msg.uuid
572
- );
2
+ import{A as e,C as t,D as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,U as _,V as v,W as y,X as b,Y as x,_ as S,a as C,c as w,f as T,g as E,h as D,i as O,j as k,k as A,l as j,m as M,n as ee,o as te,p as N,q as ne,r as P,t as re,u as F,v as ie,w as I,y as ae}from"./config-BnEFBw3y.mjs";import{a as oe,c as se,d as ce,l as L,n as R,o as le,s as z,t as ue,u as de}from"./content-5p21eXlE.mjs";import{Box as B,Text as V,render as fe,useInput as H}from"ink";import{Command as pe}from"commander";import U from"chalk";import me,{Fragment as he,createContext as ge,useCallback as _e,useContext as W,useEffect as G,useMemo as ve,useRef as ye,useState as K}from"react";import*as be from"node:os";import xe from"ink-link";import*as Se from"node:fs/promises";import Ce from"node:fs/promises";import{structuredPatch as we}from"diff";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import Te from"process";import Ee from"cli-spinners";import*as De from"node:readline";import{execSync as Oe,spawn as ke}from"node:child_process";var X=({children:e,...t})=>Y(V,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...t,children:[` `,e,` `]});const Ae=[`\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 je=()=>Y(B,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[Y(B,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[J(V,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),J(V,{children:` `}),Y(V,{children:[`We've released `,J(V,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),Y(V,{children:[`Download it and try it out for free!`,` `,J(xe,{url:`https://piebald.ai/`,fallback:!1,children:J(V,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),J(V,{children:` `}),J(V,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),J(B,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:Ae.map((e,t)=>J(V,{children:e},t))})]});let Z=function(e){return e.THEMES=`Themes`,e.THINKING_VERBS=`Thinking verbs`,e.THINKING_STYLE=`Thinking style`,e.USER_MESSAGE_DISPLAY=`User message display`,e.INPUT_PATTERN_HIGHLIGHTERS=`Input pattern highlighters`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.SUBAGENT_MODELS=`Subagent models`,e.CLAUDE_MD_ALT_NAMES=`CLAUDE.md alternative names`,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 Me({items:e,selectedIndex:t,onSelect:n,onSubmit:r}){return H((i,a)=>{a.upArrow?n(t>0?t-1:e.length-1):a.downArrow?n(t<e.length-1?t+1:0):a.return&&r(e[t].name)}),J(B,{flexDirection:`column`,children:e.map((e,n)=>J(B,{children:Y(V,{children:[Y(V,{bold:n===t,color:n===t?`cyan`:void 0,...n===t?e.selectedStyles??{}:e.styles??{},children:[n===t?`❯ `:` `,e.name]}),e.desc&&n===t&&Y(V,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,e.desc]})]})},n))})}const Ne=[{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.INPUT_PATTERN_HIGHLIGHTERS,desc:`Create custom highlighters for patterns in your input`},{name:Z.MISC,desc:`Miscellaneous settings (input box border, etc.)`},{name:Z.TOOLSETS,desc:`Manage toolsets to control which tools are available`},{name:Z.SUBAGENT_MODELS,desc:`Configure which Claude model each subagent uses (Plan, Explore, etc.)`},{name:Z.CLAUDE_MD_ALT_NAMES,desc:`Configure alternative filenames for CLAUDE.md (e.g., AGENTS.md)`},{name:Z.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],Pe=[{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 (${P})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var Fe=({onSubmit:e})=>{let t=[...Ne,...Pe],[n,r]=K(0);return J(Me,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const Ie=()=>Y(B,{flexDirection:`row`,children:[J(X,{children:`tweakcc`}),J(V,{children:` (by `}),J(xe,{url:`https://piebald.ai`,fallback:!1,children:J(V,{color:`#ff8400`,bold:!0,children:`Piebald`})}),J(V,{children:`)`})]}),Le=()=>J(B,{children:Y(V,{color:`yellow`,children:[`⭐ `,J(V,{bold:!0,children:`Star the repo at `}),J(xe,{url:`https://github.com/Piebald-AI/tweakcc`,fallback:!1,children:J(V,{bold:!0,color:`cyan`,children:`https://github.com/Piebald-AI/tweakcc`})}),J(V,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),Re=({notification:e})=>J(B,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:e.type===`success`?`green`:e.type===`error`?`red`:e.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:J(V,{color:e.type===`success`?`green`:e.type===`error`?`red`:e.type===`info`?`blue`:`yellow`,children:e.message})}),ze=({onSubmit:e,notification:t,configMigrated:n,showPiebaldAnnouncement:r,changesApplied:i,invocationCommand:a})=>Y(B,{flexDirection:`column`,gap:1,children:[n&&J(B,{children:J(V,{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."})}),J(Ie,{}),J(B,{children:Y(V,{children:[J(V,{bold:!0,children:`Customize your Claude Code installation.`}),` `,Y(V,{dimColor:!0,children:[`Settings will be saved to `,ee.replace(be.homedir(),`~`),`/config.json.`]})]})}),J(r?je:Le,{}),t&&J(Re,{notification:t}),!i&&!t&&J(Re,{notification:{message:`Your changes are configured but not applied.\nRun \`${a} --apply\` to apply your customizations!`,type:`info`}}),J(Fe,{onSubmit:e})]});function Q({color:e,backgroundColor:t,bold:n,dimColor:r,children:i}){let a=e?.startsWith(`ansi:`),o=t?.startsWith(`ansi:`);if(a||o){if(me.Children.toArray(i).some(e=>me.isValidElement(e)))return J(V,{children:i});let s=U;if(a){let t=e.slice(5);s=s[t]||s}if(o){let e=t.slice(5),n=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;s=s[n]||s}n&&(s=s.bold),r&&(s=s.dim);let c=me.Children.toArray(i).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return J(V,{children:s(c)})}return J(V,{color:e,backgroundColor:t,bold:n,dimColor:r,children:i})}function Be({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:r=3,updateDuration:i=50,restartPoint:a=10}){let[o,s]=K(0);return G(()=>{let t=setInterval(()=>{s(t=>{let n=t+1;return n>=e.length+a?-r:n})},i);return()=>clearInterval(t)},[e.length,a,i]),t.length===n.length?J(V,{children:e.split(``).map((i,a)=>{let s=a>=o&&a<o+r&&o<e.length,c=a%t.length;return J(V,{color:s?n[c]:t[c],children:i},a)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),J(V,{children:e}))}const Ve=Te.cwd();function He({theme:e}){let{ccVersion:t}=W($);return Y(B,{flexDirection:`column`,paddingLeft:1,children:[J(B,{marginBottom:1,children:Y(V,{bold:!0,children:[`Preview: `,e.name]})}),J(B,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:Y(B,{flexDirection:`column`,children:[Y(B,{flexDirection:`column`,children:[Y(V,{children:[J(Q,{color:e.colors.clawd_body,children:` ▐`}),J(V,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:`▛███▜`}),Y(V,{children:[J(Q,{color:e.colors.clawd_body,children:`▌ `}),` `,J(V,{bold:!0,children:`Claude Code`}),` `,t?`v${t}`:`v2.0.14`]})]}),Y(V,{children:[J(Q,{color:e.colors.clawd_body,children:`▝▜`}),J(V,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:`█████`}),J(Q,{color:e.colors.clawd_body,children:`▛▘`}),` `,ae(),` · `,S()]}),Y(Q,{color:e.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,Ve]}),Y(V,{children:[Y(Q,{color:e.colors.success,children:[`Login successful. Press`,` `]}),J(Q,{bold:!0,color:e.colors.success,children:`Enter`}),Y(Q,{color:e.colors.success,children:[` `,`to continue…`]})]})]}),J(V,{children:`╭─────────────────────────────────────────────╮`}),Y(V,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),Y(V,{children:[`│ 2`,` `,J(Q,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:`- console.log("`}),J(Q,{backgroundColor:e.colors.diffRemovedWord,children:`Hello, World!`}),J(Q,{backgroundColor:e.colors.diffRemoved,children:`");`}),` `,`│`]}),Y(V,{children:[`│ 2`,` `,J(Q,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:`+ console.log("`}),J(Q,{backgroundColor:e.colors.diffAddedWord,children:`Hello, Claude!`}),J(Q,{backgroundColor:e.colors.diffAdded,children:`");`}),` `,`│`]}),J(Q,{color:e.colors.warning,children:`╭─────────────────────────────────────────────╮`}),Y(Q,{color:e.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),Y(V,{children:[J(Q,{color:e.colors.warning,children:`│ `}),J(V,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),Y(Q,{color:e.colors.warning,children:[` `,`│`]})]}),J(Q,{color:e.colors.bashBorder,children:`───────────────────────────────────────────────`}),Y(V,{children:[J(Q,{color:e.colors.bashBorder,children:`!`}),J(V,{children:` ls`})]}),J(Q,{color:e.colors.promptBorder,children:`───────────────────────────────────────────────`}),J(V,{children:Y(V,{children:[`> list the dir`,` `,J(Be,{text:`ultrathink`,nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),J(Q,{color:e.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),Y(V,{children:[J(Q,{color:e.colors.planMode,children:`│ `}),Y(Q,{color:e.colors.permission,children:[`Ready to code?`,` `]}),J(V,{children:`Here is Claude's plan:`}),Y(Q,{color:e.colors.planMode,children:[` `,`│`]})]}),J(Q,{color:e.colors.permission,children:`╭─────────────────────────────────────────────╮`}),Y(V,{children:[J(Q,{color:e.colors.permission,children:`│ `}),J(V,{bold:!0,children:`Permissions:`}),` `,Y(Q,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,J(Q,{color:e.colors.permission,children:`│`})]}),J(V,{children:`> list the dir`}),Y(V,{children:[J(Q,{color:e.colors.error,children:`●`}),J(V,{children:` Update(__init__.py)`})]}),Y(V,{children:[J(V,{children:` ⎿ `}),J(Q,{color:e.colors.error,children:`User rejected update to __init__.py`})]}),Y(V,{children:[` `,`1`,` `,Y(Q,{backgroundColor:e.colors.diffRemovedDimmed,children:[`- import`,` `]}),J(Q,{backgroundColor:e.colors.diffRemovedWordDimmed,children:`os`})]}),Y(V,{children:[` `,`2`,` `,Y(Q,{backgroundColor:e.colors.diffAddedDimmed,children:[`+ import`,` `]}),J(Q,{backgroundColor:e.colors.diffAddedWordDimmed,children:`random`})]}),Y(V,{children:[J(Q,{color:e.colors.success,children:`●`}),J(V,{children:` List(.)`})]}),Y(V,{children:[J(V,{children:`●`}),J(V,{children:` The directory `}),J(Q,{color:e.colors.permission,children:`C:\\Users\\user`}),Y(V,{children:[` `,`contains `,J(V,{bold:!0,children:`123`}),` files.`]})]}),Y(V,{children:[J(Q,{color:e.colors.claude,children:`✻ Th`}),J(Q,{color:e.colors.claudeShimmer,children:`ink`}),J(Q,{color:e.colors.claude,children:`ing… `}),J(V,{children:`(esc to interrupt)`})]}),J(V,{children:J(Q,{color:e.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),J(V,{children:J(Q,{color:e.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),J(V,{children:J(Q,{color:e.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function Ue({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?J(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?J(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):J(Q,{color:r,bold:n,children:e})}function We({initialValue:e,onColorChange:n,onExit:r,colorKey:i,theme:a}){let o=Ke(e)||{h:0,s:50,l:50},s=Ge(e)||{r:128,g:128,b:128},[c,l]=K(o),[u,d]=K(s),[f,p]=K(`hsl`),[m,h]=K(`h`),[g,_]=K(!1),[v,y]=K(!1);G(()=>{let t=Ke(e),n=Ge(e);t&&n&&(_(!0),l(t),d(n),_(!1))},[e]),G(()=>{!g&&v&&n(`rgb(${u.r},${u.g},${u.b})`)},[c,u,g,v]),G(()=>{y(!0)},[]);let b=e=>{if(t(e)){let t=I(e),n=Ke(t),r=Ge(t);n&&r&&(_(!0),l(n),d(r),_(!1))}};H((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){b(e);return}t.return||t.escape?r():t.ctrl&&e===`a`?(p(e=>e===`hsl`?`rgb`:`hsl`),h(e=>f===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?h(f===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?h(f===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?x(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&x(t.shift||t.ctrl||t.meta?10:1)});let x=e=>{_(!0),f===`hsl`?l(t=>{let n={...t};m===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):m===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):m===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=C(n.h,n.s,n.l);return d({r,g:i,b:a}),n}):d(t=>{let n={...t};return m===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):m===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):m===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),l(S(n.r,n.g,n.b)),n}),_(!1)},S=(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)}},C=(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)]},w=()=>{let e=[],t=[[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 n=0;n<40;n++){let r=n/39*(t.length-1),i=Math.floor(r),a=Math.ceil(r),o=r-i,[s,c,l]=t[i],[u,d,f]=t[a],p=Math.round(s+(u-s)*o),m=Math.round(c+(d-c)*o),h=Math.round(l+(f-l)*o);e.push(J(V,{backgroundColor:`rgb(${p},${m},${h})`,children:` `},n))}return e},T=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=C(c.h,n,c.l);e.push(J(V,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},E=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=C(c.h,c.s,n);e.push(J(V,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},D=()=>{let[e,t,n]=C(c.h,c.s,c.l);return`rgb(${e},${t},${n})`},O=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},k=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(V,{backgroundColor:`rgb(${n},${u.g},${u.b})`,children:` `},t))}return e},A=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(V,{backgroundColor:`rgb(${u.r},${n},${u.b})`,children:` `},t))}return e},j=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(V,{backgroundColor:`rgb(${u.r},${u.g},${n})`,children:` `},t))}return e},M=(e,t)=>Math.round(e/t*39);return Y(B,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[Y(B,{flexDirection:`column`,children:[J(V,{bold:!0,children:`Color Picker`}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),J(V,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),J(V,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),J(V,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),J(V,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),J(V,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),f===`hsl`?Y(q,{children:[Y(B,{marginBottom:1,children:[J(B,{width:25,children:Y(V,{color:m===`h`?`yellow`:`white`,children:[m===`h`?`❯ `:` `,`Hue (`,c.h,`°):`]})}),J(B,{children:w().map((e,t)=>J(he,{children:t===M(c.h,360)?J(V,{children:`|`}):e},t))})]}),Y(B,{marginBottom:1,children:[J(B,{width:25,children:Y(V,{color:m===`s`?`yellow`:`white`,children:[m===`s`?`❯ `:` `,`Saturation (`,c.s,`%):`]})}),J(B,{children:T().map((e,t)=>J(he,{children:t===M(c.s,100)?J(V,{children:`|`}):e},t))})]}),Y(B,{marginBottom:1,children:[J(B,{width:25,children:Y(V,{color:m===`l`?`yellow`:`white`,children:[m===`l`?`❯ `:` `,`Lightness (`,c.l,`%):`]})}),J(B,{children:E().map((e,t)=>J(he,{children:t===M(c.l,100)?J(V,{children:`|`}):e},t))})]})]}):Y(q,{children:[Y(B,{marginBottom:1,children:[J(B,{width:25,children:Y(V,{color:m===`r`?`yellow`:`white`,children:[m===`r`?`❯ `:` `,`Red (`,u.r,`):`]})}),J(B,{children:k().map((e,t)=>J(he,{children:t===M(u.r,255)?J(V,{children:`|`}):e},t))})]}),Y(B,{marginBottom:1,children:[J(B,{width:25,children:Y(V,{color:m===`g`?`yellow`:`white`,children:[m===`g`?`❯ `:` `,`Green (`,u.g,`):`]})}),J(B,{children:A().map((e,t)=>J(he,{children:t===M(u.g,255)?J(V,{children:`|`}):e},t))})]}),Y(B,{marginBottom:1,children:[J(B,{width:25,children:Y(V,{color:m===`b`?`yellow`:`white`,children:[m===`b`?`❯ `:` `,`Blue (`,u.b,`):`]})}),J(B,{children:j().map((e,t)=>J(he,{children:t===M(u.b,255)?J(V,{children:`|`}):e},t))})]})]}),Y(B,{marginBottom:1,children:[J(V,{children:`Current: `}),J(V,{backgroundColor:D(),children:` `})]}),Y(B,{flexDirection:`row`,justifyContent:`space-between`,children:[Y(B,{flexDirection:`column`,children:[J(V,{dimColor:!0,children:`Hex `}),i?.startsWith(`diff`)?J(V,{backgroundColor:D(),color:a?.colors?.text||`white`,bold:!0,children:O(u.r,u.g,u.b)}):i===`inverseText`?J(V,{color:D(),backgroundColor:a?.colors?.permission,bold:!0,children:O(u.r,u.g,u.b)}):J(V,{color:D(),bold:!0,children:O(u.r,u.g,u.b)})]}),Y(B,{flexDirection:`column`,children:[J(V,{dimColor:!0,children:`RGB `}),i?.startsWith(`diff`)?J(V,{backgroundColor:D(),color:a?.colors?.text||`white`,bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`}):i===`inverseText`?J(V,{color:D(),backgroundColor:a?.colors?.permission,bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`}):J(V,{color:D(),bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`})]}),Y(B,{flexDirection:`column`,children:[J(V,{dimColor:!0,children:`HSL `}),i?.startsWith(`diff`)?J(V,{backgroundColor:D(),color:a?.colors?.text||`white`,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):i===`inverseText`?J(V,{color:D(),backgroundColor:a?.colors?.permission,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):J(V,{color:D(),bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`})]})]})]})}function Ge(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 Ke(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 qe({onBack:e,themeId:n}){let{settings:{themes:r},updateSettings:i}=W($),[a,o]=K(n),s=r.find(e=>e.id===a)||r[0],[c,l]=K(`rgb`),[u,d]=K(0),[p,m]=K(null),[h,g]=K(null),[_,v]=K(``),[y,b]=K(``),[x,S]=K(!1),[C,w]=K(0),T=_e(e=>{i(t=>{let n=t.themes.findIndex(e=>e.id===a);n!==-1&&e(t.themes[n])})},[a,i]),E=e=>{if(u>=2&&t(e)){let t=I(e),n=D[u-2];T(e=>{e.colors[n]=t})}};H((t,n)=>{if(x){if(n.escape){S(!1),e();return}return}if(p===null&&h===null){if(t.length>1&&!n.ctrl&&!n.meta){E(t);return}if(n.escape)S(!0),w(0);else if(n.ctrl&&t===`a`)l(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(n.upArrow)d(e=>Math.max(0,e-1));else if(n.downArrow)d(e=>Math.min(D.length+1,e+1));else if(n.return)if(u===0)g(`name`),v(s.name),b(s.name);else if(u===1)g(`id`),v(s.id),b(s.id);else{let e=u-2,t=D[e],n=s.colors[t];m(e),v(n),b(n)}}else if(p!==null)n.ctrl&&t===`a`&&l(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(h!==null)if(n.return){if(h===`id`){let e=a;o(_),i(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=_)})}else T(e=>{e.name=_});g(null),v(``),b(``)}else n.escape?(g(null),v(``),b(``)):n.backspace||n.delete?v(e=>e.slice(0,-1)):t&&v(e=>e+t)});let D=Object.keys(s.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 Y(B,{children:[Y(B,{flexDirection:`column`,width:`50%`,children:[J(B,{children:Y(X,{children:[`Editing theme “`,s.name,`” (`,s.id,`)`]})}),x?Y(B,{flexDirection:`column`,marginTop:1,children:[J(B,{marginBottom:1,children:Y(V,{bold:!0,children:[`Would you like to make “`,s.name,`” your current Claude Code theme?`]})}),J(Me,{items:[{name:`Yes`,desc:`Set ${s.id} as active theme`},{name:`No`,desc:`Go back without changing theme`}],selectedIndex:C,onSelect:w,onSubmit:()=>{C===0&&f(s.id),S(!1),e()}}),J(V,{dimColor:!0,children:`enter to select, esc to cancel`})]}):p===null&&h===null?Y(q,{children:[Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{dimColor:!0,children:`enter to edit theme name, id, or color`}),J(V,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),J(V,{dimColor:!0,children:`paste color from clipboard (when on color)`}),J(V,{dimColor:!0,children:`esc to go back`})]}),u<2?Y(B,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[J(V,{bold:!0,children:u===0?`Theme Name`:`Theme ID`}),J(V,{children:u===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):Y(B,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:s.colors[D[u-2]],flexDirection:`column`,paddingLeft:1,children:[J(Ue,{colorKey:D[u-2],theme:s,bold:!0}),J(V,{children:k(D[u-2])})]}),Y(B,{flexDirection:`column`,children:[Y(B,{children:[J(V,{color:u===0?`yellow`:`white`,children:u===0?`❯ `:` `}),J(V,{bold:!0,children:`Name: `}),J(V,{children:s.name})]}),Y(B,{marginBottom:1,children:[J(V,{color:u===1?`yellow`:`white`,children:u===1?`❯ `:` `}),J(V,{bold:!0,children:`ID: `}),J(V,{children:s.id})]}),(()=>{if(u<2)return Y(q,{children:[D.slice(0,20).map((e,t)=>{let n=t+2;return Y(B,{children:[J(V,{color:u===n?`yellow`:`white`,children:u===n?`❯ `:` `}),J(B,{width:A+2,children:J(V,{children:J(Ue,{colorKey:e,theme:s,bold:!0})})}),J(Q,{color:s.colors[e],children:O(s.colors[e],c)})]},e)}),D.length>20&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let e=u-2,t=Math.max(0,e-10),n=Math.min(D.length,t+20),r=Math.max(0,n-20),i=D.slice(r,n);return Y(q,{children:[r>0&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,t)=>{let n=r+t+2;return Y(B,{children:[J(V,{color:u===n?`yellow`:`white`,children:u===n?`❯ `:` `}),J(B,{width:A+2,children:J(V,{children:J(Ue,{colorKey:e,theme:s,bold:!0})})}),J(Q,{color:s.colors[e],children:O(s.colors[e],c)})]},e)}),n<D.length&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-n,` more below`]})]})})()]})]}):h?Y(B,{flexDirection:`column`,marginTop:1,children:[Y(V,{children:[`Editing `,h===`name`?`theme name`:`theme ID`,`:`]}),J(B,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:J(V,{children:_})}),J(V,{dimColor:!0,children:`enter to save, esc to cancel`})]}):J(We,{initialValue:y,colorKey:D[p],theme:s,onColorChange:e=>{v(e),T(t=>{t.colors[D[p]]=e})},onExit:()=>{T(e=>{e.colors[D[p]]=_}),m(null),v(``),b(``)}})]}),J(B,{width:`50%`,children:J(He,{theme:s})})]})}function Je(e){return e.map(e=>`${e.name} (${e.id})`)}function Ye({onBack:e}){let{settings:{themes:t},updateSettings:n}=W($),[r,i]=K(0),[a,o]=K(null),[s,c]=K(!0),l=()=>{let e={colors:{...(t[0]||b.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};n(t=>{t.themes.push(e)}),o(e.id),c(!1)},u=e=>{t.length<=1||(n(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),r>=t.length-1&&i(Math.max(0,t.length-2)))},d=()=>{n(e=>{e.themes=[...b.themes]}),i(0)};if(H((n,a)=>{if(a.escape)e();else if(a.upArrow)i(e=>Math.max(0,e-1));else if(a.downArrow)i(e=>Math.min(t.length-1,e+1));else if(a.return){let e=t[r];e&&(o(e.id),c(!1))}else if(n===`n`)l();else if(n===`d`){let e=t[r];e&&u(e.id)}else a.ctrl&&n===`r`&&d()},{isActive:s}),a)return J(qe,{themeId:a,onBack:()=>{o(null),c(!0)}});let f=Je(t),p=t.find(e=>f[r]?.includes(`(${e.id})`))||t[0];return t.length===0?J(B,{children:Y(B,{flexDirection:`column`,width:`100%`,children:[J(X,{children:`Themes`}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{dimColor:!0,children:`n to create a new theme`}),J(V,{dimColor:!0,children:`esc to go back`})]}),J(V,{children:`No themes available!`})]})}):Y(B,{children:[Y(B,{flexDirection:`column`,width:`50%`,children:[J(X,{children:`Themes`}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{dimColor:!0,children:`n to create a new theme`}),J(V,{dimColor:!0,children:`d to delete a theme`}),J(V,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),J(V,{dimColor:!0,children:`enter to edit theme`}),J(V,{dimColor:!0,children:`esc to go back`})]}),J(B,{flexDirection:`column`,children:f.map((e,t)=>Y(V,{color:r===t?`yellow`:void 0,children:[r===t?`❯ `:` `,e]},t))})]}),J(B,{width:`50%`,children:J(He,{theme:p})})]})}function Xe({onBack:e}){let{settings:{thinkingVerbs:{format:t,verbs:n},themes:r},updateSettings:i}=W($),a=[`format`,`verbs`],[o,s]=K(0),c=a[o],[l,u]=K(0),[d,f]=K(!1),[p,m]=K(``),[h,g]=K(!1),[_,v]=K(!1),[y,x]=K(t),S=ie(),C=(r.find(e=>e.id===S)||r.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return H((r,o)=>{if(_){o.return?(i(e=>{e.thinkingVerbs.format=y}),v(!1)):o.escape?(x(t),v(!1)):o.backspace||o.delete?x(e=>e.slice(0,-1)):r&&x(e=>e+r);return}if(d||h){o.return&&p.trim()?(h?(i(e=>{e.thinkingVerbs.verbs.push(p.trim())}),g(!1)):(i(e=>{e.thinkingVerbs.verbs[l]=p.trim()}),f(!1)),m(``)):o.escape?(m(``),f(!1),g(!1)):o.backspace||o.delete?m(e=>e.slice(0,-1)):r&&m(e=>e+r);return}o.escape?e():o.return?c===`format`&&(x(t),v(!0)):o.tab?o.shift?s(e=>e===0?a.length-1:e-1):s(e=>e===a.length-1?0:e+1):o.upArrow?c===`verbs`&&n.length>0&&u(e=>e>0?e-1:n.length-1):o.downArrow?c===`verbs`&&n.length>0&&u(e=>e<n.length-1?e+1:0):r===`e`&&c===`verbs`?n.length>0&&(m(n[l]),f(!0)):r===`d`&&c===`verbs`?n.length>1&&(i(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==l)}),l>=n.length-1&&u(Math.max(0,n.length-2))):r===`n`&&c===`verbs`?(g(!0),m(``)):o.ctrl&&r===`r`&&c===`verbs`&&(i(e=>{e.thinkingVerbs.verbs=[...b.thinkingVerbs.verbs]}),u(0))}),Y(B,{children:[Y(B,{flexDirection:`column`,width:`50%`,children:[Y(B,{marginBottom:1,flexDirection:`column`,children:[J(X,{children:`Thinking Verbs`}),Y(B,{flexDirection:`column`,children:[J(V,{dimColor:!0,children:c===`format`?`enter to edit format`:`changes auto-saved`}),J(V,{dimColor:!0,children:`esc to go back`}),J(V,{dimColor:!0,children:`tab to switch sections`})]})]}),J(B,{marginBottom:1,children:J(V,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),Y(B,{flexDirection:`column`,children:[Y(V,{children:[J(V,{color:c===`format`?`yellow`:void 0,children:c===`format`?`❯ `:` `}),J(V,{bold:!0,color:c===`format`?`yellow`:void 0,children:`Format`})]}),c===`format`&&(_?Y(V,{dimColor:!0,children:[` `,`enter to save`]}):Y(V,{dimColor:!0,children:[` `,`enter to edit`]}))]}),J(B,{marginLeft:2,marginBottom:1,children:J(B,{borderStyle:`round`,borderColor:_?`yellow`:`gray`,children:J(V,{children:_?y:t})})}),J(B,{children:Y(V,{children:[J(V,{color:c===`verbs`?`yellow`:void 0,children:c===`verbs`?`❯ `:` `}),J(V,{bold:!0,color:c===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),c===`verbs`&&J(B,{flexDirection:`column`,children:Y(V,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),J(B,{marginLeft:2,marginBottom:1,children:Y(B,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,l-4),t=Math.min(n.length,e+8),r=Math.max(0,t-8),i=n.slice(r,t);return Y(q,{children:[r>0&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,t)=>{let n=r+t;return Y(V,{color:c===`verbs`&&n===l?`cyan`:void 0,children:[c===`verbs`&&n===l?`❯ `:` `,e]},n)}),t<n.length&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↓ `,n.length-t,` more below`]})]})})(),h&&Y(B,{alignItems:`center`,children:[J(V,{color:`yellow`,children:`❯ `}),J(B,{borderStyle:`round`,borderColor:`yellow`,children:J(V,{children:p})})]}),d&&Y(B,{marginTop:1,alignItems:`center`,children:[J(V,{children:`Editing: `}),J(B,{borderStyle:`round`,borderColor:`yellow`,children:J(V,{children:p})})]})]})})]}),Y(B,{width:`50%`,flexDirection:`column`,children:[J(B,{marginBottom:1,children:J(V,{bold:!0,children:`Preview`})}),J(B,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:Y(V,{children:[Y(V,{color:C,children:[`✻ `,t.replace(/\{\}/g,n[l]),` `]}),J(V,{children:`(esc to interrupt)`})]})})]})]})}const Ze=e=>e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z])([A-Z][a-z])/g,`$1 $2`).replace(/(\d+)/g,` $1 `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase()),Qe=e=>{let t=Math.max(...e.map(e=>e.length));return e.map(e=>e.padEnd(t))},$e=Object.entries(Ee).map(([e,t])=>({name:Ze(e),phases:t.frames.map(e=>e.trimEnd()),reverseMirror:!1,updateInterval:t.interval})),et=[{name:`Default`,phases:b.thinkingStyle.phases,reverseMirror:b.thinkingStyle.reverseMirror},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1},...$e];function tt({onBack:e}){let{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:r},themes:i},updateSettings:a}=W($),o=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[s,c]=K(0),l=o[s],[u,d]=K(0),[f,p]=K(0),[m,h]=K(!1),[g,_]=K(``),[v,y]=K(!1),[x,S]=K(!1),[C,w]=K(n.toString()),[T,E]=K(0),D=ie(),O=(i.find(e=>e.id===D)||i.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;G(()=>{if(t.length>0){let e=r?[...t,...[...t].reverse().slice(1,-1)]:t,i=setInterval(()=>{E(t=>(t+1)%e.length)},n);return()=>clearInterval(i)}},[t,n,r]),H((r,i)=>{if(x){if(i.return){let e=parseInt(C);!isNaN(e)&&e>0&&a(t=>{t.thinkingStyle.updateInterval=e}),S(!1)}else i.escape?(w(n.toString()),S(!1)):i.backspace||i.delete?w(e=>e.slice(0,-1)):r&&r.match(/^[0-9]$/)&&w(e=>e+r);return}if(m||v){if(i.return&&g.length){let e=v?[...t,g]:t.map((e,t)=>t===u?g:e);a(t=>{t.thinkingStyle.phases=Qe(e)}),h(!1),_(``)}else i.escape?(_(``),h(!1),y(!1)):i.backspace||i.delete?_(e=>e.slice(0,-1)):r&&_(e=>e+r);return}if(i.escape)e();else if(i.return)if(l===`updateInterval`)w(n.toString()),S(!0);else if(l===`presets`){let e=et[f];a(t=>{t.thinkingStyle.phases=Qe([...e.phases]),t.thinkingStyle.reverseMirror=e.reverseMirror,e.updateInterval!==void 0&&(t.thinkingStyle.updateInterval=e.updateInterval)})}else l===`reverseMirror`&&a(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(i.tab)i.shift?c(e=>e===0?o.length-1:e-1):c(e=>e===o.length-1?0:e+1);else if(i.upArrow)l===`phases`&&t.length>0?d(e=>e>0?e-1:t.length-1):l===`presets`&&p(e=>e>0?e-1:et.length-1);else if(i.downArrow)l===`phases`&&t.length>0?d(e=>e<t.length-1?e+1:0):l===`presets`&&p(e=>e<et.length-1?e+1:0);else if(r===` `)l===`reverseMirror`&&a(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(r===`e`&&l===`phases`)t.length>0&&(_(t[u]),h(!0));else if(r===`a`&&l===`phases`)y(!0),_(``);else if(r===`d`&&l===`phases`)t.length>1&&(a(e=>{e.thinkingStyle.phases=Qe(t.filter((e,t)=>t!==u))}),u>=t.length&&d(Math.max(0,t.length-1)));else if(r===`w`&&l===`phases`){if(u>0){let e=[...t];[e[u-1],e[u]]=[e[u],e[u-1]],a(t=>{t.thinkingStyle.phases=e}),d(e=>e-1)}}else if(r===`s`&&l===`phases`){if(u<t.length-1){let e=[...t];[e[u],e[u+1]]=[e[u+1],e[u]],a(t=>{t.thinkingStyle.phases=e}),d(e=>e+1)}}else i.ctrl&&r===`r`&&(a(e=>{e.thinkingStyle=b.thinkingStyle}),d(0),p(0))});let k=r?`●`:`○`,A=(()=>r?[...t,...[...t].reverse().slice(1,-1)]:t)(),j=A.length>0?A[T]:`·`;return J(B,{children:Y(B,{flexDirection:`column`,width:`100%`,children:[Y(B,{flexDirection:`row`,width:`100%`,children:[Y(B,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[J(X,{children:`Thinking style`}),Y(B,{flexDirection:`column`,children:[Y(V,{dimColor:!0,children:[`enter to`,` `,l===`updateInterval`?`edit interval`:l===`presets`?`apply preset`:`save`]}),J(V,{dimColor:!0,children:`esc to go back`}),J(V,{dimColor:!0,children:`tab to switch sections`})]})]}),Y(B,{width:`50%`,flexDirection:`column`,children:[J(B,{children:J(V,{bold:!0,children:`Preview`})}),Y(B,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[J(B,{width:(j?.length??0)+1,children:J(V,{color:O,children:j})}),Y(V,{children:[J(V,{color:O,children:`Thinking… `}),J(V,{children:`(esc to interrupt)`})]})]})]})]}),Y(B,{flexDirection:`row`,gap:4,children:[Y(B,{flexDirection:`column`,children:[Y(V,{children:[J(V,{color:l===`reverseMirror`?`yellow`:void 0,children:l===`reverseMirror`?`❯ `:` `}),J(V,{bold:!0,color:l===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),l===`reverseMirror`&&Y(V,{dimColor:!0,children:[` `,`space to toggle`]}),J(B,{marginLeft:2,marginBottom:1,children:Y(V,{children:[k,` `,r?`Enabled`:`Disabled`]})})]}),Y(B,{flexDirection:`column`,children:[Y(V,{children:[J(V,{color:l===`updateInterval`?`yellow`:void 0,children:l===`updateInterval`?`❯ `:` `}),J(V,{bold:!0,color:l===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),l===`updateInterval`&&(x?Y(V,{dimColor:!0,children:[` `,`enter to save`]}):Y(V,{dimColor:!0,children:[` `,`enter to edit`]})),J(B,{marginLeft:2,marginBottom:1,children:J(B,{borderStyle:`round`,borderColor:x?`yellow`:`gray`,children:J(V,{children:x?C:n})})})]})]}),J(B,{children:Y(V,{children:[J(V,{color:l===`phases`?`yellow`:void 0,children:l===`phases`?`❯ `:` `}),J(V,{bold:!0,color:l===`phases`?`yellow`:void 0,children:`Phases`})]})}),l===`phases`&&J(B,{marginBottom:1,flexDirection:`column`,children:Y(V,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),J(B,{marginLeft:2,marginBottom:1,children:Y(B,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,u-4),n=Math.min(t.length,e+8),r=Math.max(0,n-8),i=t.slice(r,n);return Y(q,{children:[r>0&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,t)=>{let n=r+t;return Y(V,{color:l===`phases`&&n===u?`cyan`:void 0,children:[l===`phases`&&n===u?`❯ `:` `,e]},n)}),n<t.length&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↓ `,t.length-n,` more below`]})]})})(),v&&Y(B,{children:[J(V,{color:`yellow`,children:`❯ `}),J(B,{borderStyle:`round`,borderColor:`yellow`,children:J(V,{children:g})})]}),m&&Y(B,{marginTop:1,children:[J(V,{children:`Editing: `}),J(B,{borderStyle:`round`,borderColor:`yellow`,children:J(V,{children:g})})]})]})}),J(B,{children:Y(V,{children:[J(V,{color:l===`presets`?`yellow`:void 0,children:l===`presets`?`❯ `:` `}),J(V,{bold:!0,color:l===`presets`?`yellow`:void 0,children:`Presets`})]})}),l===`presets`&&Y(V,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases and interval`]}),J(B,{marginLeft:2,marginBottom:1,children:J(B,{flexDirection:`column`,children:(()=>{let e=Math.max(0,f-6),t=Math.min(et.length,e+12),n=Math.max(0,t-12),r=et.slice(n,t),i=e=>{let t=e.phases.join(``);return t.length>30?t.slice(0,27)+`…`:t};return Y(q,{children:[n>0&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↑ `,n,` more above`]}),r.map((e,t)=>{let r=n+t,a=l===`presets`&&r===f;return Y(V,{color:a?`cyan`:void 0,children:[a?`❯ `:` `,e.name,` `,i(e)]},r)}),t<et.length&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↓ `,et.length-t,` more below`]})]})})()})}),J(B,{marginTop:1,children:J(V,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function nt(e,t){let n=ye(!0);G(()=>{if(n.current){n.current=!1;return}return e()},t)}const rt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],it=[{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 at({onBack:e}){let{settings:t,updateSettings:n}=W($),[r,i]=K(!1),[a,o]=K(!1),[s,c]=K(!1),[l,u]=K(()=>t.userMessageDisplay.format),[d,f]=K(()=>String(t.userMessageDisplay.paddingX)),[p,m]=K(()=>String(t.userMessageDisplay.paddingY)),[h,g]=K(t.userMessageDisplay.fitBoxToContent),[_,v]=K(0),[y,x]=K(()=>[...t.userMessageDisplay.styling]),[S,C]=K(()=>t.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[w,T]=K(()=>t.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:t.userMessageDisplay.foregroundColor),[E,D]=K(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[O,k]=K(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[A,j]=K(()=>it.findIndex(e=>e.value===t.userMessageDisplay.borderStyle)),[M,ee]=K(()=>t.userMessageDisplay.borderColor),[te,N]=K(null),[ne,P]=K(``),re=ie(),F=t.themes?.find(e=>e.id===re)||t.themes?.[0],[I,ae]=K(`text`),oe=[`format`,`styling`,`foreground`,`background`],se=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[ce,L]=K(0),[R,le]=K(0),z=I===`text`?oe[ce]:se[R],ue=()=>{n(e=>{e.userMessageDisplay.format=l,e.userMessageDisplay.styling=[...y],e.userMessageDisplay.foregroundColor=S===`default`?`default`:w,e.userMessageDisplay.backgroundColor=E===`none`?null:E===`default`?`default`:O,e.userMessageDisplay.borderStyle=it[A].value,e.userMessageDisplay.borderColor=M,e.userMessageDisplay.paddingX=parseInt(d)||0,e.userMessageDisplay.paddingY=parseInt(p)||0,e.userMessageDisplay.fitBoxToContent=h})},de=()=>{u(b.userMessageDisplay.format),x([...b.userMessageDisplay.styling]),C(`default`),T(`rgb(255,255,255)`),D(`none`),k(`rgb(0,0,0)`),j(it.findIndex(e=>e.value===b.userMessageDisplay.borderStyle)),ee(b.userMessageDisplay.borderColor),f(String(b.userMessageDisplay.paddingX)),m(String(b.userMessageDisplay.paddingY)),g(b.userMessageDisplay.fitBoxToContent),n(e=>{e.userMessageDisplay={...b.userMessageDisplay}})};nt(()=>{ue()},[l,y,S,w,E,O,A,M,d,p,h]),H((n,l)=>{if(r){l.return?i(!1):l.escape?(u(t.userMessageDisplay.format),i(!1)):l.backspace||l.delete?u(e=>e.slice(0,-1)):n&&u(e=>e+n);return}if(a){l.return?o(!1):l.escape?(f(String(t.userMessageDisplay.paddingX)),o(!1)):l.backspace||l.delete?f(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&f(e=>e+n);return}if(s){l.return?c(!1):l.escape?(m(String(t.userMessageDisplay.paddingY)),c(!1)):l.backspace||l.delete?m(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&m(e=>e+n);return}if(te===null){if(l.escape)e();else if(l.ctrl&&n===`r`)de();else if(l.leftArrow||l.rightArrow)ae(e=>e===`text`?`border`:`text`);else if(l.tab)I===`text`?l.shift?L(e=>e===0?oe.length-1:e-1):L(e=>e===oe.length-1?0:e+1):l.shift?le(e=>e===0?se.length-1:e-1):le(e=>e===se.length-1?0:e+1);else if(l.return)z===`format`?i(!0):z===`paddingX`?o(!0):z===`paddingY`?c(!0):z===`foreground`?S===`custom`&&(P(w),N(`foreground`)):z===`background`?E===`custom`&&(P(O),N(`background`)):z===`borderColor`&&(P(M),N(`border`));else if(l.upArrow)z===`styling`?v(e=>Math.max(0,e-1)):z===`borderStyle`?j(e=>e===0?it.length-1:e-1):z===`foreground`?C(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!w||w===``)&&T(`rgb(255,255,255)`),t}):z===`background`&&D(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(0,0,0)`),t});else if(l.downArrow)z===`styling`?v(e=>Math.min(rt.length-1,e+1)):z===`borderStyle`?j(e=>e===it.length-1?0:e+1):z===`foreground`?C(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!w||w===``)&&T(`rgb(255,255,255)`),t}):z===`background`&&D(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(0,0,0)`),t});else if(n===` `)if(z===`styling`){let e=rt[_].value;x(y.indexOf(e)>=0?y.filter(t=>t!==e):[...y,e])}else z===`fitBoxToContent`&&g(e=>!e)}});let fe=e=>{let t=S===`default`?F?.colors?.text:w,n=E===`none`?void 0:E===`default`?F?.colors?.userMessageBackground:O,r=it[A].value,i=parseInt(d)||0,a=parseInt(p)||0,o=J(V,{bold:y.includes(`bold`),italic:y.includes(`italic`),underline:y.includes(`underline`),strikethrough:y.includes(`strikethrough`),inverse:y.includes(`inverse`),color:t,backgroundColor:n,children:e});if(r===`topBottomSingle`||r===`topBottomDouble`||r===`topBottomBold`){let t=r===`topBottomSingle`?`─`:r===`topBottomDouble`?`═`:`━`,n=e.length+i*2,s=t.repeat(n);return Y(B,{flexDirection:`column`,children:[J(V,{color:M,children:s}),a>0&&J(B,{height:a}),J(B,{paddingX:i,children:o}),a>0&&J(B,{height:a}),J(V,{color:M,children:s})]})}else if(r!==`none`||i>0||a>0||h){let e=i>0||a>0?J(B,{paddingX:i,paddingY:a,children:o}):o,t={};return r!==`none`&&(t.borderStyle=r,t.borderColor=M),h?t.alignSelf=`flex-start`:t.flexGrow=1,r===`none`?e:J(B,{...t,children:e})}else return o};return te?J(We,{initialValue:ne,theme:F,onColorChange:e=>{te===`foreground`?T(e):te===`background`?k(e):te===`border`&&ee(e)},onExit:()=>{N(null),P(``)}}):Y(B,{flexDirection:`column`,children:[J(X,{children:`Customize how user messages are displayed`}),Y(B,{flexDirection:`column`,marginBottom:1,children:[J(V,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),J(V,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),Y(B,{flexDirection:`row`,gap:1,children:[Y(B,{flexDirection:`column`,width:`50%`,borderStyle:I===`text`?`round`:`single`,borderColor:I===`text`?`yellow`:`gray`,paddingX:1,children:[J(B,{marginBottom:1,children:J(V,{bold:!0,color:I===`text`?`yellow`:void 0,children:`Text & Styling`})}),J(B,{children:Y(V,{color:z===`format`?`yellow`:void 0,bold:z===`format`,children:[z===`format`?`❯ `:` `,`Format String`]})}),z===`format`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:r?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),J(B,{marginLeft:2,marginBottom:1,children:J(B,{borderStyle:`round`,borderColor:r?`yellow`:`gray`,children:J(V,{children:l})})}),J(B,{children:Y(V,{color:z===`styling`?`yellow`:void 0,bold:z===`styling`,children:[z===`styling`?`❯ `:` `,`Styling`]})}),z===`styling`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),J(B,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:rt.map((e,t)=>J(B,{children:Y(V,{color:z===`styling`&&_===t?`cyan`:void 0,children:[z===`styling`&&_===t?`❯ `:` `,y.includes(e.value)?`●`:`○`,` `,e.label]})},e.value))}),Y(B,{flexDirection:`row`,gap:1,marginBottom:1,children:[Y(B,{flexDirection:`column`,width:`50%`,children:[J(B,{children:Y(V,{color:z===`foreground`?`yellow`:void 0,bold:z===`foreground`,children:[z===`foreground`?`❯ `:` `,`Foreground`]})}),z===`foreground`&&J(B,{marginLeft:2,children:Y(V,{dimColor:!0,children:[`up/down · `,S===`custom`?`enter`:``]})}),Y(B,{marginLeft:2,flexDirection:`column`,children:[J(B,{children:Y(V,{children:[S===`default`?`● `:`○ `,`Default`]})}),J(B,{children:Y(V,{children:[S===`custom`?`● `:`○ `,`Custom`,S===`custom`&&`: `,S===`custom`&&J(V,{color:w,children:w})]})})]})]}),Y(B,{flexDirection:`column`,width:`50%`,children:[J(B,{children:Y(V,{color:z===`background`?`yellow`:void 0,bold:z===`background`,children:[z===`background`?`❯ `:` `,`Background`]})}),z===`background`&&J(B,{marginLeft:2,children:Y(V,{dimColor:!0,children:[`up/down · `,E===`custom`?`enter`:``]})}),Y(B,{marginLeft:2,flexDirection:`column`,children:[J(B,{children:Y(V,{children:[E===`default`?`● `:`○ `,`Default`]})}),J(B,{children:Y(V,{children:[E===`none`?`● `:`○ `,`None`]})}),J(B,{children:Y(V,{children:[E===`custom`?`● `:`○ `,`Custom`,E===`custom`&&`: `,E===`custom`&&J(V,{backgroundColor:O,children:O})]})})]})]})]})]}),Y(B,{flexDirection:`column`,width:`50%`,borderStyle:I===`border`?`round`:`single`,borderColor:I===`border`?`yellow`:`gray`,paddingX:1,children:[J(B,{marginBottom:1,children:J(V,{bold:!0,color:I===`border`?`yellow`:void 0,children:`Border & Padding`})}),J(B,{children:Y(V,{color:z===`borderStyle`?`yellow`:void 0,bold:z===`borderStyle`,children:[z===`borderStyle`?`❯ `:` `,`Border Style`]})}),z===`borderStyle`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:`up/down to navigate`})}),Y(B,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[J(B,{flexDirection:`column`,width:`50%`,children:it.slice(0,6).map((e,t)=>J(B,{children:Y(V,{color:z===`borderStyle`&&A===t?`cyan`:void 0,children:[z===`borderStyle`&&A===t?`❯ `:` `,A===t?`● `:`○ `,e.label]})},e.value))}),J(B,{flexDirection:`column`,width:`50%`,children:it.slice(6).map((e,t)=>{let n=t+6;return J(B,{children:Y(V,{color:z===`borderStyle`&&A===n?`cyan`:void 0,children:[z===`borderStyle`&&A===n?`❯ `:` `,A===n?`● `:`○ `,e.label]})},e.value)})})]}),J(B,{children:Y(V,{color:z===`borderColor`?`yellow`:void 0,bold:z===`borderColor`,children:[z===`borderColor`?`❯ `:` `,`Border Color`]})}),z===`borderColor`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:`enter to pick color`})}),J(B,{marginLeft:2,marginBottom:1,children:J(V,{color:M,children:M})}),Y(B,{flexDirection:`row`,gap:1,children:[Y(B,{flexDirection:`column`,width:`33%`,children:[J(B,{children:Y(V,{color:z===`paddingX`?`yellow`:void 0,bold:z===`paddingX`,children:[z===`paddingX`?`❯ `:` `,`Padding X`]})}),z===`paddingX`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:a?`enter/esc`:`enter`})}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:a?`yellow`:`gray`,children:J(V,{children:d})})})]}),Y(B,{flexDirection:`column`,width:`33%`,children:[J(B,{children:Y(V,{color:z===`paddingY`?`yellow`:void 0,bold:z===`paddingY`,children:[z===`paddingY`?`❯ `:` `,`Padding Y`]})}),z===`paddingY`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:s?`enter/esc`:`enter`})}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:s?`yellow`:`gray`,children:J(V,{children:p})})})]}),Y(B,{flexDirection:`column`,width:`33%`,children:[J(B,{children:Y(V,{color:z===`fitBoxToContent`?`yellow`:void 0,bold:z===`fitBoxToContent`,children:[z===`fitBoxToContent`?`❯ `:` `,h?`●`:`○`,` Fit box to content`]})}),z===`fitBoxToContent`&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:`space`})})]})]})]})]}),Y(B,{flexDirection:`column`,marginTop:1,paddingX:1,children:[J(B,{marginBottom:1,children:J(V,{bold:!0,children:`Preview`})}),Y(B,{flexDirection:`row`,gap:2,children:[Y(B,{flexDirection:`column`,width:`50%`,children:[J(B,{marginBottom:1,children:J(V,{underline:!0,children:`Before (Claude Code default):`})}),J(B,{marginLeft:1,children:Y(V,{backgroundColor:F?.colors?.userMessageBackground,color:F?.colors?.text,children:[` `,`> list the dir`,` `]})}),J(B,{marginLeft:1,marginTop:1,children:Y(V,{children:[J(V,{color:F?.colors?.inactive||`#888888`,children:`●`}),J(V,{children:` The directory `}),J(V,{color:F?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(V,{children:` contains `}),J(V,{bold:!0,children:`123`}),J(V,{children:` files.`})]})})]}),Y(B,{flexDirection:`column`,width:`50%`,children:[J(B,{marginBottom:1,children:J(V,{underline:!0,children:`After (Your customization):`})}),J(B,{marginLeft:1,flexDirection:`row`,children:(()=>fe(l.replace(/\{\}/g,`list the dir`)))()}),J(B,{marginLeft:1,marginTop:1,children:Y(V,{children:[J(V,{color:F?.colors?.inactive||`#888888`,children:`●`}),J(V,{children:` The directory `}),J(V,{color:F?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(V,{children:` contains `}),J(V,{bold:!0,children:`123`}),J(V,{children:` files.`})]})})]})]})]})]})}const ot=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],st=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function ct({testText:e,regex:t,regexFlags:n,format:r,styling:i,foregroundColor:a,backgroundColor:o}){let s=[];try{let c=n.includes(`g`)?n:n+`g`,l=new RegExp(t,c),u=[...e.matchAll(l)];if(u.length===0)return J(V,{children:e});let d=0;return u.forEach((t,n)=>{let c=t.index,l=c+t[0].length;c>d&&s.push(J(V,{children:e.slice(d,c)},`plain-${n}`));let u=r.replace(/\{MATCH\}/g,t[0]);s.push(J(V,{bold:i.includes(`bold`),italic:i.includes(`italic`),underline:i.includes(`underline`),strikethrough:i.includes(`strikethrough`),inverse:i.includes(`inverse`),color:a,backgroundColor:o,children:u},`match-${n}`)),d=l}),d<e.length&&s.push(J(V,{children:e.slice(d)},`plain-end`)),J(q,{children:s})}catch{return J(V,{children:e})}}function lt({highlighterIndex:e,onBack:t}){let{settings:n,updateSettings:r}=W($),i=n.inputPatternHighlighters[e],a=ie(),o=n.themes?.find(e=>e.id===a)||n.themes?.[0],[s,c]=K(i?.name||`New Highlighter`),[l,u]=K(i?.regex||``),[d,f]=K(i?.regexFlags||`g`),[p,m]=K(i?.format||`{MATCH}`),[h,g]=K(i?.styling||[]),[_,v]=K(i?.foregroundColor===null?`none`:`custom`),[y,b]=K(i?.foregroundColor||`rgb(255,0,255)`),[x,S]=K(i?.backgroundColor?`custom`:`none`),[C,w]=K(i?.backgroundColor||`rgb(0,0,0)`),[T,E]=K(i?.enabled??!0),[D,O]=K(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[k,A]=K(`name`),[j,M]=K(!1),[ee,te]=K(0),[N,ne]=K(null),[P,re]=K(``),[F,I]=K(null),[ae,oe]=K(0),[se,ce]=K(0);if(G(()=>{let e=st[ae];A(e[Math.min(se,e.length-1)])},[ae,se]),G(()=>{if(!l){I(null);return}try{new RegExp(l,d),I(null)}catch(e){I(e.message)}},[l,d]),G(()=>{e>=0&&r(t=>{t.inputPatternHighlighters[e]&&(t.inputPatternHighlighters[e]={name:s,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?y:null,backgroundColor:x===`custom`?C:null,enabled:T})})},[e,s,l,d,p,h,_,y,x,C,T]),G(()=>{r(e=>{e.inputPatternHighlightersTestText=D})},[D]),H((e,r)=>{if(j){r.return?M(!1):r.escape?(k===`name`&&c(i?.name||``),k===`regex`&&u(i?.regex||``),k===`regexFlags`&&f(i?.regexFlags||`g`),k===`format`&&m(i?.format||`{MATCH}`),k===`testText`&&O(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),M(!1)):r.backspace||r.delete?(k===`name`&&c(e=>e.slice(0,-1)),k===`regex`&&u(e=>e.slice(0,-1)),k===`regexFlags`&&f(e=>e.slice(0,-1)),k===`format`&&m(e=>e.slice(0,-1)),k===`testText`&&O(e=>e.slice(0,-1))):e&&e.length===1&&(k===`name`&&c(t=>t+e),k===`regex`&&u(t=>t+e),k===`regexFlags`&&f(t=>t+e),k===`format`&&m(t=>t+e),k===`testText`&&O(t=>t+e));return}if(N===null){if(r.escape)t();else if(r.upArrow)k===`styling`&&ee>0?te(e=>e-1):oe(e=>Math.max(0,e-1));else if(r.downArrow)k===`styling`&&ee<ot.length-1?te(e=>e+1):oe(e=>Math.min(st.length-1,e+1));else if(r.leftArrow)k===`foreground`?v(e=>e===`none`?`custom`:`none`):k===`background`?S(e=>e===`none`?`custom`:`none`):ce(e=>Math.max(0,e-1));else if(r.rightArrow)if(k===`foreground`)v(e=>e===`none`?`custom`:`none`);else if(k===`background`)S(e=>e===`none`?`custom`:`none`);else{let e=st[ae].length-1;ce(t=>Math.min(e,t+1))}else if(r.tab){let e=st.flat(),t=e.indexOf(k);if(r.shift){if(t>0){let n=e[t-1];for(let e=0;e<st.length;e++){let t=st[e].indexOf(n);if(t>=0){oe(e),ce(t);break}}}}else if(t<e.length-1){let n=e[t+1];for(let e=0;e<st.length;e++){let t=st[e].indexOf(n);if(t>=0){oe(e),ce(t);break}}}}else if(r.return)k===`name`||k===`regex`||k===`regexFlags`||k===`format`||k===`testText`?M(!0):k===`foreground`&&_===`custom`?(re(y),ne(`foreground`)):k===`background`&&x===`custom`&&(re(C),ne(`background`));else if(e===` `)if(k===`styling`){let e=ot[ee].value;h.includes(e)?g(h.filter(t=>t!==e)):g([...h,e])}else k===`enabled`&&E(!T)}}),!i)return J(B,{flexDirection:`column`,children:J(V,{color:`red`,children:`Highlighter not found`})});if(N)return J(We,{initialValue:P,theme:o,onColorChange:e=>{N===`foreground`?b(e):N===`background`&&w(e)},onExit:()=>{ne(null),re(``)}});let L=e=>k===e,R=e=>({color:L(e)?`yellow`:void 0,bold:L(e)});return Y(B,{flexDirection:`column`,children:[J(X,{children:`Edit Highlighter`}),J(B,{marginBottom:1,flexDirection:`column`,children:J(V,{dimColor:!0,children:`arrows to navigate · enter to edit · space to toggle · esc to go back`})}),Y(B,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(B,{flexDirection:`column`,width:`30%`,children:[Y(V,{...R(`name`),children:[L(`name`)?`❯ `:` `,`Name`]}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:L(`name`)?j?`green`:`yellow`:`gray`,children:J(V,{children:s||`(empty)`})})})]}),Y(B,{flexDirection:`column`,width:`45%`,children:[Y(V,{...R(`regex`),children:[L(`regex`)?`❯ `:` `,`Regex Pattern`]}),Y(B,{marginLeft:2,flexDirection:`column`,children:[J(B,{borderStyle:`round`,borderColor:L(`regex`)?j?`green`:`yellow`:F?`red`:`gray`,children:J(V,{children:l||`(empty)`})}),F&&J(V,{color:`red`,children:F})]})]}),Y(B,{flexDirection:`column`,width:`20%`,children:[Y(V,{...R(`regexFlags`),children:[L(`regexFlags`)?`❯ `:` `,`Flags`]}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:L(`regexFlags`)?j?`green`:`yellow`:`gray`,children:J(V,{children:d||`g`})})})]})]}),Y(B,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(B,{flexDirection:`column`,width:`50%`,children:[Y(V,{...R(`format`),children:[L(`format`)?`❯ `:` `,`Format String`]}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:L(`format`)?j?`green`:`yellow`:`gray`,children:J(V,{children:p||`{MATCH}`})})}),L(`format`)&&J(B,{marginLeft:2,children:Y(V,{dimColor:!0,children:[`use `,`{MATCH}`,` as placeholder`]})})]}),Y(B,{flexDirection:`column`,width:`45%`,children:[Y(V,{...R(`styling`),children:[L(`styling`)?`❯ `:` `,`Styling`]}),J(B,{marginLeft:2,flexDirection:`column`,children:ot.map((e,t)=>{let n=h.includes(e.value),r=L(`styling`)&&ee===t;return Y(V,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,n?`●`:`○`,` `,e.label]},e.value)})})]})]}),Y(B,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(B,{flexDirection:`column`,width:`48%`,children:[Y(V,{...R(`foreground`),children:[L(`foreground`)?`❯ `:` `,`Foreground Color`]}),Y(B,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(V,{color:L(`foreground`)?`yellow`:void 0,children:[`[`,_===`none`?`●`:`○`,`] none`,` `,`[`,_===`custom`?`●`:`○`,`] custom`]}),_===`custom`&&J(B,{borderStyle:`round`,borderColor:L(`foreground`)?`yellow`:`gray`,children:J(V,{color:y,children:` ████ `})})]})]}),Y(B,{flexDirection:`column`,width:`48%`,children:[Y(V,{...R(`background`),children:[L(`background`)?`❯ `:` `,`Background Color`]}),Y(B,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(V,{color:L(`background`)?`yellow`:void 0,children:[`[`,x===`none`?`●`:`○`,`] none`,` `,`[`,x===`custom`?`●`:`○`,`] custom`]}),x===`custom`&&J(B,{borderStyle:`round`,borderColor:L(`background`)?`yellow`:`gray`,children:Y(V,{backgroundColor:C,children:[` `,` `,` `]})})]})]})]}),J(B,{marginBottom:1,children:Y(V,{...R(`enabled`),children:[L(`enabled`)?`❯ `:` `,`Enabled:`,` `,J(V,{color:T?`green`:`red`,children:T?`● Yes`:`○ No`})]})}),Y(B,{flexDirection:`column`,marginBottom:1,children:[Y(V,{...R(`testText`),children:[L(`testText`)?`❯ `:` `,`Test Text`]}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:L(`testText`)?j?`green`:`yellow`:`gray`,children:J(V,{children:D||`(empty)`})})})]}),J(B,{borderStyle:`round`,padding:1,children:Y(B,{flexDirection:`column`,children:[J(V,{bold:!0,children:`Live Preview:`}),l?J(B,{marginTop:1,children:J(ct,{testText:D,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?y:void 0,backgroundColor:x===`custom`?C:void 0})}):J(V,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function ut({onBack:e}){let{settings:{inputPatternHighlighters:t,themes:n},updateSettings:r}=W($),i=ie(),a=n.find(e=>e.id===i)||n[0],o=b.themes[0],s=a?.colors.success||o.colors.success,c=a?.colors.error||o.colors.error,[l,u]=K(0),[d,f]=K(null),[p,m]=K(!0),h=()=>{let e={name:`New Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:`rgb(255,0,255)`,backgroundColor:null,enabled:!0};r(t=>{t.inputPatternHighlighters.push(e)}),f(t.length),m(!1)},g=e=>{r(t=>{t.inputPatternHighlighters.splice(e,1)}),l>=t.length-1&&u(Math.max(0,t.length-2))},_=e=>{r(t=>{t.inputPatternHighlighters[e].enabled=!t.inputPatternHighlighters[e].enabled})},v=e=>{e<=0||(r(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e-1,0,n)}),u(e-1))},y=e=>{e>=t.length-1||(r(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e+1,0,n)}),u(e+1))};return H((n,r)=>{r.escape?e():r.upArrow?u(e=>Math.max(0,e-1)):r.downArrow&&t.length>0?u(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(f(l),m(!1)):n===`n`?h():n===`x`&&t.length>0?g(l):n===` `&&t.length>0?_(l):n===`u`&&t.length>0&&l>0?v(l):n===`d`&&t.length>0&&l<t.length-1&&y(l)},{isActive:p}),d===null?Y(B,{flexDirection:`column`,children:[J(X,{children:`Input Pattern Highlighters`}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{dimColor:!0,children:`Create custom highlighters for patterns in your input prompt.`}),J(V,{dimColor:!0,children:`Matched text will be styled and optionally reformatted.`})]}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{dimColor:!0,children:`n to create a new highlighter`}),t.length>0&&J(V,{dimColor:!0,children:`space to toggle enabled/disabled`}),t.length>0&&J(V,{dimColor:!0,children:`u/d to move highlighter up/down`}),t.length>0&&J(V,{dimColor:!0,children:`x to delete a highlighter`}),t.length>0&&J(V,{dimColor:!0,children:`enter to edit highlighter`}),J(V,{dimColor:!0,children:`esc to go back`})]}),t.length===0?J(V,{children:`No highlighters created yet. Press n to create one.`}):J(B,{flexDirection:`column`,children:t.map((e,t)=>{let n=l===t,r;return n&&(r=`yellow`),Y(B,{flexDirection:`row`,children:[Y(V,{color:r,children:[n?`❯ `:` `,e.enabled?`● `:`○ `,e.name,` `]}),J(V,{dimColor:!0,children:`(`}),e.regex?Y(V,{dimColor:!0,children:[`/`,e.regex,`/`,e.regexFlags]}):J(V,{dimColor:!0,children:`(no regex)`}),e.styling.length>0&&J(q,{children:Y(V,{color:r,dimColor:!e.enabled,children:[` `,`· `,e.styling.join(`, `)]})}),J(V,{dimColor:!0,children:`)`}),e.enabled?J(V,{color:s,children:` enabled`}):J(V,{color:c,children:` disabled`})]},t)})})]}):J(lt,{highlighterIndex:d,onBack:()=>{f(null),m(!0)}})}const dt=[null,1,5,10,25,50,100,200,250,500,1e3],ft=1e3;function pt({onSubmit:e}){let{settings:t,updateSettings:n}=W($),[r,i]=K(0),[a,o]=K(!1),s={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSwarmMode:!0,enableSessionMemory:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1},c=()=>{t.misc||={...s}},l=e=>{let t=[`default`,`ascii`,`clean`,`clean-top-bottom`];return t[(t.indexOf(e)+1)%t.length]},u=e=>{switch(e){case`ascii`:return`ASCII (| and -)`;case`clean`:return`Clean (no row separators)`;case`clean-top-bottom`:return`Clean with top/bottom`;case`default`:default:return`Default (box-drawing)`}},d=e=>e===null?`Default (3)`:e<=3?`${e} (conservative)`:e<=8?`${e} (recommended)`:`${e} (aggressive)`,f=e=>e===null?`Disabled`:e===0?`0ms (instant)`:`${e}ms`,p=e=>e===null?`Off (exact counts)`:`Round to ${e}`,m=(e,t)=>{let n=dt.indexOf(e);if(n===-1)return dt[0];let r;return r=t===`next`?(n+1)%dt.length:(n-1+dt.length)%dt.length,dt[r]},h=ve(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>t.inputBox?.removeBorder??!1,toggle:()=>{n(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:()=>t.misc?.showTweakccVersion??!0,toggle:()=>{n(e=>{c(),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:()=>t.misc?.showPatchesApplied??!0,toggle:()=>{n(e=>{c(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>t.misc?.expandThinkingBlocks??!0,toggle:()=>{n(e=>{c(),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:()=>t.misc?.enableConversationTitle??!0,toggle:()=>{n(e=>{c(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>t.misc?.hideStartupBanner??!1,toggle:()=>{n(e=>{c(),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:()=>t.misc?.hideCtrlGToEdit??!1,toggle:()=>{n(e=>{c(),e.misc.hideCtrlGToEdit=!e.misc.hideCtrlGToEdit})}},{id:`hideClawd`,title:`Hide startup Clawd ASCII art`,description:`Hides the Clawd ASCII art character shown at startup.`,getValue:()=>t.misc?.hideStartupClawd??!1,toggle:()=>{n(e=>{c(),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:()=>t.misc?.increaseFileReadLimit??!1,toggle:()=>{n(e=>{c(),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:()=>t.misc?.suppressLineNumbers??!1,toggle:()=>{n(e=>{c(),e.misc.suppressLineNumbers=!e.misc.suppressLineNumbers})}},{id:`suppressRateLimitOptions`,title:`Suppress rate limit options popup`,description:`Prevents the automatic /rate-limit-options command from being triggered when hitting rate limits.`,getValue:()=>t.misc?.suppressRateLimitOptions??!1,toggle:()=>{n(e=>{c(),e.misc.suppressRateLimitOptions=!e.misc.suppressRateLimitOptions})}},{id:`mcpNonBlocking`,title:`Non-blocking MCP startup`,description:`Start immediately while MCP servers connect in background. Reduces startup time ~50% with multiple MCPs.`,getValue:()=>t.misc?.mcpConnectionNonBlocking??!0,toggle:()=>{n(e=>{c(),e.misc.mcpConnectionNonBlocking=!e.misc.mcpConnectionNonBlocking})}},{id:`mcpBatchSize`,title:`MCP server batch size`,description:`Parallel MCP connections (1-20). Use ←/→ to adjust. Higher = faster startup, more resources.`,getValue:()=>t.misc?.mcpServerBatchSize??null,getDisplayValue:()=>d(t.misc?.mcpServerBatchSize??null),toggle:()=>{n(e=>{c(),e.misc.mcpServerBatchSize=null})},increment:()=>{n(e=>{c();let t=e.misc.mcpServerBatchSize??3;e.misc.mcpServerBatchSize=Math.min(20,t+1)})},decrement:()=>{n(e=>{c();let t=(e.misc.mcpServerBatchSize??3)-1;e.misc.mcpServerBatchSize=t<1?null:t})}},{id:`tableFormat`,title:`Table output format`,description:`Controls how Claude formats tables. Default: full borders. ASCII: | and -. Clean: no top/bottom/row separators. Clean+top/bottom: borders but no row separators.`,getValue:()=>t.misc?.tableFormat??`default`,isMultiValue:!0,getDisplayValue:()=>u(t.misc?.tableFormat??`default`),toggle:()=>{n(e=>{c(),e.misc.tableFormat=l(e.misc.tableFormat??`default`)})}},{id:`enableSwarmMode`,title:`Enable swarm mode (native multi-agent)`,description:`Force-enable native multi-agent features (TeammateTool, delegate mode, swarm spawning) by bypassing the tengu_brass_pebble statsig flag.`,getValue:()=>t.misc?.enableSwarmMode??!0,toggle:()=>{n(e=>{c(),e.misc.enableSwarmMode=!e.misc.enableSwarmMode})}},{id:`statuslineThrottle`,title:`Statusline throttle`,description:`Throttle statusline updates (0-${ft}ms). Use ←/→ to adjust by 50ms. Space to disable. 0 = instant updates.`,getValue:()=>t.misc?.statuslineThrottleMs??null,getDisplayValue:()=>f(t.misc?.statuslineThrottleMs??null),toggle:()=>{n(e=>{c(),e.misc.statuslineThrottleMs=e.misc.statuslineThrottleMs===null?300:null})},increment:()=>{n(e=>{c();let t=e.misc.statuslineThrottleMs??300;e.misc.statuslineThrottleMs=Math.min(ft,t+50)})},decrement:()=>{n(e=>{c();let t=e.misc.statuslineThrottleMs??300;e.misc.statuslineThrottleMs=Math.max(0,t-50)})}},{id:`statuslineFixedInterval`,title:`Statusline fixed interval mode`,description:`Use setInterval instead of throttle. Updates happen on a fixed schedule rather than on-demand.`,getValue:()=>t.misc?.statuslineUseFixedInterval??!1,toggle:()=>{n(e=>{c(),e.misc.statuslineUseFixedInterval=!e.misc.statuslineUseFixedInterval})}},{id:`enableSessionMemory`,title:`Enable session memory`,description:`Force-enable session memory (auto-extraction + past session search) by bypassing the tengu_session_memory and tengu_coral_fern statsig flags.`,getValue:()=>t.misc?.enableSessionMemory??!0,toggle:()=>{n(e=>{c(),e.misc.enableSessionMemory=!e.misc.enableSessionMemory})}},{id:`enableRememberSkill`,title:`Enable remember skill`,description:`Register a "remember" skill to review session memories and update CLAUDE.local.md with learnings from past sessions.`,getValue:()=>t.misc?.enableRememberSkill??!1,toggle:()=>{n(e=>{c(),e.misc.enableRememberSkill=!e.misc.enableRememberSkill})}},{id:`tokenCountRounding`,title:`Token count rounding`,description:`Round displayed token counts to nearest multiple. Use ←/→ to cycle: Off, 1, 5, 10, 25, 50, 100, 200, 250, 500, 1000.`,getValue:()=>t.misc?.tokenCountRounding??null,getDisplayValue:()=>p(t.misc?.tokenCountRounding??null),toggle:()=>{n(e=>{c(),e.misc.tokenCountRounding=null})},increment:()=>{n(e=>{c(),e.misc.tokenCountRounding=m(e.misc.tokenCountRounding??null,`next`)})},decrement:()=>{n(e=>{c(),e.misc.tokenCountRounding=m(e.misc.tokenCountRounding??null,`prev`)})}},{id:`autoAcceptPlanMode`,title:`Auto-accept plan mode`,description:`Automatically accept plans without the "Ready to code?" confirmation prompt.`,getValue:()=>t.misc?.autoAcceptPlanMode??!1,toggle:()=>{n(e=>{c(),e.misc.autoAcceptPlanMode=!e.misc.autoAcceptPlanMode})}},{id:`allowBypassPermissionsInSudo`,title:`Allow bypassing permissions in sudo`,description:`⚠️ WARNING: Disables a security check. When enabled, Claude can perform system-level operations without prompts. Use extreme caution.`,getValue:()=>t.misc?.allowBypassPermissionsInSudo??!1,toggle:()=>{t.misc?.allowBypassPermissionsInSudo??!1?n(e=>{c(),e.misc.allowBypassPermissionsInSudo=!1}):o(!0)}},{id:`suppressNativeInstallerWarning`,title:`Suppress native installer warning`,description:`Suppress the native installer warning message at startup.`,getValue:()=>t.misc?.suppressNativeInstallerWarning??!1,toggle:()=>{n(e=>{c(),e.misc.suppressNativeInstallerWarning=!e.misc.suppressNativeInstallerWarning})}},{id:`filterScrollEscapeSequences`,title:`Filter scroll escape sequences`,description:`Filter out terminal escape sequences that cause unwanted scrolling.`,getValue:()=>t.misc?.filterScrollEscapeSequences??!1,toggle:()=>{n(e=>{c(),e.misc.filterScrollEscapeSequences=!e.misc.filterScrollEscapeSequences})}}],[t,n]),g=h.length,_=g-1,v=ve(()=>r<4?0:Math.min(r-4+1,g-4),[r,g]),y=h.slice(v,v+4),b=v>0,x=v+4<g;return H((t,s)=>{a?s.return?(n(e=>{c(),e.misc.allowBypassPermissionsInSudo=!0}),o(!1)):s.escape&&o(!1):s.return||s.escape?e():s.upArrow?i(e=>Math.max(0,e-1)):s.downArrow?i(e=>Math.min(_,e+1)):t===` `?h[r]?.toggle():s.rightArrow?h[r]?.increment?.():s.leftArrow&&h[r]?.decrement?.()}),J(B,{flexDirection:`column`,children:a?J(B,{flexDirection:`column`,paddingX:2,children:Y(B,{borderStyle:`double`,borderColor:`yellow`,padding:2,flexDirection:`column`,children:[J(B,{marginBottom:1,children:J(V,{bold:!0,color:`yellow`,children:`SECURITY WARNING`})}),J(B,{marginBottom:1,children:J(V,{children:`You are about to enable a feature that allows Claude Code to bypass permission checks when running with sudo privileges.`})}),J(B,{marginBottom:1,children:J(V,{color:`red`,children:`This means Claude can perform system-level operations without any prompts or confirmation.`})}),J(B,{marginBottom:1,children:J(V,{bold:!0,children:`Use with extreme caution.`})}),J(B,{children:Y(V,{children:[`Press `,J(V,{color:`red`,children:`Enter`}),` to enable,`,` `,J(V,{color:`green`,children:`Escape`}),` to cancel`]})})]})}):Y(q,{children:[J(B,{marginBottom:1,children:J(X,{children:`Miscellaneous Settings`})}),J(B,{marginBottom:1,children:J(V,{dimColor:!0,children:`Use ↑/↓ to navigate, space to toggle, ←/→ to adjust numbers, enter to go back.`})}),b&&J(B,{children:Y(V,{dimColor:!0,children:[` ↑ `,v,` more above`]})}),y.map((e,t)=>{let n=v+t===r,i=e.getValue(),a=!!e.getDisplayValue,o=!!e.increment,s;s=o?`◆`:a?`◉`:i?`☑`:`☐`;let c;c=a?e.getDisplayValue():typeof i==`boolean`?i?`Enabled`:`Disabled`:String(i??`Default`);let l=n&&o?` ← → `:``;return Y(B,{flexDirection:`column`,children:[J(B,{children:Y(V,{children:[J(V,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),J(V,{bold:!0,color:n?`cyan`:void 0,children:e.title})]})}),J(B,{children:Y(V,{dimColor:!0,children:[` `,e.description]})}),J(B,{marginLeft:4,marginBottom:1,children:Y(V,{children:[s,` `,c,J(V,{dimColor:!0,children:l})]})})]},e.id)}),x&&J(B,{children:Y(V,{dimColor:!0,children:[` `,`↓ `,g-v-4,` more below`]})}),J(B,{marginTop:1,children:Y(V,{dimColor:!0,children:[`Item `,r+1,` of `,g]})})]})})}const mt=`AgentOutputTool.AskUserQuestion.Bash.BashOutputTool.Edit.EnterPlanMode.ExitPlanMode.Glob.Grep.KillShell.ListMcpResourcesTool.LSP.NotebookEdit.Read.ReadMcpResourceTool.Skill.Task.TaskCreate.TaskGet.TaskList.TaskOutput.TaskStop.TaskUpdate.Teammate.TodoWrite.ToolSearch.WebFetch.WebSearch.Write`.split(`.`);function ht({toolsetIndex:e,onBack:t}){let{settings:n,updateSettings:r}=W($),i=n.toolsets[e],[a,o]=K(i?.name||`New Toolset`),[s,c]=K(i?.allowedTools||[]),[l,u]=K(!1),[d,f]=K(0);G(()=>{i&&r(t=>{let n=t.toolsets[e].name;t.toolsets[e].name=a,t.toolsets[e].allowedTools=s,n!==a&&(t.defaultToolset===n&&(t.defaultToolset=a),t.planModeToolset===n&&(t.planModeToolset=a))})},[a,s]);let p=e=>s===`*`?!0:s.includes(e),m=e=>{e===`All`?c(`*`):e===`None`?c([]):s===`*`?c(mt.filter(t=>t!==e)):s.includes(e)?c(s.filter(t=>t!==e)):c([...s,e])};if(H((e,n)=>{if(l){n.return?u(!1):n.escape?(o(i?.name||`New Toolset`),u(!1)):n.backspace||n.delete?o(e=>e.slice(0,-1)):e&&e.length===1&&o(t=>t+e);return}if(n.escape)t();else if(n.upArrow)f(e=>Math.max(0,e-1));else if(n.downArrow)f(e=>Math.min(mt.length+1,e+1));else if(e===` `||n.return)if(d===0)m(`All`);else if(d===1)m(`None`);else{let e=mt[d-2];e&&m(e)}else e===`n`&&u(!0)}),!i)return J(B,{flexDirection:`column`,children:J(V,{color:`red`,children:`Toolset not found`})});let h=s===`*`,g=Array.isArray(s)&&s.length===0;return Y(B,{flexDirection:`column`,children:[J(X,{children:`Edit Toolset`}),J(B,{marginBottom:1,flexDirection:`column`,children:J(V,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{bold:!0,children:`Name:`}),J(B,{marginLeft:2,children:J(B,{borderStyle:`round`,borderColor:l?`yellow`:`gray`,children:J(V,{children:a})})}),l&&J(B,{marginLeft:2,children:J(V,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{bold:!0,children:`Allowed Tools:`}),J(B,{marginLeft:2,children:Y(V,{color:d===0?`cyan`:void 0,children:[d===0?`❯ `:` `,h?`●`:`○`,` All`]})}),J(B,{marginLeft:2,children:Y(V,{color:d===1?`cyan`:void 0,children:[d===1?`❯ `:` `,g?`●`:`○`,` None`]})}),mt.map((e,t)=>{let n=t+2;return J(B,{marginLeft:2,children:Y(V,{color:d===n?`cyan`:void 0,children:[d===n?`❯ `:` `,p(e)?`◉`:`○`,` `,e]})},e)})]}),J(B,{borderStyle:`round`,padding:1,marginTop:1,children:Y(B,{flexDirection:`column`,children:[J(V,{bold:!0,children:`Summary:`}),Y(V,{children:[`Name: `,J(V,{color:`cyan`,children:a})]}),Y(V,{children:[`Tools:`,` `,s===`*`?J(V,{color:`green`,children:`All tools (*)`}):s.length===0?J(V,{color:`red`,children:`No tools ([])`}):Y(V,{color:`yellow`,children:[s.length,` selected`]})]})]})})]})}function gt({onBack:e}){let{settings:{toolsets:t,defaultToolset:n,planModeToolset:r,themes:i},updateSettings:a}=W($),o=ie(),s=i.find(e=>e.id===o)||i[0],c=b.themes[0],l=s?.colors.planMode||c.colors.planMode,u=s?.colors.autoAccept||c.colors.autoAccept,[d,f]=K(0),[p,m]=K(null),[h,g]=K(!0),_=()=>{let e={name:`New Toolset`,allowedTools:[]};a(t=>{t.toolsets.push(e)}),m(t.length),g(!1)},v=e=>{let n=t[e];a(t=>{t.toolsets.splice(e,1),t.defaultToolset===n.name&&(t.defaultToolset=null),t.planModeToolset===n.name&&(t.planModeToolset=null)}),d>=t.length-1&&f(Math.max(0,t.length-2))},y=e=>{let n=t[e];a(e=>{e.defaultToolset=n.name})},x=e=>{let n=t[e];a(e=>{e.planModeToolset=n.name})};if(H((n,r)=>{r.escape?e():r.upArrow?f(e=>Math.max(0,e-1)):r.downArrow?f(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(m(d),g(!1)):n===`n`?_():n===`x`&&t.length>0?v(d):n===`d`&&t.length>0?y(d):n===`p`&&t.length>0&&x(d)},{isActive:h}),p!==null)return J(ht,{toolsetIndex:p,onBack:()=>{m(null),g(!0)}});let S=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return Y(B,{flexDirection:`column`,children:[J(X,{children:`Toolsets`}),Y(B,{marginBottom:1,flexDirection:`column`,children:[J(V,{dimColor:!0,children:`n to create a new toolset`}),t.length>0&&J(V,{dimColor:!0,children:`d to set as default toolset`}),t.length>0&&J(V,{dimColor:!0,children:`p to set as plan mode toolset`}),t.length>0&&J(V,{dimColor:!0,children:`x to delete a toolset`}),t.length>0&&J(V,{dimColor:!0,children:`enter to edit toolset`}),J(V,{dimColor:!0,children:`esc to go back`})]}),t.length===0?J(V,{children:`No toolsets created yet. Press n to create one.`}):J(B,{flexDirection:`column`,children:t.map((e,t)=>{let i=e.name===n,a=e.name===r,o=d===t,s;return o&&(s=`yellow`),Y(B,{flexDirection:`row`,children:[Y(V,{color:s,children:[o?`❯ `:` `,e.name,` `]}),Y(V,{color:s,children:[`(`,S(e),`)`]}),i&&J(V,{color:u,children:` ⏵⏵ accept edits`}),a&&J(V,{color:l,children:` ⏸ plan mode`})]},t)})})]})}function _t({onBack:e}){let{settings:t,updateSettings:n}=W($),[r,i]=K(`plan`),[a,o]=K(!1),[s,c]=K(0),l=t.subagentModels||{plan:null,explore:null,generalPurpose:null},u=[{id:`plan`,title:`Plan Agent`,description:`The agent responsible for creating implementation plans.`},{id:`explore`,title:`Explore Agent`,description:`The agent specialized for exploring codebases.`},{id:`generalPurpose`,title:`General-purpose Agent`,description:`The agent used for general multi-step tasks.`}],d=[{label:`Default (Inherited)`,value:null},{label:`sonnet`,value:`sonnet`},{label:`haiku`,value:`haiku`},{label:`opus`,value:`opus`},{label:`sonnet[1m]`,value:`sonnet[1m]`}];return H((t,f)=>{if(a){if(f.escape)o(!1);else if(f.upArrow)c(e=>e>0?e-1:d.length-1);else if(f.downArrow)c(e=>e<d.length-1?e+1:0);else if(f.return){let e=d[s].value;n(t=>{t.subagentModels||={plan:null,explore:null,generalPurpose:null},t.subagentModels[r]=e}),o(!1)}}else if(f.escape)e();else if(f.upArrow){let e=u.findIndex(e=>e.id===r);i(u[e>0?e-1:u.length-1].id)}else if(f.downArrow){let e=u.findIndex(e=>e.id===r);i(u[e<u.length-1?e+1:0].id)}else if(t===` `||f.return){let e=l[r],t=d.findIndex(t=>t.value===e);c(t>=0?t:0),o(!0)}}),a?Y(B,{flexDirection:`column`,children:[J(B,{marginBottom:1,children:Y(X,{children:[`Select Model for`,` `,u.find(e=>e.id===r)?.title]})}),d.map((e,t)=>{let n=t===s;return J(B,{children:Y(V,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.label,e.value?Y(V,{dimColor:!0,children:[` (`,e.value,`)`]}):null]})},t)})]}):Y(B,{flexDirection:`column`,children:[J(B,{marginBottom:1,children:J(X,{children:`Subagent Model Settings`})}),J(B,{marginBottom:1,children:J(V,{dimColor:!0,children:`Configure which Claude model each subagent uses. Use arrow keys to navigate, enter or space to change a model, and escape to go back.`})}),u.map(e=>{let t=e.id===r,n=l[e.id],i=d.find(e=>e.value===n)?.label||n||`Default`;return Y(B,{flexDirection:`column`,marginBottom:1,children:[J(B,{children:Y(V,{color:t?`cyan`:void 0,children:[t?`❯ `:` `,J(V,{bold:!0,children:e.title})]})}),J(B,{marginLeft:4,children:J(V,{dimColor:!0,children:e.description})}),J(B,{marginLeft:4,children:Y(V,{children:[`Current: `,J(V,{color:`green`,children:i})]})})]},e.id)})]})}function vt({onBack:e}){let{settings:t,updateSettings:n}=W($),r=t.claudeMdAltNames??[],[i,a]=K(0),[o,s]=K(!1),[c,l]=K(``),[u,d]=K(!1);return H((t,f)=>{if(o||u){f.return&&c.trim()?(u?(n(e=>{e.claudeMdAltNames||=[],e.claudeMdAltNames.push(c.trim())}),d(!1)):(n(e=>{e.claudeMdAltNames&&(e.claudeMdAltNames[i]=c.trim())}),s(!1)),l(``)):f.escape?(l(``),s(!1),d(!1)):f.backspace||f.delete?l(e=>e.slice(0,-1)):t&&l(e=>e+t);return}f.escape?e():f.upArrow?r.length>0&&a(e=>e>0?e-1:r.length-1):f.downArrow?r.length>0&&a(e=>e<r.length-1?e+1:0):t===`e`?r.length>0&&(l(r[i]),s(!0)):t===`d`?r.length>0&&(n(e=>{e.claudeMdAltNames&&=e.claudeMdAltNames.filter((e,t)=>t!==i)}),i>=r.length-1&&a(Math.max(0,r.length-2))):t===`n`?(d(!0),l(``)):f.ctrl&&t===`r`?(n(e=>{e.claudeMdAltNames=[...b.claudeMdAltNames??[]]}),a(0)):t===`u`||f.shift&&f.upArrow?r.length>1&&i>0&&(n(e=>{if(!e.claudeMdAltNames)return;let t=e.claudeMdAltNames;[t[i-1],t[i]]=[t[i],t[i-1]]}),a(e=>e-1)):(t===`j`||f.shift&&f.downArrow)&&r.length>1&&i<r.length-1&&(n(e=>{if(!e.claudeMdAltNames)return;let t=e.claudeMdAltNames;[t[i],t[i+1]]=[t[i+1],t[i]]}),a(e=>e+1))}),Y(B,{flexDirection:`column`,children:[Y(B,{marginBottom:1,flexDirection:`column`,children:[J(X,{children:`CLAUDE.md Alternative Names`}),Y(B,{flexDirection:`column`,children:[J(V,{dimColor:!0,children:`changes auto-saved`}),J(V,{dimColor:!0,children:`esc to go back`})]})]}),J(B,{marginBottom:1,flexDirection:`column`,children:J(V,{dimColor:!0,children:`When Claude Code looks for CLAUDE.md and doesn't find it, it will try these alternative filenames in order. This lets you use AGENTS.md (and other file names).`})}),J(B,{marginBottom:1,children:J(V,{dimColor:!0,children:`e to edit · d to delete · n to add new · u/j to move up/down · ctrl+r to reset`})}),Y(B,{flexDirection:`column`,children:[r.length===0?J(V,{children:`No alternative names configured. Press n to add one.`}):J(q,{children:(()=>{let e=Math.max(0,i-6),t=Math.min(r.length,e+12),n=Math.max(0,t-12),a=r.slice(n,t);return Y(q,{children:[n>0&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↑ `,n,` more above`]}),a.map((e,t)=>{let r=n+t,a=r===i;return Y(V,{color:a?`cyan`:void 0,children:[a?`❯ `:` `,e]},r)}),t<r.length&&Y(V,{color:`gray`,dimColor:!0,children:[` `,`↓ `,r.length-t,` more below`]})]})})()}),u&&Y(B,{alignItems:`center`,children:[J(V,{color:`yellow`,children:`❯ `}),J(B,{borderStyle:`round`,borderColor:`yellow`,children:J(V,{children:c})})]}),o&&Y(B,{marginTop:1,alignItems:`center`,children:[J(V,{children:`Editing: `}),J(B,{borderStyle:`round`,borderColor:`yellow`,children:J(V,{children:c})})]})]})]})}const $=ge({settings:b,updateSettings:e=>{},changesApplied:!1,ccVersion:``});function yt({startupCheckInfo:e,configMigrated:t,invocationCommand:r,initialConfig:i}){let[a,o]=K(i),[s,c]=K(!i.hidePiebaldAnnouncement),l=_e(e=>{let t=JSON.parse(JSON.stringify(a.settings));e(t),o(e=>({...e,settings:t,changesApplied:!1})),j(e=>{e.settings=t,e.changesApplied=!1})},[a.settings]),[u,d]=K(null),[f,p]=K(null);G(()=>{e.wasUpdated&&e.oldVersion&&(p({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
3
+ (However, your customization are still remembered in ${P}.)
4
+
5
+ Please reapply your changes by running \`${r} --apply\`.`,type:`warning`}),l(()=>{}))},[]),H((e,t)=>{t.ctrl&&e===`c`&&process.exit(0),(e===`q`||t.escape)&&!u&&process.exit(0),e===`h`&&!u&&s&&(c(!1),j(e=>{e.hidePiebaldAnnouncement=!0}))},{isActive:!u});let m=t=>{switch(p(null),t){case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.INPUT_PATTERN_HIGHLIGHTERS:case Z.MISC:case Z.TOOLSETS:case Z.SUBAGENT_MODELS:case Z.CLAUDE_MD_ALT_NAMES:d(t);break;case Z.VIEW_SYSTEM_PROMPTS:g(C);break;case Z.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?y(e.ccInstInfo):_(e.ccInstInfo)).then(()=>{p({message:`Original Claude Code restored successfully!`,type:`success`}),l(()=>{})});break;case Z.OPEN_CONFIG:n(P);break;case Z.OPEN_CLI:e.ccInstInfo?.cliPath&&n(e.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},h=()=>{d(null)};return J($.Provider,{value:{settings:a.settings,updateSettings:l,changesApplied:a.changesApplied,ccVersion:e.ccInstInfo?.version||``},children:J(B,{flexDirection:`column`,children:u===null?J(ze,{onSubmit:m,notification:f,configMigrated:t,showPiebaldAnnouncement:s,changesApplied:a.changesApplied,invocationCommand:r}):u===Z.THEMES?J(Ye,{onBack:h}):u===Z.THINKING_VERBS?J(Xe,{onBack:h}):u===Z.THINKING_STYLE?J(tt,{onBack:h}):u===Z.USER_MESSAGE_DISPLAY?J(at,{onBack:h}):u===Z.INPUT_PATTERN_HIGHLIGHTERS?J(ut,{onBack:h}):u===Z.MISC?J(pt,{onSubmit:h}):u===Z.TOOLSETS?J(gt,{onBack:h}):u===Z.SUBAGENT_MODELS?J(_t,{onBack:h}):u===Z.CLAUDE_MD_ALT_NAMES?J(vt,{onBack:h}):null})})}async function bt(e,t){let n=t??await w(),r=await se(n,e);if(!r)return{startupCheckInfo:null,pendingCandidates:null,config:n};let i=de(r);return i?{startupCheckInfo:null,pendingCandidates:i,config:n}:{startupCheckInfo:await xt(n,r),pendingCandidates:null,config:n}}async function xt(e,t){if(!t)return null;if(t.version)try{i(await s(t.version))}catch{}let n=t.version,r=e.ccVersion,o=!1;await N(re)||(T(`startupCheck: ${re} not found; backing up cli.js`),await v(t),o=!0);let c=!1;return t.nativeInstallationPath&&!await N(O)&&(T(`startupCheck: ${O} not found; backing up native binary`),await a(t),c=!0),n===r?{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}:(o||(T(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await Ce.unlink(re),await v(t)),t.nativeInstallationPath&&!c&&(T(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await N(O)&&await Ce.unlink(O),await a(t)),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t})}let St;async function Ct(){if(St!==void 0)return St;try{return St=(await import(`oxfmt`)).format,St}catch(e){return T(`Failed to load oxfmt:`,e),St=null,null}}async function wt(e,t,n){let r=await Ct();if(!r)return T(`oxfmt unavailable, skipping format+diff`),null;let i=n?.contextLines??10,a=n?.printWidth??80,o=performance.now(),[s,c]=await Promise.all([r(`original.js`,e,{printWidth:a}),r(`modified.js`,t,{printWidth:a})]),l=performance.now();if(s.errors.length>0||c.errors.length>0)return T(`oxfmt format errors:`,`original:`,s.errors,`modified:`,c.errors),null;let u=we(`original.js`,`modified.js`,s.code,c.code,``,``,{context:i}),d=performance.now();return{hunks:u.hunks,changeCount:u.hunks.length,formattedLines:s.code.split(`
6
+ `).length,timings:{formatMs:l-o,diffMs:d-l,totalMs:d-o}}}function Tt(e){return new Promise(t=>{let n=!1,r=e=>{n||(n=!0,i.close(),t(e))},i=De.createInterface({input:process.stdin,output:process.stderr});i.on(`close`,()=>r(!1)),i.on(`SIGINT`,()=>r(!1)),i.question(e,e=>{let t=e.trim().toLowerCase();r(t===``||t===`y`||t===`yes`)})})}function Et(e){for(let t of e){console.log(U.cyan(`@@ -${t.oldStart} +${t.newStart} @@`));for(let e of t.lines)e.startsWith(`+`)?console.log(U.green(e)):e.startsWith(`-`)?console.log(U.red(e)):console.log(U.gray(e));console.log()}}async function Dt(e,t,n=!1){if(n)return!0;console.log(U.gray(`Formatting for diff preview...`));let r=await wt(e,t,{contextLines:10});return r?r.changeCount===0?(console.log(U.yellow(`No visible differences after formatting. Proceeding.`)),!0):(console.log(U.gray(`Formatted ${r.formattedLines.toLocaleString()} lines in ${r.timings.formatMs.toFixed(0)}ms\n`)),Et(r.hunks),console.log(U.gray(`${r.changeCount} change(s) across ${r.formattedLines.toLocaleString()} formatted lines (${r.timings.totalMs.toFixed(0)}ms)`)),Tt(U.bold(`
7
+ Apply these changes? [Y/n] `))):(console.log(U.yellow(`Could not generate formatted diff (oxfmt unavailable or parse error).`)),Tt(U.bold(`
8
+ Apply changes without diff preview? [Y/n] `)))}function Ot(e){return u(),{chalkVar:p(e),moduleLoaderFunction:o(e),reactVar:l(e),requireFuncName:m(e),textComponent:r(e),boxComponent:d(e)}}async function kt(e,t,n,r=!1){let i=`
9
+ let input = '';
10
+ process.stdin.on('data', c => input += c);
11
+ process.stdin.on('end', async () => {
573
12
  try {
574
- fsRenameSync(oldPath, newPath);
575
- return;
13
+ const vars = ${JSON.stringify(n)};
14
+ process.env = {};
15
+ const fn = new Function('js', 'vars', ${JSON.stringify(e)});
16
+ const result = await fn(input, vars);
17
+ process.stdout.write(JSON.stringify({"r": result}));
576
18
  } catch (e) {
577
- if (e.code == "ENOENT") {
578
- // named-sessions/{projectSlug} exists, so the error is because the old named-session doesn't exist.
579
- // So we need to create the new file later.
580
- // DO NOT return.
581
- } else {
582
- throw new Error('cannot rename ' + oldPath + ' -> ' + newPath + ': ' + e);
583
- }
19
+ process.stderr.write(e instanceof Error ? e.message : String(e));
20
+ process.exitCode = 1;
584
21
  }
585
- }
586
- }
587
-
588
- // Only create our summary entry if a custom title has been set. Because we want the auto
589
- // title generation to kick in if the user hasn't set a title, and the auto title generation
590
- // won't generate titles for sessions older than the most recently
591
- if (CUR_CONVERSATION_TITLE != "") {
592
- setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
593
- const uuid = cryptoRandomUUID();
594
-
595
- // Create the summary file.
596
- const newFilePath = pathJoin(projectDir, uuid + '.jsonl');
597
- const summaryObj = {
598
- type: "summary",
599
- summary: CUR_CONVERSATION_TITLE,
600
- leafUuid: msg.uuid,
601
- // This is important.
602
- tweakcc: null,
603
- };
604
- fsWriteFileSync(newFilePath, JSON.stringify(summaryObj));
605
-
606
- fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
607
- recursive: true,
608
22
  });
609
- fsWriteFileSync(
610
- pathJoin(tweakcc, "named-sessions", projectSlug, msg.uuid),
611
- uuid
612
- );
613
- }
614
- }
615
-
616
- `,i=e.slice(0,t)+r+e.slice(t);return U(e,i,r,t,t),i},an=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]}},on=e=>{let t=an(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=In(e),{location:r,messageVar:i}=t,a=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
617
- const projectDir = pathDirname(this.sessionFile);
618
- const projectSlug = pathBasename(projectDir);
619
- onNewMessage(projectDir, projectSlug, ${i});
620
- `,o=e.slice(0,r)+a+e.slice(r);return U(e,o,a,r,r),o},sn=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}},cn=e=>{let t=sn(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=In(e),{orLocation:r,loopLocation:i,messageVar:a,fileListVar:o}=t,s=e,c=`const { readFileSync: fsReadFileSync } = ${n}('fs');
621
- const tweakccSummaries = new Set();
622
- for (const file of ${o}) {
623
- const contents = fsReadFileSync(file, "utf8").trim();
624
- if (contents.includes("\\n")) continue;
625
- let obj;
626
- try {
627
- obj = JSON.parse(contents);
628
- } catch {
629
- // Skip invalid files.
630
- continue;
631
- }
632
- if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
633
- tweakccSummaries.add(obj.leafUuid);
634
- }
635
- `;s=s.slice(0,i)+c+s.slice(i),U(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 U(s,d,u,l,l),d},ln=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):(U(e,r,n,t.index,t.index+63),r)},un=e=>{let t=e;if(t=tn(t),!t)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(t=rn(t),!t)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(t=on(t),!t)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(t=cn(t),!t)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let n=ln(t);return n?t=n:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),t},dn=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}},fn=e=>{let t=dn(e);if(!t)return null;let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return U(e,n,`,`,t.startIndex,t.endIndex),n},pn=e=>{let t=e.match(/if\(([$\w]+&&[$\w]+)\)p\("tengu_external_editor_hint_shown",/);if(!t||t.index===void 0)return console.error(`patch: hideCtrlGToEdit: failed to find tengu_external_editor_hint_shown pattern`),null;let n=t[1],r=t.index+3;return{startIndex:r,endIndex:r+n.length,identifiers:[]}},mn=e=>{let t=pn(e);if(!t)return null;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return U(e,r,n,t.startIndex,t.endIndex),r},hn=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},gn=e=>{let t=hn(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];U(e,i,r,t,t)}return i},_n=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}},vn=e=>{let t=_n(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return U(e,r,n,t.startIndex,t.endIndex),r},yn=e=>{let t=e.match(/if\(([$\w]+)\.length>=\d+\)return`\$\{\1\}(?:→|\\u2192)\$\{([$\w]+)\}`;return`\$\{\1\.padStart\(\d+," "\)\}(?:→|\\u2192)\$\{\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]]}},bn=e=>{let t=yn(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 U(e,i,r,t.startIndex,t.endIndex),i},xn=e=>{let t=e.match(/\bshowAllInTranscript:[$\w]+,agentDefinitions:[$\w]+,onOpenRateLimitOptions:([$\w]+)/);if(!t||t.index===void 0)return console.error(`patch: suppressRateLimitOptions: failed to find onOpenRateLimitOptions pattern`),null;let n=t[1],r=t.index+t[0].length-n.length,i=r+n.length,a=`()=>{}`,o=e.slice(0,r)+a+e.slice(i);return U(e,o,a,r,i),o},Sn=e=>{let t=e.indexOf(`∴ Thinking…`);if(t===-1)return console.error(`patch: thinkingLabel: failed to find "∴ Thinking…" anchor`),null;let n=t,r=Math.min(t+200,e.length),i=e.slice(n,r).match(/([$\w]+(?:\.default)?)\.createElement\(([$\w]+),null,([$\w]+)\)/);return!i||i.index===void 0?(console.error(`patch: thinkingLabel: failed to find createElement pattern within 200 chars of anchor`),null):{startIndex:n+i.index,endIndex:n+i.index+i[0].length,identifiers:[i[1],i[2],i[3]]}},Cn=e=>{let t=Sn(e);if(!t)return null;let n=Rn(e);if(!n)return console.error(`patch: thinkingLabel: failed to find Box component`),null;let r=Ln(e);if(!r)return console.error(`patch: thinkingLabel: failed to find Text component`),null;let i=Pn(e);if(!i)return console.error(`patch: thinkingLabel: failed to find React variable`),null;let a=`${i}.createElement(${n},null,${i}.createElement(${r},{italic:true,dimColor:true},${t.identifiers[2]}))`,o=e.slice(0,t.startIndex)+a+e.slice(t.endIndex);return U(e,o,a,t.startIndex,t.endIndex),o},wn=async e=>{if(!e.cliPath){G(`backupClijs: Skipping for native installation (no cliPath)`);return}await br(),G(`Backing up cli.js to ${hr}`),await b.copyFile(e.cliPath,hr),await Cr(t=>{t.changesApplied=!1,t.ccVersion=e.version})},Tn=async e=>{e.nativeInstallationPath&&(await br(),G(`Backing up native binary to ${gr}`),await b.copyFile(e.nativeInstallationPath,gr),await Cr(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},En=async e=>{if(!e.cliPath)return G(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;G(`Restoring cli.js from backup to ${e.cliPath}`);let t=await b.readFile(hr);return await rr(e.cliPath,t,`restore`),await nt(),await Cr(e=>{e.changesApplied=!1}),!0},Dn=async e=>{if(!e.nativeInstallationPath)return G(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await ir(gr))return G(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;G(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await b.readFile(gr);return await rr(e.nativeInstallationPath,t,`restore`),!0},U=(e,t,n,r,i)=>{if(!Kn())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&&(K(`
636
- --- Diff ---`),K(`OLD:`,c+`\x1b[31m${l}\x1b[0m`+u),K(`NEW:`,d+`\x1b[32m${f}\x1b[0m`+p),K(`--- End Diff ---
637
- `))},W=e=>e.replace(/\$/g,`\\$`),On=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},kn=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(n)return n[1];console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},An=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]},jn=e=>{let t=An(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=${W(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 Mn=null,Nn=null;const Pn=e=>{if(Mn!=null)return Mn;let t=kn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),Mn=void 0;return}let n=An(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),Mn=void 0;return}let r=RegExp(`\\b([$\\w]+)=${W(t)}\\(${W(n)}\\(\\),1\\)`),i=e.match(r);if(i)return Mn=i[1],Mn;let a=jn(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),Mn=void 0;return}let o=RegExp(`\\b([$\\w]+)=${W(t)}\\(${W(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),Mn=void 0;return}return Mn=s[1],Mn},Fn=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${W(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]},In=e=>{if(Nn!=null)return Nn;let t=Fn(e);return t?(Nn=t,Nn):(Nn=`require`,Nn)},Ln=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]},Rn=e=>{let t=e.match(/\b([$\w]+)\.displayName="Box"/);if(t){let n=t[1],r=RegExp(`\\b([$\\w]+)=${W(n)}[^$\\w]`),i=e.match(r);if(i)return i[1];console.error(`patch: findBoxComponent: found Box displayName but failed to find Box component variable (boxOrigCompName=${n})`)}let n=e.match(/\bfunction ([$\w]+)\(\{children:[$\w]+,flexWrap:[$\w]+="nowrap",flexDirection:[$\w]+="row",flexGrow:[$\w]+=[0-9]+,flexShrink:[$\w]+=[0-9]+/);if(n){let t=n[1],r=RegExp(`\\b([$\\w]+)=${W(t)}\\}`),i=e.match(r);return i?i[1]:(console.error(`patch: findBoxComponent: found internal Box function (${t}) but no assignment found`),t)}console.error(`patch: findBoxComponent: failed to find Box component (neither displayName nor function signature found)`)},zn=async(e,t)=>{let n;if(t.nativeInstallationPath){await Dn(t);let e=!1;try{await y.stat(gr),e=!0}catch{}let r=e?gr:t.nativeInstallationPath;G(`Extracting claude.js from ${e?`backup`:`native installation`}: ${r}`);let i=await ee(r);if(!i)throw Error(`Failed to extract claude.js from native installation`);let a=C.join(J,`native-claudejs-orig.js`);x.writeFileSync(a,i),G(`Saved original extracted JS from native to: ${a}`),n=i.toString(`utf8`)}else{if(await En(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);n=await y.readFile(t.cliPath,{encoding:`utf8`})}let r=[],i=await jt(n,t.version);n=i.newContent,r.push(...i.items);let a=null;e.settings.themes&&e.settings.themes.length>0&&(a=ae(n,e.settings.themes))&&(n=a),e.settings.thinkingVerbs&&((a=Se(n,e.settings.thinkingVerbs.verbs))&&(n=a),(a=H(n,e.settings.thinkingVerbs.format))&&(n=a)),(a=he(n,e.settings.thinkingStyle.phases))&&(n=a),(a=_e(n,e.settings.thinkingStyle.updateInterval))&&(n=a),(a=ye(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=a),(a=pe(n,e.settings.thinkingStyle.reverseMirror))&&(n=a),e.settings.userMessageDisplay&&(a=we(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.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0&&(a=Me(n,e.settings.inputPatternHighlighters))&&(n=a),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`&&(a=le(n,e.settings.inputBox.removeBorder))&&(n=a),(a=Pe(n))&&(n=a),(a=de(n))&&(n=a),(a=se(n))&&(n=a),(a=Hn(n))&&(n=a),e.settings.subagentModels&&(a=Le(n,e.settings.subagentModels))&&(n=a),(a=re(n,25))&&(n=a),(e.settings.misc?.expandThinkingBlocks??!0)&&(a=Ie(n))&&(n=a),(a=Cn(n))&&(n=a);let o=e.settings.misc?.showTweakccVersion??!0,s=e.settings.misc?.showPatchesApplied??!0;(a=Ue(n,`3.4.0`,r,o,s))&&(n=a),(a=Nt(n))&&(n=a),e.settings.toolsets&&e.settings.toolsets.length>0&&(a=en(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=a),e.settings.planModeToolset&&e.settings.defaultToolset&&((a=Zt(n))&&(n=a),(a=$t(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=a));let c=e.settings.misc?.enableConversationTitle??!0,l=t.version&&st(t.version,`2.0.64`)<0;if(c&&l&&(a=un(n))&&(n=a),e.settings.misc?.hideStartupBanner&&(a=fn(n))&&(n=a),e.settings.misc?.hideCtrlGToEdit&&(a=mn(n))&&(n=a),e.settings.misc?.hideStartupClawd&&(a=gn(n))&&(n=a),e.settings.misc?.increaseFileReadLimit&&(a=vn(n))&&(n=a),e.settings.misc?.suppressLineNumbers&&(a=bn(n))&&(n=a),e.settings.misc?.suppressRateLimitOptions&&(a=xn(n))&&(n=a),t.nativeInstallationPath){G(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=C.join(J,`native-claudejs-patched.js`);x.writeFileSync(e,n,`utf8`),G(`Saved patched JS from native to: ${e}`);let r=Buffer.from(n,`utf8`);await te(t.nativeInstallationPath,r,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await rr(t.cliPath,n,`patch`)}return await Cr(e=>{e.changesApplied=!0})},Bn=[{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)`}],Vn=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 ${W(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)},Hn=e=>{let t=Vn(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Bn.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return U(e,a,i,n,n),a};let Un=!1,Wn=!1;const Gn=()=>Un,Kn=()=>Wn,qn=()=>{Un=!0},Jn=()=>{Wn=!0,Un=!0},G=(e,...t)=>{Gn()&&console.log(e,...t)},K=(e,...t)=>{Kn()&&console.log(e,...t)};function Yn(){try{let e=E.join(O.homedir(),`.claude.json`);return JSON.parse(T.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Xn(){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=Bn.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Qn(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 $n(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 er(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 tr(e){if(!er(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 nr(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 rr(e,t,n=`replace`){let r=493;try{r=(await b.stat(e)).mode,G(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){G(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await b.unlink(e),G(`[${n}] Unlinked ${e} to break hard links`)}catch(t){G(`[${n}] Could not unlink ${e}: ${t}`)}await b.writeFile(e,t),await b.chmod(e,r),G(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function ir(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 ar=e=>e.startsWith(`~`)?E.join(O.homedir(),e.slice(1)):e,or=(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]},sr=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function cr(e,t){if(e==null)return t;if(typeof t!=`object`||!t)return e;if(Array.isArray(t))return Array.isArray(e)?e:t;let n={...e};for(let e of Object.keys(t)){let r=t[e];e in n?typeof r==`object`&&r&&!Array.isArray(r)&&(n[e]=cr(n[e],r)):n[e]=r}return n}const lr=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)},ur=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function dr(){try{let e=await b.readFile(Y,`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 br(),await b.writeFile(Y,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const q={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,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!0,suppressRateLimitOptions:!1},toolsets:[],defaultToolset:null,planModeToolset:null,subagentModels:{plan:null,explore:null,generalPurpose:null},inputPatternHighlighters:[],inputPatternHighlightersTestText:`Type test text here to see highlighting`},fr={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},pr={name:`Unnamed Toolset`,allowedTools:`*`},mr=q.themes[0],J=(()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return ar(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){G(`Failed to check if ${t} exists: ${e}`)}try{if(S.existsSync(n))return n}catch(e){G(`Failed to check if ${n} exists: ${e}`)}return r?w.join(r,`tweakcc`):t})(),Y=w.join(J,`config.json`),hr=w.join(J,`cli.js.backup`),gr=w.join(J,`native-binary.backup`),_r=w.join(J,`system-prompts`),vr=w.join(J,`prompt-data-cache`),yr=()=>{let e=J,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
- 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
- `)))},br=async()=>{await b.mkdir(J,{recursive:!0}),await b.mkdir(_r,{recursive:!0});let e=w.join(J,`.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 xr=null;const Sr=async()=>{let e={ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:q};try{G(`Reading config at ${Y}`),yr();let t=await b.readFile(Y,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;return r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation),n.settings=cr(n.settings,q),n.settings.inputPatternHighlighters&&(n.settings.inputPatternHighlighters=n.settings.inputPatternHighlighters.map(e=>cr(e,fr))),n.settings.toolsets&&(n.settings.toolsets=n.settings.toolsets.map(e=>cr(e,pr))),n.settings.themes&&(n.settings.themes=n.settings.themes.map(e=>cr(e,mr))),lr(n),ur(n),delete n.settings.launchText,await rt(_r)&&(n.changesApplied=!1),await wr(n),xr=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},Cr=async e=>(G(`Updating config at ${Y}`),xr||=await Sr(),e(xr),xr.lastModified=new Date().toISOString(),await wr(xr),xr),wr=async e=>{try{e.lastModified=new Date().toISOString(),await br(),await b.writeFile(Y,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}};var X=({children:e,...n})=>P(t,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...n,children:[` `,e,` `]});const Tr=[`\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 Er=()=>P(e,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[P(e,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[N(t,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),N(t,{children:` `}),P(t,{children:[`We've released `,N(t,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),P(t,{children:[`Download it and try it out for free!`,` `,N(v,{url:`https://piebald.ai/`,fallback:!1,children:N(t,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),N(t,{children:` `}),N(t,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),N(e,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:Tr.map((e,n)=>N(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.INPUT_PATTERN_HIGHLIGHTERS=`Input pattern highlighters`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.SUBAGENT_MODELS=`Subagent models`,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 Dr({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)}),N(e,{flexDirection:`column`,children:n.map((n,r)=>N(e,{children:P(t,{children:[P(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&&P(t,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,n.desc]})]})},r))})}const Or=[{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.INPUT_PATTERN_HIGHLIGHTERS,desc:`Create custom highlighters for patterns in your input`},{name:Z.MISC,desc:`Miscellaneous settings (input box border, etc.)`},{name:Z.TOOLSETS,desc:`Manage toolsets to control which tools are available`},{name:Z.SUBAGENT_MODELS,desc:`Configure which Claude model each subagent uses (Plan, Explore, etc.)`},{name:Z.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],kr=[{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 (${Y})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var Ar=({onSubmit:e})=>{let t=[...u($).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:`Required: Updates Claude Code in-place with your changes`,selectedStyles:{color:`green`}}],...Or,...kr],[n,r]=m(0);return N(Dr,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const jr=()=>P(e,{flexDirection:`row`,children:[N(X,{children:`tweakcc`}),N(t,{children:` (by `}),N(v,{url:`https://piebald.ai`,fallback:!1,children:N(t,{color:`#ff8400`,bold:!0,children:`Piebald`})}),N(t,{children:`)`})]}),Mr=()=>N(e,{children:P(t,{color:`yellow`,children:[`⭐ `,N(t,{bold:!0,children:`Star the repo at `}),N(v,{url:`https://github.com/Piebald-AI/tweakcc`,fallback:!1,children:N(t,{bold:!0,color:`cyan`,children:`https://github.com/Piebald-AI/tweakcc`})}),N(t,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),Nr=({notification:n})=>N(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:N(t,{color:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,children:n.message})}),Pr=({onSubmit:n,notification:r,configMigrated:i,showPiebaldAnnouncement:a})=>P(e,{flexDirection:`column`,gap:1,children:[i&&N(e,{children:N(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."})}),N(jr,{}),N(e,{children:P(t,{children:[N(t,{bold:!0,children:`Customize your Claude Code installation.`}),` `,P(t,{dimColor:!0,children:[`Settings will be saved to `,J.replace(h.homedir(),`~`),`/config.json.`]})]})}),N(a?Er:Mr,{}),r&&N(Nr,{notification:r}),N(Ar,{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 N(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 N(t,{children:u(d)})}return N(t,{color:e,backgroundColor:n,bold:r,dimColor:i,children:s})}function Fr({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?N(t,{children:e.split(``).map((a,o)=>{let c=o>=s&&o<s+i&&s<e.length,l=o%n.length;return N(t,{color:c?r[l]:n[l],children:a},o)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),N(t,{children:e}))}const Ir=F.cwd();function Lr({theme:n}){let{ccVersion:r}=u($);return P(e,{flexDirection:`column`,paddingLeft:1,children:[N(e,{marginBottom:1,children:P(t,{bold:!0,children:[`Preview: `,n.name]})}),N(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:P(e,{flexDirection:`column`,children:[P(e,{flexDirection:`column`,children:[P(t,{children:[N(Q,{color:n.colors.clawd_body,children:` ▐`}),N(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`▛███▜`}),P(t,{children:[N(Q,{color:n.colors.clawd_body,children:`▌ `}),` `,N(t,{bold:!0,children:`Claude Code`}),` `,r?`v${r}`:`v2.0.14`]})]}),P(t,{children:[N(Q,{color:n.colors.clawd_body,children:`▝▜`}),N(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`█████`}),N(Q,{color:n.colors.clawd_body,children:`▛▘`}),` `,Zn(),` · `,Xn()]}),P(Q,{color:n.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,Ir]}),P(t,{children:[P(Q,{color:n.colors.success,children:[`Login successful. Press`,` `]}),N(Q,{bold:!0,color:n.colors.success,children:`Enter`}),P(Q,{color:n.colors.success,children:[` `,`to continue…`]})]})]}),N(t,{children:`╭─────────────────────────────────────────────╮`}),P(t,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),P(t,{children:[`│ 2`,` `,N(Q,{backgroundColor:n.colors.diffRemoved,color:n.colors.text,children:`- console.log("`}),N(Q,{backgroundColor:n.colors.diffRemovedWord,children:`Hello, World!`}),N(Q,{backgroundColor:n.colors.diffRemoved,children:`");`}),` `,`│`]}),P(t,{children:[`│ 2`,` `,N(Q,{backgroundColor:n.colors.diffAdded,color:n.colors.text,children:`+ console.log("`}),N(Q,{backgroundColor:n.colors.diffAddedWord,children:`Hello, Claude!`}),N(Q,{backgroundColor:n.colors.diffAdded,children:`");`}),` `,`│`]}),N(Q,{color:n.colors.warning,children:`╭─────────────────────────────────────────────╮`}),P(Q,{color:n.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),P(t,{children:[N(Q,{color:n.colors.warning,children:`│ `}),N(t,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),P(Q,{color:n.colors.warning,children:[` `,`│`]})]}),N(Q,{color:n.colors.bashBorder,children:`───────────────────────────────────────────────`}),P(t,{children:[N(Q,{color:n.colors.bashBorder,children:`!`}),N(t,{children:` ls`})]}),N(Q,{color:n.colors.promptBorder,children:`───────────────────────────────────────────────`}),N(t,{children:P(t,{children:[`> list the dir`,` `,N(Fr,{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})]})}),N(Q,{color:n.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),P(t,{children:[N(Q,{color:n.colors.planMode,children:`│ `}),P(Q,{color:n.colors.permission,children:[`Ready to code?`,` `]}),N(t,{children:`Here is Claude's plan:`}),P(Q,{color:n.colors.planMode,children:[` `,`│`]})]}),N(Q,{color:n.colors.permission,children:`╭─────────────────────────────────────────────╮`}),P(t,{children:[N(Q,{color:n.colors.permission,children:`│ `}),N(t,{bold:!0,children:`Permissions:`}),` `,P(Q,{backgroundColor:n.colors.permission,color:n.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,N(Q,{color:n.colors.permission,children:`│`})]}),N(t,{children:`> list the dir`}),P(t,{children:[N(Q,{color:n.colors.error,children:`●`}),N(t,{children:` Update(__init__.py)`})]}),P(t,{children:[N(t,{children:` ⎿ `}),N(Q,{color:n.colors.error,children:`User rejected update to __init__.py`})]}),P(t,{children:[` `,`1`,` `,P(Q,{backgroundColor:n.colors.diffRemovedDimmed,children:[`- import`,` `]}),N(Q,{backgroundColor:n.colors.diffRemovedWordDimmed,children:`os`})]}),P(t,{children:[` `,`2`,` `,P(Q,{backgroundColor:n.colors.diffAddedDimmed,children:[`+ import`,` `]}),N(Q,{backgroundColor:n.colors.diffAddedWordDimmed,children:`random`})]}),P(t,{children:[N(Q,{color:n.colors.success,children:`●`}),N(t,{children:` List(.)`})]}),P(t,{children:[N(t,{children:`●`}),N(t,{children:` The directory `}),N(Q,{color:n.colors.permission,children:`C:\\Users\\user`}),P(t,{children:[` `,`contains `,N(t,{bold:!0,children:`123`}),` files.`]})]}),P(t,{children:[N(Q,{color:n.colors.claude,children:`✻ Th`}),N(Q,{color:n.colors.claudeShimmer,children:`ink`}),N(Q,{color:n.colors.claude,children:`ing… `}),N(t,{children:`(esc to interrupt)`})]}),N(t,{children:N(Q,{color:n.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),N(t,{children:N(Q,{color:n.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),N(t,{children:N(Q,{color:n.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function Rr({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?N(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?N(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):N(Q,{color:r,bold:n,children:e})}function zr({initialValue:n,onColorChange:i,onExit:a,colorKey:o,theme:c}){let l=Vr(n)||{h:0,s:50,l:50},u=Br(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=Vr(n),t=Br(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(er(e)){let t=tr(e),n=Vr(t),r=Br(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(N(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(N(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},j=()=>{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(N(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},F=()=>{let[e,t,n]=O(f.h,f.s,f.l);return`rgb(${e},${t},${n})`},I=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},L=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(N(t,{backgroundColor:`rgb(${r},${h.g},${h.b})`,children:` `},n))}return e},R=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(N(t,{backgroundColor:`rgb(${h.r},${r},${h.b})`,children:` `},n))}return e},z=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(N(t,{backgroundColor:`rgb(${h.r},${h.g},${r})`,children:` `},n))}return e},B=(e,t)=>Math.round(e/t*39);return P(e,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[P(e,{flexDirection:`column`,children:[N(t,{bold:!0,children:`Color Picker`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),N(t,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),N(t,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),N(t,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),N(t,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),N(t,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),_===`hsl`?P(M,{children:[P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`h`?`yellow`:`white`,children:[y===`h`?`❯ `:` `,`Hue (`,f.h,`°):`]})}),N(e,{children:k().map((e,n)=>N(s,{children:n===B(f.h,360)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`s`?`yellow`:`white`,children:[y===`s`?`❯ `:` `,`Saturation (`,f.s,`%):`]})}),N(e,{children:A().map((e,n)=>N(s,{children:n===B(f.s,100)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`l`?`yellow`:`white`,children:[y===`l`?`❯ `:` `,`Lightness (`,f.l,`%):`]})}),N(e,{children:j().map((e,n)=>N(s,{children:n===B(f.l,100)?N(t,{children:`|`}):e},n))})]})]}):P(M,{children:[P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`r`?`yellow`:`white`,children:[y===`r`?`❯ `:` `,`Red (`,h.r,`):`]})}),N(e,{children:L().map((e,n)=>N(s,{children:n===B(h.r,255)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`g`?`yellow`:`white`,children:[y===`g`?`❯ `:` `,`Green (`,h.g,`):`]})}),N(e,{children:R().map((e,n)=>N(s,{children:n===B(h.g,255)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`b`?`yellow`:`white`,children:[y===`b`?`❯ `:` `,`Blue (`,h.b,`):`]})}),N(e,{children:z().map((e,n)=>N(s,{children:n===B(h.b,255)?N(t,{children:`|`}):e},n))})]})]}),P(e,{marginBottom:1,children:[N(t,{children:`Current: `}),N(t,{backgroundColor:F(),children:` `})]}),P(e,{flexDirection:`row`,justifyContent:`space-between`,children:[P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:`Hex `}),o?.startsWith(`diff`)?N(t,{backgroundColor:F(),color:c?.colors?.text||`white`,bold:!0,children:I(h.r,h.g,h.b)}):o===`inverseText`?N(t,{color:F(),backgroundColor:c?.colors?.permission,bold:!0,children:I(h.r,h.g,h.b)}):N(t,{color:F(),bold:!0,children:I(h.r,h.g,h.b)})]}),P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:`RGB `}),o?.startsWith(`diff`)?N(t,{backgroundColor:F(),color:c?.colors?.text||`white`,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):o===`inverseText`?N(t,{color:F(),backgroundColor:c?.colors?.permission,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):N(t,{color:F(),bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`})]}),P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:`HSL `}),o?.startsWith(`diff`)?N(t,{backgroundColor:F(),color:c?.colors?.text||`white`,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):o===`inverseText`?N(t,{color:F(),backgroundColor:c?.colors?.permission,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):N(t,{color:F(),bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`})]})]})]})}function Br(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 Vr(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 Hr({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&&er(e)){let t=tr(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 P(e,{children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{children:P(X,{children:[`Editing theme “`,d.name,`” (`,d.id,`)`]})}),_===null&&y===null?P(M,{children:[P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`enter to edit theme name, id, or color`}),N(t,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),N(t,{dimColor:!0,children:`paste color from clipboard (when on color)`}),N(t,{dimColor:!0,children:`esc to go back`})]}),h<2?P(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[N(t,{bold:!0,children:h===0?`Theme Name`:`Theme ID`}),N(t,{children:h===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):P(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:d.colors[D[h-2]],flexDirection:`column`,paddingLeft:1,children:[N(Rr,{colorKey:D[h-2],theme:d,bold:!0}),N(t,{children:k(D[h-2])})]}),P(e,{flexDirection:`column`,children:[P(e,{children:[N(t,{color:h===0?`yellow`:`white`,children:h===0?`❯ `:` `}),N(t,{bold:!0,children:`Name: `}),N(t,{children:d.name})]}),P(e,{marginBottom:1,children:[N(t,{color:h===1?`yellow`:`white`,children:h===1?`❯ `:` `}),N(t,{bold:!0,children:`ID: `}),N(t,{children:d.id})]}),(()=>{if(h<2)return P(M,{children:[D.slice(0,20).map((n,r)=>{let i=r+2;return P(e,{children:[N(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),N(e,{width:A+2,children:N(t,{children:N(Rr,{colorKey:n,theme:d,bold:!0})})}),N(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),D.length>20&&P(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 P(M,{children:[a>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,a,` more above`]}),o.map((n,r)=>{let i=a+r+2;return P(e,{children:[N(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),N(e,{width:A+2,children:N(t,{children:N(Rr,{colorKey:n,theme:d,bold:!0})})}),N(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),i<D.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-i,` more below`]})]})})()]})]}):y?P(e,{flexDirection:`column`,marginTop:1,children:[P(t,{children:[`Editing `,y===`name`?`theme name`:`theme ID`,`:`]}),N(e,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:N(t,{children:x})}),N(t,{dimColor:!0,children:`enter to save, esc to cancel`})]}):N(zr,{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(``)}})]}),N(e,{width:`50%`,children:N(Lr,{theme:d})})]})}function Ur(e){return e.map(e=>`${e.name} (${e.id})`)}function Wr({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]||q.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=[...q.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 N(Hr,{themeId:c,onBack:()=>{l(null),f(!0)}});let _=Ur(i),v=i.find(e=>_[o]?.includes(`(${e.id})`))||i[0];return i.length===0?N(e,{children:P(e,{flexDirection:`column`,width:`100%`,children:[N(X,{children:`Themes`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new theme`}),N(t,{dimColor:!0,children:`esc to go back`})]}),N(t,{children:`No themes available!`})]})}):P(e,{children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(X,{children:`Themes`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new theme`}),N(t,{dimColor:!0,children:`d to delete a theme`}),N(t,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),N(t,{dimColor:!0,children:`enter to edit theme`}),N(t,{dimColor:!0,children:`esc to go back`})]}),N(e,{flexDirection:`column`,children:_.map((e,n)=>P(t,{color:o===n?`yellow`:void 0,children:[o===n?`❯ `:` `,e]},n))})]}),N(e,{width:`50%`,children:N(Lr,{theme:v})})]})}function Gr({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=Yn(),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=[...q.thinkingVerbs.verbs]}),h(0))}),P(e,{children:[P(e,{flexDirection:`column`,width:`50%`,children:[P(e,{marginBottom:1,flexDirection:`column`,children:[N(X,{children:`Thinking Verbs`}),P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:f===`format`?`enter to edit format`:`changes auto-saved`}),N(t,{dimColor:!0,children:`esc to go back`}),N(t,{dimColor:!0,children:`tab to switch sections`})]})]}),N(e,{marginBottom:1,children:N(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),P(e,{flexDirection:`column`,children:[P(t,{children:[N(t,{color:f===`format`?`yellow`:void 0,children:f===`format`?`❯ `:` `}),N(t,{bold:!0,color:f===`format`?`yellow`:void 0,children:`Format`})]}),f===`format`&&(S?P(t,{dimColor:!0,children:[` `,`enter to save`]}):P(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),N(e,{marginLeft:2,marginBottom:1,children:N(e,{borderStyle:`round`,borderColor:S?`yellow`:`gray`,children:N(t,{children:S?w:i})})}),N(e,{children:P(t,{children:[N(t,{color:f===`verbs`?`yellow`:void 0,children:f===`verbs`?`❯ `:` `}),N(t,{bold:!0,color:f===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),f===`verbs`&&N(e,{flexDirection:`column`,children:P(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),N(e,{marginLeft:2,marginBottom:1,children:P(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 P(M,{children:[r>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return P(t,{color:f===`verbs`&&i===p?`cyan`:void 0,children:[f===`verbs`&&i===p?`❯ `:` `,e]},i)}),n<a.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),b&&P(e,{alignItems:`center`,children:[N(t,{color:`yellow`,children:`❯ `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:v})})]}),g&&P(e,{marginTop:1,alignItems:`center`,children:[N(t,{children:`Editing: `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:v})})]})]})})]}),P(e,{width:`50%`,flexDirection:`column`,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,children:`Preview`})}),N(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:P(t,{children:[P(t,{color:D,children:[`✻ `,i.replace(/\{\}/g,a[p]),` `]}),N(t,{children:`(esc to interrupt)`})]})})]})]})}const Kr=[{name:`Default`,phases:q.thinkingStyle.phases,reverseMirror:q.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 qr({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,j]=m(0),F=Yn(),I=(s.find(e=>e.id===F)||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(()=>{j(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=q.thinkingStyle}),_(0),y(0))});let L=o?`●`:`○`,R=(()=>o?[...i,...[...i].reverse().slice(1,-1)]:i)(),z=R.length>0?R[A]:`·`;return N(e,{children:P(e,{flexDirection:`column`,width:`100%`,children:[P(e,{flexDirection:`row`,width:`100%`,children:[P(e,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[N(X,{children:`Thinking style`}),P(e,{flexDirection:`column`,children:[P(t,{dimColor:!0,children:[`enter to`,` `,h===`updateInterval`?`edit interval`:h===`presets`?`apply preset`:`save`]}),N(t,{dimColor:!0,children:`esc to go back`}),N(t,{dimColor:!0,children:`tab to switch sections`})]})]}),P(e,{width:`50%`,flexDirection:`column`,children:[N(e,{children:N(t,{bold:!0,children:`Preview`})}),P(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[N(e,{width:(z?.length??0)+1,children:N(t,{color:I,children:z})}),P(t,{children:[N(t,{color:I,children:`Thinking… `}),N(t,{children:`(esc to interrupt)`})]})]})]})]}),P(e,{flexDirection:`row`,gap:4,children:[P(e,{flexDirection:`column`,children:[P(t,{children:[N(t,{color:h===`reverseMirror`?`yellow`:void 0,children:h===`reverseMirror`?`❯ `:` `}),N(t,{bold:!0,color:h===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),h===`reverseMirror`&&P(t,{dimColor:!0,children:[` `,`space to toggle`]}),N(e,{marginLeft:2,marginBottom:1,children:P(t,{children:[L,` `,o?`Enabled`:`Disabled`]})})]}),P(e,{flexDirection:`column`,children:[P(t,{children:[N(t,{color:h===`updateInterval`?`yellow`:void 0,children:h===`updateInterval`?`❯ `:` `}),N(t,{bold:!0,color:h===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),h===`updateInterval`&&(E?P(t,{dimColor:!0,children:[` `,`enter to save`]}):P(t,{dimColor:!0,children:[` `,`enter to edit`]})),N(e,{marginLeft:2,marginBottom:1,children:N(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:N(t,{children:E?O:a})})})]})]}),N(e,{children:P(t,{children:[N(t,{color:h===`phases`?`yellow`:void 0,children:h===`phases`?`❯ `:` `}),N(t,{bold:!0,color:h===`phases`?`yellow`:void 0,children:`Phases`})]})}),h===`phases`&&N(e,{marginBottom:1,flexDirection:`column`,children:P(t,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),N(e,{marginLeft:2,marginBottom:1,children:P(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 P(M,{children:[r>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return P(t,{color:h===`phases`&&i===g?`cyan`:void 0,children:[h===`phases`&&i===g?`❯ `:` `,e]},i)}),n<i.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),w&&P(e,{children:[N(t,{color:`yellow`,children:`❯ `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:S})})]}),b&&P(e,{marginTop:1,children:[N(t,{children:`Editing: `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:S})})]})]})}),N(e,{children:P(t,{children:[N(t,{color:h===`presets`?`yellow`:void 0,children:h===`presets`?`❯ `:` `}),N(t,{bold:!0,color:h===`presets`?`yellow`:void 0,children:`Presets`})]})}),h===`presets`&&P(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),N(e,{marginLeft:2,marginBottom:1,children:N(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 P(M,{children:[r>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return P(t,{color:h===`presets`&&i===v?`cyan`:void 0,children:[h===`presets`&&i===v?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<Kr.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,Kr.length-n,` more below`]})]})})()})}),N(e,{marginTop:1,children:N(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 Yr=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Xr=[{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 Zr({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,j]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[M,F]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[I,L]=m(()=>Xr.findIndex(e=>e.value===i.userMessageDisplay.borderStyle)),[R,z]=m(()=>i.userMessageDisplay.borderColor),[B,ee]=m(null),[te,ne]=m(``),re=Yn(),ie=i.themes?.find(e=>e.id===re)||i.themes?.[0],[ae,oe]=m(`text`),se=[`format`,`styling`,`foreground`,`background`],ce=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[le,ue]=m(0),[de,V]=m(0),H=ae===`text`?se[le]:ce[de],fe=()=>{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`:M,e.userMessageDisplay.borderStyle=Xr[I].value,e.userMessageDisplay.borderColor=R,e.userMessageDisplay.paddingX=parseInt(g)||0,e.userMessageDisplay.paddingY=parseInt(v)||0,e.userMessageDisplay.fitBoxToContent=b})},pe=()=>{h(q.userMessageDisplay.format),T([...q.userMessageDisplay.styling]),D(`default`),k(`rgb(255,255,255)`),j(`none`),F(`rgb(0,0,0)`),L(Xr.findIndex(e=>e.value===q.userMessageDisplay.borderStyle)),z(q.userMessageDisplay.borderColor),_(String(q.userMessageDisplay.paddingX)),y(String(q.userMessageDisplay.paddingY)),x(q.userMessageDisplay.fitBoxToContent),a(e=>{e.userMessageDisplay={...q.userMessageDisplay}})};Jr(()=>{fe()},[p,w,E,O,A,M,I,R,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(B===null){if(t.escape)n();else if(t.ctrl&&e===`r`)pe();else if(t.leftArrow||t.rightArrow)oe(e=>e===`text`?`border`:`text`);else if(t.tab)ae===`text`?t.shift?ue(e=>e===0?se.length-1:e-1):ue(e=>e===se.length-1?0:e+1):t.shift?V(e=>e===0?ce.length-1:e-1):V(e=>e===ce.length-1?0:e+1);else if(t.return)H===`format`?s(!0):H===`paddingX`?l(!0):H===`paddingY`?f(!0):H===`foreground`?E===`custom`&&(ne(O),ee(`foreground`)):H===`background`?A===`custom`&&(ne(M),ee(`background`)):H===`borderColor`&&(ne(R),ee(`border`));else if(t.upArrow)H===`styling`?C(e=>Math.max(0,e-1)):H===`borderStyle`?L(e=>e===0?Xr.length-1:e-1):H===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):H===`background`&&j(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!M||M===``)&&F(`rgb(0,0,0)`),t});else if(t.downArrow)H===`styling`?C(e=>Math.min(Yr.length-1,e+1)):H===`borderStyle`?L(e=>e===Xr.length-1?0:e+1):H===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):H===`background`&&j(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!M||M===``)&&F(`rgb(0,0,0)`),t});else if(e===` `)if(H===`styling`){let e=Yr[S].value;T(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else H===`fitBoxToContent`&&x(e=>!e)}});let me=n=>{let r=E===`default`?ie?.colors?.text:O,i=A===`none`?void 0:A===`default`?ie?.colors?.userMessageBackground:M,a=Xr[I].value,o=parseInt(g)||0,s=parseInt(v)||0,c=N(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 P(e,{flexDirection:`column`,children:[N(t,{color:R,children:l}),s>0&&N(e,{height:s}),N(e,{paddingX:o,children:c}),s>0&&N(e,{height:s}),N(t,{color:R,children:l})]})}else if(a!==`none`||o>0||s>0||b){let t=o>0||s>0?N(e,{paddingX:o,paddingY:s,children:c}):c,n={};return a!==`none`&&(n.borderStyle=a,n.borderColor=R),b?n.alignSelf=`flex-start`:n.flexGrow=1,a===`none`?t:N(e,{...n,children:t})}else return c};return B?N(zr,{initialValue:te,theme:ie,onColorChange:e=>{B===`foreground`?k(e):B===`background`?F(e):B===`border`&&z(e)},onExit:()=>{ee(null),ne(``)}}):P(e,{flexDirection:`column`,children:[N(X,{children:`Customize how user messages are displayed`}),P(e,{flexDirection:`column`,marginBottom:1,children:[N(t,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),N(t,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),P(e,{flexDirection:`row`,gap:1,children:[P(e,{flexDirection:`column`,width:`50%`,borderStyle:ae===`text`?`round`:`single`,borderColor:ae===`text`?`yellow`:`gray`,paddingX:1,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,color:ae===`text`?`yellow`:void 0,children:`Text & Styling`})}),N(e,{children:P(t,{color:H===`format`?`yellow`:void 0,bold:H===`format`,children:[H===`format`?`❯ `:` `,`Format String`]})}),H===`format`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:o?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),N(e,{marginLeft:2,marginBottom:1,children:N(e,{borderStyle:`round`,borderColor:o?`yellow`:`gray`,children:N(t,{children:p})})}),N(e,{children:P(t,{color:H===`styling`?`yellow`:void 0,bold:H===`styling`,children:[H===`styling`?`❯ `:` `,`Styling`]})}),H===`styling`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),N(e,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Yr.map((n,r)=>N(e,{children:P(t,{color:H===`styling`&&S===r?`cyan`:void 0,children:[H===`styling`&&S===r?`❯ `:` `,w.includes(n.value)?`●`:`○`,` `,n.label]})},n.value))}),P(e,{flexDirection:`row`,gap:1,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{children:P(t,{color:H===`foreground`?`yellow`:void 0,bold:H===`foreground`,children:[H===`foreground`?`❯ `:` `,`Foreground`]})}),H===`foreground`&&N(e,{marginLeft:2,children:P(t,{dimColor:!0,children:[`up/down · `,E===`custom`?`enter`:``]})}),P(e,{marginLeft:2,flexDirection:`column`,children:[N(e,{children:P(t,{children:[E===`default`?`● `:`○ `,`Default`]})}),N(e,{children:P(t,{children:[E===`custom`?`● `:`○ `,`Custom`,E===`custom`&&`: `,E===`custom`&&N(t,{color:O,children:O})]})})]})]}),P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{children:P(t,{color:H===`background`?`yellow`:void 0,bold:H===`background`,children:[H===`background`?`❯ `:` `,`Background`]})}),H===`background`&&N(e,{marginLeft:2,children:P(t,{dimColor:!0,children:[`up/down · `,A===`custom`?`enter`:``]})}),P(e,{marginLeft:2,flexDirection:`column`,children:[N(e,{children:P(t,{children:[A===`default`?`● `:`○ `,`Default`]})}),N(e,{children:P(t,{children:[A===`none`?`● `:`○ `,`None`]})}),N(e,{children:P(t,{children:[A===`custom`?`● `:`○ `,`Custom`,A===`custom`&&`: `,A===`custom`&&N(t,{backgroundColor:M,children:M})]})})]})]})]})]}),P(e,{flexDirection:`column`,width:`50%`,borderStyle:ae===`border`?`round`:`single`,borderColor:ae===`border`?`yellow`:`gray`,paddingX:1,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,color:ae===`border`?`yellow`:void 0,children:`Border & Padding`})}),N(e,{children:P(t,{color:H===`borderStyle`?`yellow`:void 0,bold:H===`borderStyle`,children:[H===`borderStyle`?`❯ `:` `,`Border Style`]})}),H===`borderStyle`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`up/down to navigate`})}),P(e,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[N(e,{flexDirection:`column`,width:`50%`,children:Xr.slice(0,6).map((n,r)=>N(e,{children:P(t,{color:H===`borderStyle`&&I===r?`cyan`:void 0,children:[H===`borderStyle`&&I===r?`❯ `:` `,I===r?`● `:`○ `,n.label]})},n.value))}),N(e,{flexDirection:`column`,width:`50%`,children:Xr.slice(6).map((n,r)=>{let i=r+6;return N(e,{children:P(t,{color:H===`borderStyle`&&I===i?`cyan`:void 0,children:[H===`borderStyle`&&I===i?`❯ `:` `,I===i?`● `:`○ `,n.label]})},n.value)})})]}),N(e,{children:P(t,{color:H===`borderColor`?`yellow`:void 0,bold:H===`borderColor`,children:[H===`borderColor`?`❯ `:` `,`Border Color`]})}),H===`borderColor`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`enter to pick color`})}),N(e,{marginLeft:2,marginBottom:1,children:N(t,{color:R,children:R})}),P(e,{flexDirection:`row`,gap:1,children:[P(e,{flexDirection:`column`,width:`33%`,children:[N(e,{children:P(t,{color:H===`paddingX`?`yellow`:void 0,bold:H===`paddingX`,children:[H===`paddingX`?`❯ `:` `,`Padding X`]})}),H===`paddingX`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:c?`enter/esc`:`enter`})}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:c?`yellow`:`gray`,children:N(t,{children:g})})})]}),P(e,{flexDirection:`column`,width:`33%`,children:[N(e,{children:P(t,{color:H===`paddingY`?`yellow`:void 0,bold:H===`paddingY`,children:[H===`paddingY`?`❯ `:` `,`Padding Y`]})}),H===`paddingY`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:d?`enter/esc`:`enter`})}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:d?`yellow`:`gray`,children:N(t,{children:v})})})]}),P(e,{flexDirection:`column`,width:`33%`,children:[N(e,{children:P(t,{color:H===`fitBoxToContent`?`yellow`:void 0,bold:H===`fitBoxToContent`,children:[H===`fitBoxToContent`?`❯ `:` `,b?`●`:`○`,` Fit box to content`]})}),H===`fitBoxToContent`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`space`})})]})]})]})]}),P(e,{flexDirection:`column`,marginTop:1,paddingX:1,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,children:`Preview`})}),P(e,{flexDirection:`row`,gap:2,children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,children:N(t,{underline:!0,children:`Before (Claude Code default):`})}),N(e,{marginLeft:1,children:P(t,{backgroundColor:ie?.colors?.userMessageBackground,color:ie?.colors?.text,children:[` `,`> list the dir`,` `]})}),N(e,{marginLeft:1,marginTop:1,children:P(t,{children:[N(t,{color:ie?.colors?.inactive||`#888888`,children:`●`}),N(t,{children:` The directory `}),N(t,{color:ie?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),N(t,{children:` contains `}),N(t,{bold:!0,children:`123`}),N(t,{children:` files.`})]})})]}),P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,children:N(t,{underline:!0,children:`After (Your customization):`})}),N(e,{marginLeft:1,flexDirection:`row`,children:(()=>me(p.replace(/\{\}/g,`list the dir`)))()}),N(e,{marginLeft:1,marginTop:1,children:P(t,{children:[N(t,{color:ie?.colors?.inactive||`#888888`,children:`●`}),N(t,{children:` The directory `}),N(t,{color:ie?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),N(t,{children:` contains `}),N(t,{bold:!0,children:`123`}),N(t,{children:` files.`})]})})]})]})]})]})}const Qr=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],$r=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function ei({testText:e,regex:n,regexFlags:r,format:i,styling:a,foregroundColor:o,backgroundColor:s}){let c=[];try{let l=r.includes(`g`)?r:r+`g`,u=new RegExp(n,l),d=[...e.matchAll(u)];if(d.length===0)return N(t,{children:e});let f=0;return d.forEach((n,r)=>{let l=n.index,u=l+n[0].length;l>f&&c.push(N(t,{children:e.slice(f,l)},`plain-${r}`));let d=i.replace(/\{MATCH\}/g,n[0]);c.push(N(t,{bold:a.includes(`bold`),italic:a.includes(`italic`),underline:a.includes(`underline`),strikethrough:a.includes(`strikethrough`),inverse:a.includes(`inverse`),color:o,backgroundColor:s,children:d},`match-${r}`)),f=u}),f<e.length&&c.push(N(t,{children:e.slice(f)},`plain-end`)),N(M,{children:c})}catch{return N(t,{children:e})}}function ti({highlighterIndex:n,onBack:i}){let{settings:a,updateSettings:o}=u($),s=a.inputPatternHighlighters[n],c=Yn(),l=a.themes?.find(e=>e.id===c)||a.themes?.[0],[f,p]=m(s?.name||`New Highlighter`),[h,g]=m(s?.regex||``),[_,v]=m(s?.regexFlags||`g`),[y,b]=m(s?.format||`{MATCH}`),[x,S]=m(s?.styling||[]),[C,w]=m(s?.foregroundColor===null?`none`:`custom`),[T,E]=m(s?.foregroundColor||`rgb(255,0,255)`),[D,O]=m(s?.backgroundColor?`custom`:`none`),[k,A]=m(s?.backgroundColor||`rgb(0,0,0)`),[j,M]=m(s?.enabled??!0),[F,I]=m(a.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[L,R]=m(`name`),[z,B]=m(!1),[ee,te]=m(0),[ne,re]=m(null),[ie,ae]=m(``),[oe,se]=m(null),[ce,le]=m(0),[ue,de]=m(0);if(d(()=>{let e=$r[ce];R(e[Math.min(ue,e.length-1)])},[ce,ue]),d(()=>{if(!h){se(null);return}try{new RegExp(h,_),se(null)}catch(e){se(e.message)}},[h,_]),d(()=>{n>=0&&o(e=>{e.inputPatternHighlighters[n]&&(e.inputPatternHighlighters[n]={name:f,regex:h,regexFlags:_,format:y,styling:x,foregroundColor:C===`custom`?T:null,backgroundColor:D===`custom`?k:null,enabled:j})})},[n,f,h,_,y,x,C,T,D,k,j]),d(()=>{o(e=>{e.inputPatternHighlightersTestText=F})},[F]),r((e,t)=>{if(z){t.return?B(!1):t.escape?(L===`name`&&p(s?.name||``),L===`regex`&&g(s?.regex||``),L===`regexFlags`&&v(s?.regexFlags||`g`),L===`format`&&b(s?.format||`{MATCH}`),L===`testText`&&I(a.inputPatternHighlightersTestText||`Type test text here to see highlighting`),B(!1)):t.backspace||t.delete?(L===`name`&&p(e=>e.slice(0,-1)),L===`regex`&&g(e=>e.slice(0,-1)),L===`regexFlags`&&v(e=>e.slice(0,-1)),L===`format`&&b(e=>e.slice(0,-1)),L===`testText`&&I(e=>e.slice(0,-1))):e&&e.length===1&&(L===`name`&&p(t=>t+e),L===`regex`&&g(t=>t+e),L===`regexFlags`&&v(t=>t+e),L===`format`&&b(t=>t+e),L===`testText`&&I(t=>t+e));return}if(ne===null){if(t.escape)i();else if(t.upArrow)L===`styling`&&ee>0?te(e=>e-1):le(e=>Math.max(0,e-1));else if(t.downArrow)L===`styling`&&ee<Qr.length-1?te(e=>e+1):le(e=>Math.min($r.length-1,e+1));else if(t.leftArrow)L===`foreground`?w(e=>e===`none`?`custom`:`none`):L===`background`?O(e=>e===`none`?`custom`:`none`):de(e=>Math.max(0,e-1));else if(t.rightArrow)if(L===`foreground`)w(e=>e===`none`?`custom`:`none`);else if(L===`background`)O(e=>e===`none`?`custom`:`none`);else{let e=$r[ce].length-1;de(t=>Math.min(e,t+1))}else if(t.tab){let e=$r.flat(),n=e.indexOf(L);if(t.shift){if(n>0){let t=e[n-1];for(let e=0;e<$r.length;e++){let n=$r[e].indexOf(t);if(n>=0){le(e),de(n);break}}}}else if(n<e.length-1){let t=e[n+1];for(let e=0;e<$r.length;e++){let n=$r[e].indexOf(t);if(n>=0){le(e),de(n);break}}}}else if(t.return)L===`name`||L===`regex`||L===`regexFlags`||L===`format`||L===`testText`?B(!0):L===`foreground`&&C===`custom`?(ae(T),re(`foreground`)):L===`background`&&D===`custom`&&(ae(k),re(`background`));else if(e===` `)if(L===`styling`){let e=Qr[ee].value;x.includes(e)?S(x.filter(t=>t!==e)):S([...x,e])}else L===`enabled`&&M(!j)}}),!s)return N(e,{flexDirection:`column`,children:N(t,{color:`red`,children:`Highlighter not found`})});if(ne)return N(zr,{initialValue:ie,theme:l,onColorChange:e=>{ne===`foreground`?E(e):ne===`background`&&A(e)},onExit:()=>{re(null),ae(``)}});let V=e=>L===e,H=e=>({color:V(e)?`yellow`:void 0,bold:V(e)});return P(e,{flexDirection:`column`,children:[N(X,{children:`Edit Highlighter`}),N(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:`arrows to navigate · enter to edit · space to toggle · esc to go back`})}),P(e,{flexDirection:`row`,gap:2,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`30%`,children:[P(t,{...H(`name`),children:[V(`name`)?`❯ `:` `,`Name`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`name`)?z?`green`:`yellow`:`gray`,children:N(t,{children:f||`(empty)`})})})]}),P(e,{flexDirection:`column`,width:`45%`,children:[P(t,{...H(`regex`),children:[V(`regex`)?`❯ `:` `,`Regex Pattern`]}),P(e,{marginLeft:2,flexDirection:`column`,children:[N(e,{borderStyle:`round`,borderColor:V(`regex`)?z?`green`:`yellow`:oe?`red`:`gray`,children:N(t,{children:h||`(empty)`})}),oe&&N(t,{color:`red`,children:oe})]})]}),P(e,{flexDirection:`column`,width:`20%`,children:[P(t,{...H(`regexFlags`),children:[V(`regexFlags`)?`❯ `:` `,`Flags`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`regexFlags`)?z?`green`:`yellow`:`gray`,children:N(t,{children:_||`g`})})})]})]}),P(e,{flexDirection:`row`,gap:2,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`50%`,children:[P(t,{...H(`format`),children:[V(`format`)?`❯ `:` `,`Format String`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`format`)?z?`green`:`yellow`:`gray`,children:N(t,{children:y||`{MATCH}`})})}),V(`format`)&&N(e,{marginLeft:2,children:P(t,{dimColor:!0,children:[`use `,`{MATCH}`,` as placeholder`]})})]}),P(e,{flexDirection:`column`,width:`45%`,children:[P(t,{...H(`styling`),children:[V(`styling`)?`❯ `:` `,`Styling`]}),N(e,{marginLeft:2,flexDirection:`column`,children:Qr.map((e,n)=>{let r=x.includes(e.value),i=V(`styling`)&&ee===n;return P(t,{color:i?`cyan`:void 0,children:[i?`❯ `:` `,r?`●`:`○`,` `,e.label]},e.value)})})]})]}),P(e,{flexDirection:`row`,gap:2,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`48%`,children:[P(t,{...H(`foreground`),children:[V(`foreground`)?`❯ `:` `,`Foreground Color`]}),P(e,{marginLeft:2,flexDirection:`row`,gap:1,children:[P(t,{color:V(`foreground`)?`yellow`:void 0,children:[`[`,C===`none`?`●`:`○`,`] none`,` `,`[`,C===`custom`?`●`:`○`,`] custom`]}),C===`custom`&&N(e,{borderStyle:`round`,borderColor:V(`foreground`)?`yellow`:`gray`,children:N(t,{color:T,children:` ████ `})})]})]}),P(e,{flexDirection:`column`,width:`48%`,children:[P(t,{...H(`background`),children:[V(`background`)?`❯ `:` `,`Background Color`]}),P(e,{marginLeft:2,flexDirection:`row`,gap:1,children:[P(t,{color:V(`background`)?`yellow`:void 0,children:[`[`,D===`none`?`●`:`○`,`] none`,` `,`[`,D===`custom`?`●`:`○`,`] custom`]}),D===`custom`&&N(e,{borderStyle:`round`,borderColor:V(`background`)?`yellow`:`gray`,children:P(t,{backgroundColor:k,children:[` `,` `,` `]})})]})]})]}),N(e,{marginBottom:1,children:P(t,{...H(`enabled`),children:[V(`enabled`)?`❯ `:` `,`Enabled:`,` `,N(t,{color:j?`green`:`red`,children:j?`● Yes`:`○ No`})]})}),P(e,{flexDirection:`column`,marginBottom:1,children:[P(t,{...H(`testText`),children:[V(`testText`)?`❯ `:` `,`Test Text`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`testText`)?z?`green`:`yellow`:`gray`,children:N(t,{children:F||`(empty)`})})})]}),N(e,{borderStyle:`round`,padding:1,children:P(e,{flexDirection:`column`,children:[N(t,{bold:!0,children:`Live Preview:`}),h?N(e,{marginTop:1,children:N(ei,{testText:F,regex:h,regexFlags:_,format:y,styling:x,foregroundColor:C===`custom`?T:void 0,backgroundColor:D===`custom`?k:void 0})}):N(t,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function ni({onBack:n}){let{settings:{inputPatternHighlighters:i,themes:a},updateSettings:o}=u($),s=Yn(),c=a.find(e=>e.id===s)||a[0],l=q.themes[0],d=c?.colors.success||l.colors.success,f=c?.colors.error||l.colors.error,[p,h]=m(0),[g,_]=m(null),[v,y]=m(!0),b=()=>{let e={name:`New Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:`rgb(255,0,255)`,backgroundColor:null,enabled:!0};o(t=>{t.inputPatternHighlighters.push(e)}),_(i.length),y(!1)},x=e=>{o(t=>{t.inputPatternHighlighters.splice(e,1)}),p>=i.length-1&&h(Math.max(0,i.length-2))},S=e=>{o(t=>{t.inputPatternHighlighters[e].enabled=!t.inputPatternHighlighters[e].enabled})},C=e=>{e<=0||(o(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e-1,0,n)}),h(e-1))},w=e=>{e>=i.length-1||(o(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e+1,0,n)}),h(e+1))};return r((e,t)=>{t.escape?n():t.upArrow?h(e=>Math.max(0,e-1)):t.downArrow&&i.length>0?h(e=>Math.min(i.length-1,e+1)):t.return&&i.length>0?(_(p),y(!1)):e===`n`?b():e===`x`&&i.length>0?x(p):e===` `&&i.length>0?S(p):e===`u`&&i.length>0&&p>0?C(p):e===`d`&&i.length>0&&p<i.length-1&&w(p)},{isActive:v}),g===null?P(e,{flexDirection:`column`,children:[N(X,{children:`Input Pattern Highlighters`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`Create custom highlighters for patterns in your input prompt.`}),N(t,{dimColor:!0,children:`Matched text will be styled and optionally reformatted.`})]}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new highlighter`}),i.length>0&&N(t,{dimColor:!0,children:`space to toggle enabled/disabled`}),i.length>0&&N(t,{dimColor:!0,children:`u/d to move highlighter up/down`}),i.length>0&&N(t,{dimColor:!0,children:`x to delete a highlighter`}),i.length>0&&N(t,{dimColor:!0,children:`enter to edit highlighter`}),N(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?N(t,{children:`No highlighters created yet. Press n to create one.`}):N(e,{flexDirection:`column`,children:i.map((n,r)=>{let i=p===r,a;return i&&(a=`yellow`),P(e,{flexDirection:`row`,children:[P(t,{color:a,children:[i?`❯ `:` `,n.enabled?`● `:`○ `,n.name,` `]}),N(t,{dimColor:!0,children:`(`}),n.regex?P(t,{dimColor:!0,children:[`/`,n.regex,`/`,n.regexFlags]}):N(t,{dimColor:!0,children:`(no regex)`}),n.styling.length>0&&N(M,{children:P(t,{color:a,dimColor:!n.enabled,children:[` `,`· `,n.styling.join(`, `)]})}),N(t,{dimColor:!0,children:`)`}),n.enabled?N(t,{color:d,children:` enabled`}):N(t,{color:f,children:` disabled`})]},r)})})]}):N(ti,{highlighterIndex:g,onBack:()=>{_(null),y(!0)}})}function ri({onSubmit:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(0),c={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!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?.hideCtrlGToEdit??!1,toggle:()=>{a(e=>{l(),e.misc.hideCtrlGToEdit=!e.misc.hideCtrlGToEdit})}},{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??!1,toggle:()=>{a(e=>{l(),e.misc.suppressLineNumbers=!e.misc.suppressLineNumbers})}},{id:`suppressRateLimitOptions`,title:`Suppress rate limit options popup`,description:`Prevents the automatic /rate-limit-options command from being triggered when hitting rate limits.`,getValue:()=>i.misc?.suppressRateLimitOptions??!1,toggle:()=>{a(e=>{l(),e.misc.suppressRateLimitOptions=!e.misc.suppressRateLimitOptions})}}],[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()}),P(e,{flexDirection:`column`,children:[N(e,{marginBottom:1,children:N(X,{children:`Miscellaneous Settings`})}),N(e,{marginBottom:1,children:N(t,{dimColor:!0,children:`Various tweaks and customizations. Press space to toggle settings, enter to go back.`})}),v&&N(e,{children:P(t,{dimColor:!0,children:[` ↑ `,g,` more above`]})}),_.map((n,r)=>{let i=g+r===o,a=n.getValue()?`☑`:`☐`;return P(e,{flexDirection:`column`,children:[N(e,{children:P(t,{children:[N(t,{color:i?`cyan`:void 0,children:i?`❯ `:` `}),N(t,{bold:!0,color:i?`cyan`:void 0,children:n.title})]})}),N(e,{children:P(t,{dimColor:!0,children:[` `,n.description]})}),N(e,{marginLeft:4,marginBottom:1,children:P(t,{children:[a,` `,n.getValue()?`Enabled`:`Disabled`]})})]},n.id)}),y&&N(e,{children:P(t,{dimColor:!0,children:[` `,`↓ `,p-g-4,` more below`]})}),N(e,{marginTop:1,children:P(t,{dimColor:!0,children:[`Item `,o+1,` of `,p]})})]})}const ii=[`Task`,`Bash`,`Glob`,`Grep`,`Read`,`Edit`,`Write`,`NotebookEdit`,`WebFetch`,`WebSearch`,`BashOutput`,`KillShell`,`TodoWrite`,`AskUserQuestion`,`Skill`,`SlashCommand`,`EnterPlanMode`,`ExitPlanMode`,`LSP`];function ai({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(ii.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(ii.length+1,e+1));else if(e===` `||t.return)if(_===0)b(`All`);else if(_===1)b(`None`);else{let e=ii[_-2];e&&b(e)}else e===`n`&&g(!0)}),!s)return N(e,{flexDirection:`column`,children:N(t,{color:`red`,children:`Toolset not found`})});let x=f===`*`,S=Array.isArray(f)&&f.length===0;return P(e,{flexDirection:`column`,children:[N(X,{children:`Edit Toolset`}),N(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{bold:!0,children:`Name:`}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:h?`yellow`:`gray`,children:N(t,{children:c})})}),h&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{bold:!0,children:`Allowed Tools:`}),N(e,{marginLeft:2,children:P(t,{color:_===0?`cyan`:void 0,children:[_===0?`❯ `:` `,x?`●`:`○`,` All`]})}),N(e,{marginLeft:2,children:P(t,{color:_===1?`cyan`:void 0,children:[_===1?`❯ `:` `,S?`●`:`○`,` None`]})}),ii.map((n,r)=>{let i=r+2;return N(e,{marginLeft:2,children:P(t,{color:_===i?`cyan`:void 0,children:[_===i?`❯ `:` `,y(n)?`◉`:`○`,` `,n]})},n)})]}),N(e,{borderStyle:`round`,padding:1,marginTop:1,children:P(e,{flexDirection:`column`,children:[N(t,{bold:!0,children:`Summary:`}),P(t,{children:[`Name: `,N(t,{color:`cyan`,children:c})]}),P(t,{children:[`Tools:`,` `,f===`*`?N(t,{color:`green`,children:`All tools (*)`}):f.length===0?N(t,{color:`red`,children:`No tools ([])`}):P(t,{color:`yellow`,children:[f.length,` selected`]})]})]})})]})}function oi({onBack:n}){let{settings:{toolsets:i,defaultToolset:a,planModeToolset:o,themes:s},updateSettings:c}=u($),l=Yn(),d=s.find(e=>e.id===l)||s[0],f=q.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 N(ai,{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 P(e,{flexDirection:`column`,children:[N(X,{children:`Toolsets`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new toolset`}),i.length>0&&N(t,{dimColor:!0,children:`d to set as default toolset`}),i.length>0&&N(t,{dimColor:!0,children:`p to set as plan mode toolset`}),i.length>0&&N(t,{dimColor:!0,children:`x to delete a toolset`}),i.length>0&&N(t,{dimColor:!0,children:`enter to edit toolset`}),N(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?N(t,{children:`No toolsets created yet. Press n to create one.`}):N(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`),P(e,{flexDirection:`row`,children:[P(t,{color:l,children:[c?`❯ `:` `,n.name,` `]}),P(t,{color:l,children:[`(`,E(n),`)`]}),i&&N(t,{color:h,children:` ⏵⏵ accept edits`}),s&&N(t,{color:p,children:` ⏸ plan mode`})]},r)})})]})}function si({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(`plan`),[c,l]=m(!1),[d,f]=m(0),p=i.subagentModels||{plan:null,explore:null,generalPurpose:null},h=[{id:`plan`,title:`Plan Agent`,description:`The agent responsible for creating implementation plans.`},{id:`explore`,title:`Explore Agent`,description:`The agent specialized for exploring codebases.`},{id:`generalPurpose`,title:`General-purpose Agent`,description:`The agent used for general multi-step tasks.`}],g=[{label:`Default (Inherited)`,value:null},{label:`sonnet`,value:`sonnet`},{label:`haiku`,value:`haiku`},{label:`opus`,value:`opus`},{label:`sonnet[1m]`,value:`sonnet[1m]`}];return r((e,t)=>{if(c){if(t.escape)l(!1);else if(t.upArrow)f(e=>e>0?e-1:g.length-1);else if(t.downArrow)f(e=>e<g.length-1?e+1:0);else if(t.return){let e=g[d].value;a(t=>{t.subagentModels||={plan:null,explore:null,generalPurpose:null},t.subagentModels[o]=e}),l(!1)}}else if(t.escape)n();else if(t.upArrow){let e=h.findIndex(e=>e.id===o);s(h[e>0?e-1:h.length-1].id)}else if(t.downArrow){let e=h.findIndex(e=>e.id===o);s(h[e<h.length-1?e+1:0].id)}else if(e===` `||t.return){let e=p[o],t=g.findIndex(t=>t.value===e);f(t>=0?t:0),l(!0)}}),c?P(e,{flexDirection:`column`,children:[N(e,{marginBottom:1,children:P(X,{children:[`Select Model for`,` `,h.find(e=>e.id===o)?.title]})}),g.map((n,r)=>{let i=r===d;return N(e,{children:P(t,{color:i?`cyan`:void 0,children:[i?`❯ `:` `,n.label,n.value?P(t,{dimColor:!0,children:[` (`,n.value,`)`]}):null]})},r)})]}):P(e,{flexDirection:`column`,children:[N(e,{marginBottom:1,children:N(X,{children:`Subagent Model Settings`})}),N(e,{marginBottom:1,children:N(t,{dimColor:!0,children:`Configure which Claude model each subagent uses. Use arrow keys to navigate, enter or space to change a model, and escape to go back.`})}),h.map(n=>{let r=n.id===o,i=p[n.id],a=g.find(e=>e.value===i)?.label||i||`Default`;return P(e,{flexDirection:`column`,marginBottom:1,children:[N(e,{children:P(t,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,N(t,{bold:!0,children:n.title})]})}),N(e,{marginLeft:4,children:N(t,{dimColor:!0,children:n.description})}),N(e,{marginLeft:4,children:P(t,{children:[`Current: `,N(t,{color:`green`,children:a})]})})]},n.id)})]})}const $=c({settings:q,updateSettings:e=>{},changesApplied:!1,ccVersion:``});function ci({startupCheckInfo:t,configMigrated:n}){let[i,a]=m({settings:q,changesApplied:!1,ccVersion:``,lastModified:``}),[o,s]=m(!1);d(()=>{(async()=>{let e=await Sr();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})),Cr(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
- (However, your customization are still remembered in ${Y}.)
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),Cr(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`}),zn(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.INPUT_PATTERN_HIGHLIGHTERS:case Z.MISC:case Z.TOOLSETS:case Z.SUBAGENT_MODELS:f(e);break;case Z.VIEW_SYSTEM_PROMPTS:Qn(_r);break;case Z.RESTORE_ORIGINAL:t.ccInstInfo&&(t.ccInstInfo.nativeInstallationPath?Dn(t.ccInstInfo):En(t.ccInstInfo)).then(()=>{h({message:`Original Claude Code restored successfully!`,type:`success`}),c(()=>{})});break;case Z.OPEN_CONFIG:$n(Y);break;case Z.OPEN_CLI:t.ccInstInfo?.cliPath&&$n(t.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},_=()=>{f(null)};return N($.Provider,{value:{settings:i.settings,updateSettings:c,changesApplied:i.changesApplied,ccVersion:t.ccInstInfo?.version||``},children:N(e,{flexDirection:`column`,children:u===null?N(Pr,{onSubmit:g,notification:p,configMigrated:n,showPiebaldAnnouncement:o}):u===Z.THEMES?N(Wr,{onBack:_}):u===Z.THINKING_VERBS?N(Gr,{onBack:_}):u===Z.THINKING_STYLE?N(qr,{onBack:_}):u===Z.USER_MESSAGE_DISPLAY?N(Zr,{onBack:_}):u===Z.INPUT_PATTERN_HIGHLIGHTERS?N(ni,{onBack:_}):u===Z.MISC?N(ri,{onSubmit:_}):u===Z.TOOLSETS?N(oi,{onBack:_}):u===Z.SUBAGENT_MODELS?N(si,{onBack:_}):null})})}const li=(()=>{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=R(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`)?G(`Permission denied accessing: ${t} (${n.code})`):G(`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),ui=(()=>{let e=process.platform===`win32`?g.homedir().replace(/\\/g,`/`):g.homedir(),t=[],n=(e,n=!1)=>{if(n)try{let n=R(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`)?G(`Permission denied accessing: ${e} (${n.code})`):G(`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 di=class extends Error{constructor(e){super(e),this.name=`InstallationDetectionError`}};let fi=null;async function pi(){return fi||=L.create(),fi}async function mi(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 G(`Failed to read file prefix:`,e),null}}async function hi(e){try{let t=await b.realpath(e);G(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await mi(t);if(!n)return G(`resolvePathToInstallationType: Could not read file prefix`),null;let r=await pi(),i=null;if(typeof r.detect==`function`&&(i=r.detect(n)||null),!i)return G(`resolvePathToInstallationType: WASMagic returned no mime type`),null;let a=i.toLowerCase();return G(`resolvePathToInstallationType: Detected mime type: ${a}`),a.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:a.startsWith(`text/`)?(G(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:t}}catch(e){return G(`resolvePathToInstallationType: Error:`,e),null}}async function gi(){try{let e=await I(`claude`);return G(`getClaudeFromPath: Found claude at ${e}`),e}catch{return G(`getClaudeFromPath: claude not found on PATH`),null}}function _i(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())G(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&G(`Extracted version ${a} (${i} occurrences)`),a||null}async function vi(e){let t=_i(await b.readFile(e,`utf8`));if(!t)throw Error(`No VERSION strings found in JS file: ${e}`);return t}async function yi(e){let t=await ee(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}`);let n=_i(t.toString(`utf8`));if(!n)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return n}function bi(e){let t=D.basename(e).match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function xi(e,t){let n=bi(e);return n?(G(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?vi(e):yi(e)}async function Si(){let e=[],t=new Set;for(let n of li){let r=D.join(n,`cli.js`);if(!t.has(r))try{if(await ir(r)){G(`collectCandidates: Found cli.js at ${r}`);let n=await vi(r);e.push({path:r,kind:`npm-based`,version:n}),t.add(r)}}catch(e){G(`collectCandidates: Error checking ${r}:`,e)}}for(let n of ui)if(!t.has(n))try{if(await ir(n)){G(`collectCandidates: Found native binary at ${n}`);let r=await xi(n,`native-binary`);e.push({path:n,kind:`native-binary`,version:r}),t.add(n)}}catch(e){G(`collectCandidates: Error checking ${n}:`,e)}return[...e].sort((e,t)=>or(e.version,t.version))}function Ci(e){return e.map(e=>` • ${e.path} (${e.kind}, v${e.version})`).join(`
642
- `)}function wi(e){return` 2. Set ccInstallationPath in your config file (${Y}):
643
-
644
- {
645
- "ccInstallationPath": "${e}"
646
- }`}function Ti(e){return` 1. Set the TWEAKCC_CC_INSTALLATION_PATH environment variable:
647
-
648
- export TWEAKCC_CC_INSTALLATION_PATH="${e}"`}function Ei(e){let t=e[0]?.path||`/path/to/claude`;return`Multiple Claude Code installations found.
649
-
650
- Found installations:
651
- ${Ci(e)}
652
-
653
- To specify which installation to use, either:
654
-
655
- ${Ti(t)}
656
-
657
- ${wi(t)}`}function Di(){return`Could not find Claude Code installation.
658
-
659
- To fix this, either:
660
-
661
- ${Ti(`/path/to/claude`)}
662
-
663
- ${wi(`/path/to/claude`)}
664
-
665
- 3. Install Claude Code:
666
- • npm install -g @anthropic-ai/claude-code
667
- • Or download from https://claude.ai/download`}function Oi(e,t,n,r){return t===`npm-based`?{cliPath:e,version:n,source:r}:{nativeInstallationPath:e,version:n,source:r}}async function ki(e,t){let n=process.env.TWEAKCC_CC_INSTALLATION_PATH?.trim();if(n&&n.length>0){if(G(`Checking TWEAKCC_CC_INSTALLATION_PATH: ${n}`),!await ir(n))throw new di(`TWEAKCC_CC_INSTALLATION_PATH is set to '${n}' but file does not exist.`);let e=await hi(n);if(!e)throw new di(`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 xi(e.resolvedPath,e.kind);return Gn()&&e.kind===`npm-based`&&G(`SHA256 hash: ${await nr(e.resolvedPath)}`),G(`Using Claude Code from TWEAKCC_CC_INSTALLATION_PATH: ${e.resolvedPath} (${e.kind}, v${t})`),Oi(e.resolvedPath,e.kind,t,`env-var`)}if(e.ccInstallationPath){let t=e.ccInstallationPath;if(G(`Checking ccInstallationPath: ${t}`),!await ir(t))throw new di(`ccInstallationPath is set to '${t}' but file does not exist.`);let n=await hi(t);if(!n)throw new di(`Unable to detect installation type from configured ccInstallationPath '${t}'.\nExpected a Claude Code cli.js file or native binary.`);let r=await xi(n.resolvedPath,n.kind);return Gn()&&n.kind===`npm-based`&&G(`SHA256 hash: ${await nr(n.resolvedPath)}`),G(`Using Claude Code from ccInstallationPath: ${n.resolvedPath} (${n.kind}, v${r})`),Oi(n.resolvedPath,n.kind,r,`config`)}let r=await gi();if(r){G(`Checking claude on PATH: ${r}`);let e=await hi(r);if(!e)G(`Unable to detect installation type from 'claude' on PATH (${r}). Falling back to hardcoded search paths.`);else{let t=await xi(e.resolvedPath,e.kind);return Gn()&&e.kind===`npm-based`&&G(`SHA256 hash: ${await nr(e.resolvedPath)}`),G(`Using Claude Code from PATH: ${e.resolvedPath} (${e.kind}, v${t})`),Oi(e.resolvedPath,e.kind,t,`path`)}}G(`Collecting candidates from hardcoded search paths...`);let i=await Si();if(i.length===0){if(t.interactive)return null;throw new di(Di())}if(i.length===1){let e=i[0];return G(`Using single candidate: ${e.path} (${e.kind}, v${e.version})`),Oi(e.path,e.kind,e.version,`search-paths`)}if(!t.interactive)throw new di(Ei(i));return{version:``,source:`search-paths`,_pendingCandidates:i}}function Ai(e){return e._pendingCandidates||null}async function ji(e){return G(`Saving selected installation to config: ${e.path}`),await Cr(t=>{t.ccInstallationPath=e.path}),Oi(e.path,e.kind,e.version,`config`)}function Mi(){return Di()}async function Ni(e){let t=await Sr(),n=await ki(t,e);if(!n)return{startupCheckInfo:null,pendingCandidates:null};let r=Ai(n);return r?{startupCheckInfo:null,pendingCandidates:r}:{startupCheckInfo:await Pi(t,n),pendingCandidates:null}}async function Pi(e,t){if(!t)return null;if(t.version)try{Ot(await _t(t.version))}catch{}let n=t.version,r=e.ccVersion,i=!1;await ir(hr)||(G(`startupCheck: ${hr} not found; backing up cli.js`),await wn(t),i=!0);let a=!1;return t.nativeInstallationPath&&!await ir(gr)&&(G(`startupCheck: ${gr} not found; backing up native binary`),await Tn(t),a=!0),n===r?{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}:(i||(G(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await b.unlink(hr),await wn(t)),t.nativeInstallationPath&&!a&&(G(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await ir(gr)&&await b.unlink(gr),await Tn(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])}),P(e,{flexDirection:`column`,children:[N(t,{bold:!0,color:`yellow`,children:`No claude executable was found in PATH, and multiple Claude Code installations were found. Please select one:`}),N(t,{children:` `}),n.map((n,r)=>P(e,{children:[P(t,{bold:r===a,color:r===a?`cyan`:void 0,children:[r===a?`❯ `:` `,n.path]}),P(t,{dimColor:!0,children:[` `,`(`,n.kind,`, v`,n.version,`)`]})]},n.path)),N(t,{children:` `}),P(t,{children:[`Your choice will be saved to`,` `,N(t,{color:`blue`,children:`ccInstallationPath`}),` in`,` `,P(t,{color:`blue`,children:[J.replace(h.homedir(),`~`),`/config.json`]}),`.`]}),N(t,{children:` `}),N(t,{dimColor:!0,children:`Use ↑↓ arrows to navigate, Enter to select, Esc to quit`})]})}const Ii=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.4.0`).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?Jn():t.debug&&qn();let n=await dr();if(t.apply){await Li();return}await Ri(n)};async function Li(){console.log(`Applying saved customizations to Claude Code...`),console.log(`Configuration saved at: ${Y}`);let e=await Sr();(!e.settings||Object.keys(e.settings).length===0)&&(console.error(`No saved customizations found in `+Y),process.exit(1));try{let t=await Ni({interactive:!1});(!t.startupCheckInfo||!t.startupCheckInfo.ccInstInfo)&&(console.error(Mi()),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 bt(n.version);r.success||(console.log(a.red(`
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 zn(e,n),console.log(`Customizations applied successfully!`),process.exit(0)}catch(e){throw e instanceof di&&(console.error(a.red(`Error: ${e.message}`)),process.exit(1)),e}}async function Ri(e){try{let t=await Ni({interactive:!0});if(t.pendingCandidates){await zi(t.pendingCandidates,e);return}t.startupCheckInfo||(console.error(a.red(Mi())),process.exit(1)),await Bi(t.startupCheckInfo,e)}catch(e){throw e instanceof di&&(console.error(a.red(`Error: ${e.message}`)),process.exit(1)),e}}async function zi(e,t){return new Promise((r,i)=>{let o=n(N(Fi,{candidates:e,onSelect:async e=>{try{let n=await ji(e),i=await Pi(await Sr(),n);i||(console.error(a.red(`Error: Failed to complete startup check after selection.`)),process.exit(1)),o.unmount(),await Bi(i,t),r()}catch(e){i(e)}}}))})}async function Bi(e,t){let r=await bt(e.ccInstInfo.version);r.success||(console.log(a.red(`
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(N(ci,{startupCheckInfo:e,configMigrated:t}))}Ii();export{Gn as n,G as t};
23
+ `;if(r)return Mt([],i,t);try{return await Mt([`--permission`],i,t)}catch(e){if(!At(e))throw e}try{return await Mt([`--experimental-permission`],i,t)}catch(e){if(At(e)){let e=jt();throw Error(`Your Node.js version (${e}) does not support the permission model.\nPlease either upgrade to Node.js 20+ or rerun with --dangerous-no-script-sandbox.`)}throw e}}function At(e){return e instanceof Error?e.message.includes(`bad option`):!1}function jt(){try{return Oe(`node --version`,{encoding:`utf8`}).trim()}catch{return`unknown`}}function Mt(e,t,n){return new Promise((r,i)=>{let a=ke(`node`,[...e,`-e`,t],{stdio:[`pipe`,`pipe`,`pipe`]}),o=``,s=``;a.stdout.on(`data`,e=>o+=e),a.stderr.on(`data`,e=>s+=e),a.on(`error`,i),a.stdin.on(`error`,()=>{}),a.on(`close`,e=>{if(e!==0)i(Error(s||`Script exited with code ${e}`));else try{r(JSON.parse(o).r)}catch{i(Error(`Script returned invalid JSON output.\nstdout: ${o}\nstderr: ${s}`))}}),a.stdin.write(n),a.stdin.end()})}async function Nt(e){if(!e.startsWith(`@`))return e;let t=e.slice(1);if(t.startsWith(`http://`)||t.startsWith(`https://`)){console.log(`Fetching script from ${t}...`);let e=await fetch(t);if(!e.ok)throw Error(`Failed to fetch script from ${t}: HTTP ${e.status} ${e.statusText}`);return e.text()}return console.log(`Reading script from ${t}...`),Se.readFile(t,`utf8`)}async function Pt(e){try{return await oe({path:e,interactive:!1})}catch(e){let t=e instanceof Error?e.message:String(e);console.error(U.red(`Error: ${t}`)),process.exit(1)}}async function Ft(e,t){let n=await Pt(t);n.kind===`npm`&&(console.error(U.red(`Error: Cannot unpack an npm-based installation (cli.js). Only native binaries can be unpacked.`)),console.error(U.gray(` Detected installation: ${n.path} (npm-based, v${n.version})`)),process.exit(1)),console.log(`Extracting JS from native binary: ${U.cyan(n.path)} (v${n.version})`);let r=await ue(n);await Se.writeFile(e,r,`utf8`),console.log(U.green(`✓ Extracted JS written to ${U.cyan(e)}`)),console.log(U.gray(` ${r.length.toLocaleString()} characters written`))}async function It(e,t){let n=await Pt(t);n.kind===`npm`&&(console.error(U.red(`Error: Cannot repack into an npm-based installation (cli.js). Only native binaries can be repacked.`)),console.error(U.gray(` Detected installation: ${n.path} (npm-based, v${n.version})`)),process.exit(1)),console.log(`Repacking JS into native binary: ${U.cyan(n.path)} (v${n.version})`);let r=await Se.readFile(e,`utf8`);if(!await Dt(await ue(n),r)){console.log(U.yellow(`Aborted.`));return}await R(n,r),console.log(U.green(`✓ JS from ${U.cyan(e)} repacked into ${U.cyan(n.path)}`))}async function Lt(e,t,n,r,i=!1){let a=await ue(r),o,s;if(n!==void 0){let r=[],i=0;for(;;){let t=a.indexOf(e,i);if(t===-1)break;r.push(t),i=t+e.length}r.length===0&&(console.error(U.red(`Error: String not found in content.`)),process.exit(1)),(n<1||n>r.length)&&(console.error(U.red(`Error: Index ${n} is out of range. Found ${r.length} occurrence(s).`)),process.exit(1));let c=r[n-1];o=a.slice(0,c)+t+a.slice(c+e.length),s=1}else{let n=a.split(e);s=n.length-1,s===0&&(console.error(U.red(`Error: String not found in content.`)),process.exit(1)),o=n.join(t)}if(!await Dt(a,o,i)){console.log(U.yellow(`Aborted.`));return}await R(r,o),console.log(U.green(`✓ Replaced ${s} occurrence(s) in ${U.cyan(r.path)}`))}function Rt(e){if(e.startsWith(`/`)){let t=-1;for(let n=e.length-1;n>0;n--)if(e[n]===`/`){let r=0;for(let t=n-1;t>=0&&e[t]===`\\`;t--)r++;if(r%2==0){t=n;break}}if(t>0){let n=e.slice(1,t),r=e.slice(t+1);if(!/^[gimsuy]*$/.test(r))throw Error(`Invalid regex flags: "${r}". Valid flags are: g, i, m, s, u, y`);return{pattern:n,flags:r}}}return{pattern:e,flags:``}}async function zt(e,t,n,r,i=!1){let a=await ue(r),o;try{o=Rt(e)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(U.red(`Error: ${t}`)),process.exit(1)}let s=o.flags.includes(`g`)?o.flags:o.flags+`g`,c,l,u=new RegExp(o.pattern,s);if(n!==void 0){let e=[...a.matchAll(u)];e.length===0&&(console.error(U.red(`Error: Regex pattern not found in content.`)),process.exit(1)),(n<1||n>e.length)&&(console.error(U.red(`Error: Index ${n} is out of range. Found ${e.length} match(es).`)),process.exit(1));let r=e[n-1],i=r.index,s=i+r[0].length,d=r[0].replace(new RegExp(o.pattern,o.flags),t);c=a.slice(0,i)+d+a.slice(s),l=1}else c=a.replace(u,t),l=[...a.matchAll(new RegExp(o.pattern,s))].length,l===0&&(console.error(U.red(`Error: Regex pattern not found in content.`)),process.exit(1));if(!await Dt(a,c,i)){console.log(U.yellow(`Aborted.`));return}await R(r,c),console.log(U.green(`✓ Replaced ${l} match(es) in ${U.cyan(r.path)}`))}async function Bt(e,t,n=!1,r=!1){let i=await ue(t),a=await Nt(e);console.log(`Resolving variables...`);let o=Ot(i);console.log(r?`Running patch script WITHOUT sandbox (--dangerous-no-script-sandbox)...`:`Running patch script in sandbox...`);let s;try{s=await kt(a,i,o,r)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(U.red(`Error: Script execution failed:`)),console.error(U.red(` ${t}`)),process.exit(1)}if(typeof s!=`string`&&(console.error(U.red(`Error: Script did not return a string. Got: `+typeof s)),process.exit(1)),s===i){console.log(U.yellow(`Script returned unchanged content. Nothing to do.`));return}if(!await Dt(i,s,n)){console.log(U.yellow(`Aborted.`));return}await R(t,s),console.log(U.green(`✓ Script patch applied to ${U.cyan(t.path)}`))}async function Vt(e){let t=[e.string,e.regex,e.script].filter(e=>e!==void 0);t.length===0&&(console.error(U.red(`Error: Must specify one of --string, --regex, or --script.`)),process.exit(1)),t.length>1&&(console.error(U.red(`Error: Only one of --string, --regex, or --script can be used at a time.`)),process.exit(1));let n=!!e.confirmPossibleDangerousPatch,r=await Pt(e.path);console.log(`Target: ${U.cyan(r.path)} (${r.kind}, v${r.version})`),e.string?(e.string.length!==2&&(console.error(U.red(`Error: --string requires exactly 2 arguments: <old-string> <new-string>`)),process.exit(1)),await Lt(e.string[0],e.string[1],e.index,r,n)):e.regex?(e.regex.length!==2&&(console.error(U.red(`Error: --regex requires exactly 2 arguments: <pattern> <replacement>`)),process.exit(1)),await zt(e.regex[0],e.regex[1],e.index,r,n)):e.script&&(e.index!==void 0&&(console.error(U.red(`Error: --index cannot be used with --script.`)),process.exit(1)),await Bt(e.script,r,n,!!e.dangerousNoScriptSandbox))}function Ht(){let e=process.argv[1]||``;return e.includes(`npx`)||e.includes(`.npm/_npx`)?`npx tweakcc`:e.includes(`pnpm`)||e.includes(`.pnpm`)?`pnpm dlx tweakcc`:e.includes(`yarn`)?`yarn dlx tweakcc`:e.includes(`bun`)?`bunx tweakcc`:`tweakcc`}function Ut(e,t){let n=[A.SYSTEM_PROMPTS,A.ALWAYS_APPLIED,A.MISC_CONFIGURABLE,A.FEATURES],r=new Map;for(let e of n)r.set(e,[]);for(let t of e){let e=r.get(t.group);e&&e.push(t)}console.log(`
24
+ Patches applied (run with --show-unchanged to show all patches):`);for(let e of n){let n=r.get(e).filter(e=>e.applied||e.failed||h()||t&&t.includes(e.id));if(n.length!==0){console.log(`\n ${U.bold(e)}:`);for(let e of n){let t=e.failed?U.red(`✗`):e.applied?U.green(`✓`):U.dim(`○`),n=e.details?`: ${e.details}`:``,r=e.applied&&e.description?` ${U.gray(`—`)} ${U.gray(e.description)}`:``;console.log(` ${t} ${e.name}${n}${r}`)}}}console.log(``)}const Wt=async()=>{let e=new pe;e.name(`tweakcc`).description(`Command-line tool to customize your Claude Code theme colors, thinking verbs and more.`).version(`4.0.0`).option(`-d, --debug`,`enable debug mode`).option(`-v, --verbose`,`enable verbose debug mode (includes diffs)`).option(`--show-unchanged`,`show unchanged diffs (requires --verbose)`).option(`-a, --apply`,`apply saved customizations without interactive UI`).option(`--restore`,`restore Claude Code to its original state`).option(`--revert`,`restore Claude Code to its original state (alias for --restore)`).option(`--patches <ids>`,`comma-separated list of patch IDs to apply (use with --apply)`).option(`--list-patches`,`list all available patches with their IDs`).option(`--list-system-prompts [version]`,`list all available system prompts for a CC version`).option(`--config-url <url>`,`fetch configuration from a URL instead of local config.json`).action(async()=>{let t=e.opts();t.verbose?E():t.debug&&M(),t.showUnchanged&&D();let n=await F();if(t.apply&&(t.restore||t.revert)&&(console.error(U.red(`Error: Cannot use --apply and --restore/--revert together.`)),process.exit(1)),t.listPatches){qt();return}if(t.listSystemPrompts!==void 0){await Jt(t.listSystemPrompts);return}if(t.apply){await Gt(t.patches?t.patches.split(`,`).map(e=>e.trim()):null,t.configUrl);return}if(t.configUrl&&(console.error(U.red(`Error: --config-url can only be used with --apply.`)),console.error(U.gray(`The interactive TUI is for editing local configuration only.`)),console.error(U.gray(`To apply a remote config, use:`)),console.error(U.gray(` ${Ht()} --apply --config-url <url>`)),process.exit(1)),t.restore||t.revert){await Kt();return}await Yt(n)}),e.command(`unpack`).argument(`<output-js-path>`,`path to write extracted JS`).argument(`[binary-path]`,`path to native binary (default: auto-detect)`).description(`Extract JS from a native Claude Code binary`).action(async(e,t)=>{await Ft(e,t),process.exit(0)}),e.command(`repack`).argument(`<input-js-path>`,`path to JS file to embed`).argument(`[binary-path]`,`path to native binary (default: auto-detect)`).description(`Embed JS into a native Claude Code binary`).action(async(e,t)=>{await It(e,t),process.exit(0)}),e.command(`adhoc-patch`).description(`Apply an ad-hoc patch to Claude Code`).option(`-s, --string <values...>`,`replace string: <old-string> <new-string>`).option(`-r, --regex <values...>`,`replace regex: <pattern> <replacement>`).option(`--script <script>`,`run a patch script (prefix with @ for file/URL)`).option(`-i, --index <number>`,`replace only the Nth occurrence (1-based)`,parseInt).option(`-p, --path <path>`,`path to cli.js or native binary (default: auto-detect)`).option(`--confirm-possible-dangerous-patch`,`skip diff preview and apply immediately`).option(`--dangerous-no-script-sandbox`,`run --script without the Node.js permission sandbox (use if Node < 20)`).action(async e=>{await Vt(e),process.exit(0)}),e.parse()};async function Gt(t,n){console.log(`Applying saved customizations to Claude Code...`);let r;if(n){console.log(`Fetching configuration from: ${n}`);try{r=await te(n),console.log(`Configuration fetched successfully.`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(U.red(`Error: ${t}`)),process.exit(1)}}else console.log(`Configuration saved at: ${P}`),r=await w();if(!r.settings||Object.keys(r.settings).length===0){let e=n||P;console.error(`No saved customizations found in `+e),process.exit(1)}try{let n=await bt({interactive:!1},r);(!n.startupCheckInfo||!n.startupCheckInfo.ccInstInfo)&&(console.error(L()),process.exit(1));let{ccInstInfo:i}=n.startupCheckInfo;i.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${i.nativeInstallationPath}`):console.log(`Found Claude Code at: ${i.cliPath}`),console.log(`Version: ${i.version}`),console.log(`Loading system prompts...`);let a=await ne(i.version);a.success||(console.log(U.red(`
25
+ ✖ Error downloading system prompts:`)),console.log(U.red(` ${a.errorMessage}`)),console.log(U.yellow(`
26
+ ⚠ System prompts not available - skipping system prompt customizations`))),console.log(`Applying customizations...`);let{results:o}=await e(r,i,t);Ut(o,t);let s=o.some(e=>e.failed),c=o.some(e=>e.group===A.SYSTEM_PROMPTS&&e.applied);s?(console.log(U.yellow(`Customizations applied with some failures.`)),console.log(U.dim(`These patching errors do not affect your system prompt patches.`)),c&&console.log(U.dim(`Your system prompt customizations were still applied successfully.`)),console.log(U.dim(`Please open an issue on https://github.com/Piebald-AI/tweakcc/issues/new reporting these patching errors.`))):console.log(U.green(`Customizations applied successfully!`)),console.log(U.dim(`Run with --restore/--revert to revert Claude Code to its original state.`)),process.exit(0)}catch(e){throw e instanceof z&&(console.error(U.red(`Error: ${e.message}`)),process.exit(1)),e}}async function Kt(){console.log(`Restoring Claude Code to its original state...`);try{let e=await bt({interactive:!1});(!e.startupCheckInfo||!e.startupCheckInfo.ccInstInfo)&&(console.error(L()),process.exit(1));let{ccInstInfo:t}=e.startupCheckInfo;t.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${t.nativeInstallationPath}`):console.log(`Found Claude Code at: ${t.cliPath}`),console.log(`Version: ${t.version}`),console.log(`Restoring from backup...`);let n;n=t.nativeInstallationPath?await y(t):await _(t),n||(console.error(U.red(`No backup found. Cannot restore original Claude Code.`)),console.error(U.yellow(`Tip: A backup is created automatically when you first apply customizations.`)),process.exit(1)),await x(),await j(e=>{e.changesApplied=!1}),console.log(U.blue(`Original Claude Code restored successfully!`)),console.log(U.gray(`Your customizations are still saved in ${P} and can be reapplied with --apply.`)),process.exit(0)}catch(e){throw e instanceof z&&(console.error(U.red(`Error: ${e.message}`)),process.exit(1)),e}}function qt(){let e=k(),t=[A.ALWAYS_APPLIED,A.MISC_CONFIGURABLE,A.FEATURES],n=new Map;for(let e of t)n.set(e,[]);for(let t of e){let e=n.get(t.group);e&&e.push(t)}console.log(U.gray(`Use --patches <ids> with --apply to apply specific patches, e.g.:`)),console.log(),console.log(U.gray(` tweakcc --apply --patches "themes,toolsets"`)),console.log(),console.log(U.blue.bold(`Available patches`)),console.log();for(let e of t){let t=n.get(e);if(t.length!==0){console.log(U.bold(e)+`:`);for(let e of t)console.log(` ${U.cyan(e.id)}`),console.log(` ${U.white(e.name)} ${U.gray(`—`)} ${U.gray(e.description)}`);console.log(``)}}console.log(U.bold(`System Prompts:`)),console.log(U.dim(` System prompts also have IDs that can be used with --patches. Use --list-system-prompts [version] to see them.`))}async function Jt(e){let t;if(typeof e==`string`)t=e;else{console.log(`Detecting installed Claude Code version...`);try{let e=await bt({interactive:!1});e.startupCheckInfo?.ccInstInfo?.version||(console.error(U.red(`Could not detect Claude Code version. Please specify a version:`)),console.error(U.gray(` tweakcc --list-system-prompts 1.0.20`)),process.exit(1)),t=e.startupCheckInfo.ccInstInfo.version}catch{console.error(U.red(`Could not detect Claude Code installation. Please specify a version:`)),console.error(U.gray(` tweakcc --list-system-prompts 1.0.20`)),process.exit(1)}}console.log(`Loading system prompts for CC version ${t}...`);let n=await ne(t);n.success||(console.error(U.red(`
27
+ ✖ Error loading system prompts:`)),console.error(U.red(` ${n.errorMessage}`)),process.exit(1));let r=c();(!r||r.length===0)&&(console.error(U.yellow(`No system prompts found for this version.`)),process.exit(1));let i=e=>{let t=e.indexOf(`:`);if(t===-1)return`Other`;let n=e.substring(0,t).trim();return n===`Data`?n:n+`s`},a=new Map;for(let e of r){let t=i(e.name);a.has(t)||a.set(t,[]),a.get(t).push(e)}let o=[...a.keys()].sort((e,t)=>e.localeCompare(t));console.log(U.gray(`Use --patches <ids> with --apply to apply specific prompts, e.g.:`)),console.log(),console.log(U.gray(` tweakcc --apply --patches "identity,environment"`)),console.log(),console.log(U.blue.bold(`System prompts for CC ${t}`)),console.log();for(let e of o){let t=a.get(e);t.sort((e,t)=>e.name.localeCompare(t.name)),console.log(U.bold(e)+`:`);for(let e of t)console.log(` ${U.cyan(e.id)}`),console.log(` ${U.white(e.name)} ${U.gray(`—`)} ${U.gray(e.description)}`);console.log(``)}console.log(U.yellow(`To see all original system prompts for a given Claude Code version, visit:`)),console.log(U.yellow.bold(` https://github.com/Piebald-AI/claude-code-system-prompts`))}async function Yt(e){try{let t=await bt({interactive:!0});if(t.pendingCandidates){await Xt(t.pendingCandidates,e);return}t.startupCheckInfo||(console.error(U.red(L())),process.exit(1)),await Zt(t.startupCheckInfo,e,t.config)}catch(e){throw e instanceof z&&(console.error(U.red(`Error: ${e.message}`)),process.exit(1)),e}}async function Xt(e,t){return new Promise((n,r)=>{let i=fe(J(le,{candidates:e,onSelect:async e=>{try{let r=await ce(e),a=await w(),o=await xt(a,r);o||(console.error(U.red(`Error: Failed to complete startup check after selection.`)),process.exit(1)),i.unmount(),await Zt(o,t,a),n()}catch(e){r(e)}}}))})}async function Zt(e,t,n){let r=await ne(e.ccInstInfo.version);r.success||(console.log(U.red(`
28
+ ✖ Error downloading system prompts:`)),console.log(U.red(` ${r.errorMessage}`)),console.log(U.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
29
+ `))),fe(J(yt,{startupCheckInfo:e,configMigrated:t,invocationCommand:Ht(),initialConfig:n}))}Wt();export{};