tweakcc-fixed 2.0.10 → 2.0.11

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.
@@ -0,0 +1,723 @@
1
+ import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c from"node:fs";import*as l from"node:path";import u from"node:path";import*as d from"fs";import*as f from"path";import*as p from"os";import*as m from"child_process";import*as h from"crypto";import{spawnSync as g}from"node:child_process";import _ from"gray-matter";import{fileURLToPath as v}from"node:url";import{Worker as y}from"node:worker_threads";import{diffWordsWithSpace as b}from"diff";let x=null;async function S(){if(x!==null)return x;try{return await import(`node-lief`),x=await import(`./nativeInstallation-BsZsVFzv.mjs`),x}catch(e){return W(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&W(e),null}}async function C(e,t){let n=await S();return n?n.extractClaudeJsFromNativeInstallation(e,t):{data:null,clearBytecode:!1,error:`node-lief native module unavailable on this platform/runtime (cannot extract from native installs)`}}async function w(e,t,n,r){let i=await S();if(!i)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");i.repackNativeInstallation(e,t,n,r)}async function T(e){let t=await S();return t?t.resolveNixBinaryWrapper(e):null}const E={themes:[{name:`Dark mode`,id:`dark`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(253,93,177)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(235,159,127)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(147,165,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(177,195,255)`,permission:`rgb(177,185,249)`,permissionShimmer:`rgb(207,215,255)`,planMode:`rgb(72,150,140)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(177,185,249)`,remember:`rgb(177,185,249)`,background:`rgb(0,204,204)`,success:`rgb(78,186,101)`,error:`rgb(255,107,128)`,warning:`rgb(255,193,7)`,warningShimmer:`rgb(255,223,57)`,diffAdded:`rgb(34,92,43)`,diffRemoved:`rgb(122,41,54)`,diffAddedDimmed:`rgb(71,88,74)`,diffRemovedDimmed:`rgb(105,72,77)`,diffAddedWord:`rgb(56,166,96)`,diffRemovedWord:`rgb(179,89,107)`,diffAddedWordDimmed:`rgb(46,107,58)`,diffRemovedWordDimmed:`rgb(139,57,69)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(177,185,249)`,rate_limit_empty:`rgb(80,83,112)`}},{name:`Light mode`,id:`light`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(255,0,135)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(245,149,117)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(87,105,247)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(117,135,255)`,permission:`rgb(87,105,247)`,permissionShimmer:`rgb(137,155,255)`,planMode:`rgb(0,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(87,105,247)`,remember:`rgb(0,0,255)`,background:`rgb(0,153,153)`,success:`rgb(44,122,57)`,error:`rgb(171,43,63)`,warning:`rgb(150,108,30)`,warningShimmer:`rgb(200,158,80)`,diffAdded:`rgb(105,219,124)`,diffRemoved:`rgb(255,168,180)`,diffAddedDimmed:`rgb(199,225,203)`,diffRemovedDimmed:`rgb(253,210,216)`,diffAddedWord:`rgb(47,157,68)`,diffRemovedWord:`rgb(209,69,75)`,diffAddedWordDimmed:`rgb(144,194,156)`,diffRemovedWordDimmed:`rgb(232,165,173)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(240, 240, 240)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(87,105,247)`,rate_limit_empty:`rgb(39,47,111)`}},{name:`Light mode (ANSI colors only)`,id:`light-ansi`,colors:{autoAccept:`ansi:magenta`,bashBorder:`ansi:magenta`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blue`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blue`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyan`,ide:`ansi:blueBright`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:black`,inverseText:`ansi:white`,inactive:`ansi:blackBright`,subtle:`ansi:blackBright`,suggestion:`ansi:blue`,remember:`ansi:blue`,background:`ansi:cyan`,success:`ansi:green`,error:`ansi:red`,warning:`ansi:yellow`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:red`,blue_FOR_SUBAGENTS_ONLY:`ansi:blue`,green_FOR_SUBAGENTS_ONLY:`ansi:green`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellow`,purple_FOR_SUBAGENTS_ONLY:`ansi:magenta`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyan`,professionalBlue:`ansi:blueBright`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:white`,bashMessageBackgroundColor:`ansi:whiteBright`,memoryBackgroundColor:`ansi:white`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:black`}},{name:`Dark mode (ANSI colors only)`,id:`dark-ansi`,colors:{autoAccept:`ansi:magentaBright`,bashBorder:`ansi:magentaBright`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blueBright`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blueBright`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyanBright`,ide:`ansi:blue`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:whiteBright`,inverseText:`ansi:black`,inactive:`ansi:white`,subtle:`ansi:white`,suggestion:`ansi:blueBright`,remember:`ansi:blueBright`,background:`ansi:cyanBright`,success:`ansi:greenBright`,error:`ansi:redBright`,warning:`ansi:yellowBright`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:redBright`,blue_FOR_SUBAGENTS_ONLY:`ansi:blueBright`,green_FOR_SUBAGENTS_ONLY:`ansi:greenBright`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellowBright`,purple_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyanBright`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:blackBright`,bashMessageBackgroundColor:`ansi:black`,memoryBackgroundColor:`ansi:blackBright`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:white`}},{name:`Light mode (colorblind-friendly)`,id:`light-daltonized`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(0,102,204)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(51,102,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(101,152,255)`,permission:`rgb(51,102,255)`,permissionShimmer:`rgb(101,152,255)`,planMode:`rgb(51,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(51,102,255)`,remember:`rgb(51,102,255)`,background:`rgb(0,153,153)`,success:`rgb(0,102,153)`,error:`rgb(204,0,0)`,warning:`rgb(255,153,0)`,warningShimmer:`rgb(255,183,50)`,diffAdded:`rgb(153,204,255)`,diffRemoved:`rgb(255,204,204)`,diffAddedDimmed:`rgb(209,231,253)`,diffRemovedDimmed:`rgb(255,233,233)`,diffAddedWord:`rgb(51,102,204)`,diffRemovedWord:`rgb(153,51,51)`,diffAddedWordDimmed:`rgb(102,153,204)`,diffRemovedWordDimmed:`rgb(204,153,153)`,red_FOR_SUBAGENTS_ONLY:`rgb(204,0,0)`,blue_FOR_SUBAGENTS_ONLY:`rgb(0,102,204)`,green_FOR_SUBAGENTS_ONLY:`rgb(0,204,0)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,204,0)`,purple_FOR_SUBAGENTS_ONLY:`rgb(128,0,128)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,128,0)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,102,178)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(0,178,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(220, 220, 220)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(51,102,255)`,rate_limit_empty:`rgb(23,46,114)`}},{name:`Dark mode (colorblind-friendly)`,id:`dark-daltonized`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(51,153,255)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(153,204,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(183,224,255)`,permission:`rgb(153,204,255)`,permissionShimmer:`rgb(183,224,255)`,planMode:`rgb(102,153,153)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(153,204,255)`,remember:`rgb(153,204,255)`,background:`rgb(0,204,204)`,success:`rgb(51,153,255)`,error:`rgb(255,102,102)`,warning:`rgb(255,204,0)`,warningShimmer:`rgb(255,234,50)`,diffAdded:`rgb(0,68,102)`,diffRemoved:`rgb(102,0,0)`,diffAddedDimmed:`rgb(62,81,91)`,diffRemovedDimmed:`rgb(62,44,44)`,diffAddedWord:`rgb(0,119,179)`,diffRemovedWord:`rgb(179,0,0)`,diffAddedWordDimmed:`rgb(26,99,128)`,diffRemovedWordDimmed:`rgb(128,21,21)`,red_FOR_SUBAGENTS_ONLY:`rgb(255,102,102)`,blue_FOR_SUBAGENTS_ONLY:`rgb(102,178,255)`,green_FOR_SUBAGENTS_ONLY:`rgb(102,255,102)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,255,102)`,purple_FOR_SUBAGENTS_ONLY:`rgb(178,102,255)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,178,102)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,153,204)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(102,204,204)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(153,204,255)`,rate_limit_empty:`rgb(69,92,115)`}},{name:`Monochrome`,id:`monochrome`,colors:{autoAccept:`rgb(200,200,200)`,bashBorder:`rgb(180,180,180)`,claude:`rgb(255,255,255)`,claudeShimmer:`rgb(230,230,230)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(200,200,200)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(220,220,220)`,permission:`rgb(200,200,200)`,permissionShimmer:`rgb(220,220,220)`,planMode:`rgb(180,180,180)`,ide:`rgb(190,190,190)`,promptBorder:`rgb(160,160,160)`,promptBorderShimmer:`rgb(180,180,180)`,text:`rgb(255,255,255)`,inverseText:`rgb(40,40,40)`,inactive:`rgb(120,120,120)`,subtle:`rgb(100,100,100)`,suggestion:`rgb(200,200,200)`,remember:`rgb(200,200,200)`,background:`rgb(180,180,180)`,success:`rgb(220,220,220)`,error:`rgb(180,180,180)`,warning:`rgb(200,200,200)`,warningShimmer:`rgb(220,220,220)`,diffAdded:`rgb(90,90,90)`,diffRemoved:`rgb(60,60,60)`,diffAddedDimmed:`rgb(110,110,110)`,diffRemovedDimmed:`rgb(80,80,80)`,diffAddedWord:`rgb(200,200,200)`,diffRemovedWord:`rgb(80,80,80)`,diffAddedWordDimmed:`rgb(160,160,160)`,diffRemovedWordDimmed:`rgb(70,70,70)`,red_FOR_SUBAGENTS_ONLY:`rgb(200,200,200)`,blue_FOR_SUBAGENTS_ONLY:`rgb(180,180,180)`,green_FOR_SUBAGENTS_ONLY:`rgb(210,210,210)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(190,190,190)`,purple_FOR_SUBAGENTS_ONLY:`rgb(170,170,170)`,orange_FOR_SUBAGENTS_ONLY:`rgb(195,195,195)`,pink_FOR_SUBAGENTS_ONLY:`rgb(205,205,205)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(185,185,185)`,professionalBlue:`rgb(190,190,190)`,rainbow_red:`rgb(240,240,240)`,rainbow_orange:`rgb(230,230,230)`,rainbow_yellow:`rgb(220,220,220)`,rainbow_green:`rgb(210,210,210)`,rainbow_blue:`rgb(200,200,200)`,rainbow_indigo:`rgb(190,190,190)`,rainbow_violet:`rgb(180,180,180)`,rainbow_red_shimmer:`rgb(255,255,255)`,rainbow_orange_shimmer:`rgb(245,245,245)`,rainbow_yellow_shimmer:`rgb(235,235,235)`,rainbow_green_shimmer:`rgb(225,225,225)`,rainbow_blue_shimmer:`rgb(215,215,215)`,rainbow_indigo_shimmer:`rgb(205,205,205)`,rainbow_violet_shimmer:`rgb(195,195,195)`,clawd_body:`rgb(255,255,255)`,clawd_background:`rgb(40,40,40)`,userMessageBackground:`rgb(70,70,70)`,bashMessageBackgroundColor:`rgb(65,65,65)`,memoryBackgroundColor:`rgb(75,75,75)`,rate_limit_fill:`rgb(200,200,200)`,rate_limit_empty:`rgb(90,90,90)`}}],thinkingVerbs:{format:`{}… `,verbs:`Accomplishing.Actioning.Actualizing.Architecting.Baking.Beaming.Beboppin'.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Dilly-dallying.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Mustering.Musing.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzle-dazzling.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Sautéing.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Sock-hopping.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Topsy-turvying.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:`default`,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:`default`,paddingY:`default`,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSwarmMode:!0,enableSessionMemory:!0,enableDreamMode:!0,enableLeanMemoryTypes:!1,fixSummarizeFromHere:!0,fixRewindSummaryHeader:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autoModeClassifierModel:`default`,suppressDeferredTools:!1,claudemdContextOncePerConversation:!0},toolsets:[],defaultToolset:null,planModeToolset:null,subagentModels:{plan:null,explore:null,generalPurpose:null},inputPatternHighlighters:[],inputPatternHighlightersTestText:`Type test text here to see highlighting`,claudeMdAltNames:[`AGENTS.md`,`GEMINI.md`,`CRUSH.md`,`QWEN.md`,`IFLOW.md`,`WARP.md`,`copilot-instructions.md`]},ee={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},te={name:`Unnamed Toolset`,allowedTools:`*`},D=E.themes[0],ne=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},re=e=>{let t=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),[\w$]+=[\w$]+\?[\w$]+:Math\.max\(1,Math\.min\(Math\.max\(6,Math\.floor\(\1\/2\)\),\1-3\)\)/);if(t&&t.index!==void 0){let n=t[1],r=`Math.floor(${n}/2)`,i=t.index+t[0].indexOf(r),a=i+r.length,o=e.slice(0,i)+n+e.slice(a);return P(e,o,n,i,a),o}let n=e.match(/\{rows:([\w$]+),columns:[\w$]+\}=[\w$]+\(\),([\w$]+)=Math\.floor\(\1\/2\)/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(n[2]+`=Math.floor(`),r=n.index+n[0].length,i=`${n[2]}=${n[1]}`,a=e.slice(0,t)+i+e.slice(r);return P(e,a,i,t,r),a}let r=/Math\.max\(1,Math\.floor\(\(([\w$]+)-([\w$]+)\)\/([\w$]+)\)\)/g,i;for(;(i=r.exec(e))!==null;){let t=Math.max(0,i.index-250),n=e.slice(t,i.index);if(!n.includes(`"expanded"?3`)||!n.includes(`"compact"?1:2`))continue;let r=i.index,a=i.index+i[0].length,o=`Math.max(1,${i[1]}-${i[2]})`,s=e.slice(0,r)+o+e.slice(a);return P(e,s,o,r,a),s}return null},O=e=>{let t=e.match(/Math\.max\(1,Math\.floor\(\(([\w$]+)-10\)\/2\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return P(e,r,n,t.index,t.index+t[0].length),r},k=e=>{if(!e.includes(`Math.min(6,Math.max(1,`))return W(`patch: showMoreItemsInSelectMenus: suggestions cap already removed in this CC build — no-op`),e;let t=e.match(/Math\.min\(6,Math\.max\(1,([\w$]+)-3\)\)/);if(!t||t.index===void 0)return null;let n=`Math.max(1,${t[1]}-3)`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return P(e,r,n,t.index,t.index+t[0].length),r},ie=(e,t)=>{let n=ne(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);P(i,r,n,e.startIndex,e.endIndex),i=r}let a=re(i);a?i=a:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find help menu height pattern`);let o=O(i);o?i=o:console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find visibleCount pattern`);let s=k(i);return s&&(i=s),i};function ae(e){let t=-1,n=-1,r=``,i=e.match(/switch\(([$\w]+)\)\{case"(?:light|dark)":[^}]*return [$\w]+;[^}]*default:return [$\w]+\}/);if(i&&i.index!=null)t=i.index,n=t+i[0].length,r=i[1];else{if(e.indexOf(`case"dark":return{"autoAccept"`)===-1&&e.indexOf(`case"light":return{`)===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let i=e.indexOf(`case"dark":return{`)===-1?e.indexOf(`case"light":return{`):e.indexOf(`case"dark":return{`),a=e.slice(Math.max(0,i-200),i).match(/switch\(([$\w]+)\)\{\s*$/);if(!a||a.index==null)return console.error(`patch: themes: failed to find switchMatch (old format)`),null;t=Math.max(0,i-200)+a.index,r=a[1];let o=0;for(let r=t;r<e.length&&r<t+5e4;r++)if(e[r]===`{`&&o++,e[r]===`}`&&(o--,o===0)){n=r+1;break}}if(t===-1||n===-1)return console.error(`patch: themes: failed to find switchMatch`),null;let a=-1,o=-1,s=``,c=e.match(/\[(?:\.\.\.\[\],)?(?:\{"?label"?:"(?:Dark|Light|Auto|Monochrome)[^"]*","?value"?:"[^"]+"\},?)+\]/);if(c&&c.index!==void 0)a=c.index,o=c.index+c[0].length;else{let t=[...e.matchAll(/([$\w]+)=\{label:"(?:Auto|Dark|Light|Monochrome)[^"]*",value:"[^"]+"\}/g)];if(t.length<2)return console.error(`patch: themes: failed to find objArrMatch`),null;let n=t.map(e=>e[1]).map(e=>e.replace(/\$/g,`\\$`)).join(`,`),r=RegExp(`\\[${n}((?:,\\.\\.\\.[^\\]]+)*)\\]`),i=e.match(r);if(!i||i.index===void 0)return console.error(`patch: themes: failed to find objArrMatch (new var-collected form)`),null;a=i.index,o=i.index+i[0].length,s=i[1]}let l=e.match(/(return|[$\w]+=)\{(?:"?(?:[$\w-]+)"?:"(?:Auto |Dark|Light|Monochrome)[^"]*",?)+\}/);return(!l||l.index==null)&&W(`patch: themes: objMatch not found — colors will still apply, theme name map unchanged`),{switchStatement:{startIndex:t,endIndex:n,identifiers:[r]},objArr:{startIndex:a,endIndex:o,identifiers:[s]},obj:l&&l.index!==void 0?{startIndex:l.index,endIndex:l.index+l[0].length,identifiers:[l[1]]}:null}}const oe=(e,t)=>{let n=ae(e);if(!n)return null;if(t.length===0)return e;let r=e;if(n.obj){let i=(n.obj.identifiers?.[0]??`return`)+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),P(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r}let i=n.objArr.identifiers?.[0]??``,a=`[${t.map(e=>JSON.stringify({label:e.name,value:e.id})).join(`,`)}${i}]`;r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),P(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${JSON.stringify(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),P(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},se=`(+process.env.CLAUDE_CODE_CONTEXT_LIMIT||200000)`,ce=e=>{let t=/var ([\w$]+)=200000,([\w$]+)=200000,([\w$]+)=20000,([\w$]+)=32000,([\w$]+)=(128000|64000);/,n=e.match(t);if(n)return e.replace(t,`var ${n[1]}=${se},${n[2]}=${se},${n[3]}=20000,${n[4]}=32000,${n[5]}=${n[6]};`);let r=/var ([\w$]+)=200000,([\w$]+)=20000,([\w$]+)=32000,([\w$]+)=(128000|64000);/,i=e.match(r);return i?e.replace(r,`var ${i[1]}=${se},${i[2]}=20000,${i[3]}=32000,${i[4]}=${i[5]};`):(console.error(`patch: contextLimit: failed to find context limit constants`),null)},le=(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?(P(e,n,`(input border removed)`,0,0),n):(console.error(`patch: input border: failed to find input border pattern`),null)},ue=e=>{let t=(e.match(/overrideMessage:[$\w]+,isCompacting:[$\w]+,compactingHintText:[$\w]+,compactingStartTime:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/)||e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/)||e.match(/overrideMessage:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/)||e.match(/pauseStartTimeRef:[$\w]+,spinnerSuffix:[$\w]+,verbose:[$\w]+,.{300}/))?.index,n=t===void 0?``:e.slice(t,t+2e4),r=n.match(/,([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);if(r&&r.index!=null)return{startIndex:t+r.index+r[1].length+1,endIndex:t+r.index+r[1].length+r[2].length+1,identifiers:[r[3]]};let i=/,([$\w]+)(=(\([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+\))\+"(?:…|\\u2026)")/,a=n.match(i);if(a&&a.index!=null)return{startIndex:t+a.index+a[1].length+1,endIndex:t+a.index+a[1].length+a[2].length+1,identifiers:[a[3]]};let o=n.match(/,([$\w]+)(=`\$\{([$\w]+&&![$\w]+\.isIdle\?[$\w]+\.spinnerVerb\?\?[$\w]+:[$\w]+)\}(?:…|\\u2026) ?`)/);if(o&&o.index!=null)return{startIndex:t+o.index+o[1].length+1,endIndex:t+o.index+o[1].length+o[2].length+1,identifiers:[o[3]]};let s=new RegExp(i.source,`g`),c=[...e.matchAll(s)].filter(t=>{if(t.index==null)return!1;let n=e.slice(Math.max(0,t.index-2500),t.index+1e3);return n.includes(`overrideMessage:`)&&n.includes(`.activeForm`)&&n.includes(`.isIdle`)&&n.includes(`.spinnerVerb`)&&n.includes(`spinnerTip`)});if(c.length===1){let e=c[0];return{startIndex:e.index+e[1].length+1,endIndex:e.index+e[1].length+e[2].length+1,identifiers:[e[3]]}}return console.error(`patch: thinker format: failed to find formatMatch`),null},de=(e,t)=>{let n=ue(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).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 P(e,s,o,r.startIndex,r.endIndex),s},fe=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]]}},pe=(e,t)=>{let n=fe(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 P(e,a,i,n.startIndex,n.endIndex),a},me=(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);P(s,t,a,o[e].startIndex,o[e].endIndex),s=t}return s},he=(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 P(e,o,r,i,a),o},ge=e=>{let t=e.match(/\{("aria-hidden":!0,)?flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,prefix:t[1]??``}},_e=(e,t)=>{let n=ge(e);if(!n)return null;let r=`{${n.prefix}flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return P(e,i,r,n.startIndex,n.endIndex),i},ve=(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 P(e,o,r,i,a),o},ye=(e,t)=>{let n=e.match(/\[("[A-Z][a-z'é\-\\xA-F0-9]+ed",?){6,}\]/);if(!n||n.index===void 0)return console.error(`patch: thinkingVerbs: failed to find past tense verbs pattern`),null;let r=t.map(e=>e.replace(/ing$/,`ed`)),i=JSON.stringify(r),a=n.index,o=a+n[0].length,s=e.slice(0,a)+i+e.slice(o);return P(e,s,i,a,o),s},be=(e,t)=>{let n=ve(e,t);if(n===null)return null;let r=ye(n,t);return r===null?null:r},xe=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),Se=(e,t)=>{let n=V(e);if(!n)return console.error(`patch: userMessageDisplay: failed to find Text component`),null;let r=Ii(e),i=L(e);if(!i)return console.error(`patch: userMessageDisplay: failed to find chalk variable`),null;let a=/(No content found in user prompt message.{0,250}?\b)([$\w]+(?:\.default)?\.createElement.{0,30}\b[$\w]+(?:\.default)?\.createElement.{0,40}">.+?)?(([$\w]+(?:\.default)?\.createElement).{0,200})(\([$\w]+,(?:\{[^{}]+wrap:"wrap"\},([$\w]+)(?:\.trim\(\))?\)\)|\{text:([$\w]+)[^}]*\}\)\)?))/,o=e.match(/(No content found in user prompt message[\s\S]{0,100}?;return )([$\w]+(?:\.default)?)\.createElement\(([$\w]+),(\{flexDirection:"column"[^{}]*\}),([$\w]+(?:\.default)?)\.createElement\(([$\w]+),\{text:([$\w]+)[^{}]*\}\)\)/),s=o?null:e.match(/(No content found in user prompt message.{0,1200}?)([$\w]+)=([$\w]+(?:\.default)?\.createElement)\([$\w]+,\{text:([$\w]+),useBriefLayout:[$\w]+,timestamp:[$\w]+\}\)/),c=o||s?null:e.match(a);if(!o&&(!s||s.index===void 0)&&(!c||c.index===void 0))return console.error(`patch: userMessageDisplay: failed to find user message display pattern`),e;let l=e=>`(typeof ${e}==="object"&&${e}!==null?${e}.head+"\\n("+${e}.hiddenLines+" line"+(${e}.hiddenLines===1?"":"s")+" hidden)\\n"+${e}.tail:${e})`;if(o){let r=o[1],i=o[2],a=o[3],s=o[4],c=o[5],u=o[7],d=s.slice(1,-1),f=/backgroundColor:[^,}]+(?:\?[^,}:]+:[^,}:]+)*/;if(t.backgroundColor===null)d=d.replace(RegExp(`,?${f.source}`),``).replace(/^,|,$/g,``);else if(t.backgroundColor!==`default`){let e=t.backgroundColor.match(/\d+/g);if(e){let t=`"rgb(${e.join(`,`)})"`;d=d.replace(/"userMessageBackground"/g,t)}}let p=[];if(t.borderStyle!==`none`){if(t.borderStyle.startsWith(`topBottom`)){let e=``;t.borderStyle===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),p.push(`borderStyle:${e}`)}else p.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&p.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX!==`default`&&t.paddingX>0&&p.push(`paddingX:${t.paddingX}`),t.paddingY!==`default`&&t.paddingY>0&&p.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&p.push(`alignSelf:"flex-start"`),p.length>0&&(d=d?`${d},${p.join(`,`)}`:p.join(`,`));let m=`{${d}}`,h=[];if(t.foregroundColor===`default`)h.push(`color:"text"`);else{let e=t.foregroundColor.match(/\d+/g);e&&h.push(`color:"rgb(${e.join(`,`)})"`)}if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);e&&h.push(`backgroundColor:"rgb(${e.join(`,`)})"`)}else t.backgroundColor===`default`&&h.push(`backgroundColor:"userMessageBackground"`);t.styling.includes(`bold`)&&h.push(`bold:!0`),t.styling.includes(`italic`)&&h.push(`italic:!0`),t.styling.includes(`underline`)&&h.push(`underline:!0`),t.styling.includes(`strikethrough`)&&h.push(`strikethrough:!0`),t.styling.includes(`inverse`)&&h.push(`inverse:!0`);let g=h.length>0?`{${h.join(`,`)}}`:`null`,_=l(u),v=r+`${i}.createElement(${a},${m},${c}.createElement(${n},${g},${"`"+xe(t.format).replace(/\{\}/g,()=>"${"+_+`}`)+"`"}))`,y=o.index,b=y+o[0].length,x=e.slice(0,y)+v+e.slice(b);return P(e,x,v,y,b),x}if(!r)return console.error(`patch: userMessageDisplay: failed to find Box component`),null;let u=s??c,d=s?s[3]:c[4],f=s?s[4]:c[6]??c[7],p=[],m=t.borderStyle.startsWith(`topBottom`);if(t.borderStyle!==`none`){if(m){let e=``;t.borderStyle===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:t.borderStyle===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),p.push(`borderStyle:${e}`)}else p.push(`borderStyle:"${t.borderStyle}"`);let e=t.borderColor.match(/\d+/g);e&&p.push(`borderColor:"rgb(${e.join(`,`)})"`)}t.paddingX===`default`?p.push(`paddingRight:1`):t.paddingX>0&&p.push(`paddingX:${t.paddingX}`),t.paddingY!==`default`&&t.paddingY>0&&p.push(`paddingY:${t.paddingY}`),t.fitBoxToContent&&p.push(`alignSelf:"flex-start"`);let h=i,g=[];if(t.foregroundColor!==`default`){let e=t.foregroundColor.match(/\d+/g);e&&(h+=`.rgb(${e.join(`,`)})`)}else g.push(`color:"text"`);if(t.backgroundColor!==`default`&&t.backgroundColor!==null){let e=t.backgroundColor.match(/\d+/g);if(e){h+=`.bgRgb(${e.join(`,`)})`;let t=`"rgb(${e.join(`,`)})"`;p.push(`backgroundColor:${t}`),g.push(`backgroundColor:${t}`)}}else t.backgroundColor===`default`&&(p.push(`backgroundColor:"userMessageBackground"`),g.push(`backgroundColor:"userMessageBackground"`));t.styling.includes(`bold`)&&(h+=`.bold`),t.styling.includes(`italic`)&&(h+=`.italic`),t.styling.includes(`underline`)&&(h+=`.underline`),t.styling.includes(`strikethrough`)&&(h+=`.strikethrough`),t.styling.includes(`inverse`)&&(h+=`.inverse`);let _=l(f),v="`"+xe(t.format).replace(/\{\}/g,()=>"${"+_+`}`)+"`",y=`${h}(${v})`,b=p.length>0?`{${p.join(`,`)}}`:`null`,x=g.length>0?`{${g.join(`,`)}}`:`null`,S=s?`${s[2]}=`:``,C=u[1]+`${S}${d}(${r},${b},${d}(${n},${x},${y}))`,w=u.index,T=w+u[0].length,E=e.slice(0,w)+C+e.slice(T);return P(e,E,C,w,T),E},Ce=(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},we=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 P(e,i,r,t.index,t.index+t[0].length),i}let n=/(return ([$\w]+)\.createElement\(([$\w]+),\{key:([$\w]+)),color:([$\w]+)\.highlight\?\.color,dimColor:\5\.highlight\?\.dimColor,inverse:\5\.highlight\?\.inverse\},(\2\.createElement\([$\w]+,null,\5\.text\))\)/,r=e.match(n);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find highlight?.color renderer pattern`),null;let i=r[2],a=r[3],o=r[4],s=r[5];r[6];let c=RegExp(`if\\(${s.replace(`$`,`\\$`)}\\.highlight\\.color\\)return ([$\\w]+)\\.createElement\\([$\\w]+,\\{key:[$\\w]+\\},${s.replace(`$`,`\\$`)}\\.text\\.split\\(""\\)\\.map\\([^)]+\\)\\)`),l=e,u=l.match(c);if(u&&u.index!==void 0){let e=`if(typeof ${s}.highlight?.color==='function')return ${i}.createElement(${a},{key:${o}},${i}.createElement(${a},null,${s}.highlight.color(${s}.text)));`;l=l.slice(0,u.index)+e+l.slice(u.index)}let d=l.match(n);if(!d||d.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to re-find renderer after shimmer patch`),null;let f=d[2],p=d[3],m=d[4],h=d[5],g=d[6],_=`${h}.highlight?.style?${h}.highlight.style(${h}.text):${h}.text`,v=`return ${f}.createElement(${p},{key:${m},color:${h}.highlight?.style?void 0:${h}.highlight?.color,backgroundColor:${h}.highlight?.style?void 0:${h}.highlight?.backgroundColor,dimColor:${h}.highlight?.dimColor,inverse:${h}.highlight?.style?void 0:${h}.highlight?.inverse,bold:${h}.highlight?.style?void 0:${h}.highlight?.bold,italic:${h}.highlight?.style?void 0:${h}.highlight?.italic,underline:${h}.highlight?.style?void 0:${h}.highlight?.underline,strikethrough:${h}.highlight?.style?void 0:${h}.highlight?.strikethrough},${g.replace(`${h}.text`,_)})`,y=l.slice(0,d.index)+v+l.slice(d.index+d[0].length);return P(e,y,`shimmer guard + renderer`,0,0),y},Te=(e,t,n)=>{let r=e.match(/((?:,|;let )[$\w]+=[$\w]+\.useMemo\(\(\)=>\{let [$\w]+=\[\];[\s\S]{0,2000}?)(if\([$\w]+&&[$\w]+&&![$\w]+\)([$\w]+)\.push\(\{start:[$\w]+,end:[$\w]+\+[$\w]+\.length,color:"warning",priority:\d+\})/);if(!r||r.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find useMemo/push pattern`),null;let i=r[3],a=r[1].match(/[^$\w]([$\w]+(?:\.default)?)\.useMemo\(/);if(!a)return console.error(`patch: inputPatternHighlighters: failed to extract React var from useMemo`),null;a[1];let o=Math.max(0,r.index-15e3),s=e.slice(o,r.index),c=/\binputValue:([$\w]+),/g,l=/\binput:([$\w]+),/g,u=[...s.matchAll(c)],d=[...s.matchAll(l)],f=u.at(-1)??d.at(-1)??null;if(!f)return console.error(`patch: inputPatternHighlighters: failed to find input variable pattern (looked for inputValue: and input:)`),null;let p=f[1],m=``;for(let e=0;e<n.length;e++){let r=n[e],a=Ce(t,r),o=r.format??`{MATCH}`;JSON.stringify(o).replace(/\{MATCH\}/g,`"+x+"`);let s=r.foregroundColor;if(s){let e=s.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);s=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let c=s?JSON.stringify(s):`undefined`,l=r.backgroundColor;if(l){let e=l.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(e){let[,t,n,r]=e.map(Number);l=`#${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}${r.toString(16).padStart(2,`0`)}`}}let u=l?JSON.stringify(l):null,d=r.styling??[],f=d.includes(`bold`),h=d.includes(`italic`),g=d.includes(`underline`),_=d.includes(`inverse`),v=d.includes(`dim`),y=d.includes(`strikethrough`),b=r.regex??r.pattern;if(!b){console.error(`patch: inputPatternHighlighters: highlighter "${r.name}" has no regex/pattern; skipping`);continue}let x=r.regexFlags??``;x.includes(`g`)||(x+=`g`);let S;try{S=new RegExp(b,x)}catch(e){console.error(`patch: inputPatternHighlighters: highlighter "${r.name}" has invalid regex; skipping`,e);continue}let C=ha(S);m+=`if(typeof ${p}==="string"){for(let m of ${p}.matchAll(${C})){${i}.push({start:m.index,end:m.index+m[0].length,color:${c}${u?`,backgroundColor:${u}`:``}${f?`,bold:!0`:``}${h?`,italic:!0`:``}${g?`,underline:!0`:``}${_?`,inverse:!0`:``}${v?`,dimColor:!0`:``}${y?`,strikethrough:!0`:``},style:(x)=>${a}(x),priority:100})}}`}if(!m)return console.error(`patch: inputPatternHighlighters: no usable highlighters generated (all skipped)`),null;let h=r[1]+m+r[2],g=e.slice(0,r.index),_=e.slice(r.index+r[0].length),v=g+``+h+_,y=v.indexOf(`for(let m of ${p}.matchAll(`);if(y>-1){let e=[...v.slice(Math.max(0,y-2e3),y).matchAll(/useMemo\(\(\)=>\{/g)];if(e.length>0){let t=Math.max(0,y-2e3)+e[e.length-1].index,n=v.slice(t),r=0;for(let e=0;e<n.length;e++)if(n[e]===`(`)r++;else if(n[e]===`)`&&(r--,r===0)){let n=t+e;v.slice(n-1,n)===`]`&&(v.slice(n-200,n).includes(`,${p}]`)||(v=v.slice(0,n-1)+`,${p}]`+v.slice(n)));break}}}return P(e,v,``+h,r.index,r.index+r[0].length),v},Ee=(e,t)=>{let n=t.filter(e=>e.enabled!==!1);if(n.length===0)return console.error(`patch: inputPatternHighlighters: no enabled highlighters provided`),null;let r=L(e);if(!r)return console.error(`patch: inputPatternHighlighters: failed to find chalk variable`),null;let i;return i=we(e),i?(i=Te(i,r,n),i||(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterCreation failed`),null)):(console.error(`^ patch: inputPatternHighlighters: writeCustomHighlighterImpl failed`),null)},De=e=>{let t=e.match(/(?:[$\w]+\.)?createElement\([$\w]+,\{(?=[^}]*responseLengthRef:)(?=[^}]*spinnerSuffix:)(?=[^}]*thinkingStatus:)(?=[^}]*isCompacting:)[^}]*verbose:[^,}]+[^}]*\}/);if(t&&t.index!==void 0){let e=t[0].match(/verbose:[^,}]+/);if(!e||e.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let n=t.index+e.index;return{startIndex:n,endIndex:n+e[0].length,replacement:`verbose:true`}}let n=e.match(/\{[^{}]{0,400}overrideMessage:[$\w]+,[^{}]{0,200}verbose:([$\w]+)[^{}]{0,200}\}\)\{/);if(n&&n.index!==void 0){let e=n[1],t=n.index+n[0].length;return{startIndex:t,endIndex:t,replacement:`${e}=!0;`}}return console.error(`patch: verbose: failed to find spinner props containing overrideMessage and verbose`),null},Oe=e=>{let t=De(e);if(!t)return null;let n=e.slice(0,t.startIndex)+t.replacement+e.slice(t.endIndex);return P(e,n,t.replacement,t.startIndex,t.endIndex),n},ke=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 P(e,c,s,t.index,t.index+n.length),c},Ae=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 P(e,r,n,t.index,t.index+t[0].length),r},je=e=>{let t=e.match(/(if\s*\(\s*([$\w]+)\s*===\s*"opusplan"\s*\)\s*return\s*"([^"]*Opus[^"]*plan mode[^"]*Sonnet[^"]*)";)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchDescriptionFunction: failed to find description pattern`),null;let[n,,r,i]=t,a=n+`if(${r}==="opusplan[1m]")return"${i} (1M context)";`,o=e.slice(0,t.index)+a+e.slice(t.index+n.length);return P(e,o,a,t.index,t.index+n.length),o},Me=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 P(e,a,i,t.index,t.index+n.length),a},Ne=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 in plan mode, Sonnet (1M context) otherwise"}`,c=n+`if(${r}==="opusplan[1m]")return ${o?`${o}([...${i},${s}])`:`[...${i},${s}]`};`,l=e.slice(0,t.index)+c+e.slice(t.index+n.length);return P(e,l,c,t.index,t.index+n.length),l},Pe=e=>{let t=e.match(/(if\s*\(\s*[$\w]+\s*===\s*null\s*\|\|\s*([$\w]+)\.some\s*\(\s*\(\s*[$\w]+\s*\)\s*=>\s*[$\w]+\.value\s*===\s*[$\w]+\s*\)\s*\)\s*return\s*(?:[$\w]+\()?[$\w]+\)?\s*;)/);if(!t||t.index===void 0)return console.error(`patch: opusplan1m: patchAlwaysShowInModelSelector: failed to find model list check pattern`),null;let[,,n]=t,r=`${n}.push({value:"opusplan",label:"Opus Plan Mode",description:"Use Opus in plan mode, Sonnet otherwise"});${n}.push({value:"opusplan[1m]",label:"Opus Plan Mode 1M",description:"Use Opus in plan mode, Sonnet (1M context) otherwise"});`,i=e.slice(0,t.index)+r+e.slice(t.index);return P(e,i,r,t.index,t.index),i},Fe=e=>{if(e.includes(`"opusplan[1m]"`))return console.log(`patch: opusplan1m: opusplan[1m] already supported natively — skipping`),e;let t=e,n=ke(t);if(n)t=n;else return console.error(`patch: opusplan1m: failed to apply mode switching patch`),null;if(n=Ae(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model aliases list patch`),null;if(n=je(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply description function patch`),null;if(n=Me(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply label function patch`),null;if(n=Ne(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply model selector options patch`),null;if(n=Pe(t),n)t=n;else return console.error(`patch: opusplan1m: failed to apply always-show-in-selector patch`),null;return t},Ie=e=>{if(/case"thinking":\{(?:(?!case")[^]){0,600}isTranscriptMode:true/.test(e))return console.log(`patch: thinkingVisibility: already configured natively — skipping`),e;let t=e.match(/(case"thinking":\{?)(if\(.+?\)return null;)(.{0,400}isTranscriptMode:).+?,/);if(!t||t.index===void 0)return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null;let n=t[1]+t[3]+`true,`,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return P(e,a,n,r,i),a},Le=(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].slice(0,-1)+JSON.stringify(t),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return P(e,o,r,i,a),o},Re=(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].slice(0,-1)+JSON.stringify(t),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return P(e,o,r,i,a),o},ze=(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*)"[^"]+"/,(e,n)=>n+JSON.stringify(t))+i:r+`${r.trim().endsWith(`,`)?``:`,`}model:`+JSON.stringify(t)+i;let o=n.index,s=o+n[0].length,c=e.slice(0,o)+a+e.slice(s);return P(e,c,a,o,s),c},Be=(e,t)=>{let n=e;if(t.plan){let e=Le(n,t.plan);if(e===null)return null;n=e}if(t.explore){let e=Re(n,t.explore);if(e===null)return null;n=e}if(t.generalPurpose){let e=ze(n,t.generalPurpose);if(e===null)return null;n=e}return n},Ve=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}},He=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}},Ue=e=>{let t=e.match(/"Claude Code".{0,200}\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find version display for patch 3`),null;let n={index:t.index},r=Math.max(0,n.index-5e3),i=e.slice(r,n.index),a=Array.from(i.matchAll(/[};]\s*function ([$\w]+)\(/g));if(a.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let o=a[a.length-1][1],s=RegExp(`[^$\\w]([$\\w]+)\\.createElement\\(${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}},We=(e,t,n,r=!0,i=!0)=>{let a=Ve(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc-fixed)`,s=`}.VERSION} (Claude Code)`,c=e.replaceAll(s,s+o);P(e,c,o,a.endIndex,a.endIndex);let l=L(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let u=V(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let d=B(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=He(c);if(!n)console.error(`patch: patchesAppliedIndication: patch 2 skipped (header version pattern changed)`);else{let e=`let _tw=${n.reactVar}.createElement(${n.textComponent},null,${l}.hex("#FF8400").bold("+ tweakcc v${t}"));`,r=c;c=c.slice(0,n.varInsertIndex)+e+c.slice(n.varInsertIndex),P(r,c,e,n.varInsertIndex,n.varInsertIndex);let i=n.refInsertIndex+e.length,a=`," ",_tw`,o=c;c=c.slice(0,i)+a+c.slice(i),P(o,c,a,i,i)}}if(i){let e=Ii(c);if(!e)return console.error(`patch: patchesAppliedIndication: PATCH 3 skipped (Box component not located on this CC version)`),c;let t=Ue(c);if(!t)console.log(`patch: patchesAppliedIndication: patch 3 skipped (see prior message)`);else{let r=[];r.push(`,${d}.createElement(${e}, { flexDirection: "column" },`),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {color: "success", bold: true}, "✓ tweakcc-fixed patches are applied")),`);for(let t of n)t=t.replace(`CHALK_VAR`,l),r.push(`${d}.createElement(${e}, null, ${d}.createElement(${u}, {color: "success", bold: true}, "┃ "), ${d}.createElement(${u}, {dimColor: true}, \` * ${t}\`)),`);r.push(`),`);let i=r.join(`
2
+ `);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),P(a,c,i,t.startIndex,t.endIndex)}}return c};function Ge(){try{let e=v(import.meta.url),t=f.dirname(e);for(let e=0;e<5;e++){let e=f.join(t,`data`,`prompts`),n=f.join(t,`package.json`);if(s.existsSync(n)&&s.existsSync(e))return e;let r=f.dirname(t);if(r===t)break;t=r}}catch{}return null}async function Ke(e){let t=Ge();if(t){let n=f.join(t,`prompts-${e}.json`);try{let e=await a.readFile(n,`utf-8`);return JSON.parse(e)}catch{}}let n=f.join(Sa,`prompts-${e}.json`),r=async()=>{try{return JSON.parse(await a.readFile(n,`utf-8`))}catch{return null}},i=`https://raw.githubusercontent.com/skrabe/tweakcc-fixed/refs/heads/main/data/prompts/prompts-${e}.json`;try{let t=await fetch(i,{signal:AbortSignal.timeout(2e4)});if(!t.ok){let n=await r();if(n)return n;let i;throw i=t.status===429?`Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.`:t.status===404?`Prompts file not found for Claude Code v${e}. The fork's version-bump pipeline hasn't published prompts for this release yet — check https://github.com/skrabe/tweakcc-fixed for status.`:t.status>=500?`GitHub server error (${t.status}). Please try again later.`:`HTTP ${t.status}: ${t.statusText}`,Error(i)}let o=JSON.parse(await ga(t));try{await a.mkdir(Sa,{recursive:!0}),await a.writeFile(n,JSON.stringify(o,null,2),`utf-8`)}catch(e){console.warn(`Failed to write to cache to ${n}: ${e}`)}return o}catch(t){let n=await r();if(n)return n;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 qe=()=>f.join(q,`systemPromptOriginalHashes.json`),Je=()=>f.join(q,`systemPromptAppliedHashes.json`),Ye=(e,t)=>`${e}-${t}`,Xe=e=>h.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),Ze=async e=>{try{return JSON.parse(await a.readFile(e,`utf8`))}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return{};if(t instanceof SyntaxError)return W(`${e} was not valid JSON — ignoring it and rebuilding.`),{};throw t}},Qe=async(e,t)=>{await a.mkdir(q,{recursive:!0});let n={};for(let e of Object.keys(t).sort())n[e]=t[e];let r=`${e}.tmp-${process.pid}`;try{await a.writeFile(r,JSON.stringify(n,null,2),`utf8`),await a.rename(r,e)}catch(e){try{await a.unlink(r)}catch{}throw e}},$e=async()=>Ze(qe()),et=async e=>Qe(qe(),e),tt=async e=>{let t=await $e(),n=0;for(let r of e.prompts){let e=Ye(r.id,r.version);t[e]||(t[e]=Xe(Et(r.pieces,r.identifiers,r.identifierMap)),n++)}return await et(t),n},nt=async(e,t)=>(await $e())[Ye(e,t)],rt=async()=>Ze(Je()),it=async e=>Qe(Je(),e),at=async e=>{if(Object.keys(e).length===0)return;let t=await rt();for(let[n,r]of Object.entries(e))t[n]=r;await it(t)},ot=async()=>{let e=await rt(),t={};for(let n of Object.keys(e))t[n]=null;await it(t)},st=async e=>{try{let t=await rt();if(Object.keys(t).length===0)return!1;let n=(await a.readdir(e)).filter(e=>e.endsWith(`.md`));for(let r of n){let n=t[r.replace(`.md`,``)];if(n==null)continue;let i=f.join(e,r),o=await a.readFile(i,`utf8`);if(Xe((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}},ct=(e,t)=>{let n=_(t,{delimiters:[`<!--`,`-->`]}),r=n.data,i=(n.content??``).replace(/^\n+/,``).replace(/\n+$/,``);return{id:e,name:typeof r.name==`string`?r.name:e,description:typeof r.description==`string`?r.description:``,ccVersion:typeof r.ccVersion==`string`?r.ccVersion:``,placeholders:Array.isArray(r.placeholders)?r.placeholders.filter(e=>typeof e==`string`):[],body:i,isSuppressed:i.trim().length===0}},lt=(e,t,n,r,i)=>{let a={name:e,description:t,ccVersion:n};return r.length>0&&(a.placeholders=r),_.stringify(i,a,{delimiters:[`<!--`,`-->`]})},ut=async e=>{let t=l.join(xa,`${e}.md`);try{return ct(e,await a.readFile(t,`utf8`))}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}},dt=async(e,t,n,r,i,o)=>{let s=l.join(xa,`${e}.md`);try{return await a.stat(s),!1}catch(e){if(!(e instanceof Error&&`code`in e&&e.code===`ENOENT`))throw e}return await a.mkdir(l.dirname(s),{recursive:!0}),await a.writeFile(s,lt(t,n,r,i,o)),!0},ft=(e,t)=>{let n=[],r=new Set(Object.keys(t)),i=/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g,a;for(;(a=i.exec(e))!==null;)r.has(a[1])||n.push(`unknown placeholder "{{${a[1]}}}"; allowed: ${[...r].map(e=>`{{${e}}}`).join(`, `)||`(none)`}`);if(n.length>0)return{result:``,errors:n};let o=e.split(i),s=``;for(let e=0;e<o.length;e++)e%2==0?s+=o[e].replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${"):s+=t[o[e]];return{result:s,errors:[]}},A=(e,t,n,r,i)=>{let a=e.match(t);if(!a||a.index===void 0)return i&&i(e)?e:(console.error(`patch: reminder ${r}: failed to find anchor`),null);let o=n(a),s=e.slice(0,a.index)+o+e.slice(a.index+a[0].length);return P(e,s,o,a.index,a.index+a[0].length),s},j=(e,t,n)=>{let r=`case"${t}":{`,i=[],a=0;for(;;){let t=e.indexOf(r,a);if(t<0)break;i.push(t),a=t+r.length}if(i.length===0)return null;let o=i.find(t=>e.slice(t,t+2048).includes(n));if(o===void 0)return null;let s=o+r.length,c=1,l=s,u=!1,d=!1,f=!1,p=0;for(;l<e.length&&c>0;){let t=e[l],n=e[l-1];if(d)t===`\\`?l++:t===`'`&&(d=!1);else if(f)t===`\\`?l++:t===`"`&&(f=!1);else if(u)t===`\\`?l++:t==="`"&&p===0?u=!1:t===`$`&&e[l+1]===`{`?(p++,l++):t===`}`&&p>0&&p--;else if(t===`'`&&n!==`\\`)d=!0;else if(t===`"`&&n!==`\\`)f=!0;else if(t==="`"&&n!==`\\`)u=!0;else if(t===`{`)c++;else if(t===`}`&&(c--,c===0))return{headerIdx:o,bodyStart:s,bodyEnd:l};l++}return null},pt=e=>{let t=/return\s+[^;]*?([$\w]+)\(\[([$\w]+)\(\{content:/g,n=null,r;for(;(r=t.exec(e))!==null;)n=r;return n?{arrayWrap:n[1],msgCtor:n[2]}:{arrayWrap:`o5`,msgCtor:`j6`}},mt=e=>{let t=e.match(/^\s*if\(!([$\w]+)\(\)\)return\s*\[\]/);return t?t[1]:`GX`},ht=(e,t)=>{let n=e.match(RegExp(`([$\\w]+)\\.${t}\\b`));return n?n[1]:`H`},gt=[{id:`claudemd-context`,name:`claudeMd context wrapper`,description:`Per-turn <system-reminder> that bundles { claudeMd, userEmail, currentDate } into a 'As you answer the user's questions...' block. Empty .md body = suppress entirely.`,placeholders:{context_blocks:"${Object.entries(_).map(([q,K])=>`# ${q}\\n${K}`).join(`\\n`)}"},defaultBody:`As you answer the user's questions, you can use the following context:
3
+ {{context_blocks}}
4
+
5
+ IMPORTANT: this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task.`,apply(e,t,n){let r=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)\)\{if\(Object\.entries\(\3\)\.length===0\)return \2;return\[([$\w]+)\(\{content:`<system-reminder>\n[\s\S]*?\n<\/system-reminder>\n`,isMeta:!0\}\),\.\.\.\2\]\}/);if(!r||r.index===void 0)return/function [$\w]+\([$\w]+,[$\w]+\)\{return [$\w]+;\}/.test(e)?e:(console.error(`patch: reminder claudemd-context: failed to find kY6 wrapper`),null);let[i,a,o,s,c]=r,l;l=n?`function ${a}(${o},${s}){return ${o};}`:`function ${a}(${o},${s}){if(Object.entries(${s}).length===0)return ${o};return[${c}({content:\`<system-reminder>\n${t.replace(/\bObject\.entries\(_\)/g,`Object.entries(${s})`)}\n</system-reminder>\n\`,isMeta:!0}),...${o}]}`;let u=e.slice(0,r.index)+l+e.slice(r.index+i.length);return P(e,u,l,r.index,r.index+i.length),u}},{id:`skills-listing`,name:`Skills listing reminder`,description:`The "The following skills are available..." block. Empty .md body = suppress entirely.`,placeholders:{skill_content:"${H.content}"},defaultBody:`The following skills are available for use with the Skill tool:
6
+
7
+ {{skill_content}}`,apply(e,t,n){let r=e.match(/skill_listing:\(([$\w]+)\)=>\{if\(!\1\.content\)return\[\];return ([$\w]+)\(\[([$\w]+)\(\{content:`The following skills are available for use with the Skill tool:\n\n\$\{\1\.content\}`,isMeta:!0\}\)\]\)\}/);if(!r||r.index===void 0)return/skill_listing:\([$\w]+\)=>\{if\(!0\)return\[\]/.test(e)||/skill_listing:\([$\w]+\)=>\{return \[\]/.test(e)?e:(console.error(`patch: reminder skills-listing: failed to find skill_listing renderer`),null);let[i,a,o,s]=r,c;c=n?`skill_listing:(${a})=>{return [];}`:`skill_listing:(${a})=>{if(!${a}.content)return[];return ${o}([${s}({content:\`${t.replace(/\$\{H\./g,`\${${a}.`)}\`,isMeta:!0})])}`;let l=e.slice(0,r.index)+c+e.slice(r.index+i.length);return P(e,l,c,r.index,r.index+i.length),l}},{id:`mcp-instructions`,name:`MCP server instructions block`,description:`The "# MCP Server Instructions..." block. Empty .md body = suppress entirely. Per-server pruning lives in mcp-<name>.md files.`,placeholders:{added_blocks:"${H.addedBlocks.join(`\\n\\n`)}",removed_names:"${H.removedNames.join(`\\n`)}"},defaultBody:`# MCP Server Instructions
8
+
9
+ The following MCP servers have provided instructions for how to use their tools and resources:
10
+
11
+ {{added_blocks}}`,apply(e,t,n){let r=j(e,`mcp_instructions_delta`,`# MCP Server Instructions`);if(!r)return console.error(`patch: reminder mcp-instructions: failed to find case body`),null;let{bodyStart:i,bodyEnd:a}=r,o=e.slice(i,a),{arrayWrap:s,msgCtor:c}=pt(o),l=ht(o,`addedBlocks`),u=t.replace(/\$\{H\./g,`\${${l}.`),d=n?`return [];`:`if(${l}.addedBlocks.length===0&&${l}.removedNames.length===0)return [];return ${s}([${c}({content:\`${u}\`,isMeta:!0})])`,f=e.slice(0,i)+d+e.slice(a);return P(e,f,d,i,a),f}},{id:`agent-listing`,name:`Agent listing reminder`,description:`The "Available agent types for the Agent tool" block emitted at session start. Empty .md body = suppress entirely.`,placeholders:{listing:"${H.addedLines.join(`\\n`)}",removed:"${H.removedTypes.map((K)=>`- ${K}`).join(`\\n`)}"},defaultBody:`Available agent types for the Agent tool:
12
+ {{listing}}`,apply(e,t,n){let r=j(e,`agent_listing_delta`,`Available agent types for the Agent tool:`);if(!r)return console.error(`patch: reminder agent-listing: failed to find case body`),null;let{bodyStart:i,bodyEnd:a}=r,o=e.slice(i,a),{arrayWrap:s,msgCtor:c}=pt(o),l=ht(o,`addedLines`),u=t.replace(/\$\{H\./g,`\${${l}.`),d=n?`return [];`:`if(${l}.addedLines.length===0&&${l}.removedTypes.length===0)return [];return ${s}([${c}({content:\`${u}\`,isMeta:!0})])`,f=e.slice(0,i)+d+e.slice(a);return P(e,f,d,i,a),f}},{id:`output-style-banner`,name:`Output style banner`,description:`Per-turn "X output style is active. Remember to follow..." reminder. Empty .md body = suppress entirely.`,placeholders:{style_name:"${_.name}",turn_reminder:'${H.turnReminder??"Remember to follow the specific guidelines for this style."}'},defaultBody:`{{style_name}} output style is active. {{turn_reminder}}`,apply(e,t,n){let r=e.match(/output_style:\(([$\w]+)\)=>\{let ([$\w]+)=([$\w]+)\[\1\.style\];if\(!\2\)return\[\];return ([$\w]+)\(\[([$\w]+)\(\{content:`\$\{\2\.name\} output style is active\. \$\{\1\.turnReminder\?\?"Remember to follow the specific guidelines for this style\."\}`,isMeta:!0\}\)\]\)\}/);if(!r||r.index===void 0)return/output_style:\([$\w]+\)=>\{return \[\]/.test(e)?e:(console.error(`patch: reminder output-style-banner: failed to find output_style arrow`),null);let[i,a,o,s,c,l]=r,u=t.replace(/\$\{_\.name\}/g,`\${${o}.name}`).replace(/\$\{H\.turnReminder/g,`\${${a}.turnReminder`),d;d=n?`output_style:(${a})=>{return [];}`:`output_style:(${a})=>{let ${o}=${s}[${a}.style];if(!${o})return[];return ${c}([${l}({content:\`${u}\`,isMeta:!0})])}`;let f=e.slice(0,r.index)+d+e.slice(r.index+i.length);return P(e,f,d,r.index,r.index+i.length),f}},{id:`thinking-reminder`,name:`Thinking reminder (anti-thinking nudge / F97)`,description:`Per-turn 'Respond with just the action or changes and without a thinking block...' nudge that fires when CC decides you shouldn't be thinking. Conditional (only most turns). Empty .md body = suppress entirely.`,placeholders:{},defaultBody:`Respond with just the action or changes and without a thinking block, unless this is a redesign or requires fresh reasoning.`,apply(e,t,n){return/thinking_reminder:\(/.test(e)?A(e,/thinking_reminder:\(\)=>\[([$\w]+)\(\{content:([$\w]+)\(([$\w]+)\),isMeta:!0\}\)\]/,e=>{let[,r,i]=e;return n?`thinking_reminder:()=>[]`:`thinking_reminder:()=>[${r}({content:${i}(\`${t}\`),isMeta:!0})]`},`thinking-reminder`,e=>/thinking_reminder:\(\)=>\[\]/.test(e)):e}},{id:`ultrathink-effort`,name:`Ultrathink keyword booster`,description:`Fires when user input matches /\\bultrathink\\b/i. Empty .md body = the keyword triggers nothing.`,placeholders:{},defaultBody:`The user included the keyword "ultrathink", requesting deeper reasoning on this turn. Reason as thoroughly as the task warrants.`,apply(e,t,n){return A(e,/ultrathink_effort:\(\)=>([$\w]+)\(\[([$\w]+)\(\{content:'[^']*',isMeta:!0\}\)\]\)/,e=>{let[,r,i]=e;return n?`ultrathink_effort:()=>[]`:`ultrathink_effort:()=>${r}([${i}({content:\`${t}\`,isMeta:!0})])`},`ultrathink-effort`,e=>/ultrathink_effort:\(\)=>\[\]/.test(e))}},{id:`date-change`,name:`Date change reminder`,description:`Fires when the system date rolls over mid-session. Conditional. Empty .md body = silent date rollover.`,placeholders:{new_date:"${H.newDate}"},defaultBody:`The date has changed. Today's date is now {{new_date}}. DO NOT mention this to the user explicitly because they are already aware.`,apply(e,t,n){return A(e,/date_change:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`The date has changed\. Today's date is now \$\{\1\.newDate\}\. DO NOT mention this to the user explicitly because they are already aware\.`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a]=e;return n?`date_change:(${r})=>[]`:`date_change:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.newDate\}/g,`\${${r}.newDate}`)}\`,isMeta:!0})])`},`date-change`,e=>/date_change:\([$\w]+\)=>\[\]/.test(e))}},{id:`hook-additional-context`,name:`Hook additional-context wrapper`,description:`Wraps content returned by user-defined hooks into the model context. Conditional. Empty .md body = hook content suppressed.`,placeholders:{hook_name:"${H.hookName}",hook_content:"${H.content.join(`\n`)}"},defaultBody:`{{hook_name}} hook additional context: {{hook_content}}`,apply(e,t,n){return A(e,/hook_additional_context:\(([$\w]+)\)=>\{if\(\1\.content\.length===0\)return\[\];return\[([$\w]+)\(\{content:([$\w]+)\(`\$\{\1\.hookName\} hook additional context: \$\{\1\.content\.join\(`\n`\)\}`\),isMeta:!0\}\)\]\}/,e=>{let[,r,i,a]=e;return n?`hook_additional_context:(${r})=>[]`:`hook_additional_context:(${r})=>{if(${r}.content.length===0)return[];return[${i}({content:${a}(\`${t.replace(/\$\{H\.hookName\}/g,`\${${r}.hookName}`).replace(/\$\{H\.content\.join\(`\n`\)\}/g,`\${${r}.content.join(\`\n\`)}`)}\`),isMeta:!0})]}`},`hook-additional-context`,e=>/hook_additional_context:\([$\w]+\)=>\[\]/.test(e))}},{id:`hook-blocking-error`,name:`Hook blocking-error wrapper`,description:`Surfaces hook command failures that block CC continuing. Conditional. Empty .md body = errors silenced (DANGEROUS — model will not see why hook blocked).`,placeholders:{hook_name:"${H.hookName}",command:"${H.blockingError.command}",error:"${H.blockingError.blockingError}"},defaultBody:`{{hook_name}} hook blocking error from command: "{{command}}": {{error}}`,apply(e,t,n){return A(e,/hook_blocking_error:\(([$\w]+)\)=>\[([$\w]+)\(\{content:([$\w]+)\(`\$\{\1\.hookName\} hook blocking error from command: "\$\{\1\.blockingError\.command\}": \$\{\1\.blockingError\.blockingError\}`\),isMeta:!0\}\)\]/,e=>{let[,r,i,a]=e;return n?`hook_blocking_error:(${r})=>[]`:`hook_blocking_error:(${r})=>[${i}({content:${a}(\`${t.replace(/\$\{H\.hookName\}/g,`\${${r}.hookName}`).replace(/\$\{H\.blockingError\.command\}/g,`\${${r}.blockingError.command}`).replace(/\$\{H\.blockingError\.blockingError\}/g,`\${${r}.blockingError.blockingError}`)}\`),isMeta:!0})]`},`hook-blocking-error`,e=>/hook_blocking_error:\([$\w]+\)=>\[\]/.test(e))}},{id:`hook-stopped-continuation`,name:`Hook stopped-continuation wrapper`,description:`Fires when a hook returned a stop signal. Conditional. Empty .md body = stop reason hidden from model.`,placeholders:{hook_name:"${H.hookName}",message:"${H.message}"},defaultBody:`{{hook_name}} hook stopped continuation: {{message}}`,apply(e,t,n){return A(e,/hook_stopped_continuation:\(([$\w]+)\)=>\[([$\w]+)\(\{content:([$\w]+)\(`\$\{\1\.hookName\} hook stopped continuation: \$\{\1\.message\}`\),isMeta:!0\}\)\]/,e=>{let[,r,i,a]=e;return n?`hook_stopped_continuation:(${r})=>[]`:`hook_stopped_continuation:(${r})=>[${i}({content:${a}(\`${t.replace(/\$\{H\.hookName\}/g,`\${${r}.hookName}`).replace(/\$\{H\.message\}/g,`\${${r}.message}`)}\`),isMeta:!0})]`},`hook-stopped-continuation`,e=>/hook_stopped_continuation:\([$\w]+\)=>\[\]/.test(e))}},{id:`tool-called`,name:`Tool-called preamble`,description:`Per-tool-call preamble: "Called the X tool with the following input: ...". Empty .md body = no preamble (LW strips empty content).`,placeholders:{tool_name:"${H}",tool_input:"${SH(_)}"},defaultBody:`Called the {{tool_name}} tool with the following input: {{tool_input}}`,apply(e,t,n){return A(e,/function ([$\w]+)\(([$\w]+),([$\w]+)\)\{return ([$\w]+)\(\{content:`Called the \$\{\2\} tool with the following input: \$\{([$\w]+)\(\3\)\}`,isMeta:!0\}\)\}/,e=>{let[,r,i,a,o,s]=e;return n?`function ${r}(${i},${a}){return ${o}({content:"",isMeta:!0})}`:`function ${r}(${i},${a}){return ${o}({content:\`${t.replace(/\$\{H\}/g,`\${${i}}`).replace(/\$\{SH\(_\)\}/g,`\${${s}(${a})}`)}\`,isMeta:!0})}`},`tool-called`)}},{id:`tool-result`,name:`Tool-result wrapper`,description:`Per-tool-call result wrapper: "Result of calling the X tool: <output>". Empty .md body = strip the wrapper line (just emit the result).`,placeholders:{tool_name:"${H.name}",result:"${K}"},defaultBody:`Result of calling the {{tool_name}} tool:
13
+ {{result}}`,apply(e,t,n){return A(e,/return ([$\w]+)\(\{content:`Result of calling the \$\{([$\w]+)\.name\} tool:\n\$\{([$\w]+)\}`,isMeta:!0\}\)\}catch\{return [$\w]+\(\{content:`Result of calling the \$\{\2\.name\} tool: Error`,isMeta:!0\}\)\}/,e=>{let[,r,i,a]=e;return n?`return ${r}({content:\`\${${a}}\`,isMeta:!0})}catch{return ${r}({content:"",isMeta:!0})}`:`return ${r}({content:\`${t.replace(/\$\{H\.name\}/g,`\${${i}.name}`).replace(/\$\{K\}/g,`\${${a}}`)}\`,isMeta:!0})}catch{return ${r}({content:\`Result of calling the \${${i}.name} tool: Error\`,isMeta:!0})}`},`tool-result`)}},{id:`tool-error`,name:`Tool-error wrapper`,description:`Fires from the catch branch of the tool-result wrapper when result formatting throws. Empty .md body = silent error.`,placeholders:{tool_name:"${H.name}"},defaultBody:`Result of calling the {{tool_name}} tool: Error`,apply(e,t,n){return A(e,/catch\{return ([$\w]+)\(\{content:`Result of calling the \$\{([$\w]+)\.name\} tool: Error`,isMeta:!0\}\)\}/,e=>{let[,r,i]=e;return n?`catch{return ${r}({content:"",isMeta:!0})}`:`catch{return ${r}({content:\`${t.replace(/\$\{H\.name\}/g,`\${${i}.name}`)}\`,isMeta:!0})}`},`tool-error`)}},{id:`local-command-caveat`,name:`Local-command caveat wrapper`,description:`Wraps output of !shell-command with anti-confusion framing. Empty .md body = no caveat (security-relevant; suppressing means the model may misinterpret command output as user input).`,placeholders:{tag_name:"${Gq_}"},defaultBody:`Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.`,apply(e,t,n){return A(e,/([$\w]+)\(\{content:`<\$\{([$\w]+)\}>Caveat: The messages below were generated by the user while running local commands\. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to\.<\/\$\{\2\}>`,isMeta:!0\}\)/,e=>{let[,r,i]=e;return n?`${r}({content:"",isMeta:!0})`:`${r}({content:\`<\${${i}}>${t.replace(/\$\{Gq_\}/g,`\${${i}}`)}</\${${i}}>\`,isMeta:!0})`},`local-command-caveat`)}},{id:`compact-file-reference`,name:`Compact-time file reference note`,description:`Note injected after compaction when a referenced file is too large to inline. Conditional. Empty .md body = silent omission.`,placeholders:{filename:"${H.filename}",read_tool_name:"${oO.name}"},defaultBody:`Note: {{filename}} was read before the last conversation was summarized, but the contents are too large to include. Use {{read_tool_name}} tool if you need to access it.`,apply(e,t,n){return A(e,/compact_file_reference:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`Note: \$\{\1\.filename\} was read before the last conversation was summarized, but the contents are too large to include\. Use \$\{([$\w]+)\.name\} tool if you need to access it\.`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a,o]=e;return n?`compact_file_reference:(${r})=>[]`:`compact_file_reference:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.filename\}/g,`\${${r}.filename}`).replace(/\$\{oO\.name\}/g,`\${${o}.name}`)}\`,isMeta:!0})])`},`compact-file-reference`,e=>/compact_file_reference:\([$\w]+\)=>\[\]/.test(e))}},{id:`pdf-reference`,name:`PDF too-large note`,description:`Conditional note when a referenced PDF is too large for direct read. Empty .md body = silent omission.`,placeholders:{filename:"${H.filename}",page_count:"${H.pageCount}",file_size:"${l7(H.fileSize)}",read_tool:"${uq}"},defaultBody:`PDF file: {{filename}} ({{page_count}} pages, {{file_size}}). This PDF is too large to read all at once. You MUST use the {{read_tool}} tool with the pages parameter to read specific page ranges (e.g., pages: "1-5"). Do NOT call {{read_tool}} without the pages parameter or it will fail. Start by reading the first few pages to understand the structure, then read more as needed. Maximum 20 pages per request.`,apply(e,t,n){return A(e,/pdf_reference:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`PDF file: \$\{\1\.filename\} \(\$\{\1\.pageCount\} pages, \$\{([$\w]+)\(\1\.fileSize\)\}\)\. This PDF is too large to read all at once\. You MUST use the \$\{([$\w]+)\} tool with the pages parameter[\s\S]*?Maximum 20 pages per request\.`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a,o,s]=e;return n?`pdf_reference:(${r})=>[]`:`pdf_reference:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.filename\}/g,`\${${r}.filename}`).replace(/\$\{H\.pageCount\}/g,`\${${r}.pageCount}`).replace(/\$\{l7\(H\.fileSize\)\}/g,`\${${o}(${r}.fileSize)}`).replace(/\$\{uq\}/g,`\${${s}}`)}\`,isMeta:!0})])`},`pdf-reference`,e=>/pdf_reference:\([$\w]+\)=>\[\]/.test(e))}},{id:`edited-text-file`,name:`Edited-text-file post-edit note`,description:`Conditional note injected after a file is edited (by user or linter). Empty .md body = silent edits.`,shadows:[`system-reminder-file-modification-detected-budget-exceeded`,`system-reminder-file-modified-externally`],placeholders:{filename:"${H.filename}",snippet:"${H.snippet}"},defaultBody:`Note: {{filename}} was modified, either by the user or by a linter. This change was intentional, so make sure to take it into account as you proceed (ie. don't revert it unless the user asks you to). Don't tell the user this, since they are already aware. Here are the relevant changes (shown with line numbers):
14
+ {{snippet}}`,apply(e,t,n){return A(e,/edited_text_file:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:\1\.snippet===""\?`Note: \$\{\1\.filename\} was modified, either by the user or by a linter\. This change was intentional, so make sure to take it into account as you proceed \(ie\. don't revert it unless the user asks you to\)\. Don't tell the user this, since they are already aware\. The diff was omitted because other modified files in this turn already exceeded the snippet budget; use the Read tool if you need the current content\.`:`Note: \$\{\1\.filename\} was modified, either by the user or by a linter\. This change was intentional, so make sure to take it into account as you proceed \(ie\. don't revert it unless the user asks you to\)\. Don't tell the user this, since they are already aware\. Here are the relevant changes \(shown with line numbers\):\n\$\{\1\.snippet\}`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a]=e;return n?`edited_text_file:(${r})=>[]`:`edited_text_file:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.filename\}/g,`\${${r}.filename}`).replace(/\$\{H\.snippet\}/g,`\${${r}.snippet}`)}\`,isMeta:!0})])`},`edited-text-file`,e=>/edited_text_file:\([$\w]+\)=>\[\]/.test(e))}},{id:`selected-lines-in-ide`,name:`IDE selected-lines reminder`,description:`Fires when an IDE selection is sent into chat. Conditional. Empty .md body = silent selection (model not told what user selected).`,placeholders:{line_start:"${H.lineStart}",line_end:"${H.lineEnd}",filename:"${H.filename}",selected_text:"${q}"},defaultBody:`The user selected the lines {{line_start}} to {{line_end}} from {{filename}}:
15
+ {{selected_text}}
16
+
17
+ This may or may not be related to the current task.`,apply(e,t,n){return A(e,/selected_lines_in_ide:\(([$\w]+)\)=>\{let ([$\w]+)=\1\.content\.length>2000\?\1\.content\.substring\(0,2000\)\+`\n\.\.\. \(truncated\)`:\1\.content;return ([$\w]+)\(\[([$\w]+)\(\{content:`The user selected the lines \$\{\1\.lineStart\} to \$\{\1\.lineEnd\} from \$\{\1\.filename\}:\n\$\{\2\}\n\nThis may or may not be related to the current task\.`,isMeta:!0\}\)\]\)\}/,e=>{let[,r,i,a,o]=e;return n?`selected_lines_in_ide:(${r})=>[]`:`selected_lines_in_ide:(${r})=>{let ${i}=${r}.content.length>2000?${r}.content.substring(0,2000)+\`\n... (truncated)\`:${r}.content;return ${a}([${o}({content:\`${t.replace(/\$\{H\.lineStart\}/g,`\${${r}.lineStart}`).replace(/\$\{H\.lineEnd\}/g,`\${${r}.lineEnd}`).replace(/\$\{H\.filename\}/g,`\${${r}.filename}`).replace(/\$\{q\}/g,`\${${i}}`)}\`,isMeta:!0})])}`},`selected-lines-in-ide`,e=>/selected_lines_in_ide:\([$\w]+\)=>\[\]/.test(e))}},{id:`opened-file-in-ide`,name:`IDE opened-file reminder`,description:`Fires when user focuses a new file in the IDE during a CC session. Conditional. Empty .md body = silent.`,placeholders:{filename:"${H.filename}"},defaultBody:`The user opened the file {{filename}} in the IDE. This may or may not be related to the current task.`,apply(e,t,n){return A(e,/opened_file_in_ide:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`The user opened the file \$\{\1\.filename\} in the IDE\. This may or may not be related to the current task\.`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a]=e;return n?`opened_file_in_ide:(${r})=>[]`:`opened_file_in_ide:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.filename\}/g,`\${${r}.filename}`)}\`,isMeta:!0})])`},`opened-file-in-ide`,e=>/opened_file_in_ide:\([$\w]+\)=>\[\]/.test(e))}},{id:`plan-file-reference`,name:`Plan-file reference`,description:`Surfaces an existing plan file from plan mode. Conditional. Empty .md body = plan file invisible to model.`,placeholders:{plan_file_path:"${H.planFilePath}",plan_content:"${H.planContent}"},defaultBody:`A plan file exists from plan mode at: {{plan_file_path}}
18
+
19
+ Plan contents:
20
+
21
+ {{plan_content}}
22
+
23
+ If this plan is relevant to the current work and not already complete, continue working on it.`,apply(e,t,n){return A(e,/plan_file_reference:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`A plan file exists from plan mode at: \$\{\1\.planFilePath\}\n\nPlan contents:\n\n\$\{\1\.planContent\}\n\nIf this plan is relevant to the current work and not already complete, continue working on it\.`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a]=e;return n?`plan_file_reference:(${r})=>[]`:`plan_file_reference:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.planFilePath\}/g,`\${${r}.planFilePath}`).replace(/\$\{H\.planContent\}/g,`\${${r}.planContent}`)}\`,isMeta:!0})])`},`plan-file-reference`,e=>/plan_file_reference:\([$\w]+\)=>\[\]/.test(e))}},{id:`plan-mode-exit`,name:`Plan-mode exit reminder`,description:`Fires when leaving plan mode. Conditional. Empty .md body = silent exit.`,placeholders:{plan_suffix:"${_}"},defaultBody:`## Exited Plan Mode
24
+
25
+ You have exited plan mode. You can now make edits, run tools, and take actions.{{plan_suffix}}`,apply(e,t,n){return A(e,/plan_mode_exit:\(([$\w]+)\)=>\{let ([$\w]+)=\1\.planExists\?` The plan file is located at \$\{\1\.planFilePath\} if you need to reference it\.`:"";return ([$\w]+)\(\[([$\w]+)\(\{content:`## Exited Plan Mode\n\nYou have exited plan mode\. You can now make edits, run tools, and take actions\.\$\{\2\}`,isMeta:!0\}\)\]\)\}/,e=>{let[,r,i,a,o]=e;return n?`plan_mode_exit:(${r})=>[]`:`plan_mode_exit:(${r})=>{let ${i}=${r}.planExists?\` The plan file is located at \${${r}.planFilePath} if you need to reference it.\`:"";return ${a}([${o}({content:\`${t.replace(/\$\{_\}/g,`\${${i}}`)}\`,isMeta:!0})])}`},`plan-mode-exit`,e=>/plan_mode_exit:\([$\w]+\)=>\[\]/.test(e))}},{id:`auto-mode-exit`,name:`Auto-mode exit reminder`,description:`Fires when leaving auto mode. Conditional. Empty .md body = silent exit.`,placeholders:{},defaultBody:`## Exited Auto Mode
26
+
27
+ You have exited auto mode. The user may now want to interact more directly. You should ask clarifying questions when the approach is ambiguous rather than making assumptions.`,apply(e,t,n){return A(e,/auto_mode_exit:\(\)=>([$\w]+)\(\[([$\w]+)\(\{content:`## Exited Auto Mode\n\nYou have exited auto mode\. The user may now want to interact more directly\. You should ask clarifying questions when the approach is ambiguous rather than making assumptions\.`,isMeta:!0\}\)\]\)/,e=>{let[,r,i]=e;return n?`auto_mode_exit:()=>[]`:`auto_mode_exit:()=>${r}([${i}({content:\`${t}\`,isMeta:!0})])`},`auto-mode-exit`,e=>/auto_mode_exit:\(\)=>\[\]/.test(e))}},{id:`nested-memory`,name:`Nested memory reference`,description:`Loads a referenced memory file into context. Conditional. Empty .md body = nested memory invisible.`,placeholders:{memory_path:"${H.content.path}",memory_content:"${H.content.content}"},defaultBody:`Contents of {{memory_path}}:
28
+
29
+ {{memory_content}}`,apply(e,t,n){return A(e,/nested_memory:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`Contents of \$\{\1\.content\.path\}:\n\n\$\{\1\.content\.content\}`,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a]=e;return n?`nested_memory:(${r})=>[]`:`nested_memory:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.content\.path\}/g,`\${${r}.content.path}`).replace(/\$\{H\.content\.content\}/g,`\${${r}.content.content}`)}\`,isMeta:!0})])`},`nested-memory`,e=>/nested_memory:\([$\w]+\)=>\[\]/.test(e))}},{id:`agent-mention`,name:`Agent-mention nudge`,description:`Nudges Claude to invoke an agent when user @-mentions one. Conditional. Empty .md body = silent (model decides on its own).`,placeholders:{agent_type:"${H.agentType}"},defaultBody:`The user has expressed a desire to invoke the agent "{{agent_type}}". Please invoke the agent appropriately, passing in the required context to it. `,apply(e,t,n){return A(e,/agent_mention:\(([$\w]+)\)=>([$\w]+)\(\[([$\w]+)\(\{content:`The user has expressed a desire to invoke the agent "\$\{\1\.agentType\}"\. Please invoke the agent appropriately, passing in the required context to it\. `,isMeta:!0\}\)\]\)/,e=>{let[,r,i,a]=e;return n?`agent_mention:(${r})=>[]`:`agent_mention:(${r})=>${i}([${a}({content:\`${t.replace(/\$\{H\.agentType\}/g,`\${${r}.agentType}`)}\`,isMeta:!0})])`},`agent-mention`,e=>/agent_mention:\([$\w]+\)=>\[\]/.test(e))}},{id:`memory-update`,name:`Memory-update reminder`,description:`Fires after dream / consolidation writes new memory files. Conditional. Empty .md body = silent updates.`,placeholders:{source:"${YT3[H.source]}",summary:"${H.summary}",paths:'${H.paths.join(", ")}',in_context_paths:'${H.inContextPaths.join(", ")}'},defaultBody:`{{source}} updated your memory directory: {{summary}}
30
+ Files changed: {{paths}}
31
+ Your loaded copy of {{in_context_paths}} is now stale relative to disk — Read it again if you need current contents.
32
+ This is ambient context — do not narrate it to the user unless they ask or it is directly relevant to their request.`,apply(e,t,n){let r=j(e,`memory_update`,`updated your memory directory`);if(!r)return console.error(`patch: reminder memory-update: failed to find case body`),null;let{bodyStart:i,bodyEnd:a}=r,o=e.slice(i,a),{arrayWrap:s,msgCtor:c}=pt(o),l=ht(o,`summary`),u=o.match(/\$\{([$\w]+)\[/)?.[1]??`YT3`,d=t.replace(/\$\{YT3\[H\.source\]\}/g,`\${${u}[${l}.source]}`).replace(/\$\{H\./g,`\${${l}.`),f=n?`return [];`:`return ${s}([${c}({content:\`${d}\`,isMeta:!0})])`,p=e.slice(0,i)+f+e.slice(a);return P(e,p,f,i,a),p}},{id:`verify-plan-reminder`,name:`Verify-plan reminder`,description:`Fires after plan implementation completes, directing Claude to call a verification tool. Conditional. Empty .md body = no automatic verification nudge.`,placeholders:{plan_verifier_tool:"${J7}"},defaultBody:`You have completed implementing the plan. Please call the "" tool directly (NOT the {{plan_verifier_tool}} tool or an agent) to verify that all plan items were completed correctly.`,apply(e,t,n){let r=j(e,`verify_plan_reminder`,`You have completed implementing the plan`);if(!r)return console.error(`patch: reminder verify-plan-reminder: failed to find case body`),null;let{bodyStart:i,bodyEnd:a}=r,o=e.slice(i,a),{arrayWrap:s,msgCtor:c}=pt(o),l=o.match(/\(NOT the \$\{([$\w]+)\} tool/)?.[1]??`J7`,u=t.replace(/\$\{J7\}/g,`\${${l}}`),d=n?`return [];`:`let K=\`${u}\`;return ${s}([${c}({content:K,isMeta:!0})])`,f=e.slice(0,i)+d+e.slice(a);return P(e,f,d,i,a),f}},{id:`token-usage`,name:`Token usage updater`,description:`Per-turn token usage status. Conditional (only some turns). Empty .md body = no telemetry leak into context.`,placeholders:{used:"${H.used}",total:"${H.total}",remaining:"${H.remaining}"},defaultBody:`Token usage: {{used}}/{{total}}; {{remaining}} remaining`,apply(e,t,n){return A(e,/token_usage:\(([$\w]+)\)=>\[([$\w]+)\(\{content:([$\w]+)\(`Token usage: \$\{\1\.used\}\/\$\{\1\.total\}; \$\{\1\.remaining\} remaining`\),isMeta:!0\}\)\]/,e=>{let[,r,i,a]=e;return n?`token_usage:(${r})=>[]`:`token_usage:(${r})=>[${i}({content:${a}(\`${t.replace(/\$\{H\.used\}/g,`\${${r}.used}`).replace(/\$\{H\.total\}/g,`\${${r}.total}`).replace(/\$\{H\.remaining\}/g,`\${${r}.remaining}`)}\`),isMeta:!0})]`},`token-usage`,e=>/token_usage:\([$\w]+\)=>\[\]/.test(e))}},{id:`budget-usd`,name:`USD budget updater`,description:`Per-turn USD budget status. Conditional. Empty .md body = no telemetry leak into context.`,placeholders:{used:"${H.used}",total:"${H.total}",remaining:"${H.remaining}"},defaultBody:"USD budget: ${{used}}/${{total}}; ${{remaining}} remaining",apply(e,t,n){return A(e,/budget_usd:\(([$\w]+)\)=>\[([$\w]+)\(\{content:([$\w]+)\(`USD budget: \$\$\{\1\.used\}\/\$\$\{\1\.total\}; \$\$\{\1\.remaining\} remaining`\),isMeta:!0\}\)\]/,e=>{let[,r,i,a]=e;return n?`budget_usd:(${r})=>[]`:`budget_usd:(${r})=>[${i}({content:${a}(\`${t.replace(/\$\{H\.used\}/g,`\${${r}.used}`).replace(/\$\{H\.total\}/g,`\${${r}.total}`).replace(/\$\{H\.remaining\}/g,`\${${r}.remaining}`)}\`),isMeta:!0})]`},`budget-usd`,e=>/budget_usd:\([$\w]+\)=>\[\]/.test(e))}},{id:`output-token-usage`,name:`Output-token usage updater`,description:`Per-turn output-token telemetry. Conditional. Empty .md body = no telemetry leak.`,placeholders:{turn:"${_}",session:"${gK(H.session)}"},defaultBody:`Output tokens — turn: {{turn}} · session: {{session}}`,apply(e,t,n){return A(e,/output_token_usage:\(([$\w]+)\)=>\{let ([$\w]+)=\1\.budget!==null\?`\$\{([$\w]+)\(\1\.turn\)\} \/ \$\{\3\(\1\.budget\)\}`:\3\(\1\.turn\);return\[([$\w]+)\(\{content:([$\w]+)\(`Output tokens \\u2014 turn: \$\{\2\} \\xB7 session: \$\{\3\(\1\.session\)\}`\),isMeta:!0\}\)\]\}/,e=>{let[,r,i,a,o,s]=e;return n?`output_token_usage:(${r})=>[]`:`output_token_usage:(${r})=>{let ${i}=${r}.budget!==null?\`\${${a}(${r}.turn)} / \${${a}(${r}.budget)}\`:${a}(${r}.turn);return[${o}({content:${s}(\`${t.replace(/\$\{_\}/g,`\${${i}}`).replace(/\$\{gK\(H\.session\)\}/g,`\${${a}(${r}.session)}`)}\`),isMeta:!0})]}`},`output-token-usage`,e=>/output_token_usage:\([$\w]+\)=>\[\]/.test(e))}},{id:`task-list-reminder`,name:`Task-list status reminder`,description:`Fires every turn while TaskList has entries. Wraps the current task list with reminder text about using TaskCreate. Empty .md = suppress entirely.`,shadows:[`system-reminder-task-tools-reminder`],placeholders:{tasks:"${q}"},defaultBody:"The task tools haven't been used to track work in this session yet. Now is a good time to consider whether the work warrants using them. Use this to demonstrate thoroughness, organize complex tasks, and avoid losing track of multi-step work (e.g. multi-bug fixes, feature implementations, etc). Don't use them on small or trivial tasks where they would feel intrusive.\n\nIf you've already started work without using the task tools, use `TaskCreate` to add tasks for the work you've already completed (with status `completed`) and a task for whatever you're currently working on (with status `in_progress`). Remember, in a single response, never have more than one task `in_progress` (the one you're actively working on) and you should mark a task as `completed` immediately after starting and finishing the work (don't wait until you're done). Also consider cleaning up the task list if it has become stale. Only use these if relevant to the current work. This is just a gentle reminder - ignore if not applicable.\n\nHere are the existing tasks:\n\n{{tasks}}",apply(e,t,n){let r=j(e,`task_reminder`,`Here are the existing tasks`);if(!r)return console.error(`patch: reminder task-list-reminder: failed to find case body`),null;let{bodyStart:i,bodyEnd:a}=r,o=e.slice(i,a),{arrayWrap:s,msgCtor:c}=pt(o),l=mt(o),u=ht(o,`content`),d=n?`return [];`:`if(!${l}())return[];let q=${u}.content.map((O)=>\`#\${O.id}. [\${O.status}] \${O.subject}\`).join(\`\\n\`);return ${s}([${c}({content:\`${t}\`,isMeta:!0})])`,f=e.slice(0,i)+d+e.slice(a);return P(e,f,d,i,a),f}},{id:`task-notification-framing`,name:`Task-notification framing wrapper`,description:`The "[SYSTEM NOTIFICATION - NOT USER INPUT]" text wrapping background-task event content. Fires when a run_in_background completes/errors. Empty .md = no framing (just the content).`,placeholders:{content:"${H}"},defaultBody:`[SYSTEM NOTIFICATION - NOT USER INPUT]
33
+ This is an automated background-task event, NOT a message from the user.
34
+ Do NOT interpret this as user acknowledgement, confirmation, or response to any pending question.
35
+
36
+ {{content}}`,apply(e,t,n){return A(e,/(case"task-notification":return|function [$\w]+\([$\w]+\)\{return)`\[SYSTEM NOTIFICATION - NOT USER INPUT\]\nThis is an automated background-task event, NOT a message from the user\.\nDo NOT interpret this as user acknowledgement, confirmation, or response to any pending question\.\n\n\$\{([$\w]+)\}`(;|\})/,e=>{let[,r,i,a]=e;return n?`${r}\`\${${i}}\`${a}`:`${r}\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\`${a}`},`task-notification-framing`,e=>/case"task-notification":return`\$\{[$\w]+\}`;/.test(e))}},{id:`user-sent-new-message`,name:`User-sent-new-message wrapper`,description:`Wraps a user message that arrives mid-turn. Carries the "IMPORTANT: After completing your current task, you MUST address" framing. Empty .md = no wrapping (just the message text).`,placeholders:{message:"${H}"},defaultBody:`The user sent a new message while you were working:
37
+ {{message}}
38
+
39
+ IMPORTANT: After completing your current task, you MUST address the user's message above. Do not ignore it.`,apply(e,t,n){return A(e,/((?:case"auto-continuation":)?case"human":case void 0:(?:default:)?)return`(?:The user sent a new message while you were working:\n|\$\{[$\w]+\})\$\{([$\w]+)\}\n\nIMPORTANT: After completing your current task, you MUST address the user's message above\. Do not ignore it\.`/,e=>{let[,r,i]=e;return n?`${r}return\`\${${i}}\``:`${r}return\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`user-sent-new-message`,e=>/(?:case"auto-continuation":)?case"human":case void 0:(?:default:)?return`\$\{[$\w]+\}`/.test(e))}},{id:`stop-hook-session-goal`,name:`Stop-hook session-goal reminder`,description:`Fires when /goal sets a session-scoped stop hook. Carries the "do not pause to ask" framing. Empty .md = silent goal activation (just the condition value used internally).`,placeholders:{condition:"${H}"},defaultBody:'A session-scoped Stop hook is now active with condition: "{{condition}}". Briefly acknowledge the goal, then immediately start (or continue) working toward it — treat the condition itself as your directive and do not pause to ask the user what to do. The hook will block stopping until the condition holds. It auto-clears once the condition is met — do not tell the user to run `/goal clear` after success; that\'s only for clearing a goal early.',apply(e,t,n){return A(e,/([$\w]+)=\(([$\w]+)\)=>`A session-scoped Stop hook is now active with condition: "\$\{\2\}"\. Briefly acknowledge the goal, then immediately start \(or continue\) working toward it[\s\S]*?after success; that's only for clearing a goal early\.`/,e=>{let[,r,i]=e;return n?`${r}=(${i})=>""`:`${r}=(${i})=>\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`stop-hook-session-goal`,e=>/[$\w]+=\([$\w]+\)=>""/.test(e))}},{id:`mcp-per-server-router`,name:`MCP per-server instruction router`,description:`Patches CC's MCP instruction assembly to consult ~/.tweakcc/system-reminders/mcp-<server-name>.md at runtime. Empty body in that file drops the server's block. Body containing {{server_instructions}} resolves to the server's pristine instructions. Custom body replaces. THIS .md does nothing on its own — it just enables per-server .md files. Empty body = disable this routing (servers use pristine instructions verbatim).`,placeholders:{},defaultBody:`This file is a marker that enables per-MCP-server overrides. Edit per-server content in mcp-<server-name>.md alongside this file. Leave this file with content (any content) to enable routing; empty it to disable.`,apply(e,t,n){if(n)return e;let r=e.match(/for\(let ([$\w]+) of ([$\w]+)\)if\(\1\.instructions\)([$\w]+)\.set\(\1\.name,`## \$\{\1\.name\}\n\$\{\1\.instructions\}`\);/);if(!r||r.index===void 0)return e.includes(`__tweakccMcpOverride`)?e:(console.error(`patch: reminder mcp-per-server-router: failed to find MCP assembly loop`),null);let[i,a,o,s]=r,c=`function __tweakccMcpOverride(_n,_d){try{let _f=require('fs'),_p=require('os').homedir()+'/.tweakcc/system-reminders/mcp-'+_n+'.md';let _r=_f.readFileSync(_p,'utf8');let _m=_r.match(/-->\\s*([\\s\\S]*?)\\s*\$/);if(!_m)return _d;let _b=_m[1].trim();if(_b==='')return null;return _b.replace(/\\{\\{server_instructions\\}\\}/g,_d||'')}catch{return _d}}for(let ${a} of ${o}){let _c=__tweakccMcpOverride(${a}.name,${a}.instructions);if(_c)${s}.set(${a}.name,\`## \${${a}.name}\n\${_c}\`)}`,l=e.slice(0,r.index)+c+e.slice(r.index+i.length);return P(e,l,c,r.index,r.index+i.length),l}}],_t=async()=>{let e=[l.join(n.homedir(),`.claude.json`),l.join(n.homedir(),`.claude`,`mcp.json`)];for(let t of e)try{let e=await a.readFile(t,`utf8`),n=JSON.parse(e);if(n.mcpServers&&typeof n.mcpServers==`object`)return Object.keys(n.mcpServers)}catch{}return[]},vt=async(e,t)=>{let n=[],r=e,i=await _t();for(let e of i)await dt(`mcp-${e}`,`MCP server: ${e}`,`Instructions block content for MCP server "${e}". {{server_instructions}} expands at runtime to the server's pristine instructions. Empty body drops the server's block from the model's context. Custom body replaces it.`,t,[`server_instructions`],`{{server_instructions}}`);for(let e of gt){let i=await dt(e.id,e.name,e.description,t,Object.keys(e.placeholders),e.defaultBody),a=await ut(e.id);if(!a){n.push({id:e.id,name:e.name,description:e.description,state:`default`,applied:!1,failed:!1,skipped:!0,details:`override file missing after ensure (unexpected)`});continue}let{result:o,errors:s}=ft(a.body,e.placeholders);if(s.length>0){n.push({id:e.id,name:e.name,description:e.description,state:`override`,applied:!1,failed:!0,skipped:!1,details:s.join(`; `)});continue}let c=e.apply(r,o,a.isSuppressed);if(c===null){n.push({id:e.id,name:e.name,description:e.description,state:a.isSuppressed?`suppressed`:`override`,applied:!1,failed:!0,skipped:!1,details:`patch function returned null`});continue}let l=c!==r;r=c;let u;u=a.isSuppressed?`suppressed`:a.body===e.defaultBody.trim()?`default`:`override`,n.push({id:e.id,name:e.name,description:e.description,state:u,applied:l,failed:!1,skipped:!1,details:i?`seeded default file`:void 0})}return{content:r,results:n}};let yt=null;const bt=async()=>{if(yt)return yt;let e=new Set,t=[Z,xa];for(let n of t){let t;try{t=await a.readdir(n)}catch{continue}if(Array.isArray(t))for(let r of t){if(!r.endsWith(`.md`))continue;let t;try{t=await a.readFile(f.join(n,r),`utf8`)}catch{continue}let i=_(t,{delimiters:[`<!--`,`-->`]}).data?.shadows;if(Array.isArray(i))for(let t of i)typeof t==`string`&&t&&e.add(t)}}for(let t of gt)if(Array.isArray(t.shadows))for(let n of t.shadows)typeof n==`string`&&n&&e.add(n);return yt=e,e};let xt=null;const St=async()=>{if(xt)return xt;let e=new Set,t=Ge();if(t){let n;try{n=await a.readdir(t)}catch{n=[]}for(let r of n)if(!(!r.startsWith(`prompts-`)||!r.endsWith(`.json`)))try{let n=await a.readFile(f.join(t,r),`utf8`),i=JSON.parse(n);for(let t of i.prompts??[])for(let n of Object.values(t.identifierMap??{}))n&&e.add(n)}catch{continue}}if(e.size===0)try{let t=await import(`./identifierUnion-CV566DfO.mjs`);for(let n of t.IDENTIFIER_UNION)e.add(n)}catch{}return xt=e,e},Ct=e=>{let t=_(e,{delimiters:[`<!--`,`-->`]}),{name:n,description:r,ccVersion:i,variables:a}=t.data,o=0,s=e.indexOf(t.content);return s>=0&&(o=e.slice(0,s).split(`
40
+ `).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}},wt=(e,t,n)=>{let r=t||Et(e.pieces,e.identifiers,e.identifierMap),i=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,a={name:e.name,description:e.description,ccVersion:e.version};if(i&&i.length>0&&(a.variables=i),n)for(let[e,t]of Object.entries(n))e in a||(a[e]=t);return _.stringify(r,a,{delimiters:[`<!--`,`-->`]})},Tt=async e=>{let t={};try{let n=M(e),r=_(await a.readFile(n,`utf8`),{delimiters:[`<!--`,`-->`]}),i=new Set([`name`,`description`,`ccVersion`,`variables`]);for(let[e,n]of Object.entries(r.data))i.has(e)||(t[e]=n)}catch{}return t},Et=(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},Dt=(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},M=e=>f.join(Z,`${e}.md`),Ot=async e=>{try{return await a.access(M(e)),!0}catch{return!1}},kt=async e=>{let t=M(e);return Ct(await a.readFile(t,`utf-8`))},At=async(e,t)=>{let n=M(e);await a.writeFile(n,t,`utf-8`)},jt=async(e,t)=>{let n=M(e),r=await a.readFile(n,`utf-8`),i=_(r,{delimiters:[`<!--`,`-->`]}),o=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,s=new Set([`name`,`description`,`ccVersion`,`variables`]),c={name:i.data.name,description:i.data.description,ccVersion:i.data.ccVersion};o&&o.length>0&&(c.variables=o);for(let[e,t]of Object.entries(i.data))s.has(e)||(c[e]=t);let l=_.stringify(i.content,c,{delimiters:[`<!--`,`-->`]});l!==r&&await At(e,l)},Mt=(e,t)=>{let n=e=>e.split(/(\s+)/),r=n(e),i=n(t),a=r.length,o=i.length,s=Array(a+1).fill(0).map(()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)r[e-1]===i[t-1]?s[e][t]=s[e-1][t-1]+1:s[e][t]=Math.max(s[e-1][t],s[e][t-1]);let c=Array(a).fill(!1),l=Array(o).fill(!1),u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l[d-1]=!0,d--):u>0&&(c[u-1]=!0,u--);let f=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`),p=``;for(let e=0;e<r.length;e++){let t=f(r[e]);p+=c[e]?`<mark>${t}</mark>`:t}let m=``;for(let e=0;e<i.length;e++){let t=f(i[e]);m+=l[e]?`<mark>${t}</mark>`:t}return{oldHtml:p,newHtml:m}},Nt=(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=Mt(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},Pt=async(e,t,n,r,i,o,s,c)=>{let l=n.split(`
41
+ `),u=r.split(`
42
+ `),d=i.split(`
43
+ `),p=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`),m=Nt(l,u),h=Nt(l,d),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>
44
+ <html>
45
+ <head>
46
+ <meta charset="UTF-8">
47
+ <title>Diff: ${p(t)} (${p(e)})</title>
48
+ <style>
49
+ body {
50
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
51
+ margin: 0;
52
+ padding: 20px;
53
+ background: #f5f5f5;
54
+ }
55
+ .header {
56
+ background: white;
57
+ padding: 20px;
58
+ border-radius: 8px;
59
+ margin-bottom: 20px;
60
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
61
+ }
62
+ h1 {
63
+ margin: 0 0 10px 0;
64
+ color: #333;
65
+ }
66
+ .version-info {
67
+ color: #666;
68
+ font-size: 14px;
69
+ }
70
+ .warning {
71
+ background: #fff3cd;
72
+ border-left: 4px solid #ffc107;
73
+ padding: 15px;
74
+ margin-bottom: 20px;
75
+ border-radius: 4px;
76
+ }
77
+ .warning code {
78
+ background: rgba(0,0,0,0.1);
79
+ padding: 2px 6px;
80
+ border-radius: 3px;
81
+ font-family: 'Consolas', 'Monaco', monospace;
82
+ font-size: 13px;
83
+ }
84
+ .diff-panels {
85
+ display: grid;
86
+ grid-template-columns: 1fr 1fr;
87
+ gap: 20px;
88
+ margin-bottom: 20px;
89
+ }
90
+ .diff-container {
91
+ background: white;
92
+ border-radius: 8px;
93
+ overflow: hidden;
94
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
95
+ }
96
+ .diff-header {
97
+ background: #f8f9fa;
98
+ padding: 12px 15px;
99
+ font-weight: bold;
100
+ border-bottom: 2px solid #dee2e6;
101
+ font-family: 'Consolas', 'Monaco', monospace;
102
+ font-size: 14px;
103
+ }
104
+ .diff-content {
105
+ padding: 0;
106
+ font-family: 'Consolas', 'Monaco', monospace;
107
+ font-size: 13px;
108
+ line-height: 1.5;
109
+ overflow-x: auto;
110
+ max-height: 600px;
111
+ overflow-y: auto;
112
+ }
113
+ .line {
114
+ padding: 2px 10px;
115
+ white-space: pre-wrap;
116
+ word-wrap: break-word;
117
+ }
118
+ .line .line-num {
119
+ display: inline-block;
120
+ min-width: 50px;
121
+ margin-right: 10px;
122
+ color: #6a737d;
123
+ text-align: right;
124
+ user-select: none;
125
+ font-size: 12px;
126
+ }
127
+ .line .prefix {
128
+ display: inline-block;
129
+ width: 20px;
130
+ font-weight: bold;
131
+ user-select: none;
132
+ }
133
+ .removed {
134
+ background: #ffebe9;
135
+ color: #24292e;
136
+ }
137
+ .removed .prefix {
138
+ color: #d73a49;
139
+ }
140
+ .added {
141
+ background: #e6ffed;
142
+ color: #24292e;
143
+ }
144
+ .added .prefix {
145
+ color: #22863a;
146
+ }
147
+ .unchanged {
148
+ background: #ffffff;
149
+ color: #24292e;
150
+ }
151
+ .unchanged .prefix {
152
+ color: #6a737d;
153
+ }
154
+ mark {
155
+ background: rgba(255, 200, 0, 0.4);
156
+ padding: 0;
157
+ border-radius: 2px;
158
+ }
159
+ .removed mark {
160
+ background: rgba(215, 58, 73, 0.3);
161
+ }
162
+ .added mark {
163
+ background: rgba(34, 134, 58, 0.3);
164
+ }
165
+ @media (max-width: 1200px) {
166
+ .diff-panels {
167
+ grid-template-columns: 1fr;
168
+ }
169
+ }
170
+ </style>
171
+ </head>
172
+ <body>
173
+ <div class="header">
174
+ <h1>${p(t)}</h1>
175
+ <div class="version-info">
176
+ <strong>Old Version:</strong> ${p(o)} →
177
+ <strong>New Version:</strong> ${p(s)}
178
+ </div>
179
+ </div>
180
+
181
+ <div class="warning">
182
+ <strong>⚠️ Version Mismatch Warning</strong><br>
183
+ Your customized prompt file is based on version ${p(o)},
184
+ but Claude Code is now using version ${p(s)}.
185
+ Review the differences below to understand both your customizations and the upstream changes.<br><br>
186
+ <strong>File:</strong> <code>${p(c)}</code><br><br>
187
+ When you're done reviewing, update the <code>ccVersion</code> in the file to <strong>${p(s)}</strong>.
188
+ </div>
189
+
190
+ <div class="diff-panels">
191
+ <div class="diff-container">
192
+ <div class="diff-header">Your Customizations (v${p(o)} → User)</div>
193
+ <div class="diff-content">
194
+ ${g} </div>
195
+ </div>
196
+
197
+ <div class="diff-container">
198
+ <div class="diff-header">Upstream Changes (v${p(o)} → v${p(s)})</div>
199
+ <div class="diff-content">
200
+ ${_} </div>
201
+ </div>
202
+ </div>
203
+ </body>
204
+ </html>`,y=f.join(Z,`${e}.diff.html`);return await a.writeFile(y,v,`utf-8`),y},Ft=async e=>{let n={id:e.id,name:e.name,description:e.description,action:`skipped`,newVersion:e.version};if((await bt()).has(e.id))return n.action=`skipped`,n;if(!await Ot(e.id)){if(!e.name)return n.action=`skipped`,n;let t=wt(e);return await At(e.id,t),n.action=`created`,n}let r=await kt(e.id);if(n.oldVersion=r.ccVersion,await jt(e.id,e.identifierMap),r.ccVersion&&e.version){let i=Dt(r.ccVersion,e.version);if(i===0)return n.action=`skipped`,n;if(i!=0){let i=await nt(e.id,r.ccVersion),a=Xe(r.content);if(!i||i!==a){n.action=`conflict`;let i=r.content;try{let t=(await Ke(r.ccVersion)).prompts.find(t=>t.id===e.id);t&&(i=Et(t.pieces,t.identifiers,t.identifierMap))}catch{console.log(t.yellow(`Warning: Could not fetch old version ${r.ccVersion} for comparison. Using current file as baseline.`))}let a=Et(e.pieces,e.identifiers,e.identifierMap),o=M(e.id);n.diffHtmlPath=await Pt(e.id,e.name,i,r.content,a,r.ccVersion,e.version,o)}else{let t=wt(e,void 0,await Tt(e.id));await At(e.id,t),n.action=`updated`}}}return n},It=async e=>{let n={ccVersion:e,results:[]},r=await Ke(e);await tt(r),await a.mkdir(Z,{recursive:!0});for(let e of r.prompts)try{let t=await Ft(e);n.results.push(t)}catch(n){throw console.log(t.red(`Failed to sync prompt ${e.id}:`)),n}return n};let N=null,Lt=null;const Rt=async e=>{try{return N=await Ke(e),Lt=e,{success:!0}}catch(e){return N=null,Lt=null,e instanceof Error?{success:!1,errorMessage:e.message}:{success:!1,errorMessage:`Unknown error occurred while downloading system prompts`}}},zt=()=>N?N.prompts.map(e=>({id:e.id,name:e.name,description:e.description})):null,Bt=e=>e.split(``).map(e=>/[a-f]/i.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:e).join(``),Vt=e=>e.replace(/[^\x00-\x7F]/g,e=>{let t=e.charCodeAt(0),n=[e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`\\\\u${Bt(t.toString(16).padStart(4,`0`))}`];return t<=255&&n.push(`\\\\x${Bt(t.toString(16).padStart(2,`0`))}`),`(?:${n.join(`|`)})`}),Ht=e=>e.replace(/[^\x00-\x7F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),Ut=(e,t,n)=>{let r=``,i=`\0INTERP\0`,a=`\0BS\0`,o=`\0MEMBER\0`;for(let s=0;s<e.length;s++){let c=e[s].replace(/<<CCVERSION>>/g,t);n&&(c=c.replace(/<<BUILD_TIME>>/g,n)),s>0&&(c=c.replace(/^\[[A-Za-z_$][\w$]*\](?=\})/,o)),c=c.replace(/\$\{[^{}]*\}/g,i),c=c.replace(/\\/g,a);let l=Vt(c.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).replace(/"/g,`(?:"|\\\\")`).replace(/'/g,`(?:'|\\\\')`).replace(/`/g,"(?:`|\\\\`)").replace(/\n/g,`(?:
205
+ |\\\\n)`).replace(new RegExp(i,`g`),`\\$\\{[^{}]*\\}`).replace(new RegExp(a,`g`),`(?:\\\\|\\\\\\\\)`).replace(new RegExp(o,`g`),`\\[[\\w$]+\\]`);r+=l,s<e.length-1&&(r+=`([\\w$]+)`)}return r},Wt=(e,t)=>{let n=0,r=t-1;for(;r>=0&&e[r]===`\\`;)n++,r--;return n},Gt=e=>{let t=``,n=0,r=``,i=[];for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1],c=Wt(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}},Kt=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]:``}},qt=(e,t)=>{if(e.trim()===``)return``;let n=e.trim();return t.leading+n+t.trailing},Jt=(e,t,n,r,i,a=!1,o,s)=>{let c={};for(let e=0;e<r.length;e++){let i=r[e],a=String(t[e]),o=n[a]||`UNKNOWN_${a}`;c[o]=i}let l=e,u=Object.entries(c).sort((e,t)=>t[0].length-e[0].length);for(let[e,t]of u){let n=RegExp(`\\b${e}\\b`,`g`);l=l.replace(n,()=>t)}if(l=l.replace(/<<CCVERSION>>/g,i),o&&(l=l.replace(/<<BUILD_TIME>>/g,o)),a&&(l=Ht(l)),s&&s.length>0){let e=Kt(s);l=qt(l,e)}return l},Yt=async(e,t=!1,n)=>{if(!N||Lt!==e)return[];let r=N,i=[],o=await bt();for(let t of r.prompts){if(!t.id||o.has(t.id))continue;let r=Ut(t.pieces,e,n),s=f.join(Z,`${t.id}.md`),c;try{c=await a.readFile(s,`utf8`)}catch(e){console.error(`Failed to read markdown file ${s}:`,e);continue}let l=Ct(c);i.push({promptId:t.id,prompt:l,regex:r,getInterpolatedContent:r=>{let i=r.slice(1);return Jt(l.content,t.identifiers,t.identifierMap,i,e,!1,n,t.pieces)},pieces:t.pieces,identifiers:t.identifiers,identifierMap:t.identifierMap})}return i},Xt=e=>{let n=e.results.filter(e=>e.action===`created`),r=e.results.filter(e=>e.action===`updated`),i=e.results.filter(e=>e.action===`conflict`),a=e.results.filter(e=>e.action===`skipped`);if((n.length>0||r.length>0||i.length>0)&&a.length>0&&(console.log(t.dim(`Skipped ${a.length} up-to-date file(s)`)),console.log()),n.length>0){console.log(t.bold.green(`Created ${n.length} new prompt file(s):`));for(let e of n)console.log(t.green(` ${Z}/${e.id}.md`)),console.log(t.green.dim(` ${e.description}`));console.log()}if(r.length>0){console.log(t.bold.blue(`Updated ${r.length} system prompt file(s):`));for(let e of r)e.oldVersion?console.log(t.blue(` ${e.id}.md (${e.oldVersion} → ${e.newVersion})`)):console.log(t.blue(` ${e.id}.md (→ ${e.newVersion})`));console.log()}if(i.length>0){console.log(t.bold.yellow(`WARNING: Conflicts detected for ${i.length} system prompt file(s)`));for(let e of i)console.log(t.yellow(` ${e.id}.md (${e.oldVersion} → ${e.newVersion})`)),console.log(t.yellow(` Open the diff in your browser: ${e.diffHtmlPath}`));console.log()}if(n.length>0&&(console.log(t.green.bold(`New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.`)),console.log(t.green(`You can now customize the markdown files at ${Z} in a text editor.`)),console.log(t.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(t.bold.cyan(` 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:`));for(let e of i)console.log(t.yellow(` ${e.id}.md → `)+t.bold.magenta(e.newVersion));console.log(` 5. Delete the diff HTML files`),console.log()}},Zt=/stack overflow|maximum call stack|call stack size/i,Qt=e=>e.includes(`g`)?e:e+`g`,$t=(e,t,n)=>{let r=new RegExp(e,Qt(t)),i=[],a;for(;(a=r.exec(n))!==null;)i.push(a),a[0].length===0&&r.lastIndex++;return i},en=(e,t,n)=>new Promise((r,i)=>{let a=new y(`
206
+ const { parentPort, workerData } = require('node:worker_threads');
207
+ try {
208
+ const { source, flags, content } = workerData;
209
+ const re = new RegExp(source, flags);
210
+ const matches = [];
211
+ let m;
212
+ while ((m = re.exec(content)) !== null) {
213
+ matches.push({ index: m.index, groups: Array.from(m) });
214
+ if (m[0].length === 0) re.lastIndex++;
215
+ }
216
+ parentPort.postMessage({ ok: true, matches });
217
+ } catch (err) {
218
+ parentPort.postMessage({ ok: false, error: (err && err.message) || String(err) });
219
+ }
220
+ `,{eval:!0,workerData:{source:e,flags:Qt(t),content:n},resourceLimits:{stackSizeMb:16}});a.once(`message`,e=>{if(a.terminate(),!e.ok){i(Error(e.error??`regex worker failed`));return}r((e.matches??[]).map(({index:e,groups:t})=>{let n=t;return n.index=e,n}))}),a.once(`error`,e=>{a.terminate(),i(e)})}),tn=async(e,t,n)=>{try{return $t(e,t,n)}catch(r){let i=r instanceof Error?r.message:String(r);if(!Zt.test(i))throw r;return en(e,t,n)}},nn=e=>/\\u[0-9a-fA-F]{4}/.test(e),rn=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},an=(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},on=async(e,n,r,i,a)=>{let o=r??nn(e);o&&W(`Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts`);let s=rn(e);s&&W(`Extracted BUILD_TIME from cli.js: ${s}`);let c=await Yt(n,o,s);W(`Loaded ${c.length} system prompts with regexes`);let l=await St(),u=new Map;for(let e of c){let t=u.get(e.promptId);t||(t=new Set,u.set(e.promptId,t));for(let n of Object.values(e.identifierMap))t.add(n)}let d=[],f={},p=[];for(let{promptId:r,prompt:s,regex:m,getInterpolatedContent:h,pieces:g,identifiers:_,identifierMap:v}of c){if(i&&!i.includes(r)){d.push({id:r,name:s.name,group:H.SYSTEM_PROMPTS,applied:!1,skipped:!0});continue}W(`Applying system prompt: ${s.name}`);let c=new RegExp(m,`si`),y=await tn(m,`sig`,e),b=null;if(y.length===1)b=y[0];else if(y.length>1){let t=e=>e===`"`||e===`'`||e==="`",n=y.filter(n=>{let r=n.index>0?e[n.index-1]:``,i=e[n.index+n[0].length]??``;return t(r)&&r===i});n.length===1?(b=n[0],W(`Disambiguated ${y.length} matches \u2192 1 standalone for "${s.name}"`)):b=y[0]}if(b&&b.index!==void 0){let i=h(b),a=b.index,c=a>0?e[a-1]:``;{let e=[...new Set([...i.matchAll(/(?<!\\)\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g)].map(e=>e[1]))].filter(e=>l.has(e)&&RegExp(`(?<!\\\\)\\$\\{`+e+`\\}`).test(s.content)),a=new Set(Object.values(v)),o=u.get(r);if(e.length>0&&e.every(e=>!a.has(e)&&o?.has(e))){W(`"${s.name}": placeholders resolve via a same-id sibling shape — leaving this site pristine`),d.push({id:r,name:s.name,group:H.SYSTEM_PROMPTS,applied:!1,skipped:!0});continue}if(c==="`"&&e.length>0){console.log(t.red(`Unresolved placeholder \${${e[0]}} in "${s.name}" (markdown vocabulary out of sync with CC ${n} prompt data) - skipping`)),d.push({id:r,name:s.name,group:H.SYSTEM_PROMPTS,applied:!1,details:`unresolved placeholder \${${e[0]}} - markdown out of sync with prompt data`});continue}}let m=Et(g,_,v).trim().length,y=s.content.trim().length,x=e,S=b[0].length,C=i;if((c===`"`||c===`'`)&&(C=C.replace(/\\/g,`\\\\`)),c===`"`)C=C.replace(/\r\n|\r|\n/g,`\\n`),C=an(C,`"`);else if(c===`'`)C=C.replace(/\r\n|\r|\n/g,`\\n`),C=an(C,`'`);else if(c==="`"){C=C.replace(/\r\n|\r/g,`
221
+ `);let{content:e,incomplete:n}=Gt(C);if(n){console.log(t.red(`Incomplete backtick escaping for "${s.name}" (unclosed interpolation) - skipping`)),d.push({id:r,name:s.name,group:H.SYSTEM_PROMPTS,applied:!1,details:`incomplete escaping: unclosed interpolation detected`});continue}e!==C&&console.log(t.yellow(`Auto-escaped unescaped backticks in "${s.name}"`)),C=e}o&&(C=Ht(C)),e=e.slice(0,a)+C+e.slice(a+S),f[r]=Xe(s.content),P(x,e,C,a,a+S);let w=m-y,T=x!==e,E;E=w>0?t.green(`${w} fewer chars`):w<0?t.red(`${Math.abs(w)} more chars`):`unchanged`;let ee=d.length;d.push({id:r,name:s.name,group:H.SYSTEM_PROMPTS,applied:T,details:E}),p.push(ee)}else{let n=!1;if(a!==void 0&&a!==e)try{n=(await tn(m,`sig`,a)).length>0}catch{n=!1}if(n){W(`"${s.name}": region consumed by an earlier inline-blob/reminder override — leaving superseded, no warning`),d.push({id:r,name:s.name,group:H.SYSTEM_PROMPTS,applied:!1,skipped:!0});continue}!s.name.startsWith(`Data:`)&&s.name!==`Skill: Build with Claude API`&&console.log(t.yellow(`Could not find system prompt "${s.name}" in cli.js (using regex ${ha(c)})`)),G(`\n Debug info for ${s.name}:`),G(` Regex pattern (first 200 chars): ${m.substring(0,200).replace(/\n/g,`\\n`)}...`),G(` Trying to match pattern in cli.js...`);try{G(` Partial match result: ${e.match(new RegExp(m.substring(0,100)))?`found partial`:`no match`}`)}catch{G(` Partial match failed (regex truncation issue)`)}}}try{await at(f)}catch(e){W(`Failed to store applied prompt hashes: ${e}`);for(let e of p){let t=d[e];t&&(t.failed=!0,t.details=t.details?`${t.details} (hash storage failed)`:`hash storage failed`)}}return{newContent:e,results:d}},sn=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(parseInt(t,16))),P=(e,n,r,i,a,o=40)=>{if(!Zi())return;let s=Math.max(0,i-o),c=Math.min(e.length,a+o),l=Math.min(n.length,i+r.length+o),u=e.slice(s,c),d=n.slice(s,l),f=sn(u),p=sn(d);if(f===p){Qi()&&(G(`
222
+ --- Diff ---`),G(t.blue(`UNCHANGED: `)+t.dim(f)),G(`--- End Diff ---
223
+ `));return}let m=b(f,p),h=0,g=0,_=-1,v=-1,y=-1,x=-1,S=0,C=0;for(let e of m)e.added?(y===-1&&(y=g,_=h),x=g+e.value.length,v=h,S=h,C=g+e.value.length,g+=e.value.length):e.removed?(_===-1&&(_=h,y=g),v=h+e.value.length,x=g,S=h+e.value.length,C=g,h+=e.value.length):(h+=e.value.length,g+=e.value.length);_===-1&&(_=0),y===-1&&(y=0),v===-1&&(v=f.length),x===-1&&(x=p.length);let w=f.length-S,T=p.length-C,E=Math.min(w,T,o),ee=Math.max(0,_-o),te=Math.min(f.length,S+E),D=Math.max(0,y-o),ne=Math.min(p.length,C+E),re=b(f.slice(ee,te),p.slice(D,ne)),O=``;for(let e of re)if(!e.added)if(e.removed)if(e.value.includes(`
224
+ `)){let n=e.value.split(`
225
+ `);n.forEach((e,r)=>{e&&(O+=t.bgRed.white(e)),r<n.length-1&&(O+=t.bgRed.dim(`\\n`)+`
226
+ `)})}else O+=t.bgRed.white(e.value);else O+=t.dim(e.value);let k=``;for(let e of re)if(e.added)if(e.value.includes(`
227
+ `)){let n=e.value.split(`
228
+ `);n.forEach((e,r)=>{e&&(k+=t.bgGreen.black(e)),r<n.length-1&&(k+=t.bgGreen.dim(`\\n`)+`
229
+ `)})}else k+=t.bgGreen.black(e.value);else e.removed||(k+=t.dim(e.value));G(`
230
+ --- Diff ---`),G(t.red(`OLD: `)+O),G(t.green(`NEW: `)+k),G(`--- End Diff ---
231
+ `)},F=(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),P(a,s,c,t,t+i)}return s},cn=(e,t)=>{if(!/^<!--/.test(t))return null;let n;try{n=_(t,{delimiters:[`<!--`,`-->`]})}catch{return null}let r=n.data;return typeof r.inlineBlobAnchor!=`string`||!r.inlineBlobAnchor||typeof r.inlineBlobKind!=`string`||![`array`,`template`,`string`].includes(r.inlineBlobKind)?null:{filename:e,frontmatter:r,body:n.content.replace(/^\n+/,``).replace(/\n+$/,``)}},ln=(e,t)=>{if(e[t]!==`[`)return null;let n=0,r=!1,i=null,a=t;for(;a<e.length;){let t=e[a];if(r){if(t===`\\`&&a+1<e.length){a+=2;continue}if(t===i)r=!1;else if(i==="`"&&t===`$`&&a+1<e.length&&e[a+1]===`{`){let t=1,n=a+2;for(;n<e.length&&t>0;){let r=e[n];if(r===`\\`&&n+1<e.length){n+=2;continue}if(r==="`"){let r=un(e,n);if(r===null){t=0;break}n=r;continue}r===`{`?t++:r===`}`&&t--,n++}a=n;continue}}else if(t===`"`||t===`'`||t==="`")r=!0,i=t;else if(t===`[`)n++;else if(t===`]`&&(n--,n===0))return a+1;a++}return null},un=(e,t)=>{if(e[t]!=="`")return null;let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`&&n+1<e.length){n+=2;continue}if(t==="`")return n+1;if(t===`$`&&n+1<e.length&&e[n+1]===`{`){let t=1,r=n+2;for(;r<e.length&&t>0;){let n=e[r];if(n===`\\`&&r+1<e.length){r+=2;continue}if(n==="`"){let t=un(e,r);if(t===null)return null;r=t;continue}n===`{`?t++:n===`}`&&t--,r++}n=r;continue}n++}return null},dn=e=>/\\u[0-9a-fA-F]{4}/.test(e),fn=(e,t)=>{let n=`"`;for(let r of e){let e=r.codePointAt(0);if(r===`\\`)n+=`\\\\`;else if(r===`"`)n+=`\\"`;else if(r===`
232
+ `)n+=`\\n`;else if(r===`\r`)n+=`\\r`;else if(r===` `)n+=`\\t`;else if(t&&e>126)if(e<=65535)n+=`\\u`+e.toString(16).padStart(4,`0`);else{let t=e-65536,r=55296+(t>>10),i=56320+(t&1023);n+=`\\u`+r.toString(16).padStart(4,`0`)+`\\u`+i.toString(16).padStart(4,`0`)}else n+=r}return n+=`"`,n},pn=e=>{let t=[],n=0;for(;n<e.length;){if(e[n]===`$`&&n+1<e.length&&e[n+1]===`{`&&(n===0||e[n-1]!==`\\`)){let r=1,i=n+2,a=!1,o=null,s=i;for(;i<e.length&&r>0;){let t=e[i];if(a){if(t===`\\`&&i+1<e.length){i+=2;continue}t===o&&(a=!1)}else if(t===`"`||t===`'`||t==="`")a=!0,o=t;else if(t===`{`)r++;else if(t===`}`&&(r--,r===0))break;i++}t.push(e.slice(s,i)),n=i+1;continue}n++}return t},mn=(e,t)=>{let n=``,r=0,i=0;for(;r<e.length;){if(e[r]===`$`&&r+1<e.length&&e[r+1]===`{`&&(r===0||e[r-1]!==`\\`)){let a=1,o=r+2,s=!1,c=null;for(;o<e.length&&a>0;){let t=e[o];if(s){if(t===`\\`&&o+1<e.length){o+=2;continue}t===c&&(s=!1)}else if(t===`"`||t===`'`||t==="`")s=!0,c=t;else if(t===`{`)a++;else if(t===`}`&&(a--,a===0))break;o++}i<t.length?n+="${"+t[i]+`}`:n+=e.slice(r,o+1),i++,r=o+1;continue}n+=e[r],r++}return n},hn=e=>{let t=new Set;for(let n of e.matchAll(/(?<!\\)\$\{([A-Za-z$][\w$]*)\}/g)){let e=n[1];e.length>4||e===e.toUpperCase()&&/[A-Z]/.test(e)&&e.length>2||t.add(e)}return t},gn=(e,t)=>{let n=hn(e),r=[];for(let e of hn(t))n.has(e)||r.push(e);return r},_n=e=>{let t=[],n=0,r=!1,i=null,a=e=>/[A-Za-z_$]/.test(e),o=e=>/[A-Za-z0-9_$]/.test(e);for(;n<e.length;){let s=e[n];if(r){if(s===`\\`&&n+1<e.length){n+=2;continue}if(s===i){r=!1,n++;continue}if(i==="`"&&s===`$`&&n+1<e.length&&e[n+1]===`{`){let r=1,i=n+2,a=!1,o=null;for(;i<e.length&&r>0;){let t=e[i];if(a){if(t===`\\`&&i+1<e.length){i+=2;continue}t===o&&(a=!1),i++;continue}if(t===`"`||t===`'`||t==="`"){a=!0,o=t,i++;continue}if(t===`{`)r++;else if(t===`}`&&(r--,r===0))break;i++}let s=e.slice(n+2,i);for(let e of _n(s))t.push({name:e.name,start:e.start+n+2,end:e.end+n+2});n=i+1;continue}n++;continue}if(s===`"`||s===`'`||s==="`"){r=!0,i=s,n++;continue}if(a(s)){let r=n>0?e[n-1]:``,i=n>1?e[n-2]:``,a=n>2?e[n-3]:``,s=!(r===`.`&&i===`.`&&a===`.`)&&(r===`.`||r===`?`&&i===`?`),c=n;for(;n<e.length&&o(e[n]);)n++;let l=e.slice(c,n);!s&&![`true`,`false`,`null`,`undefined`,`this`,`void`,`new`].includes(l)&&t.push({name:l,start:c,end:n});continue}n++}return t},vn=(e,t)=>{let n=_n(e);if(n.length===0)return e;let r=``,i=0,a=0;for(let o of n)r+=e.slice(i,o.start),a<t.length?r+=t[a]:r+=o.name,i=o.end,a++;return r+=e.slice(i),r},yn=(e,t)=>{let n="`",r=0;for(;r<e.length;){let i=e[r];if(i===`$`&&r+1<e.length&&e[r+1]===`{`){let t=1,i=r+2,a=!1,o=null;for(;i<e.length&&t>0;){let n=e[i];if(a){if(n===`\\`&&i+1<e.length){i+=2;continue}n===o&&(a=!1)}else n===`"`||n===`'`||n==="`"?(a=!0,o=n):n===`{`?t++:n===`}`&&t--;i++}n+=e.slice(r,i),r=i;continue}let a=i.codePointAt(0);if(i===`\\`)n+=`\\\\`;else if(i==="`")n+="\\`";else if(t&&a>126)if(a<=65535)n+=`\\u`+a.toString(16).padStart(4,`0`);else{let e=a-65536,t=55296+(e>>10),r=56320+(e&1023);n+=`\\u`+t.toString(16).padStart(4,`0`)+`\\u`+r.toString(16).padStart(4,`0`)}else n+=i;r++}return n+="`",n},bn=async e=>{let t=dn(e);t&&W(`inlineBlobOverrides: cli.js uses unicode escaping`);let n;try{n=await a.readdir(Z)}catch{return{content:e,results:[]}}let r=n.filter(e=>e.startsWith(`inline-`)&&e.endsWith(`.md`));if(r.length===0)return{content:e,results:[]};let i=[];for(let n of r.sort()){let r=l.join(Z,n),o;try{o=await a.readFile(r,`utf8`)}catch(e){i.push({filename:n,name:n,applied:!1,failed:!0,details:`read failed: ${e}`});continue}let s=cn(n,o);if(!s){i.push({filename:n,name:n,applied:!1,failed:!0,details:`frontmatter missing inlineBlobAnchor/Kind`});continue}let{frontmatter:c,body:u}=s,d;try{d=new RegExp(c.inlineBlobAnchor,`s`)}catch(e){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`invalid anchor regex: ${e}`});continue}let f=d.exec(e);if(!f){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`anchor not found in cli.js`});continue}let p,m,h;if(c.inlineBlobKind===`array`){let r=e.indexOf(`[`,f.index);if(r===-1){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`no [ after anchor`});continue}let a=ln(e,r);if(a===null){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`array walker failed`});continue}p=r,m=a,h=c.inlineBlobRawPassthrough===`true`?`[`+vn(u,_n(e.slice(r+1,a-1)).map(e=>e.name))+`]`:`[`+u.split(`
233
+ `).map(e=>fn(e,t)).join(`,`)+`]`}else if(c.inlineBlobKind===`template`){let r=e[f.index]==="`"?f.index:e.indexOf("`",f.index);if(r===-1){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`no backtick at/after anchor`});continue}let a=un(e,r);if(a===null){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`template walker failed`});continue}p=r,m=a,h=yn(mn(u,pn(e.slice(r+1,a-1))),t)}else if(c.inlineBlobKind===`string`){let r=f.index;for(;r<e.length&&e[r]!==`"`&&e[r]!==`'`;)r++;if(r>=e.length){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`no quote at/after anchor`});continue}let a=e[r],o=r+1;for(;o<e.length;){if(e[o]===`\\`){o+=2;continue}if(e[o]===a)break;o++}if(o>=e.length){i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`unterminated string`});continue}p=r,m=o+1,h=fn(u,t)}else{i.push({filename:n,name:c.name,applied:!1,failed:!0,details:`kind ${c.inlineBlobKind} not implemented`});continue}let g=f.index,_=f.index+f[0].length;if(!(p<=_&&m>g)){console.log(`inline-blob: anchor for "${c.name}" (${n}) matched outside its target literal — cannot apply safely, skipping`),i.push({filename:n,name:c.name,applied:!1,failed:!1,skipped:!0,details:`anchor matched outside target literal — skipped (unsafe)`});continue}let v=gn(e.slice(p,m),h);if(v.length>0){console.log(`inline-blob: "${c.name}" (${n}) would introduce undefined var \${${v[0]}} (markdown out of sync with CC prompt data) — cannot apply safely, skipping`),i.push({filename:n,name:c.name,applied:!1,failed:!1,skipped:!0,details:`would introduce undefined \${${v[0]}} — skipped (unsafe)`});continue}let y=e;e=e.slice(0,p)+h+e.slice(m);let b=m-p-h.length,x=b>0?`${b} fewer chars`:b<0?`${-b} more chars`:`unchanged`;P(y,e,h,p,m),i.push({filename:n,name:c.name,applied:!0,failed:!1,details:x})}return{content:e,results:i}},xn=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-4e3),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]}},Sn=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;if(i=F(i,t,``),i=F(i,n,``),i=F(i,r,``),i.includes(`textDocument/didOpen`))return W(`patch: fixLspSupport: native LSP didOpen detected — skipping injection`),i;let a=xn(i);if(!a||!a.identifiers)return null;let[o,s]=a.identifiers,c=`
234
+ const path = await import('path');
235
+ const ext = path.extname(${o}).toLowerCase();
236
+ const langMap = {
237
+ '.ts': 'typescript',
238
+ '.tsx': 'typescriptreact',
239
+ '.js': 'javascript',
240
+ '.jsx': 'javascriptreact',
241
+ '.mjs': 'javascript',
242
+ '.cjs': 'javascript',
243
+ '.mts': 'typescript',
244
+ '.cts': 'typescript',
245
+ '.py': 'python',
246
+ '.pyi': 'python',
247
+ '.pyw': 'python',
248
+ '.rs': 'rust',
249
+ '.go': 'go',
250
+ '.java': 'java',
251
+ '.kt': 'kotlin',
252
+ '.kts': 'kotlin',
253
+ '.scala': 'scala',
254
+ '.sc': 'scala',
255
+ '.groovy': 'groovy',
256
+ '.c': 'c',
257
+ '.cpp': 'cpp',
258
+ '.cc': 'cpp',
259
+ '.cxx': 'cpp',
260
+ '.c++': 'cpp',
261
+ '.h': 'c',
262
+ '.hpp': 'cpp',
263
+ '.hh': 'cpp',
264
+ '.hxx': 'cpp',
265
+ '.h++': 'cpp',
266
+ '.cs': 'csharp',
267
+ '.csx': 'csharp',
268
+ '.html': 'html',
269
+ '.htm': 'html',
270
+ '.css': 'css',
271
+ '.scss': 'scss',
272
+ '.sass': 'sass',
273
+ '.less': 'less',
274
+ '.php': 'php',
275
+ '.phtml': 'php',
276
+ '.php3': 'php',
277
+ '.php4': 'php',
278
+ '.php5': 'php',
279
+ '.phps': 'php',
280
+ '.rb': 'ruby',
281
+ '.rbw': 'ruby',
282
+ '.rake': 'ruby',
283
+ '.gemspec': 'ruby',
284
+ '.sh': 'shellscript',
285
+ '.bash': 'shellscript',
286
+ '.zsh': 'shellscript',
287
+ '.fish': 'fish',
288
+ '.swift': 'swift',
289
+ '.m': 'objective-c',
290
+ '.mm': 'objective-cpp',
291
+ '.lua': 'lua',
292
+ '.pl': 'perl',
293
+ '.pm': 'perl',
294
+ '.t': 'perl',
295
+ '.pod': 'perl',
296
+ '.r': 'r',
297
+ '.R': 'r',
298
+ '.rmd': 'rmd',
299
+ '.Rmd': 'rmd',
300
+ '.ex': 'elixir',
301
+ '.exs': 'elixir',
302
+ '.erl': 'erlang',
303
+ '.hrl': 'erlang',
304
+ '.hs': 'haskell',
305
+ '.lhs': 'haskell',
306
+ '.ml': 'ocaml',
307
+ '.mli': 'ocaml',
308
+ '.clj': 'clojure',
309
+ '.cljs': 'clojure',
310
+ '.cljc': 'clojure',
311
+ '.edn': 'clojure',
312
+ '.json': 'json',
313
+ '.jsonc': 'jsonc',
314
+ '.xml': 'xml',
315
+ '.yaml': 'yaml',
316
+ '.yml': 'yaml',
317
+ '.toml': 'toml',
318
+ '.ini': 'ini',
319
+ '.cfg': 'ini',
320
+ '.conf': 'conf',
321
+ '.md': 'markdown',
322
+ '.markdown': 'markdown',
323
+ '.mdown': 'markdown',
324
+ '.rst': 'restructuredtext',
325
+ '.tex': 'latex',
326
+ '.sql': 'sql',
327
+ '.graphql': 'graphql',
328
+ '.gql': 'graphql',
329
+ '.dart': 'dart',
330
+ '.jl': 'julia',
331
+ '.zig': 'zig',
332
+ '.nim': 'nim',
333
+ '.nims': 'nim',
334
+ '.cr': 'crystal',
335
+ '.d': 'd',
336
+ '.di': 'd',
337
+ '.fs': 'fsharp',
338
+ '.fsx': 'fsharp',
339
+ '.fsi': 'fsharp',
340
+ '.ps1': 'powershell',
341
+ '.psm1': 'powershell',
342
+ '.psd1': 'powershell',
343
+ '.bat': 'bat',
344
+ '.cmd': 'bat',
345
+ '.mk': 'makefile',
346
+ '.dockerfile': 'dockerfile',
347
+ '.proto': 'proto',
348
+ '.vhd': 'vhdl',
349
+ '.vhdl': 'vhdl',
350
+ '.v': 'verilog',
351
+ '.sv': 'systemverilog',
352
+ '.asm': 'asm',
353
+ '.s': 'asm',
354
+ '.f': 'fortran',
355
+ '.f90': 'fortran',
356
+ '.f95': 'fortran',
357
+ '.cob': 'cobol',
358
+ '.cbl': 'cobol',
359
+ '.ada': 'ada',
360
+ '.adb': 'ada',
361
+ '.ads': 'ada',
362
+ '.sol': 'solidity',
363
+ '.vue': 'vue',
364
+ '.svelte': 'svelte',
365
+ '.astro': 'astro',
366
+ '.tf': 'terraform',
367
+ '.tfvars': 'terraform',
368
+ '.prisma': 'prisma'
369
+ };
370
+ const languageId = langMap[ext] || 'plaintext';
371
+ try {
372
+ const fs = await import('fs/promises');
373
+ const text = await fs.readFile(${o}, 'utf8');
374
+ await ${s}.sendNotification('textDocument/didOpen', {
375
+ textDocument: {
376
+ uri: "file://" + ${o},
377
+ languageId: languageId,
378
+ version: 1,
379
+ text: text
380
+ }
381
+ });
382
+ } catch (openErr) { }
383
+ `,l=i.slice(0,a.startIndex)+c+i.slice(a.endIndex);return P(i,l,c,a.startIndex,a.endIndex),l},Cn=e=>{let t=e.match(/messagesSummarized:([$\w]+)\.length\},([$\w]+)=([$\w]+)==="up_to"\?\1:([$\w]+),([$\w]+)=\3==="up_to"\?\{\.\.\.([$\w]+),forkContextMessages:\1\}:\6/);if(!t||t.index===void 0)return/messagesSummarized:([$\w]+)\.length\},([$\w]+)=\1,([$\w]+)=\{\.\.\.([$\w]+),forkContextMessages:\1\}/.test(e)?(W(`patch: fixSummarizeFromHere: already applied in this CC build — no-op`),e):(console.error(`patch: fixSummarizeFromHere: failed to find the summarize-direction ternary`),null);let[,n,r,,,i,a]=t,o=`messagesSummarized:${n}.length},${r}=${n},${i}={...${a},forkContextMessages:${n}}`,s=e.slice(0,t.index)+o+e.slice(t.index+t[0].length);return P(e,s,o,t.index,t.index+o.length),s},wn=e=>{let t=e.match(/content:([$\w]+\([$\w]+,!1,[$\w]+,void 0,[$\w]+\)),(isCompactSummary:!0,\.\.\.[$\w]+\.length>0\?\{summarizeMetadata:\{messagesSummarized:[$\w]+\.length,userContext:[$\w]+,direction:([$\w]+)\}\})/);if(!t||t.index===void 0)return e.includes(`.replace(/This session is being continued`)?(W(`patch: fixRewindSummaryHeader: already applied in this CC build — no-op`),e):(console.error(`patch: fixRewindSummaryHeader: failed to find the rewind summary message (summarizeMetadata.direction call site)`),null);if(!e.includes(`This session is being continued from a previous conversation that ran out of context`))return console.error(`patch: fixRewindSummaryHeader: rewind call site found but the compaction header phrase changed — needs re-anchoring`),null;let[,n,r,i]=t,a=`content:${`${n}.replace(/This session is being continued from a previous conversation that ran out of context\\.[^\\n]*/,${i}==="up_to"?${JSON.stringify(`This session was rewound at your request, not a context overflow. The summary below covers the earlier portion up to your selected point; the recent messages are kept intact.`)}:${JSON.stringify(`This session was rewound to an earlier point at your request, not a context overflow. The summary below captures the later work you chose to carry forward; the messages above are intact.`)})`},${r}`,o=e.slice(0,t.index)+a+e.slice(t.index+t[0].length);return P(e,o,a,t.index,t.index+a.length),o},Tn=(e,t)=>{let n=1,r=t+1,i=0,a=!1,o=null,s=!1;for(;r<e.length;){let t=e[r];if(o){s?s=!1:t===`\\`?s=!0:t===o&&(o=null),r++;continue}if(t===`"`||t===`'`||t==="`")o=t,a=!0;else if(t===`[`||t===`(`||t===`{`)n++,a=!0;else if(t===`]`){if(n===1)return a&&i++,{itemCount:i,closingBracket:r};n--}else t===`)`||t===`}`?n--:t===`,`&&n===1?(a&&i++,a=!1):/\s/.test(t)||(a=!0);r++}return null},En=e=>{let t=/=>\s*\[/g,n,r=null;for(;(n=t.exec(e))!==null;){let t=n.index+n[0].length-1,i=e.slice(Math.max(0,n.index-12e3),Math.min(e.length,n.index+12e3));if(!/name:"[^"]+"[\s\S]{0,1200}description:/.test(i))continue;let a=Tn(e,t);a&&a.itemCount>=30&&(!r||a.itemCount>r.items)&&(r={closing:a.closingBracket,items:a.itemCount})}return r?r.closing:(console.error(`patch: findSlashCommandListEndPosition: failed to find arrayStartPattern`),null)},Dn=(e,t)=>{let n=En(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 P(e,r,t,n,n),r},On=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)},kn=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]},I=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},An=e=>{let t=En(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},jn=(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 P(e,i,a,o.index,o.index),i},Mn=(e,t,n)=>{let r=I(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`};
384
+ let ${o} = undefined;
385
+ const toolsets = ${c};
386
+ if (toolsets.hasOwnProperty(currentToolset)) {
387
+ const allowedTools = toolsets[currentToolset];
388
+ if (allowedTools === "*") {
389
+ ${o} = ${s};
390
+ } else {
391
+ ${o} = ${s}.filter((toolDef) => allowedTools.includes(toolDef.name));
392
+ }
393
+ } else {
394
+ ${o} = ${s};
395
+ }let `,u=a.index,d=u+a[0].length,f=e.slice(0,u)+l+e.slice(d);return P(e,f,l,u,d),f},Nn=(e,t,n)=>{if(!I(e))return console.error(`patch: toolsets: computeToolsFilter: failed to find app state info`),null;let r=e.match(/([$\w]+)=(?:([$\w]+\.useCallback\())?\(\)=>\{let ([$\w]+)=([$\w]+)\.getState\(\),([$\w]+)=([$\w]+)\(\3\.toolPermissionContext,\3\.mcp\.tools(?:,\{skillTools:\3\.skillTools\})?\),([$\w]+)=([$\w]+)\([$\w]+,\5,\3\.toolPermissionContext\.mode\);if\(!([$\w]+)\)return \7;return ([$\w]+)\(\9,\7,!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=r[10],m=r[0].includes(`{skillTools:${o}.skillTools}`)?`,{skillTools:${o}.skillTools}`:``,h=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),g=n?JSON.stringify(n):`undefined`,_=r[0],v=_.match(RegExp(`${d.replace(/\$/g,`\\$`)}\\(([$\\w]+),${c.replace(/\$/g,`\\$`)},`));if(!v)return console.error(`patch: toolsets: computeToolsFilter: failed to extract init var from merge call`),null;let y=`${i}=${a}()=>{let ${o}=${s}.getState(),${c}=${l}(${o}.toolPermissionContext,${o}.mcp.tools${m}),${u}=${d}(${v[1]},${c},${o}.toolPermissionContext.mode);const __ts=${h},__tc=${o}.toolset??${g},__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(!${f})return __tf(${u});return __tf(${p}(${f},${u},!1,!0).resolvedTools)}`,b=r.index,x=b+_.length,S=e.slice(0,b)+y+e.slice(x);return P(e,S,y,b,x),S},Pn=(e,t,n)=>{let r=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),i=n?JSON.stringify(n):`undefined`,a=e.match(/let ([$\w]+)=([$\w]+)\(([$\w]+)\);(?=[\s\S]{0,2500}tools:\1,refreshTools:\(\)=>\2\(([$\w]+)\(\)\))/);if(!a||a.index===void 0)return console.error(`patch: toolsets: printToolsFilter: failed to find print tools initialization`),null;let o=a[1],s=a[2],c=a[3],l=a[4],u=`let ${o}=${s}(${c});const __tpts=${r},__tptf=(t,s)=>{const n=s.toolset??${i};globalThis.__tweakcc_toolset={name:n,tools:__tpts[n]};if(__tpts.hasOwnProperty(n)){const a=__tpts[n];if(a==="*")return t;return t.filter(d=>a.includes(d.name))}return t};${o}=__tptf(${o},${c});`,d=e.slice(0,a.index)+u+e.slice(a.index+a[0].length);P(e,d,u,a.index,a.index+a[0].length);let f=RegExp(`refreshTools:\\(\\)=>${s.replace(/\$/g,`\\$`)}\\(${l.replace(/\$/g,`\\$`)}\\(\\)\\)`),p=d.match(f);if(!p||p.index===void 0)return console.error(`patch: toolsets: printToolsFilter: failed to find print refreshTools`),null;let m=`refreshTools:()=>{let s=${l}();return __tptf(${s}(s),s)}`,h=d;return d=d.slice(0,p.index)+m+d.slice(p.index+p[0].length),P(h,d,m,p.index,p.index+p[0].length),d},Fn=(e,t,n)=>{let r=/`<tool_use_error>Error: No such tool available: \$\{([$\w.]+)\}(?:\$\{([$\w.]+)\})?<\/tool_use_error>`/g,i=e,a=0,o=`__tweakcc_toolErrorMsg`,s=`function ${o}(toolName,hint){hint=hint||"";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+hint+". 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+hint+"</tool_use_error>"};`;if(i=i.replace(r,(e,t,n)=>(a++,n?`${o}(${t},${n})`:`${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.]+)\}(?:\$\{([$\w.]+)\})?`/g,(e,t,n)=>`${n?`${o}(${t},${n})`:`${o}(${t})`}.replace(/<\\/?tool_use_error>/g,"")`);let c=i.indexOf(`
396
+ `,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)},In=(e,t,n)=>{let r=An(e);if(r===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let i=B(e);if(!i)return console.error(`patch: toolsets: failed to find React variable`),null;let a=Ii(e);if(!a)return console.error(`patch: toolsets: failed to find Box component`),null;let o=V(e);if(!o)return console.error(`patch: toolsets: failed to find Text component`),null;let s=On(e);if(!s)return console.error(`patch: toolsets: failed to find Select component`),null;let c=kn(e),l=I(e);if(!l)return console.error(`patch: toolsets: failed to find app state getter`),null;let u=L(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 }) => {
397
+ const currentToolset = ${d}(state => state.toolset) ?? ${n?JSON.stringify(n):`undefined`};
398
+
399
+ const setState = ${f}();
400
+
401
+ // Handle command-line argument
402
+ if (input !== "" && input != null) {
403
+ if (!${p}.includes(input)) {
404
+ onExit(${u}.red(\`\${${u}.bold(input)} is not a valid toolset. Valid toolsets: \` + ${JSON.stringify(t.map(e=>e.name).join(`, `))}));
405
+ return;
406
+ } else {
407
+ setState(prev => ({ ...prev, toolset: input }));
408
+ onExit(\`Toolset changed to \${${u}.bold(input)}\`);
409
+ return;
410
+ }
411
+ }
412
+
413
+ // Render interactive UI
414
+ return ${i}.createElement(
415
+ ${a},
416
+ { flexDirection: "column" },
417
+ ${c?`${i}.createElement(${c}, { dividerColor: "permission" }),`:`${i}.createElement(${o}, { dimColor: true }, "─".repeat(40)),`}
418
+ ${i}.createElement(
419
+ ${a},
420
+ { paddingX: 1, marginBottom: 1, flexDirection: "column" },
421
+ ${i}.createElement(${a}, null,
422
+ ${i}.createElement(${o}, { bold: true, color: "remember" }, "Select toolset")
423
+ ),
424
+ ${i}.createElement(${a}, null,
425
+ ${i}.createElement(${o}, { dimColor: true }, "A toolset is a collection of tools that Claude sees and is allowed to call.")
426
+ ),
427
+ ${i}.createElement(${a}, { marginBottom: 1 },
428
+ ${i}.createElement(${o}, { dimColor: true }, "Claude cannot call tools that are not included in the selected toolset.")
429
+ ),
430
+ ${i}.createElement(${a}, null,
431
+ ${i}.createElement(${o}, { color: "warning" }, "Note that Claude may hallucinate that it has access to tools outside of the toolset.")
432
+ ),
433
+ ${i}.createElement(${a}, { marginBottom: 1 },
434
+ ${i}.createElement(${o}, { dimColor: true }, "If so, explicitly remind it what its tool list is, or tell it to check it itself.")
435
+ ),
436
+ ${i}.createElement(${a}, null,
437
+ ${i}.createElement(${o}, { dimColor: true, bold: true }, "Toolsets are managed with tweakcc-fixed. "),
438
+ ${i}.createElement(${o}, { dimColor: true }, "Run "),
439
+ ${i}.createElement(${o}, { color: "permission" }, "npx tweakcc-fixed"),
440
+ ${i}.createElement(${o}, { dimColor: true }, " to manage them.")
441
+ ),
442
+ ${i}.createElement(${a}, { marginBottom: 1 },
443
+ ${i}.createElement(${o}, { color: "permission" }, "https://github.com/skrabe/tweakcc-fixed")
444
+ ),
445
+ ${i}.createElement(${a}, { marginBottom: 1 },
446
+ ${i}.createElement(${o}, null, "Current toolset: "),
447
+ ${i}.createElement(${o}, { bold: true }, currentToolset || "undefined")
448
+ ),
449
+ ${i}.createElement(${a}, { marginBottom: 1 },
450
+ ${i}.createElement(${s}, {
451
+ options: ${m},
452
+ onChange: (input) => {
453
+ setState(prev => ({ ...prev, toolset: input }));
454
+ onExit(\`Toolset changed to \${${u}.bold(input)}\`);
455
+ },
456
+ onCancel: () => onExit(\`Toolset not changed (left as \${${u}.bold(currentToolset)})\`)
457
+ })
458
+ ),
459
+ ${i}.createElement(${o}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
460
+ )
461
+ );
462
+ };`,g=e.slice(0,r)+h+e.slice(r);return P(e,g,h,r,r),g},Ln=e=>{let t=e.match(/\{color:"bashBorder"\},"! for (?:bash|shell) 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},Rn=(e,t)=>{let n=Ln(e);if(n===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let r=I(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 P(e,o,a,n,n),o},zn=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):(P(e,o,a,t.index,t.index+i.length),o)},Bn=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):(P(e,i,r,t.index,t.index+n.length),i)},Vn=e=>{let t=B(e);return t?Dn(e,`, {
463
+ aliases: ["change-tools"],
464
+ type: "local-jsx",
465
+ name: "toolset",
466
+ description: "Select a toolset (managed by tweakcc)",
467
+ argumentHint: "[toolset-name]",
468
+ isEnabled: () => true,
469
+ isHidden: false,
470
+ load: () => Promise.resolve().then(() => ({call: (onExit, ctx, input) => {
471
+ return ${t}.createElement(toolsetComp, { onExit, input });
472
+ }})),
473
+ userFacingName() {
474
+ return "toolset";
475
+ }
476
+ }`):(console.error(`patch: toolsets: failed to find React variable`),null)},Hn=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},Un=(e,t)=>{let n=Hn(e);if(n===null)return null;let r=I(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 P(e,o,a,n,n),o},Wn=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]}},Gn=(e,t,n)=>{let r=Wn(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 P(e,c,s,i,i),c},Kn=(e,t,n,r)=>{if(!t||t.length===0)return e;let i=e;if(i=jn(i,n),!i)return console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null;if(i=Mn(i,t,n),!i)return console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null;if(i=Nn(i,t,n),!i)return console.error(`patch: toolsets: step 2b failed (writeComputeToolsFilter)`),null;if(i=Pn(i,t,n),!i)return console.error(`patch: toolsets: step 2c failed (writePrintToolsFilter)`),null;let a=Fn(i,t,n);if(a?i=a:console.error(`patch: toolsets: step 2d failed (writeToolsetAwareErrors) — continuing without friendlier errors`),i=In(i,t,n),!i)return console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null;if(i=Vn(i),!i)return console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null;if(i=Rn(i,n),!i)return console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null;if(i=zn(i),!i)return console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null;if(i=Bn(i),!i)return console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null;if(r&&n){if(i=Un(i,n),!i)return console.error(`patch: toolsets: step 8a failed (addCurrentToolsetAtToolChangeComponentScope)`),null;if(i=Gn(i,r,n),!i)return console.error(`patch: toolsets: step 8b failed (writeModeChangeUpdateToolset)`),null}return i},qn=/\{top:\["┌","─","┬","┐"\],middle:\["├","─","┼","┤"\],bottom:\["└","─","┴","┘"\]\}/,Jn=/top:\["\\u250C","\\u2500","\\u252C","\\u2510"\],middle:\["\\u251C","\\u2500","\\u253C","\\u2524"\],bottom:\["\\u2514","\\u2500","\\u2534","\\u2518"\]/,Yn=/top: \["┌", "─", "┬", "┐"\],\s+middle: \["├", "─", "┼", "┤"\],\s+bottom: \["└", "─", "┴", "┘"\]/,Xn=/if\(([$\w]+)\.push\(\.\.\.([$\w]+)\(([$\w]+),!1\)\),([$\w]+)<([$\w]+)\.rows\.length-1\)([$\w]+)\.push\(([$\w]+)\("middle"\)\)/g,Zn=/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,Qn=/([$\w]+)\.push\(([$\w]+)\("top"\)\),/g,$n=/,([$\w]+)\.push\(([$\w]+)\("bottom"\)\),/g,er=/([$\w]+)\.push\(\s*([$\w]+)\(\s*"top"\s*\)\s*\)\s*,\s*/g,tr=/,\s*([$\w]+)\.push\(\s*([$\w]+)\(\s*"bottom"\s*\)\s*\)\s*,/g;function nr(e){let t=e,n=!1,r=t;t=t.replace(Xn,`$1.push(...$2($3,!1))`),t!==r&&(n=!0);let i=t;return t=t.replace(Zn,`$1.push(...$2($3,!1))`),t!==i&&(n=!0),{result:t,success:n}}function rr(e){let t=e,n=!1,r=t;t=t.replace(Qn,``),t!==r&&(n=!0);let i=t;t=t.replace(er,``),t!==i&&(n=!0);let a=t;t=t.replace($n,`,`),t!==a&&(n=!0);let o=t;return t=t.replace(tr,`,`),t!==o&&(n=!0),{result:t,success:n}}const ir=(e,t)=>{if(t===`markdown`&&(t=`ascii`),t===`default`)return W(`Table format is "default", no patching needed`),null;let n=e,r=0;if(t===`ascii`){if(qn.test(n)){let e=n;n=n.replace(qn,`{top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]}`),n!==e&&(r++,W(`Patched table border definition object (minified format)`))}else if(Jn.test(n)){let e=n;n=n.replace(Jn,`top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]`),n!==e&&(r++,W(`Patched table border definition object (native Unicode format)`))}else if(Yn.test(n)){let e=n;n=n.replace(Yn,`top: ["", "", "", ""],
477
+ 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,t=n.match(/function [$\w]+\([^)]*\)\{[\s\S]{0,1600}?let ([$\w]+)="(?:\\u2502|│)";[\s\S]{0,1600}?\1\+=" "\+[$\w]+\+" (?:\\u2502|│)"/);if(t&&t.index!==void 0){let e=t.index,r=e+t[0].length,i=n.slice(e,r).replace(/" \\u2502"/g,`" |"`).replace(/" │"/g,`" |"`);n=n.slice(0,e)+i+n.slice(r)}n!==e&&(r++,W(`Patched compact table vertical separators`))}{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}=nr(n);t&&(n=e,r++,W(`Removed inter-row separators`))}{let{result:e,success:t}=rr(n);t&&(n=e,r++,W(`Removed top/bottom border pushes`))}}else if(t===`clean`){if(qn.test(n)){let e=n;n=n.replace(qn,`{top:["","","",""],middle:["├","─","┼","┤"],bottom:["","","",""]}`),n!==e&&(r++,W(`Patched table border definition for clean format (minified format)`))}else if(Jn.test(n)){let e=n;n=n.replace(Jn,`top:["","","",""],middle:["\\u251C","\\u2500","\\u253C","\\u2524"],bottom:["","","",""]`),n!==e&&(r++,W(`Patched table border definition for clean format (native Unicode format)`))}else if(Yn.test(n)){let e=n;n=n.replace(Yn,`top: ["", "", "", ""],
478
+ middle: ["├", "─", "┼", "┤"],
479
+ 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}=nr(n);t&&(n=e,r++,W(`Removed inter-row separators`))}{let{result:e,success:t}=rr(n);t&&(n=e,r++,W(`Removed top/bottom border pushes`))}}else if(t===`clean-top-bottom`){let{result:e,success:t}=nr(n);t&&(n=e,r++,W(`Removed inter-row separators (keeping top/bottom borders)`))}else return console.error(`patch: tableFormat: failed to find handler for unknown format "${t}"`),W(`Unknown table format "${t}", skipping`),null;if(r===0)return console.error(`patch: tableFormat: failed to find any table-rendering patterns to patch for format "${t}" (border-definition object, vertical-border chars, horizontal separator, or inter-row separator)`),G(`No table format patches were applied - patterns may not have matched`),null;W(`[Table format patch: ${r} modifications for ${t} style]`);let i=ar(e,n);if(i!==-1){let{oldEnd:t,newEnd:r}=or(e,n,i),a=n.slice(i,r);P(e,n,a,i,t)}return W(`Table format patch applied: ${r} changes, file size ${e.length} -> ${n.length}`),n};function ar(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 or(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 sr=e=>B(e)?Dn(e,`, {
480
+ type: "local",
481
+ name: "title",
482
+ description: "Set the conversation title",
483
+ isEnabled: () => !0,
484
+ isHidden: !1,
485
+ async call(A, B, I) {
486
+ if (!A)
487
+ throw new Error("Please specify a conversation title.");
488
+ CUR_CONVERSATION_TITLE = A;
489
+ setTerminalTitleOverride(A);
490
+ return {
491
+ type: "text",
492
+ value: \`Conversation title set to \\x1b[1m\${A}\\x1b[0m\`,
493
+ }
494
+ },
495
+ userFacingName() {
496
+ return "title";
497
+ },
498
+ }`):(console.error(`patch: conversationTitle: failed to find React variable`),null),cr=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},lr=e=>{let t=cr(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=Mi(e),r=`
499
+ function getTweakccBaseDir() {
500
+ const { join: pathJoin } = ${n}('path');
501
+ const { homedir: osHomedir } = ${n}('os');
502
+ const { statSync: fsStatSync, mkdirSync: fsMkdirSync } = ${n}('fs');
503
+ // Prioritize ~/.tweakcc which is the original and default. Only respect
504
+ // XDG_CONFIG_HOME if it doesn't exist.
505
+ let dir;
506
+ let homedirTweakcc = pathJoin(osHomedir(), ".tweakcc");
507
+ try {
508
+ if (fsStatSync(homedirTweakcc).isDirectory()) {
509
+ dir = homedirTweakcc;
510
+ }
511
+ } catch (e) {
512
+ if (e.code == "ENOENT") {
513
+ // Doesn't exist. Move on and see if the XDG one exists.
514
+ } else {
515
+ throw new Error('cannot stat ' + homedirTweakcc + ': ' + e);
516
+ }
517
+ }
518
+
519
+ // Try XDG.
520
+ if (process.env.XDG_CONFIG_HOME) {
521
+ // XDG_CONFIG_HOME is set. If it's set and ~/.tweakcc doesn't exist, prefer it.
522
+ const xdgTweakcc = pathJoin(process.env.XDG_CONFIG_HOME, "tweakcc");
523
+ dir = xdgTweakcc;
524
+ }
525
+
526
+ // Create the dir.
527
+ fsMkdirSync(dir, { recursive: true });
528
+ return dir;
529
+ }
530
+
531
+ const findSummaryEntryForLeafUuid = (filePath, messageUuid) => {
532
+ const { readFileSync: fsReadFileSync, statSync: fsStatSync } = ${n}('fs');
533
+ // Optimization: skip files that are certain to not be tweakcc summary files (which only contain 1 small line).
534
+ if (fsStatSync(filePath).size > 1000) {
535
+ return null;
536
+ }
537
+ const lines = fsReadFileSync(filePath, "utf8")
538
+ .split("\\n")
539
+ .map((l) => JSON.parse(l.trim()));
540
+ for (const line of lines) {
541
+ if (line.type == "summary" && line.uuid == messageUuid) {
542
+ return line;
543
+ }
544
+ }
545
+ return null;
546
+ };
547
+
548
+ const getSummaryFileForLeafMessage = (
549
+ projectDirectory,
550
+ projectSlug,
551
+ messageUuid
552
+ ) => {
553
+ const { join: pathJoin } = ${n}('path');
554
+ const { readFileSync: fsReadFileSync, readdirSync: fsReaddirSync } = ${n}('fs');
555
+ try {
556
+ // File contains the uuid
557
+ const summaryFileId = fsReadFileSync(
558
+ pathJoin(getTweakccBaseDir(), "named-sessions", projectSlug, messageUuid),
559
+ "utf8"
560
+ ).trim();
561
+ return pathJoin(projectDirectory, summaryFileId + '.jsonl');
562
+ } catch (e) {
563
+ // File not found or can't be accessed, etc. Ignore.
564
+ }
565
+
566
+ // Just read each file and try to find it.
567
+ for (const file of fsReaddirSync(projectDirectory)) {
568
+ try {
569
+ const pth = pathJoin(projectDirectory, file);
570
+ const summaryObj = findSummaryEntryForLeafUuid(pth);
571
+ if (summaryObj != null && summaryObj.tweakcc != null) {
572
+ // It needs to be a tweakcc one.
573
+ return pth;
574
+ }
575
+ } catch {}
576
+ }
577
+
578
+ // It doesn't exist.
579
+ return null;
580
+ };
581
+
582
+ const setTerminalTitleOverride = (title) => {
583
+ process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE = 1;
584
+ if (process.platform === "win32") process.title = 'Claude: ' + title;
585
+ else process.stdout.write('\\x1B]0;Claude: ' + title + '\\x07');
586
+ };
587
+
588
+ let CUR_CONVERSATION_TITLE = "";
589
+ function onNewMessage(projectDir, projectSlug, msg) {
590
+ const { join: pathJoin } = ${n}('path');
591
+ const { readFileSync: fsReadFileSync, writeFileSync: fsWriteFileSync, mkdirSync: fsMkdirSync, renameSync: fsRenameSync } = ${n}('fs');
592
+ const { randomUUID: cryptoRandomUUID } = ${n}('crypto');
593
+ const tweakcc = getTweakccBaseDir();
594
+
595
+ if (msg.parentUuid) {
596
+ const path = getSummaryFileForLeafMessage(
597
+ projectDir,
598
+ projectSlug,
599
+ msg.parentUuid
600
+ );
601
+ if (path) {
602
+ // There's an old file. Update it to the new file.
603
+ const summaryObj = findSummaryEntryForLeafUuid(path);
604
+ summaryObj.leafUuid = msg.uuid;
605
+ if (CUR_CONVERSATION_TITLE != "") {
606
+ summaryObj.summary = CUR_CONVERSATION_TITLE;
607
+ } else {
608
+ CUR_CONVERSATION_TITLE = summaryObj.summary;
609
+ }
610
+ setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
611
+ fsWriteFileSync(path, JSON.stringify(summaryObj));
612
+
613
+ // Update the cache; it points from message ID to summary file ID.
614
+ fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
615
+ recursive: true,
616
+ });
617
+ const oldPath = pathJoin(
618
+ tweakcc,
619
+ "named-sessions",
620
+ projectSlug,
621
+ msg.parentUuid
622
+ );
623
+ const newPath = pathJoin(
624
+ tweakcc,
625
+ "named-sessions",
626
+ projectSlug,
627
+ msg.uuid
628
+ );
629
+ try {
630
+ fsRenameSync(oldPath, newPath);
631
+ return;
632
+ } catch (e) {
633
+ if (e.code == "ENOENT") {
634
+ // named-sessions/{projectSlug} exists, so the error is because the old named-session doesn't exist.
635
+ // So we need to create the new file later.
636
+ // DO NOT return.
637
+ } else {
638
+ throw new Error('cannot rename ' + oldPath + ' -> ' + newPath + ': ' + e);
639
+ }
640
+ }
641
+ }
642
+ }
643
+
644
+ // Only create our summary entry if a custom title has been set. Because we want the auto
645
+ // title generation to kick in if the user hasn't set a title, and the auto title generation
646
+ // won't generate titles for sessions older than the most recently
647
+ if (CUR_CONVERSATION_TITLE != "") {
648
+ setTerminalTitleOverride(CUR_CONVERSATION_TITLE);
649
+ const uuid = cryptoRandomUUID();
650
+
651
+ // Create the summary file.
652
+ const newFilePath = pathJoin(projectDir, uuid + '.jsonl');
653
+ const summaryObj = {
654
+ type: "summary",
655
+ summary: CUR_CONVERSATION_TITLE,
656
+ leafUuid: msg.uuid,
657
+ // This is important.
658
+ tweakcc: null,
659
+ };
660
+ fsWriteFileSync(newFilePath, JSON.stringify(summaryObj));
661
+
662
+ fsMkdirSync(pathJoin(tweakcc, "named-sessions", projectSlug), {
663
+ recursive: true,
664
+ });
665
+ fsWriteFileSync(
666
+ pathJoin(tweakcc, "named-sessions", projectSlug, msg.uuid),
667
+ uuid
668
+ );
669
+ }
670
+ }
671
+
672
+ `,i=e.slice(0,t)+r+e.slice(t);return P(e,i,r,t,t),i},ur=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]}},dr=e=>{let t=ur(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=Mi(e),{location:r,messageVar:i}=t,a=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
673
+ const projectDir = pathDirname(this.sessionFile);
674
+ const projectSlug = pathBasename(projectDir);
675
+ onNewMessage(projectDir, projectSlug, ${i});
676
+ `,o=e.slice(0,r)+a+e.slice(r);return P(e,o,a,r,r),o},fr=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}},pr=e=>{let t=fr(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=Mi(e),{orLocation:r,loopLocation:i,messageVar:a,fileListVar:o}=t,s=e,c=`const { readFileSync: fsReadFileSync } = ${n}('fs');
677
+ const tweakccSummaries = new Set();
678
+ for (const file of ${o}) {
679
+ const contents = fsReadFileSync(file, "utf8").trim();
680
+ if (contents.includes("\\n")) continue;
681
+ let obj;
682
+ try {
683
+ obj = JSON.parse(contents);
684
+ } catch {
685
+ // Skip invalid files.
686
+ continue;
687
+ }
688
+ if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
689
+ tweakccSummaries.add(obj.leafUuid);
690
+ }
691
+ `;s=s.slice(0,i)+c+s.slice(i),P(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 P(s,d,u,l,l),d},mr=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):(P(e,r,n,t.index,t.index+63),r)},hr=e=>{let t=/(([$\w]+)=[$\w]+\(\(\)=>\[)/g,n=null;for(let r of e.matchAll(t)){let t=e.slice(Math.max(0,r.index-12e3),Math.min(e.length,r.index+12e3));if(/name:"[^"]+"[\s\S]{0,1200}description:/.test(t)){n=r;break}}if(!n||n.index===void 0)return null;let r=e.match(/var ([$\w]+)=\{\};[$\w]+\(\1,\{performSetColor:\(\)=>[$\w]+,call:\(\)=>[$\w]+\}\);async function [$\w]+\(([$\w]+),([$\w]+),([$\w]+)\)\{return \2\(await [$\w]+\(\4,\3\),\{display:"system"\}\),null\}/);if(!r||r.index===void 0)return console.error(`patch: conversationTitle: failed to find local command module anchor`),null;let i=e.indexOf(`var `,r.index+r[0].length);if(i===-1)return console.error(`patch: conversationTitle: failed to find local command module end`),null;let a=`var tweakccTitleModule={};${r[0].match(/;([$\w]+)\(/)?.[1]??`P$`}(tweakccTitleModule,{call:()=>tweakccTitleCall});async function tweakccTitleCall(args,context){let title=args?.trim?.()??"";if(!title)return{type:"text",value:"Please specify a conversation title."};context.setAppState?.((state)=>({...state,customTitle:title}));process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE="1";if(process.platform==="win32")process.title="Claude: "+title;else process.stdout.write("\\x1B]0;Claude: "+title+"\\x07");let message="Conversation title set to "+title;if(context.options?.isNonInteractiveSession){process.stdout.write(message+"\\n");return{type:"skip"}}return{type:"text",value:message}}`,o=`tweakccTitleCommand={type:"local",name:"title",description:"Set the conversation title",argumentHint:"<title>",supportsNonInteractive:!0,userFacingName(){return"title"},load:()=>Promise.resolve(tweakccTitleModule)},`,s=e.slice(0,i)+a+e.slice(i),c=n.index+n[1].length+(n.index>=i?a.length:0);return s=s.slice(0,c)+o+s.slice(c),P(e,s,a+o,i,i),s},gr=e=>{let t=hr(e);if(t)return t;let n=e;if(n=sr(n),!n)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(n=lr(n),!n)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(n=dr(n),!n)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(n=pr(n),!n)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let r=mr(n);return r?n=r:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),n},_r=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},vr=e=>{let t=_r(e);if(t){let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return P(e,n,`,`,t.startIndex,t.endIndex),n}for(let t of[/(function [$\w]+\(\)\{)(?=let [$\w]+=[\w$]+\.c\(\d+\),[$\w]+=[\w$]+\(\)\.oauthAccount\?\.displayName\?\?""|let [$\w]+=[\w$]+\(\),[$\w]+=[\w$]+\?\.displayName\?\?"")/,/(function [$\w]+\(\)\{)(?=let [$\w]+=[\w$]+\.c\(\d+\),[$\w]+=[\w$]+\(\),[$\w]+=[\w$]+\?\.displayName\?\?"")/]){let n=e.match(t);if(n&&n.index!==void 0){let t=n.index+n[1].length,r=`return null;`,i=e.slice(0,t)+r+e.slice(t);return P(e,i,r,t,t),i}}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 P(e,i,r,n,n),i}}return console.error(`patch: hideStartupBanner: failed to find startup banner component`),null},yr=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:[]}},br=e=>{let t=yr(e);if(!t)return null;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return P(e,r,n,t.startIndex,t.endIndex),r},xr=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},Sr=e=>{let t=xr(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];P(e,i,r,t,t)}return i},Cr=e=>{let t=e.match(/CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS[\s\S]{0,1200}tengu_amber_wren/);if(t&&t.index!==void 0){let e=t[0].match(/=25000,/);if(e&&e.index!==void 0){let n=t.index+e.index+1;return{startIndex:n,endIndex:n+5}}}let n=[`<system-reminder>`,`tengu_amber_wren`],r=null;for(let t of n){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=RegExp(`=25000,([\\s\\S]{0,700})${n}`);if(r=e.match(i),r&&r.index!==void 0)break}if(!r||r.index===void 0)return console.error(`patch: increaseFileReadLimit: failed to find 25000 token limit near known anchor`),null;let i=r.index+1;return{startIndex:i,endIndex:i+5}},wr=e=>{let t=Cr(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return P(e,r,n,t.startIndex,t.endIndex),r},Tr=e=>{let t=e;for(let[n,r]of[[/"- Results are returned using cat -n format, with line numbers starting at 1"/g,`"- Results are returned as raw file content without line-number prefixes"`],[/`\$\{[$\w]+\}\. Each line is the line number, a single separator \(a tab or `:`\), then the verbatim file content \(including any leading whitespace\)\.`/g,"`Results are raw file content without line-number prefixes.`"]]){let i=t;t=t.replace(n,r),t!==i&&P(e,t,r,0,0)}return t},Er=e=>{let t=e.match(/\{content:([$\w]+),startLine:[$\w]+(?:,tabAwareSeparator:[$\w]+=!1)?\}\)\{if\(!\1\)return"";/);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);P(e,o,a,r,t);let s=o.match(/function ([$\w]+)\(([$\w]+),[$\w]+,[$\w]+\)\{let [$\w]+=\2\.endsWith\("\\r"\)\?\2\.slice\(0,-1\):\2;return`\$\{[$\w]+\}\$\{[$\w]+\}\$\{[$\w]+\}`\}/);if(s&&s.index!==void 0){let e=`function ${s[1]}(${s[2]}){return ${s[2]}.endsWith("\\r")?${s[2]}.slice(0,-1):${s[2]}}`,t=o;o=o.slice(0,s.index)+e+o.slice(s.index+s[0].length),P(t,o,e,s.index,s.index+s[0].length)}return o=Tr(o),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 P(e,r,t,n.index,n.index+n[0].length),r}return console.error(`patch: suppressLineNumbers: failed to find line number formatter pattern`),null},Dr=e=>{let t=[/\.createElement.{0,500},showAllInTranscript:[$\w]+,agentDefinitions:[$\w]+,onOpenRateLimitOptions:([$\w]+)/g,/\.createElement\([\w$]+,\{messages:[\w$]+,tools:[\w$]+,commands:[\w$]+,verbose:!0,toolJSX:null,inProgressToolUseIDs:[\w$]+,isMessageSelectorVisible:!1,conversationId:[\w$]+,screen:[\w$]+,agentDefinitions:[\w$]+,streamingToolUses:[\w$]+,showAllInTranscript:[\w$]+,onOpenRateLimitOptions:([\w$]+)/g],n=e,r=0;for(let e of t){let t=[...n.matchAll(e)];for(let e of t.reverse()){if(e.index===void 0)continue;let t=e[1],i=e.index+e[0].length-t.length,a=i+t.length,o=`()=>{}`,s=n.slice(0,i)+o+n.slice(a);P(n,s,o,i,a),n=s,r++}}return r===0?(console.error(`patch: suppressRateLimitOptions: failed to find onOpenRateLimitOptions pattern`),null):n},Or=e=>{if(!e.includes(`"tengu_session_memory"`))return W(`patch: sessionMemory: extraction gate already removed in this CC build — no-op`),e;let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_session_memory"/);if(t&&t.index!==void 0){let n=t.index+t[0].indexOf(`{`)+1,r=`return true;`,i=e.slice(0,n)+r+e.slice(n);return P(e,i,r,n,n),i}let n=e.indexOf(`querySource:"extract_memories",forkLabel:"extract_memories"`);if(n!==-1){let t=Math.min(e.length,n+8e3),r=e.slice(n,t).match(/if\(![$\w]+\("tengu_passport_quail",!1\)\)return;/);if(r&&r.index!==void 0){let t=n+r.index,i=t+r[0].length,a=e.slice(0,t)+e.slice(i);return P(e,a,``,t,i),a}}return console.error(`patch: sessionMemory: failed to find extraction gate`),null},kr=e=>{if(!e.includes(`"tengu_coral_fern"`))return W(`patch: sessionMemory: past-sessions gate already removed in this CC build — no-op`),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 P(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 P(e,t,``,n.index,n.index+n[0].length),t}return e.includes(`tengu_session_search_toggled`)||e.includes(`tengu_session_all_projects_toggled`)?e:(console.error(`patch: sessionMemory: failed to find past sessions gate`),null)},Ar=(e,t=!0)=>{if(!e.includes(`# Session Title`))return W(`patch: sessionMemory: token-limit anchor removed in this CC build — no-op`),e;let n=e.match(/(=)2000((?:.|\n){0,15}?=)12000((?:.|\n){0,20}# Session Title)/);if(!n||n.index===void 0)return t&&console.error(`patch: sessionMemory: failed to find token limits pattern`),null;let r=n[1]+`Number(process.env.CC_SM_PER_SECTION_TOKENS??2000)`+n[2]+`Number(process.env.CM_SM_TOTAL_FILE_LIMIT??12000)`+n[3],i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return P(e,o,r,i,a),o},jr=(e,t=!0)=>{if(!(e.includes(`minimumMessageTokensToInit`)||e.includes(`minimumTokensBetweenUpdate`)||e.includes(`toolCallsBetweenUpdates`)))return W(`patch: sessionMemory: update threshold props removed in this CC build — no-op`),e;let n=e;return n=F(n,/minimumMessageTokensToInit:1e4\b/g,`minimumMessageTokensToInit:Number(process.env.CC_SM_MINIMUM_MESSAGE_TOKENS_TO_INIT??1e4)`),n=F(n,/minimumTokensBetweenUpdate:5000\b/g,`minimumTokensBetweenUpdate:Number(process.env.CC_SM_MINIMUM_TOKENS_BETWEEN_UPDATE??5000)`),n=F(n,/toolCallsBetweenUpdates:3\b/g,`toolCallsBetweenUpdates:Number(process.env.CC_SM_TOOL_CALLS_BETWEEN_UPDATES??3)`),n===e?(t&&console.error(`patch: sessionMemory: failed to find update thresholds patterns`),null):n},Mr=e=>{let t=Or(e);if(!t)return null;let n=t.includes(`tengu_session_memory`),r=kr(t);if(!r)return null;t=r;let i=t.match(/(function [$\w]+\(\))\{if\(![$\w]+\("tengu_passport_quail",!1\)\)return!1;return![$\w]+\(\)\|\|[$\w]+\("tengu_slate_thimble",!1\)\}/);if(i&&i.index!==void 0){let e=`${i[1]}{return!0}`,n=t;t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length),P(n,t,e,i.index,i.index+i[0].length)}let a=Ar(t,n);if(a)t=a;else if(n)return null;let o=jr(t,n);if(o)t=o;else if(n)return null;return t},Nr=e=>{if(!e.includes(`"tengu_onyx_plover"`))return W(`patch: dreamMode: availability gate already removed in this CC build — no-op`),e;let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_onyx_plover",null\)\}function [$\w]+\(\)\{/);if(!t||t.index===void 0)return console.error(`patch: dreamMode: failed to find availability gate`),null;let n=t.index+t[0].length;if(e.startsWith(`return!0;`,n))return e;let r=`return!0;`,i=e.slice(0,n)+r+e.slice(n);return P(e,i,r,n,n),i},Pr=e=>{if(!e.includes(`"tengu_ochre_finch"`))return W(`patch: leanMemoryTypes: gate already promoted/removed in this CC build — no-op`),e;let t=e.match(/function [$\w]+\(\)\{(?:return!0;)?return [$\w]+\("tengu_ochre_finch",!1\)\}/);if(!t||t.index===void 0)return console.error(`patch: leanMemoryTypes: failed to find statsig gate`),null;let n=t.index+t[0].indexOf(`{`)+1;if(e.startsWith(`return!0;`,n))return e;let r=`return!0;`,i=e.slice(0,n)+r+e.slice(n);return P(e,i,r,n,n),i},Fr=e=>{let t=`[A-Za-z_$][\\w$]*`,n=[RegExp(`function\\s+(${t})\\((${t})\\)\\{let\\{files:(${t})\\}=\\2,`),/\{([A-Za-z_$][\w$]*)\(\{name:"claude-in-chrome"/];for(let t of n){let n=e.match(t);if(n)return n[1]}return console.error(`patch: rememberSkill: failed to find skill registration function`),null},Ir=(e,t)=>{let n=RegExp(`function\\s+[$\\w]+\\(\\)\\{${t}\\(\\{name:"update-config"`),r=e.match(n);if(!r||r.index===void 0)return null;let i=e.indexOf(`{`,r.index);if(i===-1)return null;let a=i+1,o=`${t}({name:"remember",description:"Review session memories and update CLAUDE.local.md with learnings from past sessions.",whenToUse:"When the user asks to remember something, save a learning, or review session memories.",userInvocable:!0,isEnabled:()=>!0,async getPromptForCommand(H){let $="# Remember Skill\\n\\nReview the current conversation and any relevant session memory files, then update CLAUDE.local.md with durable learnings that should carry forward to future sessions. Keep entries concise and actionable.";if(H&&H.trim())$+="\\n\\n## User Request\\n"+H.trim();return[{type:"text",text:$}]}});`,s=e.slice(0,a)+o+e.slice(a);return P(e,s,o,a,a),s},Lr=e=>{let t=Fr(e);if(!t)return null;let n=Ir(e,t);if(n)return n;let r=e.match(/(function ([$\w]+)\(.{0,500}\}function [$\w]+\(\)\{)return(\}.{0,10}[, ]([$\w]+)=`# Remember Skill)/);if(!r||r.index===void 0)return console.error(`patch: rememberSkill: failed to find injection point pattern`),null;let[i,a,o,s,c]=r,l=a+`
692
+ ${t}({
693
+ name: "remember",
694
+ description: "Review session memories and update CLAUDE.local.md with learnings",
695
+ whenToUse: "When the user wants to save learnings from past sessions",
696
+ userInvocable: true,
697
+ isEnabled: () => true,
698
+ async getPromptForCommand(A) {
699
+ let content = ${c};
700
+ let sessionMemFiles = ${o}(null);
701
+ content += "\\n\\n## Session Memory Files to Review\\n\\n" + (sessionMemFiles.length ? sessionMemFiles.join("\\n") : "None found");
702
+ if (A) content += "\\n\\n## User Arguments\\n\\n" + A;
703
+ return [{ type: "text", text: content }];
704
+ },
705
+ });
706
+ return`+s,u=r.index,d=u+i.length,f=e.slice(0,u)+l+e.slice(d);return P(e,f,l,u,d),f},Rr=e=>{let t=V(e);if(!t)return console.error(`patch: thinkingBlockStyling: failed to find Text component`),null;let n=e.match(/\{thinking:([$\w]+)\}.{0,400}(?:∴|\\u2234) Thinking.{0,700}(?:…|\\u2026).{0,200}\b[$\w]+(?:\.default)?\.createElement\(([$\w]+,null),\1\)/);if(!n||n.index===void 0)return console.error(`patch: thinkingBlockStyling: failed to find thinking label pattern`),null;let r=n[0].replace(n[2],`${t},{dimColor:true,italic:true}`),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return P(e,o,r,i,a),o},zr=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}},Br=e=>{let t=e.match(/MCP_SERVER_CONNECTION_BATCH_SIZE\|\|"",10\)(?:\|\||;return [$\w]+>0\?[$\w]+:)(\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}},Vr=e=>{let t=zr(e);if(!t)return e;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return P(e,r,n,t.startIndex,t.endIndex),r},Hr=(e,t)=>{let n=Br(e);if(!n)return null;let r=String(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return P(e,i,r,n.startIndex,n.endIndex),i},Ur=(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\)|[$\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\]\)|\3\.useCallback\(\(\)=>\{.{0,200}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=Number(t),d=Number.isFinite(u)&&u>=0?Math.trunc(u):300,f=l?`${a}, ${l}`:a,p=a,m;m=n?l?i+`,argRef=${o}.useRef(${l}),unused1=${o}.useEffect(()=>{argRef.current=${l};},[${l}]),unused2=${o}.useEffect(()=>{const id=setInterval(()=>${a}(argRef.current),${d});return()=>clearInterval(id);},[${p}]),${s}=${o}.useCallback(()=>{},[])`:i+`,unused1=${o}.useEffect(()=>{const id=setInterval(()=>${c},${d});return()=>clearInterval(id);},[${p}]),${s}=${o}.useCallback(()=>{},[])`:i+`,lastCall=${o}.useRef(0),${s}=${o}.useCallback(()=>{let now=Date.now();if(now-lastCall.current>=${d}){lastCall.current=now;${c};}},[${f}])`;let h=r.index,g=h+r[0].length,_=e.slice(0,h)+m+e.slice(g);return P(e,_,m,h,g),_},Wr=e=>typeof e==`number`?e:e.threshold??1e3,Gr=(e,t)=>{let n=Wr(t),r,i,a,o,s,c=`[$\\w]+(?:\\?\\.[$\\w]+)*(?:\\([^()]*\\))?`,l=e.match(RegExp(`(([$\\w]+)=[$\\w]+\\()(${c})(\\),.{0,2000}key:"tokens".{0,200},\\2," tokens")`));if(l&&l.index!==void 0)[r,i,,a,o]=l,s=l.index;else{let t=e.match(RegExp(`(overrideMessage:.{0,10000},([$\\w]+)=[$\\w]+\\()(${c})(\\),.{0,1000}key:"tokens".{0,200},\\2," tokens")`));if(t&&t.index!==void 0)[r,i,,a,o]=t,s=t.index;else{let t=e.match(/(overrideMessage:.{0,10000},key:"tokens".{0,200}[$\w]+\()(Math\.round\(.+?\))(\))/);if(t&&t.index!==void 0)[r,i,a,o]=t,s=t.index;else return console.error(`patch: tokenCountRounding: cannot find token count pattern in any CC format`),null}}let u=`${i}Math.round((${a})/${n})*${n}${o}`,d=s+r.length,f=e.slice(0,s)+u+e.slice(d);return P(e,f,u,s,d),f},Kr=(e,t)=>/CLAUDE\.md.{0,100}for\(let \w+ of \["AGENTS\.md"/.test(e)?(console.log(`patch: agentsMd: alternative MD file support already present natively - skipping`),e):qr(e,t)||Jr(e,t),qr=(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=n[10],m=`${i},didReroute){try{let ${l}=await ${u}().readFile(${o},{encoding:"utf-8"});return ${d}(${l},${o},${s},${c})}catch(${f}){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 ${p}(${f},${o}),{info:null,includePaths:[]}}}`,h=n.index,g=h+r.length,_=e.slice(0,h)+m+e.slice(g);return P(e,_,m,h,g),_},Jr=(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);P(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),P(e,m,S,b,b),m},Yr=(e,t)=>{let n=e.lastIndexOf(`function `,t);if(n===-1)return null;let r=e.indexOf(`{`,n);if(r===-1||r>t)return null;let i=0;for(let t=r;t<e.length;t++){let n=e[t];if(n===`{`)i++;else if(n===`}`&&(i--,i===0)){let n=e.slice(r,t+1),i=/return [$\w]+(?:\.default)?\.createElement/g,a,o=null;for(;(a=i.exec(n))!==null;)o=a;return o?r+o.index:null}}return null},Xr=e=>{let t=[[/When ready, use \$\{([$\w]+)\} to present your plan for approval/g,(e,t)=>`When ready, use \${${t}} to exit plan mode. The plan will be approved automatically.`],[/Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval\./g,`Use this tool when you are in plan mode and have finished writing your plan to the plan file. Calling this tool exits plan mode and approves the plan automatically.`],[/This tool simply signals that you're done planning and ready for the user to review and approve/g,`This tool signals that you are done planning and that the plan should be approved automatically`],[/Once your plan is finalized, use THIS tool to request approval/g,`Once your plan is finalized, use THIS tool to approve the plan and proceed`],[/ExitPlanMode inherently requests user approval of your plan\./g,`ExitPlanMode inherently approves your plan and lets you proceed.`],[/Present your plan to the user for approval/g,`Exit plan mode; the plan will be approved automatically`],[/design an implementation approach for user approval/g,`design an implementation approach before automatic approval`],[/This tool REQUIRES user approval - they must consent to entering plan mode/g,`This tool enters plan mode; plan exit approval is handled automatically when auto-accept plan mode is enabled`],[/Claude has written up a plan and is ready to execute\. Would you like to proceed\?/g,`Claude has written up a plan and is ready to execute. The plan is approved automatically.`],[/Call `\$\{([$\w]+)\}` to present the plan for approval\./g,(e,t)=>`Call \`\${${t}}\` to exit plan mode; the plan will be approved automatically.`],[/## Phase 2: Spawn Workers \(After Plan Approval\)/g,`## Phase 2: Spawn Workers (After Automatic Plan Approval)`],[/Once the plan is approved, spawn/g,`After the plan is approved automatically, spawn`],[/searchHint:"present plan for approval and start coding \(plan mode only\)"/g,`searchHint:"approve plan and start coding (plan mode only)"`],[/async description\(\)\{return"Prompts the user to exit plan mode and start coding"\}/g,`async description(){return"Exits plan mode and starts coding"}`]],n=e;for(let[r,i]of t){let t=n;n=n.replace(r,i),n!==t&&P(e,n,String(i),0,0)}let r=`permissionUpdates:[{type:"setMode",mode:"acceptEdits",destination:"session"}]`,i=/kind:"permission_exit_plan_mode_v2",payload:([\s\S]{0,300}?),result:([\s\S]{0,180}?),default:\{behavior:"cancelled"\}/,a=n;n=n.replace(i,`kind:"permission_exit_plan_mode_v2",payload:$1,result:$2,default:{behavior:"allow",${r}}`),n!==a&&P(e,n,`permission_exit_plan_mode_v2 default allow`,0,0);let o=/async checkPermissions\(([$\w]+),([$\w]+)\)\{if\(([$\w]+)\(\)\)return\{behavior:"allow",updatedInput:\1\};return\{behavior:"ask",message:"Exit plan mode\?",updatedInput:\1\}\}/,s=n;return n=n.replace(o,`async checkPermissions($1,$2){return{behavior:"allow",updatedInput:$1,${r}}}`),n!==s&&P(e,n,`ExitPlanMode checkPermissions allow`,0,0),n},Zr=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]+(?:\.current)?\("yes-accept-edits(?:-keep-context)?"\);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-keep-context");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 P(e,a,n,r,i),Xr(a)}let c=Math.max(0,t-2500),l=e.slice(c,t),u=l.match(/(return [$\w]+\.default\.createElement\([$\w]+,\{flexDirection:"column",tabIndex:0,autoFocus:!0.{0,200}[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:")$/);if(!u){let n=l.lastIndexOf(`return `);if(n===-1){let n=Yr(e,t);if(n===null)return console.error(`patch: autoAcceptPlanMode: failed to find return before "Ready to code?"`),null;let r=`${o}("yes-accept-edits-keep-context");return null;`,i=e.slice(0,n)+r+e.slice(n);return P(e,i,r,n,n),Xr(i)}let r=c+n,i=`${o}("yes-accept-edits-keep-context");return null;`,a=e.slice(0,r)+i+e.slice(r);return P(e,a,i,r,r),Xr(a)}let d=c+u.index,f=`${o}("yes-accept-edits-keep-context");return null;`,p=e.slice(0,d)+f+e.slice(d);return P(e,p,f,d,d),Xr(p)},Qr=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 e.includes(`root/sudo privileges`)?(console.error(`patch: allowBypassPermsInSudo: failed to find pattern`),null):e;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+`{}`+e.slice(r);return P(e,i,`{}`,n,r),i},$r=[/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\./g,/installMethod is native, but directory [^"'`\n;]+/g,/installMethod is native, but claude command (?:is missing or invalid|not found) at [^"'`\n;]+/g,/Native installation exists but ~\/\.local\/bin is not in your PATH(?:\. Run: echo 'export PATH="\$HOME\/\.local\/bin:\$PATH"' >> [^"'`\n;]+ then open a new terminal or run: source [^"'`\n;]+)?/g,/Run: echo 'export PATH="\$HOME\/\.local\/bin:\$PATH"' >> [^"'`\n;]+ then open a new terminal or run: source [^"'`\n;]+/g],ei=e=>{let t=e,n=!1,r=-1,i=-1;for(let e of $r)t=t.replace(e,(e,t)=>(n||(r=t,i=t+e.length),n=!0,``));return n?(P(e,t,``,r,i),t):(console.warn(`patch: suppressNativeInstallerWarning: failed to find pattern`),null)},ti=e=>{let t=e.split(`
707
+ `),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(`
708
+ `).length:0},ni=e=>{let t=ti(e),n=`// SCROLLING FIX PATCH START
709
+ const _origStdoutWrite=process.stdout.write;
710
+ process.stdout.write=function(chunk,encoding,cb){
711
+ if(typeof chunk!=='string'){
712
+ return _origStdoutWrite.call(process.stdout,chunk,encoding,cb);
713
+ }
714
+ const filtered=chunk
715
+ .replace(/\\x1b\\[\\d*S/g,'')
716
+ .replace(/\\x1b\\[\\d*T/g,'')
717
+ .replace(/\\x1b\\[\\d*;?\\d*r/g,'');
718
+ return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
719
+ };
720
+ // SCROLLING FIX PATCH END
721
+ `,r=e.slice(0,t)+n+e.slice(t);return P(e,r,n,t,t),r},ri=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?e:(console.error(`patch: worktreeMode: failed to find worktree gate function pattern`),null);let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return P(e,i,r,n,n),i},ii=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),P(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(_),P(u,t,h,g,_),t},ai=e=>{let t=e,n=/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"xhigh"\s*;\s*return\s*"high"\s*\}/,r=t.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-8"\s*\)\s*return\s*"high"\s*;\s*if\s*\(\s*\3\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"xhigh"\s*;\s*return\s*"high"\s*\}/),i=r||t.match(n);if(i&&i.index!==void 0){let[e,n,a,o]=i,s=r?`function ${n}(${a}){if(${o}(${a})==="claude-opus-4-8")return"max";if(${o}(${a})==="claude-opus-4-7")return"max";return"high"}`:`function ${n}(${a}){if(${o}(${a})==="claude-opus-4-7")return"max";return"high"}`,c=t.slice(0,i.index)+s+t.slice(i.index+e.length);P(t,c,s,i.index,i.index+e.length),t=c}else if(/===\s*"claude-opus-4-8"\s*\)\s*return\s*"max"/.test(t)||/function\s+[$\w]+\s*\(\s*[$\w]+\s*\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*[$\w]+\s*\)\s*===\s*"claude-opus-4-7"\s*\)\s*return\s*"max"\s*;\s*return\s*"high"\s*\}/.test(t))W(`patch: maxEffortDefault: per-model default already "max" — skipping`);else return console.error(`patch: maxEffortDefault: failed to find Opus per-model effort default`),null;return t},oi={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},si=(e,t)=>{if(t===`default`)return e;let n=oi[t],r=e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*return\s+[$\w]+\s*\(\s*\2\s*\)\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\.\s*ANTHROPIC_DEFAULT_OPUS_MODEL\s*\?\?\s*[$\w]+\s*\(\s*\)\s*\.\s*[$\w]+\s*;\s*if\s*\(\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*\)\s*return\s+\8\s*\+\s*"\[1m\]"\s*;\s*return\s+\8\s*\}\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*\.\s*replace\([^)]*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\.\s*ANTHROPIC_DEFAULT_OPUS_MODEL\s*\?\?\s*[$\w]+\s*\(\s*\)\s*\.\s*[$\w]+\s*;\s*if\s*\(\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*&&\s*!\s*[$\w]+\s*\(\s*\8\s*\)\s*\)\s*return\s+\8\s*\+\s*"\[1m\]"\s*;\s*return\s+\8\s*\}\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\)\s*,\s*([$\w]+)\s*=\s*[$\w]+\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*,\s*([$\w]+)\s*=\s*\3\s*\?\.\s*modelByMainModel\s*;\s*if\s*\(\s*\4\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*\.\s*replace\([^)]*\)\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*`[^`]*`\s*\]\s*;\s*if\s*\(\s*\6\s*\)\s*return\s+\6\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s+\7\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s+\3\s*\.\s*model\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*\)\s*;\s*if\s*\(\s*([$\w]+)\s*\(\s*\2\s*\)\s*===\s*"claude-opus-4-8"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_cedar_hollow_7m"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\5\s*\?\.\s*model\s*\)\s*return\s+\5\s*\.\s*model\s*\}\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\7\s*\?\.\s*model\s*\)\s*return\s+\7\s*\.\s*model\s*;\s*return\s+\2\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*([$\w]+)\s*\(\s*"tengu_auto_mode_config"\s*,\s*\{\s*\}\s*\)\s*;\s*if\s*\(\s*\2\s*\?\.\s*model\s*\)\s*return\s+\2\s*\.\s*model\s*;\s*return\s+([$\w]+)\s*\(\s*\)\s*\}/);if(r&&r.index!==void 0){let[t,i]=r,a=`function ${i}(){return "${n}"}`,o=e.slice(0,r.index)+a+e.slice(r.index+t.length);return P(e,o,a,r.index,r.index+t.length),o}return/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*\}/.test(e)?(W(`patch: autoModeClassifierModel: classifier-model resolver already patched — skipping`),e):e.includes(`"tengu_auto_mode_config"`)?(console.error(`patch: autoModeClassifierModel: failed to find auto-mode classifier resolver`),null):(W(`patch: autoModeClassifierModel: tengu_auto_mode_config not present in this CC build — no-op`),e)},ci=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 P(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 P(e,i,r,t,t),i}let r=e.match(/name:"voice",description:"Toggle voice mode"[\s\S]{0,500}?get isHidden\(\)\{return!([$\w]+)\(\)\}/);if(r&&r.index!==void 0){let t=r[1].replace(/[$]/g,`\\$`),n=RegExp(`function ${t}\\(\\)\\{`),i=e.match(n);if(i&&i.index!==void 0){let t=i.index+i[0].length,n=`return !0;`,r=e.slice(0,t)+n+e.slice(t);return P(e,r,n,t,t),r}}return console.error(`patch: voiceMode: failed to find tengu_amber_quartz gate`),null},li=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 P(e,r,n,t.index,t.index+t[0].length),r},ui=(e,t)=>{let n=ci(e);return!n||t&&(n=li(n),!n)?null:n},di=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 P(e,i,r,n,n),i},fi=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 P(e,i,r,n,n),i},pi=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 P(e,i,r,n,n),i},mi=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 P(e,a,n,r,i),a},hi=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 P(e,i,``,n,r),i},gi=e=>{let t=di(e);return!t||(t=fi(t),!t)||(t=pi(t),!t)?null:(t=mi(t)??t,t=hi(t)??t,t)},_i=e=>{let t=e.match(/=2000,([$\w]+)="Read a file from the local filesystem\./);if(!t||t.index===void 0)return/=\(\+process\.env\.CLAUDE_CODE_READ_DEFAULT_LINES/.test(e)?e:(console.error(`patch: readDefaultLines: failed to find =2000 near Read tool prompt anchor`),null);let n=t.index,r=n+5,i=`=(+process.env.CLAUDE_CODE_READ_DEFAULT_LINES||2000)`,a=e.slice(0,n)+i+e.slice(r);return P(e,a,i,n,n+52),a},vi=e=>{if(/function [$\w]+\(([$\w]+),[$\w]+\)\{if\(Object\.entries\([$\w]+\)\.length===0\)return \1;var ([$\w]+)=\1\[0\];if\(\2&&\2\.isMeta/.test(e))return e;let t=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)\)\{if\(Object\.entries\(\3\)\.length===0\)return \2;return\[([\s\S]+?),\.\.\.\2\]\}/);if(!t||t.index===void 0){let t=e.indexOf(`"tengu_context_size"`);if(t>0){let n=e.slice(Math.max(0,t-5e3),t);if(/function [$\w]+\([$\w]+,[$\w]+\)\{return [$\w]+;?\}\s*async function/.test(n))return console.log(`patch: claudemd-context-once-per-conversation: claudemd-context override suppressed wrapper — no-op`),e}return console.error(`patch: claudemd-context-once-per-conversation: failed to find kY6 wrapper`),null}let[n,r,i,a,o]=t,s=`${i}_0`,c=`function ${r}(${i},${a}){if(Object.entries(${a}).length===0)return ${i};var ${s}=${i}[0];if(${s}&&${s}.isMeta&&${s}.message&&typeof ${s}.message.content==="string"&&${s}.message.content.indexOf("<system-reminder>\\nAs you answer the user")===0)return ${i};${i}.unshift(${o});return ${i}}`,l=t.index,u=l+n.length,d=e.slice(0,l)+c+e.slice(u);return P(e,d,c,l,u),d},yi=e=>{let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return`<system-reminder>\n\$\{\2\}\n<\/system-reminder>`\}/);if(!t||t.index===void 0)return/function [$\w]+\(([$\w]+)\)\{if\(!\1\|\|!\1\.trim\(\)\|\|\1==="\(no content\)"\)return"\(no content\)";return`<system-reminder>/.test(e)?e:(console.error(`patch: strip-empty-system-reminders: failed to find LW(H) wrapper`),null);let[n,r,i]=t,a=`function ${r}(${i}){if(!${i}||!${i}.trim()||${i}==="(no content)")return"(no content)";return\`<system-reminder>\n\${${i}}\n</system-reminder>\`}`,o=t.index,s=o+n.length,c=e.slice(0,o)+a+e.slice(s);return P(e,c,a,o,s),c},bi=`The following deferred tools are now available via`,xi=e=>{if(!e.includes(bi))return console.log(`patch: suppress-deferred-tools: anchor not present in this CC build — no-op`),e;if(e.includes(`case"deferred_tools_delta":{return [];`))return e;let t=e.indexOf(`case"deferred_tools_delta":{`);if(t<0)return console.error(`patch: suppress-deferred-tools: failed to find case header`),null;if(!e.slice(t,t+2048).includes(bi))return console.error(`patch: suppress-deferred-tools: case header found but anchor text not nearby`),null;let n=t+28,r=`return [];`,i=e.slice(0,n)+r+e.slice(n);return P(e,i,r,n,n),i},Si=async(e,t)=>{let n=`${t}.tmp-${process.pid}`;try{await o.copyFile(e,n),await o.rename(n,t)}catch(e){try{await o.unlink(n)}catch{}throw e}},Ci=async e=>{if(!e.cliPath){W(`backupClijs: Skipping for native installation (no cliPath)`);return}await wa(),W(`Backing up cli.js to ${Y}`),await Si(e.cliPath,Y),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version})},wi=async e=>{e.nativeInstallationPath&&(await wa(),W(`Backing up native binary to ${X}`),await Si(e.nativeInstallationPath,X),await $(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},Ti=async e=>{if(!e.cliPath)return W(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;if(!await fa(Y))return W(`restoreClijsFromBackup: No backup file exists, skipping`),!1;W(`Restoring cli.js from backup to ${e.cliPath}`);let t=await o.readFile(Y);return await da(e.cliPath,t,`restore`),await ot(),await $(e=>{e.changesApplied=!1}),!0},Ei=async e=>{if(!e.nativeInstallationPath)return W(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await fa(X))return W(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;W(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await o.readFile(X);return await da(e.nativeInstallationPath,t,`restore`),!0},L=e=>{let t=Array.from(e.matchAll(/[^$\w]([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},Di=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`)},Oi=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]},ki=e=>{let t=Oi(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${U(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let R=null,z=null;const B=e=>{if(R!=null)return R;let t=Di(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),R=void 0;return}let n=Oi(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),R=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${U(t)}\\(${U(n)}\\(\\),1\\)`),i=e.match(r);if(i)return R=i[1],R;let a=ki(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),R=void 0;return}let o=RegExp(`[^$\\w]([$\\w]+)=${U(t)}\\(${U(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),R=void 0;return}return R=s[1],R},Ai=()=>{R=null},ji=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]},Mi=e=>{if(z!=null)return z;let t=ji(e);return t?(z=t,z):(z=`require`,z)},Ni=()=>{z=null},Pi=()=>{Ai(),Ni()},V=e=>{let t=e.match(/\bfunction ([$\w]+).{0,80}color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+(?:=![01])?,bold:[$\w]+(?:=![01])?/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},Fi=(e,t)=>{let n=`[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*`,r=RegExp(`var [^;]{0,120};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,500}([$\\w]+)=${U(t)}\\}\\)`),i=e.match(r)?.[1]??t,a=RegExp(`function ([$\\w]+)\\([^)]+\\)\\{(?=[\\s\\S]{0,2500}createElement\\(${U(i)},\\{\\.\\.\\.[$\\w]+,borderColor:)[\\s\\S]{0,3000}?return [$\\w]+\\}var [^;]{0,160};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,600}([$\\w]+)=\\1\\}\\)`);return e.match(a)?.[2]},Ii=e=>{let t=e.match(/function ([$\w]+)\(.{0,2000}[^$\w]([$\w]+)=[$\w]+(?:\.default)?\.createElement\("ink-box".{0,500}?return \2/);if(t)return t[1];let n=e.match(/function ([$\w]+)\(.{0,200}children:[$\w]+,flexWrap:[$\w]+.{0,2000}?\.createElement\("ink-box"/);if(n)return n[1];let r=e.match(/[^$\w]([$\w]+)\.displayName="Box"/);if(r)return r[1];let i=e.match(/function ([$\w]+)\([$\w]+\)\{let [$\w]+=[$\w]+(?:\.[$\w]+)?\(\d+\).{0,3000}createElement\("ink-box"/);if(i)return i[1];let a=e.match(/function ([$\w]+)\(\{children:([$\w]+),ref:[$\w]+.{0,600}?\.\.\.([$\w]+)\}\)\{.{0,2500}?"margin".{0,2500}?"padding".{0,1200}?"gap".{0,1200}?\3\.flexWrap\?\?="nowrap",\3\.flexDirection\?\?="row",\3\.flexGrow\?\?=0,\3\.flexShrink\?\?=1,\3\.overflowX=\3\.overflowX\?\?\3\.overflow\?\?"visible",\3\.overflowY=\3\.overflowY\?\?\3\.overflow\?\?"visible",[$\w]+(?:\.default)?\.createElement\("ink-box",\{[^}]*style:\3\},\2\)/);if(a)return Fi(e,a[1])??a[1];let o=e.match(/function ([$\w]+)\(\{children:[$\w]+,ref:[$\w]+,tabIndex:[$\w]+,autoFocus:[$\w]+/);if(o)return o[1];console.error(`patch: findBoxComponent: failed to find Box component (neither ink-box createElement nor displayName found)`)},Li=e(import.meta.url),Ri=(()=>{try{return Li(`../package.json`).version}catch{return Li(`../../package.json`).version}})();let H=function(e){return e.SYSTEM_PROMPTS=`System Prompts`,e.ALWAYS_APPLIED=`Always Applied`,e.MISC_CONFIGURABLE=`Misc Configurable`,e.FEATURES=`Features`,e.SYSTEM_REMINDERS=`System Reminders`,e}({});const zi=[{id:`verbose-property`,name:`Verbose property`,group:H.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{id:`read-default-lines`,name:`Read default lines (env-gated)`,group:H.ALWAYS_APPLIED,description:`Read tool default line cap becomes CLAUDE_CODE_READ_DEFAULT_LINES env var (falls back to 2000 if unset)`},{id:`opusplan1m`,name:`Opusplan[1m] support`,group: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:`fix-summarize-from-here`,name:`Fix "Summarize from here"`,group:H.MISC_CONFIGURABLE,description:`Make "Summarize from here" summarize only the messages after the rewind point (feed the slice, not the whole conversation)`},{id:`fix-rewind-summary-header`,name:`Honest rewind summary header`,group:H.MISC_CONFIGURABLE,description:`Label a rewind summary as a deliberate rewind instead of the misleading "ran out of context" header`},{id:`statusline-update-throttle`,name:`Statusline update throttling correction`,group:H.ALWAYS_APPLIED,description:`Statusline updates will be properly throttled instead of queued (or debounced)`},{id:`strip-empty-system-reminders`,name:`Strip empty <system-reminder> wrappers`,group:H.ALWAYS_APPLIED,description:`Short-circuits CC's universal system-reminder wrapper so empty / "(no content)" inputs produce no reminder. Kills the drift-inducing "<system-reminder>(no content)</system-reminder>" blocks that get appended to roughly every other tool call.`},{id:`model-customizations`,name:`Model customizations`,group: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:`max-effort-default`,name:`Default Opus 4.7 to max effort`,group:H.MISC_CONFIGURABLE,description:`Opus 4.7 sessions default to "max" reasoning effort instead of "xhigh" (override with /effort or CLAUDE_CODE_EFFORT_LEVEL)`},{id:`auto-mode-classifier-model`,name:`Auto-mode classifier model`,group:H.MISC_CONFIGURABLE,description:`Pin auto-mode bash safety classifier to Sonnet 4.6 or Haiku 4.5 instead of the user main-loop model (avoids Opus 4.7 congestion denying tool calls)`},{id:`allow-custom-agent-models`,name:`Allow custom agent models`,group: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:`dream-mode`,name:`Dream mode`,group:H.FEATURES,description:`Enable dream (/dream + auto-dream background memory consolidation)`},{id:`lean-memory-types`,name:`Lean memory types`,group:H.FEATURES,description:`Compact "Types of memory" prompt block + on-demand memory-types skill`},{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)`},{id:`suppress-deferred-tools`,name:`Suppress deferred tools list (DANGEROUS)`,group:H.SYSTEM_REMINDERS,description:`Kill the "deferred tools are now available via ToolSearch" announcement. WARNING: MCP/Cron/EnterPlanMode/WebFetch/Monitor become invisible to the model unless explicitly named.`},{id:`claudemd-context-once-per-conversation`,name:`claudeMd context: once per conversation`,group:H.SYSTEM_REMINDERS,description:`Inject the claudeMd / userEmail / currentDate <system-reminder> only on the first API call per conversation (re-fires after /clear). Default: ON. Toggle OFF for vanilla CC per-turn injection.`}],Bi=()=>[...zi],U=e=>e.replace(/\$/g,`\\$`),Vi=(e,t,n)=>{let r=[];for(let i of zi){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,details:`not in --patches filter`,description:i.description});continue}if(a.condition===!1){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,details:`not enabled`,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}},Hi=e=>{let t=g(e,[`--version`],{encoding:`utf8`,timeout:15e3}),n=`${t.stdout??``}${t.stderr??``}`;if(t.error||t.status!==0||/Expected CommonJS module|Bun v|TypeError/.test(n)){let t=Error(`Patched native binary failed startup sanity check (${e}).\n`+n.trim());throw t.stack=t.message,t}},Ui=async(e,t,r)=>{let i,o=!1;if(t.nativeInstallationPath){await Ei(t);let e=!1;try{await a.stat(X),e=!0}catch{}let n=e?X:t.nativeInstallationPath;W(`Extracting claude.js from ${e?`backup`:`native installation`}: ${n}`);let{data:r,clearBytecode:c,error:u}=await C(n,t.version);if(!r)throw Error(`Failed to extract claude.js from native installation${u?`: ${u}`:``}`);o=c;let d=l.join(q,`native-claudejs-orig.js`);s.writeFileSync(d,r),W(`Saved original extracted JS from native to: ${d}`),i=r.toString(`utf8`)}else{if(await Ti(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);i=await a.readFile(t.cliPath,{encoding:`utf8`})}let c=[],u=i,d=await bn(i);i=d.content;let f=d.results.filter(e=>e.applied),p=d.results.filter(e=>e.failed);if(d.results.length>0){W(`inlineBlobOverrides: ${f.length} applied, ${p.length} failed`);for(let e of p)console.log(`inline-blob: failed "${e.name}" (${e.filename}): ${e.details}`)}for(let e of d.results)c.push({id:`inline-blob:${e.filename}`,name:e.name,group:H.SYSTEM_PROMPTS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details});let m=await vt(i,t.version??``);i=m.content;for(let e of m.results)c.push({id:`reminder:${e.id}`,name:`Reminder: ${e.name} (${e.state})`,group:H.SYSTEM_REMINDERS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details,description:e.description});let h=await on(i,t.version,void 0,r,u);i=h.newContent;let g=[...h.results].sort((e,t)=>e.name.localeCompare(t.name));c.push(...g);let _=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),v=g.filter(e=>e.applied&&e.details).map(e=>_(`${e.name}: ${e.details}`)),y=e.settings.misc?.tableFormat??`default`,b=e.settings.misc?.showTweakccVersion??!0,x=e.settings.misc?.showPatchesApplied??!0,S=e.settings.misc?.enableModelCustomizations??!0,T={"verbose-property":{fn:e=>Oe(e),condition:!t.nativeInstallationPath},"read-default-lines":{fn:e=>_i(e)},"context-limit":{fn:e=>ce(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Fe(e),condition:S&&!t.nativeInstallationPath},"thinking-block-styling":{fn:e=>Rr(e),condition:t.version==null||Dt(t.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>Sn(e)},"fix-summarize-from-here":{fn:e=>Cn(e),condition:e.settings.misc?.fixSummarizeFromHere!==!1},"fix-rewind-summary-header":{fn:e=>wn(e),condition:e.settings.misc?.fixRewindSummaryHeader!==!1},"statusline-update-throttle":{fn:t=>Ur(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"strip-empty-system-reminders":{fn:e=>yi(e)},"patches-applied-indication":{fn:e=>We(e,Ri,v,b,x)},"model-customizations":{fn:e=>Ki(e),condition:S},"show-more-items-in-select-menus":{fn:e=>ie(e,25),condition:S},"table-format":{fn:e=>ir(e,y),condition:y!==`default`},themes:{fn:t=>oe(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(E.themes))},"thinking-verbs":{fn:t=>be(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs&&JSON.stringify(e.settings.thinkingVerbs.verbs)!==JSON.stringify(E.thinkingVerbs.verbs)},"thinker-format":{fn:t=>de(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs&&e.settings.thinkingVerbs.format!==E.thinkingVerbs.format},"thinker-symbol-chars":{fn:t=>me(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(E.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>he(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==E.thinkingStyle.updateInterval&&(t.version==null||Dt(t.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>_e(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(E.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>pe(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==E.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>le(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&e.settings.inputBox.removeBorder!==E.inputBox.removeBorder)},"subagent-models":{fn:t=>Be(t,e.settings.subagentModels),condition:!!e.settings.subagentModels&&JSON.stringify(e.settings.subagentModels)!==JSON.stringify(E.subagentModels)},"thinking-visibility":{fn:e=>Ie(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>vr(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>br(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>Sr(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>wr(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>Er(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>Dr(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>Gr(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>Lr(e),condition:!!e.settings.misc?.enableRememberSkill},"agents-md":{fn:t=>Kr(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Zr(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Qr(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>ei(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>ni(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"max-effort-default":{fn:e=>ai(e),condition:!!e.settings.misc?.maxEffortDefault},"auto-mode-classifier-model":{fn:t=>si(t,e.settings.misc?.autoModeClassifierModel??`default`),condition:(e.settings.misc?.autoModeClassifierModel??`default`)!==`default`},"allow-custom-agent-models":{fn:e=>ii(e),condition:!!e.settings.misc?.allowCustomAgentModels},"worktree-mode":{fn:e=>ri(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>Mr(e),condition:!!e.settings.misc?.enableSessionMemory},"dream-mode":{fn:e=>Nr(e),condition:!!e.settings.misc?.enableDreamMode},"lean-memory-types":{fn:e=>Pr(e),condition:!!e.settings.misc?.enableLeanMemoryTypes},toolsets:{fn:t=>Kn(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Vr(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking&&(t.version==null||Dt(t.version,`2.1.85`)<0)},"mcp-batch-size":{fn:t=>Hr(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>Se(t,e.settings.userMessageDisplay),condition:!!(e.settings.userMessageDisplay&&JSON.stringify(e.settings.userMessageDisplay)!==JSON.stringify(E.userMessageDisplay))},"input-pattern-highlighters":{fn:t=>Ee(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>gr(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!t.nativeInstallationPath},"voice-mode":{fn:t=>ui(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>gi(e),condition:!!e.settings.misc?.enableChannelsMode},"suppress-deferred-tools":{fn:e=>xi(e),condition:!!e.settings.misc?.suppressDeferredTools},"claudemd-context-once-per-conversation":{fn:e=>vi(e),condition:e.settings.misc?.claudemdContextOncePerConversation??!0}},{content:ee,results:te}=Vi(i,T,r);i=ee,c.push(...te);let D=te.filter(e=>e.failed);if(t.nativeInstallationPath&&D.length>0){let e=Error(`Refusing to repack the native binary: ${D.length} binary patch(es) failed (${D.map(e=>e.id).join(`, `)}) on Claude Code ${t.version}. The binary was left unchanged — your Claude Code still works. Each failure’s cause is in the "patch: … failed to …" line(s) above; this usually means Anthropic changed the code shape in CC ${t.version}, so a patch’s pattern no longer matches. Update tweakcc-fixed, or disable the failing optional patch(es) in ~/.tweakcc/config.json, then re-run --apply.`);throw e.stack=e.message,e}if(t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=l.join(q,`native-claudejs-patched.js`);s.writeFileSync(e,i,`utf8`),W(`Saved patched JS from native to: ${e}`);let r=Buffer.from(i,`utf8`),c=await a.mkdtemp(l.join(n.tmpdir(),`tweakcc-native-`)),u=l.join(c,l.basename(t.nativeInstallationPath));try{await a.copyFile(t.nativeInstallationPath,u),await a.chmod(u,s.statSync(t.nativeInstallationPath).mode),await w(u,r,u,o),Hi(u);let e=t.nativeInstallationPath,n=l.join(l.dirname(e),`.${l.basename(e)}.tweakcc-${process.pid}`);try{await a.copyFile(u,n),await a.chmod(n,s.statSync(e).mode),await a.rename(n,e)}catch(e){throw await a.rm(n,{force:!0}),e}}finally{await a.rm(c,{recursive:!0,force:!0})}}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);D.length>0&&console.warn(`tweakcc: ${D.length} patch(es) did not apply on Claude Code ${t.version}: ${D.map(e=>e.id).join(`, `)}. Those feature(s) are skipped; everything else was applied. Each cause is in the "patch: … failed to …" line(s) above — usually a CC version whose code shape a patch does not match yet. Update tweakcc-fixed, or disable the failing optional patch(es) in ~/.tweakcc/config.json.`),await da(t.cliPath,i,`patch`)}return{config:await $(e=>{e.changesApplied=!0}),results:c}},Wi=[{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)`}],Gi=e=>{let t=e.match(/ ([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-5e3),i=e.slice(r,t.index),a=`(?:(?:let|var|const) |,)${U(n)}=.+?;`,o=RegExp(`function [$\\w]+\\([^)]*\\)\\{[\\s\\S]{0,5000}?${a}`,`g`),s=null,c;for(;(c=o.exec(i))!==null;)s=c;return s?{insertionIndex:r+s.index+s[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with ${n}`),null)},Ki=e=>{if(e.includes(`"value":"claude-opus-4-6"`))return console.log(`patch: modelCustomizations: custom models already present — skipping`),e;let t=Gi(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Wi.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return P(e,a,i,n,n),a};let qi=!1,Ji=!1,Yi=!1;const Xi=()=>qi,Zi=()=>Ji,Qi=()=>Yi,$i=()=>{qi=!0},ea=()=>{Ji=!0,qi=!0},ta=()=>{Yi=!0},W=(e,...t)=>{Xi()&&console.log(e,...t)},G=(e,...t)=>{Zi()&&console.log(e,...t)};function na(){try{let e=f.join(p.homedir(),`.claude.json`);return JSON.parse(d.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function ra(e){try{let t=f.join(p.homedir(),`.claude.json`),n=JSON.parse(d.readFileSync(t,`utf8`));n.theme=e,d.writeFileSync(t,JSON.stringify(n,null,2))}catch{}}function ia(){try{let e=f.join(p.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(d.readFileSync(e,`utf8`))?.claudeAiOauth?.subscriptionType||`unknown`){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`}}catch{}return`Claude API`}function aa(){try{let e=f.join(p.homedir(),`.claude`,`settings.json`),t=JSON.parse(d.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=Wi.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function oa(e){process.platform===`win32`?m.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?m.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():m.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function sa(e){if(process.platform===`win32`)m.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)m.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=f.dirname(e);m.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function ca(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 la(e){if(!ca(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 ua(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=h.createHash(t),o=d.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function da(e,t,n=`replace`){let r=493;try{r=(await o.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 o.unlink(e),W(`[${n}] Unlinked ${e} to break hard links`)}catch(t){W(`[${n}] Could not unlink ${e}: ${t}`)}await o.writeFile(e,t),await o.chmod(e,r),W(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function fa(e){try{return await o.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const pa=e=>e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):e,ma=(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]},ha=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function K(e,t){if(e==null)return t;if(typeof t!=`object`||!t)return e;if(Array.isArray(t))return Array.isArray(e)?e:t;let n={...e};for(let e of Object.keys(t)){let r=t[e];e in n?typeof r==`object`&&r&&!Array.isArray(r)&&(n[e]=K(n[e],r)):n[e]=r}return n}const ga=async(e,t=33554432)=>{let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>t)throw Error(`Response body too large: ${n} bytes exceeds the ${t}-byte limit.`);let r=e.body;if(!r){let n=await e.text();if(Buffer.byteLength(n,`utf8`)>t)throw Error(`Response body exceeds the ${t}-byte limit.`);return n}let i=r.getReader(),a=[],o=0;for(;;){let{done:e,value:n}=await i.read();if(e)break;if(n){if(o+=n.byteLength,o>t)throw await i.cancel().catch(()=>{}),Error(`Response body exceeds the ${t}-byte limit — aborting download.`);a.push(Buffer.from(n))}}return Buffer.concat(a).toString(`utf8`)},_a=e=>{let t=e?.settings?.userMessageDisplay;if(!t)return;let n=!!t.prefix,r=`borderStyle`in t,i=`padding`in t,a=`paddingX`in t,o=`fitBoxToContent`in t,s=t.padding;n&&(e.settings.userMessageDisplay={format:(t.prefix?.format||``)+(t.message?.format||`{}`),styling:[...t.prefix?.styling||[],...t.message?.styling||[]],foregroundColor:t.message?.foregroundColor===`rgb(0,0,0)`?`default`:t.message?.foregroundColor||t.prefix?.foregroundColor||`default`,backgroundColor:t.message?.backgroundColor===`rgb(0,0,0)`?null:t.message?.backgroundColor||t.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1});let c=e.settings.userMessageDisplay;r||(c.borderStyle=`none`,c.borderColor=`rgb(255,255,255)`),i&&!a?(c.paddingX=s||0,c.paddingY=0,delete c.padding):a||(c.paddingX=0,c.paddingY=0),o||(c.fitBoxToContent=!1)},va=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function ya(){try{let e=await o.readFile(J,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=u.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await wa(),await o.writeFile(J,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`||e instanceof SyntaxError)return!1;throw e}}const ba=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return pa(e);let t=u.join(r.homedir(),`.tweakcc`),n=u.join(r.homedir(),`.claude`,`tweakcc`),i=process.env.XDG_CONFIG_HOME;try{if(c.existsSync(t))return t}catch(e){W(`Failed to check if ${t} exists: ${e}`)}try{if(c.existsSync(n))return n}catch(e){W(`Failed to check if ${n} exists: ${e}`)}return i?u.join(i,`tweakcc`):t},q=ba(),J=u.join(q,`config.json`),Y=u.join(q,`cli.js.backup`),X=u.join(q,`native-binary.backup`),Z=u.join(q,`system-prompts`),xa=u.join(q,`system-reminders`),Sa=u.join(q,`prompt-data-cache`),Ca=()=>{let e=q,n=r.homedir(),i=[u.join(n,`.tweakcc`),u.join(n,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?u.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return c.existsSync(t)&&t!==e}catch{return!1}});i.length>0&&(console.warn(t.yellow(`
722
+ Multiple configuration locations detected:`)),console.warn(t.gray(` Active: ${e}`)),console.warn(t.gray(` Other existing locations:`)),i.forEach(e=>{console.warn(t.gray(` - ${e}`))}),console.warn(t.gray(` Only the active location is used. To switch locations,`)),console.warn(t.gray(` move your config.json to the desired directory.
723
+ `)))},wa=async()=>{await o.mkdir(q,{recursive:!0}),await o.mkdir(Z,{recursive:!0}),await o.mkdir(xa,{recursive:!0});let e=u.join(q,`.gitignore`);try{await o.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await o.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(i)+i)}};let Q=null;const Ta=()=>({ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:E}),Ea=e=>{let t=e?.settings?.thinkingVerbs;t?.punctuation&&(t.format=`{}`+t.punctuation,delete t.punctuation),_a(e),e.settings=K(e.settings,E),e.settings.inputPatternHighlighters&&(e.settings.inputPatternHighlighters=e.settings.inputPatternHighlighters.map(e=>K(e,ee))),e.settings.toolsets&&(e.settings.toolsets=e.settings.toolsets.map(e=>K(e,te))),e.settings.themes&&(e.settings.themes=e.settings.themes.map(e=>K(e,D))),va(e),delete e.settings.launchText},Da=async()=>{let e=Ta();try{W(`Reading config at ${J}`),Ca();let t=await o.readFile(J,`utf8`),n={...e,...JSON.parse(t)},r=JSON.stringify(n);Ea(n);let i=await st(Z);return i&&(n.changesApplied=!1),(JSON.stringify(n)!==r||i)&&await Oa(n),Q=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;if(t instanceof SyntaxError){let t=`${J}.corrupt-${Date.now()}`;try{await o.rename(J,t),console.error(`tweakcc: ${J} was not valid JSON — moved it to ${t} and reset to defaults.`)}catch{console.error(`tweakcc: ${J} was not valid JSON — falling back to defaults.`)}return e}throw t}},$=async e=>(W(`Updating config at ${J}`),Q||=await Da(),e(Q),Q.lastModified=new Date().toISOString(),await Oa(Q),Q),Oa=async e=>{e.lastModified=new Date().toISOString(),await wa();let t=`${J}.tmp-${process.pid}`;try{await o.writeFile(t,JSON.stringify(e,null,2)),await o.rename(t,J)}catch(e){try{await o.unlink(t)}catch{}throw console.error(`Error saving config:`,e),e}},ka=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 o.readFile(J,`utf8`);n=JSON.parse(e)}catch{n=Ta()}let r;try{r=await fetch(e,{headers:{Accept:`application/json`,"User-Agent":`tweakcc`},signal:AbortSignal.timeout(2e4)})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to fetch config from ${e}\n Network error: ${n}\n Please check your internet connection and try again.`)}if(!r.ok)throw Error(`Failed to fetch config from ${e}\n HTTP ${r.status}: ${r.statusText}\n Please check that the URL is correct and accessible.`);let i;try{let e=await ga(r,8*1024*1024);i=JSON.parse(e)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to parse config from ${e}\n JSON parse error: ${n}\n Please ensure the URL returns valid JSON.`)}let a={sourceUrl:e,dateFetched:new Date().toISOString(),settings:i};await $(e=>{e.remoteConfig=a});let s={...Ta(),ccVersion:n.ccVersion||``,ccInstallationPath:n.ccInstallationPath||null,settings:{...E,...i},remoteConfig:a};return Ea(s),W(`Successfully fetched and parsed config from ${e}`),s};export{ot as $,sa as A,Di as B,Xi as C,oa as D,la as E,Bi as F,Ti as G,Mi as H,Pi as I,P as J,Ei as K,Ii as L,H as M,Ri as N,ga as O,Ui as P,It as Q,L as R,ua as S,ca as T,Ci as U,B as V,wi as W,zt as X,Xt as Y,Rt as Z,ta as _,Z as a,na as b,ba as c,ya as d,E as et,ma as f,$i as g,fa as h,X as i,T as it,ra as j,da as k,Da as l,K as m,q as n,C as nt,xa as o,W as p,F as q,J as r,w as rt,ka as s,Y as t,D as tt,$ as u,ea as v,Qi as w,aa as x,ia as y,V as z};