tweakcc-fixed 2.7.23 → 2.7.24
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/dist/{config-BqRjOmoZ.mjs → config-DtZztjxv.mjs} +3 -3
- package/dist/{content-CD_fyzYM.mjs → content-DBHwlD7l.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/{nativeInstallation-DXp_GwWa.mjs → nativeInstallation-Dzn3Uvig.mjs} +1 -1
- package/package.json +1 -1
|
@@ -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{spawnSync as _}from"node:child_process";import v from"gray-matter";import{fileURLToPath as y}from"node:url";import{Worker as b}from"node:worker_threads";import{diffWordsWithSpace as x}from"diff";import*as S from"node:crypto";let C=null;async function w(){if(C!==null)return C;try{return await import(`node-lief`),C=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{spawnSync as _}from"node:child_process";import v from"gray-matter";import{fileURLToPath as y}from"node:url";import{Worker as b}from"node:worker_threads";import{diffWordsWithSpace as x}from"diff";import*as S from"node:crypto";let C=null;async function w(){if(C!==null)return C;try{return await import(`node-lief`),C=await import(`./nativeInstallation-Dzn3Uvig.mjs`),C}catch(e){return J(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&J(e),null}}async function T(e,t){let n=await w();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 E(e,t,n,r){let i=await w();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 D(e){let t=await w();return t?t.resolveNixBinaryWrapper(e):null}const O=`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:
|
|
@@ -753,9 +753,9 @@ const filtered=chunk
|
|
|
753
753
|
return _origStdoutWrite.call(process.stdout,filtered,encoding,cb);
|
|
754
754
|
};
|
|
755
755
|
// SCROLLING FIX PATCH END
|
|
756
|
-
`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},Ra=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?e:(console.error(`patch: worktreeMode: failed to find worktree gate function pattern`),null);let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},za=e=>{let t=e,n=t.match(/,model:([$\w]+)\.enum\(([$\w]+)\)\.optional\(\)/);if(!n||n.index===void 0)return t.match(/let\s+[$\w]+\s*=\s*([$\w]+)\s*&&\s*typeof\s+\1\s*===\s*"string"\s*&&\s*[$\w]+\.includes\(\1\)/)?(console.error(`patch: allowCustomAgentModels: failed to find Zod enum pattern`),null):t;let r=n[1],i=n[2],a=`,model:${r}.string().optional()`,o=n.index,s=o+n[0].length;t=t.slice(0,o)+a+t.slice(s),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},Ba=e=>{let t=e;{let e=!1;for(let n of[`claude-opus-4-8`,`claude-opus-4-7`]){let r=RegExp(`(id:"${n}"[\\s\\S]{0,900}?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]"[\s\S]{0,900}?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},Va=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*\}/);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},Ha=[`Everything a person will read follows these rules: your replies, files you write, commit messages, pull request and issue text. Messages to other agents do not.`,`IMPORTANT. Answer first. Put the result in the first line. Never open with preamble, a restatement of the question, or a summary of what you are about to say, and never build up to the answer. A yes-or-no question gets yes or no in the first word.`,`Write plainly. Use the ordinary word. Say what a thing is rather than naming it with a metaphor: not "this is the load-bearing constraint" but "this line breaks if you change it". Say what a program did in literal terms: a client loaded or ignored a file, a rule did not "land", "fire", "win" or turn out to be "dead weight". Never invent a term and then reuse it as if the user had agreed to it, and never use a term you coined earlier in the session without saying plainly what it means. If a phrase would sound strange said out loud to a colleague, it is the wrong phrase.`,`Length is not the problem and shortness is not the goal. A long answer in plain words is fine. Never compress into fragments, abbreviations, arrow chains or jargon to make a reply shorter. Cut padding, not substance: opening announcements, restatements of the question, recaps of what you just did, closers that ask whether the reader needs anything else, apologies repeated more than once, and hedging words that carry no real uncertainty. Match the size of the answer to the size of the question, so a small question gets a small answer.`,`Keep a reply short by leaving things out, never by writing tighter. Include what changes what the reader does or believes next, and drop the rest: alternatives you rejected, steps that went as expected, and background the reader already has. An answer is the right length when everything left in it is doing work.`,`One kind of reply is never trimmed: reporting work that did not succeed. Name every package and version, every test that failed and how many, every step you skipped, and everything you could not check along with the reason. Say plainly which parts you verified and which you are taking on trust. Selectivity does not apply here, because the reader cannot tell what is missing.`,`Plain does not mean more certain. When you put something in simpler words, a hedge stays a hedge, an estimate stays an estimate, and a number stays that number rather than becoming "most" or "nearly all". Do not promote a suggestion into an instruction, and do not call something by a kind it does not have, such as calling a directory a branch.`,`Make it skimmable. Bold the key terms. Keep paragraphs short with a blank line between them. Headers, short lists and tables are welcome wherever they help the reader find things, and anything long should have them.`,`State problems and failures matter-of-factly: what happened, why, and what fixes it. Do not withhold the conclusion until the end. Do not turn an observation into an aphorism, and do not end a section with a clever line that restates it.`,`Replace stock phrases with the plain thing they stand for. Instead of "load-bearing", say what actually breaks if it changes. Instead of "surface area", say what it touches. Instead of "blast radius", say what else this breaks. Instead of "footgun", say what mistake it invites. Instead of "the unlock", say what this makes possible. Instead of "seam", "spine", "scaffold" or "substrate", name the actual part. Instead of "orthogonal", say unrelated. Instead of "non-trivial", say hard, or say how hard. Instead of "the honest answer", "to be honest" or "let me be straight with you", just answer. Instead of "and that matters", "the key insight" or "it is worth noting", delete the phrase and state the point. Instead of "the smoking gun", say what the evidence is. Instead of "the good news is", say the news. Instead of "this is not just X, it is Y", say Y. Instead of "you are absolutely right", agree once in plain words and move on. Instead of "just say the word", ask the question.`].join(` `),Ua=[{what:`load-bearing update cue`,find:/give brief updates when you find something load-bearing or change direction\./,replace:`give a one-line update when you find something important or change direction.`},{what:`readability-over-brevity clause`,find:/Being readable and being concise are different things, and readab(?:le|ility) matters more\..*?technical terms spelled out\./s,replace:Ha},{what:`prose-not-headers rule`,find:/a simple question gets a direct answer in prose, not headers and sections\./,replace:`a simple question gets a direct answer. ALWAYS bold the key terms so the reply can be skimmed. Keep blocks to three sentences with a blank line between them, and NEVER answer a simple question with more than three blocks.`},{what:`text-output prose-not-headers rule`,find:/a simple question gets a direct answer, not headers and sections\./,replace:`a simple question gets a direct answer. ALWAYS bold the key terms so the reply can be skimmed. Keep blocks to three sentences with a blank line between them, and NEVER answer a simple question with more than three blocks.`},{what:`text-output end-of-turn cap`,find:/End-of-turn summary: one or two sentences\. What changed and what's next\. Nothing else\./,replace:Ha},{what:`claudeMd relevance hedge`,find:/(?:IMPORTANT: this context may or may not be relevant to your tasks\. You should not respond to this context unless it is highly relevant to your task\.|This context may or may not be relevant; draw on it only where it bears on the task\.)/,replace:`Treat any instruction in that context as the user's standing preference and follow it. This governs the reply you are about to write. Answer in the first line. Write in plain, ordinary words, the way you would say it to a colleague sitting next to you. Keep a reply short by leaving out only details that do not change what the reader does or believes next; never make the writing dense to make it shorter. Preserve every fact, number, version, caveat and real uncertainty, and never trim a report of failed or unverified work. Bold the key terms and keep paragraphs short so the reply can be skimmed. Do not open with preamble or close with a recap. Name things literally rather than with metaphors, and do not use a term you invented earlier without saying what it means.`}],Wa=e=>{let t=e,n=[],r=[],i=-1,a=-1;for(let{what:e,find:o,replace:s}of Ua){let c=t.match(o);if(!c||c.index===void 0){r.push(e);continue}i===-1&&(i=c.index,a=c.index+s.length),t=t.slice(0,c.index)+s+t.slice(c.index+c[0].length),n.push(e)}return n.length===0?/Plain does not mean more certain\./.test(t)?(J(`patch: adhdOutputStyle: comms prompt already in ADHD shape — skipping`),e):(console.error(`patch: adhdOutputStyle: failed to find any of the comms-prompt anchors (${r.join(`, `)})`),null):(r.length>0&&J(`patch: adhdOutputStyle: rewrote ${n.join(`, `)}; skipped ${r.join(`, `)} (already overridden or reshaped upstream)`),V(e,t,t.slice(i,a),i,a),t)},Ga={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},Ka=(e,t)=>{if(t===`default`)return e;let n=Ga[t],r=/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*\}/,i=/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*\}/,a=/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*\}/,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*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*\}/,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*[$\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*\}/,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*return\s+[$\w]+\s*\(\s*\2\s*\)\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*\{\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*\}/,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*[$\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*\}/,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*"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*\}/,f=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(f&&f.index!==void 0){let[t,r]=f,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,f.index)+i+e.slice(f.index+t.length);return V(e,a,i,f.index,f.index+t.length),a}let p=e.match(d);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(u);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(l);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(c)||e.match(s)||e.match(o)||e.match(a)||e.match(i)||e.match(r);if(g&&g.index!==void 0){let[t,r]=g,i=`function ${r}(){return "${n}"}`,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}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)},qa=`__tweakccRouterClassify`,Ja=1e3,Ya=(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(`
|
|
756
|
+
`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},Ra=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_worktree_mode"/);if(!t||t.index===void 0)return e.includes(`EnterWorktree`)?e:(console.error(`patch: worktreeMode: failed to find worktree gate function pattern`),null);let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},za=e=>{let t=e,n=t.match(/,model:([$\w]+)\.enum\(([$\w]+)\)\.optional\(\)/);if(!n||n.index===void 0)return t.match(/let\s+[$\w]+\s*=\s*([$\w]+)\s*&&\s*typeof\s+\1\s*===\s*"string"\s*&&\s*[$\w]+\.includes\(\1\)/)?(console.error(`patch: allowCustomAgentModels: failed to find Zod enum pattern`),null):t;let r=n[1],i=n[2],a=`,model:${r}.string().optional()`,o=n.index,s=o+n[0].length;t=t.slice(0,o)+a+t.slice(s),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},Ba=e=>{let t=e;{let e=!1;for(let n of[`claude-opus-4-8`,`claude-opus-4-7`]){let r=RegExp(`(id:"${n}"[\\s\\S]{0,900}?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]"[\s\S]{0,900}?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},Va=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*\}/);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},Ha=[`Everything a person will read follows these rules: your replies, files you write, commit messages, pull request and issue text. Messages to other agents do not.`,`IMPORTANT. Show the thing rather than describing it. Give the command, not a description of running it. Give the path and line, not a description of where. Give the value, the number or the error string itself. Steps the reader performs go in a numbered list, one action each, rather than a paragraph walking through them. If a sentence describes an action, a location or a value, replace the sentence with the action, the location or the value.`,`Answer first. Put the result in the first line. Never open with preamble, a restatement of the question, or a summary of what you are about to say, and never build up to the answer. A yes-or-no question gets yes or no in the first word.`,`Say each thing once. Never write a sentence whose only job is to restate, sharpen or dramatise the sentence before it. Do not announce what you are about to say. Do not defend a choice nobody questioned. Do not repeat facts back that the reader just gave you. Do not explain what an experienced reader already knows. Never close with an offer of further help: if a decision is the reader's, ask the question plainly, once.`,`Length is not the problem and shortness is not the goal. A long answer in plain words is fine. Never compress into fragments, abbreviations, arrow chains or jargon to make a reply shorter. Match the size of the answer to the size of the question, so a small question gets a small answer.`,`Keep a reply short by leaving things out, never by writing tighter. Include what changes what the reader does or believes next, and drop the rest: alternatives you rejected, steps that went as expected, and background the reader already has. An answer is the right length when everything left in it is doing work.`,`One kind of reply is never trimmed: reporting work that did not succeed. Name every package and version, every test that failed and how many, every step you skipped, and everything you could not check along with the reason. Say plainly which parts you verified and which you are taking on trust. Selectivity does not apply here, because the reader cannot tell what is missing.`,`Plain does not mean more certain. When you put something in simpler words, a hedge stays a hedge, an estimate stays an estimate, and a number stays that number rather than becoming "most" or "nearly all". Keep both sides of a count: "340 of 347 passing" does not become "7 failing", and "6 of 9 packages" keeps the 9. Keep every qualifier that limits where or when something is true, such as "in the browser only", because dropping one turns a narrow problem into a general one. Do not promote a suggestion into an instruction, and do not call something by a kind it does not have, such as calling a directory a branch.`,`Do not add technical detail you were not given and did not check, because invented detail reads exactly like observed detail and the reader cannot tell them apart. If you are inferring rather than reporting, say so in the same sentence. Passing tests mean those tests passed, not that the feature works.`,`Write plainly. Use the ordinary word. Say what a thing is rather than naming it with a metaphor: not "this is the load-bearing constraint" but "this line breaks if you change it". Say what a program did in literal terms: a client loaded or ignored a file, a rule did not "land", "fire", "win" or turn out to be "dead weight". Never invent a term and then reuse it as if the user had agreed to it, and never carry shorthand you built up while working into a summary written for someone who did not watch you work.`,`Make it skimmable. Bold the key terms. Keep paragraphs short with a blank line between them. A heading earns its place above a group of related points, never above a single line, and never over something the sentence itself already announces.`,`State problems and failures matter-of-factly: what happened, why, and what fixes it. Do not withhold the conclusion until the end. Do not turn an observation into an aphorism, and do not end a section with a clever line that restates it.`,`Replace stock phrases with the plain thing they stand for. Instead of "load-bearing", say what actually breaks if it changes. Instead of "surface area", say what it touches. Instead of "blast radius", say what else this breaks. Instead of "footgun", say what mistake it invites. Instead of "the unlock", say what this makes possible. Instead of "seam", "spine", "scaffold" or "substrate", name the actual part. Instead of "orthogonal", say unrelated. Instead of "non-trivial", say hard, or say how hard. Instead of "the honest answer", "to be honest" or "let me be straight with you", just answer. Instead of "and that matters", "the key insight" or "it is worth noting", delete the phrase and state the point. Instead of "the smoking gun", say what the evidence is. Instead of "the good news is", say the news. Instead of "this is not just X, it is Y", say Y. Instead of "you are absolutely right", agree once in plain words and move on. Instead of "just say the word", ask the question.`,`Never use these words: genuinely, meaningfully, crucially, fundamentally, essentially, materially, here is the thing, the real question is, the upshot, good catch, great question. Never use em dashes; use a comma, a full stop, or two sentences.`].join(` `),Ua=[{what:`load-bearing update cue`,find:/give brief updates when you find something load-bearing or change direction\./,replace:`give a one-line update when you find something important or change direction.`},{what:`readability-over-brevity clause`,find:/Being readable and being concise are different things, and readab(?:le|ility) matters more\..*?technical terms spelled out\./s,replace:Ha},{what:`prose-not-headers rule`,find:/a simple question gets a direct answer in prose, not headers and sections\./,replace:`a simple question gets a direct answer. ALWAYS bold the key terms so the reply can be skimmed. Keep blocks to three sentences with a blank line between them, and NEVER answer a simple question with more than three blocks.`},{what:`text-output prose-not-headers rule`,find:/a simple question gets a direct answer, not headers and sections\./,replace:`a simple question gets a direct answer. ALWAYS bold the key terms so the reply can be skimmed. Keep blocks to three sentences with a blank line between them, and NEVER answer a simple question with more than three blocks.`},{what:`text-output end-of-turn cap`,find:/End-of-turn summary: one or two sentences\. What changed and what's next\. Nothing else\./,replace:Ha},{what:`claudeMd relevance hedge`,find:/(?:IMPORTANT: this context may or may not be relevant to your tasks\. You should not respond to this context unless it is highly relevant to your task\.|This context may or may not be relevant; draw on it only where it bears on the task\.)/,replace:`Treat any instruction in that context as the user's standing preference and follow it. This governs the reply you are about to write. Answer in the first line. Show the command, the path or the value rather than describing it. Write in plain, ordinary words, the way you would say it to a colleague sitting next to you. Say each thing once: no sentence that only restates the one before, no announcing what is coming, no defending a choice nobody questioned, and no closing offer of help. Keep a reply short by leaving out only details that do not change what the reader does or believes next; never make the writing dense to make it shorter. Preserve every fact, number, version, caveat and real uncertainty, keep both sides of a count, and never trim a report of failed or unverified work. Bold the key terms and keep paragraphs short so the reply can be skimmed. Name things literally rather than with metaphors, and do not use a term you invented earlier without saying what it means.`}],Wa=e=>{let t=e,n=[],r=[],i=-1,a=-1;for(let{what:e,find:o,replace:s}of Ua){let c=t.match(o);if(!c||c.index===void 0){r.push(e);continue}i===-1&&(i=c.index,a=c.index+s.length),t=t.slice(0,c.index)+s+t.slice(c.index+c[0].length),n.push(e)}return n.length===0?/Plain does not mean more certain\./.test(t)?(J(`patch: adhdOutputStyle: comms prompt already in ADHD shape — skipping`),e):(console.error(`patch: adhdOutputStyle: failed to find any of the comms-prompt anchors (${r.join(`, `)})`),null):(r.length>0&&J(`patch: adhdOutputStyle: rewrote ${n.join(`, `)}; skipped ${r.join(`, `)} (already overridden or reshaped upstream)`),V(e,t,t.slice(i,a),i,a),t)},Ga={sonnet:`claude-sonnet-4-6`,haiku:`claude-haiku-4-5`},Ka=(e,t)=>{if(t===`default`)return e;let n=Ga[t],r=/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*\}/,i=/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*\}/,a=/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*\}/,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*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*\}/,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*[$\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*\}/,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*return\s+[$\w]+\s*\(\s*\2\s*\)\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*\{\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*\}/,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*[$\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*\}/,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*"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*\}/,f=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(f&&f.index!==void 0){let[t,r]=f,i=`function ${r}(){return{value:"${n}",src:"default"}}`,a=e.slice(0,f.index)+i+e.slice(f.index+t.length);return V(e,a,i,f.index,f.index+t.length),a}let p=e.match(d);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(u);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(l);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(c)||e.match(s)||e.match(o)||e.match(a)||e.match(i)||e.match(r);if(g&&g.index!==void 0){let[t,r]=g,i=`function ${r}(){return "${n}"}`,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}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)},qa=`__tweakccRouterClassify`,Ja=1e3,Ya=(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(`
|
|
757
757
|
`),p=(typeof e.systemPrompt==`string`&&e.systemPrompt.trim()?e.systemPrompt:O).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 __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(),__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 ${qa}(__text,__mode,__model){try{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>${Ja})__st.log.splice(0,__st.log.length-${Ja});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 __res=null;try{__res=await __tweakccRouterClassifyLlm(__input,__max)}catch(__e){__res=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){}}`},Xa=(e,t,n,r)=>{let i=/(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\)\}/,a=/(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\}/,o=/(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\}/,s=e.match(i),c=s||e.match(a)||e.match(o);if(!c||c.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 l=c[1],u=c[2],d=c[3],f=c[4],p=c[6],m=c[7];if(s){let t=s[5].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;p=r[4],m=r[5]}let h=`var __st=__tweakccRouterState();if(__st.baseline===void 0)__st.baseline=(${d}==null?null:${d});let __twkRE=__st.effort;if(__twkRE&&${f}==null&&(${d}==null||${d}===__st.baseline)){if(__twkRE==="max"&&!${p}(${u}))__twkRE="high";if(__twkRE==="xhigh"&&!${m}(${u}))__twkRE="high";return __twkRE}`,g=Ya(t,n,r,ms(e))+l+h+c[0].slice(l.length),_=c.index,v=_+c[0].length,y=e.slice(0,_)+g+e.slice(v);return V(e,y,g,_,v),y},Za=e=>{let t=e.match(/if\(([$\w]+)===null&&([$\w]+)!=="prompt"\)throw Error\(`Mode: \$\{\2\} requires a string input\.`\);/);if(!t||t.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 n=t[1],r=t[2],i=[...e.slice(Math.max(0,t.index-4e3),t.index).matchAll(/([$\w]+)\.options\.mainLoopModel/g)],a=i[i.length-1],o=`await ${qa}(${n},${r},${a?`${a[1]}.options.mainLoopModel`:`void 0`});`,s=t.index+t[0].length,c=e.slice(0,s)+o+e.slice(s);return V(e,c,o,s,s),c},Qa=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)__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},$a=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&&(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},eo=e=>{let t=e.match(/onRestoreMessage:\(([$\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&&(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},to=e=>{let t=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:/),n=e.match(/function ([$\w]+)\(\)\{return\{agentType:"main",agentId:[$\w]+\(\)\}\}/);return t&&n?{gB:t[1],km:n[1]}:null},no=e=>{let t=e.match(/getSessionId\(\)\{return ([$\w]+)\(\)\}/);return t?t[1]:null},ro=(e,t)=>{if(e.includes(qa))return J(`patch: complexityRouter: already patched - skipping`),e;let n=to(e);if(!n)return console.warn(`patch: complexityRouter: gB/km side-call helpers not found in this CC build - cannot route without the Haiku classifier; skipping the router`),e;let r=no(e);r||J(`patch: complexityRouter: session-id accessor not found - cross-session summary persistence disabled (in-memory only)`);let i=Xa(e,t,n,r);if(i===null)return null;if(i===e)return e;let a=Za(i);return a===null?null:a===i?(J(`patch: complexityRouter: submit handler absent - reverting the resolver wrap too (all-or-nothing no-op)`),e):eo($a(Qa(a)))},U=`fableplan`,io=`globalThis.__tweakccFablePlanEffort`,ao=e=>{let t=e.match(/(\[(?:"[\w[\]]+",)*"opusplan"(?:,"[\w[\]]+")*\])(\s*,\s*[$\w]+\s*=\s*\["sonnet","opus","haiku")/);if(t&&t[1].includes(`"${U}"`))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)+`,"${U}"]`+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},oo=(e,t,n)=>{let r=e.match(/(function ([$\w]+)\(([$\w]+)\)\{let\{permissionMode:([$\w]+),mainLoopModel:([$\w]+),exceeds200kTokens:([$\w]+)=!1\}=\3,([$\w]+)=([$\w]+)\(\);)/);if(!r||r.index===void 0)return console.error(`patch: fablePlan: failed to find the plan-mode model resolver (uM shape)`),null;let[,i,,,a,,,o]=r,s=i+`if(${o}==="${U}"){${io}=${a}==="plan"?"${t.planEffort}":"${t.execEffort}";return ${n}(${a}==="plan"?"${t.planModel}":"${t.execModel}")}${io}=void 0;`,c=e.slice(0,r.index)+s+e.slice(r.index+r[0].length);return V(e,c,s,r.index,r.index+r[0].length),c},so=(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"${U}":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},co=(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"${U}":${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}},lo=(e,t)=>{let n=e.match(/(function [$\w]+\(([$\w]+),([$\w]+)\)\{let ([$\w]+)=[$\w]+\(\2\),([$\w]+)=[$\w]+\.ANTHROPIC_CUSTOM_MODEL_OPTION;)/);if(!n||n.index===void 0)return console.error(`patch: fablePlan: failed to find the model picker options`),null;let r=n[4],i=`${po(t.planModel)} Plan Mode`,a=`Use ${po(t.planModel)} in plan mode, ${po(t.execModel)} otherwise`,o=`if(!${r}.some((z)=>z.value==="${U}"))${r}.push(${JSON.stringify({value:U,label:i,description:a})});`,s=n[1]+o,c=e.slice(0,n.index)+s+e.slice(n.index+n[0].length);return V(e,c,s,n.index,n.index+n[0].length),c},uo=e=>{let t=e.match(/(function ([$\w]+)\(([$\w]+),([$\w]+)\)\{)(if\(!([$\w]+)\(\3\)\)return;let [$\w]+=[$\w]+\(\3\),[$\w]+=[$\w]+\(\3\),[$\w]+=[$\w]+\(\);)/);if(!t||t.index===void 0)return e.includes(`CLAUDE_CODE_EFFORT_LEVEL`)?(console.error(`patch: fablePlan: failed to find the effort resolver`),null):(J(`patch: fablePlan: effort resolver absent in this build — no-op`),e);let n=`if(${io}!==void 0)return ${io};`,r=t[1]+n+t[5],i=e.slice(0,t.index)+r+e.slice(t.index+t[0].length);return V(e,i,r,t.index,t.index+t[0].length),i},fo=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},po=e=>e.charAt(0).toUpperCase()+e.slice(1),mo=RegExp(`\\["sonnet",(?:"[\\w[\\]]+",)*"${U}"[,\\]]`),ho=(e,t)=>{if(mo.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=co(e,t);if(!n)return null;let r=n.file,i=ao(r);if(!i)return null;r=i;let a=oo(r,t,n.resolver);if(!a)return null;r=a;let o=so(r,t);if(!o)return null;r=o;let s=lo(r,t);if(!s)return null;r=s;let c=uo(r);if(!c)return null;if(r=c,t.offerClearContextOnPlanAccept){let e=fo(r);if(!e)return null;r=e}return r},go=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_amber_quartz"/);if(t&&t.index!==void 0){let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i}let n=e.match(/function [$\w]+\(\)\{return![$\w]+\("tengu_amber_quartz_disabled"/);if(n&&n.index!==void 0){let t=n.index+n[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,t)+r+e.slice(t);return V(e,i,r,t,t),i}let r=e.match(/name:"voice",description:"Toggle voice mode"[\s\S]{0,500}?get isHidden\(\)\{return!([$\w]+)\(\)\}/);if(r&&r.index!==void 0){let t=r[1].replace(/[$]/g,`\\$`),n=RegExp(`function ${t}\\(\\)\\{`),i=e.match(n);if(i&&i.index!==void 0){let t=i.index+i[0].length,n=`return !0;`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r}}return console.error(`patch: voiceMode: failed to find tengu_amber_quartz gate`),null},_o=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},vo=(e,t)=>{let n=go(e);return!n||t&&(n=_o(n),!n)?null:n},yo=e=>{let t=e.match(/function [$\w]+\(\)\{return [$\w]+\("tengu_harbor",!1\)/);if(!t||t.index===void 0)return console.error(`patch: channelsMode: failed to find tengu_harbor gate`),null;let n=t.index+t[0].indexOf(`{`)+1,r=`return !0;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},bo=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},xo=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},So=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},Co=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},wo=e=>{let t=yo(e);return!t||(t=bo(t),!t)||(t=xo(t),!t)||(t=So(t),!t)||(t=Co(t),!t)?null:t},To=e=>{if(/name:"clear-screen"/.test(e))return e;let t=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=Eo(r);return i?(r=i,Br(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)},Eo=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},Do=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},Oo=e=>X(JSON.stringify(e)).replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),ko=`"$_cc_bin"`,Ao=/\{mode:"embedded",command:process\.execPath,args:\[[^\]]*\],argv0:"rg"\}/,jo=`Search backend note (fff):`;``+jo;const Mo=`most-relevant-first`;``+Mo;const No=(e,t)=>{let n=Oo(t);if(e.includes(`ARGV0=\${t} ${n}`)||e.includes(`exec -a \${t} ${n}`))return e;if(e.split(ko).length-1==0)return console.error(`patch: swapRipgrepForFff: bash-search shadow anchor "$_cc_bin" not found`),null;let r=e.split(ko).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(ko),e.indexOf(ko)+10),r},Po=(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(Ao);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},Fo=(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},Io=(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=Fo(e,r);continue}if(i===`{`){t.b++;continue}if(i===`}`){t.b===0?n.pop():t.b--;continue}}return-1},Lo=(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=Io(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},Ro=(e,t)=>{let n=No(e,t);if(n===null)return null;let r=n;return r=Po(r,t),r=Lo(r,`built on ripgrep`,`
|
|
758
758
|
|
|
759
|
-
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.`,jo,`Grep description`),r=Lo(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.`,Mo,`Bash description`),r},zo=3e4;function Bo(){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 Vo(){try{let e=u.dirname(y(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 Ho(e){try{return await a.access(e,s.constants.X_OK),!0}catch{return!1}}async function Uo(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 Wo(e){try{return(await a.stat(e)).mtimeMs}catch{return-1}}async function Go(){let e=Bo();if(!e)return null;let t=u.join(Z,`fff`,e,`rg-fff`),n=u.join(u.dirname(t),`.version`),r=Vo();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 Wo(n)>await Wo(t)&&await Uo(n,t),t}let i=r?.version,o=await a.readFile(n,`utf-8`).then(e=>e.trim()).catch(()=>null);if(await Ho(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(zo)});if(!r.ok)return null;let o=Buffer.from(await r.arrayBuffer()),s=await fetch(`${c}/rg-fff-${e}.sha256`,{signal:AbortSignal.timeout(zo)});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=S.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 Ko=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},qo=e=>{let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return`<system-reminder>\n\$\{\2\}\n<\/system-reminder>`\}/);if(!t||t.index===void 0)return/function [$\w]+\(([$\w]+)\)\{if\(!\1\|\|!\1\.trim\(\)\|\|\1==="\(no content\)"\)return"\(no content\)";return`<system-reminder>/.test(e)?e:(console.error(`patch: strip-empty-system-reminders: failed to find LW(H) wrapper`),null);let[n,r,i]=t,a=`function ${r}(${i}){if(!${i}||!${i}.trim()||${i}==="(no content)")return"(no content)";return\`<system-reminder>\n\${${i}}\n</system-reminder>\`}`,o=t.index,s=o+n.length,c=e.slice(0,o)+a+e.slice(s);return V(e,c,a,o,s),c},Jo=`The following deferred tools are now available via`,Yo=e=>{if(!e.includes(Jo))return console.log(`patch: suppress-deferred-tools: anchor not present in this CC build — no-op`),e;if(e.includes(`case"deferred_tools_delta":{return [];`))return e;let t=e.indexOf(`case"deferred_tools_delta":{`);if(t<0)return console.error(`patch: suppress-deferred-tools: failed to find case header`),null;if(!e.slice(t,t+2048).includes(Jo))return console.error(`patch: suppress-deferred-tools: case header found but anchor text not nearby`),null;let n=t+28,r=`return [];`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},Xo=[`__tweakcc`,`tweakcc v`],Zo=e=>Xo.some(t=>e.includes(t)),Qo=Math.max(...Xo.map(e=>e.length)),$o=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(Zo(t)){a(!0);return}r=t.slice(-(Qo-1))}),n.on(`error`,()=>a(!1)),n.on(`close`,()=>a(!1)),n.on(`end`,()=>a(!1))});var es=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 ts=async e=>{if(await $o(e))throw new es(e)},ns=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}},rs=async e=>{if(!e.cliPath){J(`backupClijs: Skipping for native installation (no cliPath)`);return}await ts(e.cliPath),await mc(),J(`Backing up cli.js to ${lc}`),await ns(e.cliPath,lc),await yc(t=>{t.changesApplied=!1,t.ccVersion=e.version})},is=async e=>{e.nativeInstallationPath&&(await ts(e.nativeInstallationPath),await mc(),J(`Backing up native binary to ${uc}`),await ns(e.nativeInstallationPath,uc),await yc(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},as=async e=>e.cliPath?await $s(lc)?(J(`Restoring cli.js from backup to ${e.cliPath}`),await Qs(e.cliPath,lc,`restore`),await ct(),await yc(e=>{e.changesApplied=!1}),!0):(J(`restoreClijsFromBackup: No backup file exists, skipping`),!1):(J(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1),os=async e=>e.nativeInstallationPath?await $s(uc)?(J(`Restoring native binary from backup to ${e.nativeInstallationPath}`),await Qs(e.nativeInstallationPath,uc,`restore`),await ct(),await yc(e=>{e.changesApplied=!1}),!0):(J(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1):(J(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1),ss=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},cs=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`)},ls=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]},us=e=>{let t=ls(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 W=null,G=null;const ds=e=>{if(W!=null)return W;let t=cs(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),W=void 0;return}let n=ls(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),W=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${q(t)}\\(${q(n)}\\(\\),1\\)`),i=e.match(r);if(i)return W=i[1],W;let a=us(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),W=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})`),W=void 0;return}return W=s[1],W},fs=()=>{W=null},ps=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]},ms=e=>{if(G!=null)return G;let t=ps(e);return t?(G=t,G):(G=`require`,G)},hs=()=>{G=null},gs=()=>{fs(),hs()},_s=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]},vs=(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]},ys=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 vs(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)`)},bs=e(import.meta.url),xs=(()=>{try{return bs(`../package.json`).version}catch{return bs(`../../package.json`).version}})();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 Ss=[{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:`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:`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:`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:`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:`adhd-output-style`,name:`ADHD-friendly output style`,group:K.MISC_CONFIGURABLE,description:`Rewrites the always-on "# Communicating with the user" prompt for skim-first reading: answer in the first line, bold the key terms, short blocks, and a soft "usually under 120 words" anchor. Removes the three clauses that drive Claude-speak: the "load-bearing" update cue (the prompt is where that tic comes from), the "readable matters more" ranking, and the "in prose, not headers and sections" ban on the structure skim-readers rely on. Also restates the shape rule in the per-turn CLAUDE.md reminder, where recency makes it stick, and drops that reminder's "may or may not be relevant" hedge which labelled your own CLAUDE.md as ignorable.`,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:`Auto-route reasoning effort (thinking depth) by task complexity: routine work runs at low effort, the top tier only for genuinely frontier problems. Rides on your current model - no model switch, no prompt-cache churn. A one-shot Haiku side-call routes each prompt using a rolling TL;DR summary of the session (so terse follow-ups that continue hard work stay elevated; persisted across resume, reseeded from the main model summary on compaction). While on it drives effort, overriding your saved effortLevel default; an in-session /effort or CLAUDE_CODE_EFFORT_LEVEL still wins. 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 its own reasoning effort (Fable xhigh, Opus medium by default). 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:`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:`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}],Cs=()=>[...Ss],q=e=>e.replace(/\$/g,`\\$`),ws=(e,t,n)=>{let r=[];for(let i of Ss){let a=t[i.id];if(n&&!n.includes(i.id)){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,details:`not in --patches filter`,description:i.description});continue}if(a.condition===!1){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,details:`not enabled`,description:i.description});continue}J(`Applying patch: ${i.name}`);let o=a.fn(e),s=o===null,c=!s&&o!==e;s||(e=o),r.push({id:i.id,name:i.name,group:i.group,applied:c,failed:s,description:i.description,modelFacing:i.modelFacing})}return{content:e,results:r}},Ts=e=>{let t=_(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}},Es=async(e,r,i)=>{let o,c=!1;if(r.nativeInstallationPath){await os(r);let e=!1;try{await a.stat(uc),e=!0}catch{}let t=e?uc:r.nativeInstallationPath;J(`Extracting claude.js from ${e?`backup`:`native installation`}: ${t}`);let{data:n,clearBytecode:i,error:l}=await T(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 as(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 Mr({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: ${Nr(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 Dr(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 xt(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 fr(o,r.version,void 0,i,d);o=g.newContent;let _=[...g.results].sort((e,t)=>e.name.localeCompare(t.name));l.push(..._);let v=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),y=_.filter(e=>e.applied&&e.details).map(e=>v(`${e.name}: ${e.details}`)),b=e.settings.misc?.tableFormat??`default`,x=e.settings.misc?.showTweakccVersion??!0,S=e.settings.misc?.showPatchesApplied??!0,C=e.settings.misc?.enableModelCustomizations??!0,w=!!e.settings.misc?.swapRipgrepForFff,D=null;w&&(D=await Go(),D||console.log(`patch: swapRipgrepForFff: no fff wrapper available for this platform — keeping ripgrep`));let O={"verbose-property":{fn:e=>Oe(e),condition:!r.nativeInstallationPath},"read-default-lines":{fn:e=>Do(e)},"context-limit":{fn:e=>ce(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Fe(e),condition:C&&!r.nativeInstallationPath},"thinking-block-styling":{fn:e=>ma(e),condition:r.version==null||At(r.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>Fr(e)},"fix-summarize-from-here":{fn:e=>Ir(e),condition:e.settings.misc?.fixSummarizeFromHere!==!1},"fix-rewind-summary-header":{fn:e=>Lr(e),condition:e.settings.misc?.fixRewindSummaryHeader!==!1},"statusline-update-throttle":{fn:t=>ba(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"clear-screen":{fn:e=>To(e)},"strip-empty-system-reminders":{fn:e=>qo(e)},"patches-applied-indication":{fn:e=>Ke(e,xs,y,x,S)},"model-customizations":{fn:e=>ks(e),condition:C},"show-more-items-in-select-menus":{fn:e=>re(e,25),condition:C},"table-format":{fn:e=>Mi(e,b),condition:b!==`default`},themes:{fn:t=>oe(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(k.themes))},"thinking-verbs":{fn:t=>be(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs&&JSON.stringify(e.settings.thinkingVerbs.verbs)!==JSON.stringify(k.thinkingVerbs.verbs)},"thinker-format":{fn:t=>de(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs&&e.settings.thinkingVerbs.format!==k.thinkingVerbs.format},"thinker-symbol-chars":{fn:t=>me(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(k.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>he(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==k.thinkingStyle.updateInterval&&(r.version==null||At(r.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>_e(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(k.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>pe(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==k.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>le(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&e.settings.inputBox.removeBorder!==k.inputBox.removeBorder)},"subagent-models":{fn:t=>Be(t,e.settings.subagentModels),condition:!!e.settings.subagentModels&&JSON.stringify(e.settings.subagentModels)!==JSON.stringify(k.subagentModels)},"thinking-visibility":{fn:e=>Ie(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>Ki(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>Ji(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>Xi(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>Qi(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>ea(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>ta(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>Ca(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>pa(e),condition:!!e.settings.misc?.enableRememberSkill},"agents-md":{fn:t=>wa(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Ma(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Na(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Fa(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>La(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"max-effort-default":{fn:e=>Ba(e),condition:!!e.settings.misc?.maxEffortDefault},"autonomous-operation-all-models":{fn:e=>Va(e),condition:!!e.settings.misc?.autonomousOperationAllModels},"adhd-output-style":{fn:e=>Wa(e),condition:!!e.settings.misc?.adhdOutputStyle},"auto-mode-classifier-model":{fn:t=>Ka(t,e.settings.misc?.autoModeClassifierModel??`default`),condition:(e.settings.misc?.autoModeClassifierModel??`default`)!==`default`},"complexity-router":{fn:t=>ro(t,e.settings.complexityRouter),condition:e.settings.complexityRouter.enabled},"fable-plan":{fn:t=>ho(t,e.settings.fablePlan),condition:e.settings.fablePlan.enabled},"allow-custom-agent-models":{fn:e=>za(e),condition:!!e.settings.misc?.allowCustomAgentModels},"worktree-mode":{fn:e=>Ra(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>sa(e),condition:!!e.settings.misc?.enableSessionMemory},"swap-ripgrep-for-fff":{fn:e=>Ro(e,D),condition:w&&!!D},"dream-mode":{fn:e=>ca(e),condition:!!e.settings.misc?.enableDreamMode},"lean-memory-types":{fn:e=>la(e),condition:!!e.settings.misc?.enableLeanMemoryTypes},toolsets:{fn:t=>bi(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>va(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking&&(r.version==null||At(r.version,`2.1.85`)<0)},"mcp-batch-size":{fn:t=>ya(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>Se(t,e.settings.userMessageDisplay),condition:!!(e.settings.userMessageDisplay&&JSON.stringify(e.settings.userMessageDisplay)!==JSON.stringify(k.userMessageDisplay))},"input-pattern-highlighters":{fn:t=>Ee(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>Wi(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!r.nativeInstallationPath},"voice-mode":{fn:t=>vo(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>wo(e),condition:!!e.settings.misc?.enableChannelsMode},"suppress-deferred-tools":{fn:e=>Yo(e),condition:!!e.settings.misc?.suppressDeferredTools},"claudemd-context-once-per-conversation":{fn:e=>Ko(e),condition:e.settings.misc?.claudemdContextOncePerConversation??!1}},{content:A,results:j}=ws(o,O,i);o=A,l.push(...j);let M=j.filter(e=>e.failed);if(r.nativeInstallationPath&&M.length>0){let e=Error(`Refusing to repack the native binary: ${M.length} binary patch(es) failed (${M.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 E(l,t,l,c),Ts(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`);M.length>0&&console.warn(`tweakcc: ${M.length} patch(es) did not apply on Claude Code ${r.version}: ${M.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 Zs(r.cliPath,o,`patch`)}return{config:await yc(e=>{e.changesApplied=!0}),results:l}},Ds=[{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)`}],Os=e=>{let t=e.match(/(?<![$\w])([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-5e3),i=e.slice(r,t.index),a=`(?:(?:let|var|const) |,)${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)},ks=e=>{if(e.includes(`"value":"claude-opus-4-6"`))return console.log(`patch: modelCustomizations: custom models already present — skipping`),e;let t=Os(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Ds.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 As=!1,js=!1,Ms=!1;const Ns=()=>As,Ps=()=>js,Fs=()=>Ms,Is=()=>{As=!0},Ls=()=>{js=!0,As=!0},Rs=()=>{Ms=!0},J=(e,...t)=>{Ns()&&console.log(e,...t)},Y=(e,...t)=>{Ps()&&console.log(e,...t)},X=e=>e.replace(/[\u0080-\uffff]/g,e=>`\\u`+e.charCodeAt(0).toString(16).padStart(4,`0`));function zs(){try{let e=p.join(m.homedir(),`.claude.json`);return JSON.parse(f.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Bs(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 Vs(){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 Hs(){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=Ds.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Us(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 Ws(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 Gs(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 Ks(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 qs(e){if(!Ks(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 Js(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 Ys(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 Xs(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 Zs(e,t,n=`replace`){await Xs(e,await Ys(e,n),n,e=>o.writeFile(e,t))}async function Qs(e,t,n=`replace`){await Xs(e,await Ys(e,n),n,e=>o.copyFile(t,e))}async function $s(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 ec=e=>e.startsWith(`~`)?p.join(m.homedir(),e.slice(1)):e,tc=(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]},nc=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function rc(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]=rc(n[e],r)):n[e]=r}return n}const ic=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`)},ac=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)},oc=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function sc(){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 mc(),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 cc=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return ec(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=cc(),Q=d.join(Z,`config.json`),lc=d.join(Z,`cli.js.backup`),uc=d.join(Z,`native-binary.backup`),$=d.join(Z,`system-prompts`),dc=d.join(Z,`system-reminders`),fc=d.join(Z,`prompt-data-cache`),pc=()=>{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(`
|
|
759
|
+
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.`,jo,`Grep description`),r=Lo(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.`,Mo,`Bash description`),r},zo=3e4;function Bo(){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 Vo(){try{let e=u.dirname(y(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 Ho(e){try{return await a.access(e,s.constants.X_OK),!0}catch{return!1}}async function Uo(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 Wo(e){try{return(await a.stat(e)).mtimeMs}catch{return-1}}async function Go(){let e=Bo();if(!e)return null;let t=u.join(Z,`fff`,e,`rg-fff`),n=u.join(u.dirname(t),`.version`),r=Vo();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 Wo(n)>await Wo(t)&&await Uo(n,t),t}let i=r?.version,o=await a.readFile(n,`utf-8`).then(e=>e.trim()).catch(()=>null);if(await Ho(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(zo)});if(!r.ok)return null;let o=Buffer.from(await r.arrayBuffer()),s=await fetch(`${c}/rg-fff-${e}.sha256`,{signal:AbortSignal.timeout(zo)});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=S.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 Ko=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},qo=e=>{let t=e.match(/function ([$\w]+)\(([$\w]+)\)\{return`<system-reminder>\n\$\{\2\}\n<\/system-reminder>`\}/);if(!t||t.index===void 0)return/function [$\w]+\(([$\w]+)\)\{if\(!\1\|\|!\1\.trim\(\)\|\|\1==="\(no content\)"\)return"\(no content\)";return`<system-reminder>/.test(e)?e:(console.error(`patch: strip-empty-system-reminders: failed to find LW(H) wrapper`),null);let[n,r,i]=t,a=`function ${r}(${i}){if(!${i}||!${i}.trim()||${i}==="(no content)")return"(no content)";return\`<system-reminder>\n\${${i}}\n</system-reminder>\`}`,o=t.index,s=o+n.length,c=e.slice(0,o)+a+e.slice(s);return V(e,c,a,o,s),c},Jo=`The following deferred tools are now available via`,Yo=e=>{if(!e.includes(Jo))return console.log(`patch: suppress-deferred-tools: anchor not present in this CC build — no-op`),e;if(e.includes(`case"deferred_tools_delta":{return [];`))return e;let t=e.indexOf(`case"deferred_tools_delta":{`);if(t<0)return console.error(`patch: suppress-deferred-tools: failed to find case header`),null;if(!e.slice(t,t+2048).includes(Jo))return console.error(`patch: suppress-deferred-tools: case header found but anchor text not nearby`),null;let n=t+28,r=`return [];`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),i},Xo=[`__tweakcc`,`tweakcc v`],Zo=e=>Xo.some(t=>e.includes(t)),Qo=Math.max(...Xo.map(e=>e.length)),$o=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(Zo(t)){a(!0);return}r=t.slice(-(Qo-1))}),n.on(`error`,()=>a(!1)),n.on(`close`,()=>a(!1)),n.on(`end`,()=>a(!1))});var es=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 ts=async e=>{if(await $o(e))throw new es(e)},ns=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}},rs=async e=>{if(!e.cliPath){J(`backupClijs: Skipping for native installation (no cliPath)`);return}await ts(e.cliPath),await mc(),J(`Backing up cli.js to ${lc}`),await ns(e.cliPath,lc),await yc(t=>{t.changesApplied=!1,t.ccVersion=e.version})},is=async e=>{e.nativeInstallationPath&&(await ts(e.nativeInstallationPath),await mc(),J(`Backing up native binary to ${uc}`),await ns(e.nativeInstallationPath,uc),await yc(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},as=async e=>e.cliPath?await $s(lc)?(J(`Restoring cli.js from backup to ${e.cliPath}`),await Qs(e.cliPath,lc,`restore`),await ct(),await yc(e=>{e.changesApplied=!1}),!0):(J(`restoreClijsFromBackup: No backup file exists, skipping`),!1):(J(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1),os=async e=>e.nativeInstallationPath?await $s(uc)?(J(`Restoring native binary from backup to ${e.nativeInstallationPath}`),await Qs(e.nativeInstallationPath,uc,`restore`),await ct(),await yc(e=>{e.changesApplied=!1}),!0):(J(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1):(J(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1),ss=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},cs=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`)},ls=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]},us=e=>{let t=ls(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 W=null,G=null;const ds=e=>{if(W!=null)return W;let t=cs(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),W=void 0;return}let n=ls(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),W=void 0;return}let r=RegExp(`[^$\\w]([$\\w]+)=${q(t)}\\(${q(n)}\\(\\),1\\)`),i=e.match(r);if(i)return W=i[1],W;let a=us(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),W=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})`),W=void 0;return}return W=s[1],W},fs=()=>{W=null},ps=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]},ms=e=>{if(G!=null)return G;let t=ps(e);return t?(G=t,G):(G=`require`,G)},hs=()=>{G=null},gs=()=>{fs(),hs()},_s=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]},vs=(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]},ys=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 vs(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)`)},bs=e(import.meta.url),xs=(()=>{try{return bs(`../package.json`).version}catch{return bs(`../../package.json`).version}})();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 Ss=[{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:`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:`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:`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:`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:`adhd-output-style`,name:`ADHD-friendly output style`,group:K.MISC_CONFIGURABLE,description:`EXPERIMENTAL, and it may not visibly change your output. This rewrites prompt text, which is a weak and inconsistent lever: Claude can and does ignore it, the effect varies a lot between one reply and the next, and on some tasks it changes nothing measurable. It was chosen over the alternatives by blind ranking across roughly 900 generated replies, where it placed last in 1 of 16 comparisons and the unmodified prompt placed last in 10 - but that is an average over many replies, not a promise about any one of them. Rewrites the always-on "# Communicating with the user" prompt for skim-first reading. There is no word limit anywhere in it: length follows the substance, and the rules cut kinds of content instead, which is what testing showed actually works. Answer in the first line; show the command, path or value rather than describing it; say each thing once; keep both sides of a count and every qualifier; bold the key terms and keep paragraphs short. Removes the three clauses that drive Claude-speak: the "load-bearing" update cue (the prompt is where that tic comes from), the "readable matters more" ranking, and the "in prose, not headers and sections" ban on the structure skim-readers rely on. Also restates the rules in the per-turn CLAUDE.md reminder, where recency makes them stick, and drops that reminder's "may or may not be relevant" hedge which labelled your own CLAUDE.md as ignorable.`,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:`Auto-route reasoning effort (thinking depth) by task complexity: routine work runs at low effort, the top tier only for genuinely frontier problems. Rides on your current model - no model switch, no prompt-cache churn. A one-shot Haiku side-call routes each prompt using a rolling TL;DR summary of the session (so terse follow-ups that continue hard work stay elevated; persisted across resume, reseeded from the main model summary on compaction). While on it drives effort, overriding your saved effortLevel default; an in-session /effort or CLAUDE_CODE_EFFORT_LEVEL still wins. 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 its own reasoning effort (Fable xhigh, Opus medium by default). 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:`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:`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}],Cs=()=>[...Ss],q=e=>e.replace(/\$/g,`\\$`),ws=(e,t,n)=>{let r=[];for(let i of Ss){let a=t[i.id];if(n&&!n.includes(i.id)){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,details:`not in --patches filter`,description:i.description});continue}if(a.condition===!1){r.push({id:i.id,name:i.name,group:i.group,applied:!1,skipped:!0,details:`not enabled`,description:i.description});continue}J(`Applying patch: ${i.name}`);let o=a.fn(e),s=o===null,c=!s&&o!==e;s||(e=o),r.push({id:i.id,name:i.name,group:i.group,applied:c,failed:s,description:i.description,modelFacing:i.modelFacing})}return{content:e,results:r}},Ts=e=>{let t=_(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}},Es=async(e,r,i)=>{let o,c=!1;if(r.nativeInstallationPath){await os(r);let e=!1;try{await a.stat(uc),e=!0}catch{}let t=e?uc:r.nativeInstallationPath;J(`Extracting claude.js from ${e?`backup`:`native installation`}: ${t}`);let{data:n,clearBytecode:i,error:l}=await T(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 as(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 Mr({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: ${Nr(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 Dr(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 xt(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 fr(o,r.version,void 0,i,d);o=g.newContent;let _=[...g.results].sort((e,t)=>e.name.localeCompare(t.name));l.push(..._);let v=e=>e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$/g,`\\$`),y=_.filter(e=>e.applied&&e.details).map(e=>v(`${e.name}: ${e.details}`)),b=e.settings.misc?.tableFormat??`default`,x=e.settings.misc?.showTweakccVersion??!0,S=e.settings.misc?.showPatchesApplied??!0,C=e.settings.misc?.enableModelCustomizations??!0,w=!!e.settings.misc?.swapRipgrepForFff,D=null;w&&(D=await Go(),D||console.log(`patch: swapRipgrepForFff: no fff wrapper available for this platform — keeping ripgrep`));let O={"verbose-property":{fn:e=>Oe(e),condition:!r.nativeInstallationPath},"read-default-lines":{fn:e=>Do(e)},"context-limit":{fn:e=>ce(e),condition:!!e.settings.misc?.enableContextLimitOverride},opusplan1m:{fn:e=>Fe(e),condition:C&&!r.nativeInstallationPath},"thinking-block-styling":{fn:e=>ma(e),condition:r.version==null||At(r.version,`2.1.26`)<0},"fix-lsp-support":{fn:e=>Fr(e)},"fix-summarize-from-here":{fn:e=>Ir(e),condition:e.settings.misc?.fixSummarizeFromHere!==!1},"fix-rewind-summary-header":{fn:e=>Lr(e),condition:e.settings.misc?.fixRewindSummaryHeader!==!1},"statusline-update-throttle":{fn:t=>ba(t,e.settings.misc?.statuslineThrottleMs??300,e.settings.misc?.statuslineUseFixedInterval??!1),condition:e.settings.misc?.statuslineThrottleMs!=null},"clear-screen":{fn:e=>To(e)},"strip-empty-system-reminders":{fn:e=>qo(e)},"patches-applied-indication":{fn:e=>Ke(e,xs,y,x,S)},"model-customizations":{fn:e=>ks(e),condition:C},"show-more-items-in-select-menus":{fn:e=>re(e,25),condition:C},"table-format":{fn:e=>Mi(e,b),condition:b!==`default`},themes:{fn:t=>oe(t,e.settings.themes),condition:!!(e.settings.themes&&e.settings.themes.length>0&&JSON.stringify(e.settings.themes)!==JSON.stringify(k.themes))},"thinking-verbs":{fn:t=>be(t,e.settings.thinkingVerbs.verbs),condition:!!e.settings.thinkingVerbs&&JSON.stringify(e.settings.thinkingVerbs.verbs)!==JSON.stringify(k.thinkingVerbs.verbs)},"thinker-format":{fn:t=>de(t,e.settings.thinkingVerbs.format),condition:!!e.settings.thinkingVerbs&&e.settings.thinkingVerbs.format!==k.thinkingVerbs.format},"thinker-symbol-chars":{fn:t=>me(t,e.settings.thinkingStyle.phases),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(k.thinkingStyle.phases)},"thinker-symbol-speed":{fn:t=>he(t,e.settings.thinkingStyle.updateInterval),condition:e.settings.thinkingStyle.updateInterval!==k.thinkingStyle.updateInterval&&(r.version==null||At(r.version,`2.1.27`)<0)},"thinker-symbol-width":{fn:t=>_e(t,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1),condition:JSON.stringify(e.settings.thinkingStyle.phases)!==JSON.stringify(k.thinkingStyle.phases)},"thinker-symbol-mirror":{fn:t=>pe(t,e.settings.thinkingStyle.reverseMirror),condition:e.settings.thinkingStyle.reverseMirror!==k.thinkingStyle.reverseMirror},"input-box-border":{fn:t=>le(t,e.settings.inputBox.removeBorder),condition:!!(e.settings.inputBox&&e.settings.inputBox.removeBorder!==k.inputBox.removeBorder)},"subagent-models":{fn:t=>Be(t,e.settings.subagentModels),condition:!!e.settings.subagentModels&&JSON.stringify(e.settings.subagentModels)!==JSON.stringify(k.subagentModels)},"thinking-visibility":{fn:e=>Ie(e),condition:e.settings.misc?.expandThinkingBlocks??!0},"hide-startup-banner":{fn:e=>Ki(e),condition:!!e.settings.misc?.hideStartupBanner},"hide-ctrl-g-to-edit":{fn:e=>Ji(e),condition:!!e.settings.misc?.hideCtrlGToEdit},"hide-startup-clawd":{fn:e=>Xi(e),condition:!!e.settings.misc?.hideStartupClawd},"increase-file-read-limit":{fn:e=>Qi(e),condition:!!e.settings.misc?.increaseFileReadLimit},"suppress-line-numbers":{fn:e=>ea(e),condition:!!e.settings.misc?.suppressLineNumbers},"suppress-rate-limit-options":{fn:e=>ta(e),condition:!!e.settings.misc?.suppressRateLimitOptions},"token-count-rounding":{fn:t=>Ca(t,e.settings.misc.tokenCountRounding),condition:!!e.settings.misc?.tokenCountRounding},"remember-skill":{fn:e=>pa(e),condition:!!e.settings.misc?.enableRememberSkill},"agents-md":{fn:t=>wa(t,e.settings.claudeMdAltNames),condition:!!(e.settings.claudeMdAltNames&&e.settings.claudeMdAltNames.length>0)},"auto-accept-plan-mode":{fn:e=>Ma(e),condition:!!e.settings.misc?.autoAcceptPlanMode},"allow-sudo-bypass-permissions":{fn:e=>Na(e),condition:!!e.settings.misc?.allowBypassPermissionsInSudo},"suppress-native-installer-warning":{fn:e=>Fa(e),condition:!!e.settings.misc?.suppressNativeInstallerWarning},"filter-scroll-escape-sequences":{fn:e=>La(e),condition:!!e.settings.misc?.filterScrollEscapeSequences},"max-effort-default":{fn:e=>Ba(e),condition:!!e.settings.misc?.maxEffortDefault},"autonomous-operation-all-models":{fn:e=>Va(e),condition:!!e.settings.misc?.autonomousOperationAllModels},"adhd-output-style":{fn:e=>Wa(e),condition:!!e.settings.misc?.adhdOutputStyle},"auto-mode-classifier-model":{fn:t=>Ka(t,e.settings.misc?.autoModeClassifierModel??`default`),condition:(e.settings.misc?.autoModeClassifierModel??`default`)!==`default`},"complexity-router":{fn:t=>ro(t,e.settings.complexityRouter),condition:e.settings.complexityRouter.enabled},"fable-plan":{fn:t=>ho(t,e.settings.fablePlan),condition:e.settings.fablePlan.enabled},"allow-custom-agent-models":{fn:e=>za(e),condition:!!e.settings.misc?.allowCustomAgentModels},"worktree-mode":{fn:e=>Ra(e),condition:!!e.settings.misc?.enableWorktreeMode},"session-memory":{fn:e=>sa(e),condition:!!e.settings.misc?.enableSessionMemory},"swap-ripgrep-for-fff":{fn:e=>Ro(e,D),condition:w&&!!D},"dream-mode":{fn:e=>ca(e),condition:!!e.settings.misc?.enableDreamMode},"lean-memory-types":{fn:e=>la(e),condition:!!e.settings.misc?.enableLeanMemoryTypes},toolsets:{fn:t=>bi(t,e.settings.toolsets,e.settings.defaultToolset,e.settings.planModeToolset),condition:!!(e.settings.toolsets&&e.settings.toolsets.length>0)},"mcp-non-blocking":{fn:e=>va(e),condition:!!e.settings.misc?.mcpConnectionNonBlocking&&(r.version==null||At(r.version,`2.1.85`)<0)},"mcp-batch-size":{fn:t=>ya(t,e.settings.misc.mcpServerBatchSize),condition:!!e.settings.misc?.mcpServerBatchSize},"user-message-display":{fn:t=>Se(t,e.settings.userMessageDisplay),condition:!!(e.settings.userMessageDisplay&&JSON.stringify(e.settings.userMessageDisplay)!==JSON.stringify(k.userMessageDisplay))},"input-pattern-highlighters":{fn:t=>Ee(t,e.settings.inputPatternHighlighters),condition:!!(e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0)},"conversation-title":{fn:e=>Wi(e),condition:(e.settings.misc?.enableConversationTitle??!0)&&!r.nativeInstallationPath},"voice-mode":{fn:t=>vo(t,e.settings.misc?.enableVoiceConciseOutput??!0),condition:!!e.settings.misc?.enableVoiceMode},"channels-mode":{fn:e=>wo(e),condition:!!e.settings.misc?.enableChannelsMode},"suppress-deferred-tools":{fn:e=>Yo(e),condition:!!e.settings.misc?.suppressDeferredTools},"claudemd-context-once-per-conversation":{fn:e=>Ko(e),condition:e.settings.misc?.claudemdContextOncePerConversation??!1}},{content:A,results:j}=ws(o,O,i);o=A,l.push(...j);let M=j.filter(e=>e.failed);if(r.nativeInstallationPath&&M.length>0){let e=Error(`Refusing to repack the native binary: ${M.length} binary patch(es) failed (${M.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 E(l,t,l,c),Ts(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`);M.length>0&&console.warn(`tweakcc: ${M.length} patch(es) did not apply on Claude Code ${r.version}: ${M.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 Zs(r.cliPath,o,`patch`)}return{config:await yc(e=>{e.changesApplied=!0}),results:l}},Ds=[{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)`}],Os=e=>{let t=e.match(/(?<![$\w])([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-5e3),i=e.slice(r,t.index),a=`(?:(?:let|var|const) |,)${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)},ks=e=>{if(e.includes(`"value":"claude-opus-4-6"`))return console.log(`patch: modelCustomizations: custom models already present — skipping`),e;let t=Os(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Ds.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 As=!1,js=!1,Ms=!1;const Ns=()=>As,Ps=()=>js,Fs=()=>Ms,Is=()=>{As=!0},Ls=()=>{js=!0,As=!0},Rs=()=>{Ms=!0},J=(e,...t)=>{Ns()&&console.log(e,...t)},Y=(e,...t)=>{Ps()&&console.log(e,...t)},X=e=>e.replace(/[\u0080-\uffff]/g,e=>`\\u`+e.charCodeAt(0).toString(16).padStart(4,`0`));function zs(){try{let e=p.join(m.homedir(),`.claude.json`);return JSON.parse(f.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Bs(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 Vs(){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 Hs(){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=Ds.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Us(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 Ws(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 Gs(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 Ks(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 qs(e){if(!Ks(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 Js(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 Ys(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 Xs(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 Zs(e,t,n=`replace`){await Xs(e,await Ys(e,n),n,e=>o.writeFile(e,t))}async function Qs(e,t,n=`replace`){await Xs(e,await Ys(e,n),n,e=>o.copyFile(t,e))}async function $s(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 ec=e=>e.startsWith(`~`)?p.join(m.homedir(),e.slice(1)):e,tc=(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]},nc=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function rc(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]=rc(n[e],r)):n[e]=r}return n}const ic=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`)},ac=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)},oc=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function sc(){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 mc(),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 cc=()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return ec(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=cc(),Q=d.join(Z,`config.json`),lc=d.join(Z,`cli.js.backup`),uc=d.join(Z,`native-binary.backup`),$=d.join(Z,`system-prompts`),dc=d.join(Z,`system-reminders`),fc=d.join(Z,`prompt-data-cache`),pc=()=>{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(`
|
|
760
760
|
Multiple configuration locations detected:`)),console.warn(t.gray(` Active: ${e}`)),console.warn(t.gray(` Other existing locations:`)),i.forEach(e=>{console.warn(t.gray(` - ${e}`))}),console.warn(t.gray(` Only the active location is used. To switch locations,`)),console.warn(t.gray(` move your config.json to the desired directory.
|
|
761
761
|
`)))},mc=async()=>{await o.mkdir(Z,{recursive:!0}),await o.mkdir($,{recursive:!0}),await o.mkdir(dc,{recursive:!0});let e=d.join(Z,`.gitignore`);try{await o.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await o.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(i)+i)}};let hc=null;const gc=()=>({ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:k}),_c=e=>{let t=e?.settings?.thinkingVerbs;t?.punctuation&&(t.format=`{}`+t.punctuation,delete t.punctuation),ac(e),e.settings=rc(e.settings,k),e.settings.inputPatternHighlighters&&(e.settings.inputPatternHighlighters=e.settings.inputPatternHighlighters.map(e=>rc(e,A))),e.settings.toolsets&&(e.settings.toolsets=e.settings.toolsets.map(e=>rc(e,j))),e.settings.themes&&(e.settings.themes=e.settings.themes.map(e=>rc(e,M)));{let t=e.settings.complexityRouter;delete t.mode;let n=k.complexityRouter,r=(e,t,n,r)=>typeof e==`number`&&Number.isFinite(e)?Math.min(r,Math.max(n,Math.round(e))):t;t.messageCap=r(t.messageCap,n.messageCap,500,4e5),t.assistantCap=r(t.assistantCap,n.assistantCap,500,4e5),t.timeoutMs=r(t.timeoutMs,n.timeoutMs,1e3,12e4),(typeof t.systemPrompt!=`string`||t.systemPrompt.trim().length===0)&&(t.systemPrompt=n.systemPrompt);let i=k.complexityRouter.levels,a=[`low`,`medium`,`high`,`xhigh`,`max`];t.levels=Array.isArray(t.levels)&&t.levels.length>0?t.levels.map((e,t)=>{let n=i[Math.min(t,i.length-1)],r=rc(e,n);return a.includes(r.effort)||(r.effort=n.effort),t>=i.length&&(r.id=`level-${t}`),r}):i.map(e=>({...e}))}oc(e),delete e.settings.launchText},vc=async()=>{let e=gc();try{J(`Reading config at ${Q}`),pc();let t=await o.readFile(Q,`utf8`),n={...e,...JSON.parse(t)},r=JSON.stringify(n);_c(n);let i=await lt($);return i&&(n.changesApplied=!1),(JSON.stringify(n)!==r||i)&&await bc(n),hc=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;if(t instanceof SyntaxError){let t=`${Q}.corrupt-${Date.now()}`;try{await o.rename(Q,t),console.error(`tweakcc: ${Q} was not valid JSON — moved it to ${t} and reset to defaults.`)}catch{console.error(`tweakcc: ${Q} was not valid JSON — falling back to defaults.`)}return e}throw t}},yc=async e=>(J(`Updating config at ${Q}`),hc||=await vc(),e(hc),hc.lastModified=new Date().toISOString(),await bc(hc),hc),bc=async e=>{e.lastModified=new Date().toISOString(),await mc();let t=`${Q}.tmp-${process.pid}`;try{await o.writeFile(t,JSON.stringify(e,null,2)),await o.rename(t,Q)}catch(e){try{await o.unlink(t)}catch{}throw console.error(`Error saving config:`,e),e}},xc=async e=>{J(`Fetching config from URL: ${e}`);let t;try{t=new URL(e)}catch{throw Error(`Invalid URL format: ${e}\n Expected a valid URL like https://example.com/config.json`)}if(![`http:`,`https:`].includes(t.protocol))throw Error(`Unsupported URL protocol: ${t.protocol}\n Only http:// and https:// URLs are supported`);let n;try{let e=await o.readFile(Q,`utf8`);n=JSON.parse(e)}catch{n=gc()}let r;try{r=await fetch(e,{headers:{Accept:`application/json`,"User-Agent":`tweakcc`},signal:AbortSignal.timeout(2e4)})}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to fetch config from ${e}\n Network error: ${n}\n Please check your internet connection and try again.`)}if(!r.ok)throw Error(`Failed to fetch config from ${e}\n HTTP ${r.status}: ${r.statusText}\n Please check that the URL is correct and accessible.`);let i;try{let e=await ic(r,8*1024*1024);i=JSON.parse(e)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to parse config from ${e}\n JSON parse error: ${n}\n Please ensure the URL returns valid JSON.`)}let a={sourceUrl:e,dateFetched:new Date().toISOString(),settings:i};await yc(e=>{e.remoteConfig=a});let s={...gc(),ccVersion:n.ccVersion||``,ccInstallationPath:n.ccInstallationPath||null,settings:{...k,...i},remoteConfig:a};return _c(s),J(`Successfully fetched and parsed config from ${e}`),s};export{H as $,Zs as A,ss as B,Js as C,qs as D,Ks as E,xs as F,es as G,cs as H,Es as I,as as J,rs as K,Cs as L,Ws as M,Bs as N,Us as O,K as P,Mr as Q,gs as R,Hs as S,Fs as T,ds as U,_s as V,ms as W,Zo as X,os as Y,Nr as Z,Is as _,$ as a,ct as at,Vs as b,cc as c,T as ct,sc as d,V as et,tc as f,Gs as g,$s as h,uc as i,Bt as it,Qs as j,ic as k,vc as l,E as lt,rc as m,Z as n,Wt as nt,dc as o,k as ot,J as p,is as q,Q as r,Ht as rt,xc as s,M as st,lc as t,hn as tt,yc as u,D as ut,Rs as v,Ns as w,zs as x,Ls as y,ys as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,C as t,ct as n,f as r,h as i,l as a,lt as o,n as s,p as c,r as l,u,ut as ee,w as d}from"./config-
|
|
1
|
+
import{A as e,C as t,ct as n,f as r,h as i,l as a,lt as o,n as s,p as c,r as l,u,ut as ee,w as d}from"./config-DtZztjxv.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`)?c(`Permission denied accessing: ${t} (${n.code})`):c(`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`)?c(`Permission denied accessing: ${e} (${n.code})`):c(`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 c(`WASMagic initialization failed (likely SIMD unsupported on this CPU):`,e),c(`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 c(`detectFileTypeFallback: Detected JavaScript via shebang`),`javascript`;if(e.length>=4){let t=e.subarray(0,4);if(t.equals(ie))return c(`detectFileTypeFallback: Detected ELF binary`),`binary`;if(t.equals(ae)||t.equals(oe)||t.equals(se)||t.equals(k)||t.equals(A))return c(`detectFileTypeFallback: Detected Mach-O binary`),`binary`}if(e.length>=2&&e.subarray(0,2).equals(j))return c(`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 c(`detectFileTypeFallback: Detected binary (${r} null bytes in first ${t} bytes)`),`binary`;let i=n/t;return i>.9?(c(`detectFileTypeFallback: Detected JavaScript via text heuristic (${Math.round(i*100)}% printable)`),`javascript`):(c(`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 c(`Failed to read file prefix:`,e),null}}async function P(e){if(process.platform===`win32`)return e;let t=await ee(e);return t?(c(`maybeResolveNixWrapper: resolved Nix wrapper ${e} -> ${t}`),t):e}async function F(e){try{let t=await b.realpath(e);c(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await N(t);if(!n)return c(`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 c(`resolvePathToInstallationType: Detected mime type: ${n}`),n.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:n.startsWith(`text/`)?(c(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:await P(t)}}}c(`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)}:(c(`resolvePathToInstallationType: Fallback could not determine file type`),null)}catch(e){return c(`resolvePathToInstallationType: Error:`,e),null}}async function I(){c(`getClaudeFromPath: PATH = ${process.env.PATH}`),c(`getClaudeFromPath: PATHEXT = ${process.env.PATHEXT}`);try{let e=await w(`claude`);return c(`getClaudeFromPath: Found claude at ${e}`),e}catch{return c(`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())c(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&c(`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:r}=await n(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}${r?` (${r})`:``}`);let i=L(t.toString(`utf8`));if(!i)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return i}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?(c(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?R(e):z(e)}async function H(){let e=[],t=new Set;for(let n of E){let r=x.join(n,`cli.js`);try{if(await i(r)){let n=await b.realpath(r).catch(()=>r);if(t.has(n))continue;t.add(n),c(`collectCandidates: Found cli.js at ${n}`);let i=await R(n);e.push({path:n,kind:`npm-based`,version:i})}}catch(e){c(`collectCandidates: Error checking ${r}:`,e)}}for(let n of ne)try{if(await i(n)){let r=await b.realpath(n).catch(()=>n);if(t.has(r))continue;t.add(r);let i=await P(r);c(`collectCandidates: Found native binary at ${r}${i===r?``:` (resolved -> ${i})`}`);let a=await V(i,`native-binary`);e.push({path:i,kind:`native-binary`,version:a})}}catch(e){c(`collectCandidates: Error checking ${n}:`,e)}return[...e].sort((e,t)=>r(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 (${l}):
|
|
4
4
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B as e,D as t,E as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,at as ee,b as E,ct as D,d as O,g as te,h as k,i as ne,it as A,k as re,l as j,m as ie,n as ae,nt as oe,o as se,ot as M,p as N,q as ce,r as P,rt as F,s as I,st as le,t as ue,tt as de,u as fe,v as pe,x as me,y as he,z as L}from"./config-BqRjOmoZ.mjs";import{a as ge,c as _e,d as ve,l as ye,n as be,o as xe,s as Se,t as Ce,u as we}from"./content-CD_fyzYM.mjs";import{Box as R,Text as z,render as Te,useInput as B,useStdin as Ee}from"ink";import{Command as De}from"commander";import V from"chalk";import Oe,{Fragment as ke,createContext as Ae,useCallback as je,useContext as H,useEffect as U,useMemo as Me,useRef as Ne,useState as W}from"react";import*as Pe from"node:os";import Fe from"ink-link";import*as Ie from"node:fs/promises";import*as G from"node:fs";import*as K from"node:path";import{execFile as Le,execSync as Re,spawn as ze}from"node:child_process";import Be from"gray-matter";import{structuredPatch as Ve}from"diff";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import He from"process";import Ue from"cli-spinners";import*as We from"node:readline";var X=({children:e,...t})=>Y(z,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...t,children:[` `,e,` `]});const Ge=[`\x1B[?25l\x1B[0m \x1B[38;2;0;0;0m \x1B[38;2;252;130;0m▂\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▇\x1B[38;2;254;131;0m\x1B[48;2;252;130;0m▇\x1B[48;2;252;130;0m▇▇\x1B[48;2;252;130;0m▇\x1B[0m\x1B[38;2;252;130;0m▇\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▂ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;254;131;0m▗\x1B[38;2;254;131;0m▆\x1B[48;2;254;131;0m \x1B[38;2;254;132;0m╶ \x1B[0m\x1B[38;2;254;131;0m▆\x1B[38;2;254;131;0m▖ \x1B[0m`,` \x1B[7m\x1B[38;2;254;131;0m▘\x1B[0m\x1B[38;2;11;6;0m\x1B[48;2;254;131;0m \x1B[38;2;254;216;182m\x1B[48;2;254;136;12m▃\x1B[38;2;254;249;246m\x1B[48;2;254;143;29m▅\x1B[38;2;254;253;253m\x1B[48;2;254;143;40m▆\x1B[38;2;254;254;253m\x1B[48;2;254;152;68m▆▆▆\x1B[38;2;254;253;252m\x1B[48;2;254;141;34m▆\x1B[38;2;254;247;242m\x1B[48;2;254;140;24m▅\x1B[38;2;254;224;199m\x1B[48;2;254;140;20m▖\x1B[48;2;254;131;0m \x1B[0m\x1B[7m\x1B[38;2;254;131;0m▝\x1B[0m \x1B[0m`,`\x1B[7m\x1B[38;2;251;127;0m▌\x1B[0m\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[38;2;252;128;0m\x1B[48;2;254;131;0m▃\x1B[38;2;252;129;0m▂\x1B[38;2;253;130;0m▁\x1B[38;2;249;135;16m\x1B[48;2;253;226;202m▋\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┈\x1B[48;2;246;246;245m┈\x1B[38;2;47;47;47m\x1B[48;2;244;244;243m▂\x1B[38;2;112;112;112m\x1B[48;2;251;251;251m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m▁╌▝\x1B[38;2;254;254;253m\x1B[48;2;254;254;254m▋\x1B[38;2;254;254;254m\x1B[48;2;254;253;252m┈\x1B[38;2;252;209;168m\x1B[48;2;251;129;0m▍\x1B[38;2;253;129;0m\x1B[48;2;254;131;0m▂\x1B[38;2;252;128;0m▃\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[0m\x1B[38;2;251;127;0m▌\x1B[0m`,`\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▏\x1B[38;2;245;118;0m\x1B[48;2;248;122;0m▄\x1B[38;2;247;121;0m\x1B[48;2;247;122;0m┈\x1B[38;2;106;68;38m\x1B[48;2;245;123;2m▃\x1B[38;2;39;33;28m\x1B[48;2;211;109;6m▅\x1B[38;2;27;20;12m\x1B[48;2;237;237;237m▌\x1B[48;2;254;254;253m \x1B[38;2;90;90;89m\x1B[48;2;231;230;230m▝\x1B[38;2;215;215;214m\x1B[48;2;48;48;48m▁\x1B[38;2;203;203;202m\x1B[48;2;42;42;42m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┇╴\x1B[38;2;253;252;252m▂\x1B[38;2;251;250;250m\x1B[48;2;253;253;253m▃\x1B[38;2;249;249;248m\x1B[48;2;252;252;251m▄\x1B[38;2;249;248;248m\x1B[48;2;237;118;0m▍\x1B[38;2;246;121;0m\x1B[48;2;250;125;0m▄\x1B[38;2;246;119;0m\x1B[48;2;249;124;0m▄\x1B[38;2;245;118;0m\x1B[48;2;248;123;0m▄\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▉\x1B[0m`,`\x1B[38;2;238;108;0m\x1B[48;2;237;109;0m▏\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;233;109;2m\x1B[48;2;125;73;29m▇\x1B[38;2;225;104;1m\x1B[48;2;50;32;18m▄\x1B[38;2;62;29;2m\x1B[48;2;239;237;237m▌\x1B[38;2;254;253;253m\x1B[48;2;254;254;254m┻\x1B[38;2;254;254;253m▊\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;253;253;252m▂\x1B[38;2;251;251;251m\x1B[48;2;254;253;253m▃\x1B[38;2;249;249;249m\x1B[48;2;252;252;252m▄\x1B[38;2;247;247;247m\x1B[48;2;250;250;250m▄\x1B[38;2;245;245;244m\x1B[48;2;248;248;248m▄\x1B[38;2;243;243;242m\x1B[48;2;246;246;245m▄\x1B[38;2;243;242;242m\x1B[48;2;230;109;0m▍\x1B[38;2;239;111;0m\x1B[48;2;243;116;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;237;108;0m\x1B[48;2;238;108;0m▉\x1B[0m`,`\x1B[7m\x1B[38;2;231;98;0m▌\x1B[0m\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[38;2;231;99;0m\x1B[48;2;235;105;0m▄\x1B[38;2;232;100;0m\x1B[48;2;236;105;0m▄\x1B[38;2;232;101;0m\x1B[48;2;236;106;0m▄\x1B[38;2;223;99;0m\x1B[48;2;247;238;235m▌\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;252;252;251m▃\x1B[38;2;250;250;250m\x1B[48;2;253;253;252m▄\x1B[38;2;248;248;247m\x1B[48;2;251;251;250m▄\x1B[38;2;246;245;245m\x1B[48;2;249;248;248m▄\x1B[38;2;243;243;243m\x1B[48;2;246;246;246m▄\x1B[38;2;241;241;241m\x1B[48;2;244;244;244m▄\x1B[38;2;239;239;238m\x1B[48;2;242;242;242m▄\x1B[38;2;237;237;236m\x1B[48;2;240;240;239m▄\x1B[38;2;237;236;236m\x1B[48;2;223;99;0m▍\x1B[38;2;232;100;0m\x1B[48;2;236;106;0m▄\x1B[38;2;231;100;0m\x1B[48;2;235;105;0m▄\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[0m\x1B[38;2;231;98;0m▌\x1B[0m`,` \x1B[7m\x1B[38;2;224;89;0m▖\x1B[0m\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[38;2;225;90;0m\x1B[48;2;228;95;0m▄\x1B[38;2;225;91;0m\x1B[48;2;229;96;0m▄\x1B[38;2;217;90;1m\x1B[48;2;97;77;70m▌\x1B[38;2;70;70;70m\x1B[48;2;207;207;207m▆\x1B[38;2;66;65;65m\x1B[48;2;228;228;227m▄\x1B[38;2;66;66;66m\x1B[48;2;233;232;232m▂\x1B[38;2;169;169;169m\x1B[48;2;243;243;243m▁\x1B[38;2;240;239;239m\x1B[48;2;243;242;242m▄\x1B[38;2;238;237;237m\x1B[48;2;241;240;240m▄\x1B[38;2;235;235;235m\x1B[48;2;238;238;238m▄\x1B[38;2;233;233;233m\x1B[48;2;236;236;236m▄\x1B[38;2;231;231;230m\x1B[48;2;234;234;233m▄\x1B[38;2;231;230;230m\x1B[48;2;216;89;0m▍\x1B[38;2;225;90;0m\x1B[48;2;229;95;0m▄\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[0m\x1B[7m\x1B[38;2;224;89;0m▗\x1B[0m \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;217;80;0m▝\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m\x1B[48;2;221;86;0m▄\x1B[38;2;197;78;9m\x1B[48;2;66;66;65m▋\x1B[38;2;65;65;64m\x1B[48;2;60;60;60m▘\x1B[38;2;52;52;51m\x1B[48;2;56;56;56m▗\x1B[38;2;45;45;45m\x1B[48;2;50;50;49m▗\x1B[38;2;42;42;42m\x1B[48;2;46;46;46m┈\x1B[38;2;41;41;41m\x1B[48;2;203;202;202m▆\x1B[38;2;38;38;38m\x1B[48;2;218;218;218m▄\x1B[38;2;45;45;45m\x1B[48;2;221;221;221m▂\x1B[38;2;229;229;229m┊\x1B[38;2;225;225;225m\x1B[48;2;228;228;227m▄\x1B[38;2;225;224;224m\x1B[48;2;209;79;0m▍\x1B[0m\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m▘ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[7m\x1B[38;2;191;73;0m▆\x1B[38;2;191;73;0m▄\x1B[38;2;56;55;55m▃\x1B[38;2;46;46;46m▁\x1B[0m\x1B[38;2;20;20;20m\x1B[48;2;42;42;42m▁\x1B[38;2;36;36;36m\x1B[48;2;35;34;34m╴\x1B[38;2;23;23;23m\x1B[48;2;29;29;28m▁\x1B[38;2;10;10;10m\x1B[48;2;22;22;22m▁\x1B[0m\x1B[7m\x1B[38;2;15;15;15m▁\x1B[38;2;22;22;21m▃\x1B[38;2;154;154;154m▅\x1B[38;2;175;116;83m▇\x1B[0m\x1B[38;2;17;15;14m \x1B[0m`,`\x1B[?25h\x1B[0m`];var Ke=()=>Y(R,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[Y(R,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[J(z,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),J(z,{children:` `}),Y(z,{children:[`We've released `,J(z,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),Y(z,{children:[`Download it and try it out for free!`,` `,J(Fe,{url:`https://piebald.ai/`,fallback:!1,children:J(z,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),J(z,{children:` `}),J(z,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),J(R,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:Ge.map((e,t)=>J(z,{children:e},t))})]});let Z=function(e){return e.THEMES=`Themes`,e.THINKING_VERBS=`Thinking verbs`,e.THINKING_STYLE=`Thinking style`,e.USER_MESSAGE_DISPLAY=`User message display`,e.INPUT_PATTERN_HIGHLIGHTERS=`Input pattern highlighters`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.SUBAGENT_MODELS=`Subagent models`,e.COMPLEXITY_ROUTER=`Complexity effort router [experimental]`,e.FABLE_PLAN=`Fable Plan mode`,e.CLAUDE_MD_ALT_NAMES=`CLAUDE.md alternative names`,e.SYSTEM_REMINDERS=`System reminders (injection lobotomy)`,e.SKILLS=`Skills (per-skill on/name-only/user-invocable/off)`,e.BROWSER_BRIDGE=`Better Claude in Chrome`,e.VIEW_SYSTEM_PROMPTS=`View system prompts`,e.RESTORE_ORIGINAL=`Restore original Claude Code (preserves config.json)`,e.OPEN_CONFIG=`Open config.json`,e.OPEN_CLI=`Open Claude Code's cli.js`,e.EXIT=`Exit`,e}({});function qe({items:e,selectedIndex:t,onSelect:n,onSubmit:r}){return B((i,a)=>{e.length!==0&&(a.upArrow?n(t>0?t-1:e.length-1):a.downArrow?n(t<e.length-1?t+1:0):a.return&&r(e[t].name))}),J(R,{flexDirection:`column`,children:e.map((e,n)=>J(R,{children:Y(z,{children:[Y(z,{bold:n===t,color:n===t?`cyan`:void 0,...n===t?e.selectedStyles??{}:e.styles??{},children:[n===t?`❯ `:` `,e.name]}),e.desc&&n===t&&Y(z,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,e.desc]})]})},n))})}const Je=[{name:Z.THEMES,desc:`Modify Claude Code's built-in themes or create your own`},{name:Z.THINKING_VERBS,desc:`Customize the list of verbs that Claude Code uses when it's working`},{name:Z.THINKING_STYLE,desc:`Choose custom spinners`},{name:Z.USER_MESSAGE_DISPLAY,desc:`Customize how user messages are displayed`},{name:Z.INPUT_PATTERN_HIGHLIGHTERS,desc:`Create custom highlighters for patterns in your input`},{name:Z.MISC,desc:`Miscellaneous settings (input box border, etc.)`},{name:Z.TOOLSETS,desc:`Manage toolsets to control which tools are available`},{name:Z.SUBAGENT_MODELS,desc:`Configure which Claude model each subagent uses (Plan, Explore, etc.)`},{name:Z.COMPLEXITY_ROUTER,desc:`[EXPERIMENTAL] Auto-route reasoning effort by task complexity (routine=low ... hardest=max)`},{name:Z.FABLE_PLAN,desc:`Plan on one model, execute on another (a /model entry, like opusplan)`},{name:Z.CLAUDE_MD_ALT_NAMES,desc:`Configure alternative filenames for CLAUDE.md (e.g., AGENTS.md)`},{name:Z.SYSTEM_REMINDERS,desc:`Suppress per-turn <system-reminder> injections (skills list, MCP instructions, claudeMd wrapper, etc.)`},{name:Z.SKILLS,desc:`Per-skill listing control (writes settings.json skillOverrides — no patch needed)`},{name:Z.BROWSER_BRIDGE,desc:`Drive your real, logged-in tabs over CDP — a fuller take on Claude in Chrome`},{name:Z.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],Ye=[{name:Z.RESTORE_ORIGINAL,desc:`Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)`},{name:Z.OPEN_CONFIG,desc:`Opens your tweakcc config file (${P})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var Xe=({onSubmit:e})=>{let t=[...Je,...Ye],[n,r]=W(0);return J(qe,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const Ze=()=>Y(R,{flexDirection:`row`,children:[J(X,{children:`tweakcc`}),J(z,{children:` (by `}),J(Fe,{url:`https://piebald.ai`,fallback:!1,children:J(z,{color:`#ff8400`,bold:!0,children:`Piebald`})}),J(z,{children:`)`})]}),Qe=()=>J(R,{children:Y(z,{color:`yellow`,children:[`⭐ `,J(z,{bold:!0,children:`Star the repo at `}),J(Fe,{url:`https://github.com/skrabe/tweakcc-fixed`,fallback:!1,children:J(z,{bold:!0,color:`cyan`,children:`https://github.com/skrabe/tweakcc-fixed`})}),J(z,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),$e=({notification:e})=>J(R,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:e.type===`success`?`green`:e.type===`error`?`red`:e.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:J(z,{color:e.type===`success`?`green`:e.type===`error`?`red`:e.type===`info`?`blue`:`yellow`,children:e.message})}),et=({onSubmit:e,notification:t,configMigrated:n,showPiebaldAnnouncement:r,changesApplied:i,invocationCommand:a})=>Y(R,{flexDirection:`column`,gap:1,children:[n&&J(R,{children:J(z,{color:`blue`,bold:!0,children:"Note that in tweakcc v3.2.0+, `ccInstallationDir` config is deprecated. You are now migrated to `ccInstallationPath` which supports npm and native installs."})}),J(Ze,{}),J(R,{children:Y(z,{children:[J(z,{bold:!0,children:`Customize your Claude Code installation.`}),` `,Y(z,{dimColor:!0,children:[`Settings will be saved to `,ae.replace(Pe.homedir(),`~`),`/config.json.`]})]})}),J(r?Ke:Qe,{}),t&&J($e,{notification:t}),!i&&!t&&J($e,{notification:{message:`Your changes are configured but not applied.\nRun \`${a} --apply\` to apply your customizations!`,type:`info`}}),J(Xe,{onSubmit:e})]});function Q({color:e,backgroundColor:t,bold:n,dimColor:r,children:i}){let a=e?.startsWith(`ansi:`),o=t?.startsWith(`ansi:`);if(a||o){if(Oe.Children.toArray(i).some(e=>Oe.isValidElement(e)))return J(z,{children:i});let s=V;if(a){let t=e.slice(5);s=s[t]||s}if(o){let e=t.slice(5),n=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;s=s[n]||s}n&&(s=s.bold),r&&(s=s.dim);let c=Oe.Children.toArray(i).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return J(z,{children:s(c)})}return J(z,{color:e,backgroundColor:t,bold:n,dimColor:r,children:i})}function tt({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:r=3,updateDuration:i=50,restartPoint:a=10}){let[o,s]=W(0);return U(()=>{let t=setInterval(()=>{s(t=>{let n=t+1;return n>=e.length+a?-r:n})},i);return()=>clearInterval(t)},[e.length,a,i]),t.length===n.length?J(z,{children:e.split(``).map((i,a)=>{let s=a>=o&&a<o+r&&o<e.length,c=a%t.length;return J(z,{color:s?n[c]:t[c],children:i},a)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),J(z,{children:e}))}const nt=He.cwd();function rt({theme:e}){let{ccVersion:t}=H($);return Y(R,{flexDirection:`column`,paddingLeft:1,children:[J(R,{marginBottom:1,children:Y(z,{bold:!0,children:[`Preview: `,e.name]})}),J(R,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:Y(R,{flexDirection:`column`,children:[Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(Q,{color:e.colors.clawd_body,children:` ▐`}),J(z,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:`▛███▜`}),Y(z,{children:[J(Q,{color:e.colors.clawd_body,children:`▌ `}),` `,J(z,{bold:!0,children:`Claude Code`}),` `,t?`v${t}`:`v2.0.14`]})]}),Y(z,{children:[J(Q,{color:e.colors.clawd_body,children:`▝▜`}),J(z,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:`█████`}),J(Q,{color:e.colors.clawd_body,children:`▛▘`}),` `,g(),` · `,E()]}),Y(Q,{color:e.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,nt]}),Y(z,{children:[Y(Q,{color:e.colors.success,children:[`Login successful. Press`,` `]}),J(Q,{bold:!0,color:e.colors.success,children:`Enter`}),Y(Q,{color:e.colors.success,children:[` `,`to continue…`]})]})]}),J(z,{children:`╭─────────────────────────────────────────────╮`}),Y(z,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),Y(z,{children:[`│ 2`,` `,J(Q,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:`- console.log("`}),J(Q,{backgroundColor:e.colors.diffRemovedWord,children:`Hello, World!`}),J(Q,{backgroundColor:e.colors.diffRemoved,children:`");`}),` `,`│`]}),Y(z,{children:[`│ 2`,` `,J(Q,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:`+ console.log("`}),J(Q,{backgroundColor:e.colors.diffAddedWord,children:`Hello, Claude!`}),J(Q,{backgroundColor:e.colors.diffAdded,children:`");`}),` `,`│`]}),J(Q,{color:e.colors.warning,children:`╭─────────────────────────────────────────────╮`}),Y(Q,{color:e.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),Y(z,{children:[J(Q,{color:e.colors.warning,children:`│ `}),J(z,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),Y(Q,{color:e.colors.warning,children:[` `,`│`]})]}),J(Q,{color:e.colors.bashBorder,children:`───────────────────────────────────────────────`}),Y(z,{children:[J(Q,{color:e.colors.bashBorder,children:`!`}),J(z,{children:` ls`})]}),J(Q,{color:e.colors.promptBorder,children:`───────────────────────────────────────────────`}),J(z,{children:Y(z,{children:[`> list the dir`,` `,J(tt,{text:`ultrathink`,nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),J(Q,{color:e.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),Y(z,{children:[J(Q,{color:e.colors.planMode,children:`│ `}),Y(Q,{color:e.colors.permission,children:[`Ready to code?`,` `]}),J(z,{children:`Here is Claude's plan:`}),Y(Q,{color:e.colors.planMode,children:[` `,`│`]})]}),J(Q,{color:e.colors.permission,children:`╭─────────────────────────────────────────────╮`}),Y(z,{children:[J(Q,{color:e.colors.permission,children:`│ `}),J(z,{bold:!0,children:`Permissions:`}),` `,Y(Q,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,J(Q,{color:e.colors.permission,children:`│`})]}),J(z,{children:`> list the dir`}),Y(z,{children:[J(Q,{color:e.colors.error,children:`●`}),J(z,{children:` Update(__init__.py)`})]}),Y(z,{children:[J(z,{children:` ⎿ `}),J(Q,{color:e.colors.error,children:`User rejected update to __init__.py`})]}),Y(z,{children:[` `,`1`,` `,Y(Q,{backgroundColor:e.colors.diffRemovedDimmed,children:[`- import`,` `]}),J(Q,{backgroundColor:e.colors.diffRemovedWordDimmed,children:`os`})]}),Y(z,{children:[` `,`2`,` `,Y(Q,{backgroundColor:e.colors.diffAddedDimmed,children:[`+ import`,` `]}),J(Q,{backgroundColor:e.colors.diffAddedWordDimmed,children:`random`})]}),Y(z,{children:[J(Q,{color:e.colors.success,children:`●`}),J(z,{children:` List(.)`})]}),Y(z,{children:[J(z,{children:`●`}),J(z,{children:` The directory `}),J(Q,{color:e.colors.permission,children:`C:\\Users\\user`}),Y(z,{children:[` `,`contains `,J(z,{bold:!0,children:`123`}),` files.`]})]}),Y(z,{children:[J(Q,{color:e.colors.claude,children:`✻ Th`}),J(Q,{color:e.colors.claudeShimmer,children:`ink`}),J(Q,{color:e.colors.claude,children:`ing… `}),J(z,{children:`(esc to interrupt)`})]}),J(z,{children:J(Q,{color:e.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),J(z,{children:J(Q,{color:e.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),J(z,{children:J(Q,{color:e.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function it({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?J(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?J(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):J(Q,{color:r,bold:n,children:e})}function at({initialValue:e,onColorChange:r,onExit:i,colorKey:a,theme:o}){let s=st(e)||{h:0,s:50,l:50},c=ot(e)||{r:128,g:128,b:128},[l,u]=W(s),[d,f]=W(c),[p,m]=W(`hsl`),[h,g]=W(`h`),[_,v]=W(!1),[y,b]=W(!1);U(()=>{let t=st(e),n=ot(e);t&&n&&(v(!0),u(t),f(n),v(!1))},[e]),U(()=>{!_&&y&&r(`rgb(${d.r},${d.g},${d.b})`)},[l,d,_,y]),U(()=>{b(!0)},[]);let x=e=>{if(n(e)){let n=t(e),r=st(n),i=ot(n);r&&i&&(v(!0),u(r),f(i),v(!1))}};B((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){x(e);return}t.return||t.escape?i():t.ctrl&&e===`a`?(m(e=>e===`hsl`?`rgb`:`hsl`),g(e=>p===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?g(p===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?g(p===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?S(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&S(t.shift||t.ctrl||t.meta?10:1)});let S=e=>{v(!0),p===`hsl`?u(t=>{let n={...t};h===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):h===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):h===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=w(n.h,n.s,n.l);return f({r,g:i,b:a}),n}):f(t=>{let n={...t};return h===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):h===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):h===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),u(C(n.r,n.g,n.b)),n}),v(!1)},C=(e,t,n)=>{let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===r?((i-a)/c+(i<a?6:0))/6:o===i?((a-r)/c+2)/6:((r-i)/c+4)/6),{h:Math.round(d*360),s:Math.round(u*100),l:Math.round(l*100)}},w=(e,t,n)=>{e/=360,t/=100,n/=100;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e*6%2-1)),a=n-r/2,o=0,s=0,c=0;return 0<=e&&e<1/6?(o=r,s=i,c=0):1/6<=e&&e<2/6?(o=i,s=r,c=0):2/6<=e&&e<3/6?(o=0,s=r,c=i):3/6<=e&&e<4/6?(o=0,s=i,c=r):4/6<=e&&e<5/6?(o=i,s=0,c=r):5/6<=e&&e<1&&(o=r,s=0,c=i),[Math.round((o+a)*255),Math.round((s+a)*255),Math.round((c+a)*255)]},T=()=>{let e=[],t=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let n=0;n<40;n++){let r=n/39*(t.length-1),i=Math.floor(r),a=Math.ceil(r),o=r-i,[s,c,l]=t[i],[u,d,f]=t[a],p=Math.round(s+(u-s)*o),m=Math.round(c+(d-c)*o),h=Math.round(l+(f-l)*o);e.push(J(z,{backgroundColor:`rgb(${p},${m},${h})`,children:` `},n))}return e},ee=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(l.h,n,l.l);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},E=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(l.h,l.s,n);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},D=()=>{let[e,t,n]=w(l.h,l.s,l.l);return`rgb(${e},${t},${n})`},O=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},te=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${n},${d.g},${d.b})`,children:` `},t))}return e},k=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${d.r},${n},${d.b})`,children:` `},t))}return e},ne=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${d.r},${d.g},${n})`,children:` `},t))}return e},A=(e,t)=>Math.round(e/t*39);return Y(R,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[Y(R,{flexDirection:`column`,children:[J(z,{bold:!0,children:`Color Picker`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),J(z,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),J(z,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),J(z,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),J(z,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),J(z,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),p===`hsl`?Y(q,{children:[Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`h`?`yellow`:`white`,children:[h===`h`?`❯ `:` `,`Hue (`,l.h,`°):`]})}),J(R,{children:T().map((e,t)=>J(ke,{children:t===A(l.h,360)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`s`?`yellow`:`white`,children:[h===`s`?`❯ `:` `,`Saturation (`,l.s,`%):`]})}),J(R,{children:ee().map((e,t)=>J(ke,{children:t===A(l.s,100)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`l`?`yellow`:`white`,children:[h===`l`?`❯ `:` `,`Lightness (`,l.l,`%):`]})}),J(R,{children:E().map((e,t)=>J(ke,{children:t===A(l.l,100)?J(z,{children:`|`}):e},t))})]})]}):Y(q,{children:[Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`r`?`yellow`:`white`,children:[h===`r`?`❯ `:` `,`Red (`,d.r,`):`]})}),J(R,{children:te().map((e,t)=>J(ke,{children:t===A(d.r,255)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`g`?`yellow`:`white`,children:[h===`g`?`❯ `:` `,`Green (`,d.g,`):`]})}),J(R,{children:k().map((e,t)=>J(ke,{children:t===A(d.g,255)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`b`?`yellow`:`white`,children:[h===`b`?`❯ `:` `,`Blue (`,d.b,`):`]})}),J(R,{children:ne().map((e,t)=>J(ke,{children:t===A(d.b,255)?J(z,{children:`|`}):e},t))})]})]}),Y(R,{marginBottom:1,children:[J(z,{children:`Current: `}),J(z,{backgroundColor:D(),children:` `})]}),Y(R,{flexDirection:`row`,justifyContent:`space-between`,children:[Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Hex `}),a?.startsWith(`diff`)?J(z,{backgroundColor:D(),color:o?.colors?.text||`white`,bold:!0,children:O(d.r,d.g,d.b)}):a===`inverseText`?J(z,{color:D(),backgroundColor:o?.colors?.permission,bold:!0,children:O(d.r,d.g,d.b)}):J(z,{color:D(),bold:!0,children:O(d.r,d.g,d.b)})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`RGB `}),a?.startsWith(`diff`)?J(z,{backgroundColor:D(),color:o?.colors?.text||`white`,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):a===`inverseText`?J(z,{color:D(),backgroundColor:o?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):J(z,{color:D(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`HSL `}),a?.startsWith(`diff`)?J(z,{backgroundColor:D(),color:o?.colors?.text||`white`,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):a===`inverseText`?J(z,{color:D(),backgroundColor:o?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):J(z,{color:D(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function ot(e){let t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};let n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){let e=n[1];return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}return null}function st(e){let t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){let e=parseInt(n[1])/255,t=parseInt(n[2])/255,r=parseInt(n[3])/255,i=Math.max(e,t,r),a=Math.min(e,t,r),o=i-a,s=(i+a)/2,c=0;o!==0&&(c=s>.5?o/(2-i-a):o/(i+a));let l=0;return o!==0&&(l=i===e?((t-r)/o+(t<r?6:0))/6:i===t?((r-e)/o+2)/6:((e-t)/o+4)/6),{h:Math.round(l*360),s:Math.round(c*100),l:Math.round(s*100)}}let r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){let e=r[1],t=parseInt(e.substr(0,2),16)/255,n=parseInt(e.substr(2,2),16)/255,i=parseInt(e.substr(4,2),16)/255,a=Math.max(t,n,i),o=Math.min(t,n,i),s=a-o,c=(a+o)/2,l=0;s!==0&&(l=c>.5?s/(2-a-o):s/(a+o));let u=0;return s!==0&&(u=a===t?((n-i)/s+(n<i?6:0))/6:a===n?((i-t)/s+2)/6:((t-n)/s+4)/6),{h:Math.round(u*360),s:Math.round(l*100),l:Math.round(c*100)}}return{h:0,s:50,l:50}}function ct({onBack:e,themeId:r}){let{settings:{themes:i},updateSettings:a}=H($),[o,s]=W(r),c=i.find(e=>e.id===o)||i[0],[l,u]=W(`rgb`),[f,p]=W(0),[m,h]=W(null),[g,_]=W(null),[v,y]=W(``),[b,x]=W(``),[S,C]=W(!1),[w,T]=W(0),ee=je(e=>{a(t=>{let n=t.themes.findIndex(e=>e.id===o);n!==-1&&e(t.themes[n])})},[o,a]),E=e=>{if(f>=2&&n(e)){let n=t(e),r=D[f-2];ee(e=>{e.colors[r]=n})}};B((t,n)=>{if(S){if(n.escape){C(!1),e();return}return}if(m===null&&g===null){if(t.length>1&&!n.ctrl&&!n.meta){E(t);return}if(n.escape)C(!0),T(0);else if(n.ctrl&&t===`a`)u(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(n.upArrow)p(e=>Math.max(0,e-1));else if(n.downArrow)p(e=>Math.min(D.length+1,e+1));else if(n.return)if(f===0)_(`name`),y(c.name),x(c.name);else if(f===1)_(`id`),y(c.id),x(c.id);else{let e=f-2,t=D[e],n=c.colors[t];h(e),y(n),x(n)}}else if(m!==null)n.ctrl&&t===`a`&&u(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(g!==null)if(n.return){if(g===`id`){let e=o;s(v),a(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=v)})}else ee(e=>{e.name=v});_(null),y(``),x(``)}else n.escape?(_(null),y(``),x(``)):n.backspace||n.delete?y(e=>e.slice(0,-1)):t&&y(e=>e+t)});let D=Object.keys(c.colors),O=(e,t)=>{let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)return e;let r=parseInt(n[1]),i=parseInt(n[2]),a=parseInt(n[3]);switch(t){case`hex`:{let e=e=>e.toString(16).padStart(2,`0`);return`#${e(r)}${e(i)}${e(a)}`}case`hsl`:{let e=r/255,t=i/255,n=a/255,o=Math.max(e,t,n),s=Math.min(e,t,n),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===e?((t-n)/c+(t<n?6:0))/6:o===t?((n-e)/c+2)/6:((e-t)/c+4)/6),`hsl(${Math.round(d*360)}, ${Math.round(u*100)}%, ${Math.round(l*100)}%)`}case`rgb`:default:return e}},te=e=>({autoAccept:`Auto-accept edits mode indicator`,bashBorder:`Bash command border`,claude:`Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.`,claudeShimmer:`Color used for the shimmering effect on the thinking verb.`,claudeBlue_FOR_SYSTEM_SPINNER:`System spinner color (blue variant)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`System spinner shimmer color (blue variant)`,permission:`Permission prompt color`,permissionShimmer:`Permission prompt shimmer color`,planMode:`Plan mode indicator`,ide:`Color used for IDE-related messages.`,promptBorder:`Input prompt border color`,promptBorderShimmer:`Input prompt border shimmer color`,text:`Code color. Used in diffs.`,inverseText:`Inverse text color. Used for the text of tabs, where the background is filled in.`,inactive:`Inactive/dimmed text. Used for line numbers and less prominent text.`,subtle:`Subtle text. Used for help text and secondary information.`,suggestion:`Suggestion text color. Used for suggestions for theme names and various other things.`,remember:`Remember/note color. Used for various text relating to memories.`,background:`Background color for certain UI elements`,success:`Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).`,error:`Error indicator`,warning:`Warning indicator`,warningShimmer:`Warning shimmer color`,diffAdded:`Added diff background`,diffRemoved:`Removed diff background`,diffAddedDimmed:`Added diff background (dimmed)`,diffRemovedDimmed:`Removed diff background (dimmed)`,diffAddedWord:`Added word highlight`,diffRemovedWord:`Removed word highlight`,diffAddedWordDimmed:`Added word highlight (dimmed)`,diffRemovedWordDimmed:`Removed word highlight (dimmed)`,red_FOR_SUBAGENTS_ONLY:`Red color for sub agents`,blue_FOR_SUBAGENTS_ONLY:`Blue color for sub agents`,green_FOR_SUBAGENTS_ONLY:`Green color for sub agents`,yellow_FOR_SUBAGENTS_ONLY:`Yellow color for sub agents`,purple_FOR_SUBAGENTS_ONLY:`Purple color for sub agents`,orange_FOR_SUBAGENTS_ONLY:`Orange color for sub agents`,pink_FOR_SUBAGENTS_ONLY:`Pink color for sub agents`,cyan_FOR_SUBAGENTS_ONLY:`Cyan color for sub agents`,professionalBlue:`Professional blue color for business contexts?`,rainbow_red:`"ultrathink" rainbow - red`,rainbow_orange:`"ultrathink" rainbow - orange`,rainbow_yellow:`"ultrathink" rainbow - yellow`,rainbow_green:`"ultrathink" rainbow - green`,rainbow_blue:`"ultrathink" rainbow - blue`,rainbow_indigo:`"ultrathink" rainbow - indigo`,rainbow_violet:`"ultrathink" rainbow - violet`,rainbow_red_shimmer:`"ultrathink" rainbow (shimmer) - red`,rainbow_orange_shimmer:`"ultrathink" rainbow (shimmer) - orange`,rainbow_yellow_shimmer:`"ultrathink" rainbow (shimmer) - yellow`,rainbow_green_shimmer:`"ultrathink" rainbow (shimmer) - green`,rainbow_blue_shimmer:`"ultrathink" rainbow (shimmer) - blue`,rainbow_indigo_shimmer:`"ultrathink" rainbow (shimmer) - indigo`,rainbow_violet_shimmer:`"ultrathink" rainbow (shimmer) - violet`,clawd_body:`"Clawd" character body color`,clawd_background:`"Clawd" character background color`,userMessageBackground:`Background color for user messages`,bashMessageBackgroundColor:`Background color for bash command output`,memoryBackgroundColor:`Background color for memory/context information`,rate_limit_fill:`Rate limit indicator fill color`,rate_limit_empty:`Rate limit indicator empty/background color`})[e]||``,k=Math.max(...D.map(e=>e.length));return Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(X,{children:[`Editing theme “`,c.name,`” (`,c.id,`)`]})}),S?Y(R,{flexDirection:`column`,marginTop:1,children:[J(R,{marginBottom:1,children:Y(z,{bold:!0,children:[`Would you like to make “`,c.name,`” your current Claude Code theme?`]})}),J(qe,{items:[{name:`Yes`,desc:`Set ${c.id} as active theme`},{name:`No`,desc:`Go back without changing theme`}],selectedIndex:w,onSelect:T,onSubmit:()=>{w===0&&d(c.id),C(!1),e()}}),J(z,{dimColor:!0,children:`enter to select, esc to cancel`})]}):m===null&&g===null?Y(q,{children:[Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`enter to edit theme name, id, or color`}),J(z,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),J(z,{dimColor:!0,children:`paste color from clipboard (when on color)`}),J(z,{dimColor:!0,children:`esc to go back`})]}),f<2?Y(R,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[J(z,{bold:!0,children:f===0?`Theme Name`:`Theme ID`}),J(z,{children:f===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):Y(R,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:c.colors[D[f-2]],flexDirection:`column`,paddingLeft:1,children:[J(it,{colorKey:D[f-2],theme:c,bold:!0}),J(z,{children:te(D[f-2])})]}),Y(R,{flexDirection:`column`,children:[Y(R,{children:[J(z,{color:f===0?`yellow`:`white`,children:f===0?`❯ `:` `}),J(z,{bold:!0,children:`Name: `}),J(z,{children:c.name})]}),Y(R,{marginBottom:1,children:[J(z,{color:f===1?`yellow`:`white`,children:f===1?`❯ `:` `}),J(z,{bold:!0,children:`ID: `}),J(z,{children:c.id})]}),(()=>{if(f<2)return Y(q,{children:[D.slice(0,20).map((e,t)=>{let n=t+2;return Y(R,{children:[J(z,{color:f===n?`yellow`:`white`,children:f===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(it,{colorKey:e,theme:c,bold:!0})})}),J(Q,{color:c.colors[e],children:O(c.colors[e],l)})]},e)}),D.length>20&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let e=f-2,t=Math.max(0,e-10),n=Math.min(D.length,t+20),r=Math.max(0,n-20),i=D.slice(r,n);return Y(q,{children:[r>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,t)=>{let n=r+t+2;return Y(R,{children:[J(z,{color:f===n?`yellow`:`white`,children:f===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(it,{colorKey:e,theme:c,bold:!0})})}),J(Q,{color:c.colors[e],children:O(c.colors[e],l)})]},e)}),n<D.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-n,` more below`]})]})})()]})]}):g?Y(R,{flexDirection:`column`,marginTop:1,children:[Y(z,{children:[`Editing `,g===`name`?`theme name`:`theme ID`,`:`]}),J(R,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:J(z,{children:v})}),J(z,{dimColor:!0,children:`enter to save, esc to cancel`})]}):J(at,{initialValue:b,colorKey:D[m],theme:c,onColorChange:e=>{y(e),ee(t=>{t.colors[D[m]]=e})},onExit:()=>{ee(e=>{e.colors[D[m]]=v}),h(null),y(``),x(``)}})]}),J(R,{width:`50%`,children:J(rt,{theme:c})})]})}const lt=`https://raw.githubusercontent.com/Piebald-AI/claude-code-themes/main`,ut=`${lt}/index.json`,dt=2e4;async function ft(){N(`Fetching community theme index from ${ut}`);let e=await fetch(ut,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(dt)});if(!e.ok)throw Error(`Failed to fetch community theme index: ${e.status} ${e.statusText}`);return JSON.parse(await re(e))}async function pt(e){let t=`${lt}/themes/${e}.json`;N(`Fetching community theme from ${t}`);let n=await fetch(t,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(dt)});if(!n.ok)throw Error(`Failed to fetch community theme "${e}": ${n.status} ${n.statusText}`);return JSON.parse(await re(n))}function mt({onBack:e}){let{updateSettings:t}=H($),[n,r]=W({status:`loading`}),[i,a]=W(0),[o,s]=W(null),[c,l]=W(!1),[u,d]=W(null),f=Ne(0);U(()=>{ft().then(e=>{r({status:`loaded`,entries:e})}).catch(e=>{r({status:`error`,message:e.message})})},[]);let p=n.status===`loaded`?n.entries:[],m=je(async e=>{let t=++f.current;l(!0),d(null);try{let n=await pt(e);if(t!==f.current)return;s(ie(n,le))}catch{if(t!==f.current)return;s(null),d(`Failed to load preview.`)}finally{t===f.current&&l(!1)}},[]),h=je(async e=>{d(`Downloading theme…`);try{let n=ie(await pt(e.id),le),r=!1;t(e=>{e.themes.some(e=>e.id===n.id)||(e.themes.push(n),r=!0)}),d(r?`Added "${n.name}" to your themes!`:`Theme "${n.name}" (${n.id}) is already in your config.`)}catch{d(`Failed to download theme.`)}},[t]);return B((t,r)=>{if(r.escape){e();return}if(n.status!==`loaded`)return;let o=n.entries.length;if(o!==0){if(r.upArrow)a(e=>Math.max(0,e-1)),s(null),d(null);else if(r.downArrow)a(e=>Math.min(o-1,e+1)),s(null),d(null);else if(t===` `){let e=n.entries[i];e&&m(e.id)}else if(r.return){let e=n.entries[i];e&&h(e)}}}),n.status===`loading`?Y(R,{flexDirection:`column`,children:[J(X,{children:`Community Themes`}),J(z,{children:`Loading community themes…`})]}):n.status===`error`?Y(R,{flexDirection:`column`,children:[J(X,{children:`Community Themes`}),Y(z,{color:`red`,children:[`Error: `,n.message]}),J(z,{dimColor:!0,children:`esc to go back`})]}):Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(X,{children:`Community Themes`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`space to preview theme`}),J(z,{dimColor:!0,children:`enter to download theme`}),J(z,{dimColor:!0,children:`esc to go back`})]}),J(R,{flexDirection:`column`,children:p.map((e,t)=>Y(z,{color:i===t?`yellow`:void 0,children:[i===t?`❯ `:` `,e.name,` (`,e.id,`) by @`,e.author]},e.id))}),u&&J(R,{marginTop:1,children:J(z,{color:`cyan`,children:u})}),c&&J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`Loading preview…`})})]}),J(R,{width:`50%`,children:o?J(rt,{theme:o}):J(R,{flexDirection:`column`,justifyContent:`center`,alignItems:`center`,height:10,children:J(z,{dimColor:!0,children:`Press space to preview the selected theme.`})})})]})}function ht(e){return e.map(e=>`${e.name} (${e.id})`)}function gt({onBack:e}){let{settings:{themes:t},updateSettings:n}=H($),[r,i]=W(0),[a,o]=W(null),[s,c]=W(!0),[l,u]=W(!1),d=t.length+1,f=()=>{let e={colors:{...(t[0]||M.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};n(t=>{t.themes.push(e)}),o(e.id),c(!1)},p=e=>{t.length<=1||(n(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),r>=t.length-1&&i(Math.max(0,t.length-2)))},m=()=>{n(e=>{e.themes=[...M.themes]}),i(0)},h=r===t.length;if(B((n,a)=>{if(a.escape)e();else if(a.upArrow)i(e=>Math.max(0,e-1));else if(a.downArrow)i(e=>Math.min(d-1,e+1));else if(a.return)if(h)u(!0),c(!1);else{let e=t[r];e&&(o(e.id),c(!1))}else if(n===`n`)f();else if(n===`d`){if(!h){let e=t[r];e&&p(e.id)}}else a.ctrl&&n===`r`&&m()},{isActive:s}),l)return J(mt,{onBack:()=>{u(!1),c(!0)}});if(a)return J(ct,{themeId:a,onBack:()=>{o(null),c(!0)}});let g=ht(t),_=t.find(e=>g[r]?.includes(`(${e.id})`))||t[0];return t.length===0?J(R,{children:Y(R,{flexDirection:`column`,width:`100%`,children:[J(X,{children:`Themes`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new theme`}),J(z,{dimColor:!0,children:`esc to go back`})]}),J(z,{children:`No themes available!`})]})}):Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(X,{children:`Themes`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new theme`}),J(z,{dimColor:!0,children:`d to delete a theme`}),J(z,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),J(z,{dimColor:!0,children:`enter to edit theme`}),J(z,{dimColor:!0,children:`esc to go back`})]}),Y(R,{flexDirection:`column`,children:[g.map((e,t)=>Y(z,{color:r===t?`yellow`:void 0,children:[r===t?`❯ `:` `,e]},t)),Y(z,{color:h?`blue`:void 0,bold:h,children:[h?`❯ `:` `,`Browse community themes…`]})]})]}),J(R,{width:`50%`,children:h?J(R,{flexDirection:`column`,justifyContent:`center`,alignItems:`center`,height:10,children:J(z,{dimColor:!0,children:`Press enter to browse community themes.`})}):J(rt,{theme:_})})]})}function _t(e,t,n){let r=Math.max(0,e-Math.floor(n/2)),i=Math.min(t,r+n);return{start:Math.max(0,i-n),end:i}}function vt({onBack:e}){let{settings:{thinkingVerbs:{format:t,verbs:n},themes:r},updateSettings:i}=H($),a=[`format`,`verbs`],[o,s]=W(0),c=a[o],[l,u]=W(0),[d,f]=W(!1),[p,m]=W(``),[h,g]=W(!1),[_,v]=W(!1),[y,b]=W(t),x=me(),S=(r.find(e=>e.id===x)||r.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return B((r,o)=>{if(_){o.return?(i(e=>{e.thinkingVerbs.format=y}),v(!1)):o.escape?(b(t),v(!1)):o.backspace||o.delete?b(e=>e.slice(0,-1)):r&&b(e=>e+r);return}if(d||h){o.return&&p.trim()?(h?(i(e=>{e.thinkingVerbs.verbs.push(p.trim())}),g(!1)):(i(e=>{e.thinkingVerbs.verbs[l]=p.trim()}),f(!1)),m(``)):o.escape?(m(``),f(!1),g(!1)):o.backspace||o.delete?m(e=>e.slice(0,-1)):r&&m(e=>e+r);return}o.escape?e():o.return?c===`format`&&(b(t),v(!0)):o.tab?o.shift?s(e=>e===0?a.length-1:e-1):s(e=>e===a.length-1?0:e+1):o.upArrow?c===`verbs`&&n.length>0&&u(e=>e>0?e-1:n.length-1):o.downArrow?c===`verbs`&&n.length>0&&u(e=>e<n.length-1?e+1:0):r===`e`&&c===`verbs`?n.length>0&&(m(n[l]),f(!0)):r===`d`&&c===`verbs`?n.length>1&&(i(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==l)}),l>=n.length-1&&u(Math.max(0,n.length-2))):r===`n`&&c===`verbs`?(g(!0),m(``)):o.ctrl&&r===`r`&&c===`verbs`&&(i(e=>{e.thinkingVerbs.verbs=[...M.thinkingVerbs.verbs]}),u(0))}),Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[Y(R,{marginBottom:1,flexDirection:`column`,children:[J(X,{children:`Thinking Verbs`}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:c===`format`?`enter to edit format`:`changes auto-saved`}),J(z,{dimColor:!0,children:`esc to go back`}),J(z,{dimColor:!0,children:`tab to switch sections`})]})]}),J(R,{marginBottom:1,children:J(z,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(z,{color:c===`format`?`yellow`:void 0,children:c===`format`?`❯ `:` `}),J(z,{bold:!0,color:c===`format`?`yellow`:void 0,children:`Format`})]}),c===`format`&&(_?Y(z,{dimColor:!0,children:[` `,`enter to save`]}):Y(z,{dimColor:!0,children:[` `,`enter to edit`]}))]}),J(R,{marginLeft:2,marginBottom:1,children:J(R,{borderStyle:`round`,borderColor:_?`yellow`:`gray`,children:J(z,{children:_?y:t})})}),J(R,{children:Y(z,{children:[J(z,{color:c===`verbs`?`yellow`:void 0,children:c===`verbs`?`❯ `:` `}),J(z,{bold:!0,color:c===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),c===`verbs`&&J(R,{flexDirection:`column`,children:Y(z,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),J(R,{marginLeft:2,marginBottom:1,children:Y(R,{flexDirection:`column`,children:[(()=>{let{start:e,end:t}=_t(l,n.length,8),r=n.slice(e,t);return Y(q,{children:[e>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,e,` more above`]}),r.map((t,n)=>{let r=e+n;return Y(z,{color:c===`verbs`&&r===l?`cyan`:void 0,children:[c===`verbs`&&r===l?`❯ `:` `,t]},r)}),t<n.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,n.length-t,` more below`]})]})})(),h&&Y(R,{alignItems:`center`,children:[J(z,{color:`yellow`,children:`❯ `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:p})})]}),d&&Y(R,{marginTop:1,alignItems:`center`,children:[J(z,{children:`Editing: `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:p})})]})]})})]}),Y(R,{width:`50%`,flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,children:`Preview`})}),J(R,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:Y(z,{children:[Y(z,{color:S,children:[`✻ `,t.replace(/\{\}/g,n[l]??``),` `]}),J(z,{children:`(esc to interrupt)`})]})})]})]})}const yt=e=>e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z])([A-Z][a-z])/g,`$1 $2`).replace(/(\d+)/g,` $1 `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase()),bt=e=>{let t=Math.max(...e.map(e=>e.length));return e.map(e=>e.padEnd(t))},xt=Object.entries(Ue).map(([e,t])=>({name:yt(e),phases:t.frames.map(e=>e.trimEnd()),reverseMirror:!1,updateInterval:t.interval})),St=[{name:`Default`,phases:M.thinkingStyle.phases,reverseMirror:M.thinkingStyle.reverseMirror},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1},...xt];function Ct({onBack:e}){let{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:r},themes:i},updateSettings:a}=H($),o=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[s,c]=W(0),l=o[s],[u,d]=W(0),[f,p]=W(0),[m,h]=W(!1),[g,_]=W(``),[v,y]=W(!1),[b,x]=W(!1),[S,C]=W(n.toString()),[w,T]=W(0),ee=me(),E=(i.find(e=>e.id===ee)||i.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;U(()=>{if(t.length>0){let e=r?[...t,...[...t].reverse().slice(1,-1)]:t,i=setInterval(()=>{T(t=>(t+1)%e.length)},n);return()=>clearInterval(i)}},[t,n,r]),U(()=>{d(e=>Math.min(e,Math.max(0,t.length-1)))},[t.length]),B((r,i)=>{if(b){if(i.return){let e=parseInt(S);!isNaN(e)&&e>0&&a(t=>{t.thinkingStyle.updateInterval=e}),x(!1)}else i.escape?(C(n.toString()),x(!1)):i.backspace||i.delete?C(e=>e.slice(0,-1)):r&&r.match(/^[0-9]$/)&&C(e=>e+r);return}if(m||v){if(i.return&&g.length){let e=v?[...t,g]:t.map((e,t)=>t===u?g:e);a(t=>{t.thinkingStyle.phases=bt(e)}),h(!1),_(``)}else i.escape?(_(``),h(!1),y(!1)):i.backspace||i.delete?_(e=>e.slice(0,-1)):r&&_(e=>e+r);return}if(i.escape)e();else if(i.return)if(l===`updateInterval`)C(n.toString()),x(!0);else if(l===`presets`){let e=St[f];a(t=>{t.thinkingStyle.phases=bt([...e.phases]),t.thinkingStyle.reverseMirror=e.reverseMirror,e.updateInterval!==void 0&&(t.thinkingStyle.updateInterval=e.updateInterval)})}else l===`reverseMirror`&&a(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(i.tab)i.shift?c(e=>e===0?o.length-1:e-1):c(e=>e===o.length-1?0:e+1);else if(i.upArrow)l===`phases`&&t.length>0?d(e=>e>0?e-1:t.length-1):l===`presets`&&p(e=>e>0?e-1:St.length-1);else if(i.downArrow)l===`phases`&&t.length>0?d(e=>e<t.length-1?e+1:0):l===`presets`&&p(e=>e<St.length-1?e+1:0);else if(r===` `)l===`reverseMirror`&&a(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(r===`e`&&l===`phases`)t.length>0&&(_(t[u]),h(!0));else if(r===`a`&&l===`phases`)y(!0),_(``);else if(r===`d`&&l===`phases`)t.length>1&&a(e=>{e.thinkingStyle.phases=bt(t.filter((e,t)=>t!==u))});else if(r===`w`&&l===`phases`){if(u>0){let e=[...t];[e[u-1],e[u]]=[e[u],e[u-1]],a(t=>{t.thinkingStyle.phases=e}),d(e=>e-1)}}else if(r===`s`&&l===`phases`){if(u<t.length-1){let e=[...t];[e[u],e[u+1]]=[e[u+1],e[u]],a(t=>{t.thinkingStyle.phases=e}),d(e=>e+1)}}else i.ctrl&&r===`r`&&(a(e=>{e.thinkingStyle=M.thinkingStyle}),d(0),p(0))});let D=r?`●`:`○`,O=(()=>r?[...t,...[...t].reverse().slice(1,-1)]:t)(),te=O.length>0?O[w]:`·`;return J(R,{children:Y(R,{flexDirection:`column`,width:`100%`,children:[Y(R,{flexDirection:`row`,width:`100%`,children:[Y(R,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[J(X,{children:`Thinking style`}),Y(R,{flexDirection:`column`,children:[Y(z,{dimColor:!0,children:[`enter to`,` `,l===`updateInterval`?`edit interval`:l===`presets`?`apply preset`:`save`]}),J(z,{dimColor:!0,children:`esc to go back`}),J(z,{dimColor:!0,children:`tab to switch sections`})]})]}),Y(R,{width:`50%`,flexDirection:`column`,children:[J(R,{children:J(z,{bold:!0,children:`Preview`})}),Y(R,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[J(R,{width:(te?.length??0)+1,children:J(z,{color:E,children:te})}),Y(z,{children:[J(z,{color:E,children:`Thinking… `}),J(z,{children:`(esc to interrupt)`})]})]})]})]}),Y(R,{flexDirection:`row`,gap:4,children:[Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(z,{color:l===`reverseMirror`?`yellow`:void 0,children:l===`reverseMirror`?`❯ `:` `}),J(z,{bold:!0,color:l===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),l===`reverseMirror`&&Y(z,{dimColor:!0,children:[` `,`space to toggle`]}),J(R,{marginLeft:2,marginBottom:1,children:Y(z,{children:[D,` `,r?`Enabled`:`Disabled`]})})]}),Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(z,{color:l===`updateInterval`?`yellow`:void 0,children:l===`updateInterval`?`❯ `:` `}),J(z,{bold:!0,color:l===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),l===`updateInterval`&&(b?Y(z,{dimColor:!0,children:[` `,`enter to save`]}):Y(z,{dimColor:!0,children:[` `,`enter to edit`]})),J(R,{marginLeft:2,marginBottom:1,children:J(R,{borderStyle:`round`,borderColor:b?`yellow`:`gray`,children:J(z,{children:b?S:n})})})]})]}),J(R,{children:Y(z,{children:[J(z,{color:l===`phases`?`yellow`:void 0,children:l===`phases`?`❯ `:` `}),J(z,{bold:!0,color:l===`phases`?`yellow`:void 0,children:`Phases`})]})}),l===`phases`&&J(R,{marginBottom:1,flexDirection:`column`,children:Y(z,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),J(R,{marginLeft:2,marginBottom:1,children:Y(R,{flexDirection:`column`,children:[(()=>{let{start:e,end:n}=_t(u,t.length,8),r=t.slice(e,n);return Y(q,{children:[e>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,e,` more above`]}),r.map((t,n)=>{let r=e+n;return Y(z,{color:l===`phases`&&r===u?`cyan`:void 0,children:[l===`phases`&&r===u?`❯ `:` `,t]},r)}),n<t.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,t.length-n,` more below`]})]})})(),v&&Y(R,{children:[J(z,{color:`yellow`,children:`❯ `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:g})})]}),m&&Y(R,{marginTop:1,children:[J(z,{children:`Editing: `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:g})})]})]})}),J(R,{children:Y(z,{children:[J(z,{color:l===`presets`?`yellow`:void 0,children:l===`presets`?`❯ `:` `}),J(z,{bold:!0,color:l===`presets`?`yellow`:void 0,children:`Presets`})]})}),l===`presets`&&Y(z,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases and interval`]}),J(R,{marginLeft:2,marginBottom:1,children:J(R,{flexDirection:`column`,children:(()=>{let{start:e,end:t}=_t(f,St.length,12),n=St.slice(e,t),r=e=>{let t=e.phases.join(``);return t.length>30?t.slice(0,27)+`…`:t};return Y(q,{children:[e>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,e,` more above`]}),n.map((t,n)=>{let i=e+n,a=l===`presets`&&i===f;return Y(z,{color:a?`cyan`:void 0,children:[a?`❯ `:` `,t.name,` `,r(t)]},i)}),t<St.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,St.length-t,` more below`]})]})})()})}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function wt(e,t){let n=Ne(!0);U(()=>{if(n.current){n.current=!1;return}return e()},t)}const Tt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Et=[{label:`none`,value:`none`},{label:`single`,value:`single`},{label:`double`,value:`double`},{label:`round`,value:`round`},{label:`bold`,value:`bold`},{label:`singleDouble`,value:`singleDouble`},{label:`doubleSingle`,value:`doubleSingle`},{label:`classic`,value:`classic`},{label:`topBottomSingle`,value:`topBottomSingle`},{label:`topBottomDouble`,value:`topBottomDouble`},{label:`topBottomBold`,value:`topBottomBold`}];function Dt({onBack:e}){let{settings:t,updateSettings:n}=H($),[r,i]=W(!1),[a,o]=W(!1),[s,c]=W(!1),[l,u]=W(()=>t.userMessageDisplay.format),[d,f]=W(()=>t.userMessageDisplay.paddingX===`default`?`default`:`custom`),[p,m]=W(()=>t.userMessageDisplay.paddingY===`default`?`default`:`custom`),[h,g]=W(()=>t.userMessageDisplay.paddingX===`default`?`0`:String(t.userMessageDisplay.paddingX)),[_,v]=W(()=>t.userMessageDisplay.paddingY===`default`?`0`:String(t.userMessageDisplay.paddingY)),[y,b]=W(t.userMessageDisplay.fitBoxToContent),[x,S]=W(0),[C,w]=W(()=>[...t.userMessageDisplay.styling]),[T,ee]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[E,D]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:t.userMessageDisplay.foregroundColor),[O,te]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[k,ne]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[A,re]=W(()=>Et.findIndex(e=>e.value===t.userMessageDisplay.borderStyle)),[j,ie]=W(()=>t.userMessageDisplay.borderColor),[ae,oe]=W(null),[se,N]=W(``),ce=me(),P=t.themes?.find(e=>e.id===ce)||t.themes?.[0],[F,I]=W(`text`),le=[`format`,`styling`,`foreground`,`background`],ue=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[de,fe]=W(0),[pe,he]=W(0),L=F===`text`?le[de]:ue[pe],ge=()=>{n(e=>{e.userMessageDisplay.format=l,e.userMessageDisplay.styling=[...C],e.userMessageDisplay.foregroundColor=T===`default`?`default`:E,e.userMessageDisplay.backgroundColor=O===`none`?null:O===`default`?`default`:k,e.userMessageDisplay.borderStyle=Et[A].value,e.userMessageDisplay.borderColor=j,e.userMessageDisplay.paddingX=d===`default`?`default`:parseInt(h)||0,e.userMessageDisplay.paddingY=p===`default`?`default`:parseInt(_)||0,e.userMessageDisplay.fitBoxToContent=y})},_e=()=>{u(M.userMessageDisplay.format),w([...M.userMessageDisplay.styling]);let e=M.userMessageDisplay.foregroundColor;ee(e===`default`?`default`:`custom`),D(e===`default`?`rgb(255,255,255)`:e);let t=M.userMessageDisplay.backgroundColor;te(t===null?`none`:t===`default`?`default`:`custom`),ne(t===null||t===`default`?`rgb(0,0,0)`:t),re(Et.findIndex(e=>e.value===M.userMessageDisplay.borderStyle)),ie(M.userMessageDisplay.borderColor);let r=M.userMessageDisplay.paddingX,i=M.userMessageDisplay.paddingY;f(r===`default`?`default`:`custom`),m(i===`default`?`default`:`custom`),g(r===`default`?`0`:String(r)),v(i===`default`?`0`:String(i)),b(M.userMessageDisplay.fitBoxToContent),n(e=>{e.userMessageDisplay={...M.userMessageDisplay}})};wt(()=>{ge()},[l,C,T,E,O,k,A,j,d,p,h,_,y]),B((n,l)=>{if(r){l.return?i(!1):l.escape?(u(t.userMessageDisplay.format),i(!1)):l.backspace||l.delete?u(e=>e.slice(0,-1)):n&&u(e=>e+n);return}if(a){l.return?o(!1):l.escape?(g(String(t.userMessageDisplay.paddingX)),o(!1)):l.backspace||l.delete?g(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&g(e=>e+n);return}if(s){l.return?c(!1):l.escape?(v(String(t.userMessageDisplay.paddingY)),c(!1)):l.backspace||l.delete?v(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&v(e=>e+n);return}if(ae===null){if(l.escape)e();else if(l.ctrl&&n===`r`)_e();else if(l.leftArrow||l.rightArrow)I(e=>e===`text`?`border`:`text`);else if(l.tab)F===`text`?l.shift?fe(e=>e===0?le.length-1:e-1):fe(e=>e===le.length-1?0:e+1):l.shift?he(e=>e===0?ue.length-1:e-1):he(e=>e===ue.length-1?0:e+1);else if(l.return)L===`format`?i(!0):L===`paddingX`?d===`custom`&&o(!0):L===`paddingY`?p===`custom`&&c(!0):L===`foreground`?T===`custom`&&(N(E),oe(`foreground`)):L===`background`?O===`custom`&&(N(k),oe(`background`)):L===`borderColor`&&(N(j),oe(`border`));else if(l.upArrow)L===`styling`?S(e=>Math.max(0,e-1)):L===`borderStyle`?re(e=>e===0?Et.length-1:e-1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?ee(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&te(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!k||k===``)&&ne(`rgb(0,0,0)`),t});else if(l.downArrow)L===`styling`?S(e=>Math.min(Tt.length-1,e+1)):L===`borderStyle`?re(e=>e===Et.length-1?0:e+1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?ee(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&te(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!k||k===``)&&ne(`rgb(0,0,0)`),t});else if(n===` `)if(L===`styling`){let e=Tt[x].value;w(C.indexOf(e)>=0?C.filter(t=>t!==e):[...C,e])}else L===`fitBoxToContent`&&b(e=>!e)}});let ve=e=>{let t=T===`default`?P?.colors?.text:E,n=O===`none`?void 0:O===`default`?P?.colors?.userMessageBackground:k,r=Et[A].value,i=d===`default`?0:parseInt(h)||0,a=p===`default`?0:parseInt(_)||0,o=d===`default`?1:i,s=J(z,{bold:C.includes(`bold`),italic:C.includes(`italic`),underline:C.includes(`underline`),strikethrough:C.includes(`strikethrough`),inverse:C.includes(`inverse`),color:t,backgroundColor:n,children:e});if(r===`topBottomSingle`||r===`topBottomDouble`||r===`topBottomBold`){let t=r===`topBottomSingle`?`─`:r===`topBottomDouble`?`═`:`━`,n=e.length+i*2,o=t.repeat(n);return Y(R,{flexDirection:`column`,children:[J(z,{color:j,children:o}),a>0&&J(R,{height:a}),J(R,{paddingX:i,children:s}),a>0&&J(R,{height:a}),J(z,{color:j,children:o})]})}else if(r!==`none`||i>0||a>0||o>0||y){let e={};i>0&&(e.paddingX=i),d===`default`&&i===0&&(e.paddingRight=o),a>0&&(e.paddingY=a);let t=Object.keys(e).length>0?J(R,{...e,children:s}):s,n={};return r!==`none`&&(n.borderStyle=r,n.borderColor=j),y?n.alignSelf=`flex-start`:n.flexGrow=1,r===`none`?t:J(R,{...n,children:t})}else return s};return ae?J(at,{initialValue:se,theme:P,onColorChange:e=>{ae===`foreground`?D(e):ae===`background`?ne(e):ae===`border`&&ie(e)},onExit:()=>{oe(null),N(``)}}):Y(R,{flexDirection:`column`,children:[J(X,{children:`Customize how user messages are displayed`}),Y(R,{flexDirection:`column`,marginBottom:1,children:[J(z,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),J(z,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),Y(R,{flexDirection:`row`,gap:1,children:[Y(R,{flexDirection:`column`,width:`50%`,borderStyle:F===`text`?`round`:`single`,borderColor:F===`text`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:F===`text`?`yellow`:void 0,children:`Text & Styling`})}),J(R,{children:Y(z,{color:L===`format`?`yellow`:void 0,bold:L===`format`,children:[L===`format`?`❯ `:` `,`Format String`]})}),L===`format`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:r?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),J(R,{marginLeft:2,marginBottom:1,children:J(R,{borderStyle:`round`,borderColor:r?`yellow`:`gray`,children:J(z,{children:l})})}),J(R,{children:Y(z,{color:L===`styling`?`yellow`:void 0,bold:L===`styling`,children:[L===`styling`?`❯ `:` `,`Styling`]})}),L===`styling`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),J(R,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Tt.map((e,t)=>J(R,{children:Y(z,{color:L===`styling`&&x===t?`cyan`:void 0,children:[L===`styling`&&x===t?`❯ `:` `,C.includes(e.value)?`●`:`○`,` `,e.label]})},e.value))}),Y(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(z,{color:L===`foreground`?`yellow`:void 0,bold:L===`foreground`,children:[L===`foreground`?`❯ `:` `,`Foreground`]})}),L===`foreground`&&J(R,{marginLeft:2,children:Y(z,{dimColor:!0,children:[`up/down · `,T===`custom`?`enter`:``]})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[T===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[T===`custom`?`● `:`○ `,`Custom`,T===`custom`&&`: `,T===`custom`&&J(z,{color:E,children:E})]})})]})]}),Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(z,{color:L===`background`?`yellow`:void 0,bold:L===`background`,children:[L===`background`?`❯ `:` `,`Background`]})}),L===`background`&&J(R,{marginLeft:2,children:Y(z,{dimColor:!0,children:[`up/down · `,O===`custom`?`enter`:``]})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[O===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[O===`none`?`● `:`○ `,`None`]})}),J(R,{children:Y(z,{children:[O===`custom`?`● `:`○ `,`Custom`,O===`custom`&&`: `,O===`custom`&&J(z,{backgroundColor:k,children:k})]})})]})]})]})]}),Y(R,{flexDirection:`column`,width:`50%`,borderStyle:F===`border`?`round`:`single`,borderColor:F===`border`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:F===`border`?`yellow`:void 0,children:`Border & Padding`})}),J(R,{children:Y(z,{color:L===`borderStyle`?`yellow`:void 0,bold:L===`borderStyle`,children:[L===`borderStyle`?`❯ `:` `,`Border Style`]})}),L===`borderStyle`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`up/down to navigate`})}),Y(R,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[J(R,{flexDirection:`column`,width:`50%`,children:Et.slice(0,6).map((e,t)=>J(R,{children:Y(z,{color:L===`borderStyle`&&A===t?`cyan`:void 0,children:[L===`borderStyle`&&A===t?`❯ `:` `,A===t?`● `:`○ `,e.label]})},e.value))}),J(R,{flexDirection:`column`,width:`50%`,children:Et.slice(6).map((e,t)=>{let n=t+6;return J(R,{children:Y(z,{color:L===`borderStyle`&&A===n?`cyan`:void 0,children:[L===`borderStyle`&&A===n?`❯ `:` `,A===n?`● `:`○ `,e.label]})},e.value)})})]}),J(R,{children:Y(z,{color:L===`borderColor`?`yellow`:void 0,bold:L===`borderColor`,children:[L===`borderColor`?`❯ `:` `,`Border Color`]})}),L===`borderColor`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`enter to pick color`})}),J(R,{marginLeft:2,marginBottom:1,children:J(z,{color:j,children:j})}),Y(R,{flexDirection:`row`,gap:1,children:[Y(R,{flexDirection:`column`,width:`33%`,children:[J(R,{children:Y(z,{color:L===`paddingX`?`yellow`:void 0,bold:L===`paddingX`,children:[L===`paddingX`?`❯ `:` `,`Padding X`]})}),L===`paddingX`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:a?`enter/esc`:d===`custom`?`up/down · enter`:`up/down`})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[d===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[d===`custom`?`● `:`○ `,`Custom`]})}),d===`custom`&&J(R,{children:J(R,{borderStyle:`round`,borderColor:a?`yellow`:`gray`,children:J(z,{children:h})})})]})]}),Y(R,{flexDirection:`column`,width:`33%`,children:[J(R,{children:Y(z,{color:L===`paddingY`?`yellow`:void 0,bold:L===`paddingY`,children:[L===`paddingY`?`❯ `:` `,`Padding Y`]})}),L===`paddingY`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:s?`enter/esc`:p===`custom`?`up/down · enter`:`up/down`})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[p===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[p===`custom`?`● `:`○ `,`Custom`]})}),p===`custom`&&J(R,{children:J(R,{borderStyle:`round`,borderColor:s?`yellow`:`gray`,children:J(z,{children:_})})})]})]}),Y(R,{flexDirection:`column`,width:`33%`,children:[J(R,{children:Y(z,{color:L===`fitBoxToContent`?`yellow`:void 0,bold:L===`fitBoxToContent`,children:[L===`fitBoxToContent`?`❯ `:` `,y?`●`:`○`,` Fit box to content`]})}),L===`fitBoxToContent`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`space`})})]})]})]})]}),Y(R,{flexDirection:`column`,marginTop:1,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,children:`Preview`})}),Y(R,{flexDirection:`row`,gap:2,children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{marginBottom:1,children:J(z,{underline:!0,children:`Before (Claude Code default):`})}),J(R,{marginLeft:1,children:Y(z,{backgroundColor:P?.colors?.userMessageBackground,color:P?.colors?.text,children:[` `,`> list the dir`,` `]})}),J(R,{marginLeft:1,marginTop:1,children:Y(z,{children:[J(z,{color:P?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:P?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(z,{children:` contains `}),J(z,{bold:!0,children:`123`}),J(z,{children:` files.`})]})})]}),Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{marginBottom:1,children:J(z,{underline:!0,children:`After (Your customization):`})}),J(R,{marginLeft:1,flexDirection:`row`,children:(()=>ve(l.replace(/\{\}/g,`list the dir`)))()}),J(R,{marginLeft:1,marginTop:1,children:Y(z,{children:[J(z,{color:P?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:P?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(z,{children:` contains `}),J(z,{bold:!0,children:`123`}),J(z,{children:` files.`})]})})]})]})]})]})}const Ot=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],kt=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function At({testText:e,regex:t,regexFlags:n,format:r,styling:i,foregroundColor:a,backgroundColor:o}){let s=[];try{let c=n.includes(`g`)?n:n+`g`,l=new RegExp(t,c),u=[...e.matchAll(l)];if(u.length===0)return J(z,{children:e});let d=0;return u.forEach((t,n)=>{let c=t.index,l=c+t[0].length;c>d&&s.push(J(z,{children:e.slice(d,c)},`plain-${n}`));let u=r.replace(/\{MATCH\}/g,t[0]);s.push(J(z,{bold:i.includes(`bold`),italic:i.includes(`italic`),underline:i.includes(`underline`),strikethrough:i.includes(`strikethrough`),inverse:i.includes(`inverse`),color:a,backgroundColor:o,children:u},`match-${n}`)),d=l}),d<e.length&&s.push(J(z,{children:e.slice(d)},`plain-end`)),J(q,{children:s})}catch{return J(z,{children:e})}}function jt({highlighterIndex:e,onBack:t}){let{settings:n,updateSettings:r}=H($),i=n.inputPatternHighlighters[e],a=me(),o=n.themes?.find(e=>e.id===a)||n.themes?.[0],[s,c]=W(i?.name||`New Highlighter`),[l,u]=W(i?.regex||``),[d,f]=W(i?.regexFlags||`g`),[p,m]=W(i?.format||`{MATCH}`),[h,g]=W(i?.styling||[]),[_,v]=W(i?.foregroundColor===null?`none`:`custom`),[y,b]=W(i?.foregroundColor||`rgb(255,0,255)`),[x,S]=W(i?.backgroundColor?`custom`:`none`),[C,w]=W(i?.backgroundColor||`rgb(0,0,0)`),[T,ee]=W(i?.enabled??!0),[E,D]=W(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[O,te]=W(`name`),[k,ne]=W(!1),[A,re]=W(0),[j,ie]=W(null),[ae,oe]=W(``),[se,M]=W(null),[N,ce]=W(0),[P,F]=W(0);if(U(()=>{let e=kt[N];te(e[Math.min(P,e.length-1)])},[N,P]),U(()=>{if(!l){M(null);return}try{new RegExp(l,d),M(null)}catch(e){M(e.message)}},[l,d]),U(()=>{e>=0&&r(t=>{t.inputPatternHighlighters[e]&&(t.inputPatternHighlighters[e]={name:s,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?y:null,backgroundColor:x===`custom`?C:null,enabled:T})})},[e,s,l,d,p,h,_,y,x,C,T]),U(()=>{r(e=>{e.inputPatternHighlightersTestText=E})},[E]),B((e,r)=>{if(k){r.return?ne(!1):r.escape?(O===`name`&&c(i?.name||``),O===`regex`&&u(i?.regex||``),O===`regexFlags`&&f(i?.regexFlags||`g`),O===`format`&&m(i?.format||`{MATCH}`),O===`testText`&&D(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),ne(!1)):r.backspace||r.delete?(O===`name`&&c(e=>e.slice(0,-1)),O===`regex`&&u(e=>e.slice(0,-1)),O===`regexFlags`&&f(e=>e.slice(0,-1)),O===`format`&&m(e=>e.slice(0,-1)),O===`testText`&&D(e=>e.slice(0,-1))):e&&e.length===1&&(O===`name`&&c(t=>t+e),O===`regex`&&u(t=>t+e),O===`regexFlags`&&f(t=>t+e),O===`format`&&m(t=>t+e),O===`testText`&&D(t=>t+e));return}if(j===null){if(r.escape)t();else if(r.upArrow)O===`styling`&&A>0?re(e=>e-1):ce(e=>Math.max(0,e-1));else if(r.downArrow)O===`styling`&&A<Ot.length-1?re(e=>e+1):ce(e=>Math.min(kt.length-1,e+1));else if(r.leftArrow)O===`foreground`?v(e=>e===`none`?`custom`:`none`):O===`background`?S(e=>e===`none`?`custom`:`none`):F(e=>Math.max(0,e-1));else if(r.rightArrow)if(O===`foreground`)v(e=>e===`none`?`custom`:`none`);else if(O===`background`)S(e=>e===`none`?`custom`:`none`);else{let e=kt[N].length-1;F(t=>Math.min(e,t+1))}else if(r.tab){let e=kt.flat(),t=e.indexOf(O);if(r.shift){if(t>0){let n=e[t-1];for(let e=0;e<kt.length;e++){let t=kt[e].indexOf(n);if(t>=0){ce(e),F(t);break}}}}else if(t<e.length-1){let n=e[t+1];for(let e=0;e<kt.length;e++){let t=kt[e].indexOf(n);if(t>=0){ce(e),F(t);break}}}}else if(r.return)O===`name`||O===`regex`||O===`regexFlags`||O===`format`||O===`testText`?ne(!0):O===`foreground`&&_===`custom`?(oe(y),ie(`foreground`)):O===`background`&&x===`custom`&&(oe(C),ie(`background`));else if(e===` `)if(O===`styling`){let e=Ot[A].value;h.includes(e)?g(h.filter(t=>t!==e)):g([...h,e])}else O===`enabled`&&ee(!T)}}),!i)return J(R,{flexDirection:`column`,children:J(z,{color:`red`,children:`Highlighter not found`})});if(j)return J(at,{initialValue:ae,theme:o,onColorChange:e=>{j===`foreground`?b(e):j===`background`&&w(e)},onExit:()=>{ie(null),oe(``)}});let I=e=>O===e,le=e=>({color:I(e)?`yellow`:void 0,bold:I(e)});return Y(R,{flexDirection:`column`,children:[J(X,{children:`Edit Highlighter`}),J(R,{marginBottom:1,flexDirection:`column`,children:J(z,{dimColor:!0,children:`arrows to navigate · enter to edit · space to toggle · esc to go back`})}),Y(R,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`30%`,children:[Y(z,{...le(`name`),children:[I(`name`)?`❯ `:` `,`Name`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`name`)?k?`green`:`yellow`:`gray`,children:J(z,{children:s||`(empty)`})})})]}),Y(R,{flexDirection:`column`,width:`45%`,children:[Y(z,{...le(`regex`),children:[I(`regex`)?`❯ `:` `,`Regex Pattern`]}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{borderStyle:`round`,borderColor:I(`regex`)?k?`green`:`yellow`:se?`red`:`gray`,children:J(z,{children:l||`(empty)`})}),se&&J(z,{color:`red`,children:se})]})]}),Y(R,{flexDirection:`column`,width:`20%`,children:[Y(z,{...le(`regexFlags`),children:[I(`regexFlags`)?`❯ `:` `,`Flags`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`regexFlags`)?k?`green`:`yellow`:`gray`,children:J(z,{children:d||`g`})})})]})]}),Y(R,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`50%`,children:[Y(z,{...le(`format`),children:[I(`format`)?`❯ `:` `,`Format String`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`format`)?k?`green`:`yellow`:`gray`,children:J(z,{children:p||`{MATCH}`})})}),I(`format`)&&J(R,{marginLeft:2,children:Y(z,{dimColor:!0,children:[`use `,`{MATCH}`,` as placeholder`]})})]}),Y(R,{flexDirection:`column`,width:`45%`,children:[Y(z,{...le(`styling`),children:[I(`styling`)?`❯ `:` `,`Styling`]}),J(R,{marginLeft:2,flexDirection:`column`,children:Ot.map((e,t)=>{let n=h.includes(e.value),r=I(`styling`)&&A===t;return Y(z,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,n?`●`:`○`,` `,e.label]},e.value)})})]})]}),Y(R,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`48%`,children:[Y(z,{...le(`foreground`),children:[I(`foreground`)?`❯ `:` `,`Foreground Color`]}),Y(R,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(z,{color:I(`foreground`)?`yellow`:void 0,children:[`[`,_===`none`?`●`:`○`,`] none`,` `,`[`,_===`custom`?`●`:`○`,`] custom`]}),_===`custom`&&J(R,{borderStyle:`round`,borderColor:I(`foreground`)?`yellow`:`gray`,children:J(z,{color:y,children:` ████ `})})]})]}),Y(R,{flexDirection:`column`,width:`48%`,children:[Y(z,{...le(`background`),children:[I(`background`)?`❯ `:` `,`Background Color`]}),Y(R,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(z,{color:I(`background`)?`yellow`:void 0,children:[`[`,x===`none`?`●`:`○`,`] none`,` `,`[`,x===`custom`?`●`:`○`,`] custom`]}),x===`custom`&&J(R,{borderStyle:`round`,borderColor:I(`background`)?`yellow`:`gray`,children:Y(z,{backgroundColor:C,children:[` `,` `,` `]})})]})]})]}),J(R,{marginBottom:1,children:Y(z,{...le(`enabled`),children:[I(`enabled`)?`❯ `:` `,`Enabled:`,` `,J(z,{color:T?`green`:`red`,children:T?`● Yes`:`○ No`})]})}),Y(R,{flexDirection:`column`,marginBottom:1,children:[Y(z,{...le(`testText`),children:[I(`testText`)?`❯ `:` `,`Test Text`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`testText`)?k?`green`:`yellow`:`gray`,children:J(z,{children:E||`(empty)`})})})]}),J(R,{borderStyle:`round`,padding:1,children:Y(R,{flexDirection:`column`,children:[J(z,{bold:!0,children:`Live Preview:`}),l?J(R,{marginTop:1,children:J(At,{testText:E,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?y:void 0,backgroundColor:x===`custom`?C:void 0})}):J(z,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function Mt({onBack:e}){let{settings:{inputPatternHighlighters:t,themes:n},updateSettings:r}=H($),i=me(),a=n.find(e=>e.id===i)||n[0],o=M.themes[0],s=a?.colors.success||o.colors.success,c=a?.colors.error||o.colors.error,[l,u]=W(0),[d,f]=W(null),[p,m]=W(!0),h=()=>{let e={name:`New Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:`rgb(255,0,255)`,backgroundColor:null,enabled:!0};r(t=>{t.inputPatternHighlighters.push(e)}),f(t.length),m(!1)},g=e=>{r(t=>{t.inputPatternHighlighters.splice(e,1)}),l>=t.length-1&&u(Math.max(0,t.length-2))},_=e=>{r(t=>{t.inputPatternHighlighters[e].enabled=!t.inputPatternHighlighters[e].enabled})},v=e=>{e<=0||(r(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e-1,0,n)}),u(e-1))},y=e=>{e>=t.length-1||(r(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e+1,0,n)}),u(e+1))};return B((n,r)=>{r.escape?e():r.upArrow?u(e=>Math.max(0,e-1)):r.downArrow&&t.length>0?u(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(f(l),m(!1)):n===`n`?h():n===`x`&&t.length>0?g(l):n===` `&&t.length>0?_(l):n===`u`&&t.length>0&&l>0?v(l):n===`d`&&t.length>0&&l<t.length-1&&y(l)},{isActive:p}),d===null?Y(R,{flexDirection:`column`,children:[J(X,{children:`Input Pattern Highlighters`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Create custom highlighters for patterns in your input prompt.`}),J(z,{dimColor:!0,children:`Matched text will be styled and optionally reformatted.`})]}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new highlighter`}),t.length>0&&J(z,{dimColor:!0,children:`space to toggle enabled/disabled`}),t.length>0&&J(z,{dimColor:!0,children:`u/d to move highlighter up/down`}),t.length>0&&J(z,{dimColor:!0,children:`x to delete a highlighter`}),t.length>0&&J(z,{dimColor:!0,children:`enter to edit highlighter`}),J(z,{dimColor:!0,children:`esc to go back`})]}),t.length===0?J(z,{children:`No highlighters created yet. Press n to create one.`}):J(R,{flexDirection:`column`,children:t.map((e,t)=>{let n=l===t,r;return n&&(r=`yellow`),Y(R,{flexDirection:`row`,children:[Y(z,{color:r,children:[n?`❯ `:` `,e.enabled?`● `:`○ `,e.name,` `]}),J(z,{dimColor:!0,children:`(`}),e.regex?Y(z,{dimColor:!0,children:[`/`,e.regex,`/`,e.regexFlags]}):J(z,{dimColor:!0,children:`(no regex)`}),e.styling.length>0&&J(q,{children:Y(z,{color:r,dimColor:!e.enabled,children:[` `,`· `,e.styling.join(`, `)]})}),J(z,{dimColor:!0,children:`)`}),e.enabled?J(z,{color:s,children:` enabled`}):J(z,{color:c,children:` disabled`})]},t)})})]}):J(jt,{highlighterIndex:d,onBack:()=>{f(null),m(!0)}})}const Nt=[null,1,5,10,25,50,100,200,250,500,1e3],Pt=1e3;function Ft({onSubmit:e}){let{settings:t,updateSettings:n}=H($),[r,i]=W(0),[a,o]=W(!1),s={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSessionMemory:!0,enableDreamMode:!0,enableLeanMemoryTypes:!1,fixSummarizeFromHere:!0,fixRewindSummaryHeader:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,swapRipgrepForFff:!1,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autonomousOperationAllModels:!1,adhdOutputStyle:!1,autoModeClassifierModel:`default`,suppressDeferredTools:!1,claudemdContextOncePerConversation:!0},c=()=>{t.misc||={...s}},l=e=>{let t=[`default`,`sonnet`,`haiku`];return t[(t.indexOf(e)+1)%t.length]},u=e=>{switch(e){case`sonnet`:return`Sonnet 4.6`;case`haiku`:return`Haiku 4.5`;case`default`:default:return`Default (main-loop model)`}},d=e=>{let t=[`default`,`ascii`,`clean`,`clean-top-bottom`];return t[(t.indexOf(e)+1)%t.length]},f=e=>{switch(e){case`ascii`:return`ASCII (| and -)`;case`clean`:return`Clean (no row separators)`;case`clean-top-bottom`:return`Clean with top/bottom`;case`default`:default:return`Default (box-drawing)`}},p=e=>e===null?`Default (3)`:e<=3?`${e} (conservative)`:e<=8?`${e} (recommended)`:`${e} (aggressive)`,m=e=>e===null?`Disabled`:e===0?`0ms (instant)`:`${e}ms`,h=e=>e===null?`Off (exact counts)`:`Round to ${e}`,g=(e,t)=>{let n=Nt.indexOf(e);if(n===-1)return Nt[0];let r;return r=t===`next`?(n+1)%Nt.length:(n-1+Nt.length)%Nt.length,Nt[r]},_=Me(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>t.inputBox?.removeBorder??!1,toggle:()=>{n(e=>{e.inputBox||={removeBorder:!1},e.inputBox.removeBorder=!e.inputBox.removeBorder})}},{id:`showVersion`,title:`Show tweakcc version at startup`,description:`Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.`,getValue:()=>t.misc?.showTweakccVersion??!0,toggle:()=>{n(e=>{c(),e.misc.showTweakccVersion=!e.misc.showTweakccVersion})}},{id:`showPatches`,title:`Show patches applied indicator at startup`,description:`Shows the green "tweakcc patches are applied" indicator when starting Claude Code.`,getValue:()=>t.misc?.showPatchesApplied??!0,toggle:()=>{n(e=>{c(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>t.misc?.expandThinkingBlocks??!0,toggle:()=>{n(e=>{c(),e.misc.expandThinkingBlocks=!e.misc.expandThinkingBlocks})}},{id:`conversationTitle`,title:`Allow renaming sessions via /title`,description:`Enables /title and /rename commands for manually naming conversations.`,getValue:()=>t.misc?.enableConversationTitle??!0,toggle:()=>{n(e=>{c(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`enableModelCustomizations`,title:`Enable model customizations (/model shows all models)`,description:`Show all Claude models in /model menu, not just the latest 3. Disable to use Claude Code default model list.`,getValue:()=>t.misc?.enableModelCustomizations??!0,toggle:()=>{n(e=>{c(),e.misc.enableModelCustomizations=!e.misc.enableModelCustomizations})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>t.misc?.hideStartupBanner??!1,toggle:()=>{n(e=>{c(),e.misc.hideStartupBanner=!e.misc.hideStartupBanner})}},{id:`hideCtrlG`,title:`Hide ctrl-g to edit prompt hint`,description:`Hides the "ctrl-g to edit prompt" hint shown during streaming.`,getValue:()=>t.misc?.hideCtrlGToEdit??!1,toggle:()=>{n(e=>{c(),e.misc.hideCtrlGToEdit=!e.misc.hideCtrlGToEdit})}},{id:`hideClawd`,title:`Hide startup Clawd ASCII art`,description:`Hides the Clawd ASCII art character shown at startup.`,getValue:()=>t.misc?.hideStartupClawd??!1,toggle:()=>{n(e=>{c(),e.misc.hideStartupClawd=!e.misc.hideStartupClawd})}},{id:`increaseFileReadLimit`,title:`Increase file read token limit`,description:`Increases the maximum file read limit from 25,000 to 1,000,000 tokens.`,getValue:()=>t.misc?.increaseFileReadLimit??!1,toggle:()=>{n(e=>{c(),e.misc.increaseFileReadLimit=!e.misc.increaseFileReadLimit})}},{id:`suppressLineNumbers`,title:`Suppress line numbers in file reads/edits`,description:`Removes line number prefixes from file content to reduce token usage.`,getValue:()=>t.misc?.suppressLineNumbers??!1,toggle:()=>{n(e=>{c(),e.misc.suppressLineNumbers=!e.misc.suppressLineNumbers})}},{id:`suppressRateLimitOptions`,title:`Suppress rate limit options popup`,description:`Prevents the automatic /rate-limit-options command from being triggered when hitting rate limits.`,getValue:()=>t.misc?.suppressRateLimitOptions??!1,toggle:()=>{n(e=>{c(),e.misc.suppressRateLimitOptions=!e.misc.suppressRateLimitOptions})}},{id:`mcpNonBlocking`,title:`Non-blocking MCP startup`,description:`Start immediately while MCP servers connect in background. Reduces startup time ~50% with multiple MCPs.`,getValue:()=>t.misc?.mcpConnectionNonBlocking??!0,toggle:()=>{n(e=>{c(),e.misc.mcpConnectionNonBlocking=!e.misc.mcpConnectionNonBlocking})}},{id:`mcpBatchSize`,title:`MCP server batch size`,description:`Parallel MCP connections (1-20). Use ←/→ to adjust. Higher = faster startup, more resources.`,getValue:()=>t.misc?.mcpServerBatchSize??null,getDisplayValue:()=>p(t.misc?.mcpServerBatchSize??null),toggle:()=>{n(e=>{c(),e.misc.mcpServerBatchSize=null})},increment:()=>{n(e=>{c();let t=e.misc.mcpServerBatchSize??3;e.misc.mcpServerBatchSize=Math.min(20,t+1)})},decrement:()=>{n(e=>{c();let t=(e.misc.mcpServerBatchSize??3)-1;e.misc.mcpServerBatchSize=t<1?null:t})}},{id:`tableFormat`,title:`Table output format`,description:`Controls how Claude formats tables. Default: full borders. ASCII: | and -. Clean: no top/bottom/row separators. Clean+top/bottom: borders but no row separators.`,getValue:()=>t.misc?.tableFormat??`default`,isMultiValue:!0,getDisplayValue:()=>f(t.misc?.tableFormat??`default`),toggle:()=>{n(e=>{c(),e.misc.tableFormat=d(e.misc.tableFormat??`default`)})}},{id:`enableWorktreeMode`,title:`Enable worktree mode (EnterWorktree tool)`,description:`Force-enable the EnterWorktree tool for isolated git worktree sessions by bypassing the tengu_worktree_mode feature flag.`,getValue:()=>t.misc?.enableWorktreeMode??!0,toggle:()=>{n(e=>{c(),e.misc.enableWorktreeMode=!e.misc.enableWorktreeMode})}},{id:`swapRipgrepForFff`,title:`[EXPERIMENTAL] fff for Bash search (grep/find/rg -> fff)`,description:`Route Claude Code's Bash search through fff. CC shadows the shell grep->embedded ugrep and find->embedded bfs (and offers rg); the agent uses grep far more than rg. This repoints all three at a per-platform fff wrapper that serves (relevance-ranked, warm-index daemon): literal, regex (RE2, the dialect the model writes), -i, multi-word phrases, context (-A/-B/-C), extension globs (-g/--include '*.ts'), and multi-path (app lib scripts). Anything fff can't serve faithfully (PCRE, multiline/newline/empty regex, -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 intent. Transparent (no prompt-compliance reliance), CC-scoped (your own terminal grep/find/rg are untouched). Installs the wrapper into ~/.tweakcc/fff.`,getValue:()=>t.misc?.swapRipgrepForFff??!1,toggle:()=>{n(e=>{c(),e.misc.swapRipgrepForFff=!e.misc.swapRipgrepForFff})}},{id:`enableVoiceMode`,title:`Enable voice mode (/voice command)`,description:`Force-enable the /voice command by bypassing the tengu_amber_quartz feature gate.`,getValue:()=>t.misc?.enableVoiceMode??!1,toggle:()=>{n(e=>{c(),e.misc.enableVoiceMode=!e.misc.enableVoiceMode})}},{id:`enableVoiceConciseOutput`,title:`Enable concise output for voice mode`,description:`Enable the concise-output prompt used for voice interactions. Only applies when voice mode is enabled.`,getValue:()=>t.misc?.enableVoiceConciseOutput??!0,toggle:()=>{n(e=>{c(),e.misc.enableVoiceConciseOutput=!e.misc.enableVoiceConciseOutput})}},{id:`enableChannelsMode`,title:`Enable channels mode (MCP channel notifications)`,description:`Force-enable MCP channel notifications by bypassing the tengu_harbor feature gate, allowlist, and permission relay.`,getValue:()=>t.misc?.enableChannelsMode??!1,toggle:()=>{n(e=>{c(),e.misc.enableChannelsMode=!e.misc.enableChannelsMode})}},{id:`enableContextLimitOverride`,title:`Override context limit`,description:`Replaces the default model context limit with CLAUDE_CODE_CONTEXT_LIMIT env var. Must be exported manually before launching CC, or falls back to 200K.`,getValue:()=>t.misc?.enableContextLimitOverride??!1,toggle:()=>{n(e=>{c(),e.misc.enableContextLimitOverride=!e.misc.enableContextLimitOverride})}},{id:`statuslineThrottle`,title:`Statusline throttle`,description:`Throttle statusline updates (0-${Pt}ms). Use ←/→ to adjust by 50ms. Space to disable. 0 = instant updates.`,getValue:()=>t.misc?.statuslineThrottleMs??null,getDisplayValue:()=>m(t.misc?.statuslineThrottleMs??null),toggle:()=>{n(e=>{c(),e.misc.statuslineThrottleMs=e.misc.statuslineThrottleMs===null?300:null})},increment:()=>{n(e=>{c();let t=e.misc.statuslineThrottleMs??300;e.misc.statuslineThrottleMs=Math.min(Pt,t+50)})},decrement:()=>{n(e=>{c();let t=e.misc.statuslineThrottleMs??300;e.misc.statuslineThrottleMs=Math.max(0,t-50)})}},{id:`statuslineFixedInterval`,title:`Statusline fixed interval mode`,description:`Use setInterval instead of throttle. Updates happen on a fixed schedule rather than on-demand.`,getValue:()=>t.misc?.statuslineUseFixedInterval??!1,toggle:()=>{n(e=>{c(),e.misc.statuslineUseFixedInterval=!e.misc.statuslineUseFixedInterval})}},{id:`enableSessionMemory`,title:`Enable session memory`,description:`Force-enable session memory (auto-extraction + past session search) by bypassing the tengu_session_memory and tengu_coral_fern statsig flags.`,getValue:()=>t.misc?.enableSessionMemory??!0,toggle:()=>{n(e=>{c(),e.misc.enableSessionMemory=!e.misc.enableSessionMemory})}},{id:`enableDreamMode`,title:`Enable dream mode`,description:`Force-enable dream (/dream + auto-dream background memory consolidation) by bypassing the tengu_onyx_plover statsig gate. On/off still follows autoDreamEnabled in ~/.claude/settings.json.`,getValue:()=>t.misc?.enableDreamMode??!0,toggle:()=>{n(e=>{c(),e.misc.enableDreamMode=!e.misc.enableDreamMode})}},{id:`fixSummarizeFromHere`,title:`Fix "Summarize from here"`,description:`Make "Summarize from here" summarize only the messages after the rewind point instead of the whole conversation.`,getValue:()=>t.misc?.fixSummarizeFromHere??!0,toggle:()=>{n(e=>{c(),e.misc.fixSummarizeFromHere=!(e.misc.fixSummarizeFromHere??!0)})}},{id:`fixRewindSummaryHeader`,title:`Honest rewind summary header`,description:`Label a rewind summary as a deliberate rewind (you continued forward, then rewound and chose to carry the summary forward) instead of the misleading "ran out of context" header.`,getValue:()=>t.misc?.fixRewindSummaryHeader??!0,toggle:()=>{n(e=>{c(),e.misc.fixRewindSummaryHeader=!(e.misc.fixRewindSummaryHeader??!0)})}},{id:`enableLeanMemoryTypes`,title:`Enable lean memory types`,description:`Force the tengu_ochre_finch statsig gate: memory prompts carry a compact "Types of memory" list and the full taxonomy moves to the on-demand memory-types skill.`,getValue:()=>t.misc?.enableLeanMemoryTypes??!1,toggle:()=>{n(e=>{c(),e.misc.enableLeanMemoryTypes=!e.misc.enableLeanMemoryTypes})}},{id:`enableRememberSkill`,title:`Enable remember skill`,description:`Register a "remember" skill to review session memories and update CLAUDE.local.md with learnings from past sessions.`,getValue:()=>t.misc?.enableRememberSkill??!1,toggle:()=>{n(e=>{c(),e.misc.enableRememberSkill=!e.misc.enableRememberSkill})}},{id:`tokenCountRounding`,title:`Token count rounding`,description:`Round displayed token counts to nearest multiple. Use ←/→ to cycle: Off, 1, 5, 10, 25, 50, 100, 200, 250, 500, 1000.`,getValue:()=>t.misc?.tokenCountRounding??null,getDisplayValue:()=>h(t.misc?.tokenCountRounding??null),toggle:()=>{n(e=>{c(),e.misc.tokenCountRounding=null})},increment:()=>{n(e=>{c(),e.misc.tokenCountRounding=g(e.misc.tokenCountRounding??null,`next`)})},decrement:()=>{n(e=>{c(),e.misc.tokenCountRounding=g(e.misc.tokenCountRounding??null,`prev`)})}},{id:`autoAcceptPlanMode`,title:`Auto-accept plan mode`,description:`Automatically accept plans without the "Ready to code?" confirmation prompt.`,getValue:()=>t.misc?.autoAcceptPlanMode??!1,toggle:()=>{n(e=>{c(),e.misc.autoAcceptPlanMode=!e.misc.autoAcceptPlanMode})}},{id:`allowBypassPermissionsInSudo`,title:`Allow bypassing permissions in sudo`,description:`⚠️ WARNING: Disables a security check. When enabled, Claude can perform system-level operations without prompts. Use extreme caution.`,getValue:()=>t.misc?.allowBypassPermissionsInSudo??!1,toggle:()=>{t.misc?.allowBypassPermissionsInSudo??!1?n(e=>{c(),e.misc.allowBypassPermissionsInSudo=!1}):o(!0)}},{id:`suppressNativeInstallerWarning`,title:`Suppress native installer warning`,description:`Suppress the native installer warning message at startup.`,getValue:()=>t.misc?.suppressNativeInstallerWarning??!1,toggle:()=>{n(e=>{c(),e.misc.suppressNativeInstallerWarning=!e.misc.suppressNativeInstallerWarning})}},{id:`filterScrollEscapeSequences`,title:`Filter scroll escape sequences`,description:`Filter out terminal escape sequences that cause unwanted scrolling.`,getValue:()=>t.misc?.filterScrollEscapeSequences??!1,toggle:()=>{n(e=>{c(),e.misc.filterScrollEscapeSequences=!e.misc.filterScrollEscapeSequences})}},{id:`allowCustomAgentModels`,title:`Allow custom agent models`,description:`Allow arbitrary model names in custom agent frontmatter (e.g. gemini-2.5-flash). Useful with a local proxy for non-Claude models.`,getValue:()=>t.misc?.allowCustomAgentModels??!1,toggle:()=>{n(e=>{c(),e.misc.allowCustomAgentModels=!e.misc.allowCustomAgentModels})}},{id:`maxEffortDefault`,title:`Default Opus 4.7 to max effort`,description:`Patches CC so Opus 4.7 sessions default to "max" reasoning effort instead of "xhigh". /effort and CLAUDE_CODE_EFFORT_LEVEL still override at runtime.`,getValue:()=>t.misc?.maxEffortDefault??!1,toggle:()=>{n(e=>{c(),e.misc.maxEffortDefault=!e.misc.maxEffortDefault})}},{id:`autonomousOperationAllModels`,title:`Fable/Mythos prompt set (all models)`,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 your turn"); the "# Communicating with the user" comms block in place of "# Text output"; /loop dynamic-pacing turn behavior; and brief-mode comms shaping. Per-model feature-flag routing follows fable too, but is inert on a local install (those flags default off without a live gate service).`,getValue:()=>t.misc?.autonomousOperationAllModels??!1,toggle:()=>{n(e=>{c(),e.misc.autonomousOperationAllModels=!e.misc.autonomousOperationAllModels})}},{id:`adhdOutputStyle`,title:`ADHD-friendly output style`,description:`Rewrites the always-on "# Communicating with the user" prompt for skim-first reading: answer in the first line, bold the key terms, three-sentence blocks, and a soft "usually under 120 words" anchor (soft, not a hard cap: Anthropic measured a 3% eval drop from hard caps and reverted them). Removes the three clauses that drive Claude-speak: the "load-bearing" update cue, the "readable matters more" ranking, and the "in prose, not headers and sections" rule. Also restates the shape rule in the per-turn CLAUDE.md reminder, where recency makes it stick, and drops that reminder's "may or may not be relevant" hedge.`,getValue:()=>t.misc?.adhdOutputStyle??!1,toggle:()=>{n(e=>{c(),e.misc.adhdOutputStyle=!e.misc.adhdOutputStyle})}},{id:`autoModeClassifierModel`,title:`Auto-mode classifier model`,description:`Pin auto-mode bash safety classifier to a fixed model. Default routes to your main-loop model (e.g. Opus 4.7), which gets denied as "temporarily unavailable" when that model is congested. Sonnet/Haiku have more headroom and the binary XML classifier task fits either.`,getValue:()=>t.misc?.autoModeClassifierModel??`default`,getDisplayValue:()=>u(t.misc?.autoModeClassifierModel??`default`),toggle:()=>{n(e=>{c(),e.misc.autoModeClassifierModel=l(e.misc.autoModeClassifierModel??`default`)})}}],[t,n]),v=_.length,y=v-1,b=Me(()=>r<4?0:Math.min(r-4+1,v-4),[r,v]),x=_.slice(b,b+4),S=b>0,C=b+4<v;return B((t,s)=>{a?s.return?(n(e=>{c(),e.misc.allowBypassPermissionsInSudo=!0}),o(!1)):s.escape&&o(!1):s.return||s.escape?e():s.upArrow?i(e=>Math.max(0,e-1)):s.downArrow?i(e=>Math.min(y,e+1)):t===` `?_[r]?.toggle():s.rightArrow?_[r]?.increment?.():s.leftArrow&&_[r]?.decrement?.()}),J(R,{flexDirection:`column`,children:a?J(R,{flexDirection:`column`,paddingX:2,children:Y(R,{borderStyle:`double`,borderColor:`yellow`,padding:2,flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:`yellow`,children:`SECURITY WARNING`})}),J(R,{marginBottom:1,children:J(z,{children:`You are about to enable a feature that allows Claude Code to bypass permission checks when running with sudo privileges.`})}),J(R,{marginBottom:1,children:J(z,{color:`red`,children:`This means Claude can perform system-level operations without any prompts or confirmation.`})}),J(R,{marginBottom:1,children:J(z,{bold:!0,children:`Use with extreme caution.`})}),J(R,{children:Y(z,{children:[`Press `,J(z,{color:`red`,children:`Enter`}),` to enable,`,` `,J(z,{color:`green`,children:`Escape`}),` to cancel`]})})]})}):Y(q,{children:[J(R,{marginBottom:1,children:J(X,{children:`Miscellaneous Settings`})}),J(R,{marginBottom:1,children:J(z,{dimColor:!0,children:`Use ↑/↓ to navigate, space to toggle, ←/→ to adjust numbers, enter to go back.`})}),S&&J(R,{children:Y(z,{dimColor:!0,children:[` ↑ `,b,` more above`]})}),x.map((e,t)=>{let n=b+t===r,i=e.getValue(),a=!!e.getDisplayValue,o=!!e.increment,s;s=o?`◆`:a?`◉`:i?`☑`:`☐`;let c;c=a?e.getDisplayValue():typeof i==`boolean`?i?`Enabled`:`Disabled`:String(i??`Default`);let l=n&&o?` ← → `:``;return Y(R,{flexDirection:`column`,children:[J(R,{children:Y(z,{children:[J(z,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),J(z,{bold:!0,color:n?`cyan`:void 0,children:e.title})]})}),J(R,{children:Y(z,{dimColor:!0,children:[` `,e.description]})}),J(R,{marginLeft:4,marginBottom:1,children:Y(z,{children:[s,` `,c,J(z,{dimColor:!0,children:l})]})})]},e.id)}),C&&J(R,{children:Y(z,{dimColor:!0,children:[` `,`↓ `,v-b-4,` more below`]})}),J(R,{marginTop:1,children:Y(z,{dimColor:!0,children:[`Item `,r+1,` of `,v]})})]})})}const It=`AgentOutputTool.AskUserQuestion.Bash.BashOutputTool.Edit.EnterPlanMode.ExitPlanMode.Glob.Grep.KillShell.ListMcpResourcesTool.LSP.NotebookEdit.Read.ReadMcpResourceTool.Skill.Task.TaskCreate.TaskGet.TaskList.TaskOutput.TaskStop.TaskUpdate.Teammate.TodoWrite.ToolSearch.WebFetch.WebSearch.Write`.split(`.`);function Lt({toolsetIndex:e,onBack:t}){let{settings:n,updateSettings:r}=H($),i=n.toolsets[e],[a,o]=W(i?.name||`New Toolset`),[s,c]=W(i?.allowedTools||[]),[l,u]=W(!1),[d,f]=W(0);U(()=>{i&&r(t=>{let n=t.toolsets[e].name;t.toolsets[e].name=a,t.toolsets[e].allowedTools=s,n!==a&&(t.defaultToolset===n&&(t.defaultToolset=a),t.planModeToolset===n&&(t.planModeToolset=a))})},[a,s]);let p=e=>s===`*`?!0:s.includes(e),m=e=>{e===`All`?c(`*`):e===`None`?c([]):s===`*`?c(It.filter(t=>t!==e)):s.includes(e)?c(s.filter(t=>t!==e)):c([...s,e])};if(B((e,n)=>{if(l){n.return?(a.trim()||o(i?.name||`New Toolset`),u(!1)):n.escape?(o(i?.name||`New Toolset`),u(!1)):n.backspace||n.delete?o(e=>e.slice(0,-1)):e&&e.length===1&&o(t=>t+e);return}if(n.escape)t();else if(n.upArrow)f(e=>Math.max(0,e-1));else if(n.downArrow)f(e=>Math.min(It.length+1,e+1));else if(e===` `||n.return)if(d===0)m(`All`);else if(d===1)m(`None`);else{let e=It[d-2];e&&m(e)}else e===`n`&&u(!0)}),!i)return J(R,{flexDirection:`column`,children:J(z,{color:`red`,children:`Toolset not found`})});let h=s===`*`,g=Array.isArray(s)&&s.length===0;return Y(R,{flexDirection:`column`,children:[J(X,{children:`Edit Toolset`}),J(R,{marginBottom:1,flexDirection:`column`,children:J(z,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{bold:!0,children:`Name:`}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:l?`yellow`:`gray`,children:J(z,{children:a})})}),l&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{bold:!0,children:`Allowed Tools:`}),J(R,{marginLeft:2,children:Y(z,{color:d===0?`cyan`:void 0,children:[d===0?`❯ `:` `,h?`●`:`○`,` All`]})}),J(R,{marginLeft:2,children:Y(z,{color:d===1?`cyan`:void 0,children:[d===1?`❯ `:` `,g?`●`:`○`,` None`]})}),It.map((e,t)=>{let n=t+2;return J(R,{marginLeft:2,children:Y(z,{color:d===n?`cyan`:void 0,children:[d===n?`❯ `:` `,p(e)?`◉`:`○`,` `,e]})},e)})]}),J(R,{borderStyle:`round`,padding:1,marginTop:1,children:Y(R,{flexDirection:`column`,children:[J(z,{bold:!0,children:`Summary:`}),Y(z,{children:[`Name: `,J(z,{color:`cyan`,children:a})]}),Y(z,{children:[`Tools:`,` `,s===`*`?J(z,{color:`green`,children:`All tools (*)`}):s.length===0?J(z,{color:`red`,children:`No tools ([])`}):Y(z,{color:`yellow`,children:[s.length,` selected`]})]})]})})]})}function Rt({onBack:e}){let{settings:{toolsets:t,defaultToolset:n,planModeToolset:r,themes:i},updateSettings:a}=H($),o=me(),s=i.find(e=>e.id===o)||i[0],c=M.themes[0],l=s?.colors.planMode||c.colors.planMode,u=s?.colors.autoAccept||c.colors.autoAccept,[d,f]=W(0),[p,m]=W(null),[h,g]=W(!0),_=()=>{let e={name:`New Toolset`,allowedTools:[]};a(t=>{t.toolsets.push(e)}),m(t.length),g(!1)},v=e=>{let n=t[e];a(t=>{t.toolsets.splice(e,1),t.defaultToolset===n.name&&(t.defaultToolset=null),t.planModeToolset===n.name&&(t.planModeToolset=null)}),d>=t.length-1&&f(Math.max(0,t.length-2))},y=e=>{let n=t[e];a(e=>{e.defaultToolset=n.name})},b=e=>{let n=t[e];a(e=>{e.planModeToolset=n.name})};if(B((n,r)=>{r.escape?e():r.upArrow?f(e=>Math.max(0,e-1)):r.downArrow?f(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(m(d),g(!1)):n===`n`?_():n===`x`&&t.length>0?v(d):n===`d`&&t.length>0?y(d):n===`p`&&t.length>0&&b(d)},{isActive:h}),p!==null)return J(Lt,{toolsetIndex:p,onBack:()=>{m(null),g(!0)}});let x=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return Y(R,{flexDirection:`column`,children:[J(X,{children:`Toolsets`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new toolset`}),t.length>0&&J(z,{dimColor:!0,children:`d to set as default toolset`}),t.length>0&&J(z,{dimColor:!0,children:`p to set as plan mode toolset`}),t.length>0&&J(z,{dimColor:!0,children:`x to delete a toolset`}),t.length>0&&J(z,{dimColor:!0,children:`enter to edit toolset`}),J(z,{dimColor:!0,children:`esc to go back`})]}),t.length===0?J(z,{children:`No toolsets created yet. Press n to create one.`}):J(R,{flexDirection:`column`,children:t.map((e,t)=>{let i=e.name===n,a=e.name===r,o=d===t,s;return o&&(s=`yellow`),Y(R,{flexDirection:`row`,children:[Y(z,{color:s,children:[o?`❯ `:` `,e.name,` `]}),Y(z,{color:s,children:[`(`,x(e),`)`]}),i&&J(z,{color:u,children:` ⏵⏵ accept edits`}),a&&J(z,{color:l,children:` ⏸ plan mode`})]},t)})})]})}function zt({onBack:e}){let{settings:t,updateSettings:n}=H($),[r,i]=W(`plan`),[a,o]=W(!1),[s,c]=W(0),l=t.subagentModels||{plan:null,explore:null,generalPurpose:null},u=[{id:`plan`,title:`Plan Agent`,description:`The agent responsible for creating implementation plans.`},{id:`explore`,title:`Explore Agent`,description:`The agent specialized for exploring codebases.`},{id:`generalPurpose`,title:`General-purpose Agent`,description:`The agent used for general multi-step tasks.`}],d=[{label:`Default (Inherited)`,value:null},{label:`sonnet`,value:`sonnet`},{label:`haiku`,value:`haiku`},{label:`opus`,value:`opus`},{label:`sonnet[1m]`,value:`sonnet[1m]`}];return B((t,f)=>{if(a){if(f.escape)o(!1);else if(f.upArrow)c(e=>e>0?e-1:d.length-1);else if(f.downArrow)c(e=>e<d.length-1?e+1:0);else if(f.return){let e=d[s].value;n(t=>{t.subagentModels||={plan:null,explore:null,generalPurpose:null},t.subagentModels[r]=e}),o(!1)}}else if(f.escape)e();else if(f.upArrow){let e=u.findIndex(e=>e.id===r);i(u[e>0?e-1:u.length-1].id)}else if(f.downArrow){let e=u.findIndex(e=>e.id===r);i(u[e<u.length-1?e+1:0].id)}else if(t===` `||f.return){let e=l[r],t=d.findIndex(t=>t.value===e);c(t>=0?t:0),o(!0)}}),a?Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:Y(X,{children:[`Select Model for`,` `,u.find(e=>e.id===r)?.title]})}),d.map((e,t)=>{let n=t===s;return J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.label,e.value?Y(z,{dimColor:!0,children:[` (`,e.value,`)`]}):null]})},t)})]}):Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(X,{children:`Subagent Model Settings`})}),J(R,{marginBottom:1,children:J(z,{dimColor:!0,children:`Configure which Claude model each subagent uses. Use arrow keys to navigate, enter or space to change a model, and escape to go back.`})}),u.map(e=>{let t=e.id===r,n=l[e.id],i=d.find(e=>e.value===n)?.label||n||`Default`;return Y(R,{flexDirection:`column`,marginBottom:1,children:[J(R,{children:Y(z,{color:t?`cyan`:void 0,children:[t?`❯ `:` `,J(z,{bold:!0,children:e.title})]})}),J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:e.description})}),J(R,{marginLeft:4,children:Y(z,{children:[`Current: `,J(z,{color:`green`,children:i})]})})]},e.id)})]})}const Bt=[{value:`low`,blurb:`Fastest, cheapest - minimal reasoning`},{value:`medium`,blurb:`Balanced reasoning`},{value:`high`,blurb:`Deep reasoning`},{value:`xhigh`,blurb:`Very deep reasoning`},{value:`max`,blurb:`Maximum reasoning - slowest, priciest`}],Vt={messageCap:{label:`Message cap`,unit:`chars`,lo:500,hi:4e5,hint:`max chars of a user message fed to the classifier`},assistantCap:{label:`Assistant cap`,unit:`chars`,lo:500,hi:4e5,hint:`prev assistant reply beyond this is middle-truncated (head+tail + an omitted-size marker the classifier weighs); no mechanical floor`},timeoutMs:{label:`Haiku timeout`,unit:`ms`,lo:1e3,hi:12e4,hint:`classifier call timeout; on timeout the router fails open`}},Ht=[`enabled`,`pinPerTask`,`messageCap`,`assistantCap`,`timeoutMs`,`systemPrompt`],Ut=e=>e in Vt,Wt=M.complexityRouter;function Gt({onBack:e}){let{settings:t,updateSettings:n}=H($),r={...Wt,...t.complexityRouter??{},levels:t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:Wt.levels},i=Ht.length+r.levels.length,{setRawMode:a,isRawModeSupported:o}=Ee(),[s,c]=W(0),[l,u]=W(null),[d,f]=W(0),[p,m]=W(null),[h,g]=W(null),[,_]=W(0),v=e=>{n(t=>{let n={...Wt,...t.complexityRouter??{},levels:(t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:Wt.levels).map(e=>({...e}))};e(n),t.complexityRouter=n})};if(B((t,n)=>{if(h){if(n.escape){g(null);return}if(n.return){let{kind:e,levelIndex:t,value:n}=h;v(r=>{let i=r.levels[t];i&&(i[e]=n)}),g(null);return}if(n.backspace||n.delete){g(e=>e&&{...e,value:e.value.slice(0,-1)});return}t&&!n.ctrl&&!n.meta&&g(e=>e&&{...e,value:e.value+t});return}if(p){if(n.escape){m(null);return}if(n.return){let e=Vt[p.row],t=parseInt(p.value,10),n=Number.isFinite(t)?Math.min(e.hi,Math.max(e.lo,t)):Wt[p.row],r=p.row;v(e=>{e[r]=n}),m(null);return}if(n.backspace||n.delete){m(e=>e&&{...e,value:e.value.slice(0,-1)});return}/^[0-9]$/.test(t)&&m(e=>e&&e.value.length<7?{...e,value:e.value+t}:e);return}if(l){if(n.escape){u(null);return}if(n.upArrow){f(e=>e>0?e-1:Bt.length-1);return}if(n.downArrow){f(e=>e<Bt.length-1?e+1:0);return}if(n.return){let e=Bt[d].value,t=l.levelIndex;v(n=>{n.levels[t]&&(n.levels[t].effort=e)}),u(null)}return}if(n.escape){e();return}if(n.upArrow){c(e=>e>0?e-1:i-1);return}if(n.downArrow){c(e=>e<i-1?e+1:0);return}let y=s<Ht.length,b=s-Ht.length;if(t===`x`){if(y){let e=Ht[s];Ut(e)?v(t=>{t[e]=Wt[e]}):e===`systemPrompt`&&v(e=>{e.systemPrompt=Wt.systemPrompt})}else{let e=Wt.levels[b];e&&v(t=>{let n=t.levels[b];n&&(n.effort=e.effort,n.label=e.label,n.help=e.help)})}return}if(!y&&(t===`l`||t===`h`)){let e=t===`l`?`label`:`help`,n=r.levels[b];n&&g({kind:e,levelIndex:b,value:n[e]});return}if(t===` `||n.return)if(y){let e=Ht[s];if(e===`enabled`)v(e=>{e.enabled=!e.enabled});else if(e===`pinPerTask`)v(e=>{e.pinPerTask=!e.pinPerTask});else if(e===`systemPrompt`){o&&a(!1);let e=te(r.systemPrompt);if(o&&a(!0),e!=null){let t=e.replace(/\s+$/,``);t&&t!==r.systemPrompt&&v(e=>{e.systemPrompt=t})}_(e=>e+1)}else m({row:e,value:String(r[e])})}else{let e=Bt.findIndex(e=>e.value===r.levels[b]?.effort);f(e>=0?e:0),u({levelIndex:b})}}),l)return Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:Y(X,{children:[`Select effort for "`,r.levels[l.levelIndex]?.label,`"`]})}),Bt.map((e,t)=>{let n=t===d;return J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.value,Y(z,{dimColor:!0,children:[` - `,e.blurb]})]})},t)})]});let y=(e,t)=>{let n=t===s,i,a,o=``;if(e===`enabled`)i=`Enabled`,a=r.enabled?`on`:`off`;else if(e===`pinPerTask`)i=`Pin per task`,a=r.pinPerTask?`on`:`off`;else if(e===`systemPrompt`){i=`System prompt`;let e=r.systemPrompt===Wt.systemPrompt;a=`${r.systemPrompt.length} chars${e?` (default)`:` (customized)`} - enter to edit in $EDITOR`,o=`opens the classifier system prompt in your $EDITOR; {LEVELS} (the tier rubric) and {MAX} are substituted at apply time · x = reset to default`}else{let t=Vt[e];i=t.label,p?.row===e?(a=`${p.value||`0`}_`,o=`type a number (${t.lo}-${t.hi}), enter to save · esc cancel`):(a=`${r[e]} ${t.unit}`,o=t.hint)}return Y(R,{flexDirection:`column`,children:[Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,i,`: `,J(z,{color:`green`,children:a})]}),n&&o?J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:o})}):null]},e)};return Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(X,{children:`Complexity Effort Router [experimental]`})}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Classifies each task by difficulty and sets the reasoning-effort (thinking) level to match - low for routine work, the top tier only for genuinely frontier problems. Runs on your current model (no model switch). Off by default.`}),J(z,{dimColor:!0,children:`Heads up - it burns more tokens: effort level is part of the prompt cache key, so every turn the router changes the level the whole conversation is re-read uncached (a big one-time hit that turn, then cheaper again while the level holds). Each level keeps its own cache, so returning to a prior level reuses most of its earlier work. pin per task on (the default, monotonic) minimizes the churn; pin off flips both ways and pays it more often. Measured, not theoretical.`}),J(z,{dimColor:!0,children:`A one-shot Haiku side-call routes each prompt, fed a rolling TL;DR summary of the session plus the model in use and the level it set last turn (so it judges in context, not cold). Kept in ~/.tweakcc/router- state, restored on resume; reset and reseeded from the main model's summary when the conversation compacts. On a Haiku error it keeps the last level, else defaults high.`}),J(z,{dimColor:!0,children:`Rewind-aware: it snapshots the routed state each turn, so /rewind (Restore conversation) cuts the summary back to the point you rewound to - effort and memory follow the conversation instead of carrying rewound-away work. (Summarize-from-here rewinds reseed via compaction.)`}),J(z,{dimColor:!0,children:`Fully customizable: edit the classifier System prompt in your $EDITOR, and each tier's label/help inline - all with sane defaults.`}),J(z,{dimColor:!0,children:`pin per task is a monotonic floor - effort never drops below the session max (only escalates); turn it off to track each prompt up and down. Reset on /clear.`}),J(z,{dimColor:!0,children:`While on, the router drives effort, overriding your saved effortLevel. An in-session /effort takes back manual control for that session, and CLAUDE_CODE_EFFORT_LEVEL always wins.`}),J(z,{dimColor:!0,children:`See it: Claude Code's working indicator already shows it live - e.g. "thinking with max effort" reflects the routed level. TWEAKCC_ROUTER_DEBUG=1 also logs each decision.`}),J(z,{dimColor:!0,children:`↑↓ navigate · enter/space toggle, edit, or open $EDITOR · digits set a number · on a tier: l/h edit label/help · x reset · esc back`})]}),Ht.map((e,t)=>y(e,t)),J(R,{marginTop:1,marginBottom:1,children:J(z,{bold:!0,children:`Complexity levels and their effort`})}),r.levels.map((e,t)=>{let n=Ht.length+t===s,r=h?.levelIndex===t&&h.kind===`label`,i=h?.levelIndex===t&&h.kind===`help`;return Y(R,{flexDirection:`column`,marginBottom:1,children:[J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,J(z,{bold:!0,children:r?`${h.value}_`:e.label}),` `,J(z,{color:`green`,children:e.effort})]})}),J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:i?`${h.value}_`:e.help})}),n&&!h?J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:`enter = set effort · l = edit label · h = edit help · x = reset this tier`})}):null,n&&h?J(R,{marginLeft:4,children:Y(z,{dimColor:!0,children:[`editing `,h.kind,` - type to change · enter save · esc cancel`]})}):null]},e.id)})]})}const Kt=[`fable`,`opus`,`sonnet`,`haiku`],qt=[`low`,`medium`,`high`,`xhigh`,`max`],Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=[{kind:`enabled`},{kind:`model`,side:`plan`},{kind:`effort`,side:`plan`},{kind:`model`,side:`exec`},{kind:`effort`,side:`exec`},{kind:`clearContext`}],Xt=({onBack:e})=>{let{settings:t,updateSettings:n}=H($),r={...M.fablePlan,...t.fablePlan??{}},[i,a]=W(0),o=e=>{n(t=>({...t,fablePlan:{...M.fablePlan,...t.fablePlan??{},...e}}))},s=e=>{let t=Yt[i];if(t.kind===`enabled`){o({enabled:!r.enabled});return}if(t.kind===`clearContext`){o({offerClearContextOnPlanAccept:!r.offerClearContextOnPlanAccept});return}if(t.kind===`model`){let n=t.side===`plan`?`planModel`:`execModel`,i=t.side===`plan`?r.execModel:r.planModel,a=Kt.indexOf(r[n]);for(let t=1;t<=Kt.length;t++){let r=Kt[(a+e*t+Kt.length*t)%Kt.length];if(r!==i){o({[n]:r});return}}return}let n=t.side===`plan`?`planEffort`:`execEffort`,a=qt[(qt.indexOf(r[n])+e+qt.length)%qt.length];o({[n]:a})};B((t,n)=>{if(n.escape||t===`q`){e();return}n.upArrow?a(e=>(e-1+Yt.length)%Yt.length):n.downArrow?a(e=>(e+1)%Yt.length):n.leftArrow?s(-1):n.rightArrow||n.return||t===` `?s(1):t===`x`&&o({...M.fablePlan})});let c=(e,t,n)=>Y(R,{children:[Y(z,{color:e===i?`cyan`:void 0,children:[e===i?`❯ `:` `,t.padEnd(26)]}),J(z,{color:e===i?`cyan`:`green`,bold:e===i,children:n})]},t),l=`${r.planModel}plan`;return Y(R,{flexDirection:`column`,paddingX:1,children:[J(z,{bold:!0,children:`Fable Plan mode`}),Y(R,{marginTop:1,flexDirection:`column`,children:[Y(z,{dimColor:!0,children:[`Adds a `,J(z,{color:`green`,children:l}),` entry to Claude Code's`,` `,J(z,{color:`green`,children:`/model`}),` list: `,Jt(r.planModel),` `,`while planning, `,Jt(r.execModel),` while executing, each at its own reasoning effort.`]}),Y(z,{dimColor:!0,children:[`It is a model you select, the same mechanism Claude Code ships for opusplan. Nothing changes for any other model, and your selection stays `,J(z,{color:`green`,children:l}),` throughout — the pairing is resolved per request, so no model is ever switched underneath you mid-session.`]})]}),J(R,{marginTop:1,flexDirection:`column`,children:Yt.map((e,t)=>{if(e.kind===`enabled`)return c(t,`Enabled`,r.enabled?`yes`:`no`);if(e.kind===`clearContext`)return c(t,`Offer "clear context"`,r.offerClearContextOnPlanAccept?`yes`:`no`);let n=e.side===`plan`?`Planning`:`Executing`;return e.kind===`model`?c(t,`${n} model`,Jt(e.side===`plan`?r.planModel:r.execModel)):c(t,`${n} effort`,e.side===`plan`?r.planEffort:r.execEffort)})}),Y(R,{marginTop:1,flexDirection:`column`,children:[Y(z,{dimColor:!0,children:[`Claude Code defaults its "clear context" option off. On, the plan-approval dialog offers "Yes, clear context (N% used)", which hands only the plan to `,Jt(r.execModel),`. Continuing instead re-sends the whole planning transcript to a different model, so the cache is cold either way and you pay for the transcript twice.`]}),J(z,{dimColor:!0,children:`Effort follows the resolved model, so the complexity router still drives every model that is not part of this pairing.`})]}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`↑↓ move · ←→ change · x reset to defaults · esc back`})})]})},Zt=K.join(ae,`claude-browser-bridge`),Qt=K.join(Zt,`host`,`setup.mjs`),$t=K.join(Zt,`extension`),en=K.join(Pe.homedir(),`.claude-browser-bridge`,`install-state.json`),tn=`/tmp/claude-browser-bridge-${Pe.userInfo().username}.sock`;function nn(e){try{return!G.statSync(K.join(e,`Local State`)).isFile()||!G.statSync(K.join(e,`NativeMessagingHosts`)).isDirectory()?!1:G.existsSync(K.join(e,`Default`))?!0:G.readdirSync(e).some(e=>/^Profile \d+$/.test(e))}catch{return!1}}function rn(e){let t=K.basename(e);return t===`User Data`&&(t=K.basename(K.dirname(e))),t.includes(`.`)&&(t=t.split(`.`).pop()||t),t=t.replace(/[-_]/g,` `),t.charAt(0).toUpperCase()+t.slice(1)}function an(e){return new Promise(t=>{Le(process.execPath,e,{maxBuffer:8*1024*1024},(e,n,r)=>{t({code:e?typeof e.code==`number`?e.code:1:0,out:String(n)+String(r)})})})}function on(e){return new Promise(t=>{Le(`git`,e,{maxBuffer:8*1024*1024},(e,n,r)=>{t({code:e?1:0,out:String(n)+String(r)})})})}async function sn(){if(G.existsSync(K.join(Zt,`.git`))&&G.existsSync(Qt)){let e=await on([`-C`,Zt,`pull`,`--ff-only`]);return G.existsSync(Qt)?{code:0,out:e.out}:e}return G.existsSync(Zt)&&G.rmSync(Zt,{recursive:!0,force:!0}),on([`clone`,`--depth`,`1`,`https://github.com/skrabe/claude-browser-bridge`,Zt])}function cn(){let e=process.platform===`darwin`?K.join(Pe.homedir(),`Library`,`Application Support`):K.join(Pe.homedir(),`.config`),t=e=>{try{return G.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>K.join(e,t.name))}catch{return[]}},n=[];for(let r of t(e))for(let e of[r,...t(r)])nn(e)&&n.push(rn(e));return n.sort()}function ln(){try{return JSON.parse(G.readFileSync(en,`utf8`))}catch{return null}}const un=({onBack:e})=>{let[t,n]=W(`menu`),[r,i]=W(0),[a,o]=W(ln()),[s,c]=W(`global`),[l,u]=W(`Working…`),[d,f]=W([]),[p,m]=W(null),[h,g]=W(``),_=je(()=>{o(ln())},[]);U(()=>{_()},[_]);let v=G.existsSync(tn),y=!!a,b=()=>{c(`global`),i(0),n(`scope`)},x=je(async e=>{n(`busy`),u(`Fetching the bridge…`),f([]);let t=await sn();if(t.code!==0||!G.existsSync(Qt)){g(`Failed to fetch the bridge repo:
|
|
2
|
+
import{B as e,D as t,E as n,F as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,U as v,V as y,W as b,X as x,Y as S,Z as C,_ as w,a as T,at as ee,b as E,ct as D,d as O,g as te,h as k,i as ne,it as A,k as re,l as j,m as ie,n as ae,nt as oe,o as se,ot as M,p as N,q as ce,r as P,rt as F,s as I,st as le,t as ue,tt as de,u as fe,v as pe,x as me,y as he,z as L}from"./config-DtZztjxv.mjs";import{a as ge,c as _e,d as ve,l as ye,n as be,o as xe,s as Se,t as Ce,u as we}from"./content-DBHwlD7l.mjs";import{Box as R,Text as z,render as Te,useInput as B,useStdin as Ee}from"ink";import{Command as De}from"commander";import V from"chalk";import Oe,{Fragment as ke,createContext as Ae,useCallback as je,useContext as H,useEffect as U,useMemo as Me,useRef as Ne,useState as W}from"react";import*as Pe from"node:os";import Fe from"ink-link";import*as Ie from"node:fs/promises";import*as G from"node:fs";import*as K from"node:path";import{execFile as Le,execSync as Re,spawn as ze}from"node:child_process";import Be from"gray-matter";import{structuredPatch as Ve}from"diff";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import He from"process";import Ue from"cli-spinners";import*as We from"node:readline";var X=({children:e,...t})=>Y(z,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...t,children:[` `,e,` `]});const Ge=[`\x1B[?25l\x1B[0m \x1B[38;2;0;0;0m \x1B[38;2;252;130;0m▂\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▇\x1B[38;2;254;131;0m\x1B[48;2;252;130;0m▇\x1B[48;2;252;130;0m▇▇\x1B[48;2;252;130;0m▇\x1B[0m\x1B[38;2;252;130;0m▇\x1B[38;2;252;130;0m▅\x1B[38;2;252;130;0m▄\x1B[38;2;252;130;0m▂ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;254;131;0m▗\x1B[38;2;254;131;0m▆\x1B[48;2;254;131;0m \x1B[38;2;254;132;0m╶ \x1B[0m\x1B[38;2;254;131;0m▆\x1B[38;2;254;131;0m▖ \x1B[0m`,` \x1B[7m\x1B[38;2;254;131;0m▘\x1B[0m\x1B[38;2;11;6;0m\x1B[48;2;254;131;0m \x1B[38;2;254;216;182m\x1B[48;2;254;136;12m▃\x1B[38;2;254;249;246m\x1B[48;2;254;143;29m▅\x1B[38;2;254;253;253m\x1B[48;2;254;143;40m▆\x1B[38;2;254;254;253m\x1B[48;2;254;152;68m▆▆▆\x1B[38;2;254;253;252m\x1B[48;2;254;141;34m▆\x1B[38;2;254;247;242m\x1B[48;2;254;140;24m▅\x1B[38;2;254;224;199m\x1B[48;2;254;140;20m▖\x1B[48;2;254;131;0m \x1B[0m\x1B[7m\x1B[38;2;254;131;0m▝\x1B[0m \x1B[0m`,`\x1B[7m\x1B[38;2;251;127;0m▌\x1B[0m\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[38;2;252;128;0m\x1B[48;2;254;131;0m▃\x1B[38;2;252;129;0m▂\x1B[38;2;253;130;0m▁\x1B[38;2;249;135;16m\x1B[48;2;253;226;202m▋\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┈\x1B[48;2;246;246;245m┈\x1B[38;2;47;47;47m\x1B[48;2;244;244;243m▂\x1B[38;2;112;112;112m\x1B[48;2;251;251;251m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m▁╌▝\x1B[38;2;254;254;253m\x1B[48;2;254;254;254m▋\x1B[38;2;254;254;254m\x1B[48;2;254;253;252m┈\x1B[38;2;252;209;168m\x1B[48;2;251;129;0m▍\x1B[38;2;253;129;0m\x1B[48;2;254;131;0m▂\x1B[38;2;252;128;0m▃\x1B[38;2;251;127;0m\x1B[48;2;253;130;0m▃\x1B[0m\x1B[38;2;251;127;0m▌\x1B[0m`,`\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▏\x1B[38;2;245;118;0m\x1B[48;2;248;122;0m▄\x1B[38;2;247;121;0m\x1B[48;2;247;122;0m┈\x1B[38;2;106;68;38m\x1B[48;2;245;123;2m▃\x1B[38;2;39;33;28m\x1B[48;2;211;109;6m▅\x1B[38;2;27;20;12m\x1B[48;2;237;237;237m▌\x1B[48;2;254;254;253m \x1B[38;2;90;90;89m\x1B[48;2;231;230;230m▝\x1B[38;2;215;215;214m\x1B[48;2;48;48;48m▁\x1B[38;2;203;203;202m\x1B[48;2;42;42;42m▂\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┇╴\x1B[38;2;253;252;252m▂\x1B[38;2;251;250;250m\x1B[48;2;253;253;253m▃\x1B[38;2;249;249;248m\x1B[48;2;252;252;251m▄\x1B[38;2;249;248;248m\x1B[48;2;237;118;0m▍\x1B[38;2;246;121;0m\x1B[48;2;250;125;0m▄\x1B[38;2;246;119;0m\x1B[48;2;249;124;0m▄\x1B[38;2;245;118;0m\x1B[48;2;248;123;0m▄\x1B[38;2;243;118;0m\x1B[48;2;243;118;0m▉\x1B[0m`,`\x1B[38;2;238;108;0m\x1B[48;2;237;109;0m▏\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;233;109;2m\x1B[48;2;125;73;29m▇\x1B[38;2;225;104;1m\x1B[48;2;50;32;18m▄\x1B[38;2;62;29;2m\x1B[48;2;239;237;237m▌\x1B[38;2;254;253;253m\x1B[48;2;254;254;254m┻\x1B[38;2;254;254;253m▊\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;253;253;252m▂\x1B[38;2;251;251;251m\x1B[48;2;254;253;253m▃\x1B[38;2;249;249;249m\x1B[48;2;252;252;252m▄\x1B[38;2;247;247;247m\x1B[48;2;250;250;250m▄\x1B[38;2;245;245;244m\x1B[48;2;248;248;248m▄\x1B[38;2;243;243;242m\x1B[48;2;246;246;245m▄\x1B[38;2;243;242;242m\x1B[48;2;230;109;0m▍\x1B[38;2;239;111;0m\x1B[48;2;243;116;0m▄\x1B[38;2;239;109;0m\x1B[48;2;242;114;0m▄\x1B[38;2;238;108;0m\x1B[48;2;241;113;0m▄\x1B[38;2;237;108;0m\x1B[48;2;238;108;0m▉\x1B[0m`,`\x1B[7m\x1B[38;2;231;98;0m▌\x1B[0m\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[38;2;231;99;0m\x1B[48;2;235;105;0m▄\x1B[38;2;232;100;0m\x1B[48;2;236;105;0m▄\x1B[38;2;232;101;0m\x1B[48;2;236;106;0m▄\x1B[38;2;223;99;0m\x1B[48;2;247;238;235m▌\x1B[38;2;254;254;254m\x1B[48;2;254;254;253m┊\x1B[38;2;252;252;251m▃\x1B[38;2;250;250;250m\x1B[48;2;253;253;252m▄\x1B[38;2;248;248;247m\x1B[48;2;251;251;250m▄\x1B[38;2;246;245;245m\x1B[48;2;249;248;248m▄\x1B[38;2;243;243;243m\x1B[48;2;246;246;246m▄\x1B[38;2;241;241;241m\x1B[48;2;244;244;244m▄\x1B[38;2;239;239;238m\x1B[48;2;242;242;242m▄\x1B[38;2;237;237;236m\x1B[48;2;240;240;239m▄\x1B[38;2;237;236;236m\x1B[48;2;223;99;0m▍\x1B[38;2;232;100;0m\x1B[48;2;236;106;0m▄\x1B[38;2;231;100;0m\x1B[48;2;235;105;0m▄\x1B[38;2;231;98;0m\x1B[48;2;234;103;0m▄\x1B[0m\x1B[38;2;231;98;0m▌\x1B[0m`,` \x1B[7m\x1B[38;2;224;89;0m▖\x1B[0m\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[38;2;225;90;0m\x1B[48;2;228;95;0m▄\x1B[38;2;225;91;0m\x1B[48;2;229;96;0m▄\x1B[38;2;217;90;1m\x1B[48;2;97;77;70m▌\x1B[38;2;70;70;70m\x1B[48;2;207;207;207m▆\x1B[38;2;66;65;65m\x1B[48;2;228;228;227m▄\x1B[38;2;66;66;66m\x1B[48;2;233;232;232m▂\x1B[38;2;169;169;169m\x1B[48;2;243;243;243m▁\x1B[38;2;240;239;239m\x1B[48;2;243;242;242m▄\x1B[38;2;238;237;237m\x1B[48;2;241;240;240m▄\x1B[38;2;235;235;235m\x1B[48;2;238;238;238m▄\x1B[38;2;233;233;233m\x1B[48;2;236;236;236m▄\x1B[38;2;231;231;230m\x1B[48;2;234;234;233m▄\x1B[38;2;231;230;230m\x1B[48;2;216;89;0m▍\x1B[38;2;225;90;0m\x1B[48;2;229;95;0m▄\x1B[38;2;224;89;0m\x1B[48;2;228;94;0m▄\x1B[0m\x1B[7m\x1B[38;2;224;89;0m▗\x1B[0m \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[38;2;217;80;0m▝\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m\x1B[48;2;221;86;0m▄\x1B[38;2;197;78;9m\x1B[48;2;66;66;65m▋\x1B[38;2;65;65;64m\x1B[48;2;60;60;60m▘\x1B[38;2;52;52;51m\x1B[48;2;56;56;56m▗\x1B[38;2;45;45;45m\x1B[48;2;50;50;49m▗\x1B[38;2;42;42;42m\x1B[48;2;46;46;46m┈\x1B[38;2;41;41;41m\x1B[48;2;203;202;202m▆\x1B[38;2;38;38;38m\x1B[48;2;218;218;218m▄\x1B[38;2;45;45;45m\x1B[48;2;221;221;221m▂\x1B[38;2;229;229;229m┊\x1B[38;2;225;225;225m\x1B[48;2;228;228;227m▄\x1B[38;2;225;224;224m\x1B[48;2;209;79;0m▍\x1B[0m\x1B[7m\x1B[38;2;217;80;0m▂\x1B[0m\x1B[38;2;217;80;0m▘ \x1B[0m`,` \x1B[38;2;0;0;0m \x1B[7m\x1B[38;2;191;73;0m▆\x1B[38;2;191;73;0m▄\x1B[38;2;56;55;55m▃\x1B[38;2;46;46;46m▁\x1B[0m\x1B[38;2;20;20;20m\x1B[48;2;42;42;42m▁\x1B[38;2;36;36;36m\x1B[48;2;35;34;34m╴\x1B[38;2;23;23;23m\x1B[48;2;29;29;28m▁\x1B[38;2;10;10;10m\x1B[48;2;22;22;22m▁\x1B[0m\x1B[7m\x1B[38;2;15;15;15m▁\x1B[38;2;22;22;21m▃\x1B[38;2;154;154;154m▅\x1B[38;2;175;116;83m▇\x1B[0m\x1B[38;2;17;15;14m \x1B[0m`,`\x1B[?25h\x1B[0m`];var Ke=()=>Y(R,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[Y(R,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[J(z,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),J(z,{children:` `}),Y(z,{children:[`We've released `,J(z,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),Y(z,{children:[`Download it and try it out for free!`,` `,J(Fe,{url:`https://piebald.ai/`,fallback:!1,children:J(z,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),J(z,{children:` `}),J(z,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),J(R,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:Ge.map((e,t)=>J(z,{children:e},t))})]});let Z=function(e){return e.THEMES=`Themes`,e.THINKING_VERBS=`Thinking verbs`,e.THINKING_STYLE=`Thinking style`,e.USER_MESSAGE_DISPLAY=`User message display`,e.INPUT_PATTERN_HIGHLIGHTERS=`Input pattern highlighters`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.SUBAGENT_MODELS=`Subagent models`,e.COMPLEXITY_ROUTER=`Complexity effort router [experimental]`,e.FABLE_PLAN=`Fable Plan mode`,e.CLAUDE_MD_ALT_NAMES=`CLAUDE.md alternative names`,e.SYSTEM_REMINDERS=`System reminders (injection lobotomy)`,e.SKILLS=`Skills (per-skill on/name-only/user-invocable/off)`,e.BROWSER_BRIDGE=`Better Claude in Chrome`,e.VIEW_SYSTEM_PROMPTS=`View system prompts`,e.RESTORE_ORIGINAL=`Restore original Claude Code (preserves config.json)`,e.OPEN_CONFIG=`Open config.json`,e.OPEN_CLI=`Open Claude Code's cli.js`,e.EXIT=`Exit`,e}({});function qe({items:e,selectedIndex:t,onSelect:n,onSubmit:r}){return B((i,a)=>{e.length!==0&&(a.upArrow?n(t>0?t-1:e.length-1):a.downArrow?n(t<e.length-1?t+1:0):a.return&&r(e[t].name))}),J(R,{flexDirection:`column`,children:e.map((e,n)=>J(R,{children:Y(z,{children:[Y(z,{bold:n===t,color:n===t?`cyan`:void 0,...n===t?e.selectedStyles??{}:e.styles??{},children:[n===t?`❯ `:` `,e.name]}),e.desc&&n===t&&Y(z,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,e.desc]})]})},n))})}const Je=[{name:Z.THEMES,desc:`Modify Claude Code's built-in themes or create your own`},{name:Z.THINKING_VERBS,desc:`Customize the list of verbs that Claude Code uses when it's working`},{name:Z.THINKING_STYLE,desc:`Choose custom spinners`},{name:Z.USER_MESSAGE_DISPLAY,desc:`Customize how user messages are displayed`},{name:Z.INPUT_PATTERN_HIGHLIGHTERS,desc:`Create custom highlighters for patterns in your input`},{name:Z.MISC,desc:`Miscellaneous settings (input box border, etc.)`},{name:Z.TOOLSETS,desc:`Manage toolsets to control which tools are available`},{name:Z.SUBAGENT_MODELS,desc:`Configure which Claude model each subagent uses (Plan, Explore, etc.)`},{name:Z.COMPLEXITY_ROUTER,desc:`[EXPERIMENTAL] Auto-route reasoning effort by task complexity (routine=low ... hardest=max)`},{name:Z.FABLE_PLAN,desc:`Plan on one model, execute on another (a /model entry, like opusplan)`},{name:Z.CLAUDE_MD_ALT_NAMES,desc:`Configure alternative filenames for CLAUDE.md (e.g., AGENTS.md)`},{name:Z.SYSTEM_REMINDERS,desc:`Suppress per-turn <system-reminder> injections (skills list, MCP instructions, claudeMd wrapper, etc.)`},{name:Z.SKILLS,desc:`Per-skill listing control (writes settings.json skillOverrides — no patch needed)`},{name:Z.BROWSER_BRIDGE,desc:`Drive your real, logged-in tabs over CDP — a fuller take on Claude in Chrome`},{name:Z.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],Ye=[{name:Z.RESTORE_ORIGINAL,desc:`Reverts your Claude Code install to its original state (your customizations are remembered and can be reapplied)`},{name:Z.OPEN_CONFIG,desc:`Opens your tweakcc config file (${P})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var Xe=({onSubmit:e})=>{let t=[...Je,...Ye],[n,r]=W(0);return J(qe,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const Ze=()=>Y(R,{flexDirection:`row`,children:[J(X,{children:`tweakcc`}),J(z,{children:` (by `}),J(Fe,{url:`https://piebald.ai`,fallback:!1,children:J(z,{color:`#ff8400`,bold:!0,children:`Piebald`})}),J(z,{children:`)`})]}),Qe=()=>J(R,{children:Y(z,{color:`yellow`,children:[`⭐ `,J(z,{bold:!0,children:`Star the repo at `}),J(Fe,{url:`https://github.com/skrabe/tweakcc-fixed`,fallback:!1,children:J(z,{bold:!0,color:`cyan`,children:`https://github.com/skrabe/tweakcc-fixed`})}),J(z,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),$e=({notification:e})=>J(R,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:e.type===`success`?`green`:e.type===`error`?`red`:e.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:J(z,{color:e.type===`success`?`green`:e.type===`error`?`red`:e.type===`info`?`blue`:`yellow`,children:e.message})}),et=({onSubmit:e,notification:t,configMigrated:n,showPiebaldAnnouncement:r,changesApplied:i,invocationCommand:a})=>Y(R,{flexDirection:`column`,gap:1,children:[n&&J(R,{children:J(z,{color:`blue`,bold:!0,children:"Note that in tweakcc v3.2.0+, `ccInstallationDir` config is deprecated. You are now migrated to `ccInstallationPath` which supports npm and native installs."})}),J(Ze,{}),J(R,{children:Y(z,{children:[J(z,{bold:!0,children:`Customize your Claude Code installation.`}),` `,Y(z,{dimColor:!0,children:[`Settings will be saved to `,ae.replace(Pe.homedir(),`~`),`/config.json.`]})]})}),J(r?Ke:Qe,{}),t&&J($e,{notification:t}),!i&&!t&&J($e,{notification:{message:`Your changes are configured but not applied.\nRun \`${a} --apply\` to apply your customizations!`,type:`info`}}),J(Xe,{onSubmit:e})]});function Q({color:e,backgroundColor:t,bold:n,dimColor:r,children:i}){let a=e?.startsWith(`ansi:`),o=t?.startsWith(`ansi:`);if(a||o){if(Oe.Children.toArray(i).some(e=>Oe.isValidElement(e)))return J(z,{children:i});let s=V;if(a){let t=e.slice(5);s=s[t]||s}if(o){let e=t.slice(5),n=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;s=s[n]||s}n&&(s=s.bold),r&&(s=s.dim);let c=Oe.Children.toArray(i).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return J(z,{children:s(c)})}return J(z,{color:e,backgroundColor:t,bold:n,dimColor:r,children:i})}function tt({text:e,nonShimmerColors:t,shimmerColors:n,shimmerWidth:r=3,updateDuration:i=50,restartPoint:a=10}){let[o,s]=W(0);return U(()=>{let t=setInterval(()=>{s(t=>{let n=t+1;return n>=e.length+a?-r:n})},i);return()=>clearInterval(t)},[e.length,a,i]),t.length===n.length?J(z,{children:e.split(``).map((i,a)=>{let s=a>=o&&a<o+r&&o<e.length,c=a%t.length;return J(z,{color:s?n[c]:t[c],children:i},a)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),J(z,{children:e}))}const nt=He.cwd();function rt({theme:e}){let{ccVersion:t}=H($);return Y(R,{flexDirection:`column`,paddingLeft:1,children:[J(R,{marginBottom:1,children:Y(z,{bold:!0,children:[`Preview: `,e.name]})}),J(R,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:Y(R,{flexDirection:`column`,children:[Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(Q,{color:e.colors.clawd_body,children:` ▐`}),J(z,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:`▛███▜`}),Y(z,{children:[J(Q,{color:e.colors.clawd_body,children:`▌ `}),` `,J(z,{bold:!0,children:`Claude Code`}),` `,t?`v${t}`:`v2.0.14`]})]}),Y(z,{children:[J(Q,{color:e.colors.clawd_body,children:`▝▜`}),J(z,{color:e.colors.clawd_body,backgroundColor:e.colors.clawd_background,children:`█████`}),J(Q,{color:e.colors.clawd_body,children:`▛▘`}),` `,g(),` · `,E()]}),Y(Q,{color:e.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,nt]}),Y(z,{children:[Y(Q,{color:e.colors.success,children:[`Login successful. Press`,` `]}),J(Q,{bold:!0,color:e.colors.success,children:`Enter`}),Y(Q,{color:e.colors.success,children:[` `,`to continue…`]})]})]}),J(z,{children:`╭─────────────────────────────────────────────╮`}),Y(z,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),Y(z,{children:[`│ 2`,` `,J(Q,{backgroundColor:e.colors.diffRemoved,color:e.colors.text,children:`- console.log("`}),J(Q,{backgroundColor:e.colors.diffRemovedWord,children:`Hello, World!`}),J(Q,{backgroundColor:e.colors.diffRemoved,children:`");`}),` `,`│`]}),Y(z,{children:[`│ 2`,` `,J(Q,{backgroundColor:e.colors.diffAdded,color:e.colors.text,children:`+ console.log("`}),J(Q,{backgroundColor:e.colors.diffAddedWord,children:`Hello, Claude!`}),J(Q,{backgroundColor:e.colors.diffAdded,children:`");`}),` `,`│`]}),J(Q,{color:e.colors.warning,children:`╭─────────────────────────────────────────────╮`}),Y(Q,{color:e.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),Y(z,{children:[J(Q,{color:e.colors.warning,children:`│ `}),J(z,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),Y(Q,{color:e.colors.warning,children:[` `,`│`]})]}),J(Q,{color:e.colors.bashBorder,children:`───────────────────────────────────────────────`}),Y(z,{children:[J(Q,{color:e.colors.bashBorder,children:`!`}),J(z,{children:` ls`})]}),J(Q,{color:e.colors.promptBorder,children:`───────────────────────────────────────────────`}),J(z,{children:Y(z,{children:[`> list the dir`,` `,J(tt,{text:`ultrathink`,nonShimmerColors:[e.colors.rainbow_red,e.colors.rainbow_orange,e.colors.rainbow_yellow,e.colors.rainbow_green,e.colors.rainbow_blue,e.colors.rainbow_indigo,e.colors.rainbow_violet],shimmerColors:[e.colors.rainbow_red_shimmer,e.colors.rainbow_orange_shimmer,e.colors.rainbow_yellow_shimmer,e.colors.rainbow_green_shimmer,e.colors.rainbow_blue_shimmer,e.colors.rainbow_indigo_shimmer,e.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),J(Q,{color:e.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),Y(z,{children:[J(Q,{color:e.colors.planMode,children:`│ `}),Y(Q,{color:e.colors.permission,children:[`Ready to code?`,` `]}),J(z,{children:`Here is Claude's plan:`}),Y(Q,{color:e.colors.planMode,children:[` `,`│`]})]}),J(Q,{color:e.colors.permission,children:`╭─────────────────────────────────────────────╮`}),Y(z,{children:[J(Q,{color:e.colors.permission,children:`│ `}),J(z,{bold:!0,children:`Permissions:`}),` `,Y(Q,{backgroundColor:e.colors.permission,color:e.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,J(Q,{color:e.colors.permission,children:`│`})]}),J(z,{children:`> list the dir`}),Y(z,{children:[J(Q,{color:e.colors.error,children:`●`}),J(z,{children:` Update(__init__.py)`})]}),Y(z,{children:[J(z,{children:` ⎿ `}),J(Q,{color:e.colors.error,children:`User rejected update to __init__.py`})]}),Y(z,{children:[` `,`1`,` `,Y(Q,{backgroundColor:e.colors.diffRemovedDimmed,children:[`- import`,` `]}),J(Q,{backgroundColor:e.colors.diffRemovedWordDimmed,children:`os`})]}),Y(z,{children:[` `,`2`,` `,Y(Q,{backgroundColor:e.colors.diffAddedDimmed,children:[`+ import`,` `]}),J(Q,{backgroundColor:e.colors.diffAddedWordDimmed,children:`random`})]}),Y(z,{children:[J(Q,{color:e.colors.success,children:`●`}),J(z,{children:` List(.)`})]}),Y(z,{children:[J(z,{children:`●`}),J(z,{children:` The directory `}),J(Q,{color:e.colors.permission,children:`C:\\Users\\user`}),Y(z,{children:[` `,`contains `,J(z,{bold:!0,children:`123`}),` files.`]})]}),Y(z,{children:[J(Q,{color:e.colors.claude,children:`✻ Th`}),J(Q,{color:e.colors.claudeShimmer,children:`ink`}),J(Q,{color:e.colors.claude,children:`ing… `}),J(z,{children:`(esc to interrupt)`})]}),J(z,{children:J(Q,{color:e.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),J(z,{children:J(Q,{color:e.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),J(z,{children:J(Q,{color:e.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function it({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?J(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?J(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):J(Q,{color:r,bold:n,children:e})}function at({initialValue:e,onColorChange:r,onExit:i,colorKey:a,theme:o}){let s=st(e)||{h:0,s:50,l:50},c=ot(e)||{r:128,g:128,b:128},[l,u]=W(s),[d,f]=W(c),[p,m]=W(`hsl`),[h,g]=W(`h`),[_,v]=W(!1),[y,b]=W(!1);U(()=>{let t=st(e),n=ot(e);t&&n&&(v(!0),u(t),f(n),v(!1))},[e]),U(()=>{!_&&y&&r(`rgb(${d.r},${d.g},${d.b})`)},[l,d,_,y]),U(()=>{b(!0)},[]);let x=e=>{if(n(e)){let n=t(e),r=st(n),i=ot(n);r&&i&&(v(!0),u(r),f(i),v(!1))}};B((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){x(e);return}t.return||t.escape?i():t.ctrl&&e===`a`?(m(e=>e===`hsl`?`rgb`:`hsl`),g(e=>p===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?g(p===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?g(p===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?S(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&S(t.shift||t.ctrl||t.meta?10:1)});let S=e=>{v(!0),p===`hsl`?u(t=>{let n={...t};h===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):h===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):h===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=w(n.h,n.s,n.l);return f({r,g:i,b:a}),n}):f(t=>{let n={...t};return h===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):h===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):h===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),u(C(n.r,n.g,n.b)),n}),v(!1)},C=(e,t,n)=>{let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===r?((i-a)/c+(i<a?6:0))/6:o===i?((a-r)/c+2)/6:((r-i)/c+4)/6),{h:Math.round(d*360),s:Math.round(u*100),l:Math.round(l*100)}},w=(e,t,n)=>{e/=360,t/=100,n/=100;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e*6%2-1)),a=n-r/2,o=0,s=0,c=0;return 0<=e&&e<1/6?(o=r,s=i,c=0):1/6<=e&&e<2/6?(o=i,s=r,c=0):2/6<=e&&e<3/6?(o=0,s=r,c=i):3/6<=e&&e<4/6?(o=0,s=i,c=r):4/6<=e&&e<5/6?(o=i,s=0,c=r):5/6<=e&&e<1&&(o=r,s=0,c=i),[Math.round((o+a)*255),Math.round((s+a)*255),Math.round((c+a)*255)]},T=()=>{let e=[],t=[[255,0,0],[255,127,0],[255,255,0],[127,255,0],[0,255,0],[0,255,127],[0,255,255],[0,127,255],[0,0,255],[127,0,255],[255,0,255],[255,0,127],[255,0,0]];for(let n=0;n<40;n++){let r=n/39*(t.length-1),i=Math.floor(r),a=Math.ceil(r),o=r-i,[s,c,l]=t[i],[u,d,f]=t[a],p=Math.round(s+(u-s)*o),m=Math.round(c+(d-c)*o),h=Math.round(l+(f-l)*o);e.push(J(z,{backgroundColor:`rgb(${p},${m},${h})`,children:` `},n))}return e},ee=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(l.h,n,l.l);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},E=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(l.h,l.s,n);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},D=()=>{let[e,t,n]=w(l.h,l.s,l.l);return`rgb(${e},${t},${n})`},O=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},te=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${n},${d.g},${d.b})`,children:` `},t))}return e},k=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${d.r},${n},${d.b})`,children:` `},t))}return e},ne=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${d.r},${d.g},${n})`,children:` `},t))}return e},A=(e,t)=>Math.round(e/t*39);return Y(R,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[Y(R,{flexDirection:`column`,children:[J(z,{bold:!0,children:`Color Picker`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),J(z,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),J(z,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),J(z,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),J(z,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),J(z,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),p===`hsl`?Y(q,{children:[Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`h`?`yellow`:`white`,children:[h===`h`?`❯ `:` `,`Hue (`,l.h,`°):`]})}),J(R,{children:T().map((e,t)=>J(ke,{children:t===A(l.h,360)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`s`?`yellow`:`white`,children:[h===`s`?`❯ `:` `,`Saturation (`,l.s,`%):`]})}),J(R,{children:ee().map((e,t)=>J(ke,{children:t===A(l.s,100)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`l`?`yellow`:`white`,children:[h===`l`?`❯ `:` `,`Lightness (`,l.l,`%):`]})}),J(R,{children:E().map((e,t)=>J(ke,{children:t===A(l.l,100)?J(z,{children:`|`}):e},t))})]})]}):Y(q,{children:[Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`r`?`yellow`:`white`,children:[h===`r`?`❯ `:` `,`Red (`,d.r,`):`]})}),J(R,{children:te().map((e,t)=>J(ke,{children:t===A(d.r,255)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`g`?`yellow`:`white`,children:[h===`g`?`❯ `:` `,`Green (`,d.g,`):`]})}),J(R,{children:k().map((e,t)=>J(ke,{children:t===A(d.g,255)?J(z,{children:`|`}):e},t))})]}),Y(R,{marginBottom:1,children:[J(R,{width:25,children:Y(z,{color:h===`b`?`yellow`:`white`,children:[h===`b`?`❯ `:` `,`Blue (`,d.b,`):`]})}),J(R,{children:ne().map((e,t)=>J(ke,{children:t===A(d.b,255)?J(z,{children:`|`}):e},t))})]})]}),Y(R,{marginBottom:1,children:[J(z,{children:`Current: `}),J(z,{backgroundColor:D(),children:` `})]}),Y(R,{flexDirection:`row`,justifyContent:`space-between`,children:[Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Hex `}),a?.startsWith(`diff`)?J(z,{backgroundColor:D(),color:o?.colors?.text||`white`,bold:!0,children:O(d.r,d.g,d.b)}):a===`inverseText`?J(z,{color:D(),backgroundColor:o?.colors?.permission,bold:!0,children:O(d.r,d.g,d.b)}):J(z,{color:D(),bold:!0,children:O(d.r,d.g,d.b)})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`RGB `}),a?.startsWith(`diff`)?J(z,{backgroundColor:D(),color:o?.colors?.text||`white`,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):a===`inverseText`?J(z,{color:D(),backgroundColor:o?.colors?.permission,bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`}):J(z,{color:D(),bold:!0,children:`rgb(${d.r}, ${d.g}, ${d.b})`})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`HSL `}),a?.startsWith(`diff`)?J(z,{backgroundColor:D(),color:o?.colors?.text||`white`,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):a===`inverseText`?J(z,{color:D(),backgroundColor:o?.colors?.permission,bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`}):J(z,{color:D(),bold:!0,children:`hsl(${l.h}, ${l.s}%, ${l.l}%)`})]})]})]})}function ot(e){let t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(t)return{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])};let n=e.match(/^#([a-fA-F0-9]{6})$/);if(n){let e=n[1];return{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}return null}function st(e){let t=e.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(t)return{h:parseInt(t[1]),s:parseInt(t[2]),l:parseInt(t[3])};let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){let e=parseInt(n[1])/255,t=parseInt(n[2])/255,r=parseInt(n[3])/255,i=Math.max(e,t,r),a=Math.min(e,t,r),o=i-a,s=(i+a)/2,c=0;o!==0&&(c=s>.5?o/(2-i-a):o/(i+a));let l=0;return o!==0&&(l=i===e?((t-r)/o+(t<r?6:0))/6:i===t?((r-e)/o+2)/6:((e-t)/o+4)/6),{h:Math.round(l*360),s:Math.round(c*100),l:Math.round(s*100)}}let r=e.match(/^#([a-fA-F0-9]{6})$/);if(r){let e=r[1],t=parseInt(e.substr(0,2),16)/255,n=parseInt(e.substr(2,2),16)/255,i=parseInt(e.substr(4,2),16)/255,a=Math.max(t,n,i),o=Math.min(t,n,i),s=a-o,c=(a+o)/2,l=0;s!==0&&(l=c>.5?s/(2-a-o):s/(a+o));let u=0;return s!==0&&(u=a===t?((n-i)/s+(n<i?6:0))/6:a===n?((i-t)/s+2)/6:((t-n)/s+4)/6),{h:Math.round(u*360),s:Math.round(l*100),l:Math.round(c*100)}}return{h:0,s:50,l:50}}function ct({onBack:e,themeId:r}){let{settings:{themes:i},updateSettings:a}=H($),[o,s]=W(r),c=i.find(e=>e.id===o)||i[0],[l,u]=W(`rgb`),[f,p]=W(0),[m,h]=W(null),[g,_]=W(null),[v,y]=W(``),[b,x]=W(``),[S,C]=W(!1),[w,T]=W(0),ee=je(e=>{a(t=>{let n=t.themes.findIndex(e=>e.id===o);n!==-1&&e(t.themes[n])})},[o,a]),E=e=>{if(f>=2&&n(e)){let n=t(e),r=D[f-2];ee(e=>{e.colors[r]=n})}};B((t,n)=>{if(S){if(n.escape){C(!1),e();return}return}if(m===null&&g===null){if(t.length>1&&!n.ctrl&&!n.meta){E(t);return}if(n.escape)C(!0),T(0);else if(n.ctrl&&t===`a`)u(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(n.upArrow)p(e=>Math.max(0,e-1));else if(n.downArrow)p(e=>Math.min(D.length+1,e+1));else if(n.return)if(f===0)_(`name`),y(c.name),x(c.name);else if(f===1)_(`id`),y(c.id),x(c.id);else{let e=f-2,t=D[e],n=c.colors[t];h(e),y(n),x(n)}}else if(m!==null)n.ctrl&&t===`a`&&u(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(g!==null)if(n.return){if(g===`id`){let e=o;s(v),a(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=v)})}else ee(e=>{e.name=v});_(null),y(``),x(``)}else n.escape?(_(null),y(``),x(``)):n.backspace||n.delete?y(e=>e.slice(0,-1)):t&&y(e=>e+t)});let D=Object.keys(c.colors),O=(e,t)=>{let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)return e;let r=parseInt(n[1]),i=parseInt(n[2]),a=parseInt(n[3]);switch(t){case`hex`:{let e=e=>e.toString(16).padStart(2,`0`);return`#${e(r)}${e(i)}${e(a)}`}case`hsl`:{let e=r/255,t=i/255,n=a/255,o=Math.max(e,t,n),s=Math.min(e,t,n),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===e?((t-n)/c+(t<n?6:0))/6:o===t?((n-e)/c+2)/6:((e-t)/c+4)/6),`hsl(${Math.round(d*360)}, ${Math.round(u*100)}%, ${Math.round(l*100)}%)`}case`rgb`:default:return e}},te=e=>({autoAccept:`Auto-accept edits mode indicator`,bashBorder:`Bash command border`,claude:`Claude branding color. Used for the Claude logo, the welcome message, and the thinking text.`,claudeShimmer:`Color used for the shimmering effect on the thinking verb.`,claudeBlue_FOR_SYSTEM_SPINNER:`System spinner color (blue variant)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`System spinner shimmer color (blue variant)`,permission:`Permission prompt color`,permissionShimmer:`Permission prompt shimmer color`,planMode:`Plan mode indicator`,ide:`Color used for IDE-related messages.`,promptBorder:`Input prompt border color`,promptBorderShimmer:`Input prompt border shimmer color`,text:`Code color. Used in diffs.`,inverseText:`Inverse text color. Used for the text of tabs, where the background is filled in.`,inactive:`Inactive/dimmed text. Used for line numbers and less prominent text.`,subtle:`Subtle text. Used for help text and secondary information.`,suggestion:`Suggestion text color. Used for suggestions for theme names and various other things.`,remember:`Remember/note color. Used for various text relating to memories.`,background:`Background color for certain UI elements`,success:`Success indicator. Used for the bullet on successful tool calls, and various success messages (such as sign in successful).`,error:`Error indicator`,warning:`Warning indicator`,warningShimmer:`Warning shimmer color`,diffAdded:`Added diff background`,diffRemoved:`Removed diff background`,diffAddedDimmed:`Added diff background (dimmed)`,diffRemovedDimmed:`Removed diff background (dimmed)`,diffAddedWord:`Added word highlight`,diffRemovedWord:`Removed word highlight`,diffAddedWordDimmed:`Added word highlight (dimmed)`,diffRemovedWordDimmed:`Removed word highlight (dimmed)`,red_FOR_SUBAGENTS_ONLY:`Red color for sub agents`,blue_FOR_SUBAGENTS_ONLY:`Blue color for sub agents`,green_FOR_SUBAGENTS_ONLY:`Green color for sub agents`,yellow_FOR_SUBAGENTS_ONLY:`Yellow color for sub agents`,purple_FOR_SUBAGENTS_ONLY:`Purple color for sub agents`,orange_FOR_SUBAGENTS_ONLY:`Orange color for sub agents`,pink_FOR_SUBAGENTS_ONLY:`Pink color for sub agents`,cyan_FOR_SUBAGENTS_ONLY:`Cyan color for sub agents`,professionalBlue:`Professional blue color for business contexts?`,rainbow_red:`"ultrathink" rainbow - red`,rainbow_orange:`"ultrathink" rainbow - orange`,rainbow_yellow:`"ultrathink" rainbow - yellow`,rainbow_green:`"ultrathink" rainbow - green`,rainbow_blue:`"ultrathink" rainbow - blue`,rainbow_indigo:`"ultrathink" rainbow - indigo`,rainbow_violet:`"ultrathink" rainbow - violet`,rainbow_red_shimmer:`"ultrathink" rainbow (shimmer) - red`,rainbow_orange_shimmer:`"ultrathink" rainbow (shimmer) - orange`,rainbow_yellow_shimmer:`"ultrathink" rainbow (shimmer) - yellow`,rainbow_green_shimmer:`"ultrathink" rainbow (shimmer) - green`,rainbow_blue_shimmer:`"ultrathink" rainbow (shimmer) - blue`,rainbow_indigo_shimmer:`"ultrathink" rainbow (shimmer) - indigo`,rainbow_violet_shimmer:`"ultrathink" rainbow (shimmer) - violet`,clawd_body:`"Clawd" character body color`,clawd_background:`"Clawd" character background color`,userMessageBackground:`Background color for user messages`,bashMessageBackgroundColor:`Background color for bash command output`,memoryBackgroundColor:`Background color for memory/context information`,rate_limit_fill:`Rate limit indicator fill color`,rate_limit_empty:`Rate limit indicator empty/background color`})[e]||``,k=Math.max(...D.map(e=>e.length));return Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(X,{children:[`Editing theme “`,c.name,`” (`,c.id,`)`]})}),S?Y(R,{flexDirection:`column`,marginTop:1,children:[J(R,{marginBottom:1,children:Y(z,{bold:!0,children:[`Would you like to make “`,c.name,`” your current Claude Code theme?`]})}),J(qe,{items:[{name:`Yes`,desc:`Set ${c.id} as active theme`},{name:`No`,desc:`Go back without changing theme`}],selectedIndex:w,onSelect:T,onSubmit:()=>{w===0&&d(c.id),C(!1),e()}}),J(z,{dimColor:!0,children:`enter to select, esc to cancel`})]}):m===null&&g===null?Y(q,{children:[Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`enter to edit theme name, id, or color`}),J(z,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),J(z,{dimColor:!0,children:`paste color from clipboard (when on color)`}),J(z,{dimColor:!0,children:`esc to go back`})]}),f<2?Y(R,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[J(z,{bold:!0,children:f===0?`Theme Name`:`Theme ID`}),J(z,{children:f===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):Y(R,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:c.colors[D[f-2]],flexDirection:`column`,paddingLeft:1,children:[J(it,{colorKey:D[f-2],theme:c,bold:!0}),J(z,{children:te(D[f-2])})]}),Y(R,{flexDirection:`column`,children:[Y(R,{children:[J(z,{color:f===0?`yellow`:`white`,children:f===0?`❯ `:` `}),J(z,{bold:!0,children:`Name: `}),J(z,{children:c.name})]}),Y(R,{marginBottom:1,children:[J(z,{color:f===1?`yellow`:`white`,children:f===1?`❯ `:` `}),J(z,{bold:!0,children:`ID: `}),J(z,{children:c.id})]}),(()=>{if(f<2)return Y(q,{children:[D.slice(0,20).map((e,t)=>{let n=t+2;return Y(R,{children:[J(z,{color:f===n?`yellow`:`white`,children:f===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(it,{colorKey:e,theme:c,bold:!0})})}),J(Q,{color:c.colors[e],children:O(c.colors[e],l)})]},e)}),D.length>20&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let e=f-2,t=Math.max(0,e-10),n=Math.min(D.length,t+20),r=Math.max(0,n-20),i=D.slice(r,n);return Y(q,{children:[r>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,t)=>{let n=r+t+2;return Y(R,{children:[J(z,{color:f===n?`yellow`:`white`,children:f===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(it,{colorKey:e,theme:c,bold:!0})})}),J(Q,{color:c.colors[e],children:O(c.colors[e],l)})]},e)}),n<D.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-n,` more below`]})]})})()]})]}):g?Y(R,{flexDirection:`column`,marginTop:1,children:[Y(z,{children:[`Editing `,g===`name`?`theme name`:`theme ID`,`:`]}),J(R,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:J(z,{children:v})}),J(z,{dimColor:!0,children:`enter to save, esc to cancel`})]}):J(at,{initialValue:b,colorKey:D[m],theme:c,onColorChange:e=>{y(e),ee(t=>{t.colors[D[m]]=e})},onExit:()=>{ee(e=>{e.colors[D[m]]=v}),h(null),y(``),x(``)}})]}),J(R,{width:`50%`,children:J(rt,{theme:c})})]})}const lt=`https://raw.githubusercontent.com/Piebald-AI/claude-code-themes/main`,ut=`${lt}/index.json`,dt=2e4;async function ft(){N(`Fetching community theme index from ${ut}`);let e=await fetch(ut,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(dt)});if(!e.ok)throw Error(`Failed to fetch community theme index: ${e.status} ${e.statusText}`);return JSON.parse(await re(e))}async function pt(e){let t=`${lt}/themes/${e}.json`;N(`Fetching community theme from ${t}`);let n=await fetch(t,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(dt)});if(!n.ok)throw Error(`Failed to fetch community theme "${e}": ${n.status} ${n.statusText}`);return JSON.parse(await re(n))}function mt({onBack:e}){let{updateSettings:t}=H($),[n,r]=W({status:`loading`}),[i,a]=W(0),[o,s]=W(null),[c,l]=W(!1),[u,d]=W(null),f=Ne(0);U(()=>{ft().then(e=>{r({status:`loaded`,entries:e})}).catch(e=>{r({status:`error`,message:e.message})})},[]);let p=n.status===`loaded`?n.entries:[],m=je(async e=>{let t=++f.current;l(!0),d(null);try{let n=await pt(e);if(t!==f.current)return;s(ie(n,le))}catch{if(t!==f.current)return;s(null),d(`Failed to load preview.`)}finally{t===f.current&&l(!1)}},[]),h=je(async e=>{d(`Downloading theme…`);try{let n=ie(await pt(e.id),le),r=!1;t(e=>{e.themes.some(e=>e.id===n.id)||(e.themes.push(n),r=!0)}),d(r?`Added "${n.name}" to your themes!`:`Theme "${n.name}" (${n.id}) is already in your config.`)}catch{d(`Failed to download theme.`)}},[t]);return B((t,r)=>{if(r.escape){e();return}if(n.status!==`loaded`)return;let o=n.entries.length;if(o!==0){if(r.upArrow)a(e=>Math.max(0,e-1)),s(null),d(null);else if(r.downArrow)a(e=>Math.min(o-1,e+1)),s(null),d(null);else if(t===` `){let e=n.entries[i];e&&m(e.id)}else if(r.return){let e=n.entries[i];e&&h(e)}}}),n.status===`loading`?Y(R,{flexDirection:`column`,children:[J(X,{children:`Community Themes`}),J(z,{children:`Loading community themes…`})]}):n.status===`error`?Y(R,{flexDirection:`column`,children:[J(X,{children:`Community Themes`}),Y(z,{color:`red`,children:[`Error: `,n.message]}),J(z,{dimColor:!0,children:`esc to go back`})]}):Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(X,{children:`Community Themes`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`space to preview theme`}),J(z,{dimColor:!0,children:`enter to download theme`}),J(z,{dimColor:!0,children:`esc to go back`})]}),J(R,{flexDirection:`column`,children:p.map((e,t)=>Y(z,{color:i===t?`yellow`:void 0,children:[i===t?`❯ `:` `,e.name,` (`,e.id,`) by @`,e.author]},e.id))}),u&&J(R,{marginTop:1,children:J(z,{color:`cyan`,children:u})}),c&&J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`Loading preview…`})})]}),J(R,{width:`50%`,children:o?J(rt,{theme:o}):J(R,{flexDirection:`column`,justifyContent:`center`,alignItems:`center`,height:10,children:J(z,{dimColor:!0,children:`Press space to preview the selected theme.`})})})]})}function ht(e){return e.map(e=>`${e.name} (${e.id})`)}function gt({onBack:e}){let{settings:{themes:t},updateSettings:n}=H($),[r,i]=W(0),[a,o]=W(null),[s,c]=W(!0),[l,u]=W(!1),d=t.length+1,f=()=>{let e={colors:{...(t[0]||M.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};n(t=>{t.themes.push(e)}),o(e.id),c(!1)},p=e=>{t.length<=1||(n(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),r>=t.length-1&&i(Math.max(0,t.length-2)))},m=()=>{n(e=>{e.themes=[...M.themes]}),i(0)},h=r===t.length;if(B((n,a)=>{if(a.escape)e();else if(a.upArrow)i(e=>Math.max(0,e-1));else if(a.downArrow)i(e=>Math.min(d-1,e+1));else if(a.return)if(h)u(!0),c(!1);else{let e=t[r];e&&(o(e.id),c(!1))}else if(n===`n`)f();else if(n===`d`){if(!h){let e=t[r];e&&p(e.id)}}else a.ctrl&&n===`r`&&m()},{isActive:s}),l)return J(mt,{onBack:()=>{u(!1),c(!0)}});if(a)return J(ct,{themeId:a,onBack:()=>{o(null),c(!0)}});let g=ht(t),_=t.find(e=>g[r]?.includes(`(${e.id})`))||t[0];return t.length===0?J(R,{children:Y(R,{flexDirection:`column`,width:`100%`,children:[J(X,{children:`Themes`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new theme`}),J(z,{dimColor:!0,children:`esc to go back`})]}),J(z,{children:`No themes available!`})]})}):Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(X,{children:`Themes`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new theme`}),J(z,{dimColor:!0,children:`d to delete a theme`}),J(z,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),J(z,{dimColor:!0,children:`enter to edit theme`}),J(z,{dimColor:!0,children:`esc to go back`})]}),Y(R,{flexDirection:`column`,children:[g.map((e,t)=>Y(z,{color:r===t?`yellow`:void 0,children:[r===t?`❯ `:` `,e]},t)),Y(z,{color:h?`blue`:void 0,bold:h,children:[h?`❯ `:` `,`Browse community themes…`]})]})]}),J(R,{width:`50%`,children:h?J(R,{flexDirection:`column`,justifyContent:`center`,alignItems:`center`,height:10,children:J(z,{dimColor:!0,children:`Press enter to browse community themes.`})}):J(rt,{theme:_})})]})}function _t(e,t,n){let r=Math.max(0,e-Math.floor(n/2)),i=Math.min(t,r+n);return{start:Math.max(0,i-n),end:i}}function vt({onBack:e}){let{settings:{thinkingVerbs:{format:t,verbs:n},themes:r},updateSettings:i}=H($),a=[`format`,`verbs`],[o,s]=W(0),c=a[o],[l,u]=W(0),[d,f]=W(!1),[p,m]=W(``),[h,g]=W(!1),[_,v]=W(!1),[y,b]=W(t),x=me(),S=(r.find(e=>e.id===x)||r.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return B((r,o)=>{if(_){o.return?(i(e=>{e.thinkingVerbs.format=y}),v(!1)):o.escape?(b(t),v(!1)):o.backspace||o.delete?b(e=>e.slice(0,-1)):r&&b(e=>e+r);return}if(d||h){o.return&&p.trim()?(h?(i(e=>{e.thinkingVerbs.verbs.push(p.trim())}),g(!1)):(i(e=>{e.thinkingVerbs.verbs[l]=p.trim()}),f(!1)),m(``)):o.escape?(m(``),f(!1),g(!1)):o.backspace||o.delete?m(e=>e.slice(0,-1)):r&&m(e=>e+r);return}o.escape?e():o.return?c===`format`&&(b(t),v(!0)):o.tab?o.shift?s(e=>e===0?a.length-1:e-1):s(e=>e===a.length-1?0:e+1):o.upArrow?c===`verbs`&&n.length>0&&u(e=>e>0?e-1:n.length-1):o.downArrow?c===`verbs`&&n.length>0&&u(e=>e<n.length-1?e+1:0):r===`e`&&c===`verbs`?n.length>0&&(m(n[l]),f(!0)):r===`d`&&c===`verbs`?n.length>1&&(i(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==l)}),l>=n.length-1&&u(Math.max(0,n.length-2))):r===`n`&&c===`verbs`?(g(!0),m(``)):o.ctrl&&r===`r`&&c===`verbs`&&(i(e=>{e.thinkingVerbs.verbs=[...M.thinkingVerbs.verbs]}),u(0))}),Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[Y(R,{marginBottom:1,flexDirection:`column`,children:[J(X,{children:`Thinking Verbs`}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:c===`format`?`enter to edit format`:`changes auto-saved`}),J(z,{dimColor:!0,children:`esc to go back`}),J(z,{dimColor:!0,children:`tab to switch sections`})]})]}),J(R,{marginBottom:1,children:J(z,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(z,{color:c===`format`?`yellow`:void 0,children:c===`format`?`❯ `:` `}),J(z,{bold:!0,color:c===`format`?`yellow`:void 0,children:`Format`})]}),c===`format`&&(_?Y(z,{dimColor:!0,children:[` `,`enter to save`]}):Y(z,{dimColor:!0,children:[` `,`enter to edit`]}))]}),J(R,{marginLeft:2,marginBottom:1,children:J(R,{borderStyle:`round`,borderColor:_?`yellow`:`gray`,children:J(z,{children:_?y:t})})}),J(R,{children:Y(z,{children:[J(z,{color:c===`verbs`?`yellow`:void 0,children:c===`verbs`?`❯ `:` `}),J(z,{bold:!0,color:c===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),c===`verbs`&&J(R,{flexDirection:`column`,children:Y(z,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),J(R,{marginLeft:2,marginBottom:1,children:Y(R,{flexDirection:`column`,children:[(()=>{let{start:e,end:t}=_t(l,n.length,8),r=n.slice(e,t);return Y(q,{children:[e>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,e,` more above`]}),r.map((t,n)=>{let r=e+n;return Y(z,{color:c===`verbs`&&r===l?`cyan`:void 0,children:[c===`verbs`&&r===l?`❯ `:` `,t]},r)}),t<n.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,n.length-t,` more below`]})]})})(),h&&Y(R,{alignItems:`center`,children:[J(z,{color:`yellow`,children:`❯ `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:p})})]}),d&&Y(R,{marginTop:1,alignItems:`center`,children:[J(z,{children:`Editing: `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:p})})]})]})})]}),Y(R,{width:`50%`,flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,children:`Preview`})}),J(R,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:Y(z,{children:[Y(z,{color:S,children:[`✻ `,t.replace(/\{\}/g,n[l]??``),` `]}),J(z,{children:`(esc to interrupt)`})]})})]})]})}const yt=e=>e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/([A-Z])([A-Z][a-z])/g,`$1 $2`).replace(/(\d+)/g,` $1 `).replace(/\s+/g,` `).trim().replace(/^./,e=>e.toUpperCase()),bt=e=>{let t=Math.max(...e.map(e=>e.length));return e.map(e=>e.padEnd(t))},xt=Object.entries(Ue).map(([e,t])=>({name:yt(e),phases:t.frames.map(e=>e.trimEnd()),reverseMirror:!1,updateInterval:t.interval})),St=[{name:`Default`,phases:M.thinkingStyle.phases,reverseMirror:M.thinkingStyle.reverseMirror},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1},...xt];function Ct({onBack:e}){let{settings:{thinkingStyle:{phases:t,updateInterval:n,reverseMirror:r},themes:i},updateSettings:a}=H($),o=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[s,c]=W(0),l=o[s],[u,d]=W(0),[f,p]=W(0),[m,h]=W(!1),[g,_]=W(``),[v,y]=W(!1),[b,x]=W(!1),[S,C]=W(n.toString()),[w,T]=W(0),ee=me(),E=(i.find(e=>e.id===ee)||i.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;U(()=>{if(t.length>0){let e=r?[...t,...[...t].reverse().slice(1,-1)]:t,i=setInterval(()=>{T(t=>(t+1)%e.length)},n);return()=>clearInterval(i)}},[t,n,r]),U(()=>{d(e=>Math.min(e,Math.max(0,t.length-1)))},[t.length]),B((r,i)=>{if(b){if(i.return){let e=parseInt(S);!isNaN(e)&&e>0&&a(t=>{t.thinkingStyle.updateInterval=e}),x(!1)}else i.escape?(C(n.toString()),x(!1)):i.backspace||i.delete?C(e=>e.slice(0,-1)):r&&r.match(/^[0-9]$/)&&C(e=>e+r);return}if(m||v){if(i.return&&g.length){let e=v?[...t,g]:t.map((e,t)=>t===u?g:e);a(t=>{t.thinkingStyle.phases=bt(e)}),h(!1),_(``)}else i.escape?(_(``),h(!1),y(!1)):i.backspace||i.delete?_(e=>e.slice(0,-1)):r&&_(e=>e+r);return}if(i.escape)e();else if(i.return)if(l===`updateInterval`)C(n.toString()),x(!0);else if(l===`presets`){let e=St[f];a(t=>{t.thinkingStyle.phases=bt([...e.phases]),t.thinkingStyle.reverseMirror=e.reverseMirror,e.updateInterval!==void 0&&(t.thinkingStyle.updateInterval=e.updateInterval)})}else l===`reverseMirror`&&a(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(i.tab)i.shift?c(e=>e===0?o.length-1:e-1):c(e=>e===o.length-1?0:e+1);else if(i.upArrow)l===`phases`&&t.length>0?d(e=>e>0?e-1:t.length-1):l===`presets`&&p(e=>e>0?e-1:St.length-1);else if(i.downArrow)l===`phases`&&t.length>0?d(e=>e<t.length-1?e+1:0):l===`presets`&&p(e=>e<St.length-1?e+1:0);else if(r===` `)l===`reverseMirror`&&a(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(r===`e`&&l===`phases`)t.length>0&&(_(t[u]),h(!0));else if(r===`a`&&l===`phases`)y(!0),_(``);else if(r===`d`&&l===`phases`)t.length>1&&a(e=>{e.thinkingStyle.phases=bt(t.filter((e,t)=>t!==u))});else if(r===`w`&&l===`phases`){if(u>0){let e=[...t];[e[u-1],e[u]]=[e[u],e[u-1]],a(t=>{t.thinkingStyle.phases=e}),d(e=>e-1)}}else if(r===`s`&&l===`phases`){if(u<t.length-1){let e=[...t];[e[u],e[u+1]]=[e[u+1],e[u]],a(t=>{t.thinkingStyle.phases=e}),d(e=>e+1)}}else i.ctrl&&r===`r`&&(a(e=>{e.thinkingStyle=M.thinkingStyle}),d(0),p(0))});let D=r?`●`:`○`,O=(()=>r?[...t,...[...t].reverse().slice(1,-1)]:t)(),te=O.length>0?O[w]:`·`;return J(R,{children:Y(R,{flexDirection:`column`,width:`100%`,children:[Y(R,{flexDirection:`row`,width:`100%`,children:[Y(R,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[J(X,{children:`Thinking style`}),Y(R,{flexDirection:`column`,children:[Y(z,{dimColor:!0,children:[`enter to`,` `,l===`updateInterval`?`edit interval`:l===`presets`?`apply preset`:`save`]}),J(z,{dimColor:!0,children:`esc to go back`}),J(z,{dimColor:!0,children:`tab to switch sections`})]})]}),Y(R,{width:`50%`,flexDirection:`column`,children:[J(R,{children:J(z,{bold:!0,children:`Preview`})}),Y(R,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[J(R,{width:(te?.length??0)+1,children:J(z,{color:E,children:te})}),Y(z,{children:[J(z,{color:E,children:`Thinking… `}),J(z,{children:`(esc to interrupt)`})]})]})]})]}),Y(R,{flexDirection:`row`,gap:4,children:[Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(z,{color:l===`reverseMirror`?`yellow`:void 0,children:l===`reverseMirror`?`❯ `:` `}),J(z,{bold:!0,color:l===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),l===`reverseMirror`&&Y(z,{dimColor:!0,children:[` `,`space to toggle`]}),J(R,{marginLeft:2,marginBottom:1,children:Y(z,{children:[D,` `,r?`Enabled`:`Disabled`]})})]}),Y(R,{flexDirection:`column`,children:[Y(z,{children:[J(z,{color:l===`updateInterval`?`yellow`:void 0,children:l===`updateInterval`?`❯ `:` `}),J(z,{bold:!0,color:l===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),l===`updateInterval`&&(b?Y(z,{dimColor:!0,children:[` `,`enter to save`]}):Y(z,{dimColor:!0,children:[` `,`enter to edit`]})),J(R,{marginLeft:2,marginBottom:1,children:J(R,{borderStyle:`round`,borderColor:b?`yellow`:`gray`,children:J(z,{children:b?S:n})})})]})]}),J(R,{children:Y(z,{children:[J(z,{color:l===`phases`?`yellow`:void 0,children:l===`phases`?`❯ `:` `}),J(z,{bold:!0,color:l===`phases`?`yellow`:void 0,children:`Phases`})]})}),l===`phases`&&J(R,{marginBottom:1,flexDirection:`column`,children:Y(z,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),J(R,{marginLeft:2,marginBottom:1,children:Y(R,{flexDirection:`column`,children:[(()=>{let{start:e,end:n}=_t(u,t.length,8),r=t.slice(e,n);return Y(q,{children:[e>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,e,` more above`]}),r.map((t,n)=>{let r=e+n;return Y(z,{color:l===`phases`&&r===u?`cyan`:void 0,children:[l===`phases`&&r===u?`❯ `:` `,t]},r)}),n<t.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,t.length-n,` more below`]})]})})(),v&&Y(R,{children:[J(z,{color:`yellow`,children:`❯ `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:g})})]}),m&&Y(R,{marginTop:1,children:[J(z,{children:`Editing: `}),J(R,{borderStyle:`round`,borderColor:`yellow`,children:J(z,{children:g})})]})]})}),J(R,{children:Y(z,{children:[J(z,{color:l===`presets`?`yellow`:void 0,children:l===`presets`?`❯ `:` `}),J(z,{bold:!0,color:l===`presets`?`yellow`:void 0,children:`Presets`})]})}),l===`presets`&&Y(z,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases and interval`]}),J(R,{marginLeft:2,marginBottom:1,children:J(R,{flexDirection:`column`,children:(()=>{let{start:e,end:t}=_t(f,St.length,12),n=St.slice(e,t),r=e=>{let t=e.phases.join(``);return t.length>30?t.slice(0,27)+`…`:t};return Y(q,{children:[e>0&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↑ `,e,` more above`]}),n.map((t,n)=>{let i=e+n,a=l===`presets`&&i===f;return Y(z,{color:a?`cyan`:void 0,children:[a?`❯ `:` `,t.name,` `,r(t)]},i)}),t<St.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,St.length-t,` more below`]})]})})()})}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function wt(e,t){let n=Ne(!0);U(()=>{if(n.current){n.current=!1;return}return e()},t)}const Tt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Et=[{label:`none`,value:`none`},{label:`single`,value:`single`},{label:`double`,value:`double`},{label:`round`,value:`round`},{label:`bold`,value:`bold`},{label:`singleDouble`,value:`singleDouble`},{label:`doubleSingle`,value:`doubleSingle`},{label:`classic`,value:`classic`},{label:`topBottomSingle`,value:`topBottomSingle`},{label:`topBottomDouble`,value:`topBottomDouble`},{label:`topBottomBold`,value:`topBottomBold`}];function Dt({onBack:e}){let{settings:t,updateSettings:n}=H($),[r,i]=W(!1),[a,o]=W(!1),[s,c]=W(!1),[l,u]=W(()=>t.userMessageDisplay.format),[d,f]=W(()=>t.userMessageDisplay.paddingX===`default`?`default`:`custom`),[p,m]=W(()=>t.userMessageDisplay.paddingY===`default`?`default`:`custom`),[h,g]=W(()=>t.userMessageDisplay.paddingX===`default`?`0`:String(t.userMessageDisplay.paddingX)),[_,v]=W(()=>t.userMessageDisplay.paddingY===`default`?`0`:String(t.userMessageDisplay.paddingY)),[y,b]=W(t.userMessageDisplay.fitBoxToContent),[x,S]=W(0),[C,w]=W(()=>[...t.userMessageDisplay.styling]),[T,ee]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[E,D]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:t.userMessageDisplay.foregroundColor),[O,te]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[k,ne]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[A,re]=W(()=>Et.findIndex(e=>e.value===t.userMessageDisplay.borderStyle)),[j,ie]=W(()=>t.userMessageDisplay.borderColor),[ae,oe]=W(null),[se,N]=W(``),ce=me(),P=t.themes?.find(e=>e.id===ce)||t.themes?.[0],[F,I]=W(`text`),le=[`format`,`styling`,`foreground`,`background`],ue=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[de,fe]=W(0),[pe,he]=W(0),L=F===`text`?le[de]:ue[pe],ge=()=>{n(e=>{e.userMessageDisplay.format=l,e.userMessageDisplay.styling=[...C],e.userMessageDisplay.foregroundColor=T===`default`?`default`:E,e.userMessageDisplay.backgroundColor=O===`none`?null:O===`default`?`default`:k,e.userMessageDisplay.borderStyle=Et[A].value,e.userMessageDisplay.borderColor=j,e.userMessageDisplay.paddingX=d===`default`?`default`:parseInt(h)||0,e.userMessageDisplay.paddingY=p===`default`?`default`:parseInt(_)||0,e.userMessageDisplay.fitBoxToContent=y})},_e=()=>{u(M.userMessageDisplay.format),w([...M.userMessageDisplay.styling]);let e=M.userMessageDisplay.foregroundColor;ee(e===`default`?`default`:`custom`),D(e===`default`?`rgb(255,255,255)`:e);let t=M.userMessageDisplay.backgroundColor;te(t===null?`none`:t===`default`?`default`:`custom`),ne(t===null||t===`default`?`rgb(0,0,0)`:t),re(Et.findIndex(e=>e.value===M.userMessageDisplay.borderStyle)),ie(M.userMessageDisplay.borderColor);let r=M.userMessageDisplay.paddingX,i=M.userMessageDisplay.paddingY;f(r===`default`?`default`:`custom`),m(i===`default`?`default`:`custom`),g(r===`default`?`0`:String(r)),v(i===`default`?`0`:String(i)),b(M.userMessageDisplay.fitBoxToContent),n(e=>{e.userMessageDisplay={...M.userMessageDisplay}})};wt(()=>{ge()},[l,C,T,E,O,k,A,j,d,p,h,_,y]),B((n,l)=>{if(r){l.return?i(!1):l.escape?(u(t.userMessageDisplay.format),i(!1)):l.backspace||l.delete?u(e=>e.slice(0,-1)):n&&u(e=>e+n);return}if(a){l.return?o(!1):l.escape?(g(String(t.userMessageDisplay.paddingX)),o(!1)):l.backspace||l.delete?g(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&g(e=>e+n);return}if(s){l.return?c(!1):l.escape?(v(String(t.userMessageDisplay.paddingY)),c(!1)):l.backspace||l.delete?v(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&v(e=>e+n);return}if(ae===null){if(l.escape)e();else if(l.ctrl&&n===`r`)_e();else if(l.leftArrow||l.rightArrow)I(e=>e===`text`?`border`:`text`);else if(l.tab)F===`text`?l.shift?fe(e=>e===0?le.length-1:e-1):fe(e=>e===le.length-1?0:e+1):l.shift?he(e=>e===0?ue.length-1:e-1):he(e=>e===ue.length-1?0:e+1);else if(l.return)L===`format`?i(!0):L===`paddingX`?d===`custom`&&o(!0):L===`paddingY`?p===`custom`&&c(!0):L===`foreground`?T===`custom`&&(N(E),oe(`foreground`)):L===`background`?O===`custom`&&(N(k),oe(`background`)):L===`borderColor`&&(N(j),oe(`border`));else if(l.upArrow)L===`styling`?S(e=>Math.max(0,e-1)):L===`borderStyle`?re(e=>e===0?Et.length-1:e-1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?ee(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&te(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!k||k===``)&&ne(`rgb(0,0,0)`),t});else if(l.downArrow)L===`styling`?S(e=>Math.min(Tt.length-1,e+1)):L===`borderStyle`?re(e=>e===Et.length-1?0:e+1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?ee(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&te(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!k||k===``)&&ne(`rgb(0,0,0)`),t});else if(n===` `)if(L===`styling`){let e=Tt[x].value;w(C.indexOf(e)>=0?C.filter(t=>t!==e):[...C,e])}else L===`fitBoxToContent`&&b(e=>!e)}});let ve=e=>{let t=T===`default`?P?.colors?.text:E,n=O===`none`?void 0:O===`default`?P?.colors?.userMessageBackground:k,r=Et[A].value,i=d===`default`?0:parseInt(h)||0,a=p===`default`?0:parseInt(_)||0,o=d===`default`?1:i,s=J(z,{bold:C.includes(`bold`),italic:C.includes(`italic`),underline:C.includes(`underline`),strikethrough:C.includes(`strikethrough`),inverse:C.includes(`inverse`),color:t,backgroundColor:n,children:e});if(r===`topBottomSingle`||r===`topBottomDouble`||r===`topBottomBold`){let t=r===`topBottomSingle`?`─`:r===`topBottomDouble`?`═`:`━`,n=e.length+i*2,o=t.repeat(n);return Y(R,{flexDirection:`column`,children:[J(z,{color:j,children:o}),a>0&&J(R,{height:a}),J(R,{paddingX:i,children:s}),a>0&&J(R,{height:a}),J(z,{color:j,children:o})]})}else if(r!==`none`||i>0||a>0||o>0||y){let e={};i>0&&(e.paddingX=i),d===`default`&&i===0&&(e.paddingRight=o),a>0&&(e.paddingY=a);let t=Object.keys(e).length>0?J(R,{...e,children:s}):s,n={};return r!==`none`&&(n.borderStyle=r,n.borderColor=j),y?n.alignSelf=`flex-start`:n.flexGrow=1,r===`none`?t:J(R,{...n,children:t})}else return s};return ae?J(at,{initialValue:se,theme:P,onColorChange:e=>{ae===`foreground`?D(e):ae===`background`?ne(e):ae===`border`&&ie(e)},onExit:()=>{oe(null),N(``)}}):Y(R,{flexDirection:`column`,children:[J(X,{children:`Customize how user messages are displayed`}),Y(R,{flexDirection:`column`,marginBottom:1,children:[J(z,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),J(z,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),Y(R,{flexDirection:`row`,gap:1,children:[Y(R,{flexDirection:`column`,width:`50%`,borderStyle:F===`text`?`round`:`single`,borderColor:F===`text`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:F===`text`?`yellow`:void 0,children:`Text & Styling`})}),J(R,{children:Y(z,{color:L===`format`?`yellow`:void 0,bold:L===`format`,children:[L===`format`?`❯ `:` `,`Format String`]})}),L===`format`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:r?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),J(R,{marginLeft:2,marginBottom:1,children:J(R,{borderStyle:`round`,borderColor:r?`yellow`:`gray`,children:J(z,{children:l})})}),J(R,{children:Y(z,{color:L===`styling`?`yellow`:void 0,bold:L===`styling`,children:[L===`styling`?`❯ `:` `,`Styling`]})}),L===`styling`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),J(R,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Tt.map((e,t)=>J(R,{children:Y(z,{color:L===`styling`&&x===t?`cyan`:void 0,children:[L===`styling`&&x===t?`❯ `:` `,C.includes(e.value)?`●`:`○`,` `,e.label]})},e.value))}),Y(R,{flexDirection:`row`,gap:1,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(z,{color:L===`foreground`?`yellow`:void 0,bold:L===`foreground`,children:[L===`foreground`?`❯ `:` `,`Foreground`]})}),L===`foreground`&&J(R,{marginLeft:2,children:Y(z,{dimColor:!0,children:[`up/down · `,T===`custom`?`enter`:``]})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[T===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[T===`custom`?`● `:`○ `,`Custom`,T===`custom`&&`: `,T===`custom`&&J(z,{color:E,children:E})]})})]})]}),Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(z,{color:L===`background`?`yellow`:void 0,bold:L===`background`,children:[L===`background`?`❯ `:` `,`Background`]})}),L===`background`&&J(R,{marginLeft:2,children:Y(z,{dimColor:!0,children:[`up/down · `,O===`custom`?`enter`:``]})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[O===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[O===`none`?`● `:`○ `,`None`]})}),J(R,{children:Y(z,{children:[O===`custom`?`● `:`○ `,`Custom`,O===`custom`&&`: `,O===`custom`&&J(z,{backgroundColor:k,children:k})]})})]})]})]})]}),Y(R,{flexDirection:`column`,width:`50%`,borderStyle:F===`border`?`round`:`single`,borderColor:F===`border`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:F===`border`?`yellow`:void 0,children:`Border & Padding`})}),J(R,{children:Y(z,{color:L===`borderStyle`?`yellow`:void 0,bold:L===`borderStyle`,children:[L===`borderStyle`?`❯ `:` `,`Border Style`]})}),L===`borderStyle`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`up/down to navigate`})}),Y(R,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[J(R,{flexDirection:`column`,width:`50%`,children:Et.slice(0,6).map((e,t)=>J(R,{children:Y(z,{color:L===`borderStyle`&&A===t?`cyan`:void 0,children:[L===`borderStyle`&&A===t?`❯ `:` `,A===t?`● `:`○ `,e.label]})},e.value))}),J(R,{flexDirection:`column`,width:`50%`,children:Et.slice(6).map((e,t)=>{let n=t+6;return J(R,{children:Y(z,{color:L===`borderStyle`&&A===n?`cyan`:void 0,children:[L===`borderStyle`&&A===n?`❯ `:` `,A===n?`● `:`○ `,e.label]})},e.value)})})]}),J(R,{children:Y(z,{color:L===`borderColor`?`yellow`:void 0,bold:L===`borderColor`,children:[L===`borderColor`?`❯ `:` `,`Border Color`]})}),L===`borderColor`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`enter to pick color`})}),J(R,{marginLeft:2,marginBottom:1,children:J(z,{color:j,children:j})}),Y(R,{flexDirection:`row`,gap:1,children:[Y(R,{flexDirection:`column`,width:`33%`,children:[J(R,{children:Y(z,{color:L===`paddingX`?`yellow`:void 0,bold:L===`paddingX`,children:[L===`paddingX`?`❯ `:` `,`Padding X`]})}),L===`paddingX`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:a?`enter/esc`:d===`custom`?`up/down · enter`:`up/down`})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[d===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[d===`custom`?`● `:`○ `,`Custom`]})}),d===`custom`&&J(R,{children:J(R,{borderStyle:`round`,borderColor:a?`yellow`:`gray`,children:J(z,{children:h})})})]})]}),Y(R,{flexDirection:`column`,width:`33%`,children:[J(R,{children:Y(z,{color:L===`paddingY`?`yellow`:void 0,bold:L===`paddingY`,children:[L===`paddingY`?`❯ `:` `,`Padding Y`]})}),L===`paddingY`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:s?`enter/esc`:p===`custom`?`up/down · enter`:`up/down`})}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{children:Y(z,{children:[p===`default`?`● `:`○ `,`Default`]})}),J(R,{children:Y(z,{children:[p===`custom`?`● `:`○ `,`Custom`]})}),p===`custom`&&J(R,{children:J(R,{borderStyle:`round`,borderColor:s?`yellow`:`gray`,children:J(z,{children:_})})})]})]}),Y(R,{flexDirection:`column`,width:`33%`,children:[J(R,{children:Y(z,{color:L===`fitBoxToContent`?`yellow`:void 0,bold:L===`fitBoxToContent`,children:[L===`fitBoxToContent`?`❯ `:` `,y?`●`:`○`,` Fit box to content`]})}),L===`fitBoxToContent`&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`space`})})]})]})]})]}),Y(R,{flexDirection:`column`,marginTop:1,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,children:`Preview`})}),Y(R,{flexDirection:`row`,gap:2,children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{marginBottom:1,children:J(z,{underline:!0,children:`Before (Claude Code default):`})}),J(R,{marginLeft:1,children:Y(z,{backgroundColor:P?.colors?.userMessageBackground,color:P?.colors?.text,children:[` `,`> list the dir`,` `]})}),J(R,{marginLeft:1,marginTop:1,children:Y(z,{children:[J(z,{color:P?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:P?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(z,{children:` contains `}),J(z,{bold:!0,children:`123`}),J(z,{children:` files.`})]})})]}),Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{marginBottom:1,children:J(z,{underline:!0,children:`After (Your customization):`})}),J(R,{marginLeft:1,flexDirection:`row`,children:(()=>ve(l.replace(/\{\}/g,`list the dir`)))()}),J(R,{marginLeft:1,marginTop:1,children:Y(z,{children:[J(z,{color:P?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:P?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(z,{children:` contains `}),J(z,{bold:!0,children:`123`}),J(z,{children:` files.`})]})})]})]})]})]})}const Ot=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],kt=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function At({testText:e,regex:t,regexFlags:n,format:r,styling:i,foregroundColor:a,backgroundColor:o}){let s=[];try{let c=n.includes(`g`)?n:n+`g`,l=new RegExp(t,c),u=[...e.matchAll(l)];if(u.length===0)return J(z,{children:e});let d=0;return u.forEach((t,n)=>{let c=t.index,l=c+t[0].length;c>d&&s.push(J(z,{children:e.slice(d,c)},`plain-${n}`));let u=r.replace(/\{MATCH\}/g,t[0]);s.push(J(z,{bold:i.includes(`bold`),italic:i.includes(`italic`),underline:i.includes(`underline`),strikethrough:i.includes(`strikethrough`),inverse:i.includes(`inverse`),color:a,backgroundColor:o,children:u},`match-${n}`)),d=l}),d<e.length&&s.push(J(z,{children:e.slice(d)},`plain-end`)),J(q,{children:s})}catch{return J(z,{children:e})}}function jt({highlighterIndex:e,onBack:t}){let{settings:n,updateSettings:r}=H($),i=n.inputPatternHighlighters[e],a=me(),o=n.themes?.find(e=>e.id===a)||n.themes?.[0],[s,c]=W(i?.name||`New Highlighter`),[l,u]=W(i?.regex||``),[d,f]=W(i?.regexFlags||`g`),[p,m]=W(i?.format||`{MATCH}`),[h,g]=W(i?.styling||[]),[_,v]=W(i?.foregroundColor===null?`none`:`custom`),[y,b]=W(i?.foregroundColor||`rgb(255,0,255)`),[x,S]=W(i?.backgroundColor?`custom`:`none`),[C,w]=W(i?.backgroundColor||`rgb(0,0,0)`),[T,ee]=W(i?.enabled??!0),[E,D]=W(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[O,te]=W(`name`),[k,ne]=W(!1),[A,re]=W(0),[j,ie]=W(null),[ae,oe]=W(``),[se,M]=W(null),[N,ce]=W(0),[P,F]=W(0);if(U(()=>{let e=kt[N];te(e[Math.min(P,e.length-1)])},[N,P]),U(()=>{if(!l){M(null);return}try{new RegExp(l,d),M(null)}catch(e){M(e.message)}},[l,d]),U(()=>{e>=0&&r(t=>{t.inputPatternHighlighters[e]&&(t.inputPatternHighlighters[e]={name:s,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?y:null,backgroundColor:x===`custom`?C:null,enabled:T})})},[e,s,l,d,p,h,_,y,x,C,T]),U(()=>{r(e=>{e.inputPatternHighlightersTestText=E})},[E]),B((e,r)=>{if(k){r.return?ne(!1):r.escape?(O===`name`&&c(i?.name||``),O===`regex`&&u(i?.regex||``),O===`regexFlags`&&f(i?.regexFlags||`g`),O===`format`&&m(i?.format||`{MATCH}`),O===`testText`&&D(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),ne(!1)):r.backspace||r.delete?(O===`name`&&c(e=>e.slice(0,-1)),O===`regex`&&u(e=>e.slice(0,-1)),O===`regexFlags`&&f(e=>e.slice(0,-1)),O===`format`&&m(e=>e.slice(0,-1)),O===`testText`&&D(e=>e.slice(0,-1))):e&&e.length===1&&(O===`name`&&c(t=>t+e),O===`regex`&&u(t=>t+e),O===`regexFlags`&&f(t=>t+e),O===`format`&&m(t=>t+e),O===`testText`&&D(t=>t+e));return}if(j===null){if(r.escape)t();else if(r.upArrow)O===`styling`&&A>0?re(e=>e-1):ce(e=>Math.max(0,e-1));else if(r.downArrow)O===`styling`&&A<Ot.length-1?re(e=>e+1):ce(e=>Math.min(kt.length-1,e+1));else if(r.leftArrow)O===`foreground`?v(e=>e===`none`?`custom`:`none`):O===`background`?S(e=>e===`none`?`custom`:`none`):F(e=>Math.max(0,e-1));else if(r.rightArrow)if(O===`foreground`)v(e=>e===`none`?`custom`:`none`);else if(O===`background`)S(e=>e===`none`?`custom`:`none`);else{let e=kt[N].length-1;F(t=>Math.min(e,t+1))}else if(r.tab){let e=kt.flat(),t=e.indexOf(O);if(r.shift){if(t>0){let n=e[t-1];for(let e=0;e<kt.length;e++){let t=kt[e].indexOf(n);if(t>=0){ce(e),F(t);break}}}}else if(t<e.length-1){let n=e[t+1];for(let e=0;e<kt.length;e++){let t=kt[e].indexOf(n);if(t>=0){ce(e),F(t);break}}}}else if(r.return)O===`name`||O===`regex`||O===`regexFlags`||O===`format`||O===`testText`?ne(!0):O===`foreground`&&_===`custom`?(oe(y),ie(`foreground`)):O===`background`&&x===`custom`&&(oe(C),ie(`background`));else if(e===` `)if(O===`styling`){let e=Ot[A].value;h.includes(e)?g(h.filter(t=>t!==e)):g([...h,e])}else O===`enabled`&&ee(!T)}}),!i)return J(R,{flexDirection:`column`,children:J(z,{color:`red`,children:`Highlighter not found`})});if(j)return J(at,{initialValue:ae,theme:o,onColorChange:e=>{j===`foreground`?b(e):j===`background`&&w(e)},onExit:()=>{ie(null),oe(``)}});let I=e=>O===e,le=e=>({color:I(e)?`yellow`:void 0,bold:I(e)});return Y(R,{flexDirection:`column`,children:[J(X,{children:`Edit Highlighter`}),J(R,{marginBottom:1,flexDirection:`column`,children:J(z,{dimColor:!0,children:`arrows to navigate · enter to edit · space to toggle · esc to go back`})}),Y(R,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`30%`,children:[Y(z,{...le(`name`),children:[I(`name`)?`❯ `:` `,`Name`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`name`)?k?`green`:`yellow`:`gray`,children:J(z,{children:s||`(empty)`})})})]}),Y(R,{flexDirection:`column`,width:`45%`,children:[Y(z,{...le(`regex`),children:[I(`regex`)?`❯ `:` `,`Regex Pattern`]}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{borderStyle:`round`,borderColor:I(`regex`)?k?`green`:`yellow`:se?`red`:`gray`,children:J(z,{children:l||`(empty)`})}),se&&J(z,{color:`red`,children:se})]})]}),Y(R,{flexDirection:`column`,width:`20%`,children:[Y(z,{...le(`regexFlags`),children:[I(`regexFlags`)?`❯ `:` `,`Flags`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`regexFlags`)?k?`green`:`yellow`:`gray`,children:J(z,{children:d||`g`})})})]})]}),Y(R,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`50%`,children:[Y(z,{...le(`format`),children:[I(`format`)?`❯ `:` `,`Format String`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`format`)?k?`green`:`yellow`:`gray`,children:J(z,{children:p||`{MATCH}`})})}),I(`format`)&&J(R,{marginLeft:2,children:Y(z,{dimColor:!0,children:[`use `,`{MATCH}`,` as placeholder`]})})]}),Y(R,{flexDirection:`column`,width:`45%`,children:[Y(z,{...le(`styling`),children:[I(`styling`)?`❯ `:` `,`Styling`]}),J(R,{marginLeft:2,flexDirection:`column`,children:Ot.map((e,t)=>{let n=h.includes(e.value),r=I(`styling`)&&A===t;return Y(z,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,n?`●`:`○`,` `,e.label]},e.value)})})]})]}),Y(R,{flexDirection:`row`,gap:2,marginBottom:1,children:[Y(R,{flexDirection:`column`,width:`48%`,children:[Y(z,{...le(`foreground`),children:[I(`foreground`)?`❯ `:` `,`Foreground Color`]}),Y(R,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(z,{color:I(`foreground`)?`yellow`:void 0,children:[`[`,_===`none`?`●`:`○`,`] none`,` `,`[`,_===`custom`?`●`:`○`,`] custom`]}),_===`custom`&&J(R,{borderStyle:`round`,borderColor:I(`foreground`)?`yellow`:`gray`,children:J(z,{color:y,children:` ████ `})})]})]}),Y(R,{flexDirection:`column`,width:`48%`,children:[Y(z,{...le(`background`),children:[I(`background`)?`❯ `:` `,`Background Color`]}),Y(R,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(z,{color:I(`background`)?`yellow`:void 0,children:[`[`,x===`none`?`●`:`○`,`] none`,` `,`[`,x===`custom`?`●`:`○`,`] custom`]}),x===`custom`&&J(R,{borderStyle:`round`,borderColor:I(`background`)?`yellow`:`gray`,children:Y(z,{backgroundColor:C,children:[` `,` `,` `]})})]})]})]}),J(R,{marginBottom:1,children:Y(z,{...le(`enabled`),children:[I(`enabled`)?`❯ `:` `,`Enabled:`,` `,J(z,{color:T?`green`:`red`,children:T?`● Yes`:`○ No`})]})}),Y(R,{flexDirection:`column`,marginBottom:1,children:[Y(z,{...le(`testText`),children:[I(`testText`)?`❯ `:` `,`Test Text`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`testText`)?k?`green`:`yellow`:`gray`,children:J(z,{children:E||`(empty)`})})})]}),J(R,{borderStyle:`round`,padding:1,children:Y(R,{flexDirection:`column`,children:[J(z,{bold:!0,children:`Live Preview:`}),l?J(R,{marginTop:1,children:J(At,{testText:E,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?y:void 0,backgroundColor:x===`custom`?C:void 0})}):J(z,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function Mt({onBack:e}){let{settings:{inputPatternHighlighters:t,themes:n},updateSettings:r}=H($),i=me(),a=n.find(e=>e.id===i)||n[0],o=M.themes[0],s=a?.colors.success||o.colors.success,c=a?.colors.error||o.colors.error,[l,u]=W(0),[d,f]=W(null),[p,m]=W(!0),h=()=>{let e={name:`New Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:`rgb(255,0,255)`,backgroundColor:null,enabled:!0};r(t=>{t.inputPatternHighlighters.push(e)}),f(t.length),m(!1)},g=e=>{r(t=>{t.inputPatternHighlighters.splice(e,1)}),l>=t.length-1&&u(Math.max(0,t.length-2))},_=e=>{r(t=>{t.inputPatternHighlighters[e].enabled=!t.inputPatternHighlighters[e].enabled})},v=e=>{e<=0||(r(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e-1,0,n)}),u(e-1))},y=e=>{e>=t.length-1||(r(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e+1,0,n)}),u(e+1))};return B((n,r)=>{r.escape?e():r.upArrow?u(e=>Math.max(0,e-1)):r.downArrow&&t.length>0?u(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(f(l),m(!1)):n===`n`?h():n===`x`&&t.length>0?g(l):n===` `&&t.length>0?_(l):n===`u`&&t.length>0&&l>0?v(l):n===`d`&&t.length>0&&l<t.length-1&&y(l)},{isActive:p}),d===null?Y(R,{flexDirection:`column`,children:[J(X,{children:`Input Pattern Highlighters`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Create custom highlighters for patterns in your input prompt.`}),J(z,{dimColor:!0,children:`Matched text will be styled and optionally reformatted.`})]}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new highlighter`}),t.length>0&&J(z,{dimColor:!0,children:`space to toggle enabled/disabled`}),t.length>0&&J(z,{dimColor:!0,children:`u/d to move highlighter up/down`}),t.length>0&&J(z,{dimColor:!0,children:`x to delete a highlighter`}),t.length>0&&J(z,{dimColor:!0,children:`enter to edit highlighter`}),J(z,{dimColor:!0,children:`esc to go back`})]}),t.length===0?J(z,{children:`No highlighters created yet. Press n to create one.`}):J(R,{flexDirection:`column`,children:t.map((e,t)=>{let n=l===t,r;return n&&(r=`yellow`),Y(R,{flexDirection:`row`,children:[Y(z,{color:r,children:[n?`❯ `:` `,e.enabled?`● `:`○ `,e.name,` `]}),J(z,{dimColor:!0,children:`(`}),e.regex?Y(z,{dimColor:!0,children:[`/`,e.regex,`/`,e.regexFlags]}):J(z,{dimColor:!0,children:`(no regex)`}),e.styling.length>0&&J(q,{children:Y(z,{color:r,dimColor:!e.enabled,children:[` `,`· `,e.styling.join(`, `)]})}),J(z,{dimColor:!0,children:`)`}),e.enabled?J(z,{color:s,children:` enabled`}):J(z,{color:c,children:` disabled`})]},t)})})]}):J(jt,{highlighterIndex:d,onBack:()=>{f(null),m(!0)}})}const Nt=[null,1,5,10,25,50,100,200,250,500,1e3],Pt=1e3;function Ft({onSubmit:e}){let{settings:t,updateSettings:n}=H($),[r,i]=W(0),[a,o]=W(!1),s={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1,mcpConnectionNonBlocking:!0,mcpServerBatchSize:null,statuslineThrottleMs:null,statuslineUseFixedInterval:!1,tableFormat:`default`,enableSessionMemory:!0,enableDreamMode:!0,enableLeanMemoryTypes:!1,fixSummarizeFromHere:!0,fixRewindSummaryHeader:!0,enableRememberSkill:!1,tokenCountRounding:null,autoAcceptPlanMode:!1,allowBypassPermissionsInSudo:!1,suppressNativeInstallerWarning:!1,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,swapRipgrepForFff:!1,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autonomousOperationAllModels:!1,adhdOutputStyle:!1,autoModeClassifierModel:`default`,suppressDeferredTools:!1,claudemdContextOncePerConversation:!0},c=()=>{t.misc||={...s}},l=e=>{let t=[`default`,`sonnet`,`haiku`];return t[(t.indexOf(e)+1)%t.length]},u=e=>{switch(e){case`sonnet`:return`Sonnet 4.6`;case`haiku`:return`Haiku 4.5`;case`default`:default:return`Default (main-loop model)`}},d=e=>{let t=[`default`,`ascii`,`clean`,`clean-top-bottom`];return t[(t.indexOf(e)+1)%t.length]},f=e=>{switch(e){case`ascii`:return`ASCII (| and -)`;case`clean`:return`Clean (no row separators)`;case`clean-top-bottom`:return`Clean with top/bottom`;case`default`:default:return`Default (box-drawing)`}},p=e=>e===null?`Default (3)`:e<=3?`${e} (conservative)`:e<=8?`${e} (recommended)`:`${e} (aggressive)`,m=e=>e===null?`Disabled`:e===0?`0ms (instant)`:`${e}ms`,h=e=>e===null?`Off (exact counts)`:`Round to ${e}`,g=(e,t)=>{let n=Nt.indexOf(e);if(n===-1)return Nt[0];let r;return r=t===`next`?(n+1)%Nt.length:(n-1+Nt.length)%Nt.length,Nt[r]},_=Me(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>t.inputBox?.removeBorder??!1,toggle:()=>{n(e=>{e.inputBox||={removeBorder:!1},e.inputBox.removeBorder=!e.inputBox.removeBorder})}},{id:`showVersion`,title:`Show tweakcc version at startup`,description:`Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.`,getValue:()=>t.misc?.showTweakccVersion??!0,toggle:()=>{n(e=>{c(),e.misc.showTweakccVersion=!e.misc.showTweakccVersion})}},{id:`showPatches`,title:`Show patches applied indicator at startup`,description:`Shows the green "tweakcc patches are applied" indicator when starting Claude Code.`,getValue:()=>t.misc?.showPatchesApplied??!0,toggle:()=>{n(e=>{c(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>t.misc?.expandThinkingBlocks??!0,toggle:()=>{n(e=>{c(),e.misc.expandThinkingBlocks=!e.misc.expandThinkingBlocks})}},{id:`conversationTitle`,title:`Allow renaming sessions via /title`,description:`Enables /title and /rename commands for manually naming conversations.`,getValue:()=>t.misc?.enableConversationTitle??!0,toggle:()=>{n(e=>{c(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`enableModelCustomizations`,title:`Enable model customizations (/model shows all models)`,description:`Show all Claude models in /model menu, not just the latest 3. Disable to use Claude Code default model list.`,getValue:()=>t.misc?.enableModelCustomizations??!0,toggle:()=>{n(e=>{c(),e.misc.enableModelCustomizations=!e.misc.enableModelCustomizations})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>t.misc?.hideStartupBanner??!1,toggle:()=>{n(e=>{c(),e.misc.hideStartupBanner=!e.misc.hideStartupBanner})}},{id:`hideCtrlG`,title:`Hide ctrl-g to edit prompt hint`,description:`Hides the "ctrl-g to edit prompt" hint shown during streaming.`,getValue:()=>t.misc?.hideCtrlGToEdit??!1,toggle:()=>{n(e=>{c(),e.misc.hideCtrlGToEdit=!e.misc.hideCtrlGToEdit})}},{id:`hideClawd`,title:`Hide startup Clawd ASCII art`,description:`Hides the Clawd ASCII art character shown at startup.`,getValue:()=>t.misc?.hideStartupClawd??!1,toggle:()=>{n(e=>{c(),e.misc.hideStartupClawd=!e.misc.hideStartupClawd})}},{id:`increaseFileReadLimit`,title:`Increase file read token limit`,description:`Increases the maximum file read limit from 25,000 to 1,000,000 tokens.`,getValue:()=>t.misc?.increaseFileReadLimit??!1,toggle:()=>{n(e=>{c(),e.misc.increaseFileReadLimit=!e.misc.increaseFileReadLimit})}},{id:`suppressLineNumbers`,title:`Suppress line numbers in file reads/edits`,description:`Removes line number prefixes from file content to reduce token usage.`,getValue:()=>t.misc?.suppressLineNumbers??!1,toggle:()=>{n(e=>{c(),e.misc.suppressLineNumbers=!e.misc.suppressLineNumbers})}},{id:`suppressRateLimitOptions`,title:`Suppress rate limit options popup`,description:`Prevents the automatic /rate-limit-options command from being triggered when hitting rate limits.`,getValue:()=>t.misc?.suppressRateLimitOptions??!1,toggle:()=>{n(e=>{c(),e.misc.suppressRateLimitOptions=!e.misc.suppressRateLimitOptions})}},{id:`mcpNonBlocking`,title:`Non-blocking MCP startup`,description:`Start immediately while MCP servers connect in background. Reduces startup time ~50% with multiple MCPs.`,getValue:()=>t.misc?.mcpConnectionNonBlocking??!0,toggle:()=>{n(e=>{c(),e.misc.mcpConnectionNonBlocking=!e.misc.mcpConnectionNonBlocking})}},{id:`mcpBatchSize`,title:`MCP server batch size`,description:`Parallel MCP connections (1-20). Use ←/→ to adjust. Higher = faster startup, more resources.`,getValue:()=>t.misc?.mcpServerBatchSize??null,getDisplayValue:()=>p(t.misc?.mcpServerBatchSize??null),toggle:()=>{n(e=>{c(),e.misc.mcpServerBatchSize=null})},increment:()=>{n(e=>{c();let t=e.misc.mcpServerBatchSize??3;e.misc.mcpServerBatchSize=Math.min(20,t+1)})},decrement:()=>{n(e=>{c();let t=(e.misc.mcpServerBatchSize??3)-1;e.misc.mcpServerBatchSize=t<1?null:t})}},{id:`tableFormat`,title:`Table output format`,description:`Controls how Claude formats tables. Default: full borders. ASCII: | and -. Clean: no top/bottom/row separators. Clean+top/bottom: borders but no row separators.`,getValue:()=>t.misc?.tableFormat??`default`,isMultiValue:!0,getDisplayValue:()=>f(t.misc?.tableFormat??`default`),toggle:()=>{n(e=>{c(),e.misc.tableFormat=d(e.misc.tableFormat??`default`)})}},{id:`enableWorktreeMode`,title:`Enable worktree mode (EnterWorktree tool)`,description:`Force-enable the EnterWorktree tool for isolated git worktree sessions by bypassing the tengu_worktree_mode feature flag.`,getValue:()=>t.misc?.enableWorktreeMode??!0,toggle:()=>{n(e=>{c(),e.misc.enableWorktreeMode=!e.misc.enableWorktreeMode})}},{id:`swapRipgrepForFff`,title:`[EXPERIMENTAL] fff for Bash search (grep/find/rg -> fff)`,description:`Route Claude Code's Bash search through fff. CC shadows the shell grep->embedded ugrep and find->embedded bfs (and offers rg); the agent uses grep far more than rg. This repoints all three at a per-platform fff wrapper that serves (relevance-ranked, warm-index daemon): literal, regex (RE2, the dialect the model writes), -i, multi-word phrases, context (-A/-B/-C), extension globs (-g/--include '*.ts'), and multi-path (app lib scripts). Anything fff can't serve faithfully (PCRE, multiline/newline/empty regex, -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 intent. Transparent (no prompt-compliance reliance), CC-scoped (your own terminal grep/find/rg are untouched). Installs the wrapper into ~/.tweakcc/fff.`,getValue:()=>t.misc?.swapRipgrepForFff??!1,toggle:()=>{n(e=>{c(),e.misc.swapRipgrepForFff=!e.misc.swapRipgrepForFff})}},{id:`enableVoiceMode`,title:`Enable voice mode (/voice command)`,description:`Force-enable the /voice command by bypassing the tengu_amber_quartz feature gate.`,getValue:()=>t.misc?.enableVoiceMode??!1,toggle:()=>{n(e=>{c(),e.misc.enableVoiceMode=!e.misc.enableVoiceMode})}},{id:`enableVoiceConciseOutput`,title:`Enable concise output for voice mode`,description:`Enable the concise-output prompt used for voice interactions. Only applies when voice mode is enabled.`,getValue:()=>t.misc?.enableVoiceConciseOutput??!0,toggle:()=>{n(e=>{c(),e.misc.enableVoiceConciseOutput=!e.misc.enableVoiceConciseOutput})}},{id:`enableChannelsMode`,title:`Enable channels mode (MCP channel notifications)`,description:`Force-enable MCP channel notifications by bypassing the tengu_harbor feature gate, allowlist, and permission relay.`,getValue:()=>t.misc?.enableChannelsMode??!1,toggle:()=>{n(e=>{c(),e.misc.enableChannelsMode=!e.misc.enableChannelsMode})}},{id:`enableContextLimitOverride`,title:`Override context limit`,description:`Replaces the default model context limit with CLAUDE_CODE_CONTEXT_LIMIT env var. Must be exported manually before launching CC, or falls back to 200K.`,getValue:()=>t.misc?.enableContextLimitOverride??!1,toggle:()=>{n(e=>{c(),e.misc.enableContextLimitOverride=!e.misc.enableContextLimitOverride})}},{id:`statuslineThrottle`,title:`Statusline throttle`,description:`Throttle statusline updates (0-${Pt}ms). Use ←/→ to adjust by 50ms. Space to disable. 0 = instant updates.`,getValue:()=>t.misc?.statuslineThrottleMs??null,getDisplayValue:()=>m(t.misc?.statuslineThrottleMs??null),toggle:()=>{n(e=>{c(),e.misc.statuslineThrottleMs=e.misc.statuslineThrottleMs===null?300:null})},increment:()=>{n(e=>{c();let t=e.misc.statuslineThrottleMs??300;e.misc.statuslineThrottleMs=Math.min(Pt,t+50)})},decrement:()=>{n(e=>{c();let t=e.misc.statuslineThrottleMs??300;e.misc.statuslineThrottleMs=Math.max(0,t-50)})}},{id:`statuslineFixedInterval`,title:`Statusline fixed interval mode`,description:`Use setInterval instead of throttle. Updates happen on a fixed schedule rather than on-demand.`,getValue:()=>t.misc?.statuslineUseFixedInterval??!1,toggle:()=>{n(e=>{c(),e.misc.statuslineUseFixedInterval=!e.misc.statuslineUseFixedInterval})}},{id:`enableSessionMemory`,title:`Enable session memory`,description:`Force-enable session memory (auto-extraction + past session search) by bypassing the tengu_session_memory and tengu_coral_fern statsig flags.`,getValue:()=>t.misc?.enableSessionMemory??!0,toggle:()=>{n(e=>{c(),e.misc.enableSessionMemory=!e.misc.enableSessionMemory})}},{id:`enableDreamMode`,title:`Enable dream mode`,description:`Force-enable dream (/dream + auto-dream background memory consolidation) by bypassing the tengu_onyx_plover statsig gate. On/off still follows autoDreamEnabled in ~/.claude/settings.json.`,getValue:()=>t.misc?.enableDreamMode??!0,toggle:()=>{n(e=>{c(),e.misc.enableDreamMode=!e.misc.enableDreamMode})}},{id:`fixSummarizeFromHere`,title:`Fix "Summarize from here"`,description:`Make "Summarize from here" summarize only the messages after the rewind point instead of the whole conversation.`,getValue:()=>t.misc?.fixSummarizeFromHere??!0,toggle:()=>{n(e=>{c(),e.misc.fixSummarizeFromHere=!(e.misc.fixSummarizeFromHere??!0)})}},{id:`fixRewindSummaryHeader`,title:`Honest rewind summary header`,description:`Label a rewind summary as a deliberate rewind (you continued forward, then rewound and chose to carry the summary forward) instead of the misleading "ran out of context" header.`,getValue:()=>t.misc?.fixRewindSummaryHeader??!0,toggle:()=>{n(e=>{c(),e.misc.fixRewindSummaryHeader=!(e.misc.fixRewindSummaryHeader??!0)})}},{id:`enableLeanMemoryTypes`,title:`Enable lean memory types`,description:`Force the tengu_ochre_finch statsig gate: memory prompts carry a compact "Types of memory" list and the full taxonomy moves to the on-demand memory-types skill.`,getValue:()=>t.misc?.enableLeanMemoryTypes??!1,toggle:()=>{n(e=>{c(),e.misc.enableLeanMemoryTypes=!e.misc.enableLeanMemoryTypes})}},{id:`enableRememberSkill`,title:`Enable remember skill`,description:`Register a "remember" skill to review session memories and update CLAUDE.local.md with learnings from past sessions.`,getValue:()=>t.misc?.enableRememberSkill??!1,toggle:()=>{n(e=>{c(),e.misc.enableRememberSkill=!e.misc.enableRememberSkill})}},{id:`tokenCountRounding`,title:`Token count rounding`,description:`Round displayed token counts to nearest multiple. Use ←/→ to cycle: Off, 1, 5, 10, 25, 50, 100, 200, 250, 500, 1000.`,getValue:()=>t.misc?.tokenCountRounding??null,getDisplayValue:()=>h(t.misc?.tokenCountRounding??null),toggle:()=>{n(e=>{c(),e.misc.tokenCountRounding=null})},increment:()=>{n(e=>{c(),e.misc.tokenCountRounding=g(e.misc.tokenCountRounding??null,`next`)})},decrement:()=>{n(e=>{c(),e.misc.tokenCountRounding=g(e.misc.tokenCountRounding??null,`prev`)})}},{id:`autoAcceptPlanMode`,title:`Auto-accept plan mode`,description:`Automatically accept plans without the "Ready to code?" confirmation prompt.`,getValue:()=>t.misc?.autoAcceptPlanMode??!1,toggle:()=>{n(e=>{c(),e.misc.autoAcceptPlanMode=!e.misc.autoAcceptPlanMode})}},{id:`allowBypassPermissionsInSudo`,title:`Allow bypassing permissions in sudo`,description:`⚠️ WARNING: Disables a security check. When enabled, Claude can perform system-level operations without prompts. Use extreme caution.`,getValue:()=>t.misc?.allowBypassPermissionsInSudo??!1,toggle:()=>{t.misc?.allowBypassPermissionsInSudo??!1?n(e=>{c(),e.misc.allowBypassPermissionsInSudo=!1}):o(!0)}},{id:`suppressNativeInstallerWarning`,title:`Suppress native installer warning`,description:`Suppress the native installer warning message at startup.`,getValue:()=>t.misc?.suppressNativeInstallerWarning??!1,toggle:()=>{n(e=>{c(),e.misc.suppressNativeInstallerWarning=!e.misc.suppressNativeInstallerWarning})}},{id:`filterScrollEscapeSequences`,title:`Filter scroll escape sequences`,description:`Filter out terminal escape sequences that cause unwanted scrolling.`,getValue:()=>t.misc?.filterScrollEscapeSequences??!1,toggle:()=>{n(e=>{c(),e.misc.filterScrollEscapeSequences=!e.misc.filterScrollEscapeSequences})}},{id:`allowCustomAgentModels`,title:`Allow custom agent models`,description:`Allow arbitrary model names in custom agent frontmatter (e.g. gemini-2.5-flash). Useful with a local proxy for non-Claude models.`,getValue:()=>t.misc?.allowCustomAgentModels??!1,toggle:()=>{n(e=>{c(),e.misc.allowCustomAgentModels=!e.misc.allowCustomAgentModels})}},{id:`maxEffortDefault`,title:`Default Opus 4.7 to max effort`,description:`Patches CC so Opus 4.7 sessions default to "max" reasoning effort instead of "xhigh". /effort and CLAUDE_CODE_EFFORT_LEVEL still override at runtime.`,getValue:()=>t.misc?.maxEffortDefault??!1,toggle:()=>{n(e=>{c(),e.misc.maxEffortDefault=!e.misc.maxEffortDefault})}},{id:`autonomousOperationAllModels`,title:`Fable/Mythos prompt set (all models)`,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 your turn"); the "# Communicating with the user" comms block in place of "# Text output"; /loop dynamic-pacing turn behavior; and brief-mode comms shaping. Per-model feature-flag routing follows fable too, but is inert on a local install (those flags default off without a live gate service).`,getValue:()=>t.misc?.autonomousOperationAllModels??!1,toggle:()=>{n(e=>{c(),e.misc.autonomousOperationAllModels=!e.misc.autonomousOperationAllModels})}},{id:`adhdOutputStyle`,title:`ADHD-friendly output style (experimental)`,description:`EXPERIMENTAL, and it may not visibly change your output. Prompt wording is a weak and inconsistent lever: Claude can ignore it, the effect varies between one reply and the next, and on some tasks nothing measurable changes. Picked by blind ranking over roughly 900 generated replies, where it came last in 1 of 16 comparisons and the unmodified prompt came last in 10 - an average, not a promise about any single reply. Rewrites the always-on "# Communicating with the user" prompt for skim-first reading, with no word limit anywhere in it: answer in the first line; show the command, path or value rather than describing it; say each thing once; keep both sides of a count and every qualifier such as "in the browser only"; bold the key terms and keep paragraphs short. Removes the three clauses that drive Claude-speak: the "load-bearing" update cue, the "readable matters more" ranking, and the "in prose, not headers and sections" rule. Also restates the rules in the per-turn CLAUDE.md reminder, where recency makes them stick, and drops that reminder's "may or may not be relevant" hedge.`,getValue:()=>t.misc?.adhdOutputStyle??!1,toggle:()=>{n(e=>{c(),e.misc.adhdOutputStyle=!e.misc.adhdOutputStyle})}},{id:`autoModeClassifierModel`,title:`Auto-mode classifier model`,description:`Pin auto-mode bash safety classifier to a fixed model. Default routes to your main-loop model (e.g. Opus 4.7), which gets denied as "temporarily unavailable" when that model is congested. Sonnet/Haiku have more headroom and the binary XML classifier task fits either.`,getValue:()=>t.misc?.autoModeClassifierModel??`default`,getDisplayValue:()=>u(t.misc?.autoModeClassifierModel??`default`),toggle:()=>{n(e=>{c(),e.misc.autoModeClassifierModel=l(e.misc.autoModeClassifierModel??`default`)})}}],[t,n]),v=_.length,y=v-1,b=Me(()=>r<4?0:Math.min(r-4+1,v-4),[r,v]),x=_.slice(b,b+4),S=b>0,C=b+4<v;return B((t,s)=>{a?s.return?(n(e=>{c(),e.misc.allowBypassPermissionsInSudo=!0}),o(!1)):s.escape&&o(!1):s.return||s.escape?e():s.upArrow?i(e=>Math.max(0,e-1)):s.downArrow?i(e=>Math.min(y,e+1)):t===` `?_[r]?.toggle():s.rightArrow?_[r]?.increment?.():s.leftArrow&&_[r]?.decrement?.()}),J(R,{flexDirection:`column`,children:a?J(R,{flexDirection:`column`,paddingX:2,children:Y(R,{borderStyle:`double`,borderColor:`yellow`,padding:2,flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:`yellow`,children:`SECURITY WARNING`})}),J(R,{marginBottom:1,children:J(z,{children:`You are about to enable a feature that allows Claude Code to bypass permission checks when running with sudo privileges.`})}),J(R,{marginBottom:1,children:J(z,{color:`red`,children:`This means Claude can perform system-level operations without any prompts or confirmation.`})}),J(R,{marginBottom:1,children:J(z,{bold:!0,children:`Use with extreme caution.`})}),J(R,{children:Y(z,{children:[`Press `,J(z,{color:`red`,children:`Enter`}),` to enable,`,` `,J(z,{color:`green`,children:`Escape`}),` to cancel`]})})]})}):Y(q,{children:[J(R,{marginBottom:1,children:J(X,{children:`Miscellaneous Settings`})}),J(R,{marginBottom:1,children:J(z,{dimColor:!0,children:`Use ↑/↓ to navigate, space to toggle, ←/→ to adjust numbers, enter to go back.`})}),S&&J(R,{children:Y(z,{dimColor:!0,children:[` ↑ `,b,` more above`]})}),x.map((e,t)=>{let n=b+t===r,i=e.getValue(),a=!!e.getDisplayValue,o=!!e.increment,s;s=o?`◆`:a?`◉`:i?`☑`:`☐`;let c;c=a?e.getDisplayValue():typeof i==`boolean`?i?`Enabled`:`Disabled`:String(i??`Default`);let l=n&&o?` ← → `:``;return Y(R,{flexDirection:`column`,children:[J(R,{children:Y(z,{children:[J(z,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),J(z,{bold:!0,color:n?`cyan`:void 0,children:e.title})]})}),J(R,{children:Y(z,{dimColor:!0,children:[` `,e.description]})}),J(R,{marginLeft:4,marginBottom:1,children:Y(z,{children:[s,` `,c,J(z,{dimColor:!0,children:l})]})})]},e.id)}),C&&J(R,{children:Y(z,{dimColor:!0,children:[` `,`↓ `,v-b-4,` more below`]})}),J(R,{marginTop:1,children:Y(z,{dimColor:!0,children:[`Item `,r+1,` of `,v]})})]})})}const It=`AgentOutputTool.AskUserQuestion.Bash.BashOutputTool.Edit.EnterPlanMode.ExitPlanMode.Glob.Grep.KillShell.ListMcpResourcesTool.LSP.NotebookEdit.Read.ReadMcpResourceTool.Skill.Task.TaskCreate.TaskGet.TaskList.TaskOutput.TaskStop.TaskUpdate.Teammate.TodoWrite.ToolSearch.WebFetch.WebSearch.Write`.split(`.`);function Lt({toolsetIndex:e,onBack:t}){let{settings:n,updateSettings:r}=H($),i=n.toolsets[e],[a,o]=W(i?.name||`New Toolset`),[s,c]=W(i?.allowedTools||[]),[l,u]=W(!1),[d,f]=W(0);U(()=>{i&&r(t=>{let n=t.toolsets[e].name;t.toolsets[e].name=a,t.toolsets[e].allowedTools=s,n!==a&&(t.defaultToolset===n&&(t.defaultToolset=a),t.planModeToolset===n&&(t.planModeToolset=a))})},[a,s]);let p=e=>s===`*`?!0:s.includes(e),m=e=>{e===`All`?c(`*`):e===`None`?c([]):s===`*`?c(It.filter(t=>t!==e)):s.includes(e)?c(s.filter(t=>t!==e)):c([...s,e])};if(B((e,n)=>{if(l){n.return?(a.trim()||o(i?.name||`New Toolset`),u(!1)):n.escape?(o(i?.name||`New Toolset`),u(!1)):n.backspace||n.delete?o(e=>e.slice(0,-1)):e&&e.length===1&&o(t=>t+e);return}if(n.escape)t();else if(n.upArrow)f(e=>Math.max(0,e-1));else if(n.downArrow)f(e=>Math.min(It.length+1,e+1));else if(e===` `||n.return)if(d===0)m(`All`);else if(d===1)m(`None`);else{let e=It[d-2];e&&m(e)}else e===`n`&&u(!0)}),!i)return J(R,{flexDirection:`column`,children:J(z,{color:`red`,children:`Toolset not found`})});let h=s===`*`,g=Array.isArray(s)&&s.length===0;return Y(R,{flexDirection:`column`,children:[J(X,{children:`Edit Toolset`}),J(R,{marginBottom:1,flexDirection:`column`,children:J(z,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{bold:!0,children:`Name:`}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:l?`yellow`:`gray`,children:J(z,{children:a})})}),l&&J(R,{marginLeft:2,children:J(z,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{bold:!0,children:`Allowed Tools:`}),J(R,{marginLeft:2,children:Y(z,{color:d===0?`cyan`:void 0,children:[d===0?`❯ `:` `,h?`●`:`○`,` All`]})}),J(R,{marginLeft:2,children:Y(z,{color:d===1?`cyan`:void 0,children:[d===1?`❯ `:` `,g?`●`:`○`,` None`]})}),It.map((e,t)=>{let n=t+2;return J(R,{marginLeft:2,children:Y(z,{color:d===n?`cyan`:void 0,children:[d===n?`❯ `:` `,p(e)?`◉`:`○`,` `,e]})},e)})]}),J(R,{borderStyle:`round`,padding:1,marginTop:1,children:Y(R,{flexDirection:`column`,children:[J(z,{bold:!0,children:`Summary:`}),Y(z,{children:[`Name: `,J(z,{color:`cyan`,children:a})]}),Y(z,{children:[`Tools:`,` `,s===`*`?J(z,{color:`green`,children:`All tools (*)`}):s.length===0?J(z,{color:`red`,children:`No tools ([])`}):Y(z,{color:`yellow`,children:[s.length,` selected`]})]})]})})]})}function Rt({onBack:e}){let{settings:{toolsets:t,defaultToolset:n,planModeToolset:r,themes:i},updateSettings:a}=H($),o=me(),s=i.find(e=>e.id===o)||i[0],c=M.themes[0],l=s?.colors.planMode||c.colors.planMode,u=s?.colors.autoAccept||c.colors.autoAccept,[d,f]=W(0),[p,m]=W(null),[h,g]=W(!0),_=()=>{let e={name:`New Toolset`,allowedTools:[]};a(t=>{t.toolsets.push(e)}),m(t.length),g(!1)},v=e=>{let n=t[e];a(t=>{t.toolsets.splice(e,1),t.defaultToolset===n.name&&(t.defaultToolset=null),t.planModeToolset===n.name&&(t.planModeToolset=null)}),d>=t.length-1&&f(Math.max(0,t.length-2))},y=e=>{let n=t[e];a(e=>{e.defaultToolset=n.name})},b=e=>{let n=t[e];a(e=>{e.planModeToolset=n.name})};if(B((n,r)=>{r.escape?e():r.upArrow?f(e=>Math.max(0,e-1)):r.downArrow?f(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(m(d),g(!1)):n===`n`?_():n===`x`&&t.length>0?v(d):n===`d`&&t.length>0?y(d):n===`p`&&t.length>0&&b(d)},{isActive:h}),p!==null)return J(Lt,{toolsetIndex:p,onBack:()=>{m(null),g(!0)}});let x=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return Y(R,{flexDirection:`column`,children:[J(X,{children:`Toolsets`}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`n to create a new toolset`}),t.length>0&&J(z,{dimColor:!0,children:`d to set as default toolset`}),t.length>0&&J(z,{dimColor:!0,children:`p to set as plan mode toolset`}),t.length>0&&J(z,{dimColor:!0,children:`x to delete a toolset`}),t.length>0&&J(z,{dimColor:!0,children:`enter to edit toolset`}),J(z,{dimColor:!0,children:`esc to go back`})]}),t.length===0?J(z,{children:`No toolsets created yet. Press n to create one.`}):J(R,{flexDirection:`column`,children:t.map((e,t)=>{let i=e.name===n,a=e.name===r,o=d===t,s;return o&&(s=`yellow`),Y(R,{flexDirection:`row`,children:[Y(z,{color:s,children:[o?`❯ `:` `,e.name,` `]}),Y(z,{color:s,children:[`(`,x(e),`)`]}),i&&J(z,{color:u,children:` ⏵⏵ accept edits`}),a&&J(z,{color:l,children:` ⏸ plan mode`})]},t)})})]})}function zt({onBack:e}){let{settings:t,updateSettings:n}=H($),[r,i]=W(`plan`),[a,o]=W(!1),[s,c]=W(0),l=t.subagentModels||{plan:null,explore:null,generalPurpose:null},u=[{id:`plan`,title:`Plan Agent`,description:`The agent responsible for creating implementation plans.`},{id:`explore`,title:`Explore Agent`,description:`The agent specialized for exploring codebases.`},{id:`generalPurpose`,title:`General-purpose Agent`,description:`The agent used for general multi-step tasks.`}],d=[{label:`Default (Inherited)`,value:null},{label:`sonnet`,value:`sonnet`},{label:`haiku`,value:`haiku`},{label:`opus`,value:`opus`},{label:`sonnet[1m]`,value:`sonnet[1m]`}];return B((t,f)=>{if(a){if(f.escape)o(!1);else if(f.upArrow)c(e=>e>0?e-1:d.length-1);else if(f.downArrow)c(e=>e<d.length-1?e+1:0);else if(f.return){let e=d[s].value;n(t=>{t.subagentModels||={plan:null,explore:null,generalPurpose:null},t.subagentModels[r]=e}),o(!1)}}else if(f.escape)e();else if(f.upArrow){let e=u.findIndex(e=>e.id===r);i(u[e>0?e-1:u.length-1].id)}else if(f.downArrow){let e=u.findIndex(e=>e.id===r);i(u[e<u.length-1?e+1:0].id)}else if(t===` `||f.return){let e=l[r],t=d.findIndex(t=>t.value===e);c(t>=0?t:0),o(!0)}}),a?Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:Y(X,{children:[`Select Model for`,` `,u.find(e=>e.id===r)?.title]})}),d.map((e,t)=>{let n=t===s;return J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.label,e.value?Y(z,{dimColor:!0,children:[` (`,e.value,`)`]}):null]})},t)})]}):Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(X,{children:`Subagent Model Settings`})}),J(R,{marginBottom:1,children:J(z,{dimColor:!0,children:`Configure which Claude model each subagent uses. Use arrow keys to navigate, enter or space to change a model, and escape to go back.`})}),u.map(e=>{let t=e.id===r,n=l[e.id],i=d.find(e=>e.value===n)?.label||n||`Default`;return Y(R,{flexDirection:`column`,marginBottom:1,children:[J(R,{children:Y(z,{color:t?`cyan`:void 0,children:[t?`❯ `:` `,J(z,{bold:!0,children:e.title})]})}),J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:e.description})}),J(R,{marginLeft:4,children:Y(z,{children:[`Current: `,J(z,{color:`green`,children:i})]})})]},e.id)})]})}const Bt=[{value:`low`,blurb:`Fastest, cheapest - minimal reasoning`},{value:`medium`,blurb:`Balanced reasoning`},{value:`high`,blurb:`Deep reasoning`},{value:`xhigh`,blurb:`Very deep reasoning`},{value:`max`,blurb:`Maximum reasoning - slowest, priciest`}],Vt={messageCap:{label:`Message cap`,unit:`chars`,lo:500,hi:4e5,hint:`max chars of a user message fed to the classifier`},assistantCap:{label:`Assistant cap`,unit:`chars`,lo:500,hi:4e5,hint:`prev assistant reply beyond this is middle-truncated (head+tail + an omitted-size marker the classifier weighs); no mechanical floor`},timeoutMs:{label:`Haiku timeout`,unit:`ms`,lo:1e3,hi:12e4,hint:`classifier call timeout; on timeout the router fails open`}},Ht=[`enabled`,`pinPerTask`,`messageCap`,`assistantCap`,`timeoutMs`,`systemPrompt`],Ut=e=>e in Vt,Wt=M.complexityRouter;function Gt({onBack:e}){let{settings:t,updateSettings:n}=H($),r={...Wt,...t.complexityRouter??{},levels:t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:Wt.levels},i=Ht.length+r.levels.length,{setRawMode:a,isRawModeSupported:o}=Ee(),[s,c]=W(0),[l,u]=W(null),[d,f]=W(0),[p,m]=W(null),[h,g]=W(null),[,_]=W(0),v=e=>{n(t=>{let n={...Wt,...t.complexityRouter??{},levels:(t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:Wt.levels).map(e=>({...e}))};e(n),t.complexityRouter=n})};if(B((t,n)=>{if(h){if(n.escape){g(null);return}if(n.return){let{kind:e,levelIndex:t,value:n}=h;v(r=>{let i=r.levels[t];i&&(i[e]=n)}),g(null);return}if(n.backspace||n.delete){g(e=>e&&{...e,value:e.value.slice(0,-1)});return}t&&!n.ctrl&&!n.meta&&g(e=>e&&{...e,value:e.value+t});return}if(p){if(n.escape){m(null);return}if(n.return){let e=Vt[p.row],t=parseInt(p.value,10),n=Number.isFinite(t)?Math.min(e.hi,Math.max(e.lo,t)):Wt[p.row],r=p.row;v(e=>{e[r]=n}),m(null);return}if(n.backspace||n.delete){m(e=>e&&{...e,value:e.value.slice(0,-1)});return}/^[0-9]$/.test(t)&&m(e=>e&&e.value.length<7?{...e,value:e.value+t}:e);return}if(l){if(n.escape){u(null);return}if(n.upArrow){f(e=>e>0?e-1:Bt.length-1);return}if(n.downArrow){f(e=>e<Bt.length-1?e+1:0);return}if(n.return){let e=Bt[d].value,t=l.levelIndex;v(n=>{n.levels[t]&&(n.levels[t].effort=e)}),u(null)}return}if(n.escape){e();return}if(n.upArrow){c(e=>e>0?e-1:i-1);return}if(n.downArrow){c(e=>e<i-1?e+1:0);return}let y=s<Ht.length,b=s-Ht.length;if(t===`x`){if(y){let e=Ht[s];Ut(e)?v(t=>{t[e]=Wt[e]}):e===`systemPrompt`&&v(e=>{e.systemPrompt=Wt.systemPrompt})}else{let e=Wt.levels[b];e&&v(t=>{let n=t.levels[b];n&&(n.effort=e.effort,n.label=e.label,n.help=e.help)})}return}if(!y&&(t===`l`||t===`h`)){let e=t===`l`?`label`:`help`,n=r.levels[b];n&&g({kind:e,levelIndex:b,value:n[e]});return}if(t===` `||n.return)if(y){let e=Ht[s];if(e===`enabled`)v(e=>{e.enabled=!e.enabled});else if(e===`pinPerTask`)v(e=>{e.pinPerTask=!e.pinPerTask});else if(e===`systemPrompt`){o&&a(!1);let e=te(r.systemPrompt);if(o&&a(!0),e!=null){let t=e.replace(/\s+$/,``);t&&t!==r.systemPrompt&&v(e=>{e.systemPrompt=t})}_(e=>e+1)}else m({row:e,value:String(r[e])})}else{let e=Bt.findIndex(e=>e.value===r.levels[b]?.effort);f(e>=0?e:0),u({levelIndex:b})}}),l)return Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:Y(X,{children:[`Select effort for "`,r.levels[l.levelIndex]?.label,`"`]})}),Bt.map((e,t)=>{let n=t===d;return J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.value,Y(z,{dimColor:!0,children:[` - `,e.blurb]})]})},t)})]});let y=(e,t)=>{let n=t===s,i,a,o=``;if(e===`enabled`)i=`Enabled`,a=r.enabled?`on`:`off`;else if(e===`pinPerTask`)i=`Pin per task`,a=r.pinPerTask?`on`:`off`;else if(e===`systemPrompt`){i=`System prompt`;let e=r.systemPrompt===Wt.systemPrompt;a=`${r.systemPrompt.length} chars${e?` (default)`:` (customized)`} - enter to edit in $EDITOR`,o=`opens the classifier system prompt in your $EDITOR; {LEVELS} (the tier rubric) and {MAX} are substituted at apply time · x = reset to default`}else{let t=Vt[e];i=t.label,p?.row===e?(a=`${p.value||`0`}_`,o=`type a number (${t.lo}-${t.hi}), enter to save · esc cancel`):(a=`${r[e]} ${t.unit}`,o=t.hint)}return Y(R,{flexDirection:`column`,children:[Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,i,`: `,J(z,{color:`green`,children:a})]}),n&&o?J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:o})}):null]},e)};return Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:J(X,{children:`Complexity Effort Router [experimental]`})}),Y(R,{marginBottom:1,flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Classifies each task by difficulty and sets the reasoning-effort (thinking) level to match - low for routine work, the top tier only for genuinely frontier problems. Runs on your current model (no model switch). Off by default.`}),J(z,{dimColor:!0,children:`Heads up - it burns more tokens: effort level is part of the prompt cache key, so every turn the router changes the level the whole conversation is re-read uncached (a big one-time hit that turn, then cheaper again while the level holds). Each level keeps its own cache, so returning to a prior level reuses most of its earlier work. pin per task on (the default, monotonic) minimizes the churn; pin off flips both ways and pays it more often. Measured, not theoretical.`}),J(z,{dimColor:!0,children:`A one-shot Haiku side-call routes each prompt, fed a rolling TL;DR summary of the session plus the model in use and the level it set last turn (so it judges in context, not cold). Kept in ~/.tweakcc/router- state, restored on resume; reset and reseeded from the main model's summary when the conversation compacts. On a Haiku error it keeps the last level, else defaults high.`}),J(z,{dimColor:!0,children:`Rewind-aware: it snapshots the routed state each turn, so /rewind (Restore conversation) cuts the summary back to the point you rewound to - effort and memory follow the conversation instead of carrying rewound-away work. (Summarize-from-here rewinds reseed via compaction.)`}),J(z,{dimColor:!0,children:`Fully customizable: edit the classifier System prompt in your $EDITOR, and each tier's label/help inline - all with sane defaults.`}),J(z,{dimColor:!0,children:`pin per task is a monotonic floor - effort never drops below the session max (only escalates); turn it off to track each prompt up and down. Reset on /clear.`}),J(z,{dimColor:!0,children:`While on, the router drives effort, overriding your saved effortLevel. An in-session /effort takes back manual control for that session, and CLAUDE_CODE_EFFORT_LEVEL always wins.`}),J(z,{dimColor:!0,children:`See it: Claude Code's working indicator already shows it live - e.g. "thinking with max effort" reflects the routed level. TWEAKCC_ROUTER_DEBUG=1 also logs each decision.`}),J(z,{dimColor:!0,children:`↑↓ navigate · enter/space toggle, edit, or open $EDITOR · digits set a number · on a tier: l/h edit label/help · x reset · esc back`})]}),Ht.map((e,t)=>y(e,t)),J(R,{marginTop:1,marginBottom:1,children:J(z,{bold:!0,children:`Complexity levels and their effort`})}),r.levels.map((e,t)=>{let n=Ht.length+t===s,r=h?.levelIndex===t&&h.kind===`label`,i=h?.levelIndex===t&&h.kind===`help`;return Y(R,{flexDirection:`column`,marginBottom:1,children:[J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,J(z,{bold:!0,children:r?`${h.value}_`:e.label}),` `,J(z,{color:`green`,children:e.effort})]})}),J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:i?`${h.value}_`:e.help})}),n&&!h?J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:`enter = set effort · l = edit label · h = edit help · x = reset this tier`})}):null,n&&h?J(R,{marginLeft:4,children:Y(z,{dimColor:!0,children:[`editing `,h.kind,` - type to change · enter save · esc cancel`]})}):null]},e.id)})]})}const Kt=[`fable`,`opus`,`sonnet`,`haiku`],qt=[`low`,`medium`,`high`,`xhigh`,`max`],Jt=e=>e.charAt(0).toUpperCase()+e.slice(1),Yt=[{kind:`enabled`},{kind:`model`,side:`plan`},{kind:`effort`,side:`plan`},{kind:`model`,side:`exec`},{kind:`effort`,side:`exec`},{kind:`clearContext`}],Xt=({onBack:e})=>{let{settings:t,updateSettings:n}=H($),r={...M.fablePlan,...t.fablePlan??{}},[i,a]=W(0),o=e=>{n(t=>({...t,fablePlan:{...M.fablePlan,...t.fablePlan??{},...e}}))},s=e=>{let t=Yt[i];if(t.kind===`enabled`){o({enabled:!r.enabled});return}if(t.kind===`clearContext`){o({offerClearContextOnPlanAccept:!r.offerClearContextOnPlanAccept});return}if(t.kind===`model`){let n=t.side===`plan`?`planModel`:`execModel`,i=t.side===`plan`?r.execModel:r.planModel,a=Kt.indexOf(r[n]);for(let t=1;t<=Kt.length;t++){let r=Kt[(a+e*t+Kt.length*t)%Kt.length];if(r!==i){o({[n]:r});return}}return}let n=t.side===`plan`?`planEffort`:`execEffort`,a=qt[(qt.indexOf(r[n])+e+qt.length)%qt.length];o({[n]:a})};B((t,n)=>{if(n.escape||t===`q`){e();return}n.upArrow?a(e=>(e-1+Yt.length)%Yt.length):n.downArrow?a(e=>(e+1)%Yt.length):n.leftArrow?s(-1):n.rightArrow||n.return||t===` `?s(1):t===`x`&&o({...M.fablePlan})});let c=(e,t,n)=>Y(R,{children:[Y(z,{color:e===i?`cyan`:void 0,children:[e===i?`❯ `:` `,t.padEnd(26)]}),J(z,{color:e===i?`cyan`:`green`,bold:e===i,children:n})]},t),l=`${r.planModel}plan`;return Y(R,{flexDirection:`column`,paddingX:1,children:[J(z,{bold:!0,children:`Fable Plan mode`}),Y(R,{marginTop:1,flexDirection:`column`,children:[Y(z,{dimColor:!0,children:[`Adds a `,J(z,{color:`green`,children:l}),` entry to Claude Code's`,` `,J(z,{color:`green`,children:`/model`}),` list: `,Jt(r.planModel),` `,`while planning, `,Jt(r.execModel),` while executing, each at its own reasoning effort.`]}),Y(z,{dimColor:!0,children:[`It is a model you select, the same mechanism Claude Code ships for opusplan. Nothing changes for any other model, and your selection stays `,J(z,{color:`green`,children:l}),` throughout — the pairing is resolved per request, so no model is ever switched underneath you mid-session.`]})]}),J(R,{marginTop:1,flexDirection:`column`,children:Yt.map((e,t)=>{if(e.kind===`enabled`)return c(t,`Enabled`,r.enabled?`yes`:`no`);if(e.kind===`clearContext`)return c(t,`Offer "clear context"`,r.offerClearContextOnPlanAccept?`yes`:`no`);let n=e.side===`plan`?`Planning`:`Executing`;return e.kind===`model`?c(t,`${n} model`,Jt(e.side===`plan`?r.planModel:r.execModel)):c(t,`${n} effort`,e.side===`plan`?r.planEffort:r.execEffort)})}),Y(R,{marginTop:1,flexDirection:`column`,children:[Y(z,{dimColor:!0,children:[`Claude Code defaults its "clear context" option off. On, the plan-approval dialog offers "Yes, clear context (N% used)", which hands only the plan to `,Jt(r.execModel),`. Continuing instead re-sends the whole planning transcript to a different model, so the cache is cold either way and you pay for the transcript twice.`]}),J(z,{dimColor:!0,children:`Effort follows the resolved model, so the complexity router still drives every model that is not part of this pairing.`})]}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`↑↓ move · ←→ change · x reset to defaults · esc back`})})]})},Zt=K.join(ae,`claude-browser-bridge`),Qt=K.join(Zt,`host`,`setup.mjs`),$t=K.join(Zt,`extension`),en=K.join(Pe.homedir(),`.claude-browser-bridge`,`install-state.json`),tn=`/tmp/claude-browser-bridge-${Pe.userInfo().username}.sock`;function nn(e){try{return!G.statSync(K.join(e,`Local State`)).isFile()||!G.statSync(K.join(e,`NativeMessagingHosts`)).isDirectory()?!1:G.existsSync(K.join(e,`Default`))?!0:G.readdirSync(e).some(e=>/^Profile \d+$/.test(e))}catch{return!1}}function rn(e){let t=K.basename(e);return t===`User Data`&&(t=K.basename(K.dirname(e))),t.includes(`.`)&&(t=t.split(`.`).pop()||t),t=t.replace(/[-_]/g,` `),t.charAt(0).toUpperCase()+t.slice(1)}function an(e){return new Promise(t=>{Le(process.execPath,e,{maxBuffer:8*1024*1024},(e,n,r)=>{t({code:e?typeof e.code==`number`?e.code:1:0,out:String(n)+String(r)})})})}function on(e){return new Promise(t=>{Le(`git`,e,{maxBuffer:8*1024*1024},(e,n,r)=>{t({code:e?1:0,out:String(n)+String(r)})})})}async function sn(){if(G.existsSync(K.join(Zt,`.git`))&&G.existsSync(Qt)){let e=await on([`-C`,Zt,`pull`,`--ff-only`]);return G.existsSync(Qt)?{code:0,out:e.out}:e}return G.existsSync(Zt)&&G.rmSync(Zt,{recursive:!0,force:!0}),on([`clone`,`--depth`,`1`,`https://github.com/skrabe/claude-browser-bridge`,Zt])}function cn(){let e=process.platform===`darwin`?K.join(Pe.homedir(),`Library`,`Application Support`):K.join(Pe.homedir(),`.config`),t=e=>{try{return G.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).map(t=>K.join(e,t.name))}catch{return[]}},n=[];for(let r of t(e))for(let e of[r,...t(r)])nn(e)&&n.push(rn(e));return n.sort()}function ln(){try{return JSON.parse(G.readFileSync(en,`utf8`))}catch{return null}}const un=({onBack:e})=>{let[t,n]=W(`menu`),[r,i]=W(0),[a,o]=W(ln()),[s,c]=W(`global`),[l,u]=W(`Working…`),[d,f]=W([]),[p,m]=W(null),[h,g]=W(``),_=je(()=>{o(ln())},[]);U(()=>{_()},[_]);let v=G.existsSync(tn),y=!!a,b=()=>{c(`global`),i(0),n(`scope`)},x=je(async e=>{n(`busy`),u(`Fetching the bridge…`),f([]);let t=await sn();if(t.code!==0||!G.existsSync(Qt)){g(`Failed to fetch the bridge repo:
|
|
3
3
|
`+t.out.slice(-600)),n(`error`);return}u(`Installing (registers with every Chromium browser, MCP, skill, disables Claude in Chrome)…`);let r=[Qt,`install`,`--scope`,e];e===`project`&&r.push(`--project`,process.cwd());let a=await an(r);if(f(a.out.split(`
|
|
4
4
|
`).filter(e=>e.includes(`[bridge]`)).map(e=>e.replace(`[bridge]`,``).trim())),a.code!==0){g(`Install failed:
|
|
5
5
|
`+a.out.slice(-600)),n(`error`);return}_(),i(0),n(`extmodal`)},[_]),S=je(async()=>{n(`busy`),u(`Connecting to the extension…`),m(null),(await an([Qt,`verify`])).code===0?(i(0),n(`done`)):(m(`Not detected. Make sure the extension is loaded AND enabled, then retry.`),i(0),n(`extmodal`))},[]),C=je(async()=>{n(`busy`),u(`Uninstalling…`);let e=await an([Qt,`uninstall`]);if(f(e.out.split(`
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,B as t,H as n,R as r,U as i,V as a,W as o,a as s,c,et as l,h as u,j as d,l as f,r as p,z as m}from"../config-
|
|
1
|
+
import{$ as e,B as t,H as n,R as r,U as i,V as a,W as o,a as s,c,et as l,h as u,j as d,l as f,r as p,z as m}from"../config-DtZztjxv.mjs";import{a as h,i as g,n as _,r as v,t as y}from"../content-DBHwlD7l.mjs";import*as b from"node:fs/promises";import*as x from"node:path";async function S(e,t){let n=x.dirname(t);await b.mkdir(n,{recursive:!0}),await b.copyFile(e,t)}async function C(e,t){if(!await u(e))throw Error(`Backup file does not exist: ${e}`);await d(t,e,`restore`)}function w(){return c()}function T(){return p}function E(){return s}async function D(){return await f()}const O={findChalkVar:t,getModuleLoaderFunction:n,getReactVar:i,getRequireFuncName:o,findTextComponent:a,findBoxComponent:m,clearCaches:r,globalReplace:e,showDiff:l};export{S as backupFile,v as findAllInstallations,w as getTweakccConfigDir,T as getTweakccConfigPath,E as getTweakccSystemPromptsDir,O as helpers,y as readContent,D as readTweakccConfig,C as restoreBackup,g as showInteractiveInstallationPicker,h as tryDetectInstallation,_ as writeContent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as e,w as t}from"./config-
|
|
1
|
+
import{p as e,w as t}from"./config-DtZztjxv.mjs";import n from"node:os";import r from"node:fs";import i from"node:path";import{execFileSync as a,execSync as o}from"node:child_process";import s from"node-lief";function c(t){try{if(r.statSync(t).size>2e5)return null;s.logging.disable();let n=s.parse(t);if(!n.symbols().some(e=>{let t=e.name;return t===`execv`||t===`_execv`}))return e(`resolveNixBinaryWrapper: no execv import found, not a Nix wrapper`),null;e(`resolveNixBinaryWrapper: execv import found, checking for Nix wrapper DOCSTRING`);let i=null;if(n.format===`ELF`){let e=n.sections().find(e=>e.name===`.rodata`);e&&(i=e.content)}else if(n.format===`MachO`){let e=n.getSegment(`__TEXT`);if(e){let t=e.getSection(`__cstring`);t&&(i=t.content)}}if(!i||i.length===0)return e(`resolveNixBinaryWrapper: could not read string section`),null;let a=i.toString(`utf-8`),o=a.match(/makeCWrapper\s+'(\/nix\/store\/[^']+)'/);if(o){let t=o[1];return e(`resolveNixBinaryWrapper: found wrapped executable via DOCSTRING: ${t}`),t}let c=a.match(/makeCWrapper\s+(\/nix\/store\/\S+)/);if(c){let t=c[1];return e(`resolveNixBinaryWrapper: found wrapped executable via unquoted DOCSTRING: ${t}`),t}let l=a.match(/\/nix\/store\/[^\0\n\r]+/g);if(l){for(let t of l)if(t.includes(`/bin/`))return e(`resolveNixBinaryWrapper: found wrapped executable via /bin/ heuristic: ${t}`),t}return e(`resolveNixBinaryWrapper: has execv but no Nix store paths found`),null}catch(t){return e(`resolveNixBinaryWrapper: error during detection:`,t),null}}const l=Buffer.from(`
|
|
2
2
|
---- Bun! ----
|
|
3
3
|
`);function u(e,t){return e.subarray(t.offset,t.offset+t.length)}function d(e,t){return{offset:e.readUInt32LE(t),length:e.readUInt32LE(t+4)}}function f(e){let t=e.replaceAll(`\\`,`/`);return t.endsWith(`/claude`)||t===`claude`||t.endsWith(`/claude.exe`)||t===`claude.exe`||t.endsWith(`/src/entrypoints/cli.js`)||t===`src/entrypoints/cli.js`||t===`/$bunfs/root/cli`||t===`B:/~BUN/root/cli`||t===`cli`}function p(t){let n=t%52==0,r=t%36==0;return n&&!r?52:r&&!n?36:n&&r?(e(`detectModuleStructSize: Ambiguous module list length ${t}, assuming new format`),52):(e(`detectModuleStructSize: Module list length ${t} doesn't cleanly divide by either struct size, assuming new format`),52)}function m(e,t,n,r){let i=u(e,t.modulesPtr),a=Math.floor(i.length/n);for(let t=0;t<a;t++){let a=g(i,t*n,n),o=r(a,u(e,a.name).toString(`utf-8`),t);if(o!==void 0)return o}}function h(e){let t=0,n=e.readBigUInt64LE(t);t+=8;let r=d(e,t);t+=8;let i=e.readUInt32LE(t);t+=4;let a=d(e,t);return t+=8,{byteCount:n,modulesPtr:r,entryPointId:i,compileExecArgvPtr:a,flags:e.readUInt32LE(t)}}function g(e,t,n){let r=t,i=d(e,r);r+=8;let a=d(e,r);r+=8;let o=d(e,r);r+=8;let s=d(e,r);r+=8;let c,l;n===52?(c=d(e,r),r+=8,l=d(e,r),r+=8):(c={offset:0,length:0},l={offset:0,length:0});let u=e.readUInt8(r);r+=1;let f=e.readUInt8(r);r+=1;let p=e.readUInt8(r);r+=1;let m=e.readUInt8(r);return{name:i,contents:a,sourcemap:o,bytecode:s,moduleInfo:c,bytecodeOriginPath:l,encoding:u,loader:f,moduleFormat:p,side:m}}function _(t){if(t.length<32+l.length)throw Error(`BUN data is too small to contain trailer and offsets`);let n=t.length-l.length,r=t.subarray(n);if(e(`parseBunDataBlob: Expected trailer: ${l.toString(`hex`)}`),e(`parseBunDataBlob: Got trailer: ${r.toString(`hex`)}`),!r.equals(l))throw Error(`BUN trailer bytes do not match trailer`);let i=t.length-32-l.length,a=h(t.subarray(i,i+32));return{bunOffsets:a,bunData:t,moduleStructSize:p(a.modulesPtr.length)}}function v(t){if(t.length<4)throw Error(`Section data too small`);e(`extractBunDataFromSection: sectionData.length=${t.length}`);let n=t.readUInt32LE(0),r=4+n,i=t.length>=8?Number(t.readBigUInt64LE(0)):0,a=8+i;e(`extractBunDataFromSection: u32 header would give size=${n}, expected total=${r}`),e(`extractBunDataFromSection: u64 header would give size=${i}, expected total=${a}`);let o,s;if(t.length>=8&&a<=t.length&&a>=t.length-4096)o=8,s=i,e(`extractBunDataFromSection: detected u64 header format (Bun >= 1.3.4)`);else if(r<=t.length&&r>=t.length-4096)o=4,s=n,e(`extractBunDataFromSection: detected u32 header format (Bun < 1.3.4)`);else throw Error(`Cannot determine section header format: sectionData.length=${t.length}, u64 would expect ${a}, u32 would expect ${r}`);e(`extractBunDataFromSection: bunDataSize from header=${s}`);let c=t.subarray(o,o+s);e(`extractBunDataFromSection: bunDataContent.length=${c.length}`);let{bunOffsets:l,bunData:u,moduleStructSize:d}=_(c);return{bunOffsets:l,bunData:u,sectionHeaderSize:o,moduleStructSize:d}}function y(t){try{let n=t.getSection(`.bun`);if(!n)return e(`extractBunDataFromELFSection: .bun section not found`),null;let r=n.content;if(r.length<8)return e(`extractBunDataFromELFSection: .bun section too small`),null;e(`extractBunDataFromELFSection: .bun section found, size=${r.length}`);let i=v(r);return e(`extractBunDataFromELFSection: successfully extracted data`),i}catch(t){return e(`extractBunDataFromELFSection: failed to extract:`,t),null}}function b(t){if(!t.hasOverlay)throw Error(`ELF binary has no overlay data`);let n=t.overlay;if(e(`extractBunDataFromELFOverlay: Overlay size=${n.length} bytes`),n.length<l.length+8+32)throw Error(`ELF overlay data is too small`);let r=n.readBigUInt64LE(n.length-8);if(e(`extractBunDataFromELFOverlay: Total byte count from tail=${r}`),r<4096n||r>2n**32n-1n)throw Error(`ELF total byte count is out of range: ${r}`);let i=n.length-8-l.length,a=n.subarray(i,n.length-8);if(e(`extractBunDataFromELFOverlay: Expected trailer: ${l.toString(`hex`)}`),e(`extractBunDataFromELFOverlay: Got trailer: ${a.toString(`hex`)}`),!a.equals(l))throw Error(`BUN trailer bytes do not match trailer`);let o=n.length-8-l.length-32,s=n.subarray(o,n.length-8-l.length),c=h(s);e(`extractBunDataFromELFOverlay: Offsets.byteCount=${c.byteCount}`);let u=typeof c.byteCount==`bigint`?c.byteCount:BigInt(c.byteCount);if(u>=r)throw Error(`ELF total byte count is out of range`);let d=8+l.length+32,f=n.length-d-Number(u),m=n.subarray(f,n.length-d);return e(`extractBunDataFromELFOverlay: Extracted ${m.length} bytes of data`),{bunOffsets:c,bunData:Buffer.concat([m,s,a]),moduleStructSize:p(c.modulesPtr.length)}}function x(e){let t=e.getSegment(`__BUN`);if(!t)throw Error(`__BUN segment not found`);let n=t.getSection(`__bun`);if(!n)throw Error(`__bun section not found`);return v(n.content)}function S(e){let t=e.sections().find(e=>e.name===`.bun`);if(!t)throw Error(`.bun section not found`);return v(t.content)}function C(){switch(process.platform){case`darwin`:return`MachO`;case`linux`:return`ELF`;case`win32`:return`PE`;default:return null}}function w(e){let t=C();if(t&&e.format!==t)throw Error(`Native binary format ${e.format} does not match ${process.platform} (${t})`)}function T(t,n){switch(e(`locateBundle: Binary format detected as ${t.format}`),w(t),t.format){case`MachO`:{let e=t,r=x(e);if(!r.sectionHeaderSize)throw Error(`sectionHeaderSize is required for Mach-O binaries`);let i=e.getSegment(`__BUN`).getSection(`__bun`);return{...r,offset:Number(i.fileOffset),length:i.content.length,write:(t,i)=>j(e,n,t,i,r.sectionHeaderSize)}}case`PE`:{let e=t,r=S(e);if(!r.sectionHeaderSize)throw Error(`sectionHeaderSize is required for PE binaries`);let i=e.sections().find(e=>e.name===`.bun`);return{...r,offset:Number(i.fileOffset),length:i.content.length,write:(t,i)=>M(e,n,t,i,r.sectionHeaderSize)}}case`ELF`:{let i=t,a=y(i);if(a){if(e(`locateBundle: Using new ELF .bun section format`),!a.sectionHeaderSize)throw Error(`sectionHeaderSize is required for ELF .bun section`);return{...a,offset:Number(i.getSection(`.bun`).fileOffset),length:i.getSection(`.bun`).content.length,write:(e,t)=>I(i,n,e,t,a.sectionHeaderSize)}}e(`locateBundle: Falling back to legacy ELF overlay format`);let o=b(i),s=r.statSync(n);return{...o,offset:s.size-i.overlay.length,length:i.overlay.length,write:(e,t)=>L(i,n,e,t)}}default:{let e=t;throw Error(`Unsupported binary format: ${e.format}`)}}}function E(t){let o=r.mkdtempSync(i.join(n.tmpdir(),`tweakcc-npm-`));try{e(`fetchNpmSource: Downloading @anthropic-ai/claude-code@${t}`),a(`npm`,[`pack`,`@anthropic-ai/claude-code@${t}`,`--pack-destination`,o],{stdio:`pipe`,timeout:3e4,cwd:o});let n=r.readdirSync(o).find(e=>e.endsWith(`.tgz`));if(!n)return e(`fetchNpmSource: No .tgz file found after npm pack`),null;a(`tar`,[`xzf`,i.join(o,n),`package/cli.js`],{stdio:`pipe`,timeout:3e4,cwd:o});let s=i.join(o,`package`,`cli.js`);if(!r.existsSync(s))return e(`fetchNpmSource: cli.js not found in extracted package`),null;let c=r.readFileSync(s);return e(`fetchNpmSource: Got cli.js, ${c.length} bytes`),c}catch(t){return e(`fetchNpmSource: Failed to fetch npm source:`,t),null}finally{try{r.rmSync(o,{recursive:!0,force:!0})}catch{}}}function D(t,n){try{s.logging.disable();let{bunOffsets:r,bunData:i,moduleStructSize:a}=T(s.parse(t),t);e(`extractClaudeJsFromNativeInstallation: Got bunData, size=${i.length} bytes, moduleStructSize=${a}`);let o=m(i,r,a,(t,n,r)=>{if(e(`extractClaudeJsFromNativeInstallation: Module ${r}: ${n}`),!f(n))return;let a=u(i,t.contents);return e(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${a.length}`),a.length>0?a:void 0});if(o){let t=o.subarray(0,64).toString(`utf8`);if(t.startsWith(`// @bun @bytecode`)&&!t.includes(`@bun-cjs`))if(e(`extractClaudeJsFromNativeInstallation: Extracted content is Bun bytecode — falling back to npm source`),n){let t=E(n);if(t)return e(`extractClaudeJsFromNativeInstallation: Using npm source (${t.length} bytes) instead of bytecode`),{data:t,clearBytecode:!0};e(`extractClaudeJsFromNativeInstallation: npm source fetch failed, returning bytecode content as-is`)}else e(`extractClaudeJsFromNativeInstallation: No version provided, cannot fetch npm source`);return{data:o,clearBytecode:!1}}return e(`extractClaudeJsFromNativeInstallation: claude module not found in any module`),{data:null,clearBytecode:!1,error:`claude module not found in any of the binary modules`}}catch(t){return e(`extractClaudeJsFromNativeInstallation: Error during extraction:`,t),{data:null,clearBytecode:!1,error:`extraction threw: ${t instanceof Error?t.message:String(t)}`}}}function O(e,t,n,r,i){let a=[],o=[];m(e,t,r,(t,s)=>{let c=u(e,t.name),l,d;n&&f(s)?(l=n,d=i?Buffer.alloc(0):u(e,t.bytecode)):(l=u(e,t.contents),d=u(e,t.bytecode));let p=u(e,t.sourcemap),m=u(e,t.moduleInfo),h=u(e,t.bytecodeOriginPath);o.push({name:c,contents:l,sourcemap:p,bytecode:d,moduleInfo:m,bytecodeOriginPath:h,encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side}),r===52?a.push(c,l,p,d,m,h):a.push(c,l,p,d)});let s=r===52?6:4,c=0,d=[];for(let e of a)d.push({offset:c,length:e.length}),c+=e.length+1;let p=c,h=o.length*r;c+=h;let g=u(e,t.compileExecArgvPtr),_=c,v=g.length;c+=v+1;let y=c;c+=32;let b=c;c+=l.length;let x=Buffer.allocUnsafe(c);x.fill(0);let S=0;for(let{offset:e,length:t}of d)t>0&&a[S].copy(x,e,0,t),x[e+t]=0,S++;v>0&&(g.copy(x,_,0,v),x[_+v]=0);for(let e=0;e<o.length;e++){let t=o[e],n=e*s,i={name:d[n],contents:d[n+1],sourcemap:d[n+2],bytecode:d[n+3],moduleInfo:r===52?d[n+4]:{offset:0,length:0},bytecodeOriginPath:r===52?d[n+5]:{offset:0,length:0},encoding:t.encoding,loader:t.loader,moduleFormat:t.moduleFormat,side:t.side},a=p+e*r;x.writeUInt32LE(i.name.offset,a),x.writeUInt32LE(i.name.length,a+4),a+=8,x.writeUInt32LE(i.contents.offset,a),x.writeUInt32LE(i.contents.length,a+4),a+=8,x.writeUInt32LE(i.sourcemap.offset,a),x.writeUInt32LE(i.sourcemap.length,a+4),a+=8,x.writeUInt32LE(i.bytecode.offset,a),x.writeUInt32LE(i.bytecode.length,a+4),a+=8,r===52&&(x.writeUInt32LE(i.moduleInfo.offset,a),x.writeUInt32LE(i.moduleInfo.length,a+4),a+=8,x.writeUInt32LE(i.bytecodeOriginPath.offset,a),x.writeUInt32LE(i.bytecodeOriginPath.length,a+4),a+=8),x.writeUInt8(i.encoding,a),x.writeUInt8(i.loader,a+1),x.writeUInt8(i.moduleFormat,a+2),x.writeUInt8(i.side,a+3)}let C={byteCount:y,modulesPtr:{offset:p,length:h},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:_,length:v},flags:t.flags},w=y,T=typeof C.byteCount==`bigint`?C.byteCount:BigInt(C.byteCount);return x.writeBigUInt64LE(T,w),w+=8,x.writeUInt32LE(C.modulesPtr.offset,w),x.writeUInt32LE(C.modulesPtr.length,w+4),w+=8,x.writeUInt32LE(C.entryPointId,w),w+=4,x.writeUInt32LE(C.compileExecArgvPtr.offset,w),x.writeUInt32LE(C.compileExecArgvPtr.length,w+4),w+=8,x.writeUInt32LE(C.flags,w),l.copy(x,b),x}function k(e,t,n,i=!0){let a=t+`.tmp`;if(e.write(a),i){let e=r.statSync(n);r.chmodSync(a,e.mode)}try{r.renameSync(a,t)}catch(e){try{r.existsSync(a)&&r.unlinkSync(a)}catch{}throw e instanceof Error&&`code`in e&&(e.code===`ETXTBSY`||e.code===`EBUSY`||e.code===`EPERM`)?Error(`Cannot update the Claude executable while it is running.
|
|
4
4
|
Please close all Claude instances and try again.`):e}}function A(e,t=8){let n=Buffer.allocUnsafe(t+e.length);return t===8?n.writeBigUInt64LE(BigInt(e.length),0):n.writeUInt32LE(e.length,0),e.copy(n,t),n}function j(n,r,i,a,c){try{e(`repackMachO: Has code signature: ${n.hasCodeSignature}`),n.hasCodeSignature&&(e(`repackMachO: Removing code signature...`),n.removeSignature());let l=n.getSegment(`__BUN`);if(!l)throw Error(`__BUN segment not found`);let u=l.getSection(`__bun`);if(!u)throw Error(`__bun section not found`);let d=A(i,c);e(`repackMachO: Original section size: ${u.size}`),e(`repackMachO: Original segment fileSize: ${l.fileSize}`),e(`repackMachO: Original segment virtualSize: ${l.virtualSize}`),e(`repackMachO: New data size: ${d.length}`),e(`repackMachO: Using header size: ${c}`);let f=d.length-Number(u.size);if(f>0){let t=n.header.cpuType===s.MachO.Header.CPU_TYPE.ARM64,r=t?16384:4096,i=Math.ceil(f/r)*r;e(`repackMachO: CPU type: ${t?`ARM64`:`x86_64`}`),e(`repackMachO: Page size: ${r} bytes`),e(`repackMachO: Need to expand by ${f} bytes`),e(`repackMachO: Rounding up to page-aligned: ${i} bytes`);let a=n.extendSegment(l,i);if(e(`repackMachO: extendSegment returned: ${a}`),!a)throw Error(`Failed to extend __BUN segment`);e(`repackMachO: Section size after extend: ${u.size}`),e(`repackMachO: Segment fileSize after extend: ${l.fileSize}`),e(`repackMachO: Segment virtualSize after extend: ${l.virtualSize}`)}u.content=d,u.size=BigInt(d.length),e(`repackMachO: Final section size: ${u.size}`),e(`repackMachO: Writing modified binary to ${a}...`),k(n,a,r);try{e(`repackMachO: Re-signing binary with ad-hoc signature...`),o(`codesign -s - -f "${a}"`,{stdio:t()?`inherit`:`ignore`}),e(`repackMachO: Code signing completed successfully`)}catch(e){console.warn(`Warning: Failed to re-sign binary. The binary may not run correctly on macOS:`,e)}e(`repackMachO: Write completed successfully`)}catch(e){throw console.error(`repackMachO failed:`,e),e}}function M(t,n,r,i,a){try{let o=t.sections().find(e=>e.name===`.bun`);if(!o)throw Error(`.bun section not found`);let s=A(r,a);e(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),e(`repackPE: New data size: ${s.length}`),e(`repackPE: Using header size: ${a}`),o.content=s,o.virtualSize=BigInt(s.length),o.size=BigInt(s.length),e(`repackPE: Writing modified binary to ${i}...`),k(t,i,n,!1),e(`repackPE: Write completed successfully`)}catch(e){throw console.error(`repackPE failed:`,e),e}}const N=16384;function P(e,t){return(e+t-1n)/t*t}function F(e){let{rwVirtualAddress:t,rwVirtualSize:n,rwFileOffset:r,rwFileSize:i,topmostLoadEnd:a,nextVirtualAddress:o,newContentSize:s,pageSize:c}=e,l=P(s,c),u=t+n,d=u>=a,f=P(d?u:o,c),p=r+(f-t),m=r+i;return{newVaddr:f,newFileOffset:p,alignedNewSize:l,extensionSize:p+l-m,compact:d}}function I(t,n,r,i,a){try{let o=t.getSection(`.bun`);if(!o)throw Error(`.bun section not found`);let s=t.segments().find(e=>e.type===`LOAD`&&(e.flags&2)!=0);if(!s)throw Error(`No writable ELF PT_LOAD segment found`);let c=A(r,a),l=o.virtualAddress,u=Buffer.alloc(8);u.writeBigUInt64LE(l);let d=null,f=s.content,p=s.virtualAddress,m=P(p,BigInt(N)),h=p+BigInt(f.length)-8n;for(let e=m;e<=h;e+=BigInt(N)){let t=Number(e-p);if(f.subarray(t,t+8).equals(u)){d=e;break}}if(d===null)throw Error(`Could not find original BUN_COMPILED location in binary (searched for 0x${l.toString(16)})`);let g=t.pageSize(),_=BigInt(c.length),v=t.segments().filter(e=>e.type===`LOAD`).reduce((e,t)=>{let n=BigInt(t.virtualAddress)+BigInt(t.virtualSize);return n>e?n:e},0n),{newVaddr:y,newFileOffset:b,extensionSize:x,compact:S}=F({rwVirtualAddress:BigInt(s.virtualAddress),rwVirtualSize:BigInt(s.virtualSize),rwFileOffset:BigInt(s.fileOffset),rwFileSize:BigInt(s.fileSize),topmostLoadEnd:v,nextVirtualAddress:BigInt(t.nextVirtualAddress()),newContentSize:_,pageSize:BigInt(g)});if(e(`repackELFSection: ${S?`compact`:`fallback`} placement (topmost LOAD ends at 0x${v.toString(16)})`),x<0n)throw Error(`New .bun location overlaps existing writable ELF segment`);if(e(`repackELFSection: moving .bun to offset=0x${b.toString(16)}, vaddr=0x${y.toString(16)}, size=0x${_.toString(16)}`),x>0n&&!t.extend(s,x))throw Error(`Failed to extend writable ELF PT_LOAD segment`);o.fileOffset=b,o.virtualAddress=y,o.content=c,o.size=_;let C=Buffer.alloc(8);C.writeBigUInt64LE(y),t.patchAddress(d,C),e(`repackELFSection: Patched BUN_COMPILED at vaddr 0x${d.toString(16)} -> 0x${y.toString(16)}`),k(t,i,n),e(`repackELFSection: Write completed successfully`)}catch(e){throw console.error(`repackELFSection failed:`,e),e}}function L(t,n,r,i){try{let a=Buffer.allocUnsafe(r.length+8);r.copy(a,0),a.writeBigUInt64LE(BigInt(r.length),r.length),e(`repackELFOverlay: Setting overlay data (${a.length} bytes)`),t.overlay=a,e(`repackELFOverlay: Writing modified binary to ${i}...`),k(t,i,n),e(`repackELFOverlay: Write completed successfully`)}catch(e){throw console.error(`repackELFOverlay failed:`,e),e}}function R(e,t,n,r){s.logging.disable();let i=T(s.parse(e),e),a=O(i.bunData,i.bunOffsets,t,i.moduleStructSize,r);i.write(a,n)}export{F as computeBunSectionPlacement,D as extractClaudeJsFromNativeInstallation,f as isClaudeModule,R as repackNativeInstallation,c as resolveNixBinaryWrapper};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tweakcc-fixed",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Maintained fork of tweakcc — patch an installed Claude Code (npm or native binary) with curated system-prompt overrides, system-reminder overrides, and fork-only patches. Pairs with skrabe/lobotomized-claude-code.",
|
|
6
6
|
"main": "dist/lib/index.mjs",
|