tweakcc 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +35 -35
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -12,16 +12,14 @@ tweakcc is a CLI tool that upgrades your Claude Code experience. Customize its
12
12
  > [!tip]
13
13
  > **NEW in 3.0.0:** tweakcc now supports Claude Code native installations! It also adds a new feature to CC called **toolsets**—try them out in Claude Code with the `/toolsets` command after you create them in tweakcc. Lastly it makes [Claude Code's native LSP server support work.](https://www.reddit.com/r/ClaudeAI/comments/1otdfo9/lsp_is_coming_to_claude_code_and_you_can_try_it/)
14
14
 
15
- <!--
16
15
  > [!note]
17
16
  > ⭐ **If you find tweakcc useful, please consider [starring the repository](https://github.com/Piebald-AI/tweakcc) to show your support!** ⭐
18
- -->
19
17
 
20
18
  <img src="./assets/demo.gif" alt="Animated GIF demonstrating running `npx tweakcc`, creating a new theme, changing all of Claude Code's UI colors to purple, changing the thinking format from '<verb>ing...' to 'Claude is <verb>ing', changing the generating spinner style to a 50m glow animation, applying the changes, running Claude, and using '/config' to switch to the new theme, and sending a message to see the new thinking verb format." width="800">
21
19
 
22
20
  With tweakcc, you can
23
21
 
24
- - Customize all of Claude Code's **system prompts**
22
+ - Customize all of Claude Code's **system prompts** (**NEW:** also see [**Claude Code System Prompts**](https://github.com/Piebald-AI/claude-code-system-prompts))
25
23
  - Create custom **toolsets** that can be used in Claude Code with the new **`/toolset`** command
26
24
  - Manually name **sessions** in Claude Code with `/title my chat name` or `/rename`
27
25
  - Create **custom themes** with a graphical HSL/RGB color picker
@@ -97,6 +95,8 @@ tweakcc allows you to customize the various parts of Claude Code's system prompt
97
95
  - prompts for builtin Task/Plan/Explore subagents, and
98
96
  - prompts for utilities such as conversation compaction, WebFetch summarization, Bash command analysis, CLAUDE.md/output style/statusline creation, and many more.
99
97
 
98
+ 👉 See [**Claude Code System Prompts**](https://github.com/Piebald-AI/claude-code-system-prompts) for a breakdown of all the system prompt parts, as well as a changelog and diffs for each CC version.
99
+
100
100
  Because the system prompt is **dynamically composed** based on several factors, **it's not one string** that can be simply modified in a text editor. It's a bunch of smaller strings sprinkled throughout Claude Code's source code.
101
101
 
102
102
  tweakcc's method for modifying involves maintaining one markdown file for each individual portion of the prompt, resulting in a file for each tool description, each agent/utility prompt, and one for the main system prompt and a few more for various large notes inserted into other prompt parts.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import{Box as m,Text as d,render as ct,useInput as de}from"ink";import{Command as dt}from"commander";import Q from"chalk";import*as te from"node:fs/promises";import ie from"node:fs/promises";import Ke,{Fragment as Ee,createContext as ut,useCallback as Nn,useContext as be,useEffect as xe,useState as O}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 Bn from"node:path";import*as ye from"node:os";import{EOL as bn}from"node:os";import*as Ce from"node:fs";import Pe from"node:fs";import{globbySync as gt}from"globby";import ft from"node:process";import*as Me from"node:child_process";import{execSync as On}from"node:child_process";import*as An from"node:crypto";import Ge from"gray-matter";import Re from"node-lief";function mt({items:e,selectedIndex:t,onSelect:n,onSubmit:r}){return de((o,i)=>{i.upArrow?n(t>0?t-1:e.length-1):i.downArrow?n(t<e.length-1?t+1:0):i.return&&r(e[t].name)}),s(m,{flexDirection:"column",children:e.map((o,i)=>s(m,{children:g(d,{children:[g(d,{bold:i===t,color:i===t?"cyan":void 0,...i===t?o.selectedStyles??{}:o.styles??{},children:[i===t?"❯ ":" ",o.name]}),o.desc&&i===t&&g(d,{dimColor:!0,bold:!1,children:[" \x1B[0;2m","- ",o.desc]})]})},i))})}let J=function(e){return e.APPLY_CHANGES="*Apply customizations",e.THEMES="Themes",e.THINKING_VERBS="Thinking verbs",e.THINKING_STYLE="Thinking style",e.USER_MESSAGE_DISPLAY="User message display",e.MISC="Misc",e.TOOLSETS="Toolsets",e.VIEW_SYSTEM_PROMPTS="View system prompts",e.RESTORE_ORIGINAL="Restore original Claude Code (preserves config.json)",e.OPEN_CONFIG="Open config.json",e.OPEN_CLI="Open Claude Code's cli.js",e.EXIT="Exit",e}({});const Z={themes:[{name:"Dark mode",id:"dark",colors:{autoAccept:"rgb(175,135,255)",bashBorder:"rgb(253,93,177)",claude:"rgb(215,119,87)",claudeShimmer:"rgb(235,159,127)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(147,165,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(177,195,255)",permission:"rgb(177,185,249)",permissionShimmer:"rgb(207,215,255)",planMode:"rgb(72,150,140)",ide:"rgb(71,130,200)",promptBorder:"rgb(136,136,136)",promptBorderShimmer:"rgb(166,166,166)",text:"rgb(255,255,255)",inverseText:"rgb(0,0,0)",inactive:"rgb(153,153,153)",subtle:"rgb(80,80,80)",suggestion:"rgb(177,185,249)",remember:"rgb(177,185,249)",background:"rgb(0,204,204)",success:"rgb(78,186,101)",error:"rgb(255,107,128)",warning:"rgb(255,193,7)",warningShimmer:"rgb(255,223,57)",diffAdded:"rgb(34,92,43)",diffRemoved:"rgb(122,41,54)",diffAddedDimmed:"rgb(71,88,74)",diffRemovedDimmed:"rgb(105,72,77)",diffAddedWord:"rgb(56,166,96)",diffRemovedWord:"rgb(179,89,107)",diffAddedWordDimmed:"rgb(46,107,58)",diffRemovedWordDimmed:"rgb(139,57,69)",red_FOR_SUBAGENTS_ONLY:"rgb(220,38,38)",blue_FOR_SUBAGENTS_ONLY:"rgb(37,99,235)",green_FOR_SUBAGENTS_ONLY:"rgb(22,163,74)",yellow_FOR_SUBAGENTS_ONLY:"rgb(202,138,4)",purple_FOR_SUBAGENTS_ONLY:"rgb(147,51,234)",orange_FOR_SUBAGENTS_ONLY:"rgb(234,88,12)",pink_FOR_SUBAGENTS_ONLY:"rgb(219,39,119)",cyan_FOR_SUBAGENTS_ONLY:"rgb(8,145,178)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(55, 55, 55)",bashMessageBackgroundColor:"rgb(65, 60, 65)",memoryBackgroundColor:"rgb(55, 65, 70)",rate_limit_fill:"rgb(177,185,249)",rate_limit_empty:"rgb(80,83,112)"}},{name:"Light mode",id:"light",colors:{autoAccept:"rgb(135,0,255)",bashBorder:"rgb(255,0,135)",claude:"rgb(215,119,87)",claudeShimmer:"rgb(245,149,117)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(87,105,247)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(117,135,255)",permission:"rgb(87,105,247)",permissionShimmer:"rgb(137,155,255)",planMode:"rgb(0,102,102)",ide:"rgb(71,130,200)",promptBorder:"rgb(153,153,153)",promptBorderShimmer:"rgb(183,183,183)",text:"rgb(0,0,0)",inverseText:"rgb(255,255,255)",inactive:"rgb(102,102,102)",subtle:"rgb(175,175,175)",suggestion:"rgb(87,105,247)",remember:"rgb(0,0,255)",background:"rgb(0,153,153)",success:"rgb(44,122,57)",error:"rgb(171,43,63)",warning:"rgb(150,108,30)",warningShimmer:"rgb(200,158,80)",diffAdded:"rgb(105,219,124)",diffRemoved:"rgb(255,168,180)",diffAddedDimmed:"rgb(199,225,203)",diffRemovedDimmed:"rgb(253,210,216)",diffAddedWord:"rgb(47,157,68)",diffRemovedWord:"rgb(209,69,75)",diffAddedWordDimmed:"rgb(144,194,156)",diffRemovedWordDimmed:"rgb(232,165,173)",red_FOR_SUBAGENTS_ONLY:"rgb(220,38,38)",blue_FOR_SUBAGENTS_ONLY:"rgb(37,99,235)",green_FOR_SUBAGENTS_ONLY:"rgb(22,163,74)",yellow_FOR_SUBAGENTS_ONLY:"rgb(202,138,4)",purple_FOR_SUBAGENTS_ONLY:"rgb(147,51,234)",orange_FOR_SUBAGENTS_ONLY:"rgb(234,88,12)",pink_FOR_SUBAGENTS_ONLY:"rgb(219,39,119)",cyan_FOR_SUBAGENTS_ONLY:"rgb(8,145,178)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(240, 240, 240)",bashMessageBackgroundColor:"rgb(250, 245, 250)",memoryBackgroundColor:"rgb(230, 245, 250)",rate_limit_fill:"rgb(87,105,247)",rate_limit_empty:"rgb(39,47,111)"}},{name:"Light mode (ANSI colors only)",id:"light-ansi",colors:{autoAccept:"ansi:magenta",bashBorder:"ansi:magenta",claude:"ansi:redBright",claudeShimmer:"ansi:yellowBright",claudeBlue_FOR_SYSTEM_SPINNER:"ansi:blue",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"ansi:blueBright",permission:"ansi:blue",permissionShimmer:"ansi:blueBright",planMode:"ansi:cyan",ide:"ansi:blueBright",promptBorder:"ansi:white",promptBorderShimmer:"ansi:whiteBright",text:"ansi:black",inverseText:"ansi:white",inactive:"ansi:blackBright",subtle:"ansi:blackBright",suggestion:"ansi:blue",remember:"ansi:blue",background:"ansi:cyan",success:"ansi:green",error:"ansi:red",warning:"ansi:yellow",warningShimmer:"ansi:yellowBright",diffAdded:"ansi:green",diffRemoved:"ansi:red",diffAddedDimmed:"ansi:green",diffRemovedDimmed:"ansi:red",diffAddedWord:"ansi:greenBright",diffRemovedWord:"ansi:redBright",diffAddedWordDimmed:"ansi:green",diffRemovedWordDimmed:"ansi:red",red_FOR_SUBAGENTS_ONLY:"ansi:red",blue_FOR_SUBAGENTS_ONLY:"ansi:blue",green_FOR_SUBAGENTS_ONLY:"ansi:green",yellow_FOR_SUBAGENTS_ONLY:"ansi:yellow",purple_FOR_SUBAGENTS_ONLY:"ansi:magenta",orange_FOR_SUBAGENTS_ONLY:"ansi:redBright",pink_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",cyan_FOR_SUBAGENTS_ONLY:"ansi:cyan",professionalBlue:"ansi:blueBright",rainbow_red:"ansi:red",rainbow_orange:"ansi:redBright",rainbow_yellow:"ansi:yellow",rainbow_green:"ansi:green",rainbow_blue:"ansi:cyan",rainbow_indigo:"ansi:blue",rainbow_violet:"ansi:magenta",rainbow_red_shimmer:"ansi:redBright",rainbow_orange_shimmer:"ansi:yellow",rainbow_yellow_shimmer:"ansi:yellowBright",rainbow_green_shimmer:"ansi:greenBright",rainbow_blue_shimmer:"ansi:cyanBright",rainbow_indigo_shimmer:"ansi:blueBright",rainbow_violet_shimmer:"ansi:magentaBright",clawd_body:"ansi:redBright",clawd_background:"ansi:black",userMessageBackground:"ansi:white",bashMessageBackgroundColor:"ansi:whiteBright",memoryBackgroundColor:"ansi:white",rate_limit_fill:"ansi:yellow",rate_limit_empty:"ansi:black"}},{name:"Dark mode (ANSI colors only)",id:"dark-ansi",colors:{autoAccept:"ansi:magentaBright",bashBorder:"ansi:magentaBright",claude:"ansi:redBright",claudeShimmer:"ansi:yellowBright",claudeBlue_FOR_SYSTEM_SPINNER:"ansi:blueBright",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"ansi:blueBright",permission:"ansi:blueBright",permissionShimmer:"ansi:blueBright",planMode:"ansi:cyanBright",ide:"ansi:blue",promptBorder:"ansi:white",promptBorderShimmer:"ansi:whiteBright",text:"ansi:whiteBright",inverseText:"ansi:black",inactive:"ansi:white",subtle:"ansi:white",suggestion:"ansi:blueBright",remember:"ansi:blueBright",background:"ansi:cyanBright",success:"ansi:greenBright",error:"ansi:redBright",warning:"ansi:yellowBright",warningShimmer:"ansi:yellowBright",diffAdded:"ansi:green",diffRemoved:"ansi:red",diffAddedDimmed:"ansi:green",diffRemovedDimmed:"ansi:red",diffAddedWord:"ansi:greenBright",diffRemovedWord:"ansi:redBright",diffAddedWordDimmed:"ansi:green",diffRemovedWordDimmed:"ansi:red",red_FOR_SUBAGENTS_ONLY:"ansi:redBright",blue_FOR_SUBAGENTS_ONLY:"ansi:blueBright",green_FOR_SUBAGENTS_ONLY:"ansi:greenBright",yellow_FOR_SUBAGENTS_ONLY:"ansi:yellowBright",purple_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",orange_FOR_SUBAGENTS_ONLY:"ansi:redBright",pink_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",cyan_FOR_SUBAGENTS_ONLY:"ansi:cyanBright",professionalBlue:"rgb(106,155,204)",rainbow_red:"ansi:red",rainbow_orange:"ansi:redBright",rainbow_yellow:"ansi:yellow",rainbow_green:"ansi:green",rainbow_blue:"ansi:cyan",rainbow_indigo:"ansi:blue",rainbow_violet:"ansi:magenta",rainbow_red_shimmer:"ansi:redBright",rainbow_orange_shimmer:"ansi:yellow",rainbow_yellow_shimmer:"ansi:yellowBright",rainbow_green_shimmer:"ansi:greenBright",rainbow_blue_shimmer:"ansi:cyanBright",rainbow_indigo_shimmer:"ansi:blueBright",rainbow_violet_shimmer:"ansi:magentaBright",clawd_body:"ansi:redBright",clawd_background:"ansi:black",userMessageBackground:"ansi:blackBright",bashMessageBackgroundColor:"ansi:black",memoryBackgroundColor:"ansi:blackBright",rate_limit_fill:"ansi:yellow",rate_limit_empty:"ansi:white"}},{name:"Light mode (colorblind-friendly)",id:"light-daltonized",colors:{autoAccept:"rgb(135,0,255)",bashBorder:"rgb(0,102,204)",claude:"rgb(255,153,51)",claudeShimmer:"rgb(255,183,101)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(51,102,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(101,152,255)",permission:"rgb(51,102,255)",permissionShimmer:"rgb(101,152,255)",planMode:"rgb(51,102,102)",ide:"rgb(71,130,200)",promptBorder:"rgb(153,153,153)",promptBorderShimmer:"rgb(183,183,183)",text:"rgb(0,0,0)",inverseText:"rgb(255,255,255)",inactive:"rgb(102,102,102)",subtle:"rgb(175,175,175)",suggestion:"rgb(51,102,255)",remember:"rgb(51,102,255)",background:"rgb(0,153,153)",success:"rgb(0,102,153)",error:"rgb(204,0,0)",warning:"rgb(255,153,0)",warningShimmer:"rgb(255,183,50)",diffAdded:"rgb(153,204,255)",diffRemoved:"rgb(255,204,204)",diffAddedDimmed:"rgb(209,231,253)",diffRemovedDimmed:"rgb(255,233,233)",diffAddedWord:"rgb(51,102,204)",diffRemovedWord:"rgb(153,51,51)",diffAddedWordDimmed:"rgb(102,153,204)",diffRemovedWordDimmed:"rgb(204,153,153)",red_FOR_SUBAGENTS_ONLY:"rgb(204,0,0)",blue_FOR_SUBAGENTS_ONLY:"rgb(0,102,204)",green_FOR_SUBAGENTS_ONLY:"rgb(0,204,0)",yellow_FOR_SUBAGENTS_ONLY:"rgb(255,204,0)",purple_FOR_SUBAGENTS_ONLY:"rgb(128,0,128)",orange_FOR_SUBAGENTS_ONLY:"rgb(255,128,0)",pink_FOR_SUBAGENTS_ONLY:"rgb(255,102,178)",cyan_FOR_SUBAGENTS_ONLY:"rgb(0,178,178)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(220, 220, 220)",bashMessageBackgroundColor:"rgb(250, 245, 250)",memoryBackgroundColor:"rgb(230, 245, 250)",rate_limit_fill:"rgb(51,102,255)",rate_limit_empty:"rgb(23,46,114)"}},{name:"Dark mode (colorblind-friendly)",id:"dark-daltonized",colors:{autoAccept:"rgb(175,135,255)",bashBorder:"rgb(51,153,255)",claude:"rgb(255,153,51)",claudeShimmer:"rgb(255,183,101)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(153,204,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(183,224,255)",permission:"rgb(153,204,255)",permissionShimmer:"rgb(183,224,255)",planMode:"rgb(102,153,153)",ide:"rgb(71,130,200)",promptBorder:"rgb(136,136,136)",promptBorderShimmer:"rgb(166,166,166)",text:"rgb(255,255,255)",inverseText:"rgb(0,0,0)",inactive:"rgb(153,153,153)",subtle:"rgb(80,80,80)",suggestion:"rgb(153,204,255)",remember:"rgb(153,204,255)",background:"rgb(0,204,204)",success:"rgb(51,153,255)",error:"rgb(255,102,102)",warning:"rgb(255,204,0)",warningShimmer:"rgb(255,234,50)",diffAdded:"rgb(0,68,102)",diffRemoved:"rgb(102,0,0)",diffAddedDimmed:"rgb(62,81,91)",diffRemovedDimmed:"rgb(62,44,44)",diffAddedWord:"rgb(0,119,179)",diffRemovedWord:"rgb(179,0,0)",diffAddedWordDimmed:"rgb(26,99,128)",diffRemovedWordDimmed:"rgb(128,21,21)",red_FOR_SUBAGENTS_ONLY:"rgb(255,102,102)",blue_FOR_SUBAGENTS_ONLY:"rgb(102,178,255)",green_FOR_SUBAGENTS_ONLY:"rgb(102,255,102)",yellow_FOR_SUBAGENTS_ONLY:"rgb(255,255,102)",purple_FOR_SUBAGENTS_ONLY:"rgb(178,102,255)",orange_FOR_SUBAGENTS_ONLY:"rgb(255,178,102)",pink_FOR_SUBAGENTS_ONLY:"rgb(255,153,204)",cyan_FOR_SUBAGENTS_ONLY:"rgb(102,204,204)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(55, 55, 55)",bashMessageBackgroundColor:"rgb(65, 60, 65)",memoryBackgroundColor:"rgb(55, 65, 70)",rate_limit_fill:"rgb(153,204,255)",rate_limit_empty:"rgb(69,92,115)"}},{name:"Monochrome",id:"monochrome",colors:{autoAccept:"rgb(200,200,200)",bashBorder:"rgb(180,180,180)",claude:"rgb(255,255,255)",claudeShimmer:"rgb(230,230,230)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(200,200,200)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(220,220,220)",permission:"rgb(200,200,200)",permissionShimmer:"rgb(220,220,220)",planMode:"rgb(180,180,180)",ide:"rgb(190,190,190)",promptBorder:"rgb(160,160,160)",promptBorderShimmer:"rgb(180,180,180)",text:"rgb(255,255,255)",inverseText:"rgb(40,40,40)",inactive:"rgb(120,120,120)",subtle:"rgb(100,100,100)",suggestion:"rgb(200,200,200)",remember:"rgb(200,200,200)",background:"rgb(180,180,180)",success:"rgb(220,220,220)",error:"rgb(180,180,180)",warning:"rgb(200,200,200)",warningShimmer:"rgb(220,220,220)",diffAdded:"rgb(90,90,90)",diffRemoved:"rgb(60,60,60)",diffAddedDimmed:"rgb(110,110,110)",diffRemovedDimmed:"rgb(80,80,80)",diffAddedWord:"rgb(200,200,200)",diffRemovedWord:"rgb(80,80,80)",diffAddedWordDimmed:"rgb(160,160,160)",diffRemovedWordDimmed:"rgb(70,70,70)",red_FOR_SUBAGENTS_ONLY:"rgb(200,200,200)",blue_FOR_SUBAGENTS_ONLY:"rgb(180,180,180)",green_FOR_SUBAGENTS_ONLY:"rgb(210,210,210)",yellow_FOR_SUBAGENTS_ONLY:"rgb(190,190,190)",purple_FOR_SUBAGENTS_ONLY:"rgb(170,170,170)",orange_FOR_SUBAGENTS_ONLY:"rgb(195,195,195)",pink_FOR_SUBAGENTS_ONLY:"rgb(205,205,205)",cyan_FOR_SUBAGENTS_ONLY:"rgb(185,185,185)",professionalBlue:"rgb(190,190,190)",rainbow_red:"rgb(240,240,240)",rainbow_orange:"rgb(230,230,230)",rainbow_yellow:"rgb(220,220,220)",rainbow_green:"rgb(210,210,210)",rainbow_blue:"rgb(200,200,200)",rainbow_indigo:"rgb(190,190,190)",rainbow_violet:"rgb(180,180,180)",rainbow_red_shimmer:"rgb(255,255,255)",rainbow_orange_shimmer:"rgb(245,245,245)",rainbow_yellow_shimmer:"rgb(235,235,235)",rainbow_green_shimmer:"rgb(225,225,225)",rainbow_blue_shimmer:"rgb(215,215,215)",rainbow_indigo_shimmer:"rgb(205,205,205)",rainbow_violet_shimmer:"rgb(195,195,195)",clawd_body:"rgb(255,255,255)",clawd_background:"rgb(40,40,40)",userMessageBackground:"rgb(70,70,70)",bashMessageBackgroundColor:"rgb(65,65,65)",memoryBackgroundColor:"rgb(75,75,75)",rate_limit_fill:"rgb(200,200,200)",rate_limit_empty:"rgb(90,90,90)"}}],thinkingVerbs:{format:"{}… ",verbs:["Accomplishing","Actioning","Actualizing","Baking","Booping","Brewing","Calculating","Cerebrating","Channelling","Churning","Clauding","Coalescing","Cogitating","Combobulating","Computing","Concocting","Conjuring","Considering","Contemplating","Cooking","Crafting","Creating","Crunching","Deciphering","Deliberating","Determining","Discombobulating","Divining","Doing","Effecting","Elucidating","Enchanting","Envisioning","Finagling","Flibbertigibbeting","Forging","Forming","Frolicking","Generating","Germinating","Hatching","Herding","Honking","Ideating","Imagining","Incubating","Inferring","Manifesting","Marinating","Meandering","Moseying","Mulling","Musing","Mustering","Noodling","Percolating","Perusing","Philosophising","Pondering","Pontificating","Processing","Puttering","Puzzling","Reticulating","Ruminating","Scheming","Schlepping","Shimmying","Simmering","Smooshing","Spelunking","Spinning","Stewing","Sussing","Synthesizing","Thinking","Tinkering","Transmuting","Unfurling","Unravelling","Vibing","Wandering","Whirring","Wibbling","Wizarding","Working","Wrangling","Alchemizing","Animating","Architecting","Bamboozling","Beaming","Befuddling","Bewitching","Billowing","Bippity-bopping","Blanching","Boogieing","Boondoggling","Bootstrapping","Burrowing","Caching","Canoodling","Caramelizing","Cascading","Catapulting","Channeling","Choreographing","Compiling","Composing","Crystallizing","Cultivating","Deploying","Dilly-dallying","Discombobulating","Distilling","Doodling","Drizzling","Ebbing","Embellishing","Ensorcelling","Evaporating","Fermenting","Fiddle-faddling","Finagling","Flambéing","Flowing","Flummoxing","Fluttering","Frosting","Gallivanting","Galloping","Garnishing","Germinating","Gitifying","Grooving","Gusting","Harmonizing","Hashing","Hexing","Hibernating","Higgledy-piggleding","Hornswoggling","Hullaballooing","Hyperspacing","Illustrating","Improvising","Incanting","Indexing","Infusing","Ionizing","Jazzercising","Jiggery-pokerying","Jitterbugging","Julienning","Kerfuffling","Kneading","Leavening","Levitating","Linting","Lollygagging","Malarkeying","Metamorphosing","Migrating","Minifying","Misting","Moonwalking","Mystifying","Nebulizing","Nesting","Nucleating","Optimizing","Orbiting","Orchestrating","Osmosing","Parsing","Perambulating","Photosynthesizing","Pipelining","Poaching","Pollinating","Pouncing","Precipitating","Prestidigitating","Proofing","Propagating","Prowling","Quantumizing","Querying","Razzle-dazzling","Razzmatazzing","Recombobulating","Reducing","Refactoring","Rippling","Roosting","Sautéing","Scampering","Scurrying","Seasoning","Serializing","Shenaniganing","Skedaddling","Sketching","Skullduggering","Slithering","Sock-hopping","Spellbinding","Sprouting","Storyboarding","Sublimating","Swirling","Swooping","Symbioting","Syncopating","Teleporting","Tempering","Thaumaturging","Thundering","Tomfoolering","Topsy-turvying","Transfiguring","Transpiling","Twisting","Undulating","Validating","Vaporizing","Waddling","Warping","Whatchamacalliting","Whirlpooling","Whisking","Willy-nillying","Zesting","Zigzagging"]},thinkingStyle:{updateInterval:120,phases:process.env.TERM==="xterm-ghostty"?["·","✢","✳","✶","✻","*"]:process.platform==="darwin"?["·","✢","✳","✶","✻","✽"]:["·","✢","*","✶","✻","✽"],reverseMirror:!0},userMessageDisplay:{prefix:{format:">",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"},message:{format:"{}",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"}},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0},toolsets:[],defaultToolset:null},pt=()=>{const e=re.join(ye.homedir(),".tweakcc"),t=process.env.XDG_CONFIG_HOME;try{if(Ce.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",r=(o,i=!1)=>{if(i){const a=gt(o,{onlyFiles:!1});e.push({pattern:o,isGlob:!0,expandedPaths:a})}else e.push({pattern:o,isGlob:!1,expandedPaths:[o]})};return r(`${ye.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform=="win32"?(r(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),r(`${t}/AppData/Roaming/npm/${n}`),r(`${t}/AppData/Roaming/nvm/*/${n}`,!0),r(`${t}/AppData/Local/Yarn/config/global/${n}`),r(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),r(`C:/nvm4w/nodejs/${n}`),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/AppData/Roaming/Yarn/config/global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0)):(process.platform=="darwin"&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`)),r(`${t}/.local/lib/${n}`),r(`${t}/.local/share/${n}`),r(`${t}/.npm-global/lib/${n}`),r(`${t}/.npm-packages/lib/${n}`),r(`${t}/.npm/lib/${n}`),r(`${t}/npm/lib/${n}`),r(`/etc/${n}`),r(`/lib/${n}`),r(`/opt/node/lib/${n}`),r(`/usr/lib/${n}`),r(`/usr/local/lib/${n}`),r(`/usr/share/${n}`),r(`/var/lib/${n}`),r(`/opt/homebrew/lib/${n}`),r(`${t}/.linuxbrew/lib/${n}`),r(`${t}/.config/yarn/global/${n}`),r(`${t}/.yarn/global/${n}`),r(`${t}/.bun/install/global/${n}`),r(`${t}/.pnpm-global/${n}`),r(`${t}/.pnpm-global/*/${n}`,!0),r(`${t}/pnpm-global/${n}`),r(`${t}/pnpm-global/*/${n}`,!0),r(`${t}/.local/share/pnpm/global/${n}`),r(`${t}/.local/share/pnpm/global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`/usr/local/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/lib/${n}`),r(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),r(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),r(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nodenv/versions/*/lib/${n}`,!0),r(`${t}/.nvs/*/lib/${n}`,!0),r(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0)),process.platform=="win32"&&e.forEach(o=>{o.pattern=o.pattern.replace(/\//g,"\\"),o.expandedPaths=o.expandedPaths.map(i=>i.replace(/\//g,"\\"))}),e},en=bt(),xn=en.flatMap(e=>e.expandedPaths),wt=({children:e,...t})=>g(d,{bold:!0,backgroundColor:"#ffd500",color:"#000",...t,children:[" ",e," "]});var pe=wt;const xt=[{name:J.THEMES,desc:"Modify Claude Code's built-in themes or create your own"},{name:J.THINKING_VERBS,desc:"Customize the list of verbs that Claude Code uses when it's working"},{name:J.THINKING_STYLE,desc:"Choose custom spinners"},{name:J.USER_MESSAGE_DISPLAY,desc:"Customize how user messages are displayed"},{name:J.MISC,desc:"Miscellaneous settings (input box border, etc.)"},{name:J.TOOLSETS,desc:"Manage toolsets to control which tools are available"},{name:J.VIEW_SYSTEM_PROMPTS,desc:"Opens the system prompts directory where you can customize Claude Code's system prompts"}],yn=[{name:J.RESTORE_ORIGINAL,desc:"Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)"},{name:J.OPEN_CONFIG,desc:`Opens your tweakcc config file (${ae})`},{name:J.OPEN_CLI,desc:"Opens Claude Code's cli.js file"},{name:J.EXIT,desc:"Bye!"}];function yt({onSubmit:e,notification:t,isNativeInstallation:n}){const r=n?yn.filter(l=>l.name!==J.OPEN_CLI):yn,o=[...be(ue).changesApplied?[]:[{name:J.APPLY_CHANGES,desc:"Required: Updates Claude Code in-place with your changes",selectedStyles:{color:"green"}}],...xt,...r],[i,a]=O(0);return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(pe,{children:"Tweak Claude Code"})}),s(m,{marginBottom:1,children:g(d,{color:"gray",children:[s(d,{bold:!0,children:"Customize your Claude Code installation."})," ",s(d,{dimColor:!0,children:"Settings will be saved to a JSON file."})]})}),s(m,{marginBottom:1,children:g(d,{color:"yellow",children:["⭐ ",s(d,{bold:!0,children:"Star the repo at "}),s(ht,{url:"https://github.com/Piebald-AI/tweakcc",fallback:!1,children:s(d,{bold:!0,color:"cyan",children:"https://github.com/Piebald-AI/tweakcc"})}),s(d,{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(d,{color:t?.type==="success"?"green":t?.type==="error"?"red":t?.type==="info"?"blue":"yellow",children:t?.message})}),s(mt,{items:o,selectedIndex:i,onSelect:a,onSubmit:l=>e(l)})]})}async function rn(e){const t=re.join(wn,`prompts-${e}.json`);try{const r=await te.readFile(t,"utf-8");return JSON.parse(r)}catch{}const n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{const r=await fetch(n);if(!r.ok){let i;throw r.status===429?i="Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.":r.status===404?i=`Prompts file not found for Claude Code v${e}. This version was released within the past day or so and will be supported within a few hours.`:r.status>=500?i=`GitHub server error (${r.status}). Please try again later.`:i=`HTTP ${r.status}: ${r.statusText}`,new Error(i)}const o=await r.json();try{await te.mkdir(wn,{recursive:!0}),await te.writeFile(t,JSON.stringify(o,null,2),"utf-8")}catch(i){console.warn(`Failed to write to cache to ${t}: ${i}`)}return o}catch(r){if(r instanceof Error){if(r.message.includes("Rate limit")||r.message.includes("not found")||r.message.includes("server error")||r.message.includes("HTTP"))throw r;const o=`Failed to download prompts for version ${e}: ${r.message}`;throw new Error(o)}throw r}}const St="modulepreload",vt=function(e){return"/"+e},Sn={},$t=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let c=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const a=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),u=l?.nonce||l?.getAttribute("nonce");o=c(n.map(h=>{if(h=vt(h,r),h in Sn)return;Sn[h]=!0;const f=h.endsWith(".css"),v=f?'[rel="stylesheet"]':"";if(!!r)for(let w=a.length-1;w>=0;w--){const x=a[w];if(x.href===h&&(!f||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${v}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":St,f||(p.as="script"),p.crossOrigin="",p.href=h,u&&p.setAttribute("nonce",u),document.head.appendChild(p),f)return new Promise((w,x)=>{p.addEventListener("load",w),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.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 te.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 te.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const r of n)t[r]=e[r];await te.writeFile(Pn,JSON.stringify(t,null,2),"utf8")},It=async e=>{const t=await Rn();let n=0;for(const r of e.prompts){const o=Dn(r.id,r.version);if(!t[o]){const i=Fe(r.pieces,r.identifiers,r.identifierMap),a=We(i);t[o]=a,n++}}return await _t(t),n},Ct=async(e,t)=>{const n=await Rn(),r=Dn(e,t);return n[r]},on=async()=>{try{const e=await te.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 te.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const r of n)t[r]=e[r];await te.writeFile(Ln,JSON.stringify(t,null,2),"utf8")},Et=async(e,t)=>{const n=await on();n[e]=t,await Fn(n)},kt=async()=>{const e=await on(),t={};for(const n of Object.keys(e))t[n]=null;await Fn(t)},Tt=async e=>{try{const t=await on();if(Object.keys(t).length===0)return!1;const r=(await te.readdir(e)).filter(o=>o.endsWith(".md"));for(const o of r){const i=o.replace(".md",""),a=t[i];if(a===void 0||a===null)continue;const l=re.join(e,o),u=await te.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:r,ccVersion:o,variables:i}=t.data;return{name:n||"",description:r||"",ccVersion:o||"",variables:i||[],content:t.content.trim()}},vn=(e,t)=>{const n=t||Fe(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,o={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(o.variables=r),Ge.stringify(n,o,{delimiters:["<!--","-->"]})},Fe=(e,t,n)=>{let r="";for(let o=0;o<e.length;o++)if(r+=e[o],o<t.length){const i=t[o],a=n[String(i)]||`UNKNOWN_${i}`;r+=a}return r},Mt=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,a=r[o]||0;if(i<a)return-1;if(i>a)return 1}return 0},Ve=e=>re.join(Se,`${e}.md`),Nt=async e=>{try{return await te.access(Ve(e)),!0}catch{return!1}},Bt=async e=>{const t=Ve(e),n=await te.readFile(t,"utf-8");return Vn(n)},nn=async(e,t)=>{const n=Ve(e);await te.writeFile(n,t,"utf-8")},Ot=async(e,t)=>{const n=Ve(e),r=await te.readFile(n,"utf-8"),o=Ge(r,{delimiters:["<!--","-->"]}),i=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,a={name:o.data.name,description:o.data.description,ccVersion:o.data.ccVersion};i&&i.length>0&&(a.variables=i);const l=Ge.stringify(o.content,a,{delimiters:["<!--","-->"]});await nn(e,l)},At=(e,t)=>{const n=w=>w.split(/(\s+)/),r=n(e),o=n(t),i=r.length,a=o.length,l=Array(i+1).fill(0).map(()=>Array(a+1).fill(0));for(let w=1;w<=i;w++)for(let x=1;x<=a;x++)r[w-1]===o[x-1]?l[w][x]=l[w-1][x-1]+1:l[w][x]=Math.max(l[w-1][x],l[w][x-1]);const u=Array(i).fill(!1),c=Array(a).fill(!1);let h=i,f=a;for(;h>0||f>0;)h>0&&f>0&&r[h-1]===o[f-1]?(h--,f--):f>0&&(h===0||l[h][f-1]>=l[h-1][f])?(c[f-1]=!0,f--):h>0&&(u[h-1]=!0,h--);const v=w=>w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");let b="";for(let w=0;w<r.length;w++){const x=v(r[w]);b+=u[w]?`<mark>${x}</mark>`:x}let p="";for(let w=0;w<o.length;w++){const x=v(o[w]);p+=c[w]?`<mark>${x}</mark>`:x}return{oldHtml:b,newHtml:p}},$n=(e,t)=>{const n=e.length,r=t.length,o=Array(n+1).fill(0).map(()=>Array(r+1).fill(0));for(let c=1;c<=n;c++)for(let h=1;h<=r;h++)e[c-1]===t[h-1]?o[c][h]=o[c-1][h-1]+1:o[c][h]=Math.max(o[c-1][h],o[c][h-1]);const i=[];let a=n,l=r;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||o[a][l-1]>=o[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 c=0;c<u.length;c++){const h=u[c],f=u[c+1];if(h.type==="removed"&&f?.type==="added"){const v=At(h.line,f.line);i.push({type:"modified",line:h.line,oldLineNo:h.oldLineNo,newLineNo:f.newLineNo,oldHtml:v.oldHtml,newHtml:v.newHtml}),c++}else i.push(h)}return i},Pt=async(e,t,n,r,o,i,a,l)=>{const u=n.split(`
3
- `),c=r.split(`
2
+ import{Box as m,Text as c,render as ct,useInput as de}from"ink";import{Command as dt}from"commander";import Q from"chalk";import*as te from"node:fs/promises";import ie from"node:fs/promises";import Ke,{Fragment as Ee,createContext as ut,useCallback as Nn,useContext as be,useEffect as xe,useState as O}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 Bn from"node:path";import*as ye from"node:os";import{EOL as bn}from"node:os";import*as Ce from"node:fs";import Pe from"node:fs";import{globbySync as gt}from"globby";import ft from"node:process";import*as Me from"node:child_process";import{execSync as On}from"node:child_process";import*as An from"node:crypto";import Ge from"gray-matter";import Re from"node-lief";function mt({items:e,selectedIndex:t,onSelect:n,onSubmit:r}){return de((o,i)=>{i.upArrow?n(t>0?t-1:e.length-1):i.downArrow?n(t<e.length-1?t+1:0):i.return&&r(e[t].name)}),s(m,{flexDirection:"column",children:e.map((o,i)=>s(m,{children:g(c,{children:[g(c,{bold:i===t,color:i===t?"cyan":void 0,...i===t?o.selectedStyles??{}:o.styles??{},children:[i===t?"❯ ":" ",o.name]}),o.desc&&i===t&&g(c,{dimColor:!0,bold:!1,children:[" \x1B[0;2m","- ",o.desc]})]})},i))})}let J=function(e){return e.APPLY_CHANGES="*Apply customizations",e.THEMES="Themes",e.THINKING_VERBS="Thinking verbs",e.THINKING_STYLE="Thinking style",e.USER_MESSAGE_DISPLAY="User message display",e.MISC="Misc",e.TOOLSETS="Toolsets",e.VIEW_SYSTEM_PROMPTS="View system prompts",e.RESTORE_ORIGINAL="Restore original Claude Code (preserves config.json)",e.OPEN_CONFIG="Open config.json",e.OPEN_CLI="Open Claude Code's cli.js",e.EXIT="Exit",e}({});const Z={themes:[{name:"Dark mode",id:"dark",colors:{autoAccept:"rgb(175,135,255)",bashBorder:"rgb(253,93,177)",claude:"rgb(215,119,87)",claudeShimmer:"rgb(235,159,127)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(147,165,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(177,195,255)",permission:"rgb(177,185,249)",permissionShimmer:"rgb(207,215,255)",planMode:"rgb(72,150,140)",ide:"rgb(71,130,200)",promptBorder:"rgb(136,136,136)",promptBorderShimmer:"rgb(166,166,166)",text:"rgb(255,255,255)",inverseText:"rgb(0,0,0)",inactive:"rgb(153,153,153)",subtle:"rgb(80,80,80)",suggestion:"rgb(177,185,249)",remember:"rgb(177,185,249)",background:"rgb(0,204,204)",success:"rgb(78,186,101)",error:"rgb(255,107,128)",warning:"rgb(255,193,7)",warningShimmer:"rgb(255,223,57)",diffAdded:"rgb(34,92,43)",diffRemoved:"rgb(122,41,54)",diffAddedDimmed:"rgb(71,88,74)",diffRemovedDimmed:"rgb(105,72,77)",diffAddedWord:"rgb(56,166,96)",diffRemovedWord:"rgb(179,89,107)",diffAddedWordDimmed:"rgb(46,107,58)",diffRemovedWordDimmed:"rgb(139,57,69)",red_FOR_SUBAGENTS_ONLY:"rgb(220,38,38)",blue_FOR_SUBAGENTS_ONLY:"rgb(37,99,235)",green_FOR_SUBAGENTS_ONLY:"rgb(22,163,74)",yellow_FOR_SUBAGENTS_ONLY:"rgb(202,138,4)",purple_FOR_SUBAGENTS_ONLY:"rgb(147,51,234)",orange_FOR_SUBAGENTS_ONLY:"rgb(234,88,12)",pink_FOR_SUBAGENTS_ONLY:"rgb(219,39,119)",cyan_FOR_SUBAGENTS_ONLY:"rgb(8,145,178)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(55, 55, 55)",bashMessageBackgroundColor:"rgb(65, 60, 65)",memoryBackgroundColor:"rgb(55, 65, 70)",rate_limit_fill:"rgb(177,185,249)",rate_limit_empty:"rgb(80,83,112)"}},{name:"Light mode",id:"light",colors:{autoAccept:"rgb(135,0,255)",bashBorder:"rgb(255,0,135)",claude:"rgb(215,119,87)",claudeShimmer:"rgb(245,149,117)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(87,105,247)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(117,135,255)",permission:"rgb(87,105,247)",permissionShimmer:"rgb(137,155,255)",planMode:"rgb(0,102,102)",ide:"rgb(71,130,200)",promptBorder:"rgb(153,153,153)",promptBorderShimmer:"rgb(183,183,183)",text:"rgb(0,0,0)",inverseText:"rgb(255,255,255)",inactive:"rgb(102,102,102)",subtle:"rgb(175,175,175)",suggestion:"rgb(87,105,247)",remember:"rgb(0,0,255)",background:"rgb(0,153,153)",success:"rgb(44,122,57)",error:"rgb(171,43,63)",warning:"rgb(150,108,30)",warningShimmer:"rgb(200,158,80)",diffAdded:"rgb(105,219,124)",diffRemoved:"rgb(255,168,180)",diffAddedDimmed:"rgb(199,225,203)",diffRemovedDimmed:"rgb(253,210,216)",diffAddedWord:"rgb(47,157,68)",diffRemovedWord:"rgb(209,69,75)",diffAddedWordDimmed:"rgb(144,194,156)",diffRemovedWordDimmed:"rgb(232,165,173)",red_FOR_SUBAGENTS_ONLY:"rgb(220,38,38)",blue_FOR_SUBAGENTS_ONLY:"rgb(37,99,235)",green_FOR_SUBAGENTS_ONLY:"rgb(22,163,74)",yellow_FOR_SUBAGENTS_ONLY:"rgb(202,138,4)",purple_FOR_SUBAGENTS_ONLY:"rgb(147,51,234)",orange_FOR_SUBAGENTS_ONLY:"rgb(234,88,12)",pink_FOR_SUBAGENTS_ONLY:"rgb(219,39,119)",cyan_FOR_SUBAGENTS_ONLY:"rgb(8,145,178)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(240, 240, 240)",bashMessageBackgroundColor:"rgb(250, 245, 250)",memoryBackgroundColor:"rgb(230, 245, 250)",rate_limit_fill:"rgb(87,105,247)",rate_limit_empty:"rgb(39,47,111)"}},{name:"Light mode (ANSI colors only)",id:"light-ansi",colors:{autoAccept:"ansi:magenta",bashBorder:"ansi:magenta",claude:"ansi:redBright",claudeShimmer:"ansi:yellowBright",claudeBlue_FOR_SYSTEM_SPINNER:"ansi:blue",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"ansi:blueBright",permission:"ansi:blue",permissionShimmer:"ansi:blueBright",planMode:"ansi:cyan",ide:"ansi:blueBright",promptBorder:"ansi:white",promptBorderShimmer:"ansi:whiteBright",text:"ansi:black",inverseText:"ansi:white",inactive:"ansi:blackBright",subtle:"ansi:blackBright",suggestion:"ansi:blue",remember:"ansi:blue",background:"ansi:cyan",success:"ansi:green",error:"ansi:red",warning:"ansi:yellow",warningShimmer:"ansi:yellowBright",diffAdded:"ansi:green",diffRemoved:"ansi:red",diffAddedDimmed:"ansi:green",diffRemovedDimmed:"ansi:red",diffAddedWord:"ansi:greenBright",diffRemovedWord:"ansi:redBright",diffAddedWordDimmed:"ansi:green",diffRemovedWordDimmed:"ansi:red",red_FOR_SUBAGENTS_ONLY:"ansi:red",blue_FOR_SUBAGENTS_ONLY:"ansi:blue",green_FOR_SUBAGENTS_ONLY:"ansi:green",yellow_FOR_SUBAGENTS_ONLY:"ansi:yellow",purple_FOR_SUBAGENTS_ONLY:"ansi:magenta",orange_FOR_SUBAGENTS_ONLY:"ansi:redBright",pink_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",cyan_FOR_SUBAGENTS_ONLY:"ansi:cyan",professionalBlue:"ansi:blueBright",rainbow_red:"ansi:red",rainbow_orange:"ansi:redBright",rainbow_yellow:"ansi:yellow",rainbow_green:"ansi:green",rainbow_blue:"ansi:cyan",rainbow_indigo:"ansi:blue",rainbow_violet:"ansi:magenta",rainbow_red_shimmer:"ansi:redBright",rainbow_orange_shimmer:"ansi:yellow",rainbow_yellow_shimmer:"ansi:yellowBright",rainbow_green_shimmer:"ansi:greenBright",rainbow_blue_shimmer:"ansi:cyanBright",rainbow_indigo_shimmer:"ansi:blueBright",rainbow_violet_shimmer:"ansi:magentaBright",clawd_body:"ansi:redBright",clawd_background:"ansi:black",userMessageBackground:"ansi:white",bashMessageBackgroundColor:"ansi:whiteBright",memoryBackgroundColor:"ansi:white",rate_limit_fill:"ansi:yellow",rate_limit_empty:"ansi:black"}},{name:"Dark mode (ANSI colors only)",id:"dark-ansi",colors:{autoAccept:"ansi:magentaBright",bashBorder:"ansi:magentaBright",claude:"ansi:redBright",claudeShimmer:"ansi:yellowBright",claudeBlue_FOR_SYSTEM_SPINNER:"ansi:blueBright",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"ansi:blueBright",permission:"ansi:blueBright",permissionShimmer:"ansi:blueBright",planMode:"ansi:cyanBright",ide:"ansi:blue",promptBorder:"ansi:white",promptBorderShimmer:"ansi:whiteBright",text:"ansi:whiteBright",inverseText:"ansi:black",inactive:"ansi:white",subtle:"ansi:white",suggestion:"ansi:blueBright",remember:"ansi:blueBright",background:"ansi:cyanBright",success:"ansi:greenBright",error:"ansi:redBright",warning:"ansi:yellowBright",warningShimmer:"ansi:yellowBright",diffAdded:"ansi:green",diffRemoved:"ansi:red",diffAddedDimmed:"ansi:green",diffRemovedDimmed:"ansi:red",diffAddedWord:"ansi:greenBright",diffRemovedWord:"ansi:redBright",diffAddedWordDimmed:"ansi:green",diffRemovedWordDimmed:"ansi:red",red_FOR_SUBAGENTS_ONLY:"ansi:redBright",blue_FOR_SUBAGENTS_ONLY:"ansi:blueBright",green_FOR_SUBAGENTS_ONLY:"ansi:greenBright",yellow_FOR_SUBAGENTS_ONLY:"ansi:yellowBright",purple_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",orange_FOR_SUBAGENTS_ONLY:"ansi:redBright",pink_FOR_SUBAGENTS_ONLY:"ansi:magentaBright",cyan_FOR_SUBAGENTS_ONLY:"ansi:cyanBright",professionalBlue:"rgb(106,155,204)",rainbow_red:"ansi:red",rainbow_orange:"ansi:redBright",rainbow_yellow:"ansi:yellow",rainbow_green:"ansi:green",rainbow_blue:"ansi:cyan",rainbow_indigo:"ansi:blue",rainbow_violet:"ansi:magenta",rainbow_red_shimmer:"ansi:redBright",rainbow_orange_shimmer:"ansi:yellow",rainbow_yellow_shimmer:"ansi:yellowBright",rainbow_green_shimmer:"ansi:greenBright",rainbow_blue_shimmer:"ansi:cyanBright",rainbow_indigo_shimmer:"ansi:blueBright",rainbow_violet_shimmer:"ansi:magentaBright",clawd_body:"ansi:redBright",clawd_background:"ansi:black",userMessageBackground:"ansi:blackBright",bashMessageBackgroundColor:"ansi:black",memoryBackgroundColor:"ansi:blackBright",rate_limit_fill:"ansi:yellow",rate_limit_empty:"ansi:white"}},{name:"Light mode (colorblind-friendly)",id:"light-daltonized",colors:{autoAccept:"rgb(135,0,255)",bashBorder:"rgb(0,102,204)",claude:"rgb(255,153,51)",claudeShimmer:"rgb(255,183,101)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(51,102,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(101,152,255)",permission:"rgb(51,102,255)",permissionShimmer:"rgb(101,152,255)",planMode:"rgb(51,102,102)",ide:"rgb(71,130,200)",promptBorder:"rgb(153,153,153)",promptBorderShimmer:"rgb(183,183,183)",text:"rgb(0,0,0)",inverseText:"rgb(255,255,255)",inactive:"rgb(102,102,102)",subtle:"rgb(175,175,175)",suggestion:"rgb(51,102,255)",remember:"rgb(51,102,255)",background:"rgb(0,153,153)",success:"rgb(0,102,153)",error:"rgb(204,0,0)",warning:"rgb(255,153,0)",warningShimmer:"rgb(255,183,50)",diffAdded:"rgb(153,204,255)",diffRemoved:"rgb(255,204,204)",diffAddedDimmed:"rgb(209,231,253)",diffRemovedDimmed:"rgb(255,233,233)",diffAddedWord:"rgb(51,102,204)",diffRemovedWord:"rgb(153,51,51)",diffAddedWordDimmed:"rgb(102,153,204)",diffRemovedWordDimmed:"rgb(204,153,153)",red_FOR_SUBAGENTS_ONLY:"rgb(204,0,0)",blue_FOR_SUBAGENTS_ONLY:"rgb(0,102,204)",green_FOR_SUBAGENTS_ONLY:"rgb(0,204,0)",yellow_FOR_SUBAGENTS_ONLY:"rgb(255,204,0)",purple_FOR_SUBAGENTS_ONLY:"rgb(128,0,128)",orange_FOR_SUBAGENTS_ONLY:"rgb(255,128,0)",pink_FOR_SUBAGENTS_ONLY:"rgb(255,102,178)",cyan_FOR_SUBAGENTS_ONLY:"rgb(0,178,178)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(220, 220, 220)",bashMessageBackgroundColor:"rgb(250, 245, 250)",memoryBackgroundColor:"rgb(230, 245, 250)",rate_limit_fill:"rgb(51,102,255)",rate_limit_empty:"rgb(23,46,114)"}},{name:"Dark mode (colorblind-friendly)",id:"dark-daltonized",colors:{autoAccept:"rgb(175,135,255)",bashBorder:"rgb(51,153,255)",claude:"rgb(255,153,51)",claudeShimmer:"rgb(255,183,101)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(153,204,255)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(183,224,255)",permission:"rgb(153,204,255)",permissionShimmer:"rgb(183,224,255)",planMode:"rgb(102,153,153)",ide:"rgb(71,130,200)",promptBorder:"rgb(136,136,136)",promptBorderShimmer:"rgb(166,166,166)",text:"rgb(255,255,255)",inverseText:"rgb(0,0,0)",inactive:"rgb(153,153,153)",subtle:"rgb(80,80,80)",suggestion:"rgb(153,204,255)",remember:"rgb(153,204,255)",background:"rgb(0,204,204)",success:"rgb(51,153,255)",error:"rgb(255,102,102)",warning:"rgb(255,204,0)",warningShimmer:"rgb(255,234,50)",diffAdded:"rgb(0,68,102)",diffRemoved:"rgb(102,0,0)",diffAddedDimmed:"rgb(62,81,91)",diffRemovedDimmed:"rgb(62,44,44)",diffAddedWord:"rgb(0,119,179)",diffRemovedWord:"rgb(179,0,0)",diffAddedWordDimmed:"rgb(26,99,128)",diffRemovedWordDimmed:"rgb(128,21,21)",red_FOR_SUBAGENTS_ONLY:"rgb(255,102,102)",blue_FOR_SUBAGENTS_ONLY:"rgb(102,178,255)",green_FOR_SUBAGENTS_ONLY:"rgb(102,255,102)",yellow_FOR_SUBAGENTS_ONLY:"rgb(255,255,102)",purple_FOR_SUBAGENTS_ONLY:"rgb(178,102,255)",orange_FOR_SUBAGENTS_ONLY:"rgb(255,178,102)",pink_FOR_SUBAGENTS_ONLY:"rgb(255,153,204)",cyan_FOR_SUBAGENTS_ONLY:"rgb(102,204,204)",professionalBlue:"rgb(106,155,204)",rainbow_red:"rgb(235,95,87)",rainbow_orange:"rgb(245,139,87)",rainbow_yellow:"rgb(250,195,95)",rainbow_green:"rgb(145,200,130)",rainbow_blue:"rgb(130,170,220)",rainbow_indigo:"rgb(155,130,200)",rainbow_violet:"rgb(200,130,180)",rainbow_red_shimmer:"rgb(250,155,147)",rainbow_orange_shimmer:"rgb(255,185,137)",rainbow_yellow_shimmer:"rgb(255,225,155)",rainbow_green_shimmer:"rgb(185,230,180)",rainbow_blue_shimmer:"rgb(180,205,240)",rainbow_indigo_shimmer:"rgb(195,180,230)",rainbow_violet_shimmer:"rgb(230,180,210)",clawd_body:"rgb(215,119,87)",clawd_background:"rgb(0,0,0)",userMessageBackground:"rgb(55, 55, 55)",bashMessageBackgroundColor:"rgb(65, 60, 65)",memoryBackgroundColor:"rgb(55, 65, 70)",rate_limit_fill:"rgb(153,204,255)",rate_limit_empty:"rgb(69,92,115)"}},{name:"Monochrome",id:"monochrome",colors:{autoAccept:"rgb(200,200,200)",bashBorder:"rgb(180,180,180)",claude:"rgb(255,255,255)",claudeShimmer:"rgb(230,230,230)",claudeBlue_FOR_SYSTEM_SPINNER:"rgb(200,200,200)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"rgb(220,220,220)",permission:"rgb(200,200,200)",permissionShimmer:"rgb(220,220,220)",planMode:"rgb(180,180,180)",ide:"rgb(190,190,190)",promptBorder:"rgb(160,160,160)",promptBorderShimmer:"rgb(180,180,180)",text:"rgb(255,255,255)",inverseText:"rgb(40,40,40)",inactive:"rgb(120,120,120)",subtle:"rgb(100,100,100)",suggestion:"rgb(200,200,200)",remember:"rgb(200,200,200)",background:"rgb(180,180,180)",success:"rgb(220,220,220)",error:"rgb(180,180,180)",warning:"rgb(200,200,200)",warningShimmer:"rgb(220,220,220)",diffAdded:"rgb(90,90,90)",diffRemoved:"rgb(60,60,60)",diffAddedDimmed:"rgb(110,110,110)",diffRemovedDimmed:"rgb(80,80,80)",diffAddedWord:"rgb(200,200,200)",diffRemovedWord:"rgb(80,80,80)",diffAddedWordDimmed:"rgb(160,160,160)",diffRemovedWordDimmed:"rgb(70,70,70)",red_FOR_SUBAGENTS_ONLY:"rgb(200,200,200)",blue_FOR_SUBAGENTS_ONLY:"rgb(180,180,180)",green_FOR_SUBAGENTS_ONLY:"rgb(210,210,210)",yellow_FOR_SUBAGENTS_ONLY:"rgb(190,190,190)",purple_FOR_SUBAGENTS_ONLY:"rgb(170,170,170)",orange_FOR_SUBAGENTS_ONLY:"rgb(195,195,195)",pink_FOR_SUBAGENTS_ONLY:"rgb(205,205,205)",cyan_FOR_SUBAGENTS_ONLY:"rgb(185,185,185)",professionalBlue:"rgb(190,190,190)",rainbow_red:"rgb(240,240,240)",rainbow_orange:"rgb(230,230,230)",rainbow_yellow:"rgb(220,220,220)",rainbow_green:"rgb(210,210,210)",rainbow_blue:"rgb(200,200,200)",rainbow_indigo:"rgb(190,190,190)",rainbow_violet:"rgb(180,180,180)",rainbow_red_shimmer:"rgb(255,255,255)",rainbow_orange_shimmer:"rgb(245,245,245)",rainbow_yellow_shimmer:"rgb(235,235,235)",rainbow_green_shimmer:"rgb(225,225,225)",rainbow_blue_shimmer:"rgb(215,215,215)",rainbow_indigo_shimmer:"rgb(205,205,205)",rainbow_violet_shimmer:"rgb(195,195,195)",clawd_body:"rgb(255,255,255)",clawd_background:"rgb(40,40,40)",userMessageBackground:"rgb(70,70,70)",bashMessageBackgroundColor:"rgb(65,65,65)",memoryBackgroundColor:"rgb(75,75,75)",rate_limit_fill:"rgb(200,200,200)",rate_limit_empty:"rgb(90,90,90)"}}],thinkingVerbs:{format:"{}… ",verbs:["Accomplishing","Actioning","Actualizing","Baking","Booping","Brewing","Calculating","Cerebrating","Channelling","Churning","Clauding","Coalescing","Cogitating","Combobulating","Computing","Concocting","Conjuring","Considering","Contemplating","Cooking","Crafting","Creating","Crunching","Deciphering","Deliberating","Determining","Discombobulating","Divining","Doing","Effecting","Elucidating","Enchanting","Envisioning","Finagling","Flibbertigibbeting","Forging","Forming","Frolicking","Generating","Germinating","Hatching","Herding","Honking","Ideating","Imagining","Incubating","Inferring","Manifesting","Marinating","Meandering","Moseying","Mulling","Musing","Mustering","Noodling","Percolating","Perusing","Philosophising","Pondering","Pontificating","Processing","Puttering","Puzzling","Reticulating","Ruminating","Scheming","Schlepping","Shimmying","Simmering","Smooshing","Spelunking","Spinning","Stewing","Sussing","Synthesizing","Thinking","Tinkering","Transmuting","Unfurling","Unravelling","Vibing","Wandering","Whirring","Wibbling","Wizarding","Working","Wrangling","Alchemizing","Animating","Architecting","Bamboozling","Beaming","Befuddling","Bewitching","Billowing","Bippity-bopping","Blanching","Boogieing","Boondoggling","Bootstrapping","Burrowing","Caching","Canoodling","Caramelizing","Cascading","Catapulting","Channeling","Choreographing","Compiling","Composing","Crystallizing","Cultivating","Deploying","Dilly-dallying","Discombobulating","Distilling","Doodling","Drizzling","Ebbing","Embellishing","Ensorcelling","Evaporating","Fermenting","Fiddle-faddling","Finagling","Flambéing","Flowing","Flummoxing","Fluttering","Frosting","Gallivanting","Galloping","Garnishing","Germinating","Gitifying","Grooving","Gusting","Harmonizing","Hashing","Hexing","Hibernating","Higgledy-piggleding","Hornswoggling","Hullaballooing","Hyperspacing","Illustrating","Improvising","Incanting","Indexing","Infusing","Ionizing","Jazzercising","Jiggery-pokerying","Jitterbugging","Julienning","Kerfuffling","Kneading","Leavening","Levitating","Linting","Lollygagging","Malarkeying","Metamorphosing","Migrating","Minifying","Misting","Moonwalking","Mystifying","Nebulizing","Nesting","Nucleating","Optimizing","Orbiting","Orchestrating","Osmosing","Parsing","Perambulating","Photosynthesizing","Pipelining","Poaching","Pollinating","Pouncing","Precipitating","Prestidigitating","Proofing","Propagating","Prowling","Quantumizing","Querying","Razzle-dazzling","Razzmatazzing","Recombobulating","Reducing","Refactoring","Rippling","Roosting","Sautéing","Scampering","Scurrying","Seasoning","Serializing","Shenaniganing","Skedaddling","Sketching","Skullduggering","Slithering","Sock-hopping","Spellbinding","Sprouting","Storyboarding","Sublimating","Swirling","Swooping","Symbioting","Syncopating","Teleporting","Tempering","Thaumaturging","Thundering","Tomfoolering","Topsy-turvying","Transfiguring","Transpiling","Twisting","Undulating","Validating","Vaporizing","Waddling","Warping","Whatchamacalliting","Whirlpooling","Whisking","Willy-nillying","Zesting","Zigzagging"]},thinkingStyle:{updateInterval:120,phases:process.env.TERM==="xterm-ghostty"?["·","✢","✳","✶","✻","*"]:process.platform==="darwin"?["·","✢","✳","✶","✻","✽"]:["·","✢","*","✶","✻","✽"],reverseMirror:!0},userMessageDisplay:{prefix:{format:">",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"},message:{format:"{}",styling:[],foreground_color:"rgb(0,0,0)",background_color:"rgb(0,0,0)"}},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0},toolsets:[],defaultToolset:null},pt=()=>{const e=re.join(ye.homedir(),".tweakcc"),t=process.env.XDG_CONFIG_HOME;try{if(Ce.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",r=(o,i=!1)=>{if(i){const a=gt(o,{onlyFiles:!1});e.push({pattern:o,isGlob:!0,expandedPaths:a})}else e.push({pattern:o,isGlob:!1,expandedPaths:[o]})};return r(`${ye.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform=="win32"?(r(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),r(`${t}/AppData/Roaming/npm/${n}`),r(`${t}/AppData/Roaming/nvm/*/${n}`,!0),r(`${t}/AppData/Local/Yarn/config/global/${n}`),r(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),r(`C:/nvm4w/nodejs/${n}`),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/AppData/Roaming/Yarn/config/global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0)):(process.platform=="darwin"&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`)),r(`${t}/.local/lib/${n}`),r(`${t}/.local/share/${n}`),r(`${t}/.npm-global/lib/${n}`),r(`${t}/.npm-packages/lib/${n}`),r(`${t}/.npm/lib/${n}`),r(`${t}/npm/lib/${n}`),r(`/etc/${n}`),r(`/lib/${n}`),r(`/opt/node/lib/${n}`),r(`/usr/lib/${n}`),r(`/usr/local/lib/${n}`),r(`/usr/share/${n}`),r(`/var/lib/${n}`),r(`/opt/homebrew/lib/${n}`),r(`${t}/.linuxbrew/lib/${n}`),r(`${t}/.config/yarn/global/${n}`),r(`${t}/.yarn/global/${n}`),r(`${t}/.bun/install/global/${n}`),r(`${t}/.pnpm-global/${n}`),r(`${t}/.pnpm-global/*/${n}`,!0),r(`${t}/pnpm-global/${n}`),r(`${t}/pnpm-global/*/${n}`,!0),r(`${t}/.local/share/pnpm/global/${n}`),r(`${t}/.local/share/pnpm/global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`/usr/local/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/lib/${n}`),r(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),r(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),r(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nodenv/versions/*/lib/${n}`,!0),r(`${t}/.nvs/*/lib/${n}`,!0),r(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0)),process.platform=="win32"&&e.forEach(o=>{o.pattern=o.pattern.replace(/\//g,"\\"),o.expandedPaths=o.expandedPaths.map(i=>i.replace(/\//g,"\\"))}),e},en=bt(),xn=en.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:J.THEMES,desc:"Modify Claude Code's built-in themes or create your own"},{name:J.THINKING_VERBS,desc:"Customize the list of verbs that Claude Code uses when it's working"},{name:J.THINKING_STYLE,desc:"Choose custom spinners"},{name:J.USER_MESSAGE_DISPLAY,desc:"Customize how user messages are displayed"},{name:J.MISC,desc:"Miscellaneous settings (input box border, etc.)"},{name:J.TOOLSETS,desc:"Manage toolsets to control which tools are available"},{name:J.VIEW_SYSTEM_PROMPTS,desc:"Opens the system prompts directory where you can customize Claude Code's system prompts"}],yn=[{name:J.RESTORE_ORIGINAL,desc:"Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)"},{name:J.OPEN_CONFIG,desc:`Opens your tweakcc config file (${ae})`},{name:J.OPEN_CLI,desc:"Opens Claude Code's cli.js file"},{name:J.EXIT,desc:"Bye!"}];function yt({onSubmit:e,notification:t,isNativeInstallation:n}){const r=n?yn.filter(l=>l.name!==J.OPEN_CLI):yn,o=[...be(ue).changesApplied?[]:[{name:J.APPLY_CHANGES,desc:"Required: Updates Claude Code in-place with your changes",selectedStyles:{color:"green"}}],...xt,...r],[i,a]=O(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:o,selectedIndex:i,onSelect:a,onSubmit:l=>e(l)})]})}async function rn(e){const t=re.join(wn,`prompts-${e}.json`);try{const r=await te.readFile(t,"utf-8");return JSON.parse(r)}catch{}const n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{const r=await fetch(n);if(!r.ok){let i;throw r.status===429?i="Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.":r.status===404?i=`Prompts file not found for Claude Code v${e}. This version was released within the past day or so and will be supported within a few hours.`:r.status>=500?i=`GitHub server error (${r.status}). Please try again later.`:i=`HTTP ${r.status}: ${r.statusText}`,new Error(i)}const o=await r.json();try{await te.mkdir(wn,{recursive:!0}),await te.writeFile(t,JSON.stringify(o,null,2),"utf-8")}catch(i){console.warn(`Failed to write to cache to ${t}: ${i}`)}return o}catch(r){if(r instanceof Error){if(r.message.includes("Rate limit")||r.message.includes("not found")||r.message.includes("server error")||r.message.includes("HTTP"))throw r;const o=`Failed to download prompts for version ${e}: ${r.message}`;throw new Error(o)}throw r}}const St="modulepreload",vt=function(e){return"/"+e},Sn={},$t=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let d=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const a=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),u=l?.nonce||l?.getAttribute("nonce");o=d(n.map(h=>{if(h=vt(h,r),h in Sn)return;Sn[h]=!0;const f=h.endsWith(".css"),v=f?'[rel="stylesheet"]':"";if(!!r)for(let w=a.length-1;w>=0;w--){const x=a[w];if(x.href===h&&(!f||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${v}`))return;const p=document.createElement("link");if(p.rel=f?"stylesheet":St,f||(p.as="script"),p.crossOrigin="",p.href=h,u&&p.setAttribute("nonce",u),document.head.appendChild(p),f)return new Promise((w,x)=>{p.addEventListener("load",w),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${h}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return o.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Pn=re.join(ce,"systemPromptOriginalHashes.json"),Dn=re.join(ce,"systemPromptAppliedHashes.json"),Ln=(e,t)=>`${e}-${t}`,We=e=>An.createHash("md5").update(e.trim(),"utf8").digest("hex"),Rn=async()=>{try{const e=await te.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 te.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const r of n)t[r]=e[r];await te.writeFile(Pn,JSON.stringify(t,null,2),"utf8")},It=async e=>{const t=await Rn();let n=0;for(const r of e.prompts){const o=Ln(r.id,r.version);if(!t[o]){const i=Fe(r.pieces,r.identifiers,r.identifierMap),a=We(i);t[o]=a,n++}}return await _t(t),n},Ct=async(e,t)=>{const n=await Rn(),r=Ln(e,t);return n[r]},on=async()=>{try{const e=await te.readFile(Dn,"utf8");return JSON.parse(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return{};throw e}},Fn=async e=>{await te.mkdir(ce,{recursive:!0});const t={},n=Object.keys(e).sort();for(const r of n)t[r]=e[r];await te.writeFile(Dn,JSON.stringify(t,null,2),"utf8")},Et=async(e,t)=>{const n=await on();n[e]=t,await Fn(n)},kt=async()=>{const e=await on(),t={};for(const n of Object.keys(e))t[n]=null;await Fn(t)},Tt=async e=>{try{const t=await on();if(Object.keys(t).length===0)return!1;const r=(await te.readdir(e)).filter(o=>o.endsWith(".md"));for(const o of r){const i=o.replace(".md",""),a=t[i];if(a===void 0||a===null)continue;const l=re.join(e,o),u=await te.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:r,ccVersion:o,variables:i}=t.data;return{name:n||"",description:r||"",ccVersion:o||"",variables:i||[],content:t.content.trim()}},vn=(e,t)=>{const n=t||Fe(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,o={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(o.variables=r),Ge.stringify(n,o,{delimiters:["<!--","-->"]})},Fe=(e,t,n)=>{let r="";for(let o=0;o<e.length;o++)if(r+=e[o],o<t.length){const i=t[o],a=n[String(i)]||`UNKNOWN_${i}`;r+=a}return r},Mt=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,a=r[o]||0;if(i<a)return-1;if(i>a)return 1}return 0},Ve=e=>re.join(Se,`${e}.md`),Nt=async e=>{try{return await te.access(Ve(e)),!0}catch{return!1}},Bt=async e=>{const t=Ve(e),n=await te.readFile(t,"utf-8");return Vn(n)},nn=async(e,t)=>{const n=Ve(e);await te.writeFile(n,t,"utf-8")},Ot=async(e,t)=>{const n=Ve(e),r=await te.readFile(n,"utf-8"),o=Ge(r,{delimiters:["<!--","-->"]}),i=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,a={name:o.data.name,description:o.data.description,ccVersion:o.data.ccVersion};i&&i.length>0&&(a.variables=i);const l=Ge.stringify(o.content,a,{delimiters:["<!--","-->"]});await nn(e,l)},At=(e,t)=>{const n=w=>w.split(/(\s+)/),r=n(e),o=n(t),i=r.length,a=o.length,l=Array(i+1).fill(0).map(()=>Array(a+1).fill(0));for(let w=1;w<=i;w++)for(let x=1;x<=a;x++)r[w-1]===o[x-1]?l[w][x]=l[w-1][x-1]+1:l[w][x]=Math.max(l[w-1][x],l[w][x-1]);const u=Array(i).fill(!1),d=Array(a).fill(!1);let h=i,f=a;for(;h>0||f>0;)h>0&&f>0&&r[h-1]===o[f-1]?(h--,f--):f>0&&(h===0||l[h][f-1]>=l[h-1][f])?(d[f-1]=!0,f--):h>0&&(u[h-1]=!0,h--);const v=w=>w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");let b="";for(let w=0;w<r.length;w++){const x=v(r[w]);b+=u[w]?`<mark>${x}</mark>`:x}let p="";for(let w=0;w<o.length;w++){const x=v(o[w]);p+=d[w]?`<mark>${x}</mark>`:x}return{oldHtml:b,newHtml:p}},$n=(e,t)=>{const n=e.length,r=t.length,o=Array(n+1).fill(0).map(()=>Array(r+1).fill(0));for(let d=1;d<=n;d++)for(let h=1;h<=r;h++)e[d-1]===t[h-1]?o[d][h]=o[d-1][h-1]+1:o[d][h]=Math.max(o[d-1][h],o[d][h-1]);const i=[];let a=n,l=r;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||o[a][l-1]>=o[a-1][l])?(u.unshift({type:"added",line:t[l-1],newLineNo:l}),l--):a>0&&(u.unshift({type:"removed",line:e[a-1],oldLineNo:a}),a--);for(let d=0;d<u.length;d++){const h=u[d],f=u[d+1];if(h.type==="removed"&&f?.type==="added"){const v=At(h.line,f.line);i.push({type:"modified",line:h.line,oldLineNo:h.oldLineNo,newLineNo:f.newLineNo,oldHtml:v.oldHtml,newHtml:v.newHtml}),d++}else i.push(h)}return i},Pt=async(e,t,n,r,o,i,a,l)=>{const u=n.split(`
3
+ `),d=r.split(`
4
4
  `),h=o.split(`
5
- `),f=_=>_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),v=$n(u,c),b=$n(u,h);let p="";for(const _ of v){const k=f(_.line);if(_.type==="modified"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",B=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${_.oldHtml}</div>
5
+ `),f=_=>_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),v=$n(u,d),b=$n(u,h);let p="";for(const _ of v){const k=f(_.line);if(_.type==="modified"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ",B=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${_.oldHtml}</div>
6
6
  `,p+=`<div class="line added"><span class="line-num">${B}</span><span class="prefix">+ </span>${_.newHtml}</div>
7
7
  `}else if(_.type==="removed"){const P=_.oldLineNo?String(_.oldLineNo).padStart(4," "):" ";p+=`<div class="line removed"><span class="line-num">${P}</span><span class="prefix">- </span>${k}</div>
8
8
  `}else if(_.type==="added"){const P=_.newLineNo?String(_.newLineNo).padStart(4," "):" ";p+=`<div class="line added"><span class="line-num">${P}</span><span class="prefix">+ </span>${k}</div>
@@ -173,24 +173,24 @@ ${w} </div>
173
173
  </div>
174
174
  </div>
175
175
  </body>
176
- </html>`,C=re.join(Se,`${e}.diff.html`);return await te.writeFile(C,x,"utf-8"),C},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 o=vn(e);return await nn(e.id,o),t.action="created",t}const r=await Bt(e.id);if(t.oldVersion=r.ccVersion,await Ot(e.id,e.identifierMap),r.ccVersion&&e.version){const o=Mt(r.ccVersion,e.version);if(o===0)return t.action="skipped",t;if(o!=0){const i=await Ct(e.id,r.ccVersion),a=We(r.content);if(!i||i!==a){t.action="conflict";let u=r.content;try{const b=(await rn(r.ccVersion)).prompts.find(p=>p.id===e.id);b&&(u=Fe(b.pieces,b.identifiers,b.identifierMap))}catch{console.log(Q.yellow(`Warning: Could not fetch old version ${r.ccVersion} for comparison. Using current file as baseline.`))}const c=Fe(e.pieces,e.identifiers,e.identifierMap),h=Ve(e.id),f=await Pt(e.id,e.name,u,r.content,c,r.ccVersion,e.version,h);t.diffHtmlPath=f}else{const u=vn(e);await nn(e.id,u),t.action="updated"}}}return t},Dt=async e=>{const t={ccVersion:e,results:[]},n=await rn(e);await It(n),await te.mkdir(Se,{recursive:!0});for(const r of n.prompts)try{const o=await Lt(r);t.results.push(o)}catch(o){throw console.log(Q.red(`Failed to sync prompt ${r.id}:`)),o}return t};let ze=null,tn=null;const _n=async e=>{try{return ze=await rn(e),tn=e,{success:!0}}catch(t){return ze=null,tn=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 r=`\\\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${r})`}),Ft=e=>e.replace(/[^\x00-\x7F]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Vt=(e,t)=>{let n="";for(let r=0;r<e.length;r++){const i=e[r].replace(/<<CCVERSION>>/g,t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=Rt(i);n+=a,r<e.length-1&&(n+="([\\w$]+)")}return n},jt=(e,t,n,r,o,i=!1)=>{const a={};for(let c=0;c<r.length;c++){const h=r[c],f=String(t[c]),v=n[f];v&&(a[v]=h)}let l=e;const u=Object.entries(a).sort((c,h)=>h[0].length-c[0].length);for(const[c,h]of u){const f=new RegExp(`\\b${c}\\b`,"g");l=l.replace(f,h)}return l=l.replace(/<<CCVERSION>>/g,o),i&&(l=Ft(l)),l},Ut=async(e,t=!1)=>{if(!ze||tn!==e)return[];const n=ze,r=[];for(const o of n.prompts){const i=Vt(o.pieces,e),a=re.join(Se,`${o.id}.md`);let l;try{l=await te.readFile(a,"utf8")}catch(h){console.error(`Failed to read markdown file ${a}:`,h);continue}const u=Vn(l),c=h=>{const f=h.slice(1);return jt(u.content,o.identifiers,o.identifierMap,f,e,t)};r.push({promptId:o.id,prompt:u,regex:i,getInterpolatedContent:c,pieces:o.pieces,identifiers:o.identifiers,identifierMap:o.identifierMap})}return r},Ht=e=>{const t=e.results.filter(i=>i.action==="created"),n=e.results.filter(i=>i.action==="updated"),r=e.results.filter(i=>i.action==="conflict"),o=e.results.filter(i=>i.action==="skipped");if((t.length>0||n.length>0||r.length>0)&&o.length>0&&(console.log(Q.dim(`Skipped ${o.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(Q.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(Q.green(` ${Se}/${i.id}.md`)),console.log(Q.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(Q.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(Q.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(Q.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(r.length>0){console.log(Q.bold.yellow(`WARNING: Conflicts detected for ${r.length} system prompt file(s)`));for(const i of r)console.log(Q.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(Q.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(Q.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(Q.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(Q.green('Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts')),console.log()),r.length>0){console.log(),console.log("Review conflicts:"),console.log(" 1. Open the diff HTML files in your browser"),console.log(" 2. Verify your customizations are still appropriate"),console.log(" 3. Update your markdown files if needed"),console.log(Q.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const i of r)console.log(Q.yellow(` ${i.id}.md → `)+Q.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},le=Buffer.from(`
176
+ </html>`,C=re.join(Se,`${e}.diff.html`);return await te.writeFile(C,x,"utf-8"),C},Dt=async e=>{const t={id:e.id,name:e.name,description:e.description,action:"skipped",newVersion:e.version};if(!await Nt(e.id)){const o=vn(e);return await nn(e.id,o),t.action="created",t}const r=await Bt(e.id);if(t.oldVersion=r.ccVersion,await Ot(e.id,e.identifierMap),r.ccVersion&&e.version){const o=Mt(r.ccVersion,e.version);if(o===0)return t.action="skipped",t;if(o!=0){const i=await Ct(e.id,r.ccVersion),a=We(r.content);if(!i||i!==a){t.action="conflict";let u=r.content;try{const b=(await rn(r.ccVersion)).prompts.find(p=>p.id===e.id);b&&(u=Fe(b.pieces,b.identifiers,b.identifierMap))}catch{console.log(Q.yellow(`Warning: Could not fetch old version ${r.ccVersion} for comparison. Using current file as baseline.`))}const d=Fe(e.pieces,e.identifiers,e.identifierMap),h=Ve(e.id),f=await Pt(e.id,e.name,u,r.content,d,r.ccVersion,e.version,h);t.diffHtmlPath=f}else{const u=vn(e);await nn(e.id,u),t.action="updated"}}}return t},Lt=async e=>{const t={ccVersion:e,results:[]},n=await rn(e);await It(n),await te.mkdir(Se,{recursive:!0});for(const r of n.prompts)try{const o=await Dt(r);t.results.push(o)}catch(o){throw console.log(Q.red(`Failed to sync prompt ${r.id}:`)),o}return t};let ze=null,tn=null;const _n=async e=>{try{return ze=await rn(e),tn=e,{success:!0}}catch(t){return ze=null,tn=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 r=`\\\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`;return`(?:${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}|${r})`}),Ft=e=>e.replace(/[^\x00-\x7F]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),Vt=(e,t)=>{let n="";for(let r=0;r<e.length;r++){const i=e[r].replace(/<<CCVERSION>>/g,t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=Rt(i);n+=a,r<e.length-1&&(n+="([\\w$]+)")}return n},jt=(e,t,n,r,o,i=!1)=>{const a={};for(let d=0;d<r.length;d++){const h=r[d],f=String(t[d]),v=n[f];v&&(a[v]=h)}let l=e;const u=Object.entries(a).sort((d,h)=>h[0].length-d[0].length);for(const[d,h]of u){const f=new RegExp(`\\b${d}\\b`,"g");l=l.replace(f,h)}return l=l.replace(/<<CCVERSION>>/g,o),i&&(l=Ft(l)),l},Ut=async(e,t=!1)=>{if(!ze||tn!==e)return[];const n=ze,r=[];for(const o of n.prompts){const i=Vt(o.pieces,e),a=re.join(Se,`${o.id}.md`);let l;try{l=await te.readFile(a,"utf8")}catch(h){console.error(`Failed to read markdown file ${a}:`,h);continue}const u=Vn(l),d=h=>{const f=h.slice(1);return jt(u.content,o.identifiers,o.identifierMap,f,e,t)};r.push({promptId:o.id,prompt:u,regex:i,getInterpolatedContent:d,pieces:o.pieces,identifiers:o.identifiers,identifierMap:o.identifierMap})}return r},Ht=e=>{const t=e.results.filter(i=>i.action==="created"),n=e.results.filter(i=>i.action==="updated"),r=e.results.filter(i=>i.action==="conflict"),o=e.results.filter(i=>i.action==="skipped");if((t.length>0||n.length>0||r.length>0)&&o.length>0&&(console.log(Q.dim(`Skipped ${o.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(Q.bold.green(`Created ${t.length} new prompt file(s):`));for(const i of t)console.log(Q.green(` ${Se}/${i.id}.md`)),console.log(Q.green.dim(` ${i.description}`));console.log()}if(n.length>0){console.log(Q.bold.blue(`Updated ${n.length} system prompt file(s):`));for(const i of n)i.oldVersion?console.log(Q.blue(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)):console.log(Q.blue(` ${i.id}.md (→ ${i.newVersion})`));console.log()}if(r.length>0){console.log(Q.bold.yellow(`WARNING: Conflicts detected for ${r.length} system prompt file(s)`));for(const i of r)console.log(Q.yellow(` ${i.id}.md (${i.oldVersion} → ${i.newVersion})`)),console.log(Q.yellow(` Open the diff in your browser: ${i.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(Q.green.bold("New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.")),console.log(Q.green(`You can now customize the markdown files at ${Se} in a text editor.`)),console.log(Q.green('Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts')),console.log()),r.length>0){console.log(),console.log("Review conflicts:"),console.log(" 1. Open the diff HTML files in your browser"),console.log(" 2. Verify your customizations are still appropriate"),console.log(" 3. Update your markdown files if needed"),console.log(Q.bold.cyan(" 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:"));for(const i of r)console.log(Q.yellow(` ${i.id}.md → `)+Q.bold.magenta(i.newVersion));console.log(" 5. Delete the diff HTML files"),console.log()}},le=Buffer.from(`
177
177
  ---- Bun! ----
178
- `),Ie=32,Gt=8,Ye=4*Gt+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 r=ve(e,t.modulesPtr),o=Math.floor(r.length/Ye);for(let i=0;i<o;i++){const a=i*Ye,l=zt(r,a),u=ve(e,l.name).toString("utf-8"),c=n(l,u,i);if(c!==void 0)return c}}function Hn(e){let t=0;const n=e.readBigUInt64LE(t);t+=8;const r=Te(e,t);t+=8;const o=e.readUInt32LE(t);t+=4;const i=Te(e,t);return{byteCount:n,modulesPtr:r,entryPointId:o,compileExecArgvPtr:i}}function zt(e,t){let n=t;const r=Te(e,n);n+=8;const o=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 c=e.readUInt8(n);n+=1;const h=e.readUInt8(n);return{name:r,contents:o,sourcemap:i,bytecode:a,encoding:l,loader:u,moduleFormat:c,side:h}}function Yt(e){if(e.length<Ie+le.length)throw new Error("BUN data is too small to contain trailer and offsets");const t=e.length-le.length,n=e.subarray(t);if(T()&&(console.log(`parseBunDataBlob: Expected trailer: ${le.toString("hex")}`),console.log(`parseBunDataBlob: Got trailer: ${n.toString("hex")}`)),!n.equals(le))throw T()&&(console.log(`Expected: ${le.toString("hex")}`),console.log(`Got: ${n.toString("hex")}`)),new Error("BUN trailer bytes do not match trailer");const r=e.length-Ie-le.length,o=e.subarray(r,r+Ie);return{bunOffsets:Hn(o),bunData:e}}function Gn(e){if(e.length<4)throw new Error("Section data too small");T()&&console.log(`extractBunDataFromSection: sectionData.length=${e.length}`);const t=e.readUInt32LE(0);T()&&console.log(`extractBunDataFromSection: bunDataSize from header=${t}`);const n=e.subarray(4,4+t);T()&&console.log(`extractBunDataFromSection: bunDataContent.length=${n.length}`);const{bunOffsets:r,bunData:o}=Yt(n);return{bunOffsets:r,bunData:o}}function Wt(e){if(!e.hasOverlay)throw new Error("ELF binary has no overlay data");const t=e.overlay;if(T()&&console.log(`extractBunDataFromELFOverlay: Overlay size=${t.length} bytes`),t.length<le.length+8+Ie)throw new Error("ELF overlay data is too small");const n=t.readBigUInt64LE(t.length-8);if(T()&&console.log(`extractBunDataFromELFOverlay: Total byte count from tail=${n}`),n<4096n||n>2n**32n-1n)throw new Error(`ELF total byte count is out of range: ${n}`);const r=t.length-8-le.length,o=t.subarray(r,t.length-8);if(T()&&(console.log(`extractBunDataFromELFOverlay: Expected trailer: ${le.toString("hex")}`),console.log(`extractBunDataFromELFOverlay: Got trailer: ${o.toString("hex")}`)),!o.equals(le))throw new Error("BUN trailer bytes do not match trailer");const i=t.length-8-le.length-Ie,a=t.subarray(i,t.length-8-le.length),l=Hn(a);T()&&console.log(`extractBunDataFromELFOverlay: Offsets.byteCount=${l.byteCount}`);const u=typeof l.byteCount=="bigint"?l.byteCount:BigInt(l.byteCount);if(u>=n)throw new Error("ELF total byte count is out of range");const c=8+le.length+Ie,h=t.length-c-Number(u),f=t.subarray(h,t.length-c);T()&&console.log(`extractBunDataFromELFOverlay: Extracted ${f.length} bytes of data`);const v=Buffer.concat([f,a,o]);return{bunOffsets:l,bunData:v}}function Jt(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 qt(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(T()&&console.log(`getBunData: Binary format detected as ${e.format}`),e.format){case"MachO":return Jt(e);case"PE":return qt(e);case"ELF":return Wt(e);default:throw new Error(`Unsupported binary format: ${e.format}`)}}function Yn(e){try{Re.logging.disable();const t=Re.parse(e),{bunOffsets:n,bunData:r}=zn(t);T()&&console.log(`extractClaudeJsFromNativeInstallation: Got bunData, size=${r.length} bytes`);const o=Un(r,n,(i,a,l)=>{if(T()&&console.log(`extractClaudeJsFromNativeInstallation: Module ${l}: ${a}`),!jn(a))return;const u=ve(r,i.contents);return T()&&console.log(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${u.length}`),u.length>0?u:void 0});return o||(T()&&console.log("extractClaudeJsFromNativeInstallation: claude module not found in any module"),null)}catch(t){return T()&&console.log("extractClaudeJsFromNativeInstallation: Error during extraction:",t),null}}function Kt(e,t,n){const r=[],o=[];Un(e,t,(k,P)=>{const B=ve(e,k.name);let j;n&&jn(P)?j=n:j=ve(e,k.contents);const q=ve(e,k.sourcemap),U=ve(e,k.bytecode);o.push({name:B,contents:j,sourcemap:q,bytecode:U,encoding:k.encoding,loader:k.loader,moduleFormat:k.moduleFormat,side:k.side}),r.push(B,j,q,U)});let i=0;const a=[];for(const k of r)a.push({offset:i,length:k.length}),i+=k.length+1;const l=i,u=o.length*Ye;i+=u;const c=ve(e,t.compileExecArgvPtr),h=i,f=c.length;i+=f+1;const v=i;i+=Ie;const b=i;i+=le.length;const p=Buffer.allocUnsafe(i);p.fill(0);let w=0;for(const{offset:k,length:P}of a)P>0&&r[w].copy(p,k,0,P),p[k+P]=0,w++;f>0&&(c.copy(p,h,0,f),p[h+f]=0);for(let k=0;k<o.length;k++){const P=o[k],B=k*4,j={name:{offset:a[B].offset,length:a[B].length},contents:{offset:a[B+1].offset,length:a[B+1].length},sourcemap:{offset:a[B+2].offset,length:a[B+2].length},bytecode:{offset:a[B+3].offset,length:a[B+3].length},encoding:P.encoding,loader:P.loader,moduleFormat:P.moduleFormat,side:P.side};let U=l+k*Ye;p.writeUInt32LE(j.name.offset,U),p.writeUInt32LE(j.name.length,U+4),U+=8,p.writeUInt32LE(j.contents.offset,U),p.writeUInt32LE(j.contents.length,U+4),U+=8,p.writeUInt32LE(j.sourcemap.offset,U),p.writeUInt32LE(j.sourcemap.length,U+4),U+=8,p.writeUInt32LE(j.bytecode.offset,U),p.writeUInt32LE(j.bytecode.length,U+4),U+=8,p.writeUInt8(j.encoding,U),p.writeUInt8(j.loader,U+1),p.writeUInt8(j.moduleFormat,U+2),p.writeUInt8(j.side,U+3)}const x={byteCount:v,modulesPtr:{offset:l,length:u},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:h,length:f}};let C=v;const _=typeof x.byteCount=="bigint"?x.byteCount:BigInt(x.byteCount);return p.writeBigUInt64LE(_,C),C+=8,p.writeUInt32LE(x.modulesPtr.offset,C),p.writeUInt32LE(x.modulesPtr.length,C+4),C+=8,p.writeUInt32LE(x.entryPointId,C),C+=4,p.writeUInt32LE(x.compileExecArgvPtr.offset,C),p.writeUInt32LE(x.compileExecArgvPtr.length,C+4),le.copy(p,b),p}function sn(e,t,n,r=!0){const o=t+".tmp";if(e.write(o),r){const i=Pe.statSync(n);Pe.chmodSync(o,i.mode)}try{Pe.renameSync(o,t)}catch(i){try{Pe.existsSync(o)&&Pe.unlinkSync(o)}catch{}throw i instanceof Error&&"code"in i&&(i.code==="ETXTBSY"||i.code==="EBUSY"||i.code==="EPERM")?new Error(`Cannot update the Claude executable while it is running.
179
- Please close all Claude instances and try again.`):i}}function Wn(e){const t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function Xt(e,t,n,r){try{T()&&console.log(`repackMachO: Has code signature: ${e.hasCodeSignature}`),e.hasCodeSignature&&(T()&&console.log("repackMachO: Removing code signature..."),e.removeSignature());const o=e.getSegment("__BUN");if(!o)throw new Error("__BUN segment not found");const i=o.getSection("__bun");if(!i)throw new Error("__bun section not found");const a=Wn(n);T()&&(console.log(`repackMachO: Original section size: ${i.size}`),console.log(`repackMachO: Original segment fileSize: ${o.fileSize}`),console.log(`repackMachO: Original segment virtualSize: ${o.virtualSize}`),console.log(`repackMachO: New data size: ${a.length}`));const l=a.length-Number(i.size);if(l>0){const u=e.header.cpuType===Re.MachO.Header.CPU_TYPE.ARM64,c=u?16384:4096,h=Math.ceil(l/c)*c;T()&&(console.log(`repackMachO: CPU type: ${u?"ARM64":"x86_64"}`),console.log(`repackMachO: Page size: ${c} bytes`),console.log(`repackMachO: Need to expand by ${l} bytes`),console.log(`repackMachO: Rounding up to page-aligned: ${h} bytes`));const f=e.extendSegment(o,h);if(T()&&console.log(`repackMachO: extendSegment returned: ${f}`),!f)throw new Error("Failed to extend __BUN segment");T()&&(console.log(`repackMachO: Section size after extend: ${i.size}`),console.log(`repackMachO: Segment fileSize after extend: ${o.fileSize}`),console.log(`repackMachO: Segment virtualSize after extend: ${o.virtualSize}`))}i.content=a,i.size=BigInt(a.length),T()&&(console.log(`repackMachO: Final section size: ${i.size}`),console.log(`repackMachO: Writing modified binary to ${r}...`)),sn(e,r,t);try{T()&&console.log("repackMachO: Re-signing binary with ad-hoc signature..."),On(`codesign -s - -f "${r}"`,{stdio:T()?"inherit":"ignore"}),T()&&console.log("repackMachO: Code signing completed successfully")}catch(u){console.warn("Warning: Failed to re-sign binary. The binary may not run correctly on macOS:",u)}T()&&console.log("repackMachO: Write completed successfully")}catch(o){throw console.error("repackMachO failed:",o),o}}function Zt(e,t,n,r){try{const o=e.sections().find(a=>a.name===".bun");if(!o)throw new Error(".bun section not found");const i=Wn(n);T()&&(console.log(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),console.log(`repackPE: New data size: ${i.length}`)),o.content=i,o.virtualSize=BigInt(i.length),o.size=BigInt(i.length),T()&&console.log(`repackPE: Writing modified binary to ${r}...`),sn(e,r,t,!1),T()&&console.log("repackPE: Write completed successfully")}catch(o){throw console.error("repackPE failed:",o),o}}function Qt(e,t,n,r){try{const o=Buffer.allocUnsafe(n.length+8);n.copy(o,0),o.writeBigUInt64LE(BigInt(n.length),n.length),T()&&console.log(`repackELF: Setting overlay data (${o.length} bytes)`),e.overlay=o,T()&&console.log(`repackELF: Writing modified binary to ${r}...`),sn(e,r,t),T()&&console.log("repackELF: Write completed successfully")}catch(o){throw console.error("repackELF failed:",o),o}}function er(e,t,n){Re.logging.disable();const r=Re.parse(e),{bunOffsets:o,bunData:i}=zn(r),a=Kt(i,o,t);switch(r.format){case"MachO":Xt(r,e,a,n);break;case"PE":Zt(r,e,a,n);break;case"ELF":Qt(r,e,a,n);break;default:throw new Error(`Unsupported binary format: ${r.format}`)}}const ln=async()=>{await ie.mkdir(ce,{recursive:!0}),await ie.mkdir(Se,{recursive:!0});const e=Bn.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 De={settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null};const an=async()=>{const e={ccVersion:"",ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:Z};try{T()&&console.log(`Reading config at ${ae}`);const t=await ie.readFile(ae,"utf8"),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format="{}"+r.punctuation,delete r.punctuation),n.settings.inputBox||(n.settings.inputBox=Z.inputBox),n.settings.toolsets||(n.settings.toolsets=Z.toolsets),Object.hasOwn(n.settings,"defaultToolset")||(n.settings.defaultToolset=Z.defaultToolset);for(const i of Z.themes){const a=n?.settings?.themes.find(l=>l.id===i.id||l.name===i.name);if(a){for(const[l,u]of Object.entries(i))l!=="colors"&&!Object.hasOwn(a,l)&&(a[l]=u);a.colors||(a.colors={});for(const[l,u]of Object.entries(i.colors))Object.hasOwn(a.colors,l)||(a.colors[l]=u)}}for(const i of n?.settings?.themes||[]){if(Z.themes.some(u=>u.id===i.id||u.name===i.name))continue;const l=Z.themes[0];i.colors||(i.colors={});for(const[u,c]of Object.entries(l.colors))Object.hasOwn(i.colors,u)||(i.colors[u]=c)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||Z,n.settings.userMessageDisplay=Z.userMessageDisplay),delete n.settings.launchText,await Tt(Se)&&(n.changesApplied=!1),De=n,n}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return e;throw t}},je=async e=>(T()&&console.log(`Updating config at ${ae}`),e(De),De.lastModified=new Date().toISOString(),await nr(De),De),nr=async e=>{try{e.lastModified=new Date().toISOString(),await ln(),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 T()&&console.log("restoreClijsFromBackup: Skipping for native installation (no cliPath)"),!1;T()&&console.log(`Restoring cli.js from backup to ${e.cliPath}`);const t=await ie.readFile(Ne);return await fn(e.cliPath,t,"restore"),await kt(),await je(n=>{n.changesApplied=!1}),!0},qn=async e=>{if(!e.nativeInstallationPath)return T()&&console.log("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await Be(ge))return T()&&console.log("restoreNativeBinaryFromBackup: No backup file exists, skipping"),!1;T()&&console.log(`Restoring native binary from backup to ${e.nativeInstallationPath}`);const t=await ie.readFile(ge);return await fn(e.nativeInstallationPath,t,"restore"),!0};async function tr(){try{const t=process.platform==="win32"?"where claude.exe":"which claude";T()&&console.log(`Looking for claude executable using: ${t}`);const r=On(t,{encoding:"utf8"}).trim().split(`
180
- `)[0].trim();if(r&&await Be(r))try{const o=await ie.realpath(r);return T()&&(o!==r?(console.log(`Found claude executable at: ${r} (symlink)`),console.log(`Resolved to: ${o}`)):console.log(`Found claude executable at: ${r}`)),o}catch(o){return T()&&console.log("Could not resolve symlink, using original path:",o),r}}catch(e){T()&&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 r;for(;(r=t.exec(e))!==null;){const a=r[1];n.set(a,(n.get(a)||0)+1)}if(n.size===0)return null;let o=0,i;for(const[a,l]of n.entries())T()&&console.log(`Found version ${a} with ${l} occurrences`),l>o&&(o=l,i=a);return T()&&i&&console.log(`Extracted version ${i} (${o} occurrences)`),i||null}async function Be(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 rr(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 or=async e=>{e.ccInstallationDir&&xn.unshift(e.ccInstallationDir);for(const n of xn)try{T()&&console.log(`Searching for Claude Code cli.js file at ${n}`);const r=Bn.join(n,"cli.js");if(!await Be(r))continue;T()&&(console.log(`Found Claude Code cli.js file at ${n}; checking hash...`),console.log(`SHA256 hash: ${await Eo(r)}`));const o=await rr(r);return{cliPath:r,version:o}}catch(r){if(r instanceof Error&&"code"in r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))continue;throw r}T()&&console.log("Could not find cli.js in standard locations, trying native installation method...");const t=await tr();if(T()&&console.log(`findClaudeExecutableOnPath() returned: ${t}`),t){T()&&console.log(`Attempting to extract claude.js from native installation: ${t}`);const n=Yn(t);if(n){const r=n.toString("utf8"),o=Kn(r);return o?(T()&&console.log(`Extracted version ${o} from native installation`),{version:o,nativeInstallationPath:t}):(T()&&console.log("Failed to extract version from native installation"),null)}}return null},In=async e=>{if(!e.cliPath){T()&&console.log("backupClijs: Skipping for native installation (no cliPath)");return}await ln(),T()&&console.log(`Backing up cli.js to ${Ne}`),await ie.copyFile(e.cliPath,Ne),await je(t=>{t.changesApplied=!1,t.ccVersion=e.version})},Cn=async e=>{e.nativeInstallationPath&&(await ln(),T()&&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 an(),t=await or(e);if(!t)return null;if(t.version)try{const a=await Dt(t.version);Ht(a)}catch{}const n=t.version,r=e.ccVersion;let o=!1;await Be(Ne)||(T()&&console.log(`startupCheck: ${Ne} not found; backing up cli.js`),await In(t),o=!0);let i=!1;return t.nativeInstallationPath&&!await Be(ge)&&(T()&&console.log(`startupCheck: ${ge} not found; backing up native binary`),await Cn(t),i=!0),n!==r?(o||(T()&&console.log(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await ie.unlink(Ne),await In(t)),t.nativeInstallationPath&&!i&&(T()&&console.log(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await Be(ge)&&await ie.unlink(ge),await Cn(t)),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}}const ir=e=>{const t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g;let r;for(;(r=n.exec(e))!==null;){const o=r.index+r[0].indexOf("=")+1;t.push({startIndex:o,endIndex:o+r[1].length})}return t},sr=(e,t)=>{const n=ir(e);if(n.length===0)return console.error("patch: writeShowMoreItemsInSelectMenus: failed to find locations"),null;const r=n.sort((i,a)=>a.startIndex-i.startIndex);let o=e;for(const i of r){const a=t.toString(),l=o.slice(0,i.startIndex)+a+o.slice(i.endIndex);V(o,l,a,i.startIndex,i.endIndex),o=l}return o};function lr(e){const t=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,n=e.match(t);if(!n||n.index==null)return console.error("patch: themes: failed to find switchMatch"),null;const r=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,o=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(r),a=e.match(o);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 ar=(e,t)=>{const n=lr(e);if(!n)return null;if(t.length===0)return e;let r=e;const o="return"+JSON.stringify(Object.fromEntries(t.map(l=>[l.id,l.name])));r=r.slice(0,n.obj.startIndex)+o+r.slice(n.obj.endIndex),V(e,r,o,n.obj.startIndex,n.obj.endIndex),e=r;const i=JSON.stringify(t.map(l=>({label:l.name,value:l.id})));r=r.slice(0,n.objArr.startIndex)+i+r.slice(n.objArr.endIndex),V(e,r,i,n.objArr.startIndex,n.objArr.endIndex),e=r;let a=`switch(${n.switchStatement.identifiers?.[0]}){
178
+ `),Ie=32,Gt=8,Ye=4*Gt+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 r=ve(e,t.modulesPtr),o=Math.floor(r.length/Ye);for(let i=0;i<o;i++){const a=i*Ye,l=zt(r,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 r=Te(e,t);t+=8;const o=e.readUInt32LE(t);t+=4;const i=Te(e,t);return{byteCount:n,modulesPtr:r,entryPointId:o,compileExecArgvPtr:i}}function zt(e,t){let n=t;const r=Te(e,n);n+=8;const o=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:r,contents:o,sourcemap:i,bytecode:a,encoding:l,loader:u,moduleFormat:d,side:h}}function Yt(e){if(e.length<Ie+le.length)throw new Error("BUN data is too small to contain trailer and offsets");const t=e.length-le.length,n=e.subarray(t);if(T()&&(console.log(`parseBunDataBlob: Expected trailer: ${le.toString("hex")}`),console.log(`parseBunDataBlob: Got trailer: ${n.toString("hex")}`)),!n.equals(le))throw T()&&(console.log(`Expected: ${le.toString("hex")}`),console.log(`Got: ${n.toString("hex")}`)),new Error("BUN trailer bytes do not match trailer");const r=e.length-Ie-le.length,o=e.subarray(r,r+Ie);return{bunOffsets:Hn(o),bunData:e}}function Gn(e){if(e.length<4)throw new Error("Section data too small");T()&&console.log(`extractBunDataFromSection: sectionData.length=${e.length}`);const t=e.readUInt32LE(0);T()&&console.log(`extractBunDataFromSection: bunDataSize from header=${t}`);const n=e.subarray(4,4+t);T()&&console.log(`extractBunDataFromSection: bunDataContent.length=${n.length}`);const{bunOffsets:r,bunData:o}=Yt(n);return{bunOffsets:r,bunData:o}}function Wt(e){if(!e.hasOverlay)throw new Error("ELF binary has no overlay data");const t=e.overlay;if(T()&&console.log(`extractBunDataFromELFOverlay: Overlay size=${t.length} bytes`),t.length<le.length+8+Ie)throw new Error("ELF overlay data is too small");const n=t.readBigUInt64LE(t.length-8);if(T()&&console.log(`extractBunDataFromELFOverlay: Total byte count from tail=${n}`),n<4096n||n>2n**32n-1n)throw new Error(`ELF total byte count is out of range: ${n}`);const r=t.length-8-le.length,o=t.subarray(r,t.length-8);if(T()&&(console.log(`extractBunDataFromELFOverlay: Expected trailer: ${le.toString("hex")}`),console.log(`extractBunDataFromELFOverlay: Got trailer: ${o.toString("hex")}`)),!o.equals(le))throw new Error("BUN trailer bytes do not match trailer");const i=t.length-8-le.length-Ie,a=t.subarray(i,t.length-8-le.length),l=Hn(a);T()&&console.log(`extractBunDataFromELFOverlay: Offsets.byteCount=${l.byteCount}`);const u=typeof l.byteCount=="bigint"?l.byteCount:BigInt(l.byteCount);if(u>=n)throw new Error("ELF total byte count is out of range");const d=8+le.length+Ie,h=t.length-d-Number(u),f=t.subarray(h,t.length-d);T()&&console.log(`extractBunDataFromELFOverlay: Extracted ${f.length} bytes of data`);const v=Buffer.concat([f,a,o]);return{bunOffsets:l,bunData:v}}function Jt(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 qt(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(T()&&console.log(`getBunData: Binary format detected as ${e.format}`),e.format){case"MachO":return Jt(e);case"PE":return qt(e);case"ELF":return Wt(e);default:throw new Error(`Unsupported binary format: ${e.format}`)}}function Yn(e){try{Re.logging.disable();const t=Re.parse(e),{bunOffsets:n,bunData:r}=zn(t);T()&&console.log(`extractClaudeJsFromNativeInstallation: Got bunData, size=${r.length} bytes`);const o=Un(r,n,(i,a,l)=>{if(T()&&console.log(`extractClaudeJsFromNativeInstallation: Module ${l}: ${a}`),!jn(a))return;const u=ve(r,i.contents);return T()&&console.log(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${u.length}`),u.length>0?u:void 0});return o||(T()&&console.log("extractClaudeJsFromNativeInstallation: claude module not found in any module"),null)}catch(t){return T()&&console.log("extractClaudeJsFromNativeInstallation: Error during extraction:",t),null}}function Kt(e,t,n){const r=[],o=[];Un(e,t,(k,P)=>{const B=ve(e,k.name);let j;n&&jn(P)?j=n:j=ve(e,k.contents);const q=ve(e,k.sourcemap),U=ve(e,k.bytecode);o.push({name:B,contents:j,sourcemap:q,bytecode:U,encoding:k.encoding,loader:k.loader,moduleFormat:k.moduleFormat,side:k.side}),r.push(B,j,q,U)});let i=0;const a=[];for(const k of r)a.push({offset:i,length:k.length}),i+=k.length+1;const l=i,u=o.length*Ye;i+=u;const d=ve(e,t.compileExecArgvPtr),h=i,f=d.length;i+=f+1;const v=i;i+=Ie;const b=i;i+=le.length;const p=Buffer.allocUnsafe(i);p.fill(0);let w=0;for(const{offset:k,length:P}of a)P>0&&r[w].copy(p,k,0,P),p[k+P]=0,w++;f>0&&(d.copy(p,h,0,f),p[h+f]=0);for(let k=0;k<o.length;k++){const P=o[k],B=k*4,j={name:{offset:a[B].offset,length:a[B].length},contents:{offset:a[B+1].offset,length:a[B+1].length},sourcemap:{offset:a[B+2].offset,length:a[B+2].length},bytecode:{offset:a[B+3].offset,length:a[B+3].length},encoding:P.encoding,loader:P.loader,moduleFormat:P.moduleFormat,side:P.side};let U=l+k*Ye;p.writeUInt32LE(j.name.offset,U),p.writeUInt32LE(j.name.length,U+4),U+=8,p.writeUInt32LE(j.contents.offset,U),p.writeUInt32LE(j.contents.length,U+4),U+=8,p.writeUInt32LE(j.sourcemap.offset,U),p.writeUInt32LE(j.sourcemap.length,U+4),U+=8,p.writeUInt32LE(j.bytecode.offset,U),p.writeUInt32LE(j.bytecode.length,U+4),U+=8,p.writeUInt8(j.encoding,U),p.writeUInt8(j.loader,U+1),p.writeUInt8(j.moduleFormat,U+2),p.writeUInt8(j.side,U+3)}const x={byteCount:v,modulesPtr:{offset:l,length:u},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:h,length:f}};let C=v;const _=typeof x.byteCount=="bigint"?x.byteCount:BigInt(x.byteCount);return p.writeBigUInt64LE(_,C),C+=8,p.writeUInt32LE(x.modulesPtr.offset,C),p.writeUInt32LE(x.modulesPtr.length,C+4),C+=8,p.writeUInt32LE(x.entryPointId,C),C+=4,p.writeUInt32LE(x.compileExecArgvPtr.offset,C),p.writeUInt32LE(x.compileExecArgvPtr.length,C+4),le.copy(p,b),p}function sn(e,t,n,r=!0){const o=t+".tmp";if(e.write(o),r){const i=Pe.statSync(n);Pe.chmodSync(o,i.mode)}try{Pe.renameSync(o,t)}catch(i){try{Pe.existsSync(o)&&Pe.unlinkSync(o)}catch{}throw i instanceof Error&&"code"in i&&(i.code==="ETXTBSY"||i.code==="EBUSY"||i.code==="EPERM")?new Error(`Cannot update the Claude executable while it is running.
179
+ Please close all Claude instances and try again.`):i}}function Wn(e){const t=Buffer.allocUnsafe(4+e.length);return t.writeUInt32LE(e.length,0),e.copy(t,4),t}function Xt(e,t,n,r){try{T()&&console.log(`repackMachO: Has code signature: ${e.hasCodeSignature}`),e.hasCodeSignature&&(T()&&console.log("repackMachO: Removing code signature..."),e.removeSignature());const o=e.getSegment("__BUN");if(!o)throw new Error("__BUN segment not found");const i=o.getSection("__bun");if(!i)throw new Error("__bun section not found");const a=Wn(n);T()&&(console.log(`repackMachO: Original section size: ${i.size}`),console.log(`repackMachO: Original segment fileSize: ${o.fileSize}`),console.log(`repackMachO: Original segment virtualSize: ${o.virtualSize}`),console.log(`repackMachO: New data size: ${a.length}`));const l=a.length-Number(i.size);if(l>0){const u=e.header.cpuType===Re.MachO.Header.CPU_TYPE.ARM64,d=u?16384:4096,h=Math.ceil(l/d)*d;T()&&(console.log(`repackMachO: CPU type: ${u?"ARM64":"x86_64"}`),console.log(`repackMachO: Page size: ${d} bytes`),console.log(`repackMachO: Need to expand by ${l} bytes`),console.log(`repackMachO: Rounding up to page-aligned: ${h} bytes`));const f=e.extendSegment(o,h);if(T()&&console.log(`repackMachO: extendSegment returned: ${f}`),!f)throw new Error("Failed to extend __BUN segment");T()&&(console.log(`repackMachO: Section size after extend: ${i.size}`),console.log(`repackMachO: Segment fileSize after extend: ${o.fileSize}`),console.log(`repackMachO: Segment virtualSize after extend: ${o.virtualSize}`))}i.content=a,i.size=BigInt(a.length),T()&&(console.log(`repackMachO: Final section size: ${i.size}`),console.log(`repackMachO: Writing modified binary to ${r}...`)),sn(e,r,t);try{T()&&console.log("repackMachO: Re-signing binary with ad-hoc signature..."),On(`codesign -s - -f "${r}"`,{stdio:T()?"inherit":"ignore"}),T()&&console.log("repackMachO: Code signing completed successfully")}catch(u){console.warn("Warning: Failed to re-sign binary. The binary may not run correctly on macOS:",u)}T()&&console.log("repackMachO: Write completed successfully")}catch(o){throw console.error("repackMachO failed:",o),o}}function Zt(e,t,n,r){try{const o=e.sections().find(a=>a.name===".bun");if(!o)throw new Error(".bun section not found");const i=Wn(n);T()&&(console.log(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),console.log(`repackPE: New data size: ${i.length}`)),o.content=i,o.virtualSize=BigInt(i.length),o.size=BigInt(i.length),T()&&console.log(`repackPE: Writing modified binary to ${r}...`),sn(e,r,t,!1),T()&&console.log("repackPE: Write completed successfully")}catch(o){throw console.error("repackPE failed:",o),o}}function Qt(e,t,n,r){try{const o=Buffer.allocUnsafe(n.length+8);n.copy(o,0),o.writeBigUInt64LE(BigInt(n.length),n.length),T()&&console.log(`repackELF: Setting overlay data (${o.length} bytes)`),e.overlay=o,T()&&console.log(`repackELF: Writing modified binary to ${r}...`),sn(e,r,t),T()&&console.log("repackELF: Write completed successfully")}catch(o){throw console.error("repackELF failed:",o),o}}function er(e,t,n){Re.logging.disable();const r=Re.parse(e),{bunOffsets:o,bunData:i}=zn(r),a=Kt(i,o,t);switch(r.format){case"MachO":Xt(r,e,a,n);break;case"PE":Zt(r,e,a,n);break;case"ELF":Qt(r,e,a,n);break;default:throw new Error(`Unsupported binary format: ${r.format}`)}}const ln=async()=>{await ie.mkdir(ce,{recursive:!0}),await ie.mkdir(Se,{recursive:!0});const e=Bn.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 Le={settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null};const an=async()=>{const e={ccVersion:"",ccInstallationDir:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:Z};try{T()&&console.log(`Reading config at ${ae}`);const t=await ie.readFile(ae,"utf8"),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format="{}"+r.punctuation,delete r.punctuation),n.settings.inputBox||(n.settings.inputBox=Z.inputBox),n.settings.toolsets||(n.settings.toolsets=Z.toolsets),Object.hasOwn(n.settings,"defaultToolset")||(n.settings.defaultToolset=Z.defaultToolset);for(const i of Z.themes){const a=n?.settings?.themes.find(l=>l.id===i.id||l.name===i.name);if(a){for(const[l,u]of Object.entries(i))l!=="colors"&&!Object.hasOwn(a,l)&&(a[l]=u);a.colors||(a.colors={});for(const[l,u]of Object.entries(i.colors))Object.hasOwn(a.colors,l)||(a.colors[l]=u)}}for(const i of n?.settings?.themes||[]){if(Z.themes.some(u=>u.id===i.id||u.name===i.name))continue;const l=Z.themes[0];i.colors||(i.colors={});for(const[u,d]of Object.entries(l.colors))Object.hasOwn(i.colors,u)||(i.colors[u]=d)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||Z,n.settings.userMessageDisplay=Z.userMessageDisplay),delete n.settings.launchText,await Tt(Se)&&(n.changesApplied=!1),Le=n,n}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return e;throw t}},je=async e=>(T()&&console.log(`Updating config at ${ae}`),e(Le),Le.lastModified=new Date().toISOString(),await nr(Le),Le),nr=async e=>{try{e.lastModified=new Date().toISOString(),await ln(),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 T()&&console.log("restoreClijsFromBackup: Skipping for native installation (no cliPath)"),!1;T()&&console.log(`Restoring cli.js from backup to ${e.cliPath}`);const t=await ie.readFile(Ne);return await fn(e.cliPath,t,"restore"),await kt(),await je(n=>{n.changesApplied=!1}),!0},qn=async e=>{if(!e.nativeInstallationPath)return T()&&console.log("restoreNativeBinaryFromBackup: No native installation path, skipping"),!1;if(!await Be(ge))return T()&&console.log("restoreNativeBinaryFromBackup: No backup file exists, skipping"),!1;T()&&console.log(`Restoring native binary from backup to ${e.nativeInstallationPath}`);const t=await ie.readFile(ge);return await fn(e.nativeInstallationPath,t,"restore"),!0};async function tr(){try{const t=process.platform==="win32"?"where claude.exe":"which claude";T()&&console.log(`Looking for claude executable using: ${t}`);const r=On(t,{encoding:"utf8"}).trim().split(`
180
+ `)[0].trim();if(r&&await Be(r))try{const o=await ie.realpath(r);return T()&&(o!==r?(console.log(`Found claude executable at: ${r} (symlink)`),console.log(`Resolved to: ${o}`)):console.log(`Found claude executable at: ${r}`)),o}catch(o){return T()&&console.log("Could not resolve symlink, using original path:",o),r}}catch(e){T()&&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 r;for(;(r=t.exec(e))!==null;){const a=r[1];n.set(a,(n.get(a)||0)+1)}if(n.size===0)return null;let o=0,i;for(const[a,l]of n.entries())T()&&console.log(`Found version ${a} with ${l} occurrences`),l>o&&(o=l,i=a);return T()&&i&&console.log(`Extracted version ${i} (${o} occurrences)`),i||null}async function Be(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 rr(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 or=async e=>{e.ccInstallationDir&&xn.unshift(e.ccInstallationDir);for(const n of xn)try{T()&&console.log(`Searching for Claude Code cli.js file at ${n}`);const r=Bn.join(n,"cli.js");if(!await Be(r))continue;T()&&(console.log(`Found Claude Code cli.js file at ${n}; checking hash...`),console.log(`SHA256 hash: ${await Io(r)}`));const o=await rr(r);return{cliPath:r,version:o}}catch(r){if(r instanceof Error&&"code"in r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))continue;throw r}T()&&console.log("Could not find cli.js in standard locations, trying native installation method...");const t=await tr();if(T()&&console.log(`findClaudeExecutableOnPath() returned: ${t}`),t){T()&&console.log(`Attempting to extract claude.js from native installation: ${t}`);const n=Yn(t);if(n){const r=n.toString("utf8"),o=Kn(r);return o?(T()&&console.log(`Extracted version ${o} from native installation`),{version:o,nativeInstallationPath:t}):(T()&&console.log("Failed to extract version from native installation"),null)}}return null},In=async e=>{if(!e.cliPath){T()&&console.log("backupClijs: Skipping for native installation (no cliPath)");return}await ln(),T()&&console.log(`Backing up cli.js to ${Ne}`),await ie.copyFile(e.cliPath,Ne),await je(t=>{t.changesApplied=!1,t.ccVersion=e.version})},Cn=async e=>{e.nativeInstallationPath&&(await ln(),T()&&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 an(),t=await or(e);if(!t)return null;if(t.version)try{const a=await Lt(t.version);Ht(a)}catch{}const n=t.version,r=e.ccVersion;let o=!1;await Be(Ne)||(T()&&console.log(`startupCheck: ${Ne} not found; backing up cli.js`),await In(t),o=!0);let i=!1;return t.nativeInstallationPath&&!await Be(ge)&&(T()&&console.log(`startupCheck: ${ge} not found; backing up native binary`),await Cn(t),i=!0),n!==r?(o||(T()&&console.log(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await ie.unlink(Ne),await In(t)),t.nativeInstallationPath&&!i&&(T()&&console.log(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await Be(ge)&&await ie.unlink(ge),await Cn(t)),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t}):{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}}const ir=e=>{const t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g;let r;for(;(r=n.exec(e))!==null;){const o=r.index+r[0].indexOf("=")+1;t.push({startIndex:o,endIndex:o+r[1].length})}return t},sr=(e,t)=>{const n=ir(e);if(n.length===0)return console.error("patch: writeShowMoreItemsInSelectMenus: failed to find locations"),null;const r=n.sort((i,a)=>a.startIndex-i.startIndex);let o=e;for(const i of r){const a=t.toString(),l=o.slice(0,i.startIndex)+a+o.slice(i.endIndex);V(o,l,a,i.startIndex,i.endIndex),o=l}return o};function lr(e){const t=/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s,n=e.match(t);if(!n||n.index==null)return console.error("patch: themes: failed to find switchMatch"),null;const r=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,o=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(r),a=e.match(o);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 ar=(e,t)=>{const n=lr(e);if(!n)return null;if(t.length===0)return e;let r=e;const o="return"+JSON.stringify(Object.fromEntries(t.map(l=>[l.id,l.name])));r=r.slice(0,n.obj.startIndex)+o+r.slice(n.obj.endIndex),V(e,r,o,n.obj.startIndex,n.obj.endIndex),e=r;const i=JSON.stringify(t.map(l=>({label:l.name,value:l.id})));r=r.slice(0,n.objArr.startIndex)+i+r.slice(n.objArr.endIndex),V(e,r,i,n.objArr.startIndex,n.objArr.endIndex),e=r;let a=`switch(${n.switchStatement.identifiers?.[0]}){
181
181
  `;return t.forEach(l=>{a+=`case"${l.id}":return${JSON.stringify(l.colors)};
182
182
  `}),a+=`default:return${JSON.stringify(t[0].colors)};
183
- }`,r=r.slice(0,n.switchStatement.startIndex)+a+r.slice(n.switchStatement.endIndex),V(e,r,a,n.switchStatement.startIndex,n.switchStatement.endIndex),r},cr=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},dr=e=>{const t=cr(e);if(!t)return null;const n="if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);",r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},ur=e=>{const t=e.indexOf('bash:"bashBorder"');if(t===-1)return console.error("patch: input border: failed to find bash pattern"),null;const n=e.slice(t,t+500),r=/borderStyle:"[^"]*"/,o=n.match(r);return!o||o.index===void 0?(console.error("patch: input border: failed to find border style pattern"),null):{startIndex:t+o.index,endIndex:t+o.index+o[0].length}},hr=(e,t)=>{const n=ur(e);if(!n)return null;if(t){const r="borderColor:undefined",o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,o,r,n.startIndex,n.endIndex),o}else return e},gr=e=>{const t=/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: spinner no-freeze: failed to find wholeMatch"),null;const r=/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/,o=n[0].match(r);if(!o||o.index===void 0)return console.error("patch: spinner no-freeze: failed to find freeze condition"),null;const i=n.index+o.index,a=i+o[0].length;return{startIndex:i,endIndex:a}},fr=e=>{const t=gr(e);if(!t)return null;const n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return V(e,n,"",t.startIndex,t.endIndex),n},mr=e=>{const t=/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker format: failed to find approxAreaMatch"),null;const r=e.slice(n.index,n.index+600),o=/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/,i=r.match(o);return!i||i.index==null?(console.error("patch: thinker format: failed to find formatMatch"),null):{startIndex:n.index+i.index+i[1].length,endIndex:n.index+i.index+i[1].length+i[2].length,identifiers:[i[3]]}},pr=(e,t)=>{const n=mr(e);if(!n)return null;const r=n,o=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),i=r.identifiers?.[0],l=`=${"`"+o.replace(/\{\}/g,"${"+i+"}")+"`"}`,u=e.slice(0,r.startIndex)+l+e.slice(r.endIndex);return V(e,u,l,r.startIndex,r.endIndex),u},br=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]]}},wr=(e,t)=>{const n=br(e);if(!n)return null;const r=n.identifiers?.[0],o=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,i=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return V(e,i,o,n.startIndex,n.endIndex),i},xr=e=>{const t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g;let r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},yr=(e,t)=>{const n=xr(e);if(n.length===0)return null;const r=JSON.stringify(t),o=n.sort((a,l)=>l.startIndex-a.startIndex);let i=e;for(let a=0;a<o.length;a++){const l=i.slice(0,o[a].startIndex)+r+i.slice(o[a].endIndex);V(i,l,r,o[a].startIndex,o[a].endIndex),i=l}return i},Sr=e=>{const t=/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker symbol speed: failed to find match"),null;const r=n[0],o=n[1],i=r.lastIndexOf(o),a=n.index+i,l=a+o.length;return{startIndex:a,endIndex:l}},vr=(e,t)=>{const n=Sr(e);if(!n)return null;const r=JSON.stringify(t),o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,o,r,n.startIndex,n.endIndex),o},$r=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}},_r=(e,t)=>{const n=$r(e);if(!n)return null;const r=`{flexWrap:"wrap",height:1,width:${t}}`,o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,o,r,n.startIndex,n.endIndex),o},Ir=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]]}},Cr=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]]}},Er=(e,t)=>{const n=Ir(e);if(!n)return null;const r=n,o=r.identifiers?.[0],i=`${o}=${JSON.stringify({words:t})}`,a=e.slice(0,r.startIndex)+i+e.slice(r.endIndex);V(e,a,i,r.startIndex,r.endIndex);const l=Cr(a);if(!l)return null;const u=l,h=`function ${u.identifiers?.[0]}(){return ${o}.words}`,f=a.slice(0,u.startIndex)+h+a.slice(u.endIndex);return V(a,f,h,u.startIndex,u.endIndex),f},kr=e=>{const t=e.indexOf("No content found in user prompt message")-700;if(t===-1)return console.error("patch: userMessageDisplay: failed to find error message"),null;const n=Math.min(e.length,t+700),r=e.slice(t,n),o=/("> "),([$\w]+)/,i=r.match(o);if(!i)return{prefixLocation:null,messageLocation:null};const a=t+r.indexOf(i[1]),l=a+i[1].length,u=l+1,c=u+i[2].length;return{prefixLocation:{startIndex:a,endIndex:l},messageLocation:{startIndex:u,endIndex:c}}},Tr=(e,t,n,r,o=!1,i=!1,a=!1,l=!1,u=!1,c,h,f=!1,v=!1,b=!1,p=!1,w=!1)=>{const x=kr(e);if(!x)return console.error("patch: userMessageDisplay: getUserMessageDisplayLocation returned null"),null;if(!x.prefixLocation)return console.error("patch: userMessageDisplay: failed to find prefix location"),null;if(!x.messageLocation)return console.error("patch: userMessageDisplay: failed to find message location"),null;const C=dn(e);if(!C)return console.error("patch: userMessageDisplay: failed to find chalk variable"),null;const _=[],k=n==="rgb(0,0,0)"&&r==="rgb(0,0,0)",B=!k||(o||i||a||l||u),j=c==="rgb(0,0,0)"&&h==="rgb(0,0,0)",U=!j||(f||v||b||p||w);if(B){const M=Tn(C,k?null:n.match(/\d+/g)?.join(",")||null,k?null:r.match(/\d+/g)?.join(",")||null,o,i,a,l,u);_.push({startIndex:x.prefixLocation.startIndex,endIndex:x.prefixLocation.endIndex,newContent:`${M}("${t}")+" "`})}if(U){const M=Tn(C,j?null:c.match(/\d+/g)?.join(",")||null,j?null:h.match(/\d+/g)?.join(",")||null,f,v,b,p,w);_.push({startIndex:x.messageLocation.startIndex,endIndex:x.messageLocation.endIndex,newContent:e.slice(x.messageLocation.startIndex,x.messageLocation.endIndex).replace(/([$\w]+)/,`${M}($1)`)})}_.sort((M,E)=>E.startIndex-M.startIndex);let A=e;for(const M of _){const E=A;A=A.slice(0,M.startIndex)+M.newContent+A.slice(M.endIndex),V(E,A,M.newContent,M.startIndex,M.endIndex)}return A},Mr=e=>{const t=/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: verbose: failed to find createElement with spinnerTip and overrideMessage"),null;const r=n[0],o=/verbose:[^,}]+/,i=r.match(o);if(!i||i.index===void 0)return console.error("patch: verbose: failed to find verbose property"),null;const a=n.index+i.index,l=a+i[0].length;return{startIndex:a,endIndex:l}},Nr=e=>{const t=Mr(e);if(!t)return null;const n="verbose:true",r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},Br=e=>{const n=e.indexOf("subscription, no need to monitor cost");if(n===-1)return console.error("patch: ignoreMaxSubscription: phrase not found"),null;const r=Math.max(0,n-60),o=n,i=e.slice(r,o),a=/if\(([$\w]+)\(\)\)/g;let l=null;for(const h of i.matchAll(a))l=h;if(!l||l.index===void 0)return console.error("patch: ignoreMaxSubscription: could not match if(<id>()) nearby"),null;const u=r+l.index,c=u+l[0].length;return{startIndex:u,endIndex:c}},Or=e=>{const t=Br(e);if(!t)return null;const n="if(!1)",r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},Ar=e=>{const t=/function ([$\w]+)\(\{\s*streamMode:\s*([$\w]+)\s*\}\)\s*\{/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find banner function pattern"),null;const[r]=n,o=n.index,i=o+r.length;return{startIndex:o,endIndex:i,identifiers:[n[1],n[2]]}},Pr=e=>{const t=/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find thinking visibility pattern"),null;const r=n.index,o=r+n[0].length;return{startIndex:r,endIndex:o,identifiers:[n[1],n[2],n[3]]}},Lr=e=>{const t=Ar(e);if(!t)return null;const n="return null;";let r=e.slice(0,t.endIndex)+n+e.slice(t.endIndex);V(e,r,n,t.endIndex,t.endIndex);const o=Pr(r);if(!o)return null;const i=`${o.identifiers[0]}${o.identifiers[1]}true${o.identifiers[2]}`;return r=r.slice(0,o.startIndex)+i+r.slice(o.endIndex),V(e,r,i,o.startIndex,o.endIndex),r},Dr=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}},Rr=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern"),null;const r=n.index+n[0].length;return{startIndex:r,endIndex:r}},Fr=(e,t,n,r,o,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 c=Math.max(0,l.index-200),h=u.slice(c,l.index+12+2),f=/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g,v=Array.from(h.matchAll(f));if(v.length===0)return console.error("patch: patchesAppliedIndication: failed to find createElement for PATCH 4"),null;const b=v[v.length-1],p=c+b.index+b[0].length,w=`${n}.createElement(${o}, null, ${i}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,x=u;u=u.slice(0,p)+w+u.slice(p),V(x,u,w,p,p);let C=1,_=p+w.length,k=-1;for(;_<u.length;){const B=u[_];if(B==="(")C++;else if(B===")"){if(C===1){k=_;break}C--}_++}if(k===-1)return console.error("patch: patchesAppliedIndication: failed to find closing paren for PATCH 4"),null;const P=u;return u=u.slice(0,k)+"),"+u.slice(k),V(P,u,"),",k,k),{content:u,closingParenIndex:k+2}},Vr=(e,t,n,r,o,i,a)=>{let l=4,u=t,c=-1;for(;u<e.length;){const p=e[u];if(p==="(")l++;else if(p===")"){if(l===1){c=u;break}l--}u++}if(c===-1)return console.error("patch: patchesAppliedIndication: failed to find insertion point for PATCH 5"),null;const h=[];h.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),h.push(`${n}.createElement(${r}, null, ${n}.createElement(${o}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${o}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let p of a)p=p.replace("CHALK_VAR",i),h.push(`${n}.createElement(${r}, null, ${n}.createElement(${o}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${o}, {dimColor: true}, \` * ${p}\`)),`);h.push("),");const f=h.join(""),v=e,b=e.slice(0,c)+f+e.slice(c);return V(v,b,f,c,c),b},jr=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3"),null;const r=Math.max(0,n.index-500),o=e.slice(r,n.index),i=/\}function ([$\w]+)\(/g,a=Array.from(o.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],c=new RegExp(`\\b([$\\w]+)\\.createElement\\(${fe(u)},null\\),?`),h=e.match(c);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}},Ur=(e,t,n,r=!0,o=!0)=>{const i=Dr(e);if(!i)return console.error("patch: patchesAppliedIndication: failed to version output location"),null;const a=`\\n${t} (tweakcc)`;let l=e.slice(0,i.endIndex)+a+e.slice(i.endIndex);V(e,l,a,i.endIndex,i.endIndex);const u=dn(e);if(!u)return console.error("patch: patchesAppliedIndication: failed to find chalk variable"),null;const c=nt(e);if(!c)return console.error("patch: patchesAppliedIndication: failed to find text component"),null;const h=Je(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(r){const b=Rr(l);if(!b)return console.error("patch: patchesAppliedIndication: patch 2 failed"),null;const p=`, " ",${h}.createElement(${c}, null, ${u}.blue.bold('+ tweakcc v${t}'))`,w=l;l=l.slice(0,b.startIndex)+p+l.slice(b.endIndex),V(w,l,p,b.startIndex,b.endIndex)}if(o){const b=jr(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(${c}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${c}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let C of n)C=C.replace("CHALK_VAR",u),p.push(`${h}.createElement(${f}, null, ${h}.createElement(${c}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${c}, {dimColor: true}, \` * ${C}\`)),`);p.push("),");const w=p.join(`
184
- `),x=l;l=l.slice(0,b.startIndex)+w+l.slice(b.endIndex),V(x,l,w,b.startIndex,b.endIndex)}let v=-1;if(r){const b=Fr(l,t,h,f,c,u);if(!b)return console.error("patch: patchesAppliedIndication: patch 4 failed"),null;l=b.content,v=b.closingParenIndex}if(o){if(v===-1){const p=/alignItems:"center",minHeight:9,?/,w=l.match(p);if(!w||w.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find reference point for PATCH 5"),null;v=w.index+w[0].length}const b=Vr(l,v,h,f,c,u,n);if(!b)return console.error("patch: patchesAppliedIndication: patch 5 failed"),null;l=b}return l},Hr=e=>/\\u[0-9a-fA-F]{4}/.test(e),Gr=e=>{const t=e.toString(),n=JSON.stringify(t.substring(1,t.length-1)),r=JSON.stringify(t.match(/\/(\w*)$/)[1]);return`new RegExp(${n}, ${r})`},zr=async(e,t,n)=>{const r=n??Hr(e);T()&&r&&console.log("Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts");const o=await Ut(t,r);T()&&console.log(`Loaded ${o.length} system prompts with regexes`);let i=0,a=0;for(const{promptId:c,prompt:h,regex:f,getInterpolatedContent:v,pieces:b,identifiers:p,identifierMap:w}of o){const x=new RegExp(f,"si"),C=e.match(x);if(C&&C.index!==void 0){const _=v(C),k=Fe(b,p,w).trim(),P=k.length,B=h.content.length;i+=P,a+=B,T()&&P!==B&&(console.log(`
183
+ }`,r=r.slice(0,n.switchStatement.startIndex)+a+r.slice(n.switchStatement.endIndex),V(e,r,a,n.switchStatement.startIndex,n.switchStatement.endIndex),r},cr=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},dr=e=>{const t=cr(e);if(!t)return null;const n="if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);",r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},ur=e=>{const t=e.indexOf('bash:"bashBorder"');if(t===-1)return console.error("patch: input border: failed to find bash pattern"),null;const n=e.slice(t,t+500),r=/borderStyle:"[^"]*"/,o=n.match(r);return!o||o.index===void 0?(console.error("patch: input border: failed to find border style pattern"),null):{startIndex:t+o.index,endIndex:t+o.index+o[0].length}},hr=(e,t)=>{const n=ur(e);if(!n)return null;if(t){const r="borderColor:undefined",o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,o,r,n.startIndex,n.endIndex),o}else return e},gr=e=>{const t=/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: spinner no-freeze: failed to find wholeMatch"),null;const r=/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/,o=n[0].match(r);if(!o||o.index===void 0)return console.error("patch: spinner no-freeze: failed to find freeze condition"),null;const i=n.index+o.index,a=i+o[0].length;return{startIndex:i,endIndex:a}},fr=e=>{const t=gr(e);if(!t)return null;const n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return V(e,n,"",t.startIndex,t.endIndex),n},mr=e=>{const t=/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker format: failed to find approxAreaMatch"),null;const r=e.slice(n.index,n.index+600),o=/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/,i=r.match(o);return!i||i.index==null?(console.error("patch: thinker format: failed to find formatMatch"),null):{startIndex:n.index+i.index+i[1].length,endIndex:n.index+i.index+i[1].length+i[2].length,identifiers:[i[3]]}},pr=(e,t)=>{const n=mr(e);if(!n)return null;const r=n,o=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),i=r.identifiers?.[0],l=`=${"`"+o.replace(/\{\}/g,"${"+i+"}")+"`"}`,u=e.slice(0,r.startIndex)+l+e.slice(r.endIndex);return V(e,u,l,r.startIndex,r.endIndex),u},br=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]]}},wr=(e,t)=>{const n=br(e);if(!n)return null;const r=n.identifiers?.[0],o=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,i=e.slice(0,n.startIndex)+o+e.slice(n.endIndex);return V(e,i,o,n.startIndex,n.endIndex),i},xr=e=>{const t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g;let r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},yr=(e,t)=>{const n=xr(e);if(n.length===0)return null;const r=JSON.stringify(t),o=n.sort((a,l)=>l.startIndex-a.startIndex);let i=e;for(let a=0;a<o.length;a++){const l=i.slice(0,o[a].startIndex)+r+i.slice(o[a].endIndex);V(i,l,r,o[a].startIndex,o[a].endIndex),i=l}return i},Sr=e=>{const t=/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/,n=e.match(t);if(!n||n.index==null)return console.error("patch: thinker symbol speed: failed to find match"),null;const r=n[0],o=n[1],i=r.lastIndexOf(o),a=n.index+i,l=a+o.length;return{startIndex:a,endIndex:l}},vr=(e,t)=>{const n=Sr(e);if(!n)return null;const r=JSON.stringify(t),o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,o,r,n.startIndex,n.endIndex),o},$r=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}},_r=(e,t)=>{const n=$r(e);if(!n)return null;const r=`{flexWrap:"wrap",height:1,width:${t}}`,o=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,o,r,n.startIndex,n.endIndex),o},Ir=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]]}},Cr=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]]}},Er=(e,t)=>{const n=Ir(e);if(!n)return null;const r=n,o=r.identifiers?.[0],i=`${o}=${JSON.stringify({words:t})}`,a=e.slice(0,r.startIndex)+i+e.slice(r.endIndex);V(e,a,i,r.startIndex,r.endIndex);const l=Cr(a);if(!l)return null;const u=l,h=`function ${u.identifiers?.[0]}(){return ${o}.words}`,f=a.slice(0,u.startIndex)+h+a.slice(u.endIndex);return V(a,f,h,u.startIndex,u.endIndex),f},kr=e=>{const t=e.indexOf("No content found in user prompt message")-700;if(t===-1)return console.error("patch: userMessageDisplay: failed to find error message"),null;const n=Math.min(e.length,t+700),r=e.slice(t,n),o=/("> "),([$\w]+)/,i=r.match(o);if(!i)return{prefixLocation:null,messageLocation:null};const a=t+r.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}}},Tr=(e,t,n,r,o=!1,i=!1,a=!1,l=!1,u=!1,d,h,f=!1,v=!1,b=!1,p=!1,w=!1)=>{const x=kr(e);if(!x)return console.error("patch: userMessageDisplay: getUserMessageDisplayLocation returned null"),null;if(!x.prefixLocation)return console.error("patch: userMessageDisplay: failed to find prefix location"),null;if(!x.messageLocation)return console.error("patch: userMessageDisplay: failed to find message location"),null;const C=dn(e);if(!C)return console.error("patch: userMessageDisplay: failed to find chalk variable"),null;const _=[],k=n==="rgb(0,0,0)"&&r==="rgb(0,0,0)",B=!k||(o||i||a||l||u),j=d==="rgb(0,0,0)"&&h==="rgb(0,0,0)",U=!j||(f||v||b||p||w);if(B){const M=Tn(C,k?null:n.match(/\d+/g)?.join(",")||null,k?null:r.match(/\d+/g)?.join(",")||null,o,i,a,l,u);_.push({startIndex:x.prefixLocation.startIndex,endIndex:x.prefixLocation.endIndex,newContent:`${M}("${t}")+" "`})}if(U){const M=Tn(C,j?null:d.match(/\d+/g)?.join(",")||null,j?null:h.match(/\d+/g)?.join(",")||null,f,v,b,p,w);_.push({startIndex:x.messageLocation.startIndex,endIndex:x.messageLocation.endIndex,newContent:e.slice(x.messageLocation.startIndex,x.messageLocation.endIndex).replace(/([$\w]+)/,`${M}($1)`)})}_.sort((M,E)=>E.startIndex-M.startIndex);let A=e;for(const M of _){const E=A;A=A.slice(0,M.startIndex)+M.newContent+A.slice(M.endIndex),V(E,A,M.newContent,M.startIndex,M.endIndex)}return A},Mr=e=>{const t=/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: verbose: failed to find createElement with spinnerTip and overrideMessage"),null;const r=n[0],o=/verbose:[^,}]+/,i=r.match(o);if(!i||i.index===void 0)return console.error("patch: verbose: failed to find verbose property"),null;const a=n.index+i.index,l=a+i[0].length;return{startIndex:a,endIndex:l}},Nr=e=>{const t=Mr(e);if(!t)return null;const n="verbose:true",r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},Br=e=>{const t=/function ([$\w]+)\(\{\s*streamMode:\s*([$\w]+)\s*\}\)\s*\{/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find banner function pattern"),null;const[r]=n,o=n.index,i=o+r.length;return{startIndex:o,endIndex:i,identifiers:[n[1],n[2]]}},Or=e=>{const t=/(case"thinking":)if\(.+?\)return null;(.+?isTranscriptMode:).+?([},])/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: thinkingVisibility: failed to find thinking visibility pattern"),null;const r=n.index,o=r+n[0].length;return{startIndex:r,endIndex:o,identifiers:[n[1],n[2],n[3]]}},Ar=e=>{const t=Br(e);if(!t)return null;const n="return null;";let r=e.slice(0,t.endIndex)+n+e.slice(t.endIndex);V(e,r,n,t.endIndex,t.endIndex);const o=Or(r);if(!o)return null;const i=`${o.identifiers[0]}${o.identifiers[1]}true${o.identifiers[2]}`;return r=r.slice(0,o.startIndex)+i+r.slice(o.endIndex),V(e,r,i,o.startIndex,o.endIndex),r},Pr=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}},Dr=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern"),null;const r=n.index+n[0].length;return{startIndex:r,endIndex:r}},Lr=(e,t,n,r,o,i)=>{const a=/alignItems:"center",minHeight:9,?/,l=e.match(a);if(!l||l.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4"),null;let u=e.slice(0,l.index)+"minHeight:9,"+e.slice(l.index+l[0].length);const d=Math.max(0,l.index-200),h=u.slice(d,l.index+12+2),f=/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g,v=Array.from(h.matchAll(f));if(v.length===0)return console.error("patch: patchesAppliedIndication: failed to find createElement for PATCH 4"),null;const b=v[v.length-1],p=d+b.index+b[0].length,w=`${n}.createElement(${o}, null, ${i}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,x=u;u=u.slice(0,p)+w+u.slice(p),V(x,u,w,p,p);let C=1,_=p+w.length,k=-1;for(;_<u.length;){const B=u[_];if(B==="(")C++;else if(B===")"){if(C===1){k=_;break}C--}_++}if(k===-1)return console.error("patch: patchesAppliedIndication: failed to find closing paren for PATCH 4"),null;const P=u;return u=u.slice(0,k)+"),"+u.slice(k),V(P,u,"),",k,k),{content:u,closingParenIndex:k+2}},Rr=(e,t,n,r,o,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(${r}, { flexDirection: "column" },`),h.push(`${n}.createElement(${r}, null, ${n}.createElement(${o}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${o}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let p of a)p=p.replace("CHALK_VAR",i),h.push(`${n}.createElement(${r}, null, ${n}.createElement(${o}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${o}, {dimColor: true}, \` * ${p}\`)),`);h.push("),");const f=h.join(""),v=e,b=e.slice(0,d)+f+e.slice(d);return V(v,b,f,d,d),b},Fr=e=>{const t=/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3"),null;const r=Math.max(0,n.index-500),o=e.slice(r,n.index),i=/\}function ([$\w]+)\(/g,a=Array.from(o.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}},Vr=(e,t,n,r=!0,o=!0)=>{const i=Pr(e);if(!i)return console.error("patch: patchesAppliedIndication: failed to version output location"),null;const a=`\\n${t} (tweakcc)`;let l=e.slice(0,i.endIndex)+a+e.slice(i.endIndex);V(e,l,a,i.endIndex,i.endIndex);const u=dn(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=Je(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(r){const b=Dr(l);if(!b)return console.error("patch: patchesAppliedIndication: patch 2 failed"),null;const p=`, " ",${h}.createElement(${d}, null, ${u}.blue.bold('+ tweakcc v${t}'))`,w=l;l=l.slice(0,b.startIndex)+p+l.slice(b.endIndex),V(w,l,p,b.startIndex,b.endIndex)}if(o){const b=Fr(l);if(!b)return console.error("patch: patchesAppliedIndication: patch 3 failed"),null;const p=[];p.push(`${h}.createElement(${f}, { flexDirection: "column" },`),p.push(`${h}.createElement(${f}, null, ${h}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${d}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let C of n)C=C.replace("CHALK_VAR",u),p.push(`${h}.createElement(${f}, null, ${h}.createElement(${d}, {color: "success", bold: true}, "┃ "), ${h}.createElement(${d}, {dimColor: true}, \` * ${C}\`)),`);p.push("),");const w=p.join(`
184
+ `),x=l;l=l.slice(0,b.startIndex)+w+l.slice(b.endIndex),V(x,l,w,b.startIndex,b.endIndex)}let v=-1;if(r){const b=Lr(l,t,h,f,d,u);if(!b)return console.error("patch: patchesAppliedIndication: patch 4 failed"),null;l=b.content,v=b.closingParenIndex}if(o){if(v===-1){const p=/alignItems:"center",minHeight:9,?/,w=l.match(p);if(!w||w.index===void 0)return console.error("patch: patchesAppliedIndication: failed to find reference point for PATCH 5"),null;v=w.index+w[0].length}const b=Rr(l,v,h,f,d,u,n);if(!b)return console.error("patch: patchesAppliedIndication: patch 5 failed"),null;l=b}return l},jr=e=>/\\u[0-9a-fA-F]{4}/.test(e),Ur=e=>{const t=e.toString(),n=JSON.stringify(t.substring(1,t.length-1)),r=JSON.stringify(t.match(/\/(\w*)$/)[1]);return`new RegExp(${n}, ${r})`},Hr=async(e,t,n)=>{const r=n??jr(e);T()&&r&&console.log("Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts");const o=await Ut(t,r);T()&&console.log(`Loaded ${o.length} system prompts with regexes`);let i=0,a=0;for(const{promptId:d,prompt:h,regex:f,getInterpolatedContent:v,pieces:b,identifiers:p,identifierMap:w}of o){const x=new RegExp(f,"si"),C=e.match(x);if(C&&C.index!==void 0){const _=v(C),k=Fe(b,p,w).trim(),P=k.length,B=h.content.length;i+=P,a+=B,T()&&P!==B&&(console.log(`
185
185
  Character count difference for ${h.name}:`),console.log(` Original baseline: ${P} chars`),console.log(` User's version: ${B} chars`),console.log(` Difference: ${P-B} chars`),Math.abs(P-B)<200&&(console.log(`
186
186
  Original baseline content:
187
187
  ${k}`),console.log(`
188
188
  User's content:
189
189
  ${h.content}`))),T()&&(console.log(`
190
- Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.index}, length ${C[0].length}`),console.log(` Original content (first 100 chars): ${C[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${_.substring(0,100)}...`),console.log(` Captured variables: ${C.slice(1).join(", ")}`),console.log(` Content identical: ${C[0]===_}`));const j=e,q=C.index,U=C[0].length;e=e.replace(x,_);const A=We(h.content);await Et(c,A),T()&&V(j,e,_,q,q+U)}else if(console.log(Q.yellow(`Could not find system prompt "${h.name}" in cli.js (using regex ${Gr(x)})`)),T()){console.log(`
191
- Debug info for ${h.name}:`),console.log(` Regex pattern (first 200 chars): ${f.substring(0,200)}...`),console.log(" Trying to match pattern in cli.js...");const _=e.match(new RegExp(f.substring(0,100)));console.log(` Partial match result: ${_?"found partial":"no match"}`)}}const l=[],u=i-a;return u>0?l.push(`system prompts: \${CHALK_VAR.green('${u} fewer chars')} than original`):u<0&&l.push(`system prompts: \${CHALK_VAR.red('${Math.abs(u)} more chars')} than original`),{newContent:e,items:l}},Yr=e=>{const t=/ensureServerStarted:([$\w]+)\b/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: fixLspSupport: failed to find ensureServerStarted"),null;const r=Math.max(0,n.index-50),o=Math.min(e.length,n.index+50),i=e.slice(r,o),a=/sendRequest:([$\w]+)[,}]/,l=i.match(a);if(!l)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([r,o,i])}`),null;const u=l[1],c=Math.max(0,n.index-2e3),h=e.slice(c,n.index),f=new RegExp(`async function ${fe(u)}\\(([$\\w]+),`,"g");let v,b=null;for(;(v=f.exec(h))!==null;)b=v;if(!b)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=b[1],w=c+b.index,x=e.slice(w,n.index),C=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,_=x.match(C);if(!_||_.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const k=_[1],P=w+_.index+_[0].length,B=e.slice(P,n.index),j=new RegExp(`if\\(!${fe(k)}\\)return;`),q=B.match(j);if(!q||q.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const U=P+q.index+q[0].length;return{startIndex:U,endIndex:U,identifiers:[p,k]}},Wr=e=>{const t=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,n=/if\([$\w]+\.startupTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': startupTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,r=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g;let o=e;const i=o;o=o.replace(t,""),o!==i?V(i,o,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const a=o;o=o.replace(n,""),o!==a?V(a,o,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const l=o;o=o.replace(r,""),o!==l?V(l,o,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=Yr(o);if(!u||!u.identifiers)return null;const[c,h]=u.identifiers,f=`
190
+ Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.index}, length ${C[0].length}`),console.log(` Original content (first 100 chars): ${C[0].substring(0,100)}...`),console.log(` Replacement content (first 100 chars): ${_.substring(0,100)}...`),console.log(` Captured variables: ${C.slice(1).join(", ")}`),console.log(` Content identical: ${C[0]===_}`));const j=e,q=C.index,U=C[0].length;e=e.replace(x,_);const A=We(h.content);await Et(d,A),T()&&V(j,e,_,q,q+U)}else if(console.log(Q.yellow(`Could not find system prompt "${h.name}" in cli.js (using regex ${Ur(x)})`)),T()){console.log(`
191
+ Debug info for ${h.name}:`),console.log(` Regex pattern (first 200 chars): ${f.substring(0,200)}...`),console.log(" Trying to match pattern in cli.js...");const _=e.match(new RegExp(f.substring(0,100)));console.log(` Partial match result: ${_?"found partial":"no match"}`)}}const l=[],u=i-a;return u>0?l.push(`system prompts: \${CHALK_VAR.green('${u} fewer chars')} than original`):u<0&&l.push(`system prompts: \${CHALK_VAR.red('${Math.abs(u)} more chars')} than original`),{newContent:e,items:l}},Gr=e=>{const t=/ensureServerStarted:([$\w]+)\b/,n=e.match(t);if(!n||n.index===void 0)return console.error("patch: fixLspSupport: failed to find ensureServerStarted"),null;const r=Math.max(0,n.index-50),o=Math.min(e.length,n.index+50),i=e.slice(r,o),a=/sendRequest:([$\w]+)[,}]/,l=i.match(a);if(!l)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([r,o,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 v,b=null;for(;(v=f.exec(h))!==null;)b=v;if(!b)return console.error(`patch: fixLspSupport: failed to find async function ${u}`),null;const p=b[1],w=d+b.index,x=e.slice(w,n.index),C=/let ([$\w]+)=await [$\w]+\([$\w]+\);/,_=x.match(C);if(!_||_.index===void 0)return console.error("patch: fixLspSupport: failed to find second line of sendRequest"),null;const k=_[1],P=w+_.index+_[0].length,B=e.slice(P,n.index),j=new RegExp(`if\\(!${fe(k)}\\)return;`),q=B.match(j);if(!q||q.index===void 0)return console.error("patch: fixLspSupport: failed to find if(!serverVar)return; line"),null;const U=P+q.index+q[0].length;return{startIndex:U,endIndex:U,identifiers:[p,k]}},zr=e=>{const t=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,n=/if\([$\w]+\.startupTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': startupTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,r=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g;let o=e;const i=o;o=o.replace(t,""),o!==i?V(i,o,"",0,0):console.warn("patch: fixLspSupport: restartOnCrash validation not found");const a=o;o=o.replace(n,""),o!==a?V(a,o,"",0,0):console.warn("patch: fixLspSupport: startupTimeout validation not found");const l=o;o=o.replace(r,""),o!==l?V(l,o,"",0,0):console.warn("patch: fixLspSupport: shutdownTimeout validation not found");const u=Gr(o);if(!u||!u.identifiers)return null;const[d,h]=u.identifiers,f=`
192
192
  const path = await import('path');
193
- const ext = path.extname(${c}).toLowerCase();
193
+ const ext = path.extname(${d}).toLowerCase();
194
194
  const langMap = {
195
195
  '.ts': 'typescript',
196
196
  '.tsx': 'typescriptreact',
@@ -328,41 +328,41 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.ind
328
328
  const languageId = langMap[ext] || 'plaintext';
329
329
  try {
330
330
  const fs = await import('fs/promises');
331
- const text = await fs.readFile(${c}, 'utf8');
331
+ const text = await fs.readFile(${d}, 'utf8');
332
332
  await ${h}.sendNotification('textDocument/didOpen', {
333
333
  textDocument: {
334
- uri: "file://" + ${c},
334
+ uri: "file://" + ${d},
335
335
  languageId: languageId,
336
336
  version: 1,
337
337
  text: text
338
338
  }
339
339
  });
340
340
  } catch (openErr) { }
341
- `,v=o.slice(0,u.startIndex)+f+o.slice(u.endIndex);return V(o,v,f,u.startIndex,u.endIndex),v},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 r=e.indexOf("[",n.index);if(r===-1)return console.error("patch: findSlashCommandListEndPosition: failed to find bracketIndex"),null;let o=1,i=r+1;for(;i<e.length&&o>0;){if(e[i]==="[")o++;else if(e[i]==="]"&&(o--,o===0))return i;i++}return console.error("patch: findSlashCommandListEndPosition: failed to find matching closing-bracket"),null},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 r=e.slice(0,n)+t+e.slice(n);return V(e,r,t,n,n),r},Jr=e=>{const t=/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findSelectComponentName: failed to find selectPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r[1]},qr=e=>{const t=/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findDividerComponentName: failed to find dividerPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r[1]},Qn=e=>{const t=/function ([$\w]+)\(\{(?:(?:commands|debug|initialPrompt|initialTools|initialMessages|initialCheckpoints|initialFileHistorySnapshots|mcpClients|dynamicMcpConfig|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r.index===void 0?(console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch"),null):r.index+r[0].length},cn=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),r=/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/,o=n.match(r);return o?{appStateVar:o[1],appStateGetterFunction:o[2]}:(console.error("patch: getAppStateVarAndGetterFunction: failed to find statePattern"),null)},Kr=e=>{const t=Qn(e);if(t===null)return console.error("patch: getToolFetchingUseMemoLocation: failed to find bodyStart"),null;const n=e.slice(t,t+300),r=/let ([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4\]\)/,o=n.match(r);if(!o||o.index===void 0)return console.error("patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern"),null;const i=t+o.index,a=i+o[0].length;return{startIndex:i,endIndex:a,outputVarName:o[1],reactVarName:o[2],toolFilterFunction:o[3],toolPermissionContextVar:o[4]}},Xr=e=>{const t=Xn(e);if(t===null)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd"),null;let n=1,r=t;for(;r>=0&&n>0;){if(e[r]==="}")n++;else if(e[r]==="{"&&(n--,n===0))break;r--}if(r<0)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace"),null;for(;r>=0&&e[r]!==";";)r--;return r<0?(console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon"),null):r+1},Zr=(e,t)=>{const n=/thinkingEnabled:([$\w]+)\(\)/g,r=Array.from(e.matchAll(n));if(r.length===0)return console.error("patch: toolsets: failed to find thinkingEnabled pattern"),null;const o=[];for(const u of r)if(u.index!==void 0){const c=u.index+u[0].length;o.push({index:c})}o.sort((u,c)=>c.index-u.index);let i=e;const l=`,toolset:${t?JSON.stringify(t):"undefined"}`;for(const u of o)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},Qr=(e,t)=>{const n=Kr(e);if(!n)return console.error("patch: toolsets: failed to find tool fetching useMemo location"),null;const r=cn(e);if(!r)return console.error("patch: toolsets: failed to find app state info"),null;const{appStateVar:o}=r,{startIndex:i,endIndex:a,outputVarName:l,reactVarName:u,toolFilterFunction:c,toolPermissionContextVar:h}=n,f=JSON.stringify(Object.fromEntries(t.map(p=>[p.name,p.allowedTools==="*"?"*":p.allowedTools]))),v=`let ${l} = ${u}.useMemo(() => {
342
- const toolsets = ${f};
341
+ `,v=o.slice(0,u.startIndex)+f+o.slice(u.endIndex);return V(o,v,f,u.startIndex,u.endIndex),v},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 r=e.indexOf("[",n.index);if(r===-1)return console.error("patch: findSlashCommandListEndPosition: failed to find bracketIndex"),null;let o=1,i=r+1;for(;i<e.length&&o>0;){if(e[i]==="[")o++;else if(e[i]==="]"&&(o--,o===0))return i;i++}return console.error("patch: findSlashCommandListEndPosition: failed to find matching closing-bracket"),null},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 r=e.slice(0,n)+t+e.slice(n);return V(e,r,t,n,n),r},Yr=e=>{const t=/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findSelectComponentName: failed to find selectPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r[1]},Wr=e=>{const t=/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g,n=Array.from(e.matchAll(t));if(n.length===0)return console.error("patch: findDividerComponentName: failed to find dividerPattern"),null;let r=n[0];for(const o of n)o[0].length>r[0].length&&(r=o);return r[1]},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,r=Array.from(e.matchAll(t)).filter(i=>i[0].includes("commands:"));if(r.length===0)return console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern"),null;let o=r[0];for(const i of r)i[0].length>o[0].length&&(o=i);return o.index===void 0?(console.error("patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch"),null):o.index+o[0].length},cn=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),r=/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/,o=n.match(r);return o?{appStateVar:o[1],appStateGetterFunction:o[2]}:(console.error("patch: getAppStateVarAndGetterFunction: failed to find statePattern"),null)},Jr=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),r=/(?:let |,)([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4\]\)/,o=n.match(r);if(!o||o.index===void 0)return console.error("patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern"),null;const i=t+o.index,a=i+o[0].length,u=o[0].startsWith(",");return{startIndex:i,endIndex:a,outputVarName:o[1],reactVarName:o[2],toolFilterFunction:o[3],toolPermissionContextVar:o[4],needsSemicolonPrefix:u}},qr=e=>{const t=Xn(e);if(t===null)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd"),null;let n=1,r=t;for(;r>=0&&n>0;){if(e[r]==="}")n++;else if(e[r]==="{"&&(n--,n===0))break;r--}if(r<0)return console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace"),null;for(;r>=0&&e[r]!==";";)r--;return r<0?(console.error("patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon"),null):r+1},Kr=(e,t)=>{const n=/thinkingEnabled:([$\w]+)\(\)/g,r=Array.from(e.matchAll(n));if(r.length===0)return console.error("patch: toolsets: failed to find thinkingEnabled pattern"),null;const o=[];for(const u of r)if(u.index!==void 0){const d=u.index+u[0].length;o.push({index:d})}o.sort((u,d)=>d.index-u.index);let i=e;const l=`,toolset:${t?JSON.stringify(t):"undefined"}`;for(const u of o)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},Xr=(e,t)=>{const n=Jr(e);if(!n)return console.error("patch: toolsets: failed to find tool fetching useMemo location"),null;const r=cn(e);if(!r)return console.error("patch: toolsets: failed to find app state info"),null;const{appStateVar:o}=r,{startIndex:i,endIndex:a,outputVarName:l,reactVarName:u,toolFilterFunction:d,toolPermissionContextVar:h,needsSemicolonPrefix:f}=n,v=JSON.stringify(Object.fromEntries(t.map(x=>[x.name,x.allowedTools==="*"?"*":x.allowedTools]))),p=`${f?";":""}let ${l} = ${u}.useMemo(() => {
342
+ const toolsets = ${v};
343
343
  if (toolsets.hasOwnProperty(${o}.toolset)) {
344
344
  const allowedTools = toolsets[${o}.toolset];
345
345
  if (allowedTools === "*") {
346
- return ${c}(${h});
346
+ return ${d}(${h});
347
347
  } else {
348
- return ${c}(${h}).filter(toolDef =>
348
+ return ${d}(${h}).filter(toolDef =>
349
349
  allowedTools.includes(toolDef.name)
350
350
  );
351
351
  }
352
352
  } else {
353
- return ${c}(${h});
353
+ return ${d}(${h});
354
354
  }
355
- }, [${c}, ${o}.toolset])`,b=e.slice(0,i)+v+e.slice(a);return V(e,b,v,i,a),b},eo=(e,t)=>{const n=Xr(e);if(n===null)return console.error("patch: toolsets: failed to find slash command insertion point"),null;const r=Je(e);if(!r)return console.error("patch: toolsets: failed to find React variable"),null;const o=tt(e);if(!o)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=Jr(e);if(!a)return console.error("patch: toolsets: failed to find Select component"),null;const l=qr(e);if(!l)return console.error("patch: toolsets: failed to find Divider component"),null;const u=cn(e);if(!u)return console.error("patch: toolsets: failed to find app state getter"),null;const c=dn(e);if(!c)return console.error("patch: toolsets: failed to find chalk variable"),null;const{appStateGetterFunction:h}=u,f=JSON.stringify(t.map(w=>w.name)),v=JSON.stringify(t.map(w=>({label:w.name,value:w.name,description:w.allowedTools==="*"?"All tools":w.allowedTools.length===0?"No tools":`${w.allowedTools.length} tool${w.allowedTools.length!==1?"s":""}: ${w.allowedTools.join(", ")}`}))),b=`const toolsetComp = ({ onExit, input }) => {
355
+ }, [${d}, ${o}.toolset])`,w=e.slice(0,i)+p+e.slice(a);return V(e,w,p,i,a),w},Zr=(e,t)=>{const n=qr(e);if(n===null)return console.error("patch: toolsets: failed to find slash command insertion point"),null;const r=Je(e);if(!r)return console.error("patch: toolsets: failed to find React variable"),null;const o=tt(e);if(!o)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=Yr(e);if(!a)return console.error("patch: toolsets: failed to find Select component"),null;const l=Wr(e);if(!l)return console.error("patch: toolsets: failed to find Divider component"),null;const u=cn(e);if(!u)return console.error("patch: toolsets: failed to find app state getter"),null;const d=dn(e);if(!d)return console.error("patch: toolsets: failed to find chalk variable"),null;const{appStateGetterFunction:h}=u,f=JSON.stringify(t.map(w=>w.name)),v=JSON.stringify(t.map(w=>({label:w.name,value:w.name,description:w.allowedTools==="*"?"All tools":w.allowedTools.length===0?"No tools":`${w.allowedTools.length} tool${w.allowedTools.length!==1?"s":""}: ${w.allowedTools.join(", ")}`}))),b=`const toolsetComp = ({ onExit, input }) => {
356
356
  const [state, setState] = ${h}();
357
357
 
358
358
  // Handle command-line argument
359
359
  if (input !== "" && input != null) {
360
360
  if (!${f}.includes(input)) {
361
- onExit(${c}.red(\`\${${c}.bold(input)} is not a valid toolset. Valid toolsets: ${t.map(w=>w.name).join(", ")}\`));
361
+ onExit(${d}.red(\`\${${d}.bold(input)} is not a valid toolset. Valid toolsets: ${t.map(w=>w.name).join(", ")}\`));
362
362
  return;
363
363
  } else {
364
364
  setState(prev => ({ ...prev, toolset: input }));
365
- onExit(\`Toolset changed to \${${c}.bold(input)}\`);
365
+ onExit(\`Toolset changed to \${${d}.bold(input)}\`);
366
366
  return;
367
367
  }
368
368
  }
@@ -408,15 +408,15 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.ind
408
408
  options: ${v},
409
409
  onChange: (input) => {
410
410
  setState(prev => ({ ...prev, toolset: input }));
411
- onExit(\`Toolset changed to \${${c}.bold(input)}\`);
411
+ onExit(\`Toolset changed to \${${d}.bold(input)}\`);
412
412
  },
413
- onCancel: () => onExit(\`Toolset not changed (left as \${${c}.bold(state.toolset)})\`)
413
+ onCancel: () => onExit(\`Toolset not changed (left as \${${d}.bold(state.toolset)})\`)
414
414
  })
415
415
  ),
416
416
  ${r}.createElement(${i}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
417
417
  )
418
418
  );
419
- };`,p=e.slice(0,n)+b+e.slice(n);return V(e,p,b,n,n),p},no=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 r=Math.max(0,n.index-500),o=e.slice(r,n.index),i=/function ([$\w]+)\(\{[^}]+\}\)\{/g,a=Array.from(o.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):r+l.index+l[0].length},to=e=>{const t=no(e);if(t===null)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point"),null;const n=cn(e);if(!n)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter"),null;const{appStateGetterFunction:r}=n,o=`let[state]=${r}();`,i=e.slice(0,t)+o+e.slice(t);return V(e,i,o,t,t),i},ro=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 r=n[1],o=n[2],i=n[0],a=`${r}(${o}).toLowerCase()," on [",state.toolset||"undefined","]"`,l=e.replace(i,a);return l===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(V(e,l,a,n.index,n.index+i.length),l)},oo=e=>{const t=/"\? for shortcuts"/g,r=Array.from(e.matchAll(t)).at(-1);if(!r||r.index===void 0)return console.error("patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'"),null;const o=r[0],i='"? for shortcuts [",state.toolset||"undefined","]"',a=e.replace(o,i);return a===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(V(e,a,i,r.index,r.index+o.length),a)},io=e=>{const t=Je(e);if(!t)return console.error("patch: toolsets: failed to find React variable"),null;const n=`, {
419
+ };`,p=e.slice(0,n)+b+e.slice(n);return V(e,p,b,n,n),p},Qr=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 r=Math.max(0,n.index-500),o=e.slice(r,n.index),i=/function ([$\w]+)\(\{[^}]+\}\)\{/g,a=Array.from(o.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):r+l.index+l[0].length},eo=e=>{const t=Qr(e);if(t===null)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point"),null;const n=cn(e);if(!n)return console.error("patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter"),null;const{appStateGetterFunction:r}=n,o=`let[state]=${r}();`,i=e.slice(0,t)+o+e.slice(t);return V(e,i,o,t,t),i},no=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 r=n[1],o=n[2],i=n[0],a=`${r}(${o}).toLowerCase()," on [",state.toolset||"undefined","]"`,l=e.replace(i,a);return l===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(V(e,l,a,n.index,n.index+i.length),l)},to=e=>{const t=/"\? for shortcuts"/g,r=Array.from(e.matchAll(t)).at(-1);if(!r||r.index===void 0)return console.error("patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'"),null;const o=r[0],i='"? for shortcuts [",state.toolset||"undefined","]"',a=e.replace(o,i);return a===e?(console.error("patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display"),null):(V(e,a,i,r.index,r.index+o.length),a)},ro=e=>{const t=Je(e);if(!t)return console.error("patch: toolsets: failed to find React variable"),null;const n=`, {
420
420
  aliases: ["change-tools"],
421
421
  type: "local-jsx",
422
422
  name: "toolset",
@@ -430,7 +430,7 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.ind
430
430
  userFacingName() {
431
431
  return "toolset";
432
432
  }
433
- }`;return Zn(e,n)},so=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=Zr(r,n),r?(r=Qr(r,t),r?(r=eo(r,t),r?(r=io(r),r?(r=to(r),r?(r=ro(r),r?(r=oo(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)},lo=e=>Je(e)?Zn(e,`, {
433
+ }`;return Zn(e,n)},oo=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=Kr(r,n),r?(r=Xr(r,t),r?(r=Zr(r,t),r?(r=ro(r),r?(r=eo(r),r?(r=no(r),r?(r=to(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)},io=e=>Je(e)?Zn(e,`, {
434
434
  type: "local",
435
435
  name: "title",
436
436
  description: "Set the conversation title",
@@ -449,7 +449,7 @@ Found match for prompt: ${h.name}`),console.log(` Match location: index ${C.ind
449
449
  userFacingName() {
450
450
  return "title";
451
451
  },
452
- }`):(console.error("patch: conversationTitle: failed to find React variable"),null),ao=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},co=e=>{const t=ao(e);if(t===null)return console.error("patch: conversationTitle: failed to find custom naming functions location"),null;const n=un(e),r=`
452
+ }`):(console.error("patch: conversationTitle: failed to find React variable"),null),so=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},lo=e=>{const t=so(e);if(t===null)return console.error("patch: conversationTitle: failed to find custom naming functions location"),null;const n=un(e),r=`
453
453
  function getTweakccBaseDir() {
454
454
  const { join: pathJoin } = ${n}('path');
455
455
  const { homedir: osHomedir } = ${n}('os');
@@ -619,11 +619,11 @@ function onNewMessage(projectDir, projectSlug, msg) {
619
619
  }
620
620
  }
621
621
 
622
- `,o=e.slice(0,t)+r+e.slice(t);return V(e,o,r,t,t),o},uo=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 r=n.index+n[1].length,o=n[2];return{location:r,messageVar:o}},ho=e=>{const t=uo(e);if(!t)return console.error("patch: conversationTitle: failed to find append entry interceptor location"),null;const n=un(e),{location:r,messageVar:o}=t,i=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
622
+ `,o=e.slice(0,t)+r+e.slice(t);return V(e,o,r,t,t),o},ao=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 r=n.index+n[1].length,o=n[2];return{location:r,messageVar:o}},co=e=>{const t=ao(e);if(!t)return console.error("patch: conversationTitle: failed to find append entry interceptor location"),null;const n=un(e),{location:r,messageVar:o}=t,i=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
623
623
  const projectDir = pathDirname(this.sessionFile);
624
624
  const projectSlug = pathBasename(projectDir);
625
625
  onNewMessage(projectDir, projectSlug, ${o});
626
- `,a=e.slice(0,r)+i+e.slice(r);return V(e,a,i,r,r),a},go=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 r=n[1],o=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 c=u[1],h=i+(u.index??0);return{orLocation:o,loopLocation:h,messageVar:r,fileListVar:c}},fo=e=>{const t=go(e);if(!t)return console.error("patch: conversationTitle: failed to find tweakcc summary check locations"),null;const n=un(e),{orLocation:r,loopLocation:o,messageVar:i,fileListVar:a}=t;let l=e;const u=`const { readFileSync: fsReadFileSync } = ${n}('fs');
626
+ `,a=e.slice(0,r)+i+e.slice(r);return V(e,a,i,r,r),a},uo=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 r=n[1],o=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:o,loopLocation:h,messageVar:r,fileListVar:d}},ho=e=>{const t=uo(e);if(!t)return console.error("patch: conversationTitle: failed to find tweakcc summary check locations"),null;const n=un(e),{orLocation:r,loopLocation:o,messageVar:i,fileListVar:a}=t;let l=e;const u=`const { readFileSync: fsReadFileSync } = ${n}('fs');
627
627
  const tweakccSummaries = new Set();
628
628
  for (const file of ${a}) {
629
629
  const contents = fsReadFileSync(file, "utf8").trim();
@@ -638,16 +638,16 @@ for (const file of ${a}) {
638
638
  if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
639
639
  tweakccSummaries.add(obj.leafUuid);
640
640
  }
641
- `;l=l.slice(0,o)+u+l.slice(o),V(e,l,u,o,o);const c=r+u.length,h=`||tweakccSummaries.has(${i}.uuid)`,f=l.slice(0,c)+h+l.slice(c);return V(l,f,h,c,c),f},mo=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 r='description:"Rename the current conversation",isEnabled:()=>!1,',o='description:"Rename the current conversation",isEnabled:()=>!0,',i=e.replace(r,o);return i===e?(console.error("patch: conversationTitle: enableRenameConversationCommand: replacement failed"),null):(V(e,i,o,n.index,n.index+63),i)},po=e=>{let t=e;if(t=lo(t),!t)return console.error("patch: conversationTitle: step 1 failed (writeTitleSlashCommand)"),null;if(t=co(t),!t)return console.error("patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)"),null;if(t=ho(t),!t)return console.error("patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)"),null;if(t=fo(t),!t)return console.error("patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)"),null;const n=mo(t);return n?t=n:console.log("patch: conversationTitle: step 5 failed (enableRenameConversationCommand)"),t},V=(e,t,n,r,o)=>{if(!T())return;const i=Math.max(0,r-20),a=Math.min(e.length,o+20),l=Math.min(t.length,r+n.length+20),u=e.slice(i,r),c=e.slice(r,o),h=e.slice(o,a),f=t.slice(i,r),v=t.slice(r,r+n.length),b=t.slice(r+n.length,l);c!==v&&(console.log(`
642
- --- Diff ---`),console.log("OLD:",u+`\x1B[31m${c}\x1B[0m`+h),console.log("NEW:",f+`\x1B[32m${v}\x1B[0m`+b),console.log(`--- End Diff ---
643
- `))},fe=e=>e.replace(/\$/g,"\\$"),dn=e=>{const t=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,n=Array.from(e.matchAll(t)),r={};for(const a of n){const l=a[1];r[l]=(r[l]||0)+1}let o,i=0;for(const[a,l]of Object.entries(r))l>i&&(i=l,o=a);return o},bo=e=>{const t=e.slice(0,1e3),n=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,r=t.match(n);if(!r){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return r[1]},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]},wo=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)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let he=null,ke=null;const Je=e=>{if(he!=null)return he;const t=bo(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 r=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(n)}\\(\\),1\\)`),o=e.match(r);if(o)return he=o[1],he;const i=wo(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},xo=e=>{const t=/import\{createRequire as ([$\w]+)\}from"node:module";/,n=e.match(t);if(!n)return;const r=n[1],o=new RegExp(`var ([$\\w]+)=${fe(r)}\\(import\\.meta\\.url\\)`),i=e.match(o);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${r})`);return}return i[1]},un=e=>{if(ke!=null)return ke;const t=xo(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 r=n[1],o=new RegExp(`\\b([$\\w]+)=${fe(r)}[^$\\w]`),i=e.match(o);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${r})`);return}return i[1]},rt=async(e,t)=>{let n;if(t.nativeInstallationPath){await qn(t);let u=!1;try{await te.stat(ge),u=!0}catch{}const c=u?ge:t.nativeInstallationPath;T()&&console.log(`Extracting claude.js from ${u?"backup":"native installation"}: ${c}`);const h=Yn(c);if(!h)throw new Error("Failed to extract claude.js from native installation");const f=re.join(ye.homedir(),".tweakcc"),v=re.join(f,"native-claudejs-orig.js");Ce.writeFileSync(v,h),T()&&console.log(`Saved original extracted JS from native to: ${v}`),n=h.toString("utf8")}else{if(await Jn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await te.readFile(t.cliPath,{encoding:"utf8"})}const r=[],o=await zr(n,t.version);n=o.newContent,r.push(...o.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=ar(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=Er(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=pr(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=yr(n,e.settings.thinkingStyle.phases))&&(n=i),(i=vr(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=_r(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=wr(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=Tr(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=hr(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Nr(n))&&(n=i),(i=fr(n))&&(n=i),(i=dr(n))&&(n=i),(i=vo(n))&&(n=i),(i=sr(n,25))&&(n=i),(i=Or(n))&&(n=i),(i=Lr(n))&&(n=i);const a=e.settings.misc?.showTweakccVersion??!0,l=e.settings.misc?.showPatchesApplied??!0;if((i=Ur(n,"3.1.1",r,a,l))&&(n=i),(i=Wr(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=so(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),(i=po(n))&&(n=i),t.nativeInstallationPath){T()&&console.log(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);const u=re.join(ye.homedir(),".tweakcc"),c=re.join(u,"native-claudejs-patched.js");Ce.writeFileSync(c,n,"utf8"),T()&&console.log(`Saved patched JS from native to: ${c}`);const h=Buffer.from(n,"utf8");er(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})},ot=[{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"}],yo=e=>{const t=e.indexOf("Switch between Claude models");if(t===-1)return console.error("patch: getModelSelectorInsertionPoint: failed to find labelIndex"),null;const n=Math.max(0,t-600),r=t,i=e.slice(n,r).match(/\[[$\w]+,\s*[$\w]+\]\s*=\s*[$\w]+\.useState\([^)]*\)\s*,\s*([$\w]+)=/);if(!i||i.index===void 0)return console.error("patch: getModelSelectorInsertionPoint: failed to find useState"),null;let 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,c=i[1];return{insertionIndex:u,optionsVar:c}},So=e=>{const t=yo(e);if(!t)return null;const{insertionIndex:n,optionsVar:r}=t,o=ot.map(a=>{const l=JSON.stringify(a.label),u=JSON.stringify(a.slug);return`${r}.push({value:${u},label:${l}});`}).join(""),i=e.slice(0,n)+o+e.slice(n);return V(e,i,o,n,n),i},vo=e=>{let t=e;const n=So(t);return n&&(t=n),t===e?null:t};let it=!1;const T=()=>it,$o=()=>{it=!0};function hn(){try{const e=re.join(ye.homedir(),".claude.json");return JSON.parse(Ce.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function _o(){try{const e=re.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ce.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=re.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ce.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const r=ot.find(o=>o.slug===n);if(r)return r.label}catch{}return"Sonnet 4.5"}function Co(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[,r,o,i]=n;return parseInt(r)<=255&&parseInt(o)<=255&&parseInt(i)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const[,r,o,i]=n;return parseInt(r)<=360&&parseInt(o)<=100&&parseInt(i)<=100}}return!1}function 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 r=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),i=parseInt(n.slice(4,6),16);return`rgb(${r},${o},${i})`}if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const r=parseInt(n[1])/360,o=parseInt(n[2])/100,i=parseInt(n[3])/100,a=(v,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?v+(b-v)*6*p:p<1/2?b:p<2/3?v+(b-v)*(2/3-p)*6:v),l=i<.5?i*(1+o):i+o-i*o,u=2*i-l,c=Math.round(a(u,l,r+1/3)*255),h=Math.round(a(u,l,r)*255),f=Math.round(a(u,l,r-1/3)*255);return`rgb(${c},${h},${f})`}}return e}async function Eo(e,t="sha256",n=64*1024){return new Promise((r,o)=>{const i=An.createHash(t),a=Ce.createReadStream(e,{highWaterMark:n});a.on("data",l=>{i.update(l)}),a.on("end",()=>{r(i.digest("hex"))}),a.on("error",l=>{o(l)})})}const Tn=(e,t,n,r,o,i,a,l)=>{let u=e;return t&&(u+=`.rgb(${t})`),n&&n!=="transparent"&&(u+=`.bgRgb(${n})`),r&&(u+=".bold"),o&&(u+=".italic"),i&&(u+=".underline"),a&&(u+=".strikethrough"),l&&(u+=".inverse"),u};async function fn(e,t,n="replace"){let r=493;try{r=(await te.stat(e)).mode,T()&&console.log(`[${n}] Original file mode for ${e}: ${(r&parseInt("777",8)).toString(8)}`)}catch(o){T()&&console.log(`[${n}] Could not stat ${e} (error: ${o}), using default mode 755`)}try{await te.unlink(e),T()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(o){T()&&console.log(`[${n}] Could not unlink ${e}: ${o}`)}await te.writeFile(e,t),await te.chmod(e,r),T()&&console.log(`[${n}] Restored permissions to ${(r&parseInt("777",8)).toString(8)}`)}function F({color:e,backgroundColor:t,bold:n,dimColor:r,children:o}){const i=e?.startsWith("ansi:"),a=t?.startsWith("ansi:");if(i||a){if(Ke.Children.toArray(o).some(f=>Ke.isValidElement(f)))return s(d,{children:o});let u=Q;if(i){const f=e.slice(5);u=u[f]||u}if(a){const f=t.slice(5),v=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[v]||u}n&&(u=u.bold),r&&(u=u.dim);const h=Ke.Children.toArray(o).map(f=>typeof f=="string"||typeof f=="number"?String(f):"").join("");return s(d,{children:u(h)})}return s(d,{color:e,backgroundColor:t,bold:n,dimColor:r,children:o})}function ko({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:r=3,updateDuration:o=50,restartPoint:i=10}){const[a,l]=O(0);return xe(()=>{const u=setInterval(()=>{l(c=>{const h=c+1;return h>=e.length+i?-r:h})},o);return()=>clearInterval(u)},[e.length,i,o]),t.length!==n.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(d,{children:e})):s(d,{children:e.split("").map((u,c)=>{const h=c>=a&&c<a+r&&a<e.length,f=c%t.length,v=h?n[f]:t[f];return s(d,{color:v,children:u},c)})})}const To=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(d,{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(d,{children:[s(F,{color:e.colors.clawd_body,children:" ▐"}),s(d,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),g(d,{children:[s(F,{color:e.colors.clawd_body,children:"▌ "})," ",s(d,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),g(d,{children:[s(F,{color:e.colors.clawd_body,children:"▝▜"}),s(d,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(F,{color:e.colors.clawd_body,children:"▛▘"})," ",Io()," · ",_o()]}),g(F,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",To]}),g(d,{children:[g(F,{color:e.colors.success,children:["Login successful. Press"," "]}),s(F,{bold:!0,color:e.colors.success,children:"Enter"}),g(F,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(d,{children:"╭─────────────────────────────────────────────╮"}),g(d,{children:["│ 1 function greet() ","{"," ","│"]}),g(d,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(F,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(F,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),g(d,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(F,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(F,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(F,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),g(F,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),g(d,{children:[s(F,{color:e.colors.warning,children:"│ "}),s(d,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),g(F,{color:e.colors.warning,children:[" ","│"]})]}),s(F,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),g(d,{children:[s(F,{color:e.colors.bashBorder,children:"!"}),s(d,{children:" ls"})]}),s(F,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(d,{children:g(d,{children:["> list the dir"," ",s(ko,{text:"ultrathink",nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),s(F,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),g(d,{children:[s(F,{color:e.colors.planMode,children:"│ "}),g(F,{color:e.colors.permission,children:["Ready to code?"," "]}),s(d,{children:"Here is Claude's plan:"}),g(F,{color:e.colors.planMode,children:[" ","│"]})]}),s(F,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),g(d,{children:[s(F,{color:e.colors.permission,children:"│ "}),s(d,{bold:!0,children:"Permissions:"})," ",g(F,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(F,{color:e.colors.permission,children:"│"})]}),s(d,{children:"> list the dir"}),g(d,{children:[s(F,{color:e.colors.error,children:"●"}),s(d,{children:" Update(__init__.py)"})]}),g(d,{children:[s(d,{children:" ⎿ "}),s(F,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),g(d,{children:[" ","1"," ",g(F,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(F,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),g(d,{children:[" ","2"," ",g(F,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(F,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),g(d,{children:[s(F,{color:e.colors.success,children:"●"}),s(d,{children:" List(.)"})]}),g(d,{children:[s(d,{children:"●"}),s(d,{children:" The directory "}),s(F,{color:e.colors.permission,children:"C:\\Users\\user"}),g(d,{children:[" ","contains ",s(d,{bold:!0,children:"123"})," files."]})]}),g(d,{children:[s(F,{color:e.colors.claude,children:"✻ Th"}),s(F,{color:e.colors.claudeShimmer,children:"ink"}),s(F,{color:e.colors.claude,children:"ing… "}),s(d,{children:"(esc to interrupt)"})]}),s(d,{children:s(F,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(d,{children:s(F,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(d,{children:s(F,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function Xe({colorKey:e,theme:t,bold:n=!1}){const r=t.colors[e];return e==="inverseText"?s(F,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(F,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):s(F,{color:r,bold:n,children:e})}function at({initialValue:e,onColorChange:t,onExit:n,colorKey:r,theme:o}){const i=Qe(e)||{h:0,s:50,l:50},a=Ze(e)||{r:128,g:128,b:128},[l,u]=O(i),[c,h]=O(a),[f,v]=O("hsl"),[b,p]=O("h"),[w,x]=O(!1),[C,_]=O(!1);xe(()=>{const I=Qe(e),$=Ze(e);I&&$&&(x(!0),u(I),h($),x(!1))},[e]),xe(()=>{if(!w&&C){const I=`rgb(${c.r},${c.g},${c.b})`;t(I)}},[l,c,w,C]),xe(()=>{_(!0)},[]);const k=I=>{if(gn(I)){const $=st(I),S=Qe($),N=Ze($);S&&N&&(x(!0),u(S),h(N),x(!1))}};de((I,$)=>{if(I.length>1&&!$.ctrl&&!$.meta){k(I);return}if($.return)n();else if($.escape)n();else if($.ctrl&&I==="a")v(S=>S==="hsl"?"rgb":"hsl"),p(S=>f==="hsl"?S==="h"?"r":S==="s"?"g":"b":S==="r"?"h":S==="g"?"s":"l");else if($.upArrow)p(f==="hsl"?S=>S==="h"?"l":S==="s"?"h":"s":S=>S==="r"?"b":S==="g"?"r":"g");else if($.downArrow||$.tab)p(f==="hsl"?S=>S==="h"?"s":S==="s"?"l":"h":S=>S==="r"?"g":S==="g"?"b":"r");else if($.leftArrow){const S=$.shift||$.ctrl||$.meta?-10:-1;P(S)}else if($.rightArrow){const S=$.shift||$.ctrl||$.meta?10:1;P(S)}});const P=I=>{x(!0),f==="hsl"?u($=>{const S={...$};b==="h"?S.h=Math.max(0,Math.min(359,$.h+I)):b==="s"?S.s=Math.max(0,Math.min(100,$.s+I)):b==="l"&&(S.l=Math.max(0,Math.min(100,$.l+I)));const[N,y,L]=j(S.h,S.s,S.l);return h({r:N,g:y,b:L}),S}):h($=>{const S={...$};b==="r"?S.r=Math.max(0,Math.min(255,$.r+I)):b==="g"?S.g=Math.max(0,Math.min(255,$.g+I)):b==="b"&&(S.b=Math.max(0,Math.min(255,$.b+I)));const N=B(S.r,S.g,S.b);return u(N),S}),x(!1)},B=(I,$,S)=>{const N=I/255,y=$/255,L=S/255,z=Math.max(N,y,L),G=Math.min(N,y,L),ne=z-G,se=(z+G)/2;let $e=0;ne!==0&&($e=se>.5?ne/(2-z-G):ne/(z+G));let we=0;return ne!==0&&(z===N?we=((y-L)/ne+(y<L?6:0))/6:z===y?we=((L-N)/ne+2)/6:we=((N-y)/ne+4)/6),{h:Math.round(we*360),s:Math.round($e*100),l:Math.round(se*100)}},j=(I,$,S)=>{I/=360,$/=100,S/=100;const N=(1-Math.abs(2*S-1))*$,y=N*(1-Math.abs(I*6%2-1)),L=S-N/2;let z=0,G=0,ne=0;return 0<=I&&I<1/6?(z=N,G=y,ne=0):1/6<=I&&I<2/6?(z=y,G=N,ne=0):2/6<=I&&I<3/6?(z=0,G=N,ne=y):3/6<=I&&I<4/6?(z=0,G=y,ne=N):4/6<=I&&I<5/6?(z=y,G=0,ne=N):5/6<=I&&I<1&&(z=N,G=0,ne=y),[Math.round((z+L)*255),Math.round((G+L)*255),Math.round((ne+L)*255)]},q=()=>{const I=[],$=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let S=0;S<40;S++){const y=S/39*($.length-1),L=Math.floor(y),z=Math.ceil(y),G=y-L,[ne,se,$e]=$[L],[we,H,R]=$[z],D=Math.round(ne+(we-ne)*G),ee=Math.round(se+(H-se)*G),W=Math.round($e+(R-$e)*G);I.push(s(d,{backgroundColor:`rgb(${D},${ee},${W})`,children:" "},S))}return I},U=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,L]=j(l.h,S,l.l);I.push(s(d,{backgroundColor:`rgb(${N},${y},${L})`,children:" "},$))}return I},A=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,L]=j(l.h,l.s,S);I.push(s(d,{backgroundColor:`rgb(${N},${y},${L})`,children:" "},$))}return I},M=()=>{const[I,$,S]=j(l.h,l.s,l.l);return`rgb(${I},${$},${S})`},E=(I,$,S)=>{const N=y=>y.toString(16).padStart(2,"0");return`#${N(I)}${N($)}${N(S)}`},Y=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(d,{backgroundColor:`rgb(${S},${c.g},${c.b})`,children:" "},$))}return I},X=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(d,{backgroundColor:`rgb(${c.r},${S},${c.b})`,children:" "},$))}return I},oe=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(d,{backgroundColor:`rgb(${c.r},${c.g},${S})`,children:" "},$))}return I},K=(I,$)=>Math.round(I/$*39);return g(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[g(m,{flexDirection:"column",children:[s(d,{bold:!0,children:"Color Picker"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(d,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(d,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(d,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(d,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(d,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(d,{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(d,{color:b==="h"?"yellow":"white",children:[b==="h"?"❯ ":" ","Hue (",l.h,"°):"]})}),s(m,{children:q().map((I,$)=>s(Ee,{children:$===K(l.h,360)?s(d,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(d,{color:b==="s"?"yellow":"white",children:[b==="s"?"❯ ":" ","Saturation (",l.s,"%):"]})}),s(m,{children:U().map((I,$)=>s(Ee,{children:$===K(l.s,100)?s(d,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(d,{color:b==="l"?"yellow":"white",children:[b==="l"?"❯ ":" ","Lightness (",l.l,"%):"]})}),s(m,{children:A().map((I,$)=>s(Ee,{children:$===K(l.l,100)?s(d,{children:"|"}):I},$))})]})]}):g(me,{children:[g(m,{marginBottom:1,children:[s(m,{width:25,children:g(d,{color:b==="r"?"yellow":"white",children:[b==="r"?"❯ ":" ","Red (",c.r,"):"]})}),s(m,{children:Y().map((I,$)=>s(Ee,{children:$===K(c.r,255)?s(d,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(d,{color:b==="g"?"yellow":"white",children:[b==="g"?"❯ ":" ","Green (",c.g,"):"]})}),s(m,{children:X().map((I,$)=>s(Ee,{children:$===K(c.g,255)?s(d,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(d,{color:b==="b"?"yellow":"white",children:[b==="b"?"❯ ":" ","Blue (",c.b,"):"]})}),s(m,{children:oe().map((I,$)=>s(Ee,{children:$===K(c.b,255)?s(d,{children:"|"}):I},$))})]})]}),g(m,{marginBottom:1,children:[s(d,{children:"Current: "}),s(d,{backgroundColor:M(),children:" "})]}),g(m,{flexDirection:"row",justifyContent:"space-between",children:[g(m,{flexDirection:"column",children:[s(d,{dimColor:!0,children:"Hex "}),r?.startsWith("diff")?s(d,{backgroundColor:M(),color:o?.colors?.text||"white",bold:!0,children:E(c.r,c.g,c.b)}):r==="inverseText"?s(d,{color:M(),backgroundColor:o?.colors?.permission,bold:!0,children:E(c.r,c.g,c.b)}):s(d,{color:M(),bold:!0,children:E(c.r,c.g,c.b)})]}),g(m,{flexDirection:"column",children:[s(d,{dimColor:!0,children:"RGB "}),r?.startsWith("diff")?s(d,{backgroundColor:M(),color:o?.colors?.text||"white",bold:!0,children:`rgb(${c.r}, ${c.g}, ${c.b})`}):r==="inverseText"?s(d,{color:M(),backgroundColor:o?.colors?.permission,bold:!0,children:`rgb(${c.r}, ${c.g}, ${c.b})`}):s(d,{color:M(),bold:!0,children:`rgb(${c.r}, ${c.g}, ${c.b})`})]}),g(m,{flexDirection:"column",children:[s(d,{dimColor:!0,children:"HSL "}),r?.startsWith("diff")?s(d,{backgroundColor:M(),color:o?.colors?.text||"white",bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):r==="inverseText"?s(d,{color:M(),backgroundColor:o?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):s(d,{color:M(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function Ze(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};const n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){const r=n[1];return{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16)}}return null}function Qe(e){const t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const o=parseInt(n[1])/255,i=parseInt(n[2])/255,a=parseInt(n[3])/255,l=Math.max(o,i,a),u=Math.min(o,i,a),c=l-u,h=(l+u)/2;let f=0;c!==0&&(f=h>.5?c/(2-l-u):c/(l+u));let v=0;return c!==0&&(l===o?v=((i-a)/c+(i<a?6:0))/6:l===i?v=((a-o)/c+2)/6:v=((o-i)/c+4)/6),{h:Math.round(v*360),s:Math.round(f*100),l:Math.round(h*100)}}const r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){const o=r[1],i=parseInt(o.substr(0,2),16)/255,a=parseInt(o.substr(2,2),16)/255,l=parseInt(o.substr(4,2),16)/255,u=Math.max(i,a,l),c=Math.min(i,a,l),h=u-c,f=(u+c)/2;let v=0;h!==0&&(v=f>.5?h/(2-u-c):h/(u+c));let b=0;return h!==0&&(u===i?b=((a-l)/h+(a<l?6:0))/6:u===a?b=((l-i)/h+2)/6:b=((i-a)/h+4)/6),{h:Math.round(b*360),s:Math.round(v*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function Mo({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:r}=be(ue),[o,i]=O(t),a=n.find(A=>A.id===o)||n[0],[l,u]=O("rgb"),[c,h]=O(0),[f,v]=O(null),[b,p]=O(null),[w,x]=O(""),[C,_]=O(""),k=Nn(A=>{r(M=>{const E=M.themes.findIndex(Y=>Y.id===o);E!==-1&&A(M.themes[E])})},[o,r]),P=A=>{if(c>=2&&gn(A)){const M=st(A),E=c-2,Y=B[E];k(X=>{X.colors[Y]=M})}};de((A,M)=>{if(f===null&&b===null){if(A.length>1&&!M.ctrl&&!M.meta){P(A);return}if(M.escape)e();else if(M.ctrl&&A==="a")u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(M.upArrow)h(E=>Math.max(0,E-1));else if(M.downArrow)h(E=>Math.min(B.length+1,E+1));else if(M.return)if(c===0)p("name"),x(a.name),_(a.name);else if(c===1)p("id"),x(a.id),_(a.id);else{const E=c-2,Y=B[E],X=a.colors[Y];v(E),x(X),_(X)}}else if(f!==null)M.ctrl&&A==="a"&&u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(b!==null)if(M.return){if(b==="id"){const E=o;i(w),r(Y=>{const X=Y.themes.findIndex(oe=>oe.id===E);X!==-1&&(Y.themes[X].id=w)})}else k(E=>{E.name=w});p(null),x(""),_("")}else M.escape?(p(null),x(""),_("")):M.backspace||M.delete?x(E=>E.slice(0,-1)):A&&x(E=>E+A)});const B=Object.keys(a.colors),j=(A,M)=>{const E=A.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!E)return A;const Y=parseInt(E[1]),X=parseInt(E[2]),oe=parseInt(E[3]);switch(M){case"hex":{const K=I=>I.toString(16).padStart(2,"0");return`#${K(Y)}${K(X)}${K(oe)}`}case"hsl":{const K=Y/255,I=X/255,$=oe/255,S=Math.max(K,I,$),N=Math.min(K,I,$),y=S-N,L=(S+N)/2;let z=0;y!==0&&(z=L>.5?y/(2-S-N):y/(S+N));let G=0;return y!==0&&(S===K?G=((I-$)/y+(I<$?6:0))/6:S===I?G=(($-K)/y+2)/6:G=((K-I)/y+4)/6),`hsl(${Math.round(G*360)}, ${Math.round(z*100)}%, ${Math.round(L*100)}%)`}case"rgb":default:return A}},q=A=>({autoAccept:"Auto-accept edits mode indicator",bashBorder:"Bash command border",claude:"Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.",claudeShimmer:"Color used for the shimmering effect on the thinking verb.",claudeBlue_FOR_SYSTEM_SPINNER:"System spinner color (blue variant)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"System spinner shimmer color (blue variant)",permission:"Permission prompt color",permissionShimmer:"Permission prompt shimmer color",planMode:"Plan mode indicator",ide:"Color used for IDE-related messages.",promptBorder:"Input prompt border color",promptBorderShimmer:"Input prompt border shimmer color",text:"Code color. Used in diffs.",inverseText:"Inverse text color. Used for the text of tabs, where the background is filled in.",inactive:"Inactive/dimmed text. Used for line numbers and less prominent text.",subtle:"Subtle text. Used for help text and secondary information.",suggestion:"Suggestion text color. Used for suggestions for theme names and various other things.",remember:"Remember/note color. Used for various text relating to memories.",background:"Background color for certain UI elements",success:"Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).",error:"Error indicator",warning:"Warning indicator",warningShimmer:"Warning shimmer color",diffAdded:"Added diff background",diffRemoved:"Removed diff background",diffAddedDimmed:"Added diff background (dimmed)",diffRemovedDimmed:"Removed diff background (dimmed)",diffAddedWord:"Added word highlight",diffRemovedWord:"Removed word highlight",diffAddedWordDimmed:"Added word highlight (dimmed)",diffRemovedWordDimmed:"Removed word highlight (dimmed)",red_FOR_SUBAGENTS_ONLY:"Red color for sub agents",blue_FOR_SUBAGENTS_ONLY:"Blue color for sub agents",green_FOR_SUBAGENTS_ONLY:"Green color for sub agents",yellow_FOR_SUBAGENTS_ONLY:"Yellow color for sub agents",purple_FOR_SUBAGENTS_ONLY:"Purple color for sub agents",orange_FOR_SUBAGENTS_ONLY:"Orange color for sub agents",pink_FOR_SUBAGENTS_ONLY:"Pink color for sub agents",cyan_FOR_SUBAGENTS_ONLY:"Cyan color for sub agents",professionalBlue:"Professional blue color for business contexts?",rainbow_red:'"ultrathink" rainbow - red',rainbow_orange:'"ultrathink" rainbow - orange',rainbow_yellow:'"ultrathink" rainbow - yellow',rainbow_green:'"ultrathink" rainbow - green',rainbow_blue:'"ultrathink" rainbow - blue',rainbow_indigo:'"ultrathink" rainbow - indigo',rainbow_violet:'"ultrathink" rainbow - violet',rainbow_red_shimmer:'"ultrathink" rainbow (shimmer) - red',rainbow_orange_shimmer:'"ultrathink" rainbow (shimmer) - orange',rainbow_yellow_shimmer:'"ultrathink" rainbow (shimmer) - yellow',rainbow_green_shimmer:'"ultrathink" rainbow (shimmer) - green',rainbow_blue_shimmer:'"ultrathink" rainbow (shimmer) - blue',rainbow_indigo_shimmer:'"ultrathink" rainbow (shimmer) - indigo',rainbow_violet_shimmer:'"ultrathink" rainbow (shimmer) - violet',clawd_body:'"Clawd" character body color',clawd_background:'"Clawd" character background color',userMessageBackground:"Background color for user messages",bashMessageBackgroundColor:"Background color for bash command output",memoryBackgroundColor:"Background color for memory/context information",rate_limit_fill:"Rate limit indicator fill color",rate_limit_empty:"Rate limit indicator empty/background color"})[A]||"",U=Math.max(...B.map(A=>A.length));return g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{children:g(pe,{children:["Editing theme “",a.name,"” (",a.id,")"]})}),f===null&&b===null?g(me,{children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(d,{dimColor:!0,children:"enter to edit theme name, id, or color"}),s(d,{dimColor:!0,children:"ctrl+a to toggle rgb, hex, hsl"}),s(d,{dimColor:!0,children:"paste color from clipboard (when on color)"}),s(d,{dimColor:!0,children:"esc to go back"})]}),c<2?g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:"yellow",flexDirection:"column",paddingLeft:1,children:[s(d,{bold:!0,children:c===0?"Theme Name":"Theme ID"}),s(d,{children:c===0?"The display name for this theme":"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):g(m,{marginBottom:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:a.colors[B[c-2]],flexDirection:"column",paddingLeft:1,children:[s(Xe,{colorKey:B[c-2],theme:a,bold:!0}),s(d,{children:q(B[c-2])})]}),g(m,{flexDirection:"column",children:[g(m,{children:[s(d,{color:c===0?"yellow":"white",children:c===0?"❯ ":" "}),s(d,{bold:!0,children:"Name: "}),s(d,{children:a.name})]}),g(m,{marginBottom:1,children:[s(d,{color:c===1?"yellow":"white",children:c===1?"❯ ":" "}),s(d,{bold:!0,children:"ID: "}),s(d,{children:a.id})]}),(()=>{if(c<2){const K=B.slice(0,20);return g(me,{children:[K.map((I,$)=>{const S=$+2;return g(m,{children:[s(d,{color:c===S?"yellow":"white",children:c===S?"❯ ":" "}),s(m,{width:U+2,children:s(d,{children:s(Xe,{colorKey:I,theme:a,bold:!0})})}),s(F,{color:a.colors[I],children:j(a.colors[I],l)})]},I)}),B.length>20&&g(d,{color:"gray",dimColor:!0,children:[" ","↓ ",B.length-20," more below"]})]})}const M=c-2,E=Math.max(0,M-Math.floor(20/2)),Y=Math.min(B.length,E+20),X=Math.max(0,Y-20),oe=B.slice(X,Y);return g(me,{children:[X>0&&g(d,{color:"gray",dimColor:!0,children:[" ","↑ ",X," more above"]}),oe.map((K,I)=>{const S=X+I+2;return g(m,{children:[s(d,{color:c===S?"yellow":"white",children:c===S?"❯ ":" "}),s(m,{width:U+2,children:s(d,{children:s(Xe,{colorKey:K,theme:a,bold:!0})})}),s(F,{color:a.colors[K],children:j(a.colors[K],l)})]},K)}),Y<B.length&&g(d,{color:"gray",dimColor:!0,children:[" ","↓ ",B.length-Y," more below"]})]})})()]})]}):b?g(m,{flexDirection:"column",marginTop:1,children:[g(d,{children:["Editing ",b==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(d,{children:w})}),s(d,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(at,{initialValue:C,colorKey:B[f],theme:a,onColorChange:A=>{x(A),k(M=>{M.colors[B[f]]=A})},onExit:()=>{k(A=>{A.colors[B[f]]=w}),v(null),x(""),_("")}})]}),s(m,{width:"50%",children:s(lt,{theme:a})})]})}function No(e){return e.map(t=>`${t.name} (${t.id})`)}function Bo({onBack:e}){const{settings:{themes:t},updateSettings:n}=be(ue),[r,o]=O(0),[i,a]=O(null),[l,u]=O(!0),c=()=>{const w={colors:{...(t[0]||Z.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(x=>{x.themes.push(w)}),a(w.id),u(!1)},h=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(x=>x.id!==p)}),r>=t.length-1&&o(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...Z.themes]}),o(0)};if(de((p,w)=>{if(w.escape)e();else if(w.upArrow)o(x=>Math.max(0,x-1));else if(w.downArrow)o(x=>Math.min(t.length-1,x+1));else if(w.return){const x=t[r];x&&(a(x.id),u(!1))}else if(p==="n")c();else if(p==="d"){const x=t[r];x&&h(x.id)}else w.ctrl&&p==="r"&&f()},{isActive:l}),i)return s(Mo,{themeId:i,onBack:()=>{a(null),u(!0)}});const v=No(t),b=t.find(p=>v[r]?.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(d,{dimColor:!0,children:"n to create a new theme"}),s(d,{dimColor:!0,children:"esc to go back"})]}),s(d,{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(d,{dimColor:!0,children:"n to create a new theme"}),s(d,{dimColor:!0,children:"d to delete a theme"}),s(d,{dimColor:!0,children:"ctrl+r to delete all themes and restore built-in"}),s(d,{dimColor:!0,children:"enter to edit theme"}),s(d,{dimColor:!0,children:"esc to go back"})]}),s(m,{flexDirection:"column",children:v.map((p,w)=>g(d,{color:r===w?"yellow":void 0,children:[r===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(lt,{theme:b})})]})}function Oo({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:r},updateSettings:o}=be(ue),i=["format","verbs"],[a,l]=O(0),u=i[a],[c,h]=O(0),[f,v]=O(!1),[b,p]=O(""),[w,x]=O(!1),[C,_]=O(!1),[k,P]=O(t),B=hn(),q=(r.find(A=>A.id===B)||r.find(A=>A.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((A,M)=>{if(C){M.return?(o(E=>{E.thinkingVerbs.format=k}),_(!1)):M.escape?(P(t),_(!1)):M.backspace||M.delete?P(E=>E.slice(0,-1)):A&&P(E=>E+A);return}if(f||w){M.return&&b.trim()?(w?(o(E=>{E.thinkingVerbs.verbs.push(b.trim())}),x(!1)):(o(E=>{E.thinkingVerbs.verbs[c]=b.trim()}),v(!1)),p("")):M.escape?(p(""),v(!1),x(!1)):M.backspace||M.delete?p(E=>E.slice(0,-1)):A&&p(E=>E+A);return}M.escape?e():M.return?u==="format"&&(P(t),_(!0)):M.tab?M.shift?l(E=>E===0?i.length-1:E-1):l(E=>E===i.length-1?0:E+1):M.upArrow?u==="verbs"&&n.length>0&&h(E=>E>0?E-1:n.length-1):M.downArrow?u==="verbs"&&n.length>0&&h(E=>E<n.length-1?E+1:0):A==="e"&&u==="verbs"?n.length>0&&(p(n[c]),v(!0)):A==="d"&&u==="verbs"?n.length>1&&(o(E=>{E.thinkingVerbs.verbs=E.thinkingVerbs.verbs.filter((Y,X)=>X!==c)}),c>=n.length-1&&h(Math.max(0,n.length-2))):A==="n"&&u==="verbs"?(x(!0),p("")):M.ctrl&&A==="r"&&u==="verbs"&&(o(E=>{E.thinkingVerbs.verbs=[...Z.thinkingVerbs.verbs]}),h(0))});const U=50;return g(m,{children:[g(m,{flexDirection:"column",width:`${100-U}%`,children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(pe,{children:"Thinking Verbs"}),g(m,{flexDirection:"column",children:[s(d,{dimColor:!0,children:u==="format"?"enter to edit format":"changes auto-saved"}),s(d,{dimColor:!0,children:"esc to go back"}),s(d,{dimColor:!0,children:"tab to switch sections"})]})]}),s(m,{marginBottom:1,children:s(d,{dimColor:!0,children:"Customize the verbs shown during generation and their format."})}),g(m,{flexDirection:"column",children:[g(d,{children:[s(d,{color:u==="format"?"yellow":void 0,children:u==="format"?"❯ ":" "}),s(d,{bold:!0,color:u==="format"?"yellow":void 0,children:"Format"})]}),u==="format"&&(C?g(d,{dimColor:!0,children:[" ","enter to save"]}):g(d,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:C?"yellow":"gray",children:s(d,{children:C?k:t})})}),s(m,{children:g(d,{children:[s(d,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(d,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:g(d,{dimColor:!0,children:[" ","e to edit · d to delete · n to add new · ctrl+r to reset"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const M=Math.max(0,c-Math.floor(4)),E=Math.min(n.length,M+8),Y=Math.max(0,E-8),X=n.slice(Y,E);return g(me,{children:[Y>0&&g(d,{color:"gray",dimColor:!0,children:[" ","↑ ",Y," more above"]}),X.map((oe,K)=>{const I=Y+K;return g(d,{color:u==="verbs"&&I===c?"cyan":void 0,children:[u==="verbs"&&I===c?"❯ ":" ",oe]},I)}),E<n.length&&g(d,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-E," more below"]})]})})(),w&&g(m,{alignItems:"center",children:[s(d,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(d,{children:b})})]}),f&&g(m,{marginTop:1,alignItems:"center",children:[s(d,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(d,{children:b})})]})]})})]}),g(m,{width:`${U}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(d,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:g(d,{children:[g(d,{color:q,children:["✻ ",t.replace(/\{\}/g,n[c])," "]}),s(d,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:Z.thinkingStyle.phases,reverseMirror:Z.thinkingStyle.reverseMirror},{name:"Basic",phases:["|","/","-","\\"],reverseMirror:!1},{name:"Braille",phases:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],reverseMirror:!1},{name:"Circle",phases:["◐","◓","◑","◒"],reverseMirror:!1},{name:"Wave",phases:["▁","▃","▄","▅","▆","▇","█"],reverseMirror:!0},{name:"Glow",phases:["░","▒","▓","█"],reverseMirror:!0},{name:"Partial block",phases:["▏","▎","▍","▌","▋","▊","▉","█"],reverseMirror:!0},{name:"Clock",phases:["🕛","🕐","🕑","🕒","🕓","🕔","🕕","🕖","🕗","🕘","🕙","🕚"],reverseMirror:!1},{name:"Globe",phases:["🌍","🌎","🌏"],reverseMirror:!1},{name:"Arc",phases:["◜","◠","◝","◞","◡","◟"],reverseMirror:!1},{name:"Triangle",phases:["◤","◥","◢","◣"],reverseMirror:!1},{name:"Bouncing",phases:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],reverseMirror:!1},{name:"Dots",phases:[".","..","..."],reverseMirror:!1},{name:"Colors",phases:["🔴","🟠","🟡","🟢","🔵","🟣"],reverseMirror:!1}];function Ao({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:r},themes:o},updateSettings:i}=be(ue),a=["reverseMirror","updateInterval","phases","presets"],[l,u]=O(0),c=a[l],[h,f]=O(0),[v,b]=O(0),[p,w]=O(!1),[x,C]=O(""),[_,k]=O(!1),[P,B]=O(!1),[j,q]=O(n.toString()),[U,A]=O(0),M=hn(),Y=(o.find(S=>S.id===M)||o.find(S=>S.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const S=r?[...t,...[...t].reverse().slice(1,-1)]:t,N=setInterval(()=>{A(y=>(y+1)%S.length)},n);return()=>clearInterval(N)}},[t,n,r]),de((S,N)=>{if(P){if(N.return){const y=parseInt(j);!isNaN(y)&&y>0&&i(L=>{L.thinkingStyle.updateInterval=y}),B(!1)}else N.escape?(q(n.toString()),B(!1)):N.backspace||N.delete?q(y=>y.slice(0,-1)):S&&S.match(/^[0-9]$/)&&q(y=>y+S);return}if(p||_){if(N.return&&x.length){const y=_?[...t,x]:t.map((L,z)=>z===h?x:L);i(L=>{L.thinkingStyle.phases=y}),w(!1),C("")}else N.escape?(C(""),w(!1),k(!1)):N.backspace||N.delete?C(y=>y.slice(0,-1)):S&&C(y=>y+S);return}if(N.escape)e();else if(N.return)if(c==="updateInterval")q(n.toString()),B(!0);else if(c==="presets"){const y=_e[v];i(L=>{L.thinkingStyle.phases=[...y.phases],L.thinkingStyle.reverseMirror=y.reverseMirror})}else c==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(N.tab)N.shift?u(y=>y===0?a.length-1:y-1):u(y=>y===a.length-1?0:y+1);else if(N.upArrow)c==="phases"&&t.length>0?f(y=>y>0?y-1:t.length-1):c==="presets"&&b(y=>y>0?y-1:_e.length-1);else if(N.downArrow)c==="phases"&&t.length>0?f(y=>y<t.length-1?y+1:0):c==="presets"&&b(y=>y<_e.length-1?y+1:0);else if(S===" ")c==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(S==="e"&&c==="phases")t.length>0&&(C(t[h]),w(!0));else if(S==="a"&&c==="phases")k(!0),C("");else if(S==="d"&&c==="phases")t.length>1&&(i(y=>{y.thinkingStyle.phases=t.filter((L,z)=>z!==h)}),h>=t.length&&f(Math.max(0,t.length-1)));else if(S==="w"&&c==="phases"){if(h>0){const y=[...t];[y[h-1],y[h]]=[y[h],y[h-1]],i(L=>{L.thinkingStyle.phases=y}),f(L=>L-1)}}else if(S==="s"&&c==="phases"){if(h<t.length-1){const y=[...t];[y[h],y[h+1]]=[y[h+1],y[h]],i(L=>{L.thinkingStyle.phases=y}),f(L=>L+1)}}else N.ctrl&&S==="r"&&(i(y=>{y.thinkingStyle=Z.thinkingStyle}),f(0),b(0))});const X=r?"●":"○",oe=50,I=r?[...t,...[...t].reverse().slice(1,-1)]:t,$=I.length>0?I[U]:"·";return s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[g(m,{flexDirection:"row",width:"100%",children:[g(m,{marginBottom:1,flexDirection:"column",width:`${100-oe}%`,children:[s(pe,{children:"Thinking style"}),g(m,{flexDirection:"column",children:[g(d,{dimColor:!0,children:["enter to"," ",c==="updateInterval"?"edit interval":c==="presets"?"apply preset":"save"]}),s(d,{dimColor:!0,children:"esc to go back"}),s(d,{dimColor:!0,children:"tab to switch sections"})]})]}),g(m,{width:`${oe}%`,flexDirection:"column",children:[s(m,{children:s(d,{bold:!0,children:"Preview"})}),g(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:($?.length??0)+1,children:s(d,{color:Y,children:$})}),g(d,{children:[s(d,{color:Y,children:"Thinking… "}),s(d,{children:"(esc to interrupt)"})]})]})]})]}),g(m,{flexDirection:"row",gap:4,children:[g(m,{flexDirection:"column",children:[g(d,{children:[s(d,{color:c==="reverseMirror"?"yellow":void 0,children:c==="reverseMirror"?"❯ ":" "}),s(d,{bold:!0,color:c==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),c==="reverseMirror"&&g(d,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:g(d,{children:[X," ",r?"Enabled":"Disabled"]})})]}),g(m,{flexDirection:"column",children:[g(d,{children:[s(d,{color:c==="updateInterval"?"yellow":void 0,children:c==="updateInterval"?"❯ ":" "}),s(d,{bold:!0,color:c==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),c==="updateInterval"&&(P?g(d,{dimColor:!0,children:[" ","enter to save"]}):g(d,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:P?"yellow":"gray",children:s(d,{children:P?j:n})})})]})]}),s(m,{children:g(d,{children:[s(d,{color:c==="phases"?"yellow":void 0,children:c==="phases"?"❯ ":" "}),s(d,{bold:!0,color:c==="phases"?"yellow":void 0,children:"Phases"})]})}),c==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:g(d,{dimColor:!0,children:[" ","[e]dit"," ","[a]dd"," ","[d]elete"," ","[w]move up"," ","[s]move down"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const N=Math.max(0,h-Math.floor(4)),y=Math.min(t.length,N+8),L=Math.max(0,y-8),z=t.slice(L,y);return g(me,{children:[L>0&&g(d,{color:"gray",dimColor:!0,children:[" ","↑ ",L," more above"]}),z.map((G,ne)=>{const se=L+ne;return g(d,{color:c==="phases"&&se===h?"cyan":void 0,children:[c==="phases"&&se===h?"❯ ":" ",G]},se)}),y<t.length&&g(d,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-y," more below"]})]})})(),_&&g(m,{children:[s(d,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(d,{children:x})})]}),p&&g(m,{marginTop:1,children:[s(d,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(d,{children:x})})]})]})}),s(m,{children:g(d,{children:[s(d,{color:c==="presets"?"yellow":void 0,children:c==="presets"?"❯ ":" "}),s(d,{bold:!0,color:c==="presets"?"yellow":void 0,children:"Presets"})]})}),c==="presets"&&g(d,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const N=Math.max(0,v-Math.floor(4)),y=Math.min(_e.length,N+8),L=Math.max(0,y-8),z=_e.slice(L,y);return g(me,{children:[L>0&&g(d,{color:"gray",dimColor:!0,children:[" ","↑ ",L," more above"]}),z.map((G,ne)=>{const se=L+ne;return g(d,{color:c==="presets"&&se===v?"cyan":void 0,children:[c==="presets"&&se===v?"❯ ":" ",G.name," ",G.phases.join("")]},se)}),y<_e.length&&g(d,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-y," more below"]})]})})()})}),s(m,{marginTop:1,children:s(d,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const Le=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function Po({onBack:e}){const{settings:t,updateSettings:n}=be(ue),[r,o]=O("prefix"),[i,a]=O(0),[l,u]=O(!1),[c,h]=O(()=>t.userMessageDisplay.prefix.format),[f,v]=O(0),[b,p]=O(()=>[...t.userMessageDisplay.prefix.styling]),[w,x]=O(()=>t.userMessageDisplay.prefix.foreground_color),[C,_]=O(()=>t.userMessageDisplay.prefix.background_color),[k,P]=O(0),[B,j]=O(0),[q,U]=O(()=>[...t.userMessageDisplay.message.styling]),[A,M]=O(()=>t.userMessageDisplay.message.foreground_color),[E,Y]=O(()=>t.userMessageDisplay.message.background_color),[X,oe]=O(null),[K,I]=O(""),$=hn(),S=t.themes?.find(H=>H.id===$)||t.themes?.[0],N=["format","styling","foreground","background"],y=["styling","foreground","background"],L=N[i],z=y[k],G=(H,R)=>{n(D=>{const ee=H==="prefix"?D.userMessageDisplay.prefix:D.userMessageDisplay.message;R(ee)})},ne=H=>{n(R=>{H==="prefix"?R.userMessageDisplay.prefix={...Z.userMessageDisplay.prefix}:R.userMessageDisplay.message={...Z.userMessageDisplay.message}}),H==="prefix"?(h(Z.userMessageDisplay.prefix.format),p([...Z.userMessageDisplay.prefix.styling]),x(Z.userMessageDisplay.prefix.foreground_color),_(Z.userMessageDisplay.prefix.background_color)):(U([...Z.userMessageDisplay.message.styling]),M(Z.userMessageDisplay.message.foreground_color),Y(Z.userMessageDisplay.message.background_color))};xe(()=>{const H=t.userMessageDisplay.prefix;h(H.format),p([...H.styling]),x(H.foreground_color),_(H.background_color);const R=t.userMessageDisplay.message;U([...R.styling]),M(R.foreground_color),Y(R.background_color)},[]),de((H,R)=>{if(l){if(R.return)G("prefix",D=>{D.format=c}),u(!1);else if(R.escape){const D=t.userMessageDisplay.prefix;h(D.format),u(!1)}else R.backspace||R.delete?h(D=>D.slice(0,-1)):H&&h(D=>D+H);return}if(X===null){if(R.escape)e();else if(R.ctrl&&H==="r")ne(r);else if(R.leftArrow||R.rightArrow)o(D=>D==="prefix"?"message":"prefix");else if(R.tab)r==="prefix"?R.shift?a(D=>D===0?N.length-1:D-1):a(D=>D===N.length-1?0:D+1):R.shift?P(D=>D===0?y.length-1:D-1):P(D=>D===y.length-1?0:D+1);else if(R.return)r==="prefix"?L==="format"?u(!0):L==="foreground"?(I(w),oe({column:"prefix",type:"foreground"})):L==="background"&&(I(C),oe({column:"prefix",type:"background"})):z==="foreground"?(I(A),oe({column:"message",type:"foreground"})):z==="background"&&(I(E),oe({column:"message",type:"background"}));else if(R.upArrow)r==="prefix"&&L==="styling"?v(D=>Math.max(0,D-1)):r==="message"&&z==="styling"&&j(D=>Math.max(0,D-1));else if(R.downArrow)r==="prefix"&&L==="styling"?v(D=>Math.min(Le.length-1,D+1)):r==="message"&&z==="styling"&&j(D=>Math.min(Le.length-1,D+1));else if(H===" "){if(r==="prefix"&&L==="styling"){const D=Le[f].value,ee=b.indexOf(D)>=0?b.filter(W=>W!==D):[...b,D];p(ee),G("prefix",W=>{W.styling=[...ee]})}else if(r==="message"&&z==="styling"){const D=Le[B].value,ee=q.indexOf(D)>=0?q.filter(W=>W!==D):[...q,D];U(ee),G("message",W=>{W.styling=[...ee]})}}}});const se=(H,R,D=!0)=>{const ee=D?R==="prefix"?b:q:[],W=D?R==="prefix"?w:A:"rgb(255,255,255)",Oe=D?R==="prefix"?C:E:"rgb(0,0,0)",Ae=W==="rgb(0,0,0)"&&Oe==="rgb(0,0,0)",Ue=ee.length>0;return Ae&&!Ue?s(d,{children:H}):s(d,{bold:ee.includes("bold"),italic:ee.includes("italic"),underline:ee.includes("underline"),strikethrough:ee.includes("strikethrough"),inverse:ee.includes("inverse"),color:Ae?void 0:W,backgroundColor:Ae?void 0:Oe,children:H})},$e=(H=!0)=>g(d,{children:[c&&g(me,{children:[se(c,"prefix",H)," "]}),se("list the dir","message",H)]}),we=H=>{const R=r===H,W=(H==="prefix"?N:y)[H==="prefix"?i:k],Oe=H==="prefix"?f:B,Ae=H==="prefix"?b:q,Ue=H==="prefix"?w:A,mn=H==="prefix"?C:E;return g(m,{flexDirection:"column",width:"45%",borderStyle:R?"round":"single",borderColor:R?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:g(d,{bold:!0,color:R?"yellow":void 0,children:[H.charAt(0).toUpperCase()+H.slice(1)," ","Configuration"]})}),H==="prefix"&&g(me,{children:[s(m,{children:g(d,{color:R&&W==="format"?"yellow":void 0,bold:R&&W==="format",children:[R&&W==="format"?"❯ ":" ","Prefix Text"]})}),R&&W==="format"&&s(m,{marginLeft:2,children:s(d,{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(d,{children:c})})})]}),s(m,{children:g(d,{color:R&&W==="styling"?"yellow":void 0,bold:R&&W==="styling",children:[R&&W==="styling"?"❯ ":" ","Styling"]})}),R&&W==="styling"&&s(m,{marginLeft:2,children:s(d,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:Le.map((qe,pn)=>s(m,{children:g(d,{color:R&&W==="styling"&&Oe===pn?"cyan":void 0,children:[R&&W==="styling"&&Oe===pn?"❯ ":" ",Ae.includes(qe.value)?"●":"○"," ",qe.label]})},qe.value))}),s(m,{children:g(d,{color:R&&W==="foreground"?"yellow":void 0,bold:R&&W==="foreground",children:[R&&W==="foreground"?"❯ ":" ","Foreground color"]})}),R&&W==="foreground"&&s(m,{marginLeft:2,children:s(d,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,marginBottom:1,children:s(d,{color:Ue,children:Ue})}),s(m,{children:g(d,{color:R&&W==="background"?"yellow":void 0,bold:R&&W==="background",children:[R&&W==="background"?"❯ ":" ","Background color"]})}),R&&W==="background"&&s(m,{marginLeft:2,children:s(d,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(d,{backgroundColor:mn,children:mn})})]})};if(X){const{column:H,type:R}=X;return s(at,{initialValue:K,theme:S,onColorChange:D=>{H==="prefix"?R==="foreground"?(x(D),G("prefix",ee=>{ee.foreground_color=D})):(_(D),G("prefix",ee=>{ee.background_color=D})):R==="foreground"?(M(D),G("message",ee=>{ee.foreground_color=D})):(Y(D),G("message",ee=>{ee.background_color=D}))},onExit:()=>{oe(null),I("")}})}return g(m,{flexDirection:"column",children:[s(pe,{children:"Customize how user messages are displayed"}),g(m,{flexDirection:"column",marginBottom:1,children:[s(d,{dimColor:!0,children:"left/right arrows to switch columns · tab to navigate options"}),s(d,{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(d,{bold:!0,children:"Preview"})}),g(m,{flexDirection:"row",gap:2,children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(d,{underline:!0,children:"Before (Claude Code default):"})}),s(m,{marginLeft:1,marginTop:1,children:g(d,{children:[s(d,{color:S?.colors?.inactive||"#888888",children:"●"}),s(d,{children:" The directory "}),s(d,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(d,{children:" contains "}),s(d,{bold:!0,children:"123"}),s(d,{children:" files."})]})})]}),g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(d,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,children:$e(!0)}),s(m,{marginLeft:1,marginTop:1,children:g(d,{children:[s(d,{color:S?.colors?.inactive||"#888888",children:"●"}),s(d,{children:" The directory "}),s(d,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(d,{children:" contains "}),s(d,{bold:!0,children:"123"}),s(d,{children:" files."})]})})]})]})]})})]})}function Lo({onSubmit:e}){const{settings:t,updateSettings:n}=be(ue),[r,o]=O(0),i=()=>{n(b=>{b.inputBox||(b.inputBox={removeBorder:!1}),b.inputBox.removeBorder=!b.inputBox.removeBorder})},a=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showTweakccVersion=!b.misc.showTweakccVersion})},l=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showPatchesApplied=!b.misc.showPatchesApplied})},u=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.expandThinkingBlocks=!b.misc.expandThinkingBlocks})};de((b,p)=>{p.return||p.escape?e():p.upArrow?o(w=>Math.max(0,w-1)):p.downArrow?o(w=>Math.min(3,w+1)):b===" "&&(r===0?i():r===1?a():r===2?l():r===3&&u())});const c=t.inputBox?.removeBorder?"☑":"☐",h=t.misc?.showTweakccVersion?"☑":"☐",f=t.misc?.showPatchesApplied?"☑":"☐",v=t.misc?.expandThinkingBlocks?"☑":"☐";return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(pe,{children:"Miscellaneous Settings"})}),s(m,{marginBottom:1,children:s(d,{color:"gray",children:s(d,{dimColor:!0,children:"Various tweaks and customizations. Press space to toggle settings, enter to go back."})})}),s(m,{children:g(d,{children:[s(d,{color:r===0?"cyan":void 0,children:r===0?"❯ ":" "}),s(d,{bold:!0,color:r===0?"cyan":void 0,children:"Remove input box border"})]})}),s(m,{flexDirection:"column",children:g(d,{dimColor:!0,children:[" ","Removes the rounded border around the input box for a cleaner look."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(d,{children:[c," ",t.inputBox?.removeBorder?"Enabled":"Disabled"]})}),s(m,{children:g(d,{children:[s(d,{color:r===1?"cyan":void 0,children:r===1?"❯ ":" "}),s(d,{bold:!0,color:r===1?"cyan":void 0,children:"Show tweakcc version at startup"})]})}),s(m,{flexDirection:"column",children:g(d,{dimColor:!0,children:[" ",'Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(d,{children:[h," ",t.misc?.showTweakccVersion?"Enabled":"Disabled"]})}),s(m,{children:g(d,{children:[s(d,{color:r===2?"cyan":void 0,children:r===2?"❯ ":" "}),s(d,{bold:!0,color:r===2?"cyan":void 0,children:"Show patches applied indicator at startup"})]})}),s(m,{flexDirection:"column",children:g(d,{dimColor:!0,children:[" ",'Shows the green "tweakcc patches are applied" indicator when starting Claude Code.']})}),s(m,{marginLeft:4,marginBottom:1,children:g(d,{children:[f," ",t.misc?.showPatchesApplied?"Enabled":"Disabled"]})}),s(m,{children:g(d,{children:[s(d,{color:r===3?"cyan":void 0,children:r===3?"❯ ":" "}),s(d,{bold:!0,color:r===3?"cyan":void 0,children:"Expand thinking blocks"})]})}),s(m,{flexDirection:"column",children:g(d,{dimColor:!0,children:[" ","Makes thinking blocks always expanded by default instead of collapsed."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(d,{children:[v," ",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 Do({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:r}=be(ue),o=n.toolsets[e],[i,a]=O(o?.name||"New Toolset"),[l,u]=O(o?.allowedTools||[]),[c,h]=O(!1),[f,v]=O(0);xe(()=>{o&&r(C=>{C.toolsets[e].name=i,C.toolsets[e].allowedTools=l})},[i,l]);const b=C=>l==="*"?!0:l.includes(C),p=C=>{C==="All"?u("*"):C==="None"?u([]):l==="*"?u(He.filter(_=>_!==C)):l.includes(C)?u(l.filter(_=>_!==C)):u([...l,C])};if(de((C,_)=>{if(c){_.return?h(!1):_.escape?(a(o?.name||"New Toolset"),h(!1)):_.backspace||_.delete?a(k=>k.slice(0,-1)):C&&C.length===1&&a(k=>k+C);return}if(_.escape)t();else if(_.upArrow)v(k=>Math.max(0,k-1));else if(_.downArrow)v(k=>Math.min(He.length+1,k+1));else if(C===" "||_.return)if(f===0)p("All");else if(f===1)p("None");else{const k=He[f-2];k&&p(k)}else C==="n"&&h(!0)}),!o)return s(m,{flexDirection:"column",children:s(d,{color:"red",children:"Toolset not found"})});const w=l==="*",x=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(d,{dimColor:!0,children:"n to edit name · space/enter to toggle · esc to go back"})}),g(m,{marginBottom:1,flexDirection:"column",children:[s(d,{bold:!0,children:"Name:"}),s(m,{marginLeft:2,children:s(m,{borderStyle:"round",borderColor:c?"yellow":"gray",children:s(d,{children:i})})}),c&&s(m,{marginLeft:2,children:s(d,{dimColor:!0,children:"enter to save · esc to cancel"})})]}),g(m,{marginBottom:1,flexDirection:"column",children:[s(d,{bold:!0,children:"Allowed Tools:"}),s(m,{marginLeft:2,children:g(d,{color:f===0?"cyan":void 0,children:[f===0?"❯ ":" ",w?"●":"○"," All"]})}),s(m,{marginLeft:2,children:g(d,{color:f===1?"cyan":void 0,children:[f===1?"❯ ":" ",x?"●":"○"," None"]})}),He.map((C,_)=>{const k=_+2;return s(m,{marginLeft:2,children:g(d,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(C)?"◉":"○"," ",C]})},C)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(d,{bold:!0,children:"Summary:"}),g(d,{children:["Name: ",s(d,{color:"cyan",children:i})]}),g(d,{children:["Tools:"," ",l==="*"?s(d,{color:"green",children:"All tools (*)"}):l.length===0?s(d,{color:"red",children:"No tools ([])"}):g(d,{color:"yellow",children:[l.length," selected"]})]})]})})]})}function Ro({onBack:e}){const{settings:{toolsets:t,defaultToolset:n},updateSettings:r}=be(ue),[o,i]=O(0),[a,l]=O(null),[u,c]=O(!0),h=()=>{const p={name:"New Toolset",allowedTools:[]};r(w=>{w.toolsets.push(p)}),l(t.length),c(!1)},f=p=>{const w=t[p];r(x=>{x.toolsets.splice(p,1),x.defaultToolset===w.name&&(x.defaultToolset=null)}),o>=t.length-1&&i(Math.max(0,t.length-2))},v=p=>{const w=t[p];r(x=>{x.defaultToolset=w.name})};if(de((p,w)=>{w.escape?e():w.upArrow?i(x=>Math.max(0,x-1)):w.downArrow?i(x=>Math.min(t.length-1,x+1)):w.return&&t.length>0?(l(o),c(!1)):p==="n"?h():p==="d"&&t.length>0?f(o):p==="s"&&t.length>0&&v(o)},{isActive:u}),a!==null)return s(Do,{toolsetIndex:a,onBack:()=>{l(null),c(!0)}});const b=p=>p.allowedTools==="*"?"All tools":p.allowedTools.length===0?"No tools":`${p.allowedTools.length} tool${p.allowedTools.length===1?"":"s"}`;return g(m,{flexDirection:"column",children:[s(pe,{children:"Toolsets"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(d,{dimColor:!0,children:"n to create a new toolset"}),t.length>0&&s(d,{dimColor:!0,children:"s to set as default toolset"}),t.length>0&&s(d,{dimColor:!0,children:"d to delete a toolset"}),t.length>0&&s(d,{dimColor:!0,children:"enter to edit toolset"}),s(d,{dimColor:!0,children:"esc to go back"})]}),t.length===0?s(d,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:t.map((p,w)=>{const x=p.name===n,C=o===w;return g(d,{color:C?"yellow":void 0,bold:x,children:[C?"❯ ":" ",p.name,x&&" [DEFAULT]"," (",b(p),")"]},w)})})]})}const ue=ut({settings:Z,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function Fo({startupCheckInfo:e}){const[t,n]=O({settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await an())})()},[]);const r=Nn(h=>{const f=JSON.parse(JSON.stringify(t.settings));h(f),n(v=>({...v,settings:f,changesApplied:!1})),je(v=>{v.settings=f,v.changesApplied=!1})},[t.settings]),[o,i]=O(null),[a,l]=O(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(l({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
641
+ `;l=l.slice(0,o)+u+l.slice(o),V(e,l,u,o,o);const d=r+u.length,h=`||tweakccSummaries.has(${i}.uuid)`,f=l.slice(0,d)+h+l.slice(d);return V(l,f,h,d,d),f},go=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 r='description:"Rename the current conversation",isEnabled:()=>!1,',o='description:"Rename the current conversation",isEnabled:()=>!0,',i=e.replace(r,o);return i===e?(console.error("patch: conversationTitle: enableRenameConversationCommand: replacement failed"),null):(V(e,i,o,n.index,n.index+63),i)},fo=e=>{let t=e;if(t=io(t),!t)return console.error("patch: conversationTitle: step 1 failed (writeTitleSlashCommand)"),null;if(t=lo(t),!t)return console.error("patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)"),null;if(t=co(t),!t)return console.error("patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)"),null;if(t=ho(t),!t)return console.error("patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)"),null;const n=go(t);return n?t=n:console.log("patch: conversationTitle: step 5 failed (enableRenameConversationCommand)"),t},V=(e,t,n,r,o)=>{if(!T())return;const i=Math.max(0,r-20),a=Math.min(e.length,o+20),l=Math.min(t.length,r+n.length+20),u=e.slice(i,r),d=e.slice(r,o),h=e.slice(o,a),f=t.slice(i,r),v=t.slice(r,r+n.length),b=t.slice(r+n.length,l);d!==v&&(console.log(`
642
+ --- Diff ---`),console.log("OLD:",u+`\x1B[31m${d}\x1B[0m`+h),console.log("NEW:",f+`\x1B[32m${v}\x1B[0m`+b),console.log(`--- End Diff ---
643
+ `))},fe=e=>e.replace(/\$/g,"\\$"),dn=e=>{const t=/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g,n=Array.from(e.matchAll(t)),r={};for(const a of n){const l=a[1];r[l]=(r[l]||0)+1}let o,i=0;for(const[a,l]of Object.entries(r))l>i&&(i=l,o=a);return o},mo=e=>{const t=e.slice(0,1e3),n=/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/,r=t.match(n);if(!r){console.log("patch: getModuleLoaderFunction: failed to find module loader function");return}return r[1]},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]},po=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)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let he=null,ke=null;const Je=e=>{if(he!=null)return he;const t=mo(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 r=new RegExp(`\\b([$\\w]+)=${fe(t)}\\(${fe(n)}\\(\\),1\\)`),o=e.match(r);if(o)return he=o[1],he;const i=po(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},bo=e=>{const t=/import\{createRequire as ([$\w]+)\}from"node:module";/,n=e.match(t);if(!n)return;const r=n[1],o=new RegExp(`var ([$\\w]+)=${fe(r)}\\(import\\.meta\\.url\\)`),i=e.match(o);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${r})`);return}return i[1]},un=e=>{if(ke!=null)return ke;const t=bo(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 r=n[1],o=new RegExp(`\\b([$\\w]+)=${fe(r)}[^$\\w]`),i=e.match(o);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${r})`);return}return i[1]},rt=async(e,t)=>{let n;if(t.nativeInstallationPath){await qn(t);let u=!1;try{await te.stat(ge),u=!0}catch{}const d=u?ge:t.nativeInstallationPath;T()&&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"),v=re.join(f,"native-claudejs-orig.js");Ce.writeFileSync(v,h),T()&&console.log(`Saved original extracted JS from native to: ${v}`),n=h.toString("utf8")}else{if(await Jn(t),!t.cliPath)throw new Error("cliPath is required for NPM installations");n=await te.readFile(t.cliPath,{encoding:"utf8"})}const r=[],o=await Hr(n,t.version);n=o.newContent,r.push(...o.items);let i=null;e.settings.themes&&e.settings.themes.length>0&&(i=ar(n,e.settings.themes))&&(n=i),e.settings.thinkingVerbs&&((i=Er(n,e.settings.thinkingVerbs.verbs))&&(n=i),(i=pr(n,e.settings.thinkingVerbs.format))&&(n=i)),(i=yr(n,e.settings.thinkingStyle.phases))&&(n=i),(i=vr(n,e.settings.thinkingStyle.updateInterval))&&(n=i),(i=_r(n,Math.max(...e.settings.thinkingStyle.phases.map(u=>u.length))+1))&&(n=i),(i=wr(n,e.settings.thinkingStyle.reverseMirror))&&(n=i),e.settings.userMessageDisplay&&(i=Tr(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=hr(n,e.settings.inputBox.removeBorder))&&(n=i),(i=Nr(n))&&(n=i),(i=fr(n))&&(n=i),(i=dr(n))&&(n=i),(i=yo(n))&&(n=i),(i=sr(n,25))&&(n=i),(i=Ar(n))&&(n=i);const a=e.settings.misc?.showTweakccVersion??!0,l=e.settings.misc?.showPatchesApplied??!0;if((i=Vr(n,"3.1.2",r,a,l))&&(n=i),(i=zr(n))&&(n=i),e.settings.toolsets&&e.settings.toolsets.length>0&&(i=oo(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=i),(i=fo(n))&&(n=i),t.nativeInstallationPath){T()&&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");Ce.writeFileSync(d,n,"utf8"),T()&&console.log(`Saved patched JS from native to: ${d}`);const h=Buffer.from(n,"utf8");er(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})},ot=[{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"}],wo=e=>{const t=e.indexOf("Switch between Claude models");if(t===-1)return console.error("patch: getModelSelectorInsertionPoint: failed to find labelIndex"),null;const n=Math.max(0,t-600),r=t,i=e.slice(n,r).match(/\[[$\w]+,\s*[$\w]+\]\s*=\s*[$\w]+\.useState\([^)]*\)\s*,\s*([$\w]+)=/);if(!i||i.index===void 0)return console.error("patch: getModelSelectorInsertionPoint: failed to find useState"),null;let 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}},xo=e=>{const t=wo(e);if(!t)return null;const{insertionIndex:n,optionsVar:r}=t,o=ot.map(a=>{const l=JSON.stringify(a.label),u=JSON.stringify(a.slug);return`${r}.push({value:${u},label:${l}});`}).join(""),i=e.slice(0,n)+o+e.slice(n);return V(e,i,o,n,n),i},yo=e=>{let t=e;const n=xo(t);return n&&(t=n),t===e?null:t};let it=!1;const T=()=>it,So=()=>{it=!0};function hn(){try{const e=re.join(ye.homedir(),".claude.json");return JSON.parse(Ce.readFileSync(e,"utf8")).theme||"dark"}catch{}return"dark"}function vo(){try{const e=re.join(ye.homedir(),".claude",".credentials.json");switch(JSON.parse(Ce.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 $o(){try{const e=re.join(ye.homedir(),".claude","settings.json"),n=JSON.parse(Ce.readFileSync(e,"utf8"))?.model||"default";if(n==="opus")return"Opus 4.1";const r=ot.find(o=>o.slug===n);if(r)return r.label}catch{}return"Sonnet 4.5"}function _o(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[,r,o,i]=n;return parseInt(r)<=255&&parseInt(o)<=255&&parseInt(i)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const[,r,o,i]=n;return parseInt(r)<=360&&parseInt(o)<=100&&parseInt(i)<=100}}return!1}function 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 r=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),i=parseInt(n.slice(4,6),16);return`rgb(${r},${o},${i})`}if(t.startsWith("hsl(")){const n=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(n){const r=parseInt(n[1])/360,o=parseInt(n[2])/100,i=parseInt(n[3])/100,a=(v,b,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?v+(b-v)*6*p:p<1/2?b:p<2/3?v+(b-v)*(2/3-p)*6:v),l=i<.5?i*(1+o):i+o-i*o,u=2*i-l,d=Math.round(a(u,l,r+1/3)*255),h=Math.round(a(u,l,r)*255),f=Math.round(a(u,l,r-1/3)*255);return`rgb(${d},${h},${f})`}}return e}async function Io(e,t="sha256",n=64*1024){return new Promise((r,o)=>{const i=An.createHash(t),a=Ce.createReadStream(e,{highWaterMark:n});a.on("data",l=>{i.update(l)}),a.on("end",()=>{r(i.digest("hex"))}),a.on("error",l=>{o(l)})})}const Tn=(e,t,n,r,o,i,a,l)=>{let u=e;return t&&(u+=`.rgb(${t})`),n&&n!=="transparent"&&(u+=`.bgRgb(${n})`),r&&(u+=".bold"),o&&(u+=".italic"),i&&(u+=".underline"),a&&(u+=".strikethrough"),l&&(u+=".inverse"),u};async function fn(e,t,n="replace"){let r=493;try{r=(await te.stat(e)).mode,T()&&console.log(`[${n}] Original file mode for ${e}: ${(r&parseInt("777",8)).toString(8)}`)}catch(o){T()&&console.log(`[${n}] Could not stat ${e} (error: ${o}), using default mode 755`)}try{await te.unlink(e),T()&&console.log(`[${n}] Unlinked ${e} to break hard links`)}catch(o){T()&&console.log(`[${n}] Could not unlink ${e}: ${o}`)}await te.writeFile(e,t),await te.chmod(e,r),T()&&console.log(`[${n}] Restored permissions to ${(r&parseInt("777",8)).toString(8)}`)}function F({color:e,backgroundColor:t,bold:n,dimColor:r,children:o}){const i=e?.startsWith("ansi:"),a=t?.startsWith("ansi:");if(i||a){if(Ke.Children.toArray(o).some(f=>Ke.isValidElement(f)))return s(c,{children:o});let u=Q;if(i){const f=e.slice(5);u=u[f]||u}if(a){const f=t.slice(5),v=f.startsWith("bg")?f:`bg${f.charAt(0).toUpperCase()}${f.slice(1)}`;u=u[v]||u}n&&(u=u.bold),r&&(u=u.dim);const h=Ke.Children.toArray(o).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:r,children:o})}function Co({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:r=3,updateDuration:o=50,restartPoint:i=10}){const[a,l]=O(0);return xe(()=>{const u=setInterval(()=>{l(d=>{const h=d+1;return h>=e.length+i?-r:h})},o);return()=>clearInterval(u)},[e.length,i,o]),t.length!==n.length?(console.error("UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length"),s(c,{children:e})):s(c,{children:e.split("").map((u,d)=>{const h=d>=a&&d<a+r&&a<e.length,f=d%t.length,v=h?n[f]:t[f];return s(c,{color:v,children:u},d)})})}const Eo=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(F,{color:e.colors.clawd_body,children:" ▐"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"▛███▜"}),g(c,{children:[s(F,{color:e.colors.clawd_body,children:"▌ "})," ",s(c,{bold:!0,children:"Claude Code"})," ",t?`v${t}`:"v2.0.14"]})]}),g(c,{children:[s(F,{color:e.colors.clawd_body,children:"▝▜"}),s(c,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:"█████"}),s(F,{color:e.colors.clawd_body,children:"▛▘"})," ",$o()," · ",vo()]}),g(F,{color:e.colors.clawd_body,children:[" ","▘▘ ▝▝"," ",Eo]}),g(c,{children:[g(F,{color:e.colors.success,children:["Login successful. Press"," "]}),s(F,{bold:!0,color:e.colors.success,children:"Enter"}),g(F,{color:e.colors.success,children:[" ","to continue…"]})]})]}),s(c,{children:"╭─────────────────────────────────────────────╮"}),g(c,{children:["│ 1 function greet() ","{"," ","│"]}),g(c,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:'- console.log("'}),s(F,{backgroundColor:e.colors.diffRemovedWord,children:"Hello, World!"}),s(F,{backgroundColor:e.colors.diffRemoved,children:'");'})," ","│"]}),g(c,{children:["│ 2"," ",s(F,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:'+ console.log("'}),s(F,{backgroundColor:e.colors.diffAddedWord,children:"Hello, Claude!"}),s(F,{backgroundColor:e.colors.diffAdded,children:'");'})," ","│"]}),s(F,{color:e.colors.warning,children:"╭─────────────────────────────────────────────╮"}),g(F,{color:e.colors.warning,children:["│ Do you trust the files in this folder?"," ","│"]}),g(c,{children:[s(F,{color:e.colors.warning,children:"│ "}),s(c,{dimColor:!0,children:"Enter to confirm · Esc to exit"}),g(F,{color:e.colors.warning,children:[" ","│"]})]}),s(F,{color:e.colors.bashBorder,children:"───────────────────────────────────────────────"}),g(c,{children:[s(F,{color:e.colors.bashBorder,children:"!"}),s(c,{children:" ls"})]}),s(F,{color:e.colors.promptBorder,children:"───────────────────────────────────────────────"}),s(c,{children:g(c,{children:["> list the dir"," ",s(Co,{text:"ultrathink",nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),s(F,{color:e.colors.planMode,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(F,{color:e.colors.planMode,children:"│ "}),g(F,{color:e.colors.permission,children:["Ready to code?"," "]}),s(c,{children:"Here is Claude's plan:"}),g(F,{color:e.colors.planMode,children:[" ","│"]})]}),s(F,{color:e.colors.permission,children:"╭─────────────────────────────────────────────╮"}),g(c,{children:[s(F,{color:e.colors.permission,children:"│ "}),s(c,{bold:!0,children:"Permissions:"})," ",g(F,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[" ","Allow"," "]})," ","Deny"," ","Workspace"," ",s(F,{color:e.colors.permission,children:"│"})]}),s(c,{children:"> list the dir"}),g(c,{children:[s(F,{color:e.colors.error,children:"●"}),s(c,{children:" Update(__init__.py)"})]}),g(c,{children:[s(c,{children:" ⎿ "}),s(F,{color:e.colors.error,children:"User rejected update to __init__.py"})]}),g(c,{children:[" ","1"," ",g(F,{backgroundColor:e.colors.diffRemovedDimmed,children:["- import"," "]}),s(F,{backgroundColor:e.colors.diffRemovedWordDimmed,children:"os"})]}),g(c,{children:[" ","2"," ",g(F,{backgroundColor:e.colors.diffAddedDimmed,children:["+ import"," "]}),s(F,{backgroundColor:e.colors.diffAddedWordDimmed,children:"random"})]}),g(c,{children:[s(F,{color:e.colors.success,children:"●"}),s(c,{children:" List(.)"})]}),g(c,{children:[s(c,{children:"●"}),s(c,{children:" The directory "}),s(F,{color:e.colors.permission,children:"C:\\Users\\user"}),g(c,{children:[" ","contains ",s(c,{bold:!0,children:"123"})," files."]})]}),g(c,{children:[s(F,{color:e.colors.claude,children:"✻ Th"}),s(F,{color:e.colors.claudeShimmer,children:"ink"}),s(F,{color:e.colors.claude,children:"ing… "}),s(c,{children:"(esc to interrupt)"})]}),s(c,{children:s(F,{color:e.colors.autoAccept,children:"⏵⏵ accept edits on (shift+tab to cycle)"})}),s(c,{children:s(F,{color:e.colors.planMode,children:"⏸ plan mode on (shift+tab to cycle)"})}),s(c,{children:s(F,{color:e.colors.ide,children:"◯ IDE connected ⧉ 44 lines selected"})})]})})]})}function Xe({colorKey:e,theme:t,bold:n=!1}){const r=t.colors[e];return e==="inverseText"?s(F,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith("diff")?s(F,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):s(F,{color:r,bold:n,children:e})}function at({initialValue:e,onColorChange:t,onExit:n,colorKey:r,theme:o}){const i=Qe(e)||{h:0,s:50,l:50},a=Ze(e)||{r:128,g:128,b:128},[l,u]=O(i),[d,h]=O(a),[f,v]=O("hsl"),[b,p]=O("h"),[w,x]=O(!1),[C,_]=O(!1);xe(()=>{const I=Qe(e),$=Ze(e);I&&$&&(x(!0),u(I),h($),x(!1))},[e]),xe(()=>{if(!w&&C){const I=`rgb(${d.r},${d.g},${d.b})`;t(I)}},[l,d,w,C]),xe(()=>{_(!0)},[]);const k=I=>{if(gn(I)){const $=st(I),S=Qe($),N=Ze($);S&&N&&(x(!0),u(S),h(N),x(!1))}};de((I,$)=>{if(I.length>1&&!$.ctrl&&!$.meta){k(I);return}if($.return)n();else if($.escape)n();else if($.ctrl&&I==="a")v(S=>S==="hsl"?"rgb":"hsl"),p(S=>f==="hsl"?S==="h"?"r":S==="s"?"g":"b":S==="r"?"h":S==="g"?"s":"l");else if($.upArrow)p(f==="hsl"?S=>S==="h"?"l":S==="s"?"h":"s":S=>S==="r"?"b":S==="g"?"r":"g");else if($.downArrow||$.tab)p(f==="hsl"?S=>S==="h"?"s":S==="s"?"l":"h":S=>S==="r"?"g":S==="g"?"b":"r");else if($.leftArrow){const S=$.shift||$.ctrl||$.meta?-10:-1;P(S)}else if($.rightArrow){const S=$.shift||$.ctrl||$.meta?10:1;P(S)}});const P=I=>{x(!0),f==="hsl"?u($=>{const S={...$};b==="h"?S.h=Math.max(0,Math.min(359,$.h+I)):b==="s"?S.s=Math.max(0,Math.min(100,$.s+I)):b==="l"&&(S.l=Math.max(0,Math.min(100,$.l+I)));const[N,y,D]=j(S.h,S.s,S.l);return h({r:N,g:y,b:D}),S}):h($=>{const S={...$};b==="r"?S.r=Math.max(0,Math.min(255,$.r+I)):b==="g"?S.g=Math.max(0,Math.min(255,$.g+I)):b==="b"&&(S.b=Math.max(0,Math.min(255,$.b+I)));const N=B(S.r,S.g,S.b);return u(N),S}),x(!1)},B=(I,$,S)=>{const N=I/255,y=$/255,D=S/255,z=Math.max(N,y,D),G=Math.min(N,y,D),ne=z-G,se=(z+G)/2;let $e=0;ne!==0&&($e=se>.5?ne/(2-z-G):ne/(z+G));let we=0;return ne!==0&&(z===N?we=((y-D)/ne+(y<D?6:0))/6:z===y?we=((D-N)/ne+2)/6:we=((N-y)/ne+4)/6),{h:Math.round(we*360),s:Math.round($e*100),l:Math.round(se*100)}},j=(I,$,S)=>{I/=360,$/=100,S/=100;const N=(1-Math.abs(2*S-1))*$,y=N*(1-Math.abs(I*6%2-1)),D=S-N/2;let z=0,G=0,ne=0;return 0<=I&&I<1/6?(z=N,G=y,ne=0):1/6<=I&&I<2/6?(z=y,G=N,ne=0):2/6<=I&&I<3/6?(z=0,G=N,ne=y):3/6<=I&&I<4/6?(z=0,G=y,ne=N):4/6<=I&&I<5/6?(z=y,G=0,ne=N):5/6<=I&&I<1&&(z=N,G=0,ne=y),[Math.round((z+D)*255),Math.round((G+D)*255),Math.round((ne+D)*255)]},q=()=>{const I=[],$=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let S=0;S<40;S++){const y=S/39*($.length-1),D=Math.floor(y),z=Math.ceil(y),G=y-D,[ne,se,$e]=$[D],[we,H,R]=$[z],L=Math.round(ne+(we-ne)*G),ee=Math.round(se+(H-se)*G),W=Math.round($e+(R-$e)*G);I.push(s(c,{backgroundColor:`rgb(${L},${ee},${W})`,children:" "},S))}return I},U=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,D]=j(l.h,S,l.l);I.push(s(c,{backgroundColor:`rgb(${N},${y},${D})`,children:" "},$))}return I},A=()=>{const I=[];for(let $=0;$<40;$++){const S=$/39*100,[N,y,D]=j(l.h,l.s,S);I.push(s(c,{backgroundColor:`rgb(${N},${y},${D})`,children:" "},$))}return I},M=()=>{const[I,$,S]=j(l.h,l.s,l.l);return`rgb(${I},${$},${S})`},E=(I,$,S)=>{const N=y=>y.toString(16).padStart(2,"0");return`#${N(I)}${N($)}${N(S)}`},Y=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${S},${d.g},${d.b})`,children:" "},$))}return I},X=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${d.r},${S},${d.b})`,children:" "},$))}return I},oe=()=>{const I=[];for(let $=0;$<40;$++){const S=Math.round($/39*255);I.push(s(c,{backgroundColor:`rgb(${d.r},${d.g},${S})`,children:" "},$))}return I},K=(I,$)=>Math.round(I/$*39);return g(m,{flexDirection:"column",borderStyle:"single",borderColor:"white",padding:1,children:[g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Color Picker"}),g(m,{marginBottom:1,flexDirection:"column",children:[s(c,{color:"gray",dimColor:!0,children:"←→ to adjust (shift/ctrl/cmd +10)"}),s(c,{color:"gray",dimColor:!0,children:"↑↓ to change bar"}),s(c,{color:"gray",dimColor:!0,children:"ctrl+a to switch rgb/hsl"}),s(c,{color:"gray",dimColor:!0,children:"paste color from clipboard"}),s(c,{color:"gray",dimColor:!0,children:"enter to exit (auto-saved)"}),s(c,{color:"gray",dimColor:!0,children:"esc to save and exit"})]})]}),f==="hsl"?g(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:q().map((I,$)=>s(Ee,{children:$===K(l.h,360)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="s"?"yellow":"white",children:[b==="s"?"❯ ":" ","Saturation (",l.s,"%):"]})}),s(m,{children:U().map((I,$)=>s(Ee,{children:$===K(l.s,100)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="l"?"yellow":"white",children:[b==="l"?"❯ ":" ","Lightness (",l.l,"%):"]})}),s(m,{children:A().map((I,$)=>s(Ee,{children:$===K(l.l,100)?s(c,{children:"|"}):I},$))})]})]}):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:Y().map((I,$)=>s(Ee,{children:$===K(d.r,255)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="g"?"yellow":"white",children:[b==="g"?"❯ ":" ","Green (",d.g,"):"]})}),s(m,{children:X().map((I,$)=>s(Ee,{children:$===K(d.g,255)?s(c,{children:"|"}):I},$))})]}),g(m,{marginBottom:1,children:[s(m,{width:25,children:g(c,{color:b==="b"?"yellow":"white",children:[b==="b"?"❯ ":" ","Blue (",d.b,"):"]})}),s(m,{children:oe().map((I,$)=>s(Ee,{children:$===K(d.b,255)?s(c,{children:"|"}):I},$))})]})]}),g(m,{marginBottom:1,children:[s(c,{children:"Current: "}),s(c,{backgroundColor:M(),children:" "})]}),g(m,{flexDirection:"row",justifyContent:"space-between",children:[g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"Hex "}),r?.startsWith("diff")?s(c,{backgroundColor:M(),color:o?.colors?.text||"white",bold:!0,children:E(d.r,d.g,d.b)}):r==="inverseText"?s(c,{color:M(),backgroundColor:o?.colors?.permission,bold:!0,children:E(d.r,d.g,d.b)}):s(c,{color:M(),bold:!0,children:E(d.r,d.g,d.b)})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"RGB "}),r?.startsWith("diff")?s(c,{backgroundColor:M(),color:o?.colors?.text||"white",bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):r==="inverseText"?s(c,{color:M(),backgroundColor:o?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):s(c,{color:M(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),g(m,{flexDirection:"column",children:[s(c,{dimColor:!0,children:"HSL "}),r?.startsWith("diff")?s(c,{backgroundColor:M(),color:o?.colors?.text||"white",bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):r==="inverseText"?s(c,{color:M(),backgroundColor:o?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):s(c,{color:M(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function Ze(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};const n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){const r=n[1];return{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16)}}return null}function Qe(e){const t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};const n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const o=parseInt(n[1])/255,i=parseInt(n[2])/255,a=parseInt(n[3])/255,l=Math.max(o,i,a),u=Math.min(o,i,a),d=l-u,h=(l+u)/2;let f=0;d!==0&&(f=h>.5?d/(2-l-u):d/(l+u));let v=0;return d!==0&&(l===o?v=((i-a)/d+(i<a?6:0))/6:l===i?v=((a-o)/d+2)/6:v=((o-i)/d+4)/6),{h:Math.round(v*360),s:Math.round(f*100),l:Math.round(h*100)}}const r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){const o=r[1],i=parseInt(o.substr(0,2),16)/255,a=parseInt(o.substr(2,2),16)/255,l=parseInt(o.substr(4,2),16)/255,u=Math.max(i,a,l),d=Math.min(i,a,l),h=u-d,f=(u+d)/2;let v=0;h!==0&&(v=f>.5?h/(2-u-d):h/(u+d));let b=0;return h!==0&&(u===i?b=((a-l)/h+(a<l?6:0))/6:u===a?b=((l-i)/h+2)/6:b=((i-a)/h+4)/6),{h:Math.round(b*360),s:Math.round(v*100),l:Math.round(f*100)}}return{h:0,s:50,l:50}}function ko({onBack:e,themeId:t}){const{settings:{themes:n},updateSettings:r}=be(ue),[o,i]=O(t),a=n.find(A=>A.id===o)||n[0],[l,u]=O("rgb"),[d,h]=O(0),[f,v]=O(null),[b,p]=O(null),[w,x]=O(""),[C,_]=O(""),k=Nn(A=>{r(M=>{const E=M.themes.findIndex(Y=>Y.id===o);E!==-1&&A(M.themes[E])})},[o,r]),P=A=>{if(d>=2&&gn(A)){const M=st(A),E=d-2,Y=B[E];k(X=>{X.colors[Y]=M})}};de((A,M)=>{if(f===null&&b===null){if(A.length>1&&!M.ctrl&&!M.meta){P(A);return}if(M.escape)e();else if(M.ctrl&&A==="a")u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(M.upArrow)h(E=>Math.max(0,E-1));else if(M.downArrow)h(E=>Math.min(B.length+1,E+1));else if(M.return)if(d===0)p("name"),x(a.name),_(a.name);else if(d===1)p("id"),x(a.id),_(a.id);else{const E=d-2,Y=B[E],X=a.colors[Y];v(E),x(X),_(X)}}else if(f!==null)M.ctrl&&A==="a"&&u(E=>E==="rgb"?"hex":E==="hex"?"hsl":"rgb");else if(b!==null)if(M.return){if(b==="id"){const E=o;i(w),r(Y=>{const X=Y.themes.findIndex(oe=>oe.id===E);X!==-1&&(Y.themes[X].id=w)})}else k(E=>{E.name=w});p(null),x(""),_("")}else M.escape?(p(null),x(""),_("")):M.backspace||M.delete?x(E=>E.slice(0,-1)):A&&x(E=>E+A)});const B=Object.keys(a.colors),j=(A,M)=>{const E=A.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!E)return A;const Y=parseInt(E[1]),X=parseInt(E[2]),oe=parseInt(E[3]);switch(M){case"hex":{const K=I=>I.toString(16).padStart(2,"0");return`#${K(Y)}${K(X)}${K(oe)}`}case"hsl":{const K=Y/255,I=X/255,$=oe/255,S=Math.max(K,I,$),N=Math.min(K,I,$),y=S-N,D=(S+N)/2;let z=0;y!==0&&(z=D>.5?y/(2-S-N):y/(S+N));let G=0;return y!==0&&(S===K?G=((I-$)/y+(I<$?6:0))/6:S===I?G=(($-K)/y+2)/6:G=((K-I)/y+4)/6),`hsl(${Math.round(G*360)}, ${Math.round(z*100)}%, ${Math.round(D*100)}%)`}case"rgb":default:return A}},q=A=>({autoAccept:"Auto-accept edits mode indicator",bashBorder:"Bash command border",claude:"Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.",claudeShimmer:"Color used for the shimmering effect on the thinking verb.",claudeBlue_FOR_SYSTEM_SPINNER:"System spinner color (blue variant)",claudeBlueShimmer_FOR_SYSTEM_SPINNER:"System spinner shimmer color (blue variant)",permission:"Permission prompt color",permissionShimmer:"Permission prompt shimmer color",planMode:"Plan mode indicator",ide:"Color used for IDE-related messages.",promptBorder:"Input prompt border color",promptBorderShimmer:"Input prompt border shimmer color",text:"Code color. Used in diffs.",inverseText:"Inverse text color. Used for the text of tabs, where the background is filled in.",inactive:"Inactive/dimmed text. Used for line numbers and less prominent text.",subtle:"Subtle text. Used for help text and secondary information.",suggestion:"Suggestion text color. Used for suggestions for theme names and various other things.",remember:"Remember/note color. Used for various text relating to memories.",background:"Background color for certain UI elements",success:"Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).",error:"Error indicator",warning:"Warning indicator",warningShimmer:"Warning shimmer color",diffAdded:"Added diff background",diffRemoved:"Removed diff background",diffAddedDimmed:"Added diff background (dimmed)",diffRemovedDimmed:"Removed diff background (dimmed)",diffAddedWord:"Added word highlight",diffRemovedWord:"Removed word highlight",diffAddedWordDimmed:"Added word highlight (dimmed)",diffRemovedWordDimmed:"Removed word highlight (dimmed)",red_FOR_SUBAGENTS_ONLY:"Red color for sub agents",blue_FOR_SUBAGENTS_ONLY:"Blue color for sub agents",green_FOR_SUBAGENTS_ONLY:"Green color for sub agents",yellow_FOR_SUBAGENTS_ONLY:"Yellow color for sub agents",purple_FOR_SUBAGENTS_ONLY:"Purple color for sub agents",orange_FOR_SUBAGENTS_ONLY:"Orange color for sub agents",pink_FOR_SUBAGENTS_ONLY:"Pink color for sub agents",cyan_FOR_SUBAGENTS_ONLY:"Cyan color for sub agents",professionalBlue:"Professional blue color for business contexts?",rainbow_red:'"ultrathink" rainbow - red',rainbow_orange:'"ultrathink" rainbow - orange',rainbow_yellow:'"ultrathink" rainbow - yellow',rainbow_green:'"ultrathink" rainbow - green',rainbow_blue:'"ultrathink" rainbow - blue',rainbow_indigo:'"ultrathink" rainbow - indigo',rainbow_violet:'"ultrathink" rainbow - violet',rainbow_red_shimmer:'"ultrathink" rainbow (shimmer) - red',rainbow_orange_shimmer:'"ultrathink" rainbow (shimmer) - orange',rainbow_yellow_shimmer:'"ultrathink" rainbow (shimmer) - yellow',rainbow_green_shimmer:'"ultrathink" rainbow (shimmer) - green',rainbow_blue_shimmer:'"ultrathink" rainbow (shimmer) - blue',rainbow_indigo_shimmer:'"ultrathink" rainbow (shimmer) - indigo',rainbow_violet_shimmer:'"ultrathink" rainbow (shimmer) - violet',clawd_body:'"Clawd" character body color',clawd_background:'"Clawd" character background color',userMessageBackground:"Background color for user messages",bashMessageBackgroundColor:"Background color for bash command output",memoryBackgroundColor:"Background color for memory/context information",rate_limit_fill:"Rate limit indicator fill color",rate_limit_empty:"Rate limit indicator empty/background color"})[A]||"",U=Math.max(...B.map(A=>A.length));return g(m,{children:[g(m,{flexDirection:"column",width:"50%",children:[s(m,{children:g(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[B[d-2]],flexDirection:"column",paddingLeft:1,children:[s(Xe,{colorKey:B[d-2],theme:a,bold:!0}),s(c,{children:q(B[d-2])})]}),g(m,{flexDirection:"column",children:[g(m,{children:[s(c,{color:d===0?"yellow":"white",children:d===0?"❯ ":" "}),s(c,{bold:!0,children:"Name: "}),s(c,{children:a.name})]}),g(m,{marginBottom:1,children:[s(c,{color:d===1?"yellow":"white",children:d===1?"❯ ":" "}),s(c,{bold:!0,children:"ID: "}),s(c,{children:a.id})]}),(()=>{if(d<2){const K=B.slice(0,20);return g(me,{children:[K.map((I,$)=>{const S=$+2;return g(m,{children:[s(c,{color:d===S?"yellow":"white",children:d===S?"❯ ":" "}),s(m,{width:U+2,children:s(c,{children:s(Xe,{colorKey:I,theme:a,bold:!0})})}),s(F,{color:a.colors[I],children:j(a.colors[I],l)})]},I)}),B.length>20&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",B.length-20," more below"]})]})}const M=d-2,E=Math.max(0,M-Math.floor(20/2)),Y=Math.min(B.length,E+20),X=Math.max(0,Y-20),oe=B.slice(X,Y);return g(me,{children:[X>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",X," more above"]}),oe.map((K,I)=>{const S=X+I+2;return g(m,{children:[s(c,{color:d===S?"yellow":"white",children:d===S?"❯ ":" "}),s(m,{width:U+2,children:s(c,{children:s(Xe,{colorKey:K,theme:a,bold:!0})})}),s(F,{color:a.colors[K],children:j(a.colors[K],l)})]},K)}),Y<B.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",B.length-Y," more below"]})]})})()]})]}):b?g(m,{flexDirection:"column",marginTop:1,children:[g(c,{children:["Editing ",b==="name"?"theme name":"theme ID",":"]}),s(m,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:s(c,{children:w})}),s(c,{dimColor:!0,children:"enter to save, esc to cancel"})]}):s(at,{initialValue:C,colorKey:B[f],theme:a,onColorChange:A=>{x(A),k(M=>{M.colors[B[f]]=A})},onExit:()=>{k(A=>{A.colors[B[f]]=w}),v(null),x(""),_("")}})]}),s(m,{width:"50%",children:s(lt,{theme:a})})]})}function To(e){return e.map(t=>`${t.name} (${t.id})`)}function Mo({onBack:e}){const{settings:{themes:t},updateSettings:n}=be(ue),[r,o]=O(0),[i,a]=O(null),[l,u]=O(!0),d=()=>{const w={colors:{...(t[0]||Z.themes[0]).colors},name:"New Custom Theme",id:`custom-${Date.now()}`};n(x=>{x.themes.push(w)}),a(w.id),u(!1)},h=p=>{t.length<=1||(n(w=>{w.themes=w.themes.filter(x=>x.id!==p)}),r>=t.length-1&&o(Math.max(0,t.length-2)))},f=()=>{n(p=>{p.themes=[...Z.themes]}),o(0)};if(de((p,w)=>{if(w.escape)e();else if(w.upArrow)o(x=>Math.max(0,x-1));else if(w.downArrow)o(x=>Math.min(t.length-1,x+1));else if(w.return){const x=t[r];x&&(a(x.id),u(!1))}else if(p==="n")d();else if(p==="d"){const x=t[r];x&&h(x.id)}else w.ctrl&&p==="r"&&f()},{isActive:l}),i)return s(ko,{themeId:i,onBack:()=>{a(null),u(!0)}});const v=To(t),b=t.find(p=>v[r]?.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:v.map((p,w)=>g(c,{color:r===w?"yellow":void 0,children:[r===w?"❯ ":" ",p]},w))})]}),s(m,{width:"50%",children:s(lt,{theme:b})})]})}function No({onBack:e}){const{settings:{thinkingVerbs:{format:t,verbs:n},themes:r},updateSettings:o}=be(ue),i=["format","verbs"],[a,l]=O(0),u=i[a],[d,h]=O(0),[f,v]=O(!1),[b,p]=O(""),[w,x]=O(!1),[C,_]=O(!1),[k,P]=O(t),B=hn(),q=(r.find(A=>A.id===B)||r.find(A=>A.id==="dark"))?.colors.claude||"rgb(215,119,87)";de((A,M)=>{if(C){M.return?(o(E=>{E.thinkingVerbs.format=k}),_(!1)):M.escape?(P(t),_(!1)):M.backspace||M.delete?P(E=>E.slice(0,-1)):A&&P(E=>E+A);return}if(f||w){M.return&&b.trim()?(w?(o(E=>{E.thinkingVerbs.verbs.push(b.trim())}),x(!1)):(o(E=>{E.thinkingVerbs.verbs[d]=b.trim()}),v(!1)),p("")):M.escape?(p(""),v(!1),x(!1)):M.backspace||M.delete?p(E=>E.slice(0,-1)):A&&p(E=>E+A);return}M.escape?e():M.return?u==="format"&&(P(t),_(!0)):M.tab?M.shift?l(E=>E===0?i.length-1:E-1):l(E=>E===i.length-1?0:E+1):M.upArrow?u==="verbs"&&n.length>0&&h(E=>E>0?E-1:n.length-1):M.downArrow?u==="verbs"&&n.length>0&&h(E=>E<n.length-1?E+1:0):A==="e"&&u==="verbs"?n.length>0&&(p(n[d]),v(!0)):A==="d"&&u==="verbs"?n.length>1&&(o(E=>{E.thinkingVerbs.verbs=E.thinkingVerbs.verbs.filter((Y,X)=>X!==d)}),d>=n.length-1&&h(Math.max(0,n.length-2))):A==="n"&&u==="verbs"?(x(!0),p("")):M.ctrl&&A==="r"&&u==="verbs"&&(o(E=>{E.thinkingVerbs.verbs=[...Z.thinkingVerbs.verbs]}),h(0))});const U=50;return g(m,{children:[g(m,{flexDirection:"column",width:`${100-U}%`,children:[g(m,{marginBottom:1,flexDirection:"column",children:[s(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"&&(C?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]}))]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:C?"yellow":"gray",children:s(c,{children:C?k:t})})}),s(m,{children:g(c,{children:[s(c,{color:u==="verbs"?"yellow":void 0,children:u==="verbs"?"❯ ":" "}),s(c,{bold:!0,color:u==="verbs"?"yellow":void 0,children:"Verbs"})]})}),u==="verbs"&&s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","e to edit · d to delete · n to add new · ctrl+r to reset"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const M=Math.max(0,d-Math.floor(4)),E=Math.min(n.length,M+8),Y=Math.max(0,E-8),X=n.slice(Y,E);return g(me,{children:[Y>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",Y," more above"]}),X.map((oe,K)=>{const I=Y+K;return g(c,{color:u==="verbs"&&I===d?"cyan":void 0,children:[u==="verbs"&&I===d?"❯ ":" ",oe]},I)}),E<n.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",n.length-E," more below"]})]})})(),w&&g(m,{alignItems:"center",children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]}),f&&g(m,{marginTop:1,alignItems:"center",children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:b})})]})]})})]}),g(m,{width:`${U}%`,flexDirection:"column",children:[s(m,{marginBottom:1,children:s(c,{bold:!0,children:"Preview"})}),s(m,{borderStyle:"single",borderColor:"gray",padding:1,flexDirection:"column",children:g(c,{children:[g(c,{color:q,children:["✻ ",t.replace(/\{\}/g,n[d])," "]}),s(c,{children:"(esc to interrupt)"})]})})]})]})}const _e=[{name:"Default",phases:Z.thinkingStyle.phases,reverseMirror:Z.thinkingStyle.reverseMirror},{name:"Basic",phases:["|","/","-","\\"],reverseMirror:!1},{name:"Braille",phases:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],reverseMirror:!1},{name:"Circle",phases:["◐","◓","◑","◒"],reverseMirror:!1},{name:"Wave",phases:["▁","▃","▄","▅","▆","▇","█"],reverseMirror:!0},{name:"Glow",phases:["░","▒","▓","█"],reverseMirror:!0},{name:"Partial block",phases:["▏","▎","▍","▌","▋","▊","▉","█"],reverseMirror:!0},{name:"Clock",phases:["🕛","🕐","🕑","🕒","🕓","🕔","🕕","🕖","🕗","🕘","🕙","🕚"],reverseMirror:!1},{name:"Globe",phases:["🌍","🌎","🌏"],reverseMirror:!1},{name:"Arc",phases:["◜","◠","◝","◞","◡","◟"],reverseMirror:!1},{name:"Triangle",phases:["◤","◥","◢","◣"],reverseMirror:!1},{name:"Bouncing",phases:["⠁","⠂","⠄","⡀","⢀","⠠","⠐","⠈"],reverseMirror:!1},{name:"Dots",phases:[".","..","..."],reverseMirror:!1},{name:"Colors",phases:["🔴","🟠","🟡","🟢","🔵","🟣"],reverseMirror:!1}];function Bo({onBack:e}){const{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:r},themes:o},updateSettings:i}=be(ue),a=["reverseMirror","updateInterval","phases","presets"],[l,u]=O(0),d=a[l],[h,f]=O(0),[v,b]=O(0),[p,w]=O(!1),[x,C]=O(""),[_,k]=O(!1),[P,B]=O(!1),[j,q]=O(n.toString()),[U,A]=O(0),M=hn(),Y=(o.find(S=>S.id===M)||o.find(S=>S.id==="dark"))?.colors.claude||"rgb(215,119,87)";xe(()=>{if(t.length>0){const S=r?[...t,...[...t].reverse().slice(1,-1)]:t,N=setInterval(()=>{A(y=>(y+1)%S.length)},n);return()=>clearInterval(N)}},[t,n,r]),de((S,N)=>{if(P){if(N.return){const y=parseInt(j);!isNaN(y)&&y>0&&i(D=>{D.thinkingStyle.updateInterval=y}),B(!1)}else N.escape?(q(n.toString()),B(!1)):N.backspace||N.delete?q(y=>y.slice(0,-1)):S&&S.match(/^[0-9]$/)&&q(y=>y+S);return}if(p||_){if(N.return&&x.length){const y=_?[...t,x]:t.map((D,z)=>z===h?x:D);i(D=>{D.thinkingStyle.phases=y}),w(!1),C("")}else N.escape?(C(""),w(!1),k(!1)):N.backspace||N.delete?C(y=>y.slice(0,-1)):S&&C(y=>y+S);return}if(N.escape)e();else if(N.return)if(d==="updateInterval")q(n.toString()),B(!0);else if(d==="presets"){const y=_e[v];i(D=>{D.thinkingStyle.phases=[...y.phases],D.thinkingStyle.reverseMirror=y.reverseMirror})}else d==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(N.tab)N.shift?u(y=>y===0?a.length-1:y-1):u(y=>y===a.length-1?0:y+1);else if(N.upArrow)d==="phases"&&t.length>0?f(y=>y>0?y-1:t.length-1):d==="presets"&&b(y=>y>0?y-1:_e.length-1);else if(N.downArrow)d==="phases"&&t.length>0?f(y=>y<t.length-1?y+1:0):d==="presets"&&b(y=>y<_e.length-1?y+1:0);else if(S===" ")d==="reverseMirror"&&i(y=>{y.thinkingStyle.reverseMirror=!y.thinkingStyle.reverseMirror});else if(S==="e"&&d==="phases")t.length>0&&(C(t[h]),w(!0));else if(S==="a"&&d==="phases")k(!0),C("");else if(S==="d"&&d==="phases")t.length>1&&(i(y=>{y.thinkingStyle.phases=t.filter((D,z)=>z!==h)}),h>=t.length&&f(Math.max(0,t.length-1)));else if(S==="w"&&d==="phases"){if(h>0){const y=[...t];[y[h-1],y[h]]=[y[h],y[h-1]],i(D=>{D.thinkingStyle.phases=y}),f(D=>D-1)}}else if(S==="s"&&d==="phases"){if(h<t.length-1){const y=[...t];[y[h],y[h+1]]=[y[h+1],y[h]],i(D=>{D.thinkingStyle.phases=y}),f(D=>D+1)}}else N.ctrl&&S==="r"&&(i(y=>{y.thinkingStyle=Z.thinkingStyle}),f(0),b(0))});const X=r?"●":"○",oe=50,I=r?[...t,...[...t].reverse().slice(1,-1)]:t,$=I.length>0?I[U]:"·";return s(m,{children:g(m,{flexDirection:"column",width:"100%",children:[g(m,{flexDirection:"row",width:"100%",children:[g(m,{marginBottom:1,flexDirection:"column",width:`${100-oe}%`,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:`${oe}%`,flexDirection:"column",children:[s(m,{children:s(c,{bold:!0,children:"Preview"})}),g(m,{borderStyle:"single",borderColor:"gray",paddingX:1,flexDirection:"row",children:[s(m,{width:($?.length??0)+1,children:s(c,{color:Y,children:$})}),g(c,{children:[s(c,{color:Y,children:"Thinking… "}),s(c,{children:"(esc to interrupt)"})]})]})]})]}),g(m,{flexDirection:"row",gap:4,children:[g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="reverseMirror"?"yellow":void 0,children:d==="reverseMirror"?"❯ ":" "}),s(c,{bold:!0,color:d==="reverseMirror"?"yellow":void 0,children:"Reverse-mirror phases"})]}),d==="reverseMirror"&&g(c,{dimColor:!0,children:[" ","space to toggle"]}),s(m,{marginLeft:2,marginBottom:1,children:g(c,{children:[X," ",r?"Enabled":"Disabled"]})})]}),g(m,{flexDirection:"column",children:[g(c,{children:[s(c,{color:d==="updateInterval"?"yellow":void 0,children:d==="updateInterval"?"❯ ":" "}),s(c,{bold:!0,color:d==="updateInterval"?"yellow":void 0,children:"Update interval (ms)"})]}),d==="updateInterval"&&(P?g(c,{dimColor:!0,children:[" ","enter to save"]}):g(c,{dimColor:!0,children:[" ","enter to edit"]})),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:P?"yellow":"gray",children:s(c,{children:P?j:n})})})]})]}),s(m,{children:g(c,{children:[s(c,{color:d==="phases"?"yellow":void 0,children:d==="phases"?"❯ ":" "}),s(c,{bold:!0,color:d==="phases"?"yellow":void 0,children:"Phases"})]})}),d==="phases"&&s(m,{marginBottom:1,flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","[e]dit"," ","[a]dd"," ","[d]elete"," ","[w]move up"," ","[s]move down"]})}),s(m,{marginLeft:2,marginBottom:1,children:g(m,{flexDirection:"column",children:[(()=>{const N=Math.max(0,h-Math.floor(4)),y=Math.min(t.length,N+8),D=Math.max(0,y-8),z=t.slice(D,y);return g(me,{children:[D>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",D," more above"]}),z.map((G,ne)=>{const se=D+ne;return g(c,{color:d==="phases"&&se===h?"cyan":void 0,children:[d==="phases"&&se===h?"❯ ":" ",G]},se)}),y<t.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",t.length-y," more below"]})]})})(),_&&g(m,{children:[s(c,{color:"yellow",children:"❯ "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:x})})]}),p&&g(m,{marginTop:1,children:[s(c,{children:"Editing: "}),s(m,{borderStyle:"round",borderColor:"yellow",children:s(c,{children:x})})]})]})}),s(m,{children:g(c,{children:[s(c,{color:d==="presets"?"yellow":void 0,children:d==="presets"?"❯ ":" "}),s(c,{bold:!0,color:d==="presets"?"yellow":void 0,children:"Presets"})]})}),d==="presets"&&g(c,{dimColor:!0,children:[" ","Selecting one will overwrite your choice of phases"]}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{flexDirection:"column",children:(()=>{const N=Math.max(0,v-Math.floor(4)),y=Math.min(_e.length,N+8),D=Math.max(0,y-8),z=_e.slice(D,y);return g(me,{children:[D>0&&g(c,{color:"gray",dimColor:!0,children:[" ","↑ ",D," more above"]}),z.map((G,ne)=>{const se=D+ne;return g(c,{color:d==="presets"&&se===v?"cyan":void 0,children:[d==="presets"&&se===v?"❯ ":" ",G.name," ",G.phases.join("")]},se)}),y<_e.length&&g(c,{color:"gray",dimColor:!0,children:[" ","↓ ",_e.length-y," more below"]})]})})()})}),s(m,{marginTop:1,children:s(c,{dimColor:!0,children:"ctrl+r to reset all settings to default"})})]})})}const De=[{label:"bold",value:"bold"},{label:"italic",value:"italic"},{label:"underline",value:"underline"},{label:"strikethrough",value:"strikethrough"},{label:"inverse",value:"inverse"}];function Oo({onBack:e}){const{settings:t,updateSettings:n}=be(ue),[r,o]=O("prefix"),[i,a]=O(0),[l,u]=O(!1),[d,h]=O(()=>t.userMessageDisplay.prefix.format),[f,v]=O(0),[b,p]=O(()=>[...t.userMessageDisplay.prefix.styling]),[w,x]=O(()=>t.userMessageDisplay.prefix.foreground_color),[C,_]=O(()=>t.userMessageDisplay.prefix.background_color),[k,P]=O(0),[B,j]=O(0),[q,U]=O(()=>[...t.userMessageDisplay.message.styling]),[A,M]=O(()=>t.userMessageDisplay.message.foreground_color),[E,Y]=O(()=>t.userMessageDisplay.message.background_color),[X,oe]=O(null),[K,I]=O(""),$=hn(),S=t.themes?.find(H=>H.id===$)||t.themes?.[0],N=["format","styling","foreground","background"],y=["styling","foreground","background"],D=N[i],z=y[k],G=(H,R)=>{n(L=>{const ee=H==="prefix"?L.userMessageDisplay.prefix:L.userMessageDisplay.message;R(ee)})},ne=H=>{n(R=>{H==="prefix"?R.userMessageDisplay.prefix={...Z.userMessageDisplay.prefix}:R.userMessageDisplay.message={...Z.userMessageDisplay.message}}),H==="prefix"?(h(Z.userMessageDisplay.prefix.format),p([...Z.userMessageDisplay.prefix.styling]),x(Z.userMessageDisplay.prefix.foreground_color),_(Z.userMessageDisplay.prefix.background_color)):(U([...Z.userMessageDisplay.message.styling]),M(Z.userMessageDisplay.message.foreground_color),Y(Z.userMessageDisplay.message.background_color))};xe(()=>{const H=t.userMessageDisplay.prefix;h(H.format),p([...H.styling]),x(H.foreground_color),_(H.background_color);const R=t.userMessageDisplay.message;U([...R.styling]),M(R.foreground_color),Y(R.background_color)},[]),de((H,R)=>{if(l){if(R.return)G("prefix",L=>{L.format=d}),u(!1);else if(R.escape){const L=t.userMessageDisplay.prefix;h(L.format),u(!1)}else R.backspace||R.delete?h(L=>L.slice(0,-1)):H&&h(L=>L+H);return}if(X===null){if(R.escape)e();else if(R.ctrl&&H==="r")ne(r);else if(R.leftArrow||R.rightArrow)o(L=>L==="prefix"?"message":"prefix");else if(R.tab)r==="prefix"?R.shift?a(L=>L===0?N.length-1:L-1):a(L=>L===N.length-1?0:L+1):R.shift?P(L=>L===0?y.length-1:L-1):P(L=>L===y.length-1?0:L+1);else if(R.return)r==="prefix"?D==="format"?u(!0):D==="foreground"?(I(w),oe({column:"prefix",type:"foreground"})):D==="background"&&(I(C),oe({column:"prefix",type:"background"})):z==="foreground"?(I(A),oe({column:"message",type:"foreground"})):z==="background"&&(I(E),oe({column:"message",type:"background"}));else if(R.upArrow)r==="prefix"&&D==="styling"?v(L=>Math.max(0,L-1)):r==="message"&&z==="styling"&&j(L=>Math.max(0,L-1));else if(R.downArrow)r==="prefix"&&D==="styling"?v(L=>Math.min(De.length-1,L+1)):r==="message"&&z==="styling"&&j(L=>Math.min(De.length-1,L+1));else if(H===" "){if(r==="prefix"&&D==="styling"){const L=De[f].value,ee=b.indexOf(L)>=0?b.filter(W=>W!==L):[...b,L];p(ee),G("prefix",W=>{W.styling=[...ee]})}else if(r==="message"&&z==="styling"){const L=De[B].value,ee=q.indexOf(L)>=0?q.filter(W=>W!==L):[...q,L];U(ee),G("message",W=>{W.styling=[...ee]})}}}});const se=(H,R,L=!0)=>{const ee=L?R==="prefix"?b:q:[],W=L?R==="prefix"?w:A:"rgb(255,255,255)",Oe=L?R==="prefix"?C:E:"rgb(0,0,0)",Ae=W==="rgb(0,0,0)"&&Oe==="rgb(0,0,0)",Ue=ee.length>0;return Ae&&!Ue?s(c,{children:H}):s(c,{bold:ee.includes("bold"),italic:ee.includes("italic"),underline:ee.includes("underline"),strikethrough:ee.includes("strikethrough"),inverse:ee.includes("inverse"),color:Ae?void 0:W,backgroundColor:Ae?void 0:Oe,children:H})},$e=(H=!0)=>g(c,{children:[d&&g(me,{children:[se(d,"prefix",H)," "]}),se("list the dir","message",H)]}),we=H=>{const R=r===H,W=(H==="prefix"?N:y)[H==="prefix"?i:k],Oe=H==="prefix"?f:B,Ae=H==="prefix"?b:q,Ue=H==="prefix"?w:A,mn=H==="prefix"?C:E;return g(m,{flexDirection:"column",width:"45%",borderStyle:R?"round":"single",borderColor:R?"yellow":"gray",padding:1,children:[s(m,{marginBottom:1,children:g(c,{bold:!0,color:R?"yellow":void 0,children:[H.charAt(0).toUpperCase()+H.slice(1)," ","Configuration"]})}),H==="prefix"&&g(me,{children:[s(m,{children:g(c,{color:R&&W==="format"?"yellow":void 0,bold:R&&W==="format",children:[R&&W==="format"?"❯ ":" ","Prefix Text"]})}),R&&W==="format"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:l?"enter to save":"enter to edit (appears before message)"})}),s(m,{marginLeft:2,marginBottom:1,children:s(m,{borderStyle:"round",borderColor:l?"yellow":"gray",children:s(c,{children:d})})})]}),s(m,{children:g(c,{color:R&&W==="styling"?"yellow":void 0,bold:R&&W==="styling",children:[R&&W==="styling"?"❯ ":" ","Styling"]})}),R&&W==="styling"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"up/down to navigate · space to toggle"})}),s(m,{marginLeft:2,marginBottom:1,flexDirection:"column",children:De.map((qe,pn)=>s(m,{children:g(c,{color:R&&W==="styling"&&Oe===pn?"cyan":void 0,children:[R&&W==="styling"&&Oe===pn?"❯ ":" ",Ae.includes(qe.value)?"●":"○"," ",qe.label]})},qe.value))}),s(m,{children:g(c,{color:R&&W==="foreground"?"yellow":void 0,bold:R&&W==="foreground",children:[R&&W==="foreground"?"❯ ":" ","Foreground color"]})}),R&&W==="foreground"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,marginBottom:1,children:s(c,{color:Ue,children:Ue})}),s(m,{children:g(c,{color:R&&W==="background"?"yellow":void 0,bold:R&&W==="background",children:[R&&W==="background"?"❯ ":" ","Background color"]})}),R&&W==="background"&&s(m,{marginLeft:2,children:s(c,{dimColor:!0,children:"enter to open color picker"})}),s(m,{marginLeft:2,children:s(c,{backgroundColor:mn,children:mn})})]})};if(X){const{column:H,type:R}=X;return s(at,{initialValue:K,theme:S,onColorChange:L=>{H==="prefix"?R==="foreground"?(x(L),G("prefix",ee=>{ee.foreground_color=L})):(_(L),G("prefix",ee=>{ee.background_color=L})):R==="foreground"?(M(L),G("message",ee=>{ee.foreground_color=L})):(Y(L),G("message",ee=>{ee.background_color=L}))},onExit:()=>{oe(null),I("")}})}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:S?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]}),g(m,{flexDirection:"column",width:"50%",children:[s(m,{marginBottom:1,children:s(c,{underline:!0,children:"After (Your customization):"})}),s(m,{marginLeft:1,children:$e(!0)}),s(m,{marginLeft:1,marginTop:1,children:g(c,{children:[s(c,{color:S?.colors?.inactive||"#888888",children:"●"}),s(c,{children:" The directory "}),s(c,{color:S?.colors?.permission||"#00ff00",children:"C:\\Users\\user"}),s(c,{children:" contains "}),s(c,{bold:!0,children:"123"}),s(c,{children:" files."})]})})]})]})]})})]})}function Ao({onSubmit:e}){const{settings:t,updateSettings:n}=be(ue),[r,o]=O(0),i=()=>{n(b=>{b.inputBox||(b.inputBox={removeBorder:!1}),b.inputBox.removeBorder=!b.inputBox.removeBorder})},a=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showTweakccVersion=!b.misc.showTweakccVersion})},l=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.showPatchesApplied=!b.misc.showPatchesApplied})},u=()=>{n(b=>{b.misc||(b.misc={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0}),b.misc.expandThinkingBlocks=!b.misc.expandThinkingBlocks})};de((b,p)=>{p.return||p.escape?e():p.upArrow?o(w=>Math.max(0,w-1)):p.downArrow?o(w=>Math.min(3,w+1)):b===" "&&(r===0?i():r===1?a():r===2?l():r===3&&u())});const d=t.inputBox?.removeBorder?"☑":"☐",h=t.misc?.showTweakccVersion?"☑":"☐",f=t.misc?.showPatchesApplied?"☑":"☐",v=t.misc?.expandThinkingBlocks?"☑":"☐";return g(m,{flexDirection:"column",children:[s(m,{marginBottom:1,children:s(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:r===0?"cyan":void 0,children:r===0?"❯ ":" "}),s(c,{bold:!0,color:r===0?"cyan":void 0,children:"Remove input box border"})]})}),s(m,{flexDirection:"column",children: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:r===1?"cyan":void 0,children:r===1?"❯ ":" "}),s(c,{bold:!0,color:r===1?"cyan":void 0,children:"Show tweakcc version at startup"})]})}),s(m,{flexDirection:"column",children: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:r===2?"cyan":void 0,children:r===2?"❯ ":" "}),s(c,{bold:!0,color:r===2?"cyan":void 0,children:"Show patches applied indicator at startup"})]})}),s(m,{flexDirection:"column",children: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:r===3?"cyan":void 0,children:r===3?"❯ ":" "}),s(c,{bold:!0,color:r===3?"cyan":void 0,children:"Expand thinking blocks"})]})}),s(m,{flexDirection:"column",children:g(c,{dimColor:!0,children:[" ","Makes thinking blocks always expanded by default instead of collapsed."]})}),s(m,{marginLeft:4,marginBottom:1,children:g(c,{children:[v," ",t.misc?.expandThinkingBlocks?"Enabled":"Disabled"]})})]})}const He=["Task","Bash","Glob","Grep","Read","Edit","Write","NotebookEdit","WebFetch","WebSearch","BashOutput","KillShell","TodoWrite","AskUserQuestion","Skill","SlashCommand","ExitPlanMode"];function Po({toolsetIndex:e,onBack:t}){const{settings:n,updateSettings:r}=be(ue),o=n.toolsets[e],[i,a]=O(o?.name||"New Toolset"),[l,u]=O(o?.allowedTools||[]),[d,h]=O(!1),[f,v]=O(0);xe(()=>{o&&r(C=>{C.toolsets[e].name=i,C.toolsets[e].allowedTools=l})},[i,l]);const b=C=>l==="*"?!0:l.includes(C),p=C=>{C==="All"?u("*"):C==="None"?u([]):l==="*"?u(He.filter(_=>_!==C)):l.includes(C)?u(l.filter(_=>_!==C)):u([...l,C])};if(de((C,_)=>{if(d){_.return?h(!1):_.escape?(a(o?.name||"New Toolset"),h(!1)):_.backspace||_.delete?a(k=>k.slice(0,-1)):C&&C.length===1&&a(k=>k+C);return}if(_.escape)t();else if(_.upArrow)v(k=>Math.max(0,k-1));else if(_.downArrow)v(k=>Math.min(He.length+1,k+1));else if(C===" "||_.return)if(f===0)p("All");else if(f===1)p("None");else{const k=He[f-2];k&&p(k)}else C==="n"&&h(!0)}),!o)return s(m,{flexDirection:"column",children:s(c,{color:"red",children:"Toolset not found"})});const w=l==="*",x=Array.isArray(l)&&l.length===0;return g(m,{flexDirection:"column",children:[s(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?"❯ ":" ",x?"●":"○"," None"]})}),He.map((C,_)=>{const k=_+2;return s(m,{marginLeft:2,children:g(c,{color:f===k?"cyan":void 0,children:[f===k?"❯ ":" ",b(C)?"◉":"○"," ",C]})},C)})]}),s(m,{borderStyle:"round",padding:1,marginTop:1,children:g(m,{flexDirection:"column",children:[s(c,{bold:!0,children:"Summary:"}),g(c,{children:["Name: ",s(c,{color:"cyan",children:i})]}),g(c,{children:["Tools:"," ",l==="*"?s(c,{color:"green",children:"All tools (*)"}):l.length===0?s(c,{color:"red",children:"No tools ([])"}):g(c,{color:"yellow",children:[l.length," selected"]})]})]})})]})}function Do({onBack:e}){const{settings:{toolsets:t,defaultToolset:n},updateSettings:r}=be(ue),[o,i]=O(0),[a,l]=O(null),[u,d]=O(!0),h=()=>{const p={name:"New Toolset",allowedTools:[]};r(w=>{w.toolsets.push(p)}),l(t.length),d(!1)},f=p=>{const w=t[p];r(x=>{x.toolsets.splice(p,1),x.defaultToolset===w.name&&(x.defaultToolset=null)}),o>=t.length-1&&i(Math.max(0,t.length-2))},v=p=>{const w=t[p];r(x=>{x.defaultToolset=w.name})};if(de((p,w)=>{w.escape?e():w.upArrow?i(x=>Math.max(0,x-1)):w.downArrow?i(x=>Math.min(t.length-1,x+1)):w.return&&t.length>0?(l(o),d(!1)):p==="n"?h():p==="d"&&t.length>0?f(o):p==="s"&&t.length>0&&v(o)},{isActive:u}),a!==null)return s(Po,{toolsetIndex:a,onBack:()=>{l(null),d(!0)}});const b=p=>p.allowedTools==="*"?"All tools":p.allowedTools.length===0?"No tools":`${p.allowedTools.length} tool${p.allowedTools.length===1?"":"s"}`;return g(m,{flexDirection:"column",children:[s(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:"s to set as default toolset"}),t.length>0&&s(c,{dimColor:!0,children:"d to delete a toolset"}),t.length>0&&s(c,{dimColor:!0,children:"enter to edit toolset"}),s(c,{dimColor:!0,children:"esc to go back"})]}),t.length===0?s(c,{children:"No toolsets created yet. Press n to create one."}):s(m,{flexDirection:"column",children:t.map((p,w)=>{const x=p.name===n,C=o===w;return g(c,{color:C?"yellow":void 0,bold:x,children:[C?"❯ ":" ",p.name,x&&" [DEFAULT]"," (",b(p),")"]},w)})})]})}const ue=ut({settings:Z,updateSettings:e=>{},changesApplied:!1,ccVersion:""});function Lo({startupCheckInfo:e}){const[t,n]=O({settings:Z,changesApplied:!1,ccVersion:"",lastModified:"",ccInstallationDir:null});xe(()=>{(async()=>{n(await an())})()},[]);const r=Nn(h=>{const f=JSON.parse(JSON.stringify(t.settings));h(f),n(v=>({...v,settings:f,changesApplied:!1})),je(v=>{v.settings=f,v.changesApplied=!1})},[t.settings]),[o,i]=O(null),[a,l]=O(null);xe(()=>{e.wasUpdated&&e.oldVersion&&(l({message:`Your Claude Code installation was updated from ${e.oldVersion} to ${e.newVersion}, and the patching was likely overwritten
644
644
  (However, your customization are still remembered in ${ae}.)
645
- Please reapply your changes below.`,type:"warning"}),r(()=>{}))},[]),de((h,f)=>{(f.ctrl&&h==="c"||(h==="q"||f.escape)&&!o)&&process.exit(0)},{isActive:!o});const u=h=>{switch(l(null),h){case J.APPLY_CHANGES:e.ccInstInfo&&(l({message:"Applying patches...",type:"info"}),rt(t,e.ccInstInfo).then(f=>{n(f),l({message:"Customization patches applied successfully!",type:"success"})}));break;case J.THEMES:case J.THINKING_VERBS:case J.THINKING_STYLE:case J.USER_MESSAGE_DISPLAY:case J.MISC:case J.TOOLSETS:i(h);break;case J.VIEW_SYSTEM_PROMPTS:Co(Se);break;case J.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?qn(e.ccInstInfo):Jn(e.ccInstInfo)).then(()=>{l({message:"Original Claude Code restored successfully!",type:"success"}),r(()=>{})});break;case J.OPEN_CONFIG:kn(ae);break;case J.OPEN_CLI:e.ccInstInfo?.cliPath&&kn(e.ccInstInfo.cliPath);break;case J.EXIT:process.exit(0)}},c=()=>{i(null)};return s(ue.Provider,{value:{settings:t.settings,updateSettings:r,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:o===null?s(yt,{onSubmit:u,notification:a,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):o===J.THEMES?s(Bo,{onBack:c}):o===J.THINKING_VERBS?s(Oo,{onBack:c}):o===J.THINKING_STYLE?s(Ao,{onBack:c}):o===J.USER_MESSAGE_DISPLAY?s(Po,{onBack:c}):o===J.MISC?s(Lo,{onSubmit:c}):o===J.TOOLSETS?s(Ro,{onBack:c}):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{}},Vo=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.1").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const t=e.opts();if(t.debug&&$o(),t.apply){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${ae}`);const r=await an();(!r.settings||Object.keys(r.settings).length===0)&&(console.error("No saved customizations found in "+ae),process.exit(1));const o=await En();if(!o||!o.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:"),en.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(`
645
+ Please reapply your changes below.`,type:"warning"}),r(()=>{}))},[]),de((h,f)=>{(f.ctrl&&h==="c"||(h==="q"||f.escape)&&!o)&&process.exit(0)},{isActive:!o});const u=h=>{switch(l(null),h){case J.APPLY_CHANGES:e.ccInstInfo&&(l({message:"Applying patches...",type:"info"}),rt(t,e.ccInstInfo).then(f=>{n(f),l({message:"Customization patches applied successfully!",type:"success"})}));break;case J.THEMES:case J.THINKING_VERBS:case J.THINKING_STYLE:case J.USER_MESSAGE_DISPLAY:case J.MISC:case J.TOOLSETS:i(h);break;case J.VIEW_SYSTEM_PROMPTS:_o(Se);break;case J.RESTORE_ORIGINAL:e.ccInstInfo&&(e.ccInstInfo.nativeInstallationPath?qn(e.ccInstInfo):Jn(e.ccInstInfo)).then(()=>{l({message:"Original Claude Code restored successfully!",type:"success"}),r(()=>{})});break;case J.OPEN_CONFIG:kn(ae);break;case J.OPEN_CLI:e.ccInstInfo?.cliPath&&kn(e.ccInstInfo.cliPath);break;case J.EXIT:process.exit(0)}},d=()=>{i(null)};return s(ue.Provider,{value:{settings:t.settings,updateSettings:r,changesApplied:t.changesApplied,ccVersion:e.ccInstInfo?.version||""},children:s(m,{flexDirection:"column",children:o===null?s(yt,{onSubmit:u,notification:a,isNativeInstallation:!!e.ccInstInfo?.nativeInstallationPath}):o===J.THEMES?s(Mo,{onBack:d}):o===J.THINKING_VERBS?s(No,{onBack:d}):o===J.THINKING_STYLE?s(Bo,{onBack:d}):o===J.USER_MESSAGE_DISPLAY?s(Oo,{onBack:d}):o===J.MISC?s(Ao,{onSubmit:d}):o===J.TOOLSETS?s(Do,{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{}},Ro=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.2").option("-d, --debug","enable debug mode").option("-a, --apply","apply saved customizations without interactive UI"),e.parse();const t=e.opts();if(t.debug&&So(),t.apply){console.log("Applying saved customizations to Claude Code..."),console.log(`Configuration saved at: ${ae}`);const r=await an();(!r.settings||Object.keys(r.settings).length===0)&&(console.error("No saved customizations found in "+ae),process.exit(1));const o=await En();if(!o||!o.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:"),en.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(`
646
646
  Also checked for 'claude' executable on PATH using '${process.platform==="win32"?"where claude.exe":"which claude"}'.`),process.exit(1)}o.ccInstInfo.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${o.ccInstInfo.nativeInstallationPath}`):console.log(`Found Claude Code at: ${o.ccInstInfo.cliPath}`),console.log(`Version: ${o.ccInstInfo.version}`),console.log("Loading system prompts...");const i=await _n(o.ccInstInfo.version);i.success||(console.log(Q.red(`
647
647
  ✖ Error downloading system prompts:`)),console.log(Q.red(` ${i.errorMessage}`)),console.log(Q.yellow(`
648
648
  ⚠ System prompts not available - skipping system prompt customizations`))),console.log("Applying customizations..."),await rt(r,o.ccInstInfo),console.log("Customizations applied successfully!"),process.exit(0)}const n=await En();if(n){const r=await _n(n.ccInstInfo.version);r.success||(console.log(Q.red(`
649
649
  ✖ Error downloading system prompts:`)),console.log(Q.red(` ${r.errorMessage}`)),console.log(Q.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
650
- `))),ct(s(Fo,{startupCheckInfo:n}))}else{const r=()=>en.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(`
650
+ `))),ct(s(Lo,{startupCheckInfo:n}))}else{const r=()=>en.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(`
651
651
  `)}}else return`- ${i.pattern}`}).join(`
652
652
  `),o=process.platform=="win32"?"C:\\absolute\\path\\to\\node_modules\\@anthropic-ai\\claude-code":"/absolute/path/to/node_modules/@anthropic-ai/claude-code";await Mn(o),console.error(`Cannot find Claude Code's cli.js -- do you have Claude Code installed?
653
653
 
@@ -670,4 +670,4 @@ Notes:
670
670
  - Don't specify the path to your Claude Code executable's directory. It needs to be the path
671
671
  to the folder that contains **cli.js**.
672
672
  - Please also open an issue so that we can add your path to the search list for all users!
673
- `),process.exit(1)}};Vo();
673
+ `),process.exit(1)}};Ro();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tweakcc",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "type": "module",
5
5
  "description": "Command-line tool to customize your Claude Code theme colors, thinking verbs and more.",
6
6
  "main": "dist/index.js",
@@ -56,7 +56,7 @@
56
56
  "gray-matter": "^4.0.3",
57
57
  "ink": "^6.1.0",
58
58
  "ink-link": "^4.1.0",
59
- "node-lief": "0.1.5",
59
+ "node-lief": "0.1.6",
60
60
  "ollama": "^0.6.0",
61
61
  "openai": "^6.3.0",
62
62
  "react": "^19.1.1"