tweakcc-fixed 2.8.41 → 2.8.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/dist/{config-h2_qLiXs.mjs → config-B24_Ecyb.mjs} +4 -4
- package/dist/{content-Co05XSpg.mjs → content-nFksvTi-.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/{nativeInstallation-Cs5d5CP9.mjs → nativeInstallation-Cx30DyG3.mjs} +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/tweakcc-fixed)
|
|
8
8
|
[](https://www.npmjs.com/package/tweakcc-fixed)
|
|
9
|
-
[](https://github.com/anthropics/claude-code)
|
|
10
10
|
[](#credit--license)
|
|
11
11
|
|
|
12
12
|
**[Install](#install) · [Customize](#what-you-can-customize) · [The fork](#what-this-fork-adds) · [How it works](#how-it-works)**
|
|
@@ -57,13 +57,11 @@ The biggest difference is coverage. Its extractor pulls over ten times the promp
|
|
|
57
57
|
|
|
58
58
|
| | tweakcc-fixed | upstream |
|
|
59
59
|
| ---------------------------- | :-----------: | :-------: |
|
|
60
|
-
| Prompt sites (CC 2.1.
|
|
61
|
-
| Unique prompt IDs | **
|
|
60
|
+
| Prompt sites (CC 2.1.295) | **11,767** | 901 |
|
|
61
|
+
| Unique prompt IDs | **11,128** | 901 |
|
|
62
62
|
| Patches | **64** | 49 |
|
|
63
63
|
| Overrides on native installs | **yes** | gated off |
|
|
64
64
|
|
|
65
|
-
¹ Upstream has not published a 2.1.294 catalogue; this is its newest, 2.1.292.
|
|
66
|
-
|
|
67
65
|
That reach shows up in a few mechanisms the base doesn't have. The `<system-reminder>` injections that fire per turn — and never surface as named prompts — become editable: blank one out to drop it, or rewrite it. Each connected MCP server's instruction block can be dropped or rewritten the same way. And where upstream gates system-prompt overrides off for native installs, this fork applies them. It pairs with [lobotomized-claude-code](https://github.com/skrabe/lobotomized-claude-code), a set of per-model override packs tuned against exactly this extraction.
|
|
68
66
|
|
|
69
67
|
The extra patches cluster around a few themes: **memory** (a dream-mode consolidation pass, leaner memory types), **reasoning** (Opus defaulting to max effort, plus the experimental complexity router), **search** (the experimental fff backend), and a run of **correctness fixes** — an honest rewind-summary header, a "summarize from here" that actually starts at the rewind point, quieter empty system-reminders, and more.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c,{createReadStream as l}from"node:fs";import*as u from"node:path";import d from"node:path";import*as f from"fs";import*as p from"path";import*as m from"os";import*as h from"child_process";import*as g from"crypto";import{execFile as _,spawnSync as v}from"node:child_process";import y from"gray-matter";import*as b from"node:crypto";import{randomUUID as x}from"node:crypto";import{fileURLToPath as S}from"node:url";import{Worker as C}from"node:worker_threads";import{diffWordsWithSpace as w}from"diff";const T=e(import.meta.url),E=(()=>{try{return T(`../package.json`)}catch{return T(`../../package.json`)}})(),D=E.version,O=E.supportedClaudeCode;let k=null;async function A(){if(k!==null)return k;try{return await import(`node-lief`),k=await import(`./nativeInstallation-
|
|
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,{createReadStream as l}from"node:fs";import*as u from"node:path";import d from"node:path";import*as f from"fs";import*as p from"path";import*as m from"os";import*as h from"child_process";import*as g from"crypto";import{execFile as _,spawnSync as v}from"node:child_process";import y from"gray-matter";import*as b from"node:crypto";import{randomUUID as x}from"node:crypto";import{fileURLToPath as S}from"node:url";import{Worker as C}from"node:worker_threads";import{diffWordsWithSpace as w}from"diff";const T=e(import.meta.url),E=(()=>{try{return T(`../package.json`)}catch{return T(`../../package.json`)}})(),D=E.version,O=E.supportedClaudeCode;let k=null;async function A(){if(k!==null)return k;try{return await import(`node-lief`),k=await import(`./nativeInstallation-Cx30DyG3.mjs`),k}catch(e){return J(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&J(e),null}}async function j(e,t){let n=await A();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 M(e,t,n,r){let i=await A();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 N(e){let t=await A();return t?t.resolveNixBinaryWrapper(e):null}const ee=[{id:`routine`,label:`Routine`,effort:`low`,help:`The requested result and method are already clear. The remaining work needs little inference; correctness is readily checked against supplied facts or an established procedure. Further investigation is unnecessary.`},{id:`standard`,label:`Standard`,effort:`medium`,help:`The normal working budget for substantive day-to-day work. Some judgment, information gathering and validation are needed, but ordinary investigation and checks can complete the requested scope. A task need not be trivial or fully specified to fit this level.`},{id:`hard`,label:`Hard`,effort:`high`,help:`Additional independent judgment or verification is materially necessary. Interacting uncertainties or hidden failure modes warrant deeper investigation and cross-checking than ordinary work, even if the overall method is known. More effort is expected to improve correctness, not simply expand the scope.`},{id:`frontier`,label:`Frontier`,effort:`max`,help:`A demanding end-to-end handoff warrants the greatest independent judgment, persistence and extensive verification, with little user iteration to catch omissions. Substantial difficulty remains that high effort is unlikely to resolve adequately. Mere breadth or importance is insufficient; an explicit maximum-effort preference also qualifies.`}],te=`You are a difficulty router for an AI coding agent. Each turn you get a compact running SUMMARY of the session, a CONTEXT block (the model in use and the level you assigned last turn), the most recent exchange (the previous user message and the assistant reply), and the user NEW message. Do two things and output ONLY a JSON object with the keys level and summary - no prose, no code fence.
|
|
2
2
|
|
|
3
3
|
# level
|
|
4
4
|
Pick the integer effort level (0 = least effort, {MAX} = most) for the NEW message, judged IN CONTEXT of the summary, the context block, and the recent exchange:
|
|
@@ -809,7 +809,7 @@ const filtered=chunk
|
|
|
809
809
|
return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
|
|
810
810
|
};
|
|
811
811
|
// SCROLLING FIX PATCH END
|
|
812
|
-
`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},pc=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?(console.log(`patch: worktreeMode: EnterWorktree present, tengu_worktree_mode gate gone — no-op`),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 V(e,i,r,n,n),i},mc=e=>{let t=/(\{name:"(?:cc-plugin-)?responsive-mode",description:)("(?:[^"\\]|\\.)*")((?:,defaultEnabled:![01])?,isAvailable:([$\w]+)(?:,defaultEnabled:![01])?\})/,n=e.match(t);if(!n||n.index===void 0)return/"(?:cc-plugin-)?responsive-mode"/.test(e)?(console.error(`patch: responsiveMode: failed to find the responsive-mode plugin listing`),null):(console.log(`patch: responsiveMode: this CC build ships no responsive-mode plugin — no-op`),e);let r=n[4].replace(/[$]/g,`\\$`);if(RegExp(`var ${r}=\\(\\)=>(?:!?[$\\w]+\\(\\)&&)*!?[$\\w]+\\(\\);`).test(e)&&n[0].includes(`defaultEnabled`))return e;let i=[RegExp(`(var ${r}=\\(\\)=>)((?:!?[$\\w]+\\(\\)&&)*!?[$\\w]+\\(\\))&&[$\\w]+\\("([a-z0-9_]+)",[$\\w]+\\(\\)\\);`),RegExp(`(var ${r}=\\(\\)=>)([$\\w]+\\(\\))&&[$\\w]+\\("([a-z0-9_]+)",[$\\w]+\\(\\)\\);`)],a=null;for(let t of i)if(a=e.match(t),a)break;if(!a||a.index===void 0)return console.error(`patch: responsiveMode: failed to find the responsive-mode availability gate`),null;let o=e,s=`${a[1]}${a[2]};`;o=o.slice(0,a.index)+s+o.slice(a.index+a[0].length),V(e,o,s,a.index,a.index+a[0].length);let c=o.match(t);if(!c||c.index===void 0)return console.error(`patch: responsiveMode: listing vanished after the gate rewrite`),null;if(!c[0].includes(`defaultEnabled`)){let e=o,t=`${c[1]}${c[2]},defaultEnabled:!1${c[3]}`;o=o.slice(0,c.index)+t+o.slice(c.index+c[0].length),V(e,o,t,c.index,c.index+c[0].length)}return o},hc=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):(J(`patch: allowCustomAgentModels: enum/includes gate removed in this CC build — no-op`),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),V(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(_),V(u,t,h,g,_),t},gc=e=>{let t=e;{let e=!1;for(let n of[`claude-opus-4-8`,`claude-opus-4-7`]){let r=RegExp(`(id:"${n}"(?:(?!id:"claude-)[\\s\\S]){0,4000}?default_effort:)"(?:high|xhigh)"`),i=t.match(r);if(i&&i.index!==void 0){let n=`${i[1]}"max"`,r=t.slice(0,i.index)+n+t.slice(i.index+i[0].length);V(t,r,n,i.index,i.index+i[0].length),t=r,e=!0}}if(e)return t;if(/id:"claude-opus-4-[78]"(?:(?!id:"claude-)[\s\S]){0,4000}?default_effort:"max"/.test(t))return J(`patch: maxEffortDefault: catalog default_effort already "max" — skipping`),t}let 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);V(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))J(`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},_c=e=>{let t=e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*\2\s*===\s*"claude-fable-5"\s*\|\|\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*,\s*"fable_5_mitigations"\s*\)\s*\|\|\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*(?:,\s*[$\w]+\s*)?\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*,\s*"fable_5_mitigations"\s*(?:,\s*[$\w]+\s*)?\)\s*\|\|\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*(?:,\s*[$\w]+\s*)?\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*,\s*"fable_5_mitigations"\s*(?:,\s*[$\w]+\s*)?\)\s*;\s*if\s*\(\s*\3\s*!==\s*void\s*0\s*\)\s*return\s*\3\s*;\s*if\s*\(\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/);if(!t||t.index===void 0)return/"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!0\s*\}/.test(e)?(J(`patch: autonomousOperationAllModels: model-family gate already flipped — skipping`),e):/"claude-fable-5"/.test(e)?(console.error(`patch: autonomousOperationAllModels: found the fable/mythos model ids but not the expected gate shape — needs a new match method`),null):(console.log(`patch: autonomousOperationAllModels: fable/mythos model-family gate not present in this CC build — no-op`),e);let[n]=t,r=n.replace(/return\s*!1\s*\}$/,`return!0}`),i=e.slice(0,t.index)+r+e.slice(t.index+n.length);return V(e,i,r,t.index,t.index+n.length),i},vc=`globalThis.__tweakccRefusalFallbackReturn`,yc=`globalThis.__tweakccRefusalFallbackOnReturn`,bc=`globalThis.__tweakccRefusalFallbackLine`,xc=`globalThis.__tweakccRefusalFallbackMessage`,Sc=`globalThis.__tweakccRefusalFallbackEvent`,Cc=`__tweakccRefusalFallbackApplyOnReset`,wc=`/*@@TWEAKCC_MODULE:`,Tc=(e,t)=>{let n=e.lastIndexOf(wc,t),r=e.indexOf(wc,n===-1?0:n+1);return[n===-1?0:n,r===-1?e.length:r]},Ec=e=>e.replace(/\$/g,`\\$`),U=(e,t,n,r)=>{let i=e.slice(0,t)+r+e.slice(t+n);return V(e,i,r,t,t+n),i},Dc=e=>{let t={},n=e.match(/function [$\w]+\(([$\w]+)\)\{return\(typeof \1==="string"\?\[\1\]:\1\)\.slice\(0,([$\w]+)\)\}/);if(n?.index!==void 0){let[r,i]=Tc(e,n.index),a=e.slice(r,i).match(RegExp(`(?<![$\\w.])${Ec(n[2])}=(\\d+)(?![\\d.])`));a&&(t.chainLength=Number(a[1]))}let r=e.match(/function [$\w]+\(([$\w]+)\)\{return ([$\w]+)\(\1\)\|\|([$\w]+)\(\1\)\?\1:"other"\}/);if(r?.index!==void 0){let[n,i]=Tc(e,r.index),a=e.slice(n,i),o=new Set;for(let e of[r[2],r[3]]){let n=a.match(RegExp(`function ${Ec(e)}\\(([$\\w]+)\\)\\{return ([^}]*)\\}`));if(!n)return t;for(let e of n[2].matchAll(RegExp(`${Ec(n[1])}==="([^"]+)"`,`g`)))o.add(e[1])}o.size>0&&(t.categories=o)}return t},Oc=(e,t)=>{let n=Object.create(null);if(e==null)return n;if(typeof e!=`object`||Array.isArray(e))return console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes should map a refusal category to a model id or a list of them; ignoring it`),n;for(let[r,i]of Object.entries(e)){let e=Array.isArray(i)?i:[i];if(!e.every(e=>typeof e==`string`)){console.warn(`patch: refusalFallbackModel: skipping refusalFallbackRoutes.${r}: a route is a model id or a non-empty list of model ids`);continue}let a=e.map(e=>e.trim()),o=a.filter(e=>e!==``);if(o.length===0){console.warn(`patch: refusalFallbackModel: skipping refusalFallbackRoutes.${r}: a route is a model id or a non-empty list of model ids`);continue}o.length<a.length&&console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes.${r} has an empty model id; skipping it`),t.categories&&!t.categories.has(r)&&console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes.${r} is not a refusal category this Claude Code knows (${[...t.categories].join(`, `)}), so it never matches`),t.chainLength!==void 0&&o.length>t.chainLength&&console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes.${r} lists ${o.length} models, and Claude Code tries only the first ${t.chainLength}`),n[r]=Array.isArray(i)?o:o[0]}return n},kc=e=>e===void 0?1:e===null?null:typeof e==`number`&&Number.isInteger(e)&&e>=0?e:(console.warn(`patch: refusalFallbackModel: refusalFallbackMaxReturns should be a whole number of returns or null; using 1`),1),Ac=e=>{let t=e.match(/(function ([$\w]+)\(([$\w]+)\)\{let\{originalModelCanonical:([$\w]+),apiRefusalCategory:[$\w]+\}=\3,[$\w]+=)\3\.routesOverride\?\?([$\w]+)\(\4\)/);if(!t||t.index===void 0)return null;let[n,r,i,a,o,s]=t;return{index:t.index,length:n.length,head:r,walker:i,arg:a,model:o,table:s}},jc=`((__tweakccD,__tweakccO)=>{`,Mc=e=>{let t=Ac(e);if(!t)return e.includes(jc)?(J(`patch: refusalFallbackModel: routes already merged, skipping`),e):(console.error(`patch: refusalFallbackModel: failed to find the refusal route walker`),null);let{head:n,arg:r,model:i,table:a}=t;return U(e,t.index,t.length,`${n}${jc}let __tweakccM=Object.assign(Object.create(null),__tweakccD);if(__tweakccO)for(let __tweakccK of Object.keys(__tweakccO))__tweakccM[__tweakccK]=[...new Set([].concat(__tweakccO[__tweakccK],Object.hasOwn(__tweakccD,__tweakccK)?__tweakccD[__tweakccK]:[]))];return __tweakccM})(${a}(${i}),${r}.routesOverride)`)},Nc=e=>{let t=[...e.matchAll(/function ([$\w]+)\(\)\{return\}/g)].find(t=>t[1]!==void 0&&e.includes(`routesOverride:${t[1]}()`));return!t||t.index===void 0?null:{index:t.index,length:t[0].length,name:t[1]}},Pc=(e,t)=>{let n=`{return JSON.parse(${JSON.stringify(JSON.stringify(t))})}`;if(e.includes(n))return J(`patch: refusalFallbackModel: routes already supplied, skipping`),e;let r=Nc(e);return r?U(e,r.index,r.length,`function ${r.name}()${n}`):(console.error(`patch: refusalFallbackModel: failed to find the refusal routes supplier`),null)},Fc=(e,t)=>`(globalThis.__tweakccRefusalFallbackHub??=new ${e}(()=>${t}()))`,Ic=(e,t,n,r,i)=>{let a=i===null?``:`if(__tweakccR.returns>=${i}){if(__tweakccR.held)return;__tweakccR.held=!0;return{held:!0,returns:__tweakccR.returns,model:__tweakccL.previousOverride??__tweakccL.previousModelForSession??__tweakccL.previousAppStateModel,fallback:__tweakccL.fallbackModel}}`;return`${yc}=(__tweakccF)=>${Fc(n,r)}.of(${e}()).subscribe(__tweakccF);${vc}=(__tweakccQ)=>{let __tweakccS=${e}(),__tweakccL=__tweakccS.modelSelection.refusalFallbackModelLatch(),__tweakccR=(globalThis.__tweakccRefusalFallbackRuns??=new ${n}(()=>({}))).of(__tweakccS);if(__tweakccR.session!==__tweakccS.id){__tweakccR.session=__tweakccS.id;__tweakccR.returns=0;__tweakccR.held=!1}if(!__tweakccL){if(__tweakccQ){__tweakccR.returns=0;__tweakccR.held=!1}return}`+a+`let __tweakccT=${t}();if(!__tweakccT)return;__tweakccR.returns++;${Fc(n,r)}.of(__tweakccS).emit(__tweakccT);return{held:!1,returns:__tweakccR.returns,model:__tweakccT.overrideValue??__tweakccT.forSessionValue??__tweakccT.appStateModel,fallback:__tweakccT.fallbackModel}};`},Lc=(e,t)=>{if(e.includes(`${vc}=`))return J(`patch: refusalFallbackModel: return already published, skipping`),e;let n=e.match(/function ([$\w]+)\(\)\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=\2\.modelSelection\.refusalFallbackModelLatch\(\);if\(\2\.modelSelection\.unlatchRefusalFallbackModel\((?:"[^"]*")?\),!\4\|\|\2\.modelSelection\.mainLoopModelOverride\(\)!==\4\.fallbackModel\)return;return \2\.modelSelection\.overrideMainLoopModel\(\4\.previousOverride\)/);if(!n||n.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the fallback-restore function`),null;let[r,i]=Tc(e,n.index),a=[...e.slice(r,i).matchAll(/var ([$\w]+)=new ([$\w]+)\(\(\)=>([$\w]+)\(\)\);function [$\w]+\(([$\w]+)\)\{return \1\.of\(([$\w]+)\(\)\)\.subscribe\(\4\)\}/g)].find(e=>e[5]===n[3]);return a?U(e,n.index,0,Ic(n[3],n[1],a[2],a[3],t)):(console.error(`patch: refusalFallbackModel: failed to find the reset event's hub in the restore's module`),null)},Rc=e=>{if(e.includes(`function ${Cc}(`))return J(`patch: refusalFallbackModel: restore callbacks already subscribed, skipping`),e;let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return ([$\w]+)\(\(([$\w]+),([$\w]+),([$\w]+)\)=>\{if\(!\6\)return;([$\w]+)\(\6,\2\),[$\w]+\("tengu_refusal_fallback_latch_reset",/);if(!t||t.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the restore's app-state registration`),null;let[,n,r,i,,,,a]=t,[o,s]=Tc(e,t.index),c=[...e.slice(o,s).matchAll(RegExp(`function ([$\\w]+)\\(([$\\w]+)\\)\\{return ${Ec(i)}\\(\\(([$\\w]+),([$\\w]+),([$\\w]+)\\)=>\\{if\\(\\5\\)\\2\\(\\)\\}\\)\\}`,`g`))];if(c.length!==1||c[0].index===void 0)return console.error(`patch: refusalFallbackModel: failed to find headless's model-drop registration`),null;let[,l,u]=c[0],d=o+c[0].index,[f,p]=d>t.index?[{at:d,name:l,param:u,kind:`drop`},{at:t.index,name:n,param:r,kind:`apply`}]:[{at:t.index,name:n,param:r,kind:`apply`},{at:d,name:l,param:u,kind:`drop`}],m=e;for(let e of[f,p]){let t=e.kind===`apply`?Cc:`__tweakccRefusalFallbackDropOnReset`,n=e.kind===`apply`?`(__tweakccT)=>${a}(__tweakccT,${e.param})`:`()=>${e.param}()`,r=`function ${e.name}(${e.param}){`;m=U(m,e.at,r.length,`${r}let __tweakccU=${t}(${e.param}),__tweakccV=${yc}?.(${n});return()=>{__tweakccV?.(),__tweakccU()}}function ${t}(${e.param}){`)}return m},zc=e=>{if(e.includes(`${bc}=`))return J(`patch: refusalFallbackModel: line already published, skipping`),e;let t=e.match(/function [$\w]+\(([$\w]+),([$\w]+),([$\w]+)\)\{return [$\w]+\("switched",\{model:([$\w]+)\(\1\),fallback:\2\},\1,\3\)\?\?`Switched to \$\{\2\}\.`\}/);if(!t||t.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the fallback's switch message`),null;let n=t[4],r=`${bc}=(__tweakccN)=>{let __tweakccM=__tweakccN.model==null?"the default model":${n}(__tweakccN.model),__tweakccF=${n}(__tweakccN.fallback);return __tweakccN.held?{content:"Staying on "+__tweakccF+" for this session \\xB7 "+(__tweakccN.returns?__tweakccM+" was flagged again after switching back \\xB7 ":"")+"/model to change",level:"warning"}:{content:"Switched back to "+__tweakccM+".",level:"notice"}};`;return U(e,t.index,0,r)},Bc=e=>{if(e.includes(`${xc}=`))return J(`patch: refusalFallbackModel: message constructor already published, skipping`),e;let t=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)(?:,([$\w]+))?\)\{return\{type:"system",subtype:"informational",content:\2,isMeta:!1,timestamp:new Date\(\)\.toISOString\(\),uuid:[$\w]+\(\),level:\3(?:,\.\.\.\4&&\{[$\w]+:\4\})?\}\}/);return!t||t.index===void 0?(console.error(`patch: refusalFallbackModel: failed to find the system-message constructor`),null):U(e,t.index,0,`${xc}=${t[1]};`)},Vc=e=>{if(e.includes(`${Sc}=`))return J(`patch: refusalFallbackModel: event queue already published, skipping`),e;let t=e.match(/function [$\w]+\([$\w]+\)\{([$\w]+)\(\)\.setEnqueueListener\([$\w]+\)\}function ([$\w]+)\(([$\w]+)\)\{\1\(\)\.enqueue\(\3\)\}/);return!t||t.index===void 0?(console.error(`patch: refusalFallbackModel: failed to find the SDK event queue`),null):U(e,t.index,0,`${Sc}=${t[2]};`)},Hc=e=>{let t=`}finally{try{let __tweakccN=${vc}`;if(e.includes(t))return J(`patch: refusalFallbackModel: REPL turn end already spliced, skipping`),e;let n=e.match(/([$\w.]+)=await this\._runImpl\([$\w]+,[^)]*\)\}finally\{/);if(!n||n.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the REPL's turn-end finally`),null;let r=n.index+n[0].length,i=e.slice(r,r+2e3).match(/([$\w]+)\(\{type:"append",messages:this\.stream\.pendingPreservedInsert\.preserved\}\)/);return i?U(e,r,0,`try{let __tweakccN=${vc}?.(${n[1]}?.num_turns>0);if(__tweakccN){let __tweakccL=${bc}?.(__tweakccN),__tweakccM=__tweakccL&&${xc}?.(__tweakccL.content,__tweakccL.level);if(__tweakccM)${i[1]}({type:"append",messages:[__tweakccM]})}}catch{}`):(console.error(`patch: refusalFallbackModel: failed to find the REPL's transcript append`),null)},Uc=e=>{let t=e.match(/noteTurnEnded\(([$\w]+),([$\w]+),([$\w]+)\)\{if\(this\.selector\.noteTurnEnded\(\1\),\1\|\|\3\.num_turns>0\)\{/);return!t||t.index===void 0?/noteTurnEnded\([$\w]+,[$\w]+,[$\w]+\)\{try\{let __tweakccN=/.test(e)?(J(`patch: refusalFallbackModel: headless turn end already spliced, skipping`),e):(console.error(`patch: refusalFallbackModel: failed to find the dispatcher's noteTurnEnded`),null):U(e,t.index+`noteTurnEnded(${t[1]},${t[2]},${t[3]}){`.length,0,`try{let __tweakccN=${vc}?.(${t[3]}?.num_turns>0);if(__tweakccN){let __tweakccL=${bc}?.(__tweakccN);if(__tweakccL)${Sc}?.({type:"system",subtype:"informational",content:__tweakccL.content,level:__tweakccL.level})}}catch{}`)},Wc=(e,t={},n=1)=>{let r=kc(n),i=Oc(t,Dc(e)),a=[Mc,e=>Pc(e,i),e=>Lc(e,r),Rc,zc,Bc,Vc,Hc,Uc],o=e;for(let e of a)if(o=e(o),o===null)return null;return o},Gc=e=>{let t=e,n=t.match(/\(\{filePath:([$\w]+),frontmatter:([$\w]+),content:([$\w]+),source:([$\w]+),baseDir:([$\w]+)\}\)=>\{([\s\S]{0,800}?)return\{name:([$\w]+),description:([$\w]+),prompt:\3\.trim\(\),source:\4,baseDir:\5,keepCodingInstructions:([$\w]+)\}/);if(n&&n.index!==void 0){let e=n[2],r=`,turnReminder:typeof ${e}["turn-reminder"]==="string"?${e}["turn-reminder"]:typeof ${e}.turnReminder==="string"?${e}.turnReminder:typeof ${e}.turnreminder==="string"?${e}.turnreminder:void 0`,i=n.index+n[0].length;t=t.slice(0,i-1)+r+t.slice(i-1)}else t.includes(`turnReminder:typeof`)||console.error(`patch: outputStyleTurnReminder: custom-style loader shape not found; frontmatter turn-reminder will not thread (fallback reminder still applies)`);let r=t.match(/([$\w]+)\[([$\w]+)\.name\]=\{name:\2\.name,description:\2\.description,prompt:\2\.prompt,source:\2\.source,keepCodingInstructions:\2\.keepCodingInstructions,forceForPlugin:\2\.forceForPlugin\}/);if(r&&r.index!==void 0){let e=r[2],n=r.index+r[0].length;t=t.slice(0,n-1)+`,turnReminder:${e}.turnReminder`+t.slice(n-1)}else /forceForPlugin:[$\w]+\.forceForPlugin,turnReminder:/.test(t)||console.error(`patch: outputStyleTurnReminder: style-table merge shape not found; frontmatter turn-reminder will not thread (fallback reminder still applies)`);return t},Kc=e=>{let t=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\?\?"([^"]*)"\}`,isMeta:!0\}\)\]\)\}/);if(!t||t.index===void 0)return/\.style\}\.name\?\?|outputStyleName_tweakcc/.test(e)?(console.log(`patch: outputStyleTurnReminder: renderer already patched — threading only`),Gc(e)):/output_style:\(([$\w]+)\)=>\{if\(typeof \1\.style!=="string"/.test(e)?(console.log(`patch: outputStyleTurnReminder: renderer promoted in this CC build — threading only`),Gc(e)):(console.error(`patch: outputStyleTurnReminder: failed to find the output-style reminder renderer`),null);let[,n,r,i,a,o]=t,s=`output_style:(${n})=>{let ${r}=${i}[${n}.style];let outputStyleName_tweakcc=${r}?.name??${n}.style;if(!outputStyleName_tweakcc)return[];return ${a}([${o}({content:\`\${outputStyleName_tweakcc} output style is active. \${${n}.turnReminder??"Write this reply the way that style describes, including its rules on what to leave out."}\`,isMeta:!0})])}`,c=e.slice(0,t.index)+s+e.slice(t.index+t[0].length);return V(e,c,s,t.index,t.index+s.length),Gc(c)},qc={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},Jc=(e,t)=>{if(t===`default`)return e;let n=qc[t],r=e.match(/function ([$\w]+)\(\)\{(?:(?!function )[\s\S])*?modelByMainModel(?:(?!function )[\s\S])*?return\{value:[^{}]*,src:"default"\}\}/);if(r&&r.index!==void 0){let t=r[1],i=`function ${t}(){return{value:"${n}",src:"default"}}`,a=r.index,o=a+r[0].length,s=e.slice(0,a)+i+e.slice(o);return J(`patch: autoModeClassifierModel: matched modelByMainModel resolver ${t} -> ${n}`),V(e,s,i,a,o),s}let i=/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*\}/,a=/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*\}/,o=/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*\}/,s=/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*\}/,c=/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*\}/,l=/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*\}/,u=/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*\{\s*value\s*:\s*\6\s*,\s*src\s*:\s*"gb"\s*\}\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s*\{\s*value\s*:\s*\7\s*,\s*src\s*:\s*"gb"\s*\}\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s*\{\s*value\s*:\s*\3\s*\.\s*model\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*;\s*return\s*\{\s*value\s*:\s*\2\s*,\s*src\s*:\s*"default"\s*\}\s*\}/,d=/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*[$\w]+\s*\(\s*\3\s*\?\.\s*modelByMainModel\s*\)\s*;\s*if\s*\(\s*\4\s*\)\s*return\s*\{\s*value\s*:\s*\4\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s*\{\s*value\s*:\s*\3\s*\.\s*model\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*;\s*return\s*\{\s*value\s*:\s*\2\s*,\s*src\s*:\s*"default"\s*\}\s*\}/,f=/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*[$\w]+\s*\(\s*\3\s*\?\.\s*modelByMainModel\s*\)\s*;\s*if\s*\(\s*\4\s*\)\s*return\s*\{\s*value\s*:\s*\4\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s*\{\s*value\s*:\s*\3\s*\.\s*model\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*!==\s*"demoted"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*;\s*if\s*\(\s*\5\s*\)\s*return\s*\{\s*value\s*:\s*\5\s*,\s*src\s*:\s*"default"\s*,\s*externalDefault\s*:\s*!0\s*\}\s*\}\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*\}/,p=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*[$\w]+\s*\(\s*\3\s*\?\.\s*modelByMainModel\s*,\s*\{\s*vet\s*:\s*\(\s*([$\w]+)\s*\)\s*=>\s*[$\w]+\s*\(\s*\5\s*,\s*"modelByMainModel"\s*\)\s*\}\s*\)\s*\?\?\s*[$\w]+\s*\(\s*\3\s*\?\.\s*model\s*,\s*"model"\s*\)\s*;\s*if\s*\(\s*\4\s*\)\s*return\s*\{\s*value\s*:\s*\4\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*!==\s*"demoted"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*;\s*if\s*\(\s*\6\s*\)\s*return\s*\{\s*value\s*:\s*\6\s*,\s*src\s*:\s*"default"\s*,\s*externalDefault\s*:\s*!0\s*\}\s*\}\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*\}/);if(p&&p.index!==void 0){let[t,r]=p,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,p.index)+i+e.slice(p.index+t.length);return V(e,a,i,p.index,p.index+t.length),a}let m=e.match(f);if(m&&m.index!==void 0){let[t,r]=m,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,m.index)+i+e.slice(m.index+t.length);return V(e,a,i,m.index,m.index+t.length),a}let h=e.match(d);if(h&&h.index!==void 0){let[t,r]=h,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,h.index)+i+e.slice(h.index+t.length);return V(e,a,i,h.index,h.index+t.length),a}let g=e.match(u);if(g&&g.index!==void 0){let[t,r]=g,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,g.index)+i+e.slice(g.index+t.length);return V(e,a,i,g.index,g.index+t.length),a}let _=e.match(l)||e.match(c)||e.match(s)||e.match(o)||e.match(a)||e.match(i);if(_&&_.index!==void 0){let[t,r]=_,i=`function ${r}(){return "${n}"}`,a=e.slice(0,_.index)+i+e.slice(_.index+t.length);return V(e,a,i,_.index,_.index+t.length),a}return/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*\}/.test(e)||/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*\{\s*value\s*:\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*,\s*src\s*:\s*"default"\s*\}\s*\}/.test(e)?(J(`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):(J(`patch: autoModeClassifierModel: tengu_auto_mode_config not present in this CC build — no-op`),e)},Yc=`/*@@TWEAKCC_MODULE:`,Xc=e=>e.includes(Yc);function Zc(e,t){if(!Xc(e))return{file:e,helpers:t};let n=[],r=(t,r,i)=>{if(r===void 0)return null;let a=e.lastIndexOf(Yc,r),o=e.indexOf(`@@*/`,a);return a<0||o<0||e.slice(a+19,o).indexOf(`:`)<0?null:(n.push({at:r,text:`globalThis.${i}=${t};`}),`globalThis.${i}`)},i=r(t.gB,t.gBIndex,`__tweakccRouterHaiku`),a=r(t.km,t.kmIndex,`__tweakccRouterAgentContext`);if(!i||!a)return null;for(let t of n.sort((e,t)=>t.at-e.at))e=e.slice(0,t.at)+t.text+e.slice(t.at);return{file:e,helpers:{gB:i,km:a}}}const Qc=`tweakcc-fixed.typesafe`,$c=`api-key`,el=1500;function tl(e){return/^[\x21-\x7e]{1,1024}$/.test(e)}function nl(e,t){if(process.platform===`darwin`)return e===`write`?{executable:`/usr/bin/security`,args:[`-i`],input:`add-generic-password -U -s ${Qc} -a ${$c} -w "${t.replace(/[\\"]/g,`\\$&`)}"\n`}:{executable:`/usr/bin/security`,args:[e===`read`?`find-generic-password`:`delete-generic-password`,`-s`,Qc,`-a`,$c,...e===`read`?[`-w`]:[]]};if(process.platform===`linux`)return{executable:`secret-tool`,args:[e===`read`?`lookup`:e===`write`?`store`:`clear`,...e===`write`?[`--label=tweakcc TypeSafe API key`]:[],`service`,Qc,`account`,$c],...e===`write`?{input:t}:{}};throw Error(`Native credential storage is unavailable on this platform. Supply TYPESAFE_API_KEY through your environment or secret manager.`)}function rl(e,t){return new Promise((n,r)=>{let i=_(e.executable,e.args,{encoding:`utf8`,timeout:t,killSignal:`SIGKILL`,maxBuffer:8192,windowsHide:!0},(e,t)=>{e?r(Error(`Could not access the OS credential store. Unlock your keychain, or install secret-tool and unlock Secret Service on Linux. Headless systems can supply TYPESAFE_API_KEY through a secret manager.`)):n(t.trim())});i.stdin?.on(`error`,()=>{}),i.stdin?.end(e.input)})}async function il(e){if(!tl(e))throw Error(`The API key must contain 1–1024 printable ASCII characters without spaces.`);if(await rl(nl(`write`,e),15e3),await rl(nl(`read`),15e3)!==e)throw Error(`The OS credential store did not retain the API key. Unlock your keychain and try again, or supply TYPESAFE_API_KEY through a secret manager.`)}async function al(){await rl(nl(`delete`),15e3)}async function ol(){let e=process.env.TYPESAFE_API_KEY;if(e)return tl(e);try{return tl(await rl(nl(`read`),el))}catch{return!1}}function sl(e){return`async function __tweakccRouterApiKey(){
|
|
812
|
+
`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},pc=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?(console.log(`patch: worktreeMode: EnterWorktree present, tengu_worktree_mode gate gone — no-op`),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 V(e,i,r,n,n),i},mc=e=>{let t=/(\{name:"(?:cc-plugin-)?responsive-mode",description:)("(?:[^"\\]|\\.)*")((?:,defaultEnabled:![01])?,isAvailable:([$\w]+)(?:,defaultEnabled:![01])?\})/,n=e.match(t);if(!n||n.index===void 0)return/"(?:cc-plugin-)?responsive-mode"/.test(e)?(console.error(`patch: responsiveMode: failed to find the responsive-mode plugin listing`),null):(console.log(`patch: responsiveMode: this CC build ships no responsive-mode plugin — no-op`),e);let r=n[4].replace(/[$]/g,`\\$`);if(RegExp(`var ${r}=\\(\\)=>(?:!?[$\\w]+\\(\\)&&)*!?[$\\w]+\\(\\);`).test(e)&&n[0].includes(`defaultEnabled`))return e;let i=[RegExp(`(var ${r}=\\(\\)=>)((?:!?[$\\w]+\\(\\)&&)*!?[$\\w]+\\(\\))&&[$\\w]+\\("([a-z0-9_]+)",[$\\w]+\\(\\)\\);`),RegExp(`(var ${r}=\\(\\)=>)([$\\w]+\\(\\))&&[$\\w]+\\("([a-z0-9_]+)",[$\\w]+\\(\\)\\);`)],a=null;for(let t of i)if(a=e.match(t),a)break;if(!a||a.index===void 0)return console.error(`patch: responsiveMode: failed to find the responsive-mode availability gate`),null;let o=e,s=`${a[1]}${a[2]};`;o=o.slice(0,a.index)+s+o.slice(a.index+a[0].length),V(e,o,s,a.index,a.index+a[0].length);let c=o.match(t);if(!c||c.index===void 0)return console.error(`patch: responsiveMode: listing vanished after the gate rewrite`),null;if(!c[0].includes(`defaultEnabled`)){let e=o,t=`${c[1]}${c[2]},defaultEnabled:!1${c[3]}`;o=o.slice(0,c.index)+t+o.slice(c.index+c[0].length),V(e,o,t,c.index,c.index+c[0].length)}return o},hc=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):(J(`patch: allowCustomAgentModels: enum/includes gate removed in this CC build — no-op`),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),V(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(_),V(u,t,h,g,_),t},gc=e=>{let t=e;{let e=!1;for(let n of[`claude-opus-4-8`,`claude-opus-4-7`]){let r=RegExp(`(id:"${n}"(?:(?!id:"claude-)[\\s\\S]){0,4000}?default_effort:)"(?:high|xhigh)"`),i=t.match(r);if(i&&i.index!==void 0){let n=`${i[1]}"max"`,r=t.slice(0,i.index)+n+t.slice(i.index+i[0].length);V(t,r,n,i.index,i.index+i[0].length),t=r,e=!0}}if(e)return t;if(/id:"claude-opus-4-[78]"(?:(?!id:"claude-)[\s\S]){0,4000}?default_effort:"max"/.test(t))return J(`patch: maxEffortDefault: catalog default_effort already "max" — skipping`),t}let 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);V(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))J(`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},_c=e=>{let t=e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*\2\s*===\s*"claude-fable-5"\s*\|\|\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*,\s*"fable_5_mitigations"\s*\)\s*\|\|\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*(?:,\s*[$\w]+\s*)?\)\s*\{\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*,\s*"fable_5_mitigations"\s*(?:,\s*[$\w]+\s*)?\)\s*\|\|\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/)||e.match(/function\s+([$\w]+)\s*\(\s*([$\w]+)\s*(?:,\s*[$\w]+\s*)?\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*,\s*"fable_5_mitigations"\s*(?:,\s*[$\w]+\s*)?\)\s*;\s*if\s*\(\s*\3\s*!==\s*void\s*0\s*\)\s*return\s*\3\s*;\s*if\s*\(\s*\2\s*===\s*"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!1\s*\}/);if(!t||t.index===void 0)return/"claude-mythos-5"\s*\)\s*return\s*!0\s*;\s*return\s*!0\s*\}/.test(e)?(J(`patch: autonomousOperationAllModels: model-family gate already flipped — skipping`),e):/"claude-fable-5"/.test(e)?(console.error(`patch: autonomousOperationAllModels: found the fable/mythos model ids but not the expected gate shape — needs a new match method`),null):(console.log(`patch: autonomousOperationAllModels: fable/mythos model-family gate not present in this CC build — no-op`),e);let[n]=t,r=n.replace(/return\s*!1\s*\}$/,`return!0}`),i=e.slice(0,t.index)+r+e.slice(t.index+n.length);return V(e,i,r,t.index,t.index+n.length),i},vc=`globalThis.__tweakccRefusalFallbackReturn`,yc=`globalThis.__tweakccRefusalFallbackOnReturn`,bc=`globalThis.__tweakccRefusalFallbackLine`,xc=`globalThis.__tweakccRefusalFallbackMessage`,Sc=`globalThis.__tweakccRefusalFallbackEvent`,Cc=`__tweakccRefusalFallbackApplyOnReset`,wc=`/*@@TWEAKCC_MODULE:`,Tc=(e,t)=>{let n=e.lastIndexOf(wc,t),r=e.indexOf(wc,n===-1?0:n+1);return[n===-1?0:n,r===-1?e.length:r]},Ec=e=>e.replace(/\$/g,`\\$`),U=(e,t,n,r)=>{let i=e.slice(0,t)+r+e.slice(t+n);return V(e,i,r,t,t+n),i},Dc=e=>{let t={},n=e.match(/function [$\w]+\(([$\w]+)\)\{return\(typeof \1==="string"\?\[\1\]:\1\)\.slice\(0,([$\w]+)\)\}/);if(n?.index!==void 0){let[r,i]=Tc(e,n.index),a=e.slice(r,i).match(RegExp(`(?<![$\\w.])${Ec(n[2])}=(\\d+)(?![\\d.])`));a&&(t.chainLength=Number(a[1]))}let r=e.match(/function [$\w]+\(([$\w]+)\)\{return ([$\w]+)\(\1\)\|\|([$\w]+)\(\1\)\?\1:"other"\}/);if(r?.index!==void 0){let[n,i]=Tc(e,r.index),a=e.slice(n,i),o=new Set;for(let e of[r[2],r[3]]){let n=a.match(RegExp(`function ${Ec(e)}\\(([$\\w]+)\\)\\{return ([^}]*)\\}`));if(!n)return t;for(let e of n[2].matchAll(RegExp(`${Ec(n[1])}==="([^"]+)"`,`g`)))o.add(e[1])}o.size>0&&(t.categories=o)}return t},Oc=(e,t)=>{let n=Object.create(null);if(e==null)return n;if(typeof e!=`object`||Array.isArray(e))return console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes should map a refusal category to a model id or a list of them; ignoring it`),n;for(let[r,i]of Object.entries(e)){let e=Array.isArray(i)?i:[i];if(!e.every(e=>typeof e==`string`)){console.warn(`patch: refusalFallbackModel: skipping refusalFallbackRoutes.${r}: a route is a model id or a non-empty list of model ids`);continue}let a=e.map(e=>e.trim()),o=a.filter(e=>e!==``);if(o.length===0){console.warn(`patch: refusalFallbackModel: skipping refusalFallbackRoutes.${r}: a route is a model id or a non-empty list of model ids`);continue}o.length<a.length&&console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes.${r} has an empty model id; skipping it`),t.categories&&!t.categories.has(r)&&console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes.${r} is not a refusal category this Claude Code knows (${[...t.categories].join(`, `)}), so it never matches`),t.chainLength!==void 0&&o.length>t.chainLength&&console.warn(`patch: refusalFallbackModel: refusalFallbackRoutes.${r} lists ${o.length} models, and Claude Code tries only the first ${t.chainLength}`),n[r]=Array.isArray(i)?o:o[0]}return n},kc=e=>e===void 0?1:e===null?null:typeof e==`number`&&Number.isInteger(e)&&e>=0?e:(console.warn(`patch: refusalFallbackModel: refusalFallbackMaxReturns should be a whole number of returns or null; using 1`),1),Ac=e=>{let t=e.match(/(function ([$\w]+)\(([$\w]+)\)\{let\{originalModelCanonical:([$\w]+),apiRefusalCategory:[$\w]+\}=\3,[$\w]+=)\3\.routesOverride\?\?([$\w]+)\(\4\)/);if(!t||t.index===void 0)return null;let[n,r,i,a,o,s]=t;return{index:t.index,length:n.length,head:r,walker:i,arg:a,model:o,table:s}},jc=`((__tweakccD,__tweakccO)=>{`,Mc=e=>{let t=Ac(e);if(!t)return e.includes(jc)?(J(`patch: refusalFallbackModel: routes already merged, skipping`),e):(console.error(`patch: refusalFallbackModel: failed to find the refusal route walker`),null);let{head:n,arg:r,model:i,table:a}=t;return U(e,t.index,t.length,`${n}${jc}let __tweakccM=Object.assign(Object.create(null),__tweakccD);if(__tweakccO)for(let __tweakccK of Object.keys(__tweakccO))__tweakccM[__tweakccK]=[...new Set([].concat(__tweakccO[__tweakccK],Object.hasOwn(__tweakccD,__tweakccK)?__tweakccD[__tweakccK]:[]))];return __tweakccM})(${a}(${i}),${r}.routesOverride)`)},Nc=e=>{let t=[...e.matchAll(/function ([$\w]+)\(\)\{return\}/g)].find(t=>t[1]!==void 0&&e.includes(`routesOverride:${t[1]}()`));return!t||t.index===void 0?null:{index:t.index,length:t[0].length,name:t[1]}},Pc=(e,t)=>{let n=`{return JSON.parse(${JSON.stringify(JSON.stringify(t))})}`;if(e.includes(n))return J(`patch: refusalFallbackModel: routes already supplied, skipping`),e;let r=Nc(e);return r?U(e,r.index,r.length,`function ${r.name}()${n}`):(console.error(`patch: refusalFallbackModel: failed to find the refusal routes supplier`),null)},Fc=(e,t)=>`(globalThis.__tweakccRefusalFallbackHub??=new ${e}(()=>${t}()))`,Ic=(e,t,n,r,i)=>{let a=i===null?``:`if(__tweakccR.returns>=${i}){if(__tweakccR.held)return;__tweakccR.held=!0;return{held:!0,returns:__tweakccR.returns,model:__tweakccL.previousOverride??__tweakccL.previousModelForSession??__tweakccL.previousAppStateModel,fallback:__tweakccL.fallbackModel}}`;return`${yc}=(__tweakccF)=>${Fc(n,r)}.of(${e}()).subscribe(__tweakccF);${vc}=(__tweakccQ)=>{let __tweakccS=${e}(),__tweakccL=__tweakccS.modelSelection.refusalFallbackModelLatch(),__tweakccR=(globalThis.__tweakccRefusalFallbackRuns??=new ${n}(()=>({}))).of(__tweakccS);if(__tweakccR.session!==__tweakccS.id){__tweakccR.session=__tweakccS.id;__tweakccR.returns=0;__tweakccR.held=!1}if(!__tweakccL){if(__tweakccQ){__tweakccR.returns=0;__tweakccR.held=!1}return}`+a+`let __tweakccT=${t}();if(!__tweakccT)return;__tweakccR.returns++;${Fc(n,r)}.of(__tweakccS).emit(__tweakccT);return{held:!1,returns:__tweakccR.returns,model:__tweakccT.overrideValue??__tweakccT.forSessionValue??__tweakccT.appStateModel,fallback:__tweakccT.fallbackModel}};`},Lc=(e,t)=>{if(e.includes(`${vc}=`))return J(`patch: refusalFallbackModel: return already published, skipping`),e;let n=e.match(/function ([$\w]+)\(\)\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=\2\.modelSelection\.refusalFallbackModelLatch\(\);if\(\2\.modelSelection\.unlatchRefusalFallbackModel\((?:"[^"]*")?\),!\4\|\|\2\.modelSelection\.mainLoopModelOverride\(\)!==\4\.fallbackModel\)return;return \2\.modelSelection\.overrideMainLoopModel\(\4\.previousOverride\)/);if(!n||n.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the fallback-restore function`),null;let[r,i]=Tc(e,n.index),a=[...e.slice(r,i).matchAll(/var ([$\w]+)=new ([$\w]+)\(\(\)=>([$\w]+)\(\)\);function [$\w]+\(([$\w]+)\)\{return \1\.of\(([$\w]+)\(\)\)\.subscribe\(\4\)\}/g)].find(e=>e[5]===n[3]);return a?U(e,n.index,0,Ic(n[3],n[1],a[2],a[3],t)):(console.error(`patch: refusalFallbackModel: failed to find the reset event's hub in the restore's module`),null)},Rc=e=>{if(e.includes(`function ${Cc}(`))return J(`patch: refusalFallbackModel: restore callbacks already subscribed, skipping`),e;let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return ([$\w]+)\(\(([$\w]+),([$\w]+),([$\w]+)\)=>\{if\(!\6\)return;([$\w]+)\(\6,\2\),[$\w]+\("tengu_refusal_fallback_latch_reset",/);if(!t||t.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the restore's app-state registration`),null;let[,n,r,i,,,,a]=t,[o,s]=Tc(e,t.index),c=[...e.slice(o,s).matchAll(RegExp(`function ([$\\w]+)\\(([$\\w]+)\\)\\{return ${Ec(i)}\\(\\(([$\\w]+),([$\\w]+),([$\\w]+)\\)=>\\{if\\(\\5\\)\\2\\(\\)\\}\\)\\}`,`g`))];if(c.length!==1||c[0].index===void 0)return console.error(`patch: refusalFallbackModel: failed to find headless's model-drop registration`),null;let[,l,u]=c[0],d=o+c[0].index,[f,p]=d>t.index?[{at:d,name:l,param:u,kind:`drop`},{at:t.index,name:n,param:r,kind:`apply`}]:[{at:t.index,name:n,param:r,kind:`apply`},{at:d,name:l,param:u,kind:`drop`}],m=e;for(let e of[f,p]){let t=e.kind===`apply`?Cc:`__tweakccRefusalFallbackDropOnReset`,n=e.kind===`apply`?`(__tweakccT)=>${a}(__tweakccT,${e.param})`:`()=>${e.param}()`,r=`function ${e.name}(${e.param}){`;m=U(m,e.at,r.length,`${r}let __tweakccU=${t}(${e.param}),__tweakccV=${yc}?.(${n});return()=>{__tweakccV?.(),__tweakccU()}}function ${t}(${e.param}){`)}return m},zc=e=>{if(e.includes(`${bc}=`))return J(`patch: refusalFallbackModel: line already published, skipping`),e;let t=e.match(/function [$\w]+\(([$\w]+),([$\w]+),([$\w]+)\)\{return [$\w]+\("switched",\{model:([$\w]+)\(\1\),fallback:\2\},\1,\3\)\?\?`Switched to \$\{\2\}\.`\}/);if(!t||t.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the fallback's switch message`),null;let n=t[4],r=`${bc}=(__tweakccN)=>{let __tweakccM=__tweakccN.model==null?"the default model":${n}(__tweakccN.model),__tweakccF=${n}(__tweakccN.fallback);return __tweakccN.held?{content:"Staying on "+__tweakccF+" for this session \\xB7 "+(__tweakccN.returns?__tweakccM+" was flagged again after switching back \\xB7 ":"")+"/model to change",level:"warning"}:{content:"Switched back to "+__tweakccM+".",level:"notice"}};`;return U(e,t.index,0,r)},Bc=e=>{if(e.includes(`${xc}=`))return J(`patch: refusalFallbackModel: message constructor already published, skipping`),e;let t=e.match(/function ([$\w]+)\(([$\w]+),([$\w]+)(?:,([$\w]+))?\)\{return\{type:"system",subtype:"informational",content:\2,isMeta:!1,timestamp:new Date\(\)\.toISOString\(\),uuid:[$\w]+\(\),level:\3(?:,\.\.\.\4&&\{[$\w]+:\4\})?\}\}/);return!t||t.index===void 0?(console.error(`patch: refusalFallbackModel: failed to find the system-message constructor`),null):U(e,t.index,0,`${xc}=${t[1]};`)},Vc=e=>{if(e.includes(`${Sc}=`))return J(`patch: refusalFallbackModel: event queue already published, skipping`),e;let t=e.match(/function [$\w]+\([$\w]+\)\{([$\w]+)\(\)\.setEnqueueListener\([$\w]+\)\}function ([$\w]+)\(([$\w]+)\)\{\1\(\)\.enqueue\(\3\)\}/);return!t||t.index===void 0?(console.error(`patch: refusalFallbackModel: failed to find the SDK event queue`),null):U(e,t.index,0,`${Sc}=${t[2]};`)},Hc=e=>{let t=`}finally{try{let __tweakccN=${vc}`;if(e.includes(t))return J(`patch: refusalFallbackModel: REPL turn end already spliced, skipping`),e;let n=e.match(/([$\w.]+)=await this\._runImpl\([$\w]+,[^)]*\)\}catch\([$\w]+\)\{[^{}]*\}finally\{/)??e.match(/([$\w.]+)=await this\._runImpl\([$\w]+,[^)]*\)\}finally\{/);if(!n||n.index===void 0)return console.error(`patch: refusalFallbackModel: failed to find the REPL's turn-end finally`),null;let r=n.index+n[0].length,i=e.slice(r,r+2e3).match(/([$\w]+)\(\{type:"append",messages:this\.stream\.pendingPreservedInsert\.preserved\}\)/);return i?U(e,r,0,`try{let __tweakccN=${vc}?.(${n[1]}?.num_turns>0);if(__tweakccN){let __tweakccL=${bc}?.(__tweakccN),__tweakccM=__tweakccL&&${xc}?.(__tweakccL.content,__tweakccL.level);if(__tweakccM)${i[1]}({type:"append",messages:[__tweakccM]})}}catch{}`):(console.error(`patch: refusalFallbackModel: failed to find the REPL's transcript append`),null)},Uc=e=>{let t=e.match(/noteTurnEnded\(([$\w]+),([$\w]+),([$\w]+)\)\{if\(this\.selector\.noteTurnEnded\(\1\),\1\|\|\3\.num_turns>0\)\{/);return!t||t.index===void 0?/noteTurnEnded\([$\w]+,[$\w]+,[$\w]+\)\{try\{let __tweakccN=/.test(e)?(J(`patch: refusalFallbackModel: headless turn end already spliced, skipping`),e):(console.error(`patch: refusalFallbackModel: failed to find the dispatcher's noteTurnEnded`),null):U(e,t.index+`noteTurnEnded(${t[1]},${t[2]},${t[3]}){`.length,0,`try{let __tweakccN=${vc}?.(${t[3]}?.num_turns>0);if(__tweakccN){let __tweakccL=${bc}?.(__tweakccN);if(__tweakccL)${Sc}?.({type:"system",subtype:"informational",content:__tweakccL.content,level:__tweakccL.level})}}catch{}`)},Wc=(e,t={},n=1)=>{let r=kc(n),i=Oc(t,Dc(e)),a=[Mc,e=>Pc(e,i),e=>Lc(e,r),Rc,zc,Bc,Vc,Hc,Uc],o=e;for(let e of a)if(o=e(o),o===null)return null;return o},Gc=e=>{let t=e,n=t.match(/\(\{filePath:([$\w]+),frontmatter:([$\w]+),content:([$\w]+),source:([$\w]+),baseDir:([$\w]+)\}\)=>\{([\s\S]{0,800}?)return\{name:([$\w]+),description:([$\w]+),prompt:\3\.trim\(\),source:\4,baseDir:\5,keepCodingInstructions:([$\w]+)\}/);if(n&&n.index!==void 0){let e=n[2],r=`,turnReminder:typeof ${e}["turn-reminder"]==="string"?${e}["turn-reminder"]:typeof ${e}.turnReminder==="string"?${e}.turnReminder:typeof ${e}.turnreminder==="string"?${e}.turnreminder:void 0`,i=n.index+n[0].length;t=t.slice(0,i-1)+r+t.slice(i-1)}else t.includes(`turnReminder:typeof`)||console.error(`patch: outputStyleTurnReminder: custom-style loader shape not found; frontmatter turn-reminder will not thread (fallback reminder still applies)`);let r=t.match(/([$\w]+)\[([$\w]+)\.name\]=\{name:\2\.name,description:\2\.description,prompt:\2\.prompt,source:\2\.source,keepCodingInstructions:\2\.keepCodingInstructions,forceForPlugin:\2\.forceForPlugin\}/);if(r&&r.index!==void 0){let e=r[2],n=r.index+r[0].length;t=t.slice(0,n-1)+`,turnReminder:${e}.turnReminder`+t.slice(n-1)}else /forceForPlugin:[$\w]+\.forceForPlugin,turnReminder:/.test(t)||console.error(`patch: outputStyleTurnReminder: style-table merge shape not found; frontmatter turn-reminder will not thread (fallback reminder still applies)`);return t},Kc=e=>{let t=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\?\?"([^"]*)"\}`,isMeta:!0\}\)\]\)\}/);if(!t||t.index===void 0)return/\.style\}\.name\?\?|outputStyleName_tweakcc/.test(e)?(console.log(`patch: outputStyleTurnReminder: renderer already patched — threading only`),Gc(e)):/output_style:\(([$\w]+)\)=>\{if\(typeof \1\.style!=="string"/.test(e)?(console.log(`patch: outputStyleTurnReminder: renderer promoted in this CC build — threading only`),Gc(e)):(console.error(`patch: outputStyleTurnReminder: failed to find the output-style reminder renderer`),null);let[,n,r,i,a,o]=t,s=`output_style:(${n})=>{let ${r}=${i}[${n}.style];let outputStyleName_tweakcc=${r}?.name??${n}.style;if(!outputStyleName_tweakcc)return[];return ${a}([${o}({content:\`\${outputStyleName_tweakcc} output style is active. \${${n}.turnReminder??"Write this reply the way that style describes, including its rules on what to leave out."}\`,isMeta:!0})])}`,c=e.slice(0,t.index)+s+e.slice(t.index+t[0].length);return V(e,c,s,t.index,t.index+s.length),Gc(c)},qc={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},Jc=(e,t)=>{if(t===`default`)return e;let n=qc[t],r=e.match(/function ([$\w]+)\(\)\{(?:(?!function )[\s\S])*?modelByMainModel(?:(?!function )[\s\S])*?return\{value:[^{}]*,src:"default"\}\}/);if(r&&r.index!==void 0){let t=r[1],i=`function ${t}(){return{value:"${n}",src:"default"}}`,a=r.index,o=a+r[0].length,s=e.slice(0,a)+i+e.slice(o);return J(`patch: autoModeClassifierModel: matched modelByMainModel resolver ${t} -> ${n}`),V(e,s,i,a,o),s}let i=/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*\}/,a=/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*\}/,o=/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*\}/,s=/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*\}/,c=/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*\}/,l=/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*\}/,u=/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*\{\s*value\s*:\s*\6\s*,\s*src\s*:\s*"gb"\s*\}\s*\}\s*let\s+([$\w]+)\s*=\s*\4\s*\[\s*\5\s*\]\s*;\s*if\s*\(\s*\7\s*\)\s*return\s*\{\s*value\s*:\s*\7\s*,\s*src\s*:\s*"gb"\s*\}\s*\}\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s*\{\s*value\s*:\s*\3\s*\.\s*model\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*;\s*return\s*\{\s*value\s*:\s*\2\s*,\s*src\s*:\s*"default"\s*\}\s*\}/,d=/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*[$\w]+\s*\(\s*\3\s*\?\.\s*modelByMainModel\s*\)\s*;\s*if\s*\(\s*\4\s*\)\s*return\s*\{\s*value\s*:\s*\4\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s*\{\s*value\s*:\s*\3\s*\.\s*model\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*\(\s*\2\s*\)\s*\|\|\s*[$\w]+\s*\(\s*\2\s*\)\s*\)\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*;\s*return\s*\{\s*value\s*:\s*\2\s*,\s*src\s*:\s*"default"\s*\}\s*\}/,f=/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*[$\w]+\s*\(\s*\3\s*\?\.\s*modelByMainModel\s*\)\s*;\s*if\s*\(\s*\4\s*\)\s*return\s*\{\s*value\s*:\s*\4\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*\3\s*\?\.\s*model\s*\)\s*return\s*\{\s*value\s*:\s*\3\s*\.\s*model\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*!==\s*"demoted"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*;\s*if\s*\(\s*\5\s*\)\s*return\s*\{\s*value\s*:\s*\5\s*,\s*src\s*:\s*"default"\s*,\s*externalDefault\s*:\s*!0\s*\}\s*\}\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*\}/,p=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*[$\w]+\s*\(\s*\3\s*\?\.\s*modelByMainModel\s*,\s*\{\s*vet\s*:\s*\(\s*([$\w]+)\s*\)\s*=>\s*[$\w]+\s*\(\s*\5\s*,\s*"modelByMainModel"\s*\)\s*\}\s*\)\s*\?\?\s*[$\w]+\s*\(\s*\3\s*\?\.\s*model\s*,\s*"model"\s*\)\s*;\s*if\s*\(\s*\4\s*\)\s*return\s*\{\s*value\s*:\s*\4\s*,\s*src\s*:\s*"gb"\s*\}\s*;\s*if\s*\(\s*[$\w]+\s*!==\s*"demoted"\s*\)\s*\{\s*let\s+([$\w]+)\s*=\s*[$\w]+\s*\(\s*\2\s*\)\s*;\s*if\s*\(\s*\6\s*\)\s*return\s*\{\s*value\s*:\s*\6\s*,\s*src\s*:\s*"default"\s*,\s*externalDefault\s*:\s*!0\s*\}\s*\}\s*return\s*\{\s*value\s*:\s*[$\w]+\s*\(\s*\2\s*\)\s*,\s*src\s*:\s*"default"\s*\}\s*\}/);if(p&&p.index!==void 0){let[t,r]=p,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,p.index)+i+e.slice(p.index+t.length);return V(e,a,i,p.index,p.index+t.length),a}let m=e.match(f);if(m&&m.index!==void 0){let[t,r]=m,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,m.index)+i+e.slice(m.index+t.length);return V(e,a,i,m.index,m.index+t.length),a}let h=e.match(d);if(h&&h.index!==void 0){let[t,r]=h,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,h.index)+i+e.slice(h.index+t.length);return V(e,a,i,h.index,h.index+t.length),a}let g=e.match(u);if(g&&g.index!==void 0){let[t,r]=g,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,g.index)+i+e.slice(g.index+t.length);return V(e,a,i,g.index,g.index+t.length),a}let _=e.match(l)||e.match(c)||e.match(s)||e.match(o)||e.match(a)||e.match(i);if(_&&_.index!==void 0){let[t,r]=_,i=`function ${r}(){return "${n}"}`,a=e.slice(0,_.index)+i+e.slice(_.index+t.length);return V(e,a,i,_.index,_.index+t.length),a}return/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*\}/.test(e)||/function\s+[$\w]+\s*\(\s*\)\s*\{\s*return\s*\{\s*value\s*:\s*"claude-(opus|sonnet|haiku)-[0-9a-z-]+"\s*,\s*src\s*:\s*"default"\s*\}\s*\}/.test(e)?(J(`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):(J(`patch: autoModeClassifierModel: tengu_auto_mode_config not present in this CC build — no-op`),e)},Yc=`/*@@TWEAKCC_MODULE:`,Xc=e=>e.includes(Yc);function Zc(e,t){if(!Xc(e))return{file:e,helpers:t};let n=[],r=(t,r,i)=>{if(r===void 0)return null;let a=e.lastIndexOf(Yc,r),o=e.indexOf(`@@*/`,a);return a<0||o<0||e.slice(a+19,o).indexOf(`:`)<0?null:(n.push({at:r,text:`globalThis.${i}=${t};`}),`globalThis.${i}`)},i=r(t.gB,t.gBIndex,`__tweakccRouterHaiku`),a=r(t.km,t.kmIndex,`__tweakccRouterAgentContext`);if(!i||!a)return null;for(let t of n.sort((e,t)=>t.at-e.at))e=e.slice(0,t.at)+t.text+e.slice(t.at);return{file:e,helpers:{gB:i,km:a}}}const Qc=`tweakcc-fixed.typesafe`,$c=`api-key`,el=1500;function tl(e){return/^[\x21-\x7e]{1,1024}$/.test(e)}function nl(e,t){if(process.platform===`darwin`)return e===`write`?{executable:`/usr/bin/security`,args:[`-i`],input:`add-generic-password -U -s ${Qc} -a ${$c} -w "${t.replace(/[\\"]/g,`\\$&`)}"\n`}:{executable:`/usr/bin/security`,args:[e===`read`?`find-generic-password`:`delete-generic-password`,`-s`,Qc,`-a`,$c,...e===`read`?[`-w`]:[]]};if(process.platform===`linux`)return{executable:`secret-tool`,args:[e===`read`?`lookup`:e===`write`?`store`:`clear`,...e===`write`?[`--label=tweakcc TypeSafe API key`]:[],`service`,Qc,`account`,$c],...e===`write`?{input:t}:{}};throw Error(`Native credential storage is unavailable on this platform. Supply TYPESAFE_API_KEY through your environment or secret manager.`)}function rl(e,t){return new Promise((n,r)=>{let i=_(e.executable,e.args,{encoding:`utf8`,timeout:t,killSignal:`SIGKILL`,maxBuffer:8192,windowsHide:!0},(e,t)=>{e?r(Error(`Could not access the OS credential store. Unlock your keychain, or install secret-tool and unlock Secret Service on Linux. Headless systems can supply TYPESAFE_API_KEY through a secret manager.`)):n(t.trim())});i.stdin?.on(`error`,()=>{}),i.stdin?.end(e.input)})}async function il(e){if(!tl(e))throw Error(`The API key must contain 1–1024 printable ASCII characters without spaces.`);if(await rl(nl(`write`,e),15e3),await rl(nl(`read`),15e3)!==e)throw Error(`The OS credential store did not retain the API key. Unlock your keychain and try again, or supply TYPESAFE_API_KEY through a secret manager.`)}async function al(){await rl(nl(`delete`),15e3)}async function ol(){let e=process.env.TYPESAFE_API_KEY;if(e)return tl(e);try{return tl(await rl(nl(`read`),el))}catch{return!1}}function sl(e){return`async function __tweakccRouterApiKey(){
|
|
813
813
|
const valid=k=>typeof k==="string"&&/^[\\x21-\\x7e]{1,1024}$/.test(k);
|
|
814
814
|
const env=process.env.TYPESAFE_API_KEY;
|
|
815
815
|
if(env)return valid(env)?env:null;
|
|
@@ -1065,7 +1065,7 @@ globalThis.__tweakccRouterState=__tweakccRouterState;
|
|
|
1065
1065
|
globalThis.__tweakccRouterClassify=__tweakccRouterClassify;
|
|
1066
1066
|
globalThis.__tweakccRouterObserve=__tweakccRouterObserve;
|
|
1067
1067
|
globalThis.__tweakccRouterInvalidate=__tweakccRouterInvalidate;
|
|
1068
|
-
`)},ll=e=>{if(e.includes(`function __tweakccRouterMessageKey(`)||!e.includes(`subtype:"turn_duration"`))return e;let t=e.match(/function ([$\w]+)\(([$\w]+)
|
|
1068
|
+
`)},ll=e=>{if(e.includes(`function __tweakccRouterMessageKey(`)||!e.includes(`subtype:"turn_duration"`))return e;let t=e.match(/function ([$\w]+)\(([$\w]+)((?:,[$\w]+){3,4})\)\{return\{type:"system",subtype:"turn_duration",durationMs:\2,/),n=e.match(/([$\w]+)\(\(\)=>(([$\w]+)\(([$\w]+),([$\w]+)\.effortValue,\{turnEffort:\5\.turnEffort,hookEffortValue:\5\.hookEffortValue(?:,carriedEffort:(?!null\})[$\w]+)?\}\))\)/),r=e.match(/children:`\$\{([$\w]+)\} for \$\{([$\w]+)\}\$\{([$\w]+)\?` \\xB7 done \$\{\3\}`:""\}`/);if(!t||!n||!r)return console.error(`patch: complexityRouter: failed to find turn status anchors`),null;let i=[...e.slice(0,n.index).matchAll(/function\*[$\w]+\(([$\w]+),[$\w]+,[$\w]+,[$\w]+,[$\w]+,(?:([$\w]+)|\{(?:[$\w]+:[$\w]+,)*\.\.\.([$\w]+)\})\)\{/g)].at(-1),a=i?i[2]??i[3]:void 0,o=[...e.slice(Math.max(0,r.index-7e3),r.index).matchAll(/\{message:([$\w]+),addMargin:[$\w]+,verb:[$\w]+\}/g)].at(-1)?.[1],s=e=>e.replace(/\$/g,`\\$`),c=!!i&&!!a&&(a===n[5]||RegExp(`[,{]${s(n[5])}=[$\\w]+===${s(a)}\\.fallbackModel\\?${s(a)}:\\{\\.\\.\\.${s(a)},`).test(e.slice(i.index,n.index)));if(!i||!c||!o)return console.error(`patch: complexityRouter: failed to find turn status scopes`),null;let l=t[3].split(`,`).length===5?`([$\\w]+),`:`()`,u=[...e.matchAll(RegExp(`(?<![$\\w.])${t[1].replace(/\$/g,`\\$`)}\\(([$\\w]+(?:\\.durationMs)?),${l}([$\\w]+)\\(((?:[$\\w]+(?:\\([^()]*\\))?)(?:\\.[$\\w]+(?:\\([^()]*\\))?)*),([$\\w]+)\\)(,[$\\w]+\\.pendingBackgroundAgentCount,[$\\w]+\\.pendingWorkflowCount)?\\)`,`g`))];if(u.length===0)return console.error(`patch: complexityRouter: failed to find turn status emission`),null;let d=[{index:t.index,old:t[0],replacement:`
|
|
1069
1069
|
function __tweakccRouterMessageKey(messages){
|
|
1070
1070
|
if(!Array.isArray(messages))return;
|
|
1071
1071
|
for(var i=messages.length-1;i>=0;i--){var m=messages[i],c=m?.message?.content??m?.content;if(m?.type!=="user"||m.isMeta||typeof m.uuid!=="string")continue;if(typeof c==="string"||Array.isArray(c)&&c.some(p=>p?.type==="text"||p?.type==="image")&&!c.some(p=>p?.type==="tool_result"))return m.uuid}
|
|
@@ -1083,7 +1083,7 @@ globalThis.__tweakccRouterRecordTurn=function(messages,options,effort,resolution
|
|
|
1083
1083
|
globalThis.__tweakccRouterSnapshotTurn=function(messages){
|
|
1084
1084
|
var snapshot=__tweakccRouterTurnHistory.get(__tweakccRouterMessageKey(messages));return snapshot?{...snapshot}:void 0;
|
|
1085
1085
|
};
|
|
1086
|
-
`+t[0].replace(`){return{`,`,__tweakccRouterSnapshot){return{...(__tweakccRouterSnapshot?{tweakccRouter:__tweakccRouterSnapshot}:{}),`)},{index:n.index,old:n[0],replacement:`${n[1]}(()=>{globalThis.__tweakccRouterResolution=void 0;let __tweakccResolved=${n[2].slice(0,-1)},${n[5]});globalThis.__tweakccRouterRecordTurn?.(${i[1]},${n[5]},__tweakccResolved,globalThis.__tweakccRouterResolution);return __tweakccResolved})`},{index:r.index,old:r[0],replacement:r[0].slice(0,-1)+`\${${o}.tweakccRouter?.effort?" \\xB7 Router \\u2192 "+${o}.tweakccRouter.effort+(${o}.tweakccRouter.source==="fallback"?" (fallback)":${o}.tweakccRouter.source==="pinned"?" (pinned)":${o}.tweakccRouter.source==="omitted"?" (incomplete input)":typeof ${o}.tweakccRouter.confidence==="number"&&Number.isFinite(${o}.tweakccRouter.confidence)&&${o}.tweakccRouter.confidence>=0&&${o}.tweakccRouter.confidence<=1?" (confidence "+Math.round(${o}.tweakccRouter.confidence*100)+"%)":""):""}\``},...
|
|
1086
|
+
`+t[0].replace(`){return{`,`,__tweakccRouterSnapshot){return{...(__tweakccRouterSnapshot?{tweakccRouter:__tweakccRouterSnapshot}:{}),`)},{index:n.index,old:n[0],replacement:`${n[1]}(()=>{globalThis.__tweakccRouterResolution=void 0;let __tweakccResolved=${n[2].slice(0,-1)},${n[5]});globalThis.__tweakccRouterRecordTurn?.(${i[1]},${n[5]},__tweakccResolved,globalThis.__tweakccRouterResolution);return __tweakccResolved})`},{index:r.index,old:r[0],replacement:r[0].slice(0,-1)+`\${${o}.tweakccRouter?.effort?" \\xB7 Router \\u2192 "+${o}.tweakccRouter.effort+(${o}.tweakccRouter.source==="fallback"?" (fallback)":${o}.tweakccRouter.source==="pinned"?" (pinned)":${o}.tweakccRouter.source==="omitted"?" (incomplete input)":typeof ${o}.tweakccRouter.confidence==="number"&&Number.isFinite(${o}.tweakccRouter.confidence)&&${o}.tweakccRouter.confidence>=0&&${o}.tweakccRouter.confidence<=1?" (confidence "+Math.round(${o}.tweakccRouter.confidence*100)+"%)":""):""}\``},...u.map(e=>({index:e.index,old:e[0],replacement:e[0].slice(0,-1)+`${e[6]?``:`,void 0,void 0`},globalThis.__tweakccRouterSnapshotTurn?.(${e[4]}))`}))].sort((e,t)=>t.index-e.index),f=e;for(let e of d){let t=f.slice(0,e.index)+e.replacement+f.slice(e.index+e.old.length);V(f,t,e.replacement,e.index,e.index+e.old.length),f=t}return f},ul=`__tweakccRouterClassify`,dl=1e3,fl=(e,t,n,r)=>{let i=e.levels.map(e=>e.effort),a=JSON.stringify(i),o=e.pinPerTask?`true`:`false`,s=e.messageCap||1e5,c=e.assistantCap||1e5,l=e.timeoutMs||15e3,u=n?`${n}()`:`null`,d=i.length-1,f=e.levels.map((e,t)=>`Level ${t} (${e.label}): ${e.help}`).join(`
|
|
1087
1087
|
`),p=(typeof e.systemPrompt==`string`&&e.systemPrompt.trim()?e.systemPrompt:te).replace(/\{LEVELS\}/g,f).replace(/\{MAX\}/g,String(d)),m=X(JSON.stringify(p)),h=X(JSON.stringify(e.levels.map(e=>e.label)));return`function __tweakccRouterState(){return globalThis.__tweakccRouter||(globalThis.__tweakccRouter={level:void 0,effort:void 0,baseline:void 0,summary:void 0,prevUser:void 0,prevAssistant:void 0,pendingCompaction:void 0,pendingRewindCut:void 0,log:void 0,model:void 0,loaded:!1})}function __tweakccRouterSyncSelection(){var selected=null;try{selected=globalThis.__tweakccRouterSelectedModel?.()||null}catch(e){}var s=__tweakccRouterState();if(s.selectedModel!==selected){if(s.selectedModel!==void 0){s.generation=(s.generation||0)+1;s.routeAbort?.abort();s.level=void 0;s.effort=void 0;s.baseline=void 0;s.prevUser=void 0;s.prevAssistant=void 0;}s.selectedModel=selected;}return selected}globalThis.__tweakccRouterSyncSelection=__tweakccRouterSyncSelection;function __tweakccRouterTrunc(__s,__cap){if(typeof __s!=="string")return"";if(__s.length<=__cap)return __s;var __mk="\\n...["+(__s.length-__cap)+" chars omitted from the middle]...\\n";var __b=__cap-__mk.length;if(__b<0)__b=0;var __h=Math.floor(__b/2);return __s.slice(0,__h)+__mk+__s.slice(__s.length-(__b-__h))}function __tweakccRouterSid(){try{var __s=${u};return typeof __s==="string"&&__s?__s:null}catch(__e){return null}}function __tweakccRouterDir(){var __p=${r}("path"),__o=${r}("os");return __p.join(__o.homedir(),".tweakcc","router-state")}function __tweakccRouterFile(__sid){return ${r}("path").join(__tweakccRouterDir(),__sid+".json")}function __tweakccRouterLoad(__st){if(__st.loaded)return;__st.loaded=!0;try{var __sid=__tweakccRouterSid();if(!__sid)return;var __fs=${r}("fs"),__f=__tweakccRouterFile(__sid);if(__fs.existsSync(__f)){var __d=JSON.parse(__fs.readFileSync(__f,"utf8"));if(__d){if(typeof __d.summary==="string")__st.summary=__d.summary;if(Number.isInteger(__d.level))__st.level=__d.level;if(Array.isArray(__d.log))__st.log=__d.log}}__tweakccRouterPrune(__fs)}catch(__e){}}function __tweakccRouterSave(__st){try{var __sid=__tweakccRouterSid();if(!__sid)return;var __fs=${r}("fs"),__dir=__tweakccRouterDir(),__j=JSON.stringify({summary:__st.summary,level:__st.level,log:Array.isArray(__st.log)?__st.log:[],updatedAt:Date.now()});__fs.mkdir(__dir,{recursive:!0},function(){try{__fs.writeFile(__tweakccRouterFile(__sid),__j,function(){})}catch(__e){}})}catch(__e){}}function __tweakccRouterDrop(__st){try{var __sid=__tweakccRouterSid();if(!__sid)return;var __fs=${r}("fs"),__f=__tweakccRouterFile(__sid);if(__fs.existsSync(__f))__fs.unlinkSync(__f)}catch(__e){}}function __tweakccRouterPrune(__fs){try{var __dir=__tweakccRouterDir(),__ns=__fs.readdirSync(__dir),__now=Date.now(),__ttl=12096e5;for(var __i=0;__i<__ns.length;__i++){try{var __ff=${r}("path").join(__dir,__ns[__i]);if(__now-__fs.statSync(__ff).mtimeMs>__ttl)__fs.unlinkSync(__ff)}catch(__e){}}}catch(__e){}}function __tweakccRouterReadResult(__r){try{if(__r==null)return null;if(typeof __r==="object"&&typeof __r.level==="number")return{level:__r.level,summary:typeof __r.summary==="string"?__r.summary:void 0};var __x;if(typeof __r==="string")__x=__r;else{var __c=(__r.message&&__r.message.content)||__r.content;__x=(Array.isArray(__c)&&__c[0]&&typeof __c[0].text==="string")?__c[0].text:(typeof __r.text==="string"?__r.text:"")}if(!__x)return null;try{var __o=JSON.parse(__x);if(__o&&typeof __o.level==="number")return{level:__o.level,summary:typeof __o.summary==="string"?__o.summary:void 0}}catch(__e){}var __m=__x.match(/-?\\d+/);if(__m)return{level:parseInt(__m[0],10),summary:void 0};return null}catch(__e){return null}}async function __tweakccRouterClassifyLlm(__input,__max){var __schema={type:"object",properties:{level:{type:"integer",description:"effort level, 0 (least) to "+__max+" (most)"},summary:{type:"string",description:"the updated running TL;DR summary"}},required:["level","summary"],additionalProperties:false};var __sys=${m};var __ac=new AbortController();__tweakccRouterState().routeAbort=__ac;var __to=setTimeout(function(){try{__ac.abort()}catch(__e){}},${l});try{var __res=await ${t.gB}({systemPrompt:[__sys],userPrompt:__input,outputFormat:{type:"json_schema",schema:__schema},signal:__ac.signal,options:{querySource:"route_complexity",agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],agentContext:${t.km}()}});return __tweakccRouterReadResult(__res)}finally{clearTimeout(__to)}}async function ${ul}(__text,__mode,__model){try{var __selected=__tweakccRouterSyncSelection();if(!__selected)return;var __ef=${a},__pin=${o},__max=__ef.length-1,__labels=${h};if(!__ef||!__ef.length)return;var __st=__tweakccRouterState();if(typeof __text!=="string")return;var __tr=__text.replace(/^\\s+/,"");if(/^\\/clear(\\s|$)/.test(__tr)){__st.level=void 0;__st.effort=void 0;__st.baseline=void 0;__st.summary=void 0;__st.prevUser=void 0;__st.prevAssistant=void 0;__st.pendingCompaction=void 0;__st.pendingRewindCut=void 0;__st.log=void 0;__st.model=void 0;__tweakccRouterDrop(__st);return}if(__tr.charAt(0)==="/")return;if(__mode!==void 0&&__mode!=="prompt")return;__tweakccRouterLoad(__st);if(__st.pendingRewindCut!=null){var __rt=__st.pendingRewindCut;__st.pendingRewindCut=void 0;var __rms=typeof __rt==="number"?__rt:Date.parse(__rt),__ci=-1;if(__rms===__rms&&Array.isArray(__st.log))for(var __i=__st.log.length-1;__i>=0;__i--){if(__st.log[__i]&&__st.log[__i].ts<=__rms){__ci=__i;break}}if(__ci>=0){var __pe=__st.log[__ci];__st.summary=__pe.summary;__st.level=__pe.level;__st.log=__st.log.slice(0,__ci)}else{__st.summary=void 0;__st.level=void 0}__st.prevUser=void 0;__st.prevAssistant=void 0;__st.pendingCompaction=void 0;if(process.env.TWEAKCC_ROUTER_DEBUG)try{process.stderr.write("[tweakcc-router] rewind cut to "+__rt+" ("+(__ci>=0?"restored":"reset")+")\\n")}catch(__e){}}if(typeof __st.pendingCompaction==="string"){__st.summary=__st.pendingCompaction;__st.prevUser=void 0;__st.prevAssistant=void 0;__st.level=void 0;__st.pendingCompaction=void 0}if(!Array.isArray(__st.log))__st.log=[];__st.log.push({ts:Date.now(),summary:typeof __st.summary==="string"?__st.summary:"",level:__st.level});if(__st.log.length>${dl})__st.log.splice(0,__st.log.length-${dl});var __plv=__st.level,__pmod=__st.model;var __mch=__pmod&&__model&&__pmod!==__model;var __ctx="model in use: "+(__model||"unknown")+(__mch?" (switched from "+__pmod+" this turn)":"")+"\\nlevel you assigned last turn: "+(__plv!==void 0?__plv+" ("+(__labels[__plv]||"?")+")":"none yet - this is the first routed turn");var __nm=__tweakccRouterTrunc(__text,${s});var __pu=__tweakccRouterTrunc(__st.prevUser,${s});var __pa=__tweakccRouterTrunc(typeof __st.prevAssistant==="string"?__st.prevAssistant:"",${c});var __input="<summary>\\n"+(__st.summary||"(none - first turn of the session)")+"\\n</summary>\\n<context>\\n"+__ctx+"\\n</context>\\n<recent_exchange>\\nuser: "+(__pu||"(none)")+"\\nassistant: "+(__pa||"(none)")+"\\n</recent_exchange>\\n<new_message>\\n"+__nm+"\\n</new_message>";var __generation=__st.generation,__res=null;try{__res=await __tweakccRouterClassifyLlm(__input,__max)}catch(__e){__res=null}if(__tweakccRouterSyncSelection()!==__selected||__st.generation!==__generation)return;__st.routeAbort=null;var __hi=__ef.indexOf("high");if(__hi<0)__hi=Math.min(2,__max);var __lv,__sm=__st.summary;if(__res&&typeof __res.summary==="string"&&__res.summary)__sm=__res.summary;if(__res&&Number.isInteger(__res.level))__lv=__res.level;else __lv=(__st.level!==void 0?__st.level:__hi);if(__pin&&__st.level!==void 0&&__lv<__st.level)__lv=__st.level;if(__lv<0)__lv=0;if(__lv>__max)__lv=__max;__st.level=__lv;__st.effort=__ef[__lv];__st.summary=__sm;__st.prevUser=__text;__st.model=__model;__tweakccRouterSave(__st);if(process.env.TWEAKCC_ROUTER_DEBUG)try{process.stderr.write("[tweakcc-router] level="+__lv+" effort="+__st.effort+" chars="+__text.length+"\\n")}catch(__e){}}catch(__e){}}`},pl=(e,t,n,r)=>{let i=/(function [$\w]+\(([$\w]+),([$\w]+),\{honorLaunchPin:[$\w]+=!0\}=\{\}\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+&&[$\w]+\(\2\),[$\w]+=[$\w]+\(\2\),([$\w]+)=[$\w]+\(\);)if\(\4===null&&![$\w]+\)return;return ([$\w]+)\(\4\?\?\([$\w]+\?[$\w]+:void 0\)\?\?\3\?\?[$\w]+,\2\)\}/,a=/(function [$\w]+\(([$\w]+),([$\w]+)\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+\(\2\),[$\w]+=[$\w]+\(\2\),([$\w]+)=[$\w]+\(\);)if\(\4===null&&![$\w]+\)return;return ([$\w]+)\(\4\?\?\([$\w]+\?[$\w]+:void 0\)\?\?\3\?\?[$\w]+,\2\)\}/,o=/(function [$\w]+\(([$\w]+),([$\w]+)\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+\(\2\),[$\w]+=[$\w]+\(\2\),([$\w]+)=[$\w]+\(\);)if\(\4===null&&![$\w]+\)return;let ([$\w]+)=\4\?\?\([$\w]+\?[$\w]+:void 0\)\?\?\3\?\?[$\w]+;(?:if\(typeof \5==="string"&&[$\w]+\(\5\)\)\5=[$\w]+\(\5,\2\);)?if\(\5==="max"&&!([$\w]+)\(\2\)\)\5="high";if\(\5==="xhigh"&&!([$\w]+)\(\2\)\)\5="high";return \5\}/,s=/(function [$\w]+\(([$\w]+),([$\w]+)\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+\(\2\),[$\w]+=[$\w]+\(\2\),([$\w]+)=[$\w]+\(\);)if\(\4===null\)return [$\w]+\?[$\w]+:void 0;let ([$\w]+)=\4\?\?\([$\w]+\?[$\w]+:void 0\)\?\?\3\?\?[$\w]+;if\(\5==="max"&&!([$\w]+)\(\2\)\)return"high";if\(\5==="xhigh"&&!([$\w]+)\(\2\)\)return"high";return \5\}/,c=e.match(/(function [$\w]+\(([$\w]+),([$\w]+),\{turnEffort:([$\w]+),hookEffortValue:[$\w]+,carriedEffort:[$\w]+=[$\w]+\(\2\)\}=\{\}\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+\(\2\)!==null;if\([$\w]+!==void 0\)\{let [$\w]+=typeof [$\w]+==="number"&&[$\w]+\?[$\w]+\([$\w]+\):[$\w]+;return [$\w]+\([$\w]+,\2\)\}let ([$\w]+)=[$\w]+\(\);)if\(\5===null&&![$\w]+\)return;let [$\w]+=[$\w]+\(\2,[$\w]+\),([$\w]+)=\5\?\?\(\5===null\?[$\w]+:void 0\)\?\?\4\?\?\3\?\?[$\w]+;if\(typeof \6==="number"&&[$\w]+\)\6=[$\w]+\(\6\);return ([$\w]+)\(\6,\2\)\}/)||e.match(/(function [$\w]+\(([$\w]+),([$\w]+),\{turnEffort:([$\w]+),hookEffortValue:[$\w]+\}=\{\}\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+\(\2\)!==null;if\([$\w]+!==void 0\)\{let [$\w]+=typeof [$\w]+==="number"&&[$\w]+\?[$\w]+\([$\w]+\):[$\w]+;return [$\w]+\([$\w]+,\2\)\}let ([$\w]+)=[$\w]+\(\);)if\(\5===null&&![$\w]+\)return;let [$\w]+=[$\w]+\(\2\),([$\w]+)=\5\?\?\(\5===null\?[$\w]+:void 0\)\?\?\4\?\?\3\?\?[$\w]+;if\(typeof \6==="number"&&[$\w]+\)\6=[$\w]+\(\6\);return ([$\w]+)\(\6,\2\)\}/)||e.match(/(function [$\w]+\(([$\w]+),([$\w]+),\{honorLaunchPin:[$\w]+=!0,turnEffort:([$\w]+),hookEffortValue:[$\w]+\}=\{\}\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+\(\2\)!==null;if\([$\w]+!==void 0\)\{let [$\w]+=typeof [$\w]+==="number"&&[$\w]+\?[$\w]+\([$\w]+\):[$\w]+;return [$\w]+\([$\w]+,\2\)\}let [$\w]+=[$\w]+&&[$\w]+\(\2\),[$\w]+=[$\w]+\(\2\),([$\w]+)=[$\w]+\(\);)if\(\5===null&&![$\w]+&&![$\w]+\)return;let ([$\w]+)=\5\?\?\(\5===null\?[$\w]+:void 0\)\?\?\4\?\?\([$\w]+\?[$\w]+:void 0\)\?\?\3\?\?[$\w]+;if\(typeof \6==="number"&&[$\w]+\)\6=[$\w]+\(\6\);return ([$\w]+)\(\6,\2\)\}/)||e.match(/(function [$\w]+\(([$\w]+),([$\w]+),\{honorLaunchPin:[$\w]+=!0,turnEffort:([$\w]+)\}=\{\}\)\{if\(![$\w]+\(\2\)\)return;let [$\w]+=[$\w]+&&[$\w]+\(\2\),[$\w]+=[$\w]+\(\2\),([$\w]+)=[$\w]+\(\),[$\w]+=[$\w]+\(\2\)!==null;)if\(\5===null&&![$\w]+&&![$\w]+\)return;let ([$\w]+)=\5\?\?\(\5===null\?[$\w]+:void 0\)\?\?\4\?\?\([$\w]+\?[$\w]+:void 0\)\?\?\3\?\?[$\w]+;if\(typeof \6==="number"&&[$\w]+\)\6=[$\w]+\(\6\);return ([$\w]+)\(\6,\2\)\}/),l=c?null:e.match(i)||e.match(a),u=c||l||e.match(o)||e.match(s);if(!u||u.index===void 0)return e.includes(`CLAUDE_CODE_EFFORT_LEVEL`)?(console.error(`patch: complexityRouter: failed to find effort resolver (XQ shape)`),null):(J(`patch: complexityRouter: effort resolver absent in this CC build - no-op`),e);let d=u[1],f=u[2],p=u[3],m=c?c[4]:null,h=c?c[5]:u[4],g=u[6],_=u[7],v=c?c[7]:l?.[5];if(v){let t=v.replace(/[$]/g,`\\$`),n=RegExp(`function ${t}\\(([$\\w]+),([$\\w]+)\\)\\{let ([$\\w]+)=\\1;(?:if\\(typeof \\3==="string"&&[$\\w]+\\(\\3\\)\\)\\3=[$\\w]+\\(\\3,\\2\\);)?if\\(\\3==="max"&&!([$\\w]+)\\(\\2\\)\\)\\3="high";if\\(\\3==="xhigh"&&!([$\\w]+)\\(\\2\\)\\)\\3="high";return \\3\\}`),r=e.match(n);if(!r)return console.error(`patch: complexityRouter: failed to find effort normalizer (support guards)`),null;g=r[4],_=r[5]}let y=`var __request=arguments[3];if(!__request||(!__request.agentId&&(__request.querySource?.startsWith("repl_main_thread")||__request.querySource==="sdk"))){var __selected=__tweakccRouterSyncSelection();var __st=__tweakccRouterState();if(__selected===${f}&&__st.baseline===void 0)__st.baseline=(${p}==null?null:${p});let __twkRE=__selected===${f}?__st.effort:void 0;if(__twkRE&&${h}==null${m?`&&${m}==null`:``}&&(${p}==null||${p}===__st.baseline)){if(__twkRE==="max"&&!${g}(${f}))__twkRE="high";if(__twkRE==="xhigh"&&!${_}(${f}))__twkRE="high";globalThis.__tweakccRouterResolution={effort:__twkRE};return __twkRE}}`,b=(t.provider===`jev`?cl:fl)(t,n,r,Xc(e)?`process.getBuiltinModule`:Zu(e));Xc(e)&&t.provider!==`jev`&&(b+=`globalThis.__tweakccRouterState=__tweakccRouterState;globalThis.__tweakccRouterClassify=__tweakccRouterClassify;`);let x=b+d+y+u[0].slice(d.length),S=u.index,C=S+u[0].length,w=e.slice(0,S)+x+e.slice(C);return V(e,w,x,S,C),w},ml=(e,t)=>{let n=e.match(/if\(([$\w]+)===null&&([$\w]+)!=="prompt"\)throw Error\(`Mode: \$\{\2\} requires a string input\.`\);/);if(!n||n.index===void 0)return e.includes(`requires a string input.`)?(console.error(`patch: complexityRouter: failed to find submit handler throw-guard`),null):(J(`patch: complexityRouter: submit handler absent in this CC build - no-op`),e);let r=n[1],i=n[2],a=[...e.slice(Math.max(0,n.index-4e3),n.index).matchAll(/([$\w]+)\.options\.mainLoopModel/g)],o=a[a.length-1],s=o?`${o[1]}.options.mainLoopModel`:`void 0`,c=o?`${o[1]}.messages`:`void 0`,l=o?`${o[1]}.session?.id`:`void 0`,u=`await ${Xc(e)?`globalThis.${ul}`:ul}(${`${r},${i},${s}${t?`,${c},${l}`:``}`});`,d=t?`try{${o?`if(!${o[1]}.agentId)`:``}{${o?`${o[1]}.__tweakccRouterTurn=`:``}${u}}}catch(__tweakccRouterError){}`:u,f=n.index+n[0].length,p=e.slice(0,f)+d+e.slice(f);return V(e,p,d,f,f),p},hl=e=>{if(e.includes(`function __tweakccRouterObserve(`)){let t=e.match(/let [$\w]+;if\(([$\w]+)\.gates\.emitToolUseSummaries&&[$\w]+\.length>0&&!([$\w]+)\.abortController\.signal\.aborted&&!\2\.agentId\)\{let [$\w]+=([$\w]+)\.at\(-1\)/);if(t?.index!==void 0){let n=e.slice(t.index,t.index+2e3).match(/([$\w]+)\.find\(\([$\w]+\)=>[$\w]+\.type==="user"&&Array\.isArray/),r=Xc(e)?`globalThis.__tweakccRouterObserve`:`__tweakccRouterObserve`,i=`try{if(!${t[2]}.agentId)${r}(${t[3]}${n?`.concat(${n[1]})`:``},${t[2]}.session?.id,${t[2]}.__tweakccRouterTurn);}catch(__tweakccRouterError){}`;return e.slice(0,t.index)+i+e.slice(t.index)}return J(`patch: complexityRouter: round capture absent - transcript refresh occurs at submit`),e}let t=e.match(/([$\w]+)=([$\w]+)\.at\(-1\),([$\w]+);if\(\1\)\{let ([$\w]+)=\1\.message\.content\.filter\(\(([$\w]+)\)=>\5\.type==="text"\);if\(\4\.length>0\)\{let ([$\w]+)=\4\.at\(-1\);if\(\6&&"text"in \6\)\3=\6\.text\}\}/);if(!t||t.index===void 0)return J(`patch: complexityRouter: prev-assistant capture site absent - router runs without prior-assistant context`),e;let n=`try{var __twr=globalThis.__tweakccRouter;if(__twr&&globalThis.__tweakccRouterSyncSelection?.())__twr.prevAssistant=${t[3]}}catch(__e){}`,r=t.index+t[0].length,i=e.slice(0,r)+n+e.slice(r);return V(e,i,n,r,r),i},gl=e=>{let t=e.match(/return\{ok:!0,summaryText:([$\w]+),/);if(!t||t.index===void 0)return J(`patch: complexityRouter: compaction summary site absent - no compaction reseed`),e;let n=t[1],r=`return globalThis.__tweakccRouter&&((typeof globalThis.__tweakccRouterInvalidate==="function"&&globalThis.__tweakccRouterInvalidate(globalThis.__tweakccRouter),globalThis.__tweakccRouter.pendingCompaction=${n})),{ok:!0,summaryText:${n},`,i=t.index,a=i+t[0].length,o=e.slice(0,i)+r+e.slice(a);return V(e,o,r,i,a),o},_l=e=>{let t=e.match(/onRestoreMessage:\(([$\w]+)\)=>([$\w]+(?:\.[$\w]+)?)\(\1,"message_selector"\)/);if(!t||t.index===void 0)return J(`patch: complexityRouter: restore-conversation site absent - no rewind cut`),e;let n=t[1],r=`onRestoreMessage:(${n})=>(globalThis.__tweakccRouter&&((typeof globalThis.__tweakccRouterInvalidate==="function"&&globalThis.__tweakccRouterInvalidate(globalThis.__tweakccRouter),globalThis.__tweakccRouter.pendingRewindCut=${n}&&${n}.timestamp)),${t[2]}(${n},"message_selector"))`,i=t.index,a=i+t[0].length,o=e.slice(0,i)+r+e.slice(a);return V(e,o,r,i,a),o},vl=e=>{let t=e.match(/function ([$\w]+)\(\)\{return\{agentType:"main",agentId:[$\w]+\(\)\}\}/);if(!t)return null;let n=e.match(/async function ([$\w]+)\(([$\w]+)\)\{(let ([$\w]+)=)([$\w]+\([$\w]+\(\)\)),[\s\S]{0,600}?return await [$\w]+\(\2,[$\w]+\[[$\w]+\],[$\w]+\[[$\w]+\+1\]\)/);if(n){let[e,r,i,a,,o]=n,s=`async function ${r}(${i}){${a}${o},`;return{gB:r,km:t[1],gBIndex:n.index,kmIndex:t.index,gBSource:e,gBOptions:`${i}.options`,gBPatched:`async function ${r}(${i}){${a}${i}.options.querySource==="route_complexity"?"claude-haiku-4-5":${o},`+e.slice(s.length)}}let r=e.match(/async function ([$\w]+)\(\{systemPrompt:[$\w]+=[$\w]+\(\[\]\),userPrompt:[$\w]+,outputFormat:[$\w]+,signal:[$\w]+,options:([$\w]+)\}\)\{return\(await [$\w]+\([\s\S]{0,500}?,model:[$\w]+\(\),enablePromptCaching:/);return r?{gB:r[1],km:t[1],gBIndex:r.index,kmIndex:t.index,gBSource:r[0],gBOptions:r[2],gBPatched:r[0].replace(/model:([$\w]+)\(\),enablePromptCaching:$/,`model:${r[2]}.querySource==="route_complexity"?"claude-haiku-4-5":$1(),enablePromptCaching:`)}:null},yl=e=>{let t=e.match(/getSessionId\(\)\{return ([$\w]+)\(\)\}/);return t?t[1]:null},bl=(e,t)=>{if(e.includes(ul))return J(`patch: complexityRouter: already patched - skipping`),e;let n=vl(e);if(!n)return console.warn(`patch: complexityRouter: gB/km side-call helpers not found in this CC build - cannot maintain routing context; skipping the router`),e;let r=yl(e);r||J(`patch: complexityRouter: session-id accessor not found - cross-session summary persistence disabled (in-memory only)`);let i=Zc(e,n);if(!i)return null;i.file=i.file.replace(n.gBSource,()=>n.gBPatched);let a=pl(i.file,t,i.helpers,r);if(a===null)return null;if(a===i.file)return e;let o=ml(a,t.provider===`jev`);if(o===null)return null;if(o===a)return J(`patch: complexityRouter: submit handler absent - reverting the resolver wrap too (all-or-nothing no-op)`),e;let s=hl(o);return ll(_l(t.provider===`jev`?s:gl(s)))},xl=[[`opusrouter`,`claude-opus-5-5`,`Opus 5.5 + Effort Router`],[`fablerouter`,`claude-fable-5-1`,`Fable 5.1 + Effort Router`]],Sl=e=>`(${e}==="opusrouter"||${e}==="fablerouter")`,Cl=(e,t,n,r)=>{let i=e.match(t);if(!i||i.index===void 0)return console.error(`patch: complexityRouterModels: failed to find ${r}`),null;let a=X(n(i)),o=e.slice(0,i.index)+a+e.slice(i.index+i[0].length);return V(e,o,a,i.index,i.index+i[0].length),o},wl=e=>{let t=Cl(e,/(=[$\w]+\(\(([$\w]+)\)=>\{let ([$\w]+)=[$\w]+\(\),([$\w]+)=[$\w]+\.find\(\(([$\w]+)\)=>\5\.value===\3\);if\(\4===void 0\|\|\4\.disabled===!0\)return;)/,e=>`${e[0]}if(${Sl(e[3])})return;`,`picker effort adjustment`);if(t===null)return null;let n=/(([$\w]+)!==void 0&&![$\w]+&&[$\w]+\([$\w]+,\{marginBottom:1,flexDirection:"column",children:)/,r=t.match(/([$\w]+)\(([$\w]+),\{color:"subtle",children:\[[$\w]+\([$\w]+,\{effort:void 0\}\)," Effort not supported"/);if(!r||(t=Cl(t,n,e=>`${e[0]}${Sl(e[2])}?${r[1]}(${r[2]},{color:"subtle",children:"Automatic effort"+(globalThis.__tweakccRouterState?.()?.effort?" · currently "+globalThis.__tweakccRouterState().effort:"")}):`,`picker effort display`),t===null))return null;let i=[/(function ([$\w]+)\(([$\w]+)\)\{)((?:if\(\3==="fableplan"\)\{[$\w]+\(\3,void 0\);return\})?let ([$\w]+)=[$\w]+\(\3\),(?:[$\w]+=[$\w]+\(\),)*[$\w]+=\5&&([$\w]+)!==void 0\?[$\w]+\(\6,\5\):\6;[$\w]+\("tengu_model_command_menu_effort")/,/(function ([$\w]+)\(([$\w]+)\)\{)((?:if\(\3==="fableplan"\)\{[$\w]+\(\3,void 0\);return\})?let ([$\w]+)=[$\w]+\(\3\),(?:[$\w]+=[$\w]+\(\),)*[$\w]+=\5&&([$\w]+)!==void 0&&\6!=="ultracode"\?[$\w]+\(\6,\5\):\6;[$\w]+\("tengu_model_command_menu_effort")/],a=i.find(e=>e.test(t))??i[i.length-1];return Cl(t,a,e=>{let n=t.slice(e.index+e[0].length).match(RegExp(`^(?:(?!function )[^])*?if\\(${e[3].replace(/\$/g,`\\$`)}===[$\\w]+\\)\\{([$\\w]+)\\(null,[$\\w]+\\);return\\}`));if(!n)throw Error(`Router picker apply call is missing`);return`${e[1]}if(${Sl(e[3])}){${n[1]}(${e[3]},void 0);return}${e[4]}`},`picker model commit`)},Tl=e=>{if(e.includes(`globalThis.__tweakccRouterSelectedModel=function(`))return e;if(!e.includes(`"claude-opus-5-5"`))return J(`patch: complexityRouterModels: verified models unavailable — no-op`),e;let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{let [$\w]+=\2\.trim\(\)[\s\S]{0,120}?if\([$\w]+\(([$\w]+)\)\)switch\(\3\)\{/);if(!t)return null;let n=xl.map(([e,t])=>`case"${e}":return"${t}";`).join(``),r=Cl(e,/(\[(?:"[\w[\]]+",)*"opusplan"(?:,"[\w[\]]+")*\])(\s*,\s*[$\w]+\s*=\s*\["sonnet","opus","haiku")/,e=>`${e[1].slice(0,-1)},"opusrouter","fablerouter"]${e[2]}`,`model alias whitelist`);if(r===null)return null;let i=r.indexOf(t[0]),a=r.replace(t[0],t[0]+n);if(V(r,a,t[0]+n,i,i+t[0].length),r=a,r=Cl(r,/(function [$\w]+\([$\w]+\)\{let [$\w]+=[$\w]+\(\);switch\([$\w]+\)\{case"opus":return [$\w]+\([$\w]+\);)/,e=>e[0]+n,`builtin model defaults`),r===null||(r=Cl(r,/function ([$\w]+)\(\)\{let ([$\w]+)=[$\w]+\(\);if\(\2!==void 0\)return [$\w]+\(\2,"explicit"\);return [$\w]+\(\)\}/,e=>`globalThis.__tweakccRouterSelectedModel=function(){let __tweakccSelected=${e[1]}();return __tweakccSelected==="opusrouter"?"claude-opus-5-5":__tweakccSelected==="fablerouter"?"claude-fable-5-1":null};${e[0]}`,`live selected model getter`),r===null))return null;for(let e of[`overrideMainLoopModel`,`replaceInitialMainLoopModel`])if(r=Cl(r,RegExp(`(${e}\\(([$\\w]+)\\)\\{this\\.#[$\\w]+=\\2)\\}`),e=>`${e[1]};queueMicrotask(()=>globalThis.__tweakccRouterSyncSelection?.())}`,`selected model setter`),r===null)return null;if(r=Cl(r,/function ([$\w]+)\(([$\w]+)=!1,([$\w]+)=null\)\{let ([$\w]+)=new Set,([$\w]+)=[$\w]+\(\2,\3\)\.filter\(\(([$\w]+)\)=>\{if\(\6\.value===null\)return!0;if\(\4\.has\(\6\.value\)\)/,e=>`function ${e[1]}(${e[2]}=!1,${e[3]}=null){let rows=__tweakccRouterBasePicker(${e[2]},${e[3]});let clean=rows.filter(row=>!${Sl(`row.value`)});for(let [alias,model,label] of ${JSON.stringify(xl)}){let index=clean.findIndex(row=>typeof row.value==="string"&&row.disabled!==!0&&${t[1]}(row.value)===model);if(index!==-1)clean.splice(index+1,0,{...clean[index],value:alias,label,description:"Automatic effort selected for each message"})}return clean}function __tweakccRouterBasePicker`+e[0].slice(`function ${e[1]}`.length),`filtered model picker`),r===null)return null;try{return wl(r)}catch{return console.error(`patch: complexityRouterModels: failed to find picker apply`),null}},W=`fableplan`,El=`globalThis.__tweakccFablePlanModelFor`,Dl=`__tweakccPermissionMode`,Ol=`/*@@TWEAKCC_MODULE:`,kl=(e,t)=>{let n=e.lastIndexOf(Ol,t);if(n===-1)return[0,e.length];let r=e.indexOf(Ol,n+1);return[n,r===-1?e.length:r]},Al=(e,t,n)=>{let[r,i]=kl(e,t),a=e.slice(r,i),o=q(n);return RegExp(`(?:^|[^$\\w.])function ${o}\\(`).test(a)?!0:RegExp(`import\\{(?:[^}]*,)?${o}(?:,[^}]*)?\\}from"`).test(a)},jl=e=>{let t=e.match(/(\[(?:"[\w[\]]+",)*"opusplan"(?:,"[\w[\]]+")*\])(\s*,\s*[$\w]+\s*=\s*\["sonnet","opus","haiku")/);if(t&&t[1].includes(`"${W}"`))return J(`patch: fablePlan: alias already in the whitelist — skipping`),e;if(!t||t.index===void 0)return console.error(`patch: fablePlan: failed to find the model alias whitelist`),null;let n=t[1].slice(0,-1)+`,"${W}"]`+t[2],r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return V(e,r,n,t.index,t.index+t[0].length),r},Ml=(e,t,n)=>{let r=e.match(/(function ([$\w]+)\(([$\w]+)\)\{let\{permissionMode:([$\w]+),mainLoopModel:([$\w]+),exceeds200kTokens:([$\w]+)=!1\}=\3;)(if\(\4!=="plan"\)return\{model:\5,clampWarning:null\};)(let [$\w]+=([$\w]+)\(\),)/),i=r?null:e.match(/(function ([$\w]+)\(([$\w]+)\)\{let\{permissionMode:([$\w]+),mainLoopModel:([$\w]+),exceeds200kTokens:([$\w]+)=!1\}=\3;)(if\(\4!=="plan"\)return \5;)(let [$\w]+=([$\w]+)\(\),)/),a=r||i?null:e.match(/(function ([$\w]+)\(([$\w]+)\)\{let\{permissionMode:([$\w]+),mainLoopModel:([$\w]+),exceeds200kTokens:([$\w]+)=!1\}=\3,([$\w]+)=([$\w]+)\(\);)/),o=r??i??a;if(!o||o.index===void 0)return console.error(`patch: fablePlan: failed to find the plan-mode model resolver (uM shape)`),null;let s=o[4],c=r??i,l=c?o[9]:o[8];if(!Al(e,o.index,n))return console.error(`patch: fablePlan: ${n} is not in scope at the plan-mode model resolver`),null;let u=`${n}("${t.planModel}")`,d=`${El}=(m)=>m==="plan"&&${l}()==="${W}"?${u}:void 0;`,f=c?`${d}${o[1]}${o[7]}if(${l}()==="${W}")return${r?`{model:${u},clampWarning:null}`:` ${u}`};${o[8]}`:`${d}${o[1]}if(${s}==="plan"&&${o[7]}==="${W}")return ${u};`,p=e.slice(0,o.index)+f+e.slice(o.index+o[0].length);return V(e,p,f,o.index,o.index+o[0].length),p},Nl=(e,t)=>{let n=RegExp(`(switch\\(([$\\w]+)\\)\\{(?:case"[\\w]+":return [$\\w]+\\([$\\w]+\\);)*?case"${t.execModel}":return ([$\\w]+)\\(([$\\w]+)\\);)`),r=e.match(n);if(!r||r.index===void 0)return console.error(`patch: fablePlan: failed to find the builtin-default alias switch`),null;let i=`${r[1]}case"${W}":return ${r[3]}(${r[4]});`,a=e.slice(0,r.index)+i+e.slice(r.index+r[0].length);return V(e,a,i,r.index,r.index+r[0].length),a},Pl=(e,t)=>{let n=RegExp(`function ([$\\w]+)\\(([$\\w]+)\\)\\{let [$\\w]+=\\2\\.trim\\(\\)[\\s\\S]{0,120}?if\\([$\\w]+\\(([$\\w]+)\\)\\)switch\\(\\3\\)\\{([\\s\\S]{0,600}?case"${t.execModel}":(return [^;]+;))`),r=e.match(n);if(!r||r.index===void 0)return console.error(`patch: fablePlan: failed to find the alias-to-model resolver (as shape)`),null;let i=r[1],a=r[0],o=`${a}case"${W}":${r[5]}`,s=e.slice(0,r.index)+o+e.slice(r.index+a.length);return V(e,s,o,r.index,r.index+a.length),{file:s,resolver:i}},Fl=(e,t)=>{let n=/(function [$\w]+\(([$\w]+),([$\w]+)\)\{let ([$\w]+)=[$\w]+\(\2\),([$\w]+)=[$\w]+\.ANTHROPIC_CUSTOM_MODEL_OPTION;)/,r=e.match(/(function [$\w]+\(([$\w]+),([$\w]+)\)\{let ([$\w]+)=[$\w]+\(\2,\3\),([$\w]+)=\4\?\?[$\w]+\(\2\),[^;]*;)(?=(?:(?!function )[^])*?[$\w]+\.ANTHROPIC_CUSTOM_MODEL_OPTION;)/)??e.match(/(function [$\w]+\(([$\w]+),([$\w]+)\)\{let ([$\w]+)=[$\w]+\(\2,\3\),([$\w]+)=\4\?\?[$\w]+\(\2\),([$\w]+)=[$\w]+\.ANTHROPIC_CUSTOM_MODEL_OPTION;)/),i=r??e.match(n);if(!i||i.index===void 0)return console.error(`patch: fablePlan: failed to find the model picker options`),null;let a=r?i[5]:i[4],o=`${Vl(t.planModel)} Plan Mode`,s=`Use ${Vl(t.planModel)} in plan mode, ${Vl(t.execModel)} otherwise`,c=`if(!${a}.some((z)=>z.value==="${W}"))${a}.push(${JSON.stringify({value:W,label:o,description:s})});`,l=i[1]+c,u=e.slice(0,i.index)+l+e.slice(i.index+i[0].length);return V(e,u,l,i.index,i.index+i[0].length),u},Il=e=>{let t=e=>`${El}?.(${e}.${Dl}??${e}.toolPermissionContext?.mode)??`,n=(t,n)=>{let r=e.slice(e.lastIndexOf(`function `,t),t).match(/^function ([$\w]+)\(([$\w]+),([$\w]+)[,)]/);return r&&r[2]===n?{name:r[1],model:r[3]}:void 0},r=()=>(console.error(`patch: fablePlan: failed to find the per-model effort lookup's model argument`),null),i=e.match(/(case"inherit":\{if\(([$\w]+)\.settingsEffortTable===void 0\)return;if\(!?[$\w]+\(\2\.settingsEffortTable\)(?:&&!?[$\w]+\(\))?\)return \2\.settingsEffortTable\.default;let ([$\w]+)=)([^;]*?\2\.mainLoopModelForSession[^;]*;return [^;]*?[$\w]+\(\2\.settingsEffortTable,\3\)\})/);if(i&&i.index!==void 0){let a=n(i.index,i[2]);if(!a)return r();let o=a.name;if(i[4].startsWith(`${El}?.(`))return J(`patch: fablePlan: effort lookup already keyed — skipping`),{file:e,resolver:o,block:!0};if(!i[4].startsWith(`${a.model}??`))return r();let s=`${i[1]}${t(i[2])}${i[4]}`,c=e.slice(0,i.index)+s+e.slice(i.index+i[0].length);return V(e,c,s,i.index,i.index+i[0].length),{file:c,resolver:o,block:!0}}let a=e.match(/(case"inherit":if\(([$\w]+)\.settingsEffortTable===void 0\)return;if\(!?[$\w]+\(\2\.settingsEffortTable\)\)return \2\.settingsEffortTable\.default;return [$\w]+\(\2\.settingsEffortTable,)/);if(!a||a.index===void 0)return e.includes(`settingsEffortTable`)?(console.error(`patch: fablePlan: failed to find the per-model effort lookup`),null):(J(`patch: fablePlan: no per-model effort table in this build — effort follows the session`),{file:e,resolver:void 0,block:!1});let o=n(a.index,a[2]);if(!o)return r();let s=o.name,c=a.index+a[0].length;if(e.startsWith(`${El}?.(`,c))return J(`patch: fablePlan: effort lookup already keyed — skipping`),{file:e,resolver:s,block:!1};if(!e.startsWith(`${o.model}??`,c))return r();let l=`${a[1]}${t(a[2])}`,u=e.slice(0,a.index)+l+e.slice(c);return V(e,u,l,a.index,c),{file:u,resolver:s,block:!1}},Ll=`routed`,Rl=(e,t,n)=>{let r=t=>n?(console.error(`patch: fablePlan: ${t}`),null):(J(`patch: fablePlan: ${t} — effort follows the session's mode`),e);if(!t)return r(`failed to name the per-model effort lookup`);let i=e.match(/function ([$\w]+)\(([$\w]+)\)\{let ([$\w]+)=\2\.getAppState\(\)\.toolPermissionContext[,;]/);if(!i||i.index===void 0)return r(`failed to find the effective permission context function`);let a=i[1],o=q(t),s=[],c=RegExp(`([^$\\w.]${o}\\()([$\\w]+)\\.getAppState\\(\\),([$\\w]+)\\(\\2\\)(?=[,)])`,`g`),l=RegExp(`([^$\\w.]${o}\\()([$\\w]+)\\?\\.getAppState\\?\\.\\(\\)\\?\\?\\{\\},`,`g`),u=/model:([$\w]+),effortState:([$\w]+)[,}]/g,d=(t,...n)=>n.every(n=>Al(e,t,n)),f={a:0,b:0,c:0};for(let n of e.matchAll(c))n.index===void 0||!d(n.index,t,a)||(f.a++,s.push([n.index,n.index+n[0].length,`${n[1]}{...${n[2]}.getAppState(),${Dl}:${a}(${n[2]}).mode},${n[3]}(${n[2]})`]));for(let n of e.matchAll(l))n.index===void 0||!d(n.index,t,a)||(f.b++,s.push([n.index,n.index+n[0].length,`${n[1]}{...${n[2]}?.getAppState?.()??{},${Dl}:${n[2]}?.getAppState?${a}(${n[2]}).mode:void 0},`]));for(let n of e.matchAll(u)){if(n.index===void 0||!d(n.index,t))continue;let r=n.index+n[0].length,i=e.indexOf(`function `,r),a=RegExp(`[^$\\w.]${o}\\(${q(n[2])},${q(n[1])}\\)`).exec(e.slice(r,i===-1?void 0:i));if(!a)continue;f.c++;let c=r+a.index+1;s.push([c,c+a[0].length-1,`${t}({...${n[2]},${Dl}:"${Ll}"},${n[1]})`])}let p={a:e.includes(`.getAppState(),${Dl}:${a}(`),b:e.includes(`??{},${Dl}:`),c:e.includes(`${Dl}:"${Ll}"`)};for(let[e,t]of[[`a`,`the per-request effort resolver`],[`b`,`the hook-input effort caller`],[`c`,`the subagent-spawn effort caller`]])if(f[e]===0&&!p[e]&&r(`failed to find ${t}`)===null)return null;if(s.length===0)return J(`patch: fablePlan: effort callers already pass the mode — skipping`),e;let m=e;for(let[e,t,n]of s.sort((e,t)=>t[0]-e[0]))m=m.slice(0,e)+n+m.slice(t);return V(e,m,s.map(e=>e[2]).join(` … `),s[s.length-1][0],s[s.length-1][0]),m},zl=(e,t)=>{if(!e.includes(`"modelPicker:decreaseEffort"`))return J(`patch: fablePlan: no model-picker effort control in this build`),e;if(e.includes(`==="${W}")return;let `))return J(`patch: fablePlan: picker effort row already handled — skipping`),e;let n=/(=[$\w]+\(\(([$\w]+)\)=>\{let ([$\w]+)=[$\w]+\(\),([$\w]+)=[$\w]+\.find\(\(([$\w]+)\)=>\5\.value===\3\);if\(\4===void 0\|\|\4\.disabled===!0\)return;)(let ([$\w]+)=[$\w]+\(\3\);if\(!\7\.supportsEffort\)return;)/,r=/(([$\w]+)!==void 0&&![$\w]+&&[$\w]+\([$\w]+,\{marginBottom:1,flexDirection:"column",children:)([$\w]+\?)/,i=/([$\w]+)\(([$\w]+),\{color:"subtle",children:\[[$\w]+\([$\w]+,\{effort:void 0\}\)," Effort not supported"/,a=[/(function ([$\w]+)\(([$\w]+)\)\{)(let ([$\w]+)=[$\w]+\(\3\),(?:[$\w]+=[$\w]+\(\),)*[$\w]+=\5&&([$\w]+)!==void 0\?[$\w]+\(\6,\5\):\6;[$\w]+\("tengu_model_command_menu_effort")/,/(function ([$\w]+)\(([$\w]+)\)\{)(let ([$\w]+)=[$\w]+\(\3\),(?:[$\w]+=[$\w]+\(\),)*[$\w]+=\5&&([$\w]+)!==void 0&&\6!=="ultracode"\?[$\w]+\(\6,\5\):\6;[$\w]+\("tengu_model_command_menu_effort")/,/(function ([$\w]+)\(([$\w]+)\)\{)(let ([$\w]+)=[$\w]+\(\3\),[$\w]+=\5&&[$\w]+!==void 0&&[$\w]+!=="ultracode"\?[$\w]+\([$\w]+,\5\):[$\w]+;if\([$\w]+\("tengu_model_command_menu_effort")/],o=e.match(n),s=e.match(r),c=e.match(i),l=null;for(let t of a)if(l=e.match(t),l)break;if(!o||o.index===void 0||!s||s.index===void 0||!c||!l||l.index===void 0)return console.error(`patch: fablePlan: failed to find the model picker effort control`),null;let u=e.slice(l.index+l[1].length).match(RegExp(`^(?:(?!function )[^])*?if\\(${l[3].replace(/\$/g,`\\$`)}===[$\\w]+\\)\\{([$\\w]+)\\(null,[$\\w]+\\);return\\}`));if(!u)return console.error(`patch: fablePlan: failed to find the model picker apply call`),null;let d=JSON.stringify(`${Vl(t.planModel)} and ${Vl(t.execModel)} each use their own effort (set it on their rows)`),f=[[o.index,o.index+o[0].length,`${o[1]}if(${o[3]}==="${W}")return;${o[6]}`],[s.index,s.index+s[0].length,`${s[1]}${s[2]}==="${W}"?${c[1]}(${c[2]},{color:"subtle",children:[${d}]}):${s[3]}`],[l.index,l.index+l[0].length,`${l[1]}if(${l[3]}==="${W}"){${u[1]}(${l[3]},void 0);return}${l[4]}`]],p=e;for(let[e,t,n]of f.sort((e,t)=>t[0]-e[0]))p=p.slice(0,e)+n+p.slice(t);return V(e,p,f.map(e=>e[2]).join(` … `),o.index,o.index),p},Bl=e=>{let t=e.match(/(=[$\w]+\(\([$\w]+\)=>[$\w]+\.settings\.showClearContextOnPlanAccept\)\?\?)!1/);if(!t||t.index===void 0)return J(`patch: fablePlan: showClearContextOnPlanAccept gate not present — no-op`),e;let n=`${t[1]}!0`,r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);return V(e,r,n,t.index,t.index+t[0].length),r},Vl=e=>e.charAt(0).toUpperCase()+e.slice(1),Hl=RegExp(`\\["sonnet",(?:"[\\w[\\]]+",)*"${W}"[,\\]]`),Ul=(e,t)=>{if(Hl.test(e))return J(`patch: fablePlan: already applied — no-op`),e;if(t.planModel===t.execModel)return console.error(`patch: fablePlan: planModel and execModel are the same — nothing to pair`),null;let n=Pl(e,t);if(!n)return null;let r=n.file,i=jl(r);if(!i)return null;r=i;let a=Ml(r,t,n.resolver);if(!a)return null;r=a;let o=Nl(r,t);if(!o)return null;r=o;let s=Fl(r,t);if(!s)return null;r=s;let c=Il(r);if(!c)return null;r=c.file;let l=Rl(r,c.resolver,c.block);if(!l)return null;r=l;let u=zl(r,t);if(!u)return null;if(r=u,t.offerClearContextOnPlanAccept){let e=Bl(r);if(!e)return null;r=e}return r},Wl=(e,t)=>{let n=`return !0;`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},Gl=e=>{let t=e.indexOf(`"allow_voice_mode"`);if(t!==-1){let n=Math.max(0,t-800),r=e.slice(n,t+400).match(/function ([$\w]+)\(\)\{return [$\w]+\(\)&&[$\w]+\(\)\}/);if(r&&r.index!==void 0){let t=n+r.index,i=e.indexOf(`{`,t);if(i!==-1)return e.startsWith(`return !0;`,i+1)?e:Wl(e,i+1)}let i=e.match(/name:"voice",description:"Toggle voice mode"[\s\S]{0,500}?get isHidden\(\)\{return![$\w]+\(\)\}/);if(i&&i.index!==void 0){let t=i[0].replace(/get isHidden\(\)\{return![$\w]+\(\)\}/,`get isHidden(){return!1}`);if(i[0]===t)return e;let n=e.slice(0,i.index)+t+e.slice(i.index+i[0].length);return V(e,n,t,i.index,i.index+i[0].length),n}}let n=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_amber_quartz"/);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 V(e,i,r,t,t),i}let r=e.match(/function [$\w]+\(\)\{return![$\w]+\("tengu_amber_quartz_disabled"/);if(r&&r.index!==void 0){let t=r.index+r[0].indexOf(`{`)+1,n=`return !0;`,i=e.slice(0,t)+n+e.slice(t);return V(e,i,n,t,t),i}let i=e.match(/name:"voice",description:"Toggle voice mode"[\s\S]{0,500}?get isHidden\(\)\{return!([$\w]+)\(\)\}/);if(i&&i.index!==void 0){let t=i[1].replace(/[$]/g,`\\$`),n=RegExp(`function ${t}\\(\\)\\{`),r=e.match(n);if(r&&r.index!==void 0){let t=r.index+r[0].length,n=`return !0;`,i=e.slice(0,t)+n+e.slice(t);return V(e,i,n,t,t),i}}return console.error(`patch: voiceMode: failed to find tengu_amber_quartz gate`),null},Kl=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 V(e,r,n,t.index,t.index+t[0].length),r},ql=(e,t)=>{let n=Gl(e);return!n||t&&(n=Kl(n),!n)?null:n},Jl=e=>{for(let t of[/function [$\w]+\(\)\{return [$\w]+\("allow_channels"\)&&[$\w]+\("tengu_harbor",!1\)/,/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor",!1\)/]){let n=e.match(t);if(!n||n.index===void 0)continue;let r=n.index+n[0].indexOf(`{`)+1,i=`return !0;`,a=e.slice(0,r)+i+e.slice(r);return V(e,a,i,r,r),a}return console.error(`patch: channelsMode: failed to find tengu_harbor gate`),null},Yl=e=>{let t=e.match(/function [$\w]+\(\)\{if\(![$\w]+\("tengu_harbor",!1\)\)return!0;/);if(!t||t.index===void 0)return e;let n=t.index+t[0].indexOf(`{`)+1,r=`return !1;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},Xl=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 V(e,i,r,n,n),i},Zl=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 V(e,i,r,n,n),i},Ql=e=>{let t=e.match(/"Channels \(experimental\) messages from ",([$\w]+),"[^"]*restart without "/);if(t&&t.index!==void 0){let n=`"Channels active \\xB7 messages from ",${t[1]}," \\xB7 restart without "`,r=t.index,i=r+t[0].length,a=e.slice(0,r)+n+e.slice(i);return V(e,a,n,r,i),a}let n=e.match(/Experimental[^"]*?inbound messages will be pushed into this session, this carries prompt injection risks\. Restart Claude Code without /);if(n&&n.index!==void 0){let t=`Channels active. Restart Claude Code without `,r=n.index,i=r+n[0].length,a=e.slice(0,r)+t+e.slice(i);return V(e,a,t,r,i),a}return console.error(`patch: channelsMode: failed to find ChannelsNotice warning text`),null},$l=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 V(e,i,``,n,r),i},eu=e=>{let t=Jl(e);return!t||(t=Yl(t),t=Xl(t),!t)||(t=Zl(t),!t)||(t=Ql(t),!t)||(t=$l(t),!t)?null:t},tu=e=>{if(/name:"clear-screen"/.test(e))return e;let t=e.match(/([,;{}])(function [$\w]+\(\)\{)([$\w]+\(\))\.get\(process\.stdout\)\?\.forceRedraw\(\)\}/)||e.match(/([,;{}])(function [$\w]+\(\)\{)([$\w]+)\.get\(process\.stdout\)\?\.forceRedraw\(\)\}/);if(!t||t.index===void 0)return J(`patch: clearScreen: failed to find forceRedraw function`),null;let n=`${t[1]}globalThis.__tweakccForceRedraw=()=>${t[3]}.get(process.stdout)?.forceRedraw();`+t[0].slice(1),r=e.slice(0,t.index)+n+e.slice(t.index+t[0].length);V(e,r,n,t.index,t.index+t[0].length);let i=nu(r);return i?(r=i,Xa(r,`,{type:"local",name:"clear-screen",description:"Clear screen without resetting conversation context",supportsNonInteractive:!1,load:()=>Promise.resolve().then(()=>({call:(H,$)=>{$.setMessages(m=>{globalThis.__tweakccHiddenUUIDs=new Set(m.map(x=>x.uuid?.slice(0,24)).filter(Boolean));return[...m]});process.stdout.write("\\x1b[2J\\x1b[H\\x1b[3J");globalThis.__tweakccForceRedraw?.();return{type:"skip"}}}))}`)||(J(`patch: clearScreen: failed to register slash command`),null)):(J(`patch: clearScreen: failed to patch render filter g97`),null)},nu=e=>{let t=e.match(/([,;{}])(function [$\w]+\(([$\w]+),[$\w]+\)\{)if\(\3\.type!=="user"\)return!0;if\(\3\.isMeta\)/);if(!t||t.index===void 0)return null;let n=t[1],r=t[2],i=`${n}${r}if(globalThis.__tweakccHiddenUUIDs?.has(${t[3]}.uuid?.slice(0,24)))return!1;`+t[0].slice(n.length+r.length),a=e.slice(0,t.index)+i+e.slice(t.index+t[0].length);return V(e,a,i,t.index,t.index+t[0].length),a},ru=[`red`,`blue`,`green`,`yellow`,`purple`,`orange`,`pink`,`cyan`],iu=/\.\.\.([$\w]+)&&\{standaloneAgentContext:\{name:\1\}\}/,au=e=>`,...(()=>{let __c=process.env.TWEAKCC_SESSION_COLOR;if(!__c||!${JSON.stringify(ru)}.includes(__c))return{};queueMicrotask(()=>{if(globalThis.__tweakccSaveAgentColor)globalThis.__tweakccSaveAgentColor(__c)});let __n=${e?`(typeof ${e}==="undefined"?"":${e}||"")`:`""`};return{standaloneAgentContext:{name:__n,color:__c}}})()`,ou=e=>{if(e.includes(`let __c=process.env.TWEAKCC_SESSION_COLOR;if(!__c`))return e;let t=au(e.match(iu)?.[1]??null),n=e.match(/,activeOverlays:new Set,fastMode:[$\w]+\([$\w]+\)/);if(!n||n.index===void 0)return console.error(`patch: sessionColor: failed to find the app state init`),null;let r=e.slice(0,n.index)+t+e.slice(n.index);return V(e,r,t,n.index,n.index+n[0].length),su(r)||(J(`patch: sessionColor: no saveAgentColor anchor; color applies without cross-session persistence`),r)},su=e=>{let t=RegExp(`([,;{}])(async function ([$\\w]+)\\(([$\\w]+),([$\\w]+),([$\\w]+)(?:,[$\\w]+)?\\)\\{let [$\\w]+=\\6\\?\\?[$\\w]+\\(\\4\\);try\\{await [$\\w]+\\([$\\w]+,\\{type:"agent-color",agentColor:\\5,sessionId:\\4\\}(?:,[$\\w]+)?\\)\\}catch\\([$\\w]+\\)\\{[\\s\\S]*?\\}if\\(\\4===([$\\w]+)\\(\\)\\))`),n=e.match(t);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=`globalThis.__tweakccSaveAgentColor=(c)=>${n[3]}(${n[7]}(),c);`,o=`${r}${a}${i}`,s=e.slice(0,n.index)+o+e.slice(n.index+n[0].length);return V(e,s,a,n.index,n.index+n[0].length),s},cu=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 V(e,a,i,n,n+52),a},lu=e=>X(JSON.stringify(e)).replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),uu=`"$_cc_bin"`,du=/\{mode:"embedded",command:process\.execPath,args:\[[^\]]*\],argv0:"rg"\}/,fu=`Search backend note (fff):`;``+fu;const pu=`most-relevant-first`;``+pu;const mu=(e,t)=>{let n=lu(t);if(e.includes(`ARGV0=\${t} ${n}`)||e.includes(`exec -a \${t} ${n}`))return e;if(e.split(uu).length-1==0)return console.error(`patch: swapRipgrepForFff: bash-search shadow anchor "$_cc_bin" not found`),null;let r=e.split(uu).join(n),i=`[[ ! -x $_cc_bin ]]`;return r.includes(i)&&(r=r.split(i).join(`[[ ! -x $_cc_bin || ! -x ${n} ]]`)),V(e,r,n,e.indexOf(uu),e.indexOf(uu)+10),r},hu=(e,t)=>{if(e.includes(`--fff-claude-bin=`))return e;let n=e.indexOf(`{mode:"embedded",command:process.execPath,args:["--no-config"],argv0:"rg"}`),r=n===-1?-1:n+74;if(n===-1){let t=e.match(du);if(!t||t.index===void 0)return J(`patch: swapRipgrepForFff: ripgrep resolver descriptor not found; skipping rg repoint`),e;n=t.index,r=t.index+t[0].length}let i=`{mode:"system",command:${X(JSON.stringify(t))},args:["--fff-claude-bin="+process.execPath]}`,a=e.slice(0,n)+i+e.slice(r);return V(e,a,i,n,r),a},gu=(e,t)=>{let n=e[t];for(t++;t<e.length;)if(e[t]===`\\`)t+=2;else if(e[t]===n)return t;else t++;return t},_u=(e,t)=>{let n=[{k:`tpl`}];for(let r=t;r<e.length;r++){let t=n[n.length-1],i=e[r];if(i===`\\`){r++;continue}if(t.k===`tpl`){if(i==="`"){if(n.pop(),n.length===0)return r;continue}i===`$`&&e[r+1]===`{`&&(n.push({k:`expr`,b:0}),r++);continue}if(i==="`"){n.push({k:`tpl`});continue}if(i===`"`||i===`'`){r=gu(e,r);continue}if(i===`{`){t.b++;continue}if(i===`}`){t.b===0?n.pop():t.b--;continue}}return-1},vu=(e,t,n,r,i)=>{if(e.includes(r))return e;if(n.includes("`"))return console.error(`patch: swapRipgrepForFff: ${i} guidance contains a backtick; skipping (would break template parity)`),e;let a=[],o=0;for(;;){let n=e.indexOf(t,o);if(n===-1)break;let r=_u(e,n);r===-1?console.error(`patch: swapRipgrepForFff: ${i} anchor at ${n} has no balanced closing backtick; skipping this site`):a.push(r),o=n+t.length}if(a.length===0)return J(`patch: swapRipgrepForFff: ${i} anchor not found; skipping`),e;let s=e;for(let e of a.sort((e,t)=>t-e))s=s.slice(0,e)+n+s.slice(e);return V(e,s,n,a[a.length-1],a[0]),s},yu=(e,t)=>{let n=mu(e,t);if(n===null)return null;let r=n;return r=hu(r,t),r=vu(r,`built on ripgrep`,`
|
|
1088
1088
|
|
|
1089
1089
|
Search backend note (fff): prefer one bare identifier over regex; results are relevance-ranked, so read the top hit first. A trailing [def] tag flags a line that likely defines the symbol.`,fu,`Grep description`),r=vu(r,`Prefer dedicated tools over`,` grep/find results are ranked most-relevant-first (read the top hit first); a trailing [def] tag flags a likely definition line, and a grep or find -name that matches nothing automatically lists the closest approximate hits tagged [~approx]. Add --fuzzy to force typo-tolerant or partial matching, e.g. grep --fuzzy SomeName.`,pu,`Bash description`),r},bu=3e4;function xu(){let{platform:e,arch:t}=process;return e===`darwin`&&t===`arm64`?`aarch64-apple-darwin`:e===`linux`&&t===`arm64`?`aarch64-unknown-linux-musl`:e===`linux`&&t===`x64`?`x86_64-unknown-linux-musl`:null}function Su(){try{let e=u.dirname(S(import.meta.url));for(let t=0;t<6;t++){let t=u.join(e,`package.json`);if(s.existsSync(t))try{let n=JSON.parse(s.readFileSync(t,`utf-8`)).version;if(typeof n==`string`)return{root:e,version:n}}catch{}let n=u.dirname(e);if(n===e)break;e=n}}catch{}return null}async function Cu(e){try{return await a.access(e,s.constants.X_OK),!0}catch{return!1}}async function wu(e,t){await a.mkdir(u.dirname(t),{recursive:!0});let n=`${t}.tmp-${process.pid}`;try{await a.copyFile(e,n),await a.chmod(n,493),await a.rename(n,t)}catch(e){throw await a.unlink(n).catch(()=>{}),e}}async function Tu(e){try{return(await a.stat(e)).mtimeMs}catch{return-1}}async function Eu(){let e=xu();if(!e)return null;let t=u.join(Z,`fff`,e,`rg-fff`),n=u.join(u.dirname(t),`.version`),r=Su();if(r)for(let e of[`release`,`debug`]){let n=u.join(r.root,`tools`,`rg-fff`,`target`,e,`rg-fff`);if(s.existsSync(n))return await Tu(n)>await Tu(t)&&await wu(n,t),t}let i=r?.version,o=await a.readFile(n,`utf-8`).then(e=>e.trim()).catch(()=>null);if(await Cu(t)&&(!i||o===i))return t;if(!i)return null;let c=`https://github.com/skrabe/tweakcc-fixed/releases/download/v${i}`;try{let r=await fetch(`${c}/rg-fff-${e}`,{signal:AbortSignal.timeout(bu)});if(!r.ok)return null;let o=Buffer.from(await r.arrayBuffer()),s=await fetch(`${c}/rg-fff-${e}.sha256`,{signal:AbortSignal.timeout(bu)});if(!s.ok)return console.error(`patch: swapRipgrepForFff: rg-fff-${e}.sha256 unavailable (${s.status}) — keeping ripgrep`),null;let l=(await s.text()).trim().split(/\s+/)[0]?.toLowerCase(),d=b.createHash(`sha256`).update(o).digest(`hex`);if(!l||l!==d)return console.error(`patch: swapRipgrepForFff: rg-fff-${e} checksum ${l?`mismatch`:`missing`} — keeping ripgrep`),null;await a.mkdir(u.dirname(t),{recursive:!0});let f=`${t}.tmp-${process.pid}`;try{await a.writeFile(f,o),await a.chmod(f,493),await a.rename(f,t)}catch(e){throw await a.unlink(f).catch(()=>{}),e}return await a.writeFile(n,i).catch(()=>{}),t}catch{return null}}const Du=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 V(e,d,c,l,u),d},Ou=e=>{let t=/function ([$\w]+)\(([$\w]+)\)\{return`\$\{([$\w]+)\}\n\$\{\2\}\n\$\{([$\w]+)\}`\}/g,n=(t,n)=>RegExp(`[,;{(\\s]${t.replace(/\$/g,`\\$`)}=${JSON.stringify(n)}[,;]`).test(e),r=null;for(let i of e.matchAll(t))if(n(i[3],`<system-reminder>`)&&n(i[4],`</system-reminder>`)){r=i;break}let i=r??e.match(/function ([$\w]+)\(([$\w]+)\)\{return`<system-reminder>\n\$\{\2\}\n<\/system-reminder>`\}/);if(!i||i.index===void 0)return/function [$\w]+\(([$\w]+)\)\{if\(!\1\|\|!\1\.trim\(\)\|\|\1==="\(no content\)"\)return"\(no content\)";return`(?:<system-reminder>|\$\{[$\w]+\}\n)/.test(e)?e:(console.error(`patch: strip-empty-system-reminders: failed to find LW(H) wrapper`),null);let[a,o,s]=i,c=`function ${o}(${s}){if(!${s}||!${s}.trim()||${s}==="(no content)")return"(no content)";return\`${r?`\${${r[3]}}`:`<system-reminder>`}\n\${${s}}\n${r?`\${${r[4]}}`:`</system-reminder>`}\`}`,l=i.index,u=l+a.length,d=e.slice(0,l)+c+e.slice(u);return V(e,d,c,l,u),d},ku=e=>{if(!e.includes(`The following deferred tools are now available via`))return console.log(`patch: suppress-deferred-tools: anchor not present in this CC build — no-op`),e;let t=`case"deferred_tools_delta":{`;if(e.includes(`case"deferred_tools_delta":{return [];`))return e;let n=e.indexOf(t);if(n<0)return console.error(`patch: suppress-deferred-tools: failed to find case header`),null;if(e.indexOf(t,n+1)>=0)return console.error(`patch: suppress-deferred-tools: case header is ambiguous (multiple matches)`),null;let r=n+28,i=`return [];`,a=e.slice(0,r)+i+e.slice(r);return V(e,a,i,r,r),a},Au=[`__tweakcc`,`tweakcc v`],ju=e=>Au.some(t=>e.includes(t)),Mu=Math.max(...Au.map(e=>e.length)),Nu=async e=>new Promise(t=>{let n;try{n=l(e,{encoding:`latin1`,highWaterMark:8<<20})}catch{t(!1);return}let r=``,i=!1,a=e=>{i||(i=!0,n.destroy(),t(e))};n.on(`data`,e=>{let t=r+e;if(ju(t)){a(!0);return}r=t.slice(-(Mu-1))}),n.on(`error`,()=>a(!1)),n.on(`close`,()=>a(!1)),n.on(`end`,()=>a(!1))});var Pu=class extends Error{constructor(e){super(`Refusing to back up ${e}: it carries tweakcc markers, so it is already patched. Backing it up would overwrite the only pristine copy with a patched one. Run \`tweakcc --restore\` first, or reinstall Claude Code, then try again.`),this.name=`NonPristineBackupError`}};const Fu=async e=>{if(await Nu(e))throw new Pu(e)},Iu=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}},Lu=async e=>{if(!e.cliPath){J(`backupClijs: Skipping for native installation (no cliPath)`);return}await Fu(e.cliPath),await Yd(),J(`Backing up cli.js to ${Wd}`),await Iu(e.cliPath,Wd),await tf(t=>{t.changesApplied=!1,t.ccVersion=e.version})},Ru=async e=>{e.nativeInstallationPath&&(await Fu(e.nativeInstallationPath),await Yd(),J(`Backing up native binary to ${Gd}`),await Iu(e.nativeInstallationPath,Gd),await tf(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},zu=async e=>e.cliPath?await Pd(Wd)?(J(`Restoring cli.js from backup to ${e.cliPath}`),await Nd(e.cliPath,Wd,`restore`),await Lt(),await tf(e=>{e.changesApplied=!1}),!0):(J(`restoreClijsFromBackup: No backup file exists, skipping`),!1):(J(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1),Bu=async e=>e.nativeInstallationPath?await Pd(Gd)?(J(`Restoring native binary from backup to ${e.nativeInstallationPath}`),await Nd(e.nativeInstallationPath,Gd,`restore`),await Lt(),await tf(e=>{e.changesApplied=!1}),!0):(J(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1):(J(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1),Vu=`/*@@TWEAKCC_MODULE:`,Hu=(e,t)=>{let n=e.lastIndexOf(Vu,t);if(n===-1)return Uu(e);let r=e.indexOf(Vu,n+1);return Uu(e.slice(n,r===-1?e.length:r))},Uu=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},Wu=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`)},Gu=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\((?:\([$\w]+\)=>|function\([$\w]+\))\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},Ku=e=>{let t=Gu(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\((?:\\([$\\w]+,[$\\w]+\\)=>|function\\([$\\w]+,[$\\w]+\\))\\{[$\\w]+\\.exports=${q(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 G=null,qu=null;const Ju=e=>{if(G!=null)return G;let t=Wu(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),G=void 0;return}let n=Gu(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),G=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${q(t)}\\(${q(n)}\\(\\),1\\)`),i=e.match(r);if(i)return G=i[1],G;let a=Ku(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),G=void 0;return}let o=RegExp(`[^$\\w]([$\\w]+)=${q(t)}\\(${q(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),G=void 0;return}return G=s[1],G},Yu=()=>{G=null},Xu=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${q(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]},Zu=e=>{if(qu!=null)return qu;let t=Xu(e);return t?(qu=t,qu):(qu=`require`,qu)},Qu=()=>{qu=null},$u=()=>{Yu(),Qu()},ed=e=>{let t=e.match(/function ([$\w]+)\([$\w]+\)\{let [$\w]+=[$\w]+\.c\(\d+\)[^;]{0,240};if\([$\w]+\[0\]!==[$\w]+\)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+,bold:[$\w]+/);if(t)return t[1];let n=e.match(/\bfunction ([$\w]+).{0,80}color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+(?:=![01])?,bold:[$\w]+(?:=![01])?/);if(!n){console.log(`patch: findTextComponent: failed to find text component`);return}return n[1]},td=(e,t)=>{let n=`[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*`,r=RegExp(`var [^;]{0,120};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,500}([$\\w]+)=${q(t)}\\}\\)`),i=e.match(r)?.[1]??t,a=RegExp(`function ([$\\w]+)\\([^)]+\\)\\{(?=[\\s\\S]{0,2500}createElement\\(${q(i)},\\{\\.\\.\\.[$\\w]+,borderColor:)[\\s\\S]{0,3000}?return [$\\w]+\\}var [^;]{0,160};var [$\\w]+=${n}\\(\\(\\)=>\\{[^}]{0,600}([$\\w]+)=\\1\\}\\)`);return e.match(a)?.[2]},nd=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 td(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)`)};let K=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 rd=[{id:`verbose-property`,name:`Verbose property`,group:K.ALWAYS_APPLIED,description:`Token counter will show (2s · ↓ 169 tokens · thinking)`},{id:`read-default-lines`,name:`Read default lines (env-gated)`,group:K.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:K.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:K.ALWAYS_APPLIED,description:`Restore dim/gray + italic styling for thinking blocks`},{id:`fix-lsp-support`,name:`Fix LSP support`,group:K.ALWAYS_APPLIED,description:`Enable/fix nascent LSP support`},{id:`no-global-cache-scope`,name:`Keep a replaced identity line out of the global prompt cache`,group:K.ALWAYS_APPLIED,description:`When a prompt override replaces one of Claude Code's identity lines, turn off the "global" cache scope that the first-party API rejects after a non-stock identity, so the prompt caches at organization scope instead. Does nothing while the identity lines are stock.`},{id:`fix-summarize-from-here`,name:`Fix "Summarize from here"`,group:K.MISC_CONFIGURABLE,description:`Make "Summarize from here" summarize only the messages after the rewind point (feed the slice, not the whole conversation)`,modelFacing:!0},{id:`fix-rewind-summary-header`,name:`Honest rewind summary header`,group:K.MISC_CONFIGURABLE,description:`Label a rewind summary as a deliberate rewind instead of the misleading "ran out of context" header`,modelFacing:!0},{id:`statusline-update-throttle`,name:`Statusline update throttling correction`,group:K.ALWAYS_APPLIED,description:`Statusline updates will be properly throttled instead of queued (or debounced)`},{id:`clear-screen`,name:`Clear screen command`,group:K.ALWAYS_APPLIED,description:`Register a /clear-screen command that clears the terminal scrollback and redraws without resetting conversation context`},{id:`strip-empty-system-reminders`,name:`Strip empty <system-reminder> wrappers`,group:K.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:K.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:K.MISC_CONFIGURABLE,description:`Show 25 items in select menus instead of default 5`},{id:`context-limit`,name:`Context limit`,group:K.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:K.MISC_CONFIGURABLE,description:`Show "tweakcc patches applied" and tweakcc version inside CC`},{id:`table-format`,name:`Table format`,group:K.MISC_CONFIGURABLE,description:`Tables generated by Claude will be rendered more compactly`},{id:`themes`,name:`Themes`,group:K.MISC_CONFIGURABLE,description:`Your custom themes will be available via /theme`},{id:`thinking-verbs`,name:`Thinking verbs`,group:K.MISC_CONFIGURABLE,description:`Your custom list of thinking verbs will be cycled through`},{id:`thinker-format`,name:`Thinker format`,group:K.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:K.MISC_CONFIGURABLE,description:`Your custom thinking spinner will be rendered`},{id:`thinker-symbol-speed`,name:`Thinker symbol speed`,group:K.MISC_CONFIGURABLE,description:`The thinking spinner will play at a custom FPS`},{id:`thinker-symbol-width`,name:`Thinker symbol width`,group:K.MISC_CONFIGURABLE,description:`The thinking spinner will be in a box of custom width`},{id:`thinker-symbol-mirror`,name:`Thinker symbol mirror`,group:K.MISC_CONFIGURABLE,description:`The thinking spinner will reverse or restart when it finishes`},{id:`input-box-border`,name:`Input box border`,group:K.MISC_CONFIGURABLE,description:`Your custom styles to the main input box's border will be applied`},{id:`input-chevron-color`,name:`Input chevron idle color`,group:K.MISC_CONFIGURABLE,description:`The idle input chevron will use your chosen theme color instead of the default`},{id:`subagent-models`,name:`Subagent models`,group:K.MISC_CONFIGURABLE,description:`Use custom models for Plan, Explore, and General subagents`},{id:`thinking-visibility`,name:`Thinking block visibility`,group:K.MISC_CONFIGURABLE,description:`Thinking blocks outputted by the model will show without Ctrl+O`},{id:`hide-startup-banner`,name:`Hide startup banner`,group:K.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:K.MISC_CONFIGURABLE,description:`Note about using Ctrl+G to edit prompt will be hidden`},{id:`hide-startup-clawd`,name:`Hide startup Clawd`,group:K.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:K.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:K.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:K.MISC_CONFIGURABLE,description:`/rate-limit-options won't be injected when limits are reached`},{id:`suppress-rate-limit-warning`,name:`Suppress rate limit warning`,group:K.MISC_CONFIGURABLE,description:`Rate limit warning banners in the status bar will be hidden`},{id:`session-color`,name:`Session color from env`,group:K.MISC_CONFIGURABLE,description:`Session prompt bar color is read from the TWEAKCC_SESSION_COLOR env var at each launch`},{id:`token-count-rounding`,name:`Token count rounding`,group:K.MISC_CONFIGURABLE,description:`Round displayed token counts to the nearest multiple of chosen value`},{id:`remember-skill`,name:`Remember skill`,group:K.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:K.MISC_CONFIGURABLE,description:`Support AGENTS.md and others in addition to CLAUDE.md`},{id:`auto-accept-plan-mode`,name:`Auto-accept plan mode`,group:K.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:K.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:K.MISC_CONFIGURABLE,description:`Suppress the native installer warning message at startup`},{id:`model-at-effort`,name:`/model name@effort`,group:K.MISC_CONFIGURABLE,description:`/model opus@high sets the model and then runs /effort high, in one command`},{id:`filter-scroll-escape-sequences`,name:`Filter scroll escape sequences`,group:K.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:K.MISC_CONFIGURABLE,description:`Opus 4.7 sessions default to "max" reasoning effort instead of "xhigh" (override with /effort or CLAUDE_CODE_EFFORT_LEVEL)`,modelFacing:!0},{id:`autonomous-operation-all-models`,name:`Fable/Mythos prompt set (all models)`,group:K.MISC_CONFIGURABLE,description:`Treats your selected model as Fable/Mythos everywhere CC branches on model family (flips the zQ gate): you get the autonomous-operation prompt (proceed without asking for reversible in-scope work; finish the job before ending the turn), the "# Communicating with the user" comms block in place of "# Text output", /loop dynamic-pacing behavior, and brief-mode comms shaping. Per-model feature-flag routing also follows fable but is inert on a local install`,modelFacing:!0},{id:`refusal-fallback-model`,name:`Route the refusal fallback, then switch back`,group:K.MISC_CONFIGURABLE,description:`When safeguards flag a message, Claude Code retries it on a fallback model from its own route table, keyed by the flagged model and the refusal category, and keeps the session on that model. This merges refusalFallbackRoutes from config.json over that table (a category you leave out keeps its stock route, one you route falls back to the stock route when none of your models is usable, and a route is a model id or a chain of them) and switches the session back to its own model once the flagged turn is answered, with a line in the transcript. refusalFallbackMaxReturns in config.json (default 1, null for no limit) caps consecutive returns, so a conversation that keeps being flagged stays on the fallback instead of paying a refusal and a retry every turn`,modelFacing:!1},{id:`output-style-turn-reminder`,name:`Custom output styles carry their own per-turn reminder`,group:K.MISC_CONFIGURABLE,description:`Claude Code restates which output style is active once per turn. Since 2.1.238 that reminder fires for custom styles as well as built-in ones, but its text is fixed: every style you write gets the same generic "Remember to follow the specific guidelines for this style." This lets a style supply its own sentence instead. Add \`turn-reminder:\` to the style's markdown frontmatter and that text is what gets restated each turn, the way the built-in styles carry their own. Without this, the key is read by the frontmatter parser and then dropped on the way to the renderer, so it has no effect. On Claude Code before 2.1.238 this also makes the reminder fire for custom styles at all, which stock builds of that era skipped entirely. The per-turn slot is the position Anthropic's own Opus 5 guidance points at for tone, where a short reminder late in a long prompt is their measured remedy.`,modelFacing:!0},{id:`auto-mode-classifier-model`,name:`Auto-mode classifier model`,group:K.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)`,modelFacing:!0},{id:`complexity-router`,name:`[EXPERIMENTAL] Complexity effort router`,group:K.FEATURES,description:`Choose reasoning effort for each user message only while an Effort Router model entry is selected. Uses Haiku, or Jev decisions with asynchronous Haiku conversation summaries, and honors explicit effort overrides. Jev requires a TypeSafe API key and sends the current message and bounded conversation context to TypeSafe. Off by default.`,modelFacing:!0},{id:`fable-plan`,name:`Fable Plan mode`,group:K.FEATURES,description:`Adds a "fableplan" entry to /model: Fable while planning, Opus while executing, each at the reasoning effort you set for that model in /model (Claude Code's per-model effort). Mirrors the mechanism Claude Code already ships for opusplan, so it is a MODEL YOU SELECT — nothing changes for any other model, your selection stays "fableplan" throughout, and no model is ever switched underneath you mid-session. Also surfaces Claude Code's own "Yes, clear context (N% used)" option on the plan-approval dialog, which Claude Code defaults off: clearing hands only the plan to the executing model, where continuing re-sends the entire planning transcript to a different one. Off by default.`,modelFacing:!0},{id:`complexity-router-models`,name:`Effort Router model entries`,group:K.FEATURES,description:`Adds opt-in Opus 5.5 and Fable 5.1 + Effort Router entries to /model. Ordinary models keep native effort behavior. Selecting a router entry enables the configured effort provider; switching away stops routing and background summaries.`,modelFacing:!0},{id:`allow-custom-agent-models`,name:`Allow custom agent models`,group:K.FEATURES,description:`Allow arbitrary model names in custom agent frontmatter (e.g. gemini-2.5-flash)`},{id:`unlock-responsive-mode`,name:`Unlock responsive mode`,group:K.FEATURES,description:`Make Claude Code's bundled responsive-mode plugin selectable. Claude Code 2.1.280 ships the whole feature in the binary - a system-reminder telling Claude to answer the message before it thinks or picks up a tool, and a system-prompt section ruling out stock AI phrasing (eager openers, agreement reflexes, corporate vocabulary, wrap-ups) - but gates it behind a server flag that answers no. This drops the flag check and keeps the session-kind guard, so the plugin appears in /plugin. It is registered DISABLED, so nothing changes until you turn it on there. Off by default.`,modelFacing:!0},{id:`worktree-mode`,name:`Worktree mode`,group:K.FEATURES,description:`Enable the EnterWorktree tool for isolated git worktree sessions`},{id:`session-memory`,name:`Session memory`,group:K.FEATURES,description:`Enable session memory (auto-extraction + past session search)`},{id:`swap-ripgrep-for-fff`,name:`[EXPERIMENTAL] fff for Bash search (grep/find/rg → fff)`,group:K.FEATURES,description:"[EXPERIMENTAL] Route Claude Code's Bash search through fff (fast file finder). CC 2.1.186 shadows the shell `grep`→embedded ugrep and `find`→embedded bfs (and offers `rg`); the agent uses grep ~136x more than rg. This repoints all three at a per-platform fff wrapper that serves, relevance-ranked from a warm-index daemon: literal, regex (RE2 — the dialect the model writes), case-insensitive (-i), multi-word phrases, context (-A/-B/-C), extension globs (-g/--include '*.ts'), and multi-path (app lib scripts) searches. Anything fff can't serve faithfully — PCRE, multiline/newline- or empty-matching regex, only-matching (-o), single-file, non-recursive grep, --no-ignore, find, non-ASCII, lines over 512 bytes, piped stdin → re-exec the real embedded ugrep/bfs/ripgrep. Every engine still ships; any uncertainty falls back, so results never diverge from the model's intent. Transparent (no prompt-compliance reliance) and CC-scoped (the user's own terminal grep/find/rg are untouched). Installs the wrapper into ~/.tweakcc/fff."},{id:`dream-mode`,name:`Dream mode`,group:K.FEATURES,description:`Enable dream (/dream + auto-dream background memory consolidation)`,modelFacing:!0},{id:`lean-memory-types`,name:`Lean memory types`,group:K.FEATURES,description:`Compact "Types of memory" prompt block + on-demand memory-types skill`,modelFacing:!0},{id:`toolsets`,name:`Toolsets`,group:K.FEATURES,description:`Custom toolsets will be registered`},{id:`mcp-non-blocking`,name:`MCP non-blocking`,group:K.FEATURES,description:`If you have MCP servers, CC startup will be much faster`},{id:`mcp-batch-size`,name:`MCP batch size`,group:K.FEATURES,description:`Change the number of MCP servers started in parallel`},{id:`user-message-display`,name:`User message display`,group:K.FEATURES,description:`User messages in the chat history will be styled`},{id:`input-pattern-highlighters`,name:`Input pattern highlighters`,group:K.FEATURES,description:`Custom input highlighters will be registered`},{id:`conversation-title`,name:`Conversation title`,group:K.FEATURES,description:`/title command will be created & enabled`},{id:`voice-mode`,name:`Voice mode`,group:K.FEATURES,description:`Enable /voice command for speech-to-text input (hold Space to record)`},{id:`channels-mode`,name:`Channels mode`,group:K.FEATURES,description:`Enable MCP channel notifications (--channels without allowlist or dev flag)`},{id:`suppress-deferred-tools`,name:`Suppress deferred tools list (DANGEROUS)`,group:K.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.`,modelFacing:!0},{id:`claudemd-context-once-per-conversation`,name:`claudeMd context: once per conversation`,group:K.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.`,modelFacing:!0}],id=()=>[...rd],q=e=>e.replace(/\$/g,`\\$`),ad=(e,t,n)=>{let r=[];for(let i of rd){let a=t[i.id];if(n&&!n.includes(i.id)&&i.id!==`no-global-cache-scope`){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}J(`Applying patch: ${i.name}`);let o=[],s=console.error;console.error=(...e)=>{o.push(e.map(String).join(` `)),s(...e)};let c;try{c=a.fn(e)}finally{console.error=s}let l=c===null,u=!l&&c!==e,d=!l&&o.length>0;c!==null&&(e=c),r.push({id:i.id,name:i.name,group:i.group,applied:u,failed:l,...d&&{partial:d,details:`partially applied (${o[0].replace(/^patch: [^:]+: /,``)})`},description:i.description,modelFacing:i.modelFacing})}return{content:e,results:r}},od=e=>{if(process.env.TWEAKCC_ALLOW_CROSS_PLATFORM===`1`)return;let t=v(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}},sd=async(e,r,i)=>{let o,c=!1;if(r.nativeInstallationPath){await Bu(r);let e=!1;try{await a.stat(Gd),e=!0}catch{}let t=e?Gd:r.nativeInstallationPath;J(`Extracting claude.js from ${e?`backup`:`native installation`}: ${t}`);let{data:n,clearBytecode:i,error:l}=await j(t,r.version);if(!n)throw Error(`Failed to extract claude.js from native installation${l?`: ${l}`:``}`);c=i;let d=u.join(Z,`native-claudejs-orig.js`);s.writeFileSync(d,n),J(`Saved original extracted JS from native to: ${d}`),o=n.toString(`utf8`)}else{if(await zu(r),!r.cliPath)throw Error(`cliPath is required for NPM installations`);o=await a.readFile(r.cliPath,{encoding:`utf8`})}let l=[],d=o;if(r.version){let e=await Pa({pristine:d,version:r.version,patchFilter:i}).catch(e=>(J(`system-prompt preflight skipped: ${e}`),null)),n=[];for(let r of e?.findings??[]){let e=`preflight: ${Fa(r)}`;r.severity===`error`?console.log(t.red(e)):(n.push(e),J(e))}n.length>0&&J(`system-prompt preflight: ${n.length} advisory finding(s) — run --validate-system-prompts for the full report`);let a=(e?.findings??[]).filter(e=>e.check===`raw-non-ascii`);if(a.length>0)throw Error(`system-prompt preflight found ${a.length} span(s) that would introduce raw non-ASCII into the binary; nothing was modified. Re-run with --validate-system-prompts for the full report.`)}let f=await ka(o);o=f.content;let p=f.results.filter(e=>e.applied),m=f.results.filter(e=>e.failed);if(f.results.length>0){J(`inlineBlobOverrides: ${p.length} applied, ${m.length} failed`);for(let e of m)console.log(`inline-blob: failed "${e.name}" (${e.filename}): ${e.details}`)}for(let e of f.results)l.push({id:`inline-blob:${e.filename}`,name:e.name,group:K.SYSTEM_PROMPTS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details});let h=await dr(o,r.version??``);o=h.content;for(let e of h.results)l.push({id:`reminder:${e.id}`,name:`Reminder: ${e.name} (${e.state})`,group:K.SYSTEM_REMINDERS,applied:e.applied,failed:e.failed,skipped:e.skipped,details:e.details,description:e.description});let g=await pa(o,r.version,void 0,i,d);o=g.newContent;let _=g.results.some(e=>e.applied&&[`system-prompt-identity`,`system-prompt-cli-identity-agent-sdk`,`system-prompt-claude-agent-identity-sdk`].includes(e.id)),v=[...g.results].sort((e,t)=>e.name.localeCompare(t.name));l.push(...v);let y=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),b=v.filter(e=>e.applied&&e.details).map(e=>y(`${e.name}: ${e.details}`)),x=e.settings.misc?.tableFormat??`default`,S=e.settings.misc?.showTweakccVersion??!0,C=e.settings.misc?.showPatchesApplied??!0,w=e.settings.misc?.enableModelCustomizations??!0,T=!!e.settings.misc?.swapRipgrepForFff,E=null;T&&(E=await Eu(),E||console.log(`patch: swapRipgrepForFff: no fff wrapper available for this platform — keeping ripgrep`));let O={"verbose-property":{fn:e=>Ge(e),condition:!r.nativeInstallationPath},"read-default-lines":{fn:e=>cu(e)},"context-limit":{fn:e=>ge(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Qe(e),condition:w&&!r.nativeInstallationPath},"thinking-block-styling":{fn:e=>zs(e),condition:r.version==null||_t(r.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>La(e)},"no-global-cache-scope":{fn:e=>Ga(e,d,_)},"fix-summarize-from-here":{fn:e=>Ka(e),condition:e.settings.misc?.fixSummarizeFromHere!==!1},"fix-rewind-summary-header":{fn:e=>qa(e),condition:e.settings.misc?.fixRewindSummaryHeader!==!1},"statusline-update-throttle":{fn:t=>Gs(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"clear-screen":{fn:e=>tu(e)},"strip-empty-system-reminders":{fn:e=>Ou(e)},"patches-applied-indication":{fn:e=>gt(e,D,b,S,C)},"model-customizations":{fn:e=>ud(e),condition:w},"show-more-items-in-select-menus":{fn:e=>le(e,25),condition:w},"table-format":{fn:e=>Yo(e,x),condition:x!==`default`},themes:{fn:t=>me(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(P.themes))},"thinking-verbs":{fn:t=>ke(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs&&JSON.stringify(e.settings.thinkingVerbs.verbs)!==JSON.stringify(P.thinkingVerbs.verbs)},"thinker-format":{fn:t=>be(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs&&e.settings.thinkingVerbs.format!==P.thinkingVerbs.format},"thinker-symbol-chars":{fn:t=>Ce(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(P.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>we(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==P.thinkingStyle.updateInterval&&(r.version==null||_t(r.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>Ee(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(P.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>Se(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==P.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>_e(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&e.settings.inputBox.removeBorder!==P.inputBox.removeBorder)},"input-chevron-color":{fn:t=>{let n=e.settings.inputBox.chevronIdleThemeColor;return ve(t,e.settings.themes?.[0]?.colors?.[n]??n)},condition:!!e.settings.inputBox?.chevronIdleThemeColor},"subagent-models":{fn:t=>rt(t,e.settings.subagentModels),condition:!!e.settings.subagentModels&&JSON.stringify(e.settings.subagentModels)!==JSON.stringify(P.subagentModels)},"thinking-visibility":{fn:e=>$e(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>us(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>fs(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>gs(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>vs(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>bs(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>Cs(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"suppress-rate-limit-warning":{fn:e=>ws(e),condition:!!e.settings.misc?.suppressRateLimitWarning},"session-color":{fn:e=>ou(e),condition:!!e.settings.misc?.sessionColor},"token-count-rounding":{fn:t=>Ys(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>Rs(e),condition:!!e.settings.misc?.enableRememberSkill},"agents-md":{fn:t=>Xs(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>oc(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>sc(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>lc(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"model-at-effort":{fn:e=>uc(e),condition:e.settings.misc?.modelAtEffort??!0},"filter-scroll-escape-sequences":{fn:e=>fc(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"max-effort-default":{fn:e=>gc(e),condition:!!e.settings.misc?.maxEffortDefault},"autonomous-operation-all-models":{fn:e=>_c(e),condition:!!e.settings.misc?.autonomousOperationAllModels},"refusal-fallback-model":{fn:t=>Wc(t,e.settings.misc?.refusalFallbackRoutes,e.settings.misc?.refusalFallbackMaxReturns),condition:!!e.settings.misc?.refusalFallbackModel},"output-style-turn-reminder":{fn:e=>Kc(e),condition:!!e.settings.misc?.outputStyleTurnReminder},"auto-mode-classifier-model":{fn:t=>Jc(t,e.settings.misc?.autoModeClassifierModel??`default`),condition:(e.settings.misc?.autoModeClassifierModel??`default`)!==`default`},"complexity-router":{fn:t=>bl(t,e.settings.complexityRouter),condition:e.settings.complexityRouter.enabled},"fable-plan":{fn:t=>Ul(t,e.settings.fablePlan),condition:e.settings.fablePlan.enabled},"complexity-router-models":{fn:e=>Tl(e),condition:e.settings.complexityRouter.enabled},"allow-custom-agent-models":{fn:e=>hc(e),condition:!!e.settings.misc?.allowCustomAgentModels},"unlock-responsive-mode":{fn:e=>mc(e),condition:!!e.settings.misc?.unlockResponsiveMode},"worktree-mode":{fn:e=>pc(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>Ms(e),condition:!!e.settings.misc?.enableSessionMemory},"swap-ripgrep-for-fff":{fn:e=>yu(e,E),condition:T&&!!E},"dream-mode":{fn:e=>Ns(e),condition:!!e.settings.misc?.enableDreamMode},"lean-memory-types":{fn:e=>Ps(e),condition:!!e.settings.misc?.enableLeanMemoryTypes},toolsets:{fn:t=>Lo(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.acceptEditsToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>Us(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking&&(r.version==null||_t(r.version,`2.1.85`)<0)},"mcp-batch-size":{fn:t=>Ws(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>Re(t,e.settings.userMessageDisplay),condition:!!(e.settings.userMessageDisplay&&JSON.stringify(e.settings.userMessageDisplay)!==JSON.stringify(P.userMessageDisplay))},"input-pattern-highlighters":{fn:t=>Ue(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>ss(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!r.nativeInstallationPath},"voice-mode":{fn:t=>ql(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>eu(e),condition:!!e.settings.misc?.enableChannelsMode},"suppress-deferred-tools":{fn:e=>ku(e),condition:!!e.settings.misc?.suppressDeferredTools},"claudemd-context-once-per-conversation":{fn:e=>Du(e),condition:e.settings.misc?.claudemdContextOncePerConversation??!1}},{content:k,results:A}=ad(o,O,i);o=k,l.push(...A);let N=A.filter(e=>e.failed);if(r.nativeInstallationPath&&N.length>0){let e=Error(`Refusing to repack the native binary: ${N.length} binary patch(es) failed (${N.map(e=>e.id).join(`, `)}) on Claude Code ${r.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 ${r.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(r.nativeInstallationPath){J(`Repacking modified claude.js into native installation: ${r.nativeInstallationPath}`);let e=u.join(Z,`native-claudejs-patched.js`);s.writeFileSync(e,o,`utf8`),J(`Saved patched JS from native to: ${e}`);let t=Buffer.from(o,`utf8`),i=await a.mkdtemp(u.join(n.tmpdir(),`tweakcc-native-`)),l=u.join(i,u.basename(r.nativeInstallationPath));try{await a.copyFile(r.nativeInstallationPath,l),await a.chmod(l,s.statSync(r.nativeInstallationPath).mode),await M(l,t,l,c),od(l);let e=r.nativeInstallationPath,n=u.join(u.dirname(e),`.${u.basename(e)}.tweakcc-${process.pid}`);try{await a.copyFile(l,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(i,{recursive:!0,force:!0})}}else{if(!r.cliPath)throw Error(`cliPath is required for NPM installations`);N.length>0&&console.warn(`tweakcc: ${N.length} patch(es) did not apply on Claude Code ${r.version}: ${N.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 Md(r.cliPath,o,`patch`)}return{config:await tf(e=>{e.changesApplied=!0}),results:l}},cd=[{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)`}],ld=e=>{let t=e.match(/(?<![$\w])([$\w]+)\.push\(\{value:[$\w]+,label:[^,]{1,40},description:[^"]{0,40}"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) |,)${q(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)},ud=e=>{if(e.includes(`"value":"claude-opus-4-6"`))return console.log(`patch: modelCustomizations: custom models already present — skipping`),e;let t=ld(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=cd.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return V(e,a,i,n,n),a};let dd=!1,fd=!1,pd=!1;const md=()=>dd,hd=()=>fd,gd=()=>pd,_d=()=>{dd=!0},vd=()=>{fd=!0,dd=!0},yd=()=>{pd=!0},J=(e,...t)=>{md()&&console.log(e,...t)},Y=(e,...t)=>{hd()&&console.log(e,...t)},X=e=>e.replace(/[\u0080-\uffff]/g,e=>`\\u`+e.charCodeAt(0).toString(16).padStart(4,`0`));function bd(){try{let e=p.join(m.homedir(),`.claude.json`);return JSON.parse(f.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function xd(e){try{let t=p.join(m.homedir(),`.claude.json`),n=JSON.parse(f.readFileSync(t,`utf8`));n.theme=e,f.writeFileSync(t,JSON.stringify(n,null,2))}catch{}}function Sd(){try{let e=p.join(m.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(f.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 Cd(){try{let e=p.join(m.homedir(),`.claude`,`settings.json`),t=JSON.parse(f.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=cd.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function wd(e){process.platform===`win32`?h.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?h.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():h.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function Td(e){if(process.platform===`win32`)h.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)h.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=p.dirname(e);h.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function Ed(e,t=`md`){let n=process.env.VISUAL||process.env.EDITOR||(process.platform===`win32`?`notepad`:`vi`),r=p.join(m.tmpdir(),`tweakcc-edit-${process.pid}-${Date.now()}.${t}`);try{f.writeFileSync(r,e,`utf8`);let t=h.spawnSync(`${n} "${r}"`,{stdio:`inherit`,shell:!0});return t.error||typeof t.status==`number`&&t.status!==0?null:f.readFileSync(r,`utf8`)}catch{return null}finally{try{f.unlinkSync(r)}catch{}}}function Dd(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 Od(e){if(!Dd(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 kd(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=g.createHash(t),o=f.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 Ad(e,t){try{let n=await o.stat(e);return J(`[${t}] Original file mode for ${e}: ${(n.mode&511).toString(8)}`),n.mode}catch(n){return J(`[${t}] Could not stat ${e} (error: ${n}), using default mode 755`),493}}async function jd(e,t,n,r){let i=`${e}.tweakcc-tmp-${process.pid}`;try{await r(i),await o.chmod(i,t),await o.rename(i,e)}catch(e){try{await o.unlink(i)}catch{}throw e}J(`[${n}] Replaced ${e} via atomic rename, mode ${(t&511).toString(8)}`)}async function Md(e,t,n=`replace`){await jd(e,await Ad(e,n),n,e=>o.writeFile(e,t))}async function Nd(e,t,n=`replace`){await jd(e,await Ad(e,n),n,e=>o.copyFile(t,e))}async function Pd(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 Fd=e=>e.startsWith(`~`)?p.join(m.homedir(),e.slice(1)):e,Id=(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]},Ld=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function Rd(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]=Rd(n[e],r)):n[e]=r}return n}const zd=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`)},Bd=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)},Vd=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function Hd(){try{let e=await o.readFile(Q,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=d.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await Yd(),await o.writeFile(Q,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 Ud=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return Fd(e);let t=d.join(r.homedir(),`.tweakcc`),n=d.join(r.homedir(),`.claude`,`tweakcc`),i=process.env.XDG_CONFIG_HOME;try{if(c.existsSync(t))return t}catch(e){J(`Failed to check if ${t} exists: ${e}`)}try{if(c.existsSync(n))return n}catch(e){J(`Failed to check if ${n} exists: ${e}`)}return i?d.join(i,`tweakcc`):t},Z=Ud(),Q=d.join(Z,`config.json`),Wd=d.join(Z,`cli.js.backup`),Gd=d.join(Z,`native-binary.backup`),$=d.join(Z,`system-prompts`),Kd=d.join(Z,`system-reminders`),qd=d.join(Z,`prompt-data-cache`),Jd=()=>{let e=Z,n=r.homedir(),i=[d.join(n,`.tweakcc`),d.join(n,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?d.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(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as e,d as t,g as n,gt as r,ht as i,j as a,l as o,m as s,mt as c,n as ee,p as l,r as u,w as d}from"./config-
|
|
1
|
+
import{T as e,d as t,g as n,gt as r,ht as i,j as a,l as o,m as s,mt as c,n as ee,p as l,r as u,w as d}from"./config-B24_Ecyb.mjs";import{Box as f,Text as p,render as m,useInput as h}from"ink";import g,{useState as _}from"react";import*as te from"node:os";import v from"node:os";import*as y from"node:fs/promises";import b from"node:fs/promises";import x from"path";import{jsx as S,jsxs as C}from"react/jsx-runtime";import w from"which";import{globbySync as T}from"globby";const E=(()=>{let e=[],t=process.platform==`win32`?v.homedir().replace(/\\/g,`/`):v.homedir(),n=`node_modules/@anthropic-ai/claude-code`,r=(t,n=!1)=>{if(n)try{let n=T(t,{onlyFiles:!1});e.push({pattern:t,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?s(`Permission denied accessing: ${t} (${n.code})`):s(`Error expanding glob pattern "${t}": ${n instanceof Error?n.message:String(n)}`),e.push({pattern:t,isGlob:!0,expandedPaths:[]})}else e.push({pattern:t,isGlob:!1,expandedPaths:[t]})};return r(`${v.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform==`win32`?(r(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),r(`${t}/AppData/Roaming/npm/${n}`),r(`${t}/AppData/Roaming/nvm/*/${n}`,!0),r(`${t}/AppData/Local/Yarn/config/global/${n}`),r(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),r(`C:/nvm4w/nodejs/${n}`),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/AppData/Roaming/Yarn/config/global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/Bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0),r(`${t}/AppData/Local/mise/installs/node/*/${n}`,!0),r(`${t}/AppData/Local/mise/installs/npm-anthropic-ai-claude-code/*/${n}`,!0)):(process.platform==`darwin`&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/Library/Caches/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0)),r(`${t}/.local/lib/${n}`),r(`${t}/.local/share/${n}`),r(`${t}/.npm-global/lib/${n}`),r(`${t}/.npm-packages/lib/${n}`),r(`${t}/.npm/lib/${n}`),r(`${t}/npm/lib/${n}`),r(`/etc/${n}`),r(`/lib/${n}`),r(`/opt/node/lib/${n}`),r(`/usr/lib/${n}`),r(`/usr/local/lib/${n}`),r(`/usr/share/${n}`),r(`/var/lib/${n}`),r(`/opt/homebrew/lib/${n}`),r(`${t}/.linuxbrew/lib/${n}`),r(`${t}/.config/yarn/global/${n}`),r(`${t}/.yarn/global/${n}`),r(`${t}/.bun/install/global/${n}`),r(`${t}/.pnpm-global/${n}`),r(`${t}/.pnpm-global/*/${n}`,!0),r(`${t}/pnpm-global/${n}`),r(`${t}/pnpm-global/*/${n}`,!0),r(`${t}/.local/share/pnpm/global/${n}`),r(`${t}/.local/share/pnpm/global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/.local/share/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`/usr/local/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/lib/${n}`),r(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),r(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),r(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nodenv/versions/*/lib/${n}`,!0),r(`${t}/.nvs/*/lib/${n}`,!0),r(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0)),process.platform==`win32`&&e.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),e})().flatMap(e=>e.expandedPaths),ne=(()=>{let e=process.platform===`win32`?v.homedir().replace(/\\/g,`/`):v.homedir(),t=[],n=(e,n=!1)=>{if(n)try{let n=T(e,{onlyFiles:!0});t.push({pattern:e,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?s(`Permission denied accessing: ${e} (${n.code})`):s(`Error expanding glob pattern "${e}": ${n instanceof Error?n.message:String(n)}`),t.push({pattern:e,isGlob:!0,expandedPaths:[]})}else t.push({pattern:e,isGlob:!1,expandedPaths:[e]})};if(n(`${e}/.local/bin/claude`),process.platform===`win32`&&(n(`${e}/.nvm/versions/node/v22.21.1/lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`),n(`${e}/.local/bin/claude.exe`)),n(`${e}/.local/share/claude/versions/*`,!0),process.platform!==`win32`){let t=`lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`,r=process.env.MISE_DATA_DIR||`${e}/.local/share/mise`;n(`${r}/installs/node/*/${t}`,!0),n(`${r}/installs/npm-anthropic-ai-claude-code/*/${t}`,!0)}return process.platform===`win32`&&t.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),t})().flatMap(e=>e.expandedPaths);var D=class extends Error{constructor(e){super(e),this.name=`InstallationDetectionError`}};let O=null;async function re(){return O||=(async()=>{try{let{WASMagic:e}=await import(`wasmagic`);return await e.create()}catch(e){return s(`WASMagic initialization failed (likely SIMD unsupported on this CPU):`,e),s(`Using fallback file type detection`),null}})(),O}const ie=Buffer.from([127,69,76,70]),ae=Buffer.from([254,237,250,206]),oe=Buffer.from([254,237,250,207]),se=Buffer.from([206,250,237,254]),k=Buffer.from([207,250,237,254]),A=Buffer.from([202,254,186,190]),j=Buffer.from([77,90]);function M(e){if(e.length===0)return null;if(e[0]===35&&e[1]===33&&e.subarray(0,Math.min(256,e.length)).toString(`utf8`).split(`
|
|
2
2
|
`)[0].includes(`node`))return s(`detectFileTypeFallback: Detected JavaScript via shebang`),`javascript`;if(e.length>=4){let t=e.subarray(0,4);if(t.equals(ie))return s(`detectFileTypeFallback: Detected ELF binary`),`binary`;if(t.equals(ae)||t.equals(oe)||t.equals(se)||t.equals(k)||t.equals(A))return s(`detectFileTypeFallback: Detected Mach-O binary`),`binary`}if(e.length>=2&&e.subarray(0,2).equals(j))return s(`detectFileTypeFallback: Detected PE binary`),`binary`;let t=Math.min(512,e.length),n=0,r=0;for(let i=0;i<t;i++){let t=e[i];(t>=32&&t<=126||t===9||t===10||t===13)&&n++,t===0&&r++}if(r>0)return s(`detectFileTypeFallback: Detected binary (${r} null bytes in first ${t} bytes)`),`binary`;let i=n/t;return i>.9?(s(`detectFileTypeFallback: Detected JavaScript via text heuristic (${Math.round(i*100)}% printable)`),`javascript`):(s(`detectFileTypeFallback: Unknown file type (${Math.round(i*100)}% printable)`),null)}async function N(e,t=4096){try{let n=await b.open(e,`r`);try{let e=Buffer.allocUnsafe(t),{bytesRead:r}=await n.read({buffer:e,position:0,length:t});return r<=0?null:e.subarray(0,r)}finally{await n.close()}}catch(e){return s(`Failed to read file prefix:`,e),null}}async function P(e){if(process.platform===`win32`)return e;let t=await r(e);return t?(s(`maybeResolveNixWrapper: resolved Nix wrapper ${e} -> ${t}`),t):e}async function F(e){try{let t=await b.realpath(e);s(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await N(t);if(!n)return s(`resolvePathToInstallationType: Could not read file prefix`),null;let r=await re();if(r&&typeof r.detect==`function`){let e=r.detect(n)||null;if(e){let n=e.toLowerCase();return s(`resolvePathToInstallationType: Detected mime type: ${n}`),n.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:n.startsWith(`text/`)?(s(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:await P(t)}}}s(`resolvePathToInstallationType: Using fallback file type detection`);let i=M(n);return i===`javascript`?{kind:`npm-based`,resolvedPath:t}:i===`binary`?{kind:`native-binary`,resolvedPath:await P(t)}:(s(`resolvePathToInstallationType: Fallback could not determine file type`),null)}catch(e){return s(`resolvePathToInstallationType: Error:`,e),null}}async function I(){s(`getClaudeFromPath: PATH = ${process.env.PATH}`),s(`getClaudeFromPath: PATHEXT = ${process.env.PATHEXT}`);try{let e=await w(`claude`);return s(`getClaudeFromPath: Found claude at ${e}`),e}catch{return s(`getClaudeFromPath: claude not found on PATH`),null}}function L(e){let t=/\bVERSION:"(\d+\.\d+\.\d+)"/g,n=new Map,r;for(;(r=t.exec(e))!==null;){let e=r[1];n.set(e,(n.get(e)||0)+1)}if(n.size===0)return null;let i=0,a;for(let[e,t]of n.entries())s(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&s(`Extracted version ${a} (${i} occurrences)`),a||null}async function R(e){let t=L(await b.readFile(e,`utf8`));if(!t)throw Error(`No VERSION strings found in JS file: ${e}`);return t}async function z(e){let{data:t,error:n}=await c(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}${n?` (${n})`:``}`);let r=L(t.toString(`utf8`));if(!r)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return r}function B(e){let t=x.basename(e).match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function V(e,t){let n=B(e);return n?(s(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?R(e):z(e)}async function H(){let e=[],t=new Set;for(let r of E){let i=x.join(r,`cli.js`);try{if(await n(i)){let n=await b.realpath(i).catch(()=>i);if(t.has(n))continue;t.add(n),s(`collectCandidates: Found cli.js at ${n}`);let r=await R(n);e.push({path:n,kind:`npm-based`,version:r})}}catch(e){s(`collectCandidates: Error checking ${i}:`,e)}}for(let r of ne)try{if(await n(r)){let n=await b.realpath(r).catch(()=>r);if(t.has(n))continue;t.add(n);let i=await P(n);s(`collectCandidates: Found native binary at ${n}${i===n?``:` (resolved -> ${i})`}`);let a=await V(i,`native-binary`);e.push({path:i,kind:`native-binary`,version:a})}}catch(e){s(`collectCandidates: Error checking ${r}:`,e)}return[...e].sort((e,t)=>l(t.version,e.version))}function U(e){return e.map(e=>` • ${e.path} (${e.kind}, v${e.version})`).join(`
|
|
3
3
|
`)}function W(e){return` 2. Set ccInstallationPath in your config file (${u}):
|
|
4
4
|
|