tweakcc 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -2
  2. package/dist/index.js +293 -80
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import{Box as m,Text as c,render as ot,useInput as de}from"ink";import{Command as it}from"commander";import Q from"chalk";import Je,{Fragment as ke,createContext as st,useCallback as En,useContext as pe,useEffect as xe,useState as T}from"react";import lt from"ink-link";import{Fragment as he,jsx as s,jsxs as h}from"react/jsx-runtime";import*as re from"node:path";import kn from"node:path";import*as ye from"node:os";import{EOL as fn}from"node:os";import*as Ee from"node:fs";import Ae from"node:fs";import{globbySync as at}from"globby";import ct from"node:process";import*as te from"node:fs/promises";import le from"node:fs/promises";import*as Be from"node:child_process";import{execSync as Mn}from"node:child_process";import*as Bn from"node:crypto";import He from"gray-matter";import De from"node-lief";function dt({items:e,selectedIndex:t,onSelect:n,onSubmit:r}){return de((o,i)=>{i.upArrow?n(t>0?t-1:e.length-1):i.downArrow?n(t<e.length-1?t+1:0):i.return&&r(e[t].name)}),s(m,{flexDirection:"column",children:e.map((o,i)=>s(m,{children:h(c,{children:[h(c,{bold:i===t,color:i===t?"cyan":void 0,...i===t?o.selectedStyles??{}:o.styles??{},children:[i===t?"❯ ":" ",o.name]}),o.desc&&i===t&&h(c,{dimColor:!0,bold:!1,children:[" \x1B[0;2m","- ",o.desc]})]})},i))})}let J=function(e){return e.APPLY_CHANGES="*Apply customizations",e.THEMES="Themes",e.THINKING_VERBS="Thinking verbs",e.THINKING_STYLE="Thinking style",e.USER_MESSAGE_DISPLAY="User message display",e.MISC="Misc",e.TOOLSETS="Toolsets",e.VIEW_SYSTEM_PROMPTS="View system prompts",e.RESTORE_ORIGINAL="Restore original Claude Code (preserves tweakcc.json)",e.OPEN_CONFIG="Open tweakcc.json",e.OPEN_CLI="Open Claude Code's cli.js",e.EXIT="Exit",e}({});const Z={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"]},thinkingStyle:{updateInterval:120,phases:process.env.TERM==="xterm-ghostty"?["·","✢","✳","✶","✻","*"]:process.platform==="darwin"?["·","✢","✳","✶","✻","✽"]:["·","✢","*","✶","✻","✽"],reverseMirror:!0},userMessageDisplay:{prefix:{format:">",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"},message:{format:"{}",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"}},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0},toolsets:[],defaultToolset:null},ut=()=>{const e=re.join(ye.homedir(),".tweakcc"),t=process.env.XDG_CONFIG_HOME;try{if(Ee.existsSync(e))return e}catch{}return t?re.join(t,"tweakcc"):e},ce=ut(),fe=re.join(ce,"config.json"),Ne=re.join(ce,"cli.js.backup"),ae=re.join(ce,"native-binary.backup"),Se=re.join(ce,"system-prompts"),mn=re.join(ce,"prompt-data-cache"),gt=()=>{const e=[],t=process.platform=="win32"?ye.homedir().replace(/\\/g,"/"):ye.homedir(),n="node_modules/@anthropic-ai/claude-code",r=(o,i=!1)=>{if(i){const l=at(o,{onlyFiles:!1});e.push({pattern:o,isGlob:!0,expandedPaths:l})}else e.push({pattern:o,isGlob:!1,expandedPaths:[o]})};return r(`${ye.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}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0)):(process.platform=="darwin"&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`)),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(`/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(`${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.platform=="win32"&&e.forEach(o=>{o.pattern=o.pattern.replace(/\//g,"\\"),o.expandedPaths=o.expandedPaths.map(i=>i.replace(/\//g,"\\"))}),e},Ze=gt(),pn=Ze.flatMap(e=>e.expandedPaths),ht=({children:e,...t})=>h(c,{bold:!0,backgroundColor:"#ffd500",color:"#000",...t,children:[" ",e," "]});var me=ht;const ft=[{name:J.THEMES,desc:"Modify Claude Code's built-in themes or create your own"},{name:J.THINKING_VERBS,desc:"Customize the list of verbs that Claude Code uses when it's working"},{name:J.THINKING_STYLE,desc:"Choose custom spinners"},{name:J.USER_MESSAGE_DISPLAY,desc:"Customize how user messages are displayed"},{name:J.MISC,desc:"Miscellaneous settings (input box border, etc.)"},{name:J.TOOLSETS,desc:"Manage toolsets to control which tools are available"},{name:J.VIEW_SYSTEM_PROMPTS,desc:"Opens the system prompts directory where you can customize Claude Code's system prompts"}],bn=[{name:J.RESTORE_ORIGINAL,desc:"Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)"},{name:J.OPEN_CONFIG,desc:`Opens your tweakcc config file (${fe})`},{name:J.OPEN_CLI,desc:"Opens Claude Code's cli.js file"},{name:J.EXIT,desc:"Bye!"}];function mt({onSubmit:e,notification:t,isNativeInstallation:n}){const r=n?bn.filter(a=>a.name!==J.OPEN_CLI):bn,o=[...pe(ue).changesApplied?[]:[{name:J.APPLY_CHANGES,desc:"Required: Updates Claude Code in-place with your changes",selectedStyles:{color:"green"}}],...ft,...r],[i,l]=T(0);return h(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(me,{children:"Tweak Claude Code"})}),s(m,{marginBottom:1,children:h(c,{color:"gray",children:[s(c,{bold:!0,children:"Customize your Claude Code installation."})," ",s(c,{dimColor:!0,children:"Settings will be saved to a JSON file."})]})}),s(m,{marginBottom:1,children:h(c,{color:"yellow",children:["⭐ ",s(c,{bold:!0,children:"Star the repo at "}),s(lt,{url:"https://github.com/Piebald-AI/tweakcc",fallback:!1,children:s(c,{bold:!0,color:"cyan",children:"https://github.com/Piebald-AI/tweakcc"})}),s(c,{bold:!0,children:" if you find this useful!"})," ⭐"]})}),t&&s(m,{marginBottom:1,borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:"bold",borderColor:t?.type==="success"?"green":t?.type==="error"?"red":t?.type==="info"?"blue":"yellow",paddingLeft:1,flexDirection:"column",children:s(c,{color:t?.type==="success"?"green":t?.type==="error"?"red":t?.type==="info"?"blue":"yellow",children:t?.message})}),s(dt,{items:o,selectedIndex:i,onSelect:l,onSubmit:a=>e(a)})]})}async function nn(e){const t=re.join(mn,`prompts-${e}.json`);try{const r=await te.readFile(t,"utf-8");return JSON.parse(r)}catch{}const n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{const r=await fetch(n);if(!r.ok){let i;throw r.status===429?i="Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.":r.status===404?i=`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?i=`GitHub server error (${r.status}). Please try again later.`:i=`HTTP ${r.status}: ${r.statusText}`,new Error(i)}const o=await r.json();try{await te.mkdir(mn,{recursive:!0}),await te.writeFile(t,JSON.stringify(o,null,2),"utf-8")}catch(i){console.warn(`Failed to write to cache to ${t}: ${i}`)}return o}catch(r){if(r instanceof Error){if(r.message.includes("Rate limit")||r.message.includes("not found")||r.message.includes("server error")||r.message.includes("HTTP"))throw r;const o=`Failed to download prompts for version ${e}: ${r.message}`;throw new Error(o)}throw r}}const pt="modulepreload",bt=function(e){return"/"+e},wn={},wt=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let d=function(g){return Promise.all(g.map(f=>Promise.resolve(f).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const l=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");o=d(n.map(g=>{if(g=bt(g,r),g in wn)return;wn[g]=!0;const f=g.endsWith(".css"),v=f?'[rel="stylesheet"]':"";if(!!r)for(let w=l.length-1;w>=0;w--){const x=l[w];if(x.href===g&&(!f||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${g}"]${v}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":pt,f||(p.as="script"),p.crossOrigin="",p.href=g,u&&p.setAttribute("nonce",u),document.head.appendChild(p),f)return new Promise((w,x)=>{p.addEventListener("load",w),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${g}`)))})}))}function i(l){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=l,window.dispatchEvent(a),!a.defaultPrevented)throw l}return o.then(l=>{for(const a of l||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})},Nn=re.join(ce,"systemPromptOriginalHashes.json"),On=re.join(ce,"systemPromptAppliedHashes.json"),Tn=(e,t)=>`${e}-${t}`,Ye=e=>Bn.createHash("md5").update(e.trim(),"utf8").digest("hex"),An=async()=>{try{const e=await te.readFile(Nn,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},xt=async e=>{await te.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const r of n)t[r]=e[r];await te.writeFile(Nn,JSON.stringify(t,null,2),"utf8")},yt=async e=>{const t=await An();let n=0;for(const r of e.prompts){const o=Tn(r.id,r.version);if(!t[o]){const i=Re(r.pieces,r.identifiers,r.identifierMap),l=Ye(i);t[o]=l,n++}}return await xt(t),n},St=async(e,t)=>{const n=await An(),r=Tn(e,t);return n[r]},tn=async()=>{try{const e=await te.readFile(On,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},Pn=async e=>{await te.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const r of n)t[r]=e[r];await te.writeFile(On,JSON.stringify(t,null,2),"utf8")},vt=async(e,t)=>{const n=await tn();n[e]=t,await Pn(n)},$t=async()=>{const e=await tn(),t={};for(const n of Object.keys(e))t[n]=null;await Pn(t)},_t=async e=>{try{const t=await tn();if(Object.keys(t).length===0)return!1;const r=(await te.readdir(e)).filter(o=>o.endsWith(".md"));for(const o of r){const i=o.replace(".md",""),l=t[i];if(l===void 0||l===null)continue;const a=re.join(e,o),u=await te.readFile(a,"utf8"),g=(await wt(()=>import("gray-matter"),[])).default(u,{delimiters:["<!--","-->"]});if(Ye(g.content)!==l)return!0}return!1}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}},Ln=e=>{const t=He(e,{delimiters:["<!--","-->"]}),{name:n,description:r,ccVersion:o,variables:i}=t.data;return{name:n||"",description:r||"",ccVersion:o||"",variables:i||[],content:t.content.trim()}},xn=(e,t)=>{const n=t||Re(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,o={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(o.variables=r),He.stringify(n,o,{delimiters:["<!--","-->"]})},Re=(e,t,n)=>{let r="";for(let o=0;o<e.length;o++)if(r+=e[o],o<t.length){const i=t[o],l=n[String(i)]||`UNKNOWN_${i}`;r+=l}return r},It=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,l=r[o]||0;if(i<l)return-1;if(i>l)return 1}return 0},Fe=e=>re.join(Se,`${e}.md`),Ct=async e=>{try{return await te.access(Fe(e)),!0}catch{return!1}},Et=async e=>{const t=Fe(e),n=await te.readFile(t,"utf-8");return Ln(n)},Qe=async(e,t)=>{const n=Fe(e);await te.writeFile(n,t,"utf-8")},kt=async(e,t)=>{const n=Fe(e),r=await te.readFile(n,"utf-8"),o=He(r,{delimiters:["<!--","-->"]}),i=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,l={name:o.data.name,description:o.data.description,ccVersion:o.data.ccVersion};i&&i.length>0&&(l.variables=i);const a=He.stringify(o.content,l,{delimiters:["<!--","-->"]});await Qe(e,a)},Mt=(e,t)=>{const n=w=>w.split(/(\s+)/),r=n(e),o=n(t),i=r.length,l=o.length,a=Array(i+1).fill(0).map(()=>Array(l+1).fill(0));for(let w=1;w<=i;w++)for(let x=1;x<=l;x++)r[w-1]===o[x-1]?a[w][x]=a[w-1][x-1]+1:a[w][x]=Math.max(a[w-1][x],a[w][x-1]);const u=Array(i).fill(!1),d=Array(l).fill(!1);let g=i,f=l;for(;g>0||f>0;)g>0&&f>0&&r[g-1]===o[f-1]?(g--,f--):f>0&&(g===0||a[g][f-1]>=a[g-1][f])?(d[f-1]=!0,f--):g>0&&(u[g-1]=!0,g--);const v=w=>w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");let b="";for(let w=0;w<r.length;w++){const x=v(r[w]);b+=u[w]?`<mark>${x}</mark>`:x}let p="";for(let w=0;w<o.length;w++){const x=v(o[w]);p+=d[w]?`<mark>${x}</mark>`:x}return{oldHtml:b,newHtml:p}},yn=(e,t)=>{const n=e.length,r=t.length,o=Array(n+1).fill(0).map(()=>Array(r+1).fill(0));for(let d=1;d<=n;d++)for(let g=1;g<=r;g++)e[d-1]===t[g-1]?o[d][g]=o[d-1][g-1]+1:o[d][g]=Math.max(o[d-1][g],o[d][g-1]);const i=[];let l=n,a=r;const u=[];for(;l>0||a>0;)l>0&&a>0&&e[l-1]===t[a-1]?(u.unshift({type:"unchanged",line:e[l-1],oldLineNo:l,newLineNo:a}),l--,a--):a>0&&(l===0||o[l][a-1]>=o[l-1][a])?(u.unshift({type:"added",line:t[a-1],newLineNo:a}),a--):l>0&&(u.unshift({type:"removed",line:e[l-1],oldLineNo:l}),l--);for(let d=0;d<u.length;d++){const g=u[d],f=u[d+1];if(g.type==="removed"&&f?.type==="added"){const v=Mt(g.line,f.line);i.push({type:"modified",line:g.line,oldLineNo:g.oldLineNo,newLineNo:f.newLineNo,oldHtml:v.oldHtml,newHtml:v.newHtml}),d++}else i.push(g)}return i},Bt=async(e,t,n,r,o,i,l,a)=>{const u=n.split(`
3
- `),d=r.split(`
4
- `),g=o.split(`
5
- `),f=_=>_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),v=yn(u,d),b=yn(u,g);let p="";for(const _ of v){const k=f(_.line);if(_.type==="modified"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",O=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${_.oldHtml}</div>
6
- `,p+=`<div class="line added"><span class="line-num">${O}</span><span class="prefix">+ </span>${_.newHtml}</div>
2
+ import{Box as m,Text as c,render as st,useInput as ue}from"ink";import{Command as lt}from"commander";import Q from"chalk";import*as te from"node:fs/promises";import ie from"node:fs/promises";import Ke,{Fragment as ke,createContext as at,useCallback as Tn,useContext as pe,useEffect as xe,useState as O}from"react";import ct from"ink-link";import{Fragment as fe,jsx as s,jsxs as g}from"react/jsx-runtime";import*as oe from"node:path";import Mn from"node:path";import*as ye from"node:os";import{EOL as mn}from"node:os";import*as Ee from"node:fs";import Ae from"node:fs";import{globbySync as dt}from"globby";import ut from"node:process";import*as Me from"node:child_process";import{execSync as Nn}from"node:child_process";import*as Bn from"node:crypto";import He from"gray-matter";import De from"node-lief";function ht({items:e,selectedIndex:t,onSelect:n,onSubmit:o}){return ue((r,i)=>{i.upArrow?n(t>0?t-1:e.length-1):i.downArrow?n(t<e.length-1?t+1:0):i.return&&o(e[t].name)}),s(m,{flexDirection:"column",children:e.map((r,i)=>s(m,{children:g(c,{children:[g(c,{bold:i===t,color:i===t?"cyan":void 0,...i===t?r.selectedStyles??{}:r.styles??{},children:[i===t?"❯ ":" ",r.name]}),r.desc&&i===t&&g(c,{dimColor:!0,bold:!1,children:[" \x1B[0;2m","- ",r.desc]})]})},i))})}let J=function(e){return e.APPLY_CHANGES="*Apply customizations",e.THEMES="Themes",e.THINKING_VERBS="Thinking verbs",e.THINKING_STYLE="Thinking style",e.USER_MESSAGE_DISPLAY="User message display",e.MISC="Misc",e.TOOLSETS="Toolsets",e.VIEW_SYSTEM_PROMPTS="View system prompts",e.RESTORE_ORIGINAL="Restore original Claude Code (preserves config.json)",e.OPEN_CONFIG="Open config.json",e.OPEN_CLI="Open Claude Code's cli.js",e.EXIT="Exit",e}({});const Z={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"]},thinkingStyle:{updateInterval:120,phases:process.env.TERM==="xterm-ghostty"?["·","✢","✳","✶","✻","*"]:process.platform==="darwin"?["·","✢","✳","✶","✻","✽"]:["·","✢","*","✶","✻","✽"],reverseMirror:!0},userMessageDisplay:{prefix:{format:">",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"},message:{format:"{}",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"}},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0},toolsets:[],defaultToolset:null},gt=()=>{const e=oe.join(ye.homedir(),".tweakcc"),t=process.env.XDG_CONFIG_HOME;try{if(Ee.existsSync(e))return e}catch{}return t?oe.join(t,"tweakcc"):e},de=gt(),ce=oe.join(de,"config.json"),Ne=oe.join(de,"cli.js.backup"),ae=oe.join(de,"native-binary.backup"),Se=oe.join(de,"system-prompts"),pn=oe.join(de,"prompt-data-cache"),ft=()=>{const e=[],t=process.platform=="win32"?ye.homedir().replace(/\\/g,"/"):ye.homedir(),n="node_modules/@anthropic-ai/claude-code",o=(r,i=!1)=>{if(i){const a=dt(r,{onlyFiles:!1});e.push({pattern:r,isGlob:!0,expandedPaths:a})}else e.push({pattern:r,isGlob:!1,expandedPaths:[r]})};return o(`${ye.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&o(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&o(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&o(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&o(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&o(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&o(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&o(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&o(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform=="win32"?(o(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),o(`${t}/AppData/Roaming/npm/${n}`),o(`${t}/AppData/Roaming/nvm/*/${n}`,!0),o(`${t}/AppData/Local/Yarn/config/global/${n}`),o(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),o(`C:/nvm4w/nodejs/${n}`),o(`${t}/n/versions/node/*/lib/${n}`,!0),o(`${t}/AppData/Roaming/Yarn/config/global/${n}`),o(`${t}/AppData/Roaming/pnpm-global/${n}`),o(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),o(`${t}/.bun/install/global/${n}`),o(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0)):(process.platform=="darwin"&&(o(`${t}/Library/${n}`),o(`/opt/local/lib/${n}`)),o(`${t}/.local/lib/${n}`),o(`${t}/.local/share/${n}`),o(`${t}/.npm-global/lib/${n}`),o(`${t}/.npm-packages/lib/${n}`),o(`${t}/.npm/lib/${n}`),o(`${t}/npm/lib/${n}`),o(`/etc/${n}`),o(`/lib/${n}`),o(`/opt/node/lib/${n}`),o(`/usr/lib/${n}`),o(`/usr/local/lib/${n}`),o(`/usr/share/${n}`),o(`/var/lib/${n}`),o(`/opt/homebrew/lib/${n}`),o(`${t}/.linuxbrew/lib/${n}`),o(`${t}/.config/yarn/global/${n}`),o(`${t}/.yarn/global/${n}`),o(`${t}/.bun/install/global/${n}`),o(`${t}/.pnpm-global/${n}`),o(`${t}/.pnpm-global/*/${n}`,!0),o(`${t}/pnpm-global/${n}`),o(`${t}/pnpm-global/*/${n}`,!0),o(`${t}/.local/share/pnpm/global/${n}`),o(`${t}/.local/share/pnpm/global/*/${n}`,!0),o(`${t}/.bun/install/global/${n}`),o(`/usr/local/n/versions/node/*/lib/${n}`,!0),o(`${t}/n/versions/node/*/lib/${n}`,!0),o(`${t}/n/lib/${n}`),o(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),o(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),o(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),o(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),o(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),o(`${t}/.nvm/versions/node/*/lib/${n}`,!0),o(`${t}/.nodenv/versions/*/lib/${n}`,!0),o(`${t}/.nvs/*/lib/${n}`,!0),o(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&o(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),o(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0)),process.platform=="win32"&&e.forEach(r=>{r.pattern=r.pattern.replace(/\//g,"\\"),r.expandedPaths=r.expandedPaths.map(i=>i.replace(/\//g,"\\"))}),e},Qe=ft(),bn=Qe.flatMap(e=>e.expandedPaths),mt=({children:e,...t})=>g(c,{bold:!0,backgroundColor:"#ffd500",color:"#000",...t,children:[" ",e," "]});var me=mt;const pt=[{name:J.THEMES,desc:"Modify Claude Code's built-in themes or create your own"},{name:J.THINKING_VERBS,desc:"Customize the list of verbs that Claude Code uses when it's working"},{name:J.THINKING_STYLE,desc:"Choose custom spinners"},{name:J.USER_MESSAGE_DISPLAY,desc:"Customize how user messages are displayed"},{name:J.MISC,desc:"Miscellaneous settings (input box border, etc.)"},{name:J.TOOLSETS,desc:"Manage toolsets to control which tools are available"},{name:J.VIEW_SYSTEM_PROMPTS,desc:"Opens the system prompts directory where you can customize Claude Code's system prompts"}],wn=[{name:J.RESTORE_ORIGINAL,desc:"Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)"},{name:J.OPEN_CONFIG,desc:`Opens your tweakcc config file (${ce})`},{name:J.OPEN_CLI,desc:"Opens Claude Code's cli.js file"},{name:J.EXIT,desc:"Bye!"}];function bt({onSubmit:e,notification:t,isNativeInstallation:n}){const o=n?wn.filter(l=>l.name!==J.OPEN_CLI):wn,r=[...pe(he).changesApplied?[]:[{name:J.APPLY_CHANGES,desc:"Required: Updates Claude Code in-place with your changes",selectedStyles:{color:"green"}}],...pt,...o],[i,a]=O(0);return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(me,{children:"Tweak Claude Code"})}),s(m,{marginBottom:1,children:g(c,{color:"gray",children:[s(c,{bold:!0,children:"Customize your Claude Code installation."})," ",s(c,{dimColor:!0,children:"Settings will be saved to a JSON file."})]})}),s(m,{marginBottom:1,children:g(c,{color:"yellow",children:["⭐ ",s(c,{bold:!0,children:"Star the repo at "}),s(ct,{url:"https://github.com/Piebald-AI/tweakcc",fallback:!1,children:s(c,{bold:!0,color:"cyan",children:"https://github.com/Piebald-AI/tweakcc"})}),s(c,{bold:!0,children:" if you find this useful!"})," ⭐"]})}),t&&s(m,{marginBottom:1,borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:"bold",borderColor:t?.type==="success"?"green":t?.type==="error"?"red":t?.type==="info"?"blue":"yellow",paddingLeft:1,flexDirection:"column",children:s(c,{color:t?.type==="success"?"green":t?.type==="error"?"red":t?.type==="info"?"blue":"yellow",children:t?.message})}),s(ht,{items:r,selectedIndex:i,onSelect:a,onSubmit:l=>e(l)})]})}async function tn(e){const t=oe.join(pn,`prompts-${e}.json`);try{const o=await te.readFile(t,"utf-8");return JSON.parse(o)}catch{}const n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{const o=await fetch(n);if(!o.ok){let i;throw o.status===429?i="Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.":o.status===404?i=`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.`:o.status>=500?i=`GitHub server error (${o.status}). Please try again later.`:i=`HTTP ${o.status}: ${o.statusText}`,new Error(i)}const r=await o.json();try{await te.mkdir(pn,{recursive:!0}),await te.writeFile(t,JSON.stringify(r,null,2),"utf-8")}catch(i){console.warn(`Failed to write to cache to ${t}: ${i}`)}return r}catch(o){if(o instanceof Error){if(o.message.includes("Rate limit")||o.message.includes("not found")||o.message.includes("server error")||o.message.includes("HTTP"))throw o;const r=`Failed to download prompts for version ${e}: ${o.message}`;throw new Error(r)}throw o}}const wt="modulepreload",xt=function(e){return"/"+e},xn={},yt=function(t,n,o){let r=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const a=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),u=l?.nonce||l?.getAttribute("nonce");r=d(n.map(h=>{if(h=xt(h,o),h in xn)return;xn[h]=!0;const f=h.endsWith(".css"),v=f?'[rel="stylesheet"]':"";if(!!o)for(let w=a.length-1;w>=0;w--){const x=a[w];if(x.href===h&&(!f||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${v}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":wt,f||(p.as="script"),p.crossOrigin="",p.href=h,u&&p.setAttribute("nonce",u),document.head.appendChild(p),f)return new Promise((w,x)=>{p.addEventListener("load",w),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return r.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},On=oe.join(de,"systemPromptOriginalHashes.json"),An=oe.join(de,"systemPromptAppliedHashes.json"),Pn=(e,t)=>`${e}-${t}`,Ye=e=>Bn.createHash("md5").update(e.trim(),"utf8").digest("hex"),Ln=async()=>{try{const e=await te.readFile(On,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},St=async e=>{await te.mkdir(de,{recursive:!0});const t={},n=Object.keys(e).sort();for(const o of n)t[o]=e[o];await te.writeFile(On,JSON.stringify(t,null,2),"utf8")},vt=async e=>{const t=await Ln();let n=0;for(const o of e.prompts){const r=Pn(o.id,o.version);if(!t[r]){const i=Re(o.pieces,o.identifiers,o.identifierMap),a=Ye(i);t[r]=a,n++}}return await St(t),n},$t=async(e,t)=>{const n=await Ln(),o=Pn(e,t);return n[o]},on=async()=>{try{const e=await te.readFile(An,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},Dn=async e=>{await te.mkdir(de,{recursive:!0});const t={},n=Object.keys(e).sort();for(const o of n)t[o]=e[o];await te.writeFile(An,JSON.stringify(t,null,2),"utf8")},_t=async(e,t)=>{const n=await on();n[e]=t,await Dn(n)},It=async()=>{const e=await on(),t={};for(const n of Object.keys(e))t[n]=null;await Dn(t)},Ct=async e=>{try{const t=await on();if(Object.keys(t).length===0)return!1;const o=(await te.readdir(e)).filter(r=>r.endsWith(".md"));for(const r of o){const i=r.replace(".md",""),a=t[i];if(a===void 0||a===null)continue;const l=oe.join(e,r),u=await te.readFile(l,"utf8"),h=(await yt(()=>import("gray-matter"),[])).default(u,{delimiters:["<!--","-->"]});if(Ye(h.content)!==a)return!0}return!1}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}},Rn=e=>{const t=He(e,{delimiters:["<!--","-->"]}),{name:n,description:o,ccVersion:r,variables:i}=t.data;return{name:n||"",description:o||"",ccVersion:r||"",variables:i||[],content:t.content.trim()}},yn=(e,t)=>{const n=t||Re(e.pieces,e.identifiers,e.identifierMap),o=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,r={name:e.name,description:e.description,ccVersion:e.version};return o&&o.length>0&&(r.variables=o),He.stringify(n,r,{delimiters:["<!--","-->"]})},Re=(e,t,n)=>{let o="";for(let r=0;r<e.length;r++)if(o+=e[r],r<t.length){const i=t[r],a=n[String(i)]||`UNKNOWN_${i}`;o+=a}return o},Et=(e,t)=>{const n=e.split(".").map(Number),o=t.split(".").map(Number);for(let r=0;r<Math.max(n.length,o.length);r++){const i=n[r]||0,a=o[r]||0;if(i<a)return-1;if(i>a)return 1}return 0},Fe=e=>oe.join(Se,`${e}.md`),kt=async e=>{try{return await te.access(Fe(e)),!0}catch{return!1}},Tt=async e=>{const t=Fe(e),n=await te.readFile(t,"utf-8");return Rn(n)},en=async(e,t)=>{const n=Fe(e);await te.writeFile(n,t,"utf-8")},Mt=async(e,t)=>{const n=Fe(e),o=await te.readFile(n,"utf-8"),r=He(o,{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);const l=He.stringify(r.content,a,{delimiters:["<!--","-->"]});await en(e,l)},Nt=(e,t)=>{const n=w=>w.split(/(\s+)/),o=n(e),r=n(t),i=o.length,a=r.length,l=Array(i+1).fill(0).map(()=>Array(a+1).fill(0));for(let w=1;w<=i;w++)for(let x=1;x<=a;x++)o[w-1]===r[x-1]?l[w][x]=l[w-1][x-1]+1:l[w][x]=Math.max(l[w-1][x],l[w][x-1]);const u=Array(i).fill(!1),d=Array(a).fill(!1);let h=i,f=a;for(;h>0||f>0;)h>0&&f>0&&o[h-1]===r[f-1]?(h--,f--):f>0&&(h===0||l[h][f-1]>=l[h-1][f])?(d[f-1]=!0,f--):h>0&&(u[h-1]=!0,h--);const v=w=>w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");let b="";for(let w=0;w<o.length;w++){const x=v(o[w]);b+=u[w]?`<mark>${x}</mark>`:x}let p="";for(let w=0;w<r.length;w++){const x=v(r[w]);p+=d[w]?`<mark>${x}</mark>`:x}return{oldHtml:b,newHtml:p}},Sn=(e,t)=>{const n=e.length,o=t.length,r=Array(n+1).fill(0).map(()=>Array(o+1).fill(0));for(let d=1;d<=n;d++)for(let h=1;h<=o;h++)e[d-1]===t[h-1]?r[d][h]=r[d-1][h-1]+1:r[d][h]=Math.max(r[d-1][h],r[d][h-1]);const i=[];let a=n,l=o;const u=[];for(;a>0||l>0;)a>0&&l>0&&e[a-1]===t[l-1]?(u.unshift({type:"unchanged",line:e[a-1],oldLineNo:a,newLineNo:l}),a--,l--):l>0&&(a===0||r[a][l-1]>=r[a-1][l])?(u.unshift({type:"added",line:t[l-1],newLineNo:l}),l--):a>0&&(u.unshift({type:"removed",line:e[a-1],oldLineNo:a}),a--);for(let d=0;d<u.length;d++){const h=u[d],f=u[d+1];if(h.type==="removed"&&f?.type==="added"){const v=Nt(h.line,f.line);i.push({type:"modified",line:h.line,oldLineNo:h.oldLineNo,newLineNo:f.newLineNo,oldHtml:v.oldHtml,newHtml:v.newHtml}),d++}else i.push(h)}return i},Bt=async(e,t,n,o,r,i,a,l)=>{const u=n.split(`
3
+ `),d=o.split(`
4
+ `),h=r.split(`
5
+ `),f=_=>_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),v=Sn(u,d),b=Sn(u,h);let p="";for(const _ of v){const k=f(_.line);if(_.type==="modified"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",B=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${_.oldHtml}</div>
6
+ `,p+=`<div class="line added"><span class="line-num">${B}</span><span class="prefix">+ </span>${_.newHtml}</div>
7
7
  `}else if(_.type==="removed"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${k}</div>
8
8
  `}else if(_.type==="added"){const P=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line added"><span class="line-num">${P}</span><span class="prefix">+ </span>${k}</div>
9
- `}else{const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",O=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line unchanged"><span class="line-num">${P} ${O}</span><span class="prefix"> </span>${k}</div>
10
- `}}let w="";for(const _ of b){const k=f(_.line);if(_.type==="modified"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",O=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";w+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${_.oldHtml}</div>
11
- `,w+=`<div class="line added"><span class="line-num">${O}</span><span class="prefix">+ </span>${_.newHtml}</div>
9
+ `}else{const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",B=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line unchanged"><span class="line-num">${P} ${B}</span><span class="prefix"> </span>${k}</div>
10
+ `}}let w="";for(const _ of b){const k=f(_.line);if(_.type==="modified"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",B=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";w+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${_.oldHtml}</div>
11
+ `,w+=`<div class="line added"><span class="line-num">${B}</span><span class="prefix">+ </span>${_.newHtml}</div>
12
12
  `}else if(_.type==="removed"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ";w+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${k}</div>
13
13
  `}else if(_.type==="added"){const P=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";w+=`<div class="line added"><span class="line-num">${P}</span><span class="prefix">+ </span>${k}</div>
14
- `}else{const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",O=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";w+=`<div class="line unchanged"><span class="line-num">${P} ${O}</span><span class="prefix"> </span>${k}</div>
14
+ `}else{const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",B=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";w+=`<div class="line unchanged"><span class="line-num">${P} ${B}</span><span class="prefix"> </span>${k}</div>
15
15
  `}}const x=`<!DOCTYPE html>
16
16
  <html>
17
17
  <head>
@@ -146,17 +146,17 @@ import{Box as m,Text as c,render as ot,useInput as de}from"ink";import{Command a
146
146
  <h1>${f(t)}</h1>
147
147
  <div class="version-info">
148
148
  <strong>Old Version:</strong> ${f(i)} →
149
- <strong>New Version:</strong> ${f(l)}
149
+ <strong>New Version:</strong> ${f(a)}
150
150
  </div>
151
151
  </div>
152
152
 
153
153
  <div class="warning">
154
154
  <strong>⚠️ Version Mismatch Warning</strong><br>
155
155
  Your customized prompt file is based on version ${f(i)},
156
- but Claude Code is now using version ${f(l)}.
156
+ but Claude Code is now using version ${f(a)}.
157
157
  Review the differences below to understand both your customizations and the upstream changes.<br><br>
158
- <strong>File:</strong> <code>${f(a)}</code><br><br>
159
- When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${f(l)}</strong>.
158
+ <strong>File:</strong> <code>${f(l)}</code><br><br>
159
+ When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${f(a)}</strong>.
160
160
  </div>
161
161
 
162
162
  <div class="diff-panels">
@@ -167,28 +167,28 @@ ${p} </div>
167
167
  </div>
168
168
 
169
169
  <div class="diff-container">
170
- <div class="diff-header">Upstream Changes (v${f(i)} → v${f(l)})</div>
170
+ <div class="diff-header">Upstream Changes (v${f(i)} → v${f(a)})</div>
171
171
  <div class="diff-content">
172
172
  ${w} </div>
173
173
  </div>
174
174
  </div>
175
175
  </body>
176
- </html>`,C=re.join(Se,`${e}.diff.html`);return await te.writeFile(C,x,"utf-8"),C},Nt=async e=>{const t={id:e.id,name:e.name,description:e.description,action:"skipped",newVersion:e.version};if(!await Ct(e.id)){const o=xn(e);return await Qe(e.id,o),t.action="created",t}const r=await Et(e.id);if(t.oldVersion=r.ccVersion,await kt(e.id,e.identifierMap),r.ccVersion&&e.version){const o=It(r.ccVersion,e.version);if(o===0)return t.action="skipped",t;if(o!=0){const i=await St(e.id,r.ccVersion),l=Ye(r.content);if(!i||i!==l){t.action="conflict";let u=r.content;try{const b=(await nn(r.ccVersion)).prompts.find(p=>p.id===e.id);b&&(u=Re(b.pieces,b.identifiers,b.identifierMap))}catch{console.log(Q.yellow(`Warning: Could not fetch old version ${r.ccVersion} for comparison. Using current file as baseline.`))}const d=Re(e.pieces,e.identifiers,e.identifierMap),g=Fe(e.id),f=await Bt(e.id,e.name,u,r.content,d,r.ccVersion,e.version,g);t.diffHtmlPath=f}else{const u=xn(e);await Qe(e.id,u),t.action="updated"}}}return t},Ot=async e=>{const t={ccVersion:e,results:[]},n=await nn(e);await yt(n),await te.mkdir(Se,{recursive:!0});for(const r of n.prompts)try{const o=await Nt(r);t.results.push(o)}catch(o){throw console.log(Q.red(`Failed to sync prompt ${r.id}:`)),o}return t};let Ge=null,en=null;const Sn=async e=>{try{return Ge=await nn(e),en=e,{success:!0}}catch(t){return Ge=null,en=null,t instanceof Error?{success:!1,errorMessage:t.message}:{success:!1,errorMessage:"Unknown error occurred while downloading system prompts"}}},Tt=e=>e.replace(/[^\x00-\x7F]/g,t=>{const r=`\\\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${r})`}),At=e=>e.replace(/[^\x00-\x7F]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Pt=(e,t)=>{let n="";for(let r=0;r<e.length;r++){const i=e[r].replace(/<<CCVERSION>>/g,t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=Tt(i);n+=l,r<e.length-1&&(n+="([\\w$]+)")}return n},Lt=(e,t,n,r,o,i=!1)=>{const l={};for(let d=0;d<r.length;d++){const g=r[d],f=String(t[d]),v=n[f];v&&(l[v]=g)}let a=e;const u=Object.entries(l).sort((d,g)=>g[0].length-d[0].length);for(const[d,g]of u){const f=new RegExp(`\\b${d}\\b`,"g");a=a.replace(f,g)}return a=a.replace(/<<CCVERSION>>/g,o),i&&(a=At(a)),a},Dt=async(e,t=!1)=>{if(!Ge||en!==e)return[];const n=Ge,r=[];for(const o of n.prompts){const i=Pt(o.pieces,e),l=re.join(Se,`${o.id}.md`);let a;try{a=await te.readFile(l,"utf8")}catch(g){console.error(`Failed to read markdown file ${l}:`,g);continue}const u=Ln(a),d=g=>{const f=g.slice(1);return Lt(u.content,o.identifiers,o.identifierMap,f,e,t)};r.push({promptId:o.id,prompt:u,regex:i,getInterpolatedContent:d,pieces:o.pieces,identifiers:o.identifiers,identifierMap:o.identifierMap})}return r},Rt=e=>{const t=e.results.filter(i=>i.action==="created"),n=e.results.filter(i=>i.action==="updated"),r=e.results.filter(i=>i.action==="conflict"),o=e.results.filter(i=>i.action==="skipped");if((t.length>0||n.length>0||r.length>0)&&o.length>0&&(console.log(Q.dim(`Skipped ${o.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(Q.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(Q.green(` ${Se}/${i.id}.md`)),console.log(Q.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(Q.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(Q.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(Q.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(r.length>0){console.log(Q.bold.yellow(`WARNING: Conflicts detected for ${r.length} system prompt file(s)`));for(const i of r)console.log(Q.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(Q.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(Q.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(Q.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(Q.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(Q.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const i of r)console.log(Q.yellow(` ${i.id}.md → `)+Q.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},se=Buffer.from(`
176
+ </html>`,C=oe.join(Se,`${e}.diff.html`);return await te.writeFile(C,x,"utf-8"),C},Ot=async e=>{const t={id:e.id,name:e.name,description:e.description,action:"skipped",newVersion:e.version};if(!await kt(e.id)){const r=yn(e);return await en(e.id,r),t.action="created",t}const o=await Tt(e.id);if(t.oldVersion=o.ccVersion,await Mt(e.id,e.identifierMap),o.ccVersion&&e.version){const r=Et(o.ccVersion,e.version);if(r===0)return t.action="skipped",t;if(r!=0){const i=await $t(e.id,o.ccVersion),a=Ye(o.content);if(!i||i!==a){t.action="conflict";let u=o.content;try{const b=(await tn(o.ccVersion)).prompts.find(p=>p.id===e.id);b&&(u=Re(b.pieces,b.identifiers,b.identifierMap))}catch{console.log(Q.yellow(`Warning: Could not fetch old version ${o.ccVersion} for comparison. Using current file as baseline.`))}const d=Re(e.pieces,e.identifiers,e.identifierMap),h=Fe(e.id),f=await Bt(e.id,e.name,u,o.content,d,o.ccVersion,e.version,h);t.diffHtmlPath=f}else{const u=yn(e);await en(e.id,u),t.action="updated"}}}return t},At=async e=>{const t={ccVersion:e,results:[]},n=await tn(e);await vt(n),await te.mkdir(Se,{recursive:!0});for(const o of n.prompts)try{const r=await Ot(o);t.results.push(r)}catch(r){throw console.log(Q.red(`Failed to sync prompt ${o.id}:`)),r}return t};let Ge=null,nn=null;const vn=async e=>{try{return Ge=await tn(e),nn=e,{success:!0}}catch(t){return Ge=null,nn=null,t instanceof Error?{success:!1,errorMessage:t.message}:{success:!1,errorMessage:"Unknown error occurred while downloading system prompts"}}},Pt=e=>e.replace(/[^\x00-\x7F]/g,t=>{const o=`\\\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${o})`}),Lt=e=>e.replace(/[^\x00-\x7F]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Dt=(e,t)=>{let n="";for(let o=0;o<e.length;o++){const i=e[o].replace(/<<CCVERSION>>/g,t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=Pt(i);n+=a,o<e.length-1&&(n+="([\\w$]+)")}return n},Rt=(e,t,n,o,r,i=!1)=>{const a={};for(let d=0;d<o.length;d++){const h=o[d],f=String(t[d]),v=n[f];v&&(a[v]=h)}let l=e;const u=Object.entries(a).sort((d,h)=>h[0].length-d[0].length);for(const[d,h]of u){const f=new RegExp(`\\b${d}\\b`,"g");l=l.replace(f,h)}return l=l.replace(/<<CCVERSION>>/g,r),i&&(l=Lt(l)),l},Ft=async(e,t=!1)=>{if(!Ge||nn!==e)return[];const n=Ge,o=[];for(const r of n.prompts){const i=Dt(r.pieces,e),a=oe.join(Se,`${r.id}.md`);let l;try{l=await te.readFile(a,"utf8")}catch(h){console.error(`Failed to read markdown file ${a}:`,h);continue}const u=Rn(l),d=h=>{const f=h.slice(1);return Rt(u.content,r.identifiers,r.identifierMap,f,e,t)};o.push({promptId:r.id,prompt:u,regex:i,getInterpolatedContent:d,pieces:r.pieces,identifiers:r.identifiers,identifierMap:r.identifierMap})}return o},Vt=e=>{const t=e.results.filter(i=>i.action==="created"),n=e.results.filter(i=>i.action==="updated"),o=e.results.filter(i=>i.action==="conflict"),r=e.results.filter(i=>i.action==="skipped");if((t.length>0||n.length>0||o.length>0)&&r.length>0&&(console.log(Q.dim(`Skipped ${r.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(Q.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(Q.green(` ${Se}/${i.id}.md`)),console.log(Q.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(Q.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(Q.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(Q.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(o.length>0){console.log(Q.bold.yellow(`WARNING: Conflicts detected for ${o.length} system prompt file(s)`));for(const i of o)console.log(Q.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(Q.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(Q.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(Q.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(Q.green('Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts')),console.log()),o.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(Q.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const i of o)console.log(Q.yellow(` ${i.id}.md → `)+Q.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},le=Buffer.from(`
177
177
  ---- Bun! ----
178
- `),Ie=32,Ft=8,ze=4*Ft+4;function ve(e,t){return e.subarray(t.offset,t.offset+t.length)}function Me(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function Dn(e){return e.endsWith("/claude")||e==="claude"||e.endsWith("/claude.exe")||e==="claude.exe"}function Rn(e,t,n){const r=ve(e,t.modulesPtr),o=Math.floor(r.length/ze);for(let i=0;i<o;i++){const l=i*ze,a=Vt(r,l),u=ve(e,a.name).toString("utf-8"),d=n(a,u,i);if(d!==void 0)return d}}function Fn(e){let t=0;const n=e.readBigUInt64LE(t);t+=8;const r=Me(e,t);t+=8;const o=e.readUInt32LE(t);t+=4;const i=Me(e,t);return{byteCount:n,modulesPtr:r,entryPointId:o,compileExecArgvPtr:i}}function Vt(e,t){let n=t;const r=Me(e,n);n+=8;const o=Me(e,n);n+=8;const i=Me(e,n);n+=8;const l=Me(e,n);n+=8;const a=e.readUInt8(n);n+=1;const u=e.readUInt8(n);n+=1;const d=e.readUInt8(n);n+=1;const g=e.readUInt8(n);return{name:r,contents:o,sourcemap:i,bytecode:l,encoding:a,loader:u,moduleFormat:d,side:g}}function Ut(e){if(e.length<Ie+se.length)throw new Error("BUN data is too small to contain trailer and offsets");const t=e.length-se.length,n=e.subarray(t);if(M()&&(console.log(`parseBunDataBlob: Expected trailer: ${se.toString("hex")}`),console.log(`parseBunDataBlob: Got trailer: ${n.toString("hex")}`)),!n.equals(se))throw M()&&(console.log(`Expected: ${se.toString("hex")}`),console.log(`Got: ${n.toString("hex")}`)),new Error("BUN trailer bytes do not match trailer");const r=e.length-Ie-se.length,o=e.subarray(r,r+Ie);return{bunOffsets:Fn(o),bunData:e}}function Vn(e){if(e.length<4)throw new Error("Section data too small");M()&&console.log(`extractBunDataFromSection: sectionData.length=${e.length}`);const t=e.readUInt32LE(0);M()&&console.log(`extractBunDataFromSection: bunDataSize from header=${t}`);const n=e.subarray(4,4+t);M()&&console.log(`extractBunDataFromSection: bunDataContent.length=${n.length}`);const{bunOffsets:r,bunData:o}=Ut(n);return{bunOffsets:r,bunData:o}}function jt(e){if(!e.hasOverlay)throw new Error("ELF binary has no overlay data");const t=e.overlay;if(M()&&console.log(`extractBunDataFromELFOverlay: Overlay size=${t.length} bytes`),t.length<se.length+8+Ie)throw new Error("ELF overlay data is too small");const n=t.readBigUInt64LE(t.length-8);if(M()&&console.log(`extractBunDataFromELFOverlay: Total byte count from tail=${n}`),n<4096n||n>2n**32n-1n)throw new Error(`ELF total byte count is out of range: ${n}`);const r=t.length-8-se.length,o=t.subarray(r,t.length-8);if(M()&&(console.log(`extractBunDataFromELFOverlay: Expected trailer: ${se.toString("hex")}`),console.log(`extractBunDataFromELFOverlay: Got trailer: ${o.toString("hex")}`)),!o.equals(se))throw new Error("BUN trailer bytes do not match trailer");const i=t.length-8-se.length-Ie,l=t.subarray(i,t.length-8-se.length),a=Fn(l);M()&&console.log(`extractBunDataFromELFOverlay: Offsets.byteCount=${a.byteCount}`);const u=typeof a.byteCount=="bigint"?a.byteCount:BigInt(a.byteCount);if(u>=n)throw new Error("ELF total byte count is out of range");const d=8+se.length+Ie,g=t.length-d-Number(u),f=t.subarray(g,t.length-d);M()&&console.log(`extractBunDataFromELFOverlay: Extracted ${f.length} bytes of data`);const v=Buffer.concat([f,l,o]);return{bunOffsets:a,bunData:v}}function Ht(e){const t=e.getSegment("__BUN");if(!t)throw new Error("__BUN segment not found");const n=t.getSection("__bun");if(!n)throw new Error("__bun section not found");return Vn(n.content)}function Gt(e){const t=e.sections().find(n=>n.name===".bun");if(!t)throw new Error(".bun section not found");return Vn(t.content)}function Un(e){switch(M()&&console.log(`getBunData: Binary format detected as ${e.format}`),e.format){case"MachO":return Ht(e);case"PE":return Gt(e);case"ELF":return jt(e);default:throw new Error(`Unsupported binary format: ${e.format}`)}}function jn(e){try{De.logging.disable();const t=De.parse(e),{bunOffsets:n,bunData:r}=Un(t);M()&&console.log(`extractClaudeJsFromNativeInstallation: Got bunData, size=${r.length} bytes`);const o=Rn(r,n,(i,l,a)=>{if(M()&&console.log(`extractClaudeJsFromNativeInstallation: Module ${a}: ${l}`),!Dn(l))return;const u=ve(r,i.contents);return M()&&console.log(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${u.length}`),u.length>0?u:void 0});return o||(M()&&console.log("extractClaudeJsFromNativeInstallation: claude module not found in any module"),null)}catch(t){return M()&&console.log("extractClaudeJsFromNativeInstallation: Error during extraction:",t),null}}function zt(e,t,n){const r=[],o=[];Rn(e,t,(k,P)=>{const O=ve(e,k.name);let V;n&&Dn(P)?V=n:V=ve(e,k.contents);const K=ve(e,k.sourcemap),U=ve(e,k.bytecode);o.push({name:O,contents:V,sourcemap:K,bytecode:U,encoding:k.encoding,loader:k.loader,moduleFormat:k.moduleFormat,side:k.side}),r.push(O,V,K,U)});let i=0;const l=[];for(const k of r)l.push({offset:i,length:k.length}),i+=k.length+1;const a=i,u=o.length*ze;i+=u;const d=ve(e,t.compileExecArgvPtr),g=i,f=d.length;i+=f+1;const v=i;i+=Ie;const b=i;i+=se.length;const p=Buffer.allocUnsafe(i);p.fill(0);let w=0;for(const{offset:k,length:P}of l)P>0&&r[w].copy(p,k,0,P),p[k+P]=0,w++;f>0&&(d.copy(p,g,0,f),p[g+f]=0);for(let k=0;k<o.length;k++){const P=o[k],O=k*4,V={name:{offset:l[O].offset,length:l[O].length},contents:{offset:l[O+1].offset,length:l[O+1].length},sourcemap:{offset:l[O+2].offset,length:l[O+2].length},bytecode:{offset:l[O+3].offset,length:l[O+3].length},encoding:P.encoding,loader:P.loader,moduleFormat:P.moduleFormat,side:P.side};let U=a+k*ze;p.writeUInt32LE(V.name.offset,U),p.writeUInt32LE(V.name.length,U+4),U+=8,p.writeUInt32LE(V.contents.offset,U),p.writeUInt32LE(V.contents.length,U+4),U+=8,p.writeUInt32LE(V.sourcemap.offset,U),p.writeUInt32LE(V.sourcemap.length,U+4),U+=8,p.writeUInt32LE(V.bytecode.offset,U),p.writeUInt32LE(V.bytecode.length,U+4),U+=8,p.writeUInt8(V.encoding,U),p.writeUInt8(V.loader,U+1),p.writeUInt8(V.moduleFormat,U+2),p.writeUInt8(V.side,U+3)}const x={byteCount:v,modulesPtr:{offset:a,length:u},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:g,length:f}};let C=v;const _=typeof x.byteCount=="bigint"?x.byteCount:BigInt(x.byteCount);return p.writeBigUInt64LE(_,C),C+=8,p.writeUInt32LE(x.modulesPtr.offset,C),p.writeUInt32LE(x.modulesPtr.length,C+4),C+=8,p.writeUInt32LE(x.entryPointId,C),C+=4,p.writeUInt32LE(x.compileExecArgvPtr.offset,C),p.writeUInt32LE(x.compileExecArgvPtr.length,C+4),se.copy(p,b),p}function rn(e,t,n,r=!0){const o=t+".tmp";if(e.write(o),r){const i=Ae.statSync(n);Ae.chmodSync(o,i.mode)}try{Ae.renameSync(o,t)}catch(i){try{Ae.existsSync(o)&&Ae.unlinkSync(o)}catch{}throw i instanceof Error&&"code"in i&&(i.code==="ETXTBSY"||i.code==="EBUSY"||i.code==="EPERM")?new Error(`Cannot update the Claude executable while it is running.
179
- Please close all Claude instances and try again.`):i}}function Hn(e){const t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function Yt(e,t,n,r){try{M()&&console.log(`repackMachO: Has code signature: ${e.hasCodeSignature}`),e.hasCodeSignature&&(M()&&console.log("repackMachO: Removing code signature..."),e.removeSignature());const o=e.getSegment("__BUN");if(!o)throw new Error("__BUN segment not found");const i=o.getSection("__bun");if(!i)throw new Error("__bun section not found");const l=Hn(n);M()&&(console.log(`repackMachO: Original section size: ${i.size}`),console.log(`repackMachO: Original segment fileSize: ${o.fileSize}`),console.log(`repackMachO: Original segment virtualSize: ${o.virtualSize}`),console.log(`repackMachO: New data size: ${l.length}`));const a=l.length-Number(i.size);if(a>0){const u=e.header.cpuType===De.MachO.Header.CPU_TYPE.ARM64,d=u?16384:4096,g=Math.ceil(a/d)*d;M()&&(console.log(`repackMachO: CPU type: ${u?"ARM64":"x86_64"}`),console.log(`repackMachO: Page size: ${d} bytes`),console.log(`repackMachO: Need to expand by ${a} bytes`),console.log(`repackMachO: Rounding up to page-aligned: ${g} bytes`));const f=e.extendSegment(o,g);if(M()&&console.log(`repackMachO: extendSegment returned: ${f}`),!f)throw new Error("Failed to extend __BUN segment");M()&&(console.log(`repackMachO: Section size after extend: ${i.size}`),console.log(`repackMachO: Segment fileSize after extend: ${o.fileSize}`),console.log(`repackMachO: Segment virtualSize after extend: ${o.virtualSize}`))}i.content=l,i.size=BigInt(l.length),M()&&(console.log(`repackMachO: Final section size: ${i.size}`),console.log(`repackMachO: Writing modified binary to ${r}...`)),rn(e,r,t);try{M()&&console.log("repackMachO: Re-signing binary with ad-hoc signature..."),Mn(`codesign -s - -f "${r}"`,{stdio:M()?"inherit":"ignore"}),M()&&console.log("repackMachO: Code signing completed successfully")}catch(u){console.warn("Warning: Failed to re-sign binary. The binary may not run correctly on macOS:",u)}M()&&console.log("repackMachO: Write completed successfully")}catch(o){throw console.error("repackMachO failed:",o),o}}function Wt(e,t,n,r){try{const o=e.sections().find(l=>l.name===".bun");if(!o)throw new Error(".bun section not found");const i=Hn(n);M()&&(console.log(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),console.log(`repackPE: New data size: ${i.length}`)),o.content=i,o.virtualSize=BigInt(i.length),o.size=BigInt(i.length),M()&&console.log(`repackPE: Writing modified binary to ${r}...`),rn(e,r,t,!1),M()&&console.log("repackPE: Write completed successfully")}catch(o){throw console.error("repackPE failed:",o),o}}function Jt(e,t,n,r){try{const o=Buffer.allocUnsafe(n.length+8);n.copy(o,0),o.writeBigUInt64LE(BigInt(n.length),n.length),M()&&console.log(`repackELF: Setting overlay data (${o.length} bytes)`),e.overlay=o,M()&&console.log(`repackELF: Writing modified binary to ${r}...`),rn(e,r,t),M()&&console.log("repackELF: Write completed successfully")}catch(o){throw console.error("repackELF failed:",o),o}}function Kt(e,t,n){De.logging.disable();const r=De.parse(e),{bunOffsets:o,bunData:i}=Un(r),l=zt(i,o,t);switch(r.format){case"MachO":Yt(r,e,l,n);break;case"PE":Wt(r,e,l,n);break;case"ELF":Jt(r,e,l,n);break;default:throw new Error(`Unsupported binary format: ${r.format}`)}}const on=async()=>{await le.mkdir(ce,{recursive:!0}),await le.mkdir(Se,{recursive:!0});const e=kn.join(ce,".gitignore");try{await le.stat(e)}catch(t){t instanceof Error&&"code"in t&&t.code==="ENOENT"&&await le.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"].join(fn)+fn)}};let Le={settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null};const sn=async()=>{const e={ccVersion:"",ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:Z};try{M()&&console.log(`Reading config at ${fe}`);const t=await le.readFile(fe,"utf8"),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format="{}"+r.punctuation,delete r.punctuation),n.settings.inputBox||(n.settings.inputBox=Z.inputBox),n.settings.toolsets||(n.settings.toolsets=Z.toolsets),Object.hasOwn(n.settings,"defaultToolset")||(n.settings.defaultToolset=Z.defaultToolset);for(const i of Z.themes){const l=n?.settings?.themes.find(a=>a.id===i.id||a.name===i.name);if(l){for(const[a,u]of Object.entries(i))a!=="colors"&&!Object.hasOwn(l,a)&&(l[a]=u);l.colors||(l.colors={});for(const[a,u]of Object.entries(i.colors))Object.hasOwn(l.colors,a)||(l.colors[a]=u)}}for(const i of n?.settings?.themes||[]){if(Z.themes.some(u=>u.id===i.id||u.name===i.name))continue;const a=Z.themes[0];i.colors||(i.colors={});for(const[u,d]of Object.entries(a.colors))Object.hasOwn(i.colors,u)||(i.colors[u]=d)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||Z,n.settings.userMessageDisplay=Z.userMessageDisplay),delete n.settings.launchText,await _t(Se)&&(n.changesApplied=!1),Le=n,n}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return e;throw t}},Ve=async e=>(M()&&console.log(`Updating config at ${fe}`),e(Le),Le.lastModified=new Date().toISOString(),await qt(Le),Le),qt=async e=>{try{e.lastModified=new Date().toISOString(),await on(),await le.writeFile(fe,JSON.stringify(e,null,2))}catch(t){throw console.error("Error saving config:",t),t}},Gn=async e=>{if(!e.cliPath)return M()&&console.log("restoreClijsFromBackup: Skipping for native installation (no cliPath)"),!1;M()&&console.log(`Restoring cli.js from backup to ${e.cliPath}`);const t=await le.readFile(Ne);return await un(e.cliPath,t,"restore"),await $t(),await Ve(n=>{n.changesApplied=!1}),!0},Xt=async e=>{if(!e.nativeInstallationPath)return M()&&console.log("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await Ce(ae))return M()&&console.log("restoreNativeBinaryFromBackup: No backup file exists, skipping"),!1;M()&&console.log(`Restoring native binary from backup to ${e.nativeInstallationPath}`);const t=await le.readFile(ae);return await un(e.nativeInstallationPath,t,"restore"),!0};async function Zt(){try{const t=process.platform==="win32"?"where claude.exe":"which claude";M()&&console.log(`Looking for claude executable using: ${t}`);const r=Mn(t,{encoding:"utf8"}).trim().split(`
180
- `)[0].trim();if(r&&await Ce(r))try{const o=await le.realpath(r);return M()&&(o!==r?(console.log(`Found claude executable at: ${r} (symlink)`),console.log(`Resolved to: ${o}`)):console.log(`Found claude executable at: ${r}`)),o}catch(o){return M()&&console.log("Could not resolve symlink, using original path:",o),r}}catch(e){M()&&console.log("Could not find claude executable on PATH:",e)}return null}function zn(e){const t=/\bVERSION:"(\d+\.\d+\.\d+)"/g,n=new Map;let r;for(;(r=t.exec(e))!==null;){const l=r[1];n.set(l,(n.get(l)||0)+1)}if(n.size===0)return null;let o=0,i;for(const[l,a]of n.entries())M()&&console.log(`Found version ${l} with ${a} occurrences`),a>o&&(o=a,i=l);return M()&&i&&console.log(`Extracted version ${i} (${o} occurrences)`),i||null}async function Ce(e){try{return await le.stat(e),!0}catch(t){if(t instanceof Error&&"code"in t&&(t.code==="ENOENT"||t.code==="ENOTDIR"))return!1;throw t}}async function Qt(e){const t=await le.readFile(e,"utf8"),n=zn(t);if(!n)throw new Error(`No VERSION strings found in JS file: ${e}`);return n}const er=async e=>{e.ccInstallationDir&&pn.unshift(e.ccInstallationDir);for(const n of pn)try{M()&&console.log(`Searching for Claude Code cli.js file at ${n}`);const r=kn.join(n,"cli.js");if(!await Ce(r))continue;M()&&(console.log(`Found Claude Code cli.js file at ${n}; checking hash...`),console.log(`SHA256 hash: ${await ao(r)}`));const o=await Qt(r);return{cliPath:r,version:o}}catch(r){if(r instanceof Error&&"code"in r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))continue;throw r}M()&&console.log("Could not find cli.js in standard locations, trying native installation method...");const t=await Zt();if(M()&&console.log(`findClaudeExecutableOnPath() returned: ${t}`),t){const n=await Ce(ae),r=n?ae:t;M()&&console.log(`Attempting to extract claude.js from ${n?"backup":"native installation"}: ${r}`);const o=jn(r);if(o){const i=o.toString("utf8"),l=zn(i);return l?(M()&&console.log(`Extracted version ${l} from native installation`),{version:l,nativeInstallationPath:t}):(M()&&console.log("Failed to extract version from native installation"),null)}}return null},vn=async e=>{if(!e.cliPath){M()&&console.log("backupClijs: Skipping for native installation (no cliPath)");return}await on(),M()&&console.log(`Backing up cli.js to ${Ne}`),await le.copyFile(e.cliPath,Ne),await Ve(t=>{t.changesApplied=!1,t.ccVersion=e.version})},$n=async e=>{e.nativeInstallationPath&&(await on(),M()&&console.log(`Backing up native binary to ${ae}`),await le.copyFile(e.nativeInstallationPath,ae),await Ve(t=>{t.changesApplied=!1,t.ccVersion=e.version}))};async function _n(){const e=await sn(),t=await er(e);if(!t)return null;if(t.version)try{const l=await Ot(t.version);Rt(l)}catch{}const n=t.version,r=e.ccVersion;let o=!1;await Ce(Ne)||(M()&&console.log(`startupCheck: ${Ne} not found; backing up cli.js`),await vn(t),o=!0);let i=!1;return t.nativeInstallationPath&&!await Ce(ae)&&(M()&&console.log(`startupCheck: ${ae} not found; backing up native binary`),await $n(t),i=!0),n!==r?(o||(M()&&console.log(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await le.unlink(Ne),await vn(t)),t.nativeInstallationPath&&!i&&(M()&&console.log(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await Ce(ae)&&await le.unlink(ae),await $n(t)),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}}const nr=e=>{const t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g;let r;for(;(r=n.exec(e))!==null;){const o=r.index+r[0].indexOf("=")+1;t.push({startIndex:o,endIndex:o+r[1].length})}return t},tr=(e,t)=>{const n=nr(e);if(n.length===0)return console.error("patch: writeShowMoreItemsInSelectMenus: failed to find locations"),null;const r=n.sort((i,l)=>l.startIndex-i.startIndex);let o=e;for(const i of r){const l=t.toString(),a=o.slice(0,i.startIndex)+l+o.slice(i.endIndex);G(o,a,l,i.startIndex,i.endIndex),o=a}return o};function rr(e){const t=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,n=e.match(t);if(!n||n.index==null)return console.error("patch: themes: failed to find switchMatch"),null;const r=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,o=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(r),l=e.match(o);return!i||i.index==null?(console.error("patch: themes: failed to find objArrMatch"),null):!l||l.index==null?(console.error("patch: themes: failed to find objMatch"),null):{switchStatement:{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:l.index,endIndex:l.index+l[0].length}}}const or=(e,t)=>{const n=rr(e);if(!n)return null;if(t.length===0)return e;let r=e;const o="return"+JSON.stringify(Object.fromEntries(t.map(a=>[a.id,a.name])));r=r.slice(0,n.obj.startIndex)+o+r.slice(n.obj.endIndex),G(e,r,o,n.obj.startIndex,n.obj.endIndex),e=r;const i=JSON.stringify(t.map(a=>({label:a.name,value:a.id})));r=r.slice(0,n.objArr.startIndex)+i+r.slice(n.objArr.endIndex),G(e,r,i,n.objArr.startIndex,n.objArr.endIndex),e=r;let l=`switch(${n.switchStatement.identifiers?.[0]}){
181
- `;return t.forEach(a=>{l+=`case"${a.id}":return${JSON.stringify(a.colors)};
182
- `}),l+=`default:return${JSON.stringify(t[0].colors)};
183
- }`,r=r.slice(0,n.switchStatement.startIndex)+l+r.slice(n.switchStatement.endIndex),G(e,r,l,n.switchStatement.startIndex,n.switchStatement.endIndex),r},ir=e=>{const t=/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/,n=e.match(t);return!n||n.index===void 0?(console.error("patch: context limit: failed to find match"),null):n.index+n[0].indexOf("{")+1},sr=e=>{const t=ir(e);if(!t)return null;const 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 G(e,r,n,t,t),r},lr=e=>{const t=e.indexOf('bash:"bashBorder"');if(t===-1)return console.error("patch: input border: failed to find bash pattern"),null;const n=e.slice(t,t+500),r=/borderStyle:"[^"]*"/,o=n.match(r);return!o||o.index===void 0?(console.error("patch: input border: failed to find border style pattern"),null):{startIndex:t+o.index,endIndex:t+o.index+o[0].length}},ar=(e,t)=>{const n=lr(e);if(!n)return null;if(t){const r="borderColor:undefined",o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return G(e,o,r,n.startIndex,n.endIndex),o}else return e},cr=e=>{const t=/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: spinner no-freeze: failed to find wholeMatch"),null;const r=/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/,o=n[0].match(r);if(!o||o.index===void 0)return console.error("patch: spinner no-freeze: failed to find freeze condition"),null;const i=n.index+o.index,l=i+o[0].length;return{startIndex:i,endIndex:l}},dr=e=>{const t=cr(e);if(!t)return null;const n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return G(e,n,"",t.startIndex,t.endIndex),n},ur=e=>{const t=/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker format: failed to find approxAreaMatch"),null;const r=e.slice(n.index,n.index+600),o=/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/,i=r.match(o);return!i||i.index==null?(console.error("patch: thinker format: failed to find formatMatch"),null):{startIndex:n.index+i.index+i[1].length,endIndex:n.index+i.index+i[1].length+i[2].length,identifiers:[i[3]]}},gr=(e,t)=>{const n=ur(e);if(!n)return null;const r=n,o=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),i=r.identifiers?.[0],a=`=${"`"+o.replace(/\{\}/g,"${"+i+"}")+"`"}`,u=e.slice(0,r.startIndex)+a+e.slice(r.endIndex);return G(e,u,a,r.startIndex,r.endIndex),u},hr=e=>{const t=/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker symbol mirror option: failed to find match"),null):{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1]]}},fr=(e,t)=>{const n=hr(e);if(!n)return null;const r=n.identifiers?.[0],o=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,i=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return G(e,i,o,n.startIndex,n.endIndex),i},mr=e=>{const t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g;let r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},pr=(e,t)=>{const n=mr(e);if(n.length===0)return null;const r=JSON.stringify(t),o=n.sort((l,a)=>a.startIndex-l.startIndex);let i=e;for(let l=0;l<o.length;l++){const a=i.slice(0,o[l].startIndex)+r+i.slice(o[l].endIndex);G(i,a,r,o[l].startIndex,o[l].endIndex),i=a}return i},br=e=>{const t=/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker symbol speed: failed to find match"),null;const r=n[0],o=n[1],i=r.lastIndexOf(o),l=n.index+i,a=l+o.length;return{startIndex:l,endIndex:a}},wr=(e,t)=>{const n=br(e);if(!n)return null;const r=JSON.stringify(t),o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return G(e,o,r,n.startIndex,n.endIndex),o},xr=e=>{const t=/\{flexWrap:"wrap",height:1,width:2\}/,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker symbol width: failed to find match"),null):{startIndex:n.index,endIndex:n.index+n[0].length}},yr=(e,t)=>{const n=xr(e);if(!n)return null;const r=`{flexWrap:"wrap",height:1,width:${t}}`,o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return G(e,o,r,n.startIndex,n.endIndex),o},Sr=e=>{const t=/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker verbs: failed to find verbsMatch"),null):{startIndex:n.index+1,endIndex:n.index+n[0].length,identifiers:[n[1]]}},vr=e=>{const t=/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker verbs: failed to find match"),null):{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1]]}},$r=(e,t)=>{const n=Sr(e);if(!n)return null;const r=n,o=r.identifiers?.[0],i=`${o}=${JSON.stringify({words:t})}`,l=e.slice(0,r.startIndex)+i+e.slice(r.endIndex);G(e,l,i,r.startIndex,r.endIndex);const a=vr(l);if(!a)return null;const u=a,g=`function ${u.identifiers?.[0]}(){return ${o}.words}`,f=l.slice(0,u.startIndex)+g+l.slice(u.endIndex);return G(l,f,g,u.startIndex,u.endIndex),f},_r=e=>{const t=e.indexOf("No content found in user prompt message")-700;if(t===-1)return console.error("patch: userMessageDisplay: failed to find error message"),null;const n=Math.min(e.length,t+700),r=e.slice(t,n),o=/("> "),([$\w]+)/,i=r.match(o);if(!i)return{prefixLocation:null,messageLocation:null};const l=t+r.indexOf(i[1]),a=l+i[1].length,u=a+1,d=u+i[2].length;return{prefixLocation:{startIndex:l,endIndex:a},messageLocation:{startIndex:u,endIndex:d}}},Ir=(e,t,n,r,o=!1,i=!1,l=!1,a=!1,u=!1,d,g,f=!1,v=!1,b=!1,p=!1,w=!1)=>{const x=_r(e);if(!x)return console.error("patch: userMessageDisplay: getUserMessageDisplayLocation returned null"),null;if(!x.prefixLocation)return console.error("patch: userMessageDisplay: failed to find prefix location"),null;if(!x.messageLocation)return console.error("patch: userMessageDisplay: failed to find message location"),null;const C=ln(e);if(!C)return console.error("patch: userMessageDisplay: failed to find chalk variable"),null;const _=[],k=n==="rgb(0,0,0)"&&r==="rgb(0,0,0)",O=!k||(o||i||l||a||u),V=d==="rgb(0,0,0)"&&g==="rgb(0,0,0)",U=!V||(f||v||b||p||w);if(O){const B=Cn(C,k?null:n.match(/\d+/g)?.join(",")||null,k?null:r.match(/\d+/g)?.join(",")||null,o,i,l,a,u);_.push({startIndex:x.prefixLocation.startIndex,endIndex:x.prefixLocation.endIndex,newContent:`${B}("${t}")+" "`})}if(U){const B=Cn(C,V?null:d.match(/\d+/g)?.join(",")||null,V?null:g.match(/\d+/g)?.join(",")||null,f,v,b,p,w);_.push({startIndex:x.messageLocation.startIndex,endIndex:x.messageLocation.endIndex,newContent:e.slice(x.messageLocation.startIndex,x.messageLocation.endIndex).replace(/([$\w]+)/,`${B}($1)`)})}_.sort((B,E)=>E.startIndex-B.startIndex);let A=e;for(const B of _){const E=A;A=A.slice(0,B.startIndex)+B.newContent+A.slice(B.endIndex),G(E,A,B.newContent,B.startIndex,B.endIndex)}return A},Cr=e=>{const t=/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: verbose: failed to find createElement with spinnerTip and overrideMessage"),null;const r=n[0],o=/verbose:[^,}]+/,i=r.match(o);if(!i||i.index===void 0)return console.error("patch: verbose: failed to find verbose property"),null;const l=n.index+i.index,a=l+i[0].length;return{startIndex:l,endIndex:a}},Er=e=>{const t=Cr(e);if(!t)return null;const n="verbose:true",r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return G(e,r,n,t.startIndex,t.endIndex),r},kr=e=>{const n=e.indexOf("subscription, no need to monitor cost");if(n===-1)return console.error("patch: ignoreMaxSubscription: phrase not found"),null;const r=Math.max(0,n-60),o=n,i=e.slice(r,o),l=/if\(([$\w]+)\(\)\)/g;let a=null;for(const g of i.matchAll(l))a=g;if(!a||a.index===void 0)return console.error("patch: ignoreMaxSubscription: could not match if(<id>()) nearby"),null;const u=r+a.index,d=u+a[0].length;return{startIndex:u,endIndex:d}},Mr=e=>{const t=kr(e);if(!t)return null;const n="if(!1)",r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return G(e,r,n,t.startIndex,t.endIndex),r},Br=e=>{const t=/function ([$\w]+)\(\{\s*streamMode:\s*([$\w]+)\s*\}\)\s*\{/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find banner function pattern"),null;const[r]=n,o=n.index,i=o+r.length;return{startIndex:o,endIndex:i,identifiers:[n[1],n[2]]}},Nr=e=>{const t=/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find thinking visibility pattern"),null;const r=n.index,o=r+n[0].length;return{startIndex:r,endIndex:o,identifiers:[n[1],n[2],n[3]]}},Or=e=>{const t=Br(e);if(!t)return null;const n="return null;";let r=e.slice(0,t.endIndex)+n+e.slice(t.endIndex);G(e,r,n,t.endIndex,t.endIndex);const o=Nr(r);if(!o)return null;const i=`${o.identifiers[0]}${o.identifiers[1]}true${o.identifiers[2]}`;return r=r.slice(0,o.startIndex)+i+r.slice(o.endIndex),G(e,r,i,o.startIndex,o.endIndex),r},Tr=e=>{const n=e.indexOf("}.VERSION} (Claude Code)");return n==-1?(console.error("patch: patchesAppliedIndication: failed to find versionIndex"),null):{startIndex:0,endIndex:n+24}},Ar=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern"),null;const r=n.index+n[0].length;return{startIndex:r,endIndex:r}},Pr=(e,t,n,r,o,i)=>{const l=/alignItems:"center",minHeight:9,?/,a=e.match(l);if(!a||a.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4"),null;let u=e.slice(0,a.index)+"minHeight:9,"+e.slice(a.index+a[0].length);const d=Math.max(0,a.index-200),g=u.slice(d,a.index+12+2),f=/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g,v=Array.from(g.matchAll(f));if(v.length===0)return console.error("patch: patchesAppliedIndication: failed to find createElement for PATCH 4"),null;const b=v[v.length-1],p=d+b.index+b[0].length,w=`${n}.createElement(${o}, null, ${i}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,x=u;u=u.slice(0,p)+w+u.slice(p),G(x,u,w,p,p);let C=1,_=p+w.length,k=-1;for(;_<u.length;){const O=u[_];if(O==="(")C++;else if(O===")"){if(C===1){k=_;break}C--}_++}if(k===-1)return console.error("patch: patchesAppliedIndication: failed to find closing paren for PATCH 4"),null;const P=u;return u=u.slice(0,k)+"),"+u.slice(k),G(P,u,"),",k,k),{content:u,closingParenIndex:k+2}},Lr=(e,t,n,r,o,i,l)=>{let a=4,u=t,d=-1;for(;u<e.length;){const p=e[u];if(p==="(")a++;else if(p===")"){if(a===1){d=u;break}a--}u++}if(d===-1)return console.error("patch: patchesAppliedIndication: failed to find insertion point for PATCH 5"),null;const g=[];g.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),g.push(`${n}.createElement(${r}, null, ${n}.createElement(${o}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${o}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let p of l)p=p.replace("CHALK_VAR",i),g.push(`${n}.createElement(${r}, null, ${n}.createElement(${o}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${o}, {dimColor: true}, \` * ${p}\`)),`);g.push("),");const f=g.join(""),v=e,b=e.slice(0,d)+f+e.slice(d);return G(v,b,f,d,d),b},Dr=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3"),null;const r=Math.max(0,n.index-500),o=e.slice(r,n.index),i=/\}function ([$\w]+)\(/g,l=Array.from(o.matchAll(i));if(l.length===0)return console.error("patch: patchesAppliedIndication: failed to find header component function"),null;const u=l[l.length-1][1],d=new RegExp(`\\b([$\\w]+)\\.createElement\\(${we(u)},null\\),?`),g=e.match(d);if(!g||g.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find createElement call for header"),null;const f=g.index+g[0].length;return{startIndex:f,endIndex:f}},Rr=(e,t,n,r=!0,o=!0)=>{const i=Tr(e);if(!i)return console.error("patch: patchesAppliedIndication: failed to version output location"),null;const l=`\\n${t} (tweakcc)`;let a=e.slice(0,i.endIndex)+l+e.slice(i.endIndex);G(e,a,l,i.endIndex,i.endIndex);const u=ln(e);if(!u)return console.error("patch: patchesAppliedIndication: failed to find chalk variable"),null;const d=qn(e);if(!d)return console.error("patch: patchesAppliedIndication: failed to find text component"),null;const g=an(e);if(!g)return console.error("patch: patchesAppliedIndication: failed to find React variable"),null;const f=Xn(e);if(!f)return console.error("patch: patchesAppliedIndication: failed to find Box component"),null;if(r){const b=Ar(a);if(!b)return console.error("patch: patchesAppliedIndication: patch 2 failed"),null;const p=`, " ",${g}.createElement(${d}, null, ${u}.blue.bold('+ tweakcc v${t}'))`,w=a;a=a.slice(0,b.startIndex)+p+a.slice(b.endIndex),G(w,a,p,b.startIndex,b.endIndex)}if(o){const b=Dr(a);if(!b)return console.error("patch: patchesAppliedIndication: patch 3 failed"),null;const p=[];p.push(`${g}.createElement(${f}, { flexDirection: "column" },`),p.push(`${g}.createElement(${f}, null, ${g}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${g}.createElement(${d}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let C of n)C=C.replace("CHALK_VAR",u),p.push(`${g}.createElement(${f}, null, ${g}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${g}.createElement(${d}, {dimColor: true}, \` * ${C}\`)),`);p.push("),");const w=p.join(`
184
- `),x=a;a=a.slice(0,b.startIndex)+w+a.slice(b.endIndex),G(x,a,w,b.startIndex,b.endIndex)}let v=-1;if(r){const b=Pr(a,t,g,f,d,u);if(!b)return console.error("patch: patchesAppliedIndication: patch 4 failed"),null;a=b.content,v=b.closingParenIndex}if(o){if(v===-1){const p=/alignItems:"center",minHeight:9,?/,w=a.match(p);if(!w||w.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find reference point for PATCH 5"),null;v=w.index+w[0].length}const b=Lr(a,v,g,f,d,u,n);if(!b)return console.error("patch: patchesAppliedIndication: patch 5 failed"),null;a=b}return a},Fr=e=>/\\u[0-9a-fA-F]{4}/.test(e),Vr=e=>{const t=e.toString(),n=JSON.stringify(t.substring(1,t.length-1)),r=JSON.stringify(t.match(/\/(\w*)$/)[1]);return`new RegExp(${n}, ${r})`},Ur=async(e,t,n)=>{const r=n??Fr(e);M()&&r&&console.log("Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts");const o=await Dt(t,r);M()&&console.log(`Loaded ${o.length} system prompts with regexes`);let i=0,l=0;for(const{promptId:d,prompt:g,regex:f,getInterpolatedContent:v,pieces:b,identifiers:p,identifierMap:w}of o){const x=new RegExp(f,"si"),C=e.match(x);if(C&&C.index!==void 0){const _=v(C),k=Re(b,p,w).trim(),P=k.length,O=g.content.length;i+=P,l+=O,M()&&P!==O&&(console.log(`
185
- Character count difference for ${g.name}:`),console.log(` Original baseline: ${P} chars`),console.log(` User's version: ${O} chars`),console.log(` Difference: ${P-O} chars`),Math.abs(P-O)<200&&(console.log(`
178
+ `),Ie=32,jt=8,ze=4*jt+4;function ve(e,t){return e.subarray(t.offset,t.offset+t.length)}function Te(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function Fn(e){return e.endsWith("/claude")||e==="claude"||e.endsWith("/claude.exe")||e==="claude.exe"}function Vn(e,t,n){const o=ve(e,t.modulesPtr),r=Math.floor(o.length/ze);for(let i=0;i<r;i++){const a=i*ze,l=Ut(o,a),u=ve(e,l.name).toString("utf-8"),d=n(l,u,i);if(d!==void 0)return d}}function jn(e){let t=0;const n=e.readBigUInt64LE(t);t+=8;const o=Te(e,t);t+=8;const r=e.readUInt32LE(t);t+=4;const i=Te(e,t);return{byteCount:n,modulesPtr:o,entryPointId:r,compileExecArgvPtr:i}}function Ut(e,t){let n=t;const o=Te(e,n);n+=8;const r=Te(e,n);n+=8;const i=Te(e,n);n+=8;const a=Te(e,n);n+=8;const l=e.readUInt8(n);n+=1;const u=e.readUInt8(n);n+=1;const d=e.readUInt8(n);n+=1;const h=e.readUInt8(n);return{name:o,contents:r,sourcemap:i,bytecode:a,encoding:l,loader:u,moduleFormat:d,side:h}}function Ht(e){if(e.length<Ie+le.length)throw new Error("BUN data is too small to contain trailer and offsets");const t=e.length-le.length,n=e.subarray(t);if(T()&&(console.log(`parseBunDataBlob: Expected trailer: ${le.toString("hex")}`),console.log(`parseBunDataBlob: Got trailer: ${n.toString("hex")}`)),!n.equals(le))throw T()&&(console.log(`Expected: ${le.toString("hex")}`),console.log(`Got: ${n.toString("hex")}`)),new Error("BUN trailer bytes do not match trailer");const o=e.length-Ie-le.length,r=e.subarray(o,o+Ie);return{bunOffsets:jn(r),bunData:e}}function Un(e){if(e.length<4)throw new Error("Section data too small");T()&&console.log(`extractBunDataFromSection: sectionData.length=${e.length}`);const t=e.readUInt32LE(0);T()&&console.log(`extractBunDataFromSection: bunDataSize from header=${t}`);const n=e.subarray(4,4+t);T()&&console.log(`extractBunDataFromSection: bunDataContent.length=${n.length}`);const{bunOffsets:o,bunData:r}=Ht(n);return{bunOffsets:o,bunData:r}}function Gt(e){if(!e.hasOverlay)throw new Error("ELF binary has no overlay data");const t=e.overlay;if(T()&&console.log(`extractBunDataFromELFOverlay: Overlay size=${t.length} bytes`),t.length<le.length+8+Ie)throw new Error("ELF overlay data is too small");const n=t.readBigUInt64LE(t.length-8);if(T()&&console.log(`extractBunDataFromELFOverlay: Total byte count from tail=${n}`),n<4096n||n>2n**32n-1n)throw new Error(`ELF total byte count is out of range: ${n}`);const o=t.length-8-le.length,r=t.subarray(o,t.length-8);if(T()&&(console.log(`extractBunDataFromELFOverlay: Expected trailer: ${le.toString("hex")}`),console.log(`extractBunDataFromELFOverlay: Got trailer: ${r.toString("hex")}`)),!r.equals(le))throw new Error("BUN trailer bytes do not match trailer");const i=t.length-8-le.length-Ie,a=t.subarray(i,t.length-8-le.length),l=jn(a);T()&&console.log(`extractBunDataFromELFOverlay: Offsets.byteCount=${l.byteCount}`);const u=typeof l.byteCount=="bigint"?l.byteCount:BigInt(l.byteCount);if(u>=n)throw new Error("ELF total byte count is out of range");const d=8+le.length+Ie,h=t.length-d-Number(u),f=t.subarray(h,t.length-d);T()&&console.log(`extractBunDataFromELFOverlay: Extracted ${f.length} bytes of data`);const v=Buffer.concat([f,a,r]);return{bunOffsets:l,bunData:v}}function zt(e){const t=e.getSegment("__BUN");if(!t)throw new Error("__BUN segment not found");const n=t.getSection("__bun");if(!n)throw new Error("__bun section not found");return Un(n.content)}function Yt(e){const t=e.sections().find(n=>n.name===".bun");if(!t)throw new Error(".bun section not found");return Un(t.content)}function Hn(e){switch(T()&&console.log(`getBunData: Binary format detected as ${e.format}`),e.format){case"MachO":return zt(e);case"PE":return Yt(e);case"ELF":return Gt(e);default:throw new Error(`Unsupported binary format: ${e.format}`)}}function Gn(e){try{De.logging.disable();const t=De.parse(e),{bunOffsets:n,bunData:o}=Hn(t);T()&&console.log(`extractClaudeJsFromNativeInstallation: Got bunData, size=${o.length} bytes`);const r=Vn(o,n,(i,a,l)=>{if(T()&&console.log(`extractClaudeJsFromNativeInstallation: Module ${l}: ${a}`),!Fn(a))return;const u=ve(o,i.contents);return T()&&console.log(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${u.length}`),u.length>0?u:void 0});return r||(T()&&console.log("extractClaudeJsFromNativeInstallation: claude module not found in any module"),null)}catch(t){return T()&&console.log("extractClaudeJsFromNativeInstallation: Error during extraction:",t),null}}function Wt(e,t,n){const o=[],r=[];Vn(e,t,(k,P)=>{const B=ve(e,k.name);let j;n&&Fn(P)?j=n:j=ve(e,k.contents);const K=ve(e,k.sourcemap),U=ve(e,k.bytecode);r.push({name:B,contents:j,sourcemap:K,bytecode:U,encoding:k.encoding,loader:k.loader,moduleFormat:k.moduleFormat,side:k.side}),o.push(B,j,K,U)});let i=0;const a=[];for(const k of o)a.push({offset:i,length:k.length}),i+=k.length+1;const l=i,u=r.length*ze;i+=u;const d=ve(e,t.compileExecArgvPtr),h=i,f=d.length;i+=f+1;const v=i;i+=Ie;const b=i;i+=le.length;const p=Buffer.allocUnsafe(i);p.fill(0);let w=0;for(const{offset:k,length:P}of a)P>0&&o[w].copy(p,k,0,P),p[k+P]=0,w++;f>0&&(d.copy(p,h,0,f),p[h+f]=0);for(let k=0;k<r.length;k++){const P=r[k],B=k*4,j={name:{offset:a[B].offset,length:a[B].length},contents:{offset:a[B+1].offset,length:a[B+1].length},sourcemap:{offset:a[B+2].offset,length:a[B+2].length},bytecode:{offset:a[B+3].offset,length:a[B+3].length},encoding:P.encoding,loader:P.loader,moduleFormat:P.moduleFormat,side:P.side};let U=l+k*ze;p.writeUInt32LE(j.name.offset,U),p.writeUInt32LE(j.name.length,U+4),U+=8,p.writeUInt32LE(j.contents.offset,U),p.writeUInt32LE(j.contents.length,U+4),U+=8,p.writeUInt32LE(j.sourcemap.offset,U),p.writeUInt32LE(j.sourcemap.length,U+4),U+=8,p.writeUInt32LE(j.bytecode.offset,U),p.writeUInt32LE(j.bytecode.length,U+4),U+=8,p.writeUInt8(j.encoding,U),p.writeUInt8(j.loader,U+1),p.writeUInt8(j.moduleFormat,U+2),p.writeUInt8(j.side,U+3)}const x={byteCount:v,modulesPtr:{offset:l,length:u},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:h,length:f}};let C=v;const _=typeof x.byteCount=="bigint"?x.byteCount:BigInt(x.byteCount);return p.writeBigUInt64LE(_,C),C+=8,p.writeUInt32LE(x.modulesPtr.offset,C),p.writeUInt32LE(x.modulesPtr.length,C+4),C+=8,p.writeUInt32LE(x.entryPointId,C),C+=4,p.writeUInt32LE(x.compileExecArgvPtr.offset,C),p.writeUInt32LE(x.compileExecArgvPtr.length,C+4),le.copy(p,b),p}function rn(e,t,n,o=!0){const r=t+".tmp";if(e.write(r),o){const i=Ae.statSync(n);Ae.chmodSync(r,i.mode)}try{Ae.renameSync(r,t)}catch(i){try{Ae.existsSync(r)&&Ae.unlinkSync(r)}catch{}throw i instanceof Error&&"code"in i&&(i.code==="ETXTBSY"||i.code==="EBUSY"||i.code==="EPERM")?new Error(`Cannot update the Claude executable while it is running.
179
+ Please close all Claude instances and try again.`):i}}function zn(e){const t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function Jt(e,t,n,o){try{T()&&console.log(`repackMachO: Has code signature: ${e.hasCodeSignature}`),e.hasCodeSignature&&(T()&&console.log("repackMachO: Removing code signature..."),e.removeSignature());const r=e.getSegment("__BUN");if(!r)throw new Error("__BUN segment not found");const i=r.getSection("__bun");if(!i)throw new Error("__bun section not found");const a=zn(n);T()&&(console.log(`repackMachO: Original section size: ${i.size}`),console.log(`repackMachO: Original segment fileSize: ${r.fileSize}`),console.log(`repackMachO: Original segment virtualSize: ${r.virtualSize}`),console.log(`repackMachO: New data size: ${a.length}`));const l=a.length-Number(i.size);if(l>0){const u=e.header.cpuType===De.MachO.Header.CPU_TYPE.ARM64,d=u?16384:4096,h=Math.ceil(l/d)*d;T()&&(console.log(`repackMachO: CPU type: ${u?"ARM64":"x86_64"}`),console.log(`repackMachO: Page size: ${d} bytes`),console.log(`repackMachO: Need to expand by ${l} bytes`),console.log(`repackMachO: Rounding up to page-aligned: ${h} bytes`));const f=e.extendSegment(r,h);if(T()&&console.log(`repackMachO: extendSegment returned: ${f}`),!f)throw new Error("Failed to extend __BUN segment");T()&&(console.log(`repackMachO: Section size after extend: ${i.size}`),console.log(`repackMachO: Segment fileSize after extend: ${r.fileSize}`),console.log(`repackMachO: Segment virtualSize after extend: ${r.virtualSize}`))}i.content=a,i.size=BigInt(a.length),T()&&(console.log(`repackMachO: Final section size: ${i.size}`),console.log(`repackMachO: Writing modified binary to ${o}...`)),rn(e,o,t);try{T()&&console.log("repackMachO: Re-signing binary with ad-hoc signature..."),Nn(`codesign -s - -f "${o}"`,{stdio:T()?"inherit":"ignore"}),T()&&console.log("repackMachO: Code signing completed successfully")}catch(u){console.warn("Warning: Failed to re-sign binary. The binary may not run correctly on macOS:",u)}T()&&console.log("repackMachO: Write completed successfully")}catch(r){throw console.error("repackMachO failed:",r),r}}function Kt(e,t,n,o){try{const r=e.sections().find(a=>a.name===".bun");if(!r)throw new Error(".bun section not found");const i=zn(n);T()&&(console.log(`repackPE: Original section size: ${r.size}, virtual size: ${r.virtualSize}`),console.log(`repackPE: New data size: ${i.length}`)),r.content=i,r.virtualSize=BigInt(i.length),r.size=BigInt(i.length),T()&&console.log(`repackPE: Writing modified binary to ${o}...`),rn(e,o,t,!1),T()&&console.log("repackPE: Write completed successfully")}catch(r){throw console.error("repackPE failed:",r),r}}function qt(e,t,n,o){try{const r=Buffer.allocUnsafe(n.length+8);n.copy(r,0),r.writeBigUInt64LE(BigInt(n.length),n.length),T()&&console.log(`repackELF: Setting overlay data (${r.length} bytes)`),e.overlay=r,T()&&console.log(`repackELF: Writing modified binary to ${o}...`),rn(e,o,t),T()&&console.log("repackELF: Write completed successfully")}catch(r){throw console.error("repackELF failed:",r),r}}function Xt(e,t,n){De.logging.disable();const o=De.parse(e),{bunOffsets:r,bunData:i}=Hn(o),a=Wt(i,r,t);switch(o.format){case"MachO":Jt(o,e,a,n);break;case"PE":Kt(o,e,a,n);break;case"ELF":qt(o,e,a,n);break;default:throw new Error(`Unsupported binary format: ${o.format}`)}}const sn=async()=>{await ie.mkdir(de,{recursive:!0}),await ie.mkdir(Se,{recursive:!0});const e=Mn.join(de,".gitignore");try{await ie.stat(e)}catch(t){t instanceof Error&&"code"in t&&t.code==="ENOENT"&&await ie.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"].join(mn)+mn)}};let Le={settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null};const ln=async()=>{const e={ccVersion:"",ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:Z};try{T()&&console.log(`Reading config at ${ce}`);const t=await ie.readFile(ce,"utf8"),n={...e,...JSON.parse(t)},o=n?.settings?.thinkingVerbs;o?.punctuation&&(o.format="{}"+o.punctuation,delete o.punctuation),n.settings.inputBox||(n.settings.inputBox=Z.inputBox),n.settings.toolsets||(n.settings.toolsets=Z.toolsets),Object.hasOwn(n.settings,"defaultToolset")||(n.settings.defaultToolset=Z.defaultToolset);for(const i of Z.themes){const a=n?.settings?.themes.find(l=>l.id===i.id||l.name===i.name);if(a){for(const[l,u]of Object.entries(i))l!=="colors"&&!Object.hasOwn(a,l)&&(a[l]=u);a.colors||(a.colors={});for(const[l,u]of Object.entries(i.colors))Object.hasOwn(a.colors,l)||(a.colors[l]=u)}}for(const i of n?.settings?.themes||[]){if(Z.themes.some(u=>u.id===i.id||u.name===i.name))continue;const l=Z.themes[0];i.colors||(i.colors={});for(const[u,d]of Object.entries(l.colors))Object.hasOwn(i.colors,u)||(i.colors[u]=d)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||Z,n.settings.userMessageDisplay=Z.userMessageDisplay),delete n.settings.launchText,await Ct(Se)&&(n.changesApplied=!1),Le=n,n}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return e;throw t}},Ve=async e=>(T()&&console.log(`Updating config at ${ce}`),e(Le),Le.lastModified=new Date().toISOString(),await Zt(Le),Le),Zt=async e=>{try{e.lastModified=new Date().toISOString(),await sn(),await ie.writeFile(ce,JSON.stringify(e,null,2))}catch(t){throw console.error("Error saving config:",t),t}},Yn=async e=>{if(!e.cliPath)return T()&&console.log("restoreClijsFromBackup: Skipping for native installation (no cliPath)"),!1;T()&&console.log(`Restoring cli.js from backup to ${e.cliPath}`);const t=await ie.readFile(Ne);return await hn(e.cliPath,t,"restore"),await It(),await Ve(n=>{n.changesApplied=!1}),!0},Qt=async e=>{if(!e.nativeInstallationPath)return T()&&console.log("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await Ce(ae))return T()&&console.log("restoreNativeBinaryFromBackup: No backup file exists, skipping"),!1;T()&&console.log(`Restoring native binary from backup to ${e.nativeInstallationPath}`);const t=await ie.readFile(ae);return await hn(e.nativeInstallationPath,t,"restore"),!0};async function eo(){try{const t=process.platform==="win32"?"where claude.exe":"which claude";T()&&console.log(`Looking for claude executable using: ${t}`);const o=Nn(t,{encoding:"utf8"}).trim().split(`
180
+ `)[0].trim();if(o&&await Ce(o))try{const r=await ie.realpath(o);return T()&&(r!==o?(console.log(`Found claude executable at: ${o} (symlink)`),console.log(`Resolved to: ${r}`)):console.log(`Found claude executable at: ${o}`)),r}catch(r){return T()&&console.log("Could not resolve symlink, using original path:",r),o}}catch(e){T()&&console.log("Could not find claude executable on PATH:",e)}return null}function Wn(e){const t=/\bVERSION:"(\d+\.\d+\.\d+)"/g,n=new Map;let o;for(;(o=t.exec(e))!==null;){const a=o[1];n.set(a,(n.get(a)||0)+1)}if(n.size===0)return null;let r=0,i;for(const[a,l]of n.entries())T()&&console.log(`Found version ${a} with ${l} occurrences`),l>r&&(r=l,i=a);return T()&&i&&console.log(`Extracted version ${i} (${r} occurrences)`),i||null}async function Ce(e){try{return await ie.stat(e),!0}catch(t){if(t instanceof Error&&"code"in t&&(t.code==="ENOENT"||t.code==="ENOTDIR"))return!1;throw t}}async function no(e){const t=await ie.readFile(e,"utf8"),n=Wn(t);if(!n)throw new Error(`No VERSION strings found in JS file: ${e}`);return n}const to=async e=>{e.ccInstallationDir&&bn.unshift(e.ccInstallationDir);for(const n of bn)try{T()&&console.log(`Searching for Claude Code cli.js file at ${n}`);const o=Mn.join(n,"cli.js");if(!await Ce(o))continue;T()&&(console.log(`Found Claude Code cli.js file at ${n}; checking hash...`),console.log(`SHA256 hash: ${await _r(o)}`));const r=await no(o);return{cliPath:o,version:r}}catch(o){if(o instanceof Error&&"code"in o&&(o.code==="ENOENT"||o.code==="ENOTDIR"))continue;throw o}T()&&console.log("Could not find cli.js in standard locations, trying native installation method...");const t=await eo();if(T()&&console.log(`findClaudeExecutableOnPath() returned: ${t}`),t){const n=await Ce(ae),o=n?ae:t;T()&&console.log(`Attempting to extract claude.js from ${n?"backup":"native installation"}: ${o}`);const r=Gn(o);if(r){const i=r.toString("utf8"),a=Wn(i);return a?(T()&&console.log(`Extracted version ${a} from native installation`),{version:a,nativeInstallationPath:t}):(T()&&console.log("Failed to extract version from native installation"),null)}}return null},$n=async e=>{if(!e.cliPath){T()&&console.log("backupClijs: Skipping for native installation (no cliPath)");return}await sn(),T()&&console.log(`Backing up cli.js to ${Ne}`),await ie.copyFile(e.cliPath,Ne),await Ve(t=>{t.changesApplied=!1,t.ccVersion=e.version})},_n=async e=>{e.nativeInstallationPath&&(await sn(),T()&&console.log(`Backing up native binary to ${ae}`),await ie.copyFile(e.nativeInstallationPath,ae),await Ve(t=>{t.changesApplied=!1,t.ccVersion=e.version}))};async function In(){const e=await ln(),t=await to(e);if(!t)return null;if(t.version)try{const a=await At(t.version);Vt(a)}catch{}const n=t.version,o=e.ccVersion;let r=!1;await Ce(Ne)||(T()&&console.log(`startupCheck: ${Ne} not found; backing up cli.js`),await $n(t),r=!0);let i=!1;return t.nativeInstallationPath&&!await Ce(ae)&&(T()&&console.log(`startupCheck: ${ae} not found; backing up native binary`),await _n(t),i=!0),n!==o?(r||(T()&&console.log(`startupCheck: real version (${n}) != backed up version (${o}); backing up cli.js`),await ie.unlink(Ne),await $n(t)),t.nativeInstallationPath&&!i&&(T()&&console.log(`startupCheck: real version (${n}) != backed up version (${o}); backing up native binary`),await Ce(ae)&&await ie.unlink(ae),await _n(t)),{wasUpdated:!0,oldVersion:o,newVersion:n,ccInstInfo:t}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}}const oo=e=>{const t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g;let o;for(;(o=n.exec(e))!==null;){const r=o.index+o[0].indexOf("=")+1;t.push({startIndex:r,endIndex:r+o[1].length})}return t},ro=(e,t)=>{const n=oo(e);if(n.length===0)return console.error("patch: writeShowMoreItemsInSelectMenus: failed to find locations"),null;const o=n.sort((i,a)=>a.startIndex-i.startIndex);let r=e;for(const i of o){const a=t.toString(),l=r.slice(0,i.startIndex)+a+r.slice(i.endIndex);V(r,l,a,i.startIndex,i.endIndex),r=l}return r};function io(e){const t=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,n=e.match(t);if(!n||n.index==null)return console.error("patch: themes: failed to find switchMatch"),null;const o=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(o),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:n.index,endIndex:n.index+n[0].length,identifiers:[n[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const so=(e,t)=>{const n=io(e);if(!n)return null;if(t.length===0)return e;let o=e;const r="return"+JSON.stringify(Object.fromEntries(t.map(l=>[l.id,l.name])));o=o.slice(0,n.obj.startIndex)+r+o.slice(n.obj.endIndex),V(e,o,r,n.obj.startIndex,n.obj.endIndex),e=o;const i=JSON.stringify(t.map(l=>({label:l.name,value:l.id})));o=o.slice(0,n.objArr.startIndex)+i+o.slice(n.objArr.endIndex),V(e,o,i,n.objArr.startIndex,n.objArr.endIndex),e=o;let a=`switch(${n.switchStatement.identifiers?.[0]}){
181
+ `;return t.forEach(l=>{a+=`case"${l.id}":return${JSON.stringify(l.colors)};
182
+ `}),a+=`default:return${JSON.stringify(t[0].colors)};
183
+ }`,o=o.slice(0,n.switchStatement.startIndex)+a+o.slice(n.switchStatement.endIndex),V(e,o,a,n.switchStatement.startIndex,n.switchStatement.endIndex),o},lo=e=>{const t=/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/,n=e.match(t);return!n||n.index===void 0?(console.error("patch: context limit: failed to find match"),null):n.index+n[0].indexOf("{")+1},ao=e=>{const t=lo(e);if(!t)return null;const n="if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);",o=e.slice(0,t)+n+e.slice(t);return V(e,o,n,t,t),o},co=e=>{const t=e.indexOf('bash:"bashBorder"');if(t===-1)return console.error("patch: input border: failed to find bash pattern"),null;const n=e.slice(t,t+500),o=/borderStyle:"[^"]*"/,r=n.match(o);return!r||r.index===void 0?(console.error("patch: input border: failed to find border style pattern"),null):{startIndex:t+r.index,endIndex:t+r.index+r[0].length}},uo=(e,t)=>{const n=co(e);if(!n)return null;if(t){const o="borderColor:undefined",r=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return V(e,r,o,n.startIndex,n.endIndex),r}else return e},ho=e=>{const t=/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: spinner no-freeze: failed to find wholeMatch"),null;const o=/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/,r=n[0].match(o);if(!r||r.index===void 0)return console.error("patch: spinner no-freeze: failed to find freeze condition"),null;const i=n.index+r.index,a=i+r[0].length;return{startIndex:i,endIndex:a}},go=e=>{const t=ho(e);if(!t)return null;const n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return V(e,n,"",t.startIndex,t.endIndex),n},fo=e=>{const t=/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker format: failed to find approxAreaMatch"),null;const o=e.slice(n.index,n.index+600),r=/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/,i=o.match(r);return!i||i.index==null?(console.error("patch: thinker format: failed to find formatMatch"),null):{startIndex:n.index+i.index+i[1].length,endIndex:n.index+i.index+i[1].length+i[2].length,identifiers:[i[3]]}},mo=(e,t)=>{const n=fo(e);if(!n)return null;const o=n,r=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),i=o.identifiers?.[0],l=`=${"`"+r.replace(/\{\}/g,"${"+i+"}")+"`"}`,u=e.slice(0,o.startIndex)+l+e.slice(o.endIndex);return V(e,u,l,o.startIndex,o.endIndex),u},po=e=>{const t=/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker symbol mirror option: failed to find match"),null):{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1]]}},bo=(e,t)=>{const n=po(e);if(!n)return null;const o=n.identifiers?.[0],r=t?`=[...${o},...[...${o}].reverse()]`:`=[...${o}]`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,i,r,n.startIndex,n.endIndex),i},wo=e=>{const t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g;let o;for(;(o=n.exec(e))!==null;)t.push({startIndex:o.index,endIndex:o.index+o[0].length});return t},xo=(e,t)=>{const n=wo(e);if(n.length===0)return null;const o=JSON.stringify(t),r=n.sort((a,l)=>l.startIndex-a.startIndex);let i=e;for(let a=0;a<r.length;a++){const l=i.slice(0,r[a].startIndex)+o+i.slice(r[a].endIndex);V(i,l,o,r[a].startIndex,r[a].endIndex),i=l}return i},yo=e=>{const t=/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker symbol speed: failed to find match"),null;const o=n[0],r=n[1],i=o.lastIndexOf(r),a=n.index+i,l=a+r.length;return{startIndex:a,endIndex:l}},So=(e,t)=>{const n=yo(e);if(!n)return null;const o=JSON.stringify(t),r=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return V(e,r,o,n.startIndex,n.endIndex),r},vo=e=>{const t=/\{flexWrap:"wrap",height:1,width:2\}/,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker symbol width: failed to find match"),null):{startIndex:n.index,endIndex:n.index+n[0].length}},$o=(e,t)=>{const n=vo(e);if(!n)return null;const o=`{flexWrap:"wrap",height:1,width:${t}}`,r=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return V(e,r,o,n.startIndex,n.endIndex),r},_o=e=>{const t=/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker verbs: failed to find verbsMatch"),null):{startIndex:n.index+1,endIndex:n.index+n[0].length,identifiers:[n[1]]}},Io=e=>{const t=/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/,n=e.match(t);return!n||n.index==null?(console.error("patch: thinker verbs: failed to find match"),null):{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1]]}},Co=(e,t)=>{const n=_o(e);if(!n)return null;const o=n,r=o.identifiers?.[0],i=`${r}=${JSON.stringify({words:t})}`,a=e.slice(0,o.startIndex)+i+e.slice(o.endIndex);V(e,a,i,o.startIndex,o.endIndex);const l=Io(a);if(!l)return null;const u=l,h=`function ${u.identifiers?.[0]}(){return ${r}.words}`,f=a.slice(0,u.startIndex)+h+a.slice(u.endIndex);return V(a,f,h,u.startIndex,u.endIndex),f},Eo=e=>{const t=e.indexOf("No content found in user prompt message")-700;if(t===-1)return console.error("patch: userMessageDisplay: failed to find error message"),null;const n=Math.min(e.length,t+700),o=e.slice(t,n),r=/("> "),([$\w]+)/,i=o.match(r);if(!i)return{prefixLocation:null,messageLocation:null};const a=t+o.indexOf(i[1]),l=a+i[1].length,u=l+1,d=u+i[2].length;return{prefixLocation:{startIndex:a,endIndex:l},messageLocation:{startIndex:u,endIndex:d}}},ko=(e,t,n,o,r=!1,i=!1,a=!1,l=!1,u=!1,d,h,f=!1,v=!1,b=!1,p=!1,w=!1)=>{const x=Eo(e);if(!x)return console.error("patch: userMessageDisplay: getUserMessageDisplayLocation returned null"),null;if(!x.prefixLocation)return console.error("patch: userMessageDisplay: failed to find prefix location"),null;if(!x.messageLocation)return console.error("patch: userMessageDisplay: failed to find message location"),null;const C=cn(e);if(!C)return console.error("patch: userMessageDisplay: failed to find chalk variable"),null;const _=[],k=n==="rgb(0,0,0)"&&o==="rgb(0,0,0)",B=!k||(r||i||a||l||u),j=d==="rgb(0,0,0)"&&h==="rgb(0,0,0)",U=!j||(f||v||b||p||w);if(B){const M=En(C,k?null:n.match(/\d+/g)?.join(",")||null,k?null:o.match(/\d+/g)?.join(",")||null,r,i,a,l,u);_.push({startIndex:x.prefixLocation.startIndex,endIndex:x.prefixLocation.endIndex,newContent:`${M}("${t}")+" "`})}if(U){const M=En(C,j?null:d.match(/\d+/g)?.join(",")||null,j?null:h.match(/\d+/g)?.join(",")||null,f,v,b,p,w);_.push({startIndex:x.messageLocation.startIndex,endIndex:x.messageLocation.endIndex,newContent:e.slice(x.messageLocation.startIndex,x.messageLocation.endIndex).replace(/([$\w]+)/,`${M}($1)`)})}_.sort((M,E)=>E.startIndex-M.startIndex);let A=e;for(const M of _){const E=A;A=A.slice(0,M.startIndex)+M.newContent+A.slice(M.endIndex),V(E,A,M.newContent,M.startIndex,M.endIndex)}return A},To=e=>{const t=/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: verbose: failed to find createElement with spinnerTip and overrideMessage"),null;const o=n[0],r=/verbose:[^,}]+/,i=o.match(r);if(!i||i.index===void 0)return console.error("patch: verbose: failed to find verbose property"),null;const a=n.index+i.index,l=a+i[0].length;return{startIndex:a,endIndex:l}},Mo=e=>{const t=To(e);if(!t)return null;const n="verbose:true",o=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,o,n,t.startIndex,t.endIndex),o},No=e=>{const n=e.indexOf("subscription, no need to monitor cost");if(n===-1)return console.error("patch: ignoreMaxSubscription: phrase not found"),null;const o=Math.max(0,n-60),r=n,i=e.slice(o,r),a=/if\(([$\w]+)\(\)\)/g;let l=null;for(const h of i.matchAll(a))l=h;if(!l||l.index===void 0)return console.error("patch: ignoreMaxSubscription: could not match if(<id>()) nearby"),null;const u=o+l.index,d=u+l[0].length;return{startIndex:u,endIndex:d}},Bo=e=>{const t=No(e);if(!t)return null;const n="if(!1)",o=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,o,n,t.startIndex,t.endIndex),o},Oo=e=>{const t=/function ([$\w]+)\(\{\s*streamMode:\s*([$\w]+)\s*\}\)\s*\{/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find banner function pattern"),null;const[o]=n,r=n.index,i=r+o.length;return{startIndex:r,endIndex:i,identifiers:[n[1],n[2]]}},Ao=e=>{const t=/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find thinking visibility pattern"),null;const o=n.index,r=o+n[0].length;return{startIndex:o,endIndex:r,identifiers:[n[1],n[2],n[3]]}},Po=e=>{const t=Oo(e);if(!t)return null;const n="return null;";let o=e.slice(0,t.endIndex)+n+e.slice(t.endIndex);V(e,o,n,t.endIndex,t.endIndex);const r=Ao(o);if(!r)return null;const i=`${r.identifiers[0]}${r.identifiers[1]}true${r.identifiers[2]}`;return o=o.slice(0,r.startIndex)+i+o.slice(r.endIndex),V(e,o,i,r.startIndex,r.endIndex),o},Lo=e=>{const n=e.indexOf("}.VERSION} (Claude Code)");return n==-1?(console.error("patch: patchesAppliedIndication: failed to find versionIndex"),null):{startIndex:0,endIndex:n+24}},Do=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern"),null;const o=n.index+n[0].length;return{startIndex:o,endIndex:o}},Ro=(e,t,n,o,r,i)=>{const a=/alignItems:"center",minHeight:9,?/,l=e.match(a);if(!l||l.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4"),null;let u=e.slice(0,l.index)+"minHeight:9,"+e.slice(l.index+l[0].length);const d=Math.max(0,l.index-200),h=u.slice(d,l.index+12+2),f=/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g,v=Array.from(h.matchAll(f));if(v.length===0)return console.error("patch: patchesAppliedIndication: failed to find createElement for PATCH 4"),null;const b=v[v.length-1],p=d+b.index+b[0].length,w=`${n}.createElement(${r}, null, ${i}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${o},{alignItems:"center",flexDirection:"column"},`,x=u;u=u.slice(0,p)+w+u.slice(p),V(x,u,w,p,p);let C=1,_=p+w.length,k=-1;for(;_<u.length;){const B=u[_];if(B==="(")C++;else if(B===")"){if(C===1){k=_;break}C--}_++}if(k===-1)return console.error("patch: patchesAppliedIndication: failed to find closing paren for PATCH 4"),null;const P=u;return u=u.slice(0,k)+"),"+u.slice(k),V(P,u,"),",k,k),{content:u,closingParenIndex:k+2}},Fo=(e,t,n,o,r,i,a)=>{let l=4,u=t,d=-1;for(;u<e.length;){const p=e[u];if(p==="(")l++;else if(p===")"){if(l===1){d=u;break}l--}u++}if(d===-1)return console.error("patch: patchesAppliedIndication: failed to find insertion point for PATCH 5"),null;const h=[];h.push(`,${n}.createElement(${o}, { flexDirection: "column" },`),h.push(`${n}.createElement(${o}, null, ${n}.createElement(${r}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${r}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let p of a)p=p.replace("CHALK_VAR",i),h.push(`${n}.createElement(${o}, null, ${n}.createElement(${r}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${r}, {dimColor: true}, \` * ${p}\`)),`);h.push("),");const f=h.join(""),v=e,b=e.slice(0,d)+f+e.slice(d);return V(v,b,f,d,d),b},Vo=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3"),null;const o=Math.max(0,n.index-500),r=e.slice(o,n.index),i=/\}function ([$\w]+)\(/g,a=Array.from(r.matchAll(i));if(a.length===0)return console.error("patch: patchesAppliedIndication: failed to find header component function"),null;const u=a[a.length-1][1],d=new RegExp(`\\b([$\\w]+)\\.createElement\\(${we(u)},null\\),?`),h=e.match(d);if(!h||h.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find createElement call for header"),null;const f=h.index+h[0].length;return{startIndex:f,endIndex:f}},jo=(e,t,n,o=!0,r=!0)=>{const i=Lo(e);if(!i)return console.error("patch: patchesAppliedIndication: failed to version output location"),null;const a=`\\n${t} (tweakcc)`;let l=e.slice(0,i.endIndex)+a+e.slice(i.endIndex);V(e,l,a,i.endIndex,i.endIndex);const u=cn(e);if(!u)return console.error("patch: patchesAppliedIndication: failed to find chalk variable"),null;const d=Zn(e);if(!d)return console.error("patch: patchesAppliedIndication: failed to find text component"),null;const h=We(e);if(!h)return console.error("patch: patchesAppliedIndication: failed to find React variable"),null;const f=Qn(e);if(!f)return console.error("patch: patchesAppliedIndication: failed to find Box component"),null;if(o){const b=Do(l);if(!b)return console.error("patch: patchesAppliedIndication: patch 2 failed"),null;const p=`, " ",${h}.createElement(${d}, null, ${u}.blue.bold('+ tweakcc v${t}'))`,w=l;l=l.slice(0,b.startIndex)+p+l.slice(b.endIndex),V(w,l,p,b.startIndex,b.endIndex)}if(r){const b=Vo(l);if(!b)return console.error("patch: patchesAppliedIndication: patch 3 failed"),null;const p=[];p.push(`${h}.createElement(${f}, { flexDirection: "column" },`),p.push(`${h}.createElement(${f}, null, ${h}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${d}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let C of n)C=C.replace("CHALK_VAR",u),p.push(`${h}.createElement(${f}, null, ${h}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${d}, {dimColor: true}, \` * ${C}\`)),`);p.push("),");const w=p.join(`
184
+ `),x=l;l=l.slice(0,b.startIndex)+w+l.slice(b.endIndex),V(x,l,w,b.startIndex,b.endIndex)}let v=-1;if(o){const b=Ro(l,t,h,f,d,u);if(!b)return console.error("patch: patchesAppliedIndication: patch 4 failed"),null;l=b.content,v=b.closingParenIndex}if(r){if(v===-1){const p=/alignItems:"center",minHeight:9,?/,w=l.match(p);if(!w||w.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find reference point for PATCH 5"),null;v=w.index+w[0].length}const b=Fo(l,v,h,f,d,u,n);if(!b)return console.error("patch: patchesAppliedIndication: patch 5 failed"),null;l=b}return l},Uo=e=>/\\u[0-9a-fA-F]{4}/.test(e),Ho=e=>{const t=e.toString(),n=JSON.stringify(t.substring(1,t.length-1)),o=JSON.stringify(t.match(/\/(\w*)$/)[1]);return`new RegExp(${n}, ${o})`},Go=async(e,t,n)=>{const o=n??Uo(e);T()&&o&&console.log("Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts");const r=await Ft(t,o);T()&&console.log(`Loaded ${r.length} system prompts with regexes`);let i=0,a=0;for(const{promptId:d,prompt:h,regex:f,getInterpolatedContent:v,pieces:b,identifiers:p,identifierMap:w}of r){const x=new RegExp(f,"si"),C=e.match(x);if(C&&C.index!==void 0){const _=v(C),k=Re(b,p,w).trim(),P=k.length,B=h.content.length;i+=P,a+=B,T()&&P!==B&&(console.log(`
185
+ Character count difference for ${h.name}:`),console.log(` Original baseline: ${P} chars`),console.log(` User's version: ${B} chars`),console.log(` Difference: ${P-B} chars`),Math.abs(P-B)<200&&(console.log(`
186
186
  Original baseline content:
187
187
  ${k}`),console.log(`
188
188
  User's content:
189
- ${g.content}`))),M()&&(console.log(`
190
- Found match for prompt: ${g.name}`),console.log(` Match location: index ${C.index}, length ${C[0].length}`),console.log(` Original content (first 100 chars): ${C[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${_.substring(0,100)}...`),console.log(` Captured variables: ${C.slice(1).join(", ")}`),console.log(` Content identical: ${C[0]===_}`));const V=e,K=C.index,U=C[0].length;e=e.replace(x,_);const A=Ye(g.content);await vt(d,A),M()&&G(V,e,_,K,K+U)}else if(console.log(Q.yellow(`Could not find system prompt "${g.name}" in cli.js (using regex ${Vr(x)})`)),M()){console.log(`
191
- Debug info for ${g.name}:`),console.log(` Regex pattern (first 200 chars): ${f.substring(0,200)}...`),console.log(" Trying to match pattern in cli.js...");const _=e.match(new RegExp(f.substring(0,100)));console.log(` Partial match result: ${_?"found partial":"no match"}`)}}const a=[],u=i-l;return u>0?a.push(`system prompts: \${CHALK_VAR.green('${u} fewer chars')} than original`):u<0&&a.push(`system prompts: \${CHALK_VAR.red('${Math.abs(u)} more chars')} than original`),{newContent:e,items:a}},jr=e=>{const t=/ensureServerStarted:([$\w]+)\b/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: fixLspSupport: failed to find ensureServerStarted"),null;const r=Math.max(0,n.index-50),o=Math.min(e.length,n.index+50),i=e.slice(r,o),l=/sendRequest:([$\w]+)[,}]/,a=i.match(l);if(!a)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([r,o,i])}`),null;const u=a[1],d=Math.max(0,n.index-2e3),g=e.slice(d,n.index),f=new RegExp(`async function ${we(u)}\\(([$\\w]+),`,"g");let v,b=null;for(;(v=f.exec(g))!==null;)b=v;if(!b)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=b[1],w=d+b.index,x=e.slice(w,n.index),C=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,_=x.match(C);if(!_||_.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const k=_[1],P=w+_.index+_[0].length,O=e.slice(P,n.index),V=new RegExp(`if\\(!${we(k)}\\)return;`),K=O.match(V);if(!K||K.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const U=P+K.index+K[0].length;return{startIndex:U,endIndex:U,identifiers:[p,k]}},Hr=e=>{const 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;let o=e;const i=o;o=o.replace(t,""),o!==i?G(i,o,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const l=o;o=o.replace(n,""),o!==l?G(l,o,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const a=o;o=o.replace(r,""),o!==a?G(a,o,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=jr(o);if(!u||!u.identifiers)return null;const[d,g]=u.identifiers,f=`
189
+ ${h.content}`))),T()&&(console.log(`
190
+ Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.index}, length ${C[0].length}`),console.log(` Original content (first 100 chars): ${C[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${_.substring(0,100)}...`),console.log(` Captured variables: ${C.slice(1).join(", ")}`),console.log(` Content identical: ${C[0]===_}`));const j=e,K=C.index,U=C[0].length;e=e.replace(x,_);const A=Ye(h.content);await _t(d,A),T()&&V(j,e,_,K,K+U)}else if(console.log(Q.yellow(`Could not find system prompt "${h.name}" in cli.js (using regex ${Ho(x)})`)),T()){console.log(`
191
+ Debug info for ${h.name}:`),console.log(` Regex pattern (first 200 chars): ${f.substring(0,200)}...`),console.log(" Trying to match pattern in cli.js...");const _=e.match(new RegExp(f.substring(0,100)));console.log(` Partial match result: ${_?"found partial":"no match"}`)}}const l=[],u=i-a;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}},zo=e=>{const t=/ensureServerStarted:([$\w]+)\b/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: fixLspSupport: failed to find ensureServerStarted"),null;const o=Math.max(0,n.index-50),r=Math.min(e.length,n.index+50),i=e.slice(o,r),a=/sendRequest:([$\w]+)[,}]/,l=i.match(a);if(!l)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([o,r,i])}`),null;const u=l[1],d=Math.max(0,n.index-2e3),h=e.slice(d,n.index),f=new RegExp(`async function ${we(u)}\\(([$\\w]+),`,"g");let v,b=null;for(;(v=f.exec(h))!==null;)b=v;if(!b)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=b[1],w=d+b.index,x=e.slice(w,n.index),C=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,_=x.match(C);if(!_||_.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const k=_[1],P=w+_.index+_[0].length,B=e.slice(P,n.index),j=new RegExp(`if\\(!${we(k)}\\)return;`),K=B.match(j);if(!K||K.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const U=P+K.index+K[0].length;return{startIndex:U,endIndex:U,identifiers:[p,k]}},Yo=e=>{const 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,o=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g;let r=e;const i=r;r=r.replace(t,""),r!==i?V(i,r,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const a=r;r=r.replace(n,""),r!==a?V(a,r,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const l=r;r=r.replace(o,""),r!==l?V(l,r,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=zo(r);if(!u||!u.identifiers)return null;const[d,h]=u.identifiers,f=`
192
192
  const path = await import('path');
193
193
  const ext = path.extname(${d}).toLowerCase();
194
194
  const langMap = {
@@ -329,7 +329,7 @@ Found match for prompt: ${g.name}`),console.log(` Match location: index ${C.ind
329
329
  try {
330
330
  const fs = await import('fs/promises');
331
331
  const text = await fs.readFile(${d}, 'utf8');
332
- await ${g}.sendNotification('textDocument/didOpen', {
332
+ await ${h}.sendNotification('textDocument/didOpen', {
333
333
  textDocument: {
334
334
  uri: "file://" + ${d},
335
335
  languageId: languageId,
@@ -338,22 +338,22 @@ Found match for prompt: ${g.name}`),console.log(` Match location: index ${C.ind
338
338
  }
339
339
  });
340
340
  } catch (openErr) { }
341
- `,v=o.slice(0,u.startIndex)+f+o.slice(u.endIndex);return G(o,v,f,u.startIndex,u.endIndex),v},Gr=e=>{const t=/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findSelectComponentName: failed to find selectPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r[1]},zr=e=>{const t=/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findDividerComponentName: failed to find dividerPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r[1]},Yn=e=>{const t=/function ([$\w]+)\(\{(?:(?:commands|debug|initialPrompt|initialTools|initialMessages|initialCheckpoints|initialFileHistorySnapshots|mcpClients|dynamicMcpConfig|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r.index===void 0?(console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch"),null):r.index+r[0].length},Wn=e=>{const t=Yn(e);if(t===null)return console.error("patch: getAppStateVarAndGetterFunction: failed to find bodyStart"),null;const n=e.slice(t,t+20),r=/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/,o=n.match(r);return o?{appStateVar:o[1],appStateGetterFunction:o[2]}:(console.error("patch: getAppStateVarAndGetterFunction: failed to find statePattern"),null)},Yr=e=>{const t=Yn(e);if(t===null)return console.error("patch: getToolFetchingUseMemoLocation: failed to find bodyStart"),null;const n=e.slice(t,t+300),r=/let ([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4\]\)/,o=n.match(r);if(!o||o.index===void 0)return console.error("patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern"),null;const i=t+o.index,l=i+o[0].length;return{startIndex:i,endIndex:l,outputVarName:o[1],reactVarName:o[2],toolFilterFunction:o[3],toolPermissionContextVar:o[4]}},Jn=e=>{const t=/=>\[([$a-zA-Z_][$\w]{1,2},){30}/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: findSlashCommandListEndPosition: failed to find arrayStartPattern"),null;const r=e.indexOf("[",n.index);if(r===-1)return console.error("patch: findSlashCommandListEndPosition: failed to find bracketIndex"),null;let o=1,i=r+1;for(;i<e.length&&o>0;){if(e[i]==="[")o++;else if(e[i]==="]"&&(o--,o===0))return i;i++}return console.error("patch: findSlashCommandListEndPosition: failed to find matching closing-bracket"),null},Wr=e=>{const t=Jn(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},Jr=(e,t)=>{const n=/thinkingEnabled:([$\w]+)\(\)/g,r=Array.from(e.matchAll(n));if(r.length===0)return console.error("patch: toolsets: failed to find thinkingEnabled pattern"),null;const o=[];for(const u of r)if(u.index!==void 0){const d=u.index+u[0].length;o.push({index:d})}o.sort((u,d)=>d.index-u.index);let i=e;const a=`,toolset:${t?JSON.stringify(t):"undefined"}`;for(const u of o)i=i.slice(0,u.index)+a+i.slice(u.index);return i===e?(console.error("patch: toolsets: failed to modify app state initialization"),null):i},Kr=(e,t)=>{const n=Yr(e);if(!n)return console.error("patch: toolsets: failed to find tool fetching useMemo location"),null;const r=Wn(e);if(!r)return console.error("patch: toolsets: failed to find app state info"),null;const{appStateVar:o}=r,{startIndex:i,endIndex:l,outputVarName:a,reactVarName:u,toolFilterFunction:d,toolPermissionContextVar:g}=n,f=JSON.stringify(Object.fromEntries(t.map(p=>[p.name,p.allowedTools==="*"?"*":p.allowedTools]))),v=`let ${a} = ${u}.useMemo(() => {
341
+ `,v=r.slice(0,u.startIndex)+f+r.slice(u.endIndex);return V(r,v,f,u.startIndex,u.endIndex),v},Jn=e=>{const t=/=>\[([$a-zA-Z_][$\w]{1,2},){30}/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: findSlashCommandListEndPosition: failed to find arrayStartPattern"),null;const o=e.indexOf("[",n.index);if(o===-1)return console.error("patch: findSlashCommandListEndPosition: failed to find bracketIndex"),null;let r=1,i=o+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},Kn=(e,t)=>{const n=Jn(e);if(n===null)return console.error("patch: writeSlashCommandDefinition: failed to find slash command array end position"),null;const o=e.slice(0,n)+t+e.slice(n);return V(e,o,t,n,n),o},Wo=e=>{const t=/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findSelectComponentName: failed to find selectPattern"),null;let o=n[0];for(const r of n)r[0].length>o[0].length&&(o=r);return o[1]},Jo=e=>{const t=/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findDividerComponentName: failed to find dividerPattern"),null;let o=n[0];for(const r of n)r[0].length>o[0].length&&(o=r);return o[1]},qn=e=>{const t=/function ([$\w]+)\(\{(?:(?:commands|debug|initialPrompt|initialTools|initialMessages|initialCheckpoints|initialFileHistorySnapshots|mcpClients|dynamicMcpConfig|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern"),null;let o=n[0];for(const r of n)r[0].length>o[0].length&&(o=r);return o.index===void 0?(console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch"),null):o.index+o[0].length},an=e=>{const t=qn(e);if(t===null)return console.error("patch: getAppStateVarAndGetterFunction: failed to find bodyStart"),null;const n=e.slice(t,t+20),o=/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/,r=n.match(o);return r?{appStateVar:r[1],appStateGetterFunction:r[2]}:(console.error("patch: getAppStateVarAndGetterFunction: failed to find statePattern"),null)},Ko=e=>{const t=qn(e);if(t===null)return console.error("patch: getToolFetchingUseMemoLocation: failed to find bodyStart"),null;const n=e.slice(t,t+300),o=/let ([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4\]\)/,r=n.match(o);if(!r||r.index===void 0)return console.error("patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern"),null;const i=t+r.index,a=i+r[0].length;return{startIndex:i,endIndex:a,outputVarName:r[1],reactVarName:r[2],toolFilterFunction:r[3],toolPermissionContextVar:r[4]}},qo=e=>{const t=Jn(e);if(t===null)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd"),null;let n=1,o=t;for(;o>=0&&n>0;){if(e[o]==="}")n++;else if(e[o]==="{"&&(n--,n===0))break;o--}if(o<0)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace"),null;for(;o>=0&&e[o]!==";";)o--;return o<0?(console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon"),null):o+1},Xo=(e,t)=>{const n=/thinkingEnabled:([$\w]+)\(\)/g,o=Array.from(e.matchAll(n));if(o.length===0)return console.error("patch: toolsets: failed to find thinkingEnabled pattern"),null;const r=[];for(const u of o)if(u.index!==void 0){const d=u.index+u[0].length;r.push({index:d})}r.sort((u,d)=>d.index-u.index);let i=e;const l=`,toolset:${t?JSON.stringify(t):"undefined"}`;for(const u of r)i=i.slice(0,u.index)+l+i.slice(u.index);return i===e?(console.error("patch: toolsets: failed to modify app state initialization"),null):i},Zo=(e,t)=>{const n=Ko(e);if(!n)return console.error("patch: toolsets: failed to find tool fetching useMemo location"),null;const o=an(e);if(!o)return console.error("patch: toolsets: failed to find app state info"),null;const{appStateVar:r}=o,{startIndex:i,endIndex:a,outputVarName:l,reactVarName:u,toolFilterFunction:d,toolPermissionContextVar:h}=n,f=JSON.stringify(Object.fromEntries(t.map(p=>[p.name,p.allowedTools==="*"?"*":p.allowedTools]))),v=`let ${l} = ${u}.useMemo(() => {
342
342
  const toolsets = ${f};
343
- if (toolsets.hasOwnProperty(${o}.toolset)) {
344
- const allowedTools = toolsets[${o}.toolset];
343
+ if (toolsets.hasOwnProperty(${r}.toolset)) {
344
+ const allowedTools = toolsets[${r}.toolset];
345
345
  if (allowedTools === "*") {
346
- return ${d}(${g});
346
+ return ${d}(${h});
347
347
  } else {
348
- return ${d}(${g}).filter(toolDef =>
348
+ return ${d}(${h}).filter(toolDef =>
349
349
  allowedTools.includes(toolDef.name)
350
350
  );
351
351
  }
352
352
  } else {
353
- return ${d}(${g});
353
+ return ${d}(${h});
354
354
  }
355
- }, [${d}, ${o}.toolset])`,b=e.slice(0,i)+v+e.slice(l);return G(e,b,v,i,l),b},qr=(e,t)=>{const n=Wr(e);if(n===null)return console.error("patch: toolsets: failed to find slash command insertion point"),null;const r=an(e);if(!r)return console.error("patch: toolsets: failed to find React variable"),null;const o=Xn(e);if(!o)return console.error("patch: toolsets: failed to find Box component"),null;const i=qn(e);if(!i)return console.error("patch: toolsets: failed to find Text component"),null;const l=Gr(e);if(!l)return console.error("patch: toolsets: failed to find Select component"),null;const a=zr(e);if(!a)return console.error("patch: toolsets: failed to find Divider component"),null;const u=Wn(e);if(!u)return console.error("patch: toolsets: failed to find app state getter"),null;const d=ln(e);if(!d)return console.error("patch: toolsets: failed to find chalk variable"),null;const{appStateGetterFunction:g}=u,f=JSON.stringify(t.map(w=>w.name)),v=JSON.stringify(t.map(w=>({label:w.name,value:w.name,description:w.allowedTools==="*"?"All tools":w.allowedTools.length===0?"No tools":`${w.allowedTools.length} tool${w.allowedTools.length!==1?"s":""}: ${w.allowedTools.join(", ")}`}))),b=`const toolsetComp = ({ onExit, input }) => {
356
- const [state, setState] = ${g}();
355
+ }, [${d}, ${r}.toolset])`,b=e.slice(0,i)+v+e.slice(a);return V(e,b,v,i,a),b},Qo=(e,t)=>{const n=qo(e);if(n===null)return console.error("patch: toolsets: failed to find slash command insertion point"),null;const o=We(e);if(!o)return console.error("patch: toolsets: failed to find React variable"),null;const r=Qn(e);if(!r)return console.error("patch: toolsets: failed to find Box component"),null;const i=Zn(e);if(!i)return console.error("patch: toolsets: failed to find Text component"),null;const a=Wo(e);if(!a)return console.error("patch: toolsets: failed to find Select component"),null;const l=Jo(e);if(!l)return console.error("patch: toolsets: failed to find Divider component"),null;const u=an(e);if(!u)return console.error("patch: toolsets: failed to find app state getter"),null;const d=cn(e);if(!d)return console.error("patch: toolsets: failed to find chalk variable"),null;const{appStateGetterFunction:h}=u,f=JSON.stringify(t.map(w=>w.name)),v=JSON.stringify(t.map(w=>({label:w.name,value:w.name,description:w.allowedTools==="*"?"All tools":w.allowedTools.length===0?"No tools":`${w.allowedTools.length} tool${w.allowedTools.length!==1?"s":""}: ${w.allowedTools.join(", ")}`}))),b=`const toolsetComp = ({ onExit, input }) => {
356
+ const [state, setState] = ${h}();
357
357
 
358
358
  // Handle command-line argument
359
359
  if (input !== "" && input != null) {
@@ -368,43 +368,43 @@ Found match for prompt: ${g.name}`),console.log(` Match location: index ${C.ind
368
368
  }
369
369
 
370
370
  // Render interactive UI
371
- return ${r}.createElement(
372
- ${o},
371
+ return ${o}.createElement(
372
+ ${r},
373
373
  { flexDirection: "column" },
374
- ${r}.createElement(${a}, { dividerColor: "permission" }),
375
- ${r}.createElement(
376
- ${o},
374
+ ${o}.createElement(${l}, { dividerColor: "permission" }),
375
+ ${o}.createElement(
376
+ ${r},
377
377
  { paddingX: 1, marginBottom: 1, flexDirection: "column" },
378
- ${r}.createElement(${o}, null,
379
- ${r}.createElement(${i}, { bold: true, color: "remember" }, "Select toolset")
378
+ ${o}.createElement(${r}, null,
379
+ ${o}.createElement(${i}, { bold: true, color: "remember" }, "Select toolset")
380
380
  ),
381
- ${r}.createElement(${o}, null,
382
- ${r}.createElement(${i}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
381
+ ${o}.createElement(${r}, null,
382
+ ${o}.createElement(${i}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
383
383
  ),
384
- ${r}.createElement(${o}, { marginBottom: 1 },
385
- ${r}.createElement(${i}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
384
+ ${o}.createElement(${r}, { marginBottom: 1 },
385
+ ${o}.createElement(${i}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
386
386
  ),
387
- ${r}.createElement(${o}, null,
388
- ${r}.createElement(${i}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
387
+ ${o}.createElement(${r}, null,
388
+ ${o}.createElement(${i}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
389
389
  ),
390
- ${r}.createElement(${o}, { marginBottom: 1 },
391
- ${r}.createElement(${i}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
390
+ ${o}.createElement(${r}, { marginBottom: 1 },
391
+ ${o}.createElement(${i}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
392
392
  ),
393
- ${r}.createElement(${o}, null,
394
- ${r}.createElement(${i}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc. "),
395
- ${r}.createElement(${i}, { dimColor: true }, "Run "),
396
- ${r}.createElement(${i}, { color: "permission" }, "npx tweakcc"),
397
- ${r}.createElement(${i}, { dimColor: true }, " to manage them.")
393
+ ${o}.createElement(${r}, null,
394
+ ${o}.createElement(${i}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc. "),
395
+ ${o}.createElement(${i}, { dimColor: true }, "Run "),
396
+ ${o}.createElement(${i}, { color: "permission" }, "npx tweakcc"),
397
+ ${o}.createElement(${i}, { dimColor: true }, " to manage them.")
398
398
  ),
399
- ${r}.createElement(${o}, { marginBottom: 1 },
400
- ${r}.createElement(${i}, { color: "permission" }, "https://github.com/Piebald-AI/tweakcc")
399
+ ${o}.createElement(${r}, { marginBottom: 1 },
400
+ ${o}.createElement(${i}, { color: "permission" }, "https://github.com/Piebald-AI/tweakcc")
401
401
  ),
402
- ${r}.createElement(${o}, { marginBottom: 1 },
403
- ${r}.createElement(${i}, null, "Current toolset: "),
404
- ${r}.createElement(${i}, { bold: true }, state.toolset || "undefined")
402
+ ${o}.createElement(${r}, { marginBottom: 1 },
403
+ ${o}.createElement(${i}, null, "Current toolset: "),
404
+ ${o}.createElement(${i}, { bold: true }, state.toolset || "undefined")
405
405
  ),
406
- ${r}.createElement(${o}, { marginBottom: 1 },
407
- ${r}.createElement(${l}, {
406
+ ${o}.createElement(${r}, { marginBottom: 1 },
407
+ ${o}.createElement(${a}, {
408
408
  options: ${v},
409
409
  onChange: (input) => {
410
410
  setState(prev => ({ ...prev, toolset: input }));
@@ -413,10 +413,10 @@ Found match for prompt: ${g.name}`),console.log(` Match location: index ${C.ind
413
413
  onCancel: () => onExit(\`Toolset not changed (left as \${${d}.bold(state.toolset)})\`)
414
414
  })
415
415
  ),
416
- ${r}.createElement(${i}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
416
+ ${o}.createElement(${i}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
417
417
  )
418
418
  );
419
- };`,p=e.slice(0,n)+b+e.slice(n);return G(e,p,b,n,n),p},Xr=e=>{const t=Jn(e);if(t===null)return console.error("patch: toolsets: failed to find slash command array end position"),null;const n=an(e);if(!n)return console.error("patch: toolsets: failed to find React variable"),null;const r=`, {
419
+ };`,p=e.slice(0,n)+b+e.slice(n);return V(e,p,b,n,n),p},er=e=>{const t=/\{color:"bashBorder"\},"! for bash mode"/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find bash mode pattern"),null;const o=Math.max(0,n.index-500),r=e.slice(o,n.index),i=/function ([$\w]+)\(\{[^}]+\}\)\{/g,a=Array.from(r.matchAll(i));if(a.length===0)return console.error("patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find function pattern"),null;const l=a[a.length-1];return l.index===void 0?(console.error("patch: toolsets: findShiftTabAppStateVarInsertionPoint: match has no index"),null):o+l.index+l[0].length},nr=e=>{const t=er(e);if(t===null)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point"),null;const n=an(e);if(!n)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter"),null;const{appStateGetterFunction:o}=n,r=`let[state]=${o}();`,i=e.slice(0,t)+r+e.slice(t);return V(e,i,r,t,t),i},tr=e=>{const t=/([$\w]+)\((\w+)\)\.toLowerCase\(\)," on"/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: toolsets: appendToolsetToModeDisplay: failed to find mode display pattern"),null;const o=n[1],r=n[2],i=n[0],a=`${o}(${r}).toLowerCase()," on [",state.toolset||"undefined","]"`,l=e.replace(i,a);return l===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(V(e,l,a,n.index,n.index+i.length),l)},or=e=>{const t=/"\? for shortcuts"/g,o=Array.from(e.matchAll(t)).at(-1);if(!o||o.index===void 0)return console.error("patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'"),null;const r=o[0],i='"? for shortcuts [",state.toolset||"undefined","]"',a=e.replace(r,i);return a===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(V(e,a,i,o.index,o.index+r.length),a)},rr=e=>{const t=We(e);if(!t)return console.error("patch: toolsets: failed to find React variable"),null;const n=`, {
420
420
  aliases: ["change-tools"],
421
421
  type: "local-jsx",
422
422
  name: "toolset",
@@ -425,36 +425,249 @@ Found match for prompt: ${g.name}`),console.log(` Match location: index ${C.ind
425
425
  isEnabled: () => true,
426
426
  isHidden: false,
427
427
  async call(onExit, ctx, input) {
428
- return ${n}.createElement(toolsetComp, { onExit, input });
428
+ return ${t}.createElement(toolsetComp, { onExit, input });
429
429
  },
430
430
  userFacingName() {
431
431
  return "toolset";
432
432
  }
433
- }`,o=e.slice(0,t)+r+e.slice(t);return G(e,o,r,t,t),o},Zr=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=Jr(r,n),r?(r=Kr(r,t),r?(r=qr(r,t),r?(r=Xr(r),r||(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)},G=(e,t,n,r,o)=>{const i=Math.max(0,r-20),l=Math.min(e.length,o+20),a=Math.min(t.length,r+n.length+20),u=e.slice(i,r),d=e.slice(r,o),g=e.slice(o,l),f=t.slice(i,r),v=t.slice(r,r+n.length),b=t.slice(r+n.length,a);M()&&d!==v&&(console.log(`
434
- --- Diff ---`),console.log("OLD:",u+`\x1B[31m${d}\x1B[0m`+g),console.log("NEW:",f+`\x1B[32m${v}\x1B[0m`+b),console.log(`--- End Diff ---
435
- `))},we=e=>e.replace(/\$/g,"\\$"),ln=e=>{const t=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,n=Array.from(e.matchAll(t)),r={};for(const l of n){const a=l[1];r[a]=(r[a]||0)+1}let o,i=0;for(const[l,a]of Object.entries(r))a>i&&(i=a,o=l);return o},Qr=e=>{const t=e.slice(0,1e3),n=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,r=t.match(n);if(!r){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return r[1]},Kn=e=>{const t=/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.element"\)/,n=e.match(t);if(!n){console.log("patch: getReactModuleNameNonBun: failed to find React module name");return}return n[1]},eo=e=>{const t=Kn(e);if(!t){console.log("^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)");return}const n=new RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${we(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 ge=null;const an=e=>{if(ge!=null)return ge;const t=Qr(e);if(!t){console.log("^ patch: getReactVar: failed to find moduleLoader"),ge=void 0;return}const n=Kn(e);if(!n){console.log("^ patch: getReactVar: failed to find reactModuleVarNonBun"),ge=void 0;return}const r=new RegExp(`\\b([$\\w]+)=${we(t)}\\(${we(n)}\\(\\),1\\)`),o=e.match(r);if(o)return ge=o[1],ge;const i=eo(e);if(!i){console.log("^ patch: getReactVar: failed to find reactModuleFunctionBun"),ge=void 0;return}const l=new RegExp(`\\b([$\\w]+)=${we(t)}\\(${we(i)}\\(\\),1\\)`),a=e.match(l);if(!a){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${i})`),ge=void 0;return}return ge=a[1],ge},qn=e=>{const t=/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/,n=e.match(t);if(!n){console.log("patch: findTextComponent: failed to find text component");return}return n[1]},Xn=e=>{const t=/\b([$\w]+)\.displayName="Box"/,n=e.match(t);if(!n){console.error("patch: findBoxComponent: failed to find Box displayName");return}const r=n[1],o=new RegExp(`\\b([$\\w]+)=${we(r)}[^$\\w]`),i=e.match(o);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${r})`);return}return i[1]},Zn=async(e,t)=>{let n;if(t.nativeInstallationPath){await Xt(t);let u=!1;try{await te.stat(ae),u=!0}catch{}const d=u?ae:t.nativeInstallationPath;M()&&console.log(`Extracting claude.js from ${u?"backup":"native installation"}: ${d}`);const g=jn(d);if(!g)throw new Error("Failed to extract claude.js from native installation");const f=re.join(ye.homedir(),".tweakcc"),v=re.join(f,"native-claudejs-orig.js");Ee.writeFileSync(v,g),M()&&console.log(`Saved original extracted JS from native to: ${v}`),n=g.toString("utf8")}else{if(await Gn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await te.readFile(t.cliPath,{encoding:"utf8"})}const r=[],o=await Ur(n,t.version);n=o.newContent,r.push(...o.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=or(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=$r(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=gr(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=pr(n,e.settings.thinkingStyle.phases))&&(n=i),(i=wr(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=yr(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=fr(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=Ir(n,e.settings.userMessageDisplay.prefix.format,e.settings.userMessageDisplay.prefix.foreground_color,e.settings.userMessageDisplay.prefix.background_color,e.settings.userMessageDisplay.prefix.styling.includes("bold"),e.settings.userMessageDisplay.prefix.styling.includes("italic"),e.settings.userMessageDisplay.prefix.styling.includes("underline"),e.settings.userMessageDisplay.prefix.styling.includes("strikethrough"),e.settings.userMessageDisplay.prefix.styling.includes("inverse"),e.settings.userMessageDisplay.message.foreground_color,e.settings.userMessageDisplay.message.background_color,e.settings.userMessageDisplay.message.styling.includes("bold"),e.settings.userMessageDisplay.message.styling.includes("italic"),e.settings.userMessageDisplay.message.styling.includes("underline"),e.settings.userMessageDisplay.message.styling.includes("strikethrough"),e.settings.userMessageDisplay.message.styling.includes("inverse")))&&(n=i),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder=="boolean"&&(i=ar(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Er(n))&&(n=i),(i=dr(n))&&(n=i),(i=sr(n))&&(n=i),(i=ro(n))&&(n=i),(i=tr(n,25))&&(n=i),(i=Mr(n))&&(n=i),(i=Or(n))&&(n=i);const l=e.settings.misc?.showTweakccVersion??!0,a=e.settings.misc?.showPatchesApplied??!0;if((i=Rr(n,"3.0.1",r,l,a))&&(n=i),(i=Hr(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=Zr(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),t.nativeInstallationPath){M()&&console.log(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);const u=re.join(ye.homedir(),".tweakcc"),d=re.join(u,"native-claudejs-patched.js");Ee.writeFileSync(d,n,"utf8"),M()&&console.log(`Saved patched JS from native to: ${d}`);const g=Buffer.from(n,"utf8");Kt(t.nativeInstallationPath,g,t.nativeInstallationPath)}else{if(!t.cliPath)throw new Error("cliPath is required for NPM installations");await un(t.cliPath,n,"patch")}return await Ve(u=>{u.changesApplied=!0})},Qn=[{label:"Opus 4.1",slug:"opus-4.1",internal:"claude-opus-4-1-20250805"},{label:"Opus 4",slug:"opus-4",internal:"claude-opus-4-20250514"},{label:"Sonnet 4",slug:"sonnet-4",internal:"claude-sonnet-4-20250514"},{label:"Sonnet 3.7",slug:"sonnet-3.7",internal:"claude-3-7-sonnet-20250219"},{label:"Sonnet 3.5 (October)",slug:"sonnet-3.5-october",internal:"claude-3-5-sonnet-20241022"},{label:"Sonnet 3.5 (June)",slug:"sonnet-3.5-june",internal:"claude-3-5-sonnet-20240620"},{label:"Haiku 3.5",slug:"haiku-3.5",internal:"claude-3-5-haiku-20241022"},{label:"Haiku 3",slug:"haiku-3",internal:"claude-3-haiku-20240307"},{label:"Opus 3",slug:"opus-3",internal:"claude-3-opus-20240229"}],no=e=>{const t=e.indexOf("Switch between Claude models");if(t===-1)return console.error("patch: getModelSelectorInsertionPoint: failed to find labelIndex"),null;const n=Math.max(0,t-600),r=t,i=e.slice(n,r).match(/\[[$\w]+,\s*[$\w]+\]\s*=\s*[$\w]+\.useState\([^)]*\)\s*,\s*([$\w]+)=/);if(!i||i.index===void 0)return console.error("patch: getModelSelectorInsertionPoint: failed to find useState"),null;let a=n+i.index;for(;a<e.length&&e[a]!==";";)a++;if(a>=e.length)return console.error("patch: getModelSelectorInsertionPoint: failed to find semicolon"),null;const u=a+1,d=i[1];return{insertionIndex:u,optionsVar:d}},to=e=>{const t=no(e);if(!t)return null;const{insertionIndex:n,optionsVar:r}=t,o=Qn.map(l=>{const a=JSON.stringify(l.label),u=JSON.stringify(l.slug);return`${r}.push({value:${u},label:${a}});`}).join(""),i=e.slice(0,n)+o+e.slice(n);return G(e,i,o,n,n),i},ro=e=>{let t=e;const n=to(t);return n&&(t=n),t===e?null:t};let et=!1;const M=()=>et,oo=()=>{et=!0};function cn(){try{const e=re.join(ye.homedir(),".claude.json");return JSON.parse(Ee.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function io(){try{const e=re.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ee.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 so(){try{const e=re.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ee.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const r=Qn.find(o=>o.slug===n);if(r)return r.label}catch{}return"Sonnet 4.5"}function lo(e){process.platform==="win32"?Be.spawn("explorer",[e],{detached:!0,stdio:"ignore"}).unref():process.platform==="darwin"?Be.spawn("open",[e],{detached:!0,stdio:"ignore"}).unref():Be.spawn("xdg-open",[e],{detached:!0,stdio:"ignore"}).unref()}function In(e){if(process.platform==="win32")Be.spawn("explorer",["/select,",e],{detached:!0,stdio:"ignore"}).unref();else if(process.platform==="darwin")Be.spawn("open",["-R",e],{detached:!0,stdio:"ignore"}).unref();else{const t=re.dirname(e);Be.spawn("xdg-open",[t],{detached:!0,stdio:"ignore"}).unref()}}function dn(e){if(!e||typeof e!="string")return!1;const 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)){const n=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const[,r,o,i]=n;return parseInt(r)<=255&&parseInt(o)<=255&&parseInt(i)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const[,r,o,i]=n;return parseInt(r)<=360&&parseInt(o)<=100&&parseInt(i)<=100}}return!1}function nt(e){if(!dn(e))return e;const t=e.trim();if(t.startsWith("rgb("))return t;if(t.startsWith("#")){let n=t.slice(1);n.length===3&&(n=n.split("").map(l=>l+l).join(""));const r=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),i=parseInt(n.slice(4,6),16);return`rgb(${r},${o},${i})`}if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const r=parseInt(n[1])/360,o=parseInt(n[2])/100,i=parseInt(n[3])/100,l=(v,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?v+(b-v)*6*p:p<1/2?b:p<2/3?v+(b-v)*(2/3-p)*6:v),a=i<.5?i*(1+o):i+o-i*o,u=2*i-a,d=Math.round(l(u,a,r+1/3)*255),g=Math.round(l(u,a,r)*255),f=Math.round(l(u,a,r-1/3)*255);return`rgb(${d},${g},${f})`}}return e}async function ao(e,t="sha256",n=64*1024){return new Promise((r,o)=>{const i=Bn.createHash(t),l=Ee.createReadStream(e,{highWaterMark:n});l.on("data",a=>{i.update(a)}),l.on("end",()=>{r(i.digest("hex"))}),l.on("error",a=>{o(a)})})}const Cn=(e,t,n,r,o,i,l,a)=>{let u=e;return t&&(u+=`.rgb(${t})`),n&&n!=="transparent"&&(u+=`.bgRgb(${n})`),r&&(u+=".bold"),o&&(u+=".italic"),i&&(u+=".underline"),l&&(u+=".strikethrough"),a&&(u+=".inverse"),u};async function un(e,t,n="replace"){let r=493;try{r=(await te.stat(e)).mode,M()&&console.log(`[${n}] Original file mode for ${e}: ${(r&parseInt("777",8)).toString(8)}`)}catch(o){M()&&console.log(`[${n}] Could not stat ${e} (error: ${o}), using default mode 755`)}try{await te.unlink(e),M()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(o){M()&&console.log(`[${n}] Could not unlink ${e}: ${o}`)}await te.writeFile(e,t),await te.chmod(e,r),M()&&console.log(`[${n}] Restored permissions to ${(r&parseInt("777",8)).toString(8)}`)}function F({color:e,backgroundColor:t,bold:n,dimColor:r,children:o}){const i=e?.startsWith("ansi:"),l=t?.startsWith("ansi:");if(i||l){if(Je.Children.toArray(o).some(f=>Je.isValidElement(f)))return s(c,{children:o});let u=Q;if(i){const f=e.slice(5);u=u[f]||u}if(l){const f=t.slice(5),v=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[v]||u}n&&(u=u.bold),r&&(u=u.dim);const g=Je.Children.toArray(o).map(f=>typeof f=="string"||typeof f=="number"?String(f):"").join("");return s(c,{children:u(g)})}return s(c,{color:e,backgroundColor:t,bold:n,dimColor:r,children:o})}function co({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:r=3,updateDuration:o=50,restartPoint:i=10}){const[l,a]=T(0);return xe(()=>{const u=setInterval(()=>{a(d=>{const g=d+1;return g>=e.length+i?-r:g})},o);return()=>clearInterval(u)},[e.length,i,o]),t.length!==n.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(c,{children:e})):s(c,{children:e.split("").map((u,d)=>{const g=d>=l&&d<l+r&&l<e.length,f=d%t.length,v=g?n[f]:t[f];return s(c,{color:v,children:u},d)})})}const uo=ct.cwd();function tt({theme:e}){const{ccVersion:t}=pe(ue);return h(m,{flexDirection:"column",paddingLeft:1,children:[s(m,{marginBottom:1,children:h(c,{bold:!0,children:["Preview: ",e.name]})}),s(m,{borderStyle:"single",borderColor:"gray",paddingX:1,children:h(m,{flexDirection:"column",children:[h(m,{flexDirection:"column",children:[h(c,{children:[s(F,{color:e.colors.clawd_body,children:" ▐"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),h(c,{children:[s(F,{color:e.colors.clawd_body,children:"▌ "})," ",s(c,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),h(c,{children:[s(F,{color:e.colors.clawd_body,children:"▝▜"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(F,{color:e.colors.clawd_body,children:"▛▘"})," ",so()," · ",io()]}),h(F,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",uo]}),h(c,{children:[h(F,{color:e.colors.success,children:["Login successful. Press"," "]}),s(F,{bold:!0,color:e.colors.success,children:"Enter"}),h(F,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(c,{children:"╭─────────────────────────────────────────────╮"}),h(c,{children:["│ 1 function greet() ","{"," ","│"]}),h(c,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(F,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(F,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),h(c,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(F,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(F,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(F,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),h(F,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),h(c,{children:[s(F,{color:e.colors.warning,children:"│ "}),s(c,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),h(F,{color:e.colors.warning,children:[" ","│"]})]}),s(F,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),h(c,{children:[s(F,{color:e.colors.bashBorder,children:"!"}),s(c,{children:" ls"})]}),s(F,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(c,{children:h(c,{children:["> list the dir"," ",s(co,{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})]})}),s(F,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),h(c,{children:[s(F,{color:e.colors.planMode,children:"│ "}),h(F,{color:e.colors.permission,children:["Ready to code?"," "]}),s(c,{children:"Here is Claude's plan:"}),h(F,{color:e.colors.planMode,children:[" ","│"]})]}),s(F,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),h(c,{children:[s(F,{color:e.colors.permission,children:"│ "}),s(c,{bold:!0,children:"Permissions:"})," ",h(F,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(F,{color:e.colors.permission,children:"│"})]}),s(c,{children:"> list the dir"}),h(c,{children:[s(F,{color:e.colors.error,children:"●"}),s(c,{children:" Update(__init__.py)"})]}),h(c,{children:[s(c,{children:" ⎿ "}),s(F,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),h(c,{children:[" ","1"," ",h(F,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(F,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),h(c,{children:[" ","2"," ",h(F,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(F,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),h(c,{children:[s(F,{color:e.colors.success,children:"●"}),s(c,{children:" List(.)"})]}),h(c,{children:[s(c,{children:"●"}),s(c,{children:" The directory "}),s(F,{color:e.colors.permission,children:"C:\\Users\\user"}),h(c,{children:[" ","contains ",s(c,{bold:!0,children:"123"})," files."]})]}),h(c,{children:[s(F,{color:e.colors.claude,children:"✻ Th"}),s(F,{color:e.colors.claudeShimmer,children:"ink"}),s(F,{color:e.colors.claude,children:"ing… "}),s(c,{children:"(esc to interrupt)"})]}),s(c,{children:s(F,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(c,{children:s(F,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(c,{children:s(F,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function Ke({colorKey:e,theme:t,bold:n=!1}){const r=t.colors[e];return e==="inverseText"?s(F,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(F,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):s(F,{color:r,bold:n,children:e})}function rt({initialValue:e,onColorChange:t,onExit:n,colorKey:r,theme:o}){const i=Xe(e)||{h:0,s:50,l:50},l=qe(e)||{r:128,g:128,b:128},[a,u]=T(i),[d,g]=T(l),[f,v]=T("hsl"),[b,p]=T("h"),[w,x]=T(!1),[C,_]=T(!1);xe(()=>{const I=Xe(e),$=qe(e);I&&$&&(x(!0),u(I),g($),x(!1))},[e]),xe(()=>{if(!w&&C){const I=`rgb(${d.r},${d.g},${d.b})`;t(I)}},[a,d,w,C]),xe(()=>{_(!0)},[]);const k=I=>{if(dn(I)){const $=nt(I),S=Xe($),N=qe($);S&&N&&(x(!0),u(S),g(N),x(!1))}};de((I,$)=>{if(I.length>1&&!$.ctrl&&!$.meta){k(I);return}if($.return)n();else if($.escape)n();else if($.ctrl&&I==="a")v(S=>S==="hsl"?"rgb":"hsl"),p(S=>f==="hsl"?S==="h"?"r":S==="s"?"g":"b":S==="r"?"h":S==="g"?"s":"l");else if($.upArrow)p(f==="hsl"?S=>S==="h"?"l":S==="s"?"h":"s":S=>S==="r"?"b":S==="g"?"r":"g");else if($.downArrow||$.tab)p(f==="hsl"?S=>S==="h"?"s":S==="s"?"l":"h":S=>S==="r"?"g":S==="g"?"b":"r");else if($.leftArrow){const S=$.shift||$.ctrl||$.meta?-10:-1;P(S)}else if($.rightArrow){const S=$.shift||$.ctrl||$.meta?10:1;P(S)}});const P=I=>{x(!0),f==="hsl"?u($=>{const S={...$};b==="h"?S.h=Math.max(0,Math.min(359,$.h+I)):b==="s"?S.s=Math.max(0,Math.min(100,$.s+I)):b==="l"&&(S.l=Math.max(0,Math.min(100,$.l+I)));const[N,y,L]=V(S.h,S.s,S.l);return g({r:N,g:y,b:L}),S}):g($=>{const S={...$};b==="r"?S.r=Math.max(0,Math.min(255,$.r+I)):b==="g"?S.g=Math.max(0,Math.min(255,$.g+I)):b==="b"&&(S.b=Math.max(0,Math.min(255,$.b+I)));const N=O(S.r,S.g,S.b);return u(N),S}),x(!1)},O=(I,$,S)=>{const N=I/255,y=$/255,L=S/255,z=Math.max(N,y,L),H=Math.min(N,y,L),ne=z-H,ie=(z+H)/2;let $e=0;ne!==0&&($e=ie>.5?ne/(2-z-H):ne/(z+H));let be=0;return ne!==0&&(z===N?be=((y-L)/ne+(y<L?6:0))/6:z===y?be=((L-N)/ne+2)/6:be=((N-y)/ne+4)/6),{h:Math.round(be*360),s:Math.round($e*100),l:Math.round(ie*100)}},V=(I,$,S)=>{I/=360,$/=100,S/=100;const N=(1-Math.abs(2*S-1))*$,y=N*(1-Math.abs(I*6%2-1)),L=S-N/2;let z=0,H=0,ne=0;return 0<=I&&I<1/6?(z=N,H=y,ne=0):1/6<=I&&I<2/6?(z=y,H=N,ne=0):2/6<=I&&I<3/6?(z=0,H=N,ne=y):3/6<=I&&I<4/6?(z=0,H=y,ne=N):4/6<=I&&I<5/6?(z=y,H=0,ne=N):5/6<=I&&I<1&&(z=N,H=0,ne=y),[Math.round((z+L)*255),Math.round((H+L)*255),Math.round((ne+L)*255)]},K=()=>{const I=[],$=[[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 S=0;S<40;S++){const y=S/39*($.length-1),L=Math.floor(y),z=Math.ceil(y),H=y-L,[ne,ie,$e]=$[L],[be,j,R]=$[z],D=Math.round(ne+(be-ne)*H),ee=Math.round(ie+(j-ie)*H),W=Math.round($e+(R-$e)*H);I.push(s(c,{backgroundColor:`rgb(${D},${ee},${W})`,children:" "},S))}return I},U=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,L]=V(a.h,S,a.l);I.push(s(c,{backgroundColor:`rgb(${N},${y},${L})`,children:" "},$))}return I},A=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,L]=V(a.h,a.s,S);I.push(s(c,{backgroundColor:`rgb(${N},${y},${L})`,children:" "},$))}return I},B=()=>{const[I,$,S]=V(a.h,a.s,a.l);return`rgb(${I},${$},${S})`},E=(I,$,S)=>{const N=y=>y.toString(16).padStart(2,"0");return`#${N(I)}${N($)}${N(S)}`},Y=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${S},${d.g},${d.b})`,children:" "},$))}return I},X=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${d.r},${S},${d.b})`,children:" "},$))}return I},oe=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${d.r},${d.g},${S})`,children:" "},$))}return I},q=(I,$)=>Math.round(I/$*39);return h(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[h(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Color Picker"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(c,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(c,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(c,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(c,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(c,{color:"gray",dimColor:!0,children:"esc to save and exit"})]})]}),f==="hsl"?h(he,{children:[h(m,{marginBottom:1,children:[s(m,{width:25,children:h(c,{color:b==="h"?"yellow":"white",children:[b==="h"?"❯ ":" ","Hue (",a.h,"°):"]})}),s(m,{children:K().map((I,$)=>s(ke,{children:$===q(a.h,360)?s(c,{children:"|"}):I},$))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(c,{color:b==="s"?"yellow":"white",children:[b==="s"?"❯ ":" ","Saturation (",a.s,"%):"]})}),s(m,{children:U().map((I,$)=>s(ke,{children:$===q(a.s,100)?s(c,{children:"|"}):I},$))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(c,{color:b==="l"?"yellow":"white",children:[b==="l"?"❯ ":" ","Lightness (",a.l,"%):"]})}),s(m,{children:A().map((I,$)=>s(ke,{children:$===q(a.l,100)?s(c,{children:"|"}):I},$))})]})]}):h(he,{children:[h(m,{marginBottom:1,children:[s(m,{width:25,children:h(c,{color:b==="r"?"yellow":"white",children:[b==="r"?"❯ ":" ","Red (",d.r,"):"]})}),s(m,{children:Y().map((I,$)=>s(ke,{children:$===q(d.r,255)?s(c,{children:"|"}):I},$))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(c,{color:b==="g"?"yellow":"white",children:[b==="g"?"❯ ":" ","Green (",d.g,"):"]})}),s(m,{children:X().map((I,$)=>s(ke,{children:$===q(d.g,255)?s(c,{children:"|"}):I},$))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(c,{color:b==="b"?"yellow":"white",children:[b==="b"?"❯ ":" ","Blue (",d.b,"):"]})}),s(m,{children:oe().map((I,$)=>s(ke,{children:$===q(d.b,255)?s(c,{children:"|"}):I},$))})]})]}),h(m,{marginBottom:1,children:[s(c,{children:"Current: "}),s(c,{backgroundColor:B(),children:" "})]}),h(m,{flexDirection:"row",justifyContent:"space-between",children:[h(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"Hex "}),r?.startsWith("diff")?s(c,{backgroundColor:B(),color:o?.colors?.text||"white",bold:!0,children:E(d.r,d.g,d.b)}):r==="inverseText"?s(c,{color:B(),backgroundColor:o?.colors?.permission,bold:!0,children:E(d.r,d.g,d.b)}):s(c,{color:B(),bold:!0,children:E(d.r,d.g,d.b)})]}),h(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"RGB "}),r?.startsWith("diff")?s(c,{backgroundColor:B(),color:o?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):r==="inverseText"?s(c,{color:B(),backgroundColor:o?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(c,{color:B(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),h(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"HSL "}),r?.startsWith("diff")?s(c,{backgroundColor:B(),color:o?.colors?.text||"white",bold:!0,children:`hsl(${a.h}, ${a.s}%, ${a.l}%)`}):r==="inverseText"?s(c,{color:B(),backgroundColor:o?.colors?.permission,bold:!0,children:`hsl(${a.h}, ${a.s}%, ${a.l}%)`}):s(c,{color:B(),bold:!0,children:`hsl(${a.h}, ${a.s}%, ${a.l}%)`})]})]})]})}function qe(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};const n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){const r=n[1];return{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16)}}return null}function Xe(e){const t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const o=parseInt(n[1])/255,i=parseInt(n[2])/255,l=parseInt(n[3])/255,a=Math.max(o,i,l),u=Math.min(o,i,l),d=a-u,g=(a+u)/2;let f=0;d!==0&&(f=g>.5?d/(2-a-u):d/(a+u));let v=0;return d!==0&&(a===o?v=((i-l)/d+(i<l?6:0))/6:a===i?v=((l-o)/d+2)/6:v=((o-i)/d+4)/6),{h:Math.round(v*360),s:Math.round(f*100),l:Math.round(g*100)}}const r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){const o=r[1],i=parseInt(o.substr(0,2),16)/255,l=parseInt(o.substr(2,2),16)/255,a=parseInt(o.substr(4,2),16)/255,u=Math.max(i,l,a),d=Math.min(i,l,a),g=u-d,f=(u+d)/2;let v=0;g!==0&&(v=f>.5?g/(2-u-d):g/(u+d));let b=0;return g!==0&&(u===i?b=((l-a)/g+(l<a?6:0))/6:u===l?b=((a-i)/g+2)/6:b=((i-l)/g+4)/6),{h:Math.round(b*360),s:Math.round(v*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function go({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:r}=pe(ue),[o,i]=T(t),l=n.find(A=>A.id===o)||n[0],[a,u]=T("rgb"),[d,g]=T(0),[f,v]=T(null),[b,p]=T(null),[w,x]=T(""),[C,_]=T(""),k=En(A=>{r(B=>{const E=B.themes.findIndex(Y=>Y.id===o);E!==-1&&A(B.themes[E])})},[o,r]),P=A=>{if(d>=2&&dn(A)){const B=nt(A),E=d-2,Y=O[E];k(X=>{X.colors[Y]=B})}};de((A,B)=>{if(f===null&&b===null){if(A.length>1&&!B.ctrl&&!B.meta){P(A);return}if(B.escape)e();else if(B.ctrl&&A==="a")u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(B.upArrow)g(E=>Math.max(0,E-1));else if(B.downArrow)g(E=>Math.min(O.length+1,E+1));else if(B.return)if(d===0)p("name"),x(l.name),_(l.name);else if(d===1)p("id"),x(l.id),_(l.id);else{const E=d-2,Y=O[E],X=l.colors[Y];v(E),x(X),_(X)}}else if(f!==null)B.ctrl&&A==="a"&&u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(b!==null)if(B.return){if(b==="id"){const E=o;i(w),r(Y=>{const X=Y.themes.findIndex(oe=>oe.id===E);X!==-1&&(Y.themes[X].id=w)})}else k(E=>{E.name=w});p(null),x(""),_("")}else B.escape?(p(null),x(""),_("")):B.backspace||B.delete?x(E=>E.slice(0,-1)):A&&x(E=>E+A)});const O=Object.keys(l.colors),V=(A,B)=>{const E=A.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!E)return A;const Y=parseInt(E[1]),X=parseInt(E[2]),oe=parseInt(E[3]);switch(B){case"hex":{const q=I=>I.toString(16).padStart(2,"0");return`#${q(Y)}${q(X)}${q(oe)}`}case"hsl":{const q=Y/255,I=X/255,$=oe/255,S=Math.max(q,I,$),N=Math.min(q,I,$),y=S-N,L=(S+N)/2;let z=0;y!==0&&(z=L>.5?y/(2-S-N):y/(S+N));let H=0;return y!==0&&(S===q?H=((I-$)/y+(I<$?6:0))/6:S===I?H=(($-q)/y+2)/6:H=((q-I)/y+4)/6),`hsl(${Math.round(H*360)}, ${Math.round(z*100)}%, ${Math.round(L*100)}%)`}case"rgb":default:return A}},K=A=>({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"})[A]||"",U=Math.max(...O.map(A=>A.length));return h(m,{children:[h(m,{flexDirection:"column",width:"50%",children:[s(m,{children:h(me,{children:["Editing theme “",l.name,"” (",l.id,")"]})}),f===null&&b===null?h(he,{children:[h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"enter to edit theme name, id, or color"}),s(c,{dimColor:!0,children:"ctrl+a to toggle rgb, hex, hsl"}),s(c,{dimColor:!0,children:"paste color from clipboard (when on color)"}),s(c,{dimColor:!0,children:"esc to go back"})]}),d<2?h(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:"yellow",flexDirection:"column",paddingLeft:1,children:[s(c,{bold:!0,children:d===0?"Theme Name":"Theme ID"}),s(c,{children:d===0?"The display name for this theme":"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):h(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:l.colors[O[d-2]],flexDirection:"column",paddingLeft:1,children:[s(Ke,{colorKey:O[d-2],theme:l,bold:!0}),s(c,{children:K(O[d-2])})]}),h(m,{flexDirection:"column",children:[h(m,{children:[s(c,{color:d===0?"yellow":"white",children:d===0?"❯ ":" "}),s(c,{bold:!0,children:"Name: "}),s(c,{children:l.name})]}),h(m,{marginBottom:1,children:[s(c,{color:d===1?"yellow":"white",children:d===1?"❯ ":" "}),s(c,{bold:!0,children:"ID: "}),s(c,{children:l.id})]}),(()=>{if(d<2){const q=O.slice(0,20);return h(he,{children:[q.map((I,$)=>{const S=$+2;return h(m,{children:[s(c,{color:d===S?"yellow":"white",children:d===S?"❯ ":" "}),s(m,{width:U+2,children:s(c,{children:s(Ke,{colorKey:I,theme:l,bold:!0})})}),s(F,{color:l.colors[I],children:V(l.colors[I],a)})]},I)}),O.length>20&&h(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-20," more below"]})]})}const B=d-2,E=Math.max(0,B-Math.floor(20/2)),Y=Math.min(O.length,E+20),X=Math.max(0,Y-20),oe=O.slice(X,Y);return h(he,{children:[X>0&&h(c,{color:"gray",dimColor:!0,children:[" ","↑ ",X," more above"]}),oe.map((q,I)=>{const S=X+I+2;return h(m,{children:[s(c,{color:d===S?"yellow":"white",children:d===S?"❯ ":" "}),s(m,{width:U+2,children:s(c,{children:s(Ke,{colorKey:q,theme:l,bold:!0})})}),s(F,{color:l.colors[q],children:V(l.colors[q],a)})]},q)}),Y<O.length&&h(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-Y," more below"]})]})})()]})]}):b?h(m,{flexDirection:"column",marginTop:1,children:[h(c,{children:["Editing ",b==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(c,{children:w})}),s(c,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(rt,{initialValue:C,colorKey:O[f],theme:l,onColorChange:A=>{x(A),k(B=>{B.colors[O[f]]=A})},onExit:()=>{k(A=>{A.colors[O[f]]=w}),v(null),x(""),_("")}})]}),s(m,{width:"50%",children:s(tt,{theme:l})})]})}function ho(e){return e.map(t=>`${t.name} (${t.id})`)}function fo({onBack:e}){const{settings:{themes:t},updateSettings:n}=pe(ue),[r,o]=T(0),[i,l]=T(null),[a,u]=T(!0),d=()=>{const w={colors:{...(t[0]||Z.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(x=>{x.themes.push(w)}),l(w.id),u(!1)},g=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(x=>x.id!==p)}),r>=t.length-1&&o(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...Z.themes]}),o(0)};if(de((p,w)=>{if(w.escape)e();else if(w.upArrow)o(x=>Math.max(0,x-1));else if(w.downArrow)o(x=>Math.min(t.length-1,x+1));else if(w.return){const x=t[r];x&&(l(x.id),u(!1))}else if(p==="n")d();else if(p==="d"){const x=t[r];x&&g(x.id)}else w.ctrl&&p==="r"&&f()},{isActive:a}),i)return s(go,{themeId:i,onBack:()=>{l(null),u(!0)}});const v=ho(t),b=t.find(p=>v[r]?.includes(`(${p.id})`))||t[0];return t.length===0?s(m,{children:h(m,{flexDirection:"column",width:"100%",children:[s(me,{children:"Themes"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(c,{children:"No themes available!"})]})}):h(m,{children:[h(m,{flexDirection:"column",width:"50%",children:[s(me,{children:"Themes"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"d to delete a theme"}),s(c,{dimColor:!0,children:"ctrl+r to delete all themes and restore built-in"}),s(c,{dimColor:!0,children:"enter to edit theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(m,{flexDirection:"column",children:v.map((p,w)=>h(c,{color:r===w?"yellow":void 0,children:[r===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(tt,{theme:b})})]})}function mo({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:r},updateSettings:o}=pe(ue),i=["format","verbs"],[l,a]=T(0),u=i[l],[d,g]=T(0),[f,v]=T(!1),[b,p]=T(""),[w,x]=T(!1),[C,_]=T(!1),[k,P]=T(t),O=cn(),K=(r.find(A=>A.id===O)||r.find(A=>A.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((A,B)=>{if(C){B.return?(o(E=>{E.thinkingVerbs.format=k}),_(!1)):B.escape?(P(t),_(!1)):B.backspace||B.delete?P(E=>E.slice(0,-1)):A&&P(E=>E+A);return}if(f||w){B.return&&b.trim()?(w?(o(E=>{E.thinkingVerbs.verbs.push(b.trim())}),x(!1)):(o(E=>{E.thinkingVerbs.verbs[d]=b.trim()}),v(!1)),p("")):B.escape?(p(""),v(!1),x(!1)):B.backspace||B.delete?p(E=>E.slice(0,-1)):A&&p(E=>E+A);return}B.escape?e():B.return?u==="format"&&(P(t),_(!0)):B.tab?B.shift?a(E=>E===0?i.length-1:E-1):a(E=>E===i.length-1?0:E+1):B.upArrow?u==="verbs"&&n.length>0&&g(E=>E>0?E-1:n.length-1):B.downArrow?u==="verbs"&&n.length>0&&g(E=>E<n.length-1?E+1:0):A==="e"&&u==="verbs"?n.length>0&&(p(n[d]),v(!0)):A==="d"&&u==="verbs"?n.length>1&&(o(E=>{E.thinkingVerbs.verbs=E.thinkingVerbs.verbs.filter((Y,X)=>X!==d)}),d>=n.length-1&&g(Math.max(0,n.length-2))):A==="n"&&u==="verbs"?(x(!0),p("")):B.ctrl&&A==="r"&&u==="verbs"&&(o(E=>{E.thinkingVerbs.verbs=[...Z.thinkingVerbs.verbs]}),g(0))});const U=50;return h(m,{children:[h(m,{flexDirection:"column",width:`${100-U}%`,children:[h(m,{marginBottom:1,flexDirection:"column",children:[s(me,{children:"Thinking Verbs"}),h(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:u==="format"?"enter to edit format":"changes auto-saved"}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),s(m,{marginBottom:1,children:s(c,{dimColor:!0,children:"Customize the verbs shown during generation and their format."})}),h(m,{flexDirection:"column",children:[h(c,{children:[s(c,{color:u==="format"?"yellow":void 0,children:u==="format"?"❯ ":" "}),s(c,{bold:!0,color:u==="format"?"yellow":void 0,children:"Format"})]}),u==="format"&&(C?h(c,{dimColor:!0,children:[" ","enter to save"]}):h(c,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:C?"yellow":"gray",children:s(c,{children:C?k:t})})}),s(m,{children:h(c,{children:[s(c,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(c,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:h(c,{dimColor:!0,children:[" ","e to edit · d to delete · n to add new · ctrl+r to reset"]})}),s(m,{marginLeft:2,marginBottom:1,children:h(m,{flexDirection:"column",children:[(()=>{const B=Math.max(0,d-Math.floor(4)),E=Math.min(n.length,B+8),Y=Math.max(0,E-8),X=n.slice(Y,E);return h(he,{children:[Y>0&&h(c,{color:"gray",dimColor:!0,children:[" ","↑ ",Y," more above"]}),X.map((oe,q)=>{const I=Y+q;return h(c,{color:u==="verbs"&&I===d?"cyan":void 0,children:[u==="verbs"&&I===d?"❯ ":" ",oe]},I)}),E<n.length&&h(c,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-E," more below"]})]})})(),w&&h(m,{alignItems:"center",children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]}),f&&h(m,{marginTop:1,alignItems:"center",children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]})]})})]}),h(m,{width:`${U}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:h(c,{children:[h(c,{color:K,children:["✻ ",t.replace(/\{\}/g,n[d])," "]}),s(c,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:Z.thinkingStyle.phases,reverseMirror:Z.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 po({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:r},themes:o},updateSettings:i}=pe(ue),l=["reverseMirror","updateInterval","phases","presets"],[a,u]=T(0),d=l[a],[g,f]=T(0),[v,b]=T(0),[p,w]=T(!1),[x,C]=T(""),[_,k]=T(!1),[P,O]=T(!1),[V,K]=T(n.toString()),[U,A]=T(0),B=cn(),Y=(o.find(S=>S.id===B)||o.find(S=>S.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const S=r?[...t,...[...t].reverse().slice(1,-1)]:t,N=setInterval(()=>{A(y=>(y+1)%S.length)},n);return()=>clearInterval(N)}},[t,n,r]),de((S,N)=>{if(P){if(N.return){const y=parseInt(V);!isNaN(y)&&y>0&&i(L=>{L.thinkingStyle.updateInterval=y}),O(!1)}else N.escape?(K(n.toString()),O(!1)):N.backspace||N.delete?K(y=>y.slice(0,-1)):S&&S.match(/^[0-9]$/)&&K(y=>y+S);return}if(p||_){if(N.return&&x.length){const y=_?[...t,x]:t.map((L,z)=>z===g?x:L);i(L=>{L.thinkingStyle.phases=y}),w(!1),C("")}else N.escape?(C(""),w(!1),k(!1)):N.backspace||N.delete?C(y=>y.slice(0,-1)):S&&C(y=>y+S);return}if(N.escape)e();else if(N.return)if(d==="updateInterval")K(n.toString()),O(!0);else if(d==="presets"){const y=_e[v];i(L=>{L.thinkingStyle.phases=[...y.phases],L.thinkingStyle.reverseMirror=y.reverseMirror})}else d==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(N.tab)N.shift?u(y=>y===0?l.length-1:y-1):u(y=>y===l.length-1?0:y+1);else if(N.upArrow)d==="phases"&&t.length>0?f(y=>y>0?y-1:t.length-1):d==="presets"&&b(y=>y>0?y-1:_e.length-1);else if(N.downArrow)d==="phases"&&t.length>0?f(y=>y<t.length-1?y+1:0):d==="presets"&&b(y=>y<_e.length-1?y+1:0);else if(S===" ")d==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(S==="e"&&d==="phases")t.length>0&&(C(t[g]),w(!0));else if(S==="a"&&d==="phases")k(!0),C("");else if(S==="d"&&d==="phases")t.length>1&&(i(y=>{y.thinkingStyle.phases=t.filter((L,z)=>z!==g)}),g>=t.length&&f(Math.max(0,t.length-1)));else if(S==="w"&&d==="phases"){if(g>0){const y=[...t];[y[g-1],y[g]]=[y[g],y[g-1]],i(L=>{L.thinkingStyle.phases=y}),f(L=>L-1)}}else if(S==="s"&&d==="phases"){if(g<t.length-1){const y=[...t];[y[g],y[g+1]]=[y[g+1],y[g]],i(L=>{L.thinkingStyle.phases=y}),f(L=>L+1)}}else N.ctrl&&S==="r"&&(i(y=>{y.thinkingStyle=Z.thinkingStyle}),f(0),b(0))});const X=r?"●":"○",oe=50,I=r?[...t,...[...t].reverse().slice(1,-1)]:t,$=I.length>0?I[U]:"·";return s(m,{children:h(m,{flexDirection:"column",width:"100%",children:[h(m,{flexDirection:"row",width:"100%",children:[h(m,{marginBottom:1,flexDirection:"column",width:`${100-oe}%`,children:[s(me,{children:"Thinking style"}),h(m,{flexDirection:"column",children:[h(c,{dimColor:!0,children:["enter to"," ",d==="updateInterval"?"edit interval":d==="presets"?"apply preset":"save"]}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),h(m,{width:`${oe}%`,flexDirection:"column",children:[s(m,{children:s(c,{bold:!0,children:"Preview"})}),h(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:($?.length??0)+1,children:s(c,{color:Y,children:$})}),h(c,{children:[s(c,{color:Y,children:"Thinking… "}),s(c,{children:"(esc to interrupt)"})]})]})]})]}),h(m,{flexDirection:"row",gap:4,children:[h(m,{flexDirection:"column",children:[h(c,{children:[s(c,{color:d==="reverseMirror"?"yellow":void 0,children:d==="reverseMirror"?"❯ ":" "}),s(c,{bold:!0,color:d==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),d==="reverseMirror"&&h(c,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:h(c,{children:[X," ",r?"Enabled":"Disabled"]})})]}),h(m,{flexDirection:"column",children:[h(c,{children:[s(c,{color:d==="updateInterval"?"yellow":void 0,children:d==="updateInterval"?"❯ ":" "}),s(c,{bold:!0,color:d==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),d==="updateInterval"&&(P?h(c,{dimColor:!0,children:[" ","enter to save"]}):h(c,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:P?"yellow":"gray",children:s(c,{children:P?V:n})})})]})]}),s(m,{children:h(c,{children:[s(c,{color:d==="phases"?"yellow":void 0,children:d==="phases"?"❯ ":" "}),s(c,{bold:!0,color:d==="phases"?"yellow":void 0,children:"Phases"})]})}),d==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:h(c,{dimColor:!0,children:[" ","[e]dit"," ","[a]dd"," ","[d]elete"," ","[w]move up"," ","[s]move down"]})}),s(m,{marginLeft:2,marginBottom:1,children:h(m,{flexDirection:"column",children:[(()=>{const N=Math.max(0,g-Math.floor(4)),y=Math.min(t.length,N+8),L=Math.max(0,y-8),z=t.slice(L,y);return h(he,{children:[L>0&&h(c,{color:"gray",dimColor:!0,children:[" ","↑ ",L," more above"]}),z.map((H,ne)=>{const ie=L+ne;return h(c,{color:d==="phases"&&ie===g?"cyan":void 0,children:[d==="phases"&&ie===g?"❯ ":" ",H]},ie)}),y<t.length&&h(c,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-y," more below"]})]})})(),_&&h(m,{children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:x})})]}),p&&h(m,{marginTop:1,children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:x})})]})]})}),s(m,{children:h(c,{children:[s(c,{color:d==="presets"?"yellow":void 0,children:d==="presets"?"❯ ":" "}),s(c,{bold:!0,color:d==="presets"?"yellow":void 0,children:"Presets"})]})}),d==="presets"&&h(c,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const N=Math.max(0,v-Math.floor(4)),y=Math.min(_e.length,N+8),L=Math.max(0,y-8),z=_e.slice(L,y);return h(he,{children:[L>0&&h(c,{color:"gray",dimColor:!0,children:[" ","↑ ",L," more above"]}),z.map((H,ne)=>{const ie=L+ne;return h(c,{color:d==="presets"&&ie===v?"cyan":void 0,children:[d==="presets"&&ie===v?"❯ ":" ",H.name," ",H.phases.join("")]},ie)}),y<_e.length&&h(c,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-y," more below"]})]})})()})}),s(m,{marginTop:1,children:s(c,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const Pe=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function bo({onBack:e}){const{settings:t,updateSettings:n}=pe(ue),[r,o]=T("prefix"),[i,l]=T(0),[a,u]=T(!1),[d,g]=T(()=>t.userMessageDisplay.prefix.format),[f,v]=T(0),[b,p]=T(()=>[...t.userMessageDisplay.prefix.styling]),[w,x]=T(()=>t.userMessageDisplay.prefix.foreground_color),[C,_]=T(()=>t.userMessageDisplay.prefix.background_color),[k,P]=T(0),[O,V]=T(0),[K,U]=T(()=>[...t.userMessageDisplay.message.styling]),[A,B]=T(()=>t.userMessageDisplay.message.foreground_color),[E,Y]=T(()=>t.userMessageDisplay.message.background_color),[X,oe]=T(null),[q,I]=T(""),$=cn(),S=t.themes?.find(j=>j.id===$)||t.themes?.[0],N=["format","styling","foreground","background"],y=["styling","foreground","background"],L=N[i],z=y[k],H=(j,R)=>{n(D=>{const ee=j==="prefix"?D.userMessageDisplay.prefix:D.userMessageDisplay.message;R(ee)})},ne=j=>{n(R=>{j==="prefix"?R.userMessageDisplay.prefix={...Z.userMessageDisplay.prefix}:R.userMessageDisplay.message={...Z.userMessageDisplay.message}}),j==="prefix"?(g(Z.userMessageDisplay.prefix.format),p([...Z.userMessageDisplay.prefix.styling]),x(Z.userMessageDisplay.prefix.foreground_color),_(Z.userMessageDisplay.prefix.background_color)):(U([...Z.userMessageDisplay.message.styling]),B(Z.userMessageDisplay.message.foreground_color),Y(Z.userMessageDisplay.message.background_color))};xe(()=>{const j=t.userMessageDisplay.prefix;g(j.format),p([...j.styling]),x(j.foreground_color),_(j.background_color);const R=t.userMessageDisplay.message;U([...R.styling]),B(R.foreground_color),Y(R.background_color)},[]),de((j,R)=>{if(a){if(R.return)H("prefix",D=>{D.format=d}),u(!1);else if(R.escape){const D=t.userMessageDisplay.prefix;g(D.format),u(!1)}else R.backspace||R.delete?g(D=>D.slice(0,-1)):j&&g(D=>D+j);return}if(X===null){if(R.escape)e();else if(R.ctrl&&j==="r")ne(r);else if(R.leftArrow||R.rightArrow)o(D=>D==="prefix"?"message":"prefix");else if(R.tab)r==="prefix"?R.shift?l(D=>D===0?N.length-1:D-1):l(D=>D===N.length-1?0:D+1):R.shift?P(D=>D===0?y.length-1:D-1):P(D=>D===y.length-1?0:D+1);else if(R.return)r==="prefix"?L==="format"?u(!0):L==="foreground"?(I(w),oe({column:"prefix",type:"foreground"})):L==="background"&&(I(C),oe({column:"prefix",type:"background"})):z==="foreground"?(I(A),oe({column:"message",type:"foreground"})):z==="background"&&(I(E),oe({column:"message",type:"background"}));else if(R.upArrow)r==="prefix"&&L==="styling"?v(D=>Math.max(0,D-1)):r==="message"&&z==="styling"&&V(D=>Math.max(0,D-1));else if(R.downArrow)r==="prefix"&&L==="styling"?v(D=>Math.min(Pe.length-1,D+1)):r==="message"&&z==="styling"&&V(D=>Math.min(Pe.length-1,D+1));else if(j===" "){if(r==="prefix"&&L==="styling"){const D=Pe[f].value,ee=b.indexOf(D)>=0?b.filter(W=>W!==D):[...b,D];p(ee),H("prefix",W=>{W.styling=[...ee]})}else if(r==="message"&&z==="styling"){const D=Pe[O].value,ee=K.indexOf(D)>=0?K.filter(W=>W!==D):[...K,D];U(ee),H("message",W=>{W.styling=[...ee]})}}}});const ie=(j,R,D=!0)=>{const ee=D?R==="prefix"?b:K:[],W=D?R==="prefix"?w:A:"rgb(255,255,255)",Oe=D?R==="prefix"?C:E:"rgb(0,0,0)",Te=W==="rgb(0,0,0)"&&Oe==="rgb(0,0,0)",Ue=ee.length>0;return Te&&!Ue?s(c,{children:j}):s(c,{bold:ee.includes("bold"),italic:ee.includes("italic"),underline:ee.includes("underline"),strikethrough:ee.includes("strikethrough"),inverse:ee.includes("inverse"),color:Te?void 0:W,backgroundColor:Te?void 0:Oe,children:j})},$e=(j=!0)=>h(c,{children:[d&&h(he,{children:[ie(d,"prefix",j)," "]}),ie("list the dir","message",j)]}),be=j=>{const R=r===j,W=(j==="prefix"?N:y)[j==="prefix"?i:k],Oe=j==="prefix"?f:O,Te=j==="prefix"?b:K,Ue=j==="prefix"?w:A,gn=j==="prefix"?C:E;return h(m,{flexDirection:"column",width:"45%",borderStyle:R?"round":"single",borderColor:R?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:h(c,{bold:!0,color:R?"yellow":void 0,children:[j.charAt(0).toUpperCase()+j.slice(1)," ","Configuration"]})}),j==="prefix"&&h(he,{children:[s(m,{children:h(c,{color:R&&W==="format"?"yellow":void 0,bold:R&&W==="format",children:[R&&W==="format"?"❯ ":" ","Prefix Text"]})}),R&&W==="format"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:a?"enter to save":"enter to edit (appears before message)"})}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:a?"yellow":"gray",children:s(c,{children:d})})})]}),s(m,{children:h(c,{color:R&&W==="styling"?"yellow":void 0,bold:R&&W==="styling",children:[R&&W==="styling"?"❯ ":" ","Styling"]})}),R&&W==="styling"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:Pe.map((We,hn)=>s(m,{children:h(c,{color:R&&W==="styling"&&Oe===hn?"cyan":void 0,children:[R&&W==="styling"&&Oe===hn?"❯ ":" ",Te.includes(We.value)?"●":"○"," ",We.label]})},We.value))}),s(m,{children:h(c,{color:R&&W==="foreground"?"yellow":void 0,bold:R&&W==="foreground",children:[R&&W==="foreground"?"❯ ":" ","Foreground color"]})}),R&&W==="foreground"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,marginBottom:1,children:s(c,{color:Ue,children:Ue})}),s(m,{children:h(c,{color:R&&W==="background"?"yellow":void 0,bold:R&&W==="background",children:[R&&W==="background"?"❯ ":" ","Background color"]})}),R&&W==="background"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(c,{backgroundColor:gn,children:gn})})]})};if(X){const{column:j,type:R}=X;return s(rt,{initialValue:q,theme:S,onColorChange:D=>{j==="prefix"?R==="foreground"?(x(D),H("prefix",ee=>{ee.foreground_color=D})):(_(D),H("prefix",ee=>{ee.background_color=D})):R==="foreground"?(B(D),H("message",ee=>{ee.foreground_color=D})):(Y(D),H("message",ee=>{ee.background_color=D}))},onExit:()=>{oe(null),I("")}})}return h(m,{flexDirection:"column",children:[s(me,{children:"Customize how user messages are displayed"}),h(m,{flexDirection:"column",marginBottom:1,children:[s(c,{dimColor:!0,children:"left/right arrows to switch columns · tab to navigate options"}),s(c,{dimColor:!0,children:"enter to edit · ctrl+r to reset active column · esc to go back"})]}),h(m,{flexDirection:"row",gap:1,children:[be("prefix"),be("message")]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:h(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),h(m,{flexDirection:"row",gap:2,children:[h(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"Before (Claude Code default):"})}),s(m,{marginLeft:1,marginTop:1,children:h(c,{children:[s(c,{color:S?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]}),h(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,children:$e(!0)}),s(m,{marginLeft:1,marginTop:1,children:h(c,{children:[s(c,{color:S?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]})]})]})})]})}function wo({onSubmit:e}){const{settings:t,updateSettings:n}=pe(ue),[r,o]=T(0),i=()=>{n(b=>{b.inputBox||(b.inputBox={removeBorder:!1}),b.inputBox.removeBorder=!b.inputBox.removeBorder})},l=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showTweakccVersion=!b.misc.showTweakccVersion})},a=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showPatchesApplied=!b.misc.showPatchesApplied})},u=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.expandThinkingBlocks=!b.misc.expandThinkingBlocks})};de((b,p)=>{p.return||p.escape?e():p.upArrow?o(w=>Math.max(0,w-1)):p.downArrow?o(w=>Math.min(3,w+1)):b===" "&&(r===0?i():r===1?l():r===2?a():r===3&&u())});const d=t.inputBox?.removeBorder?"☑":"☐",g=t.misc?.showTweakccVersion?"☑":"☐",f=t.misc?.showPatchesApplied?"☑":"☐",v=t.misc?.expandThinkingBlocks?"☑":"☐";return h(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(me,{children:"Miscellaneous Settings"})}),s(m,{marginBottom:1,children:s(c,{color:"gray",children:s(c,{dimColor:!0,children:"Various tweaks and customizations. Press space to toggle settings, enter to go back."})})}),s(m,{children:h(c,{children:[s(c,{color:r===0?"cyan":void 0,children:r===0?"❯ ":" "}),s(c,{bold:!0,color:r===0?"cyan":void 0,children:"Remove input box border"})]})}),s(m,{flexDirection:"column",children:h(c,{dimColor:!0,children:[" ","Removes the rounded border around the input box for a cleaner look."]})}),s(m,{marginLeft:4,marginBottom:1,children:h(c,{children:[d," ",t.inputBox?.removeBorder?"Enabled":"Disabled"]})}),s(m,{children:h(c,{children:[s(c,{color:r===1?"cyan":void 0,children:r===1?"❯ ":" "}),s(c,{bold:!0,color:r===1?"cyan":void 0,children:"Show tweakcc version at startup"})]})}),s(m,{flexDirection:"column",children:h(c,{dimColor:!0,children:[" ",'Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:h(c,{children:[g," ",t.misc?.showTweakccVersion?"Enabled":"Disabled"]})}),s(m,{children:h(c,{children:[s(c,{color:r===2?"cyan":void 0,children:r===2?"❯ ":" "}),s(c,{bold:!0,color:r===2?"cyan":void 0,children:"Show patches applied indicator at startup"})]})}),s(m,{flexDirection:"column",children:h(c,{dimColor:!0,children:[" ",'Shows the green "tweakcc patches are applied" indicator when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:h(c,{children:[f," ",t.misc?.showPatchesApplied?"Enabled":"Disabled"]})}),s(m,{children:h(c,{children:[s(c,{color:r===3?"cyan":void 0,children:r===3?"❯ ":" "}),s(c,{bold:!0,color:r===3?"cyan":void 0,children:"Expand thinking blocks"})]})}),s(m,{flexDirection:"column",children:h(c,{dimColor:!0,children:[" ","Makes thinking blocks always expanded by default instead of collapsed."]})}),s(m,{marginLeft:4,marginBottom:1,children:h(c,{children:[v," ",t.misc?.expandThinkingBlocks?"Enabled":"Disabled"]})})]})}const je=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","ExitPlanMode"];function xo({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:r}=pe(ue),o=n.toolsets[e],[i,l]=T(o?.name||"New Toolset"),[a,u]=T(o?.allowedTools||[]),[d,g]=T(!1),[f,v]=T(0);xe(()=>{o&&r(C=>{C.toolsets[e].name=i,C.toolsets[e].allowedTools=a})},[i,a]);const b=C=>a==="*"?!0:a.includes(C),p=C=>{C==="All"?u("*"):C==="None"?u([]):a==="*"?u(je.filter(_=>_!==C)):a.includes(C)?u(a.filter(_=>_!==C)):u([...a,C])};if(de((C,_)=>{if(d){_.return?g(!1):_.escape?(l(o?.name||"New Toolset"),g(!1)):_.backspace||_.delete?l(k=>k.slice(0,-1)):C&&C.length===1&&l(k=>k+C);return}if(_.escape)t();else if(_.upArrow)v(k=>Math.max(0,k-1));else if(_.downArrow)v(k=>Math.min(je.length+1,k+1));else if(C===" "||_.return)if(f===0)p("All");else if(f===1)p("None");else{const k=je[f-2];k&&p(k)}else C==="n"&&g(!0)}),!o)return s(m,{flexDirection:"column",children:s(c,{color:"red",children:"Toolset not found"})});const w=a==="*",x=Array.isArray(a)&&a.length===0;return h(m,{flexDirection:"column",children:[s(me,{children:"Edit Toolset"}),s(m,{marginBottom:1,flexDirection:"column",children:s(c,{dimColor:!0,children:"n to edit name · space/enter to toggle · esc to go back"})}),h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Name:"}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:d?"yellow":"gray",children:s(c,{children:i})})}),d&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to save · esc to cancel"})})]}),h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Allowed Tools:"}),s(m,{marginLeft:2,children:h(c,{color:f===0?"cyan":void 0,children:[f===0?"❯ ":" ",w?"●":"○"," All"]})}),s(m,{marginLeft:2,children:h(c,{color:f===1?"cyan":void 0,children:[f===1?"❯ ":" ",x?"●":"○"," None"]})}),je.map((C,_)=>{const k=_+2;return s(m,{marginLeft:2,children:h(c,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(C)?"◉":"○"," ",C]})},C)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:h(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Summary:"}),h(c,{children:["Name: ",s(c,{color:"cyan",children:i})]}),h(c,{children:["Tools:"," ",a==="*"?s(c,{color:"green",children:"All tools (*)"}):a.length===0?s(c,{color:"red",children:"No tools ([])"}):h(c,{color:"yellow",children:[a.length," selected"]})]})]})})]})}function yo({onBack:e}){const{settings:{toolsets:t,defaultToolset:n},updateSettings:r}=pe(ue),[o,i]=T(0),[l,a]=T(null),[u,d]=T(!0),g=()=>{const p={name:"New Toolset",allowedTools:[]};r(w=>{w.toolsets.push(p)}),a(t.length),d(!1)},f=p=>{const w=t[p];r(x=>{x.toolsets.splice(p,1),x.defaultToolset===w.name&&(x.defaultToolset=null)}),o>=t.length-1&&i(Math.max(0,t.length-2))},v=p=>{const w=t[p];r(x=>{x.defaultToolset=w.name})};if(de((p,w)=>{w.escape?e():w.upArrow?i(x=>Math.max(0,x-1)):w.downArrow?i(x=>Math.min(t.length-1,x+1)):w.return&&t.length>0?(a(o),d(!1)):p==="n"?g():p==="d"&&t.length>0?f(o):p==="s"&&t.length>0&&v(o)},{isActive:u}),l!==null)return s(xo,{toolsetIndex:l,onBack:()=>{a(null),d(!0)}});const b=p=>p.allowedTools==="*"?"All tools":p.allowedTools.length===0?"No tools":`${p.allowedTools.length} tool${p.allowedTools.length===1?"":"s"}`;return h(m,{flexDirection:"column",children:[s(me,{children:"Toolsets"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new toolset"}),t.length>0&&s(c,{dimColor:!0,children:"s to set as default toolset"}),t.length>0&&s(c,{dimColor:!0,children:"d to delete a toolset"}),t.length>0&&s(c,{dimColor:!0,children:"enter to edit toolset"}),s(c,{dimColor:!0,children:"esc to go back"})]}),t.length===0?s(c,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:t.map((p,w)=>{const x=p.name===n,C=o===w;return h(c,{color:C?"yellow":void 0,bold:x,children:[C?"❯ ":" ",p.name,x&&" [DEFAULT]"," (",b(p),")"]},w)})})]})}const ue=st({settings:Z,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function So({startupCheckInfo:e}){const[t,n]=T({settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await sn())})()},[]);const r=En(g=>{const f=JSON.parse(JSON.stringify(t.settings));g(f),n(v=>({...v,settings:f,changesApplied:!1})),Ve(v=>{v.settings=f,v.changesApplied=!1})},[t.settings]),[o,i]=T(null),[l,a]=T(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(a({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
436
- (However, your customization are still remembered in ${fe}.)
437
- Please reapply your changes below.`,type:"warning"}),r(()=>{}))},[]),de((g,f)=>{(f.ctrl&&g==="c"||(g==="q"||f.escape)&&!o)&&process.exit(0)},{isActive:!o});const u=g=>{switch(a(null),g){case J.APPLY_CHANGES:e.ccInstInfo&&(a({message:"Applying patches...",type:"info"}),Zn(t,e.ccInstInfo).then(f=>{n(f),a({message:"Customization patches applied successfully!",type:"success"})}));break;case J.THEMES:case J.THINKING_VERBS:case J.THINKING_STYLE:case J.USER_MESSAGE_DISPLAY:case J.MISC:case J.TOOLSETS:i(g);break;case J.VIEW_SYSTEM_PROMPTS:lo(Se);break;case J.RESTORE_ORIGINAL:e.ccInstInfo&&Gn(e.ccInstInfo).then(()=>{a({message:"Original Claude Code restored successfully!",type:"success"}),r(()=>{})});break;case J.OPEN_CONFIG:In(fe);break;case J.OPEN_CLI:e.ccInstInfo?.cliPath&&In(e.ccInstInfo.cliPath);break;case J.EXIT:process.exit(0)}},d=()=>{i(null)};return s(ue.Provider,{value:{settings:t.settings,updateSettings:r,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:o===null?s(mt,{onSubmit:u,notification:l,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):o===J.THEMES?s(fo,{onBack:d}):o===J.THINKING_VERBS?s(mo,{onBack:d}):o===J.THINKING_STYLE?s(po,{onBack:d}):o===J.USER_MESSAGE_DISPLAY?s(bo,{onBack:d}):o===J.MISC?s(wo,{onSubmit:d}):o===J.TOOLSETS?s(yo,{onBack:d}):null})})}const vo=async()=>{const e=new it;e.name("tweakcc").description("Command-line tool to customize your Claude Code theme colors, thinking verbs and more.").version("3.0.1").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const t=e.opts();if(t.debug&&oo(),t.apply){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${fe}`);const r=await sn();(!r.settings||Object.keys(r.settings).length===0)&&(console.error("No saved customizations found in "+fe),process.exit(1));const o=await _n();(!o||!o.ccInstInfo)&&(console.error("Cannot find Claude Code's cli.js"),console.error("Searched for cli.js at the following locations:"),Ze.forEach(l=>{l.isGlob?l.expandedPaths.length===0?console.error(` - ${l.pattern} (no matches)`):(console.error(` - ${l.pattern}`),l.expandedPaths.forEach(a=>{console.error(` - ${a}`)})):console.error(` - ${l.pattern}`)}),console.error(`
438
- Also checked for 'claude' executable on PATH using '${process.platform==="win32"?"where claude.exe":"which claude"}'.`),process.exit(1)),o.ccInstInfo.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${o.ccInstInfo.nativeInstallationPath}`):console.log(`Found Claude Code at: ${o.ccInstInfo.cliPath}`),console.log(`Version: ${o.ccInstInfo.version}`),console.log("Loading system prompts...");const i=await Sn(o.ccInstInfo.version);i.success||(console.log(Q.red(`
433
+ }`;return Kn(e,n)},ir=(e,t,n)=>{if(!t||t.length===0)return null;let o=e;return o=Xo(o,n),o?(o=Zo(o,t),o?(o=Qo(o,t),o?(o=rr(o),o?(o=nr(o),o?(o=tr(o),o?(o=or(o),o||(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)},sr=e=>We(e)?Kn(e,`, {
434
+ type: "local",
435
+ name: "title",
436
+ description: "Set the conversation title",
437
+ isEnabled: () => !0,
438
+ isHidden: !1,
439
+ async call(A, B, I) {
440
+ if (!A)
441
+ throw new Error("Please specify a conversation title.");
442
+ CUR_CONVERSATION_TITLE = A;
443
+ setTerminalTitleOverride(A);
444
+ return {
445
+ type: "text",
446
+ value: \`Conversation title set to \\x1b[1m\${A}\\x1b[0m\`,
447
+ }
448
+ },
449
+ userFacingName() {
450
+ return "title";
451
+ },
452
+ }`):(console.error("patch: conversationTitle: failed to find React variable"),null),lr=e=>{const t=/class ([$\w]+)\{summaries;(?:customTitles;)?messages;checkpoints;fileHistorySnapshots;/,n=e.match(t);return!n||n.index===void 0?(console.error("patch: conversationTitle: findCustomNamingFunctionsLocation: failed to find class pattern"),null):n.index},ar=e=>{const t=lr(e);if(t===null)return console.error("patch: conversationTitle: failed to find custom naming functions location"),null;const n=`import {
453
+ join as pathJoin,
454
+ basename as pathBasename,
455
+ dirname as pathDirname,
456
+ } from "node:path";
457
+ import { homedir as osHomedir } from "node:os";
458
+ import {
459
+ statSync as fsStatSync,
460
+ readFileSync as fsReadFileSync,
461
+ writeFileSync as fsWriteFileSync,
462
+ readdirSync as fsReaddirSync,
463
+ mkdirSync as fsMkdirSync,
464
+ renameSync as fsRenameSync,
465
+ } from "node:fs";
466
+ import { randomUUID as cryptoRandomUUID } from "node:crypto";
467
+
468
+ function getTweakccBaseDir() {
469
+ // Prioritize ~/.tweakcc which is the original and default. Only respect
470
+ // XDG_CONFIG_HOME if it doesn't exist.
471
+ let dir;
472
+ let homedirTweakcc = pathJoin(osHomedir(), ".tweakcc");
473
+ try {
474
+ if (fsStatSync(homedirTweakcc).isDirectory()) {
475
+ dir = homedirTweakcc;
476
+ }
477
+ } catch (e) {
478
+ if (e.code == "ENOENT") {
479
+ // Doesn't exist. Move on and see if the XDG one exists.
480
+ } else {
481
+ throw new Error('cannot stat ' + homedirTweakcc + ': ' + e);
482
+ }
483
+ }
484
+
485
+ // Try XDG.
486
+ if (process.env.XDG_CONFIG_HOME) {
487
+ // XDG_CONFIG_HOME is set. If it's set and ~/.tweakcc doesn't exist, prefer it.
488
+ const xdgTweakcc = pathJoin(process.env.XDG_CONFIG_HOME, "tweakcc");
489
+ dir = xdgTweakcc;
490
+ }
491
+
492
+ // Create the dir.
493
+ fsMkdirSync(dir, { recursive: true });
494
+ return dir;
495
+ }
496
+
497
+ const findSummaryEntryForLeafUuid = (filePath, messageUuid) => {
498
+ const lines = fsReadFileSync(filePath, "utf8")
499
+ .split("\\n")
500
+ .map((l) => JSON.parse(l.trim()));
501
+ for (const line of lines) {
502
+ if (line.type == "summary" && line.uuid == messageUuid) {
503
+ return line;
504
+ }
505
+ }
506
+ return null;
507
+ };
508
+
509
+ const getSummaryFileForLeafMessage = (
510
+ projectDirectory,
511
+ projectSlug,
512
+ messageUuid
513
+ ) => {
514
+ try {
515
+ // File contains the uuid
516
+ const summaryFileId = fsReadFileSync(
517
+ pathJoin(getTweakccBaseDir(), "named-sessions", projectSlug, messageUuid),
518
+ "utf8"
519
+ ).trim();
520
+ return pathJoin(projectDirectory, summaryFileId + '.jsonl');
521
+ } catch (e) {
522
+ // File not found or can't be accessed, etc. Ignore.
523
+ }
524
+
525
+ // Just read each file and try to find it.
526
+ for (const file of fsReaddirSync(projectDirectory)) {
527
+ try {
528
+ const pth = pathJoin(projectDirectory, file);
529
+ const summaryObj = findSummaryEntryForLeafUuid(pth);
530
+ if (summaryObj != null && summaryObj.tweakcc != null) {
531
+ // It needs to be a tweakcc one.
532
+ return pth;
533
+ }
534
+ } catch {}
535
+ }
536
+
537
+ // It doesn't exist.
538
+ return null;
539
+ };
540
+
541
+ const setTerminalTitleOverride = (title) => {
542
+ process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE = 1;
543
+ if (process.platform === "win32") process.title = 'Claude: ' + title;
544
+ else process.stdout.write('\\x1B]0;Claude: ' + title + '\\x07');
545
+ };
546
+
547
+ let CUR_CONVERSATION_TITLE = "";
548
+ function onNewMessage(projectDir, projectSlug, msg) {
549
+ const tweakcc = getTweakccBaseDir();
550
+
551
+ if (msg.parentUuid) {
552
+ const path = getSummaryFileForLeafMessage(
553
+ projectDir,
554
+ projectSlug,
555
+ msg.parentUuid
556
+ );
557
+ if (path) {
558
+ // There's an old file. Update it to the new file.
559
+ const summaryObj = findSummaryEntryForLeafUuid(path);
560
+ summaryObj.leafUuid = msg.uuid;
561
+ if (CUR_CONVERSATION_TITLE != "") {
562
+ summaryObj.summary = CUR_CONVERSATION_TITLE;
563
+ } else {
564
+ CUR_CONVERSATION_TITLE = summaryObj.summary;
565
+ }
566
+ setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
567
+ fsWriteFileSync(path, JSON.stringify(summaryObj));
568
+
569
+ // Update the cache; it points from message ID to summary file ID.
570
+ fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
571
+ recursive: true,
572
+ });
573
+ const oldPath = pathJoin(
574
+ tweakcc,
575
+ "named-sessions",
576
+ projectSlug,
577
+ msg.parentUuid
578
+ );
579
+ const newPath = pathJoin(
580
+ tweakcc,
581
+ "named-sessions",
582
+ projectSlug,
583
+ msg.uuid
584
+ );
585
+ try {
586
+ fsRenameSync(oldPath, newPath);
587
+ return;
588
+ } catch (e) {
589
+ if (e.code == "ENOENT") {
590
+ // named-sessions/{projectSlug} exists, so the error is because the old named-session doesn't exist.
591
+ // So we need to create the new file later.
592
+ // DO NOT return.
593
+ } else {
594
+ throw new Error('cannot rename ' + oldPath + ' -> ' + newPath + ': ' + e);
595
+ }
596
+ }
597
+ }
598
+ }
599
+
600
+ // Only create our summary entry if a custom title has been set. Because we want the auto
601
+ // title generation to kick in if the user hasn't set a title, and the auto title generation
602
+ // won't generate titles for sessions older than the most recently
603
+ if (CUR_CONVERSATION_TITLE != "") {
604
+ setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
605
+ const uuid = cryptoRandomUUID();
606
+
607
+ // Create the summary file.
608
+ const newFilePath = pathJoin(projectDir, uuid + '.jsonl');
609
+ const summaryObj = {
610
+ type: "summary",
611
+ summary: CUR_CONVERSATION_TITLE,
612
+ leafUuid: msg.uuid,
613
+ // This is important.
614
+ tweakcc: null,
615
+ };
616
+ fsWriteFileSync(newFilePath, JSON.stringify(summaryObj));
617
+
618
+ fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
619
+ recursive: true,
620
+ });
621
+ fsWriteFileSync(
622
+ pathJoin(tweakcc, "named-sessions", projectSlug, msg.uuid),
623
+ uuid
624
+ );
625
+ }
626
+ }
627
+
628
+ `,o=e.slice(0,t)+n+e.slice(t);return V(e,o,n,t,t),o},cr=e=>{const t=/(if\(![$\w]+\.has\(([$\w]+)\.uuid\)\)\{)if\([$\w]+\.appendFileSync\(/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: conversationTitle: findAppendEntryInterceptorLocation: failed to find pattern"),null;const o=n.index+n[1].length,r=n[2];return{location:o,messageVar:r}},dr=e=>{const t=cr(e);if(!t)return console.error("patch: conversationTitle: failed to find append entry interceptor location"),null;const{location:n,messageVar:o}=t,r=`
629
+ const projectDir = pathDirname(this.sessionFile);
630
+ const projectSlug = pathBasename(projectDir);
631
+ onNewMessage(projectDir, projectSlug, ${o});
632
+ `,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},ur=e=>{const t=/if\([$\w]+\.has\(([$\w]+)\.uuid\)\)continue;/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find continue pattern"),null;const o=n[1],r=n.index+n[0].length-10,i=Math.max(0,n.index-200),a=e.substring(i,n.index),l=/for\(let [$\w]+ of ([$\w]+)\)try/,u=a.match(l);if(!u)return console.error("patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find loop pattern"),null;const d=u[1],h=i+(u.index??0);return{orLocation:r,loopLocation:h,messageVar:o,fileListVar:d}},hr=e=>{const t=ur(e);if(!t)return console.error("patch: conversationTitle: failed to find tweakcc summary check locations"),null;const{orLocation:n,loopLocation:o,messageVar:r,fileListVar:i}=t;let a=e;const l=`const tweakccSummaries = new Set();
633
+ for (const file of ${i}) {
634
+ const contents = fsReadFileSync(file, "utf8").trim();
635
+ if (contents.includes("\\n")) continue;
636
+ let obj;
637
+ try {
638
+ obj = JSON.parse(contents);
639
+ } catch {
640
+ // Skip invalid files.
641
+ continue;
642
+ }
643
+ if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
644
+ tweakccSummaries.add(obj.leafUuid);
645
+ }
646
+ `;a=a.slice(0,o)+l+a.slice(o),V(e,a,l,o,o);const u=n+l.length,d=`||tweakccSummaries.has(${r}.uuid)`,h=a.slice(0,u)+d+a.slice(u);return V(a,h,d,u,u),h},gr=e=>{const t=/description:"Rename the current conversation",isEnabled:\(\)=>!1,/,n=e.match(t);if(!n)return console.error("patch: conversationTitle: enableRenameConversationCommand: failed to find pattern"),null;if(n.index===void 0)return console.error("patch: conversationTitle: enableRenameConversationCommand: match.index is undefined"),null;const o='description:"Rename the current conversation",isEnabled:()=>!1,',r='description:"Rename the current conversation",isEnabled:()=>!0,',i=e.replace(o,r);return i===e?(console.error("patch: conversationTitle: enableRenameConversationCommand: replacement failed"),null):(V(e,i,r,n.index,n.index+63),i)},fr=e=>{let t=e;return t=sr(t),t?(t=ar(t),t?(t=dr(t),t?(t=hr(t),t?(t=gr(t),t||(console.error("patch: conversationTitle: step 5 failed (enableRenameConversationCommand)"),null)):(console.error("patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)"),null)):(console.error("patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)"),null)):(console.error("patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)"),null)):(console.error("patch: conversationTitle: step 1 failed (writeTitleSlashCommand)"),null)},V=(e,t,n,o,r)=>{if(!T())return;const i=Math.max(0,o-20),a=Math.min(e.length,r+20),l=Math.min(t.length,o+n.length+20),u=e.slice(i,o),d=e.slice(o,r),h=e.slice(r,a),f=t.slice(i,o),v=t.slice(o,o+n.length),b=t.slice(o+n.length,l);d!==v&&(console.log(`
647
+ --- Diff ---`),console.log("OLD:",u+`\x1B[31m${d}\x1B[0m`+h),console.log("NEW:",f+`\x1B[32m${v}\x1B[0m`+b),console.log(`--- End Diff ---
648
+ `))},we=e=>e.replace(/\$/g,"\\$"),cn=e=>{const t=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,n=Array.from(e.matchAll(t)),o={};for(const a of n){const l=a[1];o[l]=(o[l]||0)+1}let r,i=0;for(const[a,l]of Object.entries(o))l>i&&(i=l,r=a);return r},mr=e=>{const t=e.slice(0,1e3),n=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,o=t.match(n);if(!o){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return o[1]},Xn=e=>{const t=/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.element"\)/,n=e.match(t);if(!n){console.log("patch: getReactModuleNameNonBun: failed to find React module name");return}return n[1]},pr=e=>{const t=Xn(e);if(!t){console.log("^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)");return}const n=new RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${we(t)}\\(\\)`),o=e.match(n);if(!o){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return o[1]};let ge=null;const We=e=>{if(ge!=null)return ge;const t=mr(e);if(!t){console.log("^ patch: getReactVar: failed to find moduleLoader"),ge=void 0;return}const n=Xn(e);if(!n){console.log("^ patch: getReactVar: failed to find reactModuleVarNonBun"),ge=void 0;return}const o=new RegExp(`\\b([$\\w]+)=${we(t)}\\(${we(n)}\\(\\),1\\)`),r=e.match(o);if(r)return ge=r[1],ge;const i=pr(e);if(!i){console.log("^ patch: getReactVar: failed to find reactModuleFunctionBun"),ge=void 0;return}const a=new RegExp(`\\b([$\\w]+)=${we(t)}\\(${we(i)}\\(\\),1\\)`),l=e.match(a);if(!l){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${i})`),ge=void 0;return}return ge=l[1],ge},Zn=e=>{const t=/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/,n=e.match(t);if(!n){console.log("patch: findTextComponent: failed to find text component");return}return n[1]},Qn=e=>{const t=/\b([$\w]+)\.displayName="Box"/,n=e.match(t);if(!n){console.error("patch: findBoxComponent: failed to find Box displayName");return}const o=n[1],r=new RegExp(`\\b([$\\w]+)=${we(o)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${o})`);return}return i[1]},et=async(e,t)=>{let n;if(t.nativeInstallationPath){await Qt(t);let u=!1;try{await te.stat(ae),u=!0}catch{}const d=u?ae:t.nativeInstallationPath;T()&&console.log(`Extracting claude.js from ${u?"backup":"native installation"}: ${d}`);const h=Gn(d);if(!h)throw new Error("Failed to extract claude.js from native installation");const f=oe.join(ye.homedir(),".tweakcc"),v=oe.join(f,"native-claudejs-orig.js");Ee.writeFileSync(v,h),T()&&console.log(`Saved original extracted JS from native to: ${v}`),n=h.toString("utf8")}else{if(await Yn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await te.readFile(t.cliPath,{encoding:"utf8"})}const o=[],r=await Go(n,t.version);n=r.newContent,o.push(...r.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=so(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=Co(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=mo(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=xo(n,e.settings.thinkingStyle.phases))&&(n=i),(i=So(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=$o(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=bo(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=ko(n,e.settings.userMessageDisplay.prefix.format,e.settings.userMessageDisplay.prefix.foreground_color,e.settings.userMessageDisplay.prefix.background_color,e.settings.userMessageDisplay.prefix.styling.includes("bold"),e.settings.userMessageDisplay.prefix.styling.includes("italic"),e.settings.userMessageDisplay.prefix.styling.includes("underline"),e.settings.userMessageDisplay.prefix.styling.includes("strikethrough"),e.settings.userMessageDisplay.prefix.styling.includes("inverse"),e.settings.userMessageDisplay.message.foreground_color,e.settings.userMessageDisplay.message.background_color,e.settings.userMessageDisplay.message.styling.includes("bold"),e.settings.userMessageDisplay.message.styling.includes("italic"),e.settings.userMessageDisplay.message.styling.includes("underline"),e.settings.userMessageDisplay.message.styling.includes("strikethrough"),e.settings.userMessageDisplay.message.styling.includes("inverse")))&&(n=i),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder=="boolean"&&(i=uo(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Mo(n))&&(n=i),(i=go(n))&&(n=i),(i=ao(n))&&(n=i),(i=xr(n))&&(n=i),(i=ro(n,25))&&(n=i),(i=Bo(n))&&(n=i),(i=Po(n))&&(n=i);const a=e.settings.misc?.showTweakccVersion??!0,l=e.settings.misc?.showPatchesApplied??!0;if((i=jo(n,"3.1.0",o,a,l))&&(n=i),(i=Yo(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=ir(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),(i=fr(n))&&(n=i),t.nativeInstallationPath){T()&&console.log(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);const u=oe.join(ye.homedir(),".tweakcc"),d=oe.join(u,"native-claudejs-patched.js");Ee.writeFileSync(d,n,"utf8"),T()&&console.log(`Saved patched JS from native to: ${d}`);const h=Buffer.from(n,"utf8");Xt(t.nativeInstallationPath,h,t.nativeInstallationPath)}else{if(!t.cliPath)throw new Error("cliPath is required for NPM installations");await hn(t.cliPath,n,"patch")}return await Ve(u=>{u.changesApplied=!0})},nt=[{label:"Opus 4.1",slug:"opus-4.1",internal:"claude-opus-4-1-20250805"},{label:"Opus 4",slug:"opus-4",internal:"claude-opus-4-20250514"},{label:"Sonnet 4",slug:"sonnet-4",internal:"claude-sonnet-4-20250514"},{label:"Sonnet 3.7",slug:"sonnet-3.7",internal:"claude-3-7-sonnet-20250219"},{label:"Sonnet 3.5 (October)",slug:"sonnet-3.5-october",internal:"claude-3-5-sonnet-20241022"},{label:"Sonnet 3.5 (June)",slug:"sonnet-3.5-june",internal:"claude-3-5-sonnet-20240620"},{label:"Haiku 3.5",slug:"haiku-3.5",internal:"claude-3-5-haiku-20241022"},{label:"Haiku 3",slug:"haiku-3",internal:"claude-3-haiku-20240307"},{label:"Opus 3",slug:"opus-3",internal:"claude-3-opus-20240229"}],br=e=>{const t=e.indexOf("Switch between Claude models");if(t===-1)return console.error("patch: getModelSelectorInsertionPoint: failed to find labelIndex"),null;const n=Math.max(0,t-600),o=t,i=e.slice(n,o).match(/\[[$\w]+,\s*[$\w]+\]\s*=\s*[$\w]+\.useState\([^)]*\)\s*,\s*([$\w]+)=/);if(!i||i.index===void 0)return console.error("patch: getModelSelectorInsertionPoint: failed to find useState"),null;let l=n+i.index;for(;l<e.length&&e[l]!==";";)l++;if(l>=e.length)return console.error("patch: getModelSelectorInsertionPoint: failed to find semicolon"),null;const u=l+1,d=i[1];return{insertionIndex:u,optionsVar:d}},wr=e=>{const t=br(e);if(!t)return null;const{insertionIndex:n,optionsVar:o}=t,r=nt.map(a=>{const l=JSON.stringify(a.label),u=JSON.stringify(a.slug);return`${o}.push({value:${u},label:${l}});`}).join(""),i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},xr=e=>{let t=e;const n=wr(t);return n&&(t=n),t===e?null:t};let tt=!1;const T=()=>tt,yr=()=>{tt=!0};function dn(){try{const e=oe.join(ye.homedir(),".claude.json");return JSON.parse(Ee.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function Sr(){try{const e=oe.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ee.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 vr(){try{const e=oe.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ee.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const o=nt.find(r=>r.slug===n);if(o)return o.label}catch{}return"Sonnet 4.5"}function $r(e){process.platform==="win32"?Me.spawn("explorer",[e],{detached:!0,stdio:"ignore"}).unref():process.platform==="darwin"?Me.spawn("open",[e],{detached:!0,stdio:"ignore"}).unref():Me.spawn("xdg-open",[e],{detached:!0,stdio:"ignore"}).unref()}function Cn(e){if(process.platform==="win32")Me.spawn("explorer",["/select,",e],{detached:!0,stdio:"ignore"}).unref();else if(process.platform==="darwin")Me.spawn("open",["-R",e],{detached:!0,stdio:"ignore"}).unref();else{const t=oe.dirname(e);Me.spawn("xdg-open",[t],{detached:!0,stdio:"ignore"}).unref()}}function un(e){if(!e||typeof e!="string")return!1;const 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)){const n=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const[,o,r,i]=n;return parseInt(o)<=255&&parseInt(r)<=255&&parseInt(i)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const[,o,r,i]=n;return parseInt(o)<=360&&parseInt(r)<=100&&parseInt(i)<=100}}return!1}function ot(e){if(!un(e))return e;const t=e.trim();if(t.startsWith("rgb("))return t;if(t.startsWith("#")){let n=t.slice(1);n.length===3&&(n=n.split("").map(a=>a+a).join(""));const o=parseInt(n.slice(0,2),16),r=parseInt(n.slice(2,4),16),i=parseInt(n.slice(4,6),16);return`rgb(${o},${r},${i})`}if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const o=parseInt(n[1])/360,r=parseInt(n[2])/100,i=parseInt(n[3])/100,a=(v,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?v+(b-v)*6*p:p<1/2?b:p<2/3?v+(b-v)*(2/3-p)*6:v),l=i<.5?i*(1+r):i+r-i*r,u=2*i-l,d=Math.round(a(u,l,o+1/3)*255),h=Math.round(a(u,l,o)*255),f=Math.round(a(u,l,o-1/3)*255);return`rgb(${d},${h},${f})`}}return e}async function _r(e,t="sha256",n=64*1024){return new Promise((o,r)=>{const i=Bn.createHash(t),a=Ee.createReadStream(e,{highWaterMark:n});a.on("data",l=>{i.update(l)}),a.on("end",()=>{o(i.digest("hex"))}),a.on("error",l=>{r(l)})})}const En=(e,t,n,o,r,i,a,l)=>{let u=e;return t&&(u+=`.rgb(${t})`),n&&n!=="transparent"&&(u+=`.bgRgb(${n})`),o&&(u+=".bold"),r&&(u+=".italic"),i&&(u+=".underline"),a&&(u+=".strikethrough"),l&&(u+=".inverse"),u};async function hn(e,t,n="replace"){let o=493;try{o=(await te.stat(e)).mode,T()&&console.log(`[${n}] Original file mode for ${e}: ${(o&parseInt("777",8)).toString(8)}`)}catch(r){T()&&console.log(`[${n}] Could not stat ${e} (error: ${r}), using default mode 755`)}try{await te.unlink(e),T()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(r){T()&&console.log(`[${n}] Could not unlink ${e}: ${r}`)}await te.writeFile(e,t),await te.chmod(e,o),T()&&console.log(`[${n}] Restored permissions to ${(o&parseInt("777",8)).toString(8)}`)}function F({color:e,backgroundColor:t,bold:n,dimColor:o,children:r}){const i=e?.startsWith("ansi:"),a=t?.startsWith("ansi:");if(i||a){if(Ke.Children.toArray(r).some(f=>Ke.isValidElement(f)))return s(c,{children:r});let u=Q;if(i){const f=e.slice(5);u=u[f]||u}if(a){const f=t.slice(5),v=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[v]||u}n&&(u=u.bold),o&&(u=u.dim);const h=Ke.Children.toArray(r).map(f=>typeof f=="string"||typeof f=="number"?String(f):"").join("");return s(c,{children:u(h)})}return s(c,{color:e,backgroundColor:t,bold:n,dimColor:o,children:r})}function Ir({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:o=3,updateDuration:r=50,restartPoint:i=10}){const[a,l]=O(0);return xe(()=>{const u=setInterval(()=>{l(d=>{const h=d+1;return h>=e.length+i?-o:h})},r);return()=>clearInterval(u)},[e.length,i,r]),t.length!==n.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(c,{children:e})):s(c,{children:e.split("").map((u,d)=>{const h=d>=a&&d<a+o&&a<e.length,f=d%t.length,v=h?n[f]:t[f];return s(c,{color:v,children:u},d)})})}const Cr=ut.cwd();function rt({theme:e}){const{ccVersion:t}=pe(he);return g(m,{flexDirection:"column",paddingLeft:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,children:["Preview: ",e.name]})}),s(m,{borderStyle:"single",borderColor:"gray",paddingX:1,children:g(m,{flexDirection:"column",children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(F,{color:e.colors.clawd_body,children:" ▐"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),g(c,{children:[s(F,{color:e.colors.clawd_body,children:"▌ "})," ",s(c,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),g(c,{children:[s(F,{color:e.colors.clawd_body,children:"▝▜"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(F,{color:e.colors.clawd_body,children:"▛▘"})," ",vr()," · ",Sr()]}),g(F,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",Cr]}),g(c,{children:[g(F,{color:e.colors.success,children:["Login successful. Press"," "]}),s(F,{bold:!0,color:e.colors.success,children:"Enter"}),g(F,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(c,{children:"╭─────────────────────────────────────────────╮"}),g(c,{children:["│ 1 function greet() ","{"," ","│"]}),g(c,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(F,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(F,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),g(c,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(F,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(F,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(F,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),g(F,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),g(c,{children:[s(F,{color:e.colors.warning,children:"│ "}),s(c,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),g(F,{color:e.colors.warning,children:[" ","│"]})]}),s(F,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),g(c,{children:[s(F,{color:e.colors.bashBorder,children:"!"}),s(c,{children:" ls"})]}),s(F,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(c,{children:g(c,{children:["> list the dir"," ",s(Ir,{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})]})}),s(F,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(F,{color:e.colors.planMode,children:"│ "}),g(F,{color:e.colors.permission,children:["Ready to code?"," "]}),s(c,{children:"Here is Claude's plan:"}),g(F,{color:e.colors.planMode,children:[" ","│"]})]}),s(F,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(F,{color:e.colors.permission,children:"│ "}),s(c,{bold:!0,children:"Permissions:"})," ",g(F,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(F,{color:e.colors.permission,children:"│"})]}),s(c,{children:"> list the dir"}),g(c,{children:[s(F,{color:e.colors.error,children:"●"}),s(c,{children:" Update(__init__.py)"})]}),g(c,{children:[s(c,{children:" ⎿ "}),s(F,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),g(c,{children:[" ","1"," ",g(F,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(F,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),g(c,{children:[" ","2"," ",g(F,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(F,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),g(c,{children:[s(F,{color:e.colors.success,children:"●"}),s(c,{children:" List(.)"})]}),g(c,{children:[s(c,{children:"●"}),s(c,{children:" The directory "}),s(F,{color:e.colors.permission,children:"C:\\Users\\user"}),g(c,{children:[" ","contains ",s(c,{bold:!0,children:"123"})," files."]})]}),g(c,{children:[s(F,{color:e.colors.claude,children:"✻ Th"}),s(F,{color:e.colors.claudeShimmer,children:"ink"}),s(F,{color:e.colors.claude,children:"ing… "}),s(c,{children:"(esc to interrupt)"})]}),s(c,{children:s(F,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(c,{children:s(F,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(c,{children:s(F,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function qe({colorKey:e,theme:t,bold:n=!1}){const o=t.colors[e];return e==="inverseText"?s(F,{color:o,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(F,{backgroundColor:o,bold:n,color:t.colors.text,children:e}):s(F,{color:o,bold:n,children:e})}function it({initialValue:e,onColorChange:t,onExit:n,colorKey:o,theme:r}){const i=Ze(e)||{h:0,s:50,l:50},a=Xe(e)||{r:128,g:128,b:128},[l,u]=O(i),[d,h]=O(a),[f,v]=O("hsl"),[b,p]=O("h"),[w,x]=O(!1),[C,_]=O(!1);xe(()=>{const I=Ze(e),$=Xe(e);I&&$&&(x(!0),u(I),h($),x(!1))},[e]),xe(()=>{if(!w&&C){const I=`rgb(${d.r},${d.g},${d.b})`;t(I)}},[l,d,w,C]),xe(()=>{_(!0)},[]);const k=I=>{if(un(I)){const $=ot(I),S=Ze($),N=Xe($);S&&N&&(x(!0),u(S),h(N),x(!1))}};ue((I,$)=>{if(I.length>1&&!$.ctrl&&!$.meta){k(I);return}if($.return)n();else if($.escape)n();else if($.ctrl&&I==="a")v(S=>S==="hsl"?"rgb":"hsl"),p(S=>f==="hsl"?S==="h"?"r":S==="s"?"g":"b":S==="r"?"h":S==="g"?"s":"l");else if($.upArrow)p(f==="hsl"?S=>S==="h"?"l":S==="s"?"h":"s":S=>S==="r"?"b":S==="g"?"r":"g");else if($.downArrow||$.tab)p(f==="hsl"?S=>S==="h"?"s":S==="s"?"l":"h":S=>S==="r"?"g":S==="g"?"b":"r");else if($.leftArrow){const S=$.shift||$.ctrl||$.meta?-10:-1;P(S)}else if($.rightArrow){const S=$.shift||$.ctrl||$.meta?10:1;P(S)}});const P=I=>{x(!0),f==="hsl"?u($=>{const S={...$};b==="h"?S.h=Math.max(0,Math.min(359,$.h+I)):b==="s"?S.s=Math.max(0,Math.min(100,$.s+I)):b==="l"&&(S.l=Math.max(0,Math.min(100,$.l+I)));const[N,y,L]=j(S.h,S.s,S.l);return h({r:N,g:y,b:L}),S}):h($=>{const S={...$};b==="r"?S.r=Math.max(0,Math.min(255,$.r+I)):b==="g"?S.g=Math.max(0,Math.min(255,$.g+I)):b==="b"&&(S.b=Math.max(0,Math.min(255,$.b+I)));const N=B(S.r,S.g,S.b);return u(N),S}),x(!1)},B=(I,$,S)=>{const N=I/255,y=$/255,L=S/255,z=Math.max(N,y,L),G=Math.min(N,y,L),ne=z-G,se=(z+G)/2;let $e=0;ne!==0&&($e=se>.5?ne/(2-z-G):ne/(z+G));let be=0;return ne!==0&&(z===N?be=((y-L)/ne+(y<L?6:0))/6:z===y?be=((L-N)/ne+2)/6:be=((N-y)/ne+4)/6),{h:Math.round(be*360),s:Math.round($e*100),l:Math.round(se*100)}},j=(I,$,S)=>{I/=360,$/=100,S/=100;const N=(1-Math.abs(2*S-1))*$,y=N*(1-Math.abs(I*6%2-1)),L=S-N/2;let z=0,G=0,ne=0;return 0<=I&&I<1/6?(z=N,G=y,ne=0):1/6<=I&&I<2/6?(z=y,G=N,ne=0):2/6<=I&&I<3/6?(z=0,G=N,ne=y):3/6<=I&&I<4/6?(z=0,G=y,ne=N):4/6<=I&&I<5/6?(z=y,G=0,ne=N):5/6<=I&&I<1&&(z=N,G=0,ne=y),[Math.round((z+L)*255),Math.round((G+L)*255),Math.round((ne+L)*255)]},K=()=>{const I=[],$=[[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 S=0;S<40;S++){const y=S/39*($.length-1),L=Math.floor(y),z=Math.ceil(y),G=y-L,[ne,se,$e]=$[L],[be,H,R]=$[z],D=Math.round(ne+(be-ne)*G),ee=Math.round(se+(H-se)*G),W=Math.round($e+(R-$e)*G);I.push(s(c,{backgroundColor:`rgb(${D},${ee},${W})`,children:" "},S))}return I},U=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,L]=j(l.h,S,l.l);I.push(s(c,{backgroundColor:`rgb(${N},${y},${L})`,children:" "},$))}return I},A=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,L]=j(l.h,l.s,S);I.push(s(c,{backgroundColor:`rgb(${N},${y},${L})`,children:" "},$))}return I},M=()=>{const[I,$,S]=j(l.h,l.s,l.l);return`rgb(${I},${$},${S})`},E=(I,$,S)=>{const N=y=>y.toString(16).padStart(2,"0");return`#${N(I)}${N($)}${N(S)}`},Y=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${S},${d.g},${d.b})`,children:" "},$))}return I},X=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${d.r},${S},${d.b})`,children:" "},$))}return I},re=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${d.r},${d.g},${S})`,children:" "},$))}return I},q=(I,$)=>Math.round(I/$*39);return g(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Color Picker"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(c,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(c,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(c,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(c,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(c,{color:"gray",dimColor:!0,children:"esc to save and exit"})]})]}),f==="hsl"?g(fe,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="h"?"yellow":"white",children:[b==="h"?"❯ ":" ","Hue (",l.h,"°):"]})}),s(m,{children:K().map((I,$)=>s(ke,{children:$===q(l.h,360)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="s"?"yellow":"white",children:[b==="s"?"❯ ":" ","Saturation (",l.s,"%):"]})}),s(m,{children:U().map((I,$)=>s(ke,{children:$===q(l.s,100)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="l"?"yellow":"white",children:[b==="l"?"❯ ":" ","Lightness (",l.l,"%):"]})}),s(m,{children:A().map((I,$)=>s(ke,{children:$===q(l.l,100)?s(c,{children:"|"}):I},$))})]})]}):g(fe,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="r"?"yellow":"white",children:[b==="r"?"❯ ":" ","Red (",d.r,"):"]})}),s(m,{children:Y().map((I,$)=>s(ke,{children:$===q(d.r,255)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="g"?"yellow":"white",children:[b==="g"?"❯ ":" ","Green (",d.g,"):"]})}),s(m,{children:X().map((I,$)=>s(ke,{children:$===q(d.g,255)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="b"?"yellow":"white",children:[b==="b"?"❯ ":" ","Blue (",d.b,"):"]})}),s(m,{children:re().map((I,$)=>s(ke,{children:$===q(d.b,255)?s(c,{children:"|"}):I},$))})]})]}),g(m,{marginBottom:1,children:[s(c,{children:"Current: "}),s(c,{backgroundColor:M(),children:" "})]}),g(m,{flexDirection:"row",justifyContent:"space-between",children:[g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"Hex "}),o?.startsWith("diff")?s(c,{backgroundColor:M(),color:r?.colors?.text||"white",bold:!0,children:E(d.r,d.g,d.b)}):o==="inverseText"?s(c,{color:M(),backgroundColor:r?.colors?.permission,bold:!0,children:E(d.r,d.g,d.b)}):s(c,{color:M(),bold:!0,children:E(d.r,d.g,d.b)})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"RGB "}),o?.startsWith("diff")?s(c,{backgroundColor:M(),color:r?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):o==="inverseText"?s(c,{color:M(),backgroundColor:r?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(c,{color:M(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"HSL "}),o?.startsWith("diff")?s(c,{backgroundColor:M(),color:r?.colors?.text||"white",bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):o==="inverseText"?s(c,{color:M(),backgroundColor:r?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):s(c,{color:M(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function Xe(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};const n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){const o=n[1];return{r:parseInt(o.substr(0,2),16),g:parseInt(o.substr(2,2),16),b:parseInt(o.substr(4,2),16)}}return null}function Ze(e){const t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const r=parseInt(n[1])/255,i=parseInt(n[2])/255,a=parseInt(n[3])/255,l=Math.max(r,i,a),u=Math.min(r,i,a),d=l-u,h=(l+u)/2;let f=0;d!==0&&(f=h>.5?d/(2-l-u):d/(l+u));let v=0;return d!==0&&(l===r?v=((i-a)/d+(i<a?6:0))/6:l===i?v=((a-r)/d+2)/6:v=((r-i)/d+4)/6),{h:Math.round(v*360),s:Math.round(f*100),l:Math.round(h*100)}}const o=e.match(/^#([a-fA-F0-9]{6})$/);if(o){const r=o[1],i=parseInt(r.substr(0,2),16)/255,a=parseInt(r.substr(2,2),16)/255,l=parseInt(r.substr(4,2),16)/255,u=Math.max(i,a,l),d=Math.min(i,a,l),h=u-d,f=(u+d)/2;let v=0;h!==0&&(v=f>.5?h/(2-u-d):h/(u+d));let b=0;return h!==0&&(u===i?b=((a-l)/h+(a<l?6:0))/6:u===a?b=((l-i)/h+2)/6:b=((i-a)/h+4)/6),{h:Math.round(b*360),s:Math.round(v*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function Er({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:o}=pe(he),[r,i]=O(t),a=n.find(A=>A.id===r)||n[0],[l,u]=O("rgb"),[d,h]=O(0),[f,v]=O(null),[b,p]=O(null),[w,x]=O(""),[C,_]=O(""),k=Tn(A=>{o(M=>{const E=M.themes.findIndex(Y=>Y.id===r);E!==-1&&A(M.themes[E])})},[r,o]),P=A=>{if(d>=2&&un(A)){const M=ot(A),E=d-2,Y=B[E];k(X=>{X.colors[Y]=M})}};ue((A,M)=>{if(f===null&&b===null){if(A.length>1&&!M.ctrl&&!M.meta){P(A);return}if(M.escape)e();else if(M.ctrl&&A==="a")u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(M.upArrow)h(E=>Math.max(0,E-1));else if(M.downArrow)h(E=>Math.min(B.length+1,E+1));else if(M.return)if(d===0)p("name"),x(a.name),_(a.name);else if(d===1)p("id"),x(a.id),_(a.id);else{const E=d-2,Y=B[E],X=a.colors[Y];v(E),x(X),_(X)}}else if(f!==null)M.ctrl&&A==="a"&&u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(b!==null)if(M.return){if(b==="id"){const E=r;i(w),o(Y=>{const X=Y.themes.findIndex(re=>re.id===E);X!==-1&&(Y.themes[X].id=w)})}else k(E=>{E.name=w});p(null),x(""),_("")}else M.escape?(p(null),x(""),_("")):M.backspace||M.delete?x(E=>E.slice(0,-1)):A&&x(E=>E+A)});const B=Object.keys(a.colors),j=(A,M)=>{const E=A.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!E)return A;const Y=parseInt(E[1]),X=parseInt(E[2]),re=parseInt(E[3]);switch(M){case"hex":{const q=I=>I.toString(16).padStart(2,"0");return`#${q(Y)}${q(X)}${q(re)}`}case"hsl":{const q=Y/255,I=X/255,$=re/255,S=Math.max(q,I,$),N=Math.min(q,I,$),y=S-N,L=(S+N)/2;let z=0;y!==0&&(z=L>.5?y/(2-S-N):y/(S+N));let G=0;return y!==0&&(S===q?G=((I-$)/y+(I<$?6:0))/6:S===I?G=(($-q)/y+2)/6:G=((q-I)/y+4)/6),`hsl(${Math.round(G*360)}, ${Math.round(z*100)}%, ${Math.round(L*100)}%)`}case"rgb":default:return A}},K=A=>({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"})[A]||"",U=Math.max(...B.map(A=>A.length));return g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{children:g(me,{children:["Editing theme “",a.name,"” (",a.id,")"]})}),f===null&&b===null?g(fe,{children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"enter to edit theme name, id, or color"}),s(c,{dimColor:!0,children:"ctrl+a to toggle rgb, hex, hsl"}),s(c,{dimColor:!0,children:"paste color from clipboard (when on color)"}),s(c,{dimColor:!0,children:"esc to go back"})]}),d<2?g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:"yellow",flexDirection:"column",paddingLeft:1,children:[s(c,{bold:!0,children:d===0?"Theme Name":"Theme ID"}),s(c,{children:d===0?"The display name for this theme":"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:a.colors[B[d-2]],flexDirection:"column",paddingLeft:1,children:[s(qe,{colorKey:B[d-2],theme:a,bold:!0}),s(c,{children:K(B[d-2])})]}),g(m,{flexDirection:"column",children:[g(m,{children:[s(c,{color:d===0?"yellow":"white",children:d===0?"❯ ":" "}),s(c,{bold:!0,children:"Name: "}),s(c,{children:a.name})]}),g(m,{marginBottom:1,children:[s(c,{color:d===1?"yellow":"white",children:d===1?"❯ ":" "}),s(c,{bold:!0,children:"ID: "}),s(c,{children:a.id})]}),(()=>{if(d<2){const q=B.slice(0,20);return g(fe,{children:[q.map((I,$)=>{const S=$+2;return g(m,{children:[s(c,{color:d===S?"yellow":"white",children:d===S?"❯ ":" "}),s(m,{width:U+2,children:s(c,{children:s(qe,{colorKey:I,theme:a,bold:!0})})}),s(F,{color:a.colors[I],children:j(a.colors[I],l)})]},I)}),B.length>20&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",B.length-20," more below"]})]})}const M=d-2,E=Math.max(0,M-Math.floor(20/2)),Y=Math.min(B.length,E+20),X=Math.max(0,Y-20),re=B.slice(X,Y);return g(fe,{children:[X>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",X," more above"]}),re.map((q,I)=>{const S=X+I+2;return g(m,{children:[s(c,{color:d===S?"yellow":"white",children:d===S?"❯ ":" "}),s(m,{width:U+2,children:s(c,{children:s(qe,{colorKey:q,theme:a,bold:!0})})}),s(F,{color:a.colors[q],children:j(a.colors[q],l)})]},q)}),Y<B.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",B.length-Y," more below"]})]})})()]})]}):b?g(m,{flexDirection:"column",marginTop:1,children:[g(c,{children:["Editing ",b==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(c,{children:w})}),s(c,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(it,{initialValue:C,colorKey:B[f],theme:a,onColorChange:A=>{x(A),k(M=>{M.colors[B[f]]=A})},onExit:()=>{k(A=>{A.colors[B[f]]=w}),v(null),x(""),_("")}})]}),s(m,{width:"50%",children:s(rt,{theme:a})})]})}function kr(e){return e.map(t=>`${t.name} (${t.id})`)}function Tr({onBack:e}){const{settings:{themes:t},updateSettings:n}=pe(he),[o,r]=O(0),[i,a]=O(null),[l,u]=O(!0),d=()=>{const w={colors:{...(t[0]||Z.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(x=>{x.themes.push(w)}),a(w.id),u(!1)},h=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(x=>x.id!==p)}),o>=t.length-1&&r(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...Z.themes]}),r(0)};if(ue((p,w)=>{if(w.escape)e();else if(w.upArrow)r(x=>Math.max(0,x-1));else if(w.downArrow)r(x=>Math.min(t.length-1,x+1));else if(w.return){const x=t[o];x&&(a(x.id),u(!1))}else if(p==="n")d();else if(p==="d"){const x=t[o];x&&h(x.id)}else w.ctrl&&p==="r"&&f()},{isActive:l}),i)return s(Er,{themeId:i,onBack:()=>{a(null),u(!0)}});const v=kr(t),b=t.find(p=>v[o]?.includes(`(${p.id})`))||t[0];return t.length===0?s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[s(me,{children:"Themes"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(c,{children:"No themes available!"})]})}):g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(me,{children:"Themes"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new theme"}),s(c,{dimColor:!0,children:"d to delete a theme"}),s(c,{dimColor:!0,children:"ctrl+r to delete all themes and restore built-in"}),s(c,{dimColor:!0,children:"enter to edit theme"}),s(c,{dimColor:!0,children:"esc to go back"})]}),s(m,{flexDirection:"column",children:v.map((p,w)=>g(c,{color:o===w?"yellow":void 0,children:[o===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(rt,{theme:b})})]})}function Mr({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:o},updateSettings:r}=pe(he),i=["format","verbs"],[a,l]=O(0),u=i[a],[d,h]=O(0),[f,v]=O(!1),[b,p]=O(""),[w,x]=O(!1),[C,_]=O(!1),[k,P]=O(t),B=dn(),K=(o.find(A=>A.id===B)||o.find(A=>A.id==="dark"))?.colors.claude||"rgb(215,119,87)";ue((A,M)=>{if(C){M.return?(r(E=>{E.thinkingVerbs.format=k}),_(!1)):M.escape?(P(t),_(!1)):M.backspace||M.delete?P(E=>E.slice(0,-1)):A&&P(E=>E+A);return}if(f||w){M.return&&b.trim()?(w?(r(E=>{E.thinkingVerbs.verbs.push(b.trim())}),x(!1)):(r(E=>{E.thinkingVerbs.verbs[d]=b.trim()}),v(!1)),p("")):M.escape?(p(""),v(!1),x(!1)):M.backspace||M.delete?p(E=>E.slice(0,-1)):A&&p(E=>E+A);return}M.escape?e():M.return?u==="format"&&(P(t),_(!0)):M.tab?M.shift?l(E=>E===0?i.length-1:E-1):l(E=>E===i.length-1?0:E+1):M.upArrow?u==="verbs"&&n.length>0&&h(E=>E>0?E-1:n.length-1):M.downArrow?u==="verbs"&&n.length>0&&h(E=>E<n.length-1?E+1:0):A==="e"&&u==="verbs"?n.length>0&&(p(n[d]),v(!0)):A==="d"&&u==="verbs"?n.length>1&&(r(E=>{E.thinkingVerbs.verbs=E.thinkingVerbs.verbs.filter((Y,X)=>X!==d)}),d>=n.length-1&&h(Math.max(0,n.length-2))):A==="n"&&u==="verbs"?(x(!0),p("")):M.ctrl&&A==="r"&&u==="verbs"&&(r(E=>{E.thinkingVerbs.verbs=[...Z.thinkingVerbs.verbs]}),h(0))});const U=50;return g(m,{children:[g(m,{flexDirection:"column",width:`${100-U}%`,children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(me,{children:"Thinking Verbs"}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:u==="format"?"enter to edit format":"changes auto-saved"}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),s(m,{marginBottom:1,children:s(c,{dimColor:!0,children:"Customize the verbs shown during generation and their format."})}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:u==="format"?"yellow":void 0,children:u==="format"?"❯ ":" "}),s(c,{bold:!0,color:u==="format"?"yellow":void 0,children:"Format"})]}),u==="format"&&(C?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:C?"yellow":"gray",children:s(c,{children:C?k:t})})}),s(m,{children:g(c,{children:[s(c,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(c,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","e to edit · d to delete · n to add new · ctrl+r to reset"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const M=Math.max(0,d-Math.floor(4)),E=Math.min(n.length,M+8),Y=Math.max(0,E-8),X=n.slice(Y,E);return g(fe,{children:[Y>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",Y," more above"]}),X.map((re,q)=>{const I=Y+q;return g(c,{color:u==="verbs"&&I===d?"cyan":void 0,children:[u==="verbs"&&I===d?"❯ ":" ",re]},I)}),E<n.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-E," more below"]})]})})(),w&&g(m,{alignItems:"center",children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]}),f&&g(m,{marginTop:1,alignItems:"center",children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]})]})})]}),g(m,{width:`${U}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:g(c,{children:[g(c,{color:K,children:["✻ ",t.replace(/\{\}/g,n[d])," "]}),s(c,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:Z.thinkingStyle.phases,reverseMirror:Z.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 Nr({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:o},themes:r},updateSettings:i}=pe(he),a=["reverseMirror","updateInterval","phases","presets"],[l,u]=O(0),d=a[l],[h,f]=O(0),[v,b]=O(0),[p,w]=O(!1),[x,C]=O(""),[_,k]=O(!1),[P,B]=O(!1),[j,K]=O(n.toString()),[U,A]=O(0),M=dn(),Y=(r.find(S=>S.id===M)||r.find(S=>S.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const S=o?[...t,...[...t].reverse().slice(1,-1)]:t,N=setInterval(()=>{A(y=>(y+1)%S.length)},n);return()=>clearInterval(N)}},[t,n,o]),ue((S,N)=>{if(P){if(N.return){const y=parseInt(j);!isNaN(y)&&y>0&&i(L=>{L.thinkingStyle.updateInterval=y}),B(!1)}else N.escape?(K(n.toString()),B(!1)):N.backspace||N.delete?K(y=>y.slice(0,-1)):S&&S.match(/^[0-9]$/)&&K(y=>y+S);return}if(p||_){if(N.return&&x.length){const y=_?[...t,x]:t.map((L,z)=>z===h?x:L);i(L=>{L.thinkingStyle.phases=y}),w(!1),C("")}else N.escape?(C(""),w(!1),k(!1)):N.backspace||N.delete?C(y=>y.slice(0,-1)):S&&C(y=>y+S);return}if(N.escape)e();else if(N.return)if(d==="updateInterval")K(n.toString()),B(!0);else if(d==="presets"){const y=_e[v];i(L=>{L.thinkingStyle.phases=[...y.phases],L.thinkingStyle.reverseMirror=y.reverseMirror})}else d==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(N.tab)N.shift?u(y=>y===0?a.length-1:y-1):u(y=>y===a.length-1?0:y+1);else if(N.upArrow)d==="phases"&&t.length>0?f(y=>y>0?y-1:t.length-1):d==="presets"&&b(y=>y>0?y-1:_e.length-1);else if(N.downArrow)d==="phases"&&t.length>0?f(y=>y<t.length-1?y+1:0):d==="presets"&&b(y=>y<_e.length-1?y+1:0);else if(S===" ")d==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(S==="e"&&d==="phases")t.length>0&&(C(t[h]),w(!0));else if(S==="a"&&d==="phases")k(!0),C("");else if(S==="d"&&d==="phases")t.length>1&&(i(y=>{y.thinkingStyle.phases=t.filter((L,z)=>z!==h)}),h>=t.length&&f(Math.max(0,t.length-1)));else if(S==="w"&&d==="phases"){if(h>0){const y=[...t];[y[h-1],y[h]]=[y[h],y[h-1]],i(L=>{L.thinkingStyle.phases=y}),f(L=>L-1)}}else if(S==="s"&&d==="phases"){if(h<t.length-1){const y=[...t];[y[h],y[h+1]]=[y[h+1],y[h]],i(L=>{L.thinkingStyle.phases=y}),f(L=>L+1)}}else N.ctrl&&S==="r"&&(i(y=>{y.thinkingStyle=Z.thinkingStyle}),f(0),b(0))});const X=o?"●":"○",re=50,I=o?[...t,...[...t].reverse().slice(1,-1)]:t,$=I.length>0?I[U]:"·";return s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[g(m,{flexDirection:"row",width:"100%",children:[g(m,{marginBottom:1,flexDirection:"column",width:`${100-re}%`,children:[s(me,{children:"Thinking style"}),g(m,{flexDirection:"column",children:[g(c,{dimColor:!0,children:["enter to"," ",d==="updateInterval"?"edit interval":d==="presets"?"apply preset":"save"]}),s(c,{dimColor:!0,children:"esc to go back"}),s(c,{dimColor:!0,children:"tab to switch sections"})]})]}),g(m,{width:`${re}%`,flexDirection:"column",children:[s(m,{children:s(c,{bold:!0,children:"Preview"})}),g(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:($?.length??0)+1,children:s(c,{color:Y,children:$})}),g(c,{children:[s(c,{color:Y,children:"Thinking… "}),s(c,{children:"(esc to interrupt)"})]})]})]})]}),g(m,{flexDirection:"row",gap:4,children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="reverseMirror"?"yellow":void 0,children:d==="reverseMirror"?"❯ ":" "}),s(c,{bold:!0,color:d==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),d==="reverseMirror"&&g(c,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:g(c,{children:[X," ",o?"Enabled":"Disabled"]})})]}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="updateInterval"?"yellow":void 0,children:d==="updateInterval"?"❯ ":" "}),s(c,{bold:!0,color:d==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),d==="updateInterval"&&(P?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:P?"yellow":"gray",children:s(c,{children:P?j:n})})})]})]}),s(m,{children:g(c,{children:[s(c,{color:d==="phases"?"yellow":void 0,children:d==="phases"?"❯ ":" "}),s(c,{bold:!0,color:d==="phases"?"yellow":void 0,children:"Phases"})]})}),d==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","[e]dit"," ","[a]dd"," ","[d]elete"," ","[w]move up"," ","[s]move down"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const N=Math.max(0,h-Math.floor(4)),y=Math.min(t.length,N+8),L=Math.max(0,y-8),z=t.slice(L,y);return g(fe,{children:[L>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",L," more above"]}),z.map((G,ne)=>{const se=L+ne;return g(c,{color:d==="phases"&&se===h?"cyan":void 0,children:[d==="phases"&&se===h?"❯ ":" ",G]},se)}),y<t.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-y," more below"]})]})})(),_&&g(m,{children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:x})})]}),p&&g(m,{marginTop:1,children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:x})})]})]})}),s(m,{children:g(c,{children:[s(c,{color:d==="presets"?"yellow":void 0,children:d==="presets"?"❯ ":" "}),s(c,{bold:!0,color:d==="presets"?"yellow":void 0,children:"Presets"})]})}),d==="presets"&&g(c,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const N=Math.max(0,v-Math.floor(4)),y=Math.min(_e.length,N+8),L=Math.max(0,y-8),z=_e.slice(L,y);return g(fe,{children:[L>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",L," more above"]}),z.map((G,ne)=>{const se=L+ne;return g(c,{color:d==="presets"&&se===v?"cyan":void 0,children:[d==="presets"&&se===v?"❯ ":" ",G.name," ",G.phases.join("")]},se)}),y<_e.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-y," more below"]})]})})()})}),s(m,{marginTop:1,children:s(c,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const Pe=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function Br({onBack:e}){const{settings:t,updateSettings:n}=pe(he),[o,r]=O("prefix"),[i,a]=O(0),[l,u]=O(!1),[d,h]=O(()=>t.userMessageDisplay.prefix.format),[f,v]=O(0),[b,p]=O(()=>[...t.userMessageDisplay.prefix.styling]),[w,x]=O(()=>t.userMessageDisplay.prefix.foreground_color),[C,_]=O(()=>t.userMessageDisplay.prefix.background_color),[k,P]=O(0),[B,j]=O(0),[K,U]=O(()=>[...t.userMessageDisplay.message.styling]),[A,M]=O(()=>t.userMessageDisplay.message.foreground_color),[E,Y]=O(()=>t.userMessageDisplay.message.background_color),[X,re]=O(null),[q,I]=O(""),$=dn(),S=t.themes?.find(H=>H.id===$)||t.themes?.[0],N=["format","styling","foreground","background"],y=["styling","foreground","background"],L=N[i],z=y[k],G=(H,R)=>{n(D=>{const ee=H==="prefix"?D.userMessageDisplay.prefix:D.userMessageDisplay.message;R(ee)})},ne=H=>{n(R=>{H==="prefix"?R.userMessageDisplay.prefix={...Z.userMessageDisplay.prefix}:R.userMessageDisplay.message={...Z.userMessageDisplay.message}}),H==="prefix"?(h(Z.userMessageDisplay.prefix.format),p([...Z.userMessageDisplay.prefix.styling]),x(Z.userMessageDisplay.prefix.foreground_color),_(Z.userMessageDisplay.prefix.background_color)):(U([...Z.userMessageDisplay.message.styling]),M(Z.userMessageDisplay.message.foreground_color),Y(Z.userMessageDisplay.message.background_color))};xe(()=>{const H=t.userMessageDisplay.prefix;h(H.format),p([...H.styling]),x(H.foreground_color),_(H.background_color);const R=t.userMessageDisplay.message;U([...R.styling]),M(R.foreground_color),Y(R.background_color)},[]),ue((H,R)=>{if(l){if(R.return)G("prefix",D=>{D.format=d}),u(!1);else if(R.escape){const D=t.userMessageDisplay.prefix;h(D.format),u(!1)}else R.backspace||R.delete?h(D=>D.slice(0,-1)):H&&h(D=>D+H);return}if(X===null){if(R.escape)e();else if(R.ctrl&&H==="r")ne(o);else if(R.leftArrow||R.rightArrow)r(D=>D==="prefix"?"message":"prefix");else if(R.tab)o==="prefix"?R.shift?a(D=>D===0?N.length-1:D-1):a(D=>D===N.length-1?0:D+1):R.shift?P(D=>D===0?y.length-1:D-1):P(D=>D===y.length-1?0:D+1);else if(R.return)o==="prefix"?L==="format"?u(!0):L==="foreground"?(I(w),re({column:"prefix",type:"foreground"})):L==="background"&&(I(C),re({column:"prefix",type:"background"})):z==="foreground"?(I(A),re({column:"message",type:"foreground"})):z==="background"&&(I(E),re({column:"message",type:"background"}));else if(R.upArrow)o==="prefix"&&L==="styling"?v(D=>Math.max(0,D-1)):o==="message"&&z==="styling"&&j(D=>Math.max(0,D-1));else if(R.downArrow)o==="prefix"&&L==="styling"?v(D=>Math.min(Pe.length-1,D+1)):o==="message"&&z==="styling"&&j(D=>Math.min(Pe.length-1,D+1));else if(H===" "){if(o==="prefix"&&L==="styling"){const D=Pe[f].value,ee=b.indexOf(D)>=0?b.filter(W=>W!==D):[...b,D];p(ee),G("prefix",W=>{W.styling=[...ee]})}else if(o==="message"&&z==="styling"){const D=Pe[B].value,ee=K.indexOf(D)>=0?K.filter(W=>W!==D):[...K,D];U(ee),G("message",W=>{W.styling=[...ee]})}}}});const se=(H,R,D=!0)=>{const ee=D?R==="prefix"?b:K:[],W=D?R==="prefix"?w:A:"rgb(255,255,255)",Be=D?R==="prefix"?C:E:"rgb(0,0,0)",Oe=W==="rgb(0,0,0)"&&Be==="rgb(0,0,0)",je=ee.length>0;return Oe&&!je?s(c,{children:H}):s(c,{bold:ee.includes("bold"),italic:ee.includes("italic"),underline:ee.includes("underline"),strikethrough:ee.includes("strikethrough"),inverse:ee.includes("inverse"),color:Oe?void 0:W,backgroundColor:Oe?void 0:Be,children:H})},$e=(H=!0)=>g(c,{children:[d&&g(fe,{children:[se(d,"prefix",H)," "]}),se("list the dir","message",H)]}),be=H=>{const R=o===H,W=(H==="prefix"?N:y)[H==="prefix"?i:k],Be=H==="prefix"?f:B,Oe=H==="prefix"?b:K,je=H==="prefix"?w:A,gn=H==="prefix"?C:E;return g(m,{flexDirection:"column",width:"45%",borderStyle:R?"round":"single",borderColor:R?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,color:R?"yellow":void 0,children:[H.charAt(0).toUpperCase()+H.slice(1)," ","Configuration"]})}),H==="prefix"&&g(fe,{children:[s(m,{children:g(c,{color:R&&W==="format"?"yellow":void 0,bold:R&&W==="format",children:[R&&W==="format"?"❯ ":" ","Prefix Text"]})}),R&&W==="format"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:l?"enter to save":"enter to edit (appears before message)"})}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:l?"yellow":"gray",children:s(c,{children:d})})})]}),s(m,{children:g(c,{color:R&&W==="styling"?"yellow":void 0,bold:R&&W==="styling",children:[R&&W==="styling"?"❯ ":" ","Styling"]})}),R&&W==="styling"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:Pe.map((Je,fn)=>s(m,{children:g(c,{color:R&&W==="styling"&&Be===fn?"cyan":void 0,children:[R&&W==="styling"&&Be===fn?"❯ ":" ",Oe.includes(Je.value)?"●":"○"," ",Je.label]})},Je.value))}),s(m,{children:g(c,{color:R&&W==="foreground"?"yellow":void 0,bold:R&&W==="foreground",children:[R&&W==="foreground"?"❯ ":" ","Foreground color"]})}),R&&W==="foreground"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,marginBottom:1,children:s(c,{color:je,children:je})}),s(m,{children:g(c,{color:R&&W==="background"?"yellow":void 0,bold:R&&W==="background",children:[R&&W==="background"?"❯ ":" ","Background color"]})}),R&&W==="background"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(c,{backgroundColor:gn,children:gn})})]})};if(X){const{column:H,type:R}=X;return s(it,{initialValue:q,theme:S,onColorChange:D=>{H==="prefix"?R==="foreground"?(x(D),G("prefix",ee=>{ee.foreground_color=D})):(_(D),G("prefix",ee=>{ee.background_color=D})):R==="foreground"?(M(D),G("message",ee=>{ee.foreground_color=D})):(Y(D),G("message",ee=>{ee.background_color=D}))},onExit:()=>{re(null),I("")}})}return g(m,{flexDirection:"column",children:[s(me,{children:"Customize how user messages are displayed"}),g(m,{flexDirection:"column",marginBottom:1,children:[s(c,{dimColor:!0,children:"left/right arrows to switch columns · tab to navigate options"}),s(c,{dimColor:!0,children:"enter to edit · ctrl+r to reset active column · esc to go back"})]}),g(m,{flexDirection:"row",gap:1,children:[be("prefix"),be("message")]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),g(m,{flexDirection:"row",gap:2,children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"Before (Claude Code default):"})}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:S?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]}),g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,children:$e(!0)}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:S?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]})]})]})})]})}function Or({onSubmit:e}){const{settings:t,updateSettings:n}=pe(he),[o,r]=O(0),i=()=>{n(b=>{b.inputBox||(b.inputBox={removeBorder:!1}),b.inputBox.removeBorder=!b.inputBox.removeBorder})},a=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showTweakccVersion=!b.misc.showTweakccVersion})},l=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showPatchesApplied=!b.misc.showPatchesApplied})},u=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.expandThinkingBlocks=!b.misc.expandThinkingBlocks})};ue((b,p)=>{p.return||p.escape?e():p.upArrow?r(w=>Math.max(0,w-1)):p.downArrow?r(w=>Math.min(3,w+1)):b===" "&&(o===0?i():o===1?a():o===2?l():o===3&&u())});const d=t.inputBox?.removeBorder?"☑":"☐",h=t.misc?.showTweakccVersion?"☑":"☐",f=t.misc?.showPatchesApplied?"☑":"☐",v=t.misc?.expandThinkingBlocks?"☑":"☐";return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(me,{children:"Miscellaneous Settings"})}),s(m,{marginBottom:1,children:s(c,{color:"gray",children:s(c,{dimColor:!0,children:"Various tweaks and customizations. Press space to toggle settings, enter to go back."})})}),s(m,{children:g(c,{children:[s(c,{color:o===0?"cyan":void 0,children:o===0?"❯ ":" "}),s(c,{bold:!0,color:o===0?"cyan":void 0,children:"Remove input box border"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Removes the rounded border around the input box for a cleaner look."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[d," ",t.inputBox?.removeBorder?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===1?"cyan":void 0,children:o===1?"❯ ":" "}),s(c,{bold:!0,color:o===1?"cyan":void 0,children:"Show tweakcc version at startup"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ",'Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[h," ",t.misc?.showTweakccVersion?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===2?"cyan":void 0,children:o===2?"❯ ":" "}),s(c,{bold:!0,color:o===2?"cyan":void 0,children:"Show patches applied indicator at startup"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ",'Shows the green "tweakcc patches are applied" indicator when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[f," ",t.misc?.showPatchesApplied?"Enabled":"Disabled"]})}),s(m,{children:g(c,{children:[s(c,{color:o===3?"cyan":void 0,children:o===3?"❯ ":" "}),s(c,{bold:!0,color:o===3?"cyan":void 0,children:"Expand thinking blocks"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Makes thinking blocks always expanded by default instead of collapsed."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[v," ",t.misc?.expandThinkingBlocks?"Enabled":"Disabled"]})})]})}const Ue=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","ExitPlanMode"];function Ar({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:o}=pe(he),r=n.toolsets[e],[i,a]=O(r?.name||"New Toolset"),[l,u]=O(r?.allowedTools||[]),[d,h]=O(!1),[f,v]=O(0);xe(()=>{r&&o(C=>{C.toolsets[e].name=i,C.toolsets[e].allowedTools=l})},[i,l]);const b=C=>l==="*"?!0:l.includes(C),p=C=>{C==="All"?u("*"):C==="None"?u([]):l==="*"?u(Ue.filter(_=>_!==C)):l.includes(C)?u(l.filter(_=>_!==C)):u([...l,C])};if(ue((C,_)=>{if(d){_.return?h(!1):_.escape?(a(r?.name||"New Toolset"),h(!1)):_.backspace||_.delete?a(k=>k.slice(0,-1)):C&&C.length===1&&a(k=>k+C);return}if(_.escape)t();else if(_.upArrow)v(k=>Math.max(0,k-1));else if(_.downArrow)v(k=>Math.min(Ue.length+1,k+1));else if(C===" "||_.return)if(f===0)p("All");else if(f===1)p("None");else{const k=Ue[f-2];k&&p(k)}else C==="n"&&h(!0)}),!r)return s(m,{flexDirection:"column",children:s(c,{color:"red",children:"Toolset not found"})});const w=l==="*",x=Array.isArray(l)&&l.length===0;return g(m,{flexDirection:"column",children:[s(me,{children:"Edit Toolset"}),s(m,{marginBottom:1,flexDirection:"column",children:s(c,{dimColor:!0,children:"n to edit name · space/enter to toggle · esc to go back"})}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Name:"}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:d?"yellow":"gray",children:s(c,{children:i})})}),d&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to save · esc to cancel"})})]}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{bold:!0,children:"Allowed Tools:"}),s(m,{marginLeft:2,children:g(c,{color:f===0?"cyan":void 0,children:[f===0?"❯ ":" ",w?"●":"○"," All"]})}),s(m,{marginLeft:2,children:g(c,{color:f===1?"cyan":void 0,children:[f===1?"❯ ":" ",x?"●":"○"," None"]})}),Ue.map((C,_)=>{const k=_+2;return s(m,{marginLeft:2,children:g(c,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(C)?"◉":"○"," ",C]})},C)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Summary:"}),g(c,{children:["Name: ",s(c,{color:"cyan",children:i})]}),g(c,{children:["Tools:"," ",l==="*"?s(c,{color:"green",children:"All tools (*)"}):l.length===0?s(c,{color:"red",children:"No tools ([])"}):g(c,{color:"yellow",children:[l.length," selected"]})]})]})})]})}function Pr({onBack:e}){const{settings:{toolsets:t,defaultToolset:n},updateSettings:o}=pe(he),[r,i]=O(0),[a,l]=O(null),[u,d]=O(!0),h=()=>{const p={name:"New Toolset",allowedTools:[]};o(w=>{w.toolsets.push(p)}),l(t.length),d(!1)},f=p=>{const w=t[p];o(x=>{x.toolsets.splice(p,1),x.defaultToolset===w.name&&(x.defaultToolset=null)}),r>=t.length-1&&i(Math.max(0,t.length-2))},v=p=>{const w=t[p];o(x=>{x.defaultToolset=w.name})};if(ue((p,w)=>{w.escape?e():w.upArrow?i(x=>Math.max(0,x-1)):w.downArrow?i(x=>Math.min(t.length-1,x+1)):w.return&&t.length>0?(l(r),d(!1)):p==="n"?h():p==="d"&&t.length>0?f(r):p==="s"&&t.length>0&&v(r)},{isActive:u}),a!==null)return s(Ar,{toolsetIndex:a,onBack:()=>{l(null),d(!0)}});const b=p=>p.allowedTools==="*"?"All tools":p.allowedTools.length===0?"No tools":`${p.allowedTools.length} tool${p.allowedTools.length===1?"":"s"}`;return g(m,{flexDirection:"column",children:[s(me,{children:"Toolsets"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{dimColor:!0,children:"n to create a new toolset"}),t.length>0&&s(c,{dimColor:!0,children:"s to set as default toolset"}),t.length>0&&s(c,{dimColor:!0,children:"d to delete a toolset"}),t.length>0&&s(c,{dimColor:!0,children:"enter to edit toolset"}),s(c,{dimColor:!0,children:"esc to go back"})]}),t.length===0?s(c,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:t.map((p,w)=>{const x=p.name===n,C=r===w;return g(c,{color:C?"yellow":void 0,bold:x,children:[C?"❯ ":" ",p.name,x&&" [DEFAULT]"," (",b(p),")"]},w)})})]})}const he=at({settings:Z,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function Lr({startupCheckInfo:e}){const[t,n]=O({settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await ln())})()},[]);const o=Tn(h=>{const f=JSON.parse(JSON.stringify(t.settings));h(f),n(v=>({...v,settings:f,changesApplied:!1})),Ve(v=>{v.settings=f,v.changesApplied=!1})},[t.settings]),[r,i]=O(null),[a,l]=O(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(l({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
649
+ (However, your customization are still remembered in ${ce}.)
650
+ Please reapply your changes below.`,type:"warning"}),o(()=>{}))},[]),ue((h,f)=>{(f.ctrl&&h==="c"||(h==="q"||f.escape)&&!r)&&process.exit(0)},{isActive:!r});const u=h=>{switch(l(null),h){case J.APPLY_CHANGES:e.ccInstInfo&&(l({message:"Applying patches...",type:"info"}),et(t,e.ccInstInfo).then(f=>{n(f),l({message:"Customization patches applied successfully!",type:"success"})}));break;case J.THEMES:case J.THINKING_VERBS:case J.THINKING_STYLE:case J.USER_MESSAGE_DISPLAY:case J.MISC:case J.TOOLSETS:i(h);break;case J.VIEW_SYSTEM_PROMPTS:$r(Se);break;case J.RESTORE_ORIGINAL:e.ccInstInfo&&Yn(e.ccInstInfo).then(()=>{l({message:"Original Claude Code restored successfully!",type:"success"}),o(()=>{})});break;case J.OPEN_CONFIG:Cn(ce);break;case J.OPEN_CLI:e.ccInstInfo?.cliPath&&Cn(e.ccInstInfo.cliPath);break;case J.EXIT:process.exit(0)}},d=()=>{i(null)};return s(he.Provider,{value:{settings:t.settings,updateSettings:o,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:r===null?s(bt,{onSubmit:u,notification:a,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):r===J.THEMES?s(Tr,{onBack:d}):r===J.THINKING_VERBS?s(Mr,{onBack:d}):r===J.THINKING_STYLE?s(Nr,{onBack:d}):r===J.USER_MESSAGE_DISPLAY?s(Br,{onBack:d}):r===J.MISC?s(Or,{onSubmit:d}):r===J.TOOLSETS?s(Pr,{onBack:d}):null})})}const kn=async e=>{try{await ie.mkdir(de,{recursive:!0});try{await ie.stat(ce)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT"){const n={ccInstallationDir:e};await ie.writeFile(ce,JSON.stringify(n,null,2))}}}catch{}},Dr=async()=>{const e=new lt;e.name("tweakcc").description("Command-line tool to customize your Claude Code theme colors, thinking verbs and more.").version("3.1.0").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const t=e.opts();if(t.debug&&yr(),t.apply){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${ce}`);const o=await ln();(!o.settings||Object.keys(o.settings).length===0)&&(console.error("No saved customizations found in "+ce),process.exit(1));const r=await In();if(!r||!r.ccInstInfo){const a=process.platform=="win32"?"C:\\absolute\\path\\to\\node_modules\\@anthropic-ai\\claude-code":"/absolute/path/to/node_modules/@anthropic-ai/claude-code";await kn(a),console.error("Cannot find Claude Code's cli.js"),console.error("Searched for cli.js at the following locations:"),Qe.forEach(l=>{l.isGlob?l.expandedPaths.length===0?console.error(` - ${l.pattern} (no matches)`):(console.error(` - ${l.pattern}`),l.expandedPaths.forEach(u=>{console.error(` - ${u}`)})):console.error(` - ${l.pattern}`)}),console.error(`
651
+ Also checked for 'claude' executable on PATH using '${process.platform==="win32"?"where claude.exe":"which claude"}'.`),process.exit(1)}r.ccInstInfo.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${r.ccInstInfo.nativeInstallationPath}`):console.log(`Found Claude Code at: ${r.ccInstInfo.cliPath}`),console.log(`Version: ${r.ccInstInfo.version}`),console.log("Loading system prompts...");const i=await vn(r.ccInstInfo.version);i.success||(console.log(Q.red(`
439
652
  ✖ Error downloading system prompts:`)),console.log(Q.red(` ${i.errorMessage}`)),console.log(Q.yellow(`
440
- ⚠ System prompts not available - skipping system prompt customizations`))),console.log("Applying customizations..."),await Zn(r,o.ccInstInfo),console.log("Customizations applied successfully!"),process.exit(0)}const n=await _n();if(n){const r=await Sn(n.ccInstInfo.version);r.success||(console.log(Q.red(`
441
- ✖ Error downloading system prompts:`)),console.log(Q.red(` ${r.errorMessage}`)),console.log(Q.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
442
- `))),ot(s(So,{startupCheckInfo:n}))}else console.error(`Cannot find Claude Code's cli.js -- do you have Claude Code installed?
653
+ ⚠ System prompts not available - skipping system prompt customizations`))),console.log("Applying customizations..."),await et(o,r.ccInstInfo),console.log("Customizations applied successfully!"),process.exit(0)}const n=await In();if(n){const o=await vn(n.ccInstInfo.version);o.success||(console.log(Q.red(`
654
+ ✖ Error downloading system prompts:`)),console.log(Q.red(` ${o.errorMessage}`)),console.log(Q.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
655
+ `))),st(s(Lr,{startupCheckInfo:n}))}else{const o=()=>Qe.map(i=>{if(i.isGlob){if(i.expandedPaths.length===0)return`- ${i.pattern} (no matches)`;{const a=[`- ${i.pattern}`];return i.expandedPaths.forEach(l=>{a.push(` - ${l}`)}),a.join(`
656
+ `)}}else return`- ${i.pattern}`}).join(`
657
+ `),r=process.platform=="win32"?"C:\\absolute\\path\\to\\node_modules\\@anthropic-ai\\claude-code":"/absolute/path/to/node_modules/@anthropic-ai/claude-code";await kn(r),console.error(`Cannot find Claude Code's cli.js -- do you have Claude Code installed?
443
658
 
444
659
  Searched for cli.js at the following locations:
445
- ${Ze.map(o=>{if(o.isGlob){if(o.expandedPaths.length===0)return`- ${o.pattern} (no matches)`;{const i=[`- ${o.pattern}`];return o.expandedPaths.forEach(l=>{i.push(` - ${l}`)}),i.join(`
446
- `)}}else return`- ${o.pattern}`}).join(`
447
- `)}
660
+ ${o()}
448
661
 
449
662
  Also checked for 'claude' executable on PATH using '${process.platform==="win32"?"where claude.exe":"which claude"}'.
450
663
 
451
664
  If you have it installed but it's in a location not listed above, please open an issue at
452
665
  https://github.com/piebald-ai/tweakcc/issues and tell us where you have it--we'll add that location
453
666
  to our search list and release an update today! And in the meantime, you can get tweakcc working
454
- by manually specifying that location in ${fe} with the "ccInstallationDir" property:
667
+ by manually specifying that location in ${ce} with the "ccInstallationDir" property:
455
668
 
456
669
  {
457
- "ccInstallationDir": "${process.platform=="win32"?"C:\\\\absolute\\\\path\\\\to\\\\node_modules\\\\@anthropic-ai\\\\claude-code":"/absolute/path/to/node_modules/@anthropic-ai/claude-code"}"
670
+ "ccInstallationDir": "${r}"
458
671
  }
459
672
 
460
673
  Notes:
@@ -462,4 +675,4 @@ Notes:
462
675
  - Don't specify the path to your Claude Code executable's directory. It needs to be the path
463
676
  to the folder that contains **cli.js**.
464
677
  - Please also open an issue so that we can add your path to the search list for all users!
465
- `),process.exit(1)};vo();
678
+ `),process.exit(1)}};Dr();