tweakcc-fixed 2.0.2 → 2.0.3

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.
@@ -1,4 +1,4 @@
1
- import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c from"node:fs";import*as l from"node:path";import u from"node:path";import*as d from"fs";import*as f from"path";import*as p from"os";import*as m from"child_process";import*as h from"crypto";import{spawnSync as g}from"node:child_process";import _ from"gray-matter";import{fileURLToPath as v}from"node:url";import{Worker as y}from"node:worker_threads";import{diffWordsWithSpace as b}from"diff";let x=null;async function S(){if(x!==null)return x;try{return await import(`node-lief`),x=await import(`./nativeInstallation-CQ6v6E77.mjs`),x}catch(e){return G(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&G(e),null}}async function C(e,t){let n=await S();return n?n.extractClaudeJsFromNativeInstallation(e,t):{data:null,clearBytecode:!1}}async function w(e,t,n,r){let i=await S();if(!i)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");i.repackNativeInstallation(e,t,n,r)}async function T(e){let t=await S();return t?t.resolveNixBinaryWrapper(e):null}const E={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.Architecting.Baking.Beaming.Beboppin'.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Dilly-dallying.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Mustering.Musing.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzle-dazzling.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Sautéing.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Sock-hopping.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Topsy-turvying.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:`default`,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:`default`,paddingY:`default`,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSwarmMode:!0,enableSessionMemory:!0,enableDreamMode:!0,enableLeanMemoryTypes:!1,fixSummarizeFromHere:!0,fixRewindSummaryHeader:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autoModeClassifierModel:`default`,suppressDeferredTools:!1,claudemdContextOncePerConversation:!0},toolsets:[],defaultToolset:null,planModeToolset:null,subagentModels:{plan:null,explore:null,generalPurpose:null},inputPatternHighlighters:[],inputPatternHighlightersTestText:`Type test text here to see highlighting`,claudeMdAltNames:[`AGENTS.md`,`GEMINI.md`,`CRUSH.md`,`QWEN.md`,`IFLOW.md`,`WARP.md`,`copilot-instructions.md`]},D={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},ee={name:`Unnamed Toolset`,allowedTools:`*`},te=E.themes[0],ne=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},re=e=>{let t=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),[\w$]+=[\w$]+\?[\w$]+:Math\.max\(1,Math\.min\(Math\.max\(6,Math\.floor\(\1\/2\)\),\1-3\)\)/);if(t&&t.index!==void 0){let n=t[1],r=`Math.floor(${n}/2)`,i=t.index+t[0].indexOf(r),a=i+r.length,o=e.slice(0,i)+n+e.slice(a);return M(e,o,n,i,a),o}let n=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),([\w$]+)=Math\.floor\(\1\/2\)/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(n[2]+`=Math.floor(`),r=n.index+n[0].length,i=`${n[2]}=${n[1]}`,a=e.slice(0,t)+i+e.slice(r);return M(e,a,i,t,r),a}let r=/Math\.max\(1,Math\.floor\(\(([\w$]+)-([\w$]+)\)\/([\w$]+)\)\)/g,i;for(;(i=r.exec(e))!==null;){let t=Math.max(0,i.index-250),n=e.slice(t,i.index);if(!n.includes(`"expanded"?3`)||!n.includes(`"compact"?1:2`))continue;let r=i.index,a=i.index+i[0].length,o=`Math.max(1,${i[1]}-${i[2]})`,s=e.slice(0,r)+o+e.slice(a);return M(e,s,o,r,a),s}return null},O=e=>{let t=e.match(/Math\.max\(1,Math\.floor\(\(([\w$]+)-10\)\/2\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},k=e=>{if(!e.includes(`Math.min(6,Math.max(1,`))return G(`patch: showMoreItemsInSelectMenus: suggestions cap already removed in this CC build — no-op`),e;let t=e.match(/Math\.min\(6,Math\.max\(1,([\w$]+)-3\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},ie=(e,t)=>{let n=ne(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);M(i,r,n,e.startIndex,e.endIndex),i=r}let a=re(i);a?i=a:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find help menu height pattern`);let o=O(i);o?i=o:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find visibleCount pattern`);let s=k(i);return s&&(i=s),i};function ae(e){let t=-1,n=-1,r=``,i=e.match(/switch\(([$\w]+)\)\{case"(?:light|dark)":[^}]*return [$\w]+;[^}]*default:return [$\w]+\}/);if(i&&i.index!=null)t=i.index,n=t+i[0].length,r=i[1];else{if(e.indexOf(`case"dark":return{"autoAccept"`)===-1&&e.indexOf(`case"light":return{`)===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let i=e.indexOf(`case"dark":return{`)===-1?e.indexOf(`case"light":return{`):e.indexOf(`case"dark":return{`),a=e.slice(Math.max(0,i-200),i).match(/switch\(([$\w]+)\)\{\s*$/);if(!a||a.index==null)return console.error(`patch: themes: failed to find switchMatch (old format)`),null;t=Math.max(0,i-200)+a.index,r=a[1];let o=0;for(let r=t;r<e.length&&r<t+5e4;r++)if(e[r]===`{`&&o++,e[r]===`}`&&(o--,o===0)){n=r+1;break}}if(t===-1||n===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let a=-1,o=-1,s=``,c=e.match(/\[(?:\.\.\.\[\],)?(?:\{"?label"?:"(?:Dark|Light|Auto|Monochrome)[^"]*","?value"?:"[^"]+"\},?)+\]/);if(c&&c.index!==void 0)a=c.index,o=c.index+c[0].length;else{let t=[...e.matchAll(/([$\w]+)=\{label:"(?:Auto|Dark|Light|Monochrome)[^"]*",value:"[^"]+"\}/g)];if(t.length<2)return console.error(`patch: themes: failed to find objArrMatch`),null;let n=t.map(e=>e[1]).map(e=>e.replace(/\$/g,`\\$`)).join(`,`),r=RegExp(`\\[${n}((?:,\\.\\.\\.[^\\]]+)*)\\]`),i=e.match(r);if(!i||i.index===void 0)return console.error(`patch: themes: failed to find objArrMatch (new var-collected form)`),null;a=i.index,o=i.index+i[0].length,s=i[1]}let l=e.match(/(return|[$\w]+=)\{(?:"?(?:[$\w-]+)"?:"(?:Auto |Dark|Light|Monochrome)[^"]*",?)+\}/);return(!l||l.index==null)&&G(`patch: themes: objMatch not found — colors will still apply, theme name map unchanged`),{switchStatement:{startIndex:t,endIndex:n,identifiers:[r]},objArr:{startIndex:a,endIndex:o,identifiers:[s]},obj:l&&l.index!==void 0?{startIndex:l.index,endIndex:l.index+l[0].length,identifiers:[l[1]]}:null}}const oe=(e,t)=>{let n=ae(e);if(!n)return null;if(t.length===0)return e;let r=e;if(n.obj){let i=(n.obj.identifiers?.[0]??`return`)+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),M(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r}let i=n.objArr.identifiers?.[0]??``,a=`[${t.map(e=>JSON.stringify({label:e.name,value:e.id})).join(`,`)}${i}]`;r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),M(e,r,a,n.objArr.startIndex,n.objArr.endIndex),e=r;let o=`switch(${n.switchStatement.identifiers?.[0]}){\n`;return t.forEach(e=>{o+=`case"${e.id}":return${JSON.stringify(e.colors)};\n`}),o+=`default:return${JSON.stringify(t[0].colors)};\n}`,r=r.slice(0,n.switchStatement.startIndex)+o+r.slice(n.switchStatement.endIndex),M(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},se=e=>{let t=/var ([\w$]+)=200000,([\w$]+)=20000,([\w$]+)=32000,([\w$]+)=(128000|64000);/,n=e.match(t);return n?e.replace(t,`var ${n[1]}=(+process.env.CLAUDE_CODE_CONTEXT_LIMIT||200000),${n[2]}=20000,${n[3]}=32000,${n[4]}=${n[5]};`):(console.error(`patch: contextLimit: failed to find context limit constants`),null)},ce=(e,t)=>{if(!t)return e;let n=e,r=!1,i=n.match(/createElement\(([$\w]+),\{color:([$\w]+)\.bgColor\},"─"\.repeat\(([$\w]+)\)\)/);if(i){let e=i[1];n=n.replace(i[0],`createElement(${e},null,"")`);let t=RegExp(`createElement\\(${e},\\{color:${i[2]}\\.bgColor\\},${i[2]}\\.text\\?.+?"─"\\.repeat\\(${i[3]}\\)\\)`),a=n.match(t);a&&(n=n.replace(a[0],`createElement(${e},null,"")`)),r=!0}let a=n.match(/(borderColor:[$\w]+\(\),)borderStyle:"round"(,borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",borderText:)/);a&&(n=n.replace(a[0],`${a[1]}borderStyle:undefined${a[2]}`),r=!0);let o=n.match(/borderStyle:"round"(,borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%"\}.+?Save and close editor)/);return o&&(n=n.replace(o[0],`borderStyle:undefined${o[1]}`),r=!0),r?(M(e,n,`(input border removed)`,0,0),n):(console.error(`patch: input border: failed to find input border pattern`),null)},le=e=>{let t=(e.match(/overrideMessage:[$\w]+,isCompacting:[$\w]+,compactingHintText:[$\w]+,compactingStartTime:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/)||e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/)||e.match(/overrideMessage:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/)||e.match(/pauseStartTimeRef:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/))?.index,n=t===void 0?``:e.slice(t,t+2e4),r=n.match(/,([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);if(r&&r.index!=null)return{startIndex:t+r.index+r[1].length+1,endIndex:t+r.index+r[1].length+r[2].length+1,identifiers:[r[3]]};let i=/,([$\w]+)(=(\([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+\))\+"(?:…|\\u2026)")/,a=n.match(i);if(a&&a.index!=null)return{startIndex:t+a.index+a[1].length+1,endIndex:t+a.index+a[1].length+a[2].length+1,identifiers:[a[3]]};let o=n.match(/,([$\w]+)(=`\$\{([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+)\}(?:…|\\u2026) ?`)/);if(o&&o.index!=null)return{startIndex:t+o.index+o[1].length+1,endIndex:t+o.index+o[1].length+o[2].length+1,identifiers:[o[3]]};let s=new RegExp(i.source,`g`),c=[...e.matchAll(s)].filter(t=>{if(t.index==null)return!1;let n=e.slice(Math.max(0,t.index-2500),t.index+1e3);return n.includes(`overrideMessage:`)&&n.includes(`.activeForm`)&&n.includes(`.isIdle`)&&n.includes(`.spinnerVerb`)&&n.includes(`spinnerTip`)});if(c.length===1){let e=c[0];return{startIndex:e.index+e[1].length+1,endIndex:e.index+e[1].length+e[2].length+1,identifiers:[e[3]]}}return console.error(`patch: thinker format: failed to find formatMatch`),null},ue=(e,t)=>{let n=le(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o=`=${"`"+i.replace(/\{\}/g,"${"+a+`}`)+"`"}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);return M(e,s,o,r.startIndex,r.endIndex),s},de=e=>{let t=e.match(/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/);return!t||t.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},fe=(e,t)=>{let n=de(e);if(!n)return null;let r=n.identifiers?.[0],i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return M(e,a,i,n.startIndex,n.endIndex),a},pe=(e,t)=>{let n=[],r=/\["(?:[·✢*✳✶✻✽]|\\u00b7|\\xb7|\\u2722|\\x2a|\\u002a|\\u2733|\\u2736|\\u273b|\\u273d)",\s*(?:"(?:[·✢*✳✶✻✽]|\\u00b7|\\xb7|\\u2722|\\x2a|\\u002a|\\u2733|\\u2736|\\u273b|\\u273d)",?\s*)+\]/gi,i;for(;(i=r.exec(e))!==null;)n.push({startIndex:i.index,endIndex:i.index+i[0].length});if(n.length===0)return console.error(`patch: thinkerSymbolChars: could not find any thinker symbol char arrays`),null;let a=JSON.stringify(t),o=n.sort((e,t)=>t.startIndex-e.startIndex),s=e;for(let e=0;e<o.length;e++){let t=s.slice(0,o[e].startIndex)+a+s.slice(o[e].endIndex);M(s,t,a,o[e].startIndex,o[e].endIndex),s=t}return s},me=(e,t)=>{let n=e.match(/(if\(![$\w]+\)\{[$\w]+\(4\);return\})(.{0,200})120\)/);if(!n||n.index===void 0)return console.error(`patch: thinkerSymbolSpeed: failed to find thinker symbol speed pattern`),null;let r=n[2]+t+`)`,i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},he=e=>{let t=e.match(/\{("aria-hidden":!0,)?flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,prefix:t[1]??``}},ge=(e,t)=>{let n=he(e);if(!n)return null;let r=`{${n.prefix}flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return M(e,i,r,n.startIndex,n.endIndex),i},_e=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+in[g']",?){50,}\]/);if(!n||n.index===void 0)return console.error(`patch: thinkingVerbs: failed to find present tense verbs pattern`),null;let r=JSON.stringify(t),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},ve=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+ed",?){6,}\]/);if(!n||n.index===void 0)return console.error(`patch: thinkingVerbs: failed to find past tense verbs pattern`),null;let r=t.map(e=>e.replace(/ing$/,`ed`)),i=JSON.stringify(r),a=n.index,o=a+n[0].length,s=e.slice(0,a)+i+e.slice(o);return M(e,s,i,a,o),s},ye=(e,t)=>{let n=_e(e,t);if(n===null)return null;let r=ve(n,t);return r===null?null:r},be=(e,t)=>{let n=H(e);if(!n)return console.error(`patch: userMessageDisplay: failed to find Text component`),null;let r=ki(e),i=R(e);if(!i)return console.error(`patch: userMessageDisplay: failed to find chalk variable`),null;let a=/(No content found in user prompt message.{0,250}?\b)([$\w]+(?:\.default)?\.createElement.{0,30}\b[$\w]+(?:\.default)?\.createElement.{0,40}">.+?)?(([$\w]+(?:\.default)?\.createElement).{0,200})(\([$\w]+,(?:\{[^{}]+wrap:"wrap"\},([$\w]+)(?:\.trim\(\))?\)\)|\{text:([$\w]+)[^}]*\}\)\)?))/,o=e.match(/(No content found in user prompt message[\s\S]{0,100}?;return )([$\w]+(?:\.default)?)\.createElement\(([$\w]+),(\{flexDirection:"column"[^{}]*\}),([$\w]+(?:\.default)?)\.createElement\(([$\w]+),\{text:([$\w]+)[^{}]*\}\)\)/),s=o?null:e.match(/(No content found in user prompt message.{0,1200}?)([$\w]+)=([$\w]+(?:\.default)?\.createElement)\([$\w]+,\{text:([$\w]+),useBriefLayout:[$\w]+,timestamp:[$\w]+\}\)/),c=o||s?null:e.match(a);if(!o&&(!s||s.index===void 0)&&(!c||c.index===void 0))return console.error(`patch: userMessageDisplay: failed to find user message display pattern`),e;let l=e=>`(typeof ${e}==="object"&&${e}!==null?${e}.head+"\\n("+${e}.hiddenLines+" line"+(${e}.hiddenLines===1?"":"s")+" hidden)\\n"+${e}.tail:${e})`;if(o){let r=o[1],i=o[2],a=o[3],s=o[4],c=o[5],u=o[7],d=s.slice(1,-1),f=/backgroundColor:[^,}]+(?:\?[^,}:]+:[^,}:]+)*/;if(t.backgroundColor===null)d=d.replace(RegExp(`,?${f.source}`),``).replace(/^,|,$/g,``);else if(t.backgroundColor!==`default`){let e=t.backgroundColor.match(/\d+/g);if(e){let t=`"rgb(${e.join(`,`)})"`;d=d.replace(/"userMessageBackground"/g,t)}}let p=[];if(t.borderStyle!==`none`){if(t.borderStyle.startsWith(`topBottom`)){let e=``;t.borderStyle===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),p.push(`borderStyle:${e}`)}else p.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&p.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX!==`default`&&t.paddingX>0&&p.push(`paddingX:${t.paddingX}`),t.paddingY!==`default`&&t.paddingY>0&&p.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&p.push(`alignSelf:"flex-start"`),p.length>0&&(d=d?`${d},${p.join(`,`)}`:p.join(`,`));let m=`{${d}}`,h=[];if(t.foregroundColor===`default`)h.push(`color:"text"`);else{let e=t.foregroundColor.match(/\d+/g);e&&h.push(`color:"rgb(${e.join(`,`)})"`)}if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);e&&h.push(`backgroundColor:"rgb(${e.join(`,`)})"`)}else t.backgroundColor===`default`&&h.push(`backgroundColor:"userMessageBackground"`);t.styling.includes(`bold`)&&h.push(`bold:!0`),t.styling.includes(`italic`)&&h.push(`italic:!0`),t.styling.includes(`underline`)&&h.push(`underline:!0`),t.styling.includes(`strikethrough`)&&h.push(`strikethrough:!0`),t.styling.includes(`inverse`)&&h.push(`inverse:!0`);let g=h.length>0?`{${h.join(`,`)}}`:`null`,_=l(u),v=r+`${i}.createElement(${a},${m},${c}.createElement(${n},${g},${"`"+t.format.replace(/\{\}/g,()=>"${"+_+`}`)+"`"}))`,y=o.index,b=y+o[0].length,x=e.slice(0,y)+v+e.slice(b);return M(e,x,v,y,b),x}if(!r)return console.error(`patch: userMessageDisplay: failed to find Box component`),null;let u=s??c,d=s?s[3]:c[4],f=s?s[4]:c[6]??c[7],p=[],m=t.borderStyle.startsWith(`topBottom`);if(t.borderStyle!==`none`){if(m){let e=``;t.borderStyle===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),p.push(`borderStyle:${e}`)}else p.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&p.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX===`default`?p.push(`paddingRight:1`):t.paddingX>0&&p.push(`paddingX:${t.paddingX}`),t.paddingY!==`default`&&t.paddingY>0&&p.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&p.push(`alignSelf:"flex-start"`);let h=i,g=[];if(t.foregroundColor!==`default`){let e=t.foregroundColor.match(/\d+/g);e&&(h+=`.rgb(${e.join(`,`)})`)}else g.push(`color:"text"`);if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);if(e){h+=`.bgRgb(${e.join(`,`)})`;let t=`"rgb(${e.join(`,`)})"`;p.push(`backgroundColor:${t}`),g.push(`backgroundColor:${t}`)}}else t.backgroundColor===`default`&&(p.push(`backgroundColor:"userMessageBackground"`),g.push(`backgroundColor:"userMessageBackground"`));t.styling.includes(`bold`)&&(h+=`.bold`),t.styling.includes(`italic`)&&(h+=`.italic`),t.styling.includes(`underline`)&&(h+=`.underline`),t.styling.includes(`strikethrough`)&&(h+=`.strikethrough`),t.styling.includes(`inverse`)&&(h+=`.inverse`);let _=l(f),v="`"+t.format.replace(/\{\}/g,()=>"${"+_+`}`)+"`",y=`${h}(${v})`,b=p.length>0?`{${p.join(`,`)}}`:`null`,x=g.length>0?`{${g.join(`,`)}}`:`null`,S=s?`${s[2]}=`:``,C=u[1]+`${S}${d}(${r},${b},${d}(${n},${x},${y}))`,w=u.index,T=w+u[0].length,E=e.slice(0,w)+C+e.slice(T);return M(e,E,C,w,T),E},xe=(e,t)=>{let n=e;if(t.foregroundColor){let e=t.foregroundColor.match(/\d+/g);e&&(n+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor){let e=t.backgroundColor.match(/\d+/g);e&&(n+=`.bgRgb(${e.join(`,`)})`)}return t.styling.includes(`bold`)&&(n+=`.bold`),t.styling.includes(`italic`)&&(n+=`.italic`),t.styling.includes(`underline`)&&(n+=`.underline`),t.styling.includes(`strikethrough`)&&(n+=`.strikethrough`),t.styling.includes(`inverse`)&&(n+=`.inverse`),n},Se=e=>{let t=e.match(/(if\(([$\w]+)\.highlight\?\.color\))((return [$\w]+\.createElement\([$\w]+,\{key:[$\w]+),color:[$\w]+\.highlight\.color(\},[$\w]+\.createElement\([$\w]+,null,)([$\w]+\.text)(\)\)));/);if(t&&t.index!==void 0){let n=`${t[2]}.highlight.color(${t[6]})`,r=t[1]+`{if(typeof ${t[2]}.highlight.color==='function')`+t[4]+t[5]+n+t[7]+`;else `+t[3]+`}`,i=e.slice(0,t.index)+r+e.slice(t.index+t[0].length);return M(e,i,r,t.index,t.index+t[0].length),i}let n=/(return ([$\w]+)\.createElement\(([$\w]+),\{key:([$\w]+)),color:([$\w]+)\.highlight\?\.color,dimColor:\5\.highlight\?\.dimColor,inverse:\5\.highlight\?\.inverse\},(\2\.createElement\([$\w]+,null,\5\.text\))\)/,r=e.match(n);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find highlight?.color renderer pattern`),null;let i=r[2],a=r[3],o=r[4],s=r[5];r[6];let c=RegExp(`if\\(${s.replace(`$`,`\\$`)}\\.highlight\\.color\\)return ([$\\w]+)\\.createElement\\([$\\w]+,\\{key:[$\\w]+\\},${s.replace(`$`,`\\$`)}\\.text\\.split\\(""\\)\\.map\\([^)]+\\)\\)`),l=e,u=l.match(c);if(u&&u.index!==void 0){let e=`if(typeof ${s}.highlight?.color==='function')return ${i}.createElement(${a},{key:${o}},${i}.createElement(${a},null,${s}.highlight.color(${s}.text)));`;l=l.slice(0,u.index)+e+l.slice(u.index)}let d=l.match(n);if(!d||d.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to re-find renderer after shimmer patch`),null;let f=d[2],p=d[3],m=d[4],h=d[5],g=d[6],_=`${h}.highlight?.style?${h}.highlight.style(${h}.text):${h}.text`,v=`return ${f}.createElement(${p},{key:${m},color:${h}.highlight?.style?void 0:${h}.highlight?.color,backgroundColor:${h}.highlight?.style?void 0:${h}.highlight?.backgroundColor,dimColor:${h}.highlight?.dimColor,inverse:${h}.highlight?.style?void 0:${h}.highlight?.inverse,bold:${h}.highlight?.style?void 0:${h}.highlight?.bold,italic:${h}.highlight?.style?void 0:${h}.highlight?.italic,underline:${h}.highlight?.style?void 0:${h}.highlight?.underline,strikethrough:${h}.highlight?.style?void 0:${h}.highlight?.strikethrough},${g.replace(`${h}.text`,_)})`,y=l.slice(0,d.index)+v+l.slice(d.index+d[0].length);return M(e,y,`shimmer guard + renderer`,0,0),y},Ce=(e,t,n)=>{let r=e.match(/((?:,|;let )[$\w]+=[$\w]+\.useMemo\(\(\)=>\{let [$\w]+=\[\];[\s\S]{0,2000}?)(if\([$\w]+&&[$\w]+&&![$\w]+\)([$\w]+)\.push\(\{start:[$\w]+,end:[$\w]+\+[$\w]+\.length,color:"warning",priority:\d+\})/);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find useMemo/push pattern`),null;let i=r[3],a=r[1].match(/[^$\w]([$\w]+(?:\.default)?)\.useMemo\(/);if(!a)return console.error(`patch: inputPatternHighlighters: failed to extract React var from useMemo`),null;a[1];let o=Math.max(0,r.index-15e3),s=e.slice(o,r.index),c=/\binputValue:([$\w]+),/g,l=/\binput:([$\w]+),/g,u=[...s.matchAll(c)],d=[...s.matchAll(l)],f=u.at(-1)??d.at(-1)??null;if(!f)return console.error(`patch: inputPatternHighlighters: failed to find input variable pattern (looked for inputValue: and input:)`),null;let p=f[1],m=``;for(let e=0;e<n.length;e++){let r=n[e],a=xe(t,r),o=r.format??`{MATCH}`;JSON.stringify(o).replace(/\{MATCH\}/g,`"+x+"`);let s=r.foregroundColor;if(s){let e=s.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);s=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let c=s?JSON.stringify(s):`undefined`,l=r.backgroundColor;if(l){let e=l.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);l=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let u=l?JSON.stringify(l):null,d=r.styling??[],f=d.includes(`bold`),h=d.includes(`italic`),g=d.includes(`underline`),_=d.includes(`inverse`),v=d.includes(`dim`),y=d.includes(`strikethrough`),b=r.regex??r.pattern;if(!b){console.error(`patch: inputPatternHighlighters: highlighter "${r.name}" has no regex/pattern; skipping`);continue}let x=r.regexFlags??``;x.includes(`g`)||(x+=`g`);let S;try{S=new RegExp(b,x)}catch(e){console.error(`patch: inputPatternHighlighters: highlighter "${r.name}" has invalid regex; skipping`,e);continue}let C=ca(S);m+=`if(typeof ${p}==="string"){for(let m of ${p}.matchAll(${C})){${i}.push({start:m.index,end:m.index+m[0].length,color:${c}${u?`,backgroundColor:${u}`:``}${f?`,bold:!0`:``}${h?`,italic:!0`:``}${g?`,underline:!0`:``}${_?`,inverse:!0`:``}${v?`,dimColor:!0`:``}${y?`,strikethrough:!0`:``},style:(x)=>${a}(x),priority:100})}}`}if(!m)return console.error(`patch: inputPatternHighlighters: no usable highlighters generated (all skipped)`),null;let h=r[1]+m+r[2],g=e.slice(0,r.index),_=e.slice(r.index+r[0].length),v=g+``+h+_,y=v.indexOf(`for(let m of ${p}.matchAll(`);if(y>-1){let e=[...v.slice(Math.max(0,y-2e3),y).matchAll(/useMemo\(\(\)=>\{/g)];if(e.length>0){let t=Math.max(0,y-2e3)+e[e.length-1].index,n=v.slice(t),r=0;for(let e=0;e<n.length;e++)if(n[e]===`(`)r++;else if(n[e]===`)`&&(r--,r===0)){let n=t+e;v.slice(n-1,n)===`]`&&(v.slice(n-200,n).includes(`,${p}]`)||(v=v.slice(0,n-1)+`,${p}]`+v.slice(n)));break}}}return M(e,v,``+h,r.index,r.index+r[0].length),v},we=(e,t)=>{let n=t.filter(e=>e.enabled!==!1);if(n.length===0)return console.error(`patch: inputPatternHighlighters: no enabled highlighters provided`),null;let r=R(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i;return i=Se(e),i?(i=Ce(i,r,n),i||(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterCreation failed`),null)):(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterImpl failed`),null)},Te=e=>{let t=e.match(/(?:[$\w]+\.)?createElement\([$\w]+,\{(?=[^}]*responseLengthRef:)(?=[^}]*spinnerSuffix:)(?=[^}]*thinkingStatus:)(?=[^}]*isCompacting:)[^}]*verbose:[^,}]+[^}]*\}/);if(t&&t.index!==void 0){let e=t[0].match(/verbose:[^,}]+/);if(!e||e.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let n=t.index+e.index;return{startIndex:n,endIndex:n+e[0].length,replacement:`verbose:true`}}let n=e.match(/\{[^{}]{0,400}overrideMessage:[$\w]+,[^{}]{0,200}verbose:([$\w]+)[^{}]{0,200}\}\)\{/);if(n&&n.index!==void 0){let e=n[1],t=n.index+n[0].length;return{startIndex:t,endIndex:t,replacement:`${e}=!0;`}}return console.error(`patch: verbose: failed to find spinner props containing overrideMessage and verbose`),null},Ee=e=>{let t=Te(e);if(!t)return null;let n=e.slice(0,t.startIndex)+t.replacement+e.slice(t.endIndex);return M(e,n,t.replacement,t.startIndex,t.endIndex),n},De=e=>{let t=e.match(/if\s*\(\s*([$\w]+)\(\)\s*===\s*"opusplan"\s*&&\s*([$\w]+)\s*===\s*"plan"\s*&&\s*!([$\w]+)\s*\)\s*return\s*([$\w]+)\(\);/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModeSwitchingFunction: failed to find mode switching pattern`),null;let[n,r,i,a,o]=t,s=`if((${r}()==="opusplan"||${r}()==="opusplan[1m]")&&${i}==="plan"&&!${a})return ${o}();`,c=e.slice(0,t.index)+s+e.slice(t.index+n.length);return M(e,c,s,t.index,t.index+n.length),c},Oe=e=>{let t=e.match(/(\["sonnet","opus","haiku",(?:"best",)?"sonnet\[1m\]",(?:"opus\[1m\]",)?"opusplan")/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModelAliasesList: failed to find model aliases list`),null;let n=t[0]+`,"opusplan[1m]"`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},ke=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"([^"]*Opus[^"]*plan mode[^"]*Sonnet[^"]*)";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchDescriptionFunction: failed to find description pattern`),null;let[n,,r,i]=t,a=n+`if(${r}==="opusplan[1m]")return"${i} (1M context)";`,o=e.slice(0,t.index)+a+e.slice(t.index+n.length);return M(e,o,a,t.index,t.index+n.length),o},Ae=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"Opus Plan";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchLabelFunction: failed to find label pattern`),null;let[n,,r]=t,i=n+`if(${r}==="opusplan[1m]")return"Opus Plan 1M";`,a=e.slice(0,t.index)+i+e.slice(t.index+n.length);return M(e,a,i,t.index,t.index+n.length),a},je=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*(?:[$\w]+\()?\[\s*\.\.\.([$\w]+)\s*,\s*([$\w]+)\(\)\s*\]\)?;)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModelSelectorOptions: failed to find model selector pattern`),null;let[n,,r,i]=t,a=n.match(RegExp(`return\\s*([$\\w]+)\\(\\s*\\[\\.\\.\\.${W(i)}`)),o=a?a[1]:null,s=`{value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus in plan mode, Sonnet (1M context) otherwise"}`,c=n+`if(${r}==="opusplan[1m]")return ${o?`${o}([...${i},${s}])`:`[...${i},${s}]`};`,l=e.slice(0,t.index)+c+e.slice(t.index+n.length);return M(e,l,c,t.index,t.index+n.length),l},Me=e=>{let t=e.match(/(if\s*\(\s*[$\w]+\s*===\s*null\s*\|\|\s*([$\w]+)\.some\s*\(\s*\(\s*[$\w]+\s*\)\s*=>\s*[$\w]+\.value\s*===\s*[$\w]+\s*\)\s*\)\s*return\s*(?:[$\w]+\()?[$\w]+\)?\s*;)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchAlwaysShowInModelSelector: failed to find model list check pattern`),null;let[,,n]=t,r=`${n}.push({value:"opusplan",label:"Opus Plan Mode",description:"Use Opus in plan mode, Sonnet otherwise"});${n}.push({value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus in plan mode, Sonnet (1M context) otherwise"});`,i=e.slice(0,t.index)+r+e.slice(t.index);return M(e,i,r,t.index,t.index),i},Ne=e=>{if(e.includes(`"opusplan[1m]"`))return console.log(`patch: opusplan1m: opusplan[1m] already supported natively — skipping`),e;let t=e,n=De(t);if(n)t=n;else return console.error(`patch: opusplan1m: failed to apply mode switching patch`),null;if(n=Oe(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model aliases list patch`),null;if(n=ke(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply description function patch`),null;if(n=Ae(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply label function patch`),null;if(n=je(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model selector options patch`),null;if(n=Me(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply always-show-in-selector patch`),null;return t},Pe=e=>{if(/case"thinking":\{(?:(?!case")[^]){0,600}isTranscriptMode:true/.test(e))return console.log(`patch: thinkingVisibility: already configured natively — skipping`),e;let t=e.match(/(case"thinking":\{?)(if\(.+?\)return null;)(.{0,400}isTranscriptMode:).+?,/);if(!t||t.index===void 0)return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null;let n=t[1]+t[3]+`true,`,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return M(e,a,n,r,i),a},Fe=(e,t)=>{let n=e.match(/(agentType\s*:\s*"Plan"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/);if(!n||n.index===void 0)return console.error(`patch: subagentModels: failed to find Plan agent pattern`),null;let r=n[1]+t+n[2],i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},Ie=(e,t)=>{let n=e.match(/(\{agentType\s*:\s*"Explore"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/);if(!n||n.index===void 0)return console.error(`patch: subagentModels: failed to find Explore agent pattern`),null;let r=n[1]+t+n[2],i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},Le=(e,t)=>{let n=e.match(/([^$\w][$\w]+\s*=\s*\{agentType\s*:\s*"general-purpose"[\s\S]{0,2500}?)(\})/);if(!n||n.index===void 0)return console.error(`patch: subagentModels: failed to find general-purpose agent pattern`),null;let r=n[1],i=n[2],a;a=r.includes(`model:`)?r.replace(/(model\s*:\s*")[^"]+(")/,`$1${t}$2`)+i:r+`${r.trim().endsWith(`,`)?``:`,`}model:"${t}"`+i;let o=n.index,s=o+n[0].length,c=e.slice(0,o)+a+e.slice(s);return M(e,c,a,o,s),c},Re=(e,t)=>{let n=e;if(t.plan){let e=Fe(n,t.plan);if(e===null)return null;n=e}if(t.explore){let e=Ie(n,t.explore);if(e===null)return null;n=e}if(t.generalPurpose){let e=Le(n,t.generalPurpose);if(e===null)return null;n=e}return n},ze=e=>{let t=e.indexOf(`}.VERSION} (Claude Code)`);return t==-1?(console.error(`patch: patchesAppliedIndication: failed to find versionIndex`),null):{startIndex:0,endIndex:t+24}},Be=e=>{let t=e.match(/createElement\(([$\w]+),\{bold:!0\},"Claude Code"\),([$\w]+)\[\d+\]=[$\w]+;else [$\w]+=([$\w]+)\[\d+\]/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: PATCH 2 failed to find bold Claude Code pattern`),null;let n=t[1],r=t.index+t[0].length,i=e.indexOf(`;`,r);if(i===-1)return null;let a=i+1,o=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),null,[$\w]+," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)\)/);if(!o||o.index===void 0){let t=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);return!t||t.index===void 0?(console.error(`patch: patchesAppliedIndication: PATCH 2 failed to find version createElement`),null):{varInsertIndex:a,refInsertIndex:t.index+t[0].length,reactVar:t[1],textComponent:n}}return{varInsertIndex:a,refInsertIndex:o.index+o[0].length-1,reactVar:o[1],textComponent:n}},Ve=e=>{let t=e.match(/"Claude Code".{0,200}\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find version display for patch 3`),null;let n={index:t.index},r=Math.max(0,n.index-5e3),i=e.slice(r,n.index),a=Array.from(i.matchAll(/[};]\s*function ([$\w]+)\(/g));if(a.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let o=a[a.length-1][1],s=RegExp(`[^$\\w]([$\\w]+)\\.createElement\\(${W(o)},null\\),?`),c=e.match(s);if(!c||c.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let l=e.slice(Math.max(0,c.index-30),c.index+1).match(/([$\w]+)=(?:[$\w]+&&)?[^$\w]?$/);if(l){let t=l[1],n=e.slice(c.index,c.index+2e3),r=RegExp(`,${W(t)}([,\\)])`),i=n.match(r);if(i&&i.index!==void 0){let e=c.index+i.index+i[0].length-i[1].length;return{startIndex:e,endIndex:e}}}let u=c.index+c[0].length;return{startIndex:u,endIndex:u}},He=(e,t,n,r=!0,i=!0)=>{let a=ze(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc-fixed)`,s=`}.VERSION} (Claude Code)`,c=e.replaceAll(s,s+o);M(e,c,o,a.endIndex,a.endIndex);let l=R(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let u=H(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let d=V(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;if(r){let e=c.match(/(\$\{([$\w]+)\("inactive",([$\w]+)\)\(`v\$\{[$\w]+\}`\)\}) `,/);if(e&&e.index!==void 0){let n=e[0],r=e[2],i=e[3],a=`${e[1]} \${${r}("warning",${i})("+ tweakcc v${t}")} \`,`;c=c.replace(n,a)}c=c.replace(/([$\w]+\("claude",[$\w]+\)\(" Claude Code) ("\))/,`$1 + tweakcc v${t} $2`);let n=Be(c);if(!n)console.error(`patch: patchesAppliedIndication: patch 2 skipped (header version pattern changed)`);else{let e=`let _tw=${n.reactVar}.createElement(${n.textComponent},null,${l}.hex("#FF8400").bold("+ tweakcc v${t}"));`,r=c;c=c.slice(0,n.varInsertIndex)+e+c.slice(n.varInsertIndex),M(r,c,e,n.varInsertIndex,n.varInsertIndex);let i=n.refInsertIndex+e.length,a=`," ",_tw`,o=c;c=c.slice(0,i)+a+c.slice(i),M(o,c,a,i,i)}}if(i){let e=ki(c);if(!e)return console.error(`patch: patchesAppliedIndication: PATCH 3 skipped (Box component not located on this CC version)`),c;let t=Ve(c);if(!t)console.log(`patch: patchesAppliedIndication: patch 3 skipped (see prior message)`);else{let r=[];r.push(`,${d}.createElement(${e}, { flexDirection: "column" },`),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {color: "success", bold: true}, "✓ tweakcc-fixed patches are applied")),`);for(let t of n)t=t.replace(`CHALK_VAR`,l),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {dimColor: true}, \` * ${t}\`)),`);r.push(`),`);let i=r.join(`
1
+ import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c from"node:fs";import*as l from"node:path";import u from"node:path";import*as d from"fs";import*as f from"path";import*as p from"os";import*as m from"child_process";import*as h from"crypto";import{spawnSync as g}from"node:child_process";import _ from"gray-matter";import{fileURLToPath as v}from"node:url";import{Worker as y}from"node:worker_threads";import{diffWordsWithSpace as b}from"diff";let x=null;async function S(){if(x!==null)return x;try{return await import(`node-lief`),x=await import(`./nativeInstallation-CjRlkUVb.mjs`),x}catch(e){return G(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&G(e),null}}async function C(e,t){let n=await S();return n?n.extractClaudeJsFromNativeInstallation(e,t):{data:null,clearBytecode:!1}}async function w(e,t,n,r){let i=await S();if(!i)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");i.repackNativeInstallation(e,t,n,r)}async function T(e){let t=await S();return t?t.resolveNixBinaryWrapper(e):null}const E={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.Architecting.Baking.Beaming.Beboppin'.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Dilly-dallying.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Mustering.Musing.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzle-dazzling.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Sautéing.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Sock-hopping.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Topsy-turvying.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:`default`,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:`default`,paddingY:`default`,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSwarmMode:!0,enableSessionMemory:!0,enableDreamMode:!0,enableLeanMemoryTypes:!1,fixSummarizeFromHere:!0,fixRewindSummaryHeader:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autoModeClassifierModel:`default`,suppressDeferredTools:!1,claudemdContextOncePerConversation:!0},toolsets:[],defaultToolset:null,planModeToolset:null,subagentModels:{plan:null,explore:null,generalPurpose:null},inputPatternHighlighters:[],inputPatternHighlightersTestText:`Type test text here to see highlighting`,claudeMdAltNames:[`AGENTS.md`,`GEMINI.md`,`CRUSH.md`,`QWEN.md`,`IFLOW.md`,`WARP.md`,`copilot-instructions.md`]},D={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},ee={name:`Unnamed Toolset`,allowedTools:`*`},te=E.themes[0],ne=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},re=e=>{let t=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),[\w$]+=[\w$]+\?[\w$]+:Math\.max\(1,Math\.min\(Math\.max\(6,Math\.floor\(\1\/2\)\),\1-3\)\)/);if(t&&t.index!==void 0){let n=t[1],r=`Math.floor(${n}/2)`,i=t.index+t[0].indexOf(r),a=i+r.length,o=e.slice(0,i)+n+e.slice(a);return M(e,o,n,i,a),o}let n=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),([\w$]+)=Math\.floor\(\1\/2\)/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(n[2]+`=Math.floor(`),r=n.index+n[0].length,i=`${n[2]}=${n[1]}`,a=e.slice(0,t)+i+e.slice(r);return M(e,a,i,t,r),a}let r=/Math\.max\(1,Math\.floor\(\(([\w$]+)-([\w$]+)\)\/([\w$]+)\)\)/g,i;for(;(i=r.exec(e))!==null;){let t=Math.max(0,i.index-250),n=e.slice(t,i.index);if(!n.includes(`"expanded"?3`)||!n.includes(`"compact"?1:2`))continue;let r=i.index,a=i.index+i[0].length,o=`Math.max(1,${i[1]}-${i[2]})`,s=e.slice(0,r)+o+e.slice(a);return M(e,s,o,r,a),s}return null},O=e=>{let t=e.match(/Math\.max\(1,Math\.floor\(\(([\w$]+)-10\)\/2\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},k=e=>{if(!e.includes(`Math.min(6,Math.max(1,`))return G(`patch: showMoreItemsInSelectMenus: suggestions cap already removed in this CC build — no-op`),e;let t=e.match(/Math\.min\(6,Math\.max\(1,([\w$]+)-3\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},ie=(e,t)=>{let n=ne(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);M(i,r,n,e.startIndex,e.endIndex),i=r}let a=re(i);a?i=a:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find help menu height pattern`);let o=O(i);o?i=o:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find visibleCount pattern`);let s=k(i);return s&&(i=s),i};function ae(e){let t=-1,n=-1,r=``,i=e.match(/switch\(([$\w]+)\)\{case"(?:light|dark)":[^}]*return [$\w]+;[^}]*default:return [$\w]+\}/);if(i&&i.index!=null)t=i.index,n=t+i[0].length,r=i[1];else{if(e.indexOf(`case"dark":return{"autoAccept"`)===-1&&e.indexOf(`case"light":return{`)===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let i=e.indexOf(`case"dark":return{`)===-1?e.indexOf(`case"light":return{`):e.indexOf(`case"dark":return{`),a=e.slice(Math.max(0,i-200),i).match(/switch\(([$\w]+)\)\{\s*$/);if(!a||a.index==null)return console.error(`patch: themes: failed to find switchMatch (old format)`),null;t=Math.max(0,i-200)+a.index,r=a[1];let o=0;for(let r=t;r<e.length&&r<t+5e4;r++)if(e[r]===`{`&&o++,e[r]===`}`&&(o--,o===0)){n=r+1;break}}if(t===-1||n===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let a=-1,o=-1,s=``,c=e.match(/\[(?:\.\.\.\[\],)?(?:\{"?label"?:"(?:Dark|Light|Auto|Monochrome)[^"]*","?value"?:"[^"]+"\},?)+\]/);if(c&&c.index!==void 0)a=c.index,o=c.index+c[0].length;else{let t=[...e.matchAll(/([$\w]+)=\{label:"(?:Auto|Dark|Light|Monochrome)[^"]*",value:"[^"]+"\}/g)];if(t.length<2)return console.error(`patch: themes: failed to find objArrMatch`),null;let n=t.map(e=>e[1]).map(e=>e.replace(/\$/g,`\\$`)).join(`,`),r=RegExp(`\\[${n}((?:,\\.\\.\\.[^\\]]+)*)\\]`),i=e.match(r);if(!i||i.index===void 0)return console.error(`patch: themes: failed to find objArrMatch (new var-collected form)`),null;a=i.index,o=i.index+i[0].length,s=i[1]}let l=e.match(/(return|[$\w]+=)\{(?:"?(?:[$\w-]+)"?:"(?:Auto |Dark|Light|Monochrome)[^"]*",?)+\}/);return(!l||l.index==null)&&G(`patch: themes: objMatch not found — colors will still apply, theme name map unchanged`),{switchStatement:{startIndex:t,endIndex:n,identifiers:[r]},objArr:{startIndex:a,endIndex:o,identifiers:[s]},obj:l&&l.index!==void 0?{startIndex:l.index,endIndex:l.index+l[0].length,identifiers:[l[1]]}:null}}const oe=(e,t)=>{let n=ae(e);if(!n)return null;if(t.length===0)return e;let r=e;if(n.obj){let i=(n.obj.identifiers?.[0]??`return`)+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),M(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r}let i=n.objArr.identifiers?.[0]??``,a=`[${t.map(e=>JSON.stringify({label:e.name,value:e.id})).join(`,`)}${i}]`;r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),M(e,r,a,n.objArr.startIndex,n.objArr.endIndex),e=r;let o=`switch(${n.switchStatement.identifiers?.[0]}){\n`;return t.forEach(e=>{o+=`case"${e.id}":return${JSON.stringify(e.colors)};\n`}),o+=`default:return${JSON.stringify(t[0].colors)};\n}`,r=r.slice(0,n.switchStatement.startIndex)+o+r.slice(n.switchStatement.endIndex),M(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},se=e=>{let t=/var ([\w$]+)=200000,([\w$]+)=20000,([\w$]+)=32000,([\w$]+)=(128000|64000);/,n=e.match(t);return n?e.replace(t,`var ${n[1]}=(+process.env.CLAUDE_CODE_CONTEXT_LIMIT||200000),${n[2]}=20000,${n[3]}=32000,${n[4]}=${n[5]};`):(console.error(`patch: contextLimit: failed to find context limit constants`),null)},ce=(e,t)=>{if(!t)return e;let n=e,r=!1,i=n.match(/createElement\(([$\w]+),\{color:([$\w]+)\.bgColor\},"─"\.repeat\(([$\w]+)\)\)/);if(i){let e=i[1];n=n.replace(i[0],`createElement(${e},null,"")`);let t=RegExp(`createElement\\(${e},\\{color:${i[2]}\\.bgColor\\},${i[2]}\\.text\\?.+?"─"\\.repeat\\(${i[3]}\\)\\)`),a=n.match(t);a&&(n=n.replace(a[0],`createElement(${e},null,"")`)),r=!0}let a=n.match(/(borderColor:[$\w]+\(\),)borderStyle:"round"(,borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",borderText:)/);a&&(n=n.replace(a[0],`${a[1]}borderStyle:undefined${a[2]}`),r=!0);let o=n.match(/borderStyle:"round"(,borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%"\}.+?Save and close editor)/);return o&&(n=n.replace(o[0],`borderStyle:undefined${o[1]}`),r=!0),r?(M(e,n,`(input border removed)`,0,0),n):(console.error(`patch: input border: failed to find input border pattern`),null)},le=e=>{let t=(e.match(/overrideMessage:[$\w]+,isCompacting:[$\w]+,compactingHintText:[$\w]+,compactingStartTime:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/)||e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/)||e.match(/overrideMessage:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/)||e.match(/pauseStartTimeRef:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/))?.index,n=t===void 0?``:e.slice(t,t+2e4),r=n.match(/,([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);if(r&&r.index!=null)return{startIndex:t+r.index+r[1].length+1,endIndex:t+r.index+r[1].length+r[2].length+1,identifiers:[r[3]]};let i=/,([$\w]+)(=(\([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+\))\+"(?:…|\\u2026)")/,a=n.match(i);if(a&&a.index!=null)return{startIndex:t+a.index+a[1].length+1,endIndex:t+a.index+a[1].length+a[2].length+1,identifiers:[a[3]]};let o=n.match(/,([$\w]+)(=`\$\{([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+)\}(?:…|\\u2026) ?`)/);if(o&&o.index!=null)return{startIndex:t+o.index+o[1].length+1,endIndex:t+o.index+o[1].length+o[2].length+1,identifiers:[o[3]]};let s=new RegExp(i.source,`g`),c=[...e.matchAll(s)].filter(t=>{if(t.index==null)return!1;let n=e.slice(Math.max(0,t.index-2500),t.index+1e3);return n.includes(`overrideMessage:`)&&n.includes(`.activeForm`)&&n.includes(`.isIdle`)&&n.includes(`.spinnerVerb`)&&n.includes(`spinnerTip`)});if(c.length===1){let e=c[0];return{startIndex:e.index+e[1].length+1,endIndex:e.index+e[1].length+e[2].length+1,identifiers:[e[3]]}}return console.error(`patch: thinker format: failed to find formatMatch`),null},ue=(e,t)=>{let n=le(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o=`=${"`"+i.replace(/\{\}/g,"${"+a+`}`)+"`"}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);return M(e,s,o,r.startIndex,r.endIndex),s},de=e=>{let t=e.match(/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/);return!t||t.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},fe=(e,t)=>{let n=de(e);if(!n)return null;let r=n.identifiers?.[0],i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return M(e,a,i,n.startIndex,n.endIndex),a},pe=(e,t)=>{let n=[],r=/\["(?:[·✢*✳✶✻✽]|\\u00b7|\\xb7|\\u2722|\\x2a|\\u002a|\\u2733|\\u2736|\\u273b|\\u273d)",\s*(?:"(?:[·✢*✳✶✻✽]|\\u00b7|\\xb7|\\u2722|\\x2a|\\u002a|\\u2733|\\u2736|\\u273b|\\u273d)",?\s*)+\]/gi,i;for(;(i=r.exec(e))!==null;)n.push({startIndex:i.index,endIndex:i.index+i[0].length});if(n.length===0)return console.error(`patch: thinkerSymbolChars: could not find any thinker symbol char arrays`),null;let a=JSON.stringify(t),o=n.sort((e,t)=>t.startIndex-e.startIndex),s=e;for(let e=0;e<o.length;e++){let t=s.slice(0,o[e].startIndex)+a+s.slice(o[e].endIndex);M(s,t,a,o[e].startIndex,o[e].endIndex),s=t}return s},me=(e,t)=>{let n=e.match(/(if\(![$\w]+\)\{[$\w]+\(4\);return\})(.{0,200})120\)/);if(!n||n.index===void 0)return console.error(`patch: thinkerSymbolSpeed: failed to find thinker symbol speed pattern`),null;let r=n[2]+t+`)`,i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},he=e=>{let t=e.match(/\{("aria-hidden":!0,)?flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,prefix:t[1]??``}},ge=(e,t)=>{let n=he(e);if(!n)return null;let r=`{${n.prefix}flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return M(e,i,r,n.startIndex,n.endIndex),i},_e=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+in[g']",?){50,}\]/);if(!n||n.index===void 0)return console.error(`patch: thinkingVerbs: failed to find present tense verbs pattern`),null;let r=JSON.stringify(t),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},ve=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+ed",?){6,}\]/);if(!n||n.index===void 0)return console.error(`patch: thinkingVerbs: failed to find past tense verbs pattern`),null;let r=t.map(e=>e.replace(/ing$/,`ed`)),i=JSON.stringify(r),a=n.index,o=a+n[0].length,s=e.slice(0,a)+i+e.slice(o);return M(e,s,i,a,o),s},ye=(e,t)=>{let n=_e(e,t);if(n===null)return null;let r=ve(n,t);return r===null?null:r},be=(e,t)=>{let n=H(e);if(!n)return console.error(`patch: userMessageDisplay: failed to find Text component`),null;let r=ki(e),i=R(e);if(!i)return console.error(`patch: userMessageDisplay: failed to find chalk variable`),null;let a=/(No content found in user prompt message.{0,250}?\b)([$\w]+(?:\.default)?\.createElement.{0,30}\b[$\w]+(?:\.default)?\.createElement.{0,40}">.+?)?(([$\w]+(?:\.default)?\.createElement).{0,200})(\([$\w]+,(?:\{[^{}]+wrap:"wrap"\},([$\w]+)(?:\.trim\(\))?\)\)|\{text:([$\w]+)[^}]*\}\)\)?))/,o=e.match(/(No content found in user prompt message[\s\S]{0,100}?;return )([$\w]+(?:\.default)?)\.createElement\(([$\w]+),(\{flexDirection:"column"[^{}]*\}),([$\w]+(?:\.default)?)\.createElement\(([$\w]+),\{text:([$\w]+)[^{}]*\}\)\)/),s=o?null:e.match(/(No content found in user prompt message.{0,1200}?)([$\w]+)=([$\w]+(?:\.default)?\.createElement)\([$\w]+,\{text:([$\w]+),useBriefLayout:[$\w]+,timestamp:[$\w]+\}\)/),c=o||s?null:e.match(a);if(!o&&(!s||s.index===void 0)&&(!c||c.index===void 0))return console.error(`patch: userMessageDisplay: failed to find user message display pattern`),e;let l=e=>`(typeof ${e}==="object"&&${e}!==null?${e}.head+"\\n("+${e}.hiddenLines+" line"+(${e}.hiddenLines===1?"":"s")+" hidden)\\n"+${e}.tail:${e})`;if(o){let r=o[1],i=o[2],a=o[3],s=o[4],c=o[5],u=o[7],d=s.slice(1,-1),f=/backgroundColor:[^,}]+(?:\?[^,}:]+:[^,}:]+)*/;if(t.backgroundColor===null)d=d.replace(RegExp(`,?${f.source}`),``).replace(/^,|,$/g,``);else if(t.backgroundColor!==`default`){let e=t.backgroundColor.match(/\d+/g);if(e){let t=`"rgb(${e.join(`,`)})"`;d=d.replace(/"userMessageBackground"/g,t)}}let p=[];if(t.borderStyle!==`none`){if(t.borderStyle.startsWith(`topBottom`)){let e=``;t.borderStyle===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),p.push(`borderStyle:${e}`)}else p.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&p.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX!==`default`&&t.paddingX>0&&p.push(`paddingX:${t.paddingX}`),t.paddingY!==`default`&&t.paddingY>0&&p.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&p.push(`alignSelf:"flex-start"`),p.length>0&&(d=d?`${d},${p.join(`,`)}`:p.join(`,`));let m=`{${d}}`,h=[];if(t.foregroundColor===`default`)h.push(`color:"text"`);else{let e=t.foregroundColor.match(/\d+/g);e&&h.push(`color:"rgb(${e.join(`,`)})"`)}if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);e&&h.push(`backgroundColor:"rgb(${e.join(`,`)})"`)}else t.backgroundColor===`default`&&h.push(`backgroundColor:"userMessageBackground"`);t.styling.includes(`bold`)&&h.push(`bold:!0`),t.styling.includes(`italic`)&&h.push(`italic:!0`),t.styling.includes(`underline`)&&h.push(`underline:!0`),t.styling.includes(`strikethrough`)&&h.push(`strikethrough:!0`),t.styling.includes(`inverse`)&&h.push(`inverse:!0`);let g=h.length>0?`{${h.join(`,`)}}`:`null`,_=l(u),v=r+`${i}.createElement(${a},${m},${c}.createElement(${n},${g},${"`"+t.format.replace(/\{\}/g,()=>"${"+_+`}`)+"`"}))`,y=o.index,b=y+o[0].length,x=e.slice(0,y)+v+e.slice(b);return M(e,x,v,y,b),x}if(!r)return console.error(`patch: userMessageDisplay: failed to find Box component`),null;let u=s??c,d=s?s[3]:c[4],f=s?s[4]:c[6]??c[7],p=[],m=t.borderStyle.startsWith(`topBottom`);if(t.borderStyle!==`none`){if(m){let e=``;t.borderStyle===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),p.push(`borderStyle:${e}`)}else p.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&p.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX===`default`?p.push(`paddingRight:1`):t.paddingX>0&&p.push(`paddingX:${t.paddingX}`),t.paddingY!==`default`&&t.paddingY>0&&p.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&p.push(`alignSelf:"flex-start"`);let h=i,g=[];if(t.foregroundColor!==`default`){let e=t.foregroundColor.match(/\d+/g);e&&(h+=`.rgb(${e.join(`,`)})`)}else g.push(`color:"text"`);if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);if(e){h+=`.bgRgb(${e.join(`,`)})`;let t=`"rgb(${e.join(`,`)})"`;p.push(`backgroundColor:${t}`),g.push(`backgroundColor:${t}`)}}else t.backgroundColor===`default`&&(p.push(`backgroundColor:"userMessageBackground"`),g.push(`backgroundColor:"userMessageBackground"`));t.styling.includes(`bold`)&&(h+=`.bold`),t.styling.includes(`italic`)&&(h+=`.italic`),t.styling.includes(`underline`)&&(h+=`.underline`),t.styling.includes(`strikethrough`)&&(h+=`.strikethrough`),t.styling.includes(`inverse`)&&(h+=`.inverse`);let _=l(f),v="`"+t.format.replace(/\{\}/g,()=>"${"+_+`}`)+"`",y=`${h}(${v})`,b=p.length>0?`{${p.join(`,`)}}`:`null`,x=g.length>0?`{${g.join(`,`)}}`:`null`,S=s?`${s[2]}=`:``,C=u[1]+`${S}${d}(${r},${b},${d}(${n},${x},${y}))`,w=u.index,T=w+u[0].length,E=e.slice(0,w)+C+e.slice(T);return M(e,E,C,w,T),E},xe=(e,t)=>{let n=e;if(t.foregroundColor){let e=t.foregroundColor.match(/\d+/g);e&&(n+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor){let e=t.backgroundColor.match(/\d+/g);e&&(n+=`.bgRgb(${e.join(`,`)})`)}return t.styling.includes(`bold`)&&(n+=`.bold`),t.styling.includes(`italic`)&&(n+=`.italic`),t.styling.includes(`underline`)&&(n+=`.underline`),t.styling.includes(`strikethrough`)&&(n+=`.strikethrough`),t.styling.includes(`inverse`)&&(n+=`.inverse`),n},Se=e=>{let t=e.match(/(if\(([$\w]+)\.highlight\?\.color\))((return [$\w]+\.createElement\([$\w]+,\{key:[$\w]+),color:[$\w]+\.highlight\.color(\},[$\w]+\.createElement\([$\w]+,null,)([$\w]+\.text)(\)\)));/);if(t&&t.index!==void 0){let n=`${t[2]}.highlight.color(${t[6]})`,r=t[1]+`{if(typeof ${t[2]}.highlight.color==='function')`+t[4]+t[5]+n+t[7]+`;else `+t[3]+`}`,i=e.slice(0,t.index)+r+e.slice(t.index+t[0].length);return M(e,i,r,t.index,t.index+t[0].length),i}let n=/(return ([$\w]+)\.createElement\(([$\w]+),\{key:([$\w]+)),color:([$\w]+)\.highlight\?\.color,dimColor:\5\.highlight\?\.dimColor,inverse:\5\.highlight\?\.inverse\},(\2\.createElement\([$\w]+,null,\5\.text\))\)/,r=e.match(n);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find highlight?.color renderer pattern`),null;let i=r[2],a=r[3],o=r[4],s=r[5];r[6];let c=RegExp(`if\\(${s.replace(`$`,`\\$`)}\\.highlight\\.color\\)return ([$\\w]+)\\.createElement\\([$\\w]+,\\{key:[$\\w]+\\},${s.replace(`$`,`\\$`)}\\.text\\.split\\(""\\)\\.map\\([^)]+\\)\\)`),l=e,u=l.match(c);if(u&&u.index!==void 0){let e=`if(typeof ${s}.highlight?.color==='function')return ${i}.createElement(${a},{key:${o}},${i}.createElement(${a},null,${s}.highlight.color(${s}.text)));`;l=l.slice(0,u.index)+e+l.slice(u.index)}let d=l.match(n);if(!d||d.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to re-find renderer after shimmer patch`),null;let f=d[2],p=d[3],m=d[4],h=d[5],g=d[6],_=`${h}.highlight?.style?${h}.highlight.style(${h}.text):${h}.text`,v=`return ${f}.createElement(${p},{key:${m},color:${h}.highlight?.style?void 0:${h}.highlight?.color,backgroundColor:${h}.highlight?.style?void 0:${h}.highlight?.backgroundColor,dimColor:${h}.highlight?.dimColor,inverse:${h}.highlight?.style?void 0:${h}.highlight?.inverse,bold:${h}.highlight?.style?void 0:${h}.highlight?.bold,italic:${h}.highlight?.style?void 0:${h}.highlight?.italic,underline:${h}.highlight?.style?void 0:${h}.highlight?.underline,strikethrough:${h}.highlight?.style?void 0:${h}.highlight?.strikethrough},${g.replace(`${h}.text`,_)})`,y=l.slice(0,d.index)+v+l.slice(d.index+d[0].length);return M(e,y,`shimmer guard + renderer`,0,0),y},Ce=(e,t,n)=>{let r=e.match(/((?:,|;let )[$\w]+=[$\w]+\.useMemo\(\(\)=>\{let [$\w]+=\[\];[\s\S]{0,2000}?)(if\([$\w]+&&[$\w]+&&![$\w]+\)([$\w]+)\.push\(\{start:[$\w]+,end:[$\w]+\+[$\w]+\.length,color:"warning",priority:\d+\})/);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find useMemo/push pattern`),null;let i=r[3],a=r[1].match(/[^$\w]([$\w]+(?:\.default)?)\.useMemo\(/);if(!a)return console.error(`patch: inputPatternHighlighters: failed to extract React var from useMemo`),null;a[1];let o=Math.max(0,r.index-15e3),s=e.slice(o,r.index),c=/\binputValue:([$\w]+),/g,l=/\binput:([$\w]+),/g,u=[...s.matchAll(c)],d=[...s.matchAll(l)],f=u.at(-1)??d.at(-1)??null;if(!f)return console.error(`patch: inputPatternHighlighters: failed to find input variable pattern (looked for inputValue: and input:)`),null;let p=f[1],m=``;for(let e=0;e<n.length;e++){let r=n[e],a=xe(t,r),o=r.format??`{MATCH}`;JSON.stringify(o).replace(/\{MATCH\}/g,`"+x+"`);let s=r.foregroundColor;if(s){let e=s.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);s=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let c=s?JSON.stringify(s):`undefined`,l=r.backgroundColor;if(l){let e=l.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);l=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let u=l?JSON.stringify(l):null,d=r.styling??[],f=d.includes(`bold`),h=d.includes(`italic`),g=d.includes(`underline`),_=d.includes(`inverse`),v=d.includes(`dim`),y=d.includes(`strikethrough`),b=r.regex??r.pattern;if(!b){console.error(`patch: inputPatternHighlighters: highlighter "${r.name}" has no regex/pattern; skipping`);continue}let x=r.regexFlags??``;x.includes(`g`)||(x+=`g`);let S;try{S=new RegExp(b,x)}catch(e){console.error(`patch: inputPatternHighlighters: highlighter "${r.name}" has invalid regex; skipping`,e);continue}let C=ca(S);m+=`if(typeof ${p}==="string"){for(let m of ${p}.matchAll(${C})){${i}.push({start:m.index,end:m.index+m[0].length,color:${c}${u?`,backgroundColor:${u}`:``}${f?`,bold:!0`:``}${h?`,italic:!0`:``}${g?`,underline:!0`:``}${_?`,inverse:!0`:``}${v?`,dimColor:!0`:``}${y?`,strikethrough:!0`:``},style:(x)=>${a}(x),priority:100})}}`}if(!m)return console.error(`patch: inputPatternHighlighters: no usable highlighters generated (all skipped)`),null;let h=r[1]+m+r[2],g=e.slice(0,r.index),_=e.slice(r.index+r[0].length),v=g+``+h+_,y=v.indexOf(`for(let m of ${p}.matchAll(`);if(y>-1){let e=[...v.slice(Math.max(0,y-2e3),y).matchAll(/useMemo\(\(\)=>\{/g)];if(e.length>0){let t=Math.max(0,y-2e3)+e[e.length-1].index,n=v.slice(t),r=0;for(let e=0;e<n.length;e++)if(n[e]===`(`)r++;else if(n[e]===`)`&&(r--,r===0)){let n=t+e;v.slice(n-1,n)===`]`&&(v.slice(n-200,n).includes(`,${p}]`)||(v=v.slice(0,n-1)+`,${p}]`+v.slice(n)));break}}}return M(e,v,``+h,r.index,r.index+r[0].length),v},we=(e,t)=>{let n=t.filter(e=>e.enabled!==!1);if(n.length===0)return console.error(`patch: inputPatternHighlighters: no enabled highlighters provided`),null;let r=R(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i;return i=Se(e),i?(i=Ce(i,r,n),i||(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterCreation failed`),null)):(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterImpl failed`),null)},Te=e=>{let t=e.match(/(?:[$\w]+\.)?createElement\([$\w]+,\{(?=[^}]*responseLengthRef:)(?=[^}]*spinnerSuffix:)(?=[^}]*thinkingStatus:)(?=[^}]*isCompacting:)[^}]*verbose:[^,}]+[^}]*\}/);if(t&&t.index!==void 0){let e=t[0].match(/verbose:[^,}]+/);if(!e||e.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let n=t.index+e.index;return{startIndex:n,endIndex:n+e[0].length,replacement:`verbose:true`}}let n=e.match(/\{[^{}]{0,400}overrideMessage:[$\w]+,[^{}]{0,200}verbose:([$\w]+)[^{}]{0,200}\}\)\{/);if(n&&n.index!==void 0){let e=n[1],t=n.index+n[0].length;return{startIndex:t,endIndex:t,replacement:`${e}=!0;`}}return console.error(`patch: verbose: failed to find spinner props containing overrideMessage and verbose`),null},Ee=e=>{let t=Te(e);if(!t)return null;let n=e.slice(0,t.startIndex)+t.replacement+e.slice(t.endIndex);return M(e,n,t.replacement,t.startIndex,t.endIndex),n},De=e=>{let t=e.match(/if\s*\(\s*([$\w]+)\(\)\s*===\s*"opusplan"\s*&&\s*([$\w]+)\s*===\s*"plan"\s*&&\s*!([$\w]+)\s*\)\s*return\s*([$\w]+)\(\);/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModeSwitchingFunction: failed to find mode switching pattern`),null;let[n,r,i,a,o]=t,s=`if((${r}()==="opusplan"||${r}()==="opusplan[1m]")&&${i}==="plan"&&!${a})return ${o}();`,c=e.slice(0,t.index)+s+e.slice(t.index+n.length);return M(e,c,s,t.index,t.index+n.length),c},Oe=e=>{let t=e.match(/(\["sonnet","opus","haiku",(?:"best",)?"sonnet\[1m\]",(?:"opus\[1m\]",)?"opusplan")/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModelAliasesList: failed to find model aliases list`),null;let n=t[0]+`,"opusplan[1m]"`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},ke=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"([^"]*Opus[^"]*plan mode[^"]*Sonnet[^"]*)";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchDescriptionFunction: failed to find description pattern`),null;let[n,,r,i]=t,a=n+`if(${r}==="opusplan[1m]")return"${i} (1M context)";`,o=e.slice(0,t.index)+a+e.slice(t.index+n.length);return M(e,o,a,t.index,t.index+n.length),o},Ae=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"Opus Plan";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchLabelFunction: failed to find label pattern`),null;let[n,,r]=t,i=n+`if(${r}==="opusplan[1m]")return"Opus Plan 1M";`,a=e.slice(0,t.index)+i+e.slice(t.index+n.length);return M(e,a,i,t.index,t.index+n.length),a},je=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*(?:[$\w]+\()?\[\s*\.\.\.([$\w]+)\s*,\s*([$\w]+)\(\)\s*\]\)?;)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModelSelectorOptions: failed to find model selector pattern`),null;let[n,,r,i]=t,a=n.match(RegExp(`return\\s*([$\\w]+)\\(\\s*\\[\\.\\.\\.${W(i)}`)),o=a?a[1]:null,s=`{value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus in plan mode, Sonnet (1M context) otherwise"}`,c=n+`if(${r}==="opusplan[1m]")return ${o?`${o}([...${i},${s}])`:`[...${i},${s}]`};`,l=e.slice(0,t.index)+c+e.slice(t.index+n.length);return M(e,l,c,t.index,t.index+n.length),l},Me=e=>{let t=e.match(/(if\s*\(\s*[$\w]+\s*===\s*null\s*\|\|\s*([$\w]+)\.some\s*\(\s*\(\s*[$\w]+\s*\)\s*=>\s*[$\w]+\.value\s*===\s*[$\w]+\s*\)\s*\)\s*return\s*(?:[$\w]+\()?[$\w]+\)?\s*;)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchAlwaysShowInModelSelector: failed to find model list check pattern`),null;let[,,n]=t,r=`${n}.push({value:"opusplan",label:"Opus Plan Mode",description:"Use Opus in plan mode, Sonnet otherwise"});${n}.push({value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus in plan mode, Sonnet (1M context) otherwise"});`,i=e.slice(0,t.index)+r+e.slice(t.index);return M(e,i,r,t.index,t.index),i},Ne=e=>{if(e.includes(`"opusplan[1m]"`))return console.log(`patch: opusplan1m: opusplan[1m] already supported natively — skipping`),e;let t=e,n=De(t);if(n)t=n;else return console.error(`patch: opusplan1m: failed to apply mode switching patch`),null;if(n=Oe(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model aliases list patch`),null;if(n=ke(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply description function patch`),null;if(n=Ae(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply label function patch`),null;if(n=je(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model selector options patch`),null;if(n=Me(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply always-show-in-selector patch`),null;return t},Pe=e=>{if(/case"thinking":\{(?:(?!case")[^]){0,600}isTranscriptMode:true/.test(e))return console.log(`patch: thinkingVisibility: already configured natively — skipping`),e;let t=e.match(/(case"thinking":\{?)(if\(.+?\)return null;)(.{0,400}isTranscriptMode:).+?,/);if(!t||t.index===void 0)return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null;let n=t[1]+t[3]+`true,`,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return M(e,a,n,r,i),a},Fe=(e,t)=>{let n=e.match(/(agentType\s*:\s*"Plan"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/);if(!n||n.index===void 0)return console.error(`patch: subagentModels: failed to find Plan agent pattern`),null;let r=n[1]+t+n[2],i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},Ie=(e,t)=>{let n=e.match(/(\{agentType\s*:\s*"Explore"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/);if(!n||n.index===void 0)return console.error(`patch: subagentModels: failed to find Explore agent pattern`),null;let r=n[1]+t+n[2],i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return M(e,o,r,i,a),o},Le=(e,t)=>{let n=e.match(/([^$\w][$\w]+\s*=\s*\{agentType\s*:\s*"general-purpose"[\s\S]{0,2500}?)(\})/);if(!n||n.index===void 0)return console.error(`patch: subagentModels: failed to find general-purpose agent pattern`),null;let r=n[1],i=n[2],a;a=r.includes(`model:`)?r.replace(/(model\s*:\s*")[^"]+(")/,`$1${t}$2`)+i:r+`${r.trim().endsWith(`,`)?``:`,`}model:"${t}"`+i;let o=n.index,s=o+n[0].length,c=e.slice(0,o)+a+e.slice(s);return M(e,c,a,o,s),c},Re=(e,t)=>{let n=e;if(t.plan){let e=Fe(n,t.plan);if(e===null)return null;n=e}if(t.explore){let e=Ie(n,t.explore);if(e===null)return null;n=e}if(t.generalPurpose){let e=Le(n,t.generalPurpose);if(e===null)return null;n=e}return n},ze=e=>{let t=e.indexOf(`}.VERSION} (Claude Code)`);return t==-1?(console.error(`patch: patchesAppliedIndication: failed to find versionIndex`),null):{startIndex:0,endIndex:t+24}},Be=e=>{let t=e.match(/createElement\(([$\w]+),\{bold:!0\},"Claude Code"\),([$\w]+)\[\d+\]=[$\w]+;else [$\w]+=([$\w]+)\[\d+\]/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: PATCH 2 failed to find bold Claude Code pattern`),null;let n=t[1],r=t.index+t[0].length,i=e.indexOf(`;`,r);if(i===-1)return null;let a=i+1,o=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),null,[$\w]+," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)\)/);if(!o||o.index===void 0){let t=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);return!t||t.index===void 0?(console.error(`patch: patchesAppliedIndication: PATCH 2 failed to find version createElement`),null):{varInsertIndex:a,refInsertIndex:t.index+t[0].length,reactVar:t[1],textComponent:n}}return{varInsertIndex:a,refInsertIndex:o.index+o[0].length-1,reactVar:o[1],textComponent:n}},Ve=e=>{let t=e.match(/"Claude Code".{0,200}\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find version display for patch 3`),null;let n={index:t.index},r=Math.max(0,n.index-5e3),i=e.slice(r,n.index),a=Array.from(i.matchAll(/[};]\s*function ([$\w]+)\(/g));if(a.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let o=a[a.length-1][1],s=RegExp(`[^$\\w]([$\\w]+)\\.createElement\\(${W(o)},null\\),?`),c=e.match(s);if(!c||c.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let l=e.slice(Math.max(0,c.index-30),c.index+1).match(/([$\w]+)=(?:[$\w]+&&)?[^$\w]?$/);if(l){let t=l[1],n=e.slice(c.index,c.index+2e3),r=RegExp(`,${W(t)}([,\\)])`),i=n.match(r);if(i&&i.index!==void 0){let e=c.index+i.index+i[0].length-i[1].length;return{startIndex:e,endIndex:e}}}let u=c.index+c[0].length;return{startIndex:u,endIndex:u}},He=(e,t,n,r=!0,i=!0)=>{let a=ze(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc-fixed)`,s=`}.VERSION} (Claude Code)`,c=e.replaceAll(s,s+o);M(e,c,o,a.endIndex,a.endIndex);let l=R(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let u=H(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let d=V(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;if(r){let e=c.match(/(\$\{([$\w]+)\("inactive",([$\w]+)\)\(`v\$\{[$\w]+\}`\)\}) `,/);if(e&&e.index!==void 0){let n=e[0],r=e[2],i=e[3],a=`${e[1]} \${${r}("warning",${i})("+ tweakcc v${t}")} \`,`;c=c.replace(n,a)}c=c.replace(/([$\w]+\("claude",[$\w]+\)\(" Claude Code) ("\))/,`$1 + tweakcc v${t} $2`);let n=Be(c);if(!n)console.error(`patch: patchesAppliedIndication: patch 2 skipped (header version pattern changed)`);else{let e=`let _tw=${n.reactVar}.createElement(${n.textComponent},null,${l}.hex("#FF8400").bold("+ tweakcc v${t}"));`,r=c;c=c.slice(0,n.varInsertIndex)+e+c.slice(n.varInsertIndex),M(r,c,e,n.varInsertIndex,n.varInsertIndex);let i=n.refInsertIndex+e.length,a=`," ",_tw`,o=c;c=c.slice(0,i)+a+c.slice(i),M(o,c,a,i,i)}}if(i){let e=ki(c);if(!e)return console.error(`patch: patchesAppliedIndication: PATCH 3 skipped (Box component not located on this CC version)`),c;let t=Ve(c);if(!t)console.log(`patch: patchesAppliedIndication: patch 3 skipped (see prior message)`);else{let r=[];r.push(`,${d}.createElement(${e}, { flexDirection: "column" },`),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {color: "success", bold: true}, "✓ tweakcc-fixed patches are applied")),`);for(let t of n)t=t.replace(`CHALK_VAR`,l),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {dimColor: true}, \` * ${t}\`)),`);r.push(`),`);let i=r.join(`
2
2
  `);t.startIndex>0&&c[t.startIndex-1]===`,`&&i.startsWith(`,`)&&(i=i.slice(1)),i.endsWith(`,`)&&c[t.startIndex]===`,`&&(i=i.slice(0,-1));let a=c;c=c.slice(0,t.startIndex)+i+c.slice(t.endIndex),M(a,c,i,t.startIndex,t.endIndex)}}return c};function Ue(){try{let e=v(import.meta.url),t=f.dirname(e);for(let e=0;e<5;e++){let e=f.join(t,`data`,`prompts`),n=f.join(t,`package.json`);if(s.existsSync(n)&&s.existsSync(e))return e;let r=f.dirname(t);if(r===t)break;t=r}}catch{}return null}async function We(e){let t=Ue();if(t){let n=f.join(t,`prompts-${e}.json`);try{let e=await a.readFile(n,`utf-8`);return JSON.parse(e)}catch{}}let n=f.join(ha,`prompts-${e}.json`);try{let e=await a.readFile(n,`utf-8`);return JSON.parse(e)}catch{}let r=`https://raw.githubusercontent.com/skrabe/tweakcc-fixed/refs/heads/main/data/prompts/prompts-${e}.json`;try{let t=await fetch(r);if(!t.ok){let n;throw n=t.status===429?`Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.`:t.status===404?`Prompts file not found for Claude Code v${e}. The fork's version-bump pipeline hasn't published prompts for this release yet — check https://github.com/skrabe/tweakcc-fixed for status.`:t.status>=500?`GitHub server error (${t.status}). Please try again later.`:`HTTP ${t.status}: ${t.statusText}`,Error(n)}let i=await t.json();try{await a.mkdir(ha,{recursive:!0}),await a.writeFile(n,JSON.stringify(i,null,2),`utf-8`)}catch(e){console.warn(`Failed to write to cache to ${n}: ${e}`)}return i}catch(t){if(t instanceof Error){if(t.message.includes(`Rate limit`)||t.message.includes(`not found`)||t.message.includes(`server error`)||t.message.includes(`HTTP`))throw t;let n=`Failed to download prompts for version ${e}: ${t.message}`;throw Error(n)}throw t}}const Ge=()=>f.join(J,`systemPromptOriginalHashes.json`),Ke=()=>f.join(J,`systemPromptAppliedHashes.json`),qe=(e,t)=>`${e}-${t}`,Je=e=>h.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),Ye=async()=>{try{let e=await a.readFile(Ge(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Xe=async e=>{await a.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await a.writeFile(Ge(),JSON.stringify(t,null,2),`utf8`)},Ze=async e=>{let t=await Ye(),n=0;for(let r of e.prompts){let e=qe(r.id,r.version);t[e]||(t[e]=Je(dt(r.pieces,r.identifiers,r.identifierMap)),n++)}return await Xe(t),n},Qe=async(e,t)=>(await Ye())[qe(e,t)],$e=async()=>{try{let e=await a.readFile(Ke(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},et=async e=>{await a.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await a.writeFile(Ke(),JSON.stringify(t,null,2),`utf8`)},tt=async e=>{if(Object.keys(e).length===0)return;let t=await $e();for(let[n,r]of Object.entries(e))t[n]=r;await et(t)},nt=async()=>{let e=await $e(),t={};for(let n of Object.keys(e))t[n]=null;await et(t)},rt=async e=>{try{let t=await $e();if(Object.keys(t).length===0)return!1;let n=(await a.readdir(e)).filter(e=>e.endsWith(`.md`));for(let r of n){let n=t[r.replace(`.md`,``)];if(n==null)continue;let i=f.join(e,r),o=await a.readFile(i,`utf8`);if(Je((await import(`gray-matter`)).default(o,{delimiters:[`<!--`,`-->`]}).content)!==n)return!0}return!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}};let it=null;const at=async()=>{if(it)return it;let e=new Set,t=[Z,ma];for(let n of t){let t;try{t=await a.readdir(n)}catch{continue}if(Array.isArray(t))for(let r of t){if(!r.endsWith(`.md`))continue;let t;try{t=await a.readFile(f.join(n,r),`utf8`)}catch{continue}let i=_(t,{delimiters:[`<!--`,`-->`]}).data?.shadows;if(Array.isArray(i))for(let t of i)typeof t==`string`&&t&&e.add(t)}}return it=e,e};let ot=null;const st=async()=>{if(ot)return ot;let e=new Set,t=Ue();if(t){let n;try{n=await a.readdir(t)}catch{n=[]}for(let r of n)if(!(!r.startsWith(`prompts-`)||!r.endsWith(`.json`)))try{let n=await a.readFile(f.join(t,r),`utf8`),i=JSON.parse(n);for(let t of i.prompts??[])for(let n of Object.values(t.identifierMap??{}))n&&e.add(n)}catch{continue}}return ot=e,e},ct=e=>{let t=_(e,{delimiters:[`<!--`,`-->`]}),{name:n,description:r,ccVersion:i,variables:a}=t.data,o=0,s=e.indexOf(t.content);return s>=0&&(o=e.slice(0,s).split(`
3
3
  `).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}},lt=(e,t,n)=>{let r=t||dt(e.pieces,e.identifiers,e.identifierMap),i=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,a={name:e.name,description:e.description,ccVersion:e.version};if(i&&i.length>0&&(a.variables=i),n)for(let[e,t]of Object.entries(n))e in a||(a[e]=t);return _.stringify(r,a,{delimiters:[`<!--`,`-->`]})},ut=async e=>{let t={};try{let n=A(e),r=_(await a.readFile(n,`utf8`),{delimiters:[`<!--`,`-->`]}),i=new Set([`name`,`description`,`ccVersion`,`variables`]);for(let[e,n]of Object.entries(r.data))i.has(e)||(t[e]=n)}catch{}return t},dt=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++)if(r+=e[i],i<t.length){let e=t[i],a=n[String(e)]||`UNKNOWN_${e}`;r+=a}return r},ft=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]||0,i=r[e]||0;if(t<i)return-1;if(t>i)return 1}return 0},A=e=>f.join(Z,`${e}.md`),pt=async e=>{try{return await a.access(A(e)),!0}catch{return!1}},mt=async e=>{let t=A(e);return ct(await a.readFile(t,`utf-8`))},ht=async(e,t)=>{let n=A(e);await a.writeFile(n,t,`utf-8`)},gt=async(e,t)=>{let n=A(e),r=await a.readFile(n,`utf-8`),i=_(r,{delimiters:[`<!--`,`-->`]}),o=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,s=new Set([`name`,`description`,`ccVersion`,`variables`]),c={name:i.data.name,description:i.data.description,ccVersion:i.data.ccVersion};o&&o.length>0&&(c.variables=o);for(let[e,t]of Object.entries(i.data))s.has(e)||(c[e]=t);let l=_.stringify(i.content,c,{delimiters:[`<!--`,`-->`]});l!==r&&await ht(e,l)},_t=(e,t)=>{let n=e=>e.split(/(\s+)/),r=n(e),i=n(t),a=r.length,o=i.length,s=Array(a+1).fill(0).map(()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)r[e-1]===i[t-1]?s[e][t]=s[e-1][t-1]+1:s[e][t]=Math.max(s[e-1][t],s[e][t-1]);let c=Array(a).fill(!1),l=Array(o).fill(!1),u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l[d-1]=!0,d--):u>0&&(c[u-1]=!0,u--);let f=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`),p=``;for(let e=0;e<r.length;e++){let t=f(r[e]);p+=c[e]?`<mark>${t}</mark>`:t}let m=``;for(let e=0;e<i.length;e++){let t=f(i[e]);m+=l[e]?`<mark>${t}</mark>`:t}return{oldHtml:p,newHtml:m}},vt=(e,t)=>{let n=e.length,r=t.length,i=Array(n+1).fill(0).map(()=>Array(r+1).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]+1:i[a][n]=Math.max(i[a-1][n],i[a][n-1]);let a=[],o=n,s=r,c=[];for(;o>0||s>0;)o>0&&s>0&&e[o-1]===t[s-1]?(c.unshift({type:`unchanged`,line:e[o-1],oldLineNo:o,newLineNo:s}),o--,s--):s>0&&(o===0||i[o][s-1]>=i[o-1][s])?(c.unshift({type:`added`,line:t[s-1],newLineNo:s}),s--):o>0&&(c.unshift({type:`removed`,line:e[o-1],oldLineNo:o}),o--);for(let e=0;e<c.length;e++){let t=c[e],n=c[e+1];if(t.type===`removed`&&n?.type===`added`){let r=_t(t.line,n.line);a.push({type:`modified`,line:t.line,oldLineNo:t.oldLineNo,newLineNo:n.newLineNo,oldHtml:r.oldHtml,newHtml:r.newHtml}),e++}else a.push(t)}return a},yt=async(e,t,n,r,i,o,s,c)=>{let l=n.split(`
4
4
  `),u=r.split(`
@@ -683,7 +683,7 @@ const filtered=chunk
683
683
  return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
684
684
  };
685
685
  // SCROLLING FIX PATCH END
686
- `,r=e.slice(0,t)+n+e.slice(t);return M(e,r,n,t,t),r},Vr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?e:(console.error(`patch: worktreeMode: failed to find worktree gate function pattern`),null);let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Hr=e=>{let t=e,n=t.match(/,model:([$\w]+)\.enum\(([$\w]+)\)\.optional\(\)/);if(!n||n.index===void 0)return t.match(/let\s+[$\w]+\s*=\s*([$\w]+)\s*&&\s*typeof\s+\1\s*===\s*"string"\s*&&\s*[$\w]+\.includes\(\1\)/)?(console.error(`patch: allowCustomAgentModels: failed to find Zod enum pattern`),null):t;let r=n[1],i=n[2],a=`,model:${r}.string().optional()`,o=n.index,s=o+n[0].length;t=t.slice(0,o)+a+t.slice(s),M(e,t,a,o,s);let c=i.replace(/\$/g,`\\$`),l=RegExp(`([;)}])let\\s+([\\$\\w]+)\\s*=\\s*([\\$\\w]+)\\s*&&\\s*typeof\\s+\\3\\s*===\\s*"string"\\s*&&\\s*${c}\\.includes\\(\\3\\)`),u=t,d=t.match(l);if(!d||d.index===void 0)return console.error(`patch: allowCustomAgentModels: failed to find model validation flag pattern`),null;let f=d[1],p=d[2],m=d[3],h=`${f}let ${p}=${m}&&typeof ${m}==="string"`,g=d.index,_=g+d[0].length;return t=t.slice(0,g)+h+t.slice(_),M(u,t,h,g,_),t},Ur=e=>{let t=e,n=/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"xhigh"\s*;\s*return\s*"high"\s*\}/,r=t.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-8"\s*\)\s*return\s*"high"\s*;\s*if\s*\(\s*\3\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"xhigh"\s*;\s*return\s*"high"\s*\}/),i=r||t.match(n);if(i&&i.index!==void 0){let[e,n,a,o]=i,s=r?`function ${n}(${a}){if(${o}(${a})==="claude-opus-4-8")return"max";if(${o}(${a})==="claude-opus-4-7")return"max";return"high"}`:`function ${n}(${a}){if(${o}(${a})==="claude-opus-4-7")return"max";return"high"}`,c=t.slice(0,i.index)+s+t.slice(i.index+e.length);M(t,c,s,i.index,i.index+e.length),t=c}else if(/===\s*"claude-opus-4-8"\s*\)\s*return\s*"max"/.test(t)||/function\s+[$\w]+\s*\(\s*[$\w]+\s*\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*[$\w]+\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"max"\s*;\s*return\s*"high"\s*\}/.test(t))G(`patch: maxEffortDefault: per-model default already "max" — skipping`);else return console.error(`patch: maxEffortDefault: failed to find Opus per-model effort default`),null;return t},Wr={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},Gr=(e,t)=>{if(t===`default`)return e;let n=Wr[t],r=e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\.\s*ANTHROPIC_DEFAULT_OPUS_MODEL\s*\?\?\s*[$\w]+\s*\(\s*\)\s*\.\s*[$\w]+\s*;\s*if\s*\(\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*\)\s*return\s+\8\s*\+\s*"\[1m\]"\s*;\s*return\s+\8\s*\}\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*\.\s*replace\([^)]*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\.\s*ANTHROPIC_DEFAULT_OPUS_MODEL\s*\?\?\s*[$\w]+\s*\(\s*\)\s*\.\s*[$\w]+\s*;\s*if\s*\(\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*\)\s*return\s+\8\s*\+\s*"\[1m\]"\s*;\s*return\s+\8\s*\}\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*\.\s*replace\([^)]*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*\)\s*;\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-8"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_cedar_hollow_7m"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\5\s*\?\.\s*model\s*\)\s*return\s+\5\s*\.\s*model\s*\}\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\7\s*\?\.\s*model\s*\)\s*return\s+\7\s*\.\s*model\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\2\s*\?\.\s*model\s*\)\s*return\s+\2\s*\.\s*model\s*;\s*return\s+([$\w]+)\s*\(\s*\)\s*\}/);if(r&&r.index!==void 0){let[t,i]=r,a=`function ${i}(){return "${n}"}`,o=e.slice(0,r.index)+a+e.slice(r.index+t.length);return M(e,o,a,r.index,r.index+t.length),o}return/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*\}/.test(e)?(G(`patch: autoModeClassifierModel: classifier-model resolver already patched — skipping`),e):e.includes(`"tengu_auto_mode_config"`)?(console.error(`patch: autoModeClassifierModel: failed to find auto-mode classifier resolver`),null):(G(`patch: autoModeClassifierModel: tengu_auto_mode_config not present in this CC build — no-op`),e)},Kr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_amber_quartz"/);if(t&&t.index!==void 0){let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i}let n=e.match(/function [$\w]+\(\)\{return![$\w]+\("tengu_amber_quartz_disabled"/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,t)+r+e.slice(t);return M(e,i,r,t,t),i}let r=e.match(/name:"voice",description:"Toggle voice mode"[\s\S]{0,500}?get isHidden\(\)\{return!([$\w]+)\(\)\}/);if(r&&r.index!==void 0){let t=r[1].replace(/[$]/g,`\\$`),n=RegExp(`function ${t}\\(\\)\\{`),i=e.match(n);if(i&&i.index!==void 0){let t=i.index+i[0].length,n=`return !0;`,r=e.slice(0,t)+n+e.slice(t);return M(e,r,n,t,t),r}}return console.error(`patch: voiceMode: failed to find tengu_amber_quartz gate`),null},qr=e=>{let t=e.match(/if\([$\w]+\("tengu_sotto_voce",!1\)\)/);if(!t||t.index===void 0)return e;let n=`if(!0)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},Jr=(e,t)=>{let n=Kr(e);return!n||t&&(n=qr(n),!n)?null:n},Yr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Xr=e=>{let t=e.match(/reason:"server did not declare claude\/channel capability"\};?/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find gateChannelServer capability check`),null;let n=t.index+t[0].length,r=`return{action:"register"};`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Zr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor_permissions",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor_permissions gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Qr=e=>{let t=e.match(/Experimental[^"]*?inbound messages will be pushed into this session, this carries prompt injection risks\. Restart Claude Code without /);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find ChannelsNotice warning text`),null;let n=`Channels active. Restart Claude Code without `,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return M(e,a,n,r,i),a},$r=e=>{let t=e.match(/if\(![$\w]+\.dev\)[$\w]+\.push\(\{[$\w]+:[$\w]+,[$\w]+:"server: entries need --dangerously-load-development-channels"\}\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find server dev-flag warning block`),null;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+``+e.slice(r);return M(e,i,``,n,r),i},ei=e=>{let t=Yr(e);return!t||(t=Xr(t),!t)||(t=Zr(t),!t)?null:(t=Qr(t)??t,t=$r(t)??t,t)},ti=e=>{let t=e.match(/=2000,([$\w]+)="Read a file from the local filesystem\./);if(!t||t.index===void 0)return/=\(\+process\.env\.CLAUDE_CODE_READ_DEFAULT_LINES/.test(e)?e:(console.error(`patch: readDefaultLines: failed to find =2000 near Read tool prompt anchor`),null);let n=t.index,r=n+5,i=`=(+process.env.CLAUDE_CODE_READ_DEFAULT_LINES||2000)`,a=e.slice(0,n)+i+e.slice(r);return M(e,a,i,n,n+52),a},ni=e=>{if(/function [$\w]+\(([$\w]+),[$\w]+\)\{if\(Object\.entries\([$\w]+\)\.length===0\)return \1;var ([$\w]+)=\1\[0\];if\(\2&&\2\.isMeta/.test(e))return e;let t=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)\)\{if\(Object\.entries\(\3\)\.length===0\)return \2;return\[([\s\S]+?),\.\.\.\2\]\}/);if(!t||t.index===void 0){let t=e.indexOf(`"tengu_context_size"`);if(t>0){let n=e.slice(Math.max(0,t-5e3),t);if(/function [$\w]+\([$\w]+,[$\w]+\)\{return [$\w]+;?\}\s*async function/.test(n))return console.log(`patch: claudemd-context-once-per-conversation: claudemd-context override suppressed wrapper — no-op`),e}return console.error(`patch: claudemd-context-once-per-conversation: failed to find kY6 wrapper`),null}let[n,r,i,a,o]=t,s=`${i}_0`,c=`function ${r}(${i},${a}){if(Object.entries(${a}).length===0)return ${i};var ${s}=${i}[0];if(${s}&&${s}.isMeta&&${s}.message&&typeof ${s}.message.content==="string"&&${s}.message.content.indexOf("<system-reminder>\\nAs you answer the user")===0)return ${i};${i}.unshift(${o});return ${i}}`,l=t.index,u=l+n.length,d=e.slice(0,l)+c+e.slice(u);return M(e,d,c,l,u),d},ri=e=>{let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return`<system-reminder>\n\$\{\2\}\n<\/system-reminder>`\}/);if(!t||t.index===void 0)return/function [$\w]+\(([$\w]+)\)\{if\(!\1\|\|!\1\.trim\(\)\|\|\1==="\(no content\)"\)return"\(no content\)";return`<system-reminder>/.test(e)?e:(console.error(`patch: strip-empty-system-reminders: failed to find LW(H) wrapper`),null);let[n,r,i]=t,a=`function ${r}(${i}){if(!${i}||!${i}.trim()||${i}==="(no content)")return"(no content)";return\`<system-reminder>\n\${${i}}\n</system-reminder>\`}`,o=t.index,s=o+n.length,c=e.slice(0,o)+a+e.slice(s);return M(e,c,a,o,s),c},ii=`The following deferred tools are now available via`,ai=e=>{if(!e.includes(ii))return console.log(`patch: suppress-deferred-tools: anchor not present in this CC build — no-op`),e;if(e.includes(`case"deferred_tools_delta":{return [];`))return e;let t=e.indexOf(`case"deferred_tools_delta":{`);if(t<0)return console.error(`patch: suppress-deferred-tools: failed to find case header`),null;if(!e.slice(t,t+2048).includes(ii))return console.error(`patch: suppress-deferred-tools: case header found but anchor text not nearby`),null;let n=t+28,r=`return [];`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},oi=(e,t)=>{let n=_(t,{delimiters:[`<!--`,`-->`]}),r=n.data,i=(n.content??``).replace(/^\n+/,``).replace(/\n+$/,``);return{id:e,name:typeof r.name==`string`?r.name:e,description:typeof r.description==`string`?r.description:``,ccVersion:typeof r.ccVersion==`string`?r.ccVersion:``,placeholders:Array.isArray(r.placeholders)?r.placeholders.filter(e=>typeof e==`string`):[],body:i,isSuppressed:i.trim().length===0}},si=(e,t,n,r,i)=>{let a={name:e,description:t,ccVersion:n};return r.length>0&&(a.placeholders=r),_.stringify(i,a,{delimiters:[`<!--`,`-->`]})},ci=async e=>{let t=l.join(ma,`${e}.md`);try{return oi(e,await a.readFile(t,`utf8`))}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}},li=async(e,t,n,r,i,o)=>{let s=l.join(ma,`${e}.md`);try{return await a.stat(s),!1}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return await a.mkdir(l.dirname(s),{recursive:!0}),await a.writeFile(s,si(t,n,r,i,o)),!0},ui=(e,t)=>{let n=[],r=new Set(Object.keys(t)),i=/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g,a;for(;(a=i.exec(e))!==null;)r.has(a[1])||n.push(`unknown placeholder "{{${a[1]}}}"; allowed: ${[...r].map(e=>`{{${e}}}`).join(`, `)||`(none)`}`);if(n.length>0)return{result:``,errors:n};let o=e.split(i),s=``;for(let e=0;e<o.length;e++)e%2==0?s+=o[e].replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${"):s+=t[o[e]];return{result:s,errors:[]}},F=(e,t,n,r,i)=>{let a=e.match(t);if(!a||a.index===void 0)return i&&i(e)?e:(console.error(`patch: reminder ${r}: failed to find anchor`),null);let o=n(a),s=e.slice(0,a.index)+o+e.slice(a.index+a[0].length);return M(e,s,o,a.index,a.index+a[0].length),s},I=(e,t,n)=>{let r=`case"${t}":{`,i=[],a=0;for(;;){let t=e.indexOf(r,a);if(t<0)break;i.push(t),a=t+r.length}if(i.length===0)return null;let o=i.find(t=>e.slice(t,t+2048).includes(n));if(o===void 0)return null;let s=o+r.length,c=1,l=s,u=!1,d=!1,f=!1,p=0;for(;l<e.length&&c>0;){let t=e[l],n=e[l-1];if(d)t===`\\`?l++:t===`'`&&(d=!1);else if(f)t===`\\`?l++:t===`"`&&(f=!1);else if(u)t===`\\`?l++:t==="`"&&p===0?u=!1:t===`$`&&e[l+1]===`{`?(p++,l++):t===`}`&&p>0&&p--;else if(t===`'`&&n!==`\\`)d=!0;else if(t===`"`&&n!==`\\`)f=!0;else if(t==="`"&&n!==`\\`)u=!0;else if(t===`{`)c++;else if(t===`}`&&(c--,c===0))return{headerIdx:o,bodyStart:s,bodyEnd:l};l++}return null},L=e=>{let t=/return\s+([$\w]+)\(\[([$\w]+)\(\{content:/g,n=null,r;for(;(r=t.exec(e))!==null;)n=r;return n?{arrayWrap:n[1],msgCtor:n[2]}:{arrayWrap:`o5`,msgCtor:`j6`}},di=e=>{let t=e.match(/^\s*if\(!([$\w]+)\(\)\)return\s*\[\]/);return t?t[1]:`GX`},fi=(e,t)=>{let n=e.match(RegExp(`([$\\w]+)\\.${t}\\b`));return n?n[1]:`H`},pi=[{id:`claudemd-context`,name:`claudeMd context wrapper`,description:`Per-turn <system-reminder> that bundles { claudeMd, userEmail, currentDate } into a 'As you answer the user's questions...' block. Empty .md body = suppress entirely.`,placeholders:{context_blocks:"${Object.entries(_).map(([q,K])=>`# ${q}\\n${K}`).join(`\\n`)}"},defaultBody:`As you answer the user's questions, you can use the following context:
686
+ `,r=e.slice(0,t)+n+e.slice(t);return M(e,r,n,t,t),r},Vr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?e:(console.error(`patch: worktreeMode: failed to find worktree gate function pattern`),null);let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Hr=e=>{let t=e,n=t.match(/,model:([$\w]+)\.enum\(([$\w]+)\)\.optional\(\)/);if(!n||n.index===void 0)return t.match(/let\s+[$\w]+\s*=\s*([$\w]+)\s*&&\s*typeof\s+\1\s*===\s*"string"\s*&&\s*[$\w]+\.includes\(\1\)/)?(console.error(`patch: allowCustomAgentModels: failed to find Zod enum pattern`),null):t;let r=n[1],i=n[2],a=`,model:${r}.string().optional()`,o=n.index,s=o+n[0].length;t=t.slice(0,o)+a+t.slice(s),M(e,t,a,o,s);let c=i.replace(/\$/g,`\\$`),l=RegExp(`([;)}])let\\s+([\\$\\w]+)\\s*=\\s*([\\$\\w]+)\\s*&&\\s*typeof\\s+\\3\\s*===\\s*"string"\\s*&&\\s*${c}\\.includes\\(\\3\\)`),u=t,d=t.match(l);if(!d||d.index===void 0)return console.error(`patch: allowCustomAgentModels: failed to find model validation flag pattern`),null;let f=d[1],p=d[2],m=d[3],h=`${f}let ${p}=${m}&&typeof ${m}==="string"`,g=d.index,_=g+d[0].length;return t=t.slice(0,g)+h+t.slice(_),M(u,t,h,g,_),t},Ur=e=>{let t=e,n=/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"xhigh"\s*;\s*return\s*"high"\s*\}/,r=t.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-8"\s*\)\s*return\s*"high"\s*;\s*if\s*\(\s*\3\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"xhigh"\s*;\s*return\s*"high"\s*\}/),i=r||t.match(n);if(i&&i.index!==void 0){let[e,n,a,o]=i,s=r?`function ${n}(${a}){if(${o}(${a})==="claude-opus-4-8")return"max";if(${o}(${a})==="claude-opus-4-7")return"max";return"high"}`:`function ${n}(${a}){if(${o}(${a})==="claude-opus-4-7")return"max";return"high"}`,c=t.slice(0,i.index)+s+t.slice(i.index+e.length);M(t,c,s,i.index,i.index+e.length),t=c}else if(/===\s*"claude-opus-4-8"\s*\)\s*return\s*"max"/.test(t)||/function\s+[$\w]+\s*\(\s*[$\w]+\s*\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*[$\w]+\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"max"\s*;\s*return\s*"high"\s*\}/.test(t))G(`patch: maxEffortDefault: per-model default already "max" — skipping`);else return console.error(`patch: maxEffortDefault: failed to find Opus per-model effort default`),null;return t},Wr={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},Gr=(e,t)=>{if(t===`default`)return e;let n=Wr[t],r=e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*return\s+[$\w]+\s*\(\s*\2\s*\)\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\.\s*ANTHROPIC_DEFAULT_OPUS_MODEL\s*\?\?\s*[$\w]+\s*\(\s*\)\s*\.\s*[$\w]+\s*;\s*if\s*\(\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*\)\s*return\s+\8\s*\+\s*"\[1m\]"\s*;\s*return\s+\8\s*\}\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*\.\s*replace\([^)]*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\.\s*ANTHROPIC_DEFAULT_OPUS_MODEL\s*\?\?\s*[$\w]+\s*\(\s*\)\s*\.\s*[$\w]+\s*;\s*if\s*\(\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*\)\s*return\s+\8\s*\+\s*"\[1m\]"\s*;\s*return\s+\8\s*\}\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*\.\s*replace\([^)]*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*\)\s*;\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-8"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_cedar_hollow_7m"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\5\s*\?\.\s*model\s*\)\s*return\s+\5\s*\.\s*model\s*\}\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\7\s*\?\.\s*model\s*\)\s*return\s+\7\s*\.\s*model\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\2\s*\?\.\s*model\s*\)\s*return\s+\2\s*\.\s*model\s*;\s*return\s+([$\w]+)\s*\(\s*\)\s*\}/);if(r&&r.index!==void 0){let[t,i]=r,a=`function ${i}(){return "${n}"}`,o=e.slice(0,r.index)+a+e.slice(r.index+t.length);return M(e,o,a,r.index,r.index+t.length),o}return/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*\}/.test(e)?(G(`patch: autoModeClassifierModel: classifier-model resolver already patched — skipping`),e):e.includes(`"tengu_auto_mode_config"`)?(console.error(`patch: autoModeClassifierModel: failed to find auto-mode classifier resolver`),null):(G(`patch: autoModeClassifierModel: tengu_auto_mode_config not present in this CC build — no-op`),e)},Kr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_amber_quartz"/);if(t&&t.index!==void 0){let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i}let n=e.match(/function [$\w]+\(\)\{return![$\w]+\("tengu_amber_quartz_disabled"/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,t)+r+e.slice(t);return M(e,i,r,t,t),i}let r=e.match(/name:"voice",description:"Toggle voice mode"[\s\S]{0,500}?get isHidden\(\)\{return!([$\w]+)\(\)\}/);if(r&&r.index!==void 0){let t=r[1].replace(/[$]/g,`\\$`),n=RegExp(`function ${t}\\(\\)\\{`),i=e.match(n);if(i&&i.index!==void 0){let t=i.index+i[0].length,n=`return !0;`,r=e.slice(0,t)+n+e.slice(t);return M(e,r,n,t,t),r}}return console.error(`patch: voiceMode: failed to find tengu_amber_quartz gate`),null},qr=e=>{let t=e.match(/if\([$\w]+\("tengu_sotto_voce",!1\)\)/);if(!t||t.index===void 0)return e;let n=`if(!0)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return M(e,r,n,t.index,t.index+t[0].length),r},Jr=(e,t)=>{let n=Kr(e);return!n||t&&(n=qr(n),!n)?null:n},Yr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Xr=e=>{let t=e.match(/reason:"server did not declare claude\/channel capability"\};?/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find gateChannelServer capability check`),null;let n=t.index+t[0].length,r=`return{action:"register"};`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Zr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor_permissions",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor_permissions gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},Qr=e=>{let t=e.match(/Experimental[^"]*?inbound messages will be pushed into this session, this carries prompt injection risks\. Restart Claude Code without /);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find ChannelsNotice warning text`),null;let n=`Channels active. Restart Claude Code without `,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return M(e,a,n,r,i),a},$r=e=>{let t=e.match(/if\(![$\w]+\.dev\)[$\w]+\.push\(\{[$\w]+:[$\w]+,[$\w]+:"server: entries need --dangerously-load-development-channels"\}\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find server dev-flag warning block`),null;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+``+e.slice(r);return M(e,i,``,n,r),i},ei=e=>{let t=Yr(e);return!t||(t=Xr(t),!t)||(t=Zr(t),!t)?null:(t=Qr(t)??t,t=$r(t)??t,t)},ti=e=>{let t=e.match(/=2000,([$\w]+)="Read a file from the local filesystem\./);if(!t||t.index===void 0)return/=\(\+process\.env\.CLAUDE_CODE_READ_DEFAULT_LINES/.test(e)?e:(console.error(`patch: readDefaultLines: failed to find =2000 near Read tool prompt anchor`),null);let n=t.index,r=n+5,i=`=(+process.env.CLAUDE_CODE_READ_DEFAULT_LINES||2000)`,a=e.slice(0,n)+i+e.slice(r);return M(e,a,i,n,n+52),a},ni=e=>{if(/function [$\w]+\(([$\w]+),[$\w]+\)\{if\(Object\.entries\([$\w]+\)\.length===0\)return \1;var ([$\w]+)=\1\[0\];if\(\2&&\2\.isMeta/.test(e))return e;let t=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)\)\{if\(Object\.entries\(\3\)\.length===0\)return \2;return\[([\s\S]+?),\.\.\.\2\]\}/);if(!t||t.index===void 0){let t=e.indexOf(`"tengu_context_size"`);if(t>0){let n=e.slice(Math.max(0,t-5e3),t);if(/function [$\w]+\([$\w]+,[$\w]+\)\{return [$\w]+;?\}\s*async function/.test(n))return console.log(`patch: claudemd-context-once-per-conversation: claudemd-context override suppressed wrapper — no-op`),e}return console.error(`patch: claudemd-context-once-per-conversation: failed to find kY6 wrapper`),null}let[n,r,i,a,o]=t,s=`${i}_0`,c=`function ${r}(${i},${a}){if(Object.entries(${a}).length===0)return ${i};var ${s}=${i}[0];if(${s}&&${s}.isMeta&&${s}.message&&typeof ${s}.message.content==="string"&&${s}.message.content.indexOf("<system-reminder>\\nAs you answer the user")===0)return ${i};${i}.unshift(${o});return ${i}}`,l=t.index,u=l+n.length,d=e.slice(0,l)+c+e.slice(u);return M(e,d,c,l,u),d},ri=e=>{let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return`<system-reminder>\n\$\{\2\}\n<\/system-reminder>`\}/);if(!t||t.index===void 0)return/function [$\w]+\(([$\w]+)\)\{if\(!\1\|\|!\1\.trim\(\)\|\|\1==="\(no content\)"\)return"\(no content\)";return`<system-reminder>/.test(e)?e:(console.error(`patch: strip-empty-system-reminders: failed to find LW(H) wrapper`),null);let[n,r,i]=t,a=`function ${r}(${i}){if(!${i}||!${i}.trim()||${i}==="(no content)")return"(no content)";return\`<system-reminder>\n\${${i}}\n</system-reminder>\`}`,o=t.index,s=o+n.length,c=e.slice(0,o)+a+e.slice(s);return M(e,c,a,o,s),c},ii=`The following deferred tools are now available via`,ai=e=>{if(!e.includes(ii))return console.log(`patch: suppress-deferred-tools: anchor not present in this CC build — no-op`),e;if(e.includes(`case"deferred_tools_delta":{return [];`))return e;let t=e.indexOf(`case"deferred_tools_delta":{`);if(t<0)return console.error(`patch: suppress-deferred-tools: failed to find case header`),null;if(!e.slice(t,t+2048).includes(ii))return console.error(`patch: suppress-deferred-tools: case header found but anchor text not nearby`),null;let n=t+28,r=`return [];`,i=e.slice(0,n)+r+e.slice(n);return M(e,i,r,n,n),i},oi=(e,t)=>{let n=_(t,{delimiters:[`<!--`,`-->`]}),r=n.data,i=(n.content??``).replace(/^\n+/,``).replace(/\n+$/,``);return{id:e,name:typeof r.name==`string`?r.name:e,description:typeof r.description==`string`?r.description:``,ccVersion:typeof r.ccVersion==`string`?r.ccVersion:``,placeholders:Array.isArray(r.placeholders)?r.placeholders.filter(e=>typeof e==`string`):[],body:i,isSuppressed:i.trim().length===0}},si=(e,t,n,r,i)=>{let a={name:e,description:t,ccVersion:n};return r.length>0&&(a.placeholders=r),_.stringify(i,a,{delimiters:[`<!--`,`-->`]})},ci=async e=>{let t=l.join(ma,`${e}.md`);try{return oi(e,await a.readFile(t,`utf8`))}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}},li=async(e,t,n,r,i,o)=>{let s=l.join(ma,`${e}.md`);try{return await a.stat(s),!1}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return await a.mkdir(l.dirname(s),{recursive:!0}),await a.writeFile(s,si(t,n,r,i,o)),!0},ui=(e,t)=>{let n=[],r=new Set(Object.keys(t)),i=/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g,a;for(;(a=i.exec(e))!==null;)r.has(a[1])||n.push(`unknown placeholder "{{${a[1]}}}"; allowed: ${[...r].map(e=>`{{${e}}}`).join(`, `)||`(none)`}`);if(n.length>0)return{result:``,errors:n};let o=e.split(i),s=``;for(let e=0;e<o.length;e++)e%2==0?s+=o[e].replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${"):s+=t[o[e]];return{result:s,errors:[]}},F=(e,t,n,r,i)=>{let a=e.match(t);if(!a||a.index===void 0)return i&&i(e)?e:(console.error(`patch: reminder ${r}: failed to find anchor`),null);let o=n(a),s=e.slice(0,a.index)+o+e.slice(a.index+a[0].length);return M(e,s,o,a.index,a.index+a[0].length),s},I=(e,t,n)=>{let r=`case"${t}":{`,i=[],a=0;for(;;){let t=e.indexOf(r,a);if(t<0)break;i.push(t),a=t+r.length}if(i.length===0)return null;let o=i.find(t=>e.slice(t,t+2048).includes(n));if(o===void 0)return null;let s=o+r.length,c=1,l=s,u=!1,d=!1,f=!1,p=0;for(;l<e.length&&c>0;){let t=e[l],n=e[l-1];if(d)t===`\\`?l++:t===`'`&&(d=!1);else if(f)t===`\\`?l++:t===`"`&&(f=!1);else if(u)t===`\\`?l++:t==="`"&&p===0?u=!1:t===`$`&&e[l+1]===`{`?(p++,l++):t===`}`&&p>0&&p--;else if(t===`'`&&n!==`\\`)d=!0;else if(t===`"`&&n!==`\\`)f=!0;else if(t==="`"&&n!==`\\`)u=!0;else if(t===`{`)c++;else if(t===`}`&&(c--,c===0))return{headerIdx:o,bodyStart:s,bodyEnd:l};l++}return null},L=e=>{let t=/return\s+([$\w]+)\(\[([$\w]+)\(\{content:/g,n=null,r;for(;(r=t.exec(e))!==null;)n=r;return n?{arrayWrap:n[1],msgCtor:n[2]}:{arrayWrap:`o5`,msgCtor:`j6`}},di=e=>{let t=e.match(/^\s*if\(!([$\w]+)\(\)\)return\s*\[\]/);return t?t[1]:`GX`},fi=(e,t)=>{let n=e.match(RegExp(`([$\\w]+)\\.${t}\\b`));return n?n[1]:`H`},pi=[{id:`claudemd-context`,name:`claudeMd context wrapper`,description:`Per-turn <system-reminder> that bundles { claudeMd, userEmail, currentDate } into a 'As you answer the user's questions...' block. Empty .md body = suppress entirely.`,placeholders:{context_blocks:"${Object.entries(_).map(([q,K])=>`# ${q}\\n${K}`).join(`\\n`)}"},defaultBody:`As you answer the user's questions, you can use the following context:
687
687
  {{context_blocks}}
688
688
 
689
689
  IMPORTANT: this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task.`,apply(e,t,n){let r=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)\)\{if\(Object\.entries\(\3\)\.length===0\)return \2;return\[([$\w]+)\(\{content:`<system-reminder>\n[\s\S]*?\n<\/system-reminder>\n`,isMeta:!0\}\),\.\.\.\2\]\}/);if(!r||r.index===void 0)return/function [$\w]+\([$\w]+,[$\w]+\)\{return [$\w]+;\}/.test(e)?e:(console.error(`patch: reminder claudemd-context: failed to find kY6 wrapper`),null);let[i,a,o,s,c]=r,l;l=n?`function ${a}(${o},${s}){return ${o};}`:`function ${a}(${o},${s}){if(Object.entries(${s}).length===0)return ${o};return[${c}({content:\`<system-reminder>\n${t.replace(/\bObject\.entries\(_\)/g,`Object.entries(${s})`)}\n</system-reminder>\n\`,isMeta:!0}),...${o}]}`;let u=e.slice(0,r.index)+l+e.slice(r.index+i.length);return M(e,u,l,r.index,r.index+i.length),u}},{id:`skills-listing`,name:`Skills listing reminder`,description:`The "The following skills are available..." block. Empty .md body = suppress entirely.`,placeholders:{skill_content:"${H.content}"},defaultBody:`The following skills are available for use with the Skill tool:
@@ -720,6 +720,6 @@ Do NOT interpret this as user acknowledgement, confirmation, or response to any
720
720
  {{content}}`,apply(e,t,n){return F(e,/case"task-notification":return`\[SYSTEM NOTIFICATION - NOT USER INPUT\]\nThis is an automated background-task event, NOT a message from the user\.\nDo NOT interpret this as user acknowledgement, confirmation, or response to any pending question\.\n\n\$\{([$\w]+)\}`;/,e=>{let[,r]=e;return n?`case"task-notification":return\`\${${r}}\`;`:`case"task-notification":return\`${t.replace(/\$\{H\}/g,`\${${r}}`)}\`;`},`task-notification-framing`,e=>/case"task-notification":return`\$\{[$\w]+\}`;/.test(e))}},{id:`user-sent-new-message`,name:`User-sent-new-message wrapper`,description:`Wraps a user message that arrives mid-turn. Carries the "IMPORTANT: After completing your current task, you MUST address" framing. Empty .md = no wrapping (just the message text).`,placeholders:{message:"${H}"},defaultBody:`The user sent a new message while you were working:
721
721
  {{message}}
722
722
 
723
- IMPORTANT: After completing your current task, you MUST address the user's message above. Do not ignore it.`,apply(e,t,n){return F(e,/((?:case"auto-continuation":)?case"human":case void 0:(?:default:)?)return`The user sent a new message while you were working:\n\$\{([$\w]+)\}\n\nIMPORTANT: After completing your current task, you MUST address the user's message above\. Do not ignore it\.`/,e=>{let[,r,i]=e;return n?`${r}return\`\${${i}}\``:`${r}return\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`user-sent-new-message`,e=>/(?:case"auto-continuation":)?case"human":case void 0:(?:default:)?return`\$\{[$\w]+\}`/.test(e))}},{id:`stop-hook-session-goal`,name:`Stop-hook session-goal reminder`,description:`Fires when /goal sets a session-scoped stop hook. Carries the "do not pause to ask" framing. Empty .md = silent goal activation (just the condition value used internally).`,placeholders:{condition:"${H}"},defaultBody:'A session-scoped Stop hook is now active with condition: "{{condition}}". Briefly acknowledge the goal, then immediately start (or continue) working toward it — treat the condition itself as your directive and do not pause to ask the user what to do. The hook will block stopping until the condition holds. It auto-clears once the condition is met — do not tell the user to run `/goal clear` after success; that\'s only for clearing a goal early.',apply(e,t,n){return F(e,/([$\w]+)=\(([$\w]+)\)=>`A session-scoped Stop hook is now active with condition: "\$\{\2\}"\. Briefly acknowledge the goal, then immediately start \(or continue\) working toward it[\s\S]*?after success; that's only for clearing a goal early\.`/,e=>{let[,r,i]=e;return n?`${r}=(${i})=>""`:`${r}=(${i})=>\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`stop-hook-session-goal`,e=>/[$\w]+=\([$\w]+\)=>""/.test(e))}},{id:`mcp-per-server-router`,name:`MCP per-server instruction router`,description:`Patches CC's MCP instruction assembly to consult ~/.tweakcc/system-reminders/mcp-<server-name>.md at runtime. Empty body in that file drops the server's block. Body containing {{server_instructions}} resolves to the server's pristine instructions. Custom body replaces. THIS .md does nothing on its own — it just enables per-server .md files. Empty body = disable this routing (servers use pristine instructions verbatim).`,placeholders:{},defaultBody:`This file is a marker that enables per-MCP-server overrides. Edit per-server content in mcp-<server-name>.md alongside this file. Leave this file with content (any content) to enable routing; empty it to disable.`,apply(e,t,n){if(n)return e;let r=e.match(/for\(let ([$\w]+) of ([$\w]+)\)if\(\1\.instructions\)([$\w]+)\.set\(\1\.name,`## \$\{\1\.name\}\n\$\{\1\.instructions\}`\);/);if(!r||r.index===void 0)return e.includes(`__tweakccMcpOverride`)?e:(console.error(`patch: reminder mcp-per-server-router: failed to find MCP assembly loop`),null);let[i,a,o,s]=r,c=`function __tweakccMcpOverride(_n,_d){try{let _f=require('fs'),_p=require('os').homedir()+'/.tweakcc/system-reminders/mcp-'+_n+'.md';let _r=_f.readFileSync(_p,'utf8');let _m=_r.match(/-->\\s*([\\s\\S]*?)\\s*\$/);if(!_m)return _d;let _b=_m[1].trim();if(_b==='')return null;return _b.replace(/\\{\\{server_instructions\\}\\}/g,_d||'')}catch{return _d}}for(let ${a} of ${o}){let _c=__tweakccMcpOverride(${a}.name,${a}.instructions);if(_c)${s}.set(${a}.name,\`## \${${a}.name}\n\${_c}\`)}`,l=e.slice(0,r.index)+c+e.slice(r.index+i.length);return M(e,l,c,r.index,r.index+i.length),l}}],mi=async()=>{let e=[l.join(n.homedir(),`.claude.json`),l.join(n.homedir(),`.claude`,`mcp.json`)];for(let t of e)try{let e=await a.readFile(t,`utf8`),n=JSON.parse(e);if(n.mcpServers&&typeof n.mcpServers==`object`)return Object.keys(n.mcpServers)}catch{}return[]},hi=async(e,t)=>{let n=[],r=e,i=await mi();for(let e of i)await li(`mcp-${e}`,`MCP server: ${e}`,`Instructions block content for MCP server "${e}". {{server_instructions}} expands at runtime to the server's pristine instructions. Empty body drops the server's block from the model's context. Custom body replaces it.`,t,[`server_instructions`],`{{server_instructions}}`);for(let e of pi){let i=await li(e.id,e.name,e.description,t,Object.keys(e.placeholders),e.defaultBody),a=await ci(e.id);if(!a){n.push({id:e.id,name:e.name,description:e.description,state:`default`,applied:!1,failed:!1,skipped:!0,details:`override file missing after ensure (unexpected)`});continue}let{result:o,errors:s}=ui(a.body,e.placeholders);if(s.length>0){n.push({id:e.id,name:e.name,description:e.description,state:`override`,applied:!1,failed:!0,skipped:!1,details:s.join(`; `)});continue}let c=e.apply(r,o,a.isSuppressed);if(c===null){n.push({id:e.id,name:e.name,description:e.description,state:a.isSuppressed?`suppressed`:`override`,applied:!1,failed:!0,skipped:!1,details:`patch function returned null`});continue}let l=c!==r;r=c;let u;u=a.isSuppressed?`suppressed`:a.body===e.defaultBody.trim()?`default`:`override`,n.push({id:e.id,name:e.name,description:e.description,state:u,applied:l,failed:!1,skipped:!1,details:i?`seeded default file`:void 0})}return{content:r,results:n}},gi=async e=>{if(!e.cliPath){G(`backupClijs: Skipping for native installation (no cliPath)`);return}await _a(),G(`Backing up cli.js to ${pa}`),await o.copyFile(e.cliPath,pa),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version})},_i=async e=>{e.nativeInstallationPath&&(await _a(),G(`Backing up native binary to ${X}`),await o.copyFile(e.nativeInstallationPath,X),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},vi=async e=>{if(!e.cliPath)return G(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;G(`Restoring cli.js from backup to ${e.cliPath}`);let t=await o.readFile(pa);return await ia(e.cliPath,t,`restore`),await nt(),await $(e=>{e.changesApplied=!1}),!0},yi=async e=>{if(!e.nativeInstallationPath)return G(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await aa(X))return G(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;G(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await o.readFile(X);return await ia(e.nativeInstallationPath,t,`restore`),!0},R=e=>{let t=Array.from(e.matchAll(/[^$\w]([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},bi=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e4),r=Array.from(n.matchAll(/(?:var |,)([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/g));if(r.length>0){let e=r[0][1];for(let t of r)t[1].length<e.length&&(e=t[1]);return e}console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},xi=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},Si=e=>{let t=xi(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${W(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let z=null,B=null;const V=e=>{if(z!=null)return z;let t=bi(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),z=void 0;return}let n=xi(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),z=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${W(t)}\\(${W(n)}\\(\\),1\\)`),i=e.match(r);if(i)return z=i[1],z;let a=Si(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),z=void 0;return}let o=RegExp(`[^$\\w]([$\\w]+)=${W(t)}\\(${W(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),z=void 0;return}return z=s[1],z},Ci=()=>{z=null},wi=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${W(n)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${n})`);return}return i[1]},Ti=e=>{if(B!=null)return B;let t=wi(e);return t?(B=t,B):(B=`require`,B)},Ei=()=>{B=null},Di=()=>{Ci(),Ei()},H=e=>{let t=e.match(/\bfunction ([$\w]+).{0,80}color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+(?:=![01])?,bold:[$\w]+(?:=![01])?/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},Oi=(e,t)=>{let n=`[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*`,r=RegExp(`var [^;]{0,120};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,500}([$\\w]+)=${W(t)}\\}\\)`),i=e.match(r)?.[1]??t,a=RegExp(`function ([$\\w]+)\\([^)]+\\)\\{(?=[\\s\\S]{0,2500}createElement\\(${W(i)},\\{\\.\\.\\.[$\\w]+,borderColor:)[\\s\\S]{0,3000}?return [$\\w]+\\}var [^;]{0,160};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,600}([$\\w]+)=\\1\\}\\)`);return e.match(a)?.[2]},ki=e=>{let t=e.match(/function ([$\w]+)\(.{0,2000}[^$\w]([$\w]+)=[$\w]+(?:\.default)?\.createElement\("ink-box".{0,500}?return \2/);if(t)return t[1];let n=e.match(/function ([$\w]+)\(.{0,200}children:[$\w]+,flexWrap:[$\w]+.{0,2000}?\.createElement\("ink-box"/);if(n)return n[1];let r=e.match(/[^$\w]([$\w]+)\.displayName="Box"/);if(r)return r[1];let i=e.match(/function ([$\w]+)\([$\w]+\)\{let [$\w]+=[$\w]+(?:\.[$\w]+)?\(\d+\).{0,3000}createElement\("ink-box"/);if(i)return i[1];let a=e.match(/function ([$\w]+)\(\{children:([$\w]+),ref:[$\w]+.{0,600}?\.\.\.([$\w]+)\}\)\{.{0,2500}?"margin".{0,2500}?"padding".{0,1200}?"gap".{0,1200}?\3\.flexWrap\?\?="nowrap",\3\.flexDirection\?\?="row",\3\.flexGrow\?\?=0,\3\.flexShrink\?\?=1,\3\.overflowX=\3\.overflowX\?\?\3\.overflow\?\?"visible",\3\.overflowY=\3\.overflowY\?\?\3\.overflow\?\?"visible",[$\w]+(?:\.default)?\.createElement\("ink-box",\{[^}]*style:\3\},\2\)/);if(a)return Oi(e,a[1])??a[1];let o=e.match(/function ([$\w]+)\(\{children:[$\w]+,ref:[$\w]+,tabIndex:[$\w]+,autoFocus:[$\w]+/);if(o)return o[1];console.error(`patch: findBoxComponent: failed to find Box component (neither ink-box createElement nor displayName found)`)},Ai=e(import.meta.url),ji=(()=>{try{return Ai(`../package.json`).version}catch{return Ai(`../../package.json`).version}})();let U=function(e){return e.SYSTEM_PROMPTS=`System Prompts`,e.ALWAYS_APPLIED=`Always Applied`,e.MISC_CONFIGURABLE=`Misc Configurable`,e.FEATURES=`Features`,e.SYSTEM_REMINDERS=`System Reminders`,e}({});const Mi=[{id:`verbose-property`,name:`Verbose property`,group:U.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{id:`read-default-lines`,name:`Read default lines (env-gated)`,group:U.ALWAYS_APPLIED,description:`Read tool default line cap becomes CLAUDE_CODE_READ_DEFAULT_LINES env var (falls back to 2000 if unset)`},{id:`opusplan1m`,name:`Opusplan[1m] support`,group:U.ALWAYS_APPLIED,description:`Use the "Opus Plan 1M" model: Opus for planning, Sonnet 1M context for building`},{id:`thinking-block-styling`,name:`Thinking block styling`,group:U.ALWAYS_APPLIED,description:`Restore dim/gray + italic styling for thinking blocks`},{id:`fix-lsp-support`,name:`Fix LSP support`,group:U.ALWAYS_APPLIED,description:`Enable/fix nascent LSP support`},{id:`fix-summarize-from-here`,name:`Fix "Summarize from here"`,group:U.MISC_CONFIGURABLE,description:`Make "Summarize from here" summarize only the messages after the rewind point (feed the slice, not the whole conversation)`},{id:`fix-rewind-summary-header`,name:`Honest rewind summary header`,group:U.MISC_CONFIGURABLE,description:`Label a rewind summary as a deliberate rewind instead of the misleading "ran out of context" header`},{id:`statusline-update-throttle`,name:`Statusline update throttling correction`,group:U.ALWAYS_APPLIED,description:`Statusline updates will be properly throttled instead of queued (or debounced)`},{id:`strip-empty-system-reminders`,name:`Strip empty <system-reminder> wrappers`,group:U.ALWAYS_APPLIED,description:`Short-circuits CC's universal system-reminder wrapper so empty / "(no content)" inputs produce no reminder. Kills the drift-inducing "<system-reminder>(no content)</system-reminder>" blocks that get appended to roughly every other tool call.`},{id:`model-customizations`,name:`Model customizations`,group:U.MISC_CONFIGURABLE,description:`Access all Claude models with /model, not just latest 3`},{id:`show-more-items-in-select-menus`,name:`Show more items in select menus`,group:U.MISC_CONFIGURABLE,description:`Show 25 items in select menus instead of default 5`},{id:`context-limit`,name:`Context limit`,group:U.MISC_CONFIGURABLE,description:`Override the 200K context limit via CLAUDE_CODE_CONTEXT_LIMIT env var (set before launching CC)`},{id:`patches-applied-indication`,name:`Patches applied indication`,group:U.MISC_CONFIGURABLE,description:`Show "tweakcc patches applied" and tweakcc version inside CC`},{id:`table-format`,name:`Table format`,group:U.MISC_CONFIGURABLE,description:`Tables generated by Claude will be rendered more compactly`},{id:`themes`,name:`Themes`,group:U.MISC_CONFIGURABLE,description:`Your custom themes will be available via /theme`},{id:`thinking-verbs`,name:`Thinking verbs`,group:U.MISC_CONFIGURABLE,description:`Your custom list of thinking verbs will be cycled through`},{id:`thinker-format`,name:`Thinker format`,group:U.MISC_CONFIGURABLE,description:`Your custom format string that thinking verbs are wrapped in will be applied`},{id:`thinker-symbol-chars`,name:`Thinker symbol chars`,group:U.MISC_CONFIGURABLE,description:`Your custom thinking spinner will be rendered`},{id:`thinker-symbol-speed`,name:`Thinker symbol speed`,group:U.MISC_CONFIGURABLE,description:`The thinking spinner will play at a custom FPS`},{id:`thinker-symbol-width`,name:`Thinker symbol width`,group:U.MISC_CONFIGURABLE,description:`The thinking spinner will be in a box of custom width`},{id:`thinker-symbol-mirror`,name:`Thinker symbol mirror`,group:U.MISC_CONFIGURABLE,description:`The thinking spinner will reverse or restart when it finishes`},{id:`input-box-border`,name:`Input box border`,group:U.MISC_CONFIGURABLE,description:`Your custom styles to the main input box's border will be applied`},{id:`subagent-models`,name:`Subagent models`,group:U.MISC_CONFIGURABLE,description:`Use custom models for Plan, Explore, and General subagents`},{id:`thinking-visibility`,name:`Thinking block visibility`,group:U.MISC_CONFIGURABLE,description:`Thinking blocks outputted by the model will show without Ctrl+O`},{id:`hide-startup-banner`,name:`Hide startup banner`,group:U.MISC_CONFIGURABLE,description:`CC's startup banner with "Clawd" and release notes will be hidden`},{id:`hide-ctrl-g-to-edit`,name:`Hide Ctrl+G to edit`,group:U.MISC_CONFIGURABLE,description:`Note about using Ctrl+G to edit prompt will be hidden`},{id:`hide-startup-clawd`,name:`Hide startup Clawd`,group:U.MISC_CONFIGURABLE,description:`The "Clawd" icon on startup will be hidden for a cleaner look`},{id:`increase-file-read-limit`,name:`Increase file read limit`,group:U.MISC_CONFIGURABLE,description:`Max tokens Claude can read from a file at once will be increased`},{id:`suppress-line-numbers`,name:`Suppress line numbers`,group:U.MISC_CONFIGURABLE,description:`"1→" "2→" etc. prefixes for each line of Read output will be omitted`},{id:`suppress-rate-limit-options`,name:`Suppress rate limit options`,group:U.MISC_CONFIGURABLE,description:`/rate-limit-options won't be injected when limits are reached`},{id:`token-count-rounding`,name:`Token count rounding`,group:U.MISC_CONFIGURABLE,description:`Round displayed token counts to the nearest multiple of chosen value`},{id:`remember-skill`,name:`Remember skill`,group:U.MISC_CONFIGURABLE,description:`Register the built-in "/remember" skill to review session memories and update CLAUDE.local.md`},{id:`agents-md`,name:`AGENTS.md (and others)`,group:U.MISC_CONFIGURABLE,description:`Support AGENTS.md and others in addition to CLAUDE.md`},{id:`auto-accept-plan-mode`,name:`Auto-accept plan mode`,group:U.MISC_CONFIGURABLE,description:`Automatically accept plans without the "Ready to code?" confirmation prompt`},{id:`allow-sudo-bypass-permissions`,name:`Allow bypassing permissions with --dangerously-skip-permissions in sudo`,group:U.MISC_CONFIGURABLE,description:`Allow bypassing permissions with --dangerously-skip-permissions even when running with root/sudo privileges`},{id:`suppress-native-installer-warning`,name:`Suppress native installer warning`,group:U.MISC_CONFIGURABLE,description:`Suppress the native installer warning message at startup`},{id:`filter-scroll-escape-sequences`,name:`Filter scroll escape sequences`,group:U.MISC_CONFIGURABLE,description:`Filter out terminal escape sequences that cause unwanted scrolling`},{id:`max-effort-default`,name:`Default Opus 4.7 to max effort`,group:U.MISC_CONFIGURABLE,description:`Opus 4.7 sessions default to "max" reasoning effort instead of "xhigh" (override with /effort or CLAUDE_CODE_EFFORT_LEVEL)`},{id:`auto-mode-classifier-model`,name:`Auto-mode classifier model`,group:U.MISC_CONFIGURABLE,description:`Pin auto-mode bash safety classifier to Sonnet 4.6 or Haiku 4.5 instead of the user main-loop model (avoids Opus 4.7 congestion denying tool calls)`},{id:`allow-custom-agent-models`,name:`Allow custom agent models`,group:U.FEATURES,description:`Allow arbitrary model names in custom agent frontmatter (e.g. gemini-2.5-flash)`},{id:`worktree-mode`,name:`Worktree mode`,group:U.FEATURES,description:`Enable the EnterWorktree tool for isolated git worktree sessions`},{id:`session-memory`,name:`Session memory`,group:U.FEATURES,description:`Enable session memory (auto-extraction + past session search)`},{id:`dream-mode`,name:`Dream mode`,group:U.FEATURES,description:`Enable dream (/dream + auto-dream background memory consolidation)`},{id:`lean-memory-types`,name:`Lean memory types`,group:U.FEATURES,description:`Compact "Types of memory" prompt block + on-demand memory-types skill`},{id:`toolsets`,name:`Toolsets`,group:U.FEATURES,description:`Custom toolsets will be registered`},{id:`mcp-non-blocking`,name:`MCP non-blocking`,group:U.FEATURES,description:`If you have MCP servers, CC startup will be much faster`},{id:`mcp-batch-size`,name:`MCP batch size`,group:U.FEATURES,description:`Change the number of MCP servers started in parallel`},{id:`user-message-display`,name:`User message display`,group:U.FEATURES,description:`User messages in the chat history will be styled`},{id:`input-pattern-highlighters`,name:`Input pattern highlighters`,group:U.FEATURES,description:`Custom input highlighters will be registered`},{id:`conversation-title`,name:`Conversation title`,group:U.FEATURES,description:`/title command will be created & enabled`},{id:`voice-mode`,name:`Voice mode`,group:U.FEATURES,description:`Enable /voice command for speech-to-text input (hold Space to record)`},{id:`channels-mode`,name:`Channels mode`,group:U.FEATURES,description:`Enable MCP channel notifications (--channels without allowlist or dev flag)`},{id:`suppress-deferred-tools`,name:`Suppress deferred tools list (DANGEROUS)`,group:U.SYSTEM_REMINDERS,description:`Kill the "deferred tools are now available via ToolSearch" announcement. WARNING: MCP/Cron/EnterPlanMode/WebFetch/Monitor become invisible to the model unless explicitly named.`},{id:`claudemd-context-once-per-conversation`,name:`claudeMd context: once per conversation`,group:U.SYSTEM_REMINDERS,description:`Inject the claudeMd / userEmail / currentDate <system-reminder> only on the first API call per conversation (re-fires after /clear). Default: ON. Toggle OFF for vanilla CC per-turn injection.`}],Ni=()=>[...Mi],W=e=>e.replace(/\$/g,`\\$`),Pi=(e,t,n)=>{let r=[];for(let i of Mi){let a=t[i.id];if(n&&!n.includes(i.id)){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,description:i.description});continue}if(a.condition===!1){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,description:i.description});continue}G(`Applying patch: ${i.name}`);let o=a.fn(e),s=o===null,c=!s&&o!==e;s||(e=o),r.push({id:i.id,name:i.name,group:i.group,applied:c,failed:s,description:i.description})}return{content:e,results:r}},Fi=e=>{let t=g(e,[`--version`],{encoding:`utf8`,timeout:15e3}),n=`${t.stdout??``}${t.stderr??``}`;if(t.error||t.status!==0||/Expected CommonJS module|Bun v|TypeError/.test(n)){let t=Error(`Patched native binary failed startup sanity check (${e}).\n`+n.trim());throw t.stack=t.message,t}},Ii=async(e,t,r)=>{let i,o=!1;if(t.nativeInstallationPath){await yi(t);let e=!1;try{await a.stat(X),e=!0}catch{}let n=e?X:t.nativeInstallationPath;G(`Extracting claude.js from ${e?`backup`:`native installation`}: ${n}`);let{data:r,clearBytecode:c}=await C(n,t.version);if(!r)throw Error(`Failed to extract claude.js from native installation`);o=c;let u=l.join(J,`native-claudejs-orig.js`);s.writeFileSync(u,r),G(`Saved original extracted JS from native to: ${u}`),i=r.toString(`utf8`)}else{if(await vi(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);i=await a.readFile(t.cliPath,{encoding:`utf8`})}let c=[],u=await rn(i);i=u.content;let d=u.results.filter(e=>e.applied),f=u.results.filter(e=>e.failed);if(u.results.length>0){G(`inlineBlobOverrides: ${d.length} applied, ${f.length} failed`);for(let e of f)console.log(`inline-blob: failed "${e.name}" (${e.filename}): ${e.details}`)}for(let e of u.results)c.push({id:`inline-blob:${e.filename}`,name:e.name,group:U.SYSTEM_PROMPTS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details});let p=await hi(i,t.version??``);i=p.content;for(let e of p.results)c.push({id:`reminder:${e.id}`,name:`Reminder: ${e.name} (${e.state})`,group:U.SYSTEM_REMINDERS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details,description:e.description});let m=await Wt(i,t.version,void 0,r);i=m.newContent;let h=[...m.results].sort((e,t)=>e.name.localeCompare(t.name));c.push(...h);let g=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),_=h.filter(e=>e.applied&&e.details).map(e=>g(`${e.name}: ${e.details}`)),v=e.settings.misc?.tableFormat??`default`,y=e.settings.misc?.showTweakccVersion??!0,b=e.settings.misc?.showPatchesApplied??!0,x=e.settings.misc?.enableModelCustomizations??!0,S={"verbose-property":{fn:e=>Ee(e),condition:!t.nativeInstallationPath},"read-default-lines":{fn:e=>ti(e)},"context-limit":{fn:e=>se(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Ne(e),condition:x&&!t.nativeInstallationPath},"thinking-block-styling":{fn:e=>Sr(e),condition:t.version==null||ft(t.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>on(e)},"fix-summarize-from-here":{fn:e=>sn(e),condition:e.settings.misc?.fixSummarizeFromHere!==!1},"fix-rewind-summary-header":{fn:e=>cn(e),condition:e.settings.misc?.fixRewindSummaryHeader!==!1},"statusline-update-throttle":{fn:t=>Dr(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"strip-empty-system-reminders":{fn:e=>ri(e)},"patches-applied-indication":{fn:e=>He(e,ji,_,y,b)},"model-customizations":{fn:e=>zi(e),condition:x},"show-more-items-in-select-menus":{fn:e=>ie(e,25),condition:x},"table-format":{fn:e=>Hn(e,v),condition:v!==`default`},themes:{fn:t=>oe(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(E.themes))},"thinking-verbs":{fn:t=>ye(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs&&JSON.stringify(e.settings.thinkingVerbs.verbs)!==JSON.stringify(E.thinkingVerbs.verbs)},"thinker-format":{fn:t=>ue(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs&&e.settings.thinkingVerbs.format!==E.thinkingVerbs.format},"thinker-symbol-chars":{fn:t=>pe(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(E.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>me(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==E.thinkingStyle.updateInterval&&(t.version==null||ft(t.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>ge(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(E.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>fe(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==E.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>ce(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&e.settings.inputBox.removeBorder!==E.inputBox.removeBorder)},"subagent-models":{fn:t=>Re(t,e.settings.subagentModels),condition:!!e.settings.subagentModels&&JSON.stringify(e.settings.subagentModels)!==JSON.stringify(E.subagentModels)},"thinking-visibility":{fn:e=>Pe(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>nr(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>ir(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>or(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>cr(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>ur(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>dr(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>kr(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>xr(e),condition:!!e.settings.misc?.enableRememberSkill},"agents-md":{fn:t=>Ar(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Fr(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Ir(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Rr(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>Br(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"max-effort-default":{fn:e=>Ur(e),condition:!!e.settings.misc?.maxEffortDefault},"auto-mode-classifier-model":{fn:t=>Gr(t,e.settings.misc?.autoModeClassifierModel??`default`),condition:(e.settings.misc?.autoModeClassifierModel??`default`)!==`default`},"allow-custom-agent-models":{fn:e=>Hr(e),condition:!!e.settings.misc?.allowCustomAgentModels},"worktree-mode":{fn:e=>Vr(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>gr(e),condition:!!e.settings.misc?.enableSessionMemory},"dream-mode":{fn:e=>_r(e),condition:!!e.settings.misc?.enableDreamMode},"lean-memory-types":{fn:e=>vr(e),condition:!!e.settings.misc?.enableLeanMemoryTypes},toolsets:{fn:t=>An(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Tr(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking&&(t.version==null||ft(t.version,`2.1.85`)<0)},"mcp-batch-size":{fn:t=>Er(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>be(t,e.settings.userMessageDisplay),condition:!!(e.settings.userMessageDisplay&&JSON.stringify(e.settings.userMessageDisplay)!==JSON.stringify(E.userMessageDisplay))},"input-pattern-highlighters":{fn:t=>we(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>er(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!t.nativeInstallationPath},"voice-mode":{fn:t=>Jr(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>ei(e),condition:!!e.settings.misc?.enableChannelsMode},"suppress-deferred-tools":{fn:e=>ai(e),condition:!!e.settings.misc?.suppressDeferredTools},"claudemd-context-once-per-conversation":{fn:e=>ni(e),condition:e.settings.misc?.claudemdContextOncePerConversation??!0}},{content:T,results:D}=Pi(i,S,r);i=T,c.push(...D);let ee=D.filter(e=>e.failed);if(t.nativeInstallationPath&&ee.length>0){let e=Error(`Refusing to repack native binary because one or more binary patches failed: `+ee.map(e=>e.id).join(`, `));throw e.stack=e.message,e}if(t.nativeInstallationPath){G(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=l.join(J,`native-claudejs-patched.js`);s.writeFileSync(e,i,`utf8`),G(`Saved patched JS from native to: ${e}`);let r=Buffer.from(i,`utf8`),c=await a.mkdtemp(l.join(n.tmpdir(),`tweakcc-native-`)),u=l.join(c,l.basename(t.nativeInstallationPath));try{await a.copyFile(t.nativeInstallationPath,u),await a.chmod(u,s.statSync(t.nativeInstallationPath).mode),await w(u,r,u,o),Fi(u),await a.copyFile(u,t.nativeInstallationPath)}finally{await a.rm(c,{recursive:!0,force:!0})}}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await ia(t.cliPath,i,`patch`)}return{config:await $(e=>{e.changesApplied=!0}),results:c}},Li=[{value:`claude-opus-4-6`,label:`Opus 4.6`,description:`Claude Opus 4.6 (February 2026)`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,description:`Claude Sonnet 4.6 (February 2026)`},{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,description:`Claude Haiku 4.5 (October 2025)`},{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],Ri=e=>{let t=e.match(/ ([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-5e3),i=e.slice(r,t.index),a=`(?:(?:let|var|const) |,)${W(n)}=.+?;`,o=RegExp(`function [$\\w]+\\([^)]*\\)\\{[\\s\\S]{0,5000}?${a}`,`g`),s=null,c;for(;(c=o.exec(i))!==null;)s=c;return s?{insertionIndex:r+s.index+s[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with ${n}`),null)},zi=e=>{if(e.includes(`"value":"claude-opus-4-6"`))return console.log(`patch: modelCustomizations: custom models already present — skipping`),e;let t=Ri(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Li.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return M(e,a,i,n,n),a};let Bi=!1,Vi=!1,Hi=!1;const Ui=()=>Bi,Wi=()=>Vi,Gi=()=>Hi,Ki=()=>{Bi=!0},qi=()=>{Vi=!0,Bi=!0},Ji=()=>{Hi=!0},G=(e,...t)=>{Ui()&&console.log(e,...t)},K=(e,...t)=>{Wi()&&console.log(e,...t)};function Yi(){try{let e=f.join(p.homedir(),`.claude.json`);return JSON.parse(d.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Xi(e){try{let t=f.join(p.homedir(),`.claude.json`),n=JSON.parse(d.readFileSync(t,`utf8`));n.theme=e,d.writeFileSync(t,JSON.stringify(n,null,2))}catch{}}function Zi(){try{let e=f.join(p.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(d.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 Qi(){try{let e=f.join(p.homedir(),`.claude`,`settings.json`),t=JSON.parse(d.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=Li.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function $i(e){process.platform===`win32`?m.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?m.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():m.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function ea(e){if(process.platform===`win32`)m.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)m.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=f.dirname(e);m.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function ta(e){if(!e||typeof e!=`string`)return!1;let t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){let e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=255&&parseInt(n)<=255&&parseInt(r)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=360&&parseInt(n)<=100&&parseInt(r)<=100}}return!1}function na(e){if(!ta(e))return e;let t=e.trim();if(t.startsWith(`rgb(`))return t;if(t.startsWith(`#`)){let e=t.slice(1);return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgb(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)})`}if(t.startsWith(`hsl(`)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let t=parseInt(e[1])/360,n=parseInt(e[2])/100,r=parseInt(e[3])/100,i=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=r<.5?r*(1+n):r+n-r*n,o=2*r-a;return`rgb(${Math.round(i(o,a,t+1/3)*255)},${Math.round(i(o,a,t)*255)},${Math.round(i(o,a,t-1/3)*255)})`}}return e}async function ra(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=h.createHash(t),o=d.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function ia(e,t,n=`replace`){let r=493;try{r=(await o.stat(e)).mode,G(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){G(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await o.unlink(e),G(`[${n}] Unlinked ${e} to break hard links`)}catch(t){G(`[${n}] Could not unlink ${e}: ${t}`)}await o.writeFile(e,t),await o.chmod(e,r),G(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function aa(e){try{return await o.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const oa=e=>e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):e,sa=(e,t)=>{let n=e=>{let t=e.split(`.`).map(Number);return[t[0]||0,t[1]||0,t[2]||0]},r=n(e),i=n(t);return r[0]===i[0]?r[1]===i[1]?r[2]-i[2]:r[1]-i[1]:r[0]-i[0]},ca=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function q(e,t){if(e==null)return t;if(typeof t!=`object`||!t)return e;if(Array.isArray(t))return Array.isArray(e)?e:t;let n={...e};for(let e of Object.keys(t)){let r=t[e];e in n?typeof r==`object`&&r&&!Array.isArray(r)&&(n[e]=q(n[e],r)):n[e]=r}return n}const la=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)},ua=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function da(){try{let e=await o.readFile(Y,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=u.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await _a(),await o.writeFile(Y,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const fa=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return oa(e);let t=u.join(r.homedir(),`.tweakcc`),n=u.join(r.homedir(),`.claude`,`tweakcc`),i=process.env.XDG_CONFIG_HOME;try{if(c.existsSync(t))return t}catch(e){G(`Failed to check if ${t} exists: ${e}`)}try{if(c.existsSync(n))return n}catch(e){G(`Failed to check if ${n} exists: ${e}`)}return i?u.join(i,`tweakcc`):t},J=fa(),Y=u.join(J,`config.json`),pa=u.join(J,`cli.js.backup`),X=u.join(J,`native-binary.backup`),Z=u.join(J,`system-prompts`),ma=u.join(J,`system-reminders`),ha=u.join(J,`prompt-data-cache`),ga=()=>{let e=J,n=r.homedir(),i=[u.join(n,`.tweakcc`),u.join(n,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?u.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return c.existsSync(t)&&t!==e}catch{return!1}});i.length>0&&(console.warn(t.yellow(`
723
+ IMPORTANT: After completing your current task, you MUST address the user's message above. Do not ignore it.`,apply(e,t,n){return F(e,/((?:case"auto-continuation":)?case"human":case void 0:(?:default:)?)return`(?:The user sent a new message while you were working:\n|\$\{[$\w]+\})\$\{([$\w]+)\}\n\nIMPORTANT: After completing your current task, you MUST address the user's message above\. Do not ignore it\.`/,e=>{let[,r,i]=e;return n?`${r}return\`\${${i}}\``:`${r}return\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`user-sent-new-message`,e=>/(?:case"auto-continuation":)?case"human":case void 0:(?:default:)?return`\$\{[$\w]+\}`/.test(e))}},{id:`stop-hook-session-goal`,name:`Stop-hook session-goal reminder`,description:`Fires when /goal sets a session-scoped stop hook. Carries the "do not pause to ask" framing. Empty .md = silent goal activation (just the condition value used internally).`,placeholders:{condition:"${H}"},defaultBody:'A session-scoped Stop hook is now active with condition: "{{condition}}". Briefly acknowledge the goal, then immediately start (or continue) working toward it — treat the condition itself as your directive and do not pause to ask the user what to do. The hook will block stopping until the condition holds. It auto-clears once the condition is met — do not tell the user to run `/goal clear` after success; that\'s only for clearing a goal early.',apply(e,t,n){return F(e,/([$\w]+)=\(([$\w]+)\)=>`A session-scoped Stop hook is now active with condition: "\$\{\2\}"\. Briefly acknowledge the goal, then immediately start \(or continue\) working toward it[\s\S]*?after success; that's only for clearing a goal early\.`/,e=>{let[,r,i]=e;return n?`${r}=(${i})=>""`:`${r}=(${i})=>\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`stop-hook-session-goal`,e=>/[$\w]+=\([$\w]+\)=>""/.test(e))}},{id:`mcp-per-server-router`,name:`MCP per-server instruction router`,description:`Patches CC's MCP instruction assembly to consult ~/.tweakcc/system-reminders/mcp-<server-name>.md at runtime. Empty body in that file drops the server's block. Body containing {{server_instructions}} resolves to the server's pristine instructions. Custom body replaces. THIS .md does nothing on its own — it just enables per-server .md files. Empty body = disable this routing (servers use pristine instructions verbatim).`,placeholders:{},defaultBody:`This file is a marker that enables per-MCP-server overrides. Edit per-server content in mcp-<server-name>.md alongside this file. Leave this file with content (any content) to enable routing; empty it to disable.`,apply(e,t,n){if(n)return e;let r=e.match(/for\(let ([$\w]+) of ([$\w]+)\)if\(\1\.instructions\)([$\w]+)\.set\(\1\.name,`## \$\{\1\.name\}\n\$\{\1\.instructions\}`\);/);if(!r||r.index===void 0)return e.includes(`__tweakccMcpOverride`)?e:(console.error(`patch: reminder mcp-per-server-router: failed to find MCP assembly loop`),null);let[i,a,o,s]=r,c=`function __tweakccMcpOverride(_n,_d){try{let _f=require('fs'),_p=require('os').homedir()+'/.tweakcc/system-reminders/mcp-'+_n+'.md';let _r=_f.readFileSync(_p,'utf8');let _m=_r.match(/-->\\s*([\\s\\S]*?)\\s*\$/);if(!_m)return _d;let _b=_m[1].trim();if(_b==='')return null;return _b.replace(/\\{\\{server_instructions\\}\\}/g,_d||'')}catch{return _d}}for(let ${a} of ${o}){let _c=__tweakccMcpOverride(${a}.name,${a}.instructions);if(_c)${s}.set(${a}.name,\`## \${${a}.name}\n\${_c}\`)}`,l=e.slice(0,r.index)+c+e.slice(r.index+i.length);return M(e,l,c,r.index,r.index+i.length),l}}],mi=async()=>{let e=[l.join(n.homedir(),`.claude.json`),l.join(n.homedir(),`.claude`,`mcp.json`)];for(let t of e)try{let e=await a.readFile(t,`utf8`),n=JSON.parse(e);if(n.mcpServers&&typeof n.mcpServers==`object`)return Object.keys(n.mcpServers)}catch{}return[]},hi=async(e,t)=>{let n=[],r=e,i=await mi();for(let e of i)await li(`mcp-${e}`,`MCP server: ${e}`,`Instructions block content for MCP server "${e}". {{server_instructions}} expands at runtime to the server's pristine instructions. Empty body drops the server's block from the model's context. Custom body replaces it.`,t,[`server_instructions`],`{{server_instructions}}`);for(let e of pi){let i=await li(e.id,e.name,e.description,t,Object.keys(e.placeholders),e.defaultBody),a=await ci(e.id);if(!a){n.push({id:e.id,name:e.name,description:e.description,state:`default`,applied:!1,failed:!1,skipped:!0,details:`override file missing after ensure (unexpected)`});continue}let{result:o,errors:s}=ui(a.body,e.placeholders);if(s.length>0){n.push({id:e.id,name:e.name,description:e.description,state:`override`,applied:!1,failed:!0,skipped:!1,details:s.join(`; `)});continue}let c=e.apply(r,o,a.isSuppressed);if(c===null){n.push({id:e.id,name:e.name,description:e.description,state:a.isSuppressed?`suppressed`:`override`,applied:!1,failed:!0,skipped:!1,details:`patch function returned null`});continue}let l=c!==r;r=c;let u;u=a.isSuppressed?`suppressed`:a.body===e.defaultBody.trim()?`default`:`override`,n.push({id:e.id,name:e.name,description:e.description,state:u,applied:l,failed:!1,skipped:!1,details:i?`seeded default file`:void 0})}return{content:r,results:n}},gi=async e=>{if(!e.cliPath){G(`backupClijs: Skipping for native installation (no cliPath)`);return}await _a(),G(`Backing up cli.js to ${pa}`),await o.copyFile(e.cliPath,pa),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version})},_i=async e=>{e.nativeInstallationPath&&(await _a(),G(`Backing up native binary to ${X}`),await o.copyFile(e.nativeInstallationPath,X),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},vi=async e=>{if(!e.cliPath)return G(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;G(`Restoring cli.js from backup to ${e.cliPath}`);let t=await o.readFile(pa);return await ia(e.cliPath,t,`restore`),await nt(),await $(e=>{e.changesApplied=!1}),!0},yi=async e=>{if(!e.nativeInstallationPath)return G(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await aa(X))return G(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;G(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await o.readFile(X);return await ia(e.nativeInstallationPath,t,`restore`),!0},R=e=>{let t=Array.from(e.matchAll(/[^$\w]([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},bi=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e4),r=Array.from(n.matchAll(/(?:var |,)([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/g));if(r.length>0){let e=r[0][1];for(let t of r)t[1].length<e.length&&(e=t[1]);return e}console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},xi=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},Si=e=>{let t=xi(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${W(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let z=null,B=null;const V=e=>{if(z!=null)return z;let t=bi(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),z=void 0;return}let n=xi(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),z=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${W(t)}\\(${W(n)}\\(\\),1\\)`),i=e.match(r);if(i)return z=i[1],z;let a=Si(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),z=void 0;return}let o=RegExp(`[^$\\w]([$\\w]+)=${W(t)}\\(${W(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),z=void 0;return}return z=s[1],z},Ci=()=>{z=null},wi=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${W(n)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${n})`);return}return i[1]},Ti=e=>{if(B!=null)return B;let t=wi(e);return t?(B=t,B):(B=`require`,B)},Ei=()=>{B=null},Di=()=>{Ci(),Ei()},H=e=>{let t=e.match(/\bfunction ([$\w]+).{0,80}color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+(?:=![01])?,bold:[$\w]+(?:=![01])?/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},Oi=(e,t)=>{let n=`[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*`,r=RegExp(`var [^;]{0,120};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,500}([$\\w]+)=${W(t)}\\}\\)`),i=e.match(r)?.[1]??t,a=RegExp(`function ([$\\w]+)\\([^)]+\\)\\{(?=[\\s\\S]{0,2500}createElement\\(${W(i)},\\{\\.\\.\\.[$\\w]+,borderColor:)[\\s\\S]{0,3000}?return [$\\w]+\\}var [^;]{0,160};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,600}([$\\w]+)=\\1\\}\\)`);return e.match(a)?.[2]},ki=e=>{let t=e.match(/function ([$\w]+)\(.{0,2000}[^$\w]([$\w]+)=[$\w]+(?:\.default)?\.createElement\("ink-box".{0,500}?return \2/);if(t)return t[1];let n=e.match(/function ([$\w]+)\(.{0,200}children:[$\w]+,flexWrap:[$\w]+.{0,2000}?\.createElement\("ink-box"/);if(n)return n[1];let r=e.match(/[^$\w]([$\w]+)\.displayName="Box"/);if(r)return r[1];let i=e.match(/function ([$\w]+)\([$\w]+\)\{let [$\w]+=[$\w]+(?:\.[$\w]+)?\(\d+\).{0,3000}createElement\("ink-box"/);if(i)return i[1];let a=e.match(/function ([$\w]+)\(\{children:([$\w]+),ref:[$\w]+.{0,600}?\.\.\.([$\w]+)\}\)\{.{0,2500}?"margin".{0,2500}?"padding".{0,1200}?"gap".{0,1200}?\3\.flexWrap\?\?="nowrap",\3\.flexDirection\?\?="row",\3\.flexGrow\?\?=0,\3\.flexShrink\?\?=1,\3\.overflowX=\3\.overflowX\?\?\3\.overflow\?\?"visible",\3\.overflowY=\3\.overflowY\?\?\3\.overflow\?\?"visible",[$\w]+(?:\.default)?\.createElement\("ink-box",\{[^}]*style:\3\},\2\)/);if(a)return Oi(e,a[1])??a[1];let o=e.match(/function ([$\w]+)\(\{children:[$\w]+,ref:[$\w]+,tabIndex:[$\w]+,autoFocus:[$\w]+/);if(o)return o[1];console.error(`patch: findBoxComponent: failed to find Box component (neither ink-box createElement nor displayName found)`)},Ai=e(import.meta.url),ji=(()=>{try{return Ai(`../package.json`).version}catch{return Ai(`../../package.json`).version}})();let U=function(e){return e.SYSTEM_PROMPTS=`System Prompts`,e.ALWAYS_APPLIED=`Always Applied`,e.MISC_CONFIGURABLE=`Misc Configurable`,e.FEATURES=`Features`,e.SYSTEM_REMINDERS=`System Reminders`,e}({});const Mi=[{id:`verbose-property`,name:`Verbose property`,group:U.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{id:`read-default-lines`,name:`Read default lines (env-gated)`,group:U.ALWAYS_APPLIED,description:`Read tool default line cap becomes CLAUDE_CODE_READ_DEFAULT_LINES env var (falls back to 2000 if unset)`},{id:`opusplan1m`,name:`Opusplan[1m] support`,group:U.ALWAYS_APPLIED,description:`Use the "Opus Plan 1M" model: Opus for planning, Sonnet 1M context for building`},{id:`thinking-block-styling`,name:`Thinking block styling`,group:U.ALWAYS_APPLIED,description:`Restore dim/gray + italic styling for thinking blocks`},{id:`fix-lsp-support`,name:`Fix LSP support`,group:U.ALWAYS_APPLIED,description:`Enable/fix nascent LSP support`},{id:`fix-summarize-from-here`,name:`Fix "Summarize from here"`,group:U.MISC_CONFIGURABLE,description:`Make "Summarize from here" summarize only the messages after the rewind point (feed the slice, not the whole conversation)`},{id:`fix-rewind-summary-header`,name:`Honest rewind summary header`,group:U.MISC_CONFIGURABLE,description:`Label a rewind summary as a deliberate rewind instead of the misleading "ran out of context" header`},{id:`statusline-update-throttle`,name:`Statusline update throttling correction`,group:U.ALWAYS_APPLIED,description:`Statusline updates will be properly throttled instead of queued (or debounced)`},{id:`strip-empty-system-reminders`,name:`Strip empty <system-reminder> wrappers`,group:U.ALWAYS_APPLIED,description:`Short-circuits CC's universal system-reminder wrapper so empty / "(no content)" inputs produce no reminder. Kills the drift-inducing "<system-reminder>(no content)</system-reminder>" blocks that get appended to roughly every other tool call.`},{id:`model-customizations`,name:`Model customizations`,group:U.MISC_CONFIGURABLE,description:`Access all Claude models with /model, not just latest 3`},{id:`show-more-items-in-select-menus`,name:`Show more items in select menus`,group:U.MISC_CONFIGURABLE,description:`Show 25 items in select menus instead of default 5`},{id:`context-limit`,name:`Context limit`,group:U.MISC_CONFIGURABLE,description:`Override the 200K context limit via CLAUDE_CODE_CONTEXT_LIMIT env var (set before launching CC)`},{id:`patches-applied-indication`,name:`Patches applied indication`,group:U.MISC_CONFIGURABLE,description:`Show "tweakcc patches applied" and tweakcc version inside CC`},{id:`table-format`,name:`Table format`,group:U.MISC_CONFIGURABLE,description:`Tables generated by Claude will be rendered more compactly`},{id:`themes`,name:`Themes`,group:U.MISC_CONFIGURABLE,description:`Your custom themes will be available via /theme`},{id:`thinking-verbs`,name:`Thinking verbs`,group:U.MISC_CONFIGURABLE,description:`Your custom list of thinking verbs will be cycled through`},{id:`thinker-format`,name:`Thinker format`,group:U.MISC_CONFIGURABLE,description:`Your custom format string that thinking verbs are wrapped in will be applied`},{id:`thinker-symbol-chars`,name:`Thinker symbol chars`,group:U.MISC_CONFIGURABLE,description:`Your custom thinking spinner will be rendered`},{id:`thinker-symbol-speed`,name:`Thinker symbol speed`,group:U.MISC_CONFIGURABLE,description:`The thinking spinner will play at a custom FPS`},{id:`thinker-symbol-width`,name:`Thinker symbol width`,group:U.MISC_CONFIGURABLE,description:`The thinking spinner will be in a box of custom width`},{id:`thinker-symbol-mirror`,name:`Thinker symbol mirror`,group:U.MISC_CONFIGURABLE,description:`The thinking spinner will reverse or restart when it finishes`},{id:`input-box-border`,name:`Input box border`,group:U.MISC_CONFIGURABLE,description:`Your custom styles to the main input box's border will be applied`},{id:`subagent-models`,name:`Subagent models`,group:U.MISC_CONFIGURABLE,description:`Use custom models for Plan, Explore, and General subagents`},{id:`thinking-visibility`,name:`Thinking block visibility`,group:U.MISC_CONFIGURABLE,description:`Thinking blocks outputted by the model will show without Ctrl+O`},{id:`hide-startup-banner`,name:`Hide startup banner`,group:U.MISC_CONFIGURABLE,description:`CC's startup banner with "Clawd" and release notes will be hidden`},{id:`hide-ctrl-g-to-edit`,name:`Hide Ctrl+G to edit`,group:U.MISC_CONFIGURABLE,description:`Note about using Ctrl+G to edit prompt will be hidden`},{id:`hide-startup-clawd`,name:`Hide startup Clawd`,group:U.MISC_CONFIGURABLE,description:`The "Clawd" icon on startup will be hidden for a cleaner look`},{id:`increase-file-read-limit`,name:`Increase file read limit`,group:U.MISC_CONFIGURABLE,description:`Max tokens Claude can read from a file at once will be increased`},{id:`suppress-line-numbers`,name:`Suppress line numbers`,group:U.MISC_CONFIGURABLE,description:`"1→" "2→" etc. prefixes for each line of Read output will be omitted`},{id:`suppress-rate-limit-options`,name:`Suppress rate limit options`,group:U.MISC_CONFIGURABLE,description:`/rate-limit-options won't be injected when limits are reached`},{id:`token-count-rounding`,name:`Token count rounding`,group:U.MISC_CONFIGURABLE,description:`Round displayed token counts to the nearest multiple of chosen value`},{id:`remember-skill`,name:`Remember skill`,group:U.MISC_CONFIGURABLE,description:`Register the built-in "/remember" skill to review session memories and update CLAUDE.local.md`},{id:`agents-md`,name:`AGENTS.md (and others)`,group:U.MISC_CONFIGURABLE,description:`Support AGENTS.md and others in addition to CLAUDE.md`},{id:`auto-accept-plan-mode`,name:`Auto-accept plan mode`,group:U.MISC_CONFIGURABLE,description:`Automatically accept plans without the "Ready to code?" confirmation prompt`},{id:`allow-sudo-bypass-permissions`,name:`Allow bypassing permissions with --dangerously-skip-permissions in sudo`,group:U.MISC_CONFIGURABLE,description:`Allow bypassing permissions with --dangerously-skip-permissions even when running with root/sudo privileges`},{id:`suppress-native-installer-warning`,name:`Suppress native installer warning`,group:U.MISC_CONFIGURABLE,description:`Suppress the native installer warning message at startup`},{id:`filter-scroll-escape-sequences`,name:`Filter scroll escape sequences`,group:U.MISC_CONFIGURABLE,description:`Filter out terminal escape sequences that cause unwanted scrolling`},{id:`max-effort-default`,name:`Default Opus 4.7 to max effort`,group:U.MISC_CONFIGURABLE,description:`Opus 4.7 sessions default to "max" reasoning effort instead of "xhigh" (override with /effort or CLAUDE_CODE_EFFORT_LEVEL)`},{id:`auto-mode-classifier-model`,name:`Auto-mode classifier model`,group:U.MISC_CONFIGURABLE,description:`Pin auto-mode bash safety classifier to Sonnet 4.6 or Haiku 4.5 instead of the user main-loop model (avoids Opus 4.7 congestion denying tool calls)`},{id:`allow-custom-agent-models`,name:`Allow custom agent models`,group:U.FEATURES,description:`Allow arbitrary model names in custom agent frontmatter (e.g. gemini-2.5-flash)`},{id:`worktree-mode`,name:`Worktree mode`,group:U.FEATURES,description:`Enable the EnterWorktree tool for isolated git worktree sessions`},{id:`session-memory`,name:`Session memory`,group:U.FEATURES,description:`Enable session memory (auto-extraction + past session search)`},{id:`dream-mode`,name:`Dream mode`,group:U.FEATURES,description:`Enable dream (/dream + auto-dream background memory consolidation)`},{id:`lean-memory-types`,name:`Lean memory types`,group:U.FEATURES,description:`Compact "Types of memory" prompt block + on-demand memory-types skill`},{id:`toolsets`,name:`Toolsets`,group:U.FEATURES,description:`Custom toolsets will be registered`},{id:`mcp-non-blocking`,name:`MCP non-blocking`,group:U.FEATURES,description:`If you have MCP servers, CC startup will be much faster`},{id:`mcp-batch-size`,name:`MCP batch size`,group:U.FEATURES,description:`Change the number of MCP servers started in parallel`},{id:`user-message-display`,name:`User message display`,group:U.FEATURES,description:`User messages in the chat history will be styled`},{id:`input-pattern-highlighters`,name:`Input pattern highlighters`,group:U.FEATURES,description:`Custom input highlighters will be registered`},{id:`conversation-title`,name:`Conversation title`,group:U.FEATURES,description:`/title command will be created & enabled`},{id:`voice-mode`,name:`Voice mode`,group:U.FEATURES,description:`Enable /voice command for speech-to-text input (hold Space to record)`},{id:`channels-mode`,name:`Channels mode`,group:U.FEATURES,description:`Enable MCP channel notifications (--channels without allowlist or dev flag)`},{id:`suppress-deferred-tools`,name:`Suppress deferred tools list (DANGEROUS)`,group:U.SYSTEM_REMINDERS,description:`Kill the "deferred tools are now available via ToolSearch" announcement. WARNING: MCP/Cron/EnterPlanMode/WebFetch/Monitor become invisible to the model unless explicitly named.`},{id:`claudemd-context-once-per-conversation`,name:`claudeMd context: once per conversation`,group:U.SYSTEM_REMINDERS,description:`Inject the claudeMd / userEmail / currentDate <system-reminder> only on the first API call per conversation (re-fires after /clear). Default: ON. Toggle OFF for vanilla CC per-turn injection.`}],Ni=()=>[...Mi],W=e=>e.replace(/\$/g,`\\$`),Pi=(e,t,n)=>{let r=[];for(let i of Mi){let a=t[i.id];if(n&&!n.includes(i.id)){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,description:i.description});continue}if(a.condition===!1){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,description:i.description});continue}G(`Applying patch: ${i.name}`);let o=a.fn(e),s=o===null,c=!s&&o!==e;s||(e=o),r.push({id:i.id,name:i.name,group:i.group,applied:c,failed:s,description:i.description})}return{content:e,results:r}},Fi=e=>{let t=g(e,[`--version`],{encoding:`utf8`,timeout:15e3}),n=`${t.stdout??``}${t.stderr??``}`;if(t.error||t.status!==0||/Expected CommonJS module|Bun v|TypeError/.test(n)){let t=Error(`Patched native binary failed startup sanity check (${e}).\n`+n.trim());throw t.stack=t.message,t}},Ii=async(e,t,r)=>{let i,o=!1;if(t.nativeInstallationPath){await yi(t);let e=!1;try{await a.stat(X),e=!0}catch{}let n=e?X:t.nativeInstallationPath;G(`Extracting claude.js from ${e?`backup`:`native installation`}: ${n}`);let{data:r,clearBytecode:c}=await C(n,t.version);if(!r)throw Error(`Failed to extract claude.js from native installation`);o=c;let u=l.join(J,`native-claudejs-orig.js`);s.writeFileSync(u,r),G(`Saved original extracted JS from native to: ${u}`),i=r.toString(`utf8`)}else{if(await vi(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);i=await a.readFile(t.cliPath,{encoding:`utf8`})}let c=[],u=await rn(i);i=u.content;let d=u.results.filter(e=>e.applied),f=u.results.filter(e=>e.failed);if(u.results.length>0){G(`inlineBlobOverrides: ${d.length} applied, ${f.length} failed`);for(let e of f)console.log(`inline-blob: failed "${e.name}" (${e.filename}): ${e.details}`)}for(let e of u.results)c.push({id:`inline-blob:${e.filename}`,name:e.name,group:U.SYSTEM_PROMPTS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details});let p=await hi(i,t.version??``);i=p.content;for(let e of p.results)c.push({id:`reminder:${e.id}`,name:`Reminder: ${e.name} (${e.state})`,group:U.SYSTEM_REMINDERS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details,description:e.description});let m=await Wt(i,t.version,void 0,r);i=m.newContent;let h=[...m.results].sort((e,t)=>e.name.localeCompare(t.name));c.push(...h);let g=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),_=h.filter(e=>e.applied&&e.details).map(e=>g(`${e.name}: ${e.details}`)),v=e.settings.misc?.tableFormat??`default`,y=e.settings.misc?.showTweakccVersion??!0,b=e.settings.misc?.showPatchesApplied??!0,x=e.settings.misc?.enableModelCustomizations??!0,S={"verbose-property":{fn:e=>Ee(e),condition:!t.nativeInstallationPath},"read-default-lines":{fn:e=>ti(e)},"context-limit":{fn:e=>se(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Ne(e),condition:x&&!t.nativeInstallationPath},"thinking-block-styling":{fn:e=>Sr(e),condition:t.version==null||ft(t.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>on(e)},"fix-summarize-from-here":{fn:e=>sn(e),condition:e.settings.misc?.fixSummarizeFromHere!==!1},"fix-rewind-summary-header":{fn:e=>cn(e),condition:e.settings.misc?.fixRewindSummaryHeader!==!1},"statusline-update-throttle":{fn:t=>Dr(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"strip-empty-system-reminders":{fn:e=>ri(e)},"patches-applied-indication":{fn:e=>He(e,ji,_,y,b)},"model-customizations":{fn:e=>zi(e),condition:x},"show-more-items-in-select-menus":{fn:e=>ie(e,25),condition:x},"table-format":{fn:e=>Hn(e,v),condition:v!==`default`},themes:{fn:t=>oe(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(E.themes))},"thinking-verbs":{fn:t=>ye(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs&&JSON.stringify(e.settings.thinkingVerbs.verbs)!==JSON.stringify(E.thinkingVerbs.verbs)},"thinker-format":{fn:t=>ue(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs&&e.settings.thinkingVerbs.format!==E.thinkingVerbs.format},"thinker-symbol-chars":{fn:t=>pe(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(E.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>me(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==E.thinkingStyle.updateInterval&&(t.version==null||ft(t.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>ge(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(E.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>fe(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==E.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>ce(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&e.settings.inputBox.removeBorder!==E.inputBox.removeBorder)},"subagent-models":{fn:t=>Re(t,e.settings.subagentModels),condition:!!e.settings.subagentModels&&JSON.stringify(e.settings.subagentModels)!==JSON.stringify(E.subagentModels)},"thinking-visibility":{fn:e=>Pe(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>nr(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>ir(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>or(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>cr(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>ur(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>dr(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>kr(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>xr(e),condition:!!e.settings.misc?.enableRememberSkill},"agents-md":{fn:t=>Ar(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Fr(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Ir(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Rr(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>Br(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"max-effort-default":{fn:e=>Ur(e),condition:!!e.settings.misc?.maxEffortDefault},"auto-mode-classifier-model":{fn:t=>Gr(t,e.settings.misc?.autoModeClassifierModel??`default`),condition:(e.settings.misc?.autoModeClassifierModel??`default`)!==`default`},"allow-custom-agent-models":{fn:e=>Hr(e),condition:!!e.settings.misc?.allowCustomAgentModels},"worktree-mode":{fn:e=>Vr(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>gr(e),condition:!!e.settings.misc?.enableSessionMemory},"dream-mode":{fn:e=>_r(e),condition:!!e.settings.misc?.enableDreamMode},"lean-memory-types":{fn:e=>vr(e),condition:!!e.settings.misc?.enableLeanMemoryTypes},toolsets:{fn:t=>An(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Tr(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking&&(t.version==null||ft(t.version,`2.1.85`)<0)},"mcp-batch-size":{fn:t=>Er(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>be(t,e.settings.userMessageDisplay),condition:!!(e.settings.userMessageDisplay&&JSON.stringify(e.settings.userMessageDisplay)!==JSON.stringify(E.userMessageDisplay))},"input-pattern-highlighters":{fn:t=>we(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>er(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!t.nativeInstallationPath},"voice-mode":{fn:t=>Jr(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>ei(e),condition:!!e.settings.misc?.enableChannelsMode},"suppress-deferred-tools":{fn:e=>ai(e),condition:!!e.settings.misc?.suppressDeferredTools},"claudemd-context-once-per-conversation":{fn:e=>ni(e),condition:e.settings.misc?.claudemdContextOncePerConversation??!0}},{content:T,results:D}=Pi(i,S,r);i=T,c.push(...D);let ee=D.filter(e=>e.failed);if(t.nativeInstallationPath&&ee.length>0){let e=Error(`Refusing to repack native binary because one or more binary patches failed: `+ee.map(e=>e.id).join(`, `));throw e.stack=e.message,e}if(t.nativeInstallationPath){G(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=l.join(J,`native-claudejs-patched.js`);s.writeFileSync(e,i,`utf8`),G(`Saved patched JS from native to: ${e}`);let r=Buffer.from(i,`utf8`),c=await a.mkdtemp(l.join(n.tmpdir(),`tweakcc-native-`)),u=l.join(c,l.basename(t.nativeInstallationPath));try{await a.copyFile(t.nativeInstallationPath,u),await a.chmod(u,s.statSync(t.nativeInstallationPath).mode),await w(u,r,u,o),Fi(u),await a.copyFile(u,t.nativeInstallationPath)}finally{await a.rm(c,{recursive:!0,force:!0})}}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await ia(t.cliPath,i,`patch`)}return{config:await $(e=>{e.changesApplied=!0}),results:c}},Li=[{value:`claude-opus-4-6`,label:`Opus 4.6`,description:`Claude Opus 4.6 (February 2026)`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,description:`Claude Sonnet 4.6 (February 2026)`},{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,description:`Claude Haiku 4.5 (October 2025)`},{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],Ri=e=>{let t=e.match(/ ([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-5e3),i=e.slice(r,t.index),a=`(?:(?:let|var|const) |,)${W(n)}=.+?;`,o=RegExp(`function [$\\w]+\\([^)]*\\)\\{[\\s\\S]{0,5000}?${a}`,`g`),s=null,c;for(;(c=o.exec(i))!==null;)s=c;return s?{insertionIndex:r+s.index+s[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with ${n}`),null)},zi=e=>{if(e.includes(`"value":"claude-opus-4-6"`))return console.log(`patch: modelCustomizations: custom models already present — skipping`),e;let t=Ri(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Li.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return M(e,a,i,n,n),a};let Bi=!1,Vi=!1,Hi=!1;const Ui=()=>Bi,Wi=()=>Vi,Gi=()=>Hi,Ki=()=>{Bi=!0},qi=()=>{Vi=!0,Bi=!0},Ji=()=>{Hi=!0},G=(e,...t)=>{Ui()&&console.log(e,...t)},K=(e,...t)=>{Wi()&&console.log(e,...t)};function Yi(){try{let e=f.join(p.homedir(),`.claude.json`);return JSON.parse(d.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Xi(e){try{let t=f.join(p.homedir(),`.claude.json`),n=JSON.parse(d.readFileSync(t,`utf8`));n.theme=e,d.writeFileSync(t,JSON.stringify(n,null,2))}catch{}}function Zi(){try{let e=f.join(p.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(d.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 Qi(){try{let e=f.join(p.homedir(),`.claude`,`settings.json`),t=JSON.parse(d.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=Li.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function $i(e){process.platform===`win32`?m.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?m.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():m.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function ea(e){if(process.platform===`win32`)m.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)m.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=f.dirname(e);m.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function ta(e){if(!e||typeof e!=`string`)return!1;let t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){let e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=255&&parseInt(n)<=255&&parseInt(r)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=360&&parseInt(n)<=100&&parseInt(r)<=100}}return!1}function na(e){if(!ta(e))return e;let t=e.trim();if(t.startsWith(`rgb(`))return t;if(t.startsWith(`#`)){let e=t.slice(1);return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgb(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)})`}if(t.startsWith(`hsl(`)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let t=parseInt(e[1])/360,n=parseInt(e[2])/100,r=parseInt(e[3])/100,i=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=r<.5?r*(1+n):r+n-r*n,o=2*r-a;return`rgb(${Math.round(i(o,a,t+1/3)*255)},${Math.round(i(o,a,t)*255)},${Math.round(i(o,a,t-1/3)*255)})`}}return e}async function ra(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=h.createHash(t),o=d.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function ia(e,t,n=`replace`){let r=493;try{r=(await o.stat(e)).mode,G(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){G(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await o.unlink(e),G(`[${n}] Unlinked ${e} to break hard links`)}catch(t){G(`[${n}] Could not unlink ${e}: ${t}`)}await o.writeFile(e,t),await o.chmod(e,r),G(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function aa(e){try{return await o.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const oa=e=>e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):e,sa=(e,t)=>{let n=e=>{let t=e.split(`.`).map(Number);return[t[0]||0,t[1]||0,t[2]||0]},r=n(e),i=n(t);return r[0]===i[0]?r[1]===i[1]?r[2]-i[2]:r[1]-i[1]:r[0]-i[0]},ca=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function q(e,t){if(e==null)return t;if(typeof t!=`object`||!t)return e;if(Array.isArray(t))return Array.isArray(e)?e:t;let n={...e};for(let e of Object.keys(t)){let r=t[e];e in n?typeof r==`object`&&r&&!Array.isArray(r)&&(n[e]=q(n[e],r)):n[e]=r}return n}const la=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)},ua=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function da(){try{let e=await o.readFile(Y,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=u.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await _a(),await o.writeFile(Y,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const fa=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return oa(e);let t=u.join(r.homedir(),`.tweakcc`),n=u.join(r.homedir(),`.claude`,`tweakcc`),i=process.env.XDG_CONFIG_HOME;try{if(c.existsSync(t))return t}catch(e){G(`Failed to check if ${t} exists: ${e}`)}try{if(c.existsSync(n))return n}catch(e){G(`Failed to check if ${n} exists: ${e}`)}return i?u.join(i,`tweakcc`):t},J=fa(),Y=u.join(J,`config.json`),pa=u.join(J,`cli.js.backup`),X=u.join(J,`native-binary.backup`),Z=u.join(J,`system-prompts`),ma=u.join(J,`system-reminders`),ha=u.join(J,`prompt-data-cache`),ga=()=>{let e=J,n=r.homedir(),i=[u.join(n,`.tweakcc`),u.join(n,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?u.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return c.existsSync(t)&&t!==e}catch{return!1}});i.length>0&&(console.warn(t.yellow(`
724
724
  Multiple configuration locations detected:`)),console.warn(t.gray(` Active: ${e}`)),console.warn(t.gray(` Other existing locations:`)),i.forEach(e=>{console.warn(t.gray(` - ${e}`))}),console.warn(t.gray(` Only the active location is used. To switch locations,`)),console.warn(t.gray(` move your config.json to the desired directory.
725
725
  `)))},_a=async()=>{await o.mkdir(J,{recursive:!0}),await o.mkdir(Z,{recursive:!0}),await o.mkdir(ma,{recursive:!0});let e=u.join(J,`.gitignore`);try{await o.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await o.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(i)+i)}};let Q=null;const va=()=>({ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:E}),ya=e=>{let t=e?.settings?.thinkingVerbs;t?.punctuation&&(t.format=`{}`+t.punctuation,delete t.punctuation),e.settings=q(e.settings,E),e.settings.inputPatternHighlighters&&(e.settings.inputPatternHighlighters=e.settings.inputPatternHighlighters.map(e=>q(e,D))),e.settings.toolsets&&(e.settings.toolsets=e.settings.toolsets.map(e=>q(e,ee))),e.settings.themes&&(e.settings.themes=e.settings.themes.map(e=>q(e,te))),la(e),ua(e),delete e.settings.launchText},ba=async()=>{let e=va();try{G(`Reading config at ${Y}`),ga();let t=await o.readFile(Y,`utf8`),n={...e,...JSON.parse(t)},r=JSON.stringify(n);ya(n);let i=await rt(Z);return i&&(n.changesApplied=!1),(JSON.stringify(n)!==r||i)&&await xa(n),Q=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},$=async e=>(G(`Updating config at ${Y}`),Q||=await ba(),e(Q),Q.lastModified=new Date().toISOString(),await xa(Q),Q),xa=async e=>{try{e.lastModified=new Date().toISOString(),await _a(),await o.writeFile(Y,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}},Sa=async e=>{G(`Fetching config from URL: ${e}`);let t;try{t=new URL(e)}catch{throw Error(`Invalid URL format: ${e}\n Expected a valid URL like https://example.com/config.json`)}if(![`http:`,`https:`].includes(t.protocol))throw Error(`Unsupported URL protocol: ${t.protocol}\n Only http:// and https:// URLs are supported`);let n;try{let e=await o.readFile(Y,`utf8`);n=JSON.parse(e)}catch{n=va()}let r;try{r=await fetch(e,{headers:{Accept:`application/json`,"User-Agent":`tweakcc`}})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to fetch config from ${e}\n Network error: ${n}\n Please check your internet connection and try again.`)}if(!r.ok)throw Error(`Failed to fetch config from ${e}\n HTTP ${r.status}: ${r.statusText}\n Please check that the URL is correct and accessible.`);let i;try{let e=await r.text();i=JSON.parse(e)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to parse config from ${e}\n JSON parse error: ${n}\n Please ensure the URL returns valid JSON.`)}let a={sourceUrl:e,dateFetched:new Date().toISOString(),settings:i};await $(e=>{e.remoteConfig=a});let s={...va(),ccVersion:n.ccVersion||``,ccInstallationPath:n.ccInstallationPath||null,settings:{...E,...i},remoteConfig:a};return ya(s),G(`Successfully fetched and parsed config from ${e}`),s};export{E as $,Xi as A,V as B,Ui as C,$i as D,na as E,Di as F,yi as G,gi as H,ki as I,Ft as J,N as K,R as L,ji as M,Ii as N,ia as O,Ni as P,nt as Q,H as R,ra as S,ta as T,_i as U,Ti as V,vi as W,Ct as X,wt as Y,xt as Z,Ji as _,Z as a,Yi as b,fa as c,da as d,te as et,sa as f,Ki as g,aa as h,X as i,U as j,ea as k,ba as l,q as m,J as n,w as nt,ma as o,G as p,M as q,Y as r,T as rt,Sa as s,pa as t,C as tt,$ as u,qi as v,Gi as w,Qi as x,Zi as y,bi as z};