tweakcc 3.1.5 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +56 -13
  2. package/dist/index.js +144 -128
  3. package/package.json +13 -3
package/dist/index.js CHANGED
@@ -1,23 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import{Box as m,Text as c,render as ct,useInput as de}from"ink";import{Command as dt}from"commander";import H from"chalk";import*as oe from"node:fs/promises";import ie from"node:fs/promises";import Ze,{Fragment as Ee,createContext as ut,useCallback as Nn,useContext as be,useEffect as xe,useState as P}from"react";import ht from"ink-link";import{Fragment as me,jsx as s,jsxs as g}from"react/jsx-runtime";import*as re from"node:path";import On from"node:path";import*as ye from"node:os";import{EOL as bn}from"node:os";import*as Ie from"node:fs";import Le from"node:fs";import{globbySync as gt}from"globby";import ft from"node:process";import*as Me from"node:child_process";import{execSync as Bn}from"node:child_process";import*as An from"node:crypto";import Ge from"gray-matter";import Fe from"node-lief";function mt({items:e,selectedIndex:t,onSelect:n,onSubmit:o}){return de((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 Z=function(e){return e.APPLY_CHANGES="*Apply customizations",e.THEMES="Themes",e.THINKING_VERBS="Thinking verbs",e.THINKING_STYLE="Thinking style",e.USER_MESSAGE_DISPLAY="User message display",e.MISC="Misc",e.TOOLSETS="Toolsets",e.VIEW_SYSTEM_PROMPTS="View system prompts",e.RESTORE_ORIGINAL="Restore original Claude Code (preserves config.json)",e.OPEN_CONFIG="Open config.json",e.OPEN_CLI="Open Claude Code's cli.js",e.EXIT="Exit",e}({});const ee={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,planModeToolset:null},pt=()=>{const e=re.join(ye.homedir(),".tweakcc"),t=process.env.XDG_CONFIG_HOME;try{if(Ie.existsSync(e))return e}catch{}return t?re.join(t,"tweakcc"):e},ce=pt(),ae=re.join(ce,"config.json"),Ne=re.join(ce,"cli.js.backup"),ge=re.join(ce,"native-binary.backup"),Se=re.join(ce,"system-prompts"),wn=re.join(ce,"prompt-data-cache"),bt=()=>{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=gt(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.env.MISE_DATA_DIR&&o(`${process.env.MISE_DATA_DIR}/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0),o(`${t}/.local/share/mise/installs/npm-anthropic-ai-claude-code/*/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},tn=bt(),xn=tn.flatMap(e=>e.expandedPaths),wt=({children:e,...t})=>g(c,{bold:!0,backgroundColor:"#ffd500",color:"#000",...t,children:[" ",e," "]});var pe=wt;const xt=[{name:Z.THEMES,desc:"Modify Claude Code's built-in themes or create your own"},{name:Z.THINKING_VERBS,desc:"Customize the list of verbs that Claude Code uses when it's working"},{name:Z.THINKING_STYLE,desc:"Choose custom spinners"},{name:Z.USER_MESSAGE_DISPLAY,desc:"Customize how user messages are displayed"},{name:Z.MISC,desc:"Miscellaneous settings (input box border, etc.)"},{name:Z.TOOLSETS,desc:"Manage toolsets to control which tools are available"},{name:Z.VIEW_SYSTEM_PROMPTS,desc:"Opens the system prompts directory where you can customize Claude Code's system prompts"}],yn=[{name:Z.RESTORE_ORIGINAL,desc:"Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)"},{name:Z.OPEN_CONFIG,desc:`Opens your tweakcc config file (${ae})`},{name:Z.OPEN_CLI,desc:"Opens Claude Code's cli.js file"},{name:Z.EXIT,desc:"Bye!"}];function yt({onSubmit:e,notification:t,isNativeInstallation:n}){const o=n?yn.filter(l=>l.name!==Z.OPEN_CLI):yn,r=[...be(ue).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:"Required: Updates Claude Code in-place with your changes",selectedStyles:{color:"green"}}],...xt,...o],[i,a]=P(0);return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(pe,{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(ht,{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(mt,{items:r,selectedIndex:i,onSelect:a,onSubmit:l=>e(l)})]})}async function sn(e){const t=re.join(wn,`prompts-${e}.json`);try{const o=await oe.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 oe.mkdir(wn,{recursive:!0}),await oe.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 St="modulepreload",vt=function(e){return"/"+e},Sn={},$t=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(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};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=vt(h,o),h in Sn)return;Sn[h]=!0;const f=h.endsWith(".css"),y=f?'[rel="stylesheet"]':"";if(!!o)for(let w=a.length-1;w>=0;w--){const S=a[w];if(S.href===h&&(!f||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${y}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":St,f||(p.as="script"),p.crossOrigin="",p.href=h,u&&p.setAttribute("nonce",u),document.head.appendChild(p),f)return new Promise((w,S)=>{p.addEventListener("load",w),p.addEventListener("error",()=>S(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)})},Pn=re.join(ce,"systemPromptOriginalHashes.json"),Ln=re.join(ce,"systemPromptAppliedHashes.json"),Dn=(e,t)=>`${e}-${t}`,We=e=>An.createHash("md5").update(e.trim(),"utf8").digest("hex"),Rn=async()=>{try{const e=await oe.readFile(Pn,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},_t=async e=>{await oe.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const o of n)t[o]=e[o];await oe.writeFile(Pn,JSON.stringify(t,null,2),"utf8")},Ct=async e=>{const t=await Rn();let n=0;for(const o of e.prompts){const r=Dn(o.id,o.version);if(!t[r]){const i=Ve(o.pieces,o.identifiers,o.identifierMap),a=We(i);t[r]=a,n++}}return await _t(t),n},It=async(e,t)=>{const n=await Rn(),o=Dn(e,t);return n[o]},ln=async()=>{try{const e=await oe.readFile(Ln,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},Fn=async e=>{await oe.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const o of n)t[o]=e[o];await oe.writeFile(Ln,JSON.stringify(t,null,2),"utf8")},Et=async(e,t)=>{const n=await ln();n[e]=t,await Fn(n)},kt=async()=>{const e=await ln(),t={};for(const n of Object.keys(e))t[n]=null;await Fn(t)},Tt=async e=>{try{const t=await ln();if(Object.keys(t).length===0)return!1;const o=(await oe.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=re.join(e,r),u=await oe.readFile(l,"utf8"),h=(await $t(()=>import("gray-matter"),[])).default(u,{delimiters:["<!--","-->"]});if(We(h.content)!==a)return!0}return!1}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}},Vn=e=>{const t=Ge(e,{delimiters:["<!--","-->"]}),{name:n,description:o,ccVersion:r,variables:i}=t.data;let a=0;const l=e.indexOf(t.content);return l>=0&&(a=e.slice(0,l).split(`
3
- `).length-1),{name:n||"",description:o||"",ccVersion:r||"",variables:i||[],content:t.content.trim(),contentLineOffset:a}},vn=(e,t)=>{const n=t||Ve(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),Ge.stringify(n,r,{delimiters:["<!--","-->"]})},Ve=(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},Mt=(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},Be=e=>re.join(Se,`${e}.md`),Nt=async e=>{try{return await oe.access(Be(e)),!0}catch{return!1}},Ot=async e=>{const t=Be(e),n=await oe.readFile(t,"utf-8");return Vn(n)},on=async(e,t)=>{const n=Be(e);await oe.writeFile(n,t,"utf-8")},Bt=async(e,t)=>{const n=Be(e),o=await oe.readFile(n,"utf-8"),r=Ge(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=Ge.stringify(r.content,a,{delimiters:["<!--","-->"]});await on(e,l)},At=(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 S=1;S<=a;S++)o[w-1]===r[S-1]?l[w][S]=l[w-1][S-1]+1:l[w][S]=Math.max(l[w-1][S],l[w][S-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 y=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 S=y(o[w]);b+=u[w]?`<mark>${S}</mark>`:S}let p="";for(let w=0;w<r.length;w++){const S=y(r[w]);p+=d[w]?`<mark>${S}</mark>`:S}return{oldHtml:b,newHtml:p}},$n=(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 y=At(h.line,f.line);i.push({type:"modified",line:h.line,oldLineNo:h.oldLineNo,newLineNo:f.newLineNo,oldHtml:y.oldHtml,newHtml:y.newHtml}),d++}else i.push(h)}return i},Pt=async(e,t,n,o,r,i,a,l)=>{const u=n.split(`
4
- `),d=o.split(`
5
- `),h=r.split(`
6
- `),f=x=>x.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),y=$n(u,d),b=$n(u,h);let p="";for(const x of y){const k=f(x.line);if(x.type==="modified"){const D=x.oldLineNo?String(x.oldLineNo).padStart(4," "):" ",O=x.newLineNo?String(x.newLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${D}</span><span class="prefix">- </span>${x.oldHtml}</div>
7
- `,p+=`<div class="line added"><span class="line-num">${O}</span><span class="prefix">+ </span>${x.newHtml}</div>
8
- `}else if(x.type==="removed"){const D=x.oldLineNo?String(x.oldLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${D}</span><span class="prefix">- </span>${k}</div>
9
- `}else if(x.type==="added"){const D=x.newLineNo?String(x.newLineNo).padStart(4," "):" ";p+=`<div class="line added"><span class="line-num">${D}</span><span class="prefix">+ </span>${k}</div>
10
- `}else{const D=x.oldLineNo?String(x.oldLineNo).padStart(4," "):" ",O=x.newLineNo?String(x.newLineNo).padStart(4," "):" ";p+=`<div class="line unchanged"><span class="line-num">${D} ${O}</span><span class="prefix"> </span>${k}</div>
11
- `}}let w="";for(const x of b){const k=f(x.line);if(x.type==="modified"){const D=x.oldLineNo?String(x.oldLineNo).padStart(4," "):" ",O=x.newLineNo?String(x.newLineNo).padStart(4," "):" ";w+=`<div class="line removed"><span class="line-num">${D}</span><span class="prefix">- </span>${x.oldHtml}</div>
12
- `,w+=`<div class="line added"><span class="line-num">${O}</span><span class="prefix">+ </span>${x.newHtml}</div>
13
- `}else if(x.type==="removed"){const D=x.oldLineNo?String(x.oldLineNo).padStart(4," "):" ";w+=`<div class="line removed"><span class="line-num">${D}</span><span class="prefix">- </span>${k}</div>
14
- `}else if(x.type==="added"){const D=x.newLineNo?String(x.newLineNo).padStart(4," "):" ";w+=`<div class="line added"><span class="line-num">${D}</span><span class="prefix">+ </span>${k}</div>
15
- `}else{const D=x.oldLineNo?String(x.oldLineNo).padStart(4," "):" ",O=x.newLineNo?String(x.newLineNo).padStart(4," "):" ";w+=`<div class="line unchanged"><span class="line-num">${D} ${O}</span><span class="prefix"> </span>${k}</div>
16
- `}}const S=`<!DOCTYPE html>
2
+ import{Box as m,Text as a,render as Dt,useInput as de}from"ink";import{Command as vn}from"commander";import F from"chalk";import st,{Fragment as Be,createContext as Cn,useCallback as Lt,useContext as pe,useEffect as xe,useMemo as Tt,useRef as $n,useState as B}from"react";import*as Re from"node:os";import Ce,{EOL as Mt}from"node:os";import wt from"ink-link";import*as oe from"node:fs/promises";import re from"node:fs/promises";import*as Le from"node:fs";import gt from"node:fs";import*as ae from"node:path";import le from"node:path";import*as Oe from"node:child_process";import*as Rt from"node:crypto";import Ke from"gray-matter";import{Fragment as $e,jsx as s,jsxs as h}from"react/jsx-runtime";import _n from"node:process";import In from"which";import{WASMagic as Tn}from"wasmagic";import{globbySync as Vt}from"globby";const Mn="modulepreload",En=function(e){return"/"+e},Et={},ft=function(n,t,r){let i=Promise.resolve();if(t&&t.length>0){let d=function(g){return Promise.all(g.map(f=>Promise.resolve(f).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};const l=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");i=d(t.map(g=>{if(g=En(g,r),g in Et)return;Et[g]=!0;const f=g.endsWith(".css"),x=f?'[rel="stylesheet"]':"";if(!!r)for(let b=l.length-1;b>=0;b--){const I=l[b];if(I.href===g&&(!f||I.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${g}"]${x}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":Mn,f||(p.as="script"),p.crossOrigin="",p.href=g,u&&p.setAttribute("nonce",u),document.head.appendChild(p),f)return new Promise((b,I)=>{p.addEventListener("load",b),p.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${g}`)))})}))}function o(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return i.then(l=>{for(const c of l||[])c.status==="rejected"&&o(c.reason);return n().catch(o)})};let Je=null;async function Ft(){if(Je!==null)return Je;try{return await ft(()=>import("node-lief"),[]),Je=await ft(()=>import("./nativeInstallation-D3Dxr9ST.js"),[]),Je}catch{return null}}async function jt(e){const n=await Ft();return n?n.extractClaudeJsFromNativeInstallation(e):null}async function kn(e,n,t){const r=await Ft();if(!r)throw new Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,n,t)}const Nn=e=>{const n=[],t=/visibleOptionCount:[\w$]+=(\d+)/g;let r;for(;(r=t.exec(e))!==null;){const i=r.index+r[0].indexOf("=")+1;n.push({startIndex:i,endIndex:i+r[1].length})}return n},Bn=(e,n)=>{const t=Nn(e);if(t.length===0)return console.error("patch: writeShowMoreItemsInSelectMenus: failed to find locations"),null;const r=t.sort((o,l)=>l.startIndex-o.startIndex);let i=e;for(const o of r){const l=n.toString(),c=i.slice(0,o.startIndex)+l+i.slice(o.endIndex);Y(i,c,l,o.startIndex,o.endIndex),i=c}return i};function Pn(e){const n=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,t=e.match(n);if(!t||t.index==null)return console.error("patch: themes: failed to find switchMatch"),null;const r=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,i=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,o=e.match(r),l=e.match(i);return!o||o.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:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:o.index,endIndex:o.index+o[0].length},obj:{startIndex:l.index,endIndex:l.index+l[0].length}}}const An=(e,n)=>{const t=Pn(e);if(!t)return null;if(n.length===0)return e;let r=e;const i="return"+JSON.stringify(Object.fromEntries(n.map(c=>[c.id,c.name])));r=r.slice(0,t.obj.startIndex)+i+r.slice(t.obj.endIndex),Y(e,r,i,t.obj.startIndex,t.obj.endIndex),e=r;const o=JSON.stringify(n.map(c=>({label:c.name,value:c.id})));r=r.slice(0,t.objArr.startIndex)+o+r.slice(t.objArr.endIndex),Y(e,r,o,t.objArr.startIndex,t.objArr.endIndex),e=r;let l=`switch(${t.switchStatement.identifiers?.[0]}){
3
+ `;return n.forEach(c=>{l+=`case"${c.id}":return${JSON.stringify(c.colors)};
4
+ `}),l+=`default:return${JSON.stringify(n[0].colors)};
5
+ }`,r=r.slice(0,t.switchStatement.startIndex)+l+r.slice(t.switchStatement.endIndex),Y(e,r,l,t.switchStatement.startIndex,t.switchStatement.endIndex),r},On=e=>{const n=/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/,t=e.match(n);return!t||t.index===void 0?(console.error("patch: context limit: failed to find match"),null):t.index+t[0].indexOf("{")+1},Dn=e=>{const n=On(e);if(!n)return null;const t="if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);",r=e.slice(0,n)+t+e.slice(n);return Y(e,r,t,n,n),r},Ln=e=>{const n=e.indexOf('bash:"bashBorder"');if(n===-1)return console.error("patch: input border: failed to find bash pattern"),null;const t=e.slice(n,n+500),r=/borderStyle:"[^"]*"/,i=t.match(r);return!i||i.index===void 0?(console.error("patch: input border: failed to find border style pattern"),null):{startIndex:n+i.index,endIndex:n+i.index+i[0].length}},Rn=(e,n)=>{const t=Ln(e);if(!t)return null;if(n){const r="borderColor:undefined",i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return Y(e,i,r,t.startIndex,t.endIndex),i}else return e},Vn=e=>{const n=/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: spinner no-freeze: failed to find wholeMatch"),null;const r=/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/,i=t[0].match(r);if(!i||i.index===void 0)return console.error("patch: spinner no-freeze: failed to find freeze condition"),null;const o=t.index+i.index,l=o+i[0].length;return{startIndex:o,endIndex:l}},Fn=e=>{const n=Vn(e);if(!n)return null;const t=e.slice(0,n.startIndex)+e.slice(n.endIndex);return Y(e,t,"",n.startIndex,n.endIndex),t},jn=e=>{const n=/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/,t=e.match(n);if(!t||t.index==null)return console.error("patch: thinker format: failed to find approxAreaMatch"),null;const r=e.slice(t.index,t.index+600),i=/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/,o=r.match(i);return!o||o.index==null?(console.error("patch: thinker format: failed to find formatMatch"),null):{startIndex:t.index+o.index+o[1].length,endIndex:t.index+o.index+o[1].length+o[2].length,identifiers:[o[3]]}},Un=(e,n)=>{const t=jn(e);if(!t)return null;const r=t,i=n.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),o=r.identifiers?.[0],c=`=${"`"+i.replace(/\{\}/g,"${"+o+"}")+"`"}`,u=e.slice(0,r.startIndex)+c+e.slice(r.endIndex);return Y(e,u,c,r.startIndex,r.endIndex),u},Hn=e=>{const n=/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/,t=e.match(n);return!t||t.index==null?(console.error("patch: thinker symbol mirror option: failed to find match"),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},Gn=(e,n)=>{const t=Hn(e);if(!t)return null;const r=t.identifiers?.[0],i=n?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,o=e.slice(0,t.startIndex)+i+e.slice(t.endIndex);return Y(e,o,i,t.startIndex,t.endIndex),o},Yn=e=>{const n=[],t=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g;let r;for(;(r=t.exec(e))!==null;)n.push({startIndex:r.index,endIndex:r.index+r[0].length});return n},Wn=(e,n)=>{const t=Yn(e);if(t.length===0)return null;const r=JSON.stringify(n),i=t.sort((l,c)=>c.startIndex-l.startIndex);let o=e;for(let l=0;l<i.length;l++){const c=o.slice(0,i[l].startIndex)+r+o.slice(i[l].endIndex);Y(o,c,r,i[l].startIndex,i[l].endIndex),o=c}return o},zn=e=>{const n=/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,t=e.match(n);if(!t||t.index==null)return console.error("patch: thinker symbol speed: failed to find match"),null;const r=t[0],i=t[1],o=r.lastIndexOf(i),l=t.index+o,c=l+i.length;return{startIndex:l,endIndex:c}},Jn=(e,n)=>{const t=zn(e);if(!t)return null;const r=JSON.stringify(n),i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return Y(e,i,r,t.startIndex,t.endIndex),i},Xn=e=>{const n=/\{flexWrap:"wrap",height:1,width:2\}/,t=e.match(n);return!t||t.index==null?(console.error("patch: thinker symbol width: failed to find match"),null):{startIndex:t.index,endIndex:t.index+t[0].length}},qn=(e,n)=>{const t=Xn(e);if(!t)return null;const r=`{flexWrap:"wrap",height:1,width:${n}}`,i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return Y(e,i,r,t.startIndex,t.endIndex),i},Kn=e=>{const n=/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s,t=e.match(n);return!t||t.index==null?(console.error("patch: thinker verbs: failed to find verbsMatch"),null):{startIndex:t.index+1,endIndex:t.index+t[0].length,identifiers:[t[1]]}},Qn=e=>{const n=/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/,t=e.match(n);return!t||t.index==null?(console.error("patch: thinker verbs: failed to find match"),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},Zn=(e,n)=>{const t=Kn(e);if(!t)return null;const r=t,i=r.identifiers?.[0],o=`${i}=${JSON.stringify({words:n})}`,l=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);Y(e,l,o,r.startIndex,r.endIndex);const c=Qn(l);if(!c)return null;const u=c,g=`function ${u.identifiers?.[0]}(){return ${i}.words}`,f=l.slice(0,u.startIndex)+g+l.slice(u.endIndex);return Y(l,f,g,u.startIndex,u.endIndex),f},er=e=>{const n=/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground",color:"text"\},"> ",([$\w]+)\+" "\);/,t=e.match(n);return!t||t.index==null?(console.error("patch: messageDisplayMatch: failed to find error message"),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[3]]}},tr=(e,n,t,r,i=!1,o=!1,l=!1,c=!1,u=!1,d="none",g="rgb(255,255,255)",f=0,x=0,w=!1)=>{const p=er(e);if(!p)return console.error("^ patch: userMessageDisplay: getUserMessageDisplayLocation returned null"),null;const b=yt(e);if(!b)return console.error("^ patch: userMessageDisplay: failed to find chalk variable"),null;const I=Ct(e);if(!I)return console.error("^ patch: userMessageDisplay: failed to find box component"),null;let T="";const S=[];t==="default"&&S.push('color:"text"'),r==="default"&&S.push('backgroundColor:"userMessageBackground"');const E=S.length>0?`{${S.join(",")}}`:"{}",V=[],O=d.startsWith("topBottom");if(d!=="none"){if(O){let G="";d==="topBottomSingle"?G='{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}':d==="topBottomDouble"?G='{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}':d==="topBottomBold"&&(G='{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}'),V.push(`borderStyle:${G}`)}else V.push(`borderStyle:"${d}"`);const X=g.match(/\d+/g);X&&V.push(`borderColor:"rgb(${X.join(",")})"`)}f>0&&V.push(`paddingX:${f}`),x>0&&V.push(`paddingY:${x}`),w&&V.push('alignSelf:"flex-start"');const R=V.length>0?`{${V.join(",")}}`:"{}",D=t!=="default"||r!=="default"&&r!==null||i||o||l||c||u;if(D){if(T=b,t!=="default"){const X=t.match(/\d+/g);X&&(T+=`.rgb(${X.join(",")})`)}if(r!=="default"&&r!==null){const X=r.match(/\d+/g);X&&(T+=`.bgRgb(${X.join(",")})`)}i&&(T+=".bold"),o&&(T+=".italic"),l&&(T+=".underline"),c&&(T+=".strikethrough"),u&&(T+=".inverse")}const[J,k,N]=p.identifiers,$='"'+n.replace(/\{\}/g,`"+${N}+"`)+'"',z=`
6
+ return ${J}.createElement(
7
+ ${I},
8
+ ${R},
9
+ ${J}.createElement(
10
+ ${k},
11
+ ${E},
12
+ ${D?T+"(":""}${$}${D?")":""}
13
+ )
14
+ );`,W=e.slice(0,p.startIndex)+z+e.slice(p.endIndex);return Y(e,W,z,p.startIndex,p.endIndex),W},nr=e=>{const n=/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: verbose: failed to find createElement with spinnerTip and overrideMessage"),null;const r=t[0],i=/verbose:[^,}]+/,o=r.match(i);if(!o||o.index===void 0)return console.error("patch: verbose: failed to find verbose property"),null;const l=t.index+o.index,c=l+o[0].length;return{startIndex:l,endIndex:c}},rr=e=>{const n=nr(e);if(!n)return null;const t="verbose:true",r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return Y(e,r,t,n.startIndex,n.endIndex),r},or=e=>{const n=/function ([$\w]+)\(\{\s*streamMode:\s*([$\w]+)\s*\}\)\s*\{/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: thinkingVisibility: failed to find banner function pattern"),null;const[r]=t,i=t.index,o=i+r.length;return{startIndex:i,endIndex:o,identifiers:[t[1],t[2]]}},ir=e=>{const n=/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: thinkingVisibility: failed to find thinking visibility pattern"),null;const r=t.index,i=r+t[0].length;return{startIndex:r,endIndex:i,identifiers:[t[1],t[2],t[3]]}},sr=e=>{const n=or(e);if(!n)return null;const t="return null;";let r=e.slice(0,n.endIndex)+t+e.slice(n.endIndex);Y(e,r,t,n.endIndex,n.endIndex);const i=ir(r);if(!i)return null;const o=`${i.identifiers[0]}${i.identifiers[1]}true${i.identifiers[2]}`;return r=r.slice(0,i.startIndex)+o+r.slice(i.endIndex),Y(e,r,o,i.startIndex,i.endIndex),r},lr=e=>{const t=e.indexOf("}.VERSION} (Claude Code)");return t==-1?(console.error("patch: patchesAppliedIndication: failed to find versionIndex"),null):{startIndex:0,endIndex:t+24}},ar=e=>{const n=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern"),null;const r=t.index+t[0].length;return{startIndex:r,endIndex:r}},cr=(e,n,t,r,i,o)=>{const l=/alignItems:"center",minHeight:9,?/,c=e.match(l);if(!c||c.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4"),null;let u=e.slice(0,c.index)+"minHeight:9,"+e.slice(c.index+c[0].length);const d=Math.max(0,c.index-200),g=u.slice(d,c.index+12+2),f=/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g,x=Array.from(g.matchAll(f));if(x.length===0)return console.error("patch: patchesAppliedIndication: failed to find createElement for PATCH 4"),null;const w=x[x.length-1],p=d+w.index+w[0].length,b=`${t}.createElement(${i}, null, ${o}.blue.bold(" + tweakcc v${n}")),${t}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,I=u;u=u.slice(0,p)+b+u.slice(p),Y(I,u,b,p,p);let T=1,S=p+b.length,E=-1;for(;S<u.length;){const O=u[S];if(O==="(")T++;else if(O===")"){if(T===1){E=S;break}T--}S++}if(E===-1)return console.error("patch: patchesAppliedIndication: failed to find closing paren for PATCH 4"),null;const V=u;return u=u.slice(0,E)+"),"+u.slice(E),Y(V,u,"),",E,E),{content:u,closingParenIndex:E+2}},dr=(e,n,t,r,i,o,l)=>{let c=4,u=n,d=-1;for(;u<e.length;){const p=e[u];if(p==="(")c++;else if(p===")"){if(c===1){d=u;break}c--}u++}if(d===-1)return console.error("patch: patchesAppliedIndication: failed to find insertion point for PATCH 5"),null;const g=[];g.push(`,${t}.createElement(${r}, { flexDirection: "column" },`),g.push(`${t}.createElement(${r}, null, ${t}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${t}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let p of l)p=p.replace("CHALK_VAR",o),g.push(`${t}.createElement(${r}, null, ${t}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${t}.createElement(${i}, {dimColor: true}, \` * ${p}\`)),`);g.push("),");const f=g.join(""),x=e,w=e.slice(0,d)+f+e.slice(d);return Y(x,w,f,d,d),w},ur=e=>{const n=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3"),null;const r=Math.max(0,t.index-1500),i=e.slice(r,t.index),o=/\}function ([$\w]+)\(/g,l=Array.from(i.matchAll(o));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\\(${ue(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}},hr=(e,n,t,r=!0,i=!0)=>{const o=lr(e);if(!o)return console.error("patch: patchesAppliedIndication: failed to version output location"),null;const l=`\\n${n} (tweakcc)`;let c=e.slice(0,o.endIndex)+l+e.slice(o.endIndex);Y(e,c,l,o.endIndex,o.endIndex);const u=yt(e);if(!u)return console.error("patch: patchesAppliedIndication: failed to find chalk variable"),null;const d=nn(e);if(!d)return console.error("patch: patchesAppliedIndication: failed to find text component"),null;const g=tt(e);if(!g)return console.error("patch: patchesAppliedIndication: failed to find React variable"),null;const f=Ct(e);if(!f)return console.error("patch: patchesAppliedIndication: failed to find Box component"),null;if(r){const w=ar(c);if(!w)return console.error("patch: patchesAppliedIndication: patch 2 failed"),null;const p=`, " ",${g}.createElement(${d}, null, ${u}.blue.bold('+ tweakcc v${n}'))`,b=c;c=c.slice(0,w.startIndex)+p+c.slice(w.endIndex),Y(b,c,p,w.startIndex,w.endIndex)}if(i){const w=ur(c);if(!w)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 T of t)T=T.replace("CHALK_VAR",u),p.push(`${g}.createElement(${f}, null, ${g}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${g}.createElement(${d}, {dimColor: true}, \` * ${T}\`)),`);p.push("),");const b=p.join(`
15
+ `),I=c;c=c.slice(0,w.startIndex)+b+c.slice(w.endIndex),Y(I,c,b,w.startIndex,w.endIndex)}let x=-1;if(r){const w=cr(c,n,g,f,d,u);if(!w)return console.error("patch: patchesAppliedIndication: patch 4 failed"),null;c=w.content,x=w.closingParenIndex}if(i){if(x===-1){const p=/alignItems:"center",minHeight:9,?/,b=c.match(p);if(!b||b.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find reference point for PATCH 5"),null;x=b.index+b[0].length}const w=dr(c,x,g,f,d,u,t);if(!w)return console.error("patch: patchesAppliedIndication: patch 5 failed"),null;c=w}return c};async function xt(e){const n=ae.join(Ot,`prompts-${e}.json`);try{const r=await oe.readFile(n,"utf-8");return JSON.parse(r)}catch{}const t=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{const r=await fetch(t);if(!r.ok){let o;throw r.status===429?o="Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.":r.status===404?o=`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?o=`GitHub server error (${r.status}). Please try again later.`:o=`HTTP ${r.status}: ${r.statusText}`,new Error(o)}const i=await r.json();try{await oe.mkdir(Ot,{recursive:!0}),await oe.writeFile(n,JSON.stringify(i,null,2),"utf-8")}catch(o){console.warn(`Failed to write to cache to ${n}: ${o}`)}return i}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 i=`Failed to download prompts for version ${e}: ${r.message}`;throw new Error(i)}throw r}}const Ut=()=>ae.join(se,"systemPromptOriginalHashes.json"),Ht=()=>ae.join(se,"systemPromptAppliedHashes.json"),Gt=(e,n)=>`${e}-${n}`,Ze=e=>Rt.createHash("md5").update(e.trim(),"utf8").digest("hex"),Yt=async()=>{try{const e=await oe.readFile(Ut(),"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},mr=async e=>{await oe.mkdir(se,{recursive:!0});const n={},t=Object.keys(e).sort();for(const r of t)n[r]=e[r];await oe.writeFile(Ut(),JSON.stringify(n,null,2),"utf8")},gr=async e=>{const n=await Yt();let t=0;for(const r of e.prompts){const i=Gt(r.id,r.version);if(!n[i]){const o=Ue(r.pieces,r.identifiers,r.identifierMap),l=Ze(o);n[i]=l,t++}}return await mr(n),t},fr=async(e,n)=>{const t=await Yt(),r=Gt(e,n);return t[r]},St=async()=>{try{const e=await oe.readFile(Ht(),"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},Wt=async e=>{await oe.mkdir(se,{recursive:!0});const n={},t=Object.keys(e).sort();for(const r of t)n[r]=e[r];await oe.writeFile(Ht(),JSON.stringify(n,null,2),"utf8")},pr=async(e,n)=>{const t=await St();t[e]=n,await Wt(t)},br=async()=>{const e=await St(),n={};for(const t of Object.keys(e))n[t]=null;await Wt(n)},wr=async e=>{try{const n=await St();if(Object.keys(n).length===0)return!1;const r=(await oe.readdir(e)).filter(i=>i.endsWith(".md"));for(const i of r){const o=i.replace(".md",""),l=n[o];if(l===void 0||l===null)continue;const c=ae.join(e,i),u=await oe.readFile(c,"utf8"),g=(await ft(()=>import("gray-matter"),[])).default(u,{delimiters:["<!--","-->"]});if(Ze(g.content)!==l)return!0}return!1}catch(n){if(n instanceof Error&&"code"in n&&n.code==="ENOENT")return!1;throw n}},zt=e=>{const n=Ke(e,{delimiters:["<!--","-->"]}),{name:t,description:r,ccVersion:i,variables:o}=n.data;let l=0;const c=e.indexOf(n.content);return c>=0&&(l=e.slice(0,c).split(`
16
+ `).length-1),{name:t||"",description:r||"",ccVersion:i||"",variables:o||[],content:n.content.trim(),contentLineOffset:l}},kt=(e,n)=>{const t=n||Ue(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,i={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(i.variables=r),Ke.stringify(t,i,{delimiters:["<!--","-->"]})},Ue=(e,n,t)=>{let r="";for(let i=0;i<e.length;i++)if(r+=e[i],i<n.length){const o=n[i],l=t[String(o)]||`UNKNOWN_${o}`;r+=l}return r},Jt=(e,n)=>{const t=e.split(".").map(Number),r=n.split(".").map(Number);for(let i=0;i<Math.max(t.length,r.length);i++){const o=t[i]||0,l=r[i]||0;if(o<l)return-1;if(o>l)return 1}return 0},Ve=e=>ae.join(Se,`${e}.md`),xr=async e=>{try{return await oe.access(Ve(e)),!0}catch{return!1}},Sr=async e=>{const n=Ve(e),t=await oe.readFile(n,"utf-8");return zt(t)},pt=async(e,n)=>{const t=Ve(e);await oe.writeFile(t,n,"utf-8")},yr=async(e,n)=>{const t=Ve(e),r=await oe.readFile(t,"utf-8"),i=Ke(r,{delimiters:["<!--","-->"]}),o=Object.keys(n).length>0?[...new Set(Object.values(n))]:void 0,l={name:i.data.name,description:i.data.description,ccVersion:i.data.ccVersion};o&&o.length>0&&(l.variables=o);const c=Ke.stringify(i.content,l,{delimiters:["<!--","-->"]});await pt(e,c)},vr=(e,n)=>{const t=b=>b.split(/(\s+)/),r=t(e),i=t(n),o=r.length,l=i.length,c=Array(o+1).fill(0).map(()=>Array(l+1).fill(0));for(let b=1;b<=o;b++)for(let I=1;I<=l;I++)r[b-1]===i[I-1]?c[b][I]=c[b-1][I-1]+1:c[b][I]=Math.max(c[b-1][I],c[b][I-1]);const u=Array(o).fill(!1),d=Array(l).fill(!1);let g=o,f=l;for(;g>0||f>0;)g>0&&f>0&&r[g-1]===i[f-1]?(g--,f--):f>0&&(g===0||c[g][f-1]>=c[g-1][f])?(d[f-1]=!0,f--):g>0&&(u[g-1]=!0,g--);const x=b=>b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");let w="";for(let b=0;b<r.length;b++){const I=x(r[b]);w+=u[b]?`<mark>${I}</mark>`:I}let p="";for(let b=0;b<i.length;b++){const I=x(i[b]);p+=d[b]?`<mark>${I}</mark>`:I}return{oldHtml:w,newHtml:p}},Nt=(e,n)=>{const t=e.length,r=n.length,i=Array(t+1).fill(0).map(()=>Array(r+1).fill(0));for(let d=1;d<=t;d++)for(let g=1;g<=r;g++)e[d-1]===n[g-1]?i[d][g]=i[d-1][g-1]+1:i[d][g]=Math.max(i[d-1][g],i[d][g-1]);const o=[];let l=t,c=r;const u=[];for(;l>0||c>0;)l>0&&c>0&&e[l-1]===n[c-1]?(u.unshift({type:"unchanged",line:e[l-1],oldLineNo:l,newLineNo:c}),l--,c--):c>0&&(l===0||i[l][c-1]>=i[l-1][c])?(u.unshift({type:"added",line:n[c-1],newLineNo:c}),c--):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 x=vr(g.line,f.line);o.push({type:"modified",line:g.line,oldLineNo:g.oldLineNo,newLineNo:f.newLineNo,oldHtml:x.oldHtml,newHtml:x.newHtml}),d++}else o.push(g)}return o},Cr=async(e,n,t,r,i,o,l,c)=>{const u=t.split(`
17
+ `),d=r.split(`
18
+ `),g=i.split(`
19
+ `),f=S=>S.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),x=Nt(u,d),w=Nt(u,g);let p="";for(const S of x){const E=f(S.line);if(S.type==="modified"){const V=S.oldLineNo?String(S.oldLineNo).padStart(4," "):" ",O=S.newLineNo?String(S.newLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${V}</span><span class="prefix">- </span>${S.oldHtml}</div>
20
+ `,p+=`<div class="line added"><span class="line-num">${O}</span><span class="prefix">+ </span>${S.newHtml}</div>
21
+ `}else if(S.type==="removed"){const V=S.oldLineNo?String(S.oldLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${V}</span><span class="prefix">- </span>${E}</div>
22
+ `}else if(S.type==="added"){const V=S.newLineNo?String(S.newLineNo).padStart(4," "):" ";p+=`<div class="line added"><span class="line-num">${V}</span><span class="prefix">+ </span>${E}</div>
23
+ `}else{const V=S.oldLineNo?String(S.oldLineNo).padStart(4," "):" ",O=S.newLineNo?String(S.newLineNo).padStart(4," "):" ";p+=`<div class="line unchanged"><span class="line-num">${V} ${O}</span><span class="prefix"> </span>${E}</div>
24
+ `}}let b="";for(const S of w){const E=f(S.line);if(S.type==="modified"){const V=S.oldLineNo?String(S.oldLineNo).padStart(4," "):" ",O=S.newLineNo?String(S.newLineNo).padStart(4," "):" ";b+=`<div class="line removed"><span class="line-num">${V}</span><span class="prefix">- </span>${S.oldHtml}</div>
25
+ `,b+=`<div class="line added"><span class="line-num">${O}</span><span class="prefix">+ </span>${S.newHtml}</div>
26
+ `}else if(S.type==="removed"){const V=S.oldLineNo?String(S.oldLineNo).padStart(4," "):" ";b+=`<div class="line removed"><span class="line-num">${V}</span><span class="prefix">- </span>${E}</div>
27
+ `}else if(S.type==="added"){const V=S.newLineNo?String(S.newLineNo).padStart(4," "):" ";b+=`<div class="line added"><span class="line-num">${V}</span><span class="prefix">+ </span>${E}</div>
28
+ `}else{const V=S.oldLineNo?String(S.oldLineNo).padStart(4," "):" ",O=S.newLineNo?String(S.newLineNo).padStart(4," "):" ";b+=`<div class="line unchanged"><span class="line-num">${V} ${O}</span><span class="prefix"> </span>${E}</div>
29
+ `}}const I=`<!DOCTYPE html>
17
30
  <html>
18
31
  <head>
19
32
  <meta charset="UTF-8">
20
- <title>Diff: ${f(t)} (${f(e)})</title>
33
+ <title>Diff: ${f(n)} (${f(e)})</title>
21
34
  <style>
22
35
  body {
23
36
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
@@ -144,55 +157,47 @@ import{Box as m,Text as c,render as ct,useInput as de}from"ink";import{Command a
144
157
  </head>
145
158
  <body>
146
159
  <div class="header">
147
- <h1>${f(t)}</h1>
160
+ <h1>${f(n)}</h1>
148
161
  <div class="version-info">
149
- <strong>Old Version:</strong> ${f(i)} →
150
- <strong>New Version:</strong> ${f(a)}
162
+ <strong>Old Version:</strong> ${f(o)} →
163
+ <strong>New Version:</strong> ${f(l)}
151
164
  </div>
152
165
  </div>
153
166
 
154
167
  <div class="warning">
155
168
  <strong>⚠️ Version Mismatch Warning</strong><br>
156
- Your customized prompt file is based on version ${f(i)},
157
- but Claude Code is now using version ${f(a)}.
169
+ Your customized prompt file is based on version ${f(o)},
170
+ but Claude Code is now using version ${f(l)}.
158
171
  Review the differences below to understand both your customizations and the upstream changes.<br><br>
159
- <strong>File:</strong> <code>${f(l)}</code><br><br>
160
- When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${f(a)}</strong>.
172
+ <strong>File:</strong> <code>${f(c)}</code><br><br>
173
+ When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${f(l)}</strong>.
161
174
  </div>
162
175
 
163
176
  <div class="diff-panels">
164
177
  <div class="diff-container">
165
- <div class="diff-header">Your Customizations (v${f(i)} → User)</div>
178
+ <div class="diff-header">Your Customizations (v${f(o)} → User)</div>
166
179
  <div class="diff-content">
167
180
  ${p} </div>
168
181
  </div>
169
182
 
170
183
  <div class="diff-container">
171
- <div class="diff-header">Upstream Changes (v${f(i)} → v${f(a)})</div>
184
+ <div class="diff-header">Upstream Changes (v${f(o)} → v${f(l)})</div>
172
185
  <div class="diff-content">
173
- ${w} </div>
186
+ ${b} </div>
174
187
  </div>
175
188
  </div>
176
189
  </body>
177
- </html>`,E=re.join(Se,`${e}.diff.html`);return await oe.writeFile(E,S,"utf-8"),E},Lt=async e=>{const t={id:e.id,name:e.name,description:e.description,action:"skipped",newVersion:e.version};if(!await Nt(e.id)){const r=vn(e);return await on(e.id,r),t.action="created",t}const o=await Ot(e.id);if(t.oldVersion=o.ccVersion,await Bt(e.id,e.identifierMap),o.ccVersion&&e.version){const r=Mt(o.ccVersion,e.version);if(r===0)return t.action="skipped",t;if(r!=0){const i=await It(e.id,o.ccVersion),a=We(o.content);if(!i||i!==a){t.action="conflict";let u=o.content;try{const b=(await sn(o.ccVersion)).prompts.find(p=>p.id===e.id);b&&(u=Ve(b.pieces,b.identifiers,b.identifierMap))}catch{console.log(H.yellow(`Warning: Could not fetch old version ${o.ccVersion} for comparison. Using current file as baseline.`))}const d=Ve(e.pieces,e.identifiers,e.identifierMap),h=Be(e.id),f=await Pt(e.id,e.name,u,o.content,d,o.ccVersion,e.version,h);t.diffHtmlPath=f}else{const u=vn(e);await on(e.id,u),t.action="updated"}}}return t},Dt=async e=>{const t={ccVersion:e,results:[]},n=await sn(e);await Ct(n),await oe.mkdir(Se,{recursive:!0});for(const o of n.prompts)try{const r=await Lt(o);t.results.push(r)}catch(r){throw console.log(H.red(`Failed to sync prompt ${o.id}:`)),r}return t};let ze=null,rn=null;const _n=async e=>{try{return ze=await sn(e),rn=e,{success:!0}}catch(t){return ze=null,rn=null,t instanceof Error?{success:!1,errorMessage:t.message}:{success:!1,errorMessage:"Unknown error occurred while downloading system prompts"}}},Rt=e=>e.replace(/[^\x00-\x7F]/g,t=>{const o=`\\\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${o})`}),Ft=e=>e.replace(/[^\x00-\x7F]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Vt=(e,t)=>{let n="";for(let o=0;o<e.length;o++){const i=e[o].replace(/<<CCVERSION>>/g,t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=Rt(i);n+=a,o<e.length-1&&(n+="([\\w$]+)")}return n},jt=e=>{const t=new Map;let n=0,o=1,r=1;for(let i=0;i<e.length;i++,r++){const a=e[i];if(a===`
178
- `){o++,r=0;continue}const l=e[i+1];if(a==="$"&&l==="{"){n++,i++,r++;continue}if(n){a==="{"?n++:a==="}"&&n--;continue}if(a==="`"&&e[i-1]!=="\\"){const u=t.get(o)??[];u.push(r),t.set(o,u)}}return t},Ut=(e,t,n,o)=>{const r=[],i=String(t),a=i.length,l=" ".repeat(a),u=o[0],d=o[o.length-1],h=30,f=30,y=u-1,b=n.length-d;let p=n,w=o,S="",E="",x=0;if(y>h||b>f){let I=0,z=n.length,W=0;if(y>h){const Q=y-h;I=Q,W=-Q;const q=`[${Q} chars] ...`;S=H.dim(q),x=q.length}if(b>f){const Q=b-f;z=n.length-Q,E=H.dim(`... [${Q} chars]`)}p=n.substring(I,z),w=o.map(Q=>Q+W)}r.push(`${H.red.bold("error")}${H.bold(": system prompt file contains unescaped backtick")}`),r.push(`${H.blue.bold(" ".repeat(a)+" -->")} ${e}:${t}:${u}`),r.push(`${l} ${H.blue.bold("|")}`);const k=S+p+E;r.push(`${H.blue.bold(i)} ${H.blue.bold("|")} ${k}`);const D=x+w[0]-1,O=" ".repeat(D)+"^ unescaped backtick";r.push(`${l} ${H.blue.bold("|")} ${H.red.bold(O)}`),r.push(`${l} ${H.blue.bold("|")}`),r.push(`${H.cyan.bold("help")}: add \`\\\` before the backtick to escape it`),r.push(`${l} ${H.blue.bold("|")}`);const N=[];let j=0;for(const I of w)N.push(p.substring(j,I-1)),N.push(H.green("\\")+"`"),j=I;N.push(p.substring(j));const L=S+N.join("")+E;r.push(`${H.blue.bold(i)} ${H.blue.bold("|")} ${L}`);let B="",T=0;for(let I=0;I<w.length;I++){const z=w[I],W=x+z-1+T;B=B.padEnd(W," ")+"+",T++}return r.push(`${l} ${H.blue.bold("|")} ${H.green(B)}`),r.join(`
179
- `)},Ht=(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]),y=n[f];y&&(a[y]=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=Ft(l)),l},Gt=async(e,t=!1)=>{if(!ze||rn!==e)return[];const n=ze,o=[];for(const r of n.prompts){const i=Vt(r.pieces,e),a=re.join(Se,`${r.id}.md`);let l;try{l=await oe.readFile(a,"utf8")}catch(h){console.error(`Failed to read markdown file ${a}:`,h);continue}const u=Vn(l),d=h=>{const f=h.slice(1);return Ht(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},zt=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(H.dim(`Skipped ${r.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(H.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(H.green(` ${Se}/${i.id}.md`)),console.log(H.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(H.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(H.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(H.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(o.length>0){console.log(H.bold.yellow(`WARNING: Conflicts detected for ${o.length} system prompt file(s)`));for(const i of o)console.log(H.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(H.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(H.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(H.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(H.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(H.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(H.yellow(` ${i.id}.md → `)+H.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},le=Buffer.from(`
180
- ---- Bun! ----
181
- `),Ce=32,Yt=8,Ye=4*Yt+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 jn(e){return e.endsWith("/claude")||e==="claude"||e.endsWith("/claude.exe")||e==="claude.exe"}function Un(e,t,n){const o=ve(e,t.modulesPtr),r=Math.floor(o.length/Ye);for(let i=0;i<r;i++){const a=i*Ye,l=Wt(o,a),u=ve(e,l.name).toString("utf-8"),d=n(l,u,i);if(d!==void 0)return d}}function Hn(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 Wt(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 Jt(e){if(e.length<Ce+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(M()&&(console.log(`parseBunDataBlob: Expected trailer: ${le.toString("hex")}`),console.log(`parseBunDataBlob: Got trailer: ${n.toString("hex")}`)),!n.equals(le))throw M()&&(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-Ce-le.length,r=e.subarray(o,o+Ce);return{bunOffsets:Hn(r),bunData:e}}function Gn(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:o,bunData:r}=Jt(n);return{bunOffsets:o,bunData:r}}function qt(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<le.length+8+Ce)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 o=t.length-8-le.length,r=t.subarray(o,t.length-8);if(M()&&(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-Ce,a=t.subarray(i,t.length-8-le.length),l=Hn(a);M()&&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+Ce,h=t.length-d-Number(u),f=t.subarray(h,t.length-d);M()&&console.log(`extractBunDataFromELFOverlay: Extracted ${f.length} bytes of data`);const y=Buffer.concat([f,a,r]);return{bunOffsets:l,bunData:y}}function Kt(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 Gn(n.content)}function Xt(e){const t=e.sections().find(n=>n.name===".bun");if(!t)throw new Error(".bun section not found");return Gn(t.content)}function zn(e){switch(M()&&console.log(`getBunData: Binary format detected as ${e.format}`),e.format){case"MachO":return Kt(e);case"PE":return Xt(e);case"ELF":return qt(e);default:throw new Error(`Unsupported binary format: ${e.format}`)}}function Yn(e){try{Fe.logging.disable();const t=Fe.parse(e),{bunOffsets:n,bunData:o}=zn(t);M()&&console.log(`extractClaudeJsFromNativeInstallation: Got bunData, size=${o.length} bytes`);const r=Un(o,n,(i,a,l)=>{if(M()&&console.log(`extractClaudeJsFromNativeInstallation: Module ${l}: ${a}`),!jn(a))return;const u=ve(o,i.contents);return M()&&console.log(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${u.length}`),u.length>0?u:void 0});return r||(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 o=[],r=[];Un(e,t,(k,D)=>{const O=ve(e,k.name);let N;n&&jn(D)?N=n:N=ve(e,k.contents);const j=ve(e,k.sourcemap),L=ve(e,k.bytecode);r.push({name:O,contents:N,sourcemap:j,bytecode:L,encoding:k.encoding,loader:k.loader,moduleFormat:k.moduleFormat,side:k.side}),o.push(O,N,j,L)});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*Ye;i+=u;const d=ve(e,t.compileExecArgvPtr),h=i,f=d.length;i+=f+1;const y=i;i+=Ce;const b=i;i+=le.length;const p=Buffer.allocUnsafe(i);p.fill(0);let w=0;for(const{offset:k,length:D}of a)D>0&&o[w].copy(p,k,0,D),p[k+D]=0,w++;f>0&&(d.copy(p,h,0,f),p[h+f]=0);for(let k=0;k<r.length;k++){const D=r[k],O=k*4,N={name:{offset:a[O].offset,length:a[O].length},contents:{offset:a[O+1].offset,length:a[O+1].length},sourcemap:{offset:a[O+2].offset,length:a[O+2].length},bytecode:{offset:a[O+3].offset,length:a[O+3].length},encoding:D.encoding,loader:D.loader,moduleFormat:D.moduleFormat,side:D.side};let L=l+k*Ye;p.writeUInt32LE(N.name.offset,L),p.writeUInt32LE(N.name.length,L+4),L+=8,p.writeUInt32LE(N.contents.offset,L),p.writeUInt32LE(N.contents.length,L+4),L+=8,p.writeUInt32LE(N.sourcemap.offset,L),p.writeUInt32LE(N.sourcemap.length,L+4),L+=8,p.writeUInt32LE(N.bytecode.offset,L),p.writeUInt32LE(N.bytecode.length,L+4),L+=8,p.writeUInt8(N.encoding,L),p.writeUInt8(N.loader,L+1),p.writeUInt8(N.moduleFormat,L+2),p.writeUInt8(N.side,L+3)}const S={byteCount:y,modulesPtr:{offset:l,length:u},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:h,length:f}};let E=y;const x=typeof S.byteCount=="bigint"?S.byteCount:BigInt(S.byteCount);return p.writeBigUInt64LE(x,E),E+=8,p.writeUInt32LE(S.modulesPtr.offset,E),p.writeUInt32LE(S.modulesPtr.length,E+4),E+=8,p.writeUInt32LE(S.entryPointId,E),E+=4,p.writeUInt32LE(S.compileExecArgvPtr.offset,E),p.writeUInt32LE(S.compileExecArgvPtr.length,E+4),le.copy(p,b),p}function an(e,t,n,o=!0){const r=t+".tmp";if(e.write(r),o){const i=Le.statSync(n);Le.chmodSync(r,i.mode)}try{Le.renameSync(r,t)}catch(i){try{Le.existsSync(r)&&Le.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.
182
- Please close all Claude instances and try again.`):i}}function Wn(e){const t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function Qt(e,t,n,o){try{M()&&console.log(`repackMachO: Has code signature: ${e.hasCodeSignature}`),e.hasCodeSignature&&(M()&&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=Wn(n);M()&&(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===Fe.MachO.Header.CPU_TYPE.ARM64,d=u?16384:4096,h=Math.ceil(l/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 ${l} bytes`),console.log(`repackMachO: Rounding up to page-aligned: ${h} bytes`));const f=e.extendSegment(r,h);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: ${r.fileSize}`),console.log(`repackMachO: Segment virtualSize after extend: ${r.virtualSize}`))}i.content=a,i.size=BigInt(a.length),M()&&(console.log(`repackMachO: Final section size: ${i.size}`),console.log(`repackMachO: Writing modified binary to ${o}...`)),an(e,o,t);try{M()&&console.log("repackMachO: Re-signing binary with ad-hoc signature..."),Bn(`codesign -s - -f "${o}"`,{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(r){throw console.error("repackMachO failed:",r),r}}function eo(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=Wn(n);M()&&(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),M()&&console.log(`repackPE: Writing modified binary to ${o}...`),an(e,o,t,!1),M()&&console.log("repackPE: Write completed successfully")}catch(r){throw console.error("repackPE failed:",r),r}}function no(e,t,n,o){try{const r=Buffer.allocUnsafe(n.length+8);n.copy(r,0),r.writeBigUInt64LE(BigInt(n.length),n.length),M()&&console.log(`repackELF: Setting overlay data (${r.length} bytes)`),e.overlay=r,M()&&console.log(`repackELF: Writing modified binary to ${o}...`),an(e,o,t),M()&&console.log("repackELF: Write completed successfully")}catch(r){throw console.error("repackELF failed:",r),r}}function to(e,t,n){Fe.logging.disable();const o=Fe.parse(e),{bunOffsets:r,bunData:i}=zn(o),a=Zt(i,r,t);switch(o.format){case"MachO":Qt(o,e,a,n);break;case"PE":eo(o,e,a,n);break;case"ELF":no(o,e,a,n);break;default:throw new Error(`Unsupported binary format: ${o.format}`)}}const cn=async()=>{await ie.mkdir(ce,{recursive:!0}),await ie.mkdir(Se,{recursive:!0});const e=On.join(ce,".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(bn)+bn)}};let Re={settings:ee,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null};const dn=async()=>{const e={ccVersion:"",ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:ee};try{M()&&console.log(`Reading config at ${ae}`);const t=await ie.readFile(ae,"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=ee.inputBox),n.settings.toolsets||(n.settings.toolsets=ee.toolsets),Object.hasOwn(n.settings,"defaultToolset")||(n.settings.defaultToolset=ee.defaultToolset),Object.hasOwn(n.settings,"planModeToolset")||(n.settings.planModeToolset=ee.planModeToolset);for(const i of ee.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(ee.themes.some(u=>u.id===i.id||u.name===i.name))continue;const l=ee.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||ee,n.settings.userMessageDisplay=ee.userMessageDisplay),delete n.settings.launchText,await Tt(Se)&&(n.changesApplied=!1),Re=n,n}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return e;throw t}},je=async e=>(M()&&console.log(`Updating config at ${ae}`),e(Re),Re.lastModified=new Date().toISOString(),await oo(Re),Re),oo=async e=>{try{e.lastModified=new Date().toISOString(),await cn(),await ie.writeFile(ae,JSON.stringify(e,null,2))}catch(t){throw console.error("Error saving config:",t),t}},Jn=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 ie.readFile(Ne);return await fn(e.cliPath,t,"restore"),await kt(),await je(n=>{n.changesApplied=!1}),!0},qn=async e=>{if(!e.nativeInstallationPath)return M()&&console.log("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await Oe(ge))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 ie.readFile(ge);return await fn(e.nativeInstallationPath,t,"restore"),!0};async function ro(){try{const t=process.platform==="win32"?"where claude.exe":"which claude";M()&&console.log(`Looking for claude executable using: ${t}`);const o=Bn(t,{encoding:"utf8"}).trim().split(`
183
- `)[0].trim();if(o&&await Oe(o))try{const r=await ie.realpath(o);return M()&&(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 M()&&console.log("Could not resolve symlink, using original path:",r),o}}catch(e){M()&&console.log("Could not find claude executable on PATH:",e)}return null}function Kn(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())M()&&console.log(`Found version ${a} with ${l} occurrences`),l>r&&(r=l,i=a);return M()&&i&&console.log(`Extracted version ${i} (${r} occurrences)`),i||null}async function Oe(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 io(e){const t=await ie.readFile(e,"utf8"),n=Kn(t);if(!n)throw new Error(`No VERSION strings found in JS file: ${e}`);return n}const so=async e=>{e.ccInstallationDir&&xn.unshift(e.ccInstallationDir);for(const n of xn)try{M()&&console.log(`Searching for Claude Code cli.js file at ${n}`);const o=On.join(n,"cli.js");if(!await Oe(o))continue;M()&&(console.log(`Found Claude Code cli.js file at ${n}; checking hash...`),console.log(`SHA256 hash: ${await Nr(o)}`));const r=await io(o);return{cliPath:o,version:r}}catch(o){if(o instanceof Error&&"code"in o&&(o.code==="ENOENT"||o.code==="ENOTDIR"))continue;throw o}M()&&console.log("Could not find cli.js in standard locations, trying native installation method...");const t=await ro();if(M()&&console.log(`findClaudeExecutableOnPath() returned: ${t}`),t){M()&&console.log(`Attempting to extract claude.js from native installation: ${t}`);const n=Yn(t);if(n){const o=n.toString("utf8"),r=Kn(o);return r?(M()&&console.log(`Extracted version ${r} from native installation`),{version:r,nativeInstallationPath:t}):(M()&&console.log("Failed to extract version from native installation"),null)}}return null},Cn=async e=>{if(!e.cliPath){M()&&console.log("backupClijs: Skipping for native installation (no cliPath)");return}await cn(),M()&&console.log(`Backing up cli.js to ${Ne}`),await ie.copyFile(e.cliPath,Ne),await je(t=>{t.changesApplied=!1,t.ccVersion=e.version})},In=async e=>{e.nativeInstallationPath&&(await cn(),M()&&console.log(`Backing up native binary to ${ge}`),await ie.copyFile(e.nativeInstallationPath,ge),await je(t=>{t.changesApplied=!1,t.ccVersion=e.version}))};async function En(){const e=await dn(),t=await so(e);if(!t)return null;if(t.version)try{const a=await Dt(t.version);zt(a)}catch{}const n=t.version,o=e.ccVersion;let r=!1;await Oe(Ne)||(M()&&console.log(`startupCheck: ${Ne} not found; backing up cli.js`),await Cn(t),r=!0);let i=!1;return t.nativeInstallationPath&&!await Oe(ge)&&(M()&&console.log(`startupCheck: ${ge} not found; backing up native binary`),await In(t),i=!0),n!==o?(r||(M()&&console.log(`startupCheck: real version (${n}) != backed up version (${o}); backing up cli.js`),await ie.unlink(Ne),await Cn(t)),t.nativeInstallationPath&&!i&&(M()&&console.log(`startupCheck: real version (${n}) != backed up version (${o}); backing up native binary`),await Oe(ge)&&await ie.unlink(ge),await In(t)),{wasUpdated:!0,oldVersion:o,newVersion:n,ccInstInfo:t}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}}const lo=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},ao=(e,t)=>{const n=lo(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);G(r,l,a,i.startIndex,i.endIndex),r=l}return r};function co(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 uo=(e,t)=>{const n=co(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),G(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),G(e,o,i,n.objArr.startIndex,n.objArr.endIndex),e=o;let a=`switch(${n.switchStatement.identifiers?.[0]}){
184
- `;return t.forEach(l=>{a+=`case"${l.id}":return${JSON.stringify(l.colors)};
185
- `}),a+=`default:return${JSON.stringify(t[0].colors)};
186
- }`,o=o.slice(0,n.switchStatement.startIndex)+a+o.slice(n.switchStatement.endIndex),G(e,o,a,n.switchStatement.startIndex,n.switchStatement.endIndex),o},ho=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},go=e=>{const t=ho(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 G(e,o,n,t,t),o},fo=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}},mo=(e,t)=>{const n=fo(e);if(!n)return null;if(t){const o="borderColor:undefined",r=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return G(e,r,o,n.startIndex,n.endIndex),r}else return e},po=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}},bo=e=>{const t=po(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},wo=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]]}},xo=(e,t)=>{const n=wo(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 G(e,u,l,o.startIndex,o.endIndex),u},yo=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]]}},So=(e,t)=>{const n=yo(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 G(e,i,r,n.startIndex,n.endIndex),i},vo=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},$o=(e,t)=>{const n=vo(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);G(i,l,o,r[a].startIndex,r[a].endIndex),i=l}return i},_o=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}},Co=(e,t)=>{const n=_o(e);if(!n)return null;const o=JSON.stringify(t),r=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return G(e,r,o,n.startIndex,n.endIndex),r},Io=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}},Eo=(e,t)=>{const n=Io(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 G(e,r,o,n.startIndex,n.endIndex),r},ko=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]]}},To=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]]}},Mo=(e,t)=>{const n=ko(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);G(e,a,i,o.startIndex,o.endIndex);const l=To(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 G(a,f,h,u.startIndex,u.endIndex),f},No=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}}},Oo=(e,t,n,o,r=!1,i=!1,a=!1,l=!1,u=!1,d,h,f=!1,y=!1,b=!1,p=!1,w=!1)=>{const S=No(e);if(!S)return console.error("patch: userMessageDisplay: getUserMessageDisplayLocation returned null"),null;if(!S.prefixLocation)return console.error("patch: userMessageDisplay: failed to find prefix location"),null;if(!S.messageLocation)return console.error("patch: userMessageDisplay: failed to find message location"),null;const E=un(e);if(!E)return console.error("patch: userMessageDisplay: failed to find chalk variable"),null;const x=[],k=n==="rgb(0,0,0)"&&o==="rgb(0,0,0)",O=!k||(r||i||a||l||u),N=d==="rgb(0,0,0)"&&h==="rgb(0,0,0)",L=!N||(f||y||b||p||w);if(O){const T=Tn(E,k?null:n.match(/\d+/g)?.join(",")||null,k?null:o.match(/\d+/g)?.join(",")||null,r,i,a,l,u);x.push({startIndex:S.prefixLocation.startIndex,endIndex:S.prefixLocation.endIndex,newContent:`${T}("${t}")+" "`})}if(L){const T=Tn(E,N?null:d.match(/\d+/g)?.join(",")||null,N?null:h.match(/\d+/g)?.join(",")||null,f,y,b,p,w);x.push({startIndex:S.messageLocation.startIndex,endIndex:S.messageLocation.endIndex,newContent:e.slice(S.messageLocation.startIndex,S.messageLocation.endIndex).replace(/([$\w]+)/,`${T}($1)`)})}x.sort((T,I)=>I.startIndex-T.startIndex);let B=e;for(const T of x){const I=B;B=B.slice(0,T.startIndex)+T.newContent+B.slice(T.endIndex),G(I,B,T.newContent,T.startIndex,T.endIndex)}return B},Bo=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}},Ao=e=>{const t=Bo(e);if(!t)return null;const n="verbose:true",o=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return G(e,o,n,t.startIndex,t.endIndex),o},Po=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]]}},Lo=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]]}},Do=e=>{const t=Po(e);if(!t)return null;const n="return null;";let o=e.slice(0,t.endIndex)+n+e.slice(t.endIndex);G(e,o,n,t.endIndex,t.endIndex);const r=Lo(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),G(e,o,i,r.startIndex,r.endIndex),o},Ro=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}},Fo=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}},Vo=(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,y=Array.from(h.matchAll(f));if(y.length===0)return console.error("patch: patchesAppliedIndication: failed to find createElement for PATCH 4"),null;const b=y[y.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"},`,S=u;u=u.slice(0,p)+w+u.slice(p),G(S,u,w,p,p);let E=1,x=p+w.length,k=-1;for(;x<u.length;){const O=u[x];if(O==="(")E++;else if(O===")"){if(E===1){k=x;break}E--}x++}if(k===-1)return console.error("patch: patchesAppliedIndication: failed to find closing paren for PATCH 4"),null;const D=u;return u=u.slice(0,k)+"),"+u.slice(k),G(D,u,"),",k,k),{content:u,closingParenIndex:k+2}},jo=(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(""),y=e,b=e.slice(0,d)+f+e.slice(d);return G(y,b,f,d,d),b},Uo=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\\(${fe(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}},Ho=(e,t,n,o=!0,r=!0)=>{const i=Ro(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);G(e,l,a,i.endIndex,i.endIndex);const u=un(e);if(!u)return console.error("patch: patchesAppliedIndication: failed to find chalk variable"),null;const d=nt(e);if(!d)return console.error("patch: patchesAppliedIndication: failed to find text component"),null;const h=qe(e);if(!h)return console.error("patch: patchesAppliedIndication: failed to find React variable"),null;const f=tt(e);if(!f)return console.error("patch: patchesAppliedIndication: failed to find Box component"),null;if(o){const b=Fo(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),G(w,l,p,b.startIndex,b.endIndex)}if(r){const b=Uo(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 E of n)E=E.replace("CHALK_VAR",u),p.push(`${h}.createElement(${f}, null, ${h}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${d}, {dimColor: true}, \` * ${E}\`)),`);p.push("),");const w=p.join(`
187
- `),S=l;l=l.slice(0,b.startIndex)+w+l.slice(b.endIndex),G(S,l,w,b.startIndex,b.endIndex)}let y=-1;if(o){const b=Vo(l,t,h,f,d,u);if(!b)return console.error("patch: patchesAppliedIndication: patch 4 failed"),null;l=b.content,y=b.closingParenIndex}if(r){if(y===-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;y=w.index+w[0].length}const b=jo(l,y,h,f,d,u,n);if(!b)return console.error("patch: patchesAppliedIndication: patch 5 failed"),null;l=b}return l},Go=e=>/\\u[0-9a-fA-F]{4}/.test(e),zo=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})`},Yo=async(e,t,n)=>{const o=n??Go(e);M()&&o&&console.log("Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts");const r=await Gt(t,o);M()&&console.log(`Loaded ${r.length} system prompts with regexes`);let i=0,a=0;for(const{promptId:d,prompt:h,regex:f,getInterpolatedContent:y,pieces:b,identifiers:p,identifierMap:w}of r){const S=new RegExp(f,"si"),E=e.match(S);if(E&&E.index!==void 0){const x=y(E),k=jt(x);if(k.size>0){const I=Be(d),z=h.content.split(`
188
- `);for(const[W,Q]of k){const q=W+(h.contentLineOffset||0),C=z[W-1]||"";console.log(Ut(I,q,C,Q)),console.log()}continue}const D=Ve(b,p,w).trim(),O=D.length,N=h.content.length;i+=O,a+=N,M()&&O!==N&&(console.log(`
189
- Character count difference for ${h.name}:`),console.log(` Original baseline: ${O} chars`),console.log(` User's version: ${N} chars`),console.log(` Difference: ${O-N} chars`),Math.abs(O-N)<200&&(console.log(`
190
+ </html>`,T=ae.join(Se,`${e}.diff.html`);return await oe.writeFile(T,I,"utf-8"),T},$r=async e=>{const n={id:e.id,name:e.name,description:e.description,action:"skipped",newVersion:e.version};if(!await xr(e.id)){const i=kt(e);return await pt(e.id,i),n.action="created",n}const r=await Sr(e.id);if(n.oldVersion=r.ccVersion,await yr(e.id,e.identifierMap),r.ccVersion&&e.version){const i=Jt(r.ccVersion,e.version);if(i===0)return n.action="skipped",n;if(i!=0){const o=await fr(e.id,r.ccVersion),l=Ze(r.content);if(!o||o!==l){n.action="conflict";let u=r.content;try{const w=(await xt(r.ccVersion)).prompts.find(p=>p.id===e.id);w&&(u=Ue(w.pieces,w.identifiers,w.identifierMap))}catch{console.log(F.yellow(`Warning: Could not fetch old version ${r.ccVersion} for comparison. Using current file as baseline.`))}const d=Ue(e.pieces,e.identifiers,e.identifierMap),g=Ve(e.id),f=await Cr(e.id,e.name,u,r.content,d,r.ccVersion,e.version,g);n.diffHtmlPath=f}else{const u=kt(e);await pt(e.id,u),n.action="updated"}}}return n},_r=async e=>{const n={ccVersion:e,results:[]},t=await xt(e);await gr(t),await oe.mkdir(Se,{recursive:!0});for(const r of t.prompts)try{const i=await $r(r);n.results.push(i)}catch(i){throw console.log(F.red(`Failed to sync prompt ${r.id}:`)),i}return n};let Qe=null,bt=null;const Xt=async e=>{try{return Qe=await xt(e),bt=e,{success:!0}}catch(n){return Qe=null,bt=null,n instanceof Error?{success:!1,errorMessage:n.message}:{success:!1,errorMessage:"Unknown error occurred while downloading system prompts"}}},Ir=e=>e.replace(/[^\x00-\x7F]/g,n=>{const r=`\\\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${r})`}),Tr=e=>e.replace(/[^\x00-\x7F]/g,n=>`\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`),Mr=(e,n,t)=>{let r="";for(let i=0;i<e.length;i++){let o=e[i].replace(/<<CCVERSION>>/g,n);t&&(o=o.replace(/<<BUILD_TIME>>/g,t));const l=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=Ir(l);r+=c,i<e.length-1&&(r+="([\\w$]+)")}return r},Er=e=>{const n=new Map;let t=0,r=1,i=1;for(let o=0;o<e.length;o++,i++){const l=e[o];if(l===`
191
+ `){r++,i=0;continue}const c=e[o+1];if(l==="$"&&c==="{"){t++,o++,i++;continue}if(t){l==="{"?t++:l==="}"&&t--;continue}if(l==="`"&&e[o-1]!=="\\"){const u=n.get(r)??[];u.push(i),n.set(r,u)}}return n},kr=(e,n,t,r)=>{const i=[],o=String(n),l=o.length,c=" ".repeat(l),u=r[0],d=r[r.length-1],g=30,f=30,x=u-1,w=t.length-d;let p=t,b=r,I="",T="",S=0;if(x>g||w>f){let $=0,z=t.length,W=0;if(x>g){const X=x-g;$=X,W=-X;const G=`[${X} chars] ...`;I=F.dim(G),S=G.length}if(w>f){const X=w-f;z=t.length-X,T=F.dim(`... [${X} chars]`)}p=t.substring($,z),b=r.map(X=>X+W)}i.push(`${F.red.bold("error")}${F.bold(": system prompt file contains unescaped backtick")}`),i.push(`${F.blue.bold(" ".repeat(l)+" -->")} ${e}:${n}:${u}`),i.push(`${c} ${F.blue.bold("|")}`);const E=I+p+T;i.push(`${F.blue.bold(o)} ${F.blue.bold("|")} ${E}`);const V=S+b[0]-1,O=" ".repeat(V)+"^ unescaped backtick";i.push(`${c} ${F.blue.bold("|")} ${F.red.bold(O)}`),i.push(`${c} ${F.blue.bold("|")}`),i.push(`${F.cyan.bold("help")}: add \`\\\` before the backtick to escape it`),i.push(`${c} ${F.blue.bold("|")}`);const R=[];let D=0;for(const $ of b)R.push(p.substring(D,$-1)),R.push(F.green("\\")+"`"),D=$;R.push(p.substring(D));const J=I+R.join("")+T;i.push(`${F.blue.bold(o)} ${F.blue.bold("|")} ${J}`);let k="",N=0;for(let $=0;$<b.length;$++){const z=b[$],W=S+z-1+N;k=k.padEnd(W," ")+"+",N++}return i.push(`${c} ${F.blue.bold("|")} ${F.green(k)}`),i.join(`
192
+ `)},Nr=(e,n,t,r,i,o=!1,l)=>{const c={};for(let g=0;g<r.length;g++){const f=r[g],x=String(n[g]),w=t[x];w&&(c[w]=f)}let u=e;const d=Object.entries(c).sort((g,f)=>f[0].length-g[0].length);for(const[g,f]of d){const x=new RegExp(`\\b${g}\\b`,"g");u=u.replace(x,()=>f)}return u=u.replace(/<<CCVERSION>>/g,i),l&&(u=u.replace(/<<BUILD_TIME>>/g,l)),o&&(u=Tr(u)),u},Br=async(e,n=!1,t)=>{if(!Qe||bt!==e)return[];const r=Qe,i=[];for(const o of r.prompts){const l=Mr(o.pieces,e,t),c=ae.join(Se,`${o.id}.md`);let u;try{u=await oe.readFile(c,"utf8")}catch(f){console.error(`Failed to read markdown file ${c}:`,f);continue}const d=zt(u),g=f=>{const x=f.slice(1);return Nr(d.content,o.identifiers,o.identifierMap,x,e,n,t)};i.push({promptId:o.id,prompt:d,regex:l,getInterpolatedContent:g,pieces:o.pieces,identifiers:o.identifiers,identifierMap:o.identifierMap})}return i},Pr=e=>{const n=e.results.filter(o=>o.action==="created"),t=e.results.filter(o=>o.action==="updated"),r=e.results.filter(o=>o.action==="conflict"),i=e.results.filter(o=>o.action==="skipped");if((n.length>0||t.length>0||r.length>0)&&i.length>0&&(console.log(F.dim(`Skipped ${i.length} up-to-date file(s)`)),console.log()),n.length>0){console.log(F.bold.green(`Created ${n.length} new prompt file(s):`));for(const o of n)console.log(F.green(` ${Se}/${o.id}.md`)),console.log(F.green.dim(` ${o.description}`));console.log()}if(t.length>0){console.log(F.bold.blue(`Updated ${t.length} system prompt file(s):`));for(const o of t)o.oldVersion?console.log(F.blue(` ${o.id}.md (${o.oldVersion} → ${o.newVersion})`)):console.log(F.blue(` ${o.id}.md (→ ${o.newVersion})`));console.log()}if(r.length>0){console.log(F.bold.yellow(`WARNING: Conflicts detected for ${r.length} system prompt file(s)`));for(const o of r)console.log(F.yellow(` ${o.id}.md (${o.oldVersion} → ${o.newVersion})`)),console.log(F.yellow(` Open the diff in your browser: ${o.diffHtmlPath}`));console.log()}if(n.length>0&&(console.log(F.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(F.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(F.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(F.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const o of r)console.log(F.yellow(` ${o.id}.md → `)+F.bold.magenta(o.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},Ar=e=>/\\u[0-9a-fA-F]{4}/.test(e),Or=e=>{const n=e.match(/\bBUILD_TIME:"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)"/);return n?n[1]:void 0},Dr=e=>{const n=e.toString(),t=JSON.stringify(n.substring(1,n.length-1)),r=JSON.stringify(n.match(/\/(\w*)$/)[1]);return`new RegExp(${t}, ${r})`},Lr=async(e,n,t)=>{const r=t??Ar(e);r&&M("Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts");const i=Or(e);i&&M(`Extracted BUILD_TIME from cli.js: ${i}`);const o=await Br(n,r,i);M(`Loaded ${o.length} system prompts with regexes`);let l=0,c=0;for(const{promptId:g,prompt:f,regex:x,getInterpolatedContent:w,pieces:p,identifiers:b,identifierMap:I}of o){const T=new RegExp(x,"si"),S=e.match(T);if(S&&S.index!==void 0){const E=w(S),V=Er(E);if(V.size>0){const z=Ve(g),W=f.content.split(`
193
+ `);for(const[X,G]of V){const _=X+(f.contentLineOffset||0),y=W[X-1]||"";console.log(kr(z,_,y,G)),console.log()}continue}const O=Ue(p,b,I).trim(),R=O.length,D=f.content.length;l+=R,c+=D,R!==D&&(M(`
194
+ Character count difference for ${f.name}:`),M(` Original baseline: ${R} chars`),M(` User's version: ${D} chars`),M(` Difference: ${R-D} chars`),Math.abs(R-D)<200&&(M(`
190
195
  Original baseline content:
191
- ${D}`),console.log(`
196
+ ${O}`),M(`
192
197
  User's content:
193
- ${h.content}`))),M()&&(console.log(`
194
- Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.index}, length ${E[0].length}`),console.log(` Original content (first 100 chars): ${E[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${x.substring(0,100)}...`),console.log(` Captured variables: ${E.slice(1).join(", ")}`),console.log(` Content identical: ${E[0]===x}`));const j=e,L=E.index,B=E[0].length;e=e.replace(S,()=>x);const T=We(h.content);await Et(d,T),M()&&G(j,e,x,L,L+B)}else if(console.log(H.yellow(`Could not find system prompt "${h.name}" in cli.js (using regex ${zo(S)})`)),M()){console.log(`
195
- 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 x=e.match(new RegExp(f.substring(0,100)));console.log(` Partial match result: ${x?"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}},Wo=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 ${fe(u)}\\(([$\\w]+),`,"g");let y,b=null;for(;(y=f.exec(h))!==null;)b=y;if(!b)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=b[1],w=d+b.index,S=e.slice(w,n.index),E=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,x=S.match(E);if(!x||x.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const k=x[1],D=w+x.index+x[0].length,O=e.slice(D,n.index),N=new RegExp(`if\\(!${fe(k)}\\)return;`),j=O.match(N);if(!j||j.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const L=D+j.index+j[0].length;return{startIndex:L,endIndex:L,identifiers:[p,k]}},Jo=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?G(i,r,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const a=r;r=r.replace(n,""),r!==a?G(a,r,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const l=r;r=r.replace(o,""),r!==l?G(l,r,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=Wo(r);if(!u||!u.identifiers)return null;const[d,h]=u.identifiers,f=`
198
+ ${f.content}`))),M(`
199
+ Found match for prompt: ${f.name}`),M(` Match location: index ${S.index}, length ${S[0].length}`),M(` Original content (first 100 chars): ${S[0].substring(0,100)}...`),M(` Replacement content (first 100 chars): ${E.substring(0,100)}...`),M(` Captured variables: ${S.slice(1).join(", ")}`),M(` Content identical: ${S[0]===E}`);const J=e,k=S.index,N=S[0].length;e=e.replace(T,()=>E);const $=Ze(f.content);await pr(g,$),Y(J,e,E,k,k+N)}else{console.log(F.yellow(`Could not find system prompt "${f.name}" in cli.js (using regex ${Dr(T)})`)),M(`
200
+ Debug info for ${f.name}:`),M(` Regex pattern (first 200 chars): ${x.substring(0,200)}...`),M(" Trying to match pattern in cli.js...");const E=e.match(new RegExp(x.substring(0,100)));M(` Partial match result: ${E?"found partial":"no match"}`)}}const u=[],d=l-c;return d>0?u.push(`system prompts: \${CHALK_VAR.green('${d} fewer chars')} than original`):d<0&&u.push(`system prompts: \${CHALK_VAR.red('${Math.abs(d)} more chars')} than original`),{newContent:e,items:u}},Rr=e=>{const n=/ensureServerStarted:([$\w]+)\b/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: fixLspSupport: failed to find ensureServerStarted"),null;const r=Math.max(0,t.index-50),i=Math.min(e.length,t.index+50),o=e.slice(r,i),l=/sendRequest:([$\w]+)[,}]/,c=o.match(l);if(!c)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([r,i,o])}`),null;const u=c[1],d=Math.max(0,t.index-2e3),g=e.slice(d,t.index),f=new RegExp(`async function ${ue(u)}\\(([$\\w]+),`,"g");let x,w=null;for(;(x=f.exec(g))!==null;)w=x;if(!w)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=w[1],b=d+w.index,I=e.slice(b,t.index),T=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,S=I.match(T);if(!S||S.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const E=S[1],V=b+S.index+S[0].length,O=e.slice(V,t.index),R=new RegExp(`if\\(!${ue(E)}\\)return;`),D=O.match(R);if(!D||D.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const J=V+D.index+D[0].length;return{startIndex:J,endIndex:J,identifiers:[p,E]}},Vr=e=>{const n=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,t=/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 i=e;const o=i;i=i.replace(n,""),i!==o?Y(o,i,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const l=i;i=i.replace(t,""),i!==l?Y(l,i,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const c=i;i=i.replace(r,""),i!==c?Y(c,i,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=Rr(i);if(!u||!u.identifiers)return null;const[d,g]=u.identifiers,f=`
196
201
  const path = await import('path');
197
202
  const ext = path.extname(${d}).toLowerCase();
198
203
  const langMap = {
@@ -333,7 +338,7 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.ind
333
338
  try {
334
339
  const fs = await import('fs/promises');
335
340
  const text = await fs.readFile(${d}, 'utf8');
336
- await ${h}.sendNotification('textDocument/didOpen', {
341
+ await ${g}.sendNotification('textDocument/didOpen', {
337
342
  textDocument: {
338
343
  uri: "file://" + ${d},
339
344
  languageId: languageId,
@@ -342,27 +347,27 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.ind
342
347
  }
343
348
  });
344
349
  } catch (openErr) { }
345
- `,y=r.slice(0,u.startIndex)+f+r.slice(u.endIndex);return G(r,y,f,u.startIndex,u.endIndex),y},Xn=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},Zn=(e,t)=>{const n=Xn(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 G(e,o,t,n,n),o},qo=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]},Ko=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|mcpCliEndpoint|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,o=Array.from(e.matchAll(t)).filter(i=>i[0].includes("commands:"));if(o.length===0)return console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern"),null;let r=o[0];for(const i of o)i[0].length>r[0].length&&(r=i);return r.index===void 0?(console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch"),null):r.index+r[0].length},Je=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)},Xo=e=>{const t=Qn(e);if(t===null)return console.error("patch: getToolFetchingUseMemoLocation: failed to find bodyStart"),null;const n=e.slice(t,t+2e3),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,u=r[0].startsWith(",");return{startIndex:i,endIndex:a,outputVarName:r[1],reactVarName:r[2],toolFilterFunction:r[3],toolPermissionContextVar:r[4],needsSemicolonPrefix:u}},Zo=e=>{const t=Xn(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},Qo=(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},er=(e,t)=>{const n=Xo(e);if(!n)return console.error("patch: toolsets: failed to find tool fetching useMemo location"),null;const o=Je(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,needsSemicolonPrefix:f}=n,y=JSON.stringify(Object.fromEntries(t.map(S=>[S.name,S.allowedTools==="*"?"*":S.allowedTools]))),p=`${f?";":""}let ${l} = ${u}.useMemo(() => {
346
- const toolsets = ${y};
347
- if (toolsets.hasOwnProperty(${r}.toolset)) {
348
- const allowedTools = toolsets[${r}.toolset];
350
+ `,x=i.slice(0,u.startIndex)+f+i.slice(u.endIndex);return Y(i,x,f,u.startIndex,u.endIndex),x},qt=e=>{const n=/=>\[([$a-zA-Z_][$\w]{1,2},){30}/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: findSlashCommandListEndPosition: failed to find arrayStartPattern"),null;const r=e.indexOf("[",t.index);if(r===-1)return console.error("patch: findSlashCommandListEndPosition: failed to find bracketIndex"),null;let i=1,o=r+1;for(;o<e.length&&i>0;){if(e[o]==="[")i++;else if(e[o]==="]"&&(i--,i===0))return o;o++}return console.error("patch: findSlashCommandListEndPosition: failed to find matching closing-bracket"),null},Kt=(e,n)=>{const t=qt(e);if(t===null)return console.error("patch: writeSlashCommandDefinition: failed to find slash command array end position"),null;const r=e.slice(0,t)+n+e.slice(t);return Y(e,r,n,t,t),r},Fr=e=>{const n=/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,t=Array.from(e.matchAll(n));if(t.length===0)return console.error("patch: findSelectComponentName: failed to find selectPattern"),null;let r=t[0];for(const i of t)i[0].length>r[0].length&&(r=i);return r[1]},jr=e=>{const n=/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,t=Array.from(e.matchAll(n));if(t.length===0)return console.error("patch: findDividerComponentName: failed to find dividerPattern"),null;let r=t[0];for(const i of t)i[0].length>r[0].length&&(r=i);return r[1]},Qt=e=>{const n=/function ([$\w]+)\(\{(?:(?:commands|debug|initialPrompt|initialTools|initialMessages|initialCheckpoints|initialFileHistorySnapshots|mcpClients|dynamicMcpConfig|mcpCliEndpoint|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,r=Array.from(e.matchAll(n)).filter(o=>o[0].includes("commands:"));if(r.length===0)return console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern"),null;let i=r[0];for(const o of r)o[0].length>i[0].length&&(i=o);return i.index===void 0?(console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch"),null):i.index+i[0].length},et=e=>{const n=Qt(e);if(n===null)return console.error("patch: getAppStateVarAndGetterFunction: failed to find bodyStart"),null;const t=e.slice(n,n+20),r=/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/,i=t.match(r);return i?{appStateVar:i[1],appStateGetterFunction:i[2]}:(console.error("patch: getAppStateVarAndGetterFunction: failed to find statePattern"),null)},Ur=e=>{const n=Qt(e);if(n===null)return console.error("patch: getToolFetchingUseMemoLocation: failed to find bodyStart"),null;const t=e.slice(n,n+2e3),r=/(?:let |,)([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4\]\)/,i=t.match(r);if(!i||i.index===void 0)return console.error("patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern"),null;const o=n+i.index,l=o+i[0].length,u=i[0].startsWith(",");return{startIndex:o,endIndex:l,outputVarName:i[1],reactVarName:i[2],toolFilterFunction:i[3],toolPermissionContextVar:i[4],needsSemicolonPrefix:u}},Hr=e=>{const n=qt(e);if(n===null)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd"),null;let t=1,r=n;for(;r>=0&&t>0;){if(e[r]==="}")t++;else if(e[r]==="{"&&(t--,t===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},Gr=(e,n)=>{const t=/thinkingEnabled:([$\w]+)\(\)/g,r=Array.from(e.matchAll(t));if(r.length===0)return console.error("patch: toolsets: failed to find thinkingEnabled pattern"),null;const i=[];for(const u of r)if(u.index!==void 0){const d=u.index+u[0].length;i.push({index:d})}i.sort((u,d)=>d.index-u.index);let o=e;const c=`,toolset:${n?JSON.stringify(n):"undefined"}`;for(const u of i)o=o.slice(0,u.index)+c+o.slice(u.index);return o===e?(console.error("patch: toolsets: failed to modify app state initialization"),null):o},Yr=(e,n)=>{const t=Ur(e);if(!t)return console.error("patch: toolsets: failed to find tool fetching useMemo location"),null;const r=et(e);if(!r)return console.error("patch: toolsets: failed to find app state info"),null;const{appStateVar:i}=r,{startIndex:o,endIndex:l,outputVarName:c,reactVarName:u,toolFilterFunction:d,toolPermissionContextVar:g,needsSemicolonPrefix:f}=t,x=JSON.stringify(Object.fromEntries(n.map(I=>[I.name,I.allowedTools==="*"?"*":I.allowedTools]))),p=`${f?";":""}let ${c} = ${u}.useMemo(() => {
351
+ const toolsets = ${x};
352
+ if (toolsets.hasOwnProperty(${i}.toolset)) {
353
+ const allowedTools = toolsets[${i}.toolset];
349
354
  if (allowedTools === "*") {
350
- return ${d}(${h});
355
+ return ${d}(${g});
351
356
  } else {
352
- return ${d}(${h}).filter(toolDef =>
357
+ return ${d}(${g}).filter(toolDef =>
353
358
  allowedTools.includes(toolDef.name)
354
359
  );
355
360
  }
356
361
  } else {
357
- return ${d}(${h});
362
+ return ${d}(${g});
358
363
  }
359
- }, [${d}, ${r}.toolset])`,w=e.slice(0,i)+p+e.slice(a);return G(e,w,p,i,a),w},nr=(e,t)=>{const n=Zo(e);if(n===null)return console.error("patch: toolsets: failed to find slash command insertion point"),null;const o=qe(e);if(!o)return console.error("patch: toolsets: failed to find React variable"),null;const r=tt(e);if(!r)return console.error("patch: toolsets: failed to find Box component"),null;const i=nt(e);if(!i)return console.error("patch: toolsets: failed to find Text component"),null;const a=qo(e);if(!a)return console.error("patch: toolsets: failed to find Select component"),null;const l=Ko(e);if(!l)return console.error("patch: toolsets: failed to find Divider component"),null;const u=Je(e);if(!u)return console.error("patch: toolsets: failed to find app state getter"),null;const d=un(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)),y=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 }) => {
360
- const [state, setState] = ${h}();
364
+ }, [${d}, ${i}.toolset])`,b=e.slice(0,o)+p+e.slice(l);return Y(e,b,p,o,l),b},Wr=(e,n)=>{const t=Hr(e);if(t===null)return console.error("patch: toolsets: failed to find slash command insertion point"),null;const r=tt(e);if(!r)return console.error("patch: toolsets: failed to find React variable"),null;const i=Ct(e);if(!i)return console.error("patch: toolsets: failed to find Box component"),null;const o=nn(e);if(!o)return console.error("patch: toolsets: failed to find Text component"),null;const l=Fr(e);if(!l)return console.error("patch: toolsets: failed to find Select component"),null;const c=jr(e);if(!c)return console.error("patch: toolsets: failed to find Divider component"),null;const u=et(e);if(!u)return console.error("patch: toolsets: failed to find app state getter"),null;const d=yt(e);if(!d)return console.error("patch: toolsets: failed to find chalk variable"),null;const{appStateGetterFunction:g}=u,f=JSON.stringify(n.map(b=>b.name)),x=JSON.stringify(n.map(b=>({label:b.name,value:b.name,description:b.allowedTools==="*"?"All tools":b.allowedTools.length===0?"No tools":`${b.allowedTools.length} tool${b.allowedTools.length!==1?"s":""}: ${b.allowedTools.join(", ")}`}))),w=`const toolsetComp = ({ onExit, input }) => {
365
+ const [state, setState] = ${g}();
361
366
 
362
367
  // Handle command-line argument
363
368
  if (input !== "" && input != null) {
364
369
  if (!${f}.includes(input)) {
365
- onExit(${d}.red(\`\${${d}.bold(input)} is not a valid toolset. Valid toolsets: ${t.map(w=>w.name).join(", ")}\`));
370
+ onExit(${d}.red(\`\${${d}.bold(input)} is not a valid toolset. Valid toolsets: ${n.map(b=>b.name).join(", ")}\`));
366
371
  return;
367
372
  } else {
368
373
  setState(prev => ({ ...prev, toolset: input }));
@@ -372,44 +377,44 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.ind
372
377
  }
373
378
 
374
379
  // Render interactive UI
375
- return ${o}.createElement(
376
- ${r},
380
+ return ${r}.createElement(
381
+ ${i},
377
382
  { flexDirection: "column" },
378
- ${o}.createElement(${l}, { dividerColor: "permission" }),
379
- ${o}.createElement(
380
- ${r},
383
+ ${r}.createElement(${c}, { dividerColor: "permission" }),
384
+ ${r}.createElement(
385
+ ${i},
381
386
  { paddingX: 1, marginBottom: 1, flexDirection: "column" },
382
- ${o}.createElement(${r}, null,
383
- ${o}.createElement(${i}, { bold: true, color: "remember" }, "Select toolset")
387
+ ${r}.createElement(${i}, null,
388
+ ${r}.createElement(${o}, { bold: true, color: "remember" }, "Select toolset")
384
389
  ),
385
- ${o}.createElement(${r}, null,
386
- ${o}.createElement(${i}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
390
+ ${r}.createElement(${i}, null,
391
+ ${r}.createElement(${o}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
387
392
  ),
388
- ${o}.createElement(${r}, { marginBottom: 1 },
389
- ${o}.createElement(${i}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
393
+ ${r}.createElement(${i}, { marginBottom: 1 },
394
+ ${r}.createElement(${o}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
390
395
  ),
391
- ${o}.createElement(${r}, null,
392
- ${o}.createElement(${i}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
396
+ ${r}.createElement(${i}, null,
397
+ ${r}.createElement(${o}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
393
398
  ),
394
- ${o}.createElement(${r}, { marginBottom: 1 },
395
- ${o}.createElement(${i}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
399
+ ${r}.createElement(${i}, { marginBottom: 1 },
400
+ ${r}.createElement(${o}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
396
401
  ),
397
- ${o}.createElement(${r}, null,
398
- ${o}.createElement(${i}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc. "),
399
- ${o}.createElement(${i}, { dimColor: true }, "Run "),
400
- ${o}.createElement(${i}, { color: "permission" }, "npx tweakcc"),
401
- ${o}.createElement(${i}, { dimColor: true }, " to manage them.")
402
+ ${r}.createElement(${i}, null,
403
+ ${r}.createElement(${o}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc. "),
404
+ ${r}.createElement(${o}, { dimColor: true }, "Run "),
405
+ ${r}.createElement(${o}, { color: "permission" }, "npx tweakcc"),
406
+ ${r}.createElement(${o}, { dimColor: true }, " to manage them.")
402
407
  ),
403
- ${o}.createElement(${r}, { marginBottom: 1 },
404
- ${o}.createElement(${i}, { color: "permission" }, "https://github.com/Piebald-AI/tweakcc")
408
+ ${r}.createElement(${i}, { marginBottom: 1 },
409
+ ${r}.createElement(${o}, { color: "permission" }, "https://github.com/Piebald-AI/tweakcc")
405
410
  ),
406
- ${o}.createElement(${r}, { marginBottom: 1 },
407
- ${o}.createElement(${i}, null, "Current toolset: "),
408
- ${o}.createElement(${i}, { bold: true }, state.toolset || "undefined")
411
+ ${r}.createElement(${i}, { marginBottom: 1 },
412
+ ${r}.createElement(${o}, null, "Current toolset: "),
413
+ ${r}.createElement(${o}, { bold: true }, state.toolset || "undefined")
409
414
  ),
410
- ${o}.createElement(${r}, { marginBottom: 1 },
411
- ${o}.createElement(${a}, {
412
- options: ${y},
415
+ ${r}.createElement(${i}, { marginBottom: 1 },
416
+ ${r}.createElement(${l}, {
417
+ options: ${x},
413
418
  onChange: (input) => {
414
419
  setState(prev => ({ ...prev, toolset: input }));
415
420
  onExit(\`Toolset changed to \${${d}.bold(input)}\`);
@@ -417,10 +422,10 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.ind
417
422
  onCancel: () => onExit(\`Toolset not changed (left as \${${d}.bold(state.toolset)})\`)
418
423
  })
419
424
  ),
420
- ${o}.createElement(${i}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
425
+ ${r}.createElement(${o}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
421
426
  )
422
427
  );
423
- };`,p=e.slice(0,n)+b+e.slice(n);return G(e,p,b,n,n),p},tr=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},or=e=>{const t=tr(e);if(t===null)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point"),null;const n=Je(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 G(e,i,r,t,t),i},rr=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):(G(e,l,a,n.index,n.index+i.length),l)},ir=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):(G(e,a,i,o.index,o.index+r.length),a)},sr=e=>{const t=qe(e);if(!t)return console.error("patch: toolsets: failed to find React variable"),null;const n=`, {
428
+ };`,p=e.slice(0,t)+w+e.slice(t);return Y(e,p,w,t,t),p},zr=e=>{const n=/\{color:"bashBorder"\},"! for bash mode"/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find bash mode pattern"),null;const r=Math.max(0,t.index-500),i=e.slice(r,t.index),o=/function ([$\w]+)\(\{[^}]+\}\)\{/g,l=Array.from(i.matchAll(o));if(l.length===0)return console.error("patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find function pattern"),null;const c=l[l.length-1];return c.index===void 0?(console.error("patch: toolsets: findShiftTabAppStateVarInsertionPoint: match has no index"),null):r+c.index+c[0].length},Jr=e=>{const n=zr(e);if(n===null)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point"),null;const t=et(e);if(!t)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter"),null;const{appStateGetterFunction:r}=t,i=`let[state]=${r}();`,o=e.slice(0,n)+i+e.slice(n);return Y(e,o,i,n,n),o},Xr=e=>{const n=/([$\w]+)\((\w+)\)\.toLowerCase\(\)," on"/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: toolsets: appendToolsetToModeDisplay: failed to find mode display pattern"),null;const r=t[1],i=t[2],o=t[0],l=`${r}(${i}).toLowerCase()," on [",state.toolset||"undefined","]"`,c=e.replace(o,l);return c===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(Y(e,c,l,t.index,t.index+o.length),c)},qr=e=>{const n=/"\? for shortcuts"/g,r=Array.from(e.matchAll(n)).at(-1);if(!r||r.index===void 0)return console.error("patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'"),null;const i=r[0],o='"? for shortcuts [",state.toolset||"undefined","]"',l=e.replace(i,o);return l===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(Y(e,l,o,r.index,r.index+i.length),l)},Kr=e=>{const n=tt(e);if(!n)return console.error("patch: toolsets: failed to find React variable"),null;const t=`, {
424
429
  aliases: ["change-tools"],
425
430
  type: "local-jsx",
426
431
  name: "toolset",
@@ -429,12 +434,12 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.ind
429
434
  isEnabled: () => true,
430
435
  isHidden: false,
431
436
  async call(onExit, ctx, input) {
432
- return ${t}.createElement(toolsetComp, { onExit, input });
437
+ return ${n}.createElement(toolsetComp, { onExit, input });
433
438
  },
434
439
  userFacingName() {
435
440
  return "toolset";
436
441
  }
437
- }`;return Zn(e,n)},lr=e=>{const t=/[\w$]+\([\w$]+,function\([\w$]+\)\{[\w$]+\("tengu_ext_at_mentioned",\{\}\);/,n=e.match(t);return!n||n.index===void 0?(console.error("patch: findToolChangeComponentScope: failed to find tool change component scope"),null):n.index},ar=e=>{const t=lr(e);if(t===null)return null;const n=Je(e);if(!n)return console.error("patch: addSetStateFnAccessAtToolChangeComponentScope: failed to get app state getter function"),null;const{appStateGetterFunction:o}=n,r=`const [state, setState] = ${o}();`;return e.slice(0,t)+r+e.slice(t)},cr=e=>{const t=/let [\w$]+=[\w$]+\([\w$]+,\{type:"setMode",mode:([\w$]+),destination:"session"\}\);/,n=e.match(t);return!n||n.index===void 0?(console.error("patch: findModeChange: failed to find mode change location"),null):{index:n.index,modeVar:n[1]}},dr=(e,t,n)=>{const o=cr(e);if(!o)return null;const{index:r,modeVar:i}=o,a=`if(${i}==="plan"){setState((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}else{setState((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}`;return e.slice(0,r)+a+e.slice(r)},ur=(e,t,n)=>{if(!t||t.length===0)return null;let o=e;return o=Qo(o,n),o?(o=er(o,t),o?(o=nr(o,t),o?(o=sr(o),o?(o=or(o),o?(o=rr(o),o?(o=ir(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)},hr=e=>qe(e)?Zn(e,`, {
442
+ }`;return Kt(e,t)},Qr=e=>{const n=/[\w$]+\([\w$]+,function\([\w$]+\)\{[\w$]+\("tengu_ext_at_mentioned",\{\}\);/,t=e.match(n);return!t||t.index===void 0?(console.error("patch: findToolChangeComponentScope: failed to find tool change component scope"),null):t.index},Zr=e=>{const n=Qr(e);if(n===null)return null;const t=et(e);if(!t)return console.error("patch: addSetStateFnAccessAtToolChangeComponentScope: failed to get app state getter function"),null;const{appStateGetterFunction:r}=t,i=`const [state, setState] = ${r}();`;return e.slice(0,n)+i+e.slice(n)},eo=e=>{const n=/let [\w$]+=[\w$]+\([\w$]+,\{type:"setMode",mode:([\w$]+),destination:"session"\}\);/,t=e.match(n);return!t||t.index===void 0?(console.error("patch: findModeChange: failed to find mode change location"),null):{index:t.index,modeVar:t[1]}},to=(e,n,t)=>{const r=eo(e);if(!r)return null;const{index:i,modeVar:o}=r,l=`if(${o}==="plan"){setState((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}else{setState((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}`;return e.slice(0,i)+l+e.slice(i)},no=(e,n,t)=>{if(!n||n.length===0)return null;let r=e;return r=Gr(r,t),r?(r=Yr(r,n),r?(r=Wr(r,n),r?(r=Kr(r),r?(r=Jr(r),r?(r=Xr(r),r?(r=qr(r),r||(console.error("patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)"),null)):(console.error("patch: toolsets: step 6 failed (appendToolsetToModeDisplay)"),null)):(console.error("patch: toolsets: step 5 failed (insertShiftTabAppStateVar)"),null)):(console.error("patch: toolsets: step 4 failed (writeSlashCommandDefinition)"),null)):(console.error("patch: toolsets: step 3 failed (writeToolsetComponentDefinition)"),null)):(console.error("patch: toolsets: step 2 failed (writeToolFetchingUseMemo)"),null)):(console.error("patch: toolsets: step 1 failed (writeToolsetFieldToAppState)"),null)},ro=e=>tt(e)?Kt(e,`, {
438
443
  type: "local",
439
444
  name: "title",
440
445
  description: "Set the conversation title",
@@ -453,11 +458,11 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${E.ind
453
458
  userFacingName() {
454
459
  return "title";
455
460
  },
456
- }`):(console.error("patch: conversationTitle: failed to find React variable"),null),gr=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},fr=e=>{const t=gr(e);if(t===null)return console.error("patch: conversationTitle: failed to find custom naming functions location"),null;const n=hn(e),o=`
461
+ }`):(console.error("patch: conversationTitle: failed to find React variable"),null),oo=e=>{const n=/class ([$\w]+)\{summaries;(?:customTitles;)?messages;(?:checkpoints;)?fileHistorySnapshots;/,t=e.match(n);return!t||t.index===void 0?(console.error("patch: conversationTitle: findCustomNamingFunctionsLocation: failed to find class pattern"),null):t.index},io=e=>{const n=oo(e);if(n===null)return console.error("patch: conversationTitle: failed to find custom naming functions location"),null;const t=vt(e),r=`
457
462
  function getTweakccBaseDir() {
458
- const { join: pathJoin } = ${n}('path');
459
- const { homedir: osHomedir } = ${n}('os');
460
- const { statSync: fsStatSync, mkdirSync: fsMkdirSync } = ${n}('fs');
463
+ const { join: pathJoin } = ${t}('path');
464
+ const { homedir: osHomedir } = ${t}('os');
465
+ const { statSync: fsStatSync, mkdirSync: fsMkdirSync } = ${t}('fs');
461
466
  // Prioritize ~/.tweakcc which is the original and default. Only respect
462
467
  // XDG_CONFIG_HOME if it doesn't exist.
463
468
  let dir;
@@ -487,7 +492,11 @@ function getTweakccBaseDir() {
487
492
  }
488
493
 
489
494
  const findSummaryEntryForLeafUuid = (filePath, messageUuid) => {
490
- const { readFileSync: fsReadFileSync } = ${n}('fs');
495
+ const { readFileSync: fsReadFileSync, statSync: fsStatSync } = ${t}('fs');
496
+ // Optimization: skip files that are certain to not be tweakcc summary files (which only contain 1 small line).
497
+ if (fsStatSync(filePath).size > 1000) {
498
+ return null;
499
+ }
491
500
  const lines = fsReadFileSync(filePath, "utf8")
492
501
  .split("\\n")
493
502
  .map((l) => JSON.parse(l.trim()));
@@ -504,8 +513,8 @@ const getSummaryFileForLeafMessage = (
504
513
  projectSlug,
505
514
  messageUuid
506
515
  ) => {
507
- const { join: pathJoin } = ${n}('path');
508
- const { readFileSync: fsReadFileSync, readdirSync: fsReaddirSync } = ${n}('fs');
516
+ const { join: pathJoin } = ${t}('path');
517
+ const { readFileSync: fsReadFileSync, readdirSync: fsReaddirSync } = ${t}('fs');
509
518
  try {
510
519
  // File contains the uuid
511
520
  const summaryFileId = fsReadFileSync(
@@ -541,9 +550,9 @@ const setTerminalTitleOverride = (title) => {
541
550
 
542
551
  let CUR_CONVERSATION_TITLE = "";
543
552
  function onNewMessage(projectDir, projectSlug, msg) {
544
- const { join: pathJoin } = ${n}('path');
545
- const { readFileSync: fsReadFileSync, writeFileSync: fsWriteFileSync, mkdirSync: fsMkdirSync, renameSync: fsRenameSync } = ${n}('fs');
546
- const { randomUUID: cryptoRandomUUID } = ${n}('crypto');
553
+ const { join: pathJoin } = ${t}('path');
554
+ const { readFileSync: fsReadFileSync, writeFileSync: fsWriteFileSync, mkdirSync: fsMkdirSync, renameSync: fsRenameSync } = ${t}('fs');
555
+ const { randomUUID: cryptoRandomUUID } = ${t}('crypto');
547
556
  const tweakcc = getTweakccBaseDir();
548
557
 
549
558
  if (msg.parentUuid) {
@@ -623,13 +632,13 @@ function onNewMessage(projectDir, projectSlug, msg) {
623
632
  }
624
633
  }
625
634
 
626
- `,r=e.slice(0,t)+o+e.slice(t);return G(e,r,o,t,t),r},mr=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}},pr=e=>{const t=mr(e);if(!t)return console.error("patch: conversationTitle: failed to find append entry interceptor location"),null;const n=hn(e),{location:o,messageVar:r}=t,i=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
635
+ `,i=e.slice(0,n)+r+e.slice(n);return Y(e,i,r,n,n),i},so=e=>{const n=/(if\(![$\w]+\.has\(([$\w]+)\.uuid\)\)\{)if\([$\w]+\.appendFileSync\(/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: conversationTitle: findAppendEntryInterceptorLocation: failed to find pattern"),null;const r=t.index+t[1].length,i=t[2];return{location:r,messageVar:i}},lo=e=>{const n=so(e);if(!n)return console.error("patch: conversationTitle: failed to find append entry interceptor location"),null;const t=vt(e),{location:r,messageVar:i}=n,o=`const { dirname: pathDirname, basename: pathBasename } = ${t}('path');
627
636
  const projectDir = pathDirname(this.sessionFile);
628
637
  const projectSlug = pathBasename(projectDir);
629
- onNewMessage(projectDir, projectSlug, ${r});
630
- `,a=e.slice(0,o)+i+e.slice(o);return G(e,a,i,o,o),a},br=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}},wr=e=>{const t=br(e);if(!t)return console.error("patch: conversationTitle: failed to find tweakcc summary check locations"),null;const n=hn(e),{orLocation:o,loopLocation:r,messageVar:i,fileListVar:a}=t;let l=e;const u=`const { readFileSync: fsReadFileSync } = ${n}('fs');
638
+ onNewMessage(projectDir, projectSlug, ${i});
639
+ `,l=e.slice(0,r)+o+e.slice(r);return Y(e,l,o,r,r),l},ao=e=>{const n=/if\([$\w]+\.has\(([$\w]+)\.uuid\)\)continue;/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find continue pattern"),null;const r=t[1],i=t.index+t[0].length-10,o=Math.max(0,t.index-200),l=e.substring(o,t.index),c=/for\(let [$\w]+ of ([$\w]+)\)try/,u=l.match(c);if(!u)return console.error("patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find loop pattern"),null;const d=u[1],g=o+(u.index??0);return{orLocation:i,loopLocation:g,messageVar:r,fileListVar:d}},co=e=>{const n=ao(e);if(!n)return console.error("patch: conversationTitle: failed to find tweakcc summary check locations"),null;const t=vt(e),{orLocation:r,loopLocation:i,messageVar:o,fileListVar:l}=n;let c=e;const u=`const { readFileSync: fsReadFileSync } = ${t}('fs');
631
640
  const tweakccSummaries = new Set();
632
- for (const file of ${a}) {
641
+ for (const file of ${l}) {
633
642
  const contents = fsReadFileSync(file, "utf8").trim();
634
643
  if (contents.includes("\\n")) continue;
635
644
  let obj;
@@ -642,36 +651,43 @@ for (const file of ${a}) {
642
651
  if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
643
652
  tweakccSummaries.add(obj.leafUuid);
644
653
  }
645
- `;l=l.slice(0,r)+u+l.slice(r),G(e,l,u,r,r);const d=o+u.length,h=`||tweakccSummaries.has(${i}.uuid)`,f=l.slice(0,d)+h+l.slice(d);return G(l,f,h,d,d),f},xr=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):(G(e,i,r,n.index,n.index+63),i)},yr=e=>{let t=e;if(t=hr(t),!t)return console.error("patch: conversationTitle: step 1 failed (writeTitleSlashCommand)"),null;if(t=fr(t),!t)return console.error("patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)"),null;if(t=pr(t),!t)return console.error("patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)"),null;if(t=wr(t),!t)return console.error("patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)"),null;const n=xr(t);return n?t=n:console.log("patch: conversationTitle: step 5 failed (enableRenameConversationCommand)"),t},G=(e,t,n,o,r)=>{if(!M())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),y=t.slice(o,o+n.length),b=t.slice(o+n.length,l);d!==y&&(console.log(`
646
- --- Diff ---`),console.log("OLD:",u+`\x1B[31m${d}\x1B[0m`+h),console.log("NEW:",f+`\x1B[32m${y}\x1B[0m`+b),console.log(`--- End Diff ---
647
- `))},fe=e=>e.replace(/\$/g,"\\$"),un=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},Sr=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]},et=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]},vr=e=>{const t=et(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=${fe(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 he=null,ke=null;const qe=e=>{if(he!=null)return he;const t=Sr(e);if(!t){console.log("^ patch: getReactVar: failed to find moduleLoader"),he=void 0;return}const n=et(e);if(!n){console.log("^ patch: getReactVar: failed to find reactModuleVarNonBun"),he=void 0;return}const o=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(n)}\\(\\),1\\)`),r=e.match(o);if(r)return he=r[1],he;const i=vr(e);if(!i){console.log("^ patch: getReactVar: failed to find reactModuleFunctionBun"),he=void 0;return}const a=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(i)}\\(\\),1\\)`),l=e.match(a);if(!l){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${i})`),he=void 0;return}return he=l[1],he},$r=e=>{const t=/import\{createRequire as ([$\w]+)\}from"node:module";/,n=e.match(t);if(!n)return;const o=n[1],r=new RegExp(`var ([$\\w]+)=${fe(o)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${o})`);return}return i[1]},hn=e=>{if(ke!=null)return ke;const t=$r(e);return t?(ke=t,ke):(ke="require",ke)},nt=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]},tt=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]+)=${fe(o)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${o})`);return}return i[1]},ot=async(e,t)=>{let n;if(t.nativeInstallationPath){await qn(t);let u=!1;try{await oe.stat(ge),u=!0}catch{}const d=u?ge:t.nativeInstallationPath;M()&&console.log(`Extracting claude.js from ${u?"backup":"native installation"}: ${d}`);const h=Yn(d);if(!h)throw new Error("Failed to extract claude.js from native installation");const f=re.join(ye.homedir(),".tweakcc"),y=re.join(f,"native-claudejs-orig.js");Ie.writeFileSync(y,h),M()&&console.log(`Saved original extracted JS from native to: ${y}`),n=h.toString("utf8")}else{if(await Jn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await oe.readFile(t.cliPath,{encoding:"utf8"})}const o=[],r=await Yo(n,t.version);n=r.newContent,o.push(...r.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=uo(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=Mo(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=xo(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=$o(n,e.settings.thinkingStyle.phases))&&(n=i),(i=Co(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=Eo(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=So(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=Oo(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=mo(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Ao(n))&&(n=i),(i=bo(n))&&(n=i),(i=go(n))&&(n=i),(i=Ir(n))&&(n=i),(i=ao(n,25))&&(n=i),(i=Do(n))&&(n=i);const a=e.settings.misc?.showTweakccVersion??!0,l=e.settings.misc?.showPatchesApplied??!0;if((i=Ho(n,"3.1.5",o,a,l))&&(n=i),(i=Jo(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=ur(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),e.settings.planModeToolset&&e.settings.defaultToolset&&((i=ar(n))&&(n=i),(i=dr(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=i)),(i=yr(n))&&(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");Ie.writeFileSync(d,n,"utf8"),M()&&console.log(`Saved patched JS from native to: ${d}`);const h=Buffer.from(n,"utf8");to(t.nativeInstallationPath,h,t.nativeInstallationPath)}else{if(!t.cliPath)throw new Error("cliPath is required for NPM installations");await fn(t.cliPath,n,"patch")}return await je(u=>{u.changesApplied=!0})},rt=[{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"}],_r=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}},Cr=e=>{const t=_r(e);if(!t)return null;const{insertionIndex:n,optionsVar:o}=t,r=rt.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 G(e,i,r,n,n),i},Ir=e=>{let t=e;const n=Cr(t);return n&&(t=n),t===e?null:t};let it=!1;const M=()=>it,Er=()=>{it=!0};function Ke(){try{const e=re.join(ye.homedir(),".claude.json");return JSON.parse(Ie.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function kr(){try{const e=re.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ie.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 Tr(){try{const e=re.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ie.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const o=rt.find(r=>r.slug===n);if(o)return o.label}catch{}return"Sonnet 4.5"}function Mr(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 kn(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=re.dirname(e);Me.spawn("xdg-open",[t],{detached:!0,stdio:"ignore"}).unref()}}function gn(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 st(e){if(!gn(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=(y,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?y+(b-y)*6*p:p<1/2?b:p<2/3?y+(b-y)*(2/3-p)*6:y),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 Nr(e,t="sha256",n=64*1024){return new Promise((o,r)=>{const i=An.createHash(t),a=Ie.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 Tn=(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 fn(e,t,n="replace"){let o=493;try{o=(await oe.stat(e)).mode,M()&&console.log(`[${n}] Original file mode for ${e}: ${(o&parseInt("777",8)).toString(8)}`)}catch(r){M()&&console.log(`[${n}] Could not stat ${e} (error: ${r}), using default mode 755`)}try{await oe.unlink(e),M()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(r){M()&&console.log(`[${n}] Could not unlink ${e}: ${r}`)}await oe.writeFile(e,t),await oe.chmod(e,o),M()&&console.log(`[${n}] Restored permissions to ${(o&parseInt("777",8)).toString(8)}`)}function U({color:e,backgroundColor:t,bold:n,dimColor:o,children:r}){const i=e?.startsWith("ansi:"),a=t?.startsWith("ansi:");if(i||a){if(Ze.Children.toArray(r).some(f=>Ze.isValidElement(f)))return s(c,{children:r});let u=H;if(i){const f=e.slice(5);u=u[f]||u}if(a){const f=t.slice(5),y=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[y]||u}n&&(u=u.bold),o&&(u=u.dim);const h=Ze.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 Or({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:o=3,updateDuration:r=50,restartPoint:i=10}){const[a,l]=P(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,y=h?n[f]:t[f];return s(c,{color:y,children:u},d)})})}const Br=ft.cwd();function lt({theme:e}){const{ccVersion:t}=be(ue);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(U,{color:e.colors.clawd_body,children:" ▐"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),g(c,{children:[s(U,{color:e.colors.clawd_body,children:"▌ "})," ",s(c,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),g(c,{children:[s(U,{color:e.colors.clawd_body,children:"▝▜"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(U,{color:e.colors.clawd_body,children:"▛▘"})," ",Tr()," · ",kr()]}),g(U,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",Br]}),g(c,{children:[g(U,{color:e.colors.success,children:["Login successful. Press"," "]}),s(U,{bold:!0,color:e.colors.success,children:"Enter"}),g(U,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(c,{children:"╭─────────────────────────────────────────────╮"}),g(c,{children:["│ 1 function greet() ","{"," ","│"]}),g(c,{children:["│ 2"," ",s(U,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(U,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(U,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),g(c,{children:["│ 2"," ",s(U,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(U,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(U,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(U,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),g(U,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),g(c,{children:[s(U,{color:e.colors.warning,children:"│ "}),s(c,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),g(U,{color:e.colors.warning,children:[" ","│"]})]}),s(U,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),g(c,{children:[s(U,{color:e.colors.bashBorder,children:"!"}),s(c,{children:" ls"})]}),s(U,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(c,{children:g(c,{children:["> list the dir"," ",s(Or,{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(U,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(U,{color:e.colors.planMode,children:"│ "}),g(U,{color:e.colors.permission,children:["Ready to code?"," "]}),s(c,{children:"Here is Claude's plan:"}),g(U,{color:e.colors.planMode,children:[" ","│"]})]}),s(U,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(U,{color:e.colors.permission,children:"│ "}),s(c,{bold:!0,children:"Permissions:"})," ",g(U,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(U,{color:e.colors.permission,children:"│"})]}),s(c,{children:"> list the dir"}),g(c,{children:[s(U,{color:e.colors.error,children:"●"}),s(c,{children:" Update(__init__.py)"})]}),g(c,{children:[s(c,{children:" ⎿ "}),s(U,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),g(c,{children:[" ","1"," ",g(U,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(U,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),g(c,{children:[" ","2"," ",g(U,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(U,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),g(c,{children:[s(U,{color:e.colors.success,children:"●"}),s(c,{children:" List(.)"})]}),g(c,{children:[s(c,{children:"●"}),s(c,{children:" The directory "}),s(U,{color:e.colors.permission,children:"C:\\Users\\user"}),g(c,{children:[" ","contains ",s(c,{bold:!0,children:"123"})," files."]})]}),g(c,{children:[s(U,{color:e.colors.claude,children:"✻ Th"}),s(U,{color:e.colors.claudeShimmer,children:"ink"}),s(U,{color:e.colors.claude,children:"ing… "}),s(c,{children:"(esc to interrupt)"})]}),s(c,{children:s(U,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(c,{children:s(U,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(c,{children:s(U,{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(U,{color:o,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(U,{backgroundColor:o,bold:n,color:t.colors.text,children:e}):s(U,{color:o,bold:n,children:e})}function at({initialValue:e,onColorChange:t,onExit:n,colorKey:o,theme:r}){const i=nn(e)||{h:0,s:50,l:50},a=en(e)||{r:128,g:128,b:128},[l,u]=P(i),[d,h]=P(a),[f,y]=P("hsl"),[b,p]=P("h"),[w,S]=P(!1),[E,x]=P(!1);xe(()=>{const C=nn(e),_=en(e);C&&_&&(S(!0),u(C),h(_),S(!1))},[e]),xe(()=>{if(!w&&E){const C=`rgb(${d.r},${d.g},${d.b})`;t(C)}},[l,d,w,E]),xe(()=>{x(!0)},[]);const k=C=>{if(gn(C)){const _=st(C),$=nn(_),A=en(_);$&&A&&(S(!0),u($),h(A),S(!1))}};de((C,_)=>{if(C.length>1&&!_.ctrl&&!_.meta){k(C);return}if(_.return)n();else if(_.escape)n();else if(_.ctrl&&C==="a")y($=>$==="hsl"?"rgb":"hsl"),p($=>f==="hsl"?$==="h"?"r":$==="s"?"g":"b":$==="r"?"h":$==="g"?"s":"l");else if(_.upArrow)p(f==="hsl"?$=>$==="h"?"l":$==="s"?"h":"s":$=>$==="r"?"b":$==="g"?"r":"g");else if(_.downArrow||_.tab)p(f==="hsl"?$=>$==="h"?"s":$==="s"?"l":"h":$=>$==="r"?"g":$==="g"?"b":"r");else if(_.leftArrow){const $=_.shift||_.ctrl||_.meta?-10:-1;D($)}else if(_.rightArrow){const $=_.shift||_.ctrl||_.meta?10:1;D($)}});const D=C=>{S(!0),f==="hsl"?u(_=>{const $={..._};b==="h"?$.h=Math.max(0,Math.min(359,_.h+C)):b==="s"?$.s=Math.max(0,Math.min(100,_.s+C)):b==="l"&&($.l=Math.max(0,Math.min(100,_.l+C)));const[A,v,R]=N($.h,$.s,$.l);return h({r:A,g:v,b:R}),$}):h(_=>{const $={..._};b==="r"?$.r=Math.max(0,Math.min(255,_.r+C)):b==="g"?$.g=Math.max(0,Math.min(255,_.g+C)):b==="b"&&($.b=Math.max(0,Math.min(255,_.b+C)));const A=O($.r,$.g,$.b);return u(A),$}),S(!1)},O=(C,_,$)=>{const A=C/255,v=_/255,R=$/255,K=Math.max(A,v,R),J=Math.min(A,v,R),te=K-J,se=(K+J)/2;let $e=0;te!==0&&($e=se>.5?te/(2-K-J):te/(K+J));let we=0;return te!==0&&(K===A?we=((v-R)/te+(v<R?6:0))/6:K===v?we=((R-A)/te+2)/6:we=((A-v)/te+4)/6),{h:Math.round(we*360),s:Math.round($e*100),l:Math.round(se*100)}},N=(C,_,$)=>{C/=360,_/=100,$/=100;const A=(1-Math.abs(2*$-1))*_,v=A*(1-Math.abs(C*6%2-1)),R=$-A/2;let K=0,J=0,te=0;return 0<=C&&C<1/6?(K=A,J=v,te=0):1/6<=C&&C<2/6?(K=v,J=A,te=0):2/6<=C&&C<3/6?(K=0,J=A,te=v):3/6<=C&&C<4/6?(K=0,J=v,te=A):4/6<=C&&C<5/6?(K=v,J=0,te=A):5/6<=C&&C<1&&(K=A,J=0,te=v),[Math.round((K+R)*255),Math.round((J+R)*255),Math.round((te+R)*255)]},j=()=>{const C=[],_=[[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 $=0;$<40;$++){const v=$/39*(_.length-1),R=Math.floor(v),K=Math.ceil(v),J=v-R,[te,se,$e]=_[R],[we,Y,V]=_[K],F=Math.round(te+(we-te)*J),ne=Math.round(se+(Y-se)*J),X=Math.round($e+(V-$e)*J);C.push(s(c,{backgroundColor:`rgb(${F},${ne},${X})`,children:" "},$))}return C},L=()=>{const C=[];for(let _=0;_<40;_++){const $=_/39*100,[A,v,R]=N(l.h,$,l.l);C.push(s(c,{backgroundColor:`rgb(${A},${v},${R})`,children:" "},_))}return C},B=()=>{const C=[];for(let _=0;_<40;_++){const $=_/39*100,[A,v,R]=N(l.h,l.s,$);C.push(s(c,{backgroundColor:`rgb(${A},${v},${R})`,children:" "},_))}return C},T=()=>{const[C,_,$]=N(l.h,l.s,l.l);return`rgb(${C},${_},${$})`},I=(C,_,$)=>{const A=v=>v.toString(16).padStart(2,"0");return`#${A(C)}${A(_)}${A($)}`},z=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${$},${d.g},${d.b})`,children:" "},_))}return C},W=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${d.r},${$},${d.b})`,children:" "},_))}return C},Q=()=>{const C=[];for(let _=0;_<40;_++){const $=Math.round(_/39*255);C.push(s(c,{backgroundColor:`rgb(${d.r},${d.g},${$})`,children:" "},_))}return C},q=(C,_)=>Math.round(C/_*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(me,{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:j().map((C,_)=>s(Ee,{children:_===q(l.h,360)?s(c,{children:"|"}):C},_))})]}),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:L().map((C,_)=>s(Ee,{children:_===q(l.s,100)?s(c,{children:"|"}):C},_))})]}),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:B().map((C,_)=>s(Ee,{children:_===q(l.l,100)?s(c,{children:"|"}):C},_))})]})]}):g(me,{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:z().map((C,_)=>s(Ee,{children:_===q(d.r,255)?s(c,{children:"|"}):C},_))})]}),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:W().map((C,_)=>s(Ee,{children:_===q(d.g,255)?s(c,{children:"|"}):C},_))})]}),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:Q().map((C,_)=>s(Ee,{children:_===q(d.b,255)?s(c,{children:"|"}):C},_))})]})]}),g(m,{marginBottom:1,children:[s(c,{children:"Current: "}),s(c,{backgroundColor:T(),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:T(),color:r?.colors?.text||"white",bold:!0,children:I(d.r,d.g,d.b)}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:I(d.r,d.g,d.b)}):s(c,{color:T(),bold:!0,children:I(d.r,d.g,d.b)})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"RGB "}),o?.startsWith("diff")?s(c,{backgroundColor:T(),color:r?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(c,{color:T(),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:T(),color:r?.colors?.text||"white",bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):o==="inverseText"?s(c,{color:T(),backgroundColor:r?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):s(c,{color:T(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function en(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 nn(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 y=0;return d!==0&&(l===r?y=((i-a)/d+(i<a?6:0))/6:l===i?y=((a-r)/d+2)/6:y=((r-i)/d+4)/6),{h:Math.round(y*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 y=0;h!==0&&(y=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(y*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function Ar({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:o}=be(ue),[r,i]=P(t),a=n.find(B=>B.id===r)||n[0],[l,u]=P("rgb"),[d,h]=P(0),[f,y]=P(null),[b,p]=P(null),[w,S]=P(""),[E,x]=P(""),k=Nn(B=>{o(T=>{const I=T.themes.findIndex(z=>z.id===r);I!==-1&&B(T.themes[I])})},[r,o]),D=B=>{if(d>=2&&gn(B)){const T=st(B),I=d-2,z=O[I];k(W=>{W.colors[z]=T})}};de((B,T)=>{if(f===null&&b===null){if(B.length>1&&!T.ctrl&&!T.meta){D(B);return}if(T.escape)e();else if(T.ctrl&&B==="a")u(I=>I==="rgb"?"hex":I==="hex"?"hsl":"rgb");else if(T.upArrow)h(I=>Math.max(0,I-1));else if(T.downArrow)h(I=>Math.min(O.length+1,I+1));else if(T.return)if(d===0)p("name"),S(a.name),x(a.name);else if(d===1)p("id"),S(a.id),x(a.id);else{const I=d-2,z=O[I],W=a.colors[z];y(I),S(W),x(W)}}else if(f!==null)T.ctrl&&B==="a"&&u(I=>I==="rgb"?"hex":I==="hex"?"hsl":"rgb");else if(b!==null)if(T.return){if(b==="id"){const I=r;i(w),o(z=>{const W=z.themes.findIndex(Q=>Q.id===I);W!==-1&&(z.themes[W].id=w)})}else k(I=>{I.name=w});p(null),S(""),x("")}else T.escape?(p(null),S(""),x("")):T.backspace||T.delete?S(I=>I.slice(0,-1)):B&&S(I=>I+B)});const O=Object.keys(a.colors),N=(B,T)=>{const I=B.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!I)return B;const z=parseInt(I[1]),W=parseInt(I[2]),Q=parseInt(I[3]);switch(T){case"hex":{const q=C=>C.toString(16).padStart(2,"0");return`#${q(z)}${q(W)}${q(Q)}`}case"hsl":{const q=z/255,C=W/255,_=Q/255,$=Math.max(q,C,_),A=Math.min(q,C,_),v=$-A,R=($+A)/2;let K=0;v!==0&&(K=R>.5?v/(2-$-A):v/($+A));let J=0;return v!==0&&($===q?J=((C-_)/v+(C<_?6:0))/6:$===C?J=((_-q)/v+2)/6:J=((q-C)/v+4)/6),`hsl(${Math.round(J*360)}, ${Math.round(K*100)}%, ${Math.round(R*100)}%)`}case"rgb":default:return B}},j=B=>({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"})[B]||"",L=Math.max(...O.map(B=>B.length));return g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{children:g(pe,{children:["Editing theme “",a.name,"” (",a.id,")"]})}),f===null&&b===null?g(me,{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[O[d-2]],flexDirection:"column",paddingLeft:1,children:[s(Qe,{colorKey:O[d-2],theme:a,bold:!0}),s(c,{children:j(O[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=O.slice(0,20);return g(me,{children:[q.map((C,_)=>{const $=_+2;return g(m,{children:[s(c,{color:d===$?"yellow":"white",children:d===$?"❯ ":" "}),s(m,{width:L+2,children:s(c,{children:s(Qe,{colorKey:C,theme:a,bold:!0})})}),s(U,{color:a.colors[C],children:N(a.colors[C],l)})]},C)}),O.length>20&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-20," more below"]})]})}const T=d-2,I=Math.max(0,T-Math.floor(20/2)),z=Math.min(O.length,I+20),W=Math.max(0,z-20),Q=O.slice(W,z);return g(me,{children:[W>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",W," more above"]}),Q.map((q,C)=>{const $=W+C+2;return g(m,{children:[s(c,{color:d===$?"yellow":"white",children:d===$?"❯ ":" "}),s(m,{width:L+2,children:s(c,{children:s(Qe,{colorKey:q,theme:a,bold:!0})})}),s(U,{color:a.colors[q],children:N(a.colors[q],l)})]},q)}),z<O.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-z," 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(at,{initialValue:E,colorKey:O[f],theme:a,onColorChange:B=>{S(B),k(T=>{T.colors[O[f]]=B})},onExit:()=>{k(B=>{B.colors[O[f]]=w}),y(null),S(""),x("")}})]}),s(m,{width:"50%",children:s(lt,{theme:a})})]})}function Pr(e){return e.map(t=>`${t.name} (${t.id})`)}function Lr({onBack:e}){const{settings:{themes:t},updateSettings:n}=be(ue),[o,r]=P(0),[i,a]=P(null),[l,u]=P(!0),d=()=>{const w={colors:{...(t[0]||ee.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(S=>{S.themes.push(w)}),a(w.id),u(!1)},h=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(S=>S.id!==p)}),o>=t.length-1&&r(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...ee.themes]}),r(0)};if(de((p,w)=>{if(w.escape)e();else if(w.upArrow)r(S=>Math.max(0,S-1));else if(w.downArrow)r(S=>Math.min(t.length-1,S+1));else if(w.return){const S=t[o];S&&(a(S.id),u(!1))}else if(p==="n")d();else if(p==="d"){const S=t[o];S&&h(S.id)}else w.ctrl&&p==="r"&&f()},{isActive:l}),i)return s(Ar,{themeId:i,onBack:()=>{a(null),u(!0)}});const y=Pr(t),b=t.find(p=>y[o]?.includes(`(${p.id})`))||t[0];return t.length===0?s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[s(pe,{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(pe,{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:y.map((p,w)=>g(c,{color:o===w?"yellow":void 0,children:[o===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(lt,{theme:b})})]})}function Dr({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:o},updateSettings:r}=be(ue),i=["format","verbs"],[a,l]=P(0),u=i[a],[d,h]=P(0),[f,y]=P(!1),[b,p]=P(""),[w,S]=P(!1),[E,x]=P(!1),[k,D]=P(t),O=Ke(),j=(o.find(B=>B.id===O)||o.find(B=>B.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((B,T)=>{if(E){T.return?(r(I=>{I.thinkingVerbs.format=k}),x(!1)):T.escape?(D(t),x(!1)):T.backspace||T.delete?D(I=>I.slice(0,-1)):B&&D(I=>I+B);return}if(f||w){T.return&&b.trim()?(w?(r(I=>{I.thinkingVerbs.verbs.push(b.trim())}),S(!1)):(r(I=>{I.thinkingVerbs.verbs[d]=b.trim()}),y(!1)),p("")):T.escape?(p(""),y(!1),S(!1)):T.backspace||T.delete?p(I=>I.slice(0,-1)):B&&p(I=>I+B);return}T.escape?e():T.return?u==="format"&&(D(t),x(!0)):T.tab?T.shift?l(I=>I===0?i.length-1:I-1):l(I=>I===i.length-1?0:I+1):T.upArrow?u==="verbs"&&n.length>0&&h(I=>I>0?I-1:n.length-1):T.downArrow?u==="verbs"&&n.length>0&&h(I=>I<n.length-1?I+1:0):B==="e"&&u==="verbs"?n.length>0&&(p(n[d]),y(!0)):B==="d"&&u==="verbs"?n.length>1&&(r(I=>{I.thinkingVerbs.verbs=I.thinkingVerbs.verbs.filter((z,W)=>W!==d)}),d>=n.length-1&&h(Math.max(0,n.length-2))):B==="n"&&u==="verbs"?(S(!0),p("")):T.ctrl&&B==="r"&&u==="verbs"&&(r(I=>{I.thinkingVerbs.verbs=[...ee.thinkingVerbs.verbs]}),h(0))});const L=50;return g(m,{children:[g(m,{flexDirection:"column",width:`${100-L}%`,children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(pe,{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"&&(E?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:E?"yellow":"gray",children:s(c,{children:E?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 T=Math.max(0,d-Math.floor(4)),I=Math.min(n.length,T+8),z=Math.max(0,I-8),W=n.slice(z,I);return g(me,{children:[z>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",z," more above"]}),W.map((Q,q)=>{const C=z+q;return g(c,{color:u==="verbs"&&C===d?"cyan":void 0,children:[u==="verbs"&&C===d?"❯ ":" ",Q]},C)}),I<n.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-I," 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:`${L}%`,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:j,children:["✻ ",t.replace(/\{\}/g,n[d])," "]}),s(c,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:ee.thinkingStyle.phases,reverseMirror:ee.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 Rr({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:o},themes:r},updateSettings:i}=be(ue),a=["reverseMirror","updateInterval","phases","presets"],[l,u]=P(0),d=a[l],[h,f]=P(0),[y,b]=P(0),[p,w]=P(!1),[S,E]=P(""),[x,k]=P(!1),[D,O]=P(!1),[N,j]=P(n.toString()),[L,B]=P(0),T=Ke(),z=(r.find($=>$.id===T)||r.find($=>$.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const $=o?[...t,...[...t].reverse().slice(1,-1)]:t,A=setInterval(()=>{B(v=>(v+1)%$.length)},n);return()=>clearInterval(A)}},[t,n,o]),de(($,A)=>{if(D){if(A.return){const v=parseInt(N);!isNaN(v)&&v>0&&i(R=>{R.thinkingStyle.updateInterval=v}),O(!1)}else A.escape?(j(n.toString()),O(!1)):A.backspace||A.delete?j(v=>v.slice(0,-1)):$&&$.match(/^[0-9]$/)&&j(v=>v+$);return}if(p||x){if(A.return&&S.length){const v=x?[...t,S]:t.map((R,K)=>K===h?S:R);i(R=>{R.thinkingStyle.phases=v}),w(!1),E("")}else A.escape?(E(""),w(!1),k(!1)):A.backspace||A.delete?E(v=>v.slice(0,-1)):$&&E(v=>v+$);return}if(A.escape)e();else if(A.return)if(d==="updateInterval")j(n.toString()),O(!0);else if(d==="presets"){const v=_e[y];i(R=>{R.thinkingStyle.phases=[...v.phases],R.thinkingStyle.reverseMirror=v.reverseMirror})}else d==="reverseMirror"&&i(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if(A.tab)A.shift?u(v=>v===0?a.length-1:v-1):u(v=>v===a.length-1?0:v+1);else if(A.upArrow)d==="phases"&&t.length>0?f(v=>v>0?v-1:t.length-1):d==="presets"&&b(v=>v>0?v-1:_e.length-1);else if(A.downArrow)d==="phases"&&t.length>0?f(v=>v<t.length-1?v+1:0):d==="presets"&&b(v=>v<_e.length-1?v+1:0);else if($===" ")d==="reverseMirror"&&i(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if($==="e"&&d==="phases")t.length>0&&(E(t[h]),w(!0));else if($==="a"&&d==="phases")k(!0),E("");else if($==="d"&&d==="phases")t.length>1&&(i(v=>{v.thinkingStyle.phases=t.filter((R,K)=>K!==h)}),h>=t.length&&f(Math.max(0,t.length-1)));else if($==="w"&&d==="phases"){if(h>0){const v=[...t];[v[h-1],v[h]]=[v[h],v[h-1]],i(R=>{R.thinkingStyle.phases=v}),f(R=>R-1)}}else if($==="s"&&d==="phases"){if(h<t.length-1){const v=[...t];[v[h],v[h+1]]=[v[h+1],v[h]],i(R=>{R.thinkingStyle.phases=v}),f(R=>R+1)}}else A.ctrl&&$==="r"&&(i(v=>{v.thinkingStyle=ee.thinkingStyle}),f(0),b(0))});const W=o?"●":"○",Q=50,C=o?[...t,...[...t].reverse().slice(1,-1)]:t,_=C.length>0?C[L]:"·";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-Q}%`,children:[s(pe,{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:`${Q}%`,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:z,children:_})}),g(c,{children:[s(c,{color:z,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:[W," ",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"&&(D?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:D?"yellow":"gray",children:s(c,{children:D?N: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 A=Math.max(0,h-Math.floor(4)),v=Math.min(t.length,A+8),R=Math.max(0,v-8),K=t.slice(R,v);return g(me,{children:[R>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",R," more above"]}),K.map((J,te)=>{const se=R+te;return g(c,{color:d==="phases"&&se===h?"cyan":void 0,children:[d==="phases"&&se===h?"❯ ":" ",J]},se)}),v<t.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-v," more below"]})]})})(),x&&g(m,{children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:S})})]}),p&&g(m,{marginTop:1,children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:S})})]})]})}),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 A=Math.max(0,y-Math.floor(4)),v=Math.min(_e.length,A+8),R=Math.max(0,v-8),K=_e.slice(R,v);return g(me,{children:[R>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",R," more above"]}),K.map((J,te)=>{const se=R+te;return g(c,{color:d==="presets"&&se===y?"cyan":void 0,children:[d==="presets"&&se===y?"❯ ":" ",J.name," ",J.phases.join("")]},se)}),v<_e.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-v," more below"]})]})})()})}),s(m,{marginTop:1,children:s(c,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const De=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function Fr({onBack:e}){const{settings:t,updateSettings:n}=be(ue),[o,r]=P("prefix"),[i,a]=P(0),[l,u]=P(!1),[d,h]=P(()=>t.userMessageDisplay.prefix.format),[f,y]=P(0),[b,p]=P(()=>[...t.userMessageDisplay.prefix.styling]),[w,S]=P(()=>t.userMessageDisplay.prefix.foreground_color),[E,x]=P(()=>t.userMessageDisplay.prefix.background_color),[k,D]=P(0),[O,N]=P(0),[j,L]=P(()=>[...t.userMessageDisplay.message.styling]),[B,T]=P(()=>t.userMessageDisplay.message.foreground_color),[I,z]=P(()=>t.userMessageDisplay.message.background_color),[W,Q]=P(null),[q,C]=P(""),_=Ke(),$=t.themes?.find(Y=>Y.id===_)||t.themes?.[0],A=["format","styling","foreground","background"],v=["styling","foreground","background"],R=A[i],K=v[k],J=(Y,V)=>{n(F=>{const ne=Y==="prefix"?F.userMessageDisplay.prefix:F.userMessageDisplay.message;V(ne)})},te=Y=>{n(V=>{Y==="prefix"?V.userMessageDisplay.prefix={...ee.userMessageDisplay.prefix}:V.userMessageDisplay.message={...ee.userMessageDisplay.message}}),Y==="prefix"?(h(ee.userMessageDisplay.prefix.format),p([...ee.userMessageDisplay.prefix.styling]),S(ee.userMessageDisplay.prefix.foreground_color),x(ee.userMessageDisplay.prefix.background_color)):(L([...ee.userMessageDisplay.message.styling]),T(ee.userMessageDisplay.message.foreground_color),z(ee.userMessageDisplay.message.background_color))};xe(()=>{const Y=t.userMessageDisplay.prefix;h(Y.format),p([...Y.styling]),S(Y.foreground_color),x(Y.background_color);const V=t.userMessageDisplay.message;L([...V.styling]),T(V.foreground_color),z(V.background_color)},[]),de((Y,V)=>{if(l){if(V.return)J("prefix",F=>{F.format=d}),u(!1);else if(V.escape){const F=t.userMessageDisplay.prefix;h(F.format),u(!1)}else V.backspace||V.delete?h(F=>F.slice(0,-1)):Y&&h(F=>F+Y);return}if(W===null){if(V.escape)e();else if(V.ctrl&&Y==="r")te(o);else if(V.leftArrow||V.rightArrow)r(F=>F==="prefix"?"message":"prefix");else if(V.tab)o==="prefix"?V.shift?a(F=>F===0?A.length-1:F-1):a(F=>F===A.length-1?0:F+1):V.shift?D(F=>F===0?v.length-1:F-1):D(F=>F===v.length-1?0:F+1);else if(V.return)o==="prefix"?R==="format"?u(!0):R==="foreground"?(C(w),Q({column:"prefix",type:"foreground"})):R==="background"&&(C(E),Q({column:"prefix",type:"background"})):K==="foreground"?(C(B),Q({column:"message",type:"foreground"})):K==="background"&&(C(I),Q({column:"message",type:"background"}));else if(V.upArrow)o==="prefix"&&R==="styling"?y(F=>Math.max(0,F-1)):o==="message"&&K==="styling"&&N(F=>Math.max(0,F-1));else if(V.downArrow)o==="prefix"&&R==="styling"?y(F=>Math.min(De.length-1,F+1)):o==="message"&&K==="styling"&&N(F=>Math.min(De.length-1,F+1));else if(Y===" "){if(o==="prefix"&&R==="styling"){const F=De[f].value,ne=b.indexOf(F)>=0?b.filter(X=>X!==F):[...b,F];p(ne),J("prefix",X=>{X.styling=[...ne]})}else if(o==="message"&&K==="styling"){const F=De[O].value,ne=j.indexOf(F)>=0?j.filter(X=>X!==F):[...j,F];L(ne),J("message",X=>{X.styling=[...ne]})}}}});const se=(Y,V,F=!0)=>{const ne=F?V==="prefix"?b:j:[],X=F?V==="prefix"?w:B:"rgb(255,255,255)",Ae=F?V==="prefix"?E:I:"rgb(0,0,0)",Pe=X==="rgb(0,0,0)"&&Ae==="rgb(0,0,0)",Ue=ne.length>0;return Pe&&!Ue?s(c,{children:Y}):s(c,{bold:ne.includes("bold"),italic:ne.includes("italic"),underline:ne.includes("underline"),strikethrough:ne.includes("strikethrough"),inverse:ne.includes("inverse"),color:Pe?void 0:X,backgroundColor:Pe?void 0:Ae,children:Y})},$e=(Y=!0)=>g(c,{children:[d&&g(me,{children:[se(d,"prefix",Y)," "]}),se("list the dir","message",Y)]}),we=Y=>{const V=o===Y,X=(Y==="prefix"?A:v)[Y==="prefix"?i:k],Ae=Y==="prefix"?f:O,Pe=Y==="prefix"?b:j,Ue=Y==="prefix"?w:B,mn=Y==="prefix"?E:I;return g(m,{flexDirection:"column",width:"45%",borderStyle:V?"round":"single",borderColor:V?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,color:V?"yellow":void 0,children:[Y.charAt(0).toUpperCase()+Y.slice(1)," ","Configuration"]})}),Y==="prefix"&&g(me,{children:[s(m,{children:g(c,{color:V&&X==="format"?"yellow":void 0,bold:V&&X==="format",children:[V&&X==="format"?"❯ ":" ","Prefix Text"]})}),V&&X==="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:V&&X==="styling"?"yellow":void 0,bold:V&&X==="styling",children:[V&&X==="styling"?"❯ ":" ","Styling"]})}),V&&X==="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:De.map((Xe,pn)=>s(m,{children:g(c,{color:V&&X==="styling"&&Ae===pn?"cyan":void 0,children:[V&&X==="styling"&&Ae===pn?"❯ ":" ",Pe.includes(Xe.value)?"●":"○"," ",Xe.label]})},Xe.value))}),s(m,{children:g(c,{color:V&&X==="foreground"?"yellow":void 0,bold:V&&X==="foreground",children:[V&&X==="foreground"?"❯ ":" ","Foreground color"]})}),V&&X==="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:g(c,{color:V&&X==="background"?"yellow":void 0,bold:V&&X==="background",children:[V&&X==="background"?"❯ ":" ","Background color"]})}),V&&X==="background"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(c,{backgroundColor:mn,children:mn})})]})};if(W){const{column:Y,type:V}=W;return s(at,{initialValue:q,theme:$,onColorChange:F=>{Y==="prefix"?V==="foreground"?(S(F),J("prefix",ne=>{ne.foreground_color=F})):(x(F),J("prefix",ne=>{ne.background_color=F})):V==="foreground"?(T(F),J("message",ne=>{ne.foreground_color=F})):(z(F),J("message",ne=>{ne.background_color=F}))},onExit:()=>{Q(null),C("")}})}return g(m,{flexDirection:"column",children:[s(pe,{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:[we("prefix"),we("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:$?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:$?.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:$?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:$?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]})]})]})})]})}function Vr({onSubmit:e}){const{settings:t,updateSettings:n}=be(ue),[o,r]=P(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})};de((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?"☑":"☐",y=t.misc?.expandThinkingBlocks?"☑":"☐";return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(pe,{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:[y," ",t.misc?.expandThinkingBlocks?"Enabled":"Disabled"]})})]})}const He=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","ExitPlanMode"];function jr({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:o}=be(ue),r=n.toolsets[e],[i,a]=P(r?.name||"New Toolset"),[l,u]=P(r?.allowedTools||[]),[d,h]=P(!1),[f,y]=P(0);xe(()=>{r&&o(E=>{const x=E.toolsets[e].name;E.toolsets[e].name=i,E.toolsets[e].allowedTools=l,x!==i&&(E.defaultToolset===x&&(E.defaultToolset=i),E.planModeToolset===x&&(E.planModeToolset=i))})},[i,l]);const b=E=>l==="*"?!0:l.includes(E),p=E=>{E==="All"?u("*"):E==="None"?u([]):l==="*"?u(He.filter(x=>x!==E)):l.includes(E)?u(l.filter(x=>x!==E)):u([...l,E])};if(de((E,x)=>{if(d){x.return?h(!1):x.escape?(a(r?.name||"New Toolset"),h(!1)):x.backspace||x.delete?a(k=>k.slice(0,-1)):E&&E.length===1&&a(k=>k+E);return}if(x.escape)t();else if(x.upArrow)y(k=>Math.max(0,k-1));else if(x.downArrow)y(k=>Math.min(He.length+1,k+1));else if(E===" "||x.return)if(f===0)p("All");else if(f===1)p("None");else{const k=He[f-2];k&&p(k)}else E==="n"&&h(!0)}),!r)return s(m,{flexDirection:"column",children:s(c,{color:"red",children:"Toolset not found"})});const w=l==="*",S=Array.isArray(l)&&l.length===0;return g(m,{flexDirection:"column",children:[s(pe,{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?"❯ ":" ",S?"●":"○"," None"]})}),He.map((E,x)=>{const k=x+2;return s(m,{marginLeft:2,children:g(c,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(E)?"◉":"○"," ",E]})},E)})]}),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 Ur({onBack:e}){const{settings:{toolsets:t,defaultToolset:n,planModeToolset:o,themes:r},updateSettings:i}=be(ue),a=Ke(),l=r.find(N=>N.id===a)||r[0],u=ee.themes[0],d=l?.colors.planMode||u.colors.planMode,h=l?.colors.autoAccept||u.colors.autoAccept,[f,y]=P(0),[b,p]=P(null),[w,S]=P(!0),E=()=>{const N={name:"New Toolset",allowedTools:[]};i(j=>{j.toolsets.push(N)}),p(t.length),S(!1)},x=N=>{const j=t[N];i(L=>{L.toolsets.splice(N,1),L.defaultToolset===j.name&&(L.defaultToolset=null),L.planModeToolset===j.name&&(L.planModeToolset=null)}),f>=t.length-1&&y(Math.max(0,t.length-2))},k=N=>{const j=t[N];i(L=>{L.defaultToolset=j.name})},D=N=>{const j=t[N];i(L=>{L.planModeToolset=j.name})};if(de((N,j)=>{j.escape?e():j.upArrow?y(L=>Math.max(0,L-1)):j.downArrow?y(L=>Math.min(t.length-1,L+1)):j.return&&t.length>0?(p(f),S(!1)):N==="n"?E():N==="x"&&t.length>0?x(f):N==="d"&&t.length>0?k(f):N==="p"&&t.length>0&&D(f)},{isActive:w}),b!==null)return s(jr,{toolsetIndex:b,onBack:()=>{p(null),S(!0)}});const O=N=>N.allowedTools==="*"?"All tools":N.allowedTools.length===0?"No tools":`${N.allowedTools.length} tool${N.allowedTools.length===1?"":"s"}`;return g(m,{flexDirection:"column",children:[s(pe,{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:"d to set as default toolset"}),t.length>0&&s(c,{dimColor:!0,children:"p to set as plan mode toolset"}),t.length>0&&s(c,{dimColor:!0,children:"x 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((N,j)=>{const L=N.name===n,B=N.name===o,T=f===j;let I;return T&&(I="yellow"),g(m,{flexDirection:"row",children:[g(c,{color:I,children:[T?"❯ ":" ",N.name," "]}),g(c,{color:I,children:["(",O(N),")"]}),L&&s(c,{color:h,children:" ⏵⏵ accept edits"}),B&&s(c,{color:d,children:" ⏸ plan mode"})]},j)})})]})}const ue=ut({settings:ee,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function Hr({startupCheckInfo:e}){const[t,n]=P({settings:ee,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await dn())})()},[]);const o=Nn(h=>{const f=JSON.parse(JSON.stringify(t.settings));h(f),n(y=>({...y,settings:f,changesApplied:!1})),je(y=>{y.settings=f,y.changesApplied=!1})},[t.settings]),[r,i]=P(null),[a,l]=P(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
648
- (However, your customization are still remembered in ${ae}.)
649
- Please reapply your changes below.`,type:"warning"}),o(()=>{}))},[]),de((h,f)=>{(f.ctrl&&h==="c"||(h==="q"||f.escape)&&!r)&&process.exit(0)},{isActive:!r});const u=h=>{switch(l(null),h){case Z.APPLY_CHANGES:e.ccInstInfo&&(l({message:"Applying patches...",type:"info"}),ot(t,e.ccInstInfo).then(f=>{n(f),l({message:"Customization patches applied successfully!",type:"success"})}));break;case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.MISC:case Z.TOOLSETS:i(h);break;case Z.VIEW_SYSTEM_PROMPTS:Mr(Se);break;case Z.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?qn(e.ccInstInfo):Jn(e.ccInstInfo)).then(()=>{l({message:"Original Claude Code restored successfully!",type:"success"}),o(()=>{})});break;case Z.OPEN_CONFIG:kn(ae);break;case Z.OPEN_CLI:e.ccInstInfo?.cliPath&&kn(e.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},d=()=>{i(null)};return s(ue.Provider,{value:{settings:t.settings,updateSettings:o,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:r===null?s(yt,{onSubmit:u,notification:a,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):r===Z.THEMES?s(Lr,{onBack:d}):r===Z.THINKING_VERBS?s(Dr,{onBack:d}):r===Z.THINKING_STYLE?s(Rr,{onBack:d}):r===Z.USER_MESSAGE_DISPLAY?s(Fr,{onBack:d}):r===Z.MISC?s(Vr,{onSubmit:d}):r===Z.TOOLSETS?s(Ur,{onBack:d}):null})})}const Mn=async e=>{try{await ie.mkdir(ce,{recursive:!0});try{await ie.stat(ae)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT"){const n={ccInstallationDir:e};await ie.writeFile(ae,JSON.stringify(n,null,2))}}}catch{}},Gr=async()=>{const e=new dt;e.name("tweakcc").description("Command-line tool to customize your Claude Code theme colors, thinking verbs and more.").version("3.1.5").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const t=e.opts();if(t.debug&&Er(),t.apply){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${ae}`);const o=await dn();(!o.settings||Object.keys(o.settings).length===0)&&(console.error("No saved customizations found in "+ae),process.exit(1));const r=await En();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 Mn(a),console.error("Cannot find Claude Code's cli.js"),console.error("Searched for cli.js at the following locations:"),tn.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(`
650
- 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 _n(r.ccInstInfo.version);i.success||(console.log(H.red(`
651
- Error downloading system prompts:`)),console.log(H.red(` ${i.errorMessage}`)),console.log(H.yellow(`
652
- ⚠ System prompts not available - skipping system prompt customizations`))),console.log("Applying customizations..."),await ot(o,r.ccInstInfo),console.log("Customizations applied successfully!"),process.exit(0)}const n=await En();if(n){const o=await _n(n.ccInstInfo.version);o.success||(console.log(H.red(`
653
- ✖ Error downloading system prompts:`)),console.log(H.red(` ${o.errorMessage}`)),console.log(H.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
654
- `))),ct(s(Hr,{startupCheckInfo:n}))}else{const o=()=>tn.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(`
655
- `)}}else return`- ${i.pattern}`}).join(`
656
- `),r=process.platform=="win32"?"C:\\absolute\\path\\to\\node_modules\\@anthropic-ai\\claude-code":"/absolute/path/to/node_modules/@anthropic-ai/claude-code";await Mn(r),console.error(`Cannot find Claude Code's cli.js -- do you have Claude Code installed?
654
+ `;c=c.slice(0,i)+u+c.slice(i),Y(e,c,u,i,i);const d=r+u.length,g=`||tweakccSummaries.has(${o}.uuid)`,f=c.slice(0,d)+g+c.slice(d);return Y(c,f,g,d,d),f},uo=e=>{const n=/description:"Rename the current conversation",isEnabled:\(\)=>!1,/,t=e.match(n);if(!t)return console.error("patch: conversationTitle: enableRenameConversationCommand: failed to find pattern"),null;if(t.index===void 0)return console.error("patch: conversationTitle: enableRenameConversationCommand: match.index is undefined"),null;const r='description:"Rename the current conversation",isEnabled:()=>!1,',i='description:"Rename the current conversation",isEnabled:()=>!0,',o=e.replace(r,i);return o===e?(console.error("patch: conversationTitle: enableRenameConversationCommand: replacement failed"),null):(Y(e,o,i,t.index,t.index+63),o)},ho=e=>{let n=e;if(n=ro(n),!n)return console.error("patch: conversationTitle: step 1 failed (writeTitleSlashCommand)"),null;if(n=io(n),!n)return console.error("patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)"),null;if(n=lo(n),!n)return console.error("patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)"),null;if(n=co(n),!n)return console.error("patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)"),null;const t=uo(n);return t?n=t:console.log("patch: conversationTitle: step 5 failed (enableRenameConversationCommand)"),n},mo=e=>{const n=/,[$\w]+\.createElement\([$\w]+,\{isBeforeFirstMessage:!1\}\),/,t=e.match(n);return!t||t.index===void 0?(console.error("patch: hideStartupBanner: failed to find startup banner createElement"),null):{startIndex:t.index,endIndex:t.index+t[0].length}},go=e=>{const n=mo(e);if(!n)return null;const t=e.slice(0,n.startIndex)+","+e.slice(n.endIndex);return Y(e,t,",",n.startIndex,n.endIndex),t},fo=e=>{const n=/ctrl-g to edit prompt in /,t=e.match(n);if(!t||t.index===void 0)return console.error('patch: hideCtrlGToEditPrompt: failed to find "ctrl-g to edit prompt in "'),null;const r=Math.max(0,t.index-150),i=e.slice(r,t.index),o=/:[$\w]+&&([$\w]+)\.createElement/g;let l=null,c;for(;(c=o.exec(i))!==null;)l=c;if(!l)return console.error("patch: hideCtrlGToEditPrompt: failed to find createElement pattern before ctrl-g text"),null;const u=l[1],d=r+l.index,g=l[0].length,f=`${u}.createElement`,x=g-f.length;return{startIndex:d,endIndex:d+x,identifiers:[u]}},po=e=>{const n=fo(e);if(!n)return null;if(!n.identifiers?.[0])return console.error("patch: hideCtrlGToEditPrompt: reactVar not captured"),null;const r=":false&&",i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return Y(e,i,r,n.startIndex,n.endIndex),i},bo=e=>{const n=[],t="▛███▜";let r=0;for(;;){const i=e.indexOf(t,r);if(i===-1)break;const o=Math.max(0,i-2e3),l=e.slice(o,i),c=/function [$\w]+\(\)\{/g;let u=null,d;for(;(d=c.exec(l))!==null;)u=d;if(u){const g=o+u.index+u[0].length;n.push(g)}else console.error(`patch: hideStartupClawd: failed to find function pattern before Clawd at position ${i}`);r=i+5}return n},wo=e=>{const n=bo(e);if(n.length===0)return console.error("patch: hideStartupClawd: no Clawd components found"),null;const t=[...n].sort((o,l)=>l-o),r="return null;";let i=e;for(const o of t)i=i.slice(0,o)+r+i.slice(o);if(t.length>0){const o=t[t.length-1];Y(e,i,r,o,o)}return i},Bt=async e=>{if(!e.cliPath){M("backupClijs: Skipping for native installation (no cliPath)");return}await rt(),M(`Backing up cli.js to ${De}`),await re.copyFile(e.cliPath,De),await Ne(n=>{n.changesApplied=!1,n.ccVersion=e.version})},Pt=async e=>{e.nativeInstallationPath&&(await rt(),M(`Backing up native binary to ${ge}`),await re.copyFile(e.nativeInstallationPath,ge),await Ne(n=>{n.changesApplied=!1,n.ccVersion=e.version}))},Zt=async e=>{if(!e.cliPath)return M("restoreClijsFromBackup: Skipping for native installation (no cliPath)"),!1;M(`Restoring cli.js from backup to ${e.cliPath}`);const n=await re.readFile(De);return await _t(e.cliPath,n,"restore"),await br(),await Ne(t=>{t.changesApplied=!1}),!0},en=async e=>{if(!e.nativeInstallationPath)return M("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await _e(ge))return M("restoreNativeBinaryFromBackup: No backup file exists, skipping"),!1;M(`Restoring native binary from backup to ${e.nativeInstallationPath}`);const n=await re.readFile(ge);return await _t(e.nativeInstallationPath,n,"restore"),!0},Y=(e,n,t,r,i)=>{if(!je())return;const o=Math.max(0,r-20),l=Math.min(e.length,i+20),c=Math.min(n.length,r+t.length+20),u=e.slice(o,r),d=e.slice(r,i),g=e.slice(i,l),f=n.slice(o,r),x=n.slice(r,r+t.length),w=n.slice(r+t.length,c);d!==x&&(console.log(`
655
+ --- Diff ---`),console.log("OLD:",u+`\x1B[31m${d}\x1B[0m`+g),console.log("NEW:",f+`\x1B[32m${x}\x1B[0m`+w),console.log(`--- End Diff ---
656
+ `))},ue=e=>e.replace(/\$/g,"\\$"),yt=e=>{const n=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,t=Array.from(e.matchAll(n)),r={};for(const l of t){const c=l[1];r[c]=(r[c]||0)+1}let i,o=0;for(const[l,c]of Object.entries(r))c>o&&(o=c,i=l);return i},xo=e=>{const n=e.slice(0,1e3),t=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,r=n.match(t);if(!r){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return r[1]},tn=e=>{const n=/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/,t=e.match(n);if(!t){console.log("patch: getReactModuleNameNonBun: failed to find React module name");return}return t[1]},So=e=>{const n=tn(e);if(!n){console.log("^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)");return}const t=new RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${ue(n)}\\(\\)`),r=e.match(t);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${n})`);return}return r[1]};let me=null,Pe=null;const tt=e=>{if(me!=null)return me;const n=xo(e);if(!n){console.log("^ patch: getReactVar: failed to find moduleLoader"),me=void 0;return}const t=tn(e);if(!t){console.log("^ patch: getReactVar: failed to find reactModuleVarNonBun"),me=void 0;return}const r=new RegExp(`\\b([$\\w]+)=${ue(n)}\\(${ue(t)}\\(\\),1\\)`),i=e.match(r);if(i)return me=i[1],me;const o=So(e);if(!o){console.log("^ patch: getReactVar: failed to find reactModuleFunctionBun"),me=void 0;return}const l=new RegExp(`\\b([$\\w]+)=${ue(n)}\\(${ue(o)}\\(\\),1\\)`),c=e.match(l);if(!c){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${n}, reactModuleVarNonBun=${t}, reactModuleFunctionBun=${o})`),me=void 0;return}return me=c[1],me},yo=e=>{const n=/import\{createRequire as ([$\w]+)\}from"node:module";/,t=e.match(n);if(!t)return;const r=t[1],i=new RegExp(`var ([$\\w]+)=${ue(r)}\\(import\\.meta\\.url\\)`),o=e.match(i);if(!o){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${r})`);return}return o[1]},vt=e=>{if(Pe!=null)return Pe;const n=yo(e);return n?(Pe=n,Pe):(Pe="require",Pe)},nn=e=>{const n=/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/,t=e.match(n);if(!t){console.log("patch: findTextComponent: failed to find text component");return}return t[1]},Ct=e=>{const n=/\b([$\w]+)\.displayName="Box"/,t=e.match(n);if(!t){console.error("patch: findBoxComponent: failed to find Box displayName");return}const r=t[1],i=new RegExp(`\\b([$\\w]+)=${ue(r)}[^$\\w]`),o=e.match(i);if(!o){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${r})`);return}return o[1]},rn=async(e,n)=>{let t;if(n.nativeInstallationPath){await en(n);let g=!1;try{await oe.stat(ge),g=!0}catch{}const f=g?ge:n.nativeInstallationPath;M(`Extracting claude.js from ${g?"backup":"native installation"}: ${f}`);const x=await jt(f);if(!x)throw new Error("Failed to extract claude.js from native installation");const w=ae.join(se,"native-claudejs-orig.js");Le.writeFileSync(w,x),M(`Saved original extracted JS from native to: ${w}`),t=x.toString("utf8")}else{if(await Zt(n),!n.cliPath)throw new Error("cliPath is required for NPM installations");t=await oe.readFile(n.cliPath,{encoding:"utf8"})}const r=[],i=await Lr(t,n.version);t=i.newContent,r.push(...i.items);let o=null;e.settings.themes&&e.settings.themes.length>0&&(o=An(t,e.settings.themes))&&(t=o),e.settings.thinkingVerbs&&((o=Zn(t,e.settings.thinkingVerbs.verbs))&&(t=o),(o=Un(t,e.settings.thinkingVerbs.format))&&(t=o)),(o=Wn(t,e.settings.thinkingStyle.phases))&&(t=o),(o=Jn(t,e.settings.thinkingStyle.updateInterval))&&(t=o),(o=qn(t,Math.max(...e.settings.thinkingStyle.phases.map(g=>g.length))+1))&&(t=o),(o=Gn(t,e.settings.thinkingStyle.reverseMirror))&&(t=o),e.settings.userMessageDisplay&&(o=tr(t,e.settings.userMessageDisplay.format,e.settings.userMessageDisplay.foregroundColor,e.settings.userMessageDisplay.backgroundColor,e.settings.userMessageDisplay.styling.includes("bold"),e.settings.userMessageDisplay.styling.includes("italic"),e.settings.userMessageDisplay.styling.includes("underline"),e.settings.userMessageDisplay.styling.includes("strikethrough"),e.settings.userMessageDisplay.styling.includes("inverse"),e.settings.userMessageDisplay.borderStyle,e.settings.userMessageDisplay.borderColor,e.settings.userMessageDisplay.paddingX,e.settings.userMessageDisplay.paddingY,e.settings.userMessageDisplay.fitBoxToContent))&&(t=o),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder=="boolean"&&(o=Rn(t,e.settings.inputBox.removeBorder))&&(t=o),(o=rr(t))&&(t=o),(o=Fn(t))&&(t=o),(o=Dn(t))&&(t=o),(o=Co(t))&&(t=o),(o=Bn(t,25))&&(t=o),(o=sr(t))&&(t=o);const l=e.settings.misc?.showTweakccVersion??!0,c=e.settings.misc?.showPatchesApplied??!0;(o=hr(t,"3.2.0",r,l,c))&&(t=o),(o=Vr(t))&&(t=o),e.settings.toolsets&&e.settings.toolsets.length>0&&(o=no(t,e.settings.toolsets,e.settings.defaultToolset))&&(t=o),e.settings.planModeToolset&&e.settings.defaultToolset&&((o=Zr(t))&&(t=o),(o=to(t,e.settings.planModeToolset,e.settings.defaultToolset))&&(t=o));const u=e.settings.misc?.enableConversationTitle??!0,d=n.version&&Jt(n.version,"2.0.64")<0;if(u&&d&&(o=ho(t))&&(t=o),e.settings.misc?.hideStartupBanner&&(o=go(t))&&(t=o),e.settings.misc?.hideCtrlGToEditPrompt&&(o=po(t))&&(t=o),e.settings.misc?.hideStartupClawd&&(o=wo(t))&&(t=o),n.nativeInstallationPath){M(`Repacking modified claude.js into native installation: ${n.nativeInstallationPath}`);const g=ae.join(se,"native-claudejs-patched.js");Le.writeFileSync(g,t,"utf8"),M(`Saved patched JS from native to: ${g}`);const f=Buffer.from(t,"utf8");await kn(n.nativeInstallationPath,f,n.nativeInstallationPath)}else{if(!n.cliPath)throw new Error("cliPath is required for NPM installations");await _t(n.cliPath,t,"patch")}return await Ne(g=>{g.changesApplied=!0})},on=[{value:"claude-opus-4-5-20251101",label:"Opus 4.5",description:"Claude Opus 4.5 (November 2025)"},{value:"claude-sonnet-4-5-20250929",label:"Sonnet 4.5",description:"Claude Sonnet 4.5 (September 2025)"},{value:"claude-opus-4-1-20250805",label:"Opus 4.1",description:"Claude Opus 4.1 (August 2025)"},{value:"claude-opus-4-20250514",label:"Opus 4",description:"Claude Opus 4 (May 2025)"},{value:"claude-sonnet-4-20250514",label:"Sonnet 4",description:"Claude Sonnet 4 (May 2025)"},{value:"claude-3-7-sonnet-20250219",label:"Sonnet 3.7",description:"Claude 3.7 Sonnet (February 2025)"},{value:"claude-3-5-sonnet-20241022",label:"Sonnet 3.5 (October)",description:"Claude 3.5 Sonnet (October 2024)"},{value:"claude-3-5-haiku-20241022",label:"Haiku 3.5",description:"Claude 3.5 Haiku (October 2024)"},{value:"claude-3-5-sonnet-20240620",label:"Sonnet 3.5 (June)",description:"Claude 3.5 Sonnet (June 2024)"},{value:"claude-3-haiku-20240307",label:"Haiku 3",description:"Claude 3 Haiku (March 2024)"},{value:"claude-3-opus-20240229",label:"Opus 3",description:"Claude 3 Opus (February 2024)"}],vo=e=>{const n=/\b([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/,t=e.match(n);if(!t||t.index===void 0)return console.error("patch: findCustomModelListInsertionPoint: failed to find custom model push"),null;const r=t[1],i=Math.max(0,t.index-600),o=e.slice(i,t.index),l=new RegExp(`function [$\\w]+\\(\\)\\{let ${ue(r)}=.+?;`,"g");let c=null,u;for(;(u=l.exec(o))!==null;)c=u;return c?{insertionIndex:i+c.index+c[0].length,modelListVar:r}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${r}`),null)},Co=e=>{const n=vo(e);if(!n)return null;const{insertionIndex:t,modelListVar:r}=n,i=on.map(l=>`${r}.push(${JSON.stringify(l)});`).join(""),o=e.slice(0,t)+i+e.slice(t);return Y(e,o,i,t,t),o};let sn=!1;const je=()=>sn,$o=()=>{sn=!0},M=(e,...n)=>{je()&&console.log(e,...n)};function nt(){try{const e=ae.join(Re.homedir(),".claude.json");return JSON.parse(Le.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function _o(){try{const e=ae.join(Re.homedir(),".claude",".credentials.json");switch(JSON.parse(Le.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 Io(){try{const e=ae.join(Re.homedir(),".claude","settings.json"),t=JSON.parse(Le.readFileSync(e,"utf8"))?.model||"default";if(t==="opus")return"Opus 4.5";const r=on.find(i=>i.value===t);if(r)return r.label}catch{}return"Opus 4.5"}function To(e){process.platform==="win32"?Oe.spawn("explorer",[e],{detached:!0,stdio:"ignore"}).unref():process.platform==="darwin"?Oe.spawn("open",[e],{detached:!0,stdio:"ignore"}).unref():Oe.spawn("xdg-open",[e],{detached:!0,stdio:"ignore"}).unref()}function At(e){if(process.platform==="win32")Oe.spawn("explorer",["/select,",e],{detached:!0,stdio:"ignore"}).unref();else if(process.platform==="darwin")Oe.spawn("open",["-R",e],{detached:!0,stdio:"ignore"}).unref();else{const n=ae.dirname(e);Oe.spawn("xdg-open",[n],{detached:!0,stdio:"ignore"}).unref()}}function $t(e){if(!e||typeof e!="string")return!1;const n=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(n))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(n)){const t=n.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t){const[,r,i,o]=t;return parseInt(r)<=255&&parseInt(i)<=255&&parseInt(o)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(n)){const t=n.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t){const[,r,i,o]=t;return parseInt(r)<=360&&parseInt(i)<=100&&parseInt(o)<=100}}return!1}function ln(e){if(!$t(e))return e;const n=e.trim();if(n.startsWith("rgb("))return n;if(n.startsWith("#")){let t=n.slice(1);t.length===3&&(t=t.split("").map(l=>l+l).join(""));const r=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),o=parseInt(t.slice(4,6),16);return`rgb(${r},${i},${o})`}if(n.startsWith("hsl(")){const t=n.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t){const r=parseInt(t[1])/360,i=parseInt(t[2])/100,o=parseInt(t[3])/100,l=(x,w,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?x+(w-x)*6*p:p<1/2?w:p<2/3?x+(w-x)*(2/3-p)*6:x),c=o<.5?o*(1+i):o+i-o*i,u=2*o-c,d=Math.round(l(u,c,r+1/3)*255),g=Math.round(l(u,c,r)*255),f=Math.round(l(u,c,r-1/3)*255);return`rgb(${d},${g},${f})`}}return e}async function lt(e,n="sha256",t=64*1024){return new Promise((r,i)=>{const o=Rt.createHash(n),l=Le.createReadStream(e,{highWaterMark:t});l.on("data",c=>{o.update(c)}),l.on("end",()=>{r(o.digest("hex"))}),l.on("error",c=>{i(c)})})}async function _t(e,n,t="replace"){let r=493;try{r=(await re.stat(e)).mode,M(`[${t}] Original file mode for ${e}: ${(r&parseInt("777",8)).toString(8)}`)}catch(i){M(`[${t}] Could not stat ${e} (error: ${i}), using default mode 755`)}try{await re.unlink(e),M(`[${t}] Unlinked ${e} to break hard links`)}catch(i){M(`[${t}] Could not unlink ${e}: ${i}`)}await re.writeFile(e,n),await re.chmod(e,r),M(`[${t}] Restored permissions to ${(r&parseInt("777",8)).toString(8)}`)}async function _e(e){try{return await re.stat(e),!0}catch(n){if(n instanceof Error&&"code"in n&&(n.code==="ENOENT"||n.code==="ENOTDIR"||n.code==="EACCES"||n.code==="EPERM"))return!1;throw n}}const Mo=e=>e.startsWith("~")?ae.join(Re.homedir(),e.slice(1)):e,Eo=(e,n)=>{const t=o=>{const l=o.split(".").map(Number);return[l[0]||0,l[1]||0,l[2]||0]},r=t(e),i=t(n);return r[0]!==i[0]?r[0]-i[0]:r[1]!==i[1]?r[1]-i[1]:r[2]-i[2]},ko=e=>{const n=e?.settings?.userMessageDisplay;if(n?.prefix){const t=n;e.settings.userMessageDisplay={format:(t.prefix?.format||"")+(t.message?.format||"{}"),styling:[...t.prefix?.styling||[],...t.message?.styling||[]],foregroundColor:t.message?.foregroundColor==="rgb(0,0,0)"?"default":t.message?.foregroundColor||t.prefix?.foregroundColor||"default",backgroundColor:t.message?.backgroundColor==="rgb(0,0,0)"?null:t.message?.backgroundColor||t.prefix?.backgroundColor||null,borderStyle:"none",borderColor:"rgb(255,255,255)",paddingX:0,paddingY:0,fitBoxToContent:!1}}n&&!("borderStyle"in n)&&(e.settings.userMessageDisplay.borderStyle="none",e.settings.userMessageDisplay.borderColor="rgb(255,255,255)",e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),n&&"padding"in n&&!("paddingX"in n)&&(e.settings.userMessageDisplay.paddingX=n.padding||0,e.settings.userMessageDisplay.paddingY=0,delete n.padding),n&&!("fitBoxToContent"in n)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)};async function No(){try{const e=await re.readFile(ce,"utf8"),n=JSON.parse(e);return Object.hasOwn(n,"ccInstallationDir")?(n.ccInstallationDir&&!n.ccInstallationPath&&(n.ccInstallationPath=le.join(n.ccInstallationDir,"cli.js")),delete n.ccInstallationDir,n.lastModified=new Date().toISOString(),await rt(),await re.writeFile(ce,JSON.stringify(n,null,2)),!0):!1}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return!1;throw e}}const ee={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:{format:" > {} ",styling:[],foregroundColor:"default",backgroundColor:null,borderStyle:"none",borderColor:"rgb(255,255,255)",paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEditPrompt:!1,hideStartupClawd:!1},toolsets:[],defaultToolset:null,planModeToolset:null},Bo=()=>{const e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return Mo(e);const n=le.join(Ce.homedir(),".tweakcc"),t=le.join(Ce.homedir(),".claude","tweakcc"),r=process.env.XDG_CONFIG_HOME;try{if(gt.existsSync(n))return n}catch(i){M(`Failed to check if ${n} exists: ${i}`)}try{if(gt.existsSync(t))return t}catch(i){M(`Failed to check if ${t} exists: ${i}`)}return r?le.join(r,"tweakcc"):n},se=Bo(),ce=le.join(se,"config.json"),De=le.join(se,"cli.js.backup"),ge=le.join(se,"native-binary.backup"),Se=le.join(se,"system-prompts"),Ot=le.join(se,"prompt-data-cache"),Po=()=>{const e=se,n=Ce.homedir(),t=[le.join(n,".tweakcc"),le.join(n,".claude","tweakcc"),process.env.XDG_CONFIG_HOME?le.join(process.env.XDG_CONFIG_HOME,"tweakcc"):null].filter(i=>i!==null),r=t.filter(i=>{try{return gt.existsSync(i)&&i!==e}catch{return!1}});r.length>0&&(console.warn(F.yellow(`
657
+ Multiple configuration locations detected:`)),console.warn(F.gray(` Active: ${e}`)),console.warn(F.gray(" Other existing locations:")),r.forEach(i=>{console.warn(F.gray(` - ${i}`))}),console.warn(F.gray(" Only the active location is used. To switch locations,")),console.warn(F.gray(` move your config.json to the desired directory.
658
+ `)))},rt=async()=>{await re.mkdir(se,{recursive:!0}),await re.mkdir(Se,{recursive:!0});const e=le.join(se,".gitignore");try{await re.stat(e)}catch(n){n instanceof Error&&"code"in n&&n.code==="ENOENT"&&await re.writeFile(e,[".DS_Store","prompt-data-cache","cli.js.backup","native-binary.backup","native-claudejs-orig.js","native-claudejs-patched.js","systemPromptAppliedHashes.json","systemPromptOriginalHashes.json","system-prompts/*.diff.html"].join(Mt)+Mt)}};let ke=null;const He=async()=>{const e={ccVersion:"",ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:ee};try{M(`Reading config at ${ce}`),Po();const n=await re.readFile(ce,"utf8"),t={...e,...JSON.parse(n)},r=t?.settings?.thinkingVerbs;r?.punctuation&&(r.format="{}"+r.punctuation,delete r.punctuation),t.settings.inputBox||(t.settings.inputBox=ee.inputBox),t.settings.toolsets||(t.settings.toolsets=ee.toolsets),Object.hasOwn(t.settings,"defaultToolset")||(t.settings.defaultToolset=ee.defaultToolset),Object.hasOwn(t.settings,"planModeToolset")||(t.settings.planModeToolset=ee.planModeToolset);for(const o of ee.themes){const l=t?.settings?.themes.find(c=>c.id===o.id||c.name===o.name);if(l){for(const[c,u]of Object.entries(o))c!=="colors"&&!Object.hasOwn(l,c)&&(l[c]=u);l.colors||(l.colors={});for(const[c,u]of Object.entries(o.colors))Object.hasOwn(l.colors,c)||(l.colors[c]=u)}}for(const o of t?.settings?.themes||[]){if(ee.themes.some(u=>u.id===o.id||u.name===o.name))continue;const c=ee.themes[0];o.colors||(o.colors={});for(const[u,d]of Object.entries(c.colors))Object.hasOwn(o.colors,u)||(o.colors[u]=d)}return t?.settings?.userMessageDisplay||(t.settings=t.settings||ee,t.settings.userMessageDisplay=ee.userMessageDisplay),ko(t),delete t.settings.launchText,await wr(Se)&&(t.changesApplied=!1),ke=t,t}catch(n){if(n instanceof Error&&"code"in n&&n.code==="ENOENT")return e;throw n}},Ne=async e=>(M(`Updating config at ${ce}`),!ke&&(ke=await He()),e(ke),ke.lastModified=new Date().toISOString(),await Ao(ke),ke),Ao=async e=>{try{e.lastModified=new Date().toISOString(),await rt(),await re.writeFile(ce,JSON.stringify(e,null,2))}catch(n){throw console.error("Error saving config:",n),n}},Oo=({children:e,...n})=>h(a,{bold:!0,backgroundColor:"#ffd500",color:"#000",...n,children:[" ",e," "]});var fe=Oo;const Do=["\x1B[?25l\x1B[0m \x1B[38;2;0;0;0m \x1B[38;2;252;130;0m▂\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▇\x1B[38;2;254;131;0m\x1B[48;2;252;130;0m▇\x1B[48;2;252;130;0m▇▇\x1B[48;2;252;130;0m▇\x1B[0m\x1B[38;2;252;130;0m▇\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▂ \x1B[0m"," \x1B[38;2;0;0;0m \x1B[38;2;254;131;0m▗\x1B[38;2;254;131;0m▆\x1B[48;2;254;131;0m \x1B[38;2;254;132;0m╶ \x1B[0m\x1B[38;2;254;131;0m▆\x1B[38;2;254;131;0m▖ \x1B[0m"," \x1B[7m\x1B[38;2;254;131;0m▘\x1B[0m\x1B[38;2;11;6;0m\x1B[48;2;254;131;0m \x1B[38;2;254;216;182m\x1B[48;2;254;136;12m▃\x1B[38;2;254;249;246m\x1B[48;2;254;143;29m▅\x1B[38;2;254;253;253m\x1B[48;2;254;143;40m▆\x1B[38;2;254;254;253m\x1B[48;2;254;152;68m▆▆▆\x1B[38;2;254;253;252m\x1B[48;2;254;141;34m▆\x1B[38;2;254;247;242m\x1B[48;2;254;140;24m▅\x1B[38;2;254;224;199m\x1B[48;2;254;140;20m▖\x1B[48;2;254;131;0m \x1B[0m\x1B[7m\x1B[38;2;254;131;0m▝\x1B[0m \x1B[0m","\x1B[7m\x1B[38;2;251;127;0m▌\x1B[0m\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[38;2;252;128;0m\x1B[48;2;254;131;0m▃\x1B[38;2;252;129;0m▂\x1B[38;2;253;130;0m▁\x1B[38;2;249;135;16m\x1B[48;2;253;226;202m▋\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┈\x1B[48;2;246;246;245m┈\x1B[38;2;47;47;47m\x1B[48;2;244;244;243m▂\x1B[38;2;112;112;112m\x1B[48;2;251;251;251m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m▁╌▝\x1B[38;2;254;254;253m\x1B[48;2;254;254;254m▋\x1B[38;2;254;254;254m\x1B[48;2;254;253;252m┈\x1B[38;2;252;209;168m\x1B[48;2;251;129;0m▍\x1B[38;2;253;129;0m\x1B[48;2;254;131;0m▂\x1B[38;2;252;128;0m▃\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[0m\x1B[38;2;251;127;0m▌\x1B[0m","\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▏\x1B[38;2;245;118;0m\x1B[48;2;248;122;0m▄\x1B[38;2;247;121;0m\x1B[48;2;247;122;0m┈\x1B[38;2;106;68;38m\x1B[48;2;245;123;2m▃\x1B[38;2;39;33;28m\x1B[48;2;211;109;6m▅\x1B[38;2;27;20;12m\x1B[48;2;237;237;237m▌\x1B[48;2;254;254;253m \x1B[38;2;90;90;89m\x1B[48;2;231;230;230m▝\x1B[38;2;215;215;214m\x1B[48;2;48;48;48m▁\x1B[38;2;203;203;202m\x1B[48;2;42;42;42m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┇╴\x1B[38;2;253;252;252m▂\x1B[38;2;251;250;250m\x1B[48;2;253;253;253m▃\x1B[38;2;249;249;248m\x1B[48;2;252;252;251m▄\x1B[38;2;249;248;248m\x1B[48;2;237;118;0m▍\x1B[38;2;246;121;0m\x1B[48;2;250;125;0m▄\x1B[38;2;246;119;0m\x1B[48;2;249;124;0m▄\x1B[38;2;245;118;0m\x1B[48;2;248;123;0m▄\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▉\x1B[0m","\x1B[38;2;238;108;0m\x1B[48;2;237;109;0m▏\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;233;109;2m\x1B[48;2;125;73;29m▇\x1B[38;2;225;104;1m\x1B[48;2;50;32;18m▄\x1B[38;2;62;29;2m\x1B[48;2;239;237;237m▌\x1B[38;2;254;253;253m\x1B[48;2;254;254;254m┻\x1B[38;2;254;254;253m▊\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;253;253;252m▂\x1B[38;2;251;251;251m\x1B[48;2;254;253;253m▃\x1B[38;2;249;249;249m\x1B[48;2;252;252;252m▄\x1B[38;2;247;247;247m\x1B[48;2;250;250;250m▄\x1B[38;2;245;245;244m\x1B[48;2;248;248;248m▄\x1B[38;2;243;243;242m\x1B[48;2;246;246;245m▄\x1B[38;2;243;242;242m\x1B[48;2;230;109;0m▍\x1B[38;2;239;111;0m\x1B[48;2;243;116;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;237;108;0m\x1B[48;2;238;108;0m▉\x1B[0m","\x1B[7m\x1B[38;2;231;98;0m▌\x1B[0m\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[38;2;231;99;0m\x1B[48;2;235;105;0m▄\x1B[38;2;232;100;0m\x1B[48;2;236;105;0m▄\x1B[38;2;232;101;0m\x1B[48;2;236;106;0m▄\x1B[38;2;223;99;0m\x1B[48;2;247;238;235m▌\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;252;252;251m▃\x1B[38;2;250;250;250m\x1B[48;2;253;253;252m▄\x1B[38;2;248;248;247m\x1B[48;2;251;251;250m▄\x1B[38;2;246;245;245m\x1B[48;2;249;248;248m▄\x1B[38;2;243;243;243m\x1B[48;2;246;246;246m▄\x1B[38;2;241;241;241m\x1B[48;2;244;244;244m▄\x1B[38;2;239;239;238m\x1B[48;2;242;242;242m▄\x1B[38;2;237;237;236m\x1B[48;2;240;240;239m▄\x1B[38;2;237;236;236m\x1B[48;2;223;99;0m▍\x1B[38;2;232;100;0m\x1B[48;2;236;106;0m▄\x1B[38;2;231;100;0m\x1B[48;2;235;105;0m▄\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[0m\x1B[38;2;231;98;0m▌\x1B[0m"," \x1B[7m\x1B[38;2;224;89;0m▖\x1B[0m\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[38;2;225;90;0m\x1B[48;2;228;95;0m▄\x1B[38;2;225;91;0m\x1B[48;2;229;96;0m▄\x1B[38;2;217;90;1m\x1B[48;2;97;77;70m▌\x1B[38;2;70;70;70m\x1B[48;2;207;207;207m▆\x1B[38;2;66;65;65m\x1B[48;2;228;228;227m▄\x1B[38;2;66;66;66m\x1B[48;2;233;232;232m▂\x1B[38;2;169;169;169m\x1B[48;2;243;243;243m▁\x1B[38;2;240;239;239m\x1B[48;2;243;242;242m▄\x1B[38;2;238;237;237m\x1B[48;2;241;240;240m▄\x1B[38;2;235;235;235m\x1B[48;2;238;238;238m▄\x1B[38;2;233;233;233m\x1B[48;2;236;236;236m▄\x1B[38;2;231;231;230m\x1B[48;2;234;234;233m▄\x1B[38;2;231;230;230m\x1B[48;2;216;89;0m▍\x1B[38;2;225;90;0m\x1B[48;2;229;95;0m▄\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[0m\x1B[7m\x1B[38;2;224;89;0m▗\x1B[0m \x1B[0m"," \x1B[38;2;0;0;0m \x1B[38;2;217;80;0m▝\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m\x1B[48;2;221;86;0m▄\x1B[38;2;197;78;9m\x1B[48;2;66;66;65m▋\x1B[38;2;65;65;64m\x1B[48;2;60;60;60m▘\x1B[38;2;52;52;51m\x1B[48;2;56;56;56m▗\x1B[38;2;45;45;45m\x1B[48;2;50;50;49m▗\x1B[38;2;42;42;42m\x1B[48;2;46;46;46m┈\x1B[38;2;41;41;41m\x1B[48;2;203;202;202m▆\x1B[38;2;38;38;38m\x1B[48;2;218;218;218m▄\x1B[38;2;45;45;45m\x1B[48;2;221;221;221m▂\x1B[38;2;229;229;229m┊\x1B[38;2;225;225;225m\x1B[48;2;228;228;227m▄\x1B[38;2;225;224;224m\x1B[48;2;209;79;0m▍\x1B[0m\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m▘ \x1B[0m"," \x1B[38;2;0;0;0m \x1B[7m\x1B[38;2;191;73;0m▆\x1B[38;2;191;73;0m▄\x1B[38;2;56;55;55m▃\x1B[38;2;46;46;46m▁\x1B[0m\x1B[38;2;20;20;20m\x1B[48;2;42;42;42m▁\x1B[38;2;36;36;36m\x1B[48;2;35;34;34m╴\x1B[38;2;23;23;23m\x1B[48;2;29;29;28m▁\x1B[38;2;10;10;10m\x1B[48;2;22;22;22m▁\x1B[0m\x1B[7m\x1B[38;2;15;15;15m▁\x1B[38;2;22;22;21m▃\x1B[38;2;154;154;154m▅\x1B[38;2;175;116;83m▇\x1B[0m\x1B[38;2;17;15;14m \x1B[0m","\x1B[?25h\x1B[0m"],Lo=()=>h(m,{flexDirection:"row",height:10,alignItems:"center",borderStyle:"bold",borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:"#ff8400",marginBottom:1,children:[h(m,{marginBottom:1,paddingLeft:1,flexDirection:"column",flexGrow:1,children:[s(a,{bold:!0,color:"#ff8400",children:"Piebald is released!"}),s(a,{children:" "}),h(a,{children:["We've released ",s(a,{bold:!0,children:"Piebald"}),", the ultimate agentic AI developer experience."]}),h(a,{children:["Download it and try it out for free!"," ",s(wt,{url:"https://piebald.ai/",fallback:!1,children:s(a,{color:"#ff8400",children:"https://piebald.ai/"})})]}),s(a,{children:" "}),s(a,{dimColor:!0,color:"gray",children:"press 'h' to hide"})]}),s(m,{width:22,flexShrink:0,flexDirection:"column",alignItems:"center",children:Do.map((e,n)=>s(a,{children:e},n))})]});var Ro=Lo;let Z=function(e){return e.APPLY_CHANGES="*Apply customizations",e.THEMES="Themes",e.THINKING_VERBS="Thinking verbs",e.THINKING_STYLE="Thinking style",e.USER_MESSAGE_DISPLAY="User message display",e.MISC="Misc",e.TOOLSETS="Toolsets",e.VIEW_SYSTEM_PROMPTS="View system prompts",e.RESTORE_ORIGINAL="Restore original Claude Code (preserves config.json)",e.OPEN_CONFIG="Open config.json",e.OPEN_CLI="Open Claude Code's cli.js",e.EXIT="Exit",e}({});function Vo({items:e,selectedIndex:n,onSelect:t,onSubmit:r}){return de((i,o)=>{o.upArrow?t(n>0?n-1:e.length-1):o.downArrow?t(n<e.length-1?n+1:0):o.return&&r(e[n].name)}),s(m,{flexDirection:"column",children:e.map((i,o)=>s(m,{children:h(a,{children:[h(a,{bold:o===n,color:o===n?"cyan":void 0,...o===n?i.selectedStyles??{}:i.styles??{},children:[o===n?"❯ ":" ",i.name]}),i.desc&&o===n&&h(a,{dimColor:!0,bold:!1,children:[" \x1B[0;2m","- ",i.desc]})]})},o))})}const Fo=[{name:Z.THEMES,desc:"Modify Claude Code's built-in themes or create your own"},{name:Z.THINKING_VERBS,desc:"Customize the list of verbs that Claude Code uses when it's working"},{name:Z.THINKING_STYLE,desc:"Choose custom spinners"},{name:Z.USER_MESSAGE_DISPLAY,desc:"Customize how user messages are displayed"},{name:Z.MISC,desc:"Miscellaneous settings (input box border, etc.)"},{name:Z.TOOLSETS,desc:"Manage toolsets to control which tools are available"},{name:Z.VIEW_SYSTEM_PROMPTS,desc:"Opens the system prompts directory where you can customize Claude Code's system prompts"}],jo=[{name:Z.RESTORE_ORIGINAL,desc:"Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)"},{name:Z.OPEN_CONFIG,desc:`Opens your tweakcc config file (${ce})`},{name:Z.OPEN_CLI,desc:"Opens Claude Code's cli.js file"},{name:Z.EXIT,desc:"Bye!"}],Uo=({onSubmit:e})=>{const t=[...pe(he).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:"Required: Updates Claude Code in-place with your changes",selectedStyles:{color:"green"}}],...Fo,...jo],[r,i]=B(0);return s(Vo,{items:t,selectedIndex:r,onSelect:i,onSubmit:o=>e(o)})};var Ho=Uo;const Go=()=>h(m,{flexDirection:"row",children:[s(fe,{children:"tweakcc"}),s(a,{children:" (by "}),s(wt,{url:"https://piebald.ai",fallback:!1,children:s(a,{color:"#ff8400",bold:!0,children:"Piebald"})}),s(a,{children:")"})]}),Yo=()=>s(m,{children:h(a,{color:"yellow",children:["⭐ ",s(a,{bold:!0,children:"Star the repo at "}),s(wt,{url:"https://github.com/Piebald-AI/tweakcc",fallback:!1,children:s(a,{bold:!0,color:"cyan",children:"https://github.com/Piebald-AI/tweakcc"})}),s(a,{bold:!0,children:" if you find this useful!"})," ⭐"]})}),Wo=({notification:e})=>s(m,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:"bold",borderColor:e.type==="success"?"green":e.type==="error"?"red":e.type==="info"?"blue":"yellow",paddingLeft:1,flexDirection:"column",children:s(a,{color:e.type==="success"?"green":e.type==="error"?"red":e.type==="info"?"blue":"yellow",children:e.message})}),zo=({onSubmit:e,notification:n,configMigrated:t,showPiebaldAnnouncement:r})=>h(m,{flexDirection:"column",gap:1,children:[t&&s(m,{children:s(a,{color:"blue",bold:!0,children:"Note that in tweakcc v3.2.0, `ccInstallationDir` config is deprecated. You are now migrated to `ccInstallationPath` which supports npm and native installs."})}),s(Go,{}),s(m,{children:h(a,{children:[s(a,{bold:!0,children:"Customize your Claude Code installation."})," ",h(a,{dimColor:!0,children:["Settings will be saved to ",se.replace(Re.homedir(),"~"),"/config.json."]})]})}),r?s(Ro,{}):s(Yo,{}),n&&s(Wo,{notification:n}),s(Ho,{onSubmit:e})]});function H({color:e,backgroundColor:n,bold:t,dimColor:r,children:i}){const o=e?.startsWith("ansi:"),l=n?.startsWith("ansi:");if(o||l){if(st.Children.toArray(i).some(f=>st.isValidElement(f)))return s(a,{children:i});let u=F;if(o){const f=e.slice(5);u=u[f]||u}if(l){const f=n.slice(5),x=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[x]||u}t&&(u=u.bold),r&&(u=u.dim);const g=st.Children.toArray(i).map(f=>typeof f=="string"||typeof f=="number"?String(f):"").join("");return s(a,{children:u(g)})}return s(a,{color:e,backgroundColor:n,bold:t,dimColor:r,children:i})}function Jo({text:e,nonShimmerColors:n,shimmerColors:t,shimmerWidth:r=3,updateDuration:i=50,restartPoint:o=10}){const[l,c]=B(0);return xe(()=>{const u=setInterval(()=>{c(d=>{const g=d+1;return g>=e.length+o?-r:g})},i);return()=>clearInterval(u)},[e.length,o,i]),n.length!==t.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(a,{children:e})):s(a,{children:e.split("").map((u,d)=>{const g=d>=l&&d<l+r&&l<e.length,f=d%n.length,x=g?t[f]:n[f];return s(a,{color:x,children:u},d)})})}const Xo=_n.cwd();function an({theme:e}){const{ccVersion:n}=pe(he);return h(m,{flexDirection:"column",paddingLeft:1,children:[s(m,{marginBottom:1,children:h(a,{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(a,{children:[s(H,{color:e.colors.clawd_body,children:" ▐"}),s(a,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),h(a,{children:[s(H,{color:e.colors.clawd_body,children:"▌ "})," ",s(a,{bold:!0,children:"Claude Code"})," ",n?`v${n}`:"v2.0.14"]})]}),h(a,{children:[s(H,{color:e.colors.clawd_body,children:"▝▜"}),s(a,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(H,{color:e.colors.clawd_body,children:"▛▘"})," ",Io()," · ",_o()]}),h(H,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",Xo]}),h(a,{children:[h(H,{color:e.colors.success,children:["Login successful. Press"," "]}),s(H,{bold:!0,color:e.colors.success,children:"Enter"}),h(H,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(a,{children:"╭─────────────────────────────────────────────╮"}),h(a,{children:["│ 1 function greet() ","{"," ","│"]}),h(a,{children:["│ 2"," ",s(H,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(H,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(H,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),h(a,{children:["│ 2"," ",s(H,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(H,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(H,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(H,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),h(H,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),h(a,{children:[s(H,{color:e.colors.warning,children:"│ "}),s(a,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),h(H,{color:e.colors.warning,children:[" ","│"]})]}),s(H,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),h(a,{children:[s(H,{color:e.colors.bashBorder,children:"!"}),s(a,{children:" ls"})]}),s(H,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(a,{children:h(a,{children:["> list the dir"," ",s(Jo,{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(H,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),h(a,{children:[s(H,{color:e.colors.planMode,children:"│ "}),h(H,{color:e.colors.permission,children:["Ready to code?"," "]}),s(a,{children:"Here is Claude's plan:"}),h(H,{color:e.colors.planMode,children:[" ","│"]})]}),s(H,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),h(a,{children:[s(H,{color:e.colors.permission,children:"│ "}),s(a,{bold:!0,children:"Permissions:"})," ",h(H,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(H,{color:e.colors.permission,children:"│"})]}),s(a,{children:"> list the dir"}),h(a,{children:[s(H,{color:e.colors.error,children:"●"}),s(a,{children:" Update(__init__.py)"})]}),h(a,{children:[s(a,{children:" ⎿ "}),s(H,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),h(a,{children:[" ","1"," ",h(H,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(H,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),h(a,{children:[" ","2"," ",h(H,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(H,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),h(a,{children:[s(H,{color:e.colors.success,children:"●"}),s(a,{children:" List(.)"})]}),h(a,{children:[s(a,{children:"●"}),s(a,{children:" The directory "}),s(H,{color:e.colors.permission,children:"C:\\Users\\user"}),h(a,{children:[" ","contains ",s(a,{bold:!0,children:"123"})," files."]})]}),h(a,{children:[s(H,{color:e.colors.claude,children:"✻ Th"}),s(H,{color:e.colors.claudeShimmer,children:"ink"}),s(H,{color:e.colors.claude,children:"ing… "}),s(a,{children:"(esc to interrupt)"})]}),s(a,{children:s(H,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(a,{children:s(H,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(a,{children:s(H,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function at({colorKey:e,theme:n,bold:t=!1}){const r=n.colors[e];return e==="inverseText"?s(H,{color:r,backgroundColor:n.colors.permission,bold:t,children:e}):e.startsWith("diff")?s(H,{backgroundColor:r,bold:t,color:n.colors.text,children:e}):s(H,{color:r,bold:t,children:e})}function cn({initialValue:e,onColorChange:n,onExit:t,colorKey:r,theme:i}){const o=dt(e)||{h:0,s:50,l:50},l=ct(e)||{r:128,g:128,b:128},[c,u]=B(o),[d,g]=B(l),[f,x]=B("hsl"),[w,p]=B("h"),[b,I]=B(!1),[T,S]=B(!1);xe(()=>{const _=dt(e),y=ct(e);_&&y&&(I(!0),u(_),g(y),I(!1))},[e]),xe(()=>{if(!b&&T){const _=`rgb(${d.r},${d.g},${d.b})`;n(_)}},[c,d,b,T]),xe(()=>{S(!0)},[]);const E=_=>{if($t(_)){const y=ln(_),C=dt(y),A=ct(y);C&&A&&(I(!0),u(C),g(A),I(!1))}};de((_,y)=>{if(_.length>1&&!y.ctrl&&!y.meta){E(_);return}if(y.return)t();else if(y.escape)t();else if(y.ctrl&&_==="a")x(C=>C==="hsl"?"rgb":"hsl"),p(C=>f==="hsl"?C==="h"?"r":C==="s"?"g":"b":C==="r"?"h":C==="g"?"s":"l");else if(y.upArrow)p(f==="hsl"?C=>C==="h"?"l":C==="s"?"h":"s":C=>C==="r"?"b":C==="g"?"r":"g");else if(y.downArrow||y.tab)p(f==="hsl"?C=>C==="h"?"s":C==="s"?"l":"h":C=>C==="r"?"g":C==="g"?"b":"r");else if(y.leftArrow){const C=y.shift||y.ctrl||y.meta?-10:-1;V(C)}else if(y.rightArrow){const C=y.shift||y.ctrl||y.meta?10:1;V(C)}});const V=_=>{I(!0),f==="hsl"?u(y=>{const C={...y};w==="h"?C.h=Math.max(0,Math.min(359,y.h+_)):w==="s"?C.s=Math.max(0,Math.min(100,y.s+_)):w==="l"&&(C.l=Math.max(0,Math.min(100,y.l+_)));const[A,v,U]=R(C.h,C.s,C.l);return g({r:A,g:v,b:U}),C}):g(y=>{const C={...y};w==="r"?C.r=Math.max(0,Math.min(255,y.r+_)):w==="g"?C.g=Math.max(0,Math.min(255,y.g+_)):w==="b"&&(C.b=Math.max(0,Math.min(255,y.b+_)));const A=O(C.r,C.g,C.b);return u(A),C}),I(!1)},O=(_,y,C)=>{const A=_/255,v=y/255,U=C/255,q=Math.max(A,v,U),K=Math.min(A,v,U),te=q-K,ie=(q+K)/2;let be=0;te!==0&&(be=ie>.5?te/(2-q-K):te/(q+K));let ye=0;return te!==0&&(q===A?ye=((v-U)/te+(v<U?6:0))/6:q===v?ye=((U-A)/te+2)/6:ye=((A-v)/te+4)/6),{h:Math.round(ye*360),s:Math.round(be*100),l:Math.round(ie*100)}},R=(_,y,C)=>{_/=360,y/=100,C/=100;const A=(1-Math.abs(2*C-1))*y,v=A*(1-Math.abs(_*6%2-1)),U=C-A/2;let q=0,K=0,te=0;return 0<=_&&_<1/6?(q=A,K=v,te=0):1/6<=_&&_<2/6?(q=v,K=A,te=0):2/6<=_&&_<3/6?(q=0,K=A,te=v):3/6<=_&&_<4/6?(q=0,K=v,te=A):4/6<=_&&_<5/6?(q=v,K=0,te=A):5/6<=_&&_<1&&(q=A,K=0,te=v),[Math.round((q+U)*255),Math.round((K+U)*255),Math.round((te+U)*255)]},D=()=>{const _=[],y=[[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 C=0;C<40;C++){const v=C/39*(y.length-1),U=Math.floor(v),q=Math.ceil(v),K=v-U,[te,ie,be]=y[U],[ye,Ge,ot]=y[q],Ye=Math.round(te+(ye-te)*K),P=Math.round(ie+(Ge-ie)*K),it=Math.round(be+(ot-be)*K);_.push(s(a,{backgroundColor:`rgb(${Ye},${P},${it})`,children:" "},C))}return _},J=()=>{const _=[];for(let y=0;y<40;y++){const C=y/39*100,[A,v,U]=R(c.h,C,c.l);_.push(s(a,{backgroundColor:`rgb(${A},${v},${U})`,children:" "},y))}return _},k=()=>{const _=[];for(let y=0;y<40;y++){const C=y/39*100,[A,v,U]=R(c.h,c.s,C);_.push(s(a,{backgroundColor:`rgb(${A},${v},${U})`,children:" "},y))}return _},N=()=>{const[_,y,C]=R(c.h,c.s,c.l);return`rgb(${_},${y},${C})`},$=(_,y,C)=>{const A=v=>v.toString(16).padStart(2,"0");return`#${A(_)}${A(y)}${A(C)}`},z=()=>{const _=[];for(let y=0;y<40;y++){const C=Math.round(y/39*255);_.push(s(a,{backgroundColor:`rgb(${C},${d.g},${d.b})`,children:" "},y))}return _},W=()=>{const _=[];for(let y=0;y<40;y++){const C=Math.round(y/39*255);_.push(s(a,{backgroundColor:`rgb(${d.r},${C},${d.b})`,children:" "},y))}return _},X=()=>{const _=[];for(let y=0;y<40;y++){const C=Math.round(y/39*255);_.push(s(a,{backgroundColor:`rgb(${d.r},${d.g},${C})`,children:" "},y))}return _},G=(_,y)=>Math.round(_/y*39);return h(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[h(m,{flexDirection:"column",children:[s(a,{bold:!0,children:"Color Picker"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(a,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(a,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(a,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(a,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(a,{color:"gray",dimColor:!0,children:"esc to save and exit"})]})]}),f==="hsl"?h($e,{children:[h(m,{marginBottom:1,children:[s(m,{width:25,children:h(a,{color:w==="h"?"yellow":"white",children:[w==="h"?"❯ ":" ","Hue (",c.h,"°):"]})}),s(m,{children:D().map((_,y)=>s(Be,{children:y===G(c.h,360)?s(a,{children:"|"}):_},y))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(a,{color:w==="s"?"yellow":"white",children:[w==="s"?"❯ ":" ","Saturation (",c.s,"%):"]})}),s(m,{children:J().map((_,y)=>s(Be,{children:y===G(c.s,100)?s(a,{children:"|"}):_},y))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(a,{color:w==="l"?"yellow":"white",children:[w==="l"?"❯ ":" ","Lightness (",c.l,"%):"]})}),s(m,{children:k().map((_,y)=>s(Be,{children:y===G(c.l,100)?s(a,{children:"|"}):_},y))})]})]}):h($e,{children:[h(m,{marginBottom:1,children:[s(m,{width:25,children:h(a,{color:w==="r"?"yellow":"white",children:[w==="r"?"❯ ":" ","Red (",d.r,"):"]})}),s(m,{children:z().map((_,y)=>s(Be,{children:y===G(d.r,255)?s(a,{children:"|"}):_},y))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(a,{color:w==="g"?"yellow":"white",children:[w==="g"?"❯ ":" ","Green (",d.g,"):"]})}),s(m,{children:W().map((_,y)=>s(Be,{children:y===G(d.g,255)?s(a,{children:"|"}):_},y))})]}),h(m,{marginBottom:1,children:[s(m,{width:25,children:h(a,{color:w==="b"?"yellow":"white",children:[w==="b"?"❯ ":" ","Blue (",d.b,"):"]})}),s(m,{children:X().map((_,y)=>s(Be,{children:y===G(d.b,255)?s(a,{children:"|"}):_},y))})]})]}),h(m,{marginBottom:1,children:[s(a,{children:"Current: "}),s(a,{backgroundColor:N(),children:" "})]}),h(m,{flexDirection:"row",justifyContent:"space-between",children:[h(m,{flexDirection:"column",children:[s(a,{dimColor:!0,children:"Hex "}),r?.startsWith("diff")?s(a,{backgroundColor:N(),color:i?.colors?.text||"white",bold:!0,children:$(d.r,d.g,d.b)}):r==="inverseText"?s(a,{color:N(),backgroundColor:i?.colors?.permission,bold:!0,children:$(d.r,d.g,d.b)}):s(a,{color:N(),bold:!0,children:$(d.r,d.g,d.b)})]}),h(m,{flexDirection:"column",children:[s(a,{dimColor:!0,children:"RGB "}),r?.startsWith("diff")?s(a,{backgroundColor:N(),color:i?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):r==="inverseText"?s(a,{color:N(),backgroundColor:i?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(a,{color:N(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),h(m,{flexDirection:"column",children:[s(a,{dimColor:!0,children:"HSL "}),r?.startsWith("diff")?s(a,{backgroundColor:N(),color:i?.colors?.text||"white",bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):r==="inverseText"?s(a,{color:N(),backgroundColor:i?.colors?.permission,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):s(a,{color:N(),bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`})]})]})]})}function ct(e){const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n)return{r:parseInt(n[1]),g:parseInt(n[2]),b:parseInt(n[3])};const t=e.match(/^#([a-fA-F0-9]{6})$/);if(t){const r=t[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 dt(e){const n=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n)return{h:parseInt(n[1]),s:parseInt(n[2]),l:parseInt(n[3])};const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t){const i=parseInt(t[1])/255,o=parseInt(t[2])/255,l=parseInt(t[3])/255,c=Math.max(i,o,l),u=Math.min(i,o,l),d=c-u,g=(c+u)/2;let f=0;d!==0&&(f=g>.5?d/(2-c-u):d/(c+u));let x=0;return d!==0&&(c===i?x=((o-l)/d+(o<l?6:0))/6:c===o?x=((l-i)/d+2)/6:x=((i-o)/d+4)/6),{h:Math.round(x*360),s:Math.round(f*100),l:Math.round(g*100)}}const r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){const i=r[1],o=parseInt(i.substr(0,2),16)/255,l=parseInt(i.substr(2,2),16)/255,c=parseInt(i.substr(4,2),16)/255,u=Math.max(o,l,c),d=Math.min(o,l,c),g=u-d,f=(u+d)/2;let x=0;g!==0&&(x=f>.5?g/(2-u-d):g/(u+d));let w=0;return g!==0&&(u===o?w=((l-c)/g+(l<c?6:0))/6:u===l?w=((c-o)/g+2)/6:w=((o-l)/g+4)/6),{h:Math.round(w*360),s:Math.round(x*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function qo({onBack:e,themeId:n}){const{settings:{themes:t},updateSettings:r}=pe(he),[i,o]=B(n),l=t.find(k=>k.id===i)||t[0],[c,u]=B("rgb"),[d,g]=B(0),[f,x]=B(null),[w,p]=B(null),[b,I]=B(""),[T,S]=B(""),E=Lt(k=>{r(N=>{const $=N.themes.findIndex(z=>z.id===i);$!==-1&&k(N.themes[$])})},[i,r]),V=k=>{if(d>=2&&$t(k)){const N=ln(k),$=d-2,z=O[$];E(W=>{W.colors[z]=N})}};de((k,N)=>{if(f===null&&w===null){if(k.length>1&&!N.ctrl&&!N.meta){V(k);return}if(N.escape)e();else if(N.ctrl&&k==="a")u($=>$==="rgb"?"hex":$==="hex"?"hsl":"rgb");else if(N.upArrow)g($=>Math.max(0,$-1));else if(N.downArrow)g($=>Math.min(O.length+1,$+1));else if(N.return)if(d===0)p("name"),I(l.name),S(l.name);else if(d===1)p("id"),I(l.id),S(l.id);else{const $=d-2,z=O[$],W=l.colors[z];x($),I(W),S(W)}}else if(f!==null)N.ctrl&&k==="a"&&u($=>$==="rgb"?"hex":$==="hex"?"hsl":"rgb");else if(w!==null)if(N.return){if(w==="id"){const $=i;o(b),r(z=>{const W=z.themes.findIndex(X=>X.id===$);W!==-1&&(z.themes[W].id=b)})}else E($=>{$.name=b});p(null),I(""),S("")}else N.escape?(p(null),I(""),S("")):N.backspace||N.delete?I($=>$.slice(0,-1)):k&&I($=>$+k)});const O=Object.keys(l.colors),R=(k,N)=>{const $=k.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!$)return k;const z=parseInt($[1]),W=parseInt($[2]),X=parseInt($[3]);switch(N){case"hex":{const G=_=>_.toString(16).padStart(2,"0");return`#${G(z)}${G(W)}${G(X)}`}case"hsl":{const G=z/255,_=W/255,y=X/255,C=Math.max(G,_,y),A=Math.min(G,_,y),v=C-A,U=(C+A)/2;let q=0;v!==0&&(q=U>.5?v/(2-C-A):v/(C+A));let K=0;return v!==0&&(C===G?K=((_-y)/v+(_<y?6:0))/6:C===_?K=((y-G)/v+2)/6:K=((G-_)/v+4)/6),`hsl(${Math.round(K*360)}, ${Math.round(q*100)}%, ${Math.round(U*100)}%)`}case"rgb":default:return k}},D=k=>({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"})[k]||"",J=Math.max(...O.map(k=>k.length));return h(m,{children:[h(m,{flexDirection:"column",width:"50%",children:[s(m,{children:h(fe,{children:["Editing theme “",l.name,"” (",l.id,")"]})}),f===null&&w===null?h($e,{children:[h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{dimColor:!0,children:"enter to edit theme name, id, or color"}),s(a,{dimColor:!0,children:"ctrl+a to toggle rgb, hex, hsl"}),s(a,{dimColor:!0,children:"paste color from clipboard (when on color)"}),s(a,{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(a,{bold:!0,children:d===0?"Theme Name":"Theme ID"}),s(a,{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(at,{colorKey:O[d-2],theme:l,bold:!0}),s(a,{children:D(O[d-2])})]}),h(m,{flexDirection:"column",children:[h(m,{children:[s(a,{color:d===0?"yellow":"white",children:d===0?"❯ ":" "}),s(a,{bold:!0,children:"Name: "}),s(a,{children:l.name})]}),h(m,{marginBottom:1,children:[s(a,{color:d===1?"yellow":"white",children:d===1?"❯ ":" "}),s(a,{bold:!0,children:"ID: "}),s(a,{children:l.id})]}),(()=>{if(d<2){const G=O.slice(0,20);return h($e,{children:[G.map((_,y)=>{const C=y+2;return h(m,{children:[s(a,{color:d===C?"yellow":"white",children:d===C?"❯ ":" "}),s(m,{width:J+2,children:s(a,{children:s(at,{colorKey:_,theme:l,bold:!0})})}),s(H,{color:l.colors[_],children:R(l.colors[_],c)})]},_)}),O.length>20&&h(a,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-20," more below"]})]})}const N=d-2,$=Math.max(0,N-Math.floor(20/2)),z=Math.min(O.length,$+20),W=Math.max(0,z-20),X=O.slice(W,z);return h($e,{children:[W>0&&h(a,{color:"gray",dimColor:!0,children:[" ","↑ ",W," more above"]}),X.map((G,_)=>{const C=W+_+2;return h(m,{children:[s(a,{color:d===C?"yellow":"white",children:d===C?"❯ ":" "}),s(m,{width:J+2,children:s(a,{children:s(at,{colorKey:G,theme:l,bold:!0})})}),s(H,{color:l.colors[G],children:R(l.colors[G],c)})]},G)}),z<O.length&&h(a,{color:"gray",dimColor:!0,children:[" ","↓ ",O.length-z," more below"]})]})})()]})]}):w?h(m,{flexDirection:"column",marginTop:1,children:[h(a,{children:["Editing ",w==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(a,{children:b})}),s(a,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(cn,{initialValue:T,colorKey:O[f],theme:l,onColorChange:k=>{I(k),E(N=>{N.colors[O[f]]=k})},onExit:()=>{E(k=>{k.colors[O[f]]=b}),x(null),I(""),S("")}})]}),s(m,{width:"50%",children:s(an,{theme:l})})]})}function Ko(e){return e.map(n=>`${n.name} (${n.id})`)}function Qo({onBack:e}){const{settings:{themes:n},updateSettings:t}=pe(he),[r,i]=B(0),[o,l]=B(null),[c,u]=B(!0),d=()=>{const b={colors:{...(n[0]||ee.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};t(I=>{I.themes.push(b)}),l(b.id),u(!1)},g=p=>{n.length<=1||(t(b=>{b.themes=b.themes.filter(I=>I.id!==p)}),r>=n.length-1&&i(Math.max(0,n.length-2)))},f=()=>{t(p=>{p.themes=[...ee.themes]}),i(0)};if(de((p,b)=>{if(b.escape)e();else if(b.upArrow)i(I=>Math.max(0,I-1));else if(b.downArrow)i(I=>Math.min(n.length-1,I+1));else if(b.return){const I=n[r];I&&(l(I.id),u(!1))}else if(p==="n")d();else if(p==="d"){const I=n[r];I&&g(I.id)}else b.ctrl&&p==="r"&&f()},{isActive:c}),o)return s(qo,{themeId:o,onBack:()=>{l(null),u(!0)}});const x=Ko(n),w=n.find(p=>x[r]?.includes(`(${p.id})`))||n[0];return n.length===0?s(m,{children:h(m,{flexDirection:"column",width:"100%",children:[s(fe,{children:"Themes"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{dimColor:!0,children:"n to create a new theme"}),s(a,{dimColor:!0,children:"esc to go back"})]}),s(a,{children:"No themes available!"})]})}):h(m,{children:[h(m,{flexDirection:"column",width:"50%",children:[s(fe,{children:"Themes"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{dimColor:!0,children:"n to create a new theme"}),s(a,{dimColor:!0,children:"d to delete a theme"}),s(a,{dimColor:!0,children:"ctrl+r to delete all themes and restore built-in"}),s(a,{dimColor:!0,children:"enter to edit theme"}),s(a,{dimColor:!0,children:"esc to go back"})]}),s(m,{flexDirection:"column",children:x.map((p,b)=>h(a,{color:r===b?"yellow":void 0,children:[r===b?"❯ ":" ",p]},b))})]}),s(m,{width:"50%",children:s(an,{theme:w})})]})}function Zo({onBack:e}){const{settings:{thinkingVerbs:{format:n,verbs:t},themes:r},updateSettings:i}=pe(he),o=["format","verbs"],[l,c]=B(0),u=o[l],[d,g]=B(0),[f,x]=B(!1),[w,p]=B(""),[b,I]=B(!1),[T,S]=B(!1),[E,V]=B(n),O=nt(),D=(r.find(k=>k.id===O)||r.find(k=>k.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((k,N)=>{if(T){N.return?(i($=>{$.thinkingVerbs.format=E}),S(!1)):N.escape?(V(n),S(!1)):N.backspace||N.delete?V($=>$.slice(0,-1)):k&&V($=>$+k);return}if(f||b){N.return&&w.trim()?(b?(i($=>{$.thinkingVerbs.verbs.push(w.trim())}),I(!1)):(i($=>{$.thinkingVerbs.verbs[d]=w.trim()}),x(!1)),p("")):N.escape?(p(""),x(!1),I(!1)):N.backspace||N.delete?p($=>$.slice(0,-1)):k&&p($=>$+k);return}N.escape?e():N.return?u==="format"&&(V(n),S(!0)):N.tab?N.shift?c($=>$===0?o.length-1:$-1):c($=>$===o.length-1?0:$+1):N.upArrow?u==="verbs"&&t.length>0&&g($=>$>0?$-1:t.length-1):N.downArrow?u==="verbs"&&t.length>0&&g($=>$<t.length-1?$+1:0):k==="e"&&u==="verbs"?t.length>0&&(p(t[d]),x(!0)):k==="d"&&u==="verbs"?t.length>1&&(i($=>{$.thinkingVerbs.verbs=$.thinkingVerbs.verbs.filter((z,W)=>W!==d)}),d>=t.length-1&&g(Math.max(0,t.length-2))):k==="n"&&u==="verbs"?(I(!0),p("")):N.ctrl&&k==="r"&&u==="verbs"&&(i($=>{$.thinkingVerbs.verbs=[...ee.thinkingVerbs.verbs]}),g(0))});const J=50;return h(m,{children:[h(m,{flexDirection:"column",width:`${100-J}%`,children:[h(m,{marginBottom:1,flexDirection:"column",children:[s(fe,{children:"Thinking Verbs"}),h(m,{flexDirection:"column",children:[s(a,{dimColor:!0,children:u==="format"?"enter to edit format":"changes auto-saved"}),s(a,{dimColor:!0,children:"esc to go back"}),s(a,{dimColor:!0,children:"tab to switch sections"})]})]}),s(m,{marginBottom:1,children:s(a,{dimColor:!0,children:"Customize the verbs shown during generation and their format."})}),h(m,{flexDirection:"column",children:[h(a,{children:[s(a,{color:u==="format"?"yellow":void 0,children:u==="format"?"❯ ":" "}),s(a,{bold:!0,color:u==="format"?"yellow":void 0,children:"Format"})]}),u==="format"&&(T?h(a,{dimColor:!0,children:[" ","enter to save"]}):h(a,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:T?"yellow":"gray",children:s(a,{children:T?E:n})})}),s(m,{children:h(a,{children:[s(a,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(a,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:h(a,{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 N=Math.max(0,d-Math.floor(4)),$=Math.min(t.length,N+8),z=Math.max(0,$-8),W=t.slice(z,$);return h($e,{children:[z>0&&h(a,{color:"gray",dimColor:!0,children:[" ","↑ ",z," more above"]}),W.map((X,G)=>{const _=z+G;return h(a,{color:u==="verbs"&&_===d?"cyan":void 0,children:[u==="verbs"&&_===d?"❯ ":" ",X]},_)}),$<t.length&&h(a,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-$," more below"]})]})})(),b&&h(m,{alignItems:"center",children:[s(a,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(a,{children:w})})]}),f&&h(m,{marginTop:1,alignItems:"center",children:[s(a,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(a,{children:w})})]})]})})]}),h(m,{width:`${J}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(a,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:h(a,{children:[h(a,{color:D,children:["✻ ",n.replace(/\{\}/g,t[d])," "]}),s(a,{children:"(esc to interrupt)"})]})})]})]})}const Ee=[{name:"Default",phases:ee.thinkingStyle.phases,reverseMirror:ee.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 ei({onBack:e}){const{settings:{thinkingStyle:{phases:n,updateInterval:t,reverseMirror:r},themes:i},updateSettings:o}=pe(he),l=["reverseMirror","updateInterval","phases","presets"],[c,u]=B(0),d=l[c],[g,f]=B(0),[x,w]=B(0),[p,b]=B(!1),[I,T]=B(""),[S,E]=B(!1),[V,O]=B(!1),[R,D]=B(t.toString()),[J,k]=B(0),N=nt(),z=(i.find(C=>C.id===N)||i.find(C=>C.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(n.length>0){const C=r?[...n,...[...n].reverse().slice(1,-1)]:n,A=setInterval(()=>{k(v=>(v+1)%C.length)},t);return()=>clearInterval(A)}},[n,t,r]),de((C,A)=>{if(V){if(A.return){const v=parseInt(R);!isNaN(v)&&v>0&&o(U=>{U.thinkingStyle.updateInterval=v}),O(!1)}else A.escape?(D(t.toString()),O(!1)):A.backspace||A.delete?D(v=>v.slice(0,-1)):C&&C.match(/^[0-9]$/)&&D(v=>v+C);return}if(p||S){if(A.return&&I.length){const v=S?[...n,I]:n.map((U,q)=>q===g?I:U);o(U=>{U.thinkingStyle.phases=v}),b(!1),T("")}else A.escape?(T(""),b(!1),E(!1)):A.backspace||A.delete?T(v=>v.slice(0,-1)):C&&T(v=>v+C);return}if(A.escape)e();else if(A.return)if(d==="updateInterval")D(t.toString()),O(!0);else if(d==="presets"){const v=Ee[x];o(U=>{U.thinkingStyle.phases=[...v.phases],U.thinkingStyle.reverseMirror=v.reverseMirror})}else d==="reverseMirror"&&o(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if(A.tab)A.shift?u(v=>v===0?l.length-1:v-1):u(v=>v===l.length-1?0:v+1);else if(A.upArrow)d==="phases"&&n.length>0?f(v=>v>0?v-1:n.length-1):d==="presets"&&w(v=>v>0?v-1:Ee.length-1);else if(A.downArrow)d==="phases"&&n.length>0?f(v=>v<n.length-1?v+1:0):d==="presets"&&w(v=>v<Ee.length-1?v+1:0);else if(C===" ")d==="reverseMirror"&&o(v=>{v.thinkingStyle.reverseMirror=!v.thinkingStyle.reverseMirror});else if(C==="e"&&d==="phases")n.length>0&&(T(n[g]),b(!0));else if(C==="a"&&d==="phases")E(!0),T("");else if(C==="d"&&d==="phases")n.length>1&&(o(v=>{v.thinkingStyle.phases=n.filter((U,q)=>q!==g)}),g>=n.length&&f(Math.max(0,n.length-1)));else if(C==="w"&&d==="phases"){if(g>0){const v=[...n];[v[g-1],v[g]]=[v[g],v[g-1]],o(U=>{U.thinkingStyle.phases=v}),f(U=>U-1)}}else if(C==="s"&&d==="phases"){if(g<n.length-1){const v=[...n];[v[g],v[g+1]]=[v[g+1],v[g]],o(U=>{U.thinkingStyle.phases=v}),f(U=>U+1)}}else A.ctrl&&C==="r"&&(o(v=>{v.thinkingStyle=ee.thinkingStyle}),f(0),w(0))});const W=r?"●":"○",X=50,_=r?[...n,...[...n].reverse().slice(1,-1)]:n,y=_.length>0?_[J]:"·";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-X}%`,children:[s(fe,{children:"Thinking style"}),h(m,{flexDirection:"column",children:[h(a,{dimColor:!0,children:["enter to"," ",d==="updateInterval"?"edit interval":d==="presets"?"apply preset":"save"]}),s(a,{dimColor:!0,children:"esc to go back"}),s(a,{dimColor:!0,children:"tab to switch sections"})]})]}),h(m,{width:`${X}%`,flexDirection:"column",children:[s(m,{children:s(a,{bold:!0,children:"Preview"})}),h(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:(y?.length??0)+1,children:s(a,{color:z,children:y})}),h(a,{children:[s(a,{color:z,children:"Thinking… "}),s(a,{children:"(esc to interrupt)"})]})]})]})]}),h(m,{flexDirection:"row",gap:4,children:[h(m,{flexDirection:"column",children:[h(a,{children:[s(a,{color:d==="reverseMirror"?"yellow":void 0,children:d==="reverseMirror"?"❯ ":" "}),s(a,{bold:!0,color:d==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),d==="reverseMirror"&&h(a,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:h(a,{children:[W," ",r?"Enabled":"Disabled"]})})]}),h(m,{flexDirection:"column",children:[h(a,{children:[s(a,{color:d==="updateInterval"?"yellow":void 0,children:d==="updateInterval"?"❯ ":" "}),s(a,{bold:!0,color:d==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),d==="updateInterval"&&(V?h(a,{dimColor:!0,children:[" ","enter to save"]}):h(a,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:V?"yellow":"gray",children:s(a,{children:V?R:t})})})]})]}),s(m,{children:h(a,{children:[s(a,{color:d==="phases"?"yellow":void 0,children:d==="phases"?"❯ ":" "}),s(a,{bold:!0,color:d==="phases"?"yellow":void 0,children:"Phases"})]})}),d==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:h(a,{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 A=Math.max(0,g-Math.floor(4)),v=Math.min(n.length,A+8),U=Math.max(0,v-8),q=n.slice(U,v);return h($e,{children:[U>0&&h(a,{color:"gray",dimColor:!0,children:[" ","↑ ",U," more above"]}),q.map((K,te)=>{const ie=U+te;return h(a,{color:d==="phases"&&ie===g?"cyan":void 0,children:[d==="phases"&&ie===g?"❯ ":" ",K]},ie)}),v<n.length&&h(a,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-v," more below"]})]})})(),S&&h(m,{children:[s(a,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(a,{children:I})})]}),p&&h(m,{marginTop:1,children:[s(a,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(a,{children:I})})]})]})}),s(m,{children:h(a,{children:[s(a,{color:d==="presets"?"yellow":void 0,children:d==="presets"?"❯ ":" "}),s(a,{bold:!0,color:d==="presets"?"yellow":void 0,children:"Presets"})]})}),d==="presets"&&h(a,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const A=Math.max(0,x-Math.floor(4)),v=Math.min(Ee.length,A+8),U=Math.max(0,v-8),q=Ee.slice(U,v);return h($e,{children:[U>0&&h(a,{color:"gray",dimColor:!0,children:[" ","↑ ",U," more above"]}),q.map((K,te)=>{const ie=U+te;return h(a,{color:d==="presets"&&ie===x?"cyan":void 0,children:[d==="presets"&&ie===x?"❯ ":" ",K.name," ",K.phases.join("")]},ie)}),v<Ee.length&&h(a,{color:"gray",dimColor:!0,children:[" ","↓ ",Ee.length-v," more below"]})]})})()})}),s(m,{marginTop:1,children:s(a,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}function ti(e,n){const t=$n(!0);xe(()=>{if(t.current){t.current=!1;return}return e()},n)}const ut=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}],ve=[{label:"none",value:"none"},{label:"single",value:"single"},{label:"double",value:"double"},{label:"round",value:"round"},{label:"bold",value:"bold"},{label:"singleDouble",value:"singleDouble"},{label:"doubleSingle",value:"doubleSingle"},{label:"classic",value:"classic"},{label:"topBottomSingle",value:"topBottomSingle"},{label:"topBottomDouble",value:"topBottomDouble"},{label:"topBottomBold",value:"topBottomBold"}];function ni({onBack:e}){const{settings:n,updateSettings:t}=pe(he),[r,i]=B(!1),[o,l]=B(!1),[c,u]=B(!1),[d,g]=B(()=>n.userMessageDisplay.format),[f,x]=B(()=>String(n.userMessageDisplay.paddingX)),[w,p]=B(()=>String(n.userMessageDisplay.paddingY)),[b,I]=B(n.userMessageDisplay.fitBoxToContent),[T,S]=B(0),[E,V]=B(()=>[...n.userMessageDisplay.styling]),[O,R]=B(()=>n.userMessageDisplay.foregroundColor==="default"?"default":"custom"),[D,J]=B(()=>n.userMessageDisplay.foregroundColor==="default"?"rgb(255,255,255)":n.userMessageDisplay.foregroundColor),[k,N]=B(()=>{const j=n.userMessageDisplay.backgroundColor;return j===null?"none":j==="default"?"default":"custom"}),[$,z]=B(()=>{const j=n.userMessageDisplay.backgroundColor;return j===null||j==="default"?"rgb(0,0,0)":j}),[W,X]=B(()=>ve.findIndex(j=>j.value===n.userMessageDisplay.borderStyle)),[G,_]=B(()=>n.userMessageDisplay.borderColor),[y,C]=B(null),[A,v]=B(""),U=nt(),q=n.themes?.find(j=>j.id===U)||n.themes?.[0],[K,te]=B("text"),ie=["format","styling","foreground","background"],be=["borderStyle","borderColor","paddingX","paddingY","fitBoxToContent"],[ye,Ge]=B(0),[ot,Ye]=B(0),P=K==="text"?ie[ye]:be[ot],it=()=>{t(j=>{j.userMessageDisplay.format=d,j.userMessageDisplay.styling=[...E],j.userMessageDisplay.foregroundColor=O==="default"?"default":D,j.userMessageDisplay.backgroundColor=k==="none"?null:k==="default"?"default":$,j.userMessageDisplay.borderStyle=ve[W].value,j.userMessageDisplay.borderColor=G,j.userMessageDisplay.paddingX=parseInt(f)||0,j.userMessageDisplay.paddingY=parseInt(w)||0,j.userMessageDisplay.fitBoxToContent=b})},xn=()=>{g(ee.userMessageDisplay.format),V([...ee.userMessageDisplay.styling]),R("default"),J("rgb(255,255,255)"),N("none"),z("rgb(0,0,0)"),X(ve.findIndex(j=>j.value===ee.userMessageDisplay.borderStyle)),_(ee.userMessageDisplay.borderColor),x(String(ee.userMessageDisplay.paddingX)),p(String(ee.userMessageDisplay.paddingY)),I(ee.userMessageDisplay.fitBoxToContent),t(j=>{j.userMessageDisplay={...ee.userMessageDisplay}})};ti(()=>{it()},[d,E,O,D,k,$,W,G,f,w,b]),de((j,Q)=>{if(r){Q.return?i(!1):Q.escape?(g(n.userMessageDisplay.format),i(!1)):Q.backspace||Q.delete?g(L=>L.slice(0,-1)):j&&g(L=>L+j);return}if(o){Q.return?l(!1):Q.escape?(x(String(n.userMessageDisplay.paddingX)),l(!1)):Q.backspace||Q.delete?x(L=>L.slice(0,-1)):j&&/^\d$/.test(j)&&x(L=>L+j);return}if(c){Q.return?u(!1):Q.escape?(p(String(n.userMessageDisplay.paddingY)),u(!1)):Q.backspace||Q.delete?p(L=>L.slice(0,-1)):j&&/^\d$/.test(j)&&p(L=>L+j);return}if(y===null){if(Q.escape)e();else if(Q.ctrl&&j==="r")xn();else if(Q.leftArrow||Q.rightArrow)te(L=>L==="text"?"border":"text");else if(Q.tab)K==="text"?Q.shift?Ge(L=>L===0?ie.length-1:L-1):Ge(L=>L===ie.length-1?0:L+1):Q.shift?Ye(L=>L===0?be.length-1:L-1):Ye(L=>L===be.length-1?0:L+1);else if(Q.return)P==="format"?i(!0):P==="paddingX"?l(!0):P==="paddingY"?u(!0):P==="foreground"?O==="custom"&&(v(D),C("foreground")):P==="background"?k==="custom"&&(v($),C("background")):P==="borderColor"&&(v(G),C("border"));else if(Q.upArrow)P==="styling"?S(L=>Math.max(0,L-1)):P==="borderStyle"?X(L=>L===0?ve.length-1:L-1):P==="foreground"?R(L=>{const ne=L==="default"?"custom":"default";return ne==="custom"&&(!D||D==="")&&J("rgb(255,255,255)"),ne}):P==="background"&&N(L=>{const ne=L==="default"?"custom":L==="custom"?"none":"default";return ne==="custom"&&(!$||$==="")&&z("rgb(0,0,0)"),ne});else if(Q.downArrow)P==="styling"?S(L=>Math.min(ut.length-1,L+1)):P==="borderStyle"?X(L=>L===ve.length-1?0:L+1):P==="foreground"?R(L=>{const ne=L==="default"?"custom":"default";return ne==="custom"&&(!D||D==="")&&J("rgb(255,255,255)"),ne}):P==="background"&&N(L=>{const ne=L==="default"?"none":L==="none"?"custom":"default";return ne==="custom"&&(!$||$==="")&&z("rgb(0,0,0)"),ne});else if(j===" ")if(P==="styling"){const L=ut[T].value,ne=E.indexOf(L)>=0?E.filter(Ie=>Ie!==L):[...E,L];V(ne)}else P==="fitBoxToContent"&&I(L=>!L)}});const Sn=j=>{const Q=O==="default"?q?.colors?.text:D,L=k==="none"?void 0:k==="default"?q?.colors?.userMessageBackground:$,ne=ve[W].value,Ie=parseInt(f)||0,Te=parseInt(w)||0,We=s(a,{bold:E.includes("bold"),italic:E.includes("italic"),underline:E.includes("underline"),strikethrough:E.includes("strikethrough"),inverse:E.includes("inverse"),color:Q,backgroundColor:L,children:j});if(ne==="topBottomSingle"||ne==="topBottomDouble"||ne==="topBottomBold"){const ze=ne==="topBottomSingle"?"─":ne==="topBottomDouble"?"═":"━",Me=j.length+Ie*2,It=ze.repeat(Me);return h(m,{flexDirection:"column",children:[s(a,{color:G,children:It}),Te>0&&s(m,{height:Te}),s(m,{paddingX:Ie,children:We}),Te>0&&s(m,{height:Te}),s(a,{color:G,children:It})]})}else if(ne!=="none"||Ie>0||Te>0||b){const ze=Ie>0||Te>0?s(m,{paddingX:Ie,paddingY:Te,children:We}):We,Me={};return ne!=="none"&&(Me.borderStyle=ne,Me.borderColor=G),b?Me.alignSelf="flex-start":Me.flexGrow=1,ne==="none"?ze:s(m,{...Me,children:ze})}else return We},yn=()=>{const Q=d.replace(/\{\}/g,"list the dir");return Sn(Q)};return y?s(cn,{initialValue:A,theme:q,onColorChange:j=>{y==="foreground"?J(j):y==="background"?z(j):y==="border"&&_(j)},onExit:()=>{C(null),v("")}}):h(m,{flexDirection:"column",children:[s(fe,{children:"Customize how user messages are displayed"}),h(m,{flexDirection:"column",marginBottom:1,children:[s(a,{dimColor:!0,children:"left/right arrows to switch columns · tab to navigate options"}),s(a,{dimColor:!0,children:"enter to edit · ctrl+r to reset · esc to go back"})]}),h(m,{flexDirection:"row",gap:1,children:[h(m,{flexDirection:"column",width:"50%",borderStyle:K==="text"?"round":"single",borderColor:K==="text"?"yellow":"gray",paddingX:1,children:[s(m,{marginBottom:1,children:s(a,{bold:!0,color:K==="text"?"yellow":void 0,children:"Text & Styling"})}),s(m,{children:h(a,{color:P==="format"?"yellow":void 0,bold:P==="format",children:[P==="format"?"❯ ":" ","Format String"]})}),P==="format"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:r?"enter to save · esc to cancel":"enter to edit · use {} as message placeholder"})}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:r?"yellow":"gray",children:s(a,{children:d})})}),s(m,{children:h(a,{color:P==="styling"?"yellow":void 0,bold:P==="styling",children:[P==="styling"?"❯ ":" ","Styling"]})}),P==="styling"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:ut.map((j,Q)=>s(m,{children:h(a,{color:P==="styling"&&T===Q?"cyan":void 0,children:[P==="styling"&&T===Q?"❯ ":" ",E.includes(j.value)?"●":"○"," ",j.label]})},j.value))}),h(m,{flexDirection:"row",gap:1,marginBottom:1,children:[h(m,{flexDirection:"column",width:"50%",children:[s(m,{children:h(a,{color:P==="foreground"?"yellow":void 0,bold:P==="foreground",children:[P==="foreground"?"❯ ":" ","Foreground"]})}),P==="foreground"&&s(m,{marginLeft:2,children:h(a,{dimColor:!0,children:["up/down · ",O==="custom"?"enter":""]})}),h(m,{marginLeft:2,flexDirection:"column",children:[s(m,{children:h(a,{children:[O==="default"?"● ":"○ ","Default"]})}),s(m,{children:h(a,{children:[O==="custom"?"● ":"○ ","Custom",O==="custom"&&": ",O==="custom"&&s(a,{color:D,children:D})]})})]})]}),h(m,{flexDirection:"column",width:"50%",children:[s(m,{children:h(a,{color:P==="background"?"yellow":void 0,bold:P==="background",children:[P==="background"?"❯ ":" ","Background"]})}),P==="background"&&s(m,{marginLeft:2,children:h(a,{dimColor:!0,children:["up/down · ",k==="custom"?"enter":""]})}),h(m,{marginLeft:2,flexDirection:"column",children:[s(m,{children:h(a,{children:[k==="default"?"● ":"○ ","Default"]})}),s(m,{children:h(a,{children:[k==="none"?"● ":"○ ","None"]})}),s(m,{children:h(a,{children:[k==="custom"?"● ":"○ ","Custom",k==="custom"&&": ",k==="custom"&&s(a,{backgroundColor:$,children:$})]})})]})]})]})]}),h(m,{flexDirection:"column",width:"50%",borderStyle:K==="border"?"round":"single",borderColor:K==="border"?"yellow":"gray",paddingX:1,children:[s(m,{marginBottom:1,children:s(a,{bold:!0,color:K==="border"?"yellow":void 0,children:"Border & Padding"})}),s(m,{children:h(a,{color:P==="borderStyle"?"yellow":void 0,bold:P==="borderStyle",children:[P==="borderStyle"?"❯ ":" ","Border Style"]})}),P==="borderStyle"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:"up/down to navigate"})}),h(m,{marginLeft:2,marginBottom:1,flexDirection:"row",children:[s(m,{flexDirection:"column",width:"50%",children:ve.slice(0,6).map((j,Q)=>s(m,{children:h(a,{color:P==="borderStyle"&&W===Q?"cyan":void 0,children:[P==="borderStyle"&&W===Q?"❯ ":" ",W===Q?"● ":"○ ",j.label]})},j.value))}),s(m,{flexDirection:"column",width:"50%",children:ve.slice(6).map((j,Q)=>{const L=Q+6;return s(m,{children:h(a,{color:P==="borderStyle"&&W===L?"cyan":void 0,children:[P==="borderStyle"&&W===L?"❯ ":" ",W===L?"● ":"○ ",j.label]})},j.value)})})]}),s(m,{children:h(a,{color:P==="borderColor"?"yellow":void 0,bold:P==="borderColor",children:[P==="borderColor"?"❯ ":" ","Border Color"]})}),P==="borderColor"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:"enter to pick color"})}),s(m,{marginLeft:2,marginBottom:1,children:s(a,{color:G,children:G})}),h(m,{flexDirection:"row",gap:1,children:[h(m,{flexDirection:"column",width:"33%",children:[s(m,{children:h(a,{color:P==="paddingX"?"yellow":void 0,bold:P==="paddingX",children:[P==="paddingX"?"❯ ":" ","Padding X"]})}),P==="paddingX"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:o?"enter/esc":"enter"})}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:o?"yellow":"gray",children:s(a,{children:f})})})]}),h(m,{flexDirection:"column",width:"33%",children:[s(m,{children:h(a,{color:P==="paddingY"?"yellow":void 0,bold:P==="paddingY",children:[P==="paddingY"?"❯ ":" ","Padding Y"]})}),P==="paddingY"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:c?"enter/esc":"enter"})}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:c?"yellow":"gray",children:s(a,{children:w})})})]}),h(m,{flexDirection:"column",width:"33%",children:[s(m,{children:h(a,{color:P==="fitBoxToContent"?"yellow":void 0,bold:P==="fitBoxToContent",children:[P==="fitBoxToContent"?"❯ ":" ",b?"●":"○"," Fit box to content"]})}),P==="fitBoxToContent"&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:"space"})})]})]})]})]}),h(m,{flexDirection:"column",marginTop:1,paddingX:1,children:[s(m,{marginBottom:1,children:s(a,{bold:!0,children:"Preview"})}),h(m,{flexDirection:"row",gap:2,children:[h(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(a,{underline:!0,children:"Before (Claude Code default):"})}),s(m,{marginLeft:1,children:h(a,{backgroundColor:q?.colors?.userMessageBackground,color:q?.colors?.text,children:[" ","> list the dir"," "]})}),s(m,{marginLeft:1,marginTop:1,children:h(a,{children:[s(a,{color:q?.colors?.inactive||"#888888",children:"●"}),s(a,{children:" The directory "}),s(a,{color:q?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(a,{children:" contains "}),s(a,{bold:!0,children:"123"}),s(a,{children:" files."})]})})]}),h(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(a,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,flexDirection:"row",children:yn()}),s(m,{marginLeft:1,marginTop:1,children:h(a,{children:[s(a,{color:q?.colors?.inactive||"#888888",children:"●"}),s(a,{children:" The directory "}),s(a,{color:q?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(a,{children:" contains "}),s(a,{bold:!0,children:"123"}),s(a,{children:" files."})]})})]})]})]})]})}const Ae=4;function ri({onSubmit:e}){const{settings:n,updateSettings:t}=pe(he),[r,i]=B(0),o={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEditPrompt:!1,hideStartupClawd:!1},l=()=>{n.misc||(n.misc={...o})},c=Tt(()=>[{id:"removeBorder",title:"Remove input box border",description:"Removes the rounded border around the input box for a cleaner look.",getValue:()=>n.inputBox?.removeBorder??!1,toggle:()=>{t(p=>{p.inputBox||(p.inputBox={removeBorder:!1}),p.inputBox.removeBorder=!p.inputBox.removeBorder})}},{id:"showVersion",title:"Show tweakcc version at startup",description:'Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.',getValue:()=>n.misc?.showTweakccVersion??!0,toggle:()=>{t(p=>{l(),p.misc.showTweakccVersion=!p.misc.showTweakccVersion})}},{id:"showPatches",title:"Show patches applied indicator at startup",description:'Shows the green "tweakcc patches are applied" indicator when starting Claude Code.',getValue:()=>n.misc?.showPatchesApplied??!0,toggle:()=>{t(p=>{l(),p.misc.showPatchesApplied=!p.misc.showPatchesApplied})}},{id:"expandThinking",title:"Expand thinking blocks",description:"Makes thinking blocks always expanded by default instead of collapsed.",getValue:()=>n.misc?.expandThinkingBlocks??!0,toggle:()=>{t(p=>{l(),p.misc.expandThinkingBlocks=!p.misc.expandThinkingBlocks})}},{id:"conversationTitle",title:"Allow renaming sessions via /title",description:"Enables /title and /rename commands for manually naming conversations.",getValue:()=>n.misc?.enableConversationTitle??!0,toggle:()=>{t(p=>{l(),p.misc.enableConversationTitle=!p.misc.enableConversationTitle})}},{id:"hideStartupBanner",title:"Hide startup banner",description:"Hides the startup banner message displayed before first prompt.",getValue:()=>n.misc?.hideStartupBanner??!1,toggle:()=>{t(p=>{l(),p.misc.hideStartupBanner=!p.misc.hideStartupBanner})}},{id:"hideCtrlG",title:"Hide ctrl-g to edit prompt hint",description:'Hides the "ctrl-g to edit prompt" hint shown during streaming.',getValue:()=>n.misc?.hideCtrlGToEditPrompt??!1,toggle:()=>{t(p=>{l(),p.misc.hideCtrlGToEditPrompt=!p.misc.hideCtrlGToEditPrompt})}},{id:"hideClawd",title:"Hide startup Clawd ASCII art",description:"Hides the Clawd ASCII art character shown at startup.",getValue:()=>n.misc?.hideStartupClawd??!1,toggle:()=>{t(p=>{l(),p.misc.hideStartupClawd=!p.misc.hideStartupClawd})}}],[n,t]),u=c.length,d=u-1,g=Tt(()=>r<Ae?0:Math.min(r-Ae+1,u-Ae),[r,u]),f=c.slice(g,g+Ae),x=g>0,w=g+Ae<u;return de((p,b)=>{b.return||b.escape?e():b.upArrow?i(I=>Math.max(0,I-1)):b.downArrow?i(I=>Math.min(d,I+1)):p===" "&&c[r]?.toggle()}),h(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(fe,{children:"Miscellaneous Settings"})}),s(m,{marginBottom:1,children:s(a,{dimColor:!0,children:"Various tweaks and customizations. Press space to toggle settings, enter to go back."})}),x&&s(m,{children:h(a,{dimColor:!0,children:[" ↑ ",g," more above"]})}),f.map((p,b)=>{const T=g+b===r,S=p.getValue()?"☑":"☐";return h(m,{flexDirection:"column",children:[s(m,{children:h(a,{children:[s(a,{color:T?"cyan":void 0,children:T?"❯ ":" "}),s(a,{bold:!0,color:T?"cyan":void 0,children:p.title})]})}),s(m,{children:h(a,{dimColor:!0,children:[" ",p.description]})}),s(m,{marginLeft:4,marginBottom:1,children:h(a,{children:[S," ",p.getValue()?"Enabled":"Disabled"]})})]},p.id)}),w&&s(m,{children:h(a,{dimColor:!0,children:[" ","↓ ",u-g-Ae," more below"]})}),s(m,{marginTop:1,children:h(a,{dimColor:!0,children:["Item ",r+1," of ",u]})})]})}const Xe=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","EnterPlanMode","ExitPlanMode","LSP"];function oi({toolsetIndex:e,onBack:n}){const{settings:t,updateSettings:r}=pe(he),i=t.toolsets[e],[o,l]=B(i?.name||"New Toolset"),[c,u]=B(i?.allowedTools||[]),[d,g]=B(!1),[f,x]=B(0);xe(()=>{i&&r(T=>{const S=T.toolsets[e].name;T.toolsets[e].name=o,T.toolsets[e].allowedTools=c,S!==o&&(T.defaultToolset===S&&(T.defaultToolset=o),T.planModeToolset===S&&(T.planModeToolset=o))})},[o,c]);const w=T=>c==="*"?!0:c.includes(T),p=T=>{T==="All"?u("*"):T==="None"?u([]):c==="*"?u(Xe.filter(S=>S!==T)):c.includes(T)?u(c.filter(S=>S!==T)):u([...c,T])};if(de((T,S)=>{if(d){S.return?g(!1):S.escape?(l(i?.name||"New Toolset"),g(!1)):S.backspace||S.delete?l(E=>E.slice(0,-1)):T&&T.length===1&&l(E=>E+T);return}if(S.escape)n();else if(S.upArrow)x(E=>Math.max(0,E-1));else if(S.downArrow)x(E=>Math.min(Xe.length+1,E+1));else if(T===" "||S.return)if(f===0)p("All");else if(f===1)p("None");else{const E=Xe[f-2];E&&p(E)}else T==="n"&&g(!0)}),!i)return s(m,{flexDirection:"column",children:s(a,{color:"red",children:"Toolset not found"})});const b=c==="*",I=Array.isArray(c)&&c.length===0;return h(m,{flexDirection:"column",children:[s(fe,{children:"Edit Toolset"}),s(m,{marginBottom:1,flexDirection:"column",children:s(a,{dimColor:!0,children:"n to edit name · space/enter to toggle · esc to go back"})}),h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{bold:!0,children:"Name:"}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:d?"yellow":"gray",children:s(a,{children:o})})}),d&&s(m,{marginLeft:2,children:s(a,{dimColor:!0,children:"enter to save · esc to cancel"})})]}),h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{bold:!0,children:"Allowed Tools:"}),s(m,{marginLeft:2,children:h(a,{color:f===0?"cyan":void 0,children:[f===0?"❯ ":" ",b?"●":"○"," All"]})}),s(m,{marginLeft:2,children:h(a,{color:f===1?"cyan":void 0,children:[f===1?"❯ ":" ",I?"●":"○"," None"]})}),Xe.map((T,S)=>{const E=S+2;return s(m,{marginLeft:2,children:h(a,{color:f===E?"cyan":void 0,children:[f===E?"❯ ":" ",w(T)?"◉":"○"," ",T]})},T)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:h(m,{flexDirection:"column",children:[s(a,{bold:!0,children:"Summary:"}),h(a,{children:["Name: ",s(a,{color:"cyan",children:o})]}),h(a,{children:["Tools:"," ",c==="*"?s(a,{color:"green",children:"All tools (*)"}):c.length===0?s(a,{color:"red",children:"No tools ([])"}):h(a,{color:"yellow",children:[c.length," selected"]})]})]})})]})}function ii({onBack:e}){const{settings:{toolsets:n,defaultToolset:t,planModeToolset:r,themes:i},updateSettings:o}=pe(he),l=nt(),c=i.find(R=>R.id===l)||i[0],u=ee.themes[0],d=c?.colors.planMode||u.colors.planMode,g=c?.colors.autoAccept||u.colors.autoAccept,[f,x]=B(0),[w,p]=B(null),[b,I]=B(!0),T=()=>{const R={name:"New Toolset",allowedTools:[]};o(D=>{D.toolsets.push(R)}),p(n.length),I(!1)},S=R=>{const D=n[R];o(J=>{J.toolsets.splice(R,1),J.defaultToolset===D.name&&(J.defaultToolset=null),J.planModeToolset===D.name&&(J.planModeToolset=null)}),f>=n.length-1&&x(Math.max(0,n.length-2))},E=R=>{const D=n[R];o(J=>{J.defaultToolset=D.name})},V=R=>{const D=n[R];o(J=>{J.planModeToolset=D.name})};if(de((R,D)=>{D.escape?e():D.upArrow?x(J=>Math.max(0,J-1)):D.downArrow?x(J=>Math.min(n.length-1,J+1)):D.return&&n.length>0?(p(f),I(!1)):R==="n"?T():R==="x"&&n.length>0?S(f):R==="d"&&n.length>0?E(f):R==="p"&&n.length>0&&V(f)},{isActive:b}),w!==null)return s(oi,{toolsetIndex:w,onBack:()=>{p(null),I(!0)}});const O=R=>R.allowedTools==="*"?"All tools":R.allowedTools.length===0?"No tools":`${R.allowedTools.length} tool${R.allowedTools.length===1?"":"s"}`;return h(m,{flexDirection:"column",children:[s(fe,{children:"Toolsets"}),h(m,{marginBottom:1,flexDirection:"column",children:[s(a,{dimColor:!0,children:"n to create a new toolset"}),n.length>0&&s(a,{dimColor:!0,children:"d to set as default toolset"}),n.length>0&&s(a,{dimColor:!0,children:"p to set as plan mode toolset"}),n.length>0&&s(a,{dimColor:!0,children:"x to delete a toolset"}),n.length>0&&s(a,{dimColor:!0,children:"enter to edit toolset"}),s(a,{dimColor:!0,children:"esc to go back"})]}),n.length===0?s(a,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:n.map((R,D)=>{const J=R.name===t,k=R.name===r,N=f===D;let $;return N&&($="yellow"),h(m,{flexDirection:"row",children:[h(a,{color:$,children:[N?"❯ ":" ",R.name," "]}),h(a,{color:$,children:["(",O(R),")"]}),J&&s(a,{color:g,children:" ⏵⏵ accept edits"}),k&&s(a,{color:d,children:" ⏸ plan mode"})]},D)})})]})}const he=Cn({settings:ee,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function si({startupCheckInfo:e,configMigrated:n}){const[t,r]=B({settings:ee,changesApplied:!1,ccVersion:"",lastModified:""}),[i,o]=B(!1);xe(()=>{(async()=>{const p=await He();r(p),o(!p.hidePiebaldAnnouncement)})()},[]);const l=Lt(w=>{const p=JSON.parse(JSON.stringify(t.settings));w(p),r(b=>({...b,settings:p,changesApplied:!1})),Ne(b=>{b.settings=p,b.changesApplied=!1})},[t.settings]),[c,u]=B(null),[d,g]=B(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(g({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
659
+ (However, your customization are still remembered in ${ce}.)
660
+ Please reapply your changes below.`,type:"warning"}),l(()=>{}))},[]),de((w,p)=>{p.ctrl&&w==="c"&&process.exit(0),(w==="q"||p.escape)&&!c&&process.exit(0),w==="h"&&!c&&i&&(o(!1),Ne(b=>{b.hidePiebaldAnnouncement=!0}))},{isActive:!c});const f=w=>{switch(g(null),w){case Z.APPLY_CHANGES:e.ccInstInfo&&(g({message:"Applying patches...",type:"info"}),rn(t,e.ccInstInfo).then(p=>{r(p),g({message:"Customization patches applied successfully!",type:"success"})}));break;case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.MISC:case Z.TOOLSETS:u(w);break;case Z.VIEW_SYSTEM_PROMPTS:To(Se);break;case Z.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?en(e.ccInstInfo):Zt(e.ccInstInfo)).then(()=>{g({message:"Original Claude Code restored successfully!",type:"success"}),l(()=>{})});break;case Z.OPEN_CONFIG:At(ce);break;case Z.OPEN_CLI:e.ccInstInfo?.cliPath&&At(e.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},x=()=>{u(null)};return s(he.Provider,{value:{settings:t.settings,updateSettings:l,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:c===null?s(zo,{onSubmit:f,notification:d,configMigrated:n,showPiebaldAnnouncement:i}):c===Z.THEMES?s(Qo,{onBack:x}):c===Z.THINKING_VERBS?s(Zo,{onBack:x}):c===Z.THINKING_STYLE?s(ei,{onBack:x}):c===Z.USER_MESSAGE_DISPLAY?s(ni,{onBack:x}):c===Z.MISC?s(ri,{onSubmit:x}):c===Z.TOOLSETS?s(ii,{onBack:x}):null})})}const li=()=>{const e=[],n=process.platform=="win32"?Ce.homedir().replace(/\\/g,"/"):Ce.homedir(),t="node_modules/@anthropic-ai/claude-code",r=(i,o=!1)=>{if(o)try{const l=Vt(i,{onlyFiles:!1});e.push({pattern:i,isGlob:!0,expandedPaths:l})}catch(l){l instanceof Error&&"code"in l&&(l.code==="EACCES"||l.code==="EPERM")?M(`Permission denied accessing: ${i} (${l.code})`):M(`Error expanding glob pattern "${i}": ${l instanceof Error?l.message:String(l)}`),e.push({pattern:i,isGlob:!0,expandedPaths:[]})}else e.push({pattern:i,isGlob:!1,expandedPaths:[i]})};return r(`${Ce.homedir()}/.claude/local/${t}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${t}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${t}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${t}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${t}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${t}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${t}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${t}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${t}`,!0),process.platform=="win32"?(r(`${n}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${t}`),r(`${n}/AppData/Roaming/npm/${t}`),r(`${n}/AppData/Roaming/nvm/*/${t}`,!0),r(`${n}/AppData/Local/Yarn/config/global/${t}`),r(`${n}/AppData/Local/pnpm/global/*/${t}`,!0),r(`C:/nvm4w/nodejs/${t}`),r(`${n}/n/versions/node/*/lib/${t}`,!0),r(`${n}/AppData/Roaming/Yarn/config/global/${t}`),r(`${n}/AppData/Roaming/pnpm-global/${t}`),r(`${n}/AppData/Roaming/pnpm-global/*/${t}`,!0),r(`${n}/.bun/install/global/${t}`),r(`${n}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${n}/AppData/Local/Bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${n}/AppData/Local/fnm_multishells/*/node_modules/${t}`,!0),r(`${n}/AppData/Local/mise/installs/node/*/${t}`,!0),r(`${n}/AppData/Local/mise/installs/npm-anthropic-ai-claude-code/*/${t}`,!0)):(process.platform=="darwin"&&(r(`${n}/Library/${t}`),r(`/opt/local/lib/${t}`),r(`${n}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${n}/Library/Caches/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0)),r(`${n}/.local/lib/${t}`),r(`${n}/.local/share/${t}`),r(`${n}/.npm-global/lib/${t}`),r(`${n}/.npm-packages/lib/${t}`),r(`${n}/.npm/lib/${t}`),r(`${n}/npm/lib/${t}`),r(`/etc/${t}`),r(`/lib/${t}`),r(`/opt/node/lib/${t}`),r(`/usr/lib/${t}`),r(`/usr/local/lib/${t}`),r(`/usr/share/${t}`),r(`/var/lib/${t}`),r(`/opt/homebrew/lib/${t}`),r(`${n}/.linuxbrew/lib/${t}`),r(`${n}/.config/yarn/global/${t}`),r(`${n}/.yarn/global/${t}`),r(`${n}/.bun/install/global/${t}`),r(`${n}/.pnpm-global/${t}`),r(`${n}/.pnpm-global/*/${t}`,!0),r(`${n}/pnpm-global/${t}`),r(`${n}/pnpm-global/*/${t}`,!0),r(`${n}/.local/share/pnpm/global/${t}`),r(`${n}/.local/share/pnpm/global/*/${t}`,!0),r(`${n}/.bun/install/global/${t}`),r(`${n}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${n}/.local/share/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`/usr/local/n/versions/node/*/lib/${t}`,!0),r(`${n}/n/versions/node/*/lib/${t}`,!0),r(`${n}/n/lib/${t}`),r(`${n}/.volta/tools/image/node/*/lib/${t}`,!0),r(`${n}/.fnm/node-versions/*/installation/lib/${t}`,!0),r(`${n}/.local/state/fnm_multishells/*/lib/${t}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${t}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${t}`,!0),r(`${n}/.nvm/versions/node/*/lib/${t}`,!0),r(`${n}/.nodenv/versions/*/lib/${t}`,!0),r(`${n}/.nvs/*/lib/${t}`,!0),r(`${n}/.asdf/installs/nodejs/*/lib/${t}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${t}`,!0),r(`${n}/.local/share/mise/installs/node/*/lib/${t}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/npm-anthropic-ai-claude-code/*/lib/${t}`,!0),r(`${n}/.local/share/mise/installs/npm-anthropic-ai-claude-code/*/lib/${t}`,!0)),process.platform=="win32"&&e.forEach(i=>{i.pattern=i.pattern.replace(/\//g,"\\"),i.expandedPaths=i.expandedPaths.map(o=>o.replace(/\//g,"\\"))}),e},ai=li(),ci=ai.flatMap(e=>e.expandedPaths),di=()=>{const e=process.platform==="win32"?Ce.homedir().replace(/\\/g,"/"):Ce.homedir(),n=[],t=(r,i=!1)=>{if(i)try{const o=Vt(r,{onlyFiles:!0});n.push({pattern:r,isGlob:!0,expandedPaths:o})}catch(o){o instanceof Error&&"code"in o&&(o.code==="EACCES"||o.code==="EPERM")?M(`Permission denied accessing: ${r} (${o.code})`):M(`Error expanding glob pattern "${r}": ${o instanceof Error?o.message:String(o)}`),n.push({pattern:r,isGlob:!0,expandedPaths:[]})}else n.push({pattern:r,isGlob:!1,expandedPaths:[r]})};return t(`${e}/.local/bin/claude`),t(`${e}/.local/share/claude/versions/*`,!0),process.platform==="win32"&&n.forEach(r=>{r.pattern=r.pattern.replace(/\//g,"\\"),r.expandedPaths=r.expandedPaths.map(i=>i.replace(/\//g,"\\"))}),n},ui=di(),hi=ui.flatMap(e=>e.expandedPaths);var we=class extends Error{constructor(e){super(e),this.name="InstallationDetectionError"}};let ht=null;async function mi(){return ht||(ht=Tn.create()),ht}async function gi(e,n=4096){try{const t=await re.open(e,"r");try{const r=Buffer.allocUnsafe(n),{bytesRead:i}=await t.read({buffer:r,position:0,length:n});return i<=0?null:r.subarray(0,i)}finally{await t.close()}}catch(t){return M("Failed to read file prefix:",t),null}}async function mt(e){try{const n=await re.realpath(e);M(`resolvePathToInstallationType: ${e} -> ${n}`);const t=await gi(n);if(!t)return M("resolvePathToInstallationType: Could not read file prefix"),null;const r=await mi();let i=null;if(typeof r.detect=="function"&&(i=r.detect(t)||null),!i)return M("resolvePathToInstallationType: WASMagic returned no mime type"),null;const o=i.toLowerCase();return M(`resolvePathToInstallationType: Detected mime type: ${o}`),o.includes("javascript")?{kind:"npm-based",resolvedPath:n}:o.startsWith("text/")?(M("resolvePathToInstallationType: Unrecognized file type"),null):{kind:"native-binary",resolvedPath:n}}catch(n){return M("resolvePathToInstallationType: Error:",n),null}}async function fi(){try{const e=await In("claude");return M(`getClaudeFromPath: Found claude at ${e}`),e}catch{return M("getClaudeFromPath: claude not found on PATH"),null}}function dn(e){const n=/\bVERSION:"(\d+\.\d+\.\d+)"/g,t=new Map;let r;for(;(r=n.exec(e))!==null;){const l=r[1];t.set(l,(t.get(l)||0)+1)}if(t.size===0)return null;let i=0,o;for(const[l,c]of t.entries())M(`Found version ${l} with ${c} occurrences`),c>i&&(i=c,o=l);return o&&M(`Extracted version ${o} (${i} occurrences)`),o||null}async function un(e){const n=await re.readFile(e,"utf8"),t=dn(n);if(!t)throw new Error(`No VERSION strings found in JS file: ${e}`);return t}async function pi(e){const n=await jt(e);if(!n)throw new Error(`Could not extract JS from native binary: ${e}`);const t=n.toString("utf8"),r=dn(t);if(!r)throw new Error(`No VERSION strings found in extracted JS from: ${e}`);return r}function bi(e){const n=le.basename(e),t=n.match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function qe(e,n){const t=bi(e);return t?(M(`extractVersion: Got version ${t} from filename`),t):n==="npm-based"?un(e):pi(e)}async function wi(){const e=[],n=new Set;for(const r of ci){const i=le.join(r,"cli.js");if(!n.has(i))try{if(await _e(i)){M(`collectCandidates: Found cli.js at ${i}`);const o=await un(i);e.push({path:i,kind:"npm-based",version:o}),n.add(i)}}catch(o){M(`collectCandidates: Error checking ${i}:`,o)}}for(const r of hi)if(!n.has(r))try{if(await _e(r)){M(`collectCandidates: Found native binary at ${r}`);const i=await qe(r,"native-binary");e.push({path:r,kind:"native-binary",version:i}),n.add(r)}}catch(i){M(`collectCandidates: Error checking ${r}:`,i)}return[...e].sort((r,i)=>Eo(r.version,i.version))}function xi(e){return e.map(n=>` • ${n.path} (${n.kind}, v${n.version})`).join(`
661
+ `)}function hn(e){return` 2. Set ccInstallationPath in your config file (${ce}):
657
662
 
658
- Searched for cli.js at the following locations:
659
- ${o()}
663
+ {
664
+ "ccInstallationPath": "${e}"
665
+ }`}function mn(e){return` 1. Set the TWEAKCC_CC_INSTALLATION_PATH environment variable:
660
666
 
661
- Also checked for 'claude' executable on PATH using '${process.platform==="win32"?"where claude.exe":"which claude"}'.
667
+ export TWEAKCC_CC_INSTALLATION_PATH="${e}"`}function Si(e){const n=e[0]?.path||"/path/to/claude";return`Multiple Claude Code installations found.
662
668
 
663
- If you have it installed but it's in a location not listed above, please open an issue at
664
- https://github.com/piebald-ai/tweakcc/issues and tell us where you have it--we'll add that location
665
- to our search list and release an update today! And in the meantime, you can get tweakcc working
666
- by manually specifying that location in ${ae} with the "ccInstallationDir" property:
669
+ Found installations:
670
+ ${xi(e)}
667
671
 
668
- {
669
- "ccInstallationDir": "${r}"
670
- }
672
+ To specify which installation to use, either:
673
+
674
+ ${mn(n)}
675
+
676
+ ${hn(n)}`}function gn(){return`Could not find Claude Code installation.
677
+
678
+ To fix this, either:
679
+
680
+ ${mn("/path/to/claude")}
681
+
682
+ ${hn("/path/to/claude")}
671
683
 
672
- Notes:
673
- - Don't include cli.js in the path.
674
- - Don't specify the path to your Claude Code executable's directory. It needs to be the path
675
- to the folder that contains **cli.js**.
676
- - Please also open an issue so that we can add your path to the search list for all users!
677
- `),process.exit(1)}};Gr();
684
+ 3. Install Claude Code:
685
+ npm install -g @anthropic-ai/claude-code
686
+ • Or download from https://claude.ai/download`}function Fe(e,n,t,r){return n==="npm-based"?{cliPath:e,version:t,source:r}:{nativeInstallationPath:e,version:t,source:r}}async function yi(e,n){const t=process.env.TWEAKCC_CC_INSTALLATION_PATH?.trim();if(t&&t.length>0){if(M(`Checking TWEAKCC_CC_INSTALLATION_PATH: ${t}`),!await _e(t))throw new we(`TWEAKCC_CC_INSTALLATION_PATH is set to '${t}' but file does not exist.`);const o=await mt(t);if(!o)throw new we(`Unable to detect installation type from TWEAKCC_CC_INSTALLATION_PATH value '${t}'.
687
+ Expected a Claude Code cli.js file or native binary.`);const l=await qe(o.resolvedPath,o.kind);return je()&&o.kind==="npm-based"&&M(`SHA256 hash: ${await lt(o.resolvedPath)}`),M(`Using Claude Code from TWEAKCC_CC_INSTALLATION_PATH: ${o.resolvedPath} (${o.kind}, v${l})`),Fe(o.resolvedPath,o.kind,l,"env-var")}if(e.ccInstallationPath){const o=e.ccInstallationPath;if(M(`Checking ccInstallationPath: ${o}`),!await _e(o))throw new we(`ccInstallationPath is set to '${o}' but file does not exist.`);const l=await mt(o);if(!l)throw new we(`Unable to detect installation type from configured ccInstallationPath '${o}'.
688
+ Expected a Claude Code cli.js file or native binary.`);const c=await qe(l.resolvedPath,l.kind);return je()&&l.kind==="npm-based"&&M(`SHA256 hash: ${await lt(l.resolvedPath)}`),M(`Using Claude Code from ccInstallationPath: ${l.resolvedPath} (${l.kind}, v${c})`),Fe(l.resolvedPath,l.kind,c,"config")}const r=await fi();if(r){M(`Checking claude on PATH: ${r}`);const o=await mt(r);if(!o)throw new we(`Unable to detect installation type from 'claude' on PATH (${r}).
689
+ Expected a Claude Code cli.js file or native binary.`);const l=await qe(o.resolvedPath,o.kind);return je()&&o.kind==="npm-based"&&M(`SHA256 hash: ${await lt(o.resolvedPath)}`),M(`Using Claude Code from PATH: ${o.resolvedPath} (${o.kind}, v${l})`),Fe(o.resolvedPath,o.kind,l,"path")}M("Collecting candidates from hardcoded search paths...");const i=await wi();if(i.length===0){if(n.interactive)return null;throw new we(gn())}if(i.length===1){const o=i[0];return M(`Using single candidate: ${o.path} (${o.kind}, v${o.version})`),Fe(o.path,o.kind,o.version,"search-paths")}if(!n.interactive)throw new we(Si(i));return{version:"",source:"search-paths",_pendingCandidates:i}}function vi(e){return e._pendingCandidates||null}async function Ci(e){return M(`Saving selected installation to config: ${e.path}`),await Ne(n=>{n.ccInstallationPath=e.path}),Fe(e.path,e.kind,e.version,"config")}function fn(){return gn()}async function pn(e){const n=await He(),t=await yi(n,e);if(!t)return{startupCheckInfo:null,pendingCandidates:null};const r=vi(t);return r?{startupCheckInfo:null,pendingCandidates:r}:{startupCheckInfo:await bn(n,t),pendingCandidates:null}}async function bn(e,n){if(!n)return null;if(n.version)try{const l=await _r(n.version);Pr(l)}catch{}const t=n.version,r=e.ccVersion;let i=!1;await _e(De)||(M(`startupCheck: ${De} not found; backing up cli.js`),await Bt(n),i=!0);let o=!1;return n.nativeInstallationPath&&!await _e(ge)&&(M(`startupCheck: ${ge} not found; backing up native binary`),await Pt(n),o=!0),t!==r?(i||(M(`startupCheck: real version (${t}) != backed up version (${r}); backing up cli.js`),await re.unlink(De),await Bt(n)),n.nativeInstallationPath&&!o&&(M(`startupCheck: real version (${t}) != backed up version (${r}); backing up native binary`),await _e(ge)&&await re.unlink(ge),await Pt(n)),{wasUpdated:!0,oldVersion:r,newVersion:t,ccInstInfo:n}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:n}}function $i({candidates:e,onSelect:n}){const[t,r]=B(0);return de((i,o)=>{o.escape?process.exit(0):o.upArrow?r(l=>l>0?l-1:e.length-1):o.downArrow?r(l=>l<e.length-1?l+1:0):o.return&&n(e[t])}),h(m,{flexDirection:"column",children:[s(a,{bold:!0,color:"yellow",children:"No claude executable was found in PATH, and multiple Claude Code installations were found. Please select one:"}),s(a,{children:" "}),e.map((i,o)=>h(m,{children:[h(a,{bold:o===t,color:o===t?"cyan":void 0,children:[o===t?"❯ ":" ",i.path]}),h(a,{dimColor:!0,children:[" ","(",i.kind,", v",i.version,")"]})]},i.path)),s(a,{children:" "}),h(a,{children:["Your choice will be saved to"," ",s(a,{color:"blue",children:"ccInstallationPath"})," in"," ",h(a,{color:"blue",children:[se.replace(Re.homedir(),"~"),"/config.json"]}),"."]}),s(a,{children:" "}),s(a,{dimColor:!0,children:"Use ↑↓ arrows to navigate, Enter to select, Esc to quit"})]})}const _i=async()=>{const e=new vn;e.name("tweakcc").description("Command-line tool to customize your Claude Code theme colors, thinking verbs and more.").version("3.2.0").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const n=e.opts();n.debug&&$o();const t=await No();if(n.apply){await Ii();return}await Ti(t)};async function Ii(){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${ce}`);const e=await He();(!e.settings||Object.keys(e.settings).length===0)&&(console.error("No saved customizations found in "+ce),process.exit(1));try{const n=await pn({interactive:!1});(!n.startupCheckInfo||!n.startupCheckInfo.ccInstInfo)&&(console.error(fn()),process.exit(1));const{ccInstInfo:t}=n.startupCheckInfo;t.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${t.nativeInstallationPath}`):console.log(`Found Claude Code at: ${t.cliPath}`),console.log(`Version: ${t.version}`),console.log("Loading system prompts...");const r=await Xt(t.version);r.success||(console.log(F.red(`
690
+ ✖ Error downloading system prompts:`)),console.log(F.red(` ${r.errorMessage}`)),console.log(F.yellow(`
691
+ ⚠ System prompts not available - skipping system prompt customizations`))),console.log("Applying customizations..."),await rn(e,t),console.log("Customizations applied successfully!"),process.exit(0)}catch(n){throw n instanceof we&&(console.error(F.red(`Error: ${n.message}`)),process.exit(1)),n}}async function Ti(e){try{const n=await pn({interactive:!0});if(n.pendingCandidates){await Mi(n.pendingCandidates,e);return}n.startupCheckInfo||(console.error(F.red(fn())),process.exit(1)),await wn(n.startupCheckInfo,e)}catch(n){throw n instanceof we&&(console.error(F.red(`Error: ${n.message}`)),process.exit(1)),n}}async function Mi(e,n){return new Promise((t,r)=>{const o=Dt(s($i,{candidates:e,onSelect:async l=>{try{const c=await Ci(l),u=await He(),d=await bn(u,c);d||(console.error(F.red("Error: Failed to complete startup check after selection.")),process.exit(1)),o.unmount(),await wn(d,n),t()}catch(c){r(c)}}}))})}async function wn(e,n){const t=await Xt(e.ccInstInfo.version);t.success||(console.log(F.red(`
692
+ ✖ Error downloading system prompts:`)),console.log(F.red(` ${t.errorMessage}`)),console.log(F.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
693
+ `))),Dt(s(si,{startupCheckInfo:e,configMigrated:n}))}_i();export{M as b,je as c};