tweakcc-fixed 2.8.36 → 2.8.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/dist/{config-Dwb_vz4w.mjs → config-h2_qLiXs.mjs} +2 -2
- package/dist/{content-BsLQW1df.mjs → content-Co05XSpg.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/{nativeInstallation-CuznnR3v.mjs → nativeInstallation-Cs5d5CP9.mjs} +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/tweakcc-fixed)
|
|
8
8
|
[](https://www.npmjs.com/package/tweakcc-fixed)
|
|
9
|
-
[](https://github.com/anthropics/claude-code)
|
|
10
10
|
[](#credit--license)
|
|
11
11
|
|
|
12
12
|
**[Install](#install) · [Customize](#what-you-can-customize) · [The fork](#what-this-fork-adds) · [How it works](#how-it-works)**
|
|
@@ -57,13 +57,11 @@ The biggest difference is coverage. Its extractor pulls over ten times the promp
|
|
|
57
57
|
|
|
58
58
|
| | tweakcc-fixed | upstream |
|
|
59
59
|
| ---------------------------- | :-----------: | :-------: |
|
|
60
|
-
| Prompt sites (CC 2.1.
|
|
61
|
-
| Unique prompt IDs | **10,
|
|
60
|
+
| Prompt sites (CC 2.1.292) | **11,371** | 870 |
|
|
61
|
+
| Unique prompt IDs | **10,768** | 870 |
|
|
62
62
|
| Patches | **64** | 49 |
|
|
63
63
|
| Overrides on native installs | **yes** | gated off |
|
|
64
64
|
|
|
65
|
-
¹ Upstream has not published a 2.1.291 catalogue; this is its newest, 2.1.290.
|
|
66
|
-
|
|
67
65
|
That reach shows up in a few mechanisms the base doesn't have. The `<system-reminder>` injections that fire per turn — and never surface as named prompts — become editable: blank one out to drop it, or rewrite it. Each connected MCP server's instruction block can be dropped or rewritten the same way. And where upstream gates system-prompt overrides off for native installs, this fork applies them. It pairs with [lobotomized-claude-code](https://github.com/skrabe/lobotomized-claude-code), a set of per-model override packs tuned against exactly this extraction.
|
|
68
66
|
|
|
69
67
|
The extra patches cluster around a few themes: **memory** (a dream-mode consolidation pass, leaner memory types), **reasoning** (Opus defaulting to max effort, plus the experimental complexity router), **search** (the experimental fff backend), and a run of **correctness fixes** — an honest rewind-summary header, a "summarize from here" that actually starts at the rewind point, quieter empty system-reminders, and more.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c,{createReadStream as l}from"node:fs";import*as u from"node:path";import d from"node:path";import*as f from"fs";import*as p from"path";import*as m from"os";import*as h from"child_process";import*as g from"crypto";import{execFile as _,spawnSync as v}from"node:child_process";import y from"gray-matter";import*as b from"node:crypto";import{randomUUID as x}from"node:crypto";import{fileURLToPath as S}from"node:url";import{Worker as C}from"node:worker_threads";import{diffWordsWithSpace as w}from"diff";const T=e(import.meta.url),E=(()=>{try{return T(`../package.json`)}catch{return T(`../../package.json`)}})(),D=E.version,O=E.supportedClaudeCode;let k=null;async function A(){if(k!==null)return k;try{return await import(`node-lief`),k=await import(`./nativeInstallation-
|
|
1
|
+
import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c,{createReadStream as l}from"node:fs";import*as u from"node:path";import d from"node:path";import*as f from"fs";import*as p from"path";import*as m from"os";import*as h from"child_process";import*as g from"crypto";import{execFile as _,spawnSync as v}from"node:child_process";import y from"gray-matter";import*as b from"node:crypto";import{randomUUID as x}from"node:crypto";import{fileURLToPath as S}from"node:url";import{Worker as C}from"node:worker_threads";import{diffWordsWithSpace as w}from"diff";const T=e(import.meta.url),E=(()=>{try{return T(`../package.json`)}catch{return T(`../../package.json`)}})(),D=E.version,O=E.supportedClaudeCode;let k=null;async function A(){if(k!==null)return k;try{return await import(`node-lief`),k=await import(`./nativeInstallation-Cs5d5CP9.mjs`),k}catch(e){return J(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&J(e),null}}async function j(e,t){let n=await A();return n?n.extractClaudeJsFromNativeInstallation(e,t):{data:null,clearBytecode:!1,error:`node-lief native module unavailable on this platform/runtime (cannot extract from native installs)`}}async function M(e,t,n,r){let i=await A();if(!i)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");i.repackNativeInstallation(e,t,n,r)}async function N(e){let t=await A();return t?t.resolveNixBinaryWrapper(e):null}const ee=[{id:`routine`,label:`Routine`,effort:`low`,help:`The requested result and method are already clear. The remaining work needs little inference; correctness is readily checked against supplied facts or an established procedure. Further investigation is unnecessary.`},{id:`standard`,label:`Standard`,effort:`medium`,help:`The normal working budget for substantive day-to-day work. Some judgment, information gathering and validation are needed, but ordinary investigation and checks can complete the requested scope. A task need not be trivial or fully specified to fit this level.`},{id:`hard`,label:`Hard`,effort:`high`,help:`Additional independent judgment or verification is materially necessary. Interacting uncertainties or hidden failure modes warrant deeper investigation and cross-checking than ordinary work, even if the overall method is known. More effort is expected to improve correctness, not simply expand the scope.`},{id:`frontier`,label:`Frontier`,effort:`max`,help:`A demanding end-to-end handoff warrants the greatest independent judgment, persistence and extensive verification, with little user iteration to catch omissions. Substantial difficulty remains that high effort is unlikely to resolve adequately. Mere breadth or importance is insufficient; an explicit maximum-effort preference also qualifies.`}],te=`You are a difficulty router for an AI coding agent. Each turn you get a compact running SUMMARY of the session, a CONTEXT block (the model in use and the level you assigned last turn), the most recent exchange (the previous user message and the assistant reply), and the user NEW message. Do two things and output ONLY a JSON object with the keys level and summary - no prose, no code fence.
|
|
2
2
|
|
|
3
3
|
# level
|
|
4
4
|
Pick the integer effort level (0 = least effort, {MAX} = most) for the NEW message, judged IN CONTEXT of the summary, the context block, and the recent exchange:
|
|
@@ -445,7 +445,7 @@ try {
|
|
|
445
445
|
} catch (openErr) { }
|
|
446
446
|
`,l=i.slice(0,a.startIndex)+c+i.slice(a.endIndex);return V(i,l,c,a.startIndex,a.endIndex),l},Ra=/function ([$\w]+)\(\)\{if\(!([$\w]+)\(\)\)return!1;if\(!([$\w]+)\(\)\)return!1;let ([$\w]+)=([$\w]+)\(\);return \4==="firstParty"\|\|\4==="anthropicAws"\}/g,za=/scope:([$\w]+)\(\)\?"global"/g,Ba=`"tengu_sysprompt_using_tool_based_cache"`,Va=/function [$\w]+\([$\w]+,[$\w]+\)\{let [$\w]+=([$\w]+)\(\),[$\w]+=[$\w]+\.findIndex\(/g,Ha=[`You are Claude Code, Anthropic's official CLI for Claude.`,`You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK.`,`You are a Claude agent, built on Anthropic's Claude Agent SDK.`],Ua=e=>e.replace(/\$/g,`\\$`),Wa=e=>{let t=e.indexOf(Ba);if(t===-1)return null;let n=/else if\(([$\w]+)\.has\(/.exec(e.slice(t,t+2e3));if(!n)return null;let r=RegExp(`([$\\w]+)=\\[([$\\w]+(?:,[$\\w]+)*)\\],${Ua(n[1])}=new Set\\(\\1\\)`).exec(e);if(!r)return null;let i=e.slice(Math.max(0,r.index-2e4),r.index),a=[];for(let e of r[2].split(`,`)){let t=[...i.matchAll(RegExp(`(?:var |,)${Ua(e)}=("(?:[^"\\\\]|\\\\.)*"|'(?:[^'\\\\]|\\\\.)*'|\`(?:[^\`\\\\]|\\\\.)*\`)`,`g`))].at(-1);if(!t)return null;a.push(t[1])}return a},Ga=(e,t,n)=>{let r=Wa(t),i=Wa(e);if(r&&i?r.length===i.length&&r.every((e,t)=>e===i[t]):e===t||n!==!0&&(!Ha.every(e=>t.includes(e))||Ha.every(t=>e.includes(t))))return J(`patch: noGlobalCacheScope: identity lines are stock; the global cache scope stays`),e;let a=e.indexOf(Ba);if(a===-1&&!Ra.test(e)&&!za.test(e))return J(`patch: noGlobalCacheScope: no global cache scope in this build`),e;Ra.lastIndex=0,za.lastIndex=0;let o=Math.max(0,a-500),s=a===-1?[]:[...e.slice(o,a).matchAll(Va)];if(s.length!==1)return console.error(`patch: noGlobalCacheScope: failed to find the system-prompt split predicate`),null;let c=s[0][1],l=new Set([...e.matchAll(za)].map(e=>e[1]));if(l.size>0&&(l.size!==1||!l.has(c)))return console.error(`patch: noGlobalCacheScope: scope:X()?"global" does not name the system-prompt split predicate ${c}`),null;let u=[...e.matchAll(Ra)].filter(e=>e[1]===c);if(u.length===0)return e.includes(`function ${c}(){return!1}`)?(J(`patch: noGlobalCacheScope: predicate already answers false`),e):(console.error(`patch: noGlobalCacheScope: failed to find the global-scope predicate ${c}`),null);if(u.length>1)return console.error(`patch: noGlobalCacheScope: the global-scope predicate ${c} matched ${u.length} times`),null;let[d]=u,f=d.index,p=f+d[0].length,m=`function ${c}(){return!1}`,h=e.slice(0,f)+m+e.slice(p);return V(e,h,m,f,p),h},Ka=e=>{let t=e.match(/messagesSummarized:([$\w]+)\.length\},([$\w]+)=([$\w]+)==="up_to"\?\1:([$\w]+),([$\w]+)=\3==="up_to"\?\{\.\.\.([$\w]+),forkContextMessages:\1\}:\6/);if(!t||t.index===void 0)return/messagesSummarized:([$\w]+)\.length\},([$\w]+)=\1,([$\w]+)=\{\.\.\.([$\w]+),forkContextMessages:\1\}/.test(e)?(J(`patch: fixSummarizeFromHere: already applied in this CC build — no-op`),e):(console.error(`patch: fixSummarizeFromHere: failed to find the summarize-direction ternary`),null);let[,n,r,,,i,a]=t,o=`messagesSummarized:${n}.length},${r}=${n},${i}={...${a},forkContextMessages:${n}}`,s=e.slice(0,t.index)+o+e.slice(t.index+t[0].length);return V(e,s,o,t.index,t.index+o.length),s},qa=e=>{let t=[/\.\.\.([$\w]+\([$\w]+,\{[^}]*\}\)),(isCompactSummary:!0,\.\.\.[$\w]+\.length>0\?\{summarizeMetadata:\{messagesSummarized:[$\w]+\.length,userContext:[$\w]+,direction:([$\w]+)\}\})/,/content:([$\w]+\([$\w]+,\{[^}]*\}\)),(isCompactSummary:!0,\.\.\.[$\w]+\.length>0\?\{summarizeMetadata:\{messagesSummarized:[$\w]+\.length,userContext:[$\w]+,direction:([$\w]+)\}\})/,/content:([$\w]+\([$\w]+,!1,[$\w]+,void 0,[$\w]+\)),(isCompactSummary:!0,\.\.\.[$\w]+\.length>0\?\{summarizeMetadata:\{messagesSummarized:[$\w]+\.length,userContext:[$\w]+,direction:([$\w]+)\}\})/],n=null;for(let r of t){if(n=e.match(r),n&&n.index!==void 0)break;n=null}if(!n||n.index===void 0)return e.includes(`.replace(/This session is being continued`)?(J(`patch: fixRewindSummaryHeader: already applied in this CC build — no-op`),e):(console.error(`patch: fixRewindSummaryHeader: failed to find the rewind summary message (summarizeMetadata.direction call site)`),null);if(!e.includes(`This session is being continued from a previous conversation that ran out of context`))return console.error(`patch: fixRewindSummaryHeader: rewind call site found but the compaction header phrase changed — needs re-anchoring`),null;let[,r,i,a]=n,o=n[0].startsWith(`...`),s=`/This session is being continued from a previous conversation that ran out of context\\.[^\\n]*/`,c=`${a}==="up_to"?${JSON.stringify(`This session was rewound at your request, not a context overflow. The summary below covers the earlier portion up to your selected point; the recent messages are kept intact.`)}:${JSON.stringify(`This session was rewound to an earlier point at your request, not a context overflow. The summary below captures the later work you chose to carry forward; the messages above are intact.`)}`,l=o?`...(($rw)=>({...$rw,content:$rw.content.replace(${s},${c})}))(${r}),${i}`:`content:${r}.replace(${s},${c}),${i}`,u=e.slice(0,n.index)+l+e.slice(n.index+n[0].length);return V(e,u,l,n.index,n.index+l.length),u},Ja=(e,t)=>{let n=1,r=t+1,i=0,a=!1,o=null,s=!1;for(;r<e.length;){let t=e[r];if(o){s?s=!1:t===`\\`?s=!0:t===o&&(o=null),r++;continue}if(t===`"`||t===`'`||t==="`")o=t,a=!0;else if(t===`[`||t===`(`||t===`{`)n++,a=!0;else if(t===`]`){if(n===1)return a&&i++,{itemCount:i,closingBracket:r};n--}else t===`)`||t===`}`?n--:t===`,`&&n===1?(a&&i++,a=!1):/\s/.test(t)||(a=!0);r++}return null},Ya=e=>{let t=/(?:=>|\breturn)\s*\[/g,n,r=null;for(;(n=t.exec(e))!==null;){let t=n.index+n[0].length-1,i=e.slice(Math.max(0,n.index-12e3),Math.min(e.length,n.index+12e3));if(!/name:"[^"]+"[\s\S]{0,1200}description:/.test(i))continue;let a=Ja(e,t);a&&a.itemCount>=30&&(!r||a.itemCount>r.items)&&(r={closing:a.closingBracket,items:a.itemCount})}return r?r.closing:(console.error(`patch: findSlashCommandListEndPosition: failed to find arrayStartPattern`),null)},Xa=(e,t)=>{let n=Ya(e);if(n===null)return console.error(`patch: writeSlashCommandDefinition: failed to find slash command array end position`),null;let r=e.slice(0,n)+t+e.slice(n);return V(e,r,t,n,n),r},Za=new Set([`(`,`,`,`=`,`:`,`[`,`!`,`&`,`|`,`?`,`{`,`}`,`;`,`+`,`-`,`*`,`%`,`~`,`^`,`<`,`>`]),Qa=[`return`,`typeof`,`instanceof`,`in`,`of`,`new`,`delete`,`void`,`case`,`do`,`else`,`yield`,`await`],$a=(e,t)=>{let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return!0;let r=e[n];if(Za.has(r))return!0;if(!/[$\w]/.test(r))return!1;let i=n;for(;i>=0&&/[$\w]/.test(e[i]);)i--;return Qa.includes(e.slice(i+1,n+1))},eo=(e,t)=>{let n=e[t],r=t+1;for(;r<e.length;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===n)return r+1;r++}return-1},to=(e,t)=>{let n=t+1,r=!1;for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===`
|
|
447
447
|
`)return-1;if(t===`[`)r=!0;else if(t===`]`)r=!1;else if(t===`/`&&!r){for(n++;n<e.length&&/[a-z]/.test(e[n]);)n++;return n}n++}return-1},no=(e,t)=>{let n=t+1;for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t==="`")return n+1;if(t===`$`&&e[n+1]===`{`){let t=ro(e,n+1);if(t===null)return-1;n=t+1;continue}n++}return-1},ro=(e,t)=>{let n=e[t],r=n===`{`?`}`:n===`(`?`)`:``;if(!r)return null;let i=0,a=t;for(;a<e.length;){let t=e[a];if(t===`/`&&e[a+1]===`/`){let t=e.indexOf(`
|
|
448
|
-
`,a);if(t===-1)return null;a=t+1;continue}if(t===`/`&&e[a+1]===`*`){let t=e.indexOf(`*/`,a+2);if(t===-1)return null;a=t+2;continue}if(t===`"`||t===`'`){let t=eo(e,a);if(t<0)return null;a=t;continue}if(t==="`"){let t=no(e,a);if(t<0)return null;a=t;continue}if(t===`/`&&$a(e,a)){let t=to(e,a);if(t<0)return null;a=t;continue}if(t===n)i++;else if(t===r&&(i--,i===0))return a;a++}return null},io=e=>{let t=e.match(/[^$\w][$\w]+\(([$\w]+),\{[\s\S]{0,100}"Yes, use recommended settings"/);if(t)return t[1];let n=e.match(/\.jsxs?\(([$\w]+),\{[\s\S]{0,100}"Yes, use recommended settings"/);if(n)return n[1];let r=e.match(/\.createElement\(([$\w]+),.{0,100}"Yes, use recommended settings"/);return r?r[1]:(console.error(`patch: findSelectComponentName: failed to find selectPattern`),null)},H=(e,t,n,r)=>{let i=`(process.env.TWEAKCC_TOOLSET_DEFAULT||${t?JSON.stringify(t):`undefined`})`,a=`(process.env.TWEAKCC_TOOLSET_ALLOW_EDITS||${n?JSON.stringify(n):i})`;return`${e}.toolPermissionContext?.mode!=="plan"&&${e}.toolsetAutoMode==="plan"?${i}:(${e}.toolset??(${e}.toolPermissionContext?.mode==="plan"?${`(process.env.TWEAKCC_TOOLSET_PLAN||${r?JSON.stringify(r):i})`}:(${e}.toolPermissionContext?.mode==="acceptEdits"?${a}:(${e}.toolPermissionContext?.mode==="auto"?${`(process.env.TWEAKCC_TOOLSET_AUTO||${i})`}:${i}))))`},ao=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)(?:\([$\w]+\)\{let [$\w]+=[$\w]+\(\d+\),\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+,?)+\}=|\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\))/g));if(t.length===0)return null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},oo=`/*@@TWEAKCC_MODULE:`,so=(e,t)=>{let n=e.lastIndexOf(oo,t);if(n===-1)return null;let r=e.indexOf(oo,n+1);return{start:n,end:r===-1?e.length:r}},co=(e,t,n,r)=>{let i=so(e,n),a=so(e,r);if(!i||!a||i.start===a.start)return t;let o=e.slice(i.start,i.end).match(/export\{([^}]+)\}/);if(!o)return t;let s=null;for(let e of o[1].split(`,`)){let n=e.match(/^([$\w]+)(?: as ([$\w]+))?$/);if(n&&n[1]===t){s=n[2]??n[1];break}}if(!s)return t;let c=e.slice(a.start,Math.min(a.end,a.start+8e4)),l=s.replace(/\$/g,`\\$`),u=c.match(RegExp(`(?:^|[,{])${l} as ([\$\\w]+)`));return u?u[1]:t},lo=e=>{let t=e.indexOf(`useAppState/useSetAppState cannot be called outside of an <AppStateProvider />`);if(t!==-1){let n=so(e,t),r=n?n.start:t,i=n?n.end:e.length,a=e.slice(r,i),o=/function ([$\w]+)\(([$\w]+)\)\{let ([$\w]+)=([$\w]+)\(\);return [$\w]+\(\3,\2\)\}/,s=/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/,c=a.match(o),l=a.match(s);if(c&&c.index!==void 0&&l&&l.index!==void 0)return{appStateUseSelectorFn:c[1],appStateSetState:l[1],selectorIndex:r+c.index,setStateIndex:r+l.index};let u=Math.max(0,t-400),d=e.slice(u,t+1200),f=/function ([$\w]+)\(([$\w]+)\)\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=\(\)=>\{let ([$\w]+)=\3\.getState\(\);return \2\(\6\)\};return [$\w]+\(\3\.subscribe,\5,\5\)\}/,p=/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/,m=d.match(f),h=d.match(p);if(m&&m.index!==void 0&&h&&h.index!==void 0)return{appStateUseSelectorFn:m[1],appStateSetState:h[1],selectorIndex:u+m.index,setStateIndex:u+h.index}}let n=e.match(/function ([$\w]+)\(.{0,110}`Your selector in.{0,1000}?function ([$\w]+)\(\)\{return [$\w]+\(\)\.setState\}/);if(n)return{appStateUseSelectorFn:n[1],appStateSetState:n[2],selectorIndex:n.index};let r=Array.from(e.matchAll(/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/g));for(let t of r){let n=t[1],r=t[2].replace(/\$/g,`\\$`),i=RegExp(`function ([$\\w]+)\\([$\\w]+\\)\\{(?:(?!\\bfunction\\b).){0,300}${r}\\(\\)(?:(?!\\bfunction\\b).){0,300}useSyncExternalStore\\(`),a=e.match(i);if(!a)continue;let o=a[1],s=o.replace(/\$/g,`\\$`);if(RegExp(`${s}\\(.{0,80}thinkingEnabled`).test(e))return{appStateUseSelectorFn:o,appStateSetState:n,selectorIndex:a.index,setStateIndex:t.index}}return console.error(`patch: getAppStateSelectorAndUseState: failed to find pattern`),null},uo=e=>{let t=Ya(e);if(t===null)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd`),null;let n=1,r=t;for(;r>=0&&n>0;){if(e[r]===`}`)n++;else if(e[r]===`{`&&(n--,n===0))break;r--}if(r<0)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace`),null;for(;r>=0&&e[r]!==`;`;)r--;return r<0?(console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon`),null):r+1},fo=e=>{let t=Array.from(e.matchAll(/thinkingEnabled:([$\w]+)\(\)/g));if(t.length===0)return console.error(`patch: toolsets: failed to find thinkingEnabled pattern`),null;let n=[];for(let e of t)if(e.index!==void 0){let t=e.index+e[0].length;n.push({index:t})}n.sort((e,t)=>t.index-e.index);let r=e,i=`,toolset:undefined,toolsetAutoMode:null`;for(let e of n)r=r.slice(0,e.index)+i+r.slice(e.index);if(r===e)return console.error(`patch: toolsets: failed to modify app state initialization`),null;let a=n[n.length-1];return V(e,r,i,a.index,a.index),r},po=(e,t,n,r,i)=>{let a=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),o=e.match(/renderingTools:this\.addDisplayOnlyTools\(([$\w]+)
|
|
448
|
+
`,a);if(t===-1)return null;a=t+1;continue}if(t===`/`&&e[a+1]===`*`){let t=e.indexOf(`*/`,a+2);if(t===-1)return null;a=t+2;continue}if(t===`"`||t===`'`){let t=eo(e,a);if(t<0)return null;a=t;continue}if(t==="`"){let t=no(e,a);if(t<0)return null;a=t;continue}if(t===`/`&&$a(e,a)){let t=to(e,a);if(t<0)return null;a=t;continue}if(t===n)i++;else if(t===r&&(i--,i===0))return a;a++}return null},io=e=>{let t=e.match(/[^$\w][$\w]+\(([$\w]+),\{[\s\S]{0,100}"Yes, use recommended settings"/);if(t)return t[1];let n=e.match(/\.jsxs?\(([$\w]+),\{[\s\S]{0,100}"Yes, use recommended settings"/);if(n)return n[1];let r=e.match(/\.createElement\(([$\w]+),.{0,100}"Yes, use recommended settings"/);return r?r[1]:(console.error(`patch: findSelectComponentName: failed to find selectPattern`),null)},H=(e,t,n,r)=>{let i=`(process.env.TWEAKCC_TOOLSET_DEFAULT||${t?JSON.stringify(t):`undefined`})`,a=`(process.env.TWEAKCC_TOOLSET_ALLOW_EDITS||${n?JSON.stringify(n):i})`;return`${e}.toolPermissionContext?.mode!=="plan"&&${e}.toolsetAutoMode==="plan"?${i}:(${e}.toolset??(${e}.toolPermissionContext?.mode==="plan"?${`(process.env.TWEAKCC_TOOLSET_PLAN||${r?JSON.stringify(r):i})`}:(${e}.toolPermissionContext?.mode==="acceptEdits"?${a}:(${e}.toolPermissionContext?.mode==="auto"?${`(process.env.TWEAKCC_TOOLSET_AUTO||${i})`}:${i}))))`},ao=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)(?:\([$\w]+\)\{let [$\w]+=[$\w]+\(\d+\),\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+,?)+\}=|\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\))/g));if(t.length===0)return null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},oo=`/*@@TWEAKCC_MODULE:`,so=(e,t)=>{let n=e.lastIndexOf(oo,t);if(n===-1)return null;let r=e.indexOf(oo,n+1);return{start:n,end:r===-1?e.length:r}},co=(e,t,n,r)=>{let i=so(e,n),a=so(e,r);if(!i||!a||i.start===a.start)return t;let o=e.slice(i.start,i.end).match(/export\{([^}]+)\}/);if(!o)return t;let s=null;for(let e of o[1].split(`,`)){let n=e.match(/^([$\w]+)(?: as ([$\w]+))?$/);if(n&&n[1]===t){s=n[2]??n[1];break}}if(!s)return t;let c=e.slice(a.start,Math.min(a.end,a.start+8e4)),l=s.replace(/\$/g,`\\$`),u=c.match(RegExp(`(?:^|[,{])${l} as ([\$\\w]+)`));return u?u[1]:t},lo=e=>{let t=e.indexOf(`useAppState/useSetAppState cannot be called outside of an <AppStateProvider />`);if(t!==-1){let n=so(e,t),r=n?n.start:t,i=n?n.end:e.length,a=e.slice(r,i),o=/function ([$\w]+)\(([$\w]+)\)\{let ([$\w]+)=([$\w]+)\(\);return [$\w]+\(\3,\2\)\}/,s=/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/,c=a.match(o),l=a.match(s);if(c&&c.index!==void 0&&l&&l.index!==void 0)return{appStateUseSelectorFn:c[1],appStateSetState:l[1],selectorIndex:r+c.index,setStateIndex:r+l.index};let u=Math.max(0,t-400),d=e.slice(u,t+1200),f=/function ([$\w]+)\(([$\w]+)\)\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=\(\)=>\{let ([$\w]+)=\3\.getState\(\);return \2\(\6\)\};return [$\w]+\(\3\.subscribe,\5,\5\)\}/,p=/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/,m=d.match(f),h=d.match(p);if(m&&m.index!==void 0&&h&&h.index!==void 0)return{appStateUseSelectorFn:m[1],appStateSetState:h[1],selectorIndex:u+m.index,setStateIndex:u+h.index}}let n=e.match(/function ([$\w]+)\(.{0,110}`Your selector in.{0,1000}?function ([$\w]+)\(\)\{return [$\w]+\(\)\.setState\}/);if(n)return{appStateUseSelectorFn:n[1],appStateSetState:n[2],selectorIndex:n.index};let r=Array.from(e.matchAll(/function ([$\w]+)\(\)\{return ([$\w]+)\(\)\.setState\}/g));for(let t of r){let n=t[1],r=t[2].replace(/\$/g,`\\$`),i=RegExp(`function ([$\\w]+)\\([$\\w]+\\)\\{(?:(?!\\bfunction\\b).){0,300}${r}\\(\\)(?:(?!\\bfunction\\b).){0,300}useSyncExternalStore\\(`),a=e.match(i);if(!a)continue;let o=a[1],s=o.replace(/\$/g,`\\$`);if(RegExp(`${s}\\(.{0,80}thinkingEnabled`).test(e))return{appStateUseSelectorFn:o,appStateSetState:n,selectorIndex:a.index,setStateIndex:t.index}}return console.error(`patch: getAppStateSelectorAndUseState: failed to find pattern`),null},uo=e=>{let t=Ya(e);if(t===null)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find arrayEnd`),null;let n=1,r=t;for(;r>=0&&n>0;){if(e[r]===`}`)n++;else if(e[r]===`{`&&(n--,n===0))break;r--}if(r<0)return console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching open-brace`),null;for(;r>=0&&e[r]!==`;`;)r--;return r<0?(console.error(`patch: findTopLevelPositionBeforeSlashCommand: failed to find matching semicolon`),null):r+1},fo=e=>{let t=Array.from(e.matchAll(/thinkingEnabled:([$\w]+)\(\)/g));if(t.length===0)return console.error(`patch: toolsets: failed to find thinkingEnabled pattern`),null;let n=[];for(let e of t)if(e.index!==void 0){let t=e.index+e[0].length;n.push({index:t})}n.sort((e,t)=>t.index-e.index);let r=e,i=`,toolset:undefined,toolsetAutoMode:null`;for(let e of n)r=r.slice(0,e.index)+i+r.slice(e.index);if(r===e)return console.error(`patch: toolsets: failed to modify app state initialization`),null;let a=n[n.length-1];return V(e,r,i,a.index,a.index),r},po=(e,t,n,r,i)=>{let a=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),o=e.match(/renderingTools:this\.addDisplayOnlyTools\(([$\w]+)(?=[,)])/);if(o&&o.index!==void 0){let t=/derive\(\)\{let ([$\w]+)=this\.store\.getState\(\)/g,s=null;for(let n of e.matchAll(t))if(n.index!==void 0&&n.index<o.index)s=n;else break;if(!s||s.index===void 0)return console.error(`patch: toolsets: toolFetchingMemo: failed to find derive() for renderingTools`),null;let c=s[1],l=o[1],u=`const __ts=${a},__tf=(t,s)=>{const n=${H(`s`,n,r,i)};globalThis.__tweakcc_toolset={name:n,tools:__ts[n]};if(__ts.hasOwnProperty(n)){const a=__ts[n];if(a==="*")return t;return t.filter(d=>a.includes(d.name))}return t};`,d=`renderingTools:this.addDisplayOnlyTools(__tf(${l},${c})`,f=e.slice(0,o.index)+d+e.slice(o.index+o[0].length),p=s.index+9;return f=f.slice(0,p)+u+f.slice(p),V(e,f,d,o.index,o.index),f}let s=lo(e);if(!s)return console.error(`patch: toolsets: toolFetchingMemo: failed to find app state info`),null;let{appStateUseSelectorFn:c,selectorIndex:l}=s,u=e.match(/let ([$\w]+)=([$\w]+\([$\w]+,[$\w]+\.tools,[$\w]+\)),/);if(!u||u.index===void 0)return console.error(`patch: toolsets: failed to find tool aggregation pattern`),null;let d=l===void 0?c:co(e,c,l,u.index),f=u[1],p=u[2],m=`let currentToolset = ${d}(state => ${H(`state`,n,r,i)});
|
|
449
449
|
let ${f} = undefined;
|
|
450
450
|
const toolsets = ${a};
|
|
451
451
|
if (toolsets.hasOwnProperty(currentToolset)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as e,d as t,g as n,gt as r,ht as i,j as a,l as o,m as s,mt as c,n as ee,p as l,r as u,w as d}from"./config-
|
|
1
|
+
import{T as e,d as t,g as n,gt as r,ht as i,j as a,l as o,m as s,mt as c,n as ee,p as l,r as u,w as d}from"./config-h2_qLiXs.mjs";import{Box as f,Text as p,render as m,useInput as h}from"ink";import g,{useState as _}from"react";import*as te from"node:os";import v from"node:os";import*as y from"node:fs/promises";import b from"node:fs/promises";import x from"path";import{jsx as S,jsxs as C}from"react/jsx-runtime";import w from"which";import{globbySync as T}from"globby";const E=(()=>{let e=[],t=process.platform==`win32`?v.homedir().replace(/\\/g,`/`):v.homedir(),n=`node_modules/@anthropic-ai/claude-code`,r=(t,n=!1)=>{if(n)try{let n=T(t,{onlyFiles:!1});e.push({pattern:t,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?s(`Permission denied accessing: ${t} (${n.code})`):s(`Error expanding glob pattern "${t}": ${n instanceof Error?n.message:String(n)}`),e.push({pattern:t,isGlob:!0,expandedPaths:[]})}else e.push({pattern:t,isGlob:!1,expandedPaths:[t]})};return r(`${v.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform==`win32`?(r(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),r(`${t}/AppData/Roaming/npm/${n}`),r(`${t}/AppData/Roaming/nvm/*/${n}`,!0),r(`${t}/AppData/Local/Yarn/config/global/${n}`),r(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),r(`C:/nvm4w/nodejs/${n}`),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/AppData/Roaming/Yarn/config/global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/Bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0),r(`${t}/AppData/Local/mise/installs/node/*/${n}`,!0),r(`${t}/AppData/Local/mise/installs/npm-anthropic-ai-claude-code/*/${n}`,!0)):(process.platform==`darwin`&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/Library/Caches/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0)),r(`${t}/.local/lib/${n}`),r(`${t}/.local/share/${n}`),r(`${t}/.npm-global/lib/${n}`),r(`${t}/.npm-packages/lib/${n}`),r(`${t}/.npm/lib/${n}`),r(`${t}/npm/lib/${n}`),r(`/etc/${n}`),r(`/lib/${n}`),r(`/opt/node/lib/${n}`),r(`/usr/lib/${n}`),r(`/usr/local/lib/${n}`),r(`/usr/share/${n}`),r(`/var/lib/${n}`),r(`/opt/homebrew/lib/${n}`),r(`${t}/.linuxbrew/lib/${n}`),r(`${t}/.config/yarn/global/${n}`),r(`${t}/.yarn/global/${n}`),r(`${t}/.bun/install/global/${n}`),r(`${t}/.pnpm-global/${n}`),r(`${t}/.pnpm-global/*/${n}`,!0),r(`${t}/pnpm-global/${n}`),r(`${t}/pnpm-global/*/${n}`,!0),r(`${t}/.local/share/pnpm/global/${n}`),r(`${t}/.local/share/pnpm/global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/.local/share/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`/usr/local/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/lib/${n}`),r(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),r(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),r(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nodenv/versions/*/lib/${n}`,!0),r(`${t}/.nvs/*/lib/${n}`,!0),r(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0)),process.platform==`win32`&&e.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),e})().flatMap(e=>e.expandedPaths),ne=(()=>{let e=process.platform===`win32`?v.homedir().replace(/\\/g,`/`):v.homedir(),t=[],n=(e,n=!1)=>{if(n)try{let n=T(e,{onlyFiles:!0});t.push({pattern:e,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?s(`Permission denied accessing: ${e} (${n.code})`):s(`Error expanding glob pattern "${e}": ${n instanceof Error?n.message:String(n)}`),t.push({pattern:e,isGlob:!0,expandedPaths:[]})}else t.push({pattern:e,isGlob:!1,expandedPaths:[e]})};if(n(`${e}/.local/bin/claude`),process.platform===`win32`&&(n(`${e}/.nvm/versions/node/v22.21.1/lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`),n(`${e}/.local/bin/claude.exe`)),n(`${e}/.local/share/claude/versions/*`,!0),process.platform!==`win32`){let t=`lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`,r=process.env.MISE_DATA_DIR||`${e}/.local/share/mise`;n(`${r}/installs/node/*/${t}`,!0),n(`${r}/installs/npm-anthropic-ai-claude-code/*/${t}`,!0)}return process.platform===`win32`&&t.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),t})().flatMap(e=>e.expandedPaths);var D=class extends Error{constructor(e){super(e),this.name=`InstallationDetectionError`}};let O=null;async function re(){return O||=(async()=>{try{let{WASMagic:e}=await import(`wasmagic`);return await e.create()}catch(e){return s(`WASMagic initialization failed (likely SIMD unsupported on this CPU):`,e),s(`Using fallback file type detection`),null}})(),O}const ie=Buffer.from([127,69,76,70]),ae=Buffer.from([254,237,250,206]),oe=Buffer.from([254,237,250,207]),se=Buffer.from([206,250,237,254]),k=Buffer.from([207,250,237,254]),A=Buffer.from([202,254,186,190]),j=Buffer.from([77,90]);function M(e){if(e.length===0)return null;if(e[0]===35&&e[1]===33&&e.subarray(0,Math.min(256,e.length)).toString(`utf8`).split(`
|
|
2
2
|
`)[0].includes(`node`))return s(`detectFileTypeFallback: Detected JavaScript via shebang`),`javascript`;if(e.length>=4){let t=e.subarray(0,4);if(t.equals(ie))return s(`detectFileTypeFallback: Detected ELF binary`),`binary`;if(t.equals(ae)||t.equals(oe)||t.equals(se)||t.equals(k)||t.equals(A))return s(`detectFileTypeFallback: Detected Mach-O binary`),`binary`}if(e.length>=2&&e.subarray(0,2).equals(j))return s(`detectFileTypeFallback: Detected PE binary`),`binary`;let t=Math.min(512,e.length),n=0,r=0;for(let i=0;i<t;i++){let t=e[i];(t>=32&&t<=126||t===9||t===10||t===13)&&n++,t===0&&r++}if(r>0)return s(`detectFileTypeFallback: Detected binary (${r} null bytes in first ${t} bytes)`),`binary`;let i=n/t;return i>.9?(s(`detectFileTypeFallback: Detected JavaScript via text heuristic (${Math.round(i*100)}% printable)`),`javascript`):(s(`detectFileTypeFallback: Unknown file type (${Math.round(i*100)}% printable)`),null)}async function N(e,t=4096){try{let n=await b.open(e,`r`);try{let e=Buffer.allocUnsafe(t),{bytesRead:r}=await n.read({buffer:e,position:0,length:t});return r<=0?null:e.subarray(0,r)}finally{await n.close()}}catch(e){return s(`Failed to read file prefix:`,e),null}}async function P(e){if(process.platform===`win32`)return e;let t=await r(e);return t?(s(`maybeResolveNixWrapper: resolved Nix wrapper ${e} -> ${t}`),t):e}async function F(e){try{let t=await b.realpath(e);s(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await N(t);if(!n)return s(`resolvePathToInstallationType: Could not read file prefix`),null;let r=await re();if(r&&typeof r.detect==`function`){let e=r.detect(n)||null;if(e){let n=e.toLowerCase();return s(`resolvePathToInstallationType: Detected mime type: ${n}`),n.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:n.startsWith(`text/`)?(s(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:await P(t)}}}s(`resolvePathToInstallationType: Using fallback file type detection`);let i=M(n);return i===`javascript`?{kind:`npm-based`,resolvedPath:t}:i===`binary`?{kind:`native-binary`,resolvedPath:await P(t)}:(s(`resolvePathToInstallationType: Fallback could not determine file type`),null)}catch(e){return s(`resolvePathToInstallationType: Error:`,e),null}}async function I(){s(`getClaudeFromPath: PATH = ${process.env.PATH}`),s(`getClaudeFromPath: PATHEXT = ${process.env.PATHEXT}`);try{let e=await w(`claude`);return s(`getClaudeFromPath: Found claude at ${e}`),e}catch{return s(`getClaudeFromPath: claude not found on PATH`),null}}function L(e){let t=/\bVERSION:"(\d+\.\d+\.\d+)"/g,n=new Map,r;for(;(r=t.exec(e))!==null;){let e=r[1];n.set(e,(n.get(e)||0)+1)}if(n.size===0)return null;let i=0,a;for(let[e,t]of n.entries())s(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&s(`Extracted version ${a} (${i} occurrences)`),a||null}async function R(e){let t=L(await b.readFile(e,`utf8`));if(!t)throw Error(`No VERSION strings found in JS file: ${e}`);return t}async function z(e){let{data:t,error:n}=await c(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}${n?` (${n})`:``}`);let r=L(t.toString(`utf8`));if(!r)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return r}function B(e){let t=x.basename(e).match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function V(e,t){let n=B(e);return n?(s(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?R(e):z(e)}async function H(){let e=[],t=new Set;for(let r of E){let i=x.join(r,`cli.js`);try{if(await n(i)){let n=await b.realpath(i).catch(()=>i);if(t.has(n))continue;t.add(n),s(`collectCandidates: Found cli.js at ${n}`);let r=await R(n);e.push({path:n,kind:`npm-based`,version:r})}}catch(e){s(`collectCandidates: Error checking ${i}:`,e)}}for(let r of ne)try{if(await n(r)){let n=await b.realpath(r).catch(()=>r);if(t.has(n))continue;t.add(n);let i=await P(n);s(`collectCandidates: Found native binary at ${n}${i===n?``:` (resolved -> ${i})`}`);let a=await V(i,`native-binary`);e.push({path:i,kind:`native-binary`,version:a})}}catch(e){s(`collectCandidates: Error checking ${r}:`,e)}return[...e].sort((e,t)=>l(t.version,e.version))}function U(e){return e.map(e=>` • ${e.path} (${e.kind}, v${e.version})`).join(`
|
|
3
3
|
`)}function W(e){return` 2. Set ccInstallationPath in your config file (${u}):
|
|
4
4
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,N as p,O as m,P as h,Q as g,R as _,S as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_ as ee,_t as T,a as te,at as E,b as D,ct as O,d as k,dt as A,et as j,f as M,ft as N,g as ne,h as re,i as ie,k as ae,l as oe,lt as se,m as P,mt as ce,n as F,nt as le,o as I,ot as ue,pt as de,q as fe,r as pe,s as me,st as he,t as L,tt as ge,u as _e,ut as ve,v as ye,vt as be,x as xe,y as Se,z as Ce}from"./config-Dwb_vz4w.mjs";import{a as we,c as Te,d as Ee,l as De,n as Oe,o as ke,s as Ae,t as je,u as Me}from"./content-BsLQW1df.mjs";import{Box as R,Text as z,render as Ne,useInput as B,useStdin as Pe,useStdout as Fe}from"ink";import{Command as Ie}from"commander";import V from"chalk";import Le,{Fragment as Re,createContext as ze,useCallback as Be,useContext as H,useEffect as U,useMemo as Ve,useRef as He,useState as W}from"react";import*as Ue from"node:os";import We from"ink-link";import*as Ge from"node:fs/promises";import*as G from"node:fs";import*as K from"node:path";import{execFile as Ke,execSync as qe,spawn as Je}from"node:child_process";import Ye from"gray-matter";import{structuredPatch as Xe}from"diff";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import Ze from"process";import Qe from"cli-spinners";import*as $e from"node:readline";var X=({children:e,...t})=>Y(z,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...t,children:[` `,e,` `]});const et=[`\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 tt=()=>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(We,{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:et.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 nt({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 rt=[{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`}],it=[{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 (${pe})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var at=({onSubmit:e})=>{let t=[...rt,...it],[n,r]=W(0);return J(nt,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const ot=()=>Y(R,{flexDirection:`row`,children:[J(X,{children:`tweakcc`}),J(z,{children:` (by `}),J(We,{url:`https://piebald.ai`,fallback:!1,children:J(z,{color:`#ff8400`,bold:!0,children:`Piebald`})}),J(z,{children:`)`})]}),st=()=>J(R,{children:Y(z,{color:`yellow`,children:[`⭐ `,J(z,{bold:!0,children:`Star the repo at `}),J(We,{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!`}),` ⭐`]})}),ct=({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})}),lt=({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(ot,{}),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 `,F.replace(Ue.homedir(),`~`),`/config.json.`]})]})}),J(r?tt:st,{}),t&&J(ct,{notification:t}),!i&&!t&&J(ct,{notification:{message:`Your changes are configured but not applied.\nRun \`${a} --apply\` to apply your customizations!`,type:`info`}}),J(at,{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(Le.Children.toArray(i).some(e=>Le.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=Le.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 ut({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 dt=Ze.cwd();function ft({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:`▛▘`}),` `,r(),` · `,xe()]}),Y(Q,{color:e.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,dt]}),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(ut,{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 pt({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 mt({initialValue:e,onColorChange:t,onExit:n,colorKey:r,theme:a}){let o=gt(e)||{h:0,s:50,l:50},s=ht(e)||{r:128,g:128,b:128},[c,l]=W(o),[u,d]=W(s),[f,p]=W(`hsl`),[h,g]=W(`h`),[_,v]=W(!1),[y,b]=W(!1);U(()=>{let t=gt(e),n=ht(e);t&&n&&(v(!0),l(t),d(n),v(!1))},[e]),U(()=>{!_&&y&&t(`rgb(${u.r},${u.g},${u.b})`)},[c,u,_,y]),U(()=>{b(!0)},[]);let x=e=>{if(i(e)){let t=m(e),n=gt(t),r=ht(t);n&&r&&(v(!0),l(n),d(r),v(!1))}};B((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){x(e);return}t.return||t.escape?n():t.ctrl&&e===`a`?(p(e=>e===`hsl`?`rgb`:`hsl`),g(e=>f===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?g(f===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?g(f===`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),f===`hsl`?l(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 d({r,g:i,b:a}),n}):d(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))),l(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)]},ee=()=>{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},T=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(c.h,n,c.l);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},te=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(c.h,c.s,n);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},E=()=>{let[e,t,n]=w(c.h,c.s,c.l);return`rgb(${e},${t},${n})`},D=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},O=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${n},${u.g},${u.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(${u.r},${n},${u.b})`,children:` `},t))}return e},A=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${u.r},${u.g},${n})`,children:` `},t))}return e},j=(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`})]})]}),f===`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 (`,c.h,`°):`]})}),J(R,{children:ee().map((e,t)=>J(Re,{children:t===j(c.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 (`,c.s,`%):`]})}),J(R,{children:T().map((e,t)=>J(Re,{children:t===j(c.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 (`,c.l,`%):`]})}),J(R,{children:te().map((e,t)=>J(Re,{children:t===j(c.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 (`,u.r,`):`]})}),J(R,{children:O().map((e,t)=>J(Re,{children:t===j(u.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 (`,u.g,`):`]})}),J(R,{children:k().map((e,t)=>J(Re,{children:t===j(u.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 (`,u.b,`):`]})}),J(R,{children:A().map((e,t)=>J(Re,{children:t===j(u.b,255)?J(z,{children:`|`}):e},t))})]})]}),Y(R,{marginBottom:1,children:[J(z,{children:`Current: `}),J(z,{backgroundColor:E(),children:` `})]}),Y(R,{flexDirection:`row`,justifyContent:`space-between`,children:[Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Hex `}),r?.startsWith(`diff`)?J(z,{backgroundColor:E(),color:a?.colors?.text||`white`,bold:!0,children:D(u.r,u.g,u.b)}):r===`inverseText`?J(z,{color:E(),backgroundColor:a?.colors?.permission,bold:!0,children:D(u.r,u.g,u.b)}):J(z,{color:E(),bold:!0,children:D(u.r,u.g,u.b)})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`RGB `}),r?.startsWith(`diff`)?J(z,{backgroundColor:E(),color:a?.colors?.text||`white`,bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`}):r===`inverseText`?J(z,{color:E(),backgroundColor:a?.colors?.permission,bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`}):J(z,{color:E(),bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`HSL `}),r?.startsWith(`diff`)?J(z,{backgroundColor:E(),color:a?.colors?.text||`white`,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):r===`inverseText`?J(z,{color:E(),backgroundColor:a?.colors?.permission,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):J(z,{color:E(),bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`})]})]})]})}function ht(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 gt(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 _t({onBack:e,themeId:t}){let{settings:{themes:n},updateSettings:r}=H($),[a,o]=W(t),s=n.find(e=>e.id===a)||n[0],[c,l]=W(`rgb`),[u,d]=W(0),[f,p]=W(null),[g,_]=W(null),[v,y]=W(``),[b,x]=W(``),[S,C]=W(!1),[w,ee]=W(0),T=Be(e=>{r(t=>{let n=t.themes.findIndex(e=>e.id===a);n!==-1&&e(t.themes[n])})},[a,r]),te=e=>{if(u>=2&&i(e)){let t=m(e),n=E[u-2];T(e=>{e.colors[n]=t})}};B((t,n)=>{if(S){if(n.escape){C(!1),e();return}return}if(f===null&&g===null){if(t.length>1&&!n.ctrl&&!n.meta){te(t);return}if(n.escape)C(!0),ee(0);else if(n.ctrl&&t===`a`)l(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(n.upArrow)d(e=>Math.max(0,e-1));else if(n.downArrow)d(e=>Math.min(E.length+1,e+1));else if(n.return)if(u===0)_(`name`),y(s.name),x(s.name);else if(u===1)_(`id`),y(s.id),x(s.id);else{let e=u-2,t=E[e],n=s.colors[t];p(e),y(n),x(n)}}else if(f!==null)n.ctrl&&t===`a`&&l(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(g!==null)if(n.return){if(g===`id`){let e=a;o(v),r(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=v)})}else T(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 E=Object.keys(s.colors),D=(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}},O=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(...E.map(e=>e.length));return Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(X,{children:[`Editing theme “`,s.name,`” (`,s.id,`)`]})}),S?Y(R,{flexDirection:`column`,marginTop:1,children:[J(R,{marginBottom:1,children:Y(z,{bold:!0,children:[`Would you like to make “`,s.name,`” your current Claude Code theme?`]})}),J(nt,{items:[{name:`Yes`,desc:`Set ${s.id} as active theme`},{name:`No`,desc:`Go back without changing theme`}],selectedIndex:w,onSelect:ee,onSubmit:()=>{w===0&&h(s.id),C(!1),e()}}),J(z,{dimColor:!0,children:`enter to select, esc to cancel`})]}):f===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`})]}),u<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:u===0?`Theme Name`:`Theme ID`}),J(z,{children:u===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:s.colors[E[u-2]],flexDirection:`column`,paddingLeft:1,children:[J(pt,{colorKey:E[u-2],theme:s,bold:!0}),J(z,{children:O(E[u-2])})]}),Y(R,{flexDirection:`column`,children:[Y(R,{children:[J(z,{color:u===0?`yellow`:`white`,children:u===0?`❯ `:` `}),J(z,{bold:!0,children:`Name: `}),J(z,{children:s.name})]}),Y(R,{marginBottom:1,children:[J(z,{color:u===1?`yellow`:`white`,children:u===1?`❯ `:` `}),J(z,{bold:!0,children:`ID: `}),J(z,{children:s.id})]}),(()=>{if(u<2)return Y(q,{children:[E.slice(0,20).map((e,t)=>{let n=t+2;return Y(R,{children:[J(z,{color:u===n?`yellow`:`white`,children:u===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(pt,{colorKey:e,theme:s,bold:!0})})}),J(Q,{color:s.colors[e],children:D(s.colors[e],c)})]},e)}),E.length>20&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,E.length-20,` more below`]})]});let e=u-2,t=Math.max(0,e-10),n=Math.min(E.length,t+20),r=Math.max(0,n-20),i=E.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:u===n?`yellow`:`white`,children:u===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(pt,{colorKey:e,theme:s,bold:!0})})}),J(Q,{color:s.colors[e],children:D(s.colors[e],c)})]},e)}),n<E.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,E.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(mt,{initialValue:b,colorKey:E[f],theme:s,onColorChange:e=>{y(e),T(t=>{t.colors[E[f]]=e})},onExit:()=>{T(e=>{e.colors[E[f]]=v}),p(null),y(``),x(``)}})]}),J(R,{width:`50%`,children:J(ft,{theme:s})})]})}const vt=`https://raw.githubusercontent.com/Piebald-AI/claude-code-themes/main`,yt=`${vt}/index.json`,bt=2e4;async function xt(){P(`Fetching community theme index from ${yt}`);let e=await fetch(yt,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(bt)});if(!e.ok)throw Error(`Failed to fetch community theme index: ${e.status} ${e.statusText}`);return JSON.parse(await t(e))}async function St(e){let n=`${vt}/themes/${e}.json`;P(`Fetching community theme from ${n}`);let r=await fetch(n,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(bt)});if(!r.ok)throw Error(`Failed to fetch community theme "${e}": ${r.status} ${r.statusText}`);return JSON.parse(await t(r))}function Ct({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=He(0);U(()=>{xt().then(e=>{r({status:`loaded`,entries:e})}).catch(e=>{r({status:`error`,message:e.message})})},[]);let p=n.status===`loaded`?n.entries:[],m=Be(async e=>{let t=++f.current;l(!0),d(null);try{let n=await St(e);if(t!==f.current)return;s(re(n,de))}catch{if(t!==f.current)return;s(null),d(`Failed to load preview.`)}finally{t===f.current&&l(!1)}},[]),h=Be(async e=>{d(`Downloading theme…`);try{let n=re(await St(e.id),de),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(ft,{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 wt(e){return e.map(e=>`${e.name} (${e.id})`)}function Tt({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]||N.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=[...N.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(Ct,{onBack:()=>{u(!1),c(!0)}});if(a)return J(_t,{themeId:a,onBack:()=>{o(null),c(!0)}});let g=wt(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(ft,{theme:_})})]})}function Et(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 Dt({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),[_,y]=W(!1),[b,x]=W(t),S=v(),C=(r.find(e=>e.id===S)||r.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return B((r,o)=>{if(_){o.return?(i(e=>{e.thinkingVerbs.format=b}),y(!1)):o.escape?(x(t),y(!1)):o.backspace||o.delete?x(e=>e.slice(0,-1)):r&&x(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`&&(x(t),y(!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=[...N.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:_?b: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}=Et(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:C,children:[`✻ `,t.replace(/\{\}/g,n[l]??``),` `]}),J(z,{children:`(esc to interrupt)`})]})})]})]})}const Ot=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()),kt=e=>{let t=Math.max(...e.map(e=>e.length));return e.map(e=>e.padEnd(t))},At=Object.entries(Qe).map(([e,t])=>({name:Ot(e),phases:t.frames.map(e=>e.trimEnd()),reverseMirror:!1,updateInterval:t.interval})),jt=[{name:`Default`,phases:N.thinkingStyle.phases,reverseMirror:N.thinkingStyle.reverseMirror},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1},...At];function Mt({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(``),[y,b]=W(!1),[x,S]=W(!1),[C,w]=W(n.toString()),[ee,T]=W(0),te=v(),E=(i.find(e=>e.id===te)||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(x){if(i.return){let e=parseInt(C);!isNaN(e)&&e>0&&a(t=>{t.thinkingStyle.updateInterval=e}),S(!1)}else i.escape?(w(n.toString()),S(!1)):i.backspace||i.delete?w(e=>e.slice(0,-1)):r&&r.match(/^[0-9]$/)&&w(e=>e+r);return}if(m||y){if(i.return&&g.length){let e=y?[...t,g]:t.map((e,t)=>t===u?g:e);a(t=>{t.thinkingStyle.phases=kt(e)}),h(!1),_(``)}else i.escape?(_(``),h(!1),b(!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`)w(n.toString()),S(!0);else if(l===`presets`){let e=jt[f];a(t=>{t.thinkingStyle.phases=kt([...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:jt.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<jt.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`)b(!0),_(``);else if(r===`d`&&l===`phases`)t.length>1&&a(e=>{e.thinkingStyle.phases=kt(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=N.thinkingStyle}),d(0),p(0))});let D=r?`●`:`○`,O=(()=>r?[...t,...[...t].reverse().slice(1,-1)]:t)(),k=O.length>0?O[ee]:`·`;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:(k?.length??0)+1,children:J(z,{color:E,children:k})}),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`&&(x?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:x?`yellow`:`gray`,children:J(z,{children:x?C: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}=Et(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`]})]})})(),y&&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}=Et(f,jt.length,12),n=jt.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<jt.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,jt.length-t,` more below`]})]})})()})}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function Nt(e,t){let n=He(!0);U(()=>{if(n.current){n.current=!1;return}return e()},t)}const Pt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Ft=[{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 It({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)),[_,y]=W(()=>t.userMessageDisplay.paddingY===`default`?`0`:String(t.userMessageDisplay.paddingY)),[b,x]=W(t.userMessageDisplay.fitBoxToContent),[S,C]=W(0),[w,ee]=W(()=>[...t.userMessageDisplay.styling]),[T,te]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[E,D]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:t.userMessageDisplay.foregroundColor),[O,k]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[A,j]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[M,ne]=W(()=>Ft.findIndex(e=>e.value===t.userMessageDisplay.borderStyle)),[re,ie]=W(()=>t.userMessageDisplay.borderColor),[ae,oe]=W(null),[se,P]=W(``),ce=v(),F=t.themes?.find(e=>e.id===ce)||t.themes?.[0],[le,I]=W(`text`),ue=[`format`,`styling`,`foreground`,`background`],de=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[fe,pe]=W(0),[me,he]=W(0),L=le===`text`?ue[fe]:de[me],ge=()=>{n(e=>{e.userMessageDisplay.format=l,e.userMessageDisplay.styling=[...w],e.userMessageDisplay.foregroundColor=T===`default`?`default`:E,e.userMessageDisplay.backgroundColor=O===`none`?null:O===`default`?`default`:A,e.userMessageDisplay.borderStyle=Ft[M].value,e.userMessageDisplay.borderColor=re,e.userMessageDisplay.paddingX=d===`default`?`default`:parseInt(h)||0,e.userMessageDisplay.paddingY=p===`default`?`default`:parseInt(_)||0,e.userMessageDisplay.fitBoxToContent=b})},_e=()=>{u(N.userMessageDisplay.format),ee([...N.userMessageDisplay.styling]);let e=N.userMessageDisplay.foregroundColor;te(e===`default`?`default`:`custom`),D(e===`default`?`rgb(255,255,255)`:e);let t=N.userMessageDisplay.backgroundColor;k(t===null?`none`:t===`default`?`default`:`custom`),j(t===null||t===`default`?`rgb(0,0,0)`:t),ne(Ft.findIndex(e=>e.value===N.userMessageDisplay.borderStyle)),ie(N.userMessageDisplay.borderColor);let r=N.userMessageDisplay.paddingX,i=N.userMessageDisplay.paddingY;f(r===`default`?`default`:`custom`),m(i===`default`?`default`:`custom`),g(r===`default`?`0`:String(r)),y(i===`default`?`0`:String(i)),x(N.userMessageDisplay.fitBoxToContent),n(e=>{e.userMessageDisplay={...N.userMessageDisplay}})};Nt(()=>{ge()},[l,w,T,E,O,A,M,re,d,p,h,_,b]),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?(y(String(t.userMessageDisplay.paddingY)),c(!1)):l.backspace||l.delete?y(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&y(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)le===`text`?l.shift?pe(e=>e===0?ue.length-1:e-1):pe(e=>e===ue.length-1?0:e+1):l.shift?he(e=>e===0?de.length-1:e-1):he(e=>e===de.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`&&(P(E),oe(`foreground`)):L===`background`?O===`custom`&&(P(A),oe(`background`)):L===`borderColor`&&(P(re),oe(`border`));else if(l.upArrow)L===`styling`?C(e=>Math.max(0,e-1)):L===`borderStyle`?ne(e=>e===0?Ft.length-1:e-1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?te(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&k(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!A||A===``)&&j(`rgb(0,0,0)`),t});else if(l.downArrow)L===`styling`?C(e=>Math.min(Pt.length-1,e+1)):L===`borderStyle`?ne(e=>e===Ft.length-1?0:e+1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?te(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&k(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!A||A===``)&&j(`rgb(0,0,0)`),t});else if(n===` `)if(L===`styling`){let e=Pt[S].value;ee(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else L===`fitBoxToContent`&&x(e=>!e)}});let ve=e=>{let t=T===`default`?F?.colors?.text:E,n=O===`none`?void 0:O===`default`?F?.colors?.userMessageBackground:A,r=Ft[M].value,i=d===`default`?0:parseInt(h)||0,a=p===`default`?0:parseInt(_)||0,o=d===`default`?1:i,s=J(z,{bold:w.includes(`bold`),italic:w.includes(`italic`),underline:w.includes(`underline`),strikethrough:w.includes(`strikethrough`),inverse:w.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:re,children:o}),a>0&&J(R,{height:a}),J(R,{paddingX:i,children:s}),a>0&&J(R,{height:a}),J(z,{color:re,children:o})]})}else if(r!==`none`||i>0||a>0||o>0||b){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=re),b?n.alignSelf=`flex-start`:n.flexGrow=1,r===`none`?t:J(R,{...n,children:t})}else return s};return ae?J(mt,{initialValue:se,theme:F,onColorChange:e=>{ae===`foreground`?D(e):ae===`background`?j(e):ae===`border`&&ie(e)},onExit:()=>{oe(null),P(``)}}):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:le===`text`?`round`:`single`,borderColor:le===`text`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:le===`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:Pt.map((e,t)=>J(R,{children:Y(z,{color:L===`styling`&&S===t?`cyan`:void 0,children:[L===`styling`&&S===t?`❯ `:` `,w.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:A,children:A})]})})]})]})]})]}),Y(R,{flexDirection:`column`,width:`50%`,borderStyle:le===`border`?`round`:`single`,borderColor:le===`border`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:le===`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:Ft.slice(0,6).map((e,t)=>J(R,{children:Y(z,{color:L===`borderStyle`&&M===t?`cyan`:void 0,children:[L===`borderStyle`&&M===t?`❯ `:` `,M===t?`● `:`○ `,e.label]})},e.value))}),J(R,{flexDirection:`column`,width:`50%`,children:Ft.slice(6).map((e,t)=>{let n=t+6;return J(R,{children:Y(z,{color:L===`borderStyle`&&M===n?`cyan`:void 0,children:[L===`borderStyle`&&M===n?`❯ `:` `,M===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:re,children:re})}),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`?`❯ `:` `,b?`●`:`○`,` 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:F?.colors?.userMessageBackground,color:F?.colors?.text,children:[` `,`> list the dir`,` `]})}),J(R,{marginLeft:1,marginTop:1,children:Y(z,{children:[J(z,{color:F?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:F?.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:F?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:F?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(z,{children:` contains `}),J(z,{bold:!0,children:`123`}),J(z,{children:` files.`})]})})]})]})]})]})}const Lt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Rt=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function zt({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 Bt({highlighterIndex:e,onBack:t}){let{settings:n,updateSettings:r}=H($),i=n.inputPatternHighlighters[e],a=v(),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||[]),[_,y]=W(i?.foregroundColor===null?`none`:`custom`),[b,x]=W(i?.foregroundColor||`rgb(255,0,255)`),[S,C]=W(i?.backgroundColor?`custom`:`none`),[w,ee]=W(i?.backgroundColor||`rgb(0,0,0)`),[T,te]=W(i?.enabled??!0),[E,D]=W(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[O,k]=W(`name`),[A,j]=W(!1),[M,N]=W(0),[ne,re]=W(null),[ie,ae]=W(``),[oe,se]=W(null),[P,ce]=W(0),[F,le]=W(0);if(U(()=>{let e=Rt[P];k(e[Math.min(F,e.length-1)])},[P,F]),U(()=>{if(!l){se(null);return}try{new RegExp(l,d),se(null)}catch(e){se(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`?b:null,backgroundColor:S===`custom`?w:null,enabled:T})})},[e,s,l,d,p,h,_,b,S,w,T]),U(()=>{r(e=>{e.inputPatternHighlightersTestText=E})},[E]),B((e,r)=>{if(A){r.return?j(!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`),j(!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(ne===null){if(r.escape)t();else if(r.upArrow)O===`styling`&&M>0?N(e=>e-1):ce(e=>Math.max(0,e-1));else if(r.downArrow)O===`styling`&&M<Lt.length-1?N(e=>e+1):ce(e=>Math.min(Rt.length-1,e+1));else if(r.leftArrow)O===`foreground`?y(e=>e===`none`?`custom`:`none`):O===`background`?C(e=>e===`none`?`custom`:`none`):le(e=>Math.max(0,e-1));else if(r.rightArrow)if(O===`foreground`)y(e=>e===`none`?`custom`:`none`);else if(O===`background`)C(e=>e===`none`?`custom`:`none`);else{let e=Rt[P].length-1;le(t=>Math.min(e,t+1))}else if(r.tab){let e=Rt.flat(),t=e.indexOf(O);if(r.shift){if(t>0){let n=e[t-1];for(let e=0;e<Rt.length;e++){let t=Rt[e].indexOf(n);if(t>=0){ce(e),le(t);break}}}}else if(t<e.length-1){let n=e[t+1];for(let e=0;e<Rt.length;e++){let t=Rt[e].indexOf(n);if(t>=0){ce(e),le(t);break}}}}else if(r.return)O===`name`||O===`regex`||O===`regexFlags`||O===`format`||O===`testText`?j(!0):O===`foreground`&&_===`custom`?(ae(b),re(`foreground`)):O===`background`&&S===`custom`&&(ae(w),re(`background`));else if(e===` `)if(O===`styling`){let e=Lt[M].value;h.includes(e)?g(h.filter(t=>t!==e)):g([...h,e])}else O===`enabled`&&te(!T)}}),!i)return J(R,{flexDirection:`column`,children:J(z,{color:`red`,children:`Highlighter not found`})});if(ne)return J(mt,{initialValue:ie,theme:o,onColorChange:e=>{ne===`foreground`?x(e):ne===`background`&&ee(e)},onExit:()=>{re(null),ae(``)}});let I=e=>O===e,ue=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,{...ue(`name`),children:[I(`name`)?`❯ `:` `,`Name`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`name`)?A?`green`:`yellow`:`gray`,children:J(z,{children:s||`(empty)`})})})]}),Y(R,{flexDirection:`column`,width:`45%`,children:[Y(z,{...ue(`regex`),children:[I(`regex`)?`❯ `:` `,`Regex Pattern`]}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{borderStyle:`round`,borderColor:I(`regex`)?A?`green`:`yellow`:oe?`red`:`gray`,children:J(z,{children:l||`(empty)`})}),oe&&J(z,{color:`red`,children:oe})]})]}),Y(R,{flexDirection:`column`,width:`20%`,children:[Y(z,{...ue(`regexFlags`),children:[I(`regexFlags`)?`❯ `:` `,`Flags`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`regexFlags`)?A?`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,{...ue(`format`),children:[I(`format`)?`❯ `:` `,`Format String`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`format`)?A?`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,{...ue(`styling`),children:[I(`styling`)?`❯ `:` `,`Styling`]}),J(R,{marginLeft:2,flexDirection:`column`,children:Lt.map((e,t)=>{let n=h.includes(e.value),r=I(`styling`)&&M===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,{...ue(`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:b,children:` ████ `})})]})]}),Y(R,{flexDirection:`column`,width:`48%`,children:[Y(z,{...ue(`background`),children:[I(`background`)?`❯ `:` `,`Background Color`]}),Y(R,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(z,{color:I(`background`)?`yellow`:void 0,children:[`[`,S===`none`?`●`:`○`,`] none`,` `,`[`,S===`custom`?`●`:`○`,`] custom`]}),S===`custom`&&J(R,{borderStyle:`round`,borderColor:I(`background`)?`yellow`:`gray`,children:Y(z,{backgroundColor:w,children:[` `,` `,` `]})})]})]})]}),J(R,{marginBottom:1,children:Y(z,{...ue(`enabled`),children:[I(`enabled`)?`❯ `:` `,`Enabled:`,` `,J(z,{color:T?`green`:`red`,children:T?`● Yes`:`○ No`})]})}),Y(R,{flexDirection:`column`,marginBottom:1,children:[Y(z,{...ue(`testText`),children:[I(`testText`)?`❯ `:` `,`Test Text`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`testText`)?A?`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(zt,{testText:E,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?b:void 0,backgroundColor:S===`custom`?w:void 0})}):J(z,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function Vt({onBack:e}){let{settings:{inputPatternHighlighters:t,themes:n},updateSettings:r}=H($),i=v(),a=n.find(e=>e.id===i)||n[0],o=N.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})},y=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))},b=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?y(l):n===`d`&&t.length>0&&l<t.length-1&&b(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(Bt,{highlighterIndex:d,onBack:()=>{f(null),m(!0)}})}const Ht=[null,1,5,10,25,50,100,200,250,500,1e3],Ut=1e3;function Wt({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,suppressRateLimitWarning:!1,sessionColor:!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,modelAtEffort:!0,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,unlockResponsiveMode:!1,swapRipgrepForFff:!1,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autonomousOperationAllModels:!1,refusalFallbackModel:!1,refusalFallbackRoutes:{},refusalFallbackMaxReturns:1,outputStyleTurnReminder:!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=Ht.indexOf(e);if(n===-1)return Ht[0];let r;return r=t===`next`?(n+1)%Ht.length:(n-1+Ht.length)%Ht.length,Ht[r]},_=Ve(()=>[{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,chevronIdleThemeColor:null},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:`suppressRateLimitWarning`,title:`Suppress rate limit warning banners`,description:`Hides rate limit warning banners in the status bar. Error messages when limits are actually reached are still shown.`,getValue:()=>t.misc?.suppressRateLimitWarning??!1,toggle:()=>{n(e=>{c(),e.misc.suppressRateLimitWarning=!e.misc.suppressRateLimitWarning})}},{id:`sessionColor`,title:`Session color from TWEAKCC_SESSION_COLOR`,description:`Colors the session prompt bar from the TWEAKCC_SESSION_COLOR env var, read at each launch, so concurrent sessions can be told apart. Accepts red, blue, green, yellow, purple, orange, pink or cyan; any other value leaves the bar alone.`,getValue:()=>t.misc?.sessionColor??!1,toggle:()=>{n(e=>{c(),e.misc.sessionColor=!e.misc.sessionColor})}},{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:`unlockResponsiveMode`,title:`Unlock responsive mode (bundled plugin)`,description:`Make Claude Code's bundled responsive-mode plugin selectable in /plugin by dropping the tengu_quiet_ember flag check. Responsive mode makes Claude answer in a sentence before it thinks or uses a tool, and adds a system-prompt section against stock AI phrasing. It stays OFF until you enable it in /plugin.`,getValue:()=>t.misc?.unlockResponsiveMode??!1,toggle:()=>{n(e=>{c(),e.misc.unlockResponsiveMode=!e.misc.unlockResponsiveMode})}},{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-${Ut}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(Ut,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:`modelAtEffort`,title:`Allow /model name@effort`,description:`Lets /model opus@high set the model and the effort level in one command.`,getValue:()=>t.misc?.modelAtEffort??!0,toggle:()=>{n(e=>{c(),e.misc.modelAtEffort=!e.misc.modelAtEffort})}},{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:`refusalFallbackModel`,title:`Route the refusal fallback, then switch back`,description:`When safeguards flag a message, Claude Code retries it on a fallback model from its own route table, keyed by the flagged model and the refusal category, and keeps the session there. With this on, refusalFallbackRoutes in config.json is merged over that table: a category you leave out keeps its stock route, one you route falls back to the stock route when none of your models is usable, and a route is a model id or a chain of them. Once the flagged turn is answered, the session switches back to its own model and the transcript says so. refusalFallbackMaxReturns in config.json (default 1, null for no limit) caps consecutive returns, so a conversation that keeps being flagged stays on the fallback rather than paying for a refusal and a retry every turn.`,getValue:()=>t.misc?.refusalFallbackModel??!1,toggle:()=>{n(e=>{c(),e.misc.refusalFallbackModel=!e.misc.refusalFallbackModel})}},{id:`outputStyleTurnReminder`,title:`Per-turn reminder for custom output styles`,description:`Claude Code reminds the model which output style is active once per turn, but only for its three built-in styles. The renderer looks the style up in the built-in table and returns nothing when it is missing, and custom styles are merged into a copy of that table rather than into the table itself. So a style you wrote yourself is injected into the system prompt once and never restated, while Proactive or Explanatory are restated every turn. This makes the reminder fire for custom styles too, using the name you configured. A style that defines its own turnReminder gets that text; otherwise it gets one short sentence pointing back at the style.`,getValue:()=>t.misc?.outputStyleTurnReminder??!1,toggle:()=>{n(e=>{c(),e.misc.outputStyleTurnReminder=!e.misc.outputStyleTurnReminder})}},{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=Ve(()=>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 Gt=`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 Kt({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.acceptEditsToolset===n&&(t.acceptEditsToolset=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(Gt.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(Gt.length+1,e+1));else if(e===` `||n.return)if(d===0)m(`All`);else if(d===1)m(`None`);else{let e=Gt[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`]})}),Gt.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 qt({onBack:e}){let{settings:{toolsets:t,defaultToolset:n,acceptEditsToolset:r,planModeToolset:i,themes:a},updateSettings:o}=H($),s=v(),c=a.find(e=>e.id===s)||a[0],l=N.themes[0],u=c?.colors.planMode||l.colors.planMode,d=c?.colors.autoAccept||l.colors.autoAccept,[f,p]=W(0),[m,h]=W(null),[g,_]=W(!0),y=()=>{let e={name:`New Toolset`,allowedTools:[]};o(t=>{t.toolsets.push(e)}),h(t.length),_(!1)},b=e=>{let n=t[e];o(t=>{t.toolsets.splice(e,1),t.defaultToolset===n.name&&(t.defaultToolset=null),t.acceptEditsToolset===n.name&&(t.acceptEditsToolset=null),t.planModeToolset===n.name&&(t.planModeToolset=null)}),f>=t.length-1&&p(Math.max(0,t.length-2))},x=e=>{let n=t[e];o(e=>{e.defaultToolset=n.name})},S=e=>{let n=t[e];o(e=>{e.acceptEditsToolset=n.name})},C=e=>{let n=t[e];o(e=>{e.planModeToolset=n.name})};if(B((n,r)=>{r.escape?e():r.upArrow?p(e=>Math.max(0,e-1)):r.downArrow?p(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(h(f),_(!1)):n===`n`?y():n===`x`&&t.length>0?b(f):n===`d`&&t.length>0?x(f):n===`a`&&t.length>0?S(f):n===`p`&&t.length>0&&C(f)},{isActive:g}),m!==null)return J(Kt,{toolsetIndex:m,onBack:()=>{h(null),_(!0)}});let w=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:`a to set as accept edits 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 a=e.name===n,o=e.name===r,s=e.name===i,c=f===t,l;return c&&(l=`yellow`),Y(R,{flexDirection:`row`,children:[Y(z,{color:l,children:[c?`❯ `:` `,e.name,` `]}),Y(z,{color:l,children:[`(`,w(e),`)`]}),a&&J(z,{color:l,children:` default`}),o&&J(z,{color:d,children:` ⏵⏵ accept edits`}),s&&J(z,{color:u,children:` ⏸ plan mode`})]},t)})})]})}function Jt({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)})]})}function Yt({onBack:t}){let[n,r]=W(null),[i,a]=W(!1),[o,s]=W(`Press c to check key availability.`),c=async e=>{a(!0);try{s(await e())}catch{s(`Credential operation failed. Unlock your keychain, or install secret-tool and unlock Secret Service on Linux. For headless use, supply TYPESAFE_API_KEY through your secret manager.`)}finally{a(!1)}};return B((a,o)=>{if(!i){if(o.escape){n===null?t():r(null);return}if(n!==null){if(o.return){if(!n.trim()||/[^\x21-\x7e]/.test(n)){s(`Enter a nonempty API key without spaces or control characters.`);return}let t=n;r(null),c(async()=>(await e(t),`API key saved securely.`))}else o.backspace||o.delete?r(n.slice(0,-1)):a&&!o.ctrl&&!o.meta&&(/[^\x21-\x7e]/.test(a)?s(`Paste only the API key, without spaces or control characters.`):n.length+a.length<=1024&&r(n+a));return}a===`e`||o.return?(r(``),s(`Enter to save; escape to discard.`)):a===`c`?c(async()=>await g()?`API key available.`:`No API key available.`):a===`d`&&c(async()=>(await w(),`Stored key removed. TYPESAFE_API_KEY, if set, still takes precedence.`))}}),Y(R,{flexDirection:`column`,children:[J(X,{children:`TypeSafe API key`}),J(z,{children:`Stored in your OS credential store, never router settings.`}),J(z,{dimColor:!0,children:`Headless use: provide TYPESAFE_API_KEY through your secret manager.`}),J(z,{children:i?`Working…`:o}),n===null?J(z,{dimColor:!0,children:`enter/e set key · c check · d delete stored key · esc back`}):Y(z,{children:[`API key: `,`•`.repeat(Math.min(n.length,48)),`_`]})]})}const Xt=[{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`}],Zt={jevTimeoutMs:{label:`Jev timeout`,unit:`ms`,lo:250,hi:3e4,hint:`maximum routing wait; unusable responses fall back to medium`},contextBudgetBytes:{label:`Jev context budget`,unit:`bytes`,lo:4e3,hi:28e3,hint:`bounds the message, summary, and recent unsummarized context`},summaryMaxChars:{label:`Summary cap`,unit:`chars`,lo:500,hi:12e3,hint:`concise scope, progress, constraints, and unresolved difficulties`},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:`Haiku call timeout; Jev summaries run asynchronously`}},Qt=[`enabled`,`provider`,`credentials`,`jevTimeoutMs`,`contextBudgetBytes`,`summaryMaxChars`,`pinPerTask`,`messageCap`,`assistantCap`,`timeoutMs`,`systemPrompt`],$t=e=>e in Zt,en=N.complexityRouter;function tn({onBack:e}){let{settings:t,updateSettings:n}=H($),r={...en,...t.complexityRouter??{},levels:t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:en.levels},i=Qt.filter(e=>r.provider===`jev`&&e!==`systemPrompt`&&e!==`pinPerTask`||r.provider!==`jev`&&![`credentials`,`jevTimeoutMs`,`contextBudgetBytes`,`summaryMaxChars`].includes(e)),a=i.length+r.levels.length,[o,s]=W(!1),{setRawMode:c,isRawModeSupported:l}=Pe(),[u,d]=W(0),{stdout:f}=Fe(),p=Math.max(1,Math.min(a,(f.rows||24)-18)),m=Math.max(0,Math.min(u-Math.floor(p/2),a-p)),h=e=>e>=m&&e<m+p,[g,_]=W(null),[v,y]=W(0),[b,x]=W(null),[S,C]=W(null),[,w]=W(0),T=e=>{n(t=>{let n={...en,...t.complexityRouter??{},levels:(t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:en.levels).map(e=>({...e}))};e(n),t.complexityRouter=n})};if(B((t,n)=>{if(o)return;if(S){if(n.escape){C(null);return}if(n.return){let{kind:e,levelIndex:t,value:n}=S;T(r=>{let i=r.levels[t];i&&(i[e]=n)}),C(null);return}if(n.backspace||n.delete){C(e=>e&&{...e,value:e.value.slice(0,-1)});return}t&&!n.ctrl&&!n.meta&&C(e=>e&&{...e,value:e.value+t});return}if(b){if(n.escape){x(null);return}if(n.return){let e=Zt[b.row],t=Number(b.value),n=Math.round(t),r=Number.isFinite(n)?Math.min(e.hi,Math.max(e.lo,n)):en[b.row],i=b.row;T(e=>{Object.assign(e,{[i]:r})}),x(null);return}if(n.backspace||n.delete){x(e=>e&&{...e,value:e.value.slice(0,-1)});return}/^[0-9.]$/.test(t)&&x(e=>e&&e.value.length<7?{...e,value:e.value+t}:e);return}if(g){if(n.escape){_(null);return}if(n.upArrow){y(e=>e>0?e-1:Xt.length-1);return}if(n.downArrow){y(e=>e<Xt.length-1?e+1:0);return}if(n.return){let e=Xt[v].value,t=g.levelIndex;T(n=>{n.levels[t]&&(n.levels[t].effort=e)}),_(null)}return}if(n.escape){e();return}if(n.upArrow){d(e=>e>0?e-1:a-1);return}if(n.downArrow){d(e=>e<a-1?e+1:0);return}let f=u<i.length,p=u-i.length;if(t===`x`){if(f){let e=i[u];$t(e)?T(t=>{Object.assign(t,{[e]:en[e]})}):e===`systemPrompt`&&T(e=>{e.systemPrompt=en.systemPrompt})}else{let e=en.levels[p];e&&T(t=>{let n=t.levels[p];n&&(n.effort=e.effort,n.label=e.label,n.help=e.help)})}return}if(!f&&(t===`l`||t===`h`)){let e=t===`l`?`label`:`help`,n=r.levels[p];n&&C({kind:e,levelIndex:p,value:n[e]});return}if(t===` `||n.return)if(f){let e=i[u];if(e===`enabled`)T(e=>{e.enabled=!e.enabled});else if(e===`provider`)T(e=>{e.provider=e.provider===`jev`?`haiku`:`jev`});else if(e===`credentials`)s(!0);else if(e===`pinPerTask`)T(e=>{e.pinPerTask=!e.pinPerTask});else if(e===`systemPrompt`){l&&c(!1);let e=ee(r.systemPrompt);if(l&&c(!0),e!=null){let t=e.replace(/\s+$/,``);t&&t!==r.systemPrompt&&T(e=>{e.systemPrompt=t})}w(e=>e+1)}else x({row:e,value:String(r[e])})}else{let e=Xt.findIndex(e=>e.value===r.levels[p]?.effort);y(e>=0?e:0),_({levelIndex:p})}}),o)return J(Yt,{onBack:()=>s(!1)});if(g)return Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:Y(X,{children:[`Select effort for "`,r.levels[g.levelIndex]?.label,`"`]})}),Xt.map((e,t)=>{let n=t===v;return J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.value,Y(z,{dimColor:!0,children:[` - `,e.blurb]})]})},t)})]});let te=(e,t)=>{let n=t===u,i,a,o=``;if(e===`enabled`)i=`Router model entries`,a=r.enabled?`on`:`off`;else if(e===`provider`)i=`Routing provider`,a=r.provider===`jev`?`Jev + asynchronous Haiku summaries`:`Haiku`,o=`Jev sends your current message and concise context to TypeSafe, billed separately. Enter to switch.`;else if(e===`credentials`)i=`TypeSafe API key`,a=`enter to securely set, check, or delete`,o=`Model: ${r.jevModel}`;else if(e===`pinPerTask`)i=`Keep highest effort this session`,a=r.pinPerTask?`on`:`off`,o=`On: effort never falls below the session maximum. Off: adapt each message. Reset on /clear.`;else if(e===`systemPrompt`){i=`System prompt`;let e=r.systemPrompt===en.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=Zt[e];i=e===`timeoutMs`&&r.provider===`jev`?`Haiku summary timeout`:t.label,b?.row===e?(a=`${b.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:`Apply to add Opus 5.5 and Fable 5.1 + Effort Router to /model. Select a router entry to enable per-message routing. Manual /effort and CLAUDE_CODE_EFFORT_LEVEL take precedence.`}),r.provider===`jev`&&J(z,{dimColor:!0,children:`Jev receives your message and concise context. TypeSafe bills separately. Haiku updates summaries asynchronously.`}),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`})]}),i.map((e,t)=>h(t)?te(e,t):null),Y(z,{dimColor:!0,children:[`Showing `,m+1,`–`,m+p,` of `,a,` `,`settings and effort tiers`]}),r.levels.map((e,t)=>{let n=i.length+t;if(!h(n))return null;let r=n===u,a=S?.levelIndex===t&&S.kind===`label`,o=S?.levelIndex===t&&S.kind===`help`;return Y(R,{flexDirection:`column`,children:[J(R,{children:Y(z,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,J(z,{bold:!0,children:a?`${S.value}_`:e.label}),` `,J(z,{color:`green`,children:e.effort})]})}),r&&J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:o?`${S.value}_`:e.help})}),r&&!S?J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:`enter = set effort · l = edit label · h = edit help · x = reset this tier`})}):null,r&&S?J(R,{marginLeft:4,children:Y(z,{dimColor:!0,children:[`editing `,S.kind,` - type to change · enter save · esc cancel`]})}):null]},e.id)})]})}const nn=[`fable`,`opus`,`sonnet`,`haiku`],rn=e=>e.charAt(0).toUpperCase()+e.slice(1),an=[{kind:`enabled`},{kind:`model`,side:`plan`},{kind:`model`,side:`exec`},{kind:`clearContext`}],on=({onBack:e})=>{let{settings:t,updateSettings:n}=H($),r={...N.fablePlan,...t.fablePlan??{}},[i,a]=W(0),o=e=>{n(t=>({...t,fablePlan:{...N.fablePlan,...t.fablePlan??{},...e}}))},s=e=>{let t=an[i];if(t.kind===`enabled`){o({enabled:!r.enabled});return}if(t.kind===`clearContext`){o({offerClearContextOnPlanAccept:!r.offerClearContextOnPlanAccept});return}let n=t.side===`plan`?`planModel`:`execModel`,a=t.side===`plan`?r.execModel:r.planModel,s=nn.indexOf(r[n]);for(let t=1;t<=nn.length;t++){let r=nn[(s+e*t+nn.length*t)%nn.length];if(r!==a){o({[n]:r});return}}};B((t,n)=>{if(n.escape||t===`q`){e();return}n.upArrow?a(e=>(e-1+an.length)%an.length):n.downArrow?a(e=>(e+1)%an.length):n.leftArrow?s(-1):n.rightArrow||n.return||t===` `?s(1):t===`x`&&o({...N.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: `,rn(r.planModel),` `,`while planning, `,rn(r.execModel),` while executing, each at the effort you set for that model in `,J(z,{color:`green`,children:`/model`}),`.`]}),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:an.map((e,t)=>e.kind===`enabled`?c(t,`Enabled`,r.enabled?`yes`:`no`):e.kind===`clearContext`?c(t,`Offer "clear context"`,r.offerClearContextOnPlanAccept?`yes`:`no`):c(t,`${e.side===`plan`?`Planning`:`Executing`} model`,rn(e.side===`plan`?r.planModel:r.execModel)))}),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 `,rn(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.`]}),Y(z,{dimColor:!0,children:[`Reasoning effort is Claude Code's own per-model setting: pick`,` `,rn(r.planModel),` in `,J(z,{color:`green`,children:`/model`}),`, set its effort, then do the same for `,rn(r.execModel),`. An explicit `,J(z,{color:`green`,children:`/effort`}),` applies to both sides for the rest of the session.`]})]}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`↑↓ move · ←→ change · x reset to defaults · esc back`})})]})},sn=K.join(F,`claude-browser-bridge`),cn=K.join(sn,`host`,`setup.mjs`),ln=K.join(sn,`extension`),un=K.join(Ue.homedir(),`.claude-browser-bridge`,`install-state.json`),dn=`/tmp/claude-browser-bridge-${Ue.userInfo().username}.sock`;function fn(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 pn(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 mn(e){return new Promise(t=>{Ke(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 hn(e){return new Promise(t=>{Ke(`git`,e,{maxBuffer:8*1024*1024},(e,n,r)=>{t({code:e?1:0,out:String(n)+String(r)})})})}async function gn(){if(G.existsSync(K.join(sn,`.git`))&&G.existsSync(cn)){let e=await hn([`-C`,sn,`pull`,`--ff-only`]);return G.existsSync(cn)?{code:0,out:e.out}:e}return G.existsSync(sn)&&G.rmSync(sn,{recursive:!0,force:!0}),hn([`clone`,`--depth`,`1`,`https://github.com/skrabe/claude-browser-bridge`,sn])}function _n(){let e=process.platform===`darwin`?K.join(Ue.homedir(),`Library`,`Application Support`):K.join(Ue.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)])fn(e)&&n.push(pn(e));return n.sort()}function vn(){try{return JSON.parse(G.readFileSync(un,`utf8`))}catch{return null}}const yn=({onBack:e})=>{let[t,n]=W(`menu`),[r,i]=W(0),[a,o]=W(vn()),[s,c]=W(`global`),[l,u]=W(`Working…`),[d,f]=W([]),[p,m]=W(null),[h,g]=W(``),[_,v]=W(`install`),[y,b]=W(null),[x,S]=W(null),C=Be(()=>{o(vn())},[]);U(()=>{C()},[C]);let w=G.existsSync(dn),ee=!!a,T=ee&&!a.mcpName,te=()=>{c(`global`),i(0),n(`scope`)},E=Be(async e=>{n(`busy`),u(`Fetching the bridge…`),f([]);let t=await gn();if(t.code!==0||!G.existsSync(cn)){g(`Failed to fetch the bridge repo:
|
|
2
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,N as p,O as m,P as h,Q as g,R as _,S as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_ as ee,_t as T,a as te,at as E,b as D,ct as O,d as k,dt as A,et as j,f as M,ft as N,g as ne,h as re,i as ie,k as ae,l as oe,lt as se,m as P,mt as ce,n as F,nt as le,o as I,ot as ue,pt as de,q as fe,r as pe,s as me,st as he,t as L,tt as ge,u as _e,ut as ve,v as ye,vt as be,x as xe,y as Se,z as Ce}from"./config-h2_qLiXs.mjs";import{a as we,c as Te,d as Ee,l as De,n as Oe,o as ke,s as Ae,t as je,u as Me}from"./content-Co05XSpg.mjs";import{Box as R,Text as z,render as Ne,useInput as B,useStdin as Pe,useStdout as Fe}from"ink";import{Command as Ie}from"commander";import V from"chalk";import Le,{Fragment as Re,createContext as ze,useCallback as Be,useContext as H,useEffect as U,useMemo as Ve,useRef as He,useState as W}from"react";import*as Ue from"node:os";import We from"ink-link";import*as Ge from"node:fs/promises";import*as G from"node:fs";import*as K from"node:path";import{execFile as Ke,execSync as qe,spawn as Je}from"node:child_process";import Ye from"gray-matter";import{structuredPatch as Xe}from"diff";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import Ze from"process";import Qe from"cli-spinners";import*as $e from"node:readline";var X=({children:e,...t})=>Y(z,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...t,children:[` `,e,` `]});const et=[`\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 tt=()=>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(We,{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:et.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 nt({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 rt=[{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`}],it=[{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 (${pe})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var at=({onSubmit:e})=>{let t=[...rt,...it],[n,r]=W(0);return J(nt,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const ot=()=>Y(R,{flexDirection:`row`,children:[J(X,{children:`tweakcc`}),J(z,{children:` (by `}),J(We,{url:`https://piebald.ai`,fallback:!1,children:J(z,{color:`#ff8400`,bold:!0,children:`Piebald`})}),J(z,{children:`)`})]}),st=()=>J(R,{children:Y(z,{color:`yellow`,children:[`⭐ `,J(z,{bold:!0,children:`Star the repo at `}),J(We,{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!`}),` ⭐`]})}),ct=({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})}),lt=({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(ot,{}),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 `,F.replace(Ue.homedir(),`~`),`/config.json.`]})]})}),J(r?tt:st,{}),t&&J(ct,{notification:t}),!i&&!t&&J(ct,{notification:{message:`Your changes are configured but not applied.\nRun \`${a} --apply\` to apply your customizations!`,type:`info`}}),J(at,{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(Le.Children.toArray(i).some(e=>Le.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=Le.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 ut({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 dt=Ze.cwd();function ft({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:`▛▘`}),` `,r(),` · `,xe()]}),Y(Q,{color:e.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,dt]}),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(ut,{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 pt({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 mt({initialValue:e,onColorChange:t,onExit:n,colorKey:r,theme:a}){let o=gt(e)||{h:0,s:50,l:50},s=ht(e)||{r:128,g:128,b:128},[c,l]=W(o),[u,d]=W(s),[f,p]=W(`hsl`),[h,g]=W(`h`),[_,v]=W(!1),[y,b]=W(!1);U(()=>{let t=gt(e),n=ht(e);t&&n&&(v(!0),l(t),d(n),v(!1))},[e]),U(()=>{!_&&y&&t(`rgb(${u.r},${u.g},${u.b})`)},[c,u,_,y]),U(()=>{b(!0)},[]);let x=e=>{if(i(e)){let t=m(e),n=gt(t),r=ht(t);n&&r&&(v(!0),l(n),d(r),v(!1))}};B((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){x(e);return}t.return||t.escape?n():t.ctrl&&e===`a`?(p(e=>e===`hsl`?`rgb`:`hsl`),g(e=>f===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?g(f===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?g(f===`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),f===`hsl`?l(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 d({r,g:i,b:a}),n}):d(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))),l(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)]},ee=()=>{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},T=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(c.h,n,c.l);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},te=()=>{let e=[];for(let t=0;t<40;t++){let n=t/39*100,[r,i,a]=w(c.h,c.s,n);e.push(J(z,{backgroundColor:`rgb(${r},${i},${a})`,children:` `},t))}return e},E=()=>{let[e,t,n]=w(c.h,c.s,c.l);return`rgb(${e},${t},${n})`},D=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},O=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${n},${u.g},${u.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(${u.r},${n},${u.b})`,children:` `},t))}return e},A=()=>{let e=[];for(let t=0;t<40;t++){let n=Math.round(t/39*255);e.push(J(z,{backgroundColor:`rgb(${u.r},${u.g},${n})`,children:` `},t))}return e},j=(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`})]})]}),f===`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 (`,c.h,`°):`]})}),J(R,{children:ee().map((e,t)=>J(Re,{children:t===j(c.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 (`,c.s,`%):`]})}),J(R,{children:T().map((e,t)=>J(Re,{children:t===j(c.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 (`,c.l,`%):`]})}),J(R,{children:te().map((e,t)=>J(Re,{children:t===j(c.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 (`,u.r,`):`]})}),J(R,{children:O().map((e,t)=>J(Re,{children:t===j(u.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 (`,u.g,`):`]})}),J(R,{children:k().map((e,t)=>J(Re,{children:t===j(u.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 (`,u.b,`):`]})}),J(R,{children:A().map((e,t)=>J(Re,{children:t===j(u.b,255)?J(z,{children:`|`}):e},t))})]})]}),Y(R,{marginBottom:1,children:[J(z,{children:`Current: `}),J(z,{backgroundColor:E(),children:` `})]}),Y(R,{flexDirection:`row`,justifyContent:`space-between`,children:[Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`Hex `}),r?.startsWith(`diff`)?J(z,{backgroundColor:E(),color:a?.colors?.text||`white`,bold:!0,children:D(u.r,u.g,u.b)}):r===`inverseText`?J(z,{color:E(),backgroundColor:a?.colors?.permission,bold:!0,children:D(u.r,u.g,u.b)}):J(z,{color:E(),bold:!0,children:D(u.r,u.g,u.b)})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`RGB `}),r?.startsWith(`diff`)?J(z,{backgroundColor:E(),color:a?.colors?.text||`white`,bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`}):r===`inverseText`?J(z,{color:E(),backgroundColor:a?.colors?.permission,bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`}):J(z,{color:E(),bold:!0,children:`rgb(${u.r}, ${u.g}, ${u.b})`})]}),Y(R,{flexDirection:`column`,children:[J(z,{dimColor:!0,children:`HSL `}),r?.startsWith(`diff`)?J(z,{backgroundColor:E(),color:a?.colors?.text||`white`,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):r===`inverseText`?J(z,{color:E(),backgroundColor:a?.colors?.permission,bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`}):J(z,{color:E(),bold:!0,children:`hsl(${c.h}, ${c.s}%, ${c.l}%)`})]})]})]})}function ht(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 gt(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 _t({onBack:e,themeId:t}){let{settings:{themes:n},updateSettings:r}=H($),[a,o]=W(t),s=n.find(e=>e.id===a)||n[0],[c,l]=W(`rgb`),[u,d]=W(0),[f,p]=W(null),[g,_]=W(null),[v,y]=W(``),[b,x]=W(``),[S,C]=W(!1),[w,ee]=W(0),T=Be(e=>{r(t=>{let n=t.themes.findIndex(e=>e.id===a);n!==-1&&e(t.themes[n])})},[a,r]),te=e=>{if(u>=2&&i(e)){let t=m(e),n=E[u-2];T(e=>{e.colors[n]=t})}};B((t,n)=>{if(S){if(n.escape){C(!1),e();return}return}if(f===null&&g===null){if(t.length>1&&!n.ctrl&&!n.meta){te(t);return}if(n.escape)C(!0),ee(0);else if(n.ctrl&&t===`a`)l(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(n.upArrow)d(e=>Math.max(0,e-1));else if(n.downArrow)d(e=>Math.min(E.length+1,e+1));else if(n.return)if(u===0)_(`name`),y(s.name),x(s.name);else if(u===1)_(`id`),y(s.id),x(s.id);else{let e=u-2,t=E[e],n=s.colors[t];p(e),y(n),x(n)}}else if(f!==null)n.ctrl&&t===`a`&&l(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(g!==null)if(n.return){if(g===`id`){let e=a;o(v),r(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=v)})}else T(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 E=Object.keys(s.colors),D=(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}},O=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(...E.map(e=>e.length));return Y(R,{children:[Y(R,{flexDirection:`column`,width:`50%`,children:[J(R,{children:Y(X,{children:[`Editing theme “`,s.name,`” (`,s.id,`)`]})}),S?Y(R,{flexDirection:`column`,marginTop:1,children:[J(R,{marginBottom:1,children:Y(z,{bold:!0,children:[`Would you like to make “`,s.name,`” your current Claude Code theme?`]})}),J(nt,{items:[{name:`Yes`,desc:`Set ${s.id} as active theme`},{name:`No`,desc:`Go back without changing theme`}],selectedIndex:w,onSelect:ee,onSubmit:()=>{w===0&&h(s.id),C(!1),e()}}),J(z,{dimColor:!0,children:`enter to select, esc to cancel`})]}):f===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`})]}),u<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:u===0?`Theme Name`:`Theme ID`}),J(z,{children:u===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:s.colors[E[u-2]],flexDirection:`column`,paddingLeft:1,children:[J(pt,{colorKey:E[u-2],theme:s,bold:!0}),J(z,{children:O(E[u-2])})]}),Y(R,{flexDirection:`column`,children:[Y(R,{children:[J(z,{color:u===0?`yellow`:`white`,children:u===0?`❯ `:` `}),J(z,{bold:!0,children:`Name: `}),J(z,{children:s.name})]}),Y(R,{marginBottom:1,children:[J(z,{color:u===1?`yellow`:`white`,children:u===1?`❯ `:` `}),J(z,{bold:!0,children:`ID: `}),J(z,{children:s.id})]}),(()=>{if(u<2)return Y(q,{children:[E.slice(0,20).map((e,t)=>{let n=t+2;return Y(R,{children:[J(z,{color:u===n?`yellow`:`white`,children:u===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(pt,{colorKey:e,theme:s,bold:!0})})}),J(Q,{color:s.colors[e],children:D(s.colors[e],c)})]},e)}),E.length>20&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,E.length-20,` more below`]})]});let e=u-2,t=Math.max(0,e-10),n=Math.min(E.length,t+20),r=Math.max(0,n-20),i=E.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:u===n?`yellow`:`white`,children:u===n?`❯ `:` `}),J(R,{width:k+2,children:J(z,{children:J(pt,{colorKey:e,theme:s,bold:!0})})}),J(Q,{color:s.colors[e],children:D(s.colors[e],c)})]},e)}),n<E.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,E.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(mt,{initialValue:b,colorKey:E[f],theme:s,onColorChange:e=>{y(e),T(t=>{t.colors[E[f]]=e})},onExit:()=>{T(e=>{e.colors[E[f]]=v}),p(null),y(``),x(``)}})]}),J(R,{width:`50%`,children:J(ft,{theme:s})})]})}const vt=`https://raw.githubusercontent.com/Piebald-AI/claude-code-themes/main`,yt=`${vt}/index.json`,bt=2e4;async function xt(){P(`Fetching community theme index from ${yt}`);let e=await fetch(yt,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(bt)});if(!e.ok)throw Error(`Failed to fetch community theme index: ${e.status} ${e.statusText}`);return JSON.parse(await t(e))}async function St(e){let n=`${vt}/themes/${e}.json`;P(`Fetching community theme from ${n}`);let r=await fetch(n,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(bt)});if(!r.ok)throw Error(`Failed to fetch community theme "${e}": ${r.status} ${r.statusText}`);return JSON.parse(await t(r))}function Ct({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=He(0);U(()=>{xt().then(e=>{r({status:`loaded`,entries:e})}).catch(e=>{r({status:`error`,message:e.message})})},[]);let p=n.status===`loaded`?n.entries:[],m=Be(async e=>{let t=++f.current;l(!0),d(null);try{let n=await St(e);if(t!==f.current)return;s(re(n,de))}catch{if(t!==f.current)return;s(null),d(`Failed to load preview.`)}finally{t===f.current&&l(!1)}},[]),h=Be(async e=>{d(`Downloading theme…`);try{let n=re(await St(e.id),de),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(ft,{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 wt(e){return e.map(e=>`${e.name} (${e.id})`)}function Tt({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]||N.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=[...N.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(Ct,{onBack:()=>{u(!1),c(!0)}});if(a)return J(_t,{themeId:a,onBack:()=>{o(null),c(!0)}});let g=wt(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(ft,{theme:_})})]})}function Et(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 Dt({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),[_,y]=W(!1),[b,x]=W(t),S=v(),C=(r.find(e=>e.id===S)||r.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return B((r,o)=>{if(_){o.return?(i(e=>{e.thinkingVerbs.format=b}),y(!1)):o.escape?(x(t),y(!1)):o.backspace||o.delete?x(e=>e.slice(0,-1)):r&&x(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`&&(x(t),y(!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=[...N.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:_?b: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}=Et(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:C,children:[`✻ `,t.replace(/\{\}/g,n[l]??``),` `]}),J(z,{children:`(esc to interrupt)`})]})})]})]})}const Ot=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()),kt=e=>{let t=Math.max(...e.map(e=>e.length));return e.map(e=>e.padEnd(t))},At=Object.entries(Qe).map(([e,t])=>({name:Ot(e),phases:t.frames.map(e=>e.trimEnd()),reverseMirror:!1,updateInterval:t.interval})),jt=[{name:`Default`,phases:N.thinkingStyle.phases,reverseMirror:N.thinkingStyle.reverseMirror},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1},...At];function Mt({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(``),[y,b]=W(!1),[x,S]=W(!1),[C,w]=W(n.toString()),[ee,T]=W(0),te=v(),E=(i.find(e=>e.id===te)||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(x){if(i.return){let e=parseInt(C);!isNaN(e)&&e>0&&a(t=>{t.thinkingStyle.updateInterval=e}),S(!1)}else i.escape?(w(n.toString()),S(!1)):i.backspace||i.delete?w(e=>e.slice(0,-1)):r&&r.match(/^[0-9]$/)&&w(e=>e+r);return}if(m||y){if(i.return&&g.length){let e=y?[...t,g]:t.map((e,t)=>t===u?g:e);a(t=>{t.thinkingStyle.phases=kt(e)}),h(!1),_(``)}else i.escape?(_(``),h(!1),b(!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`)w(n.toString()),S(!0);else if(l===`presets`){let e=jt[f];a(t=>{t.thinkingStyle.phases=kt([...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:jt.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<jt.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`)b(!0),_(``);else if(r===`d`&&l===`phases`)t.length>1&&a(e=>{e.thinkingStyle.phases=kt(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=N.thinkingStyle}),d(0),p(0))});let D=r?`●`:`○`,O=(()=>r?[...t,...[...t].reverse().slice(1,-1)]:t)(),k=O.length>0?O[ee]:`·`;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:(k?.length??0)+1,children:J(z,{color:E,children:k})}),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`&&(x?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:x?`yellow`:`gray`,children:J(z,{children:x?C: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}=Et(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`]})]})})(),y&&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}=Et(f,jt.length,12),n=jt.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<jt.length&&Y(z,{color:`gray`,dimColor:!0,children:[` `,`↓ `,jt.length-t,` more below`]})]})})()})}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function Nt(e,t){let n=He(!0);U(()=>{if(n.current){n.current=!1;return}return e()},t)}const Pt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Ft=[{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 It({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)),[_,y]=W(()=>t.userMessageDisplay.paddingY===`default`?`0`:String(t.userMessageDisplay.paddingY)),[b,x]=W(t.userMessageDisplay.fitBoxToContent),[S,C]=W(0),[w,ee]=W(()=>[...t.userMessageDisplay.styling]),[T,te]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[E,D]=W(()=>t.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:t.userMessageDisplay.foregroundColor),[O,k]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[A,j]=W(()=>{let e=t.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[M,ne]=W(()=>Ft.findIndex(e=>e.value===t.userMessageDisplay.borderStyle)),[re,ie]=W(()=>t.userMessageDisplay.borderColor),[ae,oe]=W(null),[se,P]=W(``),ce=v(),F=t.themes?.find(e=>e.id===ce)||t.themes?.[0],[le,I]=W(`text`),ue=[`format`,`styling`,`foreground`,`background`],de=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[fe,pe]=W(0),[me,he]=W(0),L=le===`text`?ue[fe]:de[me],ge=()=>{n(e=>{e.userMessageDisplay.format=l,e.userMessageDisplay.styling=[...w],e.userMessageDisplay.foregroundColor=T===`default`?`default`:E,e.userMessageDisplay.backgroundColor=O===`none`?null:O===`default`?`default`:A,e.userMessageDisplay.borderStyle=Ft[M].value,e.userMessageDisplay.borderColor=re,e.userMessageDisplay.paddingX=d===`default`?`default`:parseInt(h)||0,e.userMessageDisplay.paddingY=p===`default`?`default`:parseInt(_)||0,e.userMessageDisplay.fitBoxToContent=b})},_e=()=>{u(N.userMessageDisplay.format),ee([...N.userMessageDisplay.styling]);let e=N.userMessageDisplay.foregroundColor;te(e===`default`?`default`:`custom`),D(e===`default`?`rgb(255,255,255)`:e);let t=N.userMessageDisplay.backgroundColor;k(t===null?`none`:t===`default`?`default`:`custom`),j(t===null||t===`default`?`rgb(0,0,0)`:t),ne(Ft.findIndex(e=>e.value===N.userMessageDisplay.borderStyle)),ie(N.userMessageDisplay.borderColor);let r=N.userMessageDisplay.paddingX,i=N.userMessageDisplay.paddingY;f(r===`default`?`default`:`custom`),m(i===`default`?`default`:`custom`),g(r===`default`?`0`:String(r)),y(i===`default`?`0`:String(i)),x(N.userMessageDisplay.fitBoxToContent),n(e=>{e.userMessageDisplay={...N.userMessageDisplay}})};Nt(()=>{ge()},[l,w,T,E,O,A,M,re,d,p,h,_,b]),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?(y(String(t.userMessageDisplay.paddingY)),c(!1)):l.backspace||l.delete?y(e=>e.slice(0,-1)):n&&/^\d$/.test(n)&&y(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)le===`text`?l.shift?pe(e=>e===0?ue.length-1:e-1):pe(e=>e===ue.length-1?0:e+1):l.shift?he(e=>e===0?de.length-1:e-1):he(e=>e===de.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`&&(P(E),oe(`foreground`)):L===`background`?O===`custom`&&(P(A),oe(`background`)):L===`borderColor`&&(P(re),oe(`border`));else if(l.upArrow)L===`styling`?C(e=>Math.max(0,e-1)):L===`borderStyle`?ne(e=>e===0?Ft.length-1:e-1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?te(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&k(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!A||A===``)&&j(`rgb(0,0,0)`),t});else if(l.downArrow)L===`styling`?C(e=>Math.min(Pt.length-1,e+1)):L===`borderStyle`?ne(e=>e===Ft.length-1?0:e+1):L===`paddingX`?f(e=>e===`default`?`custom`:`default`):L===`paddingY`?m(e=>e===`default`?`custom`:`default`):L===`foreground`?te(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!E||E===``)&&D(`rgb(255,255,255)`),t}):L===`background`&&k(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!A||A===``)&&j(`rgb(0,0,0)`),t});else if(n===` `)if(L===`styling`){let e=Pt[S].value;ee(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else L===`fitBoxToContent`&&x(e=>!e)}});let ve=e=>{let t=T===`default`?F?.colors?.text:E,n=O===`none`?void 0:O===`default`?F?.colors?.userMessageBackground:A,r=Ft[M].value,i=d===`default`?0:parseInt(h)||0,a=p===`default`?0:parseInt(_)||0,o=d===`default`?1:i,s=J(z,{bold:w.includes(`bold`),italic:w.includes(`italic`),underline:w.includes(`underline`),strikethrough:w.includes(`strikethrough`),inverse:w.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:re,children:o}),a>0&&J(R,{height:a}),J(R,{paddingX:i,children:s}),a>0&&J(R,{height:a}),J(z,{color:re,children:o})]})}else if(r!==`none`||i>0||a>0||o>0||b){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=re),b?n.alignSelf=`flex-start`:n.flexGrow=1,r===`none`?t:J(R,{...n,children:t})}else return s};return ae?J(mt,{initialValue:se,theme:F,onColorChange:e=>{ae===`foreground`?D(e):ae===`background`?j(e):ae===`border`&&ie(e)},onExit:()=>{oe(null),P(``)}}):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:le===`text`?`round`:`single`,borderColor:le===`text`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:le===`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:Pt.map((e,t)=>J(R,{children:Y(z,{color:L===`styling`&&S===t?`cyan`:void 0,children:[L===`styling`&&S===t?`❯ `:` `,w.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:A,children:A})]})})]})]})]})]}),Y(R,{flexDirection:`column`,width:`50%`,borderStyle:le===`border`?`round`:`single`,borderColor:le===`border`?`yellow`:`gray`,paddingX:1,children:[J(R,{marginBottom:1,children:J(z,{bold:!0,color:le===`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:Ft.slice(0,6).map((e,t)=>J(R,{children:Y(z,{color:L===`borderStyle`&&M===t?`cyan`:void 0,children:[L===`borderStyle`&&M===t?`❯ `:` `,M===t?`● `:`○ `,e.label]})},e.value))}),J(R,{flexDirection:`column`,width:`50%`,children:Ft.slice(6).map((e,t)=>{let n=t+6;return J(R,{children:Y(z,{color:L===`borderStyle`&&M===n?`cyan`:void 0,children:[L===`borderStyle`&&M===n?`❯ `:` `,M===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:re,children:re})}),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`?`❯ `:` `,b?`●`:`○`,` 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:F?.colors?.userMessageBackground,color:F?.colors?.text,children:[` `,`> list the dir`,` `]})}),J(R,{marginLeft:1,marginTop:1,children:Y(z,{children:[J(z,{color:F?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:F?.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:F?.colors?.inactive||`#888888`,children:`●`}),J(z,{children:` The directory `}),J(z,{color:F?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),J(z,{children:` contains `}),J(z,{bold:!0,children:`123`}),J(z,{children:` files.`})]})})]})]})]})]})}const Lt=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Rt=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function zt({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 Bt({highlighterIndex:e,onBack:t}){let{settings:n,updateSettings:r}=H($),i=n.inputPatternHighlighters[e],a=v(),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||[]),[_,y]=W(i?.foregroundColor===null?`none`:`custom`),[b,x]=W(i?.foregroundColor||`rgb(255,0,255)`),[S,C]=W(i?.backgroundColor?`custom`:`none`),[w,ee]=W(i?.backgroundColor||`rgb(0,0,0)`),[T,te]=W(i?.enabled??!0),[E,D]=W(n.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[O,k]=W(`name`),[A,j]=W(!1),[M,N]=W(0),[ne,re]=W(null),[ie,ae]=W(``),[oe,se]=W(null),[P,ce]=W(0),[F,le]=W(0);if(U(()=>{let e=Rt[P];k(e[Math.min(F,e.length-1)])},[P,F]),U(()=>{if(!l){se(null);return}try{new RegExp(l,d),se(null)}catch(e){se(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`?b:null,backgroundColor:S===`custom`?w:null,enabled:T})})},[e,s,l,d,p,h,_,b,S,w,T]),U(()=>{r(e=>{e.inputPatternHighlightersTestText=E})},[E]),B((e,r)=>{if(A){r.return?j(!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`),j(!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(ne===null){if(r.escape)t();else if(r.upArrow)O===`styling`&&M>0?N(e=>e-1):ce(e=>Math.max(0,e-1));else if(r.downArrow)O===`styling`&&M<Lt.length-1?N(e=>e+1):ce(e=>Math.min(Rt.length-1,e+1));else if(r.leftArrow)O===`foreground`?y(e=>e===`none`?`custom`:`none`):O===`background`?C(e=>e===`none`?`custom`:`none`):le(e=>Math.max(0,e-1));else if(r.rightArrow)if(O===`foreground`)y(e=>e===`none`?`custom`:`none`);else if(O===`background`)C(e=>e===`none`?`custom`:`none`);else{let e=Rt[P].length-1;le(t=>Math.min(e,t+1))}else if(r.tab){let e=Rt.flat(),t=e.indexOf(O);if(r.shift){if(t>0){let n=e[t-1];for(let e=0;e<Rt.length;e++){let t=Rt[e].indexOf(n);if(t>=0){ce(e),le(t);break}}}}else if(t<e.length-1){let n=e[t+1];for(let e=0;e<Rt.length;e++){let t=Rt[e].indexOf(n);if(t>=0){ce(e),le(t);break}}}}else if(r.return)O===`name`||O===`regex`||O===`regexFlags`||O===`format`||O===`testText`?j(!0):O===`foreground`&&_===`custom`?(ae(b),re(`foreground`)):O===`background`&&S===`custom`&&(ae(w),re(`background`));else if(e===` `)if(O===`styling`){let e=Lt[M].value;h.includes(e)?g(h.filter(t=>t!==e)):g([...h,e])}else O===`enabled`&&te(!T)}}),!i)return J(R,{flexDirection:`column`,children:J(z,{color:`red`,children:`Highlighter not found`})});if(ne)return J(mt,{initialValue:ie,theme:o,onColorChange:e=>{ne===`foreground`?x(e):ne===`background`&&ee(e)},onExit:()=>{re(null),ae(``)}});let I=e=>O===e,ue=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,{...ue(`name`),children:[I(`name`)?`❯ `:` `,`Name`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`name`)?A?`green`:`yellow`:`gray`,children:J(z,{children:s||`(empty)`})})})]}),Y(R,{flexDirection:`column`,width:`45%`,children:[Y(z,{...ue(`regex`),children:[I(`regex`)?`❯ `:` `,`Regex Pattern`]}),Y(R,{marginLeft:2,flexDirection:`column`,children:[J(R,{borderStyle:`round`,borderColor:I(`regex`)?A?`green`:`yellow`:oe?`red`:`gray`,children:J(z,{children:l||`(empty)`})}),oe&&J(z,{color:`red`,children:oe})]})]}),Y(R,{flexDirection:`column`,width:`20%`,children:[Y(z,{...ue(`regexFlags`),children:[I(`regexFlags`)?`❯ `:` `,`Flags`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`regexFlags`)?A?`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,{...ue(`format`),children:[I(`format`)?`❯ `:` `,`Format String`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`format`)?A?`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,{...ue(`styling`),children:[I(`styling`)?`❯ `:` `,`Styling`]}),J(R,{marginLeft:2,flexDirection:`column`,children:Lt.map((e,t)=>{let n=h.includes(e.value),r=I(`styling`)&&M===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,{...ue(`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:b,children:` ████ `})})]})]}),Y(R,{flexDirection:`column`,width:`48%`,children:[Y(z,{...ue(`background`),children:[I(`background`)?`❯ `:` `,`Background Color`]}),Y(R,{marginLeft:2,flexDirection:`row`,gap:1,children:[Y(z,{color:I(`background`)?`yellow`:void 0,children:[`[`,S===`none`?`●`:`○`,`] none`,` `,`[`,S===`custom`?`●`:`○`,`] custom`]}),S===`custom`&&J(R,{borderStyle:`round`,borderColor:I(`background`)?`yellow`:`gray`,children:Y(z,{backgroundColor:w,children:[` `,` `,` `]})})]})]})]}),J(R,{marginBottom:1,children:Y(z,{...ue(`enabled`),children:[I(`enabled`)?`❯ `:` `,`Enabled:`,` `,J(z,{color:T?`green`:`red`,children:T?`● Yes`:`○ No`})]})}),Y(R,{flexDirection:`column`,marginBottom:1,children:[Y(z,{...ue(`testText`),children:[I(`testText`)?`❯ `:` `,`Test Text`]}),J(R,{marginLeft:2,children:J(R,{borderStyle:`round`,borderColor:I(`testText`)?A?`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(zt,{testText:E,regex:l,regexFlags:d,format:p,styling:h,foregroundColor:_===`custom`?b:void 0,backgroundColor:S===`custom`?w:void 0})}):J(z,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function Vt({onBack:e}){let{settings:{inputPatternHighlighters:t,themes:n},updateSettings:r}=H($),i=v(),a=n.find(e=>e.id===i)||n[0],o=N.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})},y=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))},b=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?y(l):n===`d`&&t.length>0&&l<t.length-1&&b(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(Bt,{highlighterIndex:d,onBack:()=>{f(null),m(!0)}})}const Ht=[null,1,5,10,25,50,100,200,250,500,1e3],Ut=1e3;function Wt({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,suppressRateLimitWarning:!1,sessionColor:!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,modelAtEffort:!0,filterScrollEscapeSequences:!1,enableWorktreeMode:!0,unlockResponsiveMode:!1,swapRipgrepForFff:!1,allowCustomAgentModels:!1,enableContextLimitOverride:!1,enableModelCustomizations:!0,enableVoiceMode:!1,enableVoiceConciseOutput:!0,enableChannelsMode:!1,maxEffortDefault:!1,autonomousOperationAllModels:!1,refusalFallbackModel:!1,refusalFallbackRoutes:{},refusalFallbackMaxReturns:1,outputStyleTurnReminder:!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=Ht.indexOf(e);if(n===-1)return Ht[0];let r;return r=t===`next`?(n+1)%Ht.length:(n-1+Ht.length)%Ht.length,Ht[r]},_=Ve(()=>[{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,chevronIdleThemeColor:null},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:`suppressRateLimitWarning`,title:`Suppress rate limit warning banners`,description:`Hides rate limit warning banners in the status bar. Error messages when limits are actually reached are still shown.`,getValue:()=>t.misc?.suppressRateLimitWarning??!1,toggle:()=>{n(e=>{c(),e.misc.suppressRateLimitWarning=!e.misc.suppressRateLimitWarning})}},{id:`sessionColor`,title:`Session color from TWEAKCC_SESSION_COLOR`,description:`Colors the session prompt bar from the TWEAKCC_SESSION_COLOR env var, read at each launch, so concurrent sessions can be told apart. Accepts red, blue, green, yellow, purple, orange, pink or cyan; any other value leaves the bar alone.`,getValue:()=>t.misc?.sessionColor??!1,toggle:()=>{n(e=>{c(),e.misc.sessionColor=!e.misc.sessionColor})}},{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:`unlockResponsiveMode`,title:`Unlock responsive mode (bundled plugin)`,description:`Make Claude Code's bundled responsive-mode plugin selectable in /plugin by dropping the tengu_quiet_ember flag check. Responsive mode makes Claude answer in a sentence before it thinks or uses a tool, and adds a system-prompt section against stock AI phrasing. It stays OFF until you enable it in /plugin.`,getValue:()=>t.misc?.unlockResponsiveMode??!1,toggle:()=>{n(e=>{c(),e.misc.unlockResponsiveMode=!e.misc.unlockResponsiveMode})}},{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-${Ut}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(Ut,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:`modelAtEffort`,title:`Allow /model name@effort`,description:`Lets /model opus@high set the model and the effort level in one command.`,getValue:()=>t.misc?.modelAtEffort??!0,toggle:()=>{n(e=>{c(),e.misc.modelAtEffort=!e.misc.modelAtEffort})}},{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:`refusalFallbackModel`,title:`Route the refusal fallback, then switch back`,description:`When safeguards flag a message, Claude Code retries it on a fallback model from its own route table, keyed by the flagged model and the refusal category, and keeps the session there. With this on, refusalFallbackRoutes in config.json is merged over that table: a category you leave out keeps its stock route, one you route falls back to the stock route when none of your models is usable, and a route is a model id or a chain of them. Once the flagged turn is answered, the session switches back to its own model and the transcript says so. refusalFallbackMaxReturns in config.json (default 1, null for no limit) caps consecutive returns, so a conversation that keeps being flagged stays on the fallback rather than paying for a refusal and a retry every turn.`,getValue:()=>t.misc?.refusalFallbackModel??!1,toggle:()=>{n(e=>{c(),e.misc.refusalFallbackModel=!e.misc.refusalFallbackModel})}},{id:`outputStyleTurnReminder`,title:`Per-turn reminder for custom output styles`,description:`Claude Code reminds the model which output style is active once per turn, but only for its three built-in styles. The renderer looks the style up in the built-in table and returns nothing when it is missing, and custom styles are merged into a copy of that table rather than into the table itself. So a style you wrote yourself is injected into the system prompt once and never restated, while Proactive or Explanatory are restated every turn. This makes the reminder fire for custom styles too, using the name you configured. A style that defines its own turnReminder gets that text; otherwise it gets one short sentence pointing back at the style.`,getValue:()=>t.misc?.outputStyleTurnReminder??!1,toggle:()=>{n(e=>{c(),e.misc.outputStyleTurnReminder=!e.misc.outputStyleTurnReminder})}},{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=Ve(()=>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 Gt=`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 Kt({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.acceptEditsToolset===n&&(t.acceptEditsToolset=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(Gt.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(Gt.length+1,e+1));else if(e===` `||n.return)if(d===0)m(`All`);else if(d===1)m(`None`);else{let e=Gt[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`]})}),Gt.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 qt({onBack:e}){let{settings:{toolsets:t,defaultToolset:n,acceptEditsToolset:r,planModeToolset:i,themes:a},updateSettings:o}=H($),s=v(),c=a.find(e=>e.id===s)||a[0],l=N.themes[0],u=c?.colors.planMode||l.colors.planMode,d=c?.colors.autoAccept||l.colors.autoAccept,[f,p]=W(0),[m,h]=W(null),[g,_]=W(!0),y=()=>{let e={name:`New Toolset`,allowedTools:[]};o(t=>{t.toolsets.push(e)}),h(t.length),_(!1)},b=e=>{let n=t[e];o(t=>{t.toolsets.splice(e,1),t.defaultToolset===n.name&&(t.defaultToolset=null),t.acceptEditsToolset===n.name&&(t.acceptEditsToolset=null),t.planModeToolset===n.name&&(t.planModeToolset=null)}),f>=t.length-1&&p(Math.max(0,t.length-2))},x=e=>{let n=t[e];o(e=>{e.defaultToolset=n.name})},S=e=>{let n=t[e];o(e=>{e.acceptEditsToolset=n.name})},C=e=>{let n=t[e];o(e=>{e.planModeToolset=n.name})};if(B((n,r)=>{r.escape?e():r.upArrow?p(e=>Math.max(0,e-1)):r.downArrow?p(e=>Math.min(t.length-1,e+1)):r.return&&t.length>0?(h(f),_(!1)):n===`n`?y():n===`x`&&t.length>0?b(f):n===`d`&&t.length>0?x(f):n===`a`&&t.length>0?S(f):n===`p`&&t.length>0&&C(f)},{isActive:g}),m!==null)return J(Kt,{toolsetIndex:m,onBack:()=>{h(null),_(!0)}});let w=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:`a to set as accept edits 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 a=e.name===n,o=e.name===r,s=e.name===i,c=f===t,l;return c&&(l=`yellow`),Y(R,{flexDirection:`row`,children:[Y(z,{color:l,children:[c?`❯ `:` `,e.name,` `]}),Y(z,{color:l,children:[`(`,w(e),`)`]}),a&&J(z,{color:l,children:` default`}),o&&J(z,{color:d,children:` ⏵⏵ accept edits`}),s&&J(z,{color:u,children:` ⏸ plan mode`})]},t)})})]})}function Jt({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)})]})}function Yt({onBack:t}){let[n,r]=W(null),[i,a]=W(!1),[o,s]=W(`Press c to check key availability.`),c=async e=>{a(!0);try{s(await e())}catch{s(`Credential operation failed. Unlock your keychain, or install secret-tool and unlock Secret Service on Linux. For headless use, supply TYPESAFE_API_KEY through your secret manager.`)}finally{a(!1)}};return B((a,o)=>{if(!i){if(o.escape){n===null?t():r(null);return}if(n!==null){if(o.return){if(!n.trim()||/[^\x21-\x7e]/.test(n)){s(`Enter a nonempty API key without spaces or control characters.`);return}let t=n;r(null),c(async()=>(await e(t),`API key saved securely.`))}else o.backspace||o.delete?r(n.slice(0,-1)):a&&!o.ctrl&&!o.meta&&(/[^\x21-\x7e]/.test(a)?s(`Paste only the API key, without spaces or control characters.`):n.length+a.length<=1024&&r(n+a));return}a===`e`||o.return?(r(``),s(`Enter to save; escape to discard.`)):a===`c`?c(async()=>await g()?`API key available.`:`No API key available.`):a===`d`&&c(async()=>(await w(),`Stored key removed. TYPESAFE_API_KEY, if set, still takes precedence.`))}}),Y(R,{flexDirection:`column`,children:[J(X,{children:`TypeSafe API key`}),J(z,{children:`Stored in your OS credential store, never router settings.`}),J(z,{dimColor:!0,children:`Headless use: provide TYPESAFE_API_KEY through your secret manager.`}),J(z,{children:i?`Working…`:o}),n===null?J(z,{dimColor:!0,children:`enter/e set key · c check · d delete stored key · esc back`}):Y(z,{children:[`API key: `,`•`.repeat(Math.min(n.length,48)),`_`]})]})}const Xt=[{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`}],Zt={jevTimeoutMs:{label:`Jev timeout`,unit:`ms`,lo:250,hi:3e4,hint:`maximum routing wait; unusable responses fall back to medium`},contextBudgetBytes:{label:`Jev context budget`,unit:`bytes`,lo:4e3,hi:28e3,hint:`bounds the message, summary, and recent unsummarized context`},summaryMaxChars:{label:`Summary cap`,unit:`chars`,lo:500,hi:12e3,hint:`concise scope, progress, constraints, and unresolved difficulties`},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:`Haiku call timeout; Jev summaries run asynchronously`}},Qt=[`enabled`,`provider`,`credentials`,`jevTimeoutMs`,`contextBudgetBytes`,`summaryMaxChars`,`pinPerTask`,`messageCap`,`assistantCap`,`timeoutMs`,`systemPrompt`],$t=e=>e in Zt,en=N.complexityRouter;function tn({onBack:e}){let{settings:t,updateSettings:n}=H($),r={...en,...t.complexityRouter??{},levels:t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:en.levels},i=Qt.filter(e=>r.provider===`jev`&&e!==`systemPrompt`&&e!==`pinPerTask`||r.provider!==`jev`&&![`credentials`,`jevTimeoutMs`,`contextBudgetBytes`,`summaryMaxChars`].includes(e)),a=i.length+r.levels.length,[o,s]=W(!1),{setRawMode:c,isRawModeSupported:l}=Pe(),[u,d]=W(0),{stdout:f}=Fe(),p=Math.max(1,Math.min(a,(f.rows||24)-18)),m=Math.max(0,Math.min(u-Math.floor(p/2),a-p)),h=e=>e>=m&&e<m+p,[g,_]=W(null),[v,y]=W(0),[b,x]=W(null),[S,C]=W(null),[,w]=W(0),T=e=>{n(t=>{let n={...en,...t.complexityRouter??{},levels:(t.complexityRouter?.levels&&t.complexityRouter.levels.length>0?t.complexityRouter.levels:en.levels).map(e=>({...e}))};e(n),t.complexityRouter=n})};if(B((t,n)=>{if(o)return;if(S){if(n.escape){C(null);return}if(n.return){let{kind:e,levelIndex:t,value:n}=S;T(r=>{let i=r.levels[t];i&&(i[e]=n)}),C(null);return}if(n.backspace||n.delete){C(e=>e&&{...e,value:e.value.slice(0,-1)});return}t&&!n.ctrl&&!n.meta&&C(e=>e&&{...e,value:e.value+t});return}if(b){if(n.escape){x(null);return}if(n.return){let e=Zt[b.row],t=Number(b.value),n=Math.round(t),r=Number.isFinite(n)?Math.min(e.hi,Math.max(e.lo,n)):en[b.row],i=b.row;T(e=>{Object.assign(e,{[i]:r})}),x(null);return}if(n.backspace||n.delete){x(e=>e&&{...e,value:e.value.slice(0,-1)});return}/^[0-9.]$/.test(t)&&x(e=>e&&e.value.length<7?{...e,value:e.value+t}:e);return}if(g){if(n.escape){_(null);return}if(n.upArrow){y(e=>e>0?e-1:Xt.length-1);return}if(n.downArrow){y(e=>e<Xt.length-1?e+1:0);return}if(n.return){let e=Xt[v].value,t=g.levelIndex;T(n=>{n.levels[t]&&(n.levels[t].effort=e)}),_(null)}return}if(n.escape){e();return}if(n.upArrow){d(e=>e>0?e-1:a-1);return}if(n.downArrow){d(e=>e<a-1?e+1:0);return}let f=u<i.length,p=u-i.length;if(t===`x`){if(f){let e=i[u];$t(e)?T(t=>{Object.assign(t,{[e]:en[e]})}):e===`systemPrompt`&&T(e=>{e.systemPrompt=en.systemPrompt})}else{let e=en.levels[p];e&&T(t=>{let n=t.levels[p];n&&(n.effort=e.effort,n.label=e.label,n.help=e.help)})}return}if(!f&&(t===`l`||t===`h`)){let e=t===`l`?`label`:`help`,n=r.levels[p];n&&C({kind:e,levelIndex:p,value:n[e]});return}if(t===` `||n.return)if(f){let e=i[u];if(e===`enabled`)T(e=>{e.enabled=!e.enabled});else if(e===`provider`)T(e=>{e.provider=e.provider===`jev`?`haiku`:`jev`});else if(e===`credentials`)s(!0);else if(e===`pinPerTask`)T(e=>{e.pinPerTask=!e.pinPerTask});else if(e===`systemPrompt`){l&&c(!1);let e=ee(r.systemPrompt);if(l&&c(!0),e!=null){let t=e.replace(/\s+$/,``);t&&t!==r.systemPrompt&&T(e=>{e.systemPrompt=t})}w(e=>e+1)}else x({row:e,value:String(r[e])})}else{let e=Xt.findIndex(e=>e.value===r.levels[p]?.effort);y(e>=0?e:0),_({levelIndex:p})}}),o)return J(Yt,{onBack:()=>s(!1)});if(g)return Y(R,{flexDirection:`column`,children:[J(R,{marginBottom:1,children:Y(X,{children:[`Select effort for "`,r.levels[g.levelIndex]?.label,`"`]})}),Xt.map((e,t)=>{let n=t===v;return J(R,{children:Y(z,{color:n?`cyan`:void 0,children:[n?`❯ `:` `,e.value,Y(z,{dimColor:!0,children:[` - `,e.blurb]})]})},t)})]});let te=(e,t)=>{let n=t===u,i,a,o=``;if(e===`enabled`)i=`Router model entries`,a=r.enabled?`on`:`off`;else if(e===`provider`)i=`Routing provider`,a=r.provider===`jev`?`Jev + asynchronous Haiku summaries`:`Haiku`,o=`Jev sends your current message and concise context to TypeSafe, billed separately. Enter to switch.`;else if(e===`credentials`)i=`TypeSafe API key`,a=`enter to securely set, check, or delete`,o=`Model: ${r.jevModel}`;else if(e===`pinPerTask`)i=`Keep highest effort this session`,a=r.pinPerTask?`on`:`off`,o=`On: effort never falls below the session maximum. Off: adapt each message. Reset on /clear.`;else if(e===`systemPrompt`){i=`System prompt`;let e=r.systemPrompt===en.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=Zt[e];i=e===`timeoutMs`&&r.provider===`jev`?`Haiku summary timeout`:t.label,b?.row===e?(a=`${b.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:`Apply to add Opus 5.5 and Fable 5.1 + Effort Router to /model. Select a router entry to enable per-message routing. Manual /effort and CLAUDE_CODE_EFFORT_LEVEL take precedence.`}),r.provider===`jev`&&J(z,{dimColor:!0,children:`Jev receives your message and concise context. TypeSafe bills separately. Haiku updates summaries asynchronously.`}),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`})]}),i.map((e,t)=>h(t)?te(e,t):null),Y(z,{dimColor:!0,children:[`Showing `,m+1,`–`,m+p,` of `,a,` `,`settings and effort tiers`]}),r.levels.map((e,t)=>{let n=i.length+t;if(!h(n))return null;let r=n===u,a=S?.levelIndex===t&&S.kind===`label`,o=S?.levelIndex===t&&S.kind===`help`;return Y(R,{flexDirection:`column`,children:[J(R,{children:Y(z,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,J(z,{bold:!0,children:a?`${S.value}_`:e.label}),` `,J(z,{color:`green`,children:e.effort})]})}),r&&J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:o?`${S.value}_`:e.help})}),r&&!S?J(R,{marginLeft:4,children:J(z,{dimColor:!0,children:`enter = set effort · l = edit label · h = edit help · x = reset this tier`})}):null,r&&S?J(R,{marginLeft:4,children:Y(z,{dimColor:!0,children:[`editing `,S.kind,` - type to change · enter save · esc cancel`]})}):null]},e.id)})]})}const nn=[`fable`,`opus`,`sonnet`,`haiku`],rn=e=>e.charAt(0).toUpperCase()+e.slice(1),an=[{kind:`enabled`},{kind:`model`,side:`plan`},{kind:`model`,side:`exec`},{kind:`clearContext`}],on=({onBack:e})=>{let{settings:t,updateSettings:n}=H($),r={...N.fablePlan,...t.fablePlan??{}},[i,a]=W(0),o=e=>{n(t=>({...t,fablePlan:{...N.fablePlan,...t.fablePlan??{},...e}}))},s=e=>{let t=an[i];if(t.kind===`enabled`){o({enabled:!r.enabled});return}if(t.kind===`clearContext`){o({offerClearContextOnPlanAccept:!r.offerClearContextOnPlanAccept});return}let n=t.side===`plan`?`planModel`:`execModel`,a=t.side===`plan`?r.execModel:r.planModel,s=nn.indexOf(r[n]);for(let t=1;t<=nn.length;t++){let r=nn[(s+e*t+nn.length*t)%nn.length];if(r!==a){o({[n]:r});return}}};B((t,n)=>{if(n.escape||t===`q`){e();return}n.upArrow?a(e=>(e-1+an.length)%an.length):n.downArrow?a(e=>(e+1)%an.length):n.leftArrow?s(-1):n.rightArrow||n.return||t===` `?s(1):t===`x`&&o({...N.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: `,rn(r.planModel),` `,`while planning, `,rn(r.execModel),` while executing, each at the effort you set for that model in `,J(z,{color:`green`,children:`/model`}),`.`]}),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:an.map((e,t)=>e.kind===`enabled`?c(t,`Enabled`,r.enabled?`yes`:`no`):e.kind===`clearContext`?c(t,`Offer "clear context"`,r.offerClearContextOnPlanAccept?`yes`:`no`):c(t,`${e.side===`plan`?`Planning`:`Executing`} model`,rn(e.side===`plan`?r.planModel:r.execModel)))}),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 `,rn(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.`]}),Y(z,{dimColor:!0,children:[`Reasoning effort is Claude Code's own per-model setting: pick`,` `,rn(r.planModel),` in `,J(z,{color:`green`,children:`/model`}),`, set its effort, then do the same for `,rn(r.execModel),`. An explicit `,J(z,{color:`green`,children:`/effort`}),` applies to both sides for the rest of the session.`]})]}),J(R,{marginTop:1,children:J(z,{dimColor:!0,children:`↑↓ move · ←→ change · x reset to defaults · esc back`})})]})},sn=K.join(F,`claude-browser-bridge`),cn=K.join(sn,`host`,`setup.mjs`),ln=K.join(sn,`extension`),un=K.join(Ue.homedir(),`.claude-browser-bridge`,`install-state.json`),dn=`/tmp/claude-browser-bridge-${Ue.userInfo().username}.sock`;function fn(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 pn(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 mn(e){return new Promise(t=>{Ke(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 hn(e){return new Promise(t=>{Ke(`git`,e,{maxBuffer:8*1024*1024},(e,n,r)=>{t({code:e?1:0,out:String(n)+String(r)})})})}async function gn(){if(G.existsSync(K.join(sn,`.git`))&&G.existsSync(cn)){let e=await hn([`-C`,sn,`pull`,`--ff-only`]);return G.existsSync(cn)?{code:0,out:e.out}:e}return G.existsSync(sn)&&G.rmSync(sn,{recursive:!0,force:!0}),hn([`clone`,`--depth`,`1`,`https://github.com/skrabe/claude-browser-bridge`,sn])}function _n(){let e=process.platform===`darwin`?K.join(Ue.homedir(),`Library`,`Application Support`):K.join(Ue.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)])fn(e)&&n.push(pn(e));return n.sort()}function vn(){try{return JSON.parse(G.readFileSync(un,`utf8`))}catch{return null}}const yn=({onBack:e})=>{let[t,n]=W(`menu`),[r,i]=W(0),[a,o]=W(vn()),[s,c]=W(`global`),[l,u]=W(`Working…`),[d,f]=W([]),[p,m]=W(null),[h,g]=W(``),[_,v]=W(`install`),[y,b]=W(null),[x,S]=W(null),C=Be(()=>{o(vn())},[]);U(()=>{C()},[C]);let w=G.existsSync(dn),ee=!!a,T=ee&&!a.mcpName,te=()=>{c(`global`),i(0),n(`scope`)},E=Be(async e=>{n(`busy`),u(`Fetching the bridge…`),f([]);let t=await gn();if(t.code!==0||!G.existsSync(cn)){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=[cn,`install`,`--scope`,e];e===`project`&&r.push(`--project`,process.cwd());let a=await mn(r);if(f(a.out.split(`
|
|
4
4
|
`).filter(e=>e.includes(`[bridge]`)).map(e=>e.replace(`[bridge]`,``).trim())),a.code!==0&&a.code!==3){g(`Install failed:
|
|
5
5
|
`+a.out.slice(-600)),n(`error`);return}C(),i(0),S(null),a.code===3?(v(`install`),b(null),n(`desktop`)):n(`extmodal`)},[C]),D=Be(async()=>{n(`busy`),u(`Connecting to the extension…`),m(null),(await mn([cn,`verify`])).code===0?(i(0),n(`done`)):(m(`Not detected. Make sure the extension is loaded AND enabled, then retry.`),i(0),n(`extmodal`))},[]),O=Be(async()=>{n(`busy`),u(`Uninstalling…`);let e=await mn([cn,`uninstall`]);if(f(e.out.split(`
|
package/dist/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,H as t,M as n,R as r,U as i,V as a,W as o,a as s,c,g as l,it as u,l as d,r as f,rt as p,z as m}from"../config-
|
|
1
|
+
import{B as e,H as t,M as n,R as r,U as i,V as a,W as o,a as s,c,g as l,it as u,l as d,r as f,rt as p,z as m}from"../config-h2_qLiXs.mjs";import{a as h,i as g,n as _,r as v,t as y}from"../content-Co05XSpg.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 l(e))throw Error(`Backup file does not exist: ${e}`);await n(t,e,`restore`)}function w(){return c()}function T(){return f}function E(){return s}async function D(){return await d()}const O={findChalkVar:e,getModuleLoaderFunction:t,getReactVar:i,getRequireFuncName:o,findTextComponent:a,findBoxComponent:m,clearCaches:r,globalReplace:p,showDiff:u};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{T as e,m as t}from"./config-
|
|
1
|
+
import{T as e,m as t}from"./config-h2_qLiXs.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(e){try{if(r.statSync(e).size>2e5)return null;s.logging.disable();let n=s.parse(e);if(!n.symbols().some(e=>{let t=e.name;return t===`execv`||t===`_execv`}))return t(`resolveNixBinaryWrapper: no execv import found, not a Nix wrapper`),null;t(`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 t(`resolveNixBinaryWrapper: could not read string section`),null;let a=i.toString(`utf-8`),o=a.match(/makeCWrapper\s+'(\/nix\/store\/[^']+)'/);if(o){let e=o[1];return t(`resolveNixBinaryWrapper: found wrapped executable via DOCSTRING: ${e}`),e}let c=a.match(/makeCWrapper\s+(\/nix\/store\/\S+)/);if(c){let e=c[1];return t(`resolveNixBinaryWrapper: found wrapped executable via unquoted DOCSTRING: ${e}`),e}let l=a.match(/\/nix\/store\/[^\0\n\r]+/g);if(l){for(let e of l)if(e.includes(`/bin/`))return t(`resolveNixBinaryWrapper: found wrapped executable via /bin/ heuristic: ${e}`),e}return t(`resolveNixBinaryWrapper: has execv but no Nix store paths found`),null}catch(e){return t(`resolveNixBinaryWrapper: error during detection:`,e),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`}const p=/\n\/\*@@TWEAKCC_MODULE:(\d+):([^@]*)@@\*\/\n/g,m=(e,t)=>`\n/*@@TWEAKCC_MODULE:${e}:${t}@@*/\n`,h=new TextDecoder(`utf-8`,{fatal:!0});function g(e){try{return h.decode(e),!0}catch{return!1}}function _(e,t,n){if(t<=0)return!1;let r=e.replaceAll(`\\`,`/`);return!r.endsWith(`.js`)&&!f(r)?!1:n===void 0||g(n)}function v(e){let t=e.toString(`latin1`);if(!t.includes(`/*@@TWEAKCC_MODULE:`))return null;let n=new Map,r=[];p.lastIndex=0;let i;for(;(i=p.exec(t))!==null;)r.push({index:Number(i[1]),start:i.index,end:i.index+i[0].length});if(r.length===0)return null;for(let t=0;t<r.length;t++){let i=r[t].end,a=t+1<r.length?r[t+1].start:e.length;n.set(r[t].index,Buffer.from(e.subarray(i,a)))}return n}function y(e){let n=e%52==0,r=e%36==0;return n&&!r?52:r&&!n?36:n&&r?(t(`detectModuleStructSize: Ambiguous module list length ${e}, assuming new format`),52):(t(`detectModuleStructSize: Module list length ${e} doesn't cleanly divide by either struct size, assuming new format`),52)}function b(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=S(i,t*n,n),o=r(a,u(e,a.name).toString(`utf-8`),t);if(o!==void 0)return o}}function x(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 S(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 C(e){if(e.length<32+l.length)throw Error(`BUN data is too small to contain trailer and offsets`);let n=e.length-l.length,r=e.subarray(n);if(t(`parseBunDataBlob: Expected trailer: ${l.toString(`hex`)}`),t(`parseBunDataBlob: Got trailer: ${r.toString(`hex`)}`),!r.equals(l))throw Error(`BUN trailer bytes do not match trailer`);let i=e.length-32-l.length,a=x(e.subarray(i,i+32));return{bunOffsets:a,bunData:e,moduleStructSize:y(a.modulesPtr.length)}}function w(e){if(e.length<4)throw Error(`Section data too small`);t(`extractBunDataFromSection: sectionData.length=${e.length}`);let n=e.readUInt32LE(0),r=4+n,i=e.length>=8?Number(e.readBigUInt64LE(0)):0,a=8+i;t(`extractBunDataFromSection: u32 header would give size=${n}, expected total=${r}`),t(`extractBunDataFromSection: u64 header would give size=${i}, expected total=${a}`);let o,s;if(e.length>=8&&a<=e.length&&a>=e.length-4096)o=8,s=i,t(`extractBunDataFromSection: detected u64 header format (Bun >= 1.3.4)`);else if(r<=e.length&&r>=e.length-4096)o=4,s=n,t(`extractBunDataFromSection: detected u32 header format (Bun < 1.3.4)`);else throw Error(`Cannot determine section header format: sectionData.length=${e.length}, u64 would expect ${a}, u32 would expect ${r}`);t(`extractBunDataFromSection: bunDataSize from header=${s}`);let c=e.subarray(o,o+s);t(`extractBunDataFromSection: bunDataContent.length=${c.length}`);let{bunOffsets:l,bunData:u,moduleStructSize:d}=C(c);return{bunOffsets:l,bunData:u,sectionHeaderSize:o,moduleStructSize:d}}function T(e){try{let n=e.getSection(`.bun`);if(!n)return t(`extractBunDataFromELFSection: .bun section not found`),null;let r=n.content;if(r.length<8)return t(`extractBunDataFromELFSection: .bun section too small`),null;t(`extractBunDataFromELFSection: .bun section found, size=${r.length}`);let i=w(r);return t(`extractBunDataFromELFSection: successfully extracted data`),i}catch(e){return t(`extractBunDataFromELFSection: failed to extract:`,e),null}}function E(e){if(!e.hasOverlay)throw Error(`ELF binary has no overlay data`);let n=e.overlay;if(t(`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(t(`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(t(`extractBunDataFromELFOverlay: Expected trailer: ${l.toString(`hex`)}`),t(`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=x(s);t(`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),p=n.subarray(f,n.length-d);return t(`extractBunDataFromELFOverlay: Extracted ${p.length} bytes of data`),{bunOffsets:c,bunData:Buffer.concat([p,s,a]),moduleStructSize:y(c.modulesPtr.length)}}function D(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 w(n.content)}function O(e){let t=e.sections().find(e=>e.name===`.bun`);if(!t)throw Error(`.bun section not found`);return w(t.content)}function k(){switch(process.platform){case`darwin`:return`MachO`;case`linux`:return`ELF`;case`win32`:return`PE`;default:return null}}function A(e){if(process.env.TWEAKCC_ALLOW_CROSS_PLATFORM===`1`){t(`assertPlatformFormat: cross-platform check bypassed for ${e.format}`);return}let n=k();if(n&&e.format!==n)throw Error(`Native binary format ${e.format} does not match ${process.platform} (${n})`)}function j(e,n){switch(t(`locateBundle: Binary format detected as ${e.format}`),A(e),e.format){case`MachO`:{let t=e,r=D(t);if(!r.sectionHeaderSize)throw Error(`sectionHeaderSize is required for Mach-O binaries`);let i=t.getSegment(`__BUN`).getSection(`__bun`);return{...r,offset:Number(i.fileOffset),length:i.content.length,write:(e,i)=>R(t,n,e,i,r.sectionHeaderSize)}}case`PE`:{let t=e,r=O(t);if(!r.sectionHeaderSize)throw Error(`sectionHeaderSize is required for PE binaries`);let i=t.sections().find(e=>e.name===`.bun`);return{...r,offset:Number(i.fileOffset),length:i.content.length,write:(e,i)=>z(t,n,e,i,r.sectionHeaderSize)}}case`ELF`:{let i=e,a=T(i);if(a){if(t(`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)=>H(i,n,e,t,a.sectionHeaderSize)}}t(`locateBundle: Falling back to legacy ELF overlay format`);let o=E(i),s=r.statSync(n);return{...o,offset:s.size-i.overlay.length,length:i.overlay.length,write:(e,t)=>U(i,n,e,t)}}default:{let t=e;throw Error(`Unsupported binary format: ${t.format}`)}}}function M(e){let o=r.mkdtempSync(i.join(n.tmpdir(),`tweakcc-npm-`));try{t(`fetchNpmSource: Downloading @anthropic-ai/claude-code@${e}`),a(`npm`,[`pack`,`@anthropic-ai/claude-code@${e}`,`--pack-destination`,o],{stdio:`pipe`,timeout:3e4,cwd:o});let n=r.readdirSync(o).find(e=>e.endsWith(`.tgz`));if(!n)return t(`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 t(`fetchNpmSource: cli.js not found in extracted package`),null;let c=r.readFileSync(s);return t(`fetchNpmSource: Got cli.js, ${c.length} bytes`),c}catch(e){return t(`fetchNpmSource: Failed to fetch npm source:`,e),null}finally{try{r.rmSync(o,{recursive:!0,force:!0})}catch{}}}function N(e,n){try{s.logging.disable();let{bunOffsets:r,bunData:i,moduleStructSize:a}=j(s.parse(e),e);t(`extractClaudeJsFromNativeInstallation: Got bunData, size=${i.length} bytes, moduleStructSize=${a}`);let o=0,c=0;b(i,r,a,(e,t)=>{let n=e.contents.length;f(t)?o=n:_(t,n)&&(c+=n)});let l=c>o;if(t(`extractClaudeJsFromNativeInstallation: claudeLen=${o} otherJsLen=${c} codeSplit=${l}`),l){let e=[],n=0;if(b(i,r,a,(t,r,a)=>{if(t.contents.length<=0)return;let o=u(i,t.contents);_(r,t.contents.length,o)&&(e.push(Buffer.from(m(a,r),`utf8`)),e.push(o),n++)}),n===0)return{data:null,clearBytecode:!1,error:`code-split binary but no patchable JS modules were found`};let o=Buffer.from(`#!/usr/bin/env node\n// @bun @bytecode\n// Virtual bundle: ${n} modules, split on the module sentinels below.\nvar __ccVirtualBundleModules = ${n};\n`,`utf8`),s=Buffer.concat([o,...e]);return t(`extractClaudeJsFromNativeInstallation: built virtual bundle from ${n} modules, ${s.length} bytes`),{data:s,clearBytecode:!1}}let d=b(i,r,a,(e,n,r)=>{if(t(`extractClaudeJsFromNativeInstallation: Module ${r}: ${n}`),!f(n))return;let a=u(i,e.contents);return t(`extractClaudeJsFromNativeInstallation: Found claude module, contents length=${a.length}`),a.length>0?a:void 0});if(d){let e=d.subarray(0,64).toString(`utf8`);if(e.startsWith(`// @bun @bytecode`)&&!e.includes(`@bun-cjs`))if(t(`extractClaudeJsFromNativeInstallation: Extracted content is Bun bytecode — falling back to npm source`),n){let e=M(n);if(e)return t(`extractClaudeJsFromNativeInstallation: Using npm source (${e.length} bytes) instead of bytecode`),{data:e,clearBytecode:!0};t(`extractClaudeJsFromNativeInstallation: npm source fetch failed, returning bytecode content as-is`)}else t(`extractClaudeJsFromNativeInstallation: No version provided, cannot fetch npm source`);return{data:d,clearBytecode:!1}}return t(`extractClaudeJsFromNativeInstallation: claude module not found in any module`),{data:null,clearBytecode:!1,error:`claude module not found in any of the binary modules`}}catch(e){return t(`extractClaudeJsFromNativeInstallation: Error during extraction:`,e),{data:null,clearBytecode:!1,error:`extraction threw: ${e instanceof Error?e.message:String(e)}`}}}function P(e,n,r,i){let a=n.modulesPtr.offset,o=e.subarray(0,a),s=Buffer.from(e.subarray(a)),c=[],d=o.length,f=0;b(e,n,r,(t,n,a)=>{let o=i.get(a);if(!o)return;let l=u(e,t.contents);if(o.equals(l))return;let p=d%8==0?0:8-d%8;p>0&&(c.push(Buffer.alloc(p)),d+=p);let m=a*r;s.writeUInt32LE(d,m+8),s.writeUInt32LE(o.length,m+12),s.writeUInt32LE(0,m+28),c.push(o,Buffer.alloc(1)),d+=o.length+1,f++});let p=d%8==0?0:8-d%8;p>0&&c.push(Buffer.alloc(p));let m=d+p,h=m-a;t(`rebuildBunDataAppendOnly: ${f} module(s) changed, appended ${m-o.length} bytes, tail shifted by ${h}`);let g=Buffer.concat([o,...c,s]),_=g.length-32-l.length;return g.writeBigUInt64LE(BigInt(Number(n.byteCount)+h),_),g.writeUInt32LE(m,_+8),g.writeUInt32LE(n.compileExecArgvPtr.offset+h,_+20),g}function F(e,t,n,r,i){let a=[],o=[];b(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,m=o.length*r;c+=m;let h=u(e,t.compileExecArgvPtr),g=c,_=h.length;c+=_+1;let v=c;c+=32;let y=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++;_>0&&(h.copy(x,g,0,_),x[g+_]=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:v,modulesPtr:{offset:p,length:m},entryPointId:t.entryPointId,compileExecArgvPtr:{offset:g,length:_},flags:t.flags},w=v,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,y),x}function I(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 L(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 R(n,r,i,a,c){try{t(`repackMachO: Has code signature: ${n.hasCodeSignature}`),n.hasCodeSignature&&(t(`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=L(i,c);t(`repackMachO: Original section size: ${u.size}`),t(`repackMachO: Original segment fileSize: ${l.fileSize}`),t(`repackMachO: Original segment virtualSize: ${l.virtualSize}`),t(`repackMachO: New data size: ${d.length}`),t(`repackMachO: Using header size: ${c}`);let f=d.length-Number(u.size);if(f>0){let e=n.header.cpuType===s.MachO.Header.CPU_TYPE.ARM64,r=e?16384:4096,i=Math.ceil(f/r)*r;t(`repackMachO: CPU type: ${e?`ARM64`:`x86_64`}`),t(`repackMachO: Page size: ${r} bytes`),t(`repackMachO: Need to expand by ${f} bytes`),t(`repackMachO: Rounding up to page-aligned: ${i} bytes`);let a=n.extendSegment(l,i);if(t(`repackMachO: extendSegment returned: ${a}`),!a)throw Error(`Failed to extend __BUN segment`);t(`repackMachO: Section size after extend: ${u.size}`),t(`repackMachO: Segment fileSize after extend: ${l.fileSize}`),t(`repackMachO: Segment virtualSize after extend: ${l.virtualSize}`)}u.content=d,u.size=BigInt(d.length),t(`repackMachO: Final section size: ${u.size}`),t(`repackMachO: Writing modified binary to ${a}...`),I(n,a,r);try{t(`repackMachO: Re-signing binary with ad-hoc signature...`),o(`codesign -s - -f "${a}"`,{stdio:e()?`inherit`:`ignore`}),t(`repackMachO: Code signing completed successfully`)}catch(e){console.warn(`Warning: Failed to re-sign binary. The binary may not run correctly on macOS:`,e)}t(`repackMachO: Write completed successfully`)}catch(e){throw console.error(`repackMachO failed:`,e),e}}function z(e,n,r,i,a){try{let o=e.sections().find(e=>e.name===`.bun`);if(!o)throw Error(`.bun section not found`);let s=L(r,a);t(`repackPE: Original section size: ${o.size}, virtual size: ${o.virtualSize}`),t(`repackPE: New data size: ${s.length}`),t(`repackPE: Using header size: ${a}`),o.content=s,o.virtualSize=BigInt(s.length),o.size=BigInt(s.length),t(`repackPE: Writing modified binary to ${i}...`),I(e,i,n,!1),t(`repackPE: Write completed successfully`)}catch(e){throw console.error(`repackPE failed:`,e),e}}function B(e,t){return(e+t-1n)/t*t}function V(e){let{rwVirtualAddress:t,rwVirtualSize:n,rwFileOffset:r,rwFileSize:i,topmostLoadEnd:a,nextVirtualAddress:o,newContentSize:s,pageSize:c}=e,l=B(s,c),u=t+n,d=u>=a,f=B(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 H(e,n,r,i,a){try{let o=e.getSection(`.bun`);if(!o)throw Error(`.bun section not found`);let s=e.segments().find(e=>e.type===`LOAD`&&(e.flags&2)!=0);if(!s)throw Error(`No writable ELF PT_LOAD segment found`);let c=L(r,a),l=o.virtualAddress,u=Buffer.alloc(8);u.writeBigUInt64LE(l);let d=null,f=s.content,p=s.virtualAddress,m=p+BigInt(f.length),h=l>p&&l<m?l:m,g=B(p,8n),_=h-8n,v=[];for(let e=g;e<=_;e+=8n){let t=Number(e-p);f.subarray(t,t+8).equals(u)&&v.push(e)}if(d=v.find(e=>e%BigInt(16384)===0n)??v[0]??null,d===null)throw Error(`Could not find original BUN_COMPILED location in binary (searched for 0x${l.toString(16)} in the RW segment before the .bun data)`);v.length>1&&t(`repackELFSection: ${v.length} candidates for BUN_COMPILED (${v.map(e=>`0x`+e.toString(16)).join(`, `)}); using 0x${d.toString(16)}`);let y=e.pageSize(),b=BigInt(c.length),x=e.segments().filter(e=>e.type===`LOAD`).reduce((e,t)=>{let n=BigInt(t.virtualAddress)+BigInt(t.virtualSize);return n>e?n:e},0n),{newVaddr:S,newFileOffset:C,extensionSize:w,compact:T}=V({rwVirtualAddress:BigInt(s.virtualAddress),rwVirtualSize:BigInt(s.virtualSize),rwFileOffset:BigInt(s.fileOffset),rwFileSize:BigInt(s.fileSize),topmostLoadEnd:x,nextVirtualAddress:BigInt(e.nextVirtualAddress()),newContentSize:b,pageSize:BigInt(y)});if(t(`repackELFSection: ${T?`compact`:`fallback`} placement (topmost LOAD ends at 0x${x.toString(16)})`),w<0n)throw Error(`New .bun location overlaps existing writable ELF segment`);if(t(`repackELFSection: moving .bun to offset=0x${C.toString(16)}, vaddr=0x${S.toString(16)}, size=0x${b.toString(16)}`),w>0n&&!e.extend(s,w))throw Error(`Failed to extend writable ELF PT_LOAD segment`);o.fileOffset=C,o.virtualAddress=S,o.content=c,o.size=b;let E=Buffer.alloc(8);E.writeBigUInt64LE(S),e.patchAddress(d,E),t(`repackELFSection: Patched BUN_COMPILED at vaddr 0x${d.toString(16)} -> 0x${S.toString(16)}`),I(e,i,n),t(`repackELFSection: Write completed successfully`)}catch(e){throw console.error(`repackELFSection failed:`,e),e}}function U(e,n,r,i){try{let a=Buffer.allocUnsafe(r.length+8);r.copy(a,0),a.writeBigUInt64LE(BigInt(r.length),r.length),t(`repackELFOverlay: Setting overlay data (${a.length} bytes)`),e.overlay=a,t(`repackELFOverlay: Writing modified binary to ${i}...`),I(e,i,n),t(`repackELFOverlay: Write completed successfully`)}catch(e){throw console.error(`repackELFOverlay failed:`,e),e}}function W(e,t,n,r){s.logging.disable();let i=j(s.parse(e),e),a=v(t);if(a){let e=new Set;b(i.bunData,i.bunOffsets,i.moduleStructSize,(t,n,r)=>{t.contents.length<=0||_(n,t.contents.length,u(i.bunData,t.contents))&&e.add(r)});let t=[...e].filter(e=>!a.has(e)),n=[...a.keys()].filter(t=>!e.has(t));if(t.length>0||n.length>0)throw Error(`repackNativeInstallation: module sentinel mismatch — ${t.length} missing (${t.slice(0,5).join(`, `)}), ${n.length} unexpected (${n.slice(0,5).join(`, `)}). A patch most likely deleted a /*@@TWEAKCC_MODULE:@@*/ boundary.`)}let o=a?P(i.bunData,i.bunOffsets,i.moduleStructSize,a):F(i.bunData,i.bunOffsets,t,i.moduleStructSize,r);i.write(o,n)}export{V as computeBunSectionPlacement,N as extractClaudeJsFromNativeInstallation,f as isClaudeModule,_ as isPatchableJsModule,m as moduleSentinel,v as parseSentinelBundle,W as repackNativeInstallation,c as resolveNixBinaryWrapper};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tweakcc-fixed",
|
|
3
|
-
"version": "2.8.
|
|
4
|
-
"supportedClaudeCode": "2.1.
|
|
3
|
+
"version": "2.8.37",
|
|
4
|
+
"supportedClaudeCode": "2.1.292",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"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.",
|
|
7
7
|
"main": "dist/lib/index.mjs",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/skrabe/tweakcc-fixed#readme",
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@babel/parser": "^7.28.5",
|
|
55
56
|
"@eslint/js": "^9.33.0",
|
|
56
57
|
"@types/node": "^20.19.10",
|
|
57
58
|
"@types/react": "^19.2.14",
|