tweakcc 4.0.10 → 4.0.13
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 +2 -0
- package/dist/config-DDE1Qxwn.mjs +668 -0
- package/dist/content-D0J68msM.mjs +29 -0
- package/dist/index.mjs +11 -11
- package/dist/lib/index.mjs +1 -1
- package/dist/nativeInstallation-BHG6-igp.mjs +4 -0
- package/package.json +2 -2
- package/dist/config-vydrbToU.mjs +0 -669
- package/dist/content-4ekX93_Y.mjs +0 -29
- package/dist/nativeInstallation-TRHntEPK.mjs +0 -4
|
@@ -0,0 +1,668 @@
|
|
|
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-BHG6-igp.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)}async function b(e){let t=await _();return t?t.resolveNixBinaryWrapper(e):null}const x={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,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!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`]},S={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},C={name:`Unnamed Toolset`,allowedTools:`*`},ee=x.themes[0],te=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},ne=e=>{let t=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),([\w$]+)=Math\.floor\(\1\/2\)/);if(!t||t.index===void 0)return null;let n=t.index+t[0].indexOf(t[2]+`=Math.floor(`),r=t.index+t[0].length,i=`${t[2]}=${t[1]}`,a=e.slice(0,n)+i+e.slice(r);return N(e,a,i,n,r),a},re=e=>{let t=e.match(/Math\.max\(1,Math\.floor\(\(([\w$]+)-10\)\/2\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return N(e,r,n,t.index,t.index+t[0].length),r},ie=e=>{let t=e.match(/Math\.min\(6,Math\.max\(1,([\w$]+)-3\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return N(e,r,n,t.index,t.index+t[0].length),r},ae=(e,t)=>{let n=te(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);N(i,r,n,e.startIndex,e.endIndex),i=r}let a=ne(i);a?i=a:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find help menu height pattern`);let o=re(i);o?i=o:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find visibleCount pattern`);let s=ie(i);return s?i=s:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find suggestions cap pattern`),i};function oe(e){let t=-1,n=-1,r=``,i=e.match(/switch\(([$\w]+)\)\{case"(?:light|dark)":[^}]*return [$\w]+;[^}]*default:return [$\w]+\}/);if(i&&i.index!=null)t=i.index,n=t+i[0].length,r=i[1];else{if(e.indexOf(`case"dark":return{"autoAccept"`)===-1&&e.indexOf(`case"light":return{`)===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let i=e.indexOf(`case"dark":return{`)===-1?e.indexOf(`case"light":return{`):e.indexOf(`case"dark":return{`),a=e.slice(Math.max(0,i-200),i).match(/switch\(([$\w]+)\)\{\s*$/);if(!a||a.index==null)return console.error(`patch: themes: failed to find switchMatch (old format)`),null;t=Math.max(0,i-200)+a.index,r=a[1];let o=0;for(let r=t;r<e.length&&r<t+5e4;r++)if(e[r]===`{`&&o++,e[r]===`}`&&(o--,o===0)){n=r+1;break}}if(t===-1||n===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let a=e.match(/\[(?:\.\.\.\[\],)?(?:\{"?label"?:"(?:Dark|Light|Auto|Monochrome)[^"]*","?value"?:"[^"]+"\},?)+\]/);if(!a||a.index==null)return console.error(`patch: themes: failed to find objArrMatch`),null;let o=e.match(/(?:return|[$\w]+=)\{(?:"?(?:[$\w-]+)"?:"(?:Auto |Dark|Light|Monochrome)[^"]*",?)+\}/);return!o||o.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t,endIndex:n,identifiers:[r]},objArr:{startIndex:a.index,endIndex:a.index+a[0].length},obj:{startIndex:o.index,endIndex:o.index+o[0].length}}}const se=(e,t)=>{let n=oe(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),N(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),N(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),N(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},w=e=>P(e,/\b200000\b/,`(+process.env.CLAUDE_CODE_CONTEXT_LIMIT||200000)`),T=(e,t)=>{if(!t)return e;let n=e,r=!1,i=n.match(/createElement\(([$\w]+),\{color:([$\w]+)\.bgColor\},"─"\.repeat\(([$\w]+)\)\)/);if(i){let e=i[1];n=n.replace(i[0],`createElement(${e},null,"")`);let t=RegExp(`createElement\\(${e},\\{color:${i[2]}\\.bgColor\\},${i[2]}\\.text\\?.+?"─"\\.repeat\\(${i[3]}\\)\\)`),a=n.match(t);a&&(n=n.replace(a[0],`createElement(${e},null,"")`)),r=!0}let a=n.match(/(borderColor:[$\w]+\(\),)borderStyle:"round"(,borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%",borderText:)/);a&&(n=n.replace(a[0],`${a[1]}borderStyle:undefined${a[2]}`),r=!0);let o=n.match(/borderStyle:"round"(,borderLeft:!1,borderRight:!1,borderBottom:!0,width:"100%"\}.+?Save and close editor)/);return o&&(n=n.replace(o[0],`borderStyle:undefined${o[1]}`),r=!0),r?(N(e,n,`(input border removed)`,0,0),n):(console.error(`patch: input border: failed to find input border pattern`),null)},ce=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)},le=(e,t)=>{let n=ce(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 N(e,s,o,r.startIndex,r.endIndex),s},ue=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]]}},de=(e,t)=>{let n=ue(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 N(e,a,i,n.startIndex,n.endIndex),a},fe=(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);N(s,t,a,o[e].startIndex,o[e].endIndex),s=t}return s},pe=(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 N(e,o,r,i,a),o},me=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}},he=(e,t)=>{let n=me(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 N(e,i,r,n.startIndex,n.endIndex),i},ge=(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 N(e,o,r,i,a),o},_e=(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 N(e,s,i,a,o),s},ve=(e,t)=>{let n=ge(e,t);if(n===null)return null;let r=_e(n,t);return r===null?null:r},ye=(e,t)=>{let n=B(e);if(!n)return console.error(`patch: userMessageDisplay: failed to find Text component`),null;let r=V(e);if(!r)return console.error(`patch: userMessageDisplay: failed to find Box component`),null;let i=F(e);if(!i)return console.error(`patch: userMessageDisplay: failed to find chalk variable`),null;let a=/(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]+)?\}\)\)?))/,o=/(No content found in user prompt message.{0,50}?\b)(([$\w]+(?:\.default)?)\.createElement\([$\w]+,\{flexDirection:"column"[^}]*\},([$\w]+(?:\.default)?\.createElement)\([$\w]+,\{text:([$\w]+)[^}]*\}\)\))/,s=e.match(a),c=s??e.match(o);if(!c||c.index===void 0)return console.error(`patch: userMessageDisplay: failed to find user message display pattern`),null;let l,u;s?(l=c[4],u=c[6]??c[7]):(l=c[4],u=c[5]);let d=[],f=t.borderStyle.startsWith(`topBottom`);if(t.borderStyle!==`none`){if(f){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:" "}`),d.push(`borderStyle:${e}`)}else d.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&d.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX>0&&d.push(`paddingX:${t.paddingX}`),t.paddingY>0&&d.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&d.push(`alignSelf:"flex-start"`);let p=d.length>0?`{${d.join(`,`)}}`:`null`,m=i;if(t.foregroundColor!==`default`){let e=t.foregroundColor.match(/\d+/g);e&&(m+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);e&&(m+=`.bgRgb(${e.join(`,`)})`)}t.styling.includes(`bold`)&&(m+=`.bold`),t.styling.includes(`italic`)&&(m+=`.italic`),t.styling.includes(`underline`)&&(m+=`.underline`),t.styling.includes(`strikethrough`)&&(m+=`.strikethrough`),t.styling.includes(`inverse`)&&(m+=`.inverse`);let h="`"+t.format.replace(/\{\}/g,"${"+u+`}`)+"`",g=`${m}(${h})`,_=c[1]+`${l}(${r},${p},${l}(${n},null,${g}))`,v=c.index,y=v+c[0].length,b=e.slice(0,v)+_+e.slice(y);return N(e,b,_,v,y),b},be=(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},xe=e=>{let t=e.match(/(if\(([$\w]+)\.highlight\?\.color\))((return [$\w]+\.createElement\([$\w]+,\{key:[$\w]+),color:[$\w]+\.highlight\.color(\},[$\w]+\.createElement\([$\w]+,null,)([$\w]+\.text)(\)\)));/);if(t&&t.index!==void 0){let n=`${t[2]}.highlight.color(${t[6]})`,r=t[1]+`{if(typeof ${t[2]}.highlight.color==='function')`+t[4]+t[5]+n+t[7]+`;else `+t[3]+`}`,i=e.slice(0,t.index)+r+e.slice(t.index+t[0].length);return N(e,i,r,t.index,t.index+t[0].length),i}let n=/(return ([$\w]+)\.createElement\(([$\w]+),\{key:([$\w]+)),color:([$\w]+)\.highlight\?\.color,dimColor:\5\.highlight\?\.dimColor,inverse:\5\.highlight\?\.inverse\},(\2\.createElement\([$\w]+,null,\5\.text\))\)/,r=e.match(n);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find highlight?.color renderer pattern`),null;let i=r[2],a=r[3],o=r[4],s=r[5];r[6];let c=RegExp(`if\\(${s.replace(`$`,`\\$`)}\\.highlight\\.color\\)return ([$\\w]+)\\.createElement\\([$\\w]+,\\{key:[$\\w]+\\},${s.replace(`$`,`\\$`)}\\.text\\.split\\(""\\)\\.map\\([^)]+\\)\\)`),l=e,u=l.match(c);if(u&&u.index!==void 0){let e=`if(typeof ${s}.highlight?.color==='function')return ${i}.createElement(${a},{key:${o}},${i}.createElement(${a},null,${s}.highlight.color(${s}.text)));`;l=l.slice(0,u.index)+e+l.slice(u.index)}let d=l.match(n);if(!d||d.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to re-find renderer after shimmer patch`),null;let f=l.slice(0,d.index)+d[0]+l.slice(d.index+d[0].length);return N(e,f,`shimmer guard + renderer`,0,0),f},Se=(e,t,n)=>{let r=e.match(/((?:,|;let )[$\w]+=[$\w]+\.useMemo\(\(\)=>\{let [$\w]+=\[\];[\s\S]*?)(if\([$\w]+&&[$\w]+&&![$\w]+\)([$\w]+)\.push\(\{start:[$\w]+,end:[$\w]+\+[$\w]+\.length,color:"warning",priority:\d+\})/);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find useMemo/push pattern`),null;let i=r[3],a=r[1].match(/[^$\w]([$\w]+(?:\.default)?)\.useMemo\(/);if(!a)return console.error(`patch: inputPatternHighlighters: failed to extract React var from useMemo`),null;a[1];let o=Math.max(0,r.index-1e4),s=[...e.slice(o,r.index).matchAll(/\binput:([$\w]+),/g)].at(-1)??null;if(!s)return console.error(`patch: inputPatternHighlighters: failed to find input variable pattern`),null;let c=s[1],l=``;for(let e=0;e<n.length;e++){let r=n[e];be(t,r),JSON.stringify(r.format).replace(/\{MATCH\}/g,`"+x+"`);let a=r.foregroundColor;if(a){let e=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);a=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let o=a?JSON.stringify(a):`undefined`;r.styling.includes(`bold`);let s=r.styling.includes(`inverse`),u=r.styling.includes(`dim`),d=r.styling.includes(`strikethrough`),f=r.regexFlags;f.includes(`g`)||(f+=`g`);let p=Yr(new RegExp(r.regex,f));l+=`if(typeof ${c}==="string"){for(let m of ${c}.matchAll(${p})){${i}.push({start:m.index,end:m.index+m[0].length,color:${o}${s?`,inverse:!0`:``}${u?`,dimColor:!0`:``}${d?`,strikethrough:!0`:``},priority:100})}}`}let u=r[1]+l+r[2],d=e.slice(0,r.index),f=e.slice(r.index+r[0].length),p=d+``+u+f,m=p.indexOf(`for(let m of ${c}.matchAll(`);if(m>-1){let e=[...p.slice(Math.max(0,m-2e3),m).matchAll(/useMemo\(\(\)=>\{/g)];if(e.length>0){let t=Math.max(0,m-2e3)+e[e.length-1].index,n=p.slice(t),r=0;for(let e=0;e<n.length;e++)if(n[e]===`(`)r++;else if(n[e]===`)`&&(r--,r===0)){let n=t+e;p.slice(n-1,n)===`]`&&(p.slice(n-200,n).includes(`,${c}]`)||(p=p.slice(0,n-1)+`,${c}]`+p.slice(n)));break}}}return N(e,p,``+u,r.index,r.index+r[0].length),p},Ce=(e,t)=>{let n=t.filter(e=>e.enabled);if(n.length===0)return null;let r=F(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i;return i=xe(e),i?(i=Se(i,r,n),i||(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterCreation failed`),null)):(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterImpl failed`),null)},we=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}},Te=e=>{let t=we(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return N(e,r,n,t.startIndex,t.endIndex),r},Ee=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 N(e,c,s,t.index,t.index+n.length),c},De=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 N(e,r,n,t.index,t.index+t[0].length),r},Oe=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.6 in plan mode, else Sonnet 4.6 (1M context)";`,a=e.slice(0,t.index)+i+e.slice(t.index+n.length);return N(e,a,i,t.index,t.index+n.length),a},ke=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 N(e,a,i,t.index,t.index+n.length),a},Ae=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*(?:[$\w]+\()?\[\s*\.\.\.([$\w]+)\s*,\s*([$\w]+)\(\)\s*\]\)?;)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchModelSelectorOptions: failed to find model selector pattern`),null;let[n,,r,i]=t,a=n.match(RegExp(`return\\s*([$\\w]+)\\(\\s*\\[\\.\\.\\.${U(i)}`)),o=a?a[1]:null,s=`{value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus 4.6 in plan mode, Sonnet 4.6 (1M context) otherwise"}`,c=n+`if(${r}==="opusplan[1m]")return ${o?`${o}([...${i},${s}])`:`[...${i},${s}]`};`,l=e.slice(0,t.index)+c+e.slice(t.index+n.length);return N(e,l,c,t.index,t.index+n.length),l},je=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.6 in plan mode, Sonnet 4.6 otherwise"});${n}.push({value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus 4.6 in plan mode, Sonnet 4.6 (1M context) otherwise"});`,i=e.slice(0,t.index)+r+e.slice(t.index);return N(e,i,r,t.index,t.index),i},Me=e=>{let t=e,n=Ee(t);if(n)t=n;else return console.error(`patch: opusplan1m: failed to apply mode switching patch`),null;if(n=De(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model aliases list patch`),null;if(n=Oe(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply description function patch`),null;if(n=ke(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply label function patch`),null;if(n=Ae(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model selector options patch`),null;if(n=je(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply always-show-in-selector patch`),null;return t},Ne=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 N(e,a,n,r,i),a},Pe=(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 N(e,o,r,i,a),o},Fe=(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 N(e,o,r,i,a),o},Ie=(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 N(e,c,a,o,s),c},Le=(e,t)=>{let n=e;if(t.plan){let e=Pe(n,t.plan);if(e===null)return null;n=e}if(t.explore){let e=Fe(n,t.explore);if(e===null)return null;n=e}if(t.generalPurpose){let e=Ie(n,t.generalPurpose);if(e===null)return null;n=e}return n},Re=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}},ze=e=>{let t=e.match(/createElement\(([$\w]+),\{bold:!0\},"Claude Code"\),([$\w]+)\[\d+\]=[$\w]+;else [$\w]+=([$\w]+)\[\d+\]/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: PATCH 2 failed to find bold Claude Code pattern`),null;let n=t[1],r=t.index+t[0].length,i=e.indexOf(`;`,r);if(i===-1)return null;let a=i+1,o=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),null,[$\w]+," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)\)/);if(!o||o.index===void 0){let t=e.match(/[^$\w]([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);return!t||t.index===void 0?(console.error(`patch: patchesAppliedIndication: PATCH 2 failed to find version createElement`),null):{varInsertIndex:a,refInsertIndex:t.index+t[0].length,reactVar:t[1],textComponent:n}}return{varInsertIndex:a,refInsertIndex:o.index+o[0].length-1,reactVar:o[1],textComponent:n}},Be=e=>{let t=e.match(/"Claude Code".{0,200}\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find version display for patch 3`),null;let n={index:t.index},r=Math.max(0,n.index-1500),i=e.slice(r,n.index),a=Array.from(i.matchAll(/\}function ([$\w]+)\(/g));if(a.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let o=a[a.length-1][1],s=RegExp(`[^$\\w]([$\\w]+)\\.createElement\\(${U(o)},null\\),?`),c=e.match(s);if(!c||c.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let l=e.slice(Math.max(0,c.index-30),c.index+1).match(/([$\w]+)=(?:[$\w]+&&)?[^$\w]?$/);if(l){let t=l[1],n=e.slice(c.index,c.index+2e3),r=RegExp(`,${U(t)}([,\\)])`),i=n.match(r);if(i&&i.index!==void 0){let e=c.index+i.index+i[0].length-i[1].length;return{startIndex:e,endIndex:e}}}let u=c.index+c[0].length;return{startIndex:u,endIndex:u}},Ve=(e,t,n,r=!0,i=!0)=>{let a=Re(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=`}.VERSION} (Claude Code)`,c=e.replaceAll(s,s+o);N(e,c,o,a.endIndex,a.endIndex);let l=F(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let u=B(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let d=R(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;if(r){let e=c.match(/(\$\{([$\w]+)\("inactive",([$\w]+)\)\(`v\$\{[$\w]+\}`\)\}) `,/);if(e&&e.index!==void 0){let n=e[0],r=e[2],i=e[3],a=`${e[1]} \${${r}("warning",${i})("+ tweakcc v${t}")} \`,`;c=c.replace(n,a)}c=c.replace(/([$\w]+\("claude",[$\w]+\)\(" Claude Code) ("\))/,`$1 + tweakcc v${t} $2`);let n=ze(c);if(!n)return console.error(`patch: patchesAppliedIndication: patch 2 failed`),null;let r=`let _tw=${n.reactVar}.createElement(${n.textComponent},null,${l}.hex("#FF8400").bold("+ tweakcc v${t}"));`,i=c;c=c.slice(0,n.varInsertIndex)+r+c.slice(n.varInsertIndex),N(i,c,r,n.varInsertIndex,n.varInsertIndex);let a=n.refInsertIndex+r.length,o=`," ",_tw`,s=c;c=c.slice(0,a)+o+c.slice(a),N(s,c,o,a,a)}if(i){let e=V(c);if(!e)return console.error(`patch: patchesAppliedIndication: PATCH 3 skipped (Box component not located on this CC version)`),c;let t=Be(c);if(!t)console.error(`patch: patchesAppliedIndication: patch 3 skipped (version display pattern changed by PATCH 2)`);else{let r=[];r.push(`,${d}.createElement(${e}, { flexDirection: "column" },`),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let t of n)t=t.replace(`CHALK_VAR`,l),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {dimColor: true}, \` * ${t}\`)),`);r.push(`),`);let i=r.join(`
|
|
2
|
+
`);t.startIndex>0&&c[t.startIndex-1]===`,`&&i.startsWith(`,`)&&(i=i.slice(1)),i.endsWith(`,`)&&c[t.startIndex]===`,`&&(i=i.slice(0,-1));let a=c;c=c.slice(0,t.startIndex)+i+c.slice(t.endIndex),N(a,c,i,t.startIndex,t.endIndex)}}return c};async function He(e){let t=u.join(ti,`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(ti,{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 Ue=()=>u.join(J,`systemPromptOriginalHashes.json`),We=()=>u.join(J,`systemPromptAppliedHashes.json`),Ge=(e,t)=>`${e}-${t}`,Ke=e=>p.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),qe=async()=>{try{let e=await r.readFile(Ue(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Je=async e=>{await r.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await r.writeFile(Ue(),JSON.stringify(t,null,2),`utf8`)},Ye=async e=>{let t=await qe(),n=0;for(let r of e.prompts){let e=Ge(r.id,r.version);t[e]||(t[e]=Ke(E(r.pieces,r.identifiers,r.identifierMap)),n++)}return await Je(t),n},Xe=async(e,t)=>(await qe())[Ge(e,t)],Ze=async()=>{try{let e=await r.readFile(We(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Qe=async e=>{await r.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await r.writeFile(We(),JSON.stringify(t,null,2),`utf8`)},$e=async(e,t)=>{let n=await Ze();n[e]=t,await Qe(n)},et=async()=>{let e=await Ze(),t={};for(let n of Object.keys(e))t[n]=null;await Qe(t)},tt=async e=>{try{let t=await Ze();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(Ke((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}},nt=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}},rt=(e,t)=>{let n=t||E(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:[`<!--`,`-->`]})},E=(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},D=(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},O=e=>u.join(Z,`${e}.md`),it=async e=>{try{return await r.access(O(e)),!0}catch{return!1}},at=async e=>{let t=O(e);return nt(await r.readFile(t,`utf-8`))},ot=async(e,t)=>{let n=O(e);await r.writeFile(n,t,`utf-8`)},st=async(e,t)=>{let n=O(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 ot(e,m.stringify(i.content,o,{delimiters:[`<!--`,`-->`]}))},ct=(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}},lt=(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=ct(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},ut=async(e,t,n,i,a,o,s,c)=>{let l=n.split(`
|
|
4
|
+
`),d=i.split(`
|
|
5
|
+
`),f=a.split(`
|
|
6
|
+
`),p=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),m=lt(l,d),h=lt(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
|
+
<html>
|
|
8
|
+
<head>
|
|
9
|
+
<meta charset="UTF-8">
|
|
10
|
+
<title>Diff: ${p(t)} (${p(e)})</title>
|
|
11
|
+
<style>
|
|
12
|
+
body {
|
|
13
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 20px;
|
|
16
|
+
background: #f5f5f5;
|
|
17
|
+
}
|
|
18
|
+
.header {
|
|
19
|
+
background: white;
|
|
20
|
+
padding: 20px;
|
|
21
|
+
border-radius: 8px;
|
|
22
|
+
margin-bottom: 20px;
|
|
23
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
24
|
+
}
|
|
25
|
+
h1 {
|
|
26
|
+
margin: 0 0 10px 0;
|
|
27
|
+
color: #333;
|
|
28
|
+
}
|
|
29
|
+
.version-info {
|
|
30
|
+
color: #666;
|
|
31
|
+
font-size: 14px;
|
|
32
|
+
}
|
|
33
|
+
.warning {
|
|
34
|
+
background: #fff3cd;
|
|
35
|
+
border-left: 4px solid #ffc107;
|
|
36
|
+
padding: 15px;
|
|
37
|
+
margin-bottom: 20px;
|
|
38
|
+
border-radius: 4px;
|
|
39
|
+
}
|
|
40
|
+
.warning code {
|
|
41
|
+
background: rgba(0,0,0,0.1);
|
|
42
|
+
padding: 2px 6px;
|
|
43
|
+
border-radius: 3px;
|
|
44
|
+
font-family: 'Consolas', 'Monaco', monospace;
|
|
45
|
+
font-size: 13px;
|
|
46
|
+
}
|
|
47
|
+
.diff-panels {
|
|
48
|
+
display: grid;
|
|
49
|
+
grid-template-columns: 1fr 1fr;
|
|
50
|
+
gap: 20px;
|
|
51
|
+
margin-bottom: 20px;
|
|
52
|
+
}
|
|
53
|
+
.diff-container {
|
|
54
|
+
background: white;
|
|
55
|
+
border-radius: 8px;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
58
|
+
}
|
|
59
|
+
.diff-header {
|
|
60
|
+
background: #f8f9fa;
|
|
61
|
+
padding: 12px 15px;
|
|
62
|
+
font-weight: bold;
|
|
63
|
+
border-bottom: 2px solid #dee2e6;
|
|
64
|
+
font-family: 'Consolas', 'Monaco', monospace;
|
|
65
|
+
font-size: 14px;
|
|
66
|
+
}
|
|
67
|
+
.diff-content {
|
|
68
|
+
padding: 0;
|
|
69
|
+
font-family: 'Consolas', 'Monaco', monospace;
|
|
70
|
+
font-size: 13px;
|
|
71
|
+
line-height: 1.5;
|
|
72
|
+
overflow-x: auto;
|
|
73
|
+
max-height: 600px;
|
|
74
|
+
overflow-y: auto;
|
|
75
|
+
}
|
|
76
|
+
.line {
|
|
77
|
+
padding: 2px 10px;
|
|
78
|
+
white-space: pre-wrap;
|
|
79
|
+
word-wrap: break-word;
|
|
80
|
+
}
|
|
81
|
+
.line .line-num {
|
|
82
|
+
display: inline-block;
|
|
83
|
+
min-width: 50px;
|
|
84
|
+
margin-right: 10px;
|
|
85
|
+
color: #6a737d;
|
|
86
|
+
text-align: right;
|
|
87
|
+
user-select: none;
|
|
88
|
+
font-size: 12px;
|
|
89
|
+
}
|
|
90
|
+
.line .prefix {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
width: 20px;
|
|
93
|
+
font-weight: bold;
|
|
94
|
+
user-select: none;
|
|
95
|
+
}
|
|
96
|
+
.removed {
|
|
97
|
+
background: #ffebe9;
|
|
98
|
+
color: #24292e;
|
|
99
|
+
}
|
|
100
|
+
.removed .prefix {
|
|
101
|
+
color: #d73a49;
|
|
102
|
+
}
|
|
103
|
+
.added {
|
|
104
|
+
background: #e6ffed;
|
|
105
|
+
color: #24292e;
|
|
106
|
+
}
|
|
107
|
+
.added .prefix {
|
|
108
|
+
color: #22863a;
|
|
109
|
+
}
|
|
110
|
+
.unchanged {
|
|
111
|
+
background: #ffffff;
|
|
112
|
+
color: #24292e;
|
|
113
|
+
}
|
|
114
|
+
.unchanged .prefix {
|
|
115
|
+
color: #6a737d;
|
|
116
|
+
}
|
|
117
|
+
mark {
|
|
118
|
+
background: rgba(255, 200, 0, 0.4);
|
|
119
|
+
padding: 0;
|
|
120
|
+
border-radius: 2px;
|
|
121
|
+
}
|
|
122
|
+
.removed mark {
|
|
123
|
+
background: rgba(215, 58, 73, 0.3);
|
|
124
|
+
}
|
|
125
|
+
.added mark {
|
|
126
|
+
background: rgba(34, 134, 58, 0.3);
|
|
127
|
+
}
|
|
128
|
+
@media (max-width: 1200px) {
|
|
129
|
+
.diff-panels {
|
|
130
|
+
grid-template-columns: 1fr;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
134
|
+
</head>
|
|
135
|
+
<body>
|
|
136
|
+
<div class="header">
|
|
137
|
+
<h1>${p(t)}</h1>
|
|
138
|
+
<div class="version-info">
|
|
139
|
+
<strong>Old Version:</strong> ${p(o)} →
|
|
140
|
+
<strong>New Version:</strong> ${p(s)}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div class="warning">
|
|
145
|
+
<strong>⚠️ Version Mismatch Warning</strong><br>
|
|
146
|
+
Your customized prompt file is based on version ${p(o)},
|
|
147
|
+
but Claude Code is now using version ${p(s)}.
|
|
148
|
+
Review the differences below to understand both your customizations and the upstream changes.<br><br>
|
|
149
|
+
<strong>File:</strong> <code>${p(c)}</code><br><br>
|
|
150
|
+
When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${p(s)}</strong>.
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<div class="diff-panels">
|
|
154
|
+
<div class="diff-container">
|
|
155
|
+
<div class="diff-header">Your Customizations (v${p(o)} → User)</div>
|
|
156
|
+
<div class="diff-content">
|
|
157
|
+
${g} </div>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div class="diff-container">
|
|
161
|
+
<div class="diff-header">Upstream Changes (v${p(o)} → v${p(s)})</div>
|
|
162
|
+
<div class="diff-content">
|
|
163
|
+
${_} </div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</body>
|
|
167
|
+
</html>`,y=u.join(Z,`${e}.diff.html`);return await r.writeFile(y,v,`utf-8`),y},dt=async t=>{let n={id:t.id,name:t.name,description:t.description,action:`skipped`,newVersion:t.version};if(!await it(t.id)){let e=rt(t);return await ot(t.id,e),n.action=`created`,n}let r=await at(t.id);if(n.oldVersion=r.ccVersion,await st(t.id,t.identifierMap),r.ccVersion&&t.version){let i=D(r.ccVersion,t.version);if(i===0)return n.action=`skipped`,n;if(i!=0){let i=await Xe(t.id,r.ccVersion),a=Ke(r.content);if(!i||i!==a){n.action=`conflict`;let i=r.content;try{let e=(await He(r.ccVersion)).prompts.find(e=>e.id===t.id);e&&(i=E(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=E(t.pieces,t.identifiers,t.identifierMap),o=O(t.id);n.diffHtmlPath=await ut(t.id,t.name,i,r.content,a,r.ccVersion,t.version,o)}else{let e=rt(t);await ot(t.id,e),n.action=`updated`}}}return n},ft=async t=>{let n={ccVersion:t,results:[]},i=await He(t);await Ye(i),await r.mkdir(Z,{recursive:!0});for(let t of i.prompts)try{let e=await dt(t);n.results.push(e)}catch(n){throw console.log(e.red(`Failed to sync prompt ${t.id}:`)),n}return n};let k=null,pt=null;const mt=async e=>{try{return k=await He(e),pt=e,{success:!0}}catch(e){return k=null,pt=null,e instanceof Error?{success:!1,errorMessage:e.message}:{success:!1,errorMessage:`Unknown error occurred while downloading system prompts`}}},ht=()=>k?k.prompts.map(e=>({id:e.id,name:e.name,description:e.description})):null,gt=e=>e.replace(/[^\x00-\x7F]/g,e=>{let t=`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`;return`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}|${t})`}),_t=e=>e.replace(/[^\x00-\x7F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),vt=(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=gt(a.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).replace(/\n/g,`(?:
|
|
168
|
+
|\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},yt=(e,t)=>{let n=0,r=t-1;for(;r>=0&&e[r]===`\\`;)n++,r--;return n},bt=e=>{let t=``,n=0,r=``,i=[];for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1],c=yt(e,a)%2==0;if(n){if(i.length>0&&n===i[i.length-1]){if(o==="`"&&c)i.pop();else if(o===`$`&&s===`{`){c&&n++,t+="${",a++;continue}t+=o;continue}if(r)o===r&&c&&(r=``);else if(o===`$`&&s===`{`){c&&n++,t+="${",a++;continue}else o===`"`||o===`'`?r=o:o==="`"&&c?i.push(n):o===`{`?n++:o===`}`&&n--;t+=o;continue}if(o===`$`&&s===`{`&&!r){c&&n++,t+="${",a++;continue}o==="`"&&c?t+="\\`":t+=o}let a=n>0||i.length>0;return a&&W(`escapeDepthZeroBackticks: unclosed interpolation detected (depth=${n}). Some backticks may not have been escaped.`),{content:t,incomplete:a}},xt=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]:``}},St=(e,t)=>{if(e.trim()===``)return``;let n=e.trim();return t.leading+n+t.trailing},Ct=(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=_t(l)),s&&s.length>0){let e=xt(s);l=St(l,e)}return l},wt=async(e,t=!1,n)=>{if(!k||pt!==e)return[];let i=k,a=[];for(let o of i.prompts){let i=vt(o.pieces,e,n),s=u.join(Z,`${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=nt(c);a.push({promptId:o.id,prompt:l,regex:i,getInterpolatedContent:r=>{let i=r.slice(1);return Ct(l.content,o.identifiers,o.identifierMap,i,e,t,n,o.pieces)},pieces:o.pieces,identifiers:o.identifiers,identifierMap:o.identifierMap})}return a},Tt=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(` ${Z}/${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 ${Z} 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()}},Et=e=>/\\u[0-9a-fA-F]{4}/.test(e),Dt=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},Ot=(e,t)=>{let n=``;for(let r=0;r<e.length;r++)if(e[r]===t){let i=0,a=r-1;for(;a>=0&&e[a]===`\\`;)i++,a--;i%2==0?n+=`\\`+t:n+=t}else n+=e[r];return n},kt=async(t,n,r,i)=>{let a=r??Et(t);a&&W(`Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts`);let o=Dt(t);o&&W(`Extracted BUILD_TIME from cli.js: ${o}`);let s=await wt(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]:``,m=E(l,u,d).trim().length,h=r.content.trim().length,g=t,_=f[0].length,v=i;if(p===`"`)v=v.replace(/\n/g,`\\n`),v=Ot(v,`"`);else if(p===`'`)v=v.replace(/\n/g,`\\n`),v=Ot(v,`'`);else if(p==="`"){let{content:t,incomplete:a}=bt(i);if(a){console.log(e.red(`Incomplete backtick escaping for "${r.name}" (unclosed interpolation) - skipping`)),c.push({id:n,name:r.name,group:H.SYSTEM_PROMPTS,applied:!1,details:`incomplete escaping: unclosed interpolation detected`});continue}t!==i&&console.log(e.yellow(`Auto-escaped unescaped backticks in "${r.name}"`)),v=t}t=t.replace(s,()=>v);let y=Ke(r.content),b=!1;try{await $e(n,y)}catch(e){W(`Failed to store hash for "${r.name}": ${e}`),b=!0}N(g,t,v,a,a+_);let x=m-h,S=g!==t,C;C=x>0?e.green(`${x} fewer chars`):x<0?e.red(`${Math.abs(x)} more chars`):`unchanged`,b&&(C+=` (hash storage failed)`),c.push({id:n,name:r.name,group:H.SYSTEM_PROMPTS,applied:S,...b&&{failed:!0},details:C})}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 ${Yr(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}},At=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]}},jt=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=P(i,t,``),i=P(i,n,``),i=P(i,r,``);let a=At(i);if(!a||!a.identifiers)return null;let[o,s]=a.identifiers,c=`
|
|
169
|
+
const path = await import('path');
|
|
170
|
+
const ext = path.extname(${o}).toLowerCase();
|
|
171
|
+
const langMap = {
|
|
172
|
+
'.ts': 'typescript',
|
|
173
|
+
'.tsx': 'typescriptreact',
|
|
174
|
+
'.js': 'javascript',
|
|
175
|
+
'.jsx': 'javascriptreact',
|
|
176
|
+
'.mjs': 'javascript',
|
|
177
|
+
'.cjs': 'javascript',
|
|
178
|
+
'.mts': 'typescript',
|
|
179
|
+
'.cts': 'typescript',
|
|
180
|
+
'.py': 'python',
|
|
181
|
+
'.pyi': 'python',
|
|
182
|
+
'.pyw': 'python',
|
|
183
|
+
'.rs': 'rust',
|
|
184
|
+
'.go': 'go',
|
|
185
|
+
'.java': 'java',
|
|
186
|
+
'.kt': 'kotlin',
|
|
187
|
+
'.kts': 'kotlin',
|
|
188
|
+
'.scala': 'scala',
|
|
189
|
+
'.sc': 'scala',
|
|
190
|
+
'.groovy': 'groovy',
|
|
191
|
+
'.c': 'c',
|
|
192
|
+
'.cpp': 'cpp',
|
|
193
|
+
'.cc': 'cpp',
|
|
194
|
+
'.cxx': 'cpp',
|
|
195
|
+
'.c++': 'cpp',
|
|
196
|
+
'.h': 'c',
|
|
197
|
+
'.hpp': 'cpp',
|
|
198
|
+
'.hh': 'cpp',
|
|
199
|
+
'.hxx': 'cpp',
|
|
200
|
+
'.h++': 'cpp',
|
|
201
|
+
'.cs': 'csharp',
|
|
202
|
+
'.csx': 'csharp',
|
|
203
|
+
'.html': 'html',
|
|
204
|
+
'.htm': 'html',
|
|
205
|
+
'.css': 'css',
|
|
206
|
+
'.scss': 'scss',
|
|
207
|
+
'.sass': 'sass',
|
|
208
|
+
'.less': 'less',
|
|
209
|
+
'.php': 'php',
|
|
210
|
+
'.phtml': 'php',
|
|
211
|
+
'.php3': 'php',
|
|
212
|
+
'.php4': 'php',
|
|
213
|
+
'.php5': 'php',
|
|
214
|
+
'.phps': 'php',
|
|
215
|
+
'.rb': 'ruby',
|
|
216
|
+
'.rbw': 'ruby',
|
|
217
|
+
'.rake': 'ruby',
|
|
218
|
+
'.gemspec': 'ruby',
|
|
219
|
+
'.sh': 'shellscript',
|
|
220
|
+
'.bash': 'shellscript',
|
|
221
|
+
'.zsh': 'shellscript',
|
|
222
|
+
'.fish': 'fish',
|
|
223
|
+
'.swift': 'swift',
|
|
224
|
+
'.m': 'objective-c',
|
|
225
|
+
'.mm': 'objective-cpp',
|
|
226
|
+
'.lua': 'lua',
|
|
227
|
+
'.pl': 'perl',
|
|
228
|
+
'.pm': 'perl',
|
|
229
|
+
'.t': 'perl',
|
|
230
|
+
'.pod': 'perl',
|
|
231
|
+
'.r': 'r',
|
|
232
|
+
'.R': 'r',
|
|
233
|
+
'.rmd': 'rmd',
|
|
234
|
+
'.Rmd': 'rmd',
|
|
235
|
+
'.ex': 'elixir',
|
|
236
|
+
'.exs': 'elixir',
|
|
237
|
+
'.erl': 'erlang',
|
|
238
|
+
'.hrl': 'erlang',
|
|
239
|
+
'.hs': 'haskell',
|
|
240
|
+
'.lhs': 'haskell',
|
|
241
|
+
'.ml': 'ocaml',
|
|
242
|
+
'.mli': 'ocaml',
|
|
243
|
+
'.clj': 'clojure',
|
|
244
|
+
'.cljs': 'clojure',
|
|
245
|
+
'.cljc': 'clojure',
|
|
246
|
+
'.edn': 'clojure',
|
|
247
|
+
'.json': 'json',
|
|
248
|
+
'.jsonc': 'jsonc',
|
|
249
|
+
'.xml': 'xml',
|
|
250
|
+
'.yaml': 'yaml',
|
|
251
|
+
'.yml': 'yaml',
|
|
252
|
+
'.toml': 'toml',
|
|
253
|
+
'.ini': 'ini',
|
|
254
|
+
'.cfg': 'ini',
|
|
255
|
+
'.conf': 'conf',
|
|
256
|
+
'.md': 'markdown',
|
|
257
|
+
'.markdown': 'markdown',
|
|
258
|
+
'.mdown': 'markdown',
|
|
259
|
+
'.rst': 'restructuredtext',
|
|
260
|
+
'.tex': 'latex',
|
|
261
|
+
'.sql': 'sql',
|
|
262
|
+
'.graphql': 'graphql',
|
|
263
|
+
'.gql': 'graphql',
|
|
264
|
+
'.dart': 'dart',
|
|
265
|
+
'.jl': 'julia',
|
|
266
|
+
'.zig': 'zig',
|
|
267
|
+
'.nim': 'nim',
|
|
268
|
+
'.nims': 'nim',
|
|
269
|
+
'.cr': 'crystal',
|
|
270
|
+
'.d': 'd',
|
|
271
|
+
'.di': 'd',
|
|
272
|
+
'.fs': 'fsharp',
|
|
273
|
+
'.fsx': 'fsharp',
|
|
274
|
+
'.fsi': 'fsharp',
|
|
275
|
+
'.ps1': 'powershell',
|
|
276
|
+
'.psm1': 'powershell',
|
|
277
|
+
'.psd1': 'powershell',
|
|
278
|
+
'.bat': 'bat',
|
|
279
|
+
'.cmd': 'bat',
|
|
280
|
+
'.mk': 'makefile',
|
|
281
|
+
'.dockerfile': 'dockerfile',
|
|
282
|
+
'.proto': 'proto',
|
|
283
|
+
'.vhd': 'vhdl',
|
|
284
|
+
'.vhdl': 'vhdl',
|
|
285
|
+
'.v': 'verilog',
|
|
286
|
+
'.sv': 'systemverilog',
|
|
287
|
+
'.asm': 'asm',
|
|
288
|
+
'.s': 'asm',
|
|
289
|
+
'.f': 'fortran',
|
|
290
|
+
'.f90': 'fortran',
|
|
291
|
+
'.f95': 'fortran',
|
|
292
|
+
'.cob': 'cobol',
|
|
293
|
+
'.cbl': 'cobol',
|
|
294
|
+
'.ada': 'ada',
|
|
295
|
+
'.adb': 'ada',
|
|
296
|
+
'.ads': 'ada',
|
|
297
|
+
'.sol': 'solidity',
|
|
298
|
+
'.vue': 'vue',
|
|
299
|
+
'.svelte': 'svelte',
|
|
300
|
+
'.astro': 'astro',
|
|
301
|
+
'.tf': 'terraform',
|
|
302
|
+
'.tfvars': 'terraform',
|
|
303
|
+
'.prisma': 'prisma'
|
|
304
|
+
};
|
|
305
|
+
const languageId = langMap[ext] || 'plaintext';
|
|
306
|
+
try {
|
|
307
|
+
const fs = await import('fs/promises');
|
|
308
|
+
const text = await fs.readFile(${o}, 'utf8');
|
|
309
|
+
await ${s}.sendNotification('textDocument/didOpen', {
|
|
310
|
+
textDocument: {
|
|
311
|
+
uri: "file://" + ${o},
|
|
312
|
+
languageId: languageId,
|
|
313
|
+
version: 1,
|
|
314
|
+
text: text
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
} catch (openErr) { }
|
|
318
|
+
`,l=i.slice(0,a.startIndex)+c+i.slice(a.endIndex);return N(i,l,c,a.startIndex,a.endIndex),l},Mt=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},Nt=(e,t)=>{let n=Mt(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 N(e,r,t,n,n),r},Pt=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)},Ft=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 null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},A=e=>{let t=e.match(/function ([$\w]+)\(.{0,110}`Your selector in.{0,1000}?function ([$\w]+)\(\)\{return [$\w]+\(\)\.setState\}/);if(t)return{appStateUseSelectorFn:t[1],appStateSetState:t[2]};let n=Array.from(e.matchAll(/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/g));for(let t of n){let n=t[1],r=t[2].replace(/\$/g,`\\$`),i=RegExp(`function ([$\\w]+)\\([$\\w]+\\)\\{(?:(?!\\bfunction\\b).){0,300}${r}\\(\\)(?:(?!\\bfunction\\b).){0,300}useSyncExternalStore\\(`),a=e.match(i);if(!a)continue;let o=a[1],s=o.replace(/\$/g,`\\$`);if(RegExp(`${s}\\(.{0,80}thinkingEnabled`).test(e))return{appStateUseSelectorFn:o,appStateSetState:n}}return console.error(`patch: getAppStateSelectorAndUseState: failed to find pattern`),null},It=e=>{let t=Mt(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},Lt=(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 N(e,i,a,o.index,o.index),i},Rt=(e,t,n)=>{let r=A(e);if(!r)return console.error(`patch: toolsets: toolFetchingMemo: failed to find app state info`),null;let{appStateUseSelectorFn:i}=r,a=e.match(/let ([$\w]+)=([$\w]+\([$\w]+,[$\w]+\.tools,[$\w]+\)),/);if(!a||a.index===void 0)return console.error(`patch: toolsets: failed to find tool aggregation pattern`),null;let o=a[1],s=a[2],c=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),l=`let currentToolset = ${i}(state => state.toolset) ?? ${n?JSON.stringify(n):`undefined`};
|
|
319
|
+
let ${o} = undefined;
|
|
320
|
+
const toolsets = ${c};
|
|
321
|
+
if (toolsets.hasOwnProperty(currentToolset)) {
|
|
322
|
+
const allowedTools = toolsets[currentToolset];
|
|
323
|
+
if (allowedTools === "*") {
|
|
324
|
+
${o} = ${s};
|
|
325
|
+
} else {
|
|
326
|
+
${o} = ${s}.filter((toolDef) => allowedTools.includes(toolDef.name));
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
${o} = ${s};
|
|
330
|
+
}let `,u=a.index,d=u+a[0].length,f=e.slice(0,u)+l+e.slice(d);return N(e,f,l,u,d),f},zt=(e,t,n)=>{if(!A(e))return console.error(`patch: toolsets: computeToolsFilter: failed to find app state info`),null;let r=e.match(/([$\w]+)=\(\)=>\{let ([$\w]+)=([$\w]+)\.getState\(\),([$\w]+)=([$\w]+)\(\2\.toolPermissionContext,\2\.mcp\.tools\),([$\w]+)=([$\w]+)\([$\w]+,\4,\2\.toolPermissionContext\.mode\);if\(!([$\w]+)\)return \6;return ([$\w]+)\(\8,\6,!1,!0\)\.resolvedTools\}/);if(!r||r.index===void 0)return console.error(`patch: toolsets: computeToolsFilter: failed to find computeTools pattern`),null;let i=r[1],a=r[2],o=r[3],s=r[4],c=r[5],l=r[6],u=r[7],d=r[8],f=r[9],p=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),m=n?JSON.stringify(n):`undefined`,h=r[0],g=h.match(RegExp(`${u.replace(/\$/g,`\\$`)}\\(([$\\w]+),${s.replace(/\$/g,`\\$`)},`));if(!g)return console.error(`patch: toolsets: computeToolsFilter: failed to extract init var from merge call`),null;let _=`${i}=()=>{let ${a}=${o}.getState(),${s}=${c}(${a}.toolPermissionContext,${a}.mcp.tools),${l}=${u}(${g[1]},${s},${a}.toolPermissionContext.mode);const __ts=${p},__tc=${a}.toolset??${m},__tf=(t)=>{globalThis.__tweakcc_toolset={name:__tc,tools:__ts[__tc]};if(__ts.hasOwnProperty(__tc)){const a=__ts[__tc];if(a==="*")return t;return t.filter(d=>a.includes(d.name))}return t};if(!${d})return __tf(${l});return __tf(${f}(${d},${l},!1,!0).resolvedTools)}`,v=r.index,y=v+h.length,b=e.slice(0,v)+_+e.slice(y);return N(e,b,_,v,y),b},Bt=(e,t,n)=>{let r=/`<tool_use_error>Error: No such tool available: \$\{([$\w.]+)\}<\/tool_use_error>`/g,i=e,a=0,o=`__tweakcc_toolErrorMsg`,s=`function ${o}(toolName){var info=globalThis.__tweakcc_toolset;if(info&&info.tools&&info.tools!=="*"&&Array.isArray(info.tools)){return "<tool_use_error>Error: No such tool available: "+toolName+". The active toolset is '"+info.name+"' which only includes: "+info.tools.join(", ")+". Do not attempt to use "+toolName+" again — it will fail. If the user switches toolsets via /toolset, you may retry.</tool_use_error>"}return "<tool_use_error>Error: No such tool available: "+toolName+"</tool_use_error>"};`;if(i=i.replace(r,(e,t)=>(a++,`${o}(${t})`)),a===0)return console.error(`patch: toolsets: toolsetAwareErrors: failed to find error pattern`),null;i=i.replace(/`Error: No such tool available: \$\{([$\w.]+)\}`/g,(e,t)=>`${o}(${t}).replace(/<\\/?tool_use_error>/g,"")`);let c=i.indexOf(`
|
|
331
|
+
`,i.indexOf(`// Version:`));return c===-1?(console.error(`patch: toolsets: toolsetAwareErrors: failed to find insertion point for helper`),null):(i=i.slice(0,c+1)+s+i.slice(c+1),i)},Vt=(e,t,n)=>{let r=It(e);if(r===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let i=R(e);if(!i)return console.error(`patch: toolsets: failed to find React variable`),null;let a=V(e);if(!a)return console.error(`patch: toolsets: failed to find Box component`),null;let o=B(e);if(!o)return console.error(`patch: toolsets: failed to find Text component`),null;let s=Pt(e);if(!s)return console.error(`patch: toolsets: failed to find Select component`),null;let c=Ft(e),l=A(e);if(!l)return console.error(`patch: toolsets: failed to find app state getter`),null;let u=F(e);if(!u)return console.error(`patch: toolsets: failed to find chalk variable`),null;let{appStateUseSelectorFn:d,appStateSetState:f}=l,p=JSON.stringify(t.map(e=>e.name)),m=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(`, `)}`}))),h=`const toolsetComp = ({ onExit, input }) => {
|
|
332
|
+
const currentToolset = ${d}(state => state.toolset) ?? ${n?JSON.stringify(n):`undefined`};
|
|
333
|
+
|
|
334
|
+
const setState = ${f}();
|
|
335
|
+
|
|
336
|
+
// Handle command-line argument
|
|
337
|
+
if (input !== "" && input != null) {
|
|
338
|
+
if (!${p}.includes(input)) {
|
|
339
|
+
onExit(${u}.red(\`\${${u}.bold(input)} is not a valid toolset. Valid toolsets: ${t.map(e=>e.name).join(`, `)}\`));
|
|
340
|
+
return;
|
|
341
|
+
} else {
|
|
342
|
+
setState(prev => ({ ...prev, toolset: input }));
|
|
343
|
+
onExit(\`Toolset changed to \${${u}.bold(input)}\`);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Render interactive UI
|
|
349
|
+
return ${i}.createElement(
|
|
350
|
+
${a},
|
|
351
|
+
{ flexDirection: "column" },
|
|
352
|
+
${c?`${i}.createElement(${c}, { dividerColor: "permission" }),`:`${i}.createElement(${o}, { dimColor: true }, "─".repeat(40)),`}
|
|
353
|
+
${i}.createElement(
|
|
354
|
+
${a},
|
|
355
|
+
{ paddingX: 1, marginBottom: 1, flexDirection: "column" },
|
|
356
|
+
${i}.createElement(${a}, null,
|
|
357
|
+
${i}.createElement(${o}, { bold: true, color: "remember" }, "Select toolset")
|
|
358
|
+
),
|
|
359
|
+
${i}.createElement(${a}, null,
|
|
360
|
+
${i}.createElement(${o}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
|
|
361
|
+
),
|
|
362
|
+
${i}.createElement(${a}, { marginBottom: 1 },
|
|
363
|
+
${i}.createElement(${o}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
|
|
364
|
+
),
|
|
365
|
+
${i}.createElement(${a}, null,
|
|
366
|
+
${i}.createElement(${o}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
|
|
367
|
+
),
|
|
368
|
+
${i}.createElement(${a}, { marginBottom: 1 },
|
|
369
|
+
${i}.createElement(${o}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
|
|
370
|
+
),
|
|
371
|
+
${i}.createElement(${a}, null,
|
|
372
|
+
${i}.createElement(${o}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc. "),
|
|
373
|
+
${i}.createElement(${o}, { dimColor: true }, "Run "),
|
|
374
|
+
${i}.createElement(${o}, { color: "permission" }, "npx tweakcc"),
|
|
375
|
+
${i}.createElement(${o}, { dimColor: true }, " to manage them.")
|
|
376
|
+
),
|
|
377
|
+
${i}.createElement(${a}, { marginBottom: 1 },
|
|
378
|
+
${i}.createElement(${o}, { color: "permission" }, "https://github.com/Piebald-AI/tweakcc")
|
|
379
|
+
),
|
|
380
|
+
${i}.createElement(${a}, { marginBottom: 1 },
|
|
381
|
+
${i}.createElement(${o}, null, "Current toolset: "),
|
|
382
|
+
${i}.createElement(${o}, { bold: true }, currentToolset || "undefined")
|
|
383
|
+
),
|
|
384
|
+
${i}.createElement(${a}, { marginBottom: 1 },
|
|
385
|
+
${i}.createElement(${s}, {
|
|
386
|
+
options: ${m},
|
|
387
|
+
onChange: (input) => {
|
|
388
|
+
setState(prev => ({ ...prev, toolset: input }));
|
|
389
|
+
onExit(\`Toolset changed to \${${u}.bold(input)}\`);
|
|
390
|
+
},
|
|
391
|
+
onCancel: () => onExit(\`Toolset not changed (left as \${${u}.bold(currentToolset)})\`)
|
|
392
|
+
})
|
|
393
|
+
),
|
|
394
|
+
${i}.createElement(${o}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
};`,g=e.slice(0,r)+h+e.slice(r);return N(e,g,h,r,r),g},Ht=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},Ut=(e,t)=>{let n=Ht(e);if(n===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let r=A(e);if(!r)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter`),null;let{appStateUseSelectorFn:i}=r,a=`let currentToolset=${i}(state => state.toolset) ?? ${t?JSON.stringify(t):`undefined`};`,o=e.slice(0,n)+a+e.slice(n);return N(e,o,a,n,n),o},Wt=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(),currentToolset?\` on [\${currentToolset}]\`:""`,o=e.replace(i,a);return o===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(N(e,o,a,t.index,t.index+i.length),o)},Gt=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='currentToolset?`? for shortcuts [${currentToolset}]`:"? for shortcuts"',i=e.replace(n,r);return i===e?(console.error(`patch: toolsets: appendToolsetToShortcutsDisplay: failed to modify shortcuts display`),null):(N(e,i,r,t.index,t.index+n.length),i)},Kt=e=>{let t=R(e);return t?Nt(e,`, {
|
|
398
|
+
aliases: ["change-tools"],
|
|
399
|
+
type: "local-jsx",
|
|
400
|
+
name: "toolset",
|
|
401
|
+
description: "Select a toolset (managed by tweakcc)",
|
|
402
|
+
argumentHint: "[toolset-name]",
|
|
403
|
+
isEnabled: () => true,
|
|
404
|
+
isHidden: false,
|
|
405
|
+
load: () => Promise.resolve().then(() => ({call: (onExit, ctx, input) => {
|
|
406
|
+
return ${t}.createElement(toolsetComp, { onExit, input });
|
|
407
|
+
}})),
|
|
408
|
+
userFacingName() {
|
|
409
|
+
return "toolset";
|
|
410
|
+
}
|
|
411
|
+
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},qt=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},Jt=(e,t)=>{let n=qt(e);if(n===null)return null;let r=A(e);if(!r)return console.error(`patch: addCurrentToolsetAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateUseSelectorFn:i}=r,a=`const currentToolset = ${i}(state => state.toolset) ?? ${t?JSON.stringify(t):`undefined`};`,o=e.slice(0,n)+a+e.slice(n);return N(e,o,a,n,n),o},Yt=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]}},Xt=(e,t,n)=>{let r=Yt(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 N(e,c,s,i,i),c},Zt=(e,t,n,r)=>{if(!t||t.length===0)return e;let i=e;if(i=Lt(i,n),!i)return console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null;if(i=Rt(i,t,n),!i)return console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null;if(i=zt(i,t,n),!i)return console.error(`patch: toolsets: step 2b failed (writeComputeToolsFilter)`),null;let a=Bt(i,t,n);if(a?i=a:console.error(`patch: toolsets: step 2c failed (writeToolsetAwareErrors) — continuing without friendlier errors`),i=Vt(i,t,n),!i)return console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null;if(i=Kt(i),!i)return console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null;if(i=Ut(i,n),!i)return console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null;if(i=Wt(i),!i)return console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null;if(i=Gt(i),!i)return console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null;if(r&&n){if(i=Jt(i,n),!i)return console.error(`patch: toolsets: step 8a failed (addCurrentToolsetAtToolChangeComponentScope)`),null;if(i=Xt(i,r,n),!i)return console.error(`patch: toolsets: step 8b failed (writeModeChangeUpdateToolset)`),null}return i},j=/\{top:\["┌","─","┬","┐"\],middle:\["├","─","┼","┤"\],bottom:\["└","─","┴","┘"\]\}/,M=/top:\["\\u250C","\\u2500","\\u252C","\\u2510"\],middle:\["\\u251C","\\u2500","\\u253C","\\u2524"\],bottom:\["\\u2514","\\u2500","\\u2534","\\u2518"\]/,Qt=/top: \["┌", "─", "┬", "┐"\],\s+middle: \["├", "─", "┼", "┤"\],\s+bottom: \["└", "─", "┴", "┘"\]/,$t=/if\(([$\w]+)\.push\(\.\.\.([$\w]+)\(([$\w]+),!1\)\),([$\w]+)<([$\w]+)\.rows\.length-1\)([$\w]+)\.push\(([$\w]+)\("middle"\)\)/g,en=/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,tn=/([$\w]+)\.push\(([$\w]+)\("top"\)\),/g,nn=/,([$\w]+)\.push\(([$\w]+)\("bottom"\)\),/g,rn=/([$\w]+)\.push\(\s*([$\w]+)\(\s*"top"\s*\)\s*\)\s*,\s*/g,an=/,\s*([$\w]+)\.push\(\s*([$\w]+)\(\s*"bottom"\s*\)\s*\)\s*,/g;function on(e){let t=e,n=!1,r=t;t=t.replace($t,`$1.push(...$2($3,!1))`),t!==r&&(n=!0);let i=t;return t=t.replace(en,`$1.push(...$2($3,!1))`),t!==i&&(n=!0),{result:t,success:n}}function sn(e){let t=e,n=!1,r=t;t=t.replace(tn,``),t!==r&&(n=!0);let i=t;t=t.replace(rn,``),t!==i&&(n=!0);let a=t;t=t.replace(nn,`,`),t!==a&&(n=!0);let o=t;return t=t.replace(an,`,`),t!==o&&(n=!0),{result:t,success:n}}const cn=(e,t)=>{if(t===`default`)return W(`Table format is "default", no patching needed`),null;let n=e,r=0;if(t===`ascii`){if(j.test(n)){let e=n;n=n.replace(j,`{top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]}`),n!==e&&(r++,W(`Patched table border definition object (minified format)`))}else if(M.test(n)){let e=n;n=n.replace(M,`top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]`),n!==e&&(r++,W(`Patched table border definition object (native Unicode format)`))}else if(Qt.test(n)){let e=n;n=n.replace(Qt,`top: ["", "", "", ""],
|
|
412
|
+
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}=on(n);t&&(n=e,r++,W(`Removed inter-row separators`))}{let{result:e,success:t}=sn(n);t&&(n=e,r++,W(`Removed top/bottom border pushes`))}}else if(t===`clean`){if(j.test(n)){let e=n;n=n.replace(j,`{top:["","","",""],middle:["├","─","┼","┤"],bottom:["","","",""]}`),n!==e&&(r++,W(`Patched table border definition for clean format (minified format)`))}else if(M.test(n)){let e=n;n=n.replace(M,`top:["","","",""],middle:["\\u251C","\\u2500","\\u253C","\\u2524"],bottom:["","","",""]`),n!==e&&(r++,W(`Patched table border definition for clean format (native Unicode format)`))}else if(Qt.test(n)){let e=n;n=n.replace(Qt,`top: ["", "", "", ""],
|
|
413
|
+
middle: ["├", "─", "┼", "┤"],
|
|
414
|
+
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}=on(n);t&&(n=e,r++,W(`Removed inter-row separators`))}{let{result:e,success:t}=sn(n);t&&(n=e,r++,W(`Removed top/bottom border pushes`))}}else if(t===`clean-top-bottom`){let{result:e,success:t}=on(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=ln(e,n);if(i!==-1){let{oldEnd:t,newEnd:r}=un(e,n,i),a=n.slice(i,r);N(e,n,a,i,t)}return W(`Table format patch applied: ${r} changes, file size ${e.length} -> ${n.length}`),n};function ln(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 un(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 dn=e=>R(e)?Nt(e,`, {
|
|
415
|
+
type: "local",
|
|
416
|
+
name: "title",
|
|
417
|
+
description: "Set the conversation title",
|
|
418
|
+
isEnabled: () => !0,
|
|
419
|
+
isHidden: !1,
|
|
420
|
+
async call(A, B, I) {
|
|
421
|
+
if (!A)
|
|
422
|
+
throw new Error("Please specify a conversation title.");
|
|
423
|
+
CUR_CONVERSATION_TITLE = A;
|
|
424
|
+
setTerminalTitleOverride(A);
|
|
425
|
+
return {
|
|
426
|
+
type: "text",
|
|
427
|
+
value: \`Conversation title set to \\x1b[1m\${A}\\x1b[0m\`,
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
userFacingName() {
|
|
431
|
+
return "title";
|
|
432
|
+
},
|
|
433
|
+
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),fn=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},pn=e=>{let t=fn(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=z(e),r=`
|
|
434
|
+
function getTweakccBaseDir() {
|
|
435
|
+
const { join: pathJoin } = ${n}('path');
|
|
436
|
+
const { homedir: osHomedir } = ${n}('os');
|
|
437
|
+
const { statSync: fsStatSync, mkdirSync: fsMkdirSync } = ${n}('fs');
|
|
438
|
+
// Prioritize ~/.tweakcc which is the original and default. Only respect
|
|
439
|
+
// XDG_CONFIG_HOME if it doesn't exist.
|
|
440
|
+
let dir;
|
|
441
|
+
let homedirTweakcc = pathJoin(osHomedir(), ".tweakcc");
|
|
442
|
+
try {
|
|
443
|
+
if (fsStatSync(homedirTweakcc).isDirectory()) {
|
|
444
|
+
dir = homedirTweakcc;
|
|
445
|
+
}
|
|
446
|
+
} catch (e) {
|
|
447
|
+
if (e.code == "ENOENT") {
|
|
448
|
+
// Doesn't exist. Move on and see if the XDG one exists.
|
|
449
|
+
} else {
|
|
450
|
+
throw new Error('cannot stat ' + homedirTweakcc + ': ' + e);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Try XDG.
|
|
455
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
456
|
+
// XDG_CONFIG_HOME is set. If it's set and ~/.tweakcc doesn't exist, prefer it.
|
|
457
|
+
const xdgTweakcc = pathJoin(process.env.XDG_CONFIG_HOME, "tweakcc");
|
|
458
|
+
dir = xdgTweakcc;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Create the dir.
|
|
462
|
+
fsMkdirSync(dir, { recursive: true });
|
|
463
|
+
return dir;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const findSummaryEntryForLeafUuid = (filePath, messageUuid) => {
|
|
467
|
+
const { readFileSync: fsReadFileSync, statSync: fsStatSync } = ${n}('fs');
|
|
468
|
+
// Optimization: skip files that are certain to not be tweakcc summary files (which only contain 1 small line).
|
|
469
|
+
if (fsStatSync(filePath).size > 1000) {
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
const lines = fsReadFileSync(filePath, "utf8")
|
|
473
|
+
.split("\\n")
|
|
474
|
+
.map((l) => JSON.parse(l.trim()));
|
|
475
|
+
for (const line of lines) {
|
|
476
|
+
if (line.type == "summary" && line.uuid == messageUuid) {
|
|
477
|
+
return line;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return null;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
const getSummaryFileForLeafMessage = (
|
|
484
|
+
projectDirectory,
|
|
485
|
+
projectSlug,
|
|
486
|
+
messageUuid
|
|
487
|
+
) => {
|
|
488
|
+
const { join: pathJoin } = ${n}('path');
|
|
489
|
+
const { readFileSync: fsReadFileSync, readdirSync: fsReaddirSync } = ${n}('fs');
|
|
490
|
+
try {
|
|
491
|
+
// File contains the uuid
|
|
492
|
+
const summaryFileId = fsReadFileSync(
|
|
493
|
+
pathJoin(getTweakccBaseDir(), "named-sessions", projectSlug, messageUuid),
|
|
494
|
+
"utf8"
|
|
495
|
+
).trim();
|
|
496
|
+
return pathJoin(projectDirectory, summaryFileId + '.jsonl');
|
|
497
|
+
} catch (e) {
|
|
498
|
+
// File not found or can't be accessed, etc. Ignore.
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Just read each file and try to find it.
|
|
502
|
+
for (const file of fsReaddirSync(projectDirectory)) {
|
|
503
|
+
try {
|
|
504
|
+
const pth = pathJoin(projectDirectory, file);
|
|
505
|
+
const summaryObj = findSummaryEntryForLeafUuid(pth);
|
|
506
|
+
if (summaryObj != null && summaryObj.tweakcc != null) {
|
|
507
|
+
// It needs to be a tweakcc one.
|
|
508
|
+
return pth;
|
|
509
|
+
}
|
|
510
|
+
} catch {}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// It doesn't exist.
|
|
514
|
+
return null;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const setTerminalTitleOverride = (title) => {
|
|
518
|
+
process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE = 1;
|
|
519
|
+
if (process.platform === "win32") process.title = 'Claude: ' + title;
|
|
520
|
+
else process.stdout.write('\\x1B]0;Claude: ' + title + '\\x07');
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
let CUR_CONVERSATION_TITLE = "";
|
|
524
|
+
function onNewMessage(projectDir, projectSlug, msg) {
|
|
525
|
+
const { join: pathJoin } = ${n}('path');
|
|
526
|
+
const { readFileSync: fsReadFileSync, writeFileSync: fsWriteFileSync, mkdirSync: fsMkdirSync, renameSync: fsRenameSync } = ${n}('fs');
|
|
527
|
+
const { randomUUID: cryptoRandomUUID } = ${n}('crypto');
|
|
528
|
+
const tweakcc = getTweakccBaseDir();
|
|
529
|
+
|
|
530
|
+
if (msg.parentUuid) {
|
|
531
|
+
const path = getSummaryFileForLeafMessage(
|
|
532
|
+
projectDir,
|
|
533
|
+
projectSlug,
|
|
534
|
+
msg.parentUuid
|
|
535
|
+
);
|
|
536
|
+
if (path) {
|
|
537
|
+
// There's an old file. Update it to the new file.
|
|
538
|
+
const summaryObj = findSummaryEntryForLeafUuid(path);
|
|
539
|
+
summaryObj.leafUuid = msg.uuid;
|
|
540
|
+
if (CUR_CONVERSATION_TITLE != "") {
|
|
541
|
+
summaryObj.summary = CUR_CONVERSATION_TITLE;
|
|
542
|
+
} else {
|
|
543
|
+
CUR_CONVERSATION_TITLE = summaryObj.summary;
|
|
544
|
+
}
|
|
545
|
+
setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
|
|
546
|
+
fsWriteFileSync(path, JSON.stringify(summaryObj));
|
|
547
|
+
|
|
548
|
+
// Update the cache; it points from message ID to summary file ID.
|
|
549
|
+
fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
|
|
550
|
+
recursive: true,
|
|
551
|
+
});
|
|
552
|
+
const oldPath = pathJoin(
|
|
553
|
+
tweakcc,
|
|
554
|
+
"named-sessions",
|
|
555
|
+
projectSlug,
|
|
556
|
+
msg.parentUuid
|
|
557
|
+
);
|
|
558
|
+
const newPath = pathJoin(
|
|
559
|
+
tweakcc,
|
|
560
|
+
"named-sessions",
|
|
561
|
+
projectSlug,
|
|
562
|
+
msg.uuid
|
|
563
|
+
);
|
|
564
|
+
try {
|
|
565
|
+
fsRenameSync(oldPath, newPath);
|
|
566
|
+
return;
|
|
567
|
+
} catch (e) {
|
|
568
|
+
if (e.code == "ENOENT") {
|
|
569
|
+
// named-sessions/{projectSlug} exists, so the error is because the old named-session doesn't exist.
|
|
570
|
+
// So we need to create the new file later.
|
|
571
|
+
// DO NOT return.
|
|
572
|
+
} else {
|
|
573
|
+
throw new Error('cannot rename ' + oldPath + ' -> ' + newPath + ': ' + e);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Only create our summary entry if a custom title has been set. Because we want the auto
|
|
580
|
+
// title generation to kick in if the user hasn't set a title, and the auto title generation
|
|
581
|
+
// won't generate titles for sessions older than the most recently
|
|
582
|
+
if (CUR_CONVERSATION_TITLE != "") {
|
|
583
|
+
setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
|
|
584
|
+
const uuid = cryptoRandomUUID();
|
|
585
|
+
|
|
586
|
+
// Create the summary file.
|
|
587
|
+
const newFilePath = pathJoin(projectDir, uuid + '.jsonl');
|
|
588
|
+
const summaryObj = {
|
|
589
|
+
type: "summary",
|
|
590
|
+
summary: CUR_CONVERSATION_TITLE,
|
|
591
|
+
leafUuid: msg.uuid,
|
|
592
|
+
// This is important.
|
|
593
|
+
tweakcc: null,
|
|
594
|
+
};
|
|
595
|
+
fsWriteFileSync(newFilePath, JSON.stringify(summaryObj));
|
|
596
|
+
|
|
597
|
+
fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
|
|
598
|
+
recursive: true,
|
|
599
|
+
});
|
|
600
|
+
fsWriteFileSync(
|
|
601
|
+
pathJoin(tweakcc, "named-sessions", projectSlug, msg.uuid),
|
|
602
|
+
uuid
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
`,i=e.slice(0,t)+r+e.slice(t);return N(e,i,r,t,t),i},mn=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]}},hn=e=>{let t=mn(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=z(e),{location:r,messageVar:i}=t,a=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
|
|
608
|
+
const projectDir = pathDirname(this.sessionFile);
|
|
609
|
+
const projectSlug = pathBasename(projectDir);
|
|
610
|
+
onNewMessage(projectDir, projectSlug, ${i});
|
|
611
|
+
`,o=e.slice(0,r)+a+e.slice(r);return N(e,o,a,r,r),o},gn=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}},_n=e=>{let t=gn(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=z(e),{orLocation:r,loopLocation:i,messageVar:a,fileListVar:o}=t,s=e,c=`const { readFileSync: fsReadFileSync } = ${n}('fs');
|
|
612
|
+
const tweakccSummaries = new Set();
|
|
613
|
+
for (const file of ${o}) {
|
|
614
|
+
const contents = fsReadFileSync(file, "utf8").trim();
|
|
615
|
+
if (contents.includes("\\n")) continue;
|
|
616
|
+
let obj;
|
|
617
|
+
try {
|
|
618
|
+
obj = JSON.parse(contents);
|
|
619
|
+
} catch {
|
|
620
|
+
// Skip invalid files.
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
|
|
624
|
+
tweakccSummaries.add(obj.leafUuid);
|
|
625
|
+
}
|
|
626
|
+
`;s=s.slice(0,i)+c+s.slice(i),N(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 N(s,d,u,l,l),d},vn=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):(N(e,r,n,t.index,t.index+63),r)},yn=e=>{let t=e;if(t=dn(t),!t)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(t=pn(t),!t)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(t=hn(t),!t)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(t=_n(t),!t)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let n=vn(t);return n?t=n:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),t},bn=e=>{let t=e.match(/,[$\w]+\.createElement\([$\w]+,\{isBeforeFirstMessage:!1\}\),/);return t&&t.index!==void 0?{startIndex:t.index,endIndex:t.index+t[0].length}:null},xn=e=>{let t=bn(e);if(t){let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return N(e,n,`,`,t.startIndex,t.endIndex),n}let n=/(function ([$\w]+)\(\)\{)(?=[^}]{0,500}Apple_Terminal)/g,r;for(;(r=n.exec(e))!==null;){let t=r.index+r[0].length;if(e.slice(t,t+5e3).includes(`Welcome to Claude Code`)){let n=t,r=`return null;`,i=e.slice(0,n)+r+e.slice(n);return N(e,i,r,n,n),i}}return console.error(`patch: hideStartupBanner: failed to find startup banner component`),null},Sn=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:[]}},Cn=e=>{let t=Sn(e);if(!t)return null;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return N(e,r,n,t.startIndex,t.endIndex),r},wn=e=>{let t=[],n=/▛███▜|\\u259B\\u2588\\u2588\\u2588\\u259C/gi.exec(e);if(!n)return t;let r=n.index,i=Math.max(0,r-2e3),a=e.slice(i,r),o=/function ([$\w]+)\([^)]*\)\{/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(!s)return console.error(`patch: hideStartupClawd: failed to find inner Clawd function`),t;let l=s[1],u=/function ([$\w]+)\([^)]*\)\{/g,d,f=null;for(;(d=u.exec(e))!==null;){let t=d.index+d[0].length,n=e.slice(t,t+500),r=n.indexOf(`createElement(${l},`);if(r===-1)continue;let i=n.indexOf(`function `);if(!(i!==-1&&i<r)){f={index:d.index,length:d[0].length};break}}if(f){let e=f.index+f.length;t.push(e)}else{let e=i+s.index+s[0].length;t.push(e)}return t},Tn=e=>{let t=wn(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];N(e,i,r,t,t)}return i},En=e=>{let t=[`<system-reminder>`,`tengu_amber_wren`],n=null;for(let r of t){let t=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=RegExp(`=25000,([\\s\\S]{0,200})${t}`);if(n=e.match(i),n&&n.index!==void 0)break}if(!n||n.index===void 0)return console.error(`patch: increaseFileReadLimit: failed to find 25000 token limit near known anchor`),null;let r=n.index+1;return{startIndex:r,endIndex:r+5}},Dn=e=>{let t=En(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return N(e,r,n,t.startIndex,t.endIndex),r},On=e=>{let t=e.match(/\{content:([$\w]+),startLine:[$\w]+\}\)\{if\(!\1\)return"";let ([$\w]+)=\1\.split\([^)]+\);/);if(t&&t.index!==void 0){let n=t[1],r=t.index+t[0].length,i=e.slice(r).match(/\}(?=function |var |let |const |[$\w]+=[$\w]+\()/);if(i&&i.index!==void 0){let t=r+i.index,a=`return ${n}`,o=e.slice(0,r)+a+e.slice(t);return N(e,o,a,r,t),o}}let n=e.match(/if\(([$\w]+)\.length>=\d+\)return`\$\{\1\}(?:→|\\u2192)\$\{([$\w]+)\}`;return`\$\{\1\.padStart\(\d+," "\)\}(?:→|\\u2192)\$\{\2\}`/);if(n&&n.index!==void 0){let t=`return ${n[2]}`,r=e.slice(0,n.index)+t+e.slice(n.index+n[0].length);return N(e,r,t,n.index,n.index+n[0].length),r}return console.error(`patch: suppressLineNumbers: failed to find line number formatter pattern`),null},kn=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 N(e,o,a,r,i),o},An=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 N(e,i,r,n,n),i},jn=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 N(e,r,n,t.index,t.index+t[0].length),r}let n=e.match(/if\(![$\w]+\("tengu_coral_fern",!1\)\)return\s*(?:null|\[\]);/);if(n&&n.index!==void 0){let t=e.slice(0,n.index)+e.slice(n.index+n[0].length);return N(e,t,``,n.index,n.index+n[0].length),t}return console.error(`patch: sessionMemory: failed to find past sessions gate`),null},Mn=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 N(e,a,n,r,i),a},Nn=e=>{let t=e;return t=P(t,/minimumMessageTokensToInit:1e4\b/g,`minimumMessageTokensToInit:Number(process.env.CC_SM_MINIMUM_MESSAGE_TOKENS_TO_INIT??1e4)`),t=P(t,/minimumTokensBetweenUpdate:5000\b/g,`minimumTokensBetweenUpdate:Number(process.env.CC_SM_MINIMUM_TOKENS_BETWEEN_UPDATE??5000)`),t=P(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},Pn=e=>{let t=An(e);return!t||(t=jn(t),!t)||(t=Mn(t),!t)?null:(t=Nn(t),t)},Fn=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)},In=e=>{let t=Fn(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+`
|
|
627
|
+
${t}({
|
|
628
|
+
name: "remember",
|
|
629
|
+
description: "Review session memories and update CLAUDE.local.md with learnings",
|
|
630
|
+
whenToUse: "When the user wants to save learnings from past sessions",
|
|
631
|
+
userInvocable: true,
|
|
632
|
+
isEnabled: () => true,
|
|
633
|
+
async getPromptForCommand(A) {
|
|
634
|
+
let content = ${s};
|
|
635
|
+
let sessionMemFiles = ${a}(null);
|
|
636
|
+
content += "\\n\\n## Session Memory Files to Review\\n\\n" + (sessionMemFiles.length ? sessionMemFiles.join("\\n") : "None found");
|
|
637
|
+
if (A) content += "\\n\\n## User Arguments\\n\\n" + A;
|
|
638
|
+
return [{ type: "text", text: content }];
|
|
639
|
+
},
|
|
640
|
+
});
|
|
641
|
+
return`+o,l=n.index,u=l+r.length,d=e.slice(0,l)+c+e.slice(u);return N(e,d,c,l,u),d},Ln=e=>{let t=B(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 N(e,o,r,i,a),o},Rn=e=>{let t=e.match(/![$\w]+\(process\.env\.MCP_CONNECTION_NONBLOCKING\)/);return!t||t.index===void 0?null:{startIndex:t.index,endIndex:t.index+t[0].length}},zn=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}},Bn=e=>{let t=Rn(e);if(!t)return e;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return N(e,r,n,t.startIndex,t.endIndex),r},Vn=(e,t)=>{let n=zn(e);if(!n)return null;let r=String(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return N(e,i,r,n.startIndex,n.endIndex),i},Hn=(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\]\)|[$\w]+\.useCallback\(\(\)=>\{if\([$\w]+\.current!==void 0\)clearTimeout\([$\w]+\.current\);[$\w]+\.current=setTimeout\(\([$\w]+,[$\w]+\)=>\{[$\w]+\.current=void 0,[$\w]+\(\)\},300,[$\w]+,\2\)\},\[\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 N(e,h,f,p,m),h},Un=(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(/(([$\w]+)=([$\w]+)\()(.+?)(\),.{0,2000}key:"tokens".{0,200},\2," tokens")/);if(t&&t.index!==void 0)[n,r,,,i,a]=t,o=t.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 any 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 N(e,u,c,o,l),u},Wn=(e,t)=>Gn(e,t)||Kn(e,t),Gn=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=await ([$\w]+)\(\)\.readFile\(\3,\{encoding:"utf-8"\}\);return ([$\w]+)\(\6,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\9,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=`${i},didReroute){try{let ${l}=await ${u}().readFile(${o},{encoding:"utf-8"});return ${d}(${l},${o},${s},${c})}catch(${f}){${n[10]}(${f},${o});if(!didReroute&&(${o}.endsWith("/CLAUDE.md")||${o}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${o}.slice(0,-9)+alt;try{let r=await ${a}(altPath,${s},${c},true);if(r.info)return r}catch{}}}return{info:null,includePaths:[]}}}`,m=n.index,h=m+r.length,g=e.slice(0,m)+p+e.slice(h);return N(e,g,p,m,h),g},Kn=(e,t)=>{let n=e.match(/(function ([$\w]+)\(([$\w]+),([^)]+?))\)(?:.|\n){0,500}Skipping non-text file in @include/);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[4],s=n.index,c=/([$\w]+(?:\(\))?)\.(?:readFileSync|existsSync|statSync)/,l=n[0].match(c),u=null;if(!l&&(u=e.slice(Math.max(0,s-5e3),s).match(c),!u))return console.error(`patch: agentsMd: failed to find fs expression in function or caller`),null;let d=l?l[1]:u?u[1]:`require("fs")`,f=JSON.stringify(t),p=s+r.length,m=e.slice(0,p)+`,didReroute`+e.slice(p);N(e,m,`,didReroute`,p,p);let h=m.slice(s),g=/\.isFile\(\)\)return null/,_=h.match(g)??h.match(/==="EISDIR"\)return null/);if(!_||_.index===void 0)return console.error(`patch: agentsMd: failed to find early return null for injection`),null;let v=!h.match(g),y=`if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${f}){let altPath=${a}.slice(0,-9)+alt;if(${d}.existsSync(altPath)&&${d}.statSync(altPath).isFile())return ${i}(altPath,${o},true);}}`,b=s+_.index,x=_[0],S=v?`==="EISDIR"){${y}return null;}`:`.isFile()){${y}return null;}`;return m=m.slice(0,b)+S+m.slice(b+x.length),N(e,m,S,b,b),m},qn=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;if(/[$\w]+\("yes-accept-edits"\);return null;return/.test(e))return e;let n=e.slice(t,t+3e3),r=n.match(/onChange:\([$\w]+\)=>([$\w]+)\([$\w]+\),onCancel/),i=n.match(/onChange:([$\w]+),onCancel/),a=n.match(/onChange:\([$\w]+\)=>void ([$\w]+)\.current\([$\w]+\),onCancel/),o;if(r)o=r[1];else if(i)o=i[1];else if(a)o=`${a[1]}.current`;else return console.error(`patch: autoAcceptPlanMode: failed to find onChange handler`),null;let s=e.match(/(\}\}\)\)\)\);)(return [$\w]+\.default\.createElement\([$\w]+\.default\.Fragment,null,[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:"Ready to code\?")/);if(s&&s.index!==void 0){let t=`${o}("yes-accept-edits");return null;`,n=s[1]+t+s[2],r=s.index,i=r+s[0].length,a=e.slice(0,r)+n+e.slice(i);return N(e,a,n,r,i),a}let c=e.slice(Math.max(0,t-500),t),l=c.match(/(return [$\w]+\.default\.createElement\([$\w]+,\{flexDirection:"column",tabIndex:0,autoFocus:!0.{0,200}[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:")$/);if(!l){let n=c.lastIndexOf(`return `);if(n===-1)return console.error(`patch: autoAcceptPlanMode: failed to find return before "Ready to code?"`),null;let r=Math.max(0,t-500)+n,i=`${o}("yes-accept-edits");return null;`,a=e.slice(0,r)+i+e.slice(r);return N(e,a,i,r,r),a}let u=Math.max(0,t-500)+l.index,d=`${o}("yes-accept-edits");return null;`,f=e.slice(0,u)+d+e.slice(u);return N(e,f,d,u,u),f},Jn=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 N(e,i,`{}`,n,r),i},Yn=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 N(e,i,``,n,r),i},Xn=e=>{let t=e.split(`
|
|
642
|
+
`),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(`
|
|
643
|
+
`).length:0},Zn=e=>{let t=Xn(e),n=`// SCROLLING FIX PATCH START
|
|
644
|
+
const _origStdoutWrite=process.stdout.write;
|
|
645
|
+
process.stdout.write=function(chunk,encoding,cb){
|
|
646
|
+
if(typeof chunk!=='string'){
|
|
647
|
+
return _origStdoutWrite.call(process.stdout,chunk,encoding,cb);
|
|
648
|
+
}
|
|
649
|
+
const filtered=chunk
|
|
650
|
+
.replace(/\\x1b\\[\\d*S/g,'')
|
|
651
|
+
.replace(/\\x1b\\[\\d*T/g,'')
|
|
652
|
+
.replace(/\\x1b\\[\\d*;?\\d*r/g,'');
|
|
653
|
+
return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
|
|
654
|
+
};
|
|
655
|
+
// SCROLLING FIX PATCH END
|
|
656
|
+
`,r=e.slice(0,t)+n+e.slice(t);return N(e,r,n,t,t),r},Qn=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 N(e,i,r,n,n),i},$n=e=>{let t=e,n=t.match(/,model:([$\w]+)\.enum\(([$\w]+)\)\.optional\(\)/);if(!n||n.index===void 0)return t.match(/let\s+[$\w]+\s*=\s*([$\w]+)\s*&&\s*typeof\s+\1\s*===\s*"string"\s*&&\s*[$\w]+\.includes\(\1\)/)?(console.error(`patch: allowCustomAgentModels: failed to find Zod enum pattern`),null):t;let r=n[1],i=n[2],a=`,model:${r}.string().optional()`,o=n.index,s=o+n[0].length;t=t.slice(0,o)+a+t.slice(s),N(e,t,a,o,s);let c=i.replace(/\$/g,`\\$`),l=RegExp(`([;)}])let\\s+([\\$\\w]+)\\s*=\\s*([\\$\\w]+)\\s*&&\\s*typeof\\s+\\3\\s*===\\s*"string"\\s*&&\\s*${c}\\.includes\\(\\3\\)`),u=t,d=t.match(l);if(!d||d.index===void 0)return console.error(`patch: allowCustomAgentModels: failed to find model validation flag pattern`),null;let f=d[1],p=d[2],m=d[3],h=`${f}let ${p}=${m}&&typeof ${m}==="string"`,g=d.index,_=g+d[0].length;return t=t.slice(0,g)+h+t.slice(_),N(u,t,h,g,_),t},er=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_amber_quartz"/);if(t&&t.index!==void 0){let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return N(e,i,r,n,n),i}let n=e.match(/function [$\w]+\(\)\{return![$\w]+\("tengu_amber_quartz_disabled"/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,t)+r+e.slice(t);return N(e,i,r,t,t),i}return console.error(`patch: voiceMode: failed to find tengu_amber_quartz gate`),null},tr=e=>{let t=e.match(/if\([$\w]+\("tengu_sotto_voce",!1\)\)/);if(!t||t.index===void 0)return e;let n=`if(!0)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return N(e,r,n,t.index,t.index+t[0].length),r},nr=(e,t)=>{let n=er(e);return!n||t&&(n=tr(n),!n)?null:n},rr=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return N(e,i,r,n,n),i},ir=e=>{let t=e.match(/reason:"server did not declare claude\/channel capability"\};?/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find gateChannelServer capability check`),null;let n=t.index+t[0].length,r=`return{action:"register"};`,i=e.slice(0,n)+r+e.slice(n);return N(e,i,r,n,n),i},ar=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor_permissions",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor_permissions gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return N(e,i,r,n,n),i},or=e=>{let t=e.match(/Experimental[^"]*?inbound messages will be pushed into this session, this carries prompt injection risks\. Restart Claude Code without /);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find ChannelsNotice warning text`),null;let n=`Channels active. Restart Claude Code without `,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return N(e,a,n,r,i),a},sr=e=>{let t=e.match(/if\(![$\w]+\.dev\)[$\w]+\.push\(\{[$\w]+:[$\w]+,[$\w]+:"server: entries need --dangerously-load-development-channels"\}\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find server dev-flag warning block`),null;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+``+e.slice(r);return N(e,i,``,n,r),i},cr=e=>{let t=rr(e);return!t||(t=ir(t),!t)||(t=ar(t),!t)?null:(t=or(t)??t,t=sr(t)??t,t)},lr=async e=>{if(!e.cliPath){W(`backupClijs: Skipping for native installation (no cliPath)`);return}await ri(),W(`Backing up cli.js to ${ei}`),await i.copyFile(e.cliPath,ei),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version})},ur=async e=>{e.nativeInstallationPath&&(await ri(),W(`Backing up native binary to ${X}`),await i.copyFile(e.nativeInstallationPath,X),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},dr=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(ei);return await K(e.cliPath,t,`restore`),await et(),await $(e=>{e.changesApplied=!1}),!0},fr=async e=>{if(!e.nativeInstallationPath)return W(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await Kr(X))return W(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;W(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await i.readFile(X);return await K(e.nativeInstallationPath,t,`restore`),!0},pr=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16))),N=(t,n,r,i,a,o=40)=>{if(!Mr())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=pr(u),p=pr(d);if(f===p){Nr()&&(G(`
|
|
657
|
+
--- Diff ---`),G(e.blue(`UNCHANGED: `)+e.dim(f)),G(`--- End Diff ---
|
|
658
|
+
`));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 ee=f.length-S,te=p.length-C,ne=Math.min(ee,te,o),re=Math.max(0,v-o),ie=Math.min(f.length,S+ne),ae=Math.max(0,b-o),oe=Math.min(p.length,C+ne),se=h(f.slice(re,ie),p.slice(ae,oe)),w=``;for(let t of se)if(!t.added)if(t.removed)if(t.value.includes(`
|
|
659
|
+
`)){let n=t.value.split(`
|
|
660
|
+
`);n.forEach((t,r)=>{t&&(w+=e.bgRed.white(t)),r<n.length-1&&(w+=e.bgRed.dim(`\\n`)+`
|
|
661
|
+
`)})}else w+=e.bgRed.white(t.value);else w+=e.dim(t.value);let T=``;for(let t of se)if(t.added)if(t.value.includes(`
|
|
662
|
+
`)){let n=t.value.split(`
|
|
663
|
+
`);n.forEach((t,r)=>{t&&(T+=e.bgGreen.black(t)),r<n.length-1&&(T+=e.bgGreen.dim(`\\n`)+`
|
|
664
|
+
`)})}else T+=e.bgGreen.black(t.value);else t.removed||(T+=e.dim(t.value));G(`
|
|
665
|
+
--- Diff ---`),G(e.red(`OLD: `)+w),G(e.green(`NEW: `)+T),G(`--- End Diff ---
|
|
666
|
+
`)},P=(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),N(a,s,c,t,t+i)}return s},F=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},mr=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e4),r=Array.from(n.matchAll(/(?:var |,)([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/g));if(r.length>0){let e=r[0][1];for(let t of r)t[1].length<e.length&&(e=t[1]);return e}console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},hr=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]},gr=e=>{let t=hr(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 I=null,L=null;const R=e=>{if(I!=null)return I;let t=mr(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),I=void 0;return}let n=hr(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),I=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${U(t)}\\(${U(n)}\\(\\),1\\)`),i=e.match(r);if(i)return I=i[1],I;let a=gr(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),I=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})`),I=void 0;return}return I=s[1],I},_r=()=>{I=null},vr=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]},z=e=>{if(L!=null)return L;let t=vr(e);return t?(L=t,L):(L=`require`,L)},yr=()=>{L=null},br=()=>{_r(),yr()},B=e=>{let t=e.match(/\bfunction ([$\w]+).{0,30}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]},V=e=>{let t=e.match(/function ([$\w]+)\(.{0,2000}[^$\w]([$\w]+)=[$\w]+(?:\.default)?\.createElement\("ink-box".{0,300}?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];let i=e.match(/function ([$\w]+)\([$\w]+\)\{let [$\w]+=[$\w]+(?:\.[$\w]+)?\(\d+\).{0,3000}createElement\("ink-box"/);if(i)return i[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 xr=[{id:`verbose-property`,name:`Verbose property`,group:H.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{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:`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:`model-customizations`,name:`Model customizations`,group:H.MISC_CONFIGURABLE,description:`Access all Claude models with /model, not just latest 3`},{id:`show-more-items-in-select-menus`,name:`Show more items in select menus`,group:H.MISC_CONFIGURABLE,description:`Show 25 items in select menus instead of default 5`},{id:`context-limit`,name:`Context limit`,group:H.MISC_CONFIGURABLE,description:`Override the 200K context limit via CLAUDE_CODE_CONTEXT_LIMIT env var (set before launching CC)`},{id:`patches-applied-indication`,name:`Patches applied indication`,group: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:`allow-custom-agent-models`,name:`Allow custom agent models`,group:H.FEATURES,description:`Allow arbitrary model names in custom agent frontmatter (e.g. gemini-2.5-flash)`},{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`},{id:`voice-mode`,name:`Voice mode`,group:H.FEATURES,description:`Enable /voice command for speech-to-text input (hold Space to record)`},{id:`channels-mode`,name:`Channels mode`,group:H.FEATURES,description:`Enable MCP channel notifications (--channels without allowlist or dev flag)`}],Sr=()=>[...xr],U=e=>e.replace(/\$/g,`\\$`),Cr=(e,t,n)=>{let r=[];for(let i of xr){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}},wr=async(e,t,n)=>{let i;if(t.nativeInstallationPath){await fr(t);let e=!1;try{await r.stat(X),e=!0}catch{}let n=e?X: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(J,`native-claudejs-orig.js`);a.writeFileSync(c,o),W(`Saved original extracted JS from native to: ${c}`),i=o.toString(`utf8`)}else{if(await dr(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);i=await r.readFile(t.cliPath,{encoding:`utf8`})}let o=[],c=await kt(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=e.settings.misc?.enableModelCustomizations??!0,g={"verbose-property":{fn:e=>Te(e)},"context-limit":{fn:e=>w(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Me(e)},"thinking-block-styling":{fn:e=>Ln(e),condition:t.version==null||D(t.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>jt(e)},"statusline-update-throttle":{fn:t=>Hn(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"patches-applied-indication":{fn:e=>Ve(e,`4.0.13`,d,p,m)},"model-customizations":{fn:e=>Dr(e),condition:h},"show-more-items-in-select-menus":{fn:e=>ae(e,25),condition:h},"table-format":{fn:e=>cn(e,f),condition:f!==`default`},themes:{fn:t=>se(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(x.themes))},"thinking-verbs":{fn:t=>ve(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs},"thinker-format":{fn:t=>le(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs},"thinker-symbol-chars":{fn:t=>fe(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(x.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>pe(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==x.thinkingStyle.updateInterval&&(t.version==null||D(t.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>he(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(x.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>de(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==x.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>T(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`)},"subagent-models":{fn:t=>Le(t,e.settings.subagentModels),condition:!!e.settings.subagentModels},"thinking-visibility":{fn:e=>Ne(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>xn(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>Cn(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>Tn(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>Dn(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>On(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>kn(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>Un(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>In(e),condition:!!e.settings.misc?.enableRememberSkill&&!!t.version&&D(t.version,`2.1.42`)<0},"agents-md":{fn:t=>Wn(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>qn(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Jn(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Yn(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>Zn(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"allow-custom-agent-models":{fn:e=>$n(e),condition:!!e.settings.misc?.allowCustomAgentModels},"worktree-mode":{fn:e=>Qn(e),condition:!!e.settings.misc?.enableWorktreeMode&&!!t.version&&D(t.version,`2.1.51`)<0},"session-memory":{fn:e=>Pn(e),condition:!!e.settings.misc?.enableSessionMemory},toolsets:{fn:t=>Zt(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Bn(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking},"mcp-batch-size":{fn:t=>Vn(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>ye(t,e.settings.userMessageDisplay),condition:!!e.settings.userMessageDisplay},"input-pattern-highlighters":{fn:t=>Ce(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>yn(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!!(t.version&&D(t.version,`2.0.64`)<0)},"voice-mode":{fn:t=>nr(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>cr(e),condition:!!e.settings.misc?.enableChannelsMode}},{content:_,results:b}=Cr(i,g,n);if(i=_,o.push(...b),t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=s.join(J,`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 K(t.cliPath,i,`patch`)}return{config:await $(e=>{e.changesApplied=!0}),results:o}},Tr=[{value:`claude-opus-4-6`,label:`Opus 4.6`,description:`Claude Opus 4.6 (February 2026)`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6`,description:`Claude Sonnet 4.6 (February 2026)`},{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`,description:`Claude Haiku 4.5 (October 2025)`},{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],Er=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-1500),i=e.slice(r,t.index),a=`(?:let|var|const) ${U(n)}=.+?;`,o=RegExp(`function [$\\w]+\\([^)]*\\)\\{${a}`,`g`),s=null,c;for(;(c=o.exec(i))!==null;)s=c;return s?{insertionIndex:r+s.index+s[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with ${n}`),null)},Dr=e=>{let t=Er(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Tr.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return N(e,a,i,n,n),a};let Or=!1,kr=!1,Ar=!1;const jr=()=>Or,Mr=()=>kr,Nr=()=>Ar,Pr=()=>{Or=!0},Fr=()=>{kr=!0,Or=!0},Ir=()=>{Ar=!0},W=(e,...t)=>{jr()&&console.log(e,...t)},G=(e,...t)=>{Mr()&&console.log(e,...t)};function Lr(){try{let e=u.join(d.homedir(),`.claude.json`);return JSON.parse(l.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Rr(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 zr(){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 Br(){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=Tr.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Vr(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 Hr(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 Ur(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 Wr(e){if(!Ur(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 Gr(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 K(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 Kr(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 qr=e=>e.startsWith(`~`)?u.join(d.homedir(),e.slice(1)):e,Jr=(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]},Yr=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function q(e,t){if(e==null)return t;if(typeof t!=`object`||!t)return e;if(Array.isArray(t))return Array.isArray(e)?e:t;let n={...e};for(let e of Object.keys(t)){let r=t[e];e in n?typeof r==`object`&&r&&!Array.isArray(r)&&(n[e]=q(n[e],r)):n[e]=r}return n}const Xr=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)},Zr=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function Qr(){try{let e=await i.readFile(Y,`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 ri(),await i.writeFile(Y,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const $r=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return qr(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},J=$r(),Y=c.join(J,`config.json`),ei=c.join(J,`cli.js.backup`),X=c.join(J,`native-binary.backup`),Z=c.join(J,`system-prompts`),ti=c.join(J,`prompt-data-cache`),ni=()=>{let n=J,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
|
+
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.
|
|
668
|
+
`)))},ri=async()=>{await i.mkdir(J,{recursive:!0}),await i.mkdir(Z,{recursive:!0});let e=c.join(J,`.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 ii=()=>({ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:x}),ai=e=>{let t=e?.settings?.thinkingVerbs;t?.punctuation&&(t.format=`{}`+t.punctuation,delete t.punctuation),e.settings=q(e.settings,x),e.settings.inputPatternHighlighters&&(e.settings.inputPatternHighlighters=e.settings.inputPatternHighlighters.map(e=>q(e,S))),e.settings.toolsets&&(e.settings.toolsets=e.settings.toolsets.map(e=>q(e,C))),e.settings.themes&&(e.settings.themes=e.settings.themes.map(e=>q(e,ee))),Xr(e),Zr(e),delete e.settings.launchText},oi=async()=>{let e=ii();try{W(`Reading config at ${Y}`),ni();let t=await i.readFile(Y,`utf8`),n={...e,...JSON.parse(t)},r=JSON.stringify(n);ai(n);let a=await tt(Z);return a&&(n.changesApplied=!1),(JSON.stringify(n)!==r||a)&&await si(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 ${Y}`),Q||=await oi(),e(Q),Q.lastModified=new Date().toISOString(),await si(Q),Q),si=async e=>{try{e.lastModified=new Date().toISOString(),await ri(),await i.writeFile(Y,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}},ci=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(Y,`utf8`);n=JSON.parse(e)}catch{n=ii()}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={...ii(),ccVersion:n.ccVersion||``,ccInstallationPath:n.ccInstallationPath||null,settings:{...x,...a},remoteConfig:o};return ai(s),W(`Successfully fetched and parsed config from ${e}`),s};export{v as $,H as A,P as B,Nr as C,K as D,Vr as E,F,fr as G,lr as H,B as I,mt as J,Tt as K,mr as L,Sr as M,br as N,Hr as O,V as P,ee as Q,R,jr as S,Wr as T,ur as U,N as V,dr as W,et as X,ft as Y,x as Z,Fr as _,Z as a,Br as b,oi as c,Jr as d,y as et,W as f,Ir as g,Pr as h,X as i,wr as j,Rr as k,$ as l,Kr as m,J as n,ci as o,q as p,ht as q,Y as r,$r as s,ei as t,b as tt,Qr as u,zr as v,Ur as w,Gr as x,Lr as y,z};
|