tweakcc 4.0.3 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -37
- package/dist/{config-Dvq5brXH.mjs → config-Y-joBt-N.mjs} +30 -30
- package/dist/{content-DOnCP5K8.mjs → content-3z41_drP.mjs} +1 -1
- package/dist/index.mjs +3 -3
- package/dist/lib/index.mjs +1 -1
- package/dist/{nativeInstallation-B4LfUOK0.mjs → nativeInstallation-CP7Hq-4N.mjs} +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import e from"chalk";import t,{EOL as n}from"node:os";import*as r from"node:fs/promises";import i from"node:fs/promises";import*as a from"node:fs";import o from"node:fs";import*as s from"node:path";import c from"node:path";import*as l from"fs";import*as u from"path";import*as d from"os";import*as f from"child_process";import*as p from"crypto";import m from"gray-matter";import{diffWordsWithSpace as h}from"diff";let g=null;async function _(){if(g!==null)return g;try{return await import(`node-lief`),g=await import(`./nativeInstallation-B4LfUOK0.mjs`),g}catch(e){return W(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&W(e),null}}async function v(e){let t=await _();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function y(e,t,n){let r=await _();if(!r)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,t,n)}const b={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:null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSwarmMode:!0,enableSessionMemory:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1},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`]},x={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},S={name:`Unnamed Toolset`,allowedTools:`*`},C=b.themes[0],w=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},ee=(e,t)=>{let n=w(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);F(i,r,n,e.startIndex,e.endIndex),i=r}return i};function te(e){let t=e.match(/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s);if(!t||t.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let n=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(n),a=e.match(r);return!i||i.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!a||a.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const ne=(e,t)=>{let n=te(e);if(!n)return null;if(t.length===0)return e;let r=e,i=`return`+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),F(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r;let a=JSON.stringify(t.map(e=>({label:e.name,value:e.id})));r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),F(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),F(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},re=e=>{let t=e.match(/function ([$\w]+)\(([$\w,]+)\)\{if\([$\w]+\.includes\("\[(1m|2m)\]"\)\|\|[$\w]+\?\.includes\([$\w]+\)&&[$\w]+\([$\w]+\)\)return 1e6;return ([$\w]+)\}/);if(t&&t.index!==void 0)return t.index+t[0].indexOf(`{`)+1;let n=e.match(/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/);return n&&n.index!==void 0?n.index+n[0].indexOf(`{`)+1:(console.error(`patch: context limit: failed to find match`),null)},ie=e=>{let t=re(e);if(!t)return null;let n=`if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);`,r=e.slice(0,t)+n+e.slice(t);return F(e,r,n,t,t),r},ae=e=>{let t=e.indexOf(`bash:"bashBorder"`);if(t===-1)return console.error(`patch: input border: failed to find bash pattern`),null;let n=e.slice(t,t+500).match(/borderStyle:"[^"]*"/);return!n||n.index===void 0?(console.error(`patch: input border: failed to find border style pattern`),null):{startIndex:t+n.index,endIndex:t+n.index+n[0].length}},oe=(e,t)=>{let n=ae(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return F(e,r,t,n.startIndex,n.endIndex),r}else return e},T=e=>{let t=e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/);if(!t||t.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let n=e.slice(t.index,t.index+1e4),r=n.match(/,([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);if(r&&r.index!=null)return{startIndex:t.index+r.index+r[1].length+1,endIndex:t.index+r.index+r[1].length+r[2].length+1,identifiers:[r[3]]};let i=n.match(/,([$\w]+)(=(\([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+\))\+"(?:…|\\u2026)")/);return i&&i.index!=null?{startIndex:t.index+i.index+i[1].length+1,endIndex:t.index+i.index+i[1].length+i[2].length+1,identifiers:[i[3]]}:(console.error(`patch: thinker format: failed to find formatMatch`),null)},E=(e,t)=>{let n=T(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 F(e,s,o,r.startIndex,r.endIndex),s},se=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]]}},ce=(e,t)=>{let n=se(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 F(e,a,i,n.startIndex,n.endIndex),a},le=(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);F(s,t,a,o[e].startIndex,o[e].endIndex),s=t}return s},ue=(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 F(e,o,r,i,a),o},de=e=>{let t=e.match(/\{flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},fe=(e,t)=>{let n=de(e);if(!n)return null;let r=`{flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return F(e,i,r,n.startIndex,n.endIndex),i},pe=(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 F(e,o,r,i,a),o},me=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+ed",?){5,}\]/);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 F(e,s,i,a,o),s},he=(e,t)=>{let n=pe(e,t);if(n===null)return null;let r=me(n,t);return r===null?null:r},ge=(e,t)=>{let n=V(e);if(!n)return console.error(`patch: userMessageDisplay: failed to find Text component`),null;let r=or(e);if(!r)return console.error(`patch: userMessageDisplay: failed to find Box component`),null;let i=L(e);if(!i)return console.error(`patch: userMessageDisplay: failed to find chalk variable`),null;let a=e.match(/(No content found in user prompt message.{0,150}?\b)([$\w]+(?:\.default)?\.createElement.{0,30}\b[$\w]+(?:\.default)?\.createElement.{0,40}">.+?)?(([$\w]+(?:\.default)?\.createElement).{0,100})(\([$\w]+,(?:\{[^{}]+wrap:"wrap"\},([$\w]+)(?:\.trim\(\))?\)\)|\{text:([$\w]+),thinkingMetadata:[$\w]+\}\)\)?))/);if(!a||a.index===void 0)return console.error(`patch: userMessageDisplay: failed to find user message display pattern`),null;let o=a[4],s=a[6]??a[7],c=[],l=t.borderStyle.startsWith(`topBottom`);if(t.borderStyle!==`none`){if(l){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:" "}`),c.push(`borderStyle:${e}`)}else c.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&c.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX>0&&c.push(`paddingX:${t.paddingX}`),t.paddingY>0&&c.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&c.push(`alignSelf:"flex-start"`);let u=c.length>0?`{${c.join(`,`)}}`:`null`,d=i;if(t.foregroundColor!==`default`){let e=t.foregroundColor.match(/\d+/g);e&&(d+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);e&&(d+=`.bgRgb(${e.join(`,`)})`)}t.styling.includes(`bold`)&&(d+=`.bold`),t.styling.includes(`italic`)&&(d+=`.italic`),t.styling.includes(`underline`)&&(d+=`.underline`),t.styling.includes(`strikethrough`)&&(d+=`.strikethrough`),t.styling.includes(`inverse`)&&(d+=`.inverse`);let f="`"+t.format.replace(/\{\}/g,"${"+s+`}`)+"`",p=`${d}(${f})`,m=a[1]+`${o}(${r},${u},${o}(${n},null,${p}))`,h=a.index,g=h+a[0].length,_=e.slice(0,h)+m+e.slice(g);return F(e,_,m,h,g),_},_e=(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},ve=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)return console.error(`patch: inputPatternHighlighters: failed to find highlight?.color renderer pattern`),null;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 F(e,i,r,t.index,t.index+t[0].length),i},ye=(e,t,n)=>{let r=e.match(/(,[$\w]+=[$\w]+\.useMemo\(\(\)=>\{let [$\w]+=\[\];)(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(/\b([$\w]+(?:\.default)?)\.useMemo\(/);if(!a)return console.error(`patch: inputPatternHighlighters: failed to extract React var from useMemo`),null;let o=a[1],s=Math.max(0,r.index-4e3),c=e.slice(s,r.index).match(/\binput:([$\w]+),/);if(!c)return console.error(`patch: inputPatternHighlighters: failed to find input variable pattern`),null;let l=c[1],u=``;for(let e=0;e<n.length;e++){let t=n[e],r=t.regexFlags;r.includes(`g`)||(r+=`g`);let i=Ir(new RegExp(t.regex,r));u+=`,matchedTweakccReplacements${e}=${o}.useMemo(()=>{return[...${l}.matchAll(${i})].map(m=>({start:m.index,end:m.index+m[0].length}))},[${l}])`}let d=``;for(let e=0;e<n.length;e++){let r=n[e],a=_e(t,r),o=JSON.stringify(r.format).replace(/\{MATCH\}/g,`"+x+"`);d+=`for(let matchedTweakccReplacement of matchedTweakccReplacements${e}){${i}.push({start:matchedTweakccReplacement.start,end:matchedTweakccReplacement.end,color:x=>${a}(${o}),priority:100})}`}let f=r[1]+d+r[2],p=e.slice(0,r.index),m=e.slice(r.index+r[0].length),h=p+u+f+m;return F(e,h,u+f,r.index,r.index+r[0].length),h},be=(e,t)=>{let n=t.filter(e=>e.enabled);if(n.length===0)return null;let r=L(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i;return i=ve(e),i?(i=ye(i,r,n),i||(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterCreation failed`),null)):(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterImpl failed`),null)},xe=e=>{let t=e.match(/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/);if(!t||t.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let n=t[0].match(/verbose:[^,}]+/);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},Se=e=>{let t=xe(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return F(e,r,n,t.startIndex,t.endIndex),r},Ce=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 F(e,c,s,t.index,t.index+n.length),c},we=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 F(e,r,n,t.index,t.index+t[0].length),r},Te=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"Opus 4\.\d+ in plan mode, else Sonnet 4\.5";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchDescriptionFunction: failed to find description pattern`),null;let[n,,r]=t,i=n+`if(${r}==="opusplan[1m]")return"Opus 4.5 in plan mode, else Sonnet 4.5 (1M context)";`,a=e.slice(0,t.index)+i+e.slice(t.index+n.length);return F(e,a,i,t.index,t.index+n.length),a},Ee=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 F(e,a,i,t.index,t.index+n.length),a},De=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+`if(${r}==="opusplan[1m]")return[...${i},{value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus 4.5 in plan mode, Sonnet 4.5 (1M context) otherwise"}];`,o=e.slice(0,t.index)+a+e.slice(t.index+n.length);return F(e,o,a,t.index,t.index+n.length),o},Oe=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 4.5 in plan mode, Sonnet 4.5 otherwise"});${n}.push({value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus 4.5 in plan mode, Sonnet 4.5 (1M context) otherwise"});`,i=e.slice(0,t.index)+r+e.slice(t.index);return F(e,i,r,t.index,t.index),i},ke=e=>{let t=e,n=Ce(t);if(n)t=n;else return console.error(`patch: opusplan1m: failed to apply mode switching patch`),null;if(n=we(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model aliases list patch`),null;if(n=Te(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply description function patch`),null;if(n=Ee(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply label function patch`),null;if(n=De(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model selector options patch`),null;if(n=Oe(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply always-show-in-selector patch`),null;return t},Ae=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 F(e,a,n,r,i),a},je=(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 F(e,o,r,i,a),o},Me=(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 F(e,o,r,i,a),o},Ne=(e,t)=>{let n=e.match(/(\b[$\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 F(e,c,a,o,s),c},Pe=(e,t)=>{let n=e;if(t.plan){let e=je(n,t.plan);if(e===null)return null;n=e}if(t.explore){let e=Me(n,t.explore);if(e===null)return null;n=e}if(t.generalPurpose){let e=Ne(n,t.generalPurpose);if(e===null)return null;n=e}return n},Fe=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}},Ie=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern`),null;let n=t.index+t[0].length;return{startIndex:n,endIndex:n}},Le=(e,t,n,r,i,a)=>{let o=e.match(/alignItems:"center",minHeight:([$\w]+\?\d+:\d+|\d+),?/);if(!o||o.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4`),null;let s=o[1],c=e.slice(0,o.index)+`minHeight:${s},`+e.slice(o.index+o[0].length),l=Math.max(0,o.index-200),u=c.slice(l,o.index+12+2),d=Array.from(u.matchAll(/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g));if(d.length===0)return console.error(`patch: patchesAppliedIndication: failed to find createElement for PATCH 4`),null;let f=d[d.length-1],p=l+f.index+f[0].length,m=`${n}.createElement(${i}, null, ${a}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,h=c;c=c.slice(0,p)+m+c.slice(p),F(h,c,m,p,p);let g=1,_=p+m.length,v=-1;for(;_<c.length;){let e=c[_];if(e===`(`)g++;else if(e===`)`){if(g===1){v=_;break}g--}_++}if(v===-1)return console.error(`patch: patchesAppliedIndication: failed to find closing paren for PATCH 4`),null;let y=c;return c=c.slice(0,v)+`),`+c.slice(v),F(y,c,`),`,v,v),{content:c,closingParenIndex:v+2}},Re=(e,t,n,r,i,a,o)=>{let s=4,c=t,l=-1;for(;c<e.length;){let t=e[c];if(t===`(`)s++;else if(t===`)`){if(s===1){l=c;break}s--}c++}if(l===-1)return console.error(`patch: patchesAppliedIndication: failed to find insertion point for PATCH 5`),null;let u=[];u.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of o)e=e.replace(`CHALK_VAR`,a),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {dimColor: true}, \` * ${e}\`)),`);u.push(`),`);let d=u.join(``),f=e,p=e.slice(0,l)+d+e.slice(l);return F(f,p,d,l,l),p},ze=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3`),null;let n=Math.max(0,t.index-1500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/\}function ([$\w]+)\(/g));if(i.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let a=i[i.length-1][1],o=RegExp(`\\b([$\\w]+)\\.createElement\\(${U(a)},null\\),?`),s=e.match(o);if(!s||s.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let c=s.index+s[0].length;return{startIndex:c,endIndex:c}},Be=(e,t,n,r=!0,i=!0)=>{let a=Fe(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=e.slice(0,a.endIndex)+o+e.slice(a.endIndex);F(e,s,o,a.endIndex,a.endIndex);let c=L(e);if(!c)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let l=V(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let u=B(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;let d=or(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find Box component`),null;if(r){let e=Ie(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 2 failed`),null;let n=`, " ",${u}.createElement(${l}, null, ${c}.blue.bold('+ tweakcc v${t}'))`,r=s;s=s.slice(0,e.startIndex)+n+s.slice(e.endIndex),F(r,s,n,e.startIndex,e.endIndex)}if(i){let e=ze(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 3 failed`),null;let t=[];t.push(`${u}.createElement(${d}, { flexDirection: "column" },`),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of n)e=e.replace(`CHALK_VAR`,c),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {dimColor: true}, \` * ${e}\`)),`);t.push(`),`);let r=t.join(`
|
|
2
|
-
`),i=s;s=s.slice(0,e.startIndex)+r+s.slice(e.endIndex),F(i,s,r,e.startIndex,e.endIndex)}let f=-1;if(r){let e=
|
|
3
|
-
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}},
|
|
1
|
+
import e from"chalk";import t,{EOL as n}from"node:os";import*as r from"node:fs/promises";import i from"node:fs/promises";import*as a from"node:fs";import o from"node:fs";import*as s from"node:path";import c from"node:path";import*as l from"fs";import*as u from"path";import*as d from"os";import*as f from"child_process";import*as p from"crypto";import m from"gray-matter";import{diffWordsWithSpace as h}from"diff";let g=null;async function _(){if(g!==null)return g;try{return await import(`node-lief`),g=await import(`./nativeInstallation-CP7Hq-4N.mjs`),g}catch(e){return W(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&W(e),null}}async function v(e){let t=await _();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function y(e,t,n){let r=await _();if(!r)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,t,n)}const b={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:null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSwarmMode:!0,enableSessionMemory:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1,enableWorktreeMode:!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`]},x={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},S={name:`Unnamed Toolset`,allowedTools:`*`},C=b.themes[0],w=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},ee=(e,t)=>{let n=w(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);F(i,r,n,e.startIndex,e.endIndex),i=r}return i};function te(e){let t=e.match(/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s);if(!t||t.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let n=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(n),a=e.match(r);return!i||i.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!a||a.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const ne=(e,t)=>{let n=te(e);if(!n)return null;if(t.length===0)return e;let r=e,i=`return`+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),F(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r;let a=JSON.stringify(t.map(e=>({label:e.name,value:e.id})));r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),F(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),F(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},re=e=>I(e,/\b200000\b/,`process.env.CLAUDE_CODE_CONTEXT_LIMIT`),ie=e=>{let t=e.indexOf(`bash:"bashBorder"`);if(t===-1)return console.error(`patch: input border: failed to find bash pattern`),null;let n=e.slice(t,t+500).match(/borderStyle:"[^"]*"/);return!n||n.index===void 0?(console.error(`patch: input border: failed to find border style pattern`),null):{startIndex:t+n.index,endIndex:t+n.index+n[0].length}},ae=(e,t)=>{let n=ie(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return F(e,r,t,n.startIndex,n.endIndex),r}else return e},oe=e=>{let t=e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/);if(!t||t.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let n=e.slice(t.index,t.index+1e4),r=n.match(/,([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);if(r&&r.index!=null)return{startIndex:t.index+r.index+r[1].length+1,endIndex:t.index+r.index+r[1].length+r[2].length+1,identifiers:[r[3]]};let i=n.match(/,([$\w]+)(=(\([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+\))\+"(?:…|\\u2026)")/);return i&&i.index!=null?{startIndex:t.index+i.index+i[1].length+1,endIndex:t.index+i.index+i[1].length+i[2].length+1,identifiers:[i[3]]}:(console.error(`patch: thinker format: failed to find formatMatch`),null)},T=(e,t)=>{let n=oe(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 F(e,s,o,r.startIndex,r.endIndex),s},E=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]]}},se=(e,t)=>{let n=E(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 F(e,a,i,n.startIndex,n.endIndex),a},ce=(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);F(s,t,a,o[e].startIndex,o[e].endIndex),s=t}return s},le=(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 F(e,o,r,i,a),o},ue=e=>{let t=e.match(/\{flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},de=(e,t)=>{let n=ue(e);if(!n)return null;let r=`{flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return F(e,i,r,n.startIndex,n.endIndex),i},fe=(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 F(e,o,r,i,a),o},pe=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+ed",?){5,}\]/);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 F(e,s,i,a,o),s},me=(e,t)=>{let n=fe(e,t);if(n===null)return null;let r=pe(n,t);return r===null?null:r},he=(e,t)=>{let n=V(e);if(!n)return console.error(`patch: userMessageDisplay: failed to find Text component`),null;let r=ar(e);if(!r)return console.error(`patch: userMessageDisplay: failed to find Box component`),null;let i=L(e);if(!i)return console.error(`patch: userMessageDisplay: failed to find chalk variable`),null;let a=e.match(/(No content found in user prompt message.{0,150}?\b)([$\w]+(?:\.default)?\.createElement.{0,30}\b[$\w]+(?:\.default)?\.createElement.{0,40}">.+?)?(([$\w]+(?:\.default)?\.createElement).{0,100})(\([$\w]+,(?:\{[^{}]+wrap:"wrap"\},([$\w]+)(?:\.trim\(\))?\)\)|\{text:([$\w]+)(?:,thinkingMetadata:[$\w]+)?\}\)\)?))/);if(!a||a.index===void 0)return console.error(`patch: userMessageDisplay: failed to find user message display pattern`),null;let o=a[4],s=a[6]??a[7],c=[],l=t.borderStyle.startsWith(`topBottom`);if(t.borderStyle!==`none`){if(l){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:" "}`),c.push(`borderStyle:${e}`)}else c.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&c.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX>0&&c.push(`paddingX:${t.paddingX}`),t.paddingY>0&&c.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&c.push(`alignSelf:"flex-start"`);let u=c.length>0?`{${c.join(`,`)}}`:`null`,d=i;if(t.foregroundColor!==`default`){let e=t.foregroundColor.match(/\d+/g);e&&(d+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);e&&(d+=`.bgRgb(${e.join(`,`)})`)}t.styling.includes(`bold`)&&(d+=`.bold`),t.styling.includes(`italic`)&&(d+=`.italic`),t.styling.includes(`underline`)&&(d+=`.underline`),t.styling.includes(`strikethrough`)&&(d+=`.strikethrough`),t.styling.includes(`inverse`)&&(d+=`.inverse`);let f="`"+t.format.replace(/\{\}/g,"${"+s+`}`)+"`",p=`${d}(${f})`,m=a[1]+`${o}(${r},${u},${o}(${n},null,${p}))`,h=a.index,g=h+a[0].length,_=e.slice(0,h)+m+e.slice(g);return F(e,_,m,h,g),_},ge=(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},_e=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)return console.error(`patch: inputPatternHighlighters: failed to find highlight?.color renderer pattern`),null;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 F(e,i,r,t.index,t.index+t[0].length),i},ve=(e,t,n)=>{let r=e.match(/(,[$\w]+=[$\w]+\.useMemo\(\(\)=>\{let [$\w]+=\[\];)(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;let o=a[1],s=Math.max(0,r.index-4e3),c=e.slice(s,r.index).match(/\binput:([$\w]+),/);if(!c)return console.error(`patch: inputPatternHighlighters: failed to find input variable pattern`),null;let l=c[1],u=``;for(let e=0;e<n.length;e++){let t=n[e],r=t.regexFlags;r.includes(`g`)||(r+=`g`);let i=Fr(new RegExp(t.regex,r));u+=`,matchedTweakccReplacements${e}=${o}.useMemo(()=>{return[...${l}.matchAll(${i})].map(m=>({start:m.index,end:m.index+m[0].length}))},[${l}])`}let d=``;for(let e=0;e<n.length;e++){let r=n[e],a=ge(t,r),o=JSON.stringify(r.format).replace(/\{MATCH\}/g,`"+x+"`);d+=`for(let matchedTweakccReplacement of matchedTweakccReplacements${e}){${i}.push({start:matchedTweakccReplacement.start,end:matchedTweakccReplacement.end,color:x=>${a}(${o}),priority:100})}`}let f=r[1]+d+r[2],p=e.slice(0,r.index),m=e.slice(r.index+r[0].length),h=p+u+f+m;return F(e,h,u+f,r.index,r.index+r[0].length),h},ye=(e,t)=>{let n=t.filter(e=>e.enabled);if(n.length===0)return null;let r=L(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i;return i=_e(e),i?(i=ve(i,r,n),i||(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterCreation failed`),null)):(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterImpl failed`),null)},be=e=>{let t=e.match(/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/);if(!t||t.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let n=t[0].match(/verbose:[^,}]+/);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},xe=e=>{let t=be(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return F(e,r,n,t.startIndex,t.endIndex),r},Se=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 F(e,c,s,t.index,t.index+n.length),c},Ce=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 F(e,r,n,t.index,t.index+t[0].length),r},we=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"Opus .{0,20} in plan mode, else Sonnet .{0,20}";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchDescriptionFunction: failed to find description pattern`),null;let[n,,r]=t,i=n+`if(${r}==="opusplan[1m]")return"Opus 4.5 in plan mode, else Sonnet 4.5 (1M context)";`,a=e.slice(0,t.index)+i+e.slice(t.index+n.length);return F(e,a,i,t.index,t.index+n.length),a},Te=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 F(e,a,i,t.index,t.index+n.length),a},Ee=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+`if(${r}==="opusplan[1m]")return[...${i},{value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus 4.5 in plan mode, Sonnet 4.5 (1M context) otherwise"}];`,o=e.slice(0,t.index)+a+e.slice(t.index+n.length);return F(e,o,a,t.index,t.index+n.length),o},De=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 4.5 in plan mode, Sonnet 4.5 otherwise"});${n}.push({value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus 4.5 in plan mode, Sonnet 4.5 (1M context) otherwise"});`,i=e.slice(0,t.index)+r+e.slice(t.index);return F(e,i,r,t.index,t.index),i},Oe=e=>{let t=e,n=Se(t);if(n)t=n;else return console.error(`patch: opusplan1m: failed to apply mode switching patch`),null;if(n=Ce(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model aliases list patch`),null;if(n=we(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply description function patch`),null;if(n=Te(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply label function patch`),null;if(n=Ee(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model selector options patch`),null;if(n=De(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply always-show-in-selector patch`),null;return t},ke=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 F(e,a,n,r,i),a},Ae=(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 F(e,o,r,i,a),o},je=(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 F(e,o,r,i,a),o},Me=(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 F(e,c,a,o,s),c},Ne=(e,t)=>{let n=e;if(t.plan){let e=Ae(n,t.plan);if(e===null)return null;n=e}if(t.explore){let e=je(n,t.explore);if(e===null)return null;n=e}if(t.generalPurpose){let e=Me(n,t.generalPurpose);if(e===null)return null;n=e}return n},Pe=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}},Fe=e=>{let t=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern`),null;let n=t.index+t[0].length;return{startIndex:n,endIndex:n}},Ie=(e,t,n,r,i,a)=>{let o=e.match(/alignItems:"center",minHeight:([$\w]+\?\d+:\d+|\d+),?/);if(!o||o.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4`),null;let s=o[1],c=e.slice(0,o.index)+`minHeight:${s},`+e.slice(o.index+o[0].length),l=Math.max(0,o.index-200),u=c.slice(l,o.index+12+2),d=Array.from(u.matchAll(/[^$\w]([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g));if(d.length===0)return console.error(`patch: patchesAppliedIndication: failed to find createElement for PATCH 4`),null;let f=d[d.length-1],p=l+f.index+f[0].length,m=`${n}.createElement(${i}, null, ${a}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,h=c;c=c.slice(0,p)+m+c.slice(p),F(h,c,m,p,p);let g=1,_=p+m.length,v=-1;for(;_<c.length;){let e=c[_];if(e===`(`)g++;else if(e===`)`){if(g===1){v=_;break}g--}_++}if(v===-1)return console.error(`patch: patchesAppliedIndication: failed to find closing paren for PATCH 4`),null;let y=c;return c=c.slice(0,v)+`),`+c.slice(v),F(y,c,`),`,v,v),{content:c,closingParenIndex:v+2}},Le=(e,t,n,r,i,a,o)=>{let s=4,c=t,l=-1;for(;c<e.length;){let t=e[c];if(t===`(`)s++;else if(t===`)`){if(s===1){l=c;break}s--}c++}if(l===-1)return console.error(`patch: patchesAppliedIndication: failed to find insertion point for PATCH 5`),null;let u=[];u.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of o)e=e.replace(`CHALK_VAR`,a),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {dimColor: true}, \` * ${e}\`)),`);u.push(`),`);let d=u.join(``),f=e,p=e.slice(0,l)+d+e.slice(l);return F(f,p,d,l,l),p},Re=e=>{let t=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3`),null;let n=Math.max(0,t.index-1500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/\}function ([$\w]+)\(/g));if(i.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let a=i[i.length-1][1],o=RegExp(`[^$\\w]([$\\w]+)\\.createElement\\(${U(a)},null\\),?`),s=e.match(o);if(!s||s.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let c=s.index+s[0].length;return{startIndex:c,endIndex:c}},ze=(e,t,n,r=!0,i=!0)=>{let a=Pe(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=e.slice(0,a.endIndex)+o+e.slice(a.endIndex);F(e,s,o,a.endIndex,a.endIndex);let c=L(e);if(!c)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let l=V(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let u=B(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;let d=ar(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find Box component`),null;if(r){let e=Fe(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 2 failed`),null;let n=`, " ",${u}.createElement(${l}, null, ${c}.blue.bold('+ tweakcc v${t}'))`,r=s;s=s.slice(0,e.startIndex)+n+s.slice(e.endIndex),F(r,s,n,e.startIndex,e.endIndex)}if(i){let e=Re(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 3 failed`),null;let t=[];t.push(`${u}.createElement(${d}, { flexDirection: "column" },`),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of n)e=e.replace(`CHALK_VAR`,c),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {dimColor: true}, \` * ${e}\`)),`);t.push(`),`);let r=t.join(`
|
|
2
|
+
`),i=s;s=s.slice(0,e.startIndex)+r+s.slice(e.endIndex),F(i,s,r,e.startIndex,e.endIndex)}let f=-1;if(r){let e=Ie(s,t,u,d,l,c);if(!e)return console.error(`patch: patchesAppliedIndication: patch 4 failed`),null;s=e.content,f=e.closingParenIndex}if(i){if(f===-1){let e=s.match(/alignItems:"center",minHeight:([$\w]+\?\d+:\d+|\d+),?/);if(!e||e.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find reference point for PATCH 5`),null;f=e.index+e[0].length}let e=Le(s,f,u,d,l,c,n);if(!e)return console.error(`patch: patchesAppliedIndication: patch 5 failed`),null;s=e}return s};async function Be(e){let t=u.join(Vr,`prompts-${e}.json`);try{let e=await r.readFile(t,`utf-8`);return JSON.parse(e)}catch{}let n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{let i=await fetch(n);if(!i.ok){let t;throw t=i.status===429?`Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.`:i.status===404?`Prompts file not found for Claude Code v${e}. This version was released within the past day or so and will be supported within a few hours.`:i.status>=500?`GitHub server error (${i.status}). Please try again later.`:`HTTP ${i.status}: ${i.statusText}`,Error(t)}let a=await i.json();try{await r.mkdir(Vr,{recursive:!0}),await r.writeFile(t,JSON.stringify(a,null,2),`utf-8`)}catch(e){console.warn(`Failed to write to cache to ${t}: ${e}`)}return a}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 Ve=()=>u.join(q,`systemPromptOriginalHashes.json`),He=()=>u.join(q,`systemPromptAppliedHashes.json`),Ue=(e,t)=>`${e}-${t}`,We=e=>p.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),Ge=async()=>{try{let e=await r.readFile(Ve(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Ke=async e=>{await r.mkdir(q,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await r.writeFile(Ve(),JSON.stringify(t,null,2),`utf8`)},qe=async e=>{let t=await Ge(),n=0;for(let r of e.prompts){let e=Ue(r.id,r.version);t[e]||(t[e]=We(D(r.pieces,r.identifiers,r.identifierMap)),n++)}return await Ke(t),n},Je=async(e,t)=>(await Ge())[Ue(e,t)],Ye=async()=>{try{let e=await r.readFile(He(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Xe=async e=>{await r.mkdir(q,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await r.writeFile(He(),JSON.stringify(t,null,2),`utf8`)},Ze=async(e,t)=>{let n=await Ye();n[e]=t,await Xe(n)},Qe=async()=>{let e=await Ye(),t={};for(let n of Object.keys(e))t[n]=null;await Xe(t)},$e=async e=>{try{let t=await Ye();if(Object.keys(t).length===0)return!1;let n=(await r.readdir(e)).filter(e=>e.endsWith(`.md`));for(let i of n){let n=t[i.replace(`.md`,``)];if(n==null)continue;let a=u.join(e,i),o=await r.readFile(a,`utf8`);if(We((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}},et=e=>{let t=m(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
|
+
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}},tt=(e,t)=>{let n=t||D(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,i={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(i.variables=r),m.stringify(n,i,{delimiters:[`<!--`,`-->`]})},D=(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},O=(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},k=e=>u.join(X,`${e}.md`),nt=async e=>{try{return await r.access(k(e)),!0}catch{return!1}},rt=async e=>{let t=k(e);return et(await r.readFile(t,`utf-8`))},it=async(e,t)=>{let n=k(e);await r.writeFile(n,t,`utf-8`)},at=async(e,t)=>{let n=k(e),i=m(await r.readFile(n,`utf-8`),{delimiters:[`<!--`,`-->`]}),a=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,o={name:i.data.name,description:i.data.description,ccVersion:i.data.ccVersion};a&&a.length>0&&(o.variables=a),await it(e,m.stringify(i.content,o,{delimiters:[`<!--`,`-->`]}))},ot=(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,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),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}},st=(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=ot(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},ct=async(e,t,n,i,a,o,s,c)=>{let l=n.split(`
|
|
4
4
|
`),d=i.split(`
|
|
5
5
|
`),f=a.split(`
|
|
6
|
-
`),p=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),m=
|
|
6
|
+
`),p=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),m=st(l,d),h=st(l,f),g=``;for(let e of m){let t=p(e.line);if(e.type===`modified`){let t=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;g+=`<div class="line removed"><span class="line-num">${t}</span><span class="prefix">- </span>${e.oldHtml}</div>\n`,g+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${e.newHtml}</div>\n`}else if(e.type===`removed`){let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `;g+=`<div class="line removed"><span class="line-num">${n}</span><span class="prefix">- </span>${t}</div>\n`}else if(e.type===`added`){let n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;g+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${t}</div>\n`}else{let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,r=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;g+=`<div class="line unchanged"><span class="line-num">${n} ${r}</span><span class="prefix"> </span>${t}</div>\n`}}let _=``;for(let e of h){let t=p(e.line);if(e.type===`modified`){let t=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;_+=`<div class="line removed"><span class="line-num">${t}</span><span class="prefix">- </span>${e.oldHtml}</div>\n`,_+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${e.newHtml}</div>\n`}else if(e.type===`removed`){let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `;_+=`<div class="line removed"><span class="line-num">${n}</span><span class="prefix">- </span>${t}</div>\n`}else if(e.type===`added`){let n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;_+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${t}</div>\n`}else{let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,r=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;_+=`<div class="line unchanged"><span class="line-num">${n} ${r}</span><span class="prefix"> </span>${t}</div>\n`}}let v=`<!DOCTYPE html>
|
|
7
7
|
<html>
|
|
8
8
|
<head>
|
|
9
9
|
<meta charset="UTF-8">
|
|
@@ -164,13 +164,13 @@ ${_} </div>
|
|
|
164
164
|
</div>
|
|
165
165
|
</div>
|
|
166
166
|
</body>
|
|
167
|
-
</html>`,y=u.join(X,`${e}.diff.html`);return await r.writeFile(y,v,`utf-8`),y},
|
|
168
|
-
|\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},
|
|
169
|
-
`){r++,i=0;continue}let s=e[a+1];if(o===`$`&&s===`{`){n++,a++,i++;continue}if(n){o===`{`?n++:o===`}`&&n--;continue}if(o==="`"&&e[a-1]!==`\\`){let e=t.get(r)??[];e.push(i),t.set(r,e)}}return t},
|
|
170
|
-
`)},
|
|
171
|
-
`);for(let[n,a]of e){let e=n+(r.contentLineOffset||0),o=i[n-1]||``;console.log(
|
|
167
|
+
</html>`,y=u.join(X,`${e}.diff.html`);return await r.writeFile(y,v,`utf-8`),y},lt=async t=>{let n={id:t.id,name:t.name,description:t.description,action:`skipped`,newVersion:t.version};if(!await nt(t.id)){let e=tt(t);return await it(t.id,e),n.action=`created`,n}let r=await rt(t.id);if(n.oldVersion=r.ccVersion,await at(t.id,t.identifierMap),r.ccVersion&&t.version){let i=O(r.ccVersion,t.version);if(i===0)return n.action=`skipped`,n;if(i!=0){let i=await Je(t.id,r.ccVersion),a=We(r.content);if(!i||i!==a){n.action=`conflict`;let i=r.content;try{let e=(await Be(r.ccVersion)).prompts.find(e=>e.id===t.id);e&&(i=D(e.pieces,e.identifiers,e.identifierMap))}catch{console.log(e.yellow(`Warning: Could not fetch old version ${r.ccVersion} for comparison. Using current file as baseline.`))}let a=D(t.pieces,t.identifiers,t.identifierMap),o=k(t.id);n.diffHtmlPath=await ct(t.id,t.name,i,r.content,a,r.ccVersion,t.version,o)}else{let e=tt(t);await it(t.id,e),n.action=`updated`}}}return n},ut=async t=>{let n={ccVersion:t,results:[]},i=await Be(t);await qe(i),await r.mkdir(X,{recursive:!0});for(let t of i.prompts)try{let e=await lt(t);n.results.push(e)}catch(n){throw console.log(e.red(`Failed to sync prompt ${t.id}:`)),n}return n};let A=null,dt=null;const ft=async e=>{try{return A=await Be(e),dt=e,{success:!0}}catch(e){return A=null,dt=null,e instanceof Error?{success:!1,errorMessage:e.message}:{success:!1,errorMessage:`Unknown error occurred while downloading system prompts`}}},pt=()=>A?A.prompts.map(e=>({id:e.id,name:e.name,description:e.description})):null,mt=e=>e.replace(/[^\x00-\x7F]/g,e=>{let t=`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`;return`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}|${t})`}),ht=e=>e.replace(/[^\x00-\x7F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),gt=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++){let a=e[i].replace(/<<CCVERSION>>/g,t);n&&(a=a.replace(/<<BUILD_TIME>>/g,n));let o=mt(a.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).replace(/\n/g,`(?:
|
|
168
|
+
|\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},_t=e=>{let t=new Map,n=0,r=1,i=1;for(let a=0;a<e.length;a++,i++){let o=e[a];if(o===`
|
|
169
|
+
`){r++,i=0;continue}let s=e[a+1];if(o===`$`&&s===`{`){n++,a++,i++;continue}if(n){o===`{`?n++:o===`}`&&n--;continue}if(o==="`"&&e[a-1]!==`\\`){let e=t.get(r)??[];e.push(i),t.set(r,e)}}return t},vt=(t,n,r,i)=>{let a=[],o=String(n),s=o.length,c=` `.repeat(s),l=i[0],u=i[i.length-1],d=l-1,f=r.length-u,p=r,m=i,h=``,g=``,_=0;if(d>30||f>30){let t=0,n=r.length,a=0;if(d>30){let n=d-30;t=n,a=-n;let r=`[${n} chars] ...`;h=e.dim(r),_=r.length}if(f>30){let t=f-30;n=r.length-t,g=e.dim(`... [${t} chars]`)}p=r.substring(t,n),m=i.map(e=>e+a)}a.push(`${e.red.bold(`error`)}${e.bold(`: system prompt file contains unescaped backtick`)}`),a.push(`${e.blue.bold(` `.repeat(s)+` -->`)} ${t}:${n}:${l}`),a.push(`${c} ${e.blue.bold(`|`)}`);let v=h+p+g;a.push(`${e.blue.bold(o)} ${e.blue.bold(`|`)} ${v}`);let y=_+m[0]-1,b=` `.repeat(y)+`^ unescaped backtick`;a.push(`${c} ${e.blue.bold(`|`)} ${e.red.bold(b)}`),a.push(`${c} ${e.blue.bold(`|`)}`),a.push(`${e.cyan.bold(`help`)}: add \`\\\` before the backtick to escape it`),a.push(`${c} ${e.blue.bold(`|`)}`);let x=[],S=0;for(let t of m)x.push(p.substring(S,t-1)),x.push(e.green(`\\`)+"`"),S=t;x.push(p.substring(S));let C=h+x.join(``)+g;a.push(`${e.blue.bold(o)} ${e.blue.bold(`|`)} ${C}`);let w=``,ee=0;for(let e=0;e<m.length;e++){let t=m[e],n=_+t-1+ee;w=w.padEnd(n,` `)+`+`,ee++}return a.push(`${c} ${e.blue.bold(`|`)} ${e.green(w)}`),a.join(`
|
|
170
|
+
`)},yt=e=>{if(e.length===0)return{leading:``,trailing:``};let t=e[0].match(/^(\s*)/),n=t?t[1]:``,r=e[e.length-1].match(/(\s*)$/);return{leading:n,trailing:r?r[1]:``}},bt=(e,t)=>{if(e.trim()===``)return``;let n=e.trim();return t.leading+n+t.trailing},xt=(e,t,n,r,i,a=!1,o,s)=>{let c={};for(let e=0;e<r.length;e++){let i=r[e],a=n[String(t[e])];a&&(c[a]=i)}let l=e,u=Object.entries(c).sort((e,t)=>t[0].length-e[0].length);for(let[e,t]of u){let n=RegExp(`\\b${e}\\b`,`g`);l=l.replace(n,()=>t)}if(l=l.replace(/<<CCVERSION>>/g,i),o&&(l=l.replace(/<<BUILD_TIME>>/g,o)),a&&(l=ht(l)),s&&s.length>0){let e=yt(s);l=bt(l,e)}return l},St=async(e,t=!1,n)=>{if(!A||dt!==e)return[];let i=A,a=[];for(let o of i.prompts){let i=gt(o.pieces,e,n),s=u.join(X,`${o.id}.md`),c;try{c=await r.readFile(s,`utf8`)}catch(e){console.error(`Failed to read markdown file ${s}:`,e);continue}let l=et(c);a.push({promptId:o.id,prompt:l,regex:i,getInterpolatedContent:r=>{let i=r.slice(1);return xt(l.content,o.identifiers,o.identifierMap,i,e,t,n,o.pieces)},pieces:o.pieces,identifiers:o.identifiers,identifierMap:o.identifierMap})}return a},Ct=t=>{let n=t.results.filter(e=>e.action===`created`),r=t.results.filter(e=>e.action===`updated`),i=t.results.filter(e=>e.action===`conflict`),a=t.results.filter(e=>e.action===`skipped`);if((n.length>0||r.length>0||i.length>0)&&a.length>0&&(console.log(e.dim(`Skipped ${a.length} up-to-date file(s)`)),console.log()),n.length>0){console.log(e.bold.green(`Created ${n.length} new prompt file(s):`));for(let t of n)console.log(e.green(` ${X}/${t.id}.md`)),console.log(e.green.dim(` ${t.description}`));console.log()}if(r.length>0){console.log(e.bold.blue(`Updated ${r.length} system prompt file(s):`));for(let t of r)t.oldVersion?console.log(e.blue(` ${t.id}.md (${t.oldVersion} → ${t.newVersion})`)):console.log(e.blue(` ${t.id}.md (→ ${t.newVersion})`));console.log()}if(i.length>0){console.log(e.bold.yellow(`WARNING: Conflicts detected for ${i.length} system prompt file(s)`));for(let t of i)console.log(e.yellow(` ${t.id}.md (${t.oldVersion} → ${t.newVersion})`)),console.log(e.yellow(` Open the diff in your browser: ${t.diffHtmlPath}`));console.log()}if(n.length>0&&(console.log(e.green.bold(`New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.`)),console.log(e.green(`You can now customize the markdown files at ${X} in a text editor.`)),console.log(e.green(`Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts`)),console.log()),i.length>0){console.log(),console.log(`Review conflicts:`),console.log(` 1. Open the diff HTML files in your browser`),console.log(` 2. Verify your customizations are still appropriate`),console.log(` 3. Update your markdown files if needed`),console.log(e.bold.cyan(` 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:`));for(let t of i)console.log(e.yellow(` ${t.id}.md → `)+e.bold.magenta(t.newVersion));console.log(` 5. Delete the diff HTML files`),console.log()}},wt=e=>/\\u[0-9a-fA-F]{4}/.test(e),Tt=e=>{let t=e.match(/\bBUILD_TIME:"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)"/);return t?t[1]:void 0},Et=async(t,n,r,i)=>{let a=r??wt(t);a&&W(`Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts`);let o=Tt(t);o&&W(`Extracted BUILD_TIME from cli.js: ${o}`);let s=await St(n,a,o);W(`Loaded ${s.length} system prompts with regexes`);let c=[];for(let{promptId:n,prompt:r,regex:a,getInterpolatedContent:o,pieces:l,identifiers:u,identifierMap:d}of s){if(i&&!i.includes(n)){c.push({id:n,name:r.name,group:H.SYSTEM_PROMPTS,applied:!1,skipped:!0});continue}W(`Applying system prompt: ${r.name}`);let s=new RegExp(a,`si`),f=t.match(s);if(f&&f.index!==void 0){let i=o(f),a=f.index,p=a>0?t[a-1]:``;if(p==="`"){let e=_t(i);if(e.size>0){let t=k(n),i=r.content.split(`
|
|
171
|
+
`);for(let[n,a]of e){let e=n+(r.contentLineOffset||0),o=i[n-1]||``;console.log(vt(t,e,o,a)),console.log()}continue}}let m=D(l,u,d).trim().length,h=r.content.trim().length,g=t,_=f[0].length,v=i;p===`"`?(v=v.replace(/\n/g,`\\n`),v=v.replace(/"/g,`\\"`)):p===`'`&&(v=v.replace(/\n/g,`\\n`),v=v.replace(/'/g,`\\'`)),t=t.replace(s,()=>v),await Ze(n,We(r.content)),F(g,t,v,a,a+_);let y=m-h,b=y!==0,x;x=y>0?e.green(`${y} fewer chars`):y<0?e.red(`${Math.abs(y)} more chars`):`unchanged`,c.push({id:n,name:r.name,group:H.SYSTEM_PROMPTS,applied:b,details:x})}else{!r.name.startsWith(`Data:`)&&r.name!==`Skill: Build with Claude API`&&console.log(e.yellow(`Could not find system prompt "${r.name}" in cli.js (using regex ${Fr(s)})`)),G(`\n Debug info for ${r.name}:`),G(` Regex pattern (first 200 chars): ${a.substring(0,200).replace(/\n/g,`\\n`)}...`),G(` Trying to match pattern in cli.js...`);try{G(` Partial match result: ${t.match(new RegExp(a.substring(0,100)))?`found partial`:`no match`}`)}catch{G(` Partial match failed (regex truncation issue)`)}}}return{newContent:t,results:c}},Dt=e=>{let t=e.match(/ensureServerStarted:([$\w]+)/);if(!t||t.index===void 0)return console.error(`patch: fixLspSupport: failed to find ensureServerStarted`),null;let n=Math.max(0,t.index-50),r=Math.min(e.length,t.index+50),i=e.slice(n,r),a=i.match(/sendRequest:([$\w]+)[,}]/);if(!a)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([n,r,i])}`),null;let o=a[1],s=Math.max(0,t.index-2e3),c=e.slice(s,t.index),l=RegExp(`async function ${U(o)}\\(([$\\w]+),`,`g`),u,d=null;for(;(u=l.exec(c))!==null;)d=u;if(!d)return console.error(`patch: fixLspSupport: failed to find async function ${o}`),null;let f=d[1],p=s+d.index,m=e.slice(p,t.index).match(/let ([$\w]+)=await [$\w]+\([$\w]+\);/);if(!m||m.index===void 0)return console.error(`patch: fixLspSupport: failed to find second line of sendRequest`),null;let h=m[1],g=p+m.index+m[0].length,_=e.slice(g,t.index),v=RegExp(`if\\(!${U(h)}\\)return;`),y=_.match(v);if(!y||y.index===void 0)return console.error(`patch: fixLspSupport: failed to find if(!serverVar)return; line`),null;let b=g+y.index+y[0].length;return{startIndex:b,endIndex:b,identifiers:[f,h]}},Ot=e=>{let t=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,n=/if\([$\w]+\.startupTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': startupTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,r=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,i=e;i=I(i,t,``),i=I(i,n,``),i=I(i,r,``);let a=Dt(i);if(!a||!a.identifiers)return null;let[o,s]=a.identifiers,c=`
|
|
172
172
|
const path = await import('path');
|
|
173
|
-
const ext = path.extname(${
|
|
173
|
+
const ext = path.extname(${o}).toLowerCase();
|
|
174
174
|
const langMap = {
|
|
175
175
|
'.ts': 'typescript',
|
|
176
176
|
'.tsx': 'typescriptreact',
|
|
@@ -308,17 +308,17 @@ ${_} </div>
|
|
|
308
308
|
const languageId = langMap[ext] || 'plaintext';
|
|
309
309
|
try {
|
|
310
310
|
const fs = await import('fs/promises');
|
|
311
|
-
const text = await fs.readFile(${
|
|
312
|
-
await ${
|
|
311
|
+
const text = await fs.readFile(${o}, 'utf8');
|
|
312
|
+
await ${s}.sendNotification('textDocument/didOpen', {
|
|
313
313
|
textDocument: {
|
|
314
|
-
uri: "file://" + ${
|
|
314
|
+
uri: "file://" + ${o},
|
|
315
315
|
languageId: languageId,
|
|
316
316
|
version: 1,
|
|
317
317
|
text: text
|
|
318
318
|
}
|
|
319
319
|
});
|
|
320
320
|
} catch (openErr) { }
|
|
321
|
-
`,
|
|
321
|
+
`,l=i.slice(0,a.startIndex)+c+i.slice(a.endIndex);return F(i,l,c,a.startIndex,a.endIndex),l},kt=e=>{let t=e.match(/=>\[([$a-zA-Z_][$\w]{1,2},){30}/);if(!t||t.index===void 0)return console.error(`patch: findSlashCommandListEndPosition: failed to find arrayStartPattern`),null;let n=e.indexOf(`[`,t.index);if(n===-1)return console.error(`patch: findSlashCommandListEndPosition: failed to find bracketIndex`),null;let r=1,i=n+1;for(;i<e.length&&r>0;){if(e[i]===`[`)r++;else if(e[i]===`]`&&(r--,r===0))return i;i++}return console.error(`patch: findSlashCommandListEndPosition: failed to find matching closing-bracket`),null},At=(e,t)=>{let n=kt(e);if(n===null)return console.error(`patch: writeSlashCommandDefinition: failed to find slash command array end position`),null;let r=e.slice(0,n)+t+e.slice(n);return F(e,r,t,n,n),r},jt=e=>{let t=e.match(/\.createElement\(([$\w]+),.{0,100}"Yes, use recommended settings"/);return t?t[1]:(console.error(`patch: findSelectComponentName: failed to find selectPattern`),null)},Mt=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)(?:\([$\w]+\)\{let [$\w]+=[$\w]+\(\d+\),\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+,?)+\}=|\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\))/g));if(t.length===0)return console.error(`patch: findDividerComponentName: failed to find dividerPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},j=e=>{let t=e.match(/function ([$\w]+)\(.{0,110}`Your selector in.{0,1000}?function ([$\w]+)\(\)\{return [$\w]+\(\)\.setState\}/);return t?{appStateUseSelectorFn:t[1],appStateSetState:t[2]}:(console.error(`patch: getAppStateSelectorAndUseState: failed to find pattern`),null)},Nt=e=>{let t=kt(e);if(t===null)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd`),null;let n=1,r=t;for(;r>=0&&n>0;){if(e[r]===`}`)n++;else if(e[r]===`{`&&(n--,n===0))break;r--}if(r<0)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace`),null;for(;r>=0&&e[r]!==`;`;)r--;return r<0?(console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon`),null):r+1},Pt=(e,t)=>{let n=Array.from(e.matchAll(/thinkingEnabled:([$\w]+)\(\)/g));if(n.length===0)return console.error(`patch: toolsets: failed to find thinkingEnabled pattern`),null;let r=[];for(let e of n)if(e.index!==void 0){let t=e.index+e[0].length;r.push({index:t})}r.sort((e,t)=>t.index-e.index);let i=e,a=`,toolset:${t?JSON.stringify(t):`undefined`}`;for(let e of r)i=i.slice(0,e.index)+a+i.slice(e.index);if(i===e)return console.error(`patch: toolsets: failed to modify app state initialization`),null;let o=r[r.length-1];return F(e,i,a,o.index,o.index),i},Ft=(e,t)=>{let n=j(e);if(!n)return console.error(`patch: toolsets: toolFetchingMemo: failed to find app state info`),null;let{appStateUseSelectorFn:r}=n,i=e.match(/let ([$\w]+)=([$\w]+\([$\w]+,[$\w]+\.tools,[$\w]+\)),/);if(!i||i.index===void 0)return console.error(`patch: toolsets: failed to find tool aggregation pattern`),null;let a=i[1],o=i[2],s=`let currentToolset = ${r}(state => state.toolset);
|
|
322
322
|
let ${a} = undefined;
|
|
323
323
|
const toolsets = ${JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools])))};
|
|
324
324
|
if (toolsets.hasOwnProperty(currentToolset)) {
|
|
@@ -330,7 +330,7 @@ if (toolsets.hasOwnProperty(currentToolset)) {
|
|
|
330
330
|
}
|
|
331
331
|
} else {
|
|
332
332
|
${a} = ${o};
|
|
333
|
-
}let `,c=i.index,l=c+i[0].length,u=e.slice(0,c)+s+e.slice(l);return F(e,u,s,c,l),u},
|
|
333
|
+
}let `,c=i.index,l=c+i[0].length,u=e.slice(0,c)+s+e.slice(l);return F(e,u,s,c,l),u},It=(e,t)=>{let n=Nt(e);if(n===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let r=B(e);if(!r)return console.error(`patch: toolsets: failed to find React variable`),null;let i=ar(e);if(!i)return console.error(`patch: toolsets: failed to find Box component`),null;let a=V(e);if(!a)return console.error(`patch: toolsets: failed to find Text component`),null;let o=jt(e);if(!o)return console.error(`patch: toolsets: failed to find Select component`),null;let s=Mt(e);if(!s)return console.error(`patch: toolsets: failed to find Divider component`),null;let c=j(e);if(!c)return console.error(`patch: toolsets: failed to find app state getter`),null;let l=L(e);if(!l)return console.error(`patch: toolsets: failed to find chalk variable`),null;let{appStateUseSelectorFn:u,appStateSetState:d}=c,f=JSON.stringify(t.map(e=>e.name)),p=JSON.stringify(t.map(e=>({label:e.name,value:e.name,description:e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}: ${e.allowedTools.join(`, `)}`}))),m=`const toolsetComp = ({ onExit, input }) => {
|
|
334
334
|
const currentToolset = ${u}(state => state.toolset);
|
|
335
335
|
|
|
336
336
|
const setState = ${d}();
|
|
@@ -396,7 +396,7 @@ if (toolsets.hasOwnProperty(currentToolset)) {
|
|
|
396
396
|
${r}.createElement(${a}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
|
|
397
397
|
)
|
|
398
398
|
);
|
|
399
|
-
};`,h=e.slice(0,n)+m+e.slice(n);return F(e,h,m,n,n),h},
|
|
399
|
+
};`,h=e.slice(0,n)+m+e.slice(n);return F(e,h,m,n,n),h},Lt=e=>{let t=e.match(/\{color:"bashBorder"\},"! for bash mode"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find bash mode pattern`),null;let n=Math.max(0,t.index-1e4),r=e.slice(n,t.index),i=Array.from(r.matchAll(/function ([$\w]+)\((?:\{[^}]+\}|[$\w]+)\)\{/g));if(i.length===0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find function pattern`),null;let a=i[i.length-1];return a.index===void 0?(console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: match has no index`),null):n+a.index+a[0].length},Rt=e=>{let t=Lt(e);if(t===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let n=j(e);if(!n)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter`),null;let{appStateUseSelectorFn:r}=n,i=`let currentToolset=${r}(state => state.toolset);`,a=e.slice(0,t)+i+e.slice(t);return F(e,a,i,t,t),a},zt=e=>{let t=e.match(/([$\w]+)\((\w+)\)\.toLowerCase\(\)," on"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to find mode display pattern`),null;let n=t[1],r=t[2],i=t[0],a=`${n}(${r}).toLowerCase()," on [",currentToolset||"undefined","]"`,o=e.replace(i,a);return o===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(F(e,o,a,t.index,t.index+i.length),o)},Bt=e=>{let t=Array.from(e.matchAll(/"\? for shortcuts"/g)).at(-1);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'`),null;let n=t[0],r=`"? for shortcuts [",state.toolset||"undefined","]"`,i=e.replace(n,r);return i===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(F(e,i,r,t.index,t.index+n.length),i)},Vt=e=>{let t=B(e);return t?At(e,`, {
|
|
400
400
|
aliases: ["change-tools"],
|
|
401
401
|
type: "local-jsx",
|
|
402
402
|
name: "toolset",
|
|
@@ -404,16 +404,16 @@ if (toolsets.hasOwnProperty(currentToolset)) {
|
|
|
404
404
|
argumentHint: "[toolset-name]",
|
|
405
405
|
isEnabled: () => true,
|
|
406
406
|
isHidden: false,
|
|
407
|
-
|
|
407
|
+
load: () => Promise.resolve().then(() => ({call: (onExit, ctx, input) => {
|
|
408
408
|
return ${t}.createElement(toolsetComp, { onExit, input });
|
|
409
|
-
},
|
|
409
|
+
}})),
|
|
410
410
|
userFacingName() {
|
|
411
411
|
return "toolset";
|
|
412
412
|
}
|
|
413
|
-
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},
|
|
414
|
-
middle: ["|", "-", "|", "|"],bottom: ["", "", "", ""]`),n!==e&&(r++,W(`Patched table border definition object (spaced format)`))}else G(`Could not find table border definition pattern - CLI may have changed`);{let e=n;n=n.replace(/let\s+([$\w]+)\s*=\s*"\\u2502";/g,`let $1="|";`),n=n.replace(/" \\u2502"/g,`" |"`),n=n.replace(/"\\u2502"/g,`"|"`),n=n.replace(/let\s+([$\w]+)\s*=\s*"│";/g,`let $1 = "|";`),n=n.replace(/"\s*│"/g,`" |"`),n!==e&&(r++,W(`Patched vertical border characters`))}{let e=n;n=n.replace(/"─"\.repeat\(/g,`"-".repeat(`),n=n.replace(/"\\u2500"\.repeat\(/g,`"-".repeat(`),n!==e&&(r++,W(`Patched horizontal separator characters`))}{let{result:e,success:t}
|
|
413
|
+
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},Ht=e=>{let t=e.match(/[\w$]+\([\w$]+,function\([\w$]+\)\{[\w$]+\("tengu_ext_at_mentioned",\{\}\);/);return!t||t.index===void 0?(console.error(`patch: findToolChangeComponentScope: failed to find tool change component scope`),null):t.index},Ut=e=>{let t=Ht(e);if(t===null)return null;let n=j(e);if(!n)return console.error(`patch: addCurrentToolsetAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateUseSelectorFn:r}=n,i=`const currentToolset = ${r}(state => state.toolset);`,a=e.slice(0,t)+i+e.slice(t);return F(e,a,i,t,t),a},Wt=e=>{let t=e.match(/if\(([$\w]+)\(\([$\w]+\)=>\(\{\.\.\.[$\w]+,toolPermissionContext.{0,200}?mode:([$\w]+)/);return!t||t.index===void 0?(console.error(`patch: findModeChange: failed to find mode change location`),null):{index:t.index,modeVar:t[2],setStateVar:t[1]}},Gt=(e,t,n)=>{let r=Wt(e);if(!r)return null;let{index:i,modeVar:a,setStateVar:o}=r,s=`if(${a}==="plan"){${o}((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}else{${o}((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}`,c=e.slice(0,i)+s+e.slice(i);return F(e,c,s,i,i),c},Kt=(e,t,n,r)=>{if(!t||t.length===0)return e;let i=e;if(i=Pt(i,n),!i)return console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null;if(i=Ft(i,t),!i)return console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null;if(i=It(i,t),!i)return console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null;if(i=Vt(i),!i)return console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null;if(i=Rt(i),!i)return console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null;if(i=zt(i),!i)return console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null;if(i=Bt(i),!i)return console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null;if(r&&n){if(i=Ut(i),!i)return console.error(`patch: toolsets: step 8a failed (addCurrentToolsetAtToolChangeComponentScope)`),null;if(i=Gt(i,r,n),!i)return console.error(`patch: toolsets: step 8b failed (writeModeChangeUpdateToolset)`),null}return i},M=/\{top:\["┌","─","┬","┐"\],middle:\["├","─","┼","┤"\],bottom:\["└","─","┴","┘"\]\}/,N=/top:\["\\u250C","\\u2500","\\u252C","\\u2510"\],middle:\["\\u251C","\\u2500","\\u253C","\\u2524"\],bottom:\["\\u2514","\\u2500","\\u2534","\\u2518"\]/,P=/top: \["┌", "─", "┬", "┐"\],\s+middle: \["├", "─", "┼", "┤"\],\s+bottom: \["└", "─", "┴", "┘"\]/,qt=/if\(([$\w]+)\.push\(\.\.\.([$\w]+)\(([$\w]+),!1\)\),([$\w]+)<([$\w]+)\.rows\.length-1\)([$\w]+)\.push\(([$\w]+)\("middle"\)\)/g,Jt=/if\s*\(\s*\(\s*([$\w]+)\.push\(\.\.\.([$\w]+)\(([$\w]+)\s*,\s*!1\)\)\s*,\s*([$\w]+)\s*<\s*([$\w]+)\.rows\.length\s*-\s*1\s*\)\s*\)\s*([$\w]+)\.push\(([$\w]+)\("middle"\)\)\s*;?/g,Yt=/([$\w]+)\.push\(([$\w]+)\("top"\)\),/g,Xt=/,([$\w]+)\.push\(([$\w]+)\("bottom"\)\),/g,Zt=/([$\w]+)\.push\(\s*([$\w]+)\(\s*"top"\s*\)\s*\)\s*,\s*/g,Qt=/,\s*([$\w]+)\.push\(\s*([$\w]+)\(\s*"bottom"\s*\)\s*\)\s*,/g;function $t(e){let t=e,n=!1,r=t;t=t.replace(qt,`$1.push(...$2($3,!1))`),t!==r&&(n=!0);let i=t;return t=t.replace(Jt,`$1.push(...$2($3,!1))`),t!==i&&(n=!0),{result:t,success:n}}function en(e){let t=e,n=!1,r=t;t=t.replace(Yt,``),t!==r&&(n=!0);let i=t;t=t.replace(Zt,``),t!==i&&(n=!0);let a=t;t=t.replace(Xt,`,`),t!==a&&(n=!0);let o=t;return t=t.replace(Qt,`,`),t!==o&&(n=!0),{result:t,success:n}}const tn=(e,t)=>{if(t===`default`)return W(`Table format is "default", no patching needed`),null;let n=e,r=0;if(t===`ascii`){if(M.test(n)){let e=n;n=n.replace(M,`{top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]}`),n!==e&&(r++,W(`Patched table border definition object (minified format)`))}else if(N.test(n)){let e=n;n=n.replace(N,`top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]`),n!==e&&(r++,W(`Patched table border definition object (native Unicode format)`))}else if(P.test(n)){let e=n;n=n.replace(P,`top: ["", "", "", ""],
|
|
414
|
+
middle: ["|", "-", "|", "|"],bottom: ["", "", "", ""]`),n!==e&&(r++,W(`Patched table border definition object (spaced format)`))}else G(`Could not find table border definition pattern - CLI may have changed`);{let e=n;n=n.replace(/let\s+([$\w]+)\s*=\s*"\\u2502";/g,`let $1="|";`),n=n.replace(/" \\u2502"/g,`" |"`),n=n.replace(/"\\u2502"/g,`"|"`),n=n.replace(/let\s+([$\w]+)\s*=\s*"│";/g,`let $1 = "|";`),n=n.replace(/"\s*│"/g,`" |"`),n!==e&&(r++,W(`Patched vertical border characters`))}{let e=n;n=n.replace(/"─"\.repeat\(/g,`"-".repeat(`),n=n.replace(/"\\u2500"\.repeat\(/g,`"-".repeat(`),n!==e&&(r++,W(`Patched horizontal separator characters`))}{let{result:e,success:t}=$t(n);t&&(n=e,r++,W(`Removed inter-row separators`))}{let{result:e,success:t}=en(n);t&&(n=e,r++,W(`Removed top/bottom border pushes`))}}else if(t===`clean`){if(M.test(n)){let e=n;n=n.replace(M,`{top:["","","",""],middle:["├","─","┼","┤"],bottom:["","","",""]}`),n!==e&&(r++,W(`Patched table border definition for clean format (minified format)`))}else if(N.test(n)){let e=n;n=n.replace(N,`top:["","","",""],middle:["\\u251C","\\u2500","\\u253C","\\u2524"],bottom:["","","",""]`),n!==e&&(r++,W(`Patched table border definition for clean format (native Unicode format)`))}else if(P.test(n)){let e=n;n=n.replace(P,`top: ["", "", "", ""],
|
|
415
415
|
middle: ["├", "─", "┼", "┤"],
|
|
416
|
-
bottom: ["", "", "", ""]`),n!==e&&(r++,W(`Patched table border definition for clean format (spaced format)`))}else G(`Could not find table border definition pattern - CLI may have changed`);{let{result:e,success:t}
|
|
416
|
+
bottom: ["", "", "", ""]`),n!==e&&(r++,W(`Patched table border definition for clean format (spaced format)`))}else G(`Could not find table border definition pattern - CLI may have changed`);{let{result:e,success:t}=$t(n);t&&(n=e,r++,W(`Removed inter-row separators`))}{let{result:e,success:t}=en(n);t&&(n=e,r++,W(`Removed top/bottom border pushes`))}}else if(t===`clean-top-bottom`){let{result:e,success:t}=$t(n);t&&(n=e,r++,W(`Removed inter-row separators (keeping top/bottom borders)`))}else return W(`Unknown table format "${t}", skipping`),null;if(r===0)return G(`No table format patches were applied - patterns may not have matched`),null;W(`[Table format patch: ${r} modifications for ${t} style]`);let i=nn(e,n);if(i!==-1){let{oldEnd:t,newEnd:r}=rn(e,n,i),a=n.slice(i,r);F(e,n,a,i,t)}return W(`Table format patch applied: ${r} changes, file size ${e.length} -> ${n.length}`),n};function nn(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return e.length===t.length?-1:n}function rn(e,t,n){let r=e.length-1,i=t.length-1;for(;r>=n&&i>=n&&e[r]===t[i];)r--,i--;return{oldEnd:r+1,newEnd:i+1}}const an=e=>B(e)?At(e,`, {
|
|
417
417
|
type: "local",
|
|
418
418
|
name: "title",
|
|
419
419
|
description: "Set the conversation title",
|
|
@@ -432,7 +432,7 @@ if (toolsets.hasOwnProperty(currentToolset)) {
|
|
|
432
432
|
userFacingName() {
|
|
433
433
|
return "title";
|
|
434
434
|
},
|
|
435
|
-
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),
|
|
435
|
+
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),on=e=>{let t=e.match(/class ([$\w]+)\{summaries;(?:customTitles;)?messages;(?:checkpoints;)?fileHistorySnapshots;/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findCustomNamingFunctionsLocation: failed to find class pattern`),null):t.index},sn=e=>{let t=on(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=nr(e),r=`
|
|
436
436
|
function getTweakccBaseDir() {
|
|
437
437
|
const { join: pathJoin } = ${n}('path');
|
|
438
438
|
const { homedir: osHomedir } = ${n}('os');
|
|
@@ -606,11 +606,11 @@ function onNewMessage(projectDir, projectSlug, msg) {
|
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
-
`,i=e.slice(0,t)+r+e.slice(t);return F(e,i,r,t,t),i},
|
|
609
|
+
`,i=e.slice(0,t)+r+e.slice(t);return F(e,i,r,t,t),i},cn=e=>{let t=e.match(/(if\(![$\w]+\.has\(([$\w]+)\.uuid\)\)\{)if\([$\w]+\.appendFileSync\(/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findAppendEntryInterceptorLocation: failed to find pattern`),null):{location:t.index+t[1].length,messageVar:t[2]}},ln=e=>{let t=cn(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=nr(e),{location:r,messageVar:i}=t,a=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
|
|
610
610
|
const projectDir = pathDirname(this.sessionFile);
|
|
611
611
|
const projectSlug = pathBasename(projectDir);
|
|
612
612
|
onNewMessage(projectDir, projectSlug, ${i});
|
|
613
|
-
`,o=e.slice(0,r)+a+e.slice(r);return F(e,o,a,r,r),o},
|
|
613
|
+
`,o=e.slice(0,r)+a+e.slice(r);return F(e,o,a,r,r),o},un=e=>{let t=e.match(/if\([$\w]+\.has\(([$\w]+)\.uuid\)\)continue;/);if(!t||t.index===void 0)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find continue pattern`),null;let n=t[1],r=t.index+t[0].length-10,i=Math.max(0,t.index-200),a=e.substring(i,t.index).match(/for\(let [$\w]+ of ([$\w]+)\)try/);if(!a)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find loop pattern`),null;let o=a[1];return{orLocation:r,loopLocation:i+(a.index??0),messageVar:n,fileListVar:o}},dn=e=>{let t=un(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=nr(e),{orLocation:r,loopLocation:i,messageVar:a,fileListVar:o}=t,s=e,c=`const { readFileSync: fsReadFileSync } = ${n}('fs');
|
|
614
614
|
const tweakccSummaries = new Set();
|
|
615
615
|
for (const file of ${o}) {
|
|
616
616
|
const contents = fsReadFileSync(file, "utf8").trim();
|
|
@@ -625,7 +625,7 @@ for (const file of ${o}) {
|
|
|
625
625
|
if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
|
|
626
626
|
tweakccSummaries.add(obj.leafUuid);
|
|
627
627
|
}
|
|
628
|
-
`;s=s.slice(0,i)+c+s.slice(i),F(e,s,c,i,i);let l=r+c.length,u=`||tweakccSummaries.has(${a}.uuid)`,d=s.slice(0,l)+u+s.slice(l);return F(s,d,u,l,l),d},
|
|
628
|
+
`;s=s.slice(0,i)+c+s.slice(i),F(e,s,c,i,i);let l=r+c.length,u=`||tweakccSummaries.has(${a}.uuid)`,d=s.slice(0,l)+u+s.slice(l);return F(s,d,u,l,l),d},fn=e=>{let t=e.match(/description:"Rename the current conversation",isEnabled:\(\)=>!1,/);if(!t)return console.error(`patch: conversationTitle: enableRenameConversationCommand: failed to find pattern`),null;if(t.index===void 0)return console.error(`patch: conversationTitle: enableRenameConversationCommand: match.index is undefined`),null;let n=`description:"Rename the current conversation",isEnabled:()=>!0,`,r=e.replace(`description:"Rename the current conversation",isEnabled:()=>!1,`,n);return r===e?(console.error(`patch: conversationTitle: enableRenameConversationCommand: replacement failed`),null):(F(e,r,n,t.index,t.index+63),r)},pn=e=>{let t=e;if(t=an(t),!t)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(t=sn(t),!t)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(t=ln(t),!t)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(t=dn(t),!t)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let n=fn(t);return n?t=n:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),t},mn=e=>{let t=e.match(/,[$\w]+\.createElement\([$\w]+,\{isBeforeFirstMessage:!1\}\),/);return!t||t.index===void 0?(console.error(`patch: hideStartupBanner: failed to find startup banner createElement`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},hn=e=>{let t=mn(e);if(!t)return null;let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return F(e,n,`,`,t.startIndex,t.endIndex),n},gn=e=>{let t=e.match(/if\(([$\w]+&&[$\w]+)\)[$\w]+\("tengu_external_editor_hint_shown",/);if(!t||t.index===void 0)return console.error(`patch: hideCtrlGToEdit: failed to find tengu_external_editor_hint_shown pattern`),null;let n=t[1],r=t.index+3;return{startIndex:r,endIndex:r+n.length,identifiers:[]}},_n=e=>{let t=gn(e);if(!t)return null;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return F(e,r,n,t.startIndex,t.endIndex),r},vn=e=>{let t=[],n=/▛███▜|\\u259B\\u2588\\u2588\\u2588\\u259C/gi,r;for(;(r=n.exec(e))!==null;){let n=r.index,i=Math.max(0,n-2e3),a=e.slice(i,n),o=/function [$\w]+\(\)\{/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(s){let e=i+s.index+s[0].length;t.push(e)}else console.error(`patch: hideStartupClawd: failed to find function pattern before Clawd at position ${n}`)}return t},yn=e=>{let t=vn(e);if(t.length===0)return console.error(`patch: hideStartupClawd: no Clawd components found`),null;let n=[...t].sort((e,t)=>t-e),r=`return null;`,i=e;for(let e of n)i=i.slice(0,e)+r+i.slice(e);if(n.length>0){let t=n[n.length-1];F(e,i,r,t,t)}return i},bn=e=>{let t=e.match(/=25000,([\s\S]{0,100})<system-reminder>/);if(!t||t.index===void 0)return console.error(`patch: increaseFileReadLimit: failed to find 25000 token limit near system-reminder`),null;let n=t.index+1;return{startIndex:n,endIndex:n+5}},xn=e=>{let t=bn(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return F(e,r,n,t.startIndex,t.endIndex),r},Sn=e=>{let t=e.match(/if\(([$\w]+)\.length>=\d+\)return`\$\{\1\}(?:→|\\u2192)\$\{([$\w]+)\}`;return`\$\{\1\.padStart\(\d+," "\)\}(?:→|\\u2192)\$\{\2\}`/);return!t||t.index===void 0?(console.error(`patch: suppressLineNumbers: failed to find line number formatter pattern`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2]]}},Cn=e=>{let t=Sn(e);if(!t)return null;let n=t.identifiers?.[1];if(!n)return console.error(`patch: suppressLineNumbers: content variable not captured`),null;let r=`return ${n}`,i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return F(e,i,r,t.startIndex,t.endIndex),i},wn=e=>{let t=e.match(/\.createElement.{0,500},showAllInTranscript:[$\w]+,agentDefinitions:[$\w]+,onOpenRateLimitOptions:([$\w]+)/);if(!t||t.index===void 0)return console.error(`patch: suppressRateLimitOptions: failed to find onOpenRateLimitOptions pattern`),null;let n=t[1],r=t.index+t[0].length-n.length,i=r+n.length,a=`()=>{}`,o=e.slice(0,r)+a+e.slice(i);return F(e,o,a,r,i),o},Tn=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_session_memory"/);if(!t||t.index===void 0)return console.error(`patch: sessionMemory: failed to find extraction gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return true;`,i=e.slice(0,n)+r+e.slice(n);return F(e,i,r,n,n),i},En=e=>{let t=e.match(/if\([$\w]+\("tengu_coral_fern",!1\)\)\{/);if(t&&t.index!==void 0){let n=`if(true){`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return F(e,r,n,t.index,t.index+t[0].length),r}let n=e.match(/if\(![$\w]+\("tengu_coral_fern",!1\)\)return null;/);if(n&&n.index!==void 0){let t=e.slice(0,n.index)+e.slice(n.index+n[0].length);return F(e,t,``,n.index,n.index+n[0].length),t}return console.error(`patch: sessionMemory: failed to find past sessions gate`),null},Dn=e=>{let t=e.match(/(=)2000((?:.|\n){0,15}?=)12000((?:.|\n){0,20}# Session Title)/);if(!t||t.index===void 0)return console.error(`patch: sessionMemory: failed to find token limits pattern`),null;let n=t[1]+`Number(process.env.CC_SM_PER_SECTION_TOKENS??2000)`+t[2]+`Number(process.env.CM_SM_TOTAL_FILE_LIMIT??12000)`+t[3],r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return F(e,a,n,r,i),a},On=e=>{let t=e;return t=I(t,/minimumMessageTokensToInit:1e4\b/g,`minimumMessageTokensToInit:Number(process.env.CC_SM_MINIMUM_MESSAGE_TOKENS_TO_INIT??1e4)`),t=I(t,/minimumTokensBetweenUpdate:5000\b/g,`minimumTokensBetweenUpdate:Number(process.env.CC_SM_MINIMUM_TOKENS_BETWEEN_UPDATE??5000)`),t=I(t,/toolCallsBetweenUpdates:3\b/g,`toolCallsBetweenUpdates:Number(process.env.CC_SM_TOOL_CALLS_BETWEEN_UPDATES??3)`),t===e?(console.error(`patch: sessionMemory: failed to find update thresholds patterns`),null):t},kn=e=>{let t=Tn(e);return!t||(t=En(t),!t)||(t=Dn(t),!t)?null:(t=On(t),t)},An=e=>{let t=e.match(/\{([$\w]+)\(\{name:"claude-in-chrome"/);return t?t[1]:(console.error(`patch: rememberSkill: failed to find skill registration function`),null)},jn=e=>{let t=An(e);if(!t)return null;let n=e.match(/(function ([$\w]+)\(.{0,500}\}function [$\w]+\(\)\{)return(\}.{0,10}[, ]([$\w]+)=`# Remember Skill)/);if(!n||n.index===void 0)return console.error(`patch: rememberSkill: failed to find injection point pattern`),null;let[r,i,a,o,s]=n,c=i+`
|
|
629
629
|
${t}({
|
|
630
630
|
name: "remember",
|
|
631
631
|
description: "Review session memories and update CLAUDE.local.md with learnings",
|
|
@@ -640,9 +640,9 @@ ${t}({
|
|
|
640
640
|
return [{ type: "text", text: content }];
|
|
641
641
|
},
|
|
642
642
|
});
|
|
643
|
-
return`+o,l=n.index,u=l+r.length,d=e.slice(0,l)+c+e.slice(u);return F(e,d,c,l,u),d},
|
|
643
|
+
return`+o,l=n.index,u=l+r.length,d=e.slice(0,l)+c+e.slice(u);return F(e,d,c,l,u),d},Mn=e=>{let t=V(e);if(!t)return console.error(`patch: thinkingBlockStyling: failed to find Text component`),null;let n=e.match(/\{thinking:([$\w]+)\}.{0,400}(?:∴|\\u2234) Thinking.{0,700}(?:…|\\u2026).{0,200}\b[$\w]+(?:\.default)?\.createElement\(([$\w]+,null),\1\)/);if(!n||n.index===void 0)return console.error(`patch: thinkingBlockStyling: failed to find thinking label pattern`),null;let r=n[0].replace(n[2],`${t},{dimColor:true,italic:true}`),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return F(e,o,r,i,a),o},Nn=e=>{let t=e.match(/![$\w]+\(process\.env\.MCP_CONNECTION_NONBLOCKING\)/);return!t||t.index===void 0?(console.error(`patch: mcpStartup: failed to find MCP_CONNECTION_NONBLOCKING check`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},Pn=e=>{let t=e.match(/MCP_SERVER_CONNECTION_BATCH_SIZE\|\|"",10\)\|\|(\d+)/);if(!t||t.index===void 0)return console.error(`patch: mcpStartup: failed to find MCP_SERVER_CONNECTION_BATCH_SIZE default`),null;let n=t[0],r=t[1],i=n.lastIndexOf(r),a=t.index+i;return{startIndex:a,endIndex:a+r.length}},Fn=e=>{let t=Nn(e);if(!t)return null;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return F(e,r,n,t.startIndex,t.endIndex),r},In=(e,t)=>{let n=Pn(e);if(!n)return null;let r=String(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return F(e,i,r,n.startIndex,n.endIndex),i},Ln=(e,t=300,n=!1)=>{let r=e.match(/(,([$\w]+)=([$\w]+(?:\.default)?)\.useCallback.{0,1000}statusLineText.{0,200}?),([$\w]+)=([$\w.]+\(\(\)=>(\2\(([$\w]+)\)),300\)|[$\w]+\(\2,300\)|.{0,100}\{[$\w]+\.current=void 0,\2\(\)\},300\)\},\[\2\]\))/);if(!r||r.index===void 0)return console.error(`patch: statuslineUpdateThrottle: failed to find statusline update throttle pattern`),null;let i=r[1],a=r[2],o=r[3],s=r[4],c=r[6]??`${a}()`,l=r[7],u=l?`${a}, ${l}`:a,d=a,f;f=n?l?i+`,argRef=${o}.useRef(${l}),unused1=${o}.useEffect(()=>{argRef.current=${l};},[${l}]),unused2=${o}.useEffect(()=>{const id=setInterval(()=>${a}(argRef.current),${t});return()=>clearInterval(id);},[${d}]),${s}=${o}.useCallback(()=>{},[])`:i+`,unused1=${o}.useEffect(()=>{const id=setInterval(()=>${c},${t});return()=>clearInterval(id);},[${d}]),${s}=${o}.useCallback(()=>{},[])`:i+`,lastCall=${o}.useRef(0),${s}=${o}.useCallback(()=>{let now=Date.now();if(now-lastCall.current>=${t}){lastCall.current=now;${c};}},[${u}])`;let p=r.index,m=p+r[0].length,h=e.slice(0,p)+f+e.slice(m);return F(e,h,f,p,m),h},Rn=(e,t)=>{let n,r,i,a,o,s=e.match(/(overrideMessage:.{0,10000},([$\w]+)=[$\w]+\()(.+?)(\),.{0,1000}key:"tokens".{0,200},\2," tokens")/);if(s&&s.index!==void 0)[n,r,,i,a]=s,o=s.index;else{let t=e.match(/(overrideMessage:.{0,10000},key:"tokens".{0,200}[$\w]+\()(Math\.round\(.+?\))(\))/);if(t&&t.index!==void 0)[n,r,i,a]=t,o=t.index;else return console.error(`patch: tokenCountRounding: cannot find token count pattern in either newer or older CC format`),null}let c=`${r}Math.round((${i})/${t})*${t}${a}`,l=o+n.length,u=e.slice(0,o)+c+e.slice(l);return F(e,u,c,o,l),u},zn=(e,t)=>{let n=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)\)(?:.|\n){0,500}Skipping non-text file in @include(?:.|\n){0,500}\{path:[$\w]+,.{0,20}?content:[$\w]+/);if(!n||n.index===void 0)return console.error(`patch: agentsMd: failed to find CLAUDE.md reading function`),null;let r=n[1],i=n[2],a=n[3],o=n.index,s=n[0].match(/([$\w]+(?:\(\))?)\.(?:readFileSync|existsSync|statSync)/);if(!s)return console.error(`patch: agentsMd: failed to find fs expression in function`),null;let c=s[1],l=JSON.stringify(t),u=()=>`if(${i}.endsWith("/CLAUDE.md")||${i}.endsWith("\\\\CLAUDE.md")){for(let alt of ${l}){let altPath=${i}.slice(0,-9)+alt;if(${c}.existsSync(altPath)&&${c}.statSync(altPath).isFile())return ${r}(altPath,${a});}}return null;`,d=e.slice(o).match(/(if\(![$\w]+\.existsSync\([$\w]+\)\|\|![$\w]+\.statSync\([$\w]+\)\.isFile\(\)\))return null;/);if(d&&d.index!==void 0){let t=u(),n=d[1]+`{`+t+`}`,r=o+d.index,i=r+d[0].length,a=e.slice(0,r)+n+e.slice(i);return F(e,a,n,r,i),a}let f=e.slice(o).match(/(\})(}catch)/);if(f&&f.index!==void 0){let t=`else if(${i}.endsWith("/CLAUDE.md")||${i}.endsWith("\\\\CLAUDE.md")){for(let alt of ${l}){let altPath=${i}.slice(0,-9)+alt;if(${c}.existsSync(altPath)&&${c}.statSync(altPath).isFile())return ${r}(altPath,${a});}}`,n=f[1]+t+f[2],s=o+f.index,u=s+f[0].length,d=e.slice(0,s)+n+e.slice(u);return F(e,d,n,s,u),d}return console.error(`patch: agentsMd: failed to find insertion point in function body`),null},Bn=e=>{let t=e.indexOf(`title:"Ready to code?"`);if(t===-1)return console.error(`patch: autoAcceptPlanMode: failed to find "Ready to code?" title`),null;let n=e.slice(t,t+3e3).match(/onChange:\([$\w]+\)=>([$\w]+)\([$\w]+\),onCancel/);if(!n)return console.error(`patch: autoAcceptPlanMode: failed to find onChange handler`),null;let r=n[1];if(RegExp(`[$\\w]+\\("yes-accept-edits"\\);return null;return`).test(e))return e;let i=e.match(/(\}\}\)\)\)\);)(return [$\w]+\.default\.createElement\([$\w]+\.default\.Fragment,null,[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:"Ready to code\?")/);if(!i||i.index===void 0)return console.error(`patch: autoAcceptPlanMode: failed to find "Ready to code?" return pattern`),null;let a=`${r}("yes-accept-edits");return null;`,o=i[1]+a+i[2],s=i.index,c=s+i[0].length,l=e.slice(0,s)+o+e.slice(c);return F(e,l,o,s,c),l},Vn=e=>{let t=e.match(/console\.error\("--dangerously-skip-permissions cannot be used with root\/sudo privileges for security reasons"\),process\.exit\(1\)/);if(!t||t.index===void 0)return console.error(`patch: allowBypassPermsInSudo: failed to find pattern`),null;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+`{}`+e.slice(r);return F(e,i,`{}`,n,r),i},Hn=e=>{let t=e.match(/Claude Code has switched from npm to native installer\. Run `claude install` or see https:\/\/docs\.anthropic\.com\/en\/docs\/claude-code\/getting-started for more options\./);if(!t||t.index===void 0)return console.warn(`patch: suppressNativeInstallerWarning: failed to find pattern`),null;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+e.slice(r);return F(e,i,``,n,r),i},Un=e=>{let t=e.split(`
|
|
644
644
|
`),n=0;for(let e=0;e<t.length;e++){let r=t[e];if(!r.startsWith(`#!`)&&!(r.startsWith(`//`)&&(r.includes(`Version`)||r.includes(`(c)`)))&&!(r.trim()===``&&e<5)){n=e;break}}return n>0?t.slice(0,n).join(`
|
|
645
|
-
`).length:0},
|
|
645
|
+
`).length:0},Wn=e=>{let t=Un(e),n=`// SCROLLING FIX PATCH START
|
|
646
646
|
const _origStdoutWrite=process.stdout.write;
|
|
647
647
|
process.stdout.write=function(chunk,encoding,cb){
|
|
648
648
|
if(typeof chunk!=='string'){
|
|
@@ -654,7 +654,7 @@ const filtered=chunk
|
|
|
654
654
|
return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
|
|
655
655
|
};
|
|
656
656
|
// SCROLLING FIX PATCH END
|
|
657
|
-
`,r=e.slice(0,t)+n+e.slice(t);return F(e,r,n,t,t),r},
|
|
657
|
+
`,r=e.slice(0,t)+n+e.slice(t);return F(e,r,n,t,t),r},Gn=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return 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 F(e,i,r,n,n),i},Kn=async e=>{if(!e.cliPath){W(`backupClijs: Skipping for native installation (no cliPath)`);return}await Z(),W(`Backing up cli.js to ${Br}`),await i.copyFile(e.cliPath,Br),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version})},qn=async e=>{e.nativeInstallationPath&&(await Z(),W(`Backing up native binary to ${Y}`),await i.copyFile(e.nativeInstallationPath,Y),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},Jn=async e=>{if(!e.cliPath)return W(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;W(`Restoring cli.js from backup to ${e.cliPath}`);let t=await i.readFile(Br);return await jr(e.cliPath,t,`restore`),await Qe(),await $(e=>{e.changesApplied=!1}),!0},Yn=async e=>{if(!e.nativeInstallationPath)return W(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await Mr(Y))return W(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;W(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await i.readFile(Y);return await jr(e.nativeInstallationPath,t,`restore`),!0},Xn=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16))),F=(t,n,r,i,a,o=40)=>{if(!_r())return;let s=Math.max(0,i-o),c=Math.min(t.length,a+o),l=Math.min(n.length,i+r.length+o),u=t.slice(s,c),d=n.slice(s,l),f=Xn(u),p=Xn(d);if(f===p){vr()&&(G(`
|
|
658
658
|
--- Diff ---`),G(e.blue(`UNCHANGED: `)+e.dim(f)),G(`--- End Diff ---
|
|
659
659
|
`));return}let m=h(f,p),g=0,_=0,v=-1,y=-1,b=-1,x=-1,S=0,C=0;for(let e of m)e.added?(b===-1&&(b=_,v=g),x=_+e.value.length,y=g,S=g,C=_+e.value.length,_+=e.value.length):e.removed?(v===-1&&(v=g,b=_),y=g+e.value.length,x=_,S=g+e.value.length,C=_,g+=e.value.length):(g+=e.value.length,_+=e.value.length);v===-1&&(v=0),b===-1&&(b=0),y===-1&&(y=f.length),x===-1&&(x=p.length);let w=f.length-S,ee=p.length-C,te=Math.min(w,ee,o),ne=Math.max(0,v-o),re=Math.min(f.length,S+te),ie=Math.max(0,b-o),ae=Math.min(p.length,C+te),oe=h(f.slice(ne,re),p.slice(ie,ae)),T=``;for(let t of oe)if(!t.added)if(t.removed)if(t.value.includes(`
|
|
660
660
|
`)){let n=t.value.split(`
|
|
@@ -664,6 +664,6 @@ return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
|
|
|
664
664
|
`);n.forEach((t,r)=>{t&&(E+=e.bgGreen.black(t)),r<n.length-1&&(E+=e.bgGreen.dim(`\\n`)+`
|
|
665
665
|
`)})}else E+=e.bgGreen.black(t.value);else t.removed||(E+=e.dim(t.value));G(`
|
|
666
666
|
--- Diff ---`),G(e.red(`OLD: `)+T),G(e.green(`NEW: `)+E),G(`--- End Diff ---
|
|
667
|
-
`)},I=(e,t,n)=>{let r=[],i=t.global?t:new RegExp(t.source,t.flags+`g`),a;for(;(a=i.exec(e))!==null;)r.push({index:a.index,length:a[0].length});let o=new RegExp(t.source,t.flags.replace(`g`,``)),s=e;for(let e=r.length-1;e>=0;e--){let{index:t,length:i}=r[e],a=s,c=s.slice(t,t+i).replace(o,n);s=s.slice(0,t)+c+s.slice(t+i),F(a,s,c,t,t+i)}return s},L=e=>{let t=Array.from(e.matchAll(/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},Qn=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(n)return n[1];console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},$n=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]},er=e=>{let t=$n(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=${U(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 R=null,z=null;const B=e=>{if(R!=null)return R;let t=Qn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),R=void 0;return}let n=$n(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),R=void 0;return}let r=RegExp(`\\b([$\\w]+)=${U(t)}\\(${U(n)}\\(\\),1\\)`),i=e.match(r);if(i)return R=i[1],R;let a=er(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),R=void 0;return}let o=RegExp(`\\b([$\\w]+)=${U(t)}\\(${U(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),R=void 0;return}return R=s[1],R},tr=()=>{R=null},nr=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${U(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]},rr=e=>{if(z!=null)return z;let t=nr(e);return t?(z=t,z):(z=`require`,z)},ir=()=>{z=null},ar=()=>{tr(),ir()},V=e=>{let t=e.match(/\bfunction ([$\w]+).{0,20}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]},or=e=>{let t=e.match(/function ([$\w]+)\(.{0,2000}\b([$\w]+)=[$\w]+(?:\.default)?\.createElement\("ink-box".{0,200}?return \2/);if(t)return t[1];let n=e.match(/function ([$\w]+)\(\{children:[$\w]+,flexWrap:[$\w]+.{0,2000}?\.createElement\("ink-box"/);if(n)return n[1];let r=e.match(/\b([$\w]+)\.displayName="Box"/);if(r)return r[1];console.error(`patch: findBoxComponent: failed to find Box component (neither ink-box createElement nor displayName found)`)};let H=function(e){return e.SYSTEM_PROMPTS=`System Prompts`,e.ALWAYS_APPLIED=`Always Applied`,e.MISC_CONFIGURABLE=`Misc Configurable`,e.FEATURES=`Features`,e}({});const sr=[{id:`verbose-property`,name:`Verbose property`,group:H.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{id:`context-limit`,name:`Context limit`,group:H.ALWAYS_APPLIED,description:`Set the CLAUDE_CODE_CONTEXT_LIMIT env var to change 200k max for custom models`},{id:`model-customizations`,name:`Model customizations`,group:H.ALWAYS_APPLIED,description:`Access all Claude models with /model, not just latest 3`},{id:`opusplan1m`,name:`Opusplan[1m] support`,group:H.ALWAYS_APPLIED,description:`Use the "Opus Plan 1M" model: Opus for planning, Sonnet 1M context for building`},{id:`show-more-items-in-select-menus`,name:`Show more items in select menus`,group:H.ALWAYS_APPLIED,description:`Show 25 items in select menus instead of default 5`},{id:`thinking-block-styling`,name:`Thinking block styling`,group:H.ALWAYS_APPLIED,description:`Restore dim/gray + italic styling for thinking blocks`},{id:`fix-lsp-support`,name:`Fix LSP support`,group:H.ALWAYS_APPLIED,description:`Enable/fix nascent LSP support`},{id:`statusline-update-throttle`,name:`Statusline update throttling correction`,group:H.ALWAYS_APPLIED,description:`Statusline updates will be properly throttled instead of queued (or debounced)`},{id:`patches-applied-indication`,name:`Patches applied indication`,group:H.MISC_CONFIGURABLE,description:`Show "tweakcc patches applied" and tweakcc version inside CC`},{id:`table-format`,name:`Table format`,group:H.MISC_CONFIGURABLE,description:`Tables generated by Claude will be rendered more compactly`},{id:`themes`,name:`Themes`,group:H.MISC_CONFIGURABLE,description:`Your custom themes will be available via /theme`},{id:`thinking-verbs`,name:`Thinking verbs`,group:H.MISC_CONFIGURABLE,description:`Your custom list of thinking verbs will be cycled through`},{id:`thinker-format`,name:`Thinker format`,group:H.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:H.MISC_CONFIGURABLE,description:`Your custom thinking spinner will be rendered`},{id:`thinker-symbol-speed`,name:`Thinker symbol speed`,group:H.MISC_CONFIGURABLE,description:`The thinking spinner will play at a custom FPS`},{id:`thinker-symbol-width`,name:`Thinker symbol width`,group:H.MISC_CONFIGURABLE,description:`The thinking spinner will be in a box of custom width`},{id:`thinker-symbol-mirror`,name:`Thinker symbol mirror`,group:H.MISC_CONFIGURABLE,description:`The thinking spinner will reverse or restart when it finishes`},{id:`input-box-border`,name:`Input box border`,group:H.MISC_CONFIGURABLE,description:`Your custom styles to the main input box's border will be applied`},{id:`subagent-models`,name:`Subagent models`,group:H.MISC_CONFIGURABLE,description:`Use custom models for Plan, Explore, and General subagents`},{id:`thinking-visibility`,name:`Thinking block visibility`,group:H.MISC_CONFIGURABLE,description:`Thinking blocks outputted by the model will show without Ctrl+O`},{id:`hide-startup-banner`,name:`Hide startup banner`,group:H.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:H.MISC_CONFIGURABLE,description:`Note about using Ctrl+G to edit prompt will be hidden`},{id:`hide-startup-clawd`,name:`Hide startup Clawd`,group:H.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:H.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:H.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:H.MISC_CONFIGURABLE,description:`/rate-limit-options won't be injected when limits are reached`},{id:`token-count-rounding`,name:`Token count rounding`,group:H.MISC_CONFIGURABLE,description:`Round displayed token counts to the nearest multiple of chosen value`},{id:`remember-skill`,name:`Remember skill`,group:H.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:H.MISC_CONFIGURABLE,description:`Support AGENTS.md and others in addition to CLAUDE.md`},{id:`auto-accept-plan-mode`,name:`Auto-accept plan mode`,group:H.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:H.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:H.MISC_CONFIGURABLE,description:`Suppress the native installer warning message at startup`},{id:`filter-scroll-escape-sequences`,name:`Filter scroll escape sequences`,group:H.MISC_CONFIGURABLE,description:`Filter out terminal escape sequences that cause unwanted scrolling`},{id:`swarm-mode`,name:`Swarm mode`,group:H.FEATURES,description:`Enable SWARM MODE in Claude Code`},{id:`session-memory`,name:`Session memory`,group:H.FEATURES,description:`Enable session memory (auto-extraction + past session search)`},{id:`toolsets`,name:`Toolsets`,group:H.FEATURES,description:`Custom toolsets will be registered`},{id:`mcp-non-blocking`,name:`MCP non-blocking`,group:H.FEATURES,description:`If you have MCP servers, CC startup will be much faster`},{id:`mcp-batch-size`,name:`MCP batch size`,group:H.FEATURES,description:`Change the number of MCP servers started in parallel`},{id:`user-message-display`,name:`User message display`,group:H.FEATURES,description:`User messages in the chat history will be styled`},{id:`input-pattern-highlighters`,name:`Input pattern highlighters`,group:H.FEATURES,description:`Custom input highlighters will be registered`},{id:`conversation-title`,name:`Conversation title`,group:H.FEATURES,description:`/title command will be created & enabled`}],cr=()=>[...sr],U=e=>e.replace(/\$/g,`\\$`),lr=(e,t,n)=>{let r=[];for(let i of sr){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}W(`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}},ur=async(e,t,n)=>{let i;if(t.nativeInstallationPath){await Xn(t);let e=!1;try{await r.stat(Y),e=!0}catch{}let n=e?Y:t.nativeInstallationPath;W(`Extracting claude.js from ${e?`backup`:`native installation`}: ${n}`);let o=await v(n);if(!o)throw Error(`Failed to extract claude.js from native installation`);let c=s.join(q,`native-claudejs-orig.js`);a.writeFileSync(c,o),W(`Saved original extracted JS from native to: ${c}`),i=o.toString(`utf8`)}else{if(await Yn(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);i=await r.readFile(t.cliPath,{encoding:`utf8`})}let o=[],c=await Dt(i,t.version,void 0,n);i=c.newContent;let l=[...c.results].sort((e,t)=>e.name.localeCompare(t.name));o.push(...l);let u=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),d=l.filter(e=>e.applied&&e.details).map(e=>u(`${e.name}: ${e.details}`)),f=e.settings.misc?.tableFormat??`default`,p=e.settings.misc?.showTweakccVersion??!0,m=e.settings.misc?.showPatchesApplied??!0,h={"verbose-property":{fn:e=>Se(e)},"context-limit":{fn:e=>ie(e)},"model-customizations":{fn:e=>pr(e)},opusplan1m:{fn:e=>ke(e)},"show-more-items-in-select-menus":{fn:e=>ee(e,25)},"thinking-block-styling":{fn:e=>Pn(e),condition:t.version==null||O(t.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>kt(e)},"statusline-update-throttle":{fn:t=>zn(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"patches-applied-indication":{fn:e=>Be(e,`4.0.3`,d,p,m)},"table-format":{fn:e=>nn(e,f),condition:f!==`default`},themes:{fn:t=>ne(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(b.themes))},"thinking-verbs":{fn:t=>he(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs},"thinker-format":{fn:t=>E(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs},"thinker-symbol-chars":{fn:t=>le(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(b.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>ue(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==b.thinkingStyle.updateInterval&&(t.version==null||O(t.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>fe(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(b.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>ce(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==b.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>oe(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`)},"subagent-models":{fn:t=>Pe(t,e.settings.subagentModels),condition:!!e.settings.subagentModels},"thinking-visibility":{fn:e=>Ae(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>gn(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>vn(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>bn(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>Sn(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>wn(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>Tn(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>Bn(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>Nn(e),condition:!!e.settings.misc?.enableRememberSkill&&!!t.version&&O(t.version,`2.1.42`)<0},"agents-md":{fn:t=>Vn(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Hn(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Un(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Wn(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>Kn(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"swarm-mode":{fn:e=>En(e),condition:!!e.settings.misc?.enableSwarmMode},"session-memory":{fn:e=>jn(e),condition:!!e.settings.misc?.enableSessionMemory},toolsets:{fn:t=>qt(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Ln(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking},"mcp-batch-size":{fn:t=>Rn(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>ge(t,e.settings.userMessageDisplay),condition:!!e.settings.userMessageDisplay},"input-pattern-highlighters":{fn:t=>be(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>mn(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!!(t.version&&O(t.version,`2.0.64`)<0)}},{content:g,results:_}=lr(i,h,n);if(i=g,o.push(..._),t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=s.join(q,`native-claudejs-patched.js`);a.writeFileSync(e,i,`utf8`),W(`Saved patched JS from native to: ${e}`);let n=Buffer.from(i,`utf8`);await y(t.nativeInstallationPath,n,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await Mr(t.cliPath,i,`patch`)}return{config:await $(e=>{e.changesApplied=!0}),results:o}},dr=[{value:`claude-opus-4-6`,label:`Opus 4.6`,description:`Claude Opus 4.6 (February 2026)`},{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)`}],fr=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-600),i=e.slice(r,t.index),a=RegExp(`function [$\\w]+\\([^)]*\\)\\{let ${U(n)}=.+?;`,`g`),o=null,s;for(;(s=a.exec(i))!==null;)o=s;return o?{insertionIndex:r+o.index+o[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${n}`),null)},pr=e=>{let t=fr(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=dr.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return F(e,a,i,n,n),a};let mr=!1,hr=!1,gr=!1;const _r=()=>mr,vr=()=>hr,yr=()=>gr,br=()=>{mr=!0},xr=()=>{hr=!0,mr=!0},Sr=()=>{gr=!0},W=(e,...t)=>{_r()&&console.log(e,...t)},G=(e,...t)=>{vr()&&console.log(e,...t)};function Cr(){try{let e=u.join(d.homedir(),`.claude.json`);return JSON.parse(l.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function wr(e){try{let t=u.join(d.homedir(),`.claude.json`),n=JSON.parse(l.readFileSync(t,`utf8`));n.theme=e,l.writeFileSync(t,JSON.stringify(n,null,2))}catch{}}function Tr(){try{let e=u.join(d.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(l.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 Er(){try{let e=u.join(d.homedir(),`.claude`,`settings.json`),t=JSON.parse(l.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=dr.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Dr(e){process.platform===`win32`?f.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?f.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():f.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function Or(e){if(process.platform===`win32`)f.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)f.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=u.dirname(e);f.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function kr(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 Ar(e){if(!kr(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 jr(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=p.createHash(t),o=l.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 Mr(e,t,n=`replace`){let r=493;try{r=(await i.stat(e)).mode,W(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){W(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await i.unlink(e),W(`[${n}] Unlinked ${e} to break hard links`)}catch(t){W(`[${n}] Could not unlink ${e}: ${t}`)}await i.writeFile(e,t),await i.chmod(e,r),W(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function Nr(e){try{return await i.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 Pr=e=>e.startsWith(`~`)?u.join(d.homedir(),e.slice(1)):e,Fr=(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]},Ir=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function K(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]=K(n[e],r)):n[e]=r}return n}const Lr=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)},Rr=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function zr(){try{let e=await i.readFile(J,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=c.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await Z(),await i.writeFile(J,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const Br=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return Pr(e);let n=c.join(t.homedir(),`.tweakcc`),r=c.join(t.homedir(),`.claude`,`tweakcc`),i=process.env.XDG_CONFIG_HOME;try{if(o.existsSync(n))return n}catch(e){W(`Failed to check if ${n} exists: ${e}`)}try{if(o.existsSync(r))return r}catch(e){W(`Failed to check if ${r} exists: ${e}`)}return i?c.join(i,`tweakcc`):n},q=Br(),J=c.join(q,`config.json`),Vr=c.join(q,`cli.js.backup`),Y=c.join(q,`native-binary.backup`),X=c.join(q,`system-prompts`),Hr=c.join(q,`prompt-data-cache`),Ur=()=>{let n=q,r=t.homedir(),i=[c.join(r,`.tweakcc`),c.join(r,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?c.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(e=>{try{return o.existsSync(e)&&e!==n}catch{return!1}});i.length>0&&(console.warn(e.yellow(`
|
|
667
|
+
`)},I=(e,t,n)=>{let r=[],i=t.global?t:new RegExp(t.source,t.flags+`g`),a;for(;(a=i.exec(e))!==null;)r.push({index:a.index,length:a[0].length});let o=new RegExp(t.source,t.flags.replace(`g`,``)),s=e;for(let e=r.length-1;e>=0;e--){let{index:t,length:i}=r[e],a=s,c=s.slice(t,t+i).replace(o,n);s=s.slice(0,t)+c+s.slice(t+i),F(a,s,c,t,t+i)}return s},L=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},Zn=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(n)return n[1];console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},Qn=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]},$n=e=>{let t=Qn(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=${U(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 R=null,z=null;const B=e=>{if(R!=null)return R;let t=Zn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),R=void 0;return}let n=Qn(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),R=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${U(t)}\\(${U(n)}\\(\\),1\\)`),i=e.match(r);if(i)return R=i[1],R;let a=$n(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),R=void 0;return}let o=RegExp(`[^$\\w]([$\\w]+)=${U(t)}\\(${U(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),R=void 0;return}return R=s[1],R},er=()=>{R=null},tr=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${U(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]},nr=e=>{if(z!=null)return z;let t=tr(e);return t?(z=t,z):(z=`require`,z)},rr=()=>{z=null},ir=()=>{er(),rr()},V=e=>{let t=e.match(/\bfunction ([$\w]+).{0,20}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]},ar=e=>{let t=e.match(/function ([$\w]+)\(.{0,2000}[^$\w]([$\w]+)=[$\w]+(?:\.default)?\.createElement\("ink-box".{0,200}?return \2/);if(t)return t[1];let n=e.match(/function ([$\w]+)\(\{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];console.error(`patch: findBoxComponent: failed to find Box component (neither ink-box createElement nor displayName found)`)};let H=function(e){return e.SYSTEM_PROMPTS=`System Prompts`,e.ALWAYS_APPLIED=`Always Applied`,e.MISC_CONFIGURABLE=`Misc Configurable`,e.FEATURES=`Features`,e}({});const or=[{id:`verbose-property`,name:`Verbose property`,group:H.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{id:`context-limit`,name:`Context limit`,group:H.ALWAYS_APPLIED,description:`Set the CLAUDE_CODE_CONTEXT_LIMIT env var to change 200k max for custom models`},{id:`model-customizations`,name:`Model customizations`,group:H.ALWAYS_APPLIED,description:`Access all Claude models with /model, not just latest 3`},{id:`opusplan1m`,name:`Opusplan[1m] support`,group:H.ALWAYS_APPLIED,description:`Use the "Opus Plan 1M" model: Opus for planning, Sonnet 1M context for building`},{id:`show-more-items-in-select-menus`,name:`Show more items in select menus`,group:H.ALWAYS_APPLIED,description:`Show 25 items in select menus instead of default 5`},{id:`thinking-block-styling`,name:`Thinking block styling`,group:H.ALWAYS_APPLIED,description:`Restore dim/gray + italic styling for thinking blocks`},{id:`fix-lsp-support`,name:`Fix LSP support`,group:H.ALWAYS_APPLIED,description:`Enable/fix nascent LSP support`},{id:`statusline-update-throttle`,name:`Statusline update throttling correction`,group:H.ALWAYS_APPLIED,description:`Statusline updates will be properly throttled instead of queued (or debounced)`},{id:`patches-applied-indication`,name:`Patches applied indication`,group:H.MISC_CONFIGURABLE,description:`Show "tweakcc patches applied" and tweakcc version inside CC`},{id:`table-format`,name:`Table format`,group:H.MISC_CONFIGURABLE,description:`Tables generated by Claude will be rendered more compactly`},{id:`themes`,name:`Themes`,group:H.MISC_CONFIGURABLE,description:`Your custom themes will be available via /theme`},{id:`thinking-verbs`,name:`Thinking verbs`,group:H.MISC_CONFIGURABLE,description:`Your custom list of thinking verbs will be cycled through`},{id:`thinker-format`,name:`Thinker format`,group:H.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:H.MISC_CONFIGURABLE,description:`Your custom thinking spinner will be rendered`},{id:`thinker-symbol-speed`,name:`Thinker symbol speed`,group:H.MISC_CONFIGURABLE,description:`The thinking spinner will play at a custom FPS`},{id:`thinker-symbol-width`,name:`Thinker symbol width`,group:H.MISC_CONFIGURABLE,description:`The thinking spinner will be in a box of custom width`},{id:`thinker-symbol-mirror`,name:`Thinker symbol mirror`,group:H.MISC_CONFIGURABLE,description:`The thinking spinner will reverse or restart when it finishes`},{id:`input-box-border`,name:`Input box border`,group:H.MISC_CONFIGURABLE,description:`Your custom styles to the main input box's border will be applied`},{id:`subagent-models`,name:`Subagent models`,group:H.MISC_CONFIGURABLE,description:`Use custom models for Plan, Explore, and General subagents`},{id:`thinking-visibility`,name:`Thinking block visibility`,group:H.MISC_CONFIGURABLE,description:`Thinking blocks outputted by the model will show without Ctrl+O`},{id:`hide-startup-banner`,name:`Hide startup banner`,group:H.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:H.MISC_CONFIGURABLE,description:`Note about using Ctrl+G to edit prompt will be hidden`},{id:`hide-startup-clawd`,name:`Hide startup Clawd`,group:H.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:H.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:H.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:H.MISC_CONFIGURABLE,description:`/rate-limit-options won't be injected when limits are reached`},{id:`token-count-rounding`,name:`Token count rounding`,group:H.MISC_CONFIGURABLE,description:`Round displayed token counts to the nearest multiple of chosen value`},{id:`remember-skill`,name:`Remember skill`,group:H.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:H.MISC_CONFIGURABLE,description:`Support AGENTS.md and others in addition to CLAUDE.md`},{id:`auto-accept-plan-mode`,name:`Auto-accept plan mode`,group:H.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:H.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:H.MISC_CONFIGURABLE,description:`Suppress the native installer warning message at startup`},{id:`filter-scroll-escape-sequences`,name:`Filter scroll escape sequences`,group:H.MISC_CONFIGURABLE,description:`Filter out terminal escape sequences that cause unwanted scrolling`},{id:`worktree-mode`,name:`Worktree mode`,group:H.FEATURES,description:`Enable the EnterWorktree tool for isolated git worktree sessions`},{id:`session-memory`,name:`Session memory`,group:H.FEATURES,description:`Enable session memory (auto-extraction + past session search)`},{id:`toolsets`,name:`Toolsets`,group:H.FEATURES,description:`Custom toolsets will be registered`},{id:`mcp-non-blocking`,name:`MCP non-blocking`,group:H.FEATURES,description:`If you have MCP servers, CC startup will be much faster`},{id:`mcp-batch-size`,name:`MCP batch size`,group:H.FEATURES,description:`Change the number of MCP servers started in parallel`},{id:`user-message-display`,name:`User message display`,group:H.FEATURES,description:`User messages in the chat history will be styled`},{id:`input-pattern-highlighters`,name:`Input pattern highlighters`,group:H.FEATURES,description:`Custom input highlighters will be registered`},{id:`conversation-title`,name:`Conversation title`,group:H.FEATURES,description:`/title command will be created & enabled`}],sr=()=>[...or],U=e=>e.replace(/\$/g,`\\$`),cr=(e,t,n)=>{let r=[];for(let i of or){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}W(`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}},lr=async(e,t,n)=>{let i;if(t.nativeInstallationPath){await Yn(t);let e=!1;try{await r.stat(Y),e=!0}catch{}let n=e?Y:t.nativeInstallationPath;W(`Extracting claude.js from ${e?`backup`:`native installation`}: ${n}`);let o=await v(n);if(!o)throw Error(`Failed to extract claude.js from native installation`);let c=s.join(q,`native-claudejs-orig.js`);a.writeFileSync(c,o),W(`Saved original extracted JS from native to: ${c}`),i=o.toString(`utf8`)}else{if(await Jn(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);i=await r.readFile(t.cliPath,{encoding:`utf8`})}let o=[],c=await Et(i,t.version,void 0,n);i=c.newContent;let l=[...c.results].sort((e,t)=>e.name.localeCompare(t.name));o.push(...l);let u=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),d=l.filter(e=>e.applied&&e.details).map(e=>u(`${e.name}: ${e.details}`)),f=e.settings.misc?.tableFormat??`default`,p=e.settings.misc?.showTweakccVersion??!0,m=e.settings.misc?.showPatchesApplied??!0,h={"verbose-property":{fn:e=>xe(e)},"context-limit":{fn:e=>re(e)},"model-customizations":{fn:e=>fr(e)},opusplan1m:{fn:e=>Oe(e)},"show-more-items-in-select-menus":{fn:e=>ee(e,25)},"thinking-block-styling":{fn:e=>Mn(e),condition:t.version==null||O(t.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>Ot(e)},"statusline-update-throttle":{fn:t=>Ln(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"patches-applied-indication":{fn:e=>ze(e,`4.0.6`,d,p,m)},"table-format":{fn:e=>tn(e,f),condition:f!==`default`},themes:{fn:t=>ne(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(b.themes))},"thinking-verbs":{fn:t=>me(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs},"thinker-format":{fn:t=>T(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs},"thinker-symbol-chars":{fn:t=>ce(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(b.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>le(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==b.thinkingStyle.updateInterval&&(t.version==null||O(t.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>de(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(b.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>se(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==b.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>ae(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`)},"subagent-models":{fn:t=>Ne(t,e.settings.subagentModels),condition:!!e.settings.subagentModels},"thinking-visibility":{fn:e=>ke(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>hn(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>_n(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>yn(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>xn(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>Cn(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>wn(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>Rn(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>jn(e),condition:!!e.settings.misc?.enableRememberSkill&&!!t.version&&O(t.version,`2.1.42`)<0},"agents-md":{fn:t=>zn(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Bn(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Vn(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Hn(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>Wn(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"worktree-mode":{fn:e=>Gn(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>kn(e),condition:!!e.settings.misc?.enableSessionMemory},toolsets:{fn:t=>Kt(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Fn(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking},"mcp-batch-size":{fn:t=>In(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>he(t,e.settings.userMessageDisplay),condition:!!e.settings.userMessageDisplay},"input-pattern-highlighters":{fn:t=>ye(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>pn(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!!(t.version&&O(t.version,`2.0.64`)<0)}},{content:g,results:_}=cr(i,h,n);if(i=g,o.push(..._),t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=s.join(q,`native-claudejs-patched.js`);a.writeFileSync(e,i,`utf8`),W(`Saved patched JS from native to: ${e}`);let n=Buffer.from(i,`utf8`);await y(t.nativeInstallationPath,n,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await jr(t.cliPath,i,`patch`)}return{config:await $(e=>{e.changesApplied=!0}),results:o}},ur=[{value:`claude-opus-4-6`,label:`Opus 4.6`,description:`Claude Opus 4.6 (February 2026)`},{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)`}],dr=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-600),i=e.slice(r,t.index),a=RegExp(`function [$\\w]+\\([^)]*\\)\\{let ${U(n)}=.+?;`,`g`),o=null,s;for(;(s=a.exec(i))!==null;)o=s;return o?{insertionIndex:r+o.index+o[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${n}`),null)},fr=e=>{let t=dr(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=ur.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return F(e,a,i,n,n),a};let pr=!1,mr=!1,hr=!1;const gr=()=>pr,_r=()=>mr,vr=()=>hr,yr=()=>{pr=!0},br=()=>{mr=!0,pr=!0},xr=()=>{hr=!0},W=(e,...t)=>{gr()&&console.log(e,...t)},G=(e,...t)=>{_r()&&console.log(e,...t)};function Sr(){try{let e=u.join(d.homedir(),`.claude.json`);return JSON.parse(l.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Cr(e){try{let t=u.join(d.homedir(),`.claude.json`),n=JSON.parse(l.readFileSync(t,`utf8`));n.theme=e,l.writeFileSync(t,JSON.stringify(n,null,2))}catch{}}function wr(){try{let e=u.join(d.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(l.readFileSync(e,`utf8`))?.claudeAiOauth?.subscriptionType||`unknown`){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`}}catch{}return`Claude API`}function Tr(){try{let e=u.join(d.homedir(),`.claude`,`settings.json`),t=JSON.parse(l.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=ur.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Er(e){process.platform===`win32`?f.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?f.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():f.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function Dr(e){if(process.platform===`win32`)f.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)f.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=u.dirname(e);f.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function Or(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 kr(e){if(!Or(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 Ar(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=p.createHash(t),o=l.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 jr(e,t,n=`replace`){let r=493;try{r=(await i.stat(e)).mode,W(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){W(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await i.unlink(e),W(`[${n}] Unlinked ${e} to break hard links`)}catch(t){W(`[${n}] Could not unlink ${e}: ${t}`)}await i.writeFile(e,t),await i.chmod(e,r),W(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function Mr(e){try{return await i.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 Nr=e=>e.startsWith(`~`)?u.join(d.homedir(),e.slice(1)):e,Pr=(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]},Fr=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function K(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]=K(n[e],r)):n[e]=r}return n}const Ir=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)},Lr=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function Rr(){try{let e=await i.readFile(J,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=c.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await Z(),await i.writeFile(J,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const zr=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return Nr(e);let n=c.join(t.homedir(),`.tweakcc`),r=c.join(t.homedir(),`.claude`,`tweakcc`),i=process.env.XDG_CONFIG_HOME;try{if(o.existsSync(n))return n}catch(e){W(`Failed to check if ${n} exists: ${e}`)}try{if(o.existsSync(r))return r}catch(e){W(`Failed to check if ${r} exists: ${e}`)}return i?c.join(i,`tweakcc`):n},q=zr(),J=c.join(q,`config.json`),Br=c.join(q,`cli.js.backup`),Y=c.join(q,`native-binary.backup`),X=c.join(q,`system-prompts`),Vr=c.join(q,`prompt-data-cache`),Hr=()=>{let n=q,r=t.homedir(),i=[c.join(r,`.tweakcc`),c.join(r,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?c.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(e=>{try{return o.existsSync(e)&&e!==n}catch{return!1}});i.length>0&&(console.warn(e.yellow(`
|
|
668
668
|
Multiple configuration locations detected:`)),console.warn(e.gray(` Active: ${n}`)),console.warn(e.gray(` Other existing locations:`)),i.forEach(t=>{console.warn(e.gray(` - ${t}`))}),console.warn(e.gray(` Only the active location is used. To switch locations,`)),console.warn(e.gray(` move your config.json to the desired directory.
|
|
669
|
-
`)))},Z=async()=>{await i.mkdir(q,{recursive:!0}),await i.mkdir(X,{recursive:!0});let e=c.join(q,`.gitignore`);try{await i.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await i.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(n)+n)}};let Q=null;const
|
|
669
|
+
`)))},Z=async()=>{await i.mkdir(q,{recursive:!0}),await i.mkdir(X,{recursive:!0});let e=c.join(q,`.gitignore`);try{await i.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await i.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(n)+n)}};let Q=null;const Ur=()=>({ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:b}),Wr=e=>{let t=e?.settings?.thinkingVerbs;t?.punctuation&&(t.format=`{}`+t.punctuation,delete t.punctuation),e.settings=K(e.settings,b),e.settings.inputPatternHighlighters&&(e.settings.inputPatternHighlighters=e.settings.inputPatternHighlighters.map(e=>K(e,x))),e.settings.toolsets&&(e.settings.toolsets=e.settings.toolsets.map(e=>K(e,S))),e.settings.themes&&(e.settings.themes=e.settings.themes.map(e=>K(e,C))),Ir(e),Lr(e),delete e.settings.launchText},Gr=async()=>{let e=Ur();try{W(`Reading config at ${J}`),Hr();let t=await i.readFile(J,`utf8`),n={...e,...JSON.parse(t)},r=JSON.stringify(n);Wr(n);let a=await $e(X);return a&&(n.changesApplied=!1),(JSON.stringify(n)!==r||a)&&await Kr(n),Q=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},$=async e=>(W(`Updating config at ${J}`),Q||=await Gr(),e(Q),Q.lastModified=new Date().toISOString(),await Kr(Q),Q),Kr=async e=>{try{e.lastModified=new Date().toISOString(),await Z(),await i.writeFile(J,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}},qr=async e=>{W(`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 i.readFile(J,`utf8`);n=JSON.parse(e)}catch{n=Ur()}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 a;try{let e=await r.text();a=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 o={sourceUrl:e,dateFetched:new Date().toISOString(),settings:a};await $(e=>{e.remoteConfig=o});let s={...Ur(),ccVersion:n.ccVersion||``,ccInstallationPath:n.ccInstallationPath||null,settings:{...b,...a},remoteConfig:o};return Wr(s),W(`Successfully fetched and parsed config from ${e}`),s};export{lr as A,F as B,Or as C,Dr as D,jr as E,V as F,Ct as G,qn as H,Zn as I,ut as J,pt as K,B as L,ir as M,ar as N,Cr as O,L as P,y as Q,nr as R,vr as S,Er as T,Jn as U,Kn as V,Yn as W,b as X,Qe as Y,v as Z,wr as _,X as a,Ar as b,Gr as c,Pr as d,W as f,br as g,xr as h,Y as i,sr as j,H as k,$ as l,yr as m,q as n,qr as o,Mr as p,ft as q,J as r,zr as s,Br as t,Rr as u,Sr as v,kr as w,gr as x,Tr as y,I as z};
|