tweakcc 3.3.0 → 3.4.0
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 +81 -2
- package/dist/index.mjs +34 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ With tweakcc, you can
|
|
|
47
47
|
|
|
48
48
|
- Customize all of Claude Code's **system prompts** (**NEW:** also see all of [**Claude Code's system prompts**](https://github.com/Piebald-AI/claude-code-system-prompts))
|
|
49
49
|
- Create custom **toolsets** that can be used in Claude Code with the new **`/toolset`** command
|
|
50
|
+
- **Highlight** custom patterns while you type in the CC input box with custom colors and styling, like how `ultrathink` used to be rainbow-highlighted.
|
|
50
51
|
- Manually name **sessions** in Claude Code with `/title my chat name` or `/rename` (see [**our blog post**](https://piebald.ai/blog/messages-as-commits-claude-codes-git-like-dag-of-conversations) for implementation details)
|
|
51
52
|
- Create **custom themes** with a graphical HSL/RGB color picker
|
|
52
53
|
- Add custom **thinking verbs** that will show while Claude's working
|
|
@@ -78,13 +79,91 @@ $ npx tweakcc
|
|
|
78
79
|
$ pnpm dlx tweakcc
|
|
79
80
|
```
|
|
80
81
|
|
|
82
|
+
## Table of contents
|
|
83
|
+
|
|
84
|
+
- [How it works](#how-it-works)
|
|
85
|
+
- [**Features**](#features)
|
|
86
|
+
- [Input pattern highlighters](#input-pattern-highlighters)
|
|
87
|
+
- [Configuration directory](#configuration-directory)
|
|
88
|
+
- [Building from source](#building-from-source)
|
|
89
|
+
- [Related projects](#related-projects)
|
|
90
|
+
- [System prompts](#system-prompts)
|
|
91
|
+
- [Toolsets](#toolsets)
|
|
92
|
+
- [Troubleshooting](#troubleshooting)
|
|
93
|
+
- [FAQ](#faq)
|
|
94
|
+
- [License](#license)
|
|
95
|
+
|
|
81
96
|
## How it works
|
|
82
97
|
|
|
83
98
|
tweakcc works by patching Claude Code's minified `cli.js` file. For npm-based installations this file is modified directly, but for native installation it's extracted from the binary, patched, and then the binary is repacked. When you update your Claude Code installation, your customizations will be overwritten, but they're remembered in your configuration file, so they can be reapplied by just running `npx tweakcc --apply`.
|
|
84
99
|
|
|
85
|
-
tweakcc is verified to work with Claude Code **2.1.2.** In newer or earlier versions various patches might not work. However, if we have the system prompts for your version
|
|
100
|
+
tweakcc is verified to work with Claude Code **2.1.2.** In newer or earlier versions various patches might not work. However, if we have the [system prompts for your version](https://github.com/Piebald-AI/tweakcc/tree/main/data/prompts) then system prompt patching is guaranteed to work with that version, even if it's significantly different from the verified CC version. We get the latest system prompts within minutes of each new CC release, so unless you're using a CC version older than 2.0.14, your version is supported.
|
|
101
|
+
|
|
102
|
+
## Features
|
|
103
|
+
|
|
104
|
+
_More feature documentation coming soon._
|
|
105
|
+
|
|
106
|
+
### Input pattern highlighters
|
|
107
|
+
|
|
108
|
+
For a few weeks, when you typed the word "ultrathink" into the Claude Code input box, it would be highlighted rainbow. That's gone now, but the underlying highlighting infrastructure is still present in Claude Code today, and tweakcc lets you specify custom highlighters comprised of a **regular expression**, **format string**, and **colors & styling**.
|
|
109
|
+
|
|
110
|
+
Here's a demo where every word is assigned a different color based on its first letter:
|
|
111
|
+
|
|
112
|
+

|
|
113
|
+
|
|
114
|
+
Here's one where various common patterns like environment variables, file paths, numbers, and markdown constructs are highlighted:
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
Finally, here's one showing how you can render extra characters that aren't really part of the prompt by customizing the **format string**. The first line shows a copy of what I've actually got typed into the prompt, and in the prompt itself you can see that `cluade` was _visually_ (but not _in reality_) replaced with `Claude Code, ...`, etc.
|
|
119
|
+
|
|
120
|
+

|
|
121
|
+
To add some patterns, you can use the tweakcc UI or edit [`~/.tweakcc/config.json`](#configuration-directory) manually.
|
|
122
|
+
|
|
123
|
+
**Via the UI:**
|
|
124
|
+
|
|
125
|
+
| Listing | Edit |
|
|
126
|
+
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
127
|
+
|  |  |
|
|
128
|
+
|
|
129
|
+
**Via `config.json`:**
|
|
130
|
+
|
|
131
|
+
In `.settings.inputPatternHighlighters` (an array), add a new object:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
"inputPatternHighlighters": [
|
|
135
|
+
...
|
|
136
|
+
{
|
|
137
|
+
"name": "File path",
|
|
138
|
+
"regex": "(?:[a-zA-Z]:)?[/\\\\]?[a-zA-Z0-9._\\-]+(?:[/\\\\][a-zA-Z0-9._\\-]+)+",
|
|
139
|
+
"regexFlags": "g",
|
|
140
|
+
"format": "{MATCH}",
|
|
141
|
+
"styling": [
|
|
142
|
+
"bold"
|
|
143
|
+
],
|
|
144
|
+
"foregroundColor": "rgb(71,194,10)",
|
|
145
|
+
"backgroundColor": null,
|
|
146
|
+
"enabled": true
|
|
147
|
+
},
|
|
148
|
+
]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Here's the schema for the object format:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
{
|
|
155
|
+
name: string; // User-friendly name
|
|
156
|
+
regex: string; // Regex pattern (stored as string)
|
|
157
|
+
regexFlags: string; // Flags for the regex, must include 'g' for matchAll
|
|
158
|
+
format: string; // Format string, use {MATCH} as placeholder
|
|
159
|
+
styling: string[]; // ['bold', 'italic', 'underline', 'strikethrough', 'inverse']
|
|
160
|
+
foregroundColor: string | null; // null = don't specify, otherwise rgb(r,g,b)
|
|
161
|
+
backgroundColor: string | null; // null = don't specify, otherwise rgb(r,g,b)
|
|
162
|
+
enabled: boolean; // Temporarily disable this pattern
|
|
163
|
+
}
|
|
164
|
+
```
|
|
86
165
|
|
|
87
|
-
|
|
166
|
+
## Configuration directory
|
|
88
167
|
|
|
89
168
|
tweakcc stores its configuration files in one of the following locations, in order of priority:
|
|
90
169
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Box as e,Text as t,render as n,useInput as r}from"ink";import{Command as i}from"commander";import a from"chalk";import o,{Fragment as s,createContext as c,useCallback as l,useContext as u,useEffect as d,useMemo as f,useRef as p,useState as m}from"react";import*as h from"node:os";import g,{EOL as _}from"node:os";import v from"ink-link";import*as y from"node:fs/promises";import b from"node:fs/promises";import*as x from"node:fs";import S from"node:fs";import*as C from"node:path";import w from"node:path";import*as T from"fs";import*as E from"path";import D from"path";import*as O from"os";import*as k from"child_process";import*as A from"crypto";import ee from"gray-matter";import{Fragment as j,jsx as M,jsxs as N}from"react/jsx-runtime";import P from"process";import F from"which";import{WASMagic as te}from"wasmagic";import{globbySync as I}from"globby";let L=null;async function R(){if(L!==null)return L;try{return await import(`node-lief`),L=await import(`./nativeInstallation-DBmBL-fs.mjs`),L}catch(e){return W(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&W(e),null}}async function ne(e){let t=await R();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function re(e,t,n){let r=await R();if(!r)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,t,n)}const ie=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},ae=(e,t)=>{let n=ie(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);V(i,r,n,e.startIndex,e.endIndex),i=r}return i};function z(e){let t=e.match(/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s);if(!t||t.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let n=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(n),a=e.match(r);return!i||i.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!a||a.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const oe=(e,t)=>{let n=z(e);if(!n)return null;if(t.length===0)return e;let r=e,i=`return`+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),V(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r;let a=JSON.stringify(t.map(e=>({label:e.name,value:e.id})));r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),V(e,r,a,n.objArr.startIndex,n.objArr.endIndex),e=r;let o=`switch(${n.switchStatement.identifiers?.[0]}){\n`;return t.forEach(e=>{o+=`case"${e.id}":return${JSON.stringify(e.colors)};\n`}),o+=`default:return${JSON.stringify(t[0].colors)};\n}`,r=r.slice(0,n.switchStatement.startIndex)+o+r.slice(n.switchStatement.endIndex),V(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},se=e=>{let t=e.match(/function ([$\w]+)\(([$\w,]+)\)\{if\([$\w]+\.includes\("\[(1m|2m)\]"\)\|\|[$\w]+\?\.includes\([$\w]+\)&&[$\w]+\([$\w]+\)\)return 1e6;return ([$\w]+)\}/);if(t&&t.index!==void 0)return t.index+t[0].indexOf(`{`)+1;let n=e.match(/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/);return n&&n.index!==void 0?n.index+n[0].indexOf(`{`)+1:(console.error(`patch: context limit: failed to find match`),null)},ce=e=>{let t=se(e);if(!t)return null;let n=`if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);`,r=e.slice(0,t)+n+e.slice(t);return V(e,r,n,t,t),r},le=e=>{let t=e.indexOf(`bash:"bashBorder"`);if(t===-1)return console.error(`patch: input border: failed to find bash pattern`),null;let n=e.slice(t,t+500).match(/borderStyle:"[^"]*"/);return!n||n.index===void 0?(console.error(`patch: input border: failed to find border style pattern`),null):{startIndex:t+n.index,endIndex:t+n.index+n[0].length}},ue=(e,t)=>{let n=le(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return V(e,r,t,n.startIndex,n.endIndex),r}else return e},de=e=>{let t=e.match(/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/);if(!t||t.index===void 0)return console.error(`patch: spinner no-freeze: failed to find wholeMatch`),null;let n=t[0].match(/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/);if(!n||n.index===void 0)return console.error(`patch: spinner no-freeze: failed to find freeze condition`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},fe=e=>{let t=de(e);if(!t)return null;let n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return V(e,n,``,t.startIndex,t.endIndex),n},pe=e=>{let t=e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/);if(!t||t.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let n=e.slice(t.index,t.index+1e3).match(/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);return!n||n.index==null?(console.error(`patch: thinker format: failed to find formatMatch`),null):{startIndex:t.index+n.index+n[1].length,endIndex:t.index+n.index+n[1].length+n[2].length,identifiers:[n[3]]}},B=(e,t)=>{let n=pe(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o=`=${"`"+i.replace(/\{\}/g,"${"+a+`}`)+"`"}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);return V(e,s,o,r.startIndex,r.endIndex),s},me=e=>{let t=e.match(/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/);return!t||t.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},he=(e,t)=>{let n=me(e);if(!n)return null;let r=n.identifiers?.[0],i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return V(e,a,i,n.startIndex,n.endIndex),a},ge=e=>{let t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g,r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},_e=(e,t)=>{let n=ge(e);if(n.length===0)return null;let r=JSON.stringify(t),i=n.sort((e,t)=>t.startIndex-e.startIndex),a=e;for(let e=0;e<i.length;e++){let t=a.slice(0,i[e].startIndex)+r+a.slice(i[e].endIndex);V(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},ve=e=>{let t=e.match(/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/);if(!t||t.index==null)return console.error(`patch: thinker symbol speed: failed to find match`),null;let n=t[0],r=t[1],i=n.lastIndexOf(r),a=t.index+i;return{startIndex:a,endIndex:a+r.length}},ye=(e,t)=>{let n=ve(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,i,r,n.startIndex,n.endIndex),i},be=e=>{let t=e.match(/\{flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},xe=(e,t)=>{let n=be(e);if(!n)return null;let r=`{flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return V(e,i,r,n.startIndex,n.endIndex),i},Se=e=>{let t=e.match(/[,;]([$\w]+)=\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]/s);if(t&&t.index!=null)return{startIndex:t.index+1,endIndex:t.index+t[0].length,identifiers:[t[1]]};let n=e.match(/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s);return n&&n.index!=null?{startIndex:n.index+1,endIndex:n.index+n[0].length,identifiers:[n[1],`old_format`]}:(console.error(`patch: thinker verbs: failed to find verbsMatch`),null)},Ce=e=>{let t=e.match(/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/);return!t||t.index==null?(console.error(`patch: thinker verbs: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},we=(e,t)=>{let n=Se(e);if(!n)return null;let r=n,i=r.identifiers?.[0],a=r.identifiers?.[1]===`old_format`,o=a?`${i}=${JSON.stringify({words:t})}`:`${i}=${JSON.stringify(t)}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);if(V(e,s,o,r.startIndex,r.endIndex),a){let e=Ce(s);if(!e)return null;let t=e,n=`function ${t.identifiers?.[0]}(){return ${i}.words}`,r=s.slice(0,t.startIndex)+n+s.slice(t.endIndex);return V(s,r,n,t.startIndex,t.endIndex),r}return s},Te=e=>{let t=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground"\},([$\w]+)\.createElement\([$\w]+,\{color:"subtle"\},([$\w]+)\.pointer," "\),[$\w]+\.createElement\([$\w]+,\{color:"text"\},([$\w]+)\)\)/);if(t&&t.index!=null)return{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[5],`new_format`]};let n=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground",color:"text"\},"> ",([$\w]+)\+" "\);/);return n&&n.index!=null?{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1],n[2],n[3],`old_format`]}:(console.error(`patch: messageDisplayMatch: failed to find user message display pattern`),null)},Ee=(e,t,n,r,i=!1,a=!1,o=!1,s=!1,c=!1,l=`none`,u=`rgb(255,255,255)`,d=0,f=0,p=!1)=>{let m=Te(e);if(!m)return console.error(`^ patch: userMessageDisplay: getUserMessageDisplayLocation returned null`),null;let h=Cn(e);if(!h)return console.error(`^ patch: userMessageDisplay: failed to find chalk variable`),null;let g=Mn(e);if(!g)return console.error(`^ patch: userMessageDisplay: failed to find box component`),null;let _=``,v=[];n===`default`&&v.push(`color:"text"`),r===`default`&&v.push(`backgroundColor:"userMessageBackground"`);let y=v.length>0?`{${v.join(`,`)}}`:`{}`,b=[],x=l.startsWith(`topBottom`);if(l!==`none`){if(x){let e=``;l===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),b.push(`borderStyle:${e}`)}else b.push(`borderStyle:"${l}"`);let e=u.match(/\d+/g);e&&b.push(`borderColor:"rgb(${e.join(`,`)})"`)}d>0&&b.push(`paddingX:${d}`),f>0&&b.push(`paddingY:${f}`),p&&b.push(`alignSelf:"flex-start"`);let S=b.length>0?`{${b.join(`,`)}}`:`{}`,C=n!==`default`||r!==`default`&&r!==null||i||a||o||s||c;if(C){if(_=h,n!==`default`){let e=n.match(/\d+/g);e&&(_+=`.rgb(${e.join(`,`)})`)}if(r!==`default`&&r!==null){let e=r.match(/\d+/g);e&&(_+=`.bgRgb(${e.join(`,`)})`)}i&&(_+=`.bold`),a&&(_+=`.italic`),o&&(_+=`.underline`),s&&(_+=`.strikethrough`),c&&(_+=`.inverse`)}let[w,T,E,D]=m.identifiers,O=`"`+t.replace(/\{\}/g,`"+${E}+"`)+`"`,k;k=`
|
|
2
|
+
import{Box as e,Text as t,render as n,useInput as r}from"ink";import{Command as i}from"commander";import a from"chalk";import o,{Fragment as s,createContext as c,useCallback as l,useContext as u,useEffect as d,useMemo as f,useRef as p,useState as m}from"react";import*as h from"node:os";import g,{EOL as _}from"node:os";import v from"ink-link";import*as y from"node:fs/promises";import b from"node:fs/promises";import*as x from"node:fs";import S from"node:fs";import*as C from"node:path";import w from"node:path";import*as T from"fs";import*as E from"path";import D from"path";import*as O from"os";import*as k from"child_process";import*as A from"crypto";import j from"gray-matter";import{Fragment as M,jsx as N,jsxs as P}from"react/jsx-runtime";import F from"process";import I from"which";import{WASMagic as L}from"wasmagic";import{globbySync as R}from"globby";let z=null;async function B(){if(z!==null)return z;try{return await import(`node-lief`),z=await import(`./nativeInstallation-DBmBL-fs.mjs`),z}catch(e){return G(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&G(e),null}}async function ee(e){let t=await B();return t?t.extractClaudeJsFromNativeInstallation(e):null}async function te(e,t,n){let r=await B();if(!r)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");r.repackNativeInstallation(e,t,n)}const ne=e=>{let t=[],n=/visibleOptionCount:[\w$]+=(\d+)/g,r;for(;(r=n.exec(e))!==null;){let e=r.index+r[0].indexOf(`=`)+1;t.push({startIndex:e,endIndex:e+r[1].length})}return t},re=(e,t)=>{let n=ne(e);if(n.length===0)return console.error(`patch: writeShowMoreItemsInSelectMenus: failed to find locations`),null;let r=n.sort((e,t)=>t.startIndex-e.startIndex),i=e;for(let e of r){let n=t.toString(),r=i.slice(0,e.startIndex)+n+i.slice(e.endIndex);U(i,r,n,e.startIndex,e.endIndex),i=r}return i};function ie(e){let t=e.match(/switch\s*\(([^)]+)\)\s*\{[^}]*case\s*["']light["'][^}]+\}/s);if(!t||t.index==null)return console.error(`patch: themes: failed to find switchMatch`),null;let n=/\[(?:\{label:"(?:Dark|Light).+?",value:".+?"\},?)+\]/,r=/return\{(?:[$\w]+?:"(?:Dark|Light).+?",?)+\}/,i=e.match(n),a=e.match(r);return!i||i.index==null?(console.error(`patch: themes: failed to find objArrMatch`),null):!a||a.index==null?(console.error(`patch: themes: failed to find objMatch`),null):{switchStatement:{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1].trim()]},objArr:{startIndex:i.index,endIndex:i.index+i[0].length},obj:{startIndex:a.index,endIndex:a.index+a[0].length}}}const ae=(e,t)=>{let n=ie(e);if(!n)return null;if(t.length===0)return e;let r=e,i=`return`+JSON.stringify(Object.fromEntries(t.map(e=>[e.id,e.name])));r=r.slice(0,n.obj.startIndex)+i+r.slice(n.obj.endIndex),U(e,r,i,n.obj.startIndex,n.obj.endIndex),e=r;let a=JSON.stringify(t.map(e=>({label:e.name,value:e.id})));r=r.slice(0,n.objArr.startIndex)+a+r.slice(n.objArr.endIndex),U(e,r,a,n.objArr.startIndex,n.objArr.endIndex),e=r;let o=`switch(${n.switchStatement.identifiers?.[0]}){\n`;return t.forEach(e=>{o+=`case"${e.id}":return${JSON.stringify(e.colors)};\n`}),o+=`default:return${JSON.stringify(t[0].colors)};\n}`,r=r.slice(0,n.switchStatement.startIndex)+o+r.slice(n.switchStatement.endIndex),U(e,r,o,n.switchStatement.startIndex,n.switchStatement.endIndex),r},oe=e=>{let t=e.match(/function ([$\w]+)\(([$\w,]+)\)\{if\([$\w]+\.includes\("\[(1m|2m)\]"\)\|\|[$\w]+\?\.includes\([$\w]+\)&&[$\w]+\([$\w]+\)\)return 1e6;return ([$\w]+)\}/);if(t&&t.index!==void 0)return t.index+t[0].indexOf(`{`)+1;let n=e.match(/function ([$\w]+)\(([$\w]*)\)\{((?:if\([$\w]+\.includes\("\[2m\]"\)\)return 2000000;)?(?:if\([$\w]+\.includes\("\[1m\]"\)\)return 1e6;)?return 200000)\}/);return n&&n.index!==void 0?n.index+n[0].indexOf(`{`)+1:(console.error(`patch: context limit: failed to find match`),null)},se=e=>{let t=oe(e);if(!t)return null;let n=`if(process.env.CLAUDE_CODE_CONTEXT_LIMIT)return Number(process.env.CLAUDE_CODE_CONTEXT_LIMIT);`,r=e.slice(0,t)+n+e.slice(t);return U(e,r,n,t,t),r},ce=e=>{let t=e.indexOf(`bash:"bashBorder"`);if(t===-1)return console.error(`patch: input border: failed to find bash pattern`),null;let n=e.slice(t,t+500).match(/borderStyle:"[^"]*"/);return!n||n.index===void 0?(console.error(`patch: input border: failed to find border style pattern`),null):{startIndex:t+n.index,endIndex:t+n.index+n[0].length}},le=(e,t)=>{let n=ce(e);if(!n)return null;if(t){let t=`borderColor:undefined`,r=e.slice(0,n.startIndex)+t+e.slice(n.endIndex);return U(e,r,t,n.startIndex,n.endIndex),r}else return e},ue=e=>{let t=e.match(/\b[$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},\d+\)/);if(!t||t.index===void 0)return console.error(`patch: spinner no-freeze: failed to find wholeMatch`),null;let n=t[0].match(/if\(![$\w]+\)\{[$\w]+\(\d+\);return\}/);if(!n||n.index===void 0)return console.error(`patch: spinner no-freeze: failed to find freeze condition`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},de=e=>{let t=ue(e);if(!t)return null;let n=e.slice(0,t.startIndex)+e.slice(t.endIndex);return U(e,n,``,t.startIndex,t.endIndex),n},V=e=>{let t=e.match(/spinnerTip:[$\w]+,(?:[$\w]+:[$\w]+,)*overrideMessage:[$\w]+,.{300}/);if(!t||t.index==null)return console.error(`patch: thinker format: failed to find approxAreaMatch`),null;let n=e.slice(t.index,t.index+1e3).match(/([$\w]+)(=\(([^;]{1,200}?)\)\+"(?:…|\\u2026)")/);return!n||n.index==null?(console.error(`patch: thinker format: failed to find formatMatch`),null):{startIndex:t.index+n.index+n[1].length,endIndex:t.index+n.index+n[1].length+n[2].length,identifiers:[n[3]]}},H=(e,t)=>{let n=V(e);if(!n)return null;let r=n,i=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),a=r.identifiers?.[0],o=`=${"`"+i.replace(/\{\}/g,"${"+a+`}`)+"`"}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);return U(e,s,o,r.startIndex,r.endIndex),s},fe=e=>{let t=e.match(/=\s*\[\.\.\.([$\w]+),\s*\.\.\.?\[\.\.\.\1\]\.reverse\(\)\]/);return!t||t.index==null?(console.error(`patch: thinker symbol mirror option: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},pe=(e,t)=>{let n=fe(e);if(!n)return null;let r=n.identifiers?.[0],i=t?`=[...${r},...[...${r}].reverse()]`:`=[...${r}]`,a=e.slice(0,n.startIndex)+i+e.slice(n.endIndex);return U(e,a,i,n.startIndex,n.endIndex),a},me=e=>{let t=[],n=/\["[·✢*✳✶✻✽]",\s*(?:"[·✢*✳✶✻✽]",?\s*)+\]/g,r;for(;(r=n.exec(e))!==null;)t.push({startIndex:r.index,endIndex:r.index+r[0].length});return t},he=(e,t)=>{let n=me(e);if(n.length===0)return null;let r=JSON.stringify(t),i=n.sort((e,t)=>t.startIndex-e.startIndex),a=e;for(let e=0;e<i.length;e++){let t=a.slice(0,i[e].startIndex)+r+a.slice(i[e].endIndex);U(a,t,r,i[e].startIndex,i[e].endIndex),a=t}return a},ge=e=>{let t=e.match(/[, ][$\w]+\(\(\)=>\{if\(![$\w]+\)\{[$\w]+\(\d+\);return\}[$\w]+\(\([^)]+\)=>[^)]+\+1\)\},(\d+)\)/);if(!t||t.index==null)return console.error(`patch: thinker symbol speed: failed to find match`),null;let n=t[0],r=t[1],i=n.lastIndexOf(r),a=t.index+i;return{startIndex:a,endIndex:a+r.length}},_e=(e,t)=>{let n=ge(e);if(!n)return null;let r=JSON.stringify(t),i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return U(e,i,r,n.startIndex,n.endIndex),i},ve=e=>{let t=e.match(/\{flexWrap:"wrap",height:1,width:2\}/);return!t||t.index==null?(console.error(`patch: thinker symbol width: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},ye=(e,t)=>{let n=ve(e);if(!n)return null;let r=`{flexWrap:"wrap",height:1,width:${t}}`,i=e.slice(0,n.startIndex)+r+e.slice(n.endIndex);return U(e,i,r,n.startIndex,n.endIndex),i},be=e=>{let t=e.match(/[,;]([$\w]+)=\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]/s);if(t&&t.index!=null)return{startIndex:t.index+1,endIndex:t.index+t[0].length,identifiers:[t[1]]};let n=e.match(/[, ]([$\w]+)=\{words:\[(?:"[^"{}()]+ing",)+"[^"{}()]+ing"\]\}/s);return n&&n.index!=null?{startIndex:n.index+1,endIndex:n.index+n[0].length,identifiers:[n[1],`old_format`]}:(console.error(`patch: thinker verbs: failed to find verbsMatch`),null)},xe=e=>{let t=e.match(/function ([$\w]+)\(\)\{return [$\w]+\("tengu_spinner_words",[$\w]+\)\.words\}/);return!t||t.index==null?(console.error(`patch: thinker verbs: failed to find match`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1]]}},Se=(e,t)=>{let n=be(e);if(!n)return null;let r=n,i=r.identifiers?.[0],a=r.identifiers?.[1]===`old_format`,o=a?`${i}=${JSON.stringify({words:t})}`:`${i}=${JSON.stringify(t)}`,s=e.slice(0,r.startIndex)+o+e.slice(r.endIndex);if(U(e,s,o,r.startIndex,r.endIndex),a){let e=xe(s);if(!e)return null;let t=e,n=`function ${t.identifiers?.[0]}(){return ${i}.words}`,r=s.slice(0,t.startIndex)+n+s.slice(t.endIndex);return U(s,r,n,t.startIndex,t.endIndex),r}return s},Ce=e=>{let t=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground"\},([$\w]+)\.createElement\([$\w]+,\{color:"subtle"\},([$\w]+)\.pointer," "\),[$\w]+\.createElement\([$\w]+,\{color:"text"\},([$\w]+)\)\)/);if(t&&t.index!=null)return{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[5],`new_format`]};let n=e.match(/return ([$\w]+)\.createElement\(([$\w]+),\{backgroundColor:"userMessageBackground",color:"text"\},"> ",([$\w]+)\+" "\);/);return n&&n.index!=null?{startIndex:n.index,endIndex:n.index+n[0].length,identifiers:[n[1],n[2],n[3],`old_format`]}:(console.error(`patch: messageDisplayMatch: failed to find user message display pattern`),null)},we=(e,t,n,r,i=!1,a=!1,o=!1,s=!1,c=!1,l=`none`,u=`rgb(255,255,255)`,d=0,f=0,p=!1)=>{let m=Ce(e);if(!m)return console.error(`^ patch: userMessageDisplay: getUserMessageDisplayLocation returned null`),null;let h=On(e);if(!h)return console.error(`^ patch: userMessageDisplay: failed to find chalk variable`),null;let g=Rn(e);if(!g)return console.error(`^ patch: userMessageDisplay: failed to find box component`),null;let _=``,v=[];n===`default`&&v.push(`color:"text"`),r===`default`&&v.push(`backgroundColor:"userMessageBackground"`);let y=v.length>0?`{${v.join(`,`)}}`:`{}`,b=[],x=l.startsWith(`topBottom`);if(l!==`none`){if(x){let e=``;l===`topBottomSingle`?e=`{top:"─",bottom:"─",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomDouble`?e=`{top:"═",bottom:"═",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`:l===`topBottomBold`&&(e=`{top:"━",bottom:"━",left:" ",right:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" "}`),b.push(`borderStyle:${e}`)}else b.push(`borderStyle:"${l}"`);let e=u.match(/\d+/g);e&&b.push(`borderColor:"rgb(${e.join(`,`)})"`)}d>0&&b.push(`paddingX:${d}`),f>0&&b.push(`paddingY:${f}`),p&&b.push(`alignSelf:"flex-start"`);let S=b.length>0?`{${b.join(`,`)}}`:`{}`,C=n!==`default`||r!==`default`&&r!==null||i||a||o||s||c;if(C){if(_=h,n!==`default`){let e=n.match(/\d+/g);e&&(_+=`.rgb(${e.join(`,`)})`)}if(r!==`default`&&r!==null){let e=r.match(/\d+/g);e&&(_+=`.bgRgb(${e.join(`,`)})`)}i&&(_+=`.bold`),a&&(_+=`.italic`),o&&(_+=`.underline`),s&&(_+=`.strikethrough`),c&&(_+=`.inverse`)}let[w,T,E,D]=m.identifiers,O=`"`+t.replace(/\{\}/g,`"+${E}+"`)+`"`,k;k=`
|
|
3
3
|
return ${w}.createElement(
|
|
4
4
|
${g},
|
|
5
5
|
${S},
|
|
@@ -8,12 +8,12 @@ return ${w}.createElement(
|
|
|
8
8
|
${y},
|
|
9
9
|
${C?_+`(`:``}${O}${C?`)`:``}
|
|
10
10
|
)
|
|
11
|
-
);`;let A=e.slice(0,m.startIndex)+k+e.slice(m.endIndex);return V(e,A,k,m.startIndex,m.endIndex),A},De=e=>{let t=e.match(/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/);if(!t||t.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let n=t[0].match(/verbose:[^,}]+/);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},Oe=e=>{let t=De(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},ke=e=>{let t=e.match(/(case"thinking":)\{if\(![$\w]+&&![$\w]+\)return null;(return [$\w]+\.createElement\([$\w]+,\{addMargin:[$\w]+,param:[$\w]+,isTranscriptMode:)([$\w]+)(,verbose:[$\w]+,hideInTranscript:[$\w]+&&!\(![$\w]+\|\|[$\w]+===[$\w]+\)\})\)\}/);if(t&&t.index!==void 0){let e=t.index;return{startIndex:e,endIndex:e+t[0].length,identifiers:[t[1],t[2],t[4],`new_format`]}}let n=e.match(/(case"thinking":)if\([$\w!&]+\)return null;([$\w.]+\.createElement\([$\w]+,\{addMargin:[$\w]+,param:[$\w]+,isTranscriptMode:)([$\w]+)(,verbose:[$\w]+\s*\})\)/);if(n&&n.index!==void 0){let e=n.index;return{startIndex:e,endIndex:e+n[0].length,identifiers:[n[1],n[2],n[4]]}}return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null},Ae=e=>{let t=ke(e);if(!t)return null;let n=t.identifiers[3]===`new_format`,r;r=n?`${t.identifiers[0]}{${t.identifiers[1]}true${t.identifiers[2]})}`:`${t.identifiers[0]}${t.identifiers[1]}true${t.identifiers[2]}`;let i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return V(e,i,r,t.startIndex,t.endIndex),i},je=(e,t)=>{let n=e,r=!1;if(t.plan){let e=/(agentType\s*:\s*"Plan"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/,i=n.match(e);if(i){let a=n.replace(e,`$1${t.plan}$2`);a!==n&&(V(n,a,t.plan,i.index,i.index+i[0].length),n=a,r=!0)}}if(t.explore){let e=/(agentType\s*:\s*"Explore"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/,i=n.match(e);if(i){let a=n.replace(e,`$1${t.explore}$2`);a!==n&&(V(n,a,t.explore,i.index,i.index+i[0].length),n=a,r=!0)}}if(t.generalPurpose){let e=/(\b[$\w]+\s*=\s*\{agentType\s*:\s*"general-purpose"[\s\S]{0,2500}?)(\})/,i=n.match(e);if(i){let a=i[1],o=i[2],s;s=a.includes(`model:`)?a.replace(/(model\s*:\s*")[^"]+(")/,`$1${t.generalPurpose}$2`)+o:a+`${a.trim().endsWith(`,`)?``:`,`}model:"${t.generalPurpose}"`+o;let c=n.replace(e,s);c!==n&&(V(n,c,t.generalPurpose,i.index,i.index+i[0].length),n=c,r=!0)}}return r?n:null},Me=e=>{let t=e.indexOf(`}.VERSION} (Claude Code)`);return t==-1?(console.error(`patch: patchesAppliedIndication: failed to find versionIndex`),null):{startIndex:0,endIndex:t+24}},Ne=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern`),null;let n=t.index+t[0].length;return{startIndex:n,endIndex:n}},Pe=(e,t,n,r,i,a)=>{let o=e.match(/alignItems:"center",minHeight:9,?/);if(!o||o.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4`),null;let s=e.slice(0,o.index)+`minHeight:9,`+e.slice(o.index+o[0].length),c=Math.max(0,o.index-200),l=s.slice(c,o.index+12+2),u=Array.from(l.matchAll(/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g));if(u.length===0)return console.error(`patch: patchesAppliedIndication: failed to find createElement for PATCH 4`),null;let d=u[u.length-1],f=c+d.index+d[0].length,p=`${n}.createElement(${i}, null, ${a}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,m=s;s=s.slice(0,f)+p+s.slice(f),V(m,s,p,f,f);let h=1,g=f+p.length,_=-1;for(;g<s.length;){let e=s[g];if(e===`(`)h++;else if(e===`)`){if(h===1){_=g;break}h--}g++}if(_===-1)return console.error(`patch: patchesAppliedIndication: failed to find closing paren for PATCH 4`),null;let v=s;return s=s.slice(0,_)+`),`+s.slice(_),V(v,s,`),`,_,_),{content:s,closingParenIndex:_+2}},Fe=(e,t,n,r,i,a,o)=>{let s=4,c=t,l=-1;for(;c<e.length;){let t=e[c];if(t===`(`)s++;else if(t===`)`){if(s===1){l=c;break}s--}c++}if(l===-1)return console.error(`patch: patchesAppliedIndication: failed to find insertion point for PATCH 5`),null;let u=[];u.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of o)e=e.replace(`CHALK_VAR`,a),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {dimColor: true}, \` * ${e}\`)),`);u.push(`),`);let d=u.join(``),f=e,p=e.slice(0,l)+d+e.slice(l);return V(f,p,d,l,l),p},Ie=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3`),null;let n=Math.max(0,t.index-1500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/\}function ([$\w]+)\(/g));if(i.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let a=i[i.length-1][1],o=RegExp(`\\b([$\\w]+)\\.createElement\\(${H(a)},null\\),?`),s=e.match(o);if(!s||s.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let c=s.index+s[0].length;return{startIndex:c,endIndex:c}},Le=(e,t,n,r=!0,i=!0)=>{let a=Me(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=e.slice(0,a.endIndex)+o+e.slice(a.endIndex);V(e,s,o,a.endIndex,a.endIndex);let c=Cn(e);if(!c)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let l=jn(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let u=On(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;let d=Mn(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find Box component`),null;if(r){let e=Ne(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 2 failed`),null;let n=`, " ",${u}.createElement(${l}, null, ${c}.blue.bold('+ tweakcc v${t}'))`,r=s;s=s.slice(0,e.startIndex)+n+s.slice(e.endIndex),V(r,s,n,e.startIndex,e.endIndex)}if(i){let e=Ie(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 3 failed`),null;let t=[];t.push(`${u}.createElement(${d}, { flexDirection: "column" },`),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of n)e=e.replace(`CHALK_VAR`,c),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {dimColor: true}, \` * ${e}\`)),`);t.push(`),`);let r=t.join(`
|
|
12
|
-
`),i=s;s=s.slice(0,e.startIndex)+r+s.slice(e.endIndex),
|
|
13
|
-
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}}
|
|
11
|
+
);`;let A=e.slice(0,m.startIndex)+k+e.slice(m.endIndex);return U(e,A,k,m.startIndex,m.endIndex),A},Te=e=>{let t=e.match(/else if\(([$\w]+)\.type==="solid"\)return ([$\w]+)\.createElement\(([$\w]+),\{key:([$\w]+),color:[$\w]+\.color\},[$\w]+\.createElement\([$\w]+,null,([$\w]+)\.text\)\);/);return!t||t.index===void 0?(console.error(`patch: inputPatternHighlighters: failed to find solid match renderer pattern`),null):{startIndex:t.index+t[0].length,endIndex:t.index+t[0].length,identifiers:[t[1],t[2],t[3],t[4],t[5]]}},Ee=e=>{let t=e.match(/\b([$\w]+)\.push\(\{start:[$\w]+,end:[$\w]+\+[$\w]+\.length,style:\{type:"solid",color:"warning"\}/);return!t||t.index===void 0?(console.error(`patch: inputPatternHighlighters: failed to find match pushes pattern`),null):{index:t.index,rangesVar:t[1]}},De=(e,t)=>{let n=Math.max(0,t-100),r=e.slice(n,t),i=/\b[$\w]+=([$\w]+(?:\.default)?)\.useMemo\(/g,a=null,o;for(;(o=i.exec(r))!==null;)a=o;return a?a[1]:(console.error(`patch: inputPatternHighlighters: failed to find useMemo pattern`),null)},Oe=(e,t)=>{let n=Math.max(0,t-4e3),r=e.slice(n,t).match(/\binput:([$\w]+),/);return r?r[1]:(console.error(`patch: inputPatternHighlighters: failed to find input variable pattern`),null)},ke=(e,t)=>{let n=De(e,t);if(!n)return null;let r=Oe(e,t);if(!r)return null;let i=Math.max(0,t-500),a=e.slice(i,t),o=/\b[$\w]+=([$\w]+(?:\.default)?)\.useMemo\(\(\)=>\{[^}]*\},\[[^\]]*\]\),?/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(!s)return console.error(`patch: inputPatternHighlighters: failed to find useMemo insertion point`),null;let l=i+s.index+s[0].length;return{startIndex:l,endIndex:l,identifiers:[n,r]}},Ae=(e,t,n)=>{let r=Math.min(e.length,t+600),i=e.slice(t,r),a=RegExp(`return ${W(n)}}`),o=i.match(a);if(!o||o.index===void 0)return console.error(`patch: inputPatternHighlighters: failed to find return statement`),null;let s=t+o.index;return{startIndex:s,endIndex:s,identifiers:[n]}},je=(e,t)=>{let n=e;if(t.foregroundColor){let e=t.foregroundColor.match(/\d+/g);e&&(n+=`.rgb(${e.join(`,`)})`)}if(t.backgroundColor){let e=t.backgroundColor.match(/\d+/g);e&&(n+=`.bgRgb(${e.join(`,`)})`)}return t.styling.includes(`bold`)&&(n+=`.bold`),t.styling.includes(`italic`)&&(n+=`.italic`),t.styling.includes(`underline`)&&(n+=`.underline`),t.styling.includes(`strikethrough`)&&(n+=`.strikethrough`),t.styling.includes(`inverse`)&&(n+=`.inverse`),n},Me=(e,t)=>{let n=t.filter(e=>e.enabled);if(n.length===0)return null;let r=On(e);if(!r)return console.error(`^ patch: inputPatternHighlighters: failed to find chalk variable`),null;let i=e,a=Te(e);if(!a)return console.error(`^ patch: inputPatternHighlighters: solidLocation returned null`),null;let[o,s,c,l,u]=a.identifiers,d=`else if(${o}.type==="custom")return ${s}.createElement(${c},{key:${l}},${o}.fn(${o}.format.replace(/\\{MATCH\\}/g,${u}.text)));`;i=e.slice(0,a.startIndex)+d+e.slice(a.endIndex),U(e,i,d,a.startIndex,a.endIndex);let f=Ee(i);if(!f)return console.error(`^ patch: inputPatternHighlighters: matchPushes returned null`),null;let p=ke(i,f.index);if(!p)return console.error(`^ patch: inputPatternHighlighters: useMemoLocation returned null`),null;let[m,h]=p.identifiers,g=``;for(let e=0;e<n.length;e++){let t=n[e],r=t.regexFlags;r.includes(`g`)||(r+=`g`);let i=sr(new RegExp(t.regex,r));g+=`matchedTweakccReplacements${e}=${m}.useMemo(()=>{return[...${h}.matchAll(${i})].map(m=>({start:m.index,end:m.index+m[0].length}))},[${h}]),`}let _=i;i=i.slice(0,p.startIndex)+g+i.slice(p.endIndex),U(_,i,g,p.startIndex,p.endIndex);let v=Ee(i);if(!v)return console.error(`^ patch: inputPatternHighlighters: matchPushes2 returned null`),null;let y=Ae(i,v.index,v.rangesVar);if(!y)return console.error(`^ patch: inputPatternHighlighters: rangePushesLocation returned null`),null;let b=y.identifiers[0],x=``;for(let e=0;e<n.length;e++){let t=n[e],i=je(r,t),a=JSON.stringify(t.format);x+=`for(let matchedTweakccReplacement of matchedTweakccReplacements${e}){${b}.push({start:matchedTweakccReplacement.start,end:matchedTweakccReplacement.end,style:{type:"custom",fn:${i},format:${a}},priority:100})}`}let S=i;return i=i.slice(0,y.startIndex)+x+i.slice(y.endIndex),U(S,i,x,y.startIndex,y.endIndex),i},Ne=e=>{let t=e.match(/createElement\([$\w]+,\{[^}]+spinnerTip[^}]+overrideMessage[^}]+\}/);if(!t||t.index===void 0)return console.error(`patch: verbose: failed to find createElement with spinnerTip and overrideMessage`),null;let n=t[0].match(/verbose:[^,}]+/);if(!n||n.index===void 0)return console.error(`patch: verbose: failed to find verbose property`),null;let r=t.index+n.index;return{startIndex:r,endIndex:r+n[0].length}},Pe=e=>{let t=Ne(e);if(!t)return null;let n=`verbose:true`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return U(e,r,n,t.startIndex,t.endIndex),r},Fe=e=>{let t=e.match(/(case"thinking":)\{if\(![$\w]+&&![$\w]+\)return null;(return [$\w]+\.createElement\([$\w]+,\{addMargin:[$\w]+,param:[$\w]+,isTranscriptMode:)([$\w]+)(,verbose:[$\w]+,hideInTranscript:[$\w]+&&!\(![$\w]+\|\|[$\w]+===[$\w]+\)\})\)\}/);if(t&&t.index!==void 0){let e=t.index;return{startIndex:e,endIndex:e+t[0].length,identifiers:[t[1],t[2],t[4],`new_format`]}}let n=e.match(/(case"thinking":)if\([$\w!&]+\)return null;([$\w.]+\.createElement\([$\w]+,\{addMargin:[$\w]+,param:[$\w]+,isTranscriptMode:)([$\w]+)(,verbose:[$\w]+\s*\})\)/);if(n&&n.index!==void 0){let e=n.index;return{startIndex:e,endIndex:e+n[0].length,identifiers:[n[1],n[2],n[4]]}}return console.error(`patch: thinkingVisibility: failed to find thinking visibility pattern`),null},Ie=e=>{let t=Fe(e);if(!t)return null;let n=t.identifiers[3]===`new_format`,r;r=n?`${t.identifiers[0]}{${t.identifiers[1]}true${t.identifiers[2]})}`:`${t.identifiers[0]}${t.identifiers[1]}true${t.identifiers[2]}`;let i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return U(e,i,r,t.startIndex,t.endIndex),i},Le=(e,t)=>{let n=e,r=!1;if(t.plan){let e=/(agentType\s*:\s*"Plan"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/,i=n.match(e);if(i){let a=n.replace(e,`$1${t.plan}$2`);a!==n&&(U(n,a,t.plan,i.index,i.index+i[0].length),n=a,r=!0)}}if(t.explore){let e=/(agentType\s*:\s*"Explore"\s*,[\s\S]{1,2500}?\bmodel\s*:\s*")[^"]+(")/,i=n.match(e);if(i){let a=n.replace(e,`$1${t.explore}$2`);a!==n&&(U(n,a,t.explore,i.index,i.index+i[0].length),n=a,r=!0)}}if(t.generalPurpose){let e=/(\b[$\w]+\s*=\s*\{agentType\s*:\s*"general-purpose"[\s\S]{0,2500}?)(\})/,i=n.match(e);if(i){let a=i[1],o=i[2],s;s=a.includes(`model:`)?a.replace(/(model\s*:\s*")[^"]+(")/,`$1${t.generalPurpose}$2`)+o:a+`${a.trim().endsWith(`,`)?``:`,`}model:"${t.generalPurpose}"`+o;let c=n.replace(e,s);c!==n&&(U(n,c,t.generalPurpose,i.index,i.index+i[0].length),n=c,r=!0)}}return r?n:null},Re=e=>{let t=e.indexOf(`}.VERSION} (Claude Code)`);return t==-1?(console.error(`patch: patchesAppliedIndication: failed to find versionIndex`),null):{startIndex:0,endIndex:t+24}},ze=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern`),null;let n=t.index+t[0].length;return{startIndex:n,endIndex:n}},Be=(e,t,n,r,i,a)=>{let o=e.match(/alignItems:"center",minHeight:9,?/);if(!o||o.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find alignItems pattern for PATCH 4`),null;let s=e.slice(0,o.index)+`minHeight:9,`+e.slice(o.index+o[0].length),c=Math.max(0,o.index-200),l=s.slice(c,o.index+12+2),u=Array.from(l.matchAll(/\b([$\w]+)\.createElement\(([$\w]+),(?:\w+|\{[^}]+\}),/g));if(u.length===0)return console.error(`patch: patchesAppliedIndication: failed to find createElement for PATCH 4`),null;let d=u[u.length-1],f=c+d.index+d[0].length,p=`${n}.createElement(${i}, null, ${a}.blue.bold(" + tweakcc v${t}")),${n}.createElement(${r},{alignItems:"center",flexDirection:"column"},`,m=s;s=s.slice(0,f)+p+s.slice(f),U(m,s,p,f,f);let h=1,g=f+p.length,_=-1;for(;g<s.length;){let e=s[g];if(e===`(`)h++;else if(e===`)`){if(h===1){_=g;break}h--}g++}if(_===-1)return console.error(`patch: patchesAppliedIndication: failed to find closing paren for PATCH 4`),null;let v=s;return s=s.slice(0,_)+`),`+s.slice(_),U(v,s,`),`,_,_),{content:s,closingParenIndex:_+2}},Ve=(e,t,n,r,i,a,o)=>{let s=4,c=t,l=-1;for(;c<e.length;){let t=e[c];if(t===`(`)s++;else if(t===`)`){if(s===1){l=c;break}s--}c++}if(l===-1)return console.error(`patch: patchesAppliedIndication: failed to find insertion point for PATCH 5`),null;let u=[];u.push(`,${n}.createElement(${r}, { flexDirection: "column" },`),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of o)e=e.replace(`CHALK_VAR`,a),u.push(`${n}.createElement(${r}, null, ${n}.createElement(${i}, {color: "success", bold: true}, "┃ "), ${n}.createElement(${i}, {dimColor: true}, \` * ${e}\`)),`);u.push(`),`);let d=u.join(``),f=e,p=e.slice(0,l)+d+e.slice(l);return U(f,p,d,l,l),p},He=e=>{let t=e.match(/\b([$\w]+)\.createElement\(([$\w]+),\{bold:!0\},"Claude Code"\)," ",([$\w]+)\.createElement\(([$\w]+),\{dimColor:!0\},"v",[$\w]+\)/);if(!t||t.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find Claude Code version pattern for patch 3`),null;let n=Math.max(0,t.index-1500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/\}function ([$\w]+)\(/g));if(i.length===0)return console.error(`patch: patchesAppliedIndication: failed to find header component function`),null;let a=i[i.length-1][1],o=RegExp(`\\b([$\\w]+)\\.createElement\\(${W(a)},null\\),?`),s=e.match(o);if(!s||s.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find createElement call for header`),null;let c=s.index+s[0].length;return{startIndex:c,endIndex:c}},Ue=(e,t,n,r=!0,i=!0)=>{let a=Re(e);if(!a)return console.error(`patch: patchesAppliedIndication: failed to version output location`),null;let o=`\\n${t} (tweakcc)`,s=e.slice(0,a.endIndex)+o+e.slice(a.endIndex);U(e,s,o,a.endIndex,a.endIndex);let c=On(e);if(!c)return console.error(`patch: patchesAppliedIndication: failed to find chalk variable`),null;let l=Ln(e);if(!l)return console.error(`patch: patchesAppliedIndication: failed to find text component`),null;let u=Pn(e);if(!u)return console.error(`patch: patchesAppliedIndication: failed to find React variable`),null;let d=Rn(e);if(!d)return console.error(`patch: patchesAppliedIndication: failed to find Box component`),null;if(r){let e=ze(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 2 failed`),null;let n=`, " ",${u}.createElement(${l}, null, ${c}.blue.bold('+ tweakcc v${t}'))`,r=s;s=s.slice(0,e.startIndex)+n+s.slice(e.endIndex),U(r,s,n,e.startIndex,e.endIndex)}if(i){let e=He(s);if(!e)return console.error(`patch: patchesAppliedIndication: patch 3 failed`),null;let t=[];t.push(`${u}.createElement(${d}, { flexDirection: "column" },`),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {color: "success", bold: true}, "✓ tweakcc patches are applied")),`);for(let e of n)e=e.replace(`CHALK_VAR`,c),t.push(`${u}.createElement(${d}, null, ${u}.createElement(${l}, {color: "success", bold: true}, "┃ "), ${u}.createElement(${l}, {dimColor: true}, \` * ${e}\`)),`);t.push(`),`);let r=t.join(`
|
|
12
|
+
`),i=s;s=s.slice(0,e.startIndex)+r+s.slice(e.endIndex),U(i,s,r,e.startIndex,e.endIndex)}let f=-1;if(r){let e=Be(s,t,u,d,l,c);if(!e)return console.error(`patch: patchesAppliedIndication: patch 4 failed`),null;s=e.content,f=e.closingParenIndex}if(i){if(f===-1){let e=s.match(/alignItems:"center",minHeight:9,?/);if(!e||e.index===void 0)return console.error(`patch: patchesAppliedIndication: failed to find reference point for PATCH 5`),null;f=e.index+e[0].length}let e=Ve(s,f,u,d,l,c,n);if(!e)return console.error(`patch: patchesAppliedIndication: patch 5 failed`),null;s=e}return s};async function We(e){let t=E.join(vr,`prompts-${e}.json`);try{let e=await y.readFile(t,`utf-8`);return JSON.parse(e)}catch{}let n=`https://raw.githubusercontent.com/Piebald-AI/tweakcc/refs/heads/main/data/prompts/prompts-${e}.json`;try{let r=await fetch(n);if(!r.ok){let t;throw t=r.status===429?`Rate limit exceeded. GitHub has temporarily blocked requests. Please wait a few minutes and try again.`:r.status===404?`Prompts file not found for Claude Code v${e}. This version was released within the past day or so and will be supported within a few hours.`:r.status>=500?`GitHub server error (${r.status}). Please try again later.`:`HTTP ${r.status}: ${r.statusText}`,Error(t)}let i=await r.json();try{await y.mkdir(vr,{recursive:!0}),await y.writeFile(t,JSON.stringify(i,null,2),`utf-8`)}catch(e){console.warn(`Failed to write to cache to ${t}: ${e}`)}return i}catch(t){if(t instanceof Error){if(t.message.includes(`Rate limit`)||t.message.includes(`not found`)||t.message.includes(`server error`)||t.message.includes(`HTTP`))throw t;let n=`Failed to download prompts for version ${e}: ${t.message}`;throw Error(n)}throw t}}const Ge=()=>E.join(J,`systemPromptOriginalHashes.json`),Ke=()=>E.join(J,`systemPromptAppliedHashes.json`),qe=(e,t)=>`${e}-${t}`,Je=e=>A.createHash(`md5`).update(e.trim(),`utf8`).digest(`hex`),Ye=async()=>{try{let e=await y.readFile(Ge(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},Xe=async e=>{await y.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await y.writeFile(Ge(),JSON.stringify(t,null,2),`utf8`)},Ze=async e=>{let t=await Ye(),n=0;for(let r of e.prompts){let e=qe(r.id,r.version);t[e]||(t[e]=Je(ot(r.pieces,r.identifiers,r.identifierMap)),n++)}return await Xe(t),n},Qe=async(e,t)=>(await Ye())[qe(e,t)],$e=async()=>{try{let e=await y.readFile(Ke(),`utf8`);return JSON.parse(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return{};throw e}},et=async e=>{await y.mkdir(J,{recursive:!0});let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];await y.writeFile(Ke(),JSON.stringify(t,null,2),`utf8`)},tt=async(e,t)=>{let n=await $e();n[e]=t,await et(n)},nt=async()=>{let e=await $e(),t={};for(let n of Object.keys(e))t[n]=null;await et(t)},rt=async e=>{try{let t=await $e();if(Object.keys(t).length===0)return!1;let n=(await y.readdir(e)).filter(e=>e.endsWith(`.md`));for(let r of n){let n=t[r.replace(`.md`,``)];if(n==null)continue;let i=E.join(e,r),a=await y.readFile(i,`utf8`);if(Je((await import(`gray-matter`)).default(a,{delimiters:[`<!--`,`-->`]}).content)!==n)return!0}return!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}},it=e=>{let t=j(e,{delimiters:[`<!--`,`-->`]}),{name:n,description:r,ccVersion:i,variables:a}=t.data,o=0,s=e.indexOf(t.content);return s>=0&&(o=e.slice(0,s).split(`
|
|
13
|
+
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}},at=(e,t)=>{let n=t||ot(e.pieces,e.identifiers,e.identifierMap),r=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,i={name:e.name,description:e.description,ccVersion:e.version};return r&&r.length>0&&(i.variables=r),j.stringify(n,i,{delimiters:[`<!--`,`-->`]})},ot=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++)if(r+=e[i],i<t.length){let e=t[i],a=n[String(e)]||`UNKNOWN_${e}`;r+=a}return r},st=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]||0,i=r[e]||0;if(t<i)return-1;if(t>i)return 1}return 0},ct=e=>E.join(_r,`${e}.md`),lt=async e=>{try{return await y.access(ct(e)),!0}catch{return!1}},ut=async e=>{let t=ct(e);return it(await y.readFile(t,`utf-8`))},dt=async(e,t)=>{let n=ct(e);await y.writeFile(n,t,`utf-8`)},ft=async(e,t)=>{let n=ct(e),r=j(await y.readFile(n,`utf-8`),{delimiters:[`<!--`,`-->`]}),i=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,a={name:r.data.name,description:r.data.description,ccVersion:r.data.ccVersion};i&&i.length>0&&(a.variables=i),await dt(e,j.stringify(r.content,a,{delimiters:[`<!--`,`-->`]}))},pt=(e,t)=>{let n=e=>e.split(/(\s+)/),r=n(e),i=n(t),a=r.length,o=i.length,s=Array(a+1).fill(0).map(()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)r[e-1]===i[t-1]?s[e][t]=s[e-1][t-1]+1:s[e][t]=Math.max(s[e-1][t],s[e][t-1]);let c=Array(a).fill(!1),l=Array(o).fill(!1),u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l[d-1]=!0,d--):u>0&&(c[u-1]=!0,u--);let f=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),p=``;for(let e=0;e<r.length;e++){let t=f(r[e]);p+=c[e]?`<mark>${t}</mark>`:t}let m=``;for(let e=0;e<i.length;e++){let t=f(i[e]);m+=l[e]?`<mark>${t}</mark>`:t}return{oldHtml:p,newHtml:m}},mt=(e,t)=>{let n=e.length,r=t.length,i=Array(n+1).fill(0).map(()=>Array(r+1).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]+1:i[a][n]=Math.max(i[a-1][n],i[a][n-1]);let a=[],o=n,s=r,c=[];for(;o>0||s>0;)o>0&&s>0&&e[o-1]===t[s-1]?(c.unshift({type:`unchanged`,line:e[o-1],oldLineNo:o,newLineNo:s}),o--,s--):s>0&&(o===0||i[o][s-1]>=i[o-1][s])?(c.unshift({type:`added`,line:t[s-1],newLineNo:s}),s--):o>0&&(c.unshift({type:`removed`,line:e[o-1],oldLineNo:o}),o--);for(let e=0;e<c.length;e++){let t=c[e],n=c[e+1];if(t.type===`removed`&&n?.type===`added`){let r=pt(t.line,n.line);a.push({type:`modified`,line:t.line,oldLineNo:t.oldLineNo,newLineNo:n.newLineNo,oldHtml:r.oldHtml,newHtml:r.newHtml}),e++}else a.push(t)}return a},ht=async(e,t,n,r,i,a,o,s)=>{let c=n.split(`
|
|
14
14
|
`),l=r.split(`
|
|
15
15
|
`),u=i.split(`
|
|
16
|
-
`),d=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),f=
|
|
16
|
+
`),d=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),f=mt(c,l),p=mt(c,u),m=``;for(let e of f){let t=d(e.line);if(e.type===`modified`){let t=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;m+=`<div class="line removed"><span class="line-num">${t}</span><span class="prefix">- </span>${e.oldHtml}</div>\n`,m+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${e.newHtml}</div>\n`}else if(e.type===`removed`){let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `;m+=`<div class="line removed"><span class="line-num">${n}</span><span class="prefix">- </span>${t}</div>\n`}else if(e.type===`added`){let n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;m+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${t}</div>\n`}else{let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,r=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;m+=`<div class="line unchanged"><span class="line-num">${n} ${r}</span><span class="prefix"> </span>${t}</div>\n`}}let h=``;for(let e of p){let t=d(e.line);if(e.type===`modified`){let t=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;h+=`<div class="line removed"><span class="line-num">${t}</span><span class="prefix">- </span>${e.oldHtml}</div>\n`,h+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${e.newHtml}</div>\n`}else if(e.type===`removed`){let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `;h+=`<div class="line removed"><span class="line-num">${n}</span><span class="prefix">- </span>${t}</div>\n`}else if(e.type===`added`){let n=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;h+=`<div class="line added"><span class="line-num">${n}</span><span class="prefix">+ </span>${t}</div>\n`}else{let n=e.oldLineNo?String(e.oldLineNo).padStart(4,` `):` `,r=e.newLineNo?String(e.newLineNo).padStart(4,` `):` `;h+=`<div class="line unchanged"><span class="line-num">${n} ${r}</span><span class="prefix"> </span>${t}</div>\n`}}let g=`<!DOCTYPE html>
|
|
17
17
|
<html>
|
|
18
18
|
<head>
|
|
19
19
|
<meta charset="UTF-8">
|
|
@@ -174,11 +174,11 @@ ${h} </div>
|
|
|
174
174
|
</div>
|
|
175
175
|
</div>
|
|
176
176
|
</body>
|
|
177
|
-
</html>`,_=E.join(
|
|
178
|
-
|\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},
|
|
179
|
-
`){r++,i=0;continue}let s=e[a+1];if(o===`$`&&s===`{`){n++,a++,i++;continue}if(n){o===`{`?n++:o===`}`&&n--;continue}if(o==="`"&&e[a-1]!==`\\`){let e=t.get(r)??[];e.push(i),t.set(r,e)}}return t},
|
|
180
|
-
`)},
|
|
181
|
-
`);for(let[t,a]of e){let e=t+(n.contentLineOffset||0),o=i[t-1]||``;console.log(
|
|
177
|
+
</html>`,_=E.join(_r,`${e}.diff.html`);return await y.writeFile(_,g,`utf-8`),_},gt=async e=>{let t={id:e.id,name:e.name,description:e.description,action:`skipped`,newVersion:e.version};if(!await lt(e.id)){let n=at(e);return await dt(e.id,n),t.action=`created`,t}let n=await ut(e.id);if(t.oldVersion=n.ccVersion,await ft(e.id,e.identifierMap),n.ccVersion&&e.version){let r=st(n.ccVersion,e.version);if(r===0)return t.action=`skipped`,t;if(r!=0){let r=await Qe(e.id,n.ccVersion),i=Je(n.content);if(!r||r!==i){t.action=`conflict`;let r=n.content;try{let t=(await We(n.ccVersion)).prompts.find(t=>t.id===e.id);t&&(r=ot(t.pieces,t.identifiers,t.identifierMap))}catch{console.log(a.yellow(`Warning: Could not fetch old version ${n.ccVersion} for comparison. Using current file as baseline.`))}let i=ot(e.pieces,e.identifiers,e.identifierMap),o=ct(e.id);t.diffHtmlPath=await ht(e.id,e.name,r,n.content,i,n.ccVersion,e.version,o)}else{let n=at(e);await dt(e.id,n),t.action=`updated`}}}return t},_t=async e=>{let t={ccVersion:e,results:[]},n=await We(e);await Ze(n),await y.mkdir(_r,{recursive:!0});for(let e of n.prompts)try{let n=await gt(e);t.results.push(n)}catch(t){throw console.log(a.red(`Failed to sync prompt ${e.id}:`)),t}return t};let vt=null,yt=null;const bt=async e=>{try{return vt=await We(e),yt=e,{success:!0}}catch(e){return vt=null,yt=null,e instanceof Error?{success:!1,errorMessage:e.message}:{success:!1,errorMessage:`Unknown error occurred while downloading system prompts`}}},xt=e=>e.replace(/[^\x00-\x7F]/g,e=>{let t=`\\\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`;return`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}|${t})`}),St=e=>e.replace(/[^\x00-\x7F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`),Ct=(e,t,n)=>{let r=``;for(let i=0;i<e.length;i++){let a=e[i].replace(/<<CCVERSION>>/g,t);n&&(a=a.replace(/<<BUILD_TIME>>/g,n));let o=xt(a.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).replace(/\n/g,`(?:
|
|
178
|
+
|\\\\n)`);r+=o,i<e.length-1&&(r+=`([\\w$]+)`)}return r},wt=e=>{let t=new Map,n=0,r=1,i=1;for(let a=0;a<e.length;a++,i++){let o=e[a];if(o===`
|
|
179
|
+
`){r++,i=0;continue}let s=e[a+1];if(o===`$`&&s===`{`){n++,a++,i++;continue}if(n){o===`{`?n++:o===`}`&&n--;continue}if(o==="`"&&e[a-1]!==`\\`){let e=t.get(r)??[];e.push(i),t.set(r,e)}}return t},Tt=(e,t,n,r)=>{let i=[],o=String(t),s=o.length,c=` `.repeat(s),l=r[0],u=r[r.length-1],d=l-1,f=n.length-u,p=n,m=r,h=``,g=``,_=0;if(d>30||f>30){let e=0,t=n.length,i=0;if(d>30){let t=d-30;e=t,i=-t;let n=`[${t} chars] ...`;h=a.dim(n),_=n.length}if(f>30){let e=f-30;t=n.length-e,g=a.dim(`... [${e} chars]`)}p=n.substring(e,t),m=r.map(e=>e+i)}i.push(`${a.red.bold(`error`)}${a.bold(`: system prompt file contains unescaped backtick`)}`),i.push(`${a.blue.bold(` `.repeat(s)+` -->`)} ${e}:${t}:${l}`),i.push(`${c} ${a.blue.bold(`|`)}`);let v=h+p+g;i.push(`${a.blue.bold(o)} ${a.blue.bold(`|`)} ${v}`);let y=_+m[0]-1,b=` `.repeat(y)+`^ unescaped backtick`;i.push(`${c} ${a.blue.bold(`|`)} ${a.red.bold(b)}`),i.push(`${c} ${a.blue.bold(`|`)}`),i.push(`${a.cyan.bold(`help`)}: add \`\\\` before the backtick to escape it`),i.push(`${c} ${a.blue.bold(`|`)}`);let x=[],S=0;for(let e of m)x.push(p.substring(S,e-1)),x.push(a.green(`\\`)+"`"),S=e;x.push(p.substring(S));let C=h+x.join(``)+g;i.push(`${a.blue.bold(o)} ${a.blue.bold(`|`)} ${C}`);let w=``,T=0;for(let e=0;e<m.length;e++){let t=m[e],n=_+t-1+T;w=w.padEnd(n,` `)+`+`,T++}return i.push(`${c} ${a.blue.bold(`|`)} ${a.green(w)}`),i.join(`
|
|
180
|
+
`)},Et=(e,t,n,r,i,a=!1,o)=>{let s={};for(let e=0;e<r.length;e++){let i=r[e],a=n[String(t[e])];a&&(s[a]=i)}let c=e,l=Object.entries(s).sort((e,t)=>t[0].length-e[0].length);for(let[e,t]of l){let n=RegExp(`\\b${e}\\b`,`g`);c=c.replace(n,()=>t)}return c=c.replace(/<<CCVERSION>>/g,i),o&&(c=c.replace(/<<BUILD_TIME>>/g,o)),a&&(c=St(c)),c},Dt=async(e,t=!1,n)=>{if(!vt||yt!==e)return[];let r=vt,i=[];for(let a of r.prompts){let r=Ct(a.pieces,e,n),o=E.join(_r,`${a.id}.md`),s;try{s=await y.readFile(o,`utf8`)}catch(e){console.error(`Failed to read markdown file ${o}:`,e);continue}let c=it(s);i.push({promptId:a.id,prompt:c,regex:r,getInterpolatedContent:r=>{let i=r.slice(1);return Et(c.content,a.identifiers,a.identifierMap,i,e,t,n)},pieces:a.pieces,identifiers:a.identifiers,identifierMap:a.identifierMap})}return i},Ot=e=>{let t=e.results.filter(e=>e.action===`created`),n=e.results.filter(e=>e.action===`updated`),r=e.results.filter(e=>e.action===`conflict`),i=e.results.filter(e=>e.action===`skipped`);if((t.length>0||n.length>0||r.length>0)&&i.length>0&&(console.log(a.dim(`Skipped ${i.length} up-to-date file(s)`)),console.log()),t.length>0){console.log(a.bold.green(`Created ${t.length} new prompt file(s):`));for(let e of t)console.log(a.green(` ${_r}/${e.id}.md`)),console.log(a.green.dim(` ${e.description}`));console.log()}if(n.length>0){console.log(a.bold.blue(`Updated ${n.length} system prompt file(s):`));for(let e of n)e.oldVersion?console.log(a.blue(` ${e.id}.md (${e.oldVersion} → ${e.newVersion})`)):console.log(a.blue(` ${e.id}.md (→ ${e.newVersion})`));console.log()}if(r.length>0){console.log(a.bold.yellow(`WARNING: Conflicts detected for ${r.length} system prompt file(s)`));for(let e of r)console.log(a.yellow(` ${e.id}.md (${e.oldVersion} → ${e.newVersion})`)),console.log(a.yellow(` Open the diff in your browser: ${e.diffHtmlPath}`));console.log()}if(t.length>0&&(console.log(a.green.bold(`New prompt files have been created; either more are now supported by tweakcc or Anthropic has added new ones.`)),console.log(a.green(`You can now customize the markdown files at ${_r} in a text editor.`)),console.log(a.green(`Then run tweakcc and select "apply" or use tweakcc --apply to update your system prompts`)),console.log()),r.length>0){console.log(),console.log(`Review conflicts:`),console.log(` 1. Open the diff HTML files in your browser`),console.log(` 2. Verify your customizations are still appropriate`),console.log(` 3. Update your markdown files if needed`),console.log(a.bold.cyan(` 4. Important: Update the ccVersion in your markdown files to the latest version of each prompt:`));for(let e of r)console.log(a.yellow(` ${e.id}.md → `)+a.bold.magenta(e.newVersion));console.log(` 5. Delete the diff HTML files`),console.log()}},kt=e=>/\\u[0-9a-fA-F]{4}/.test(e),At=e=>{let t=e.match(/\bBUILD_TIME:"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z)"/);return t?t[1]:void 0},jt=async(e,t,n)=>{let r=n??kt(e);r&&G(`Detected Unicode escaping in cli.js - will escape non-ASCII characters in prompts`);let i=At(e);i&&G(`Extracted BUILD_TIME from cli.js: ${i}`);let o=await Dt(t,r,i);G(`Loaded ${o.length} system prompts with regexes`);let s=0,c=0;for(let{promptId:t,prompt:n,regex:r,getInterpolatedContent:i,pieces:l,identifiers:u,identifierMap:d}of o){let o=new RegExp(r,`si`),f=e.match(o);if(f&&f.index!==void 0){let r=i(f),a=f.index,p=a>0?e[a-1]:``;if(p==="`"){let e=wt(r);if(e.size>0){let r=ct(t),i=n.content.split(`
|
|
181
|
+
`);for(let[t,a]of e){let e=t+(n.contentLineOffset||0),o=i[t-1]||``;console.log(Tt(r,e,o,a)),console.log()}continue}}let m=ot(l,u,d).trim(),h=m.length,g=n.content.length;s+=h,c+=g,h!==g&&(K(`\n Character count difference for ${n.name}:`),K(` Original baseline: ${h} chars`),K(` User's version: ${g} chars`),K(` Difference: ${h-g} chars`),Math.abs(h-g)<200&&(K(`\n Original baseline content:\n${m}`),K(`\n User's content:\n${n.content}`))),K(`\nFound match for prompt: ${n.name}`),K(` Match location: index ${f.index}, length ${f[0].length}`),K(` Original content (first 100 chars): ${f[0].substring(0,100)}...`),K(` Replacement content (first 100 chars): ${r.substring(0,100)}...`),K(` Captured variables: ${f.slice(1).join(`, `)}`),K(` Content identical: ${f[0]===r}`);let _=e,v=f[0].length,y=r;p===`"`?(y=y.replace(/\n/g,`\\n`),y=y.replace(/"/g,`\\"`)):p===`'`&&(y=y.replace(/\n/g,`\\n`),y=y.replace(/'/g,`\\'`)),e=e.replace(o,()=>y),await tt(t,Je(n.content)),U(_,e,y,a,a+v)}else{console.log(a.yellow(`Could not find system prompt "${n.name}" in cli.js (using regex ${sr(o)})`)),K(`\n Debug info for ${n.name}:`),K(` Regex pattern (first 200 chars): ${r.substring(0,200).replace(/\n/g,`\\n`)}...`),K(` Trying to match pattern in cli.js...`);try{K(` Partial match result: ${e.match(new RegExp(r.substring(0,100)))?`found partial`:`no match`}`)}catch{K(` Partial match failed (regex truncation issue)`)}}}let l=[],u=s-c;return u>0?l.push(`system prompts: \${CHALK_VAR.green('${u} fewer chars')} than original`):u<0&&l.push(`system prompts: \${CHALK_VAR.red('${Math.abs(u)} more chars')} than original`),{newContent:e,items:l}},Mt=e=>{let t=e.match(/ensureServerStarted:([$\w]+)\b/);if(!t||t.index===void 0)return console.error(`patch: fixLspSupport: failed to find ensureServerStarted`),null;let n=Math.max(0,t.index-50),r=Math.min(e.length,t.index+50),i=e.slice(n,r),a=i.match(/sendRequest:([$\w]+)[,}]/);if(!a)return console.error(`patch: fixLspSupport: failed to find sendRequest near ensureServerStarted, window=${JSON.stringify([n,r,i])}`),null;let o=a[1],s=Math.max(0,t.index-2e3),c=e.slice(s,t.index),l=RegExp(`async function ${W(o)}\\(([$\\w]+),`,`g`),u,d=null;for(;(u=l.exec(c))!==null;)d=u;if(!d)return console.error(`patch: fixLspSupport: failed to find async function ${o}`),null;let f=d[1],p=s+d.index,m=e.slice(p,t.index).match(/let ([$\w]+)=await [$\w]+\([$\w]+\);/);if(!m||m.index===void 0)return console.error(`patch: fixLspSupport: failed to find second line of sendRequest`),null;let h=m[1],g=p+m.index+m[0].length,_=e.slice(g,t.index),v=RegExp(`if\\(!${W(h)}\\)return;`),y=_.match(v);if(!y||y.index===void 0)return console.error(`patch: fixLspSupport: failed to find if(!serverVar)return; line`),null;let b=g+y.index+y[0].length;return{startIndex:b,endIndex:b,identifiers:[f,h]}},Nt=e=>{let t=/if\([$\w]+\.restartOnCrash!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': restartOnCrash is not yet implemented\. Remove this field from the configuration\.`\);/g,n=/if\([$\w]+\.startupTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': startupTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,r=/if\([$\w]+\.shutdownTimeout!==void 0\)throw Error\(`LSP server '\$\{[$\w]+\}': shutdownTimeout is not yet implemented\. Remove this field from the configuration\.`\);/g,i=e,a=i;i=i.replace(t,``),i===a?console.warn(`patch: fixLspSupport: restartOnCrash validation not found`):U(a,i,``,0,0);let o=i;i=i.replace(n,``),i===o?console.warn(`patch: fixLspSupport: startupTimeout validation not found`):U(o,i,``,0,0);let s=i;i=i.replace(r,``),i===s?console.warn(`patch: fixLspSupport: shutdownTimeout validation not found`):U(s,i,``,0,0);let c=Mt(i);if(!c||!c.identifiers)return null;let[l,u]=c.identifiers,d=`
|
|
182
182
|
const path = await import('path');
|
|
183
183
|
const ext = path.extname(${l}).toLowerCase();
|
|
184
184
|
const langMap = {
|
|
@@ -328,7 +328,7 @@ ${h} </div>
|
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
} catch (openErr) { }
|
|
331
|
-
`,f=i.slice(0,c.startIndex)+d+i.slice(c.endIndex);return
|
|
331
|
+
`,f=i.slice(0,c.startIndex)+d+i.slice(c.endIndex);return U(i,f,d,c.startIndex,c.endIndex),f},Pt=e=>{let t=e.match(/=>\[([$a-zA-Z_][$\w]{1,2},){30}/);if(!t||t.index===void 0)return console.error(`patch: findSlashCommandListEndPosition: failed to find arrayStartPattern`),null;let n=e.indexOf(`[`,t.index);if(n===-1)return console.error(`patch: findSlashCommandListEndPosition: failed to find bracketIndex`),null;let r=1,i=n+1;for(;i<e.length&&r>0;){if(e[i]===`[`)r++;else if(e[i]===`]`&&(r--,r===0))return i;i++}return console.error(`patch: findSlashCommandListEndPosition: failed to find matching closing-bracket`),null},Ft=(e,t)=>{let n=Pt(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 U(e,r,t,n,n),r},It=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)\(\{(?:(?:isDisabled|hideIndexes|visibleOptionCount|highlightText|options|defaultValue|onCancel|onChange|onFocus|focusValue|layout|disableSelection):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g));if(t.length===0)return console.error(`patch: findSelectComponentName: failed to find selectPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},Lt=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)\(\{(?:(?:orientation|title|width|padding|titlePadding|titleColor|titleDimColor|dividerChar|dividerColor|dividerDimColor|boxProps):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g));if(t.length===0)return console.error(`patch: findDividerComponentName: failed to find dividerPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n[1]},Rt=e=>{let t=Array.from(e.matchAll(/function ([$\w]+)\(\{(?:(?:commands|debug|initialPrompt|initialTools|initialMessages|initialCheckpoints|initialFileHistorySnapshots|mcpClients|dynamicMcpConfig|mcpCliEndpoint|autoConnectIdeFlag|strictMcpConfig|systemPrompt|appendSystemPrompt|onBeforeQuery|onTurnComplete|disabled|mainThreadAgentDefinition|disableSlashCommands):[$\w]+(?:=(?:[^,]+,|[^}]+\})|[,}]))+\)/g)).filter(e=>e[0].includes(`commands:`));if(t.length===0)return console.error(`patch: getMainAppComponentBodyStart: failed to find appComponentPattern`),null;let n=t[0];for(let e of t)e[0].length>n[0].length&&(n=e);return n.index===void 0?(console.error(`patch: getMainAppComponentBodyStart: failed to find appComponentPattern longestMatch`),null):n.index+n[0].length},zt=e=>{let t=Rt(e);if(t===null)return console.error(`patch: getAppStateVarAndGetterFunction: failed to find bodyStart`),null;let n=e.slice(t,t+500).match(/let\[([$\w]+),[$\w]+\]=([$\w]+)\(\)/);return n?{appStateVar:n[1],appStateGetterFunction:n[2]}:(console.error(`patch: getAppStateVarAndGetterFunction: failed to find statePattern`),null)},Bt=e=>{let t=Rt(e);if(t===null)return console.error(`patch: getToolFetchingUseMemoLocation: failed to find bodyStart`),null;let n=e.slice(t,t+2e3).match(/(?:let |,)([$\w]+)=([$\w]+)\.useMemo\(\(\)=>([$\w]+)\(([$\w]+)\),\[\4(?:,[$\w]+)?\]\)/);if(!n||n.index===void 0)return console.error(`patch: getToolFetchingUseMemoLocation: failed to find useMemoPattern`),null;let r=t+n.index,i=r+n[0].length,a=n[0].startsWith(`,`);return{startIndex:r,endIndex:i,outputVarName:n[1],reactVarName:n[2],toolFilterFunction:n[3],toolPermissionContextVar:n[4],needsSemicolonPrefix:a}},Vt=e=>{let t=Pt(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},Ht=(e,t)=>{let n=Array.from(e.matchAll(/thinkingEnabled:([$\w]+)\(\)/g));if(n.length===0)return console.error(`patch: toolsets: failed to find thinkingEnabled pattern`),null;let r=[];for(let e of n)if(e.index!==void 0){let t=e.index+e[0].length;r.push({index:t})}r.sort((e,t)=>t.index-e.index);let i=e,a=`,toolset:${t?JSON.stringify(t):`undefined`}`;for(let e of r)i=i.slice(0,e.index)+a+i.slice(e.index);return i===e?(console.error(`patch: toolsets: failed to modify app state initialization`),null):i},Ut=(e,t)=>{let n=Bt(e);if(!n)return console.error(`patch: toolsets: failed to find tool fetching useMemo location`),null;let r=zt(e);if(!r)return console.error(`patch: toolsets: failed to find app state info`),null;let{appStateVar:i}=r,{startIndex:a,endIndex:o,outputVarName:s,reactVarName:c,toolFilterFunction:l,toolPermissionContextVar:u,needsSemicolonPrefix:d}=n,f=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),p=`${d?`;`:``}let ${s} = ${c}.useMemo(() => {
|
|
332
332
|
const toolsets = ${f};
|
|
333
333
|
if (toolsets.hasOwnProperty(${i}.toolset)) {
|
|
334
334
|
const allowedTools = toolsets[${i}.toolset];
|
|
@@ -342,7 +342,7 @@ ${h} </div>
|
|
|
342
342
|
} else {
|
|
343
343
|
return ${l}(${u});
|
|
344
344
|
}
|
|
345
|
-
}, [${l}, ${i}.toolset])`,m=e.slice(0,a)+p+e.slice(o);return
|
|
345
|
+
}, [${l}, ${i}.toolset])`,m=e.slice(0,a)+p+e.slice(o);return U(e,m,p,a,o),m},Wt=(e,t)=>{let n=Vt(e);if(n===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let r=Pn(e);if(!r)return console.error(`patch: toolsets: failed to find React variable`),null;let i=Rn(e);if(!i)return console.error(`patch: toolsets: failed to find Box component`),null;let a=Ln(e);if(!a)return console.error(`patch: toolsets: failed to find Text component`),null;let o=It(e);if(!o)return console.error(`patch: toolsets: failed to find Select component`),null;let s=Lt(e);if(!s)return console.error(`patch: toolsets: failed to find Divider component`),null;let c=zt(e);if(!c)return console.error(`patch: toolsets: failed to find app state getter`),null;let l=On(e);if(!l)return console.error(`patch: toolsets: failed to find chalk variable`),null;let{appStateGetterFunction:u}=c,d=JSON.stringify(t.map(e=>e.name)),f=JSON.stringify(t.map(e=>({label:e.name,value:e.name,description:e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}: ${e.allowedTools.join(`, `)}`}))),p=`const toolsetComp = ({ onExit, input }) => {
|
|
346
346
|
const [state, setState] = ${u}();
|
|
347
347
|
|
|
348
348
|
// Handle command-line argument
|
|
@@ -406,7 +406,7 @@ ${h} </div>
|
|
|
406
406
|
${r}.createElement(${a}, { dimColor: true, italic: true }, "Enter to confirm · Esc to exit")
|
|
407
407
|
)
|
|
408
408
|
);
|
|
409
|
-
};`,m=e.slice(0,n)+p+e.slice(n);return
|
|
409
|
+
};`,m=e.slice(0,n)+p+e.slice(n);return U(e,m,p,n,n),m},Gt=e=>{let t=e.match(/\{color:"bashBorder"\},"! for bash mode"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find bash mode pattern`),null;let n=Math.max(0,t.index-500),r=e.slice(n,t.index),i=Array.from(r.matchAll(/function ([$\w]+)\(\{[^}]+\}\)\{/g));if(i.length===0)return console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: failed to find function pattern`),null;let a=i[i.length-1];return a.index===void 0?(console.error(`patch: toolsets: findShiftTabAppStateVarInsertionPoint: match has no index`),null):n+a.index+a[0].length},Kt=e=>{let t=Gt(e);if(t===null)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find insertion point`),null;let n=zt(e);if(!n)return console.error(`patch: toolsets: insertShiftTabAppStateVar: failed to find app state getter`),null;let{appStateGetterFunction:r}=n,i=`let[state]=${r}();`,a=e.slice(0,t)+i+e.slice(t);return U(e,a,i,t,t),a},qt=e=>{let t=e.match(/([$\w]+)\((\w+)\)\.toLowerCase\(\)," on"/);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to find mode display pattern`),null;let n=t[1],r=t[2],i=t[0],a=`${n}(${r}).toLowerCase()," on [",state.toolset||"undefined","]"`,o=e.replace(i,a);return o===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(U(e,o,a,t.index,t.index+i.length),o)},Jt=e=>{let t=Array.from(e.matchAll(/"\? for shortcuts"/g)).at(-1);if(!t||t.index===void 0)return console.error(`patch: toolsets: appendToolsetToShortcutsDisplay: could not find '? for shortcuts'`),null;let n=t[0],r=`"? for shortcuts [",state.toolset||"undefined","]"`,i=e.replace(n,r);return i===e?(console.error(`patch: toolsets: appendToolsetToModeDisplay: failed to modify mode display`),null):(U(e,i,r,t.index,t.index+n.length),i)},Yt=e=>{let t=Pn(e);return t?Ft(e,`, {
|
|
410
410
|
aliases: ["change-tools"],
|
|
411
411
|
type: "local-jsx",
|
|
412
412
|
name: "toolset",
|
|
@@ -420,7 +420,7 @@ ${h} </div>
|
|
|
420
420
|
userFacingName() {
|
|
421
421
|
return "toolset";
|
|
422
422
|
}
|
|
423
|
-
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},
|
|
423
|
+
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},Xt=e=>{let t=e.match(/[\w$]+\([\w$]+,function\([\w$]+\)\{[\w$]+\("tengu_ext_at_mentioned",\{\}\);/);return!t||t.index===void 0?(console.error(`patch: findToolChangeComponentScope: failed to find tool change component scope`),null):t.index},Zt=e=>{let t=Xt(e);if(t===null)return null;let n=zt(e);if(!n)return console.error(`patch: addSetStateFnAccessAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateGetterFunction:r}=n,i=`const [state, setState] = ${r}();`;return e.slice(0,t)+i+e.slice(t)},Qt=e=>{let t=e.match(/let [\w$]+=[\w$]+\([\w$]+,\{type:"setMode",mode:([\w$]+),destination:"session"\}\);/);return!t||t.index===void 0?(console.error(`patch: findModeChange: failed to find mode change location`),null):{index:t.index,modeVar:t[1]}},$t=(e,t,n)=>{let r=Qt(e);if(!r)return null;let{index:i,modeVar:a}=r,o=`if(${a}==="plan"){setState((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}else{setState((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}`;return e.slice(0,i)+o+e.slice(i)},en=(e,t,n)=>{if(!t||t.length===0)return null;let r=e;return r=Ht(r,n),r?(r=Ut(r,t),r?(r=Wt(r,t),r?(r=Yt(r),r?(r=Kt(r),r?(r=qt(r),r?(r=Jt(r),r||(console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null)):(console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null)):(console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null)):(console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null)):(console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null)):(console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null)):(console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null)},tn=e=>Pn(e)?Ft(e,`, {
|
|
424
424
|
type: "local",
|
|
425
425
|
name: "title",
|
|
426
426
|
description: "Set the conversation title",
|
|
@@ -439,7 +439,7 @@ ${h} </div>
|
|
|
439
439
|
userFacingName() {
|
|
440
440
|
return "title";
|
|
441
441
|
},
|
|
442
|
-
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),
|
|
442
|
+
}`):(console.error(`patch: conversationTitle: failed to find React variable`),null),nn=e=>{let t=e.match(/class ([$\w]+)\{summaries;(?:customTitles;)?messages;(?:checkpoints;)?fileHistorySnapshots;/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findCustomNamingFunctionsLocation: failed to find class pattern`),null):t.index},rn=e=>{let t=nn(e);if(t===null)return console.error(`patch: conversationTitle: failed to find custom naming functions location`),null;let n=In(e),r=`
|
|
443
443
|
function getTweakccBaseDir() {
|
|
444
444
|
const { join: pathJoin } = ${n}('path');
|
|
445
445
|
const { homedir: osHomedir } = ${n}('os');
|
|
@@ -613,11 +613,11 @@ function onNewMessage(projectDir, projectSlug, msg) {
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
`,i=e.slice(0,t)+r+e.slice(t);return
|
|
616
|
+
`,i=e.slice(0,t)+r+e.slice(t);return U(e,i,r,t,t),i},an=e=>{let t=e.match(/(if\(![$\w]+\.has\(([$\w]+)\.uuid\)\)\{)if\([$\w]+\.appendFileSync\(/);return!t||t.index===void 0?(console.error(`patch: conversationTitle: findAppendEntryInterceptorLocation: failed to find pattern`),null):{location:t.index+t[1].length,messageVar:t[2]}},on=e=>{let t=an(e);if(!t)return console.error(`patch: conversationTitle: failed to find append entry interceptor location`),null;let n=In(e),{location:r,messageVar:i}=t,a=`const { dirname: pathDirname, basename: pathBasename } = ${n}('path');
|
|
617
617
|
const projectDir = pathDirname(this.sessionFile);
|
|
618
618
|
const projectSlug = pathBasename(projectDir);
|
|
619
619
|
onNewMessage(projectDir, projectSlug, ${i});
|
|
620
|
-
`,o=e.slice(0,r)+a+e.slice(r);return
|
|
620
|
+
`,o=e.slice(0,r)+a+e.slice(r);return U(e,o,a,r,r),o},sn=e=>{let t=e.match(/if\([$\w]+\.has\(([$\w]+)\.uuid\)\)continue;/);if(!t||t.index===void 0)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find continue pattern`),null;let n=t[1],r=t.index+t[0].length-10,i=Math.max(0,t.index-200),a=e.substring(i,t.index).match(/for\(let [$\w]+ of ([$\w]+)\)try/);if(!a)return console.error(`patch: conversationTitle: findTweakccSummaryCheckLocations: failed to find loop pattern`),null;let o=a[1];return{orLocation:r,loopLocation:i+(a.index??0),messageVar:n,fileListVar:o}},cn=e=>{let t=sn(e);if(!t)return console.error(`patch: conversationTitle: failed to find tweakcc summary check locations`),null;let n=In(e),{orLocation:r,loopLocation:i,messageVar:a,fileListVar:o}=t,s=e,c=`const { readFileSync: fsReadFileSync } = ${n}('fs');
|
|
621
621
|
const tweakccSummaries = new Set();
|
|
622
622
|
for (const file of ${o}) {
|
|
623
623
|
const contents = fsReadFileSync(file, "utf8").trim();
|
|
@@ -632,40 +632,40 @@ for (const file of ${o}) {
|
|
|
632
632
|
if (obj.type != "summary" || !obj.hasOwnProperty("tweakcc")) continue;
|
|
633
633
|
tweakccSummaries.add(obj.leafUuid);
|
|
634
634
|
}
|
|
635
|
-
`;s=s.slice(0,i)+c+s.slice(i),
|
|
636
|
-
--- Diff ---`),
|
|
637
|
-
`))},H=e=>e.replace(/\$/g,`\\$`),Cn=e=>{let t=Array.from(e.matchAll(/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},wn=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(n)return n[1];console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},Tn=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},En=e=>{let t=Tn(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${H(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let U=null,Dn=null;const On=e=>{if(U!=null)return U;let t=wn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),U=void 0;return}let n=Tn(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),U=void 0;return}let r=RegExp(`\\b([$\\w]+)=${H(t)}\\(${H(n)}\\(\\),1\\)`),i=e.match(r);if(i)return U=i[1],U;let a=En(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),U=void 0;return}let o=RegExp(`\\b([$\\w]+)=${H(t)}\\(${H(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),U=void 0;return}return U=s[1],U},kn=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${H(n)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${n})`);return}return i[1]},An=e=>{if(Dn!=null)return Dn;let t=kn(e);return t?(Dn=t,Dn):(Dn=`require`,Dn)},jn=e=>{let t=e.match(/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},Mn=e=>{let t=e.match(/\b([$\w]+)\.displayName="Box"/);if(!t){console.error(`patch: findBoxComponent: failed to find Box displayName`);return}let n=t[1],r=RegExp(`\\b([$\\w]+)=${H(n)}[^$\\w]`),i=e.match(r);if(!i){console.error(`patch: findBoxComponent: failed to find Box component variable (boxOrigCompName=${n})`);return}return i[1]},Nn=async(e,t)=>{let n;if(t.nativeInstallationPath){await Sn(t);let e=!1;try{await y.stat(Y),e=!0}catch{}let r=e?Y:t.nativeInstallationPath;W(`Extracting claude.js from ${e?`backup`:`native installation`}: ${r}`);let i=await ne(r);if(!i)throw Error(`Failed to extract claude.js from native installation`);let a=C.join(q,`native-claudejs-orig.js`);x.writeFileSync(a,i),W(`Saved original extracted JS from native to: ${a}`),n=i.toString(`utf8`)}else{if(await xn(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);n=await y.readFile(t.cliPath,{encoding:`utf8`})}let r=[],i=await Et(n,t.version);n=i.newContent,r.push(...i.items);let a=null;e.settings.themes&&e.settings.themes.length>0&&(a=oe(n,e.settings.themes))&&(n=a),e.settings.thinkingVerbs&&((a=we(n,e.settings.thinkingVerbs.verbs))&&(n=a),(a=B(n,e.settings.thinkingVerbs.format))&&(n=a)),(a=_e(n,e.settings.thinkingStyle.phases))&&(n=a),(a=ye(n,e.settings.thinkingStyle.updateInterval))&&(n=a),(a=xe(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=a),(a=he(n,e.settings.thinkingStyle.reverseMirror))&&(n=a),e.settings.userMessageDisplay&&(a=Ee(n,e.settings.userMessageDisplay.format,e.settings.userMessageDisplay.foregroundColor,e.settings.userMessageDisplay.backgroundColor,e.settings.userMessageDisplay.styling.includes(`bold`),e.settings.userMessageDisplay.styling.includes(`italic`),e.settings.userMessageDisplay.styling.includes(`underline`),e.settings.userMessageDisplay.styling.includes(`strikethrough`),e.settings.userMessageDisplay.styling.includes(`inverse`),e.settings.userMessageDisplay.borderStyle,e.settings.userMessageDisplay.borderColor,e.settings.userMessageDisplay.paddingX,e.settings.userMessageDisplay.paddingY,e.settings.userMessageDisplay.fitBoxToContent))&&(n=a),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`&&(a=ue(n,e.settings.inputBox.removeBorder))&&(n=a),(a=Oe(n))&&(n=a),(a=fe(n))&&(n=a),(a=ce(n))&&(n=a),(a=In(n))&&(n=a),e.settings.subagentModels&&(a=je(n,e.settings.subagentModels))&&(n=a),(a=ae(n,25))&&(n=a),(e.settings.misc?.expandThinkingBlocks??!0)&&(a=Ae(n))&&(n=a),(a=vn(n))&&(n=a);let o=e.settings.misc?.showTweakccVersion??!0,s=e.settings.misc?.showPatchesApplied??!0;(a=Le(n,`3.3.0`,r,o,s))&&(n=a),(a=Ot(n))&&(n=a),e.settings.toolsets&&e.settings.toolsets.length>0&&(a=Yt(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=a),e.settings.planModeToolset&&e.settings.defaultToolset&&((a=Kt(n))&&(n=a),(a=Jt(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=a));let c=e.settings.misc?.enableConversationTitle??!0,l=t.version&&tt(t.version,`2.0.64`)<0;if(c&&l&&(a=an(n))&&(n=a),e.settings.misc?.hideStartupBanner&&(a=sn(n))&&(n=a),e.settings.misc?.hideCtrlGToEdit&&(a=ln(n))&&(n=a),e.settings.misc?.hideStartupClawd&&(a=dn(n))&&(n=a),e.settings.misc?.increaseFileReadLimit&&(a=pn(n))&&(n=a),e.settings.misc?.suppressLineNumbers&&(a=hn(n))&&(n=a),e.settings.misc?.suppressRateLimitOptions&&(a=gn(n))&&(n=a),t.nativeInstallationPath){W(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=C.join(q,`native-claudejs-patched.js`);x.writeFileSync(e,n,`utf8`),W(`Saved patched JS from native to: ${e}`);let r=Buffer.from(n,`utf8`);await re(t.nativeInstallationPath,r,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await Zn(t.cliPath,n,`patch`)}return await dr(e=>{e.changesApplied=!0})},Pn=[{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],Fn=e=>{let t=e.match(/\b([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-600),i=e.slice(r,t.index),a=RegExp(`function [$\\w]+\\(\\)\\{let ${H(n)}=.+?;`,`g`),o=null,s;for(;(s=a.exec(i))!==null;)o=s;return o?{insertionIndex:r+o.index+o[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${n}`),null)},In=e=>{let t=Fn(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Pn.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return V(e,a,i,n,n),a};let Ln=!1,Rn=!1;const zn=()=>Ln,Bn=()=>Rn,Vn=()=>{Ln=!0},Hn=()=>{Rn=!0,Ln=!0},W=(e,...t)=>{zn()&&console.log(e,...t)},G=(e,...t)=>{Bn()&&console.log(e,...t)};function Un(){try{let e=E.join(O.homedir(),`.claude.json`);return JSON.parse(T.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Wn(){try{let e=E.join(O.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(T.readFileSync(e,`utf8`))?.claudeAiOauth?.subscriptionType||`unknown`){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`}}catch{}return`Claude API`}function Gn(){try{let e=E.join(O.homedir(),`.claude`,`settings.json`),t=JSON.parse(T.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=Pn.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Kn(e){process.platform===`win32`?k.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?k.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():k.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function qn(e){if(process.platform===`win32`)k.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)k.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=E.dirname(e);k.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function Jn(e){if(!e||typeof e!=`string`)return!1;let t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){let e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=255&&parseInt(n)<=255&&parseInt(r)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=360&&parseInt(n)<=100&&parseInt(r)<=100}}return!1}function Yn(e){if(!Jn(e))return e;let t=e.trim();if(t.startsWith(`rgb(`))return t;if(t.startsWith(`#`)){let e=t.slice(1);return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgb(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)})`}if(t.startsWith(`hsl(`)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let t=parseInt(e[1])/360,n=parseInt(e[2])/100,r=parseInt(e[3])/100,i=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=r<.5?r*(1+n):r+n-r*n,o=2*r-a;return`rgb(${Math.round(i(o,a,t+1/3)*255)},${Math.round(i(o,a,t)*255)},${Math.round(i(o,a,t-1/3)*255)})`}}return e}async function Xn(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=A.createHash(t),o=T.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function Zn(e,t,n=`replace`){let r=493;try{r=(await b.stat(e)).mode,W(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){W(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await b.unlink(e),W(`[${n}] Unlinked ${e} to break hard links`)}catch(t){W(`[${n}] Could not unlink ${e}: ${t}`)}await b.writeFile(e,t),await b.chmod(e,r),W(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function Qn(e){try{return await b.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const $n=e=>e.startsWith(`~`)?E.join(O.homedir(),e.slice(1)):e,er=(e,t)=>{let n=e=>{let t=e.split(`.`).map(Number);return[t[0]||0,t[1]||0,t[2]||0]},r=n(e),i=n(t);return r[0]===i[0]?r[1]===i[1]?r[2]-i[2]:r[1]-i[1]:r[0]-i[0]},tr=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)},nr=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function rr(){try{let e=await b.readFile(J,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=w.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await cr(),await b.writeFile(J,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const K={themes:[{name:`Dark mode`,id:`dark`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(253,93,177)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(235,159,127)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(147,165,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(177,195,255)`,permission:`rgb(177,185,249)`,permissionShimmer:`rgb(207,215,255)`,planMode:`rgb(72,150,140)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(177,185,249)`,remember:`rgb(177,185,249)`,background:`rgb(0,204,204)`,success:`rgb(78,186,101)`,error:`rgb(255,107,128)`,warning:`rgb(255,193,7)`,warningShimmer:`rgb(255,223,57)`,diffAdded:`rgb(34,92,43)`,diffRemoved:`rgb(122,41,54)`,diffAddedDimmed:`rgb(71,88,74)`,diffRemovedDimmed:`rgb(105,72,77)`,diffAddedWord:`rgb(56,166,96)`,diffRemovedWord:`rgb(179,89,107)`,diffAddedWordDimmed:`rgb(46,107,58)`,diffRemovedWordDimmed:`rgb(139,57,69)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(177,185,249)`,rate_limit_empty:`rgb(80,83,112)`}},{name:`Light mode`,id:`light`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(255,0,135)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(245,149,117)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(87,105,247)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(117,135,255)`,permission:`rgb(87,105,247)`,permissionShimmer:`rgb(137,155,255)`,planMode:`rgb(0,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(87,105,247)`,remember:`rgb(0,0,255)`,background:`rgb(0,153,153)`,success:`rgb(44,122,57)`,error:`rgb(171,43,63)`,warning:`rgb(150,108,30)`,warningShimmer:`rgb(200,158,80)`,diffAdded:`rgb(105,219,124)`,diffRemoved:`rgb(255,168,180)`,diffAddedDimmed:`rgb(199,225,203)`,diffRemovedDimmed:`rgb(253,210,216)`,diffAddedWord:`rgb(47,157,68)`,diffRemovedWord:`rgb(209,69,75)`,diffAddedWordDimmed:`rgb(144,194,156)`,diffRemovedWordDimmed:`rgb(232,165,173)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(240, 240, 240)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(87,105,247)`,rate_limit_empty:`rgb(39,47,111)`}},{name:`Light mode (ANSI colors only)`,id:`light-ansi`,colors:{autoAccept:`ansi:magenta`,bashBorder:`ansi:magenta`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blue`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blue`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyan`,ide:`ansi:blueBright`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:black`,inverseText:`ansi:white`,inactive:`ansi:blackBright`,subtle:`ansi:blackBright`,suggestion:`ansi:blue`,remember:`ansi:blue`,background:`ansi:cyan`,success:`ansi:green`,error:`ansi:red`,warning:`ansi:yellow`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:red`,blue_FOR_SUBAGENTS_ONLY:`ansi:blue`,green_FOR_SUBAGENTS_ONLY:`ansi:green`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellow`,purple_FOR_SUBAGENTS_ONLY:`ansi:magenta`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyan`,professionalBlue:`ansi:blueBright`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:white`,bashMessageBackgroundColor:`ansi:whiteBright`,memoryBackgroundColor:`ansi:white`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:black`}},{name:`Dark mode (ANSI colors only)`,id:`dark-ansi`,colors:{autoAccept:`ansi:magentaBright`,bashBorder:`ansi:magentaBright`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blueBright`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blueBright`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyanBright`,ide:`ansi:blue`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:whiteBright`,inverseText:`ansi:black`,inactive:`ansi:white`,subtle:`ansi:white`,suggestion:`ansi:blueBright`,remember:`ansi:blueBright`,background:`ansi:cyanBright`,success:`ansi:greenBright`,error:`ansi:redBright`,warning:`ansi:yellowBright`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:redBright`,blue_FOR_SUBAGENTS_ONLY:`ansi:blueBright`,green_FOR_SUBAGENTS_ONLY:`ansi:greenBright`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellowBright`,purple_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyanBright`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:blackBright`,bashMessageBackgroundColor:`ansi:black`,memoryBackgroundColor:`ansi:blackBright`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:white`}},{name:`Light mode (colorblind-friendly)`,id:`light-daltonized`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(0,102,204)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(51,102,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(101,152,255)`,permission:`rgb(51,102,255)`,permissionShimmer:`rgb(101,152,255)`,planMode:`rgb(51,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(51,102,255)`,remember:`rgb(51,102,255)`,background:`rgb(0,153,153)`,success:`rgb(0,102,153)`,error:`rgb(204,0,0)`,warning:`rgb(255,153,0)`,warningShimmer:`rgb(255,183,50)`,diffAdded:`rgb(153,204,255)`,diffRemoved:`rgb(255,204,204)`,diffAddedDimmed:`rgb(209,231,253)`,diffRemovedDimmed:`rgb(255,233,233)`,diffAddedWord:`rgb(51,102,204)`,diffRemovedWord:`rgb(153,51,51)`,diffAddedWordDimmed:`rgb(102,153,204)`,diffRemovedWordDimmed:`rgb(204,153,153)`,red_FOR_SUBAGENTS_ONLY:`rgb(204,0,0)`,blue_FOR_SUBAGENTS_ONLY:`rgb(0,102,204)`,green_FOR_SUBAGENTS_ONLY:`rgb(0,204,0)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,204,0)`,purple_FOR_SUBAGENTS_ONLY:`rgb(128,0,128)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,128,0)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,102,178)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(0,178,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(220, 220, 220)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(51,102,255)`,rate_limit_empty:`rgb(23,46,114)`}},{name:`Dark mode (colorblind-friendly)`,id:`dark-daltonized`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(51,153,255)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(153,204,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(183,224,255)`,permission:`rgb(153,204,255)`,permissionShimmer:`rgb(183,224,255)`,planMode:`rgb(102,153,153)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(153,204,255)`,remember:`rgb(153,204,255)`,background:`rgb(0,204,204)`,success:`rgb(51,153,255)`,error:`rgb(255,102,102)`,warning:`rgb(255,204,0)`,warningShimmer:`rgb(255,234,50)`,diffAdded:`rgb(0,68,102)`,diffRemoved:`rgb(102,0,0)`,diffAddedDimmed:`rgb(62,81,91)`,diffRemovedDimmed:`rgb(62,44,44)`,diffAddedWord:`rgb(0,119,179)`,diffRemovedWord:`rgb(179,0,0)`,diffAddedWordDimmed:`rgb(26,99,128)`,diffRemovedWordDimmed:`rgb(128,21,21)`,red_FOR_SUBAGENTS_ONLY:`rgb(255,102,102)`,blue_FOR_SUBAGENTS_ONLY:`rgb(102,178,255)`,green_FOR_SUBAGENTS_ONLY:`rgb(102,255,102)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,255,102)`,purple_FOR_SUBAGENTS_ONLY:`rgb(178,102,255)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,178,102)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,153,204)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(102,204,204)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(153,204,255)`,rate_limit_empty:`rgb(69,92,115)`}},{name:`Monochrome`,id:`monochrome`,colors:{autoAccept:`rgb(200,200,200)`,bashBorder:`rgb(180,180,180)`,claude:`rgb(255,255,255)`,claudeShimmer:`rgb(230,230,230)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(200,200,200)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(220,220,220)`,permission:`rgb(200,200,200)`,permissionShimmer:`rgb(220,220,220)`,planMode:`rgb(180,180,180)`,ide:`rgb(190,190,190)`,promptBorder:`rgb(160,160,160)`,promptBorderShimmer:`rgb(180,180,180)`,text:`rgb(255,255,255)`,inverseText:`rgb(40,40,40)`,inactive:`rgb(120,120,120)`,subtle:`rgb(100,100,100)`,suggestion:`rgb(200,200,200)`,remember:`rgb(200,200,200)`,background:`rgb(180,180,180)`,success:`rgb(220,220,220)`,error:`rgb(180,180,180)`,warning:`rgb(200,200,200)`,warningShimmer:`rgb(220,220,220)`,diffAdded:`rgb(90,90,90)`,diffRemoved:`rgb(60,60,60)`,diffAddedDimmed:`rgb(110,110,110)`,diffRemovedDimmed:`rgb(80,80,80)`,diffAddedWord:`rgb(200,200,200)`,diffRemovedWord:`rgb(80,80,80)`,diffAddedWordDimmed:`rgb(160,160,160)`,diffRemovedWordDimmed:`rgb(70,70,70)`,red_FOR_SUBAGENTS_ONLY:`rgb(200,200,200)`,blue_FOR_SUBAGENTS_ONLY:`rgb(180,180,180)`,green_FOR_SUBAGENTS_ONLY:`rgb(210,210,210)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(190,190,190)`,purple_FOR_SUBAGENTS_ONLY:`rgb(170,170,170)`,orange_FOR_SUBAGENTS_ONLY:`rgb(195,195,195)`,pink_FOR_SUBAGENTS_ONLY:`rgb(205,205,205)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(185,185,185)`,professionalBlue:`rgb(190,190,190)`,rainbow_red:`rgb(240,240,240)`,rainbow_orange:`rgb(230,230,230)`,rainbow_yellow:`rgb(220,220,220)`,rainbow_green:`rgb(210,210,210)`,rainbow_blue:`rgb(200,200,200)`,rainbow_indigo:`rgb(190,190,190)`,rainbow_violet:`rgb(180,180,180)`,rainbow_red_shimmer:`rgb(255,255,255)`,rainbow_orange_shimmer:`rgb(245,245,245)`,rainbow_yellow_shimmer:`rgb(235,235,235)`,rainbow_green_shimmer:`rgb(225,225,225)`,rainbow_blue_shimmer:`rgb(215,215,215)`,rainbow_indigo_shimmer:`rgb(205,205,205)`,rainbow_violet_shimmer:`rgb(195,195,195)`,clawd_body:`rgb(255,255,255)`,clawd_background:`rgb(40,40,40)`,userMessageBackground:`rgb(70,70,70)`,bashMessageBackgroundColor:`rgb(65,65,65)`,memoryBackgroundColor:`rgb(75,75,75)`,rate_limit_fill:`rgb(200,200,200)`,rate_limit_empty:`rgb(90,90,90)`}}],thinkingVerbs:{format:`{}… `,verbs:`Accomplishing.Actioning.Actualizing.Baking.Booping.Brewing.Calculating.Cerebrating.Channelling.Churning.Clauding.Coalescing.Cogitating.Combobulating.Computing.Concocting.Conjuring.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Deciphering.Deliberating.Determining.Discombobulating.Divining.Doing.Effecting.Elucidating.Enchanting.Envisioning.Finagling.Flibbertigibbeting.Forging.Forming.Frolicking.Generating.Germinating.Hatching.Herding.Honking.Ideating.Imagining.Incubating.Inferring.Manifesting.Marinating.Meandering.Moseying.Mulling.Musing.Mustering.Noodling.Percolating.Perusing.Philosophising.Pondering.Pontificating.Processing.Puttering.Puzzling.Reticulating.Ruminating.Scheming.Schlepping.Shimmying.Simmering.Smooshing.Spelunking.Spinning.Stewing.Sussing.Synthesizing.Thinking.Tinkering.Transmuting.Unfurling.Unravelling.Vibing.Wandering.Whirring.Wibbling.Wizarding.Working.Wrangling.Alchemizing.Animating.Architecting.Bamboozling.Beaming.Befuddling.Bewitching.Billowing.Bippity-bopping.Blanching.Boogieing.Boondoggling.Bootstrapping.Burrowing.Caching.Canoodling.Caramelizing.Cascading.Catapulting.Channeling.Choreographing.Compiling.Composing.Crystallizing.Cultivating.Deploying.Dilly-dallying.Discombobulating.Distilling.Doodling.Drizzling.Ebbing.Embellishing.Ensorcelling.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flowing.Flummoxing.Fluttering.Frosting.Gallivanting.Galloping.Garnishing.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hexing.Hibernating.Higgledy-piggleding.Hornswoggling.Hullaballooing.Hyperspacing.Illustrating.Improvising.Incanting.Indexing.Infusing.Ionizing.Jazzercising.Jiggery-pokerying.Jitterbugging.Julienning.Kerfuffling.Kneading.Leavening.Levitating.Linting.Lollygagging.Malarkeying.Metamorphosing.Migrating.Minifying.Misting.Moonwalking.Mystifying.Nebulizing.Nesting.Nucleating.Optimizing.Orbiting.Orchestrating.Osmosing.Parsing.Perambulating.Photosynthesizing.Pipelining.Poaching.Pollinating.Pouncing.Precipitating.Prestidigitating.Proofing.Propagating.Prowling.Quantumizing.Querying.Razzle-dazzling.Razzmatazzing.Recombobulating.Reducing.Refactoring.Rippling.Roosting.Sautéing.Scampering.Scurrying.Seasoning.Serializing.Shenaniganing.Skedaddling.Sketching.Skullduggering.Slithering.Sock-hopping.Spellbinding.Sprouting.Storyboarding.Sublimating.Swirling.Swooping.Symbioting.Syncopating.Teleporting.Tempering.Thaumaturging.Thundering.Tomfoolering.Topsy-turvying.Transfiguring.Transpiling.Twisting.Undulating.Validating.Vaporizing.Waddling.Warping.Whatchamacalliting.Whirlpooling.Whisking.Willy-nillying.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!0,suppressRateLimitOptions:!1},toolsets:[],defaultToolset:null,planModeToolset:null,subagentModels:{plan:null,explore:null,generalPurpose:null}},q=(()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return $n(e);let t=w.join(g.homedir(),`.tweakcc`),n=w.join(g.homedir(),`.claude`,`tweakcc`),r=process.env.XDG_CONFIG_HOME;try{if(S.existsSync(t))return t}catch(e){W(`Failed to check if ${t} exists: ${e}`)}try{if(S.existsSync(n))return n}catch(e){W(`Failed to check if ${n} exists: ${e}`)}return r?w.join(r,`tweakcc`):t})(),J=w.join(q,`config.json`),ir=w.join(q,`cli.js.backup`),Y=w.join(q,`native-binary.backup`),ar=w.join(q,`system-prompts`),or=w.join(q,`prompt-data-cache`),sr=()=>{let e=q,t=g.homedir(),n=[w.join(t,`.tweakcc`),w.join(t,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?w.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return S.existsSync(t)&&t!==e}catch{return!1}});n.length>0&&(console.warn(a.yellow(`
|
|
635
|
+
`;s=s.slice(0,i)+c+s.slice(i),U(e,s,c,i,i);let l=r+c.length,u=`||tweakccSummaries.has(${a}.uuid)`,d=s.slice(0,l)+u+s.slice(l);return U(s,d,u,l,l),d},ln=e=>{let t=e.match(/description:"Rename the current conversation",isEnabled:\(\)=>!1,/);if(!t)return console.error(`patch: conversationTitle: enableRenameConversationCommand: failed to find pattern`),null;if(t.index===void 0)return console.error(`patch: conversationTitle: enableRenameConversationCommand: match.index is undefined`),null;let n=`description:"Rename the current conversation",isEnabled:()=>!0,`,r=e.replace(`description:"Rename the current conversation",isEnabled:()=>!1,`,n);return r===e?(console.error(`patch: conversationTitle: enableRenameConversationCommand: replacement failed`),null):(U(e,r,n,t.index,t.index+63),r)},un=e=>{let t=e;if(t=tn(t),!t)return console.error(`patch: conversationTitle: step 1 failed (writeTitleSlashCommand)`),null;if(t=rn(t),!t)return console.error(`patch: conversationTitle: step 2 failed (writeCustomNamingFunctions)`),null;if(t=on(t),!t)return console.error(`patch: conversationTitle: step 3 failed (writeAppendEntryInterceptor)`),null;if(t=cn(t),!t)return console.error(`patch: conversationTitle: step 4 failed (writeTweakccSummaryCheck)`),null;let n=ln(t);return n?t=n:console.log(`patch: conversationTitle: step 5 failed (enableRenameConversationCommand)`),t},dn=e=>{let t=e.match(/,[$\w]+\.createElement\([$\w]+,\{isBeforeFirstMessage:!1\}\),/);return!t||t.index===void 0?(console.error(`patch: hideStartupBanner: failed to find startup banner createElement`),null):{startIndex:t.index,endIndex:t.index+t[0].length}},fn=e=>{let t=dn(e);if(!t)return null;let n=e.slice(0,t.startIndex)+`,`+e.slice(t.endIndex);return U(e,n,`,`,t.startIndex,t.endIndex),n},pn=e=>{let t=e.match(/if\(([$\w]+&&[$\w]+)\)p\("tengu_external_editor_hint_shown",/);if(!t||t.index===void 0)return console.error(`patch: hideCtrlGToEdit: failed to find tengu_external_editor_hint_shown pattern`),null;let n=t[1],r=t.index+3;return{startIndex:r,endIndex:r+n.length,identifiers:[]}},mn=e=>{let t=pn(e);if(!t)return null;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return U(e,r,n,t.startIndex,t.endIndex),r},hn=e=>{let t=[],n=0;for(;;){let r=e.indexOf(`▛███▜`,n);if(r===-1)break;let i=Math.max(0,r-2e3),a=e.slice(i,r),o=/function [$\w]+\(\)\{/g,s=null,c;for(;(c=o.exec(a))!==null;)s=c;if(s){let e=i+s.index+s[0].length;t.push(e)}else console.error(`patch: hideStartupClawd: failed to find function pattern before Clawd at position ${r}`);n=r+5}return t},gn=e=>{let t=hn(e);if(t.length===0)return console.error(`patch: hideStartupClawd: no Clawd components found`),null;let n=[...t].sort((e,t)=>t-e),r=`return null;`,i=e;for(let e of n)i=i.slice(0,e)+r+i.slice(e);if(n.length>0){let t=n[n.length-1];U(e,i,r,t,t)}return i},_n=e=>{let t=e.match(/=25000,([\s\S]{0,100})<system-reminder>/);if(!t||t.index===void 0)return console.error(`patch: increaseFileReadLimit: failed to find 25000 token limit near system-reminder`),null;let n=t.index+1;return{startIndex:n,endIndex:n+5}},vn=e=>{let t=_n(e);if(!t)return null;let n=`1000000`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return U(e,r,n,t.startIndex,t.endIndex),r},yn=e=>{let t=e.match(/if\(([$\w]+)\.length>=\d+\)return`\$\{\1\}(?:→|\\u2192)\$\{([$\w]+)\}`;return`\$\{\1\.padStart\(\d+," "\)\}(?:→|\\u2192)\$\{\2\}`/);return!t||t.index===void 0?(console.error(`patch: suppressLineNumbers: failed to find line number formatter pattern`),null):{startIndex:t.index,endIndex:t.index+t[0].length,identifiers:[t[1],t[2]]}},bn=e=>{let t=yn(e);if(!t)return null;let n=t.identifiers?.[1];if(!n)return console.error(`patch: suppressLineNumbers: content variable not captured`),null;let r=`return ${n}`,i=e.slice(0,t.startIndex)+r+e.slice(t.endIndex);return U(e,i,r,t.startIndex,t.endIndex),i},xn=e=>{let t=e.match(/\bshowAllInTranscript:[$\w]+,agentDefinitions:[$\w]+,onOpenRateLimitOptions:([$\w]+)/);if(!t||t.index===void 0)return console.error(`patch: suppressRateLimitOptions: failed to find onOpenRateLimitOptions pattern`),null;let n=t[1],r=t.index+t[0].length-n.length,i=r+n.length,a=`()=>{}`,o=e.slice(0,r)+a+e.slice(i);return U(e,o,a,r,i),o},Sn=e=>{let t=e.indexOf(`∴ Thinking…`);if(t===-1)return console.error(`patch: thinkingLabel: failed to find "∴ Thinking…" anchor`),null;let n=t,r=Math.min(t+200,e.length),i=e.slice(n,r).match(/([$\w]+(?:\.default)?)\.createElement\(([$\w]+),null,([$\w]+)\)/);return!i||i.index===void 0?(console.error(`patch: thinkingLabel: failed to find createElement pattern within 200 chars of anchor`),null):{startIndex:n+i.index,endIndex:n+i.index+i[0].length,identifiers:[i[1],i[2],i[3]]}},Cn=e=>{let t=Sn(e);if(!t)return null;let n=Rn(e);if(!n)return console.error(`patch: thinkingLabel: failed to find Box component`),null;let r=Ln(e);if(!r)return console.error(`patch: thinkingLabel: failed to find Text component`),null;let i=Pn(e);if(!i)return console.error(`patch: thinkingLabel: failed to find React variable`),null;let a=`${i}.createElement(${n},null,${i}.createElement(${r},{italic:true,dimColor:true},${t.identifiers[2]}))`,o=e.slice(0,t.startIndex)+a+e.slice(t.endIndex);return U(e,o,a,t.startIndex,t.endIndex),o},wn=async e=>{if(!e.cliPath){G(`backupClijs: Skipping for native installation (no cliPath)`);return}await br(),G(`Backing up cli.js to ${hr}`),await b.copyFile(e.cliPath,hr),await Cr(t=>{t.changesApplied=!1,t.ccVersion=e.version})},Tn=async e=>{e.nativeInstallationPath&&(await br(),G(`Backing up native binary to ${gr}`),await b.copyFile(e.nativeInstallationPath,gr),await Cr(t=>{t.changesApplied=!1,t.ccVersion=e.version}))},En=async e=>{if(!e.cliPath)return G(`restoreClijsFromBackup: Skipping for native installation (no cliPath)`),!1;G(`Restoring cli.js from backup to ${e.cliPath}`);let t=await b.readFile(hr);return await rr(e.cliPath,t,`restore`),await nt(),await Cr(e=>{e.changesApplied=!1}),!0},Dn=async e=>{if(!e.nativeInstallationPath)return G(`restoreNativeBinaryFromBackup: No native installation path, skipping`),!1;if(!await ir(gr))return G(`restoreNativeBinaryFromBackup: No backup file exists, skipping`),!1;G(`Restoring native binary from backup to ${e.nativeInstallationPath}`);let t=await b.readFile(gr);return await rr(e.nativeInstallationPath,t,`restore`),!0},U=(e,t,n,r,i)=>{if(!Kn())return;let a=Math.max(0,r-20),o=Math.min(e.length,i+20),s=Math.min(t.length,r+n.length+20),c=e.slice(a,r),l=e.slice(r,i),u=e.slice(i,o),d=t.slice(a,r),f=t.slice(r,r+n.length),p=t.slice(r+n.length,s);l!==f&&(K(`
|
|
636
|
+
--- Diff ---`),K(`OLD:`,c+`\x1b[31m${l}\x1b[0m`+u),K(`NEW:`,d+`\x1b[32m${f}\x1b[0m`+p),K(`--- End Diff ---
|
|
637
|
+
`))},W=e=>e.replace(/\$/g,`\\$`),On=e=>{let t=Array.from(e.matchAll(/\b([$\w]+)(?:\.(?:cyan|gray|green|red|yellow|ansi256|bgAnsi256|bgHex|bgRgb|hex|rgb|bold|dim|inverse|italic|strikethrough|underline)\b)+\(/g)),n={};for(let e of t){let t=e[1];n[t]=(n[t]||0)+1}let r,i=0;for(let[e,t]of Object.entries(n))t>i&&(i=t,r=e);return r},kn=e=>{let t=e.slice(0,2e3).match(/[,;]([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{[$\w]+=[$\w]+!=null\?/);if(t)return t[1];let n=e.slice(0,1e3).match(/var ([$\w]+)=\([$\w]+,[$\w]+,[$\w]+\)=>\{/);if(n)return n[1];console.log(`patch: getModuleLoaderFunction: failed to find module loader function`)},An=e=>{let t=e.match(/var ([$\w]+)=[$\w]+\(\([$\w]+\)=>\{var [$\w]+=Symbol\.for\("react\.(transitional\.)?element"\)/);if(!t){console.log(`patch: getReactModuleNameNonBun: failed to find React module name`);return}return t[1]},jn=e=>{let t=An(e);if(!t){console.log(`^ patch: getReactModuleFunctionBun: failed to find React module name (Bun)`);return}let n=RegExp(`var ([$\\w]+)=[$\\w]+\\(\\([$\\w]+,[$\\w]+\\)=>\\{[$\\w]+\\.exports=${W(t)}\\(\\)`),r=e.match(n);if(!r){console.log(`patch: getReactModuleFunctionBun: failed to find React module function (Bun) (reactModuleNameNonBun=${t})`);return}return r[1]};let Mn=null,Nn=null;const Pn=e=>{if(Mn!=null)return Mn;let t=kn(e);if(!t){console.log(`^ patch: getReactVar: failed to find moduleLoader`),Mn=void 0;return}let n=An(e);if(!n){console.log(`^ patch: getReactVar: failed to find reactModuleVarNonBun`),Mn=void 0;return}let r=RegExp(`\\b([$\\w]+)=${W(t)}\\(${W(n)}\\(\\),1\\)`),i=e.match(r);if(i)return Mn=i[1],Mn;let a=jn(e);if(!a){console.log(`^ patch: getReactVar: failed to find reactModuleFunctionBun`),Mn=void 0;return}let o=RegExp(`\\b([$\\w]+)=${W(t)}\\(${W(a)}\\(\\),1\\)`),s=e.match(o);if(!s){console.log(`patch: getReactVar: failed to find bunPattern (moduleLoader=${t}, reactModuleVarNonBun=${n}, reactModuleFunctionBun=${a})`),Mn=void 0;return}return Mn=s[1],Mn},Fn=e=>{let t=e.match(/import\{createRequire as ([$\w]+)\}from"node:module";/);if(!t)return;let n=t[1],r=RegExp(`var ([$\\w]+)=${W(n)}\\(import\\.meta\\.url\\)`),i=e.match(r);if(!i){console.log(`patch: findRequireFunc: failed to find require function variable (createRequireVar=${n})`);return}return i[1]},In=e=>{if(Nn!=null)return Nn;let t=Fn(e);return t?(Nn=t,Nn):(Nn=`require`,Nn)},Ln=e=>{let t=e.match(/\bfunction ([$\w]+)\(\{color:[$\w]+,backgroundColor:[$\w]+,dimColor:[$\w]+=![01],bold:[$\w]+=![01]/);if(!t){console.log(`patch: findTextComponent: failed to find text component`);return}return t[1]},Rn=e=>{let t=e.match(/\b([$\w]+)\.displayName="Box"/);if(t){let n=t[1],r=RegExp(`\\b([$\\w]+)=${W(n)}[^$\\w]`),i=e.match(r);if(i)return i[1];console.error(`patch: findBoxComponent: found Box displayName but failed to find Box component variable (boxOrigCompName=${n})`)}let n=e.match(/\bfunction ([$\w]+)\(\{children:[$\w]+,flexWrap:[$\w]+="nowrap",flexDirection:[$\w]+="row",flexGrow:[$\w]+=[0-9]+,flexShrink:[$\w]+=[0-9]+/);if(n){let t=n[1],r=RegExp(`\\b([$\\w]+)=${W(t)}\\}`),i=e.match(r);return i?i[1]:(console.error(`patch: findBoxComponent: found internal Box function (${t}) but no assignment found`),t)}console.error(`patch: findBoxComponent: failed to find Box component (neither displayName nor function signature found)`)},zn=async(e,t)=>{let n;if(t.nativeInstallationPath){await Dn(t);let e=!1;try{await y.stat(gr),e=!0}catch{}let r=e?gr:t.nativeInstallationPath;G(`Extracting claude.js from ${e?`backup`:`native installation`}: ${r}`);let i=await ee(r);if(!i)throw Error(`Failed to extract claude.js from native installation`);let a=C.join(J,`native-claudejs-orig.js`);x.writeFileSync(a,i),G(`Saved original extracted JS from native to: ${a}`),n=i.toString(`utf8`)}else{if(await En(t),!t.cliPath)throw Error(`cliPath is required for NPM installations`);n=await y.readFile(t.cliPath,{encoding:`utf8`})}let r=[],i=await jt(n,t.version);n=i.newContent,r.push(...i.items);let a=null;e.settings.themes&&e.settings.themes.length>0&&(a=ae(n,e.settings.themes))&&(n=a),e.settings.thinkingVerbs&&((a=Se(n,e.settings.thinkingVerbs.verbs))&&(n=a),(a=H(n,e.settings.thinkingVerbs.format))&&(n=a)),(a=he(n,e.settings.thinkingStyle.phases))&&(n=a),(a=_e(n,e.settings.thinkingStyle.updateInterval))&&(n=a),(a=ye(n,Math.max(...e.settings.thinkingStyle.phases.map(e=>e.length))+1))&&(n=a),(a=pe(n,e.settings.thinkingStyle.reverseMirror))&&(n=a),e.settings.userMessageDisplay&&(a=we(n,e.settings.userMessageDisplay.format,e.settings.userMessageDisplay.foregroundColor,e.settings.userMessageDisplay.backgroundColor,e.settings.userMessageDisplay.styling.includes(`bold`),e.settings.userMessageDisplay.styling.includes(`italic`),e.settings.userMessageDisplay.styling.includes(`underline`),e.settings.userMessageDisplay.styling.includes(`strikethrough`),e.settings.userMessageDisplay.styling.includes(`inverse`),e.settings.userMessageDisplay.borderStyle,e.settings.userMessageDisplay.borderColor,e.settings.userMessageDisplay.paddingX,e.settings.userMessageDisplay.paddingY,e.settings.userMessageDisplay.fitBoxToContent))&&(n=a),e.settings.inputPatternHighlighters&&e.settings.inputPatternHighlighters.length>0&&(a=Me(n,e.settings.inputPatternHighlighters))&&(n=a),e.settings.inputBox&&typeof e.settings.inputBox.removeBorder==`boolean`&&(a=le(n,e.settings.inputBox.removeBorder))&&(n=a),(a=Pe(n))&&(n=a),(a=de(n))&&(n=a),(a=se(n))&&(n=a),(a=Hn(n))&&(n=a),e.settings.subagentModels&&(a=Le(n,e.settings.subagentModels))&&(n=a),(a=re(n,25))&&(n=a),(e.settings.misc?.expandThinkingBlocks??!0)&&(a=Ie(n))&&(n=a),(a=Cn(n))&&(n=a);let o=e.settings.misc?.showTweakccVersion??!0,s=e.settings.misc?.showPatchesApplied??!0;(a=Ue(n,`3.4.0`,r,o,s))&&(n=a),(a=Nt(n))&&(n=a),e.settings.toolsets&&e.settings.toolsets.length>0&&(a=en(n,e.settings.toolsets,e.settings.defaultToolset))&&(n=a),e.settings.planModeToolset&&e.settings.defaultToolset&&((a=Zt(n))&&(n=a),(a=$t(n,e.settings.planModeToolset,e.settings.defaultToolset))&&(n=a));let c=e.settings.misc?.enableConversationTitle??!0,l=t.version&&st(t.version,`2.0.64`)<0;if(c&&l&&(a=un(n))&&(n=a),e.settings.misc?.hideStartupBanner&&(a=fn(n))&&(n=a),e.settings.misc?.hideCtrlGToEdit&&(a=mn(n))&&(n=a),e.settings.misc?.hideStartupClawd&&(a=gn(n))&&(n=a),e.settings.misc?.increaseFileReadLimit&&(a=vn(n))&&(n=a),e.settings.misc?.suppressLineNumbers&&(a=bn(n))&&(n=a),e.settings.misc?.suppressRateLimitOptions&&(a=xn(n))&&(n=a),t.nativeInstallationPath){G(`Repacking modified claude.js into native installation: ${t.nativeInstallationPath}`);let e=C.join(J,`native-claudejs-patched.js`);x.writeFileSync(e,n,`utf8`),G(`Saved patched JS from native to: ${e}`);let r=Buffer.from(n,`utf8`);await te(t.nativeInstallationPath,r,t.nativeInstallationPath)}else{if(!t.cliPath)throw Error(`cliPath is required for NPM installations`);await rr(t.cliPath,n,`patch`)}return await Cr(e=>{e.changesApplied=!0})},Bn=[{value:`claude-opus-4-5-20251101`,label:`Opus 4.5`,description:`Claude Opus 4.5 (November 2025)`},{value:`claude-sonnet-4-5-20250929`,label:`Sonnet 4.5`,description:`Claude Sonnet 4.5 (September 2025)`},{value:`claude-opus-4-1-20250805`,label:`Opus 4.1`,description:`Claude Opus 4.1 (August 2025)`},{value:`claude-opus-4-20250514`,label:`Opus 4`,description:`Claude Opus 4 (May 2025)`},{value:`claude-sonnet-4-20250514`,label:`Sonnet 4`,description:`Claude Sonnet 4 (May 2025)`},{value:`claude-3-7-sonnet-20250219`,label:`Sonnet 3.7`,description:`Claude 3.7 Sonnet (February 2025)`},{value:`claude-3-5-sonnet-20241022`,label:`Sonnet 3.5 (October)`,description:`Claude 3.5 Sonnet (October 2024)`},{value:`claude-3-5-haiku-20241022`,label:`Haiku 3.5`,description:`Claude 3.5 Haiku (October 2024)`},{value:`claude-3-5-sonnet-20240620`,label:`Sonnet 3.5 (June)`,description:`Claude 3.5 Sonnet (June 2024)`},{value:`claude-3-haiku-20240307`,label:`Haiku 3`,description:`Claude 3 Haiku (March 2024)`},{value:`claude-3-opus-20240229`,label:`Opus 3`,description:`Claude 3 Opus (February 2024)`}],Vn=e=>{let t=e.match(/\b([$\w]+)\.push\(\{value:[$\w]+,label:[$\w]+,description:"Custom model"\}\)/);if(!t||t.index===void 0)return console.error(`patch: findCustomModelListInsertionPoint: failed to find custom model push`),null;let n=t[1],r=Math.max(0,t.index-600),i=e.slice(r,t.index),a=RegExp(`function [$\\w]+\\(\\)\\{let ${W(n)}=.+?;`,`g`),o=null,s;for(;(s=a.exec(i))!==null;)o=s;return o?{insertionIndex:r+o.index+o[0].length,modelListVar:n}:(console.error(`patch: findCustomModelListInsertionPoint: failed to find function with let ${n}`),null)},Hn=e=>{let t=Vn(e);if(!t)return null;let{insertionIndex:n,modelListVar:r}=t,i=Bn.map(e=>`${r}.push(${JSON.stringify(e)});`).join(``),a=e.slice(0,n)+i+e.slice(n);return U(e,a,i,n,n),a};let Un=!1,Wn=!1;const Gn=()=>Un,Kn=()=>Wn,qn=()=>{Un=!0},Jn=()=>{Wn=!0,Un=!0},G=(e,...t)=>{Gn()&&console.log(e,...t)},K=(e,...t)=>{Kn()&&console.log(e,...t)};function Yn(){try{let e=E.join(O.homedir(),`.claude.json`);return JSON.parse(T.readFileSync(e,`utf8`)).theme||`dark`}catch{}return`dark`}function Xn(){try{let e=E.join(O.homedir(),`.claude`,`.credentials.json`);switch(JSON.parse(T.readFileSync(e,`utf8`))?.claudeAiOauth?.subscriptionType||`unknown`){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`}}catch{}return`Claude API`}function Zn(){try{let e=E.join(O.homedir(),`.claude`,`settings.json`),t=JSON.parse(T.readFileSync(e,`utf8`))?.model||`default`;if(t===`opus`)return`Opus 4.5`;let n=Bn.find(e=>e.value===t);if(n)return n.label}catch{}return`Opus 4.5`}function Qn(e){process.platform===`win32`?k.spawn(`explorer`,[e],{detached:!0,stdio:`ignore`}).unref():process.platform===`darwin`?k.spawn(`open`,[e],{detached:!0,stdio:`ignore`}).unref():k.spawn(`xdg-open`,[e],{detached:!0,stdio:`ignore`}).unref()}function $n(e){if(process.platform===`win32`)k.spawn(`explorer`,[`/select,`,e],{detached:!0,stdio:`ignore`}).unref();else if(process.platform===`darwin`)k.spawn(`open`,[`-R`,e],{detached:!0,stdio:`ignore`}).unref();else{let t=E.dirname(e);k.spawn(`xdg-open`,[t],{detached:!0,stdio:`ignore`}).unref()}}function er(e){if(!e||typeof e!=`string`)return!1;let t=e.trim();if(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/.test(t))return!0;if(/^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/.test(t)){let e=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=255&&parseInt(n)<=255&&parseInt(r)<=255}}if(/^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(t)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let[,t,n,r]=e;return parseInt(t)<=360&&parseInt(n)<=100&&parseInt(r)<=100}}return!1}function tr(e){if(!er(e))return e;let t=e.trim();if(t.startsWith(`rgb(`))return t;if(t.startsWith(`#`)){let e=t.slice(1);return e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),`rgb(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)})`}if(t.startsWith(`hsl(`)){let e=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(e){let t=parseInt(e[1])/360,n=parseInt(e[2])/100,r=parseInt(e[3])/100,i=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=r<.5?r*(1+n):r+n-r*n,o=2*r-a;return`rgb(${Math.round(i(o,a,t+1/3)*255)},${Math.round(i(o,a,t)*255)},${Math.round(i(o,a,t-1/3)*255)})`}}return e}async function nr(e,t=`sha256`,n=64*1024){return new Promise((r,i)=>{let a=A.createHash(t),o=T.createReadStream(e,{highWaterMark:n});o.on(`data`,e=>{a.update(e)}),o.on(`end`,()=>{r(a.digest(`hex`))}),o.on(`error`,e=>{i(e)})})}async function rr(e,t,n=`replace`){let r=493;try{r=(await b.stat(e)).mode,G(`[${n}] Original file mode for ${e}: ${(r&511).toString(8)}`)}catch(t){G(`[${n}] Could not stat ${e} (error: ${t}), using default mode 755`)}try{await b.unlink(e),G(`[${n}] Unlinked ${e} to break hard links`)}catch(t){G(`[${n}] Could not unlink ${e}: ${t}`)}await b.writeFile(e,t),await b.chmod(e,r),G(`[${n}] Restored permissions to ${(r&511).toString(8)}`)}async function ir(e){try{return await b.stat(e),!0}catch(e){if(e instanceof Error&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`||e.code===`EACCES`||e.code===`EPERM`))return!1;throw e}}const ar=e=>e.startsWith(`~`)?E.join(O.homedir(),e.slice(1)):e,or=(e,t)=>{let n=e=>{let t=e.split(`.`).map(Number);return[t[0]||0,t[1]||0,t[2]||0]},r=n(e),i=n(t);return r[0]===i[0]?r[1]===i[1]?r[2]-i[2]:r[1]-i[1]:r[0]-i[0]},sr=e=>{let t=e.toString(),n=t.lastIndexOf(`/`);return`new RegExp(${JSON.stringify(t.substring(1,n))}, ${JSON.stringify(t.substring(n+1))})`};function cr(e,t){if(e==null)return t;if(typeof t!=`object`||!t)return e;if(Array.isArray(t))return Array.isArray(e)?e:t;let n={...e};for(let e of Object.keys(t)){let r=t[e];e in n?typeof r==`object`&&r&&!Array.isArray(r)&&(n[e]=cr(n[e],r)):n[e]=r}return n}const lr=e=>{let t=e?.settings?.userMessageDisplay;if(t?.prefix){let n=t;e.settings.userMessageDisplay={format:(n.prefix?.format||``)+(n.message?.format||`{}`),styling:[...n.prefix?.styling||[],...n.message?.styling||[]],foregroundColor:n.message?.foregroundColor===`rgb(0,0,0)`?`default`:n.message?.foregroundColor||n.prefix?.foregroundColor||`default`,backgroundColor:n.message?.backgroundColor===`rgb(0,0,0)`?null:n.message?.backgroundColor||n.prefix?.backgroundColor||null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1}}t&&!(`borderStyle`in t)&&(e.settings.userMessageDisplay.borderStyle=`none`,e.settings.userMessageDisplay.borderColor=`rgb(255,255,255)`,e.settings.userMessageDisplay.paddingX=0,e.settings.userMessageDisplay.paddingY=0,e.settings.userMessageDisplay.fitBoxToContent=!1),t&&`padding`in t&&!(`paddingX`in t)&&(e.settings.userMessageDisplay.paddingX=t.padding||0,e.settings.userMessageDisplay.paddingY=0,delete t.padding),t&&!(`fitBoxToContent`in t)&&(e.settings.userMessageDisplay.fitBoxToContent=!1)},ur=e=>{let t=e?.settings?.misc;t&&`hideCtrlGToEditPrompt`in t&&(t.hideCtrlGToEdit=t.hideCtrlGToEditPrompt,delete t.hideCtrlGToEditPrompt)};async function dr(){try{let e=await b.readFile(Y,`utf8`),t=JSON.parse(e);return Object.hasOwn(t,`ccInstallationDir`)?(t.ccInstallationDir&&!t.ccInstallationPath&&(t.ccInstallationPath=w.join(t.ccInstallationDir,`cli.js`)),delete t.ccInstallationDir,t.lastModified=new Date().toISOString(),await br(),await b.writeFile(Y,JSON.stringify(t,null,2)),!0):!1}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}const q={themes:[{name:`Dark mode`,id:`dark`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(253,93,177)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(235,159,127)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(147,165,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(177,195,255)`,permission:`rgb(177,185,249)`,permissionShimmer:`rgb(207,215,255)`,planMode:`rgb(72,150,140)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(177,185,249)`,remember:`rgb(177,185,249)`,background:`rgb(0,204,204)`,success:`rgb(78,186,101)`,error:`rgb(255,107,128)`,warning:`rgb(255,193,7)`,warningShimmer:`rgb(255,223,57)`,diffAdded:`rgb(34,92,43)`,diffRemoved:`rgb(122,41,54)`,diffAddedDimmed:`rgb(71,88,74)`,diffRemovedDimmed:`rgb(105,72,77)`,diffAddedWord:`rgb(56,166,96)`,diffRemovedWord:`rgb(179,89,107)`,diffAddedWordDimmed:`rgb(46,107,58)`,diffRemovedWordDimmed:`rgb(139,57,69)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(177,185,249)`,rate_limit_empty:`rgb(80,83,112)`}},{name:`Light mode`,id:`light`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(255,0,135)`,claude:`rgb(215,119,87)`,claudeShimmer:`rgb(245,149,117)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(87,105,247)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(117,135,255)`,permission:`rgb(87,105,247)`,permissionShimmer:`rgb(137,155,255)`,planMode:`rgb(0,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(87,105,247)`,remember:`rgb(0,0,255)`,background:`rgb(0,153,153)`,success:`rgb(44,122,57)`,error:`rgb(171,43,63)`,warning:`rgb(150,108,30)`,warningShimmer:`rgb(200,158,80)`,diffAdded:`rgb(105,219,124)`,diffRemoved:`rgb(255,168,180)`,diffAddedDimmed:`rgb(199,225,203)`,diffRemovedDimmed:`rgb(253,210,216)`,diffAddedWord:`rgb(47,157,68)`,diffRemovedWord:`rgb(209,69,75)`,diffAddedWordDimmed:`rgb(144,194,156)`,diffRemovedWordDimmed:`rgb(232,165,173)`,red_FOR_SUBAGENTS_ONLY:`rgb(220,38,38)`,blue_FOR_SUBAGENTS_ONLY:`rgb(37,99,235)`,green_FOR_SUBAGENTS_ONLY:`rgb(22,163,74)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(202,138,4)`,purple_FOR_SUBAGENTS_ONLY:`rgb(147,51,234)`,orange_FOR_SUBAGENTS_ONLY:`rgb(234,88,12)`,pink_FOR_SUBAGENTS_ONLY:`rgb(219,39,119)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(8,145,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(240, 240, 240)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(87,105,247)`,rate_limit_empty:`rgb(39,47,111)`}},{name:`Light mode (ANSI colors only)`,id:`light-ansi`,colors:{autoAccept:`ansi:magenta`,bashBorder:`ansi:magenta`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blue`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blue`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyan`,ide:`ansi:blueBright`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:black`,inverseText:`ansi:white`,inactive:`ansi:blackBright`,subtle:`ansi:blackBright`,suggestion:`ansi:blue`,remember:`ansi:blue`,background:`ansi:cyan`,success:`ansi:green`,error:`ansi:red`,warning:`ansi:yellow`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:red`,blue_FOR_SUBAGENTS_ONLY:`ansi:blue`,green_FOR_SUBAGENTS_ONLY:`ansi:green`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellow`,purple_FOR_SUBAGENTS_ONLY:`ansi:magenta`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyan`,professionalBlue:`ansi:blueBright`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:white`,bashMessageBackgroundColor:`ansi:whiteBright`,memoryBackgroundColor:`ansi:white`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:black`}},{name:`Dark mode (ANSI colors only)`,id:`dark-ansi`,colors:{autoAccept:`ansi:magentaBright`,bashBorder:`ansi:magentaBright`,claude:`ansi:redBright`,claudeShimmer:`ansi:yellowBright`,claudeBlue_FOR_SYSTEM_SPINNER:`ansi:blueBright`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`ansi:blueBright`,permission:`ansi:blueBright`,permissionShimmer:`ansi:blueBright`,planMode:`ansi:cyanBright`,ide:`ansi:blue`,promptBorder:`ansi:white`,promptBorderShimmer:`ansi:whiteBright`,text:`ansi:whiteBright`,inverseText:`ansi:black`,inactive:`ansi:white`,subtle:`ansi:white`,suggestion:`ansi:blueBright`,remember:`ansi:blueBright`,background:`ansi:cyanBright`,success:`ansi:greenBright`,error:`ansi:redBright`,warning:`ansi:yellowBright`,warningShimmer:`ansi:yellowBright`,diffAdded:`ansi:green`,diffRemoved:`ansi:red`,diffAddedDimmed:`ansi:green`,diffRemovedDimmed:`ansi:red`,diffAddedWord:`ansi:greenBright`,diffRemovedWord:`ansi:redBright`,diffAddedWordDimmed:`ansi:green`,diffRemovedWordDimmed:`ansi:red`,red_FOR_SUBAGENTS_ONLY:`ansi:redBright`,blue_FOR_SUBAGENTS_ONLY:`ansi:blueBright`,green_FOR_SUBAGENTS_ONLY:`ansi:greenBright`,yellow_FOR_SUBAGENTS_ONLY:`ansi:yellowBright`,purple_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,orange_FOR_SUBAGENTS_ONLY:`ansi:redBright`,pink_FOR_SUBAGENTS_ONLY:`ansi:magentaBright`,cyan_FOR_SUBAGENTS_ONLY:`ansi:cyanBright`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`ansi:red`,rainbow_orange:`ansi:redBright`,rainbow_yellow:`ansi:yellow`,rainbow_green:`ansi:green`,rainbow_blue:`ansi:cyan`,rainbow_indigo:`ansi:blue`,rainbow_violet:`ansi:magenta`,rainbow_red_shimmer:`ansi:redBright`,rainbow_orange_shimmer:`ansi:yellow`,rainbow_yellow_shimmer:`ansi:yellowBright`,rainbow_green_shimmer:`ansi:greenBright`,rainbow_blue_shimmer:`ansi:cyanBright`,rainbow_indigo_shimmer:`ansi:blueBright`,rainbow_violet_shimmer:`ansi:magentaBright`,clawd_body:`ansi:redBright`,clawd_background:`ansi:black`,userMessageBackground:`ansi:blackBright`,bashMessageBackgroundColor:`ansi:black`,memoryBackgroundColor:`ansi:blackBright`,rate_limit_fill:`ansi:yellow`,rate_limit_empty:`ansi:white`}},{name:`Light mode (colorblind-friendly)`,id:`light-daltonized`,colors:{autoAccept:`rgb(135,0,255)`,bashBorder:`rgb(0,102,204)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(51,102,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(101,152,255)`,permission:`rgb(51,102,255)`,permissionShimmer:`rgb(101,152,255)`,planMode:`rgb(51,102,102)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(153,153,153)`,promptBorderShimmer:`rgb(183,183,183)`,text:`rgb(0,0,0)`,inverseText:`rgb(255,255,255)`,inactive:`rgb(102,102,102)`,subtle:`rgb(175,175,175)`,suggestion:`rgb(51,102,255)`,remember:`rgb(51,102,255)`,background:`rgb(0,153,153)`,success:`rgb(0,102,153)`,error:`rgb(204,0,0)`,warning:`rgb(255,153,0)`,warningShimmer:`rgb(255,183,50)`,diffAdded:`rgb(153,204,255)`,diffRemoved:`rgb(255,204,204)`,diffAddedDimmed:`rgb(209,231,253)`,diffRemovedDimmed:`rgb(255,233,233)`,diffAddedWord:`rgb(51,102,204)`,diffRemovedWord:`rgb(153,51,51)`,diffAddedWordDimmed:`rgb(102,153,204)`,diffRemovedWordDimmed:`rgb(204,153,153)`,red_FOR_SUBAGENTS_ONLY:`rgb(204,0,0)`,blue_FOR_SUBAGENTS_ONLY:`rgb(0,102,204)`,green_FOR_SUBAGENTS_ONLY:`rgb(0,204,0)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,204,0)`,purple_FOR_SUBAGENTS_ONLY:`rgb(128,0,128)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,128,0)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,102,178)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(0,178,178)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(220, 220, 220)`,bashMessageBackgroundColor:`rgb(250, 245, 250)`,memoryBackgroundColor:`rgb(230, 245, 250)`,rate_limit_fill:`rgb(51,102,255)`,rate_limit_empty:`rgb(23,46,114)`}},{name:`Dark mode (colorblind-friendly)`,id:`dark-daltonized`,colors:{autoAccept:`rgb(175,135,255)`,bashBorder:`rgb(51,153,255)`,claude:`rgb(255,153,51)`,claudeShimmer:`rgb(255,183,101)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(153,204,255)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(183,224,255)`,permission:`rgb(153,204,255)`,permissionShimmer:`rgb(183,224,255)`,planMode:`rgb(102,153,153)`,ide:`rgb(71,130,200)`,promptBorder:`rgb(136,136,136)`,promptBorderShimmer:`rgb(166,166,166)`,text:`rgb(255,255,255)`,inverseText:`rgb(0,0,0)`,inactive:`rgb(153,153,153)`,subtle:`rgb(80,80,80)`,suggestion:`rgb(153,204,255)`,remember:`rgb(153,204,255)`,background:`rgb(0,204,204)`,success:`rgb(51,153,255)`,error:`rgb(255,102,102)`,warning:`rgb(255,204,0)`,warningShimmer:`rgb(255,234,50)`,diffAdded:`rgb(0,68,102)`,diffRemoved:`rgb(102,0,0)`,diffAddedDimmed:`rgb(62,81,91)`,diffRemovedDimmed:`rgb(62,44,44)`,diffAddedWord:`rgb(0,119,179)`,diffRemovedWord:`rgb(179,0,0)`,diffAddedWordDimmed:`rgb(26,99,128)`,diffRemovedWordDimmed:`rgb(128,21,21)`,red_FOR_SUBAGENTS_ONLY:`rgb(255,102,102)`,blue_FOR_SUBAGENTS_ONLY:`rgb(102,178,255)`,green_FOR_SUBAGENTS_ONLY:`rgb(102,255,102)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(255,255,102)`,purple_FOR_SUBAGENTS_ONLY:`rgb(178,102,255)`,orange_FOR_SUBAGENTS_ONLY:`rgb(255,178,102)`,pink_FOR_SUBAGENTS_ONLY:`rgb(255,153,204)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(102,204,204)`,professionalBlue:`rgb(106,155,204)`,rainbow_red:`rgb(235,95,87)`,rainbow_orange:`rgb(245,139,87)`,rainbow_yellow:`rgb(250,195,95)`,rainbow_green:`rgb(145,200,130)`,rainbow_blue:`rgb(130,170,220)`,rainbow_indigo:`rgb(155,130,200)`,rainbow_violet:`rgb(200,130,180)`,rainbow_red_shimmer:`rgb(250,155,147)`,rainbow_orange_shimmer:`rgb(255,185,137)`,rainbow_yellow_shimmer:`rgb(255,225,155)`,rainbow_green_shimmer:`rgb(185,230,180)`,rainbow_blue_shimmer:`rgb(180,205,240)`,rainbow_indigo_shimmer:`rgb(195,180,230)`,rainbow_violet_shimmer:`rgb(230,180,210)`,clawd_body:`rgb(215,119,87)`,clawd_background:`rgb(0,0,0)`,userMessageBackground:`rgb(55, 55, 55)`,bashMessageBackgroundColor:`rgb(65, 60, 65)`,memoryBackgroundColor:`rgb(55, 65, 70)`,rate_limit_fill:`rgb(153,204,255)`,rate_limit_empty:`rgb(69,92,115)`}},{name:`Monochrome`,id:`monochrome`,colors:{autoAccept:`rgb(200,200,200)`,bashBorder:`rgb(180,180,180)`,claude:`rgb(255,255,255)`,claudeShimmer:`rgb(230,230,230)`,claudeBlue_FOR_SYSTEM_SPINNER:`rgb(200,200,200)`,claudeBlueShimmer_FOR_SYSTEM_SPINNER:`rgb(220,220,220)`,permission:`rgb(200,200,200)`,permissionShimmer:`rgb(220,220,220)`,planMode:`rgb(180,180,180)`,ide:`rgb(190,190,190)`,promptBorder:`rgb(160,160,160)`,promptBorderShimmer:`rgb(180,180,180)`,text:`rgb(255,255,255)`,inverseText:`rgb(40,40,40)`,inactive:`rgb(120,120,120)`,subtle:`rgb(100,100,100)`,suggestion:`rgb(200,200,200)`,remember:`rgb(200,200,200)`,background:`rgb(180,180,180)`,success:`rgb(220,220,220)`,error:`rgb(180,180,180)`,warning:`rgb(200,200,200)`,warningShimmer:`rgb(220,220,220)`,diffAdded:`rgb(90,90,90)`,diffRemoved:`rgb(60,60,60)`,diffAddedDimmed:`rgb(110,110,110)`,diffRemovedDimmed:`rgb(80,80,80)`,diffAddedWord:`rgb(200,200,200)`,diffRemovedWord:`rgb(80,80,80)`,diffAddedWordDimmed:`rgb(160,160,160)`,diffRemovedWordDimmed:`rgb(70,70,70)`,red_FOR_SUBAGENTS_ONLY:`rgb(200,200,200)`,blue_FOR_SUBAGENTS_ONLY:`rgb(180,180,180)`,green_FOR_SUBAGENTS_ONLY:`rgb(210,210,210)`,yellow_FOR_SUBAGENTS_ONLY:`rgb(190,190,190)`,purple_FOR_SUBAGENTS_ONLY:`rgb(170,170,170)`,orange_FOR_SUBAGENTS_ONLY:`rgb(195,195,195)`,pink_FOR_SUBAGENTS_ONLY:`rgb(205,205,205)`,cyan_FOR_SUBAGENTS_ONLY:`rgb(185,185,185)`,professionalBlue:`rgb(190,190,190)`,rainbow_red:`rgb(240,240,240)`,rainbow_orange:`rgb(230,230,230)`,rainbow_yellow:`rgb(220,220,220)`,rainbow_green:`rgb(210,210,210)`,rainbow_blue:`rgb(200,200,200)`,rainbow_indigo:`rgb(190,190,190)`,rainbow_violet:`rgb(180,180,180)`,rainbow_red_shimmer:`rgb(255,255,255)`,rainbow_orange_shimmer:`rgb(245,245,245)`,rainbow_yellow_shimmer:`rgb(235,235,235)`,rainbow_green_shimmer:`rgb(225,225,225)`,rainbow_blue_shimmer:`rgb(215,215,215)`,rainbow_indigo_shimmer:`rgb(205,205,205)`,rainbow_violet_shimmer:`rgb(195,195,195)`,clawd_body:`rgb(255,255,255)`,clawd_background:`rgb(40,40,40)`,userMessageBackground:`rgb(70,70,70)`,bashMessageBackgroundColor:`rgb(65,65,65)`,memoryBackgroundColor:`rgb(75,75,75)`,rate_limit_fill:`rgb(200,200,200)`,rate_limit_empty:`rgb(90,90,90)`}}],thinkingVerbs:{format:`{}… `,verbs:`Accomplishing.Actioning.Actualizing.Baking.Booping.Brewing.Calculating.Cerebrating.Channelling.Churning.Clauding.Coalescing.Cogitating.Combobulating.Computing.Concocting.Conjuring.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Deciphering.Deliberating.Determining.Discombobulating.Divining.Doing.Effecting.Elucidating.Enchanting.Envisioning.Finagling.Flibbertigibbeting.Forging.Forming.Frolicking.Generating.Germinating.Hatching.Herding.Honking.Ideating.Imagining.Incubating.Inferring.Manifesting.Marinating.Meandering.Moseying.Mulling.Musing.Mustering.Noodling.Percolating.Perusing.Philosophising.Pondering.Pontificating.Processing.Puttering.Puzzling.Reticulating.Ruminating.Scheming.Schlepping.Shimmying.Simmering.Smooshing.Spelunking.Spinning.Stewing.Sussing.Synthesizing.Thinking.Tinkering.Transmuting.Unfurling.Unravelling.Vibing.Wandering.Whirring.Wibbling.Wizarding.Working.Wrangling.Alchemizing.Animating.Architecting.Bamboozling.Beaming.Befuddling.Bewitching.Billowing.Bippity-bopping.Blanching.Boogieing.Boondoggling.Bootstrapping.Burrowing.Caching.Canoodling.Caramelizing.Cascading.Catapulting.Channeling.Choreographing.Compiling.Composing.Crystallizing.Cultivating.Deploying.Dilly-dallying.Discombobulating.Distilling.Doodling.Drizzling.Ebbing.Embellishing.Ensorcelling.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flowing.Flummoxing.Fluttering.Frosting.Gallivanting.Galloping.Garnishing.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hexing.Hibernating.Higgledy-piggleding.Hornswoggling.Hullaballooing.Hyperspacing.Illustrating.Improvising.Incanting.Indexing.Infusing.Ionizing.Jazzercising.Jiggery-pokerying.Jitterbugging.Julienning.Kerfuffling.Kneading.Leavening.Levitating.Linting.Lollygagging.Malarkeying.Metamorphosing.Migrating.Minifying.Misting.Moonwalking.Mystifying.Nebulizing.Nesting.Nucleating.Optimizing.Orbiting.Orchestrating.Osmosing.Parsing.Perambulating.Photosynthesizing.Pipelining.Poaching.Pollinating.Pouncing.Precipitating.Prestidigitating.Proofing.Propagating.Prowling.Quantumizing.Querying.Razzle-dazzling.Razzmatazzing.Recombobulating.Reducing.Refactoring.Rippling.Roosting.Sautéing.Scampering.Scurrying.Seasoning.Serializing.Shenaniganing.Skedaddling.Sketching.Skullduggering.Slithering.Sock-hopping.Spellbinding.Sprouting.Storyboarding.Sublimating.Swirling.Swooping.Symbioting.Syncopating.Teleporting.Tempering.Thaumaturging.Thundering.Tomfoolering.Topsy-turvying.Transfiguring.Transpiling.Twisting.Undulating.Validating.Vaporizing.Waddling.Warping.Whatchamacalliting.Whirlpooling.Whisking.Willy-nillying.Zesting.Zigzagging`.split(`.`)},thinkingStyle:{updateInterval:120,phases:process.env.TERM===`xterm-ghostty`?[`·`,`✢`,`✳`,`✶`,`✻`,`*`]:process.platform===`darwin`?[`·`,`✢`,`✳`,`✶`,`✻`,`✽`]:[`·`,`✢`,`*`,`✶`,`✻`,`✽`],reverseMirror:!0},userMessageDisplay:{format:` > {} `,styling:[],foregroundColor:`default`,backgroundColor:null,borderStyle:`none`,borderColor:`rgb(255,255,255)`,paddingX:0,paddingY:0,fitBoxToContent:!1},inputBox:{removeBorder:!1},misc:{showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!0,suppressRateLimitOptions:!1},toolsets:[],defaultToolset:null,planModeToolset:null,subagentModels:{plan:null,explore:null,generalPurpose:null},inputPatternHighlighters:[],inputPatternHighlightersTestText:`Type test text here to see highlighting`},fr={name:`Unnamed Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:null,backgroundColor:null,enabled:!0},pr={name:`Unnamed Toolset`,allowedTools:`*`},mr=q.themes[0],J=(()=>{let e=process.env.TWEAKCC_CONFIG_DIR?.trim();if(e&&e.length>0)return ar(e);let t=w.join(g.homedir(),`.tweakcc`),n=w.join(g.homedir(),`.claude`,`tweakcc`),r=process.env.XDG_CONFIG_HOME;try{if(S.existsSync(t))return t}catch(e){G(`Failed to check if ${t} exists: ${e}`)}try{if(S.existsSync(n))return n}catch(e){G(`Failed to check if ${n} exists: ${e}`)}return r?w.join(r,`tweakcc`):t})(),Y=w.join(J,`config.json`),hr=w.join(J,`cli.js.backup`),gr=w.join(J,`native-binary.backup`),_r=w.join(J,`system-prompts`),vr=w.join(J,`prompt-data-cache`),yr=()=>{let e=J,t=g.homedir(),n=[w.join(t,`.tweakcc`),w.join(t,`.claude`,`tweakcc`),process.env.XDG_CONFIG_HOME?w.join(process.env.XDG_CONFIG_HOME,`tweakcc`):null].filter(e=>e!==null).filter(t=>{try{return S.existsSync(t)&&t!==e}catch{return!1}});n.length>0&&(console.warn(a.yellow(`
|
|
638
638
|
Multiple configuration locations detected:`)),console.warn(a.gray(` Active: ${e}`)),console.warn(a.gray(` Other existing locations:`)),n.forEach(e=>{console.warn(a.gray(` - ${e}`))}),console.warn(a.gray(` Only the active location is used. To switch locations,`)),console.warn(a.gray(` move your config.json to the desired directory.
|
|
639
|
-
`)))},cr=async()=>{await b.mkdir(q,{recursive:!0}),await b.mkdir(ar,{recursive:!0});let e=w.join(q,`.gitignore`);try{await b.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await b.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(_)+_)}};let lr=null;const ur=async()=>{let e={ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:K};try{W(`Reading config at ${J}`),sr();let t=await b.readFile(J,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation),n.settings.inputBox||(n.settings.inputBox=K.inputBox),n.settings.toolsets||(n.settings.toolsets=K.toolsets),Object.hasOwn(n.settings,`defaultToolset`)||(n.settings.defaultToolset=K.defaultToolset),Object.hasOwn(n.settings,`planModeToolset`)||(n.settings.planModeToolset=K.planModeToolset);for(let e of K.themes){let t=n?.settings?.themes.find(t=>t.id===e.id||t.name===e.name);if(t){for(let[n,r]of Object.entries(e))n!==`colors`&&!Object.hasOwn(t,n)&&(t[n]=r);t.colors||={};for(let[n,r]of Object.entries(e.colors))Object.hasOwn(t.colors,n)||(t.colors[n]=r)}}for(let e of n?.settings?.themes||[]){if(K.themes.some(t=>t.id===e.id||t.name===e.name))continue;let t=K.themes[0];e.colors||={};for(let[n,r]of Object.entries(t.colors))Object.hasOwn(e.colors,n)||(e.colors[n]=r)}return n?.settings?.userMessageDisplay||(n.settings=n.settings||K,n.settings.userMessageDisplay=K.userMessageDisplay),tr(n),nr(n),delete n.settings.launchText,await Ze(ar)&&(n.changesApplied=!1),lr=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},dr=async e=>(W(`Updating config at ${J}`),lr||=await ur(),e(lr),lr.lastModified=new Date().toISOString(),await fr(lr),lr),fr=async e=>{try{e.lastModified=new Date().toISOString(),await cr(),await b.writeFile(J,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}};var X=({children:e,...n})=>N(t,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...n,children:[` `,e,` `]});const pr=[`\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 mr=()=>N(e,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[N(e,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[M(t,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),M(t,{children:` `}),N(t,{children:[`We've released `,M(t,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),N(t,{children:[`Download it and try it out for free!`,` `,M(v,{url:`https://piebald.ai/`,fallback:!1,children:M(t,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),M(t,{children:` `}),M(t,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),M(e,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:pr.map((e,n)=>M(t,{children:e},n))})]});let Z=function(e){return e.APPLY_CHANGES=`*Apply customizations`,e.THEMES=`Themes`,e.THINKING_VERBS=`Thinking verbs`,e.THINKING_STYLE=`Thinking style`,e.USER_MESSAGE_DISPLAY=`User message display`,e.MISC=`Misc`,e.TOOLSETS=`Toolsets`,e.SUBAGENT_MODELS=`Subagent models`,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 hr({items:n,selectedIndex:i,onSelect:a,onSubmit:o}){return r((e,t)=>{t.upArrow?a(i>0?i-1:n.length-1):t.downArrow?a(i<n.length-1?i+1:0):t.return&&o(n[i].name)}),M(e,{flexDirection:`column`,children:n.map((n,r)=>M(e,{children:N(t,{children:[N(t,{bold:r===i,color:r===i?`cyan`:void 0,...r===i?n.selectedStyles??{}:n.styles??{},children:[r===i?`❯ `:` `,n.name]}),n.desc&&r===i&&N(t,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,n.desc]})]})},r))})}const gr=[{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.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.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],_r=[{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 (${J})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var vr=({onSubmit:e})=>{let t=[...u($).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:`Required: Updates Claude Code in-place with your changes`,selectedStyles:{color:`green`}}],...gr,..._r],[n,r]=m(0);return M(hr,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const yr=()=>N(e,{flexDirection:`row`,children:[M(X,{children:`tweakcc`}),M(t,{children:` (by `}),M(v,{url:`https://piebald.ai`,fallback:!1,children:M(t,{color:`#ff8400`,bold:!0,children:`Piebald`})}),M(t,{children:`)`})]}),br=()=>M(e,{children:N(t,{color:`yellow`,children:[`⭐ `,M(t,{bold:!0,children:`Star the repo at `}),M(v,{url:`https://github.com/Piebald-AI/tweakcc`,fallback:!1,children:M(t,{bold:!0,color:`cyan`,children:`https://github.com/Piebald-AI/tweakcc`})}),M(t,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),xr=({notification:n})=>M(e,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:M(t,{color:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,children:n.message})}),Sr=({onSubmit:n,notification:r,configMigrated:i,showPiebaldAnnouncement:a})=>N(e,{flexDirection:`column`,gap:1,children:[i&&M(e,{children:M(t,{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."})}),M(yr,{}),M(e,{children:N(t,{children:[M(t,{bold:!0,children:`Customize your Claude Code installation.`}),` `,N(t,{dimColor:!0,children:[`Settings will be saved to `,q.replace(h.homedir(),`~`),`/config.json.`]})]})}),M(a?mr:br,{}),r&&M(xr,{notification:r}),M(vr,{onSubmit:n})]});function Q({color:e,backgroundColor:n,bold:r,dimColor:i,children:s}){let c=e?.startsWith(`ansi:`),l=n?.startsWith(`ansi:`);if(c||l){if(o.Children.toArray(s).some(e=>o.isValidElement(e)))return M(t,{children:s});let u=a;if(c){let t=e.slice(5);u=u[t]||u}if(l){let e=n.slice(5),t=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;u=u[t]||u}r&&(u=u.bold),i&&(u=u.dim);let d=o.Children.toArray(s).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return M(t,{children:u(d)})}return M(t,{color:e,backgroundColor:n,bold:r,dimColor:i,children:s})}function Cr({text:e,nonShimmerColors:n,shimmerColors:r,shimmerWidth:i=3,updateDuration:a=50,restartPoint:o=10}){let[s,c]=m(0);return d(()=>{let t=setInterval(()=>{c(t=>{let n=t+1;return n>=e.length+o?-i:n})},a);return()=>clearInterval(t)},[e.length,o,a]),n.length===r.length?M(t,{children:e.split(``).map((a,o)=>{let c=o>=s&&o<s+i&&s<e.length,l=o%n.length;return M(t,{color:c?r[l]:n[l],children:a},o)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),M(t,{children:e}))}const wr=P.cwd();function Tr({theme:n}){let{ccVersion:r}=u($);return N(e,{flexDirection:`column`,paddingLeft:1,children:[M(e,{marginBottom:1,children:N(t,{bold:!0,children:[`Preview: `,n.name]})}),M(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:N(e,{flexDirection:`column`,children:[N(e,{flexDirection:`column`,children:[N(t,{children:[M(Q,{color:n.colors.clawd_body,children:` ▐`}),M(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`▛███▜`}),N(t,{children:[M(Q,{color:n.colors.clawd_body,children:`▌ `}),` `,M(t,{bold:!0,children:`Claude Code`}),` `,r?`v${r}`:`v2.0.14`]})]}),N(t,{children:[M(Q,{color:n.colors.clawd_body,children:`▝▜`}),M(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`█████`}),M(Q,{color:n.colors.clawd_body,children:`▛▘`}),` `,Gn(),` · `,Wn()]}),N(Q,{color:n.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,wr]}),N(t,{children:[N(Q,{color:n.colors.success,children:[`Login successful. Press`,` `]}),M(Q,{bold:!0,color:n.colors.success,children:`Enter`}),N(Q,{color:n.colors.success,children:[` `,`to continue…`]})]})]}),M(t,{children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),N(t,{children:[`│ 2`,` `,M(Q,{backgroundColor:n.colors.diffRemoved,color:n.colors.text,children:`- console.log("`}),M(Q,{backgroundColor:n.colors.diffRemovedWord,children:`Hello, World!`}),M(Q,{backgroundColor:n.colors.diffRemoved,children:`");`}),` `,`│`]}),N(t,{children:[`│ 2`,` `,M(Q,{backgroundColor:n.colors.diffAdded,color:n.colors.text,children:`+ console.log("`}),M(Q,{backgroundColor:n.colors.diffAddedWord,children:`Hello, Claude!`}),M(Q,{backgroundColor:n.colors.diffAdded,children:`");`}),` `,`│`]}),M(Q,{color:n.colors.warning,children:`╭─────────────────────────────────────────────╮`}),N(Q,{color:n.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),N(t,{children:[M(Q,{color:n.colors.warning,children:`│ `}),M(t,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),N(Q,{color:n.colors.warning,children:[` `,`│`]})]}),M(Q,{color:n.colors.bashBorder,children:`───────────────────────────────────────────────`}),N(t,{children:[M(Q,{color:n.colors.bashBorder,children:`!`}),M(t,{children:` ls`})]}),M(Q,{color:n.colors.promptBorder,children:`───────────────────────────────────────────────`}),M(t,{children:N(t,{children:[`> list the dir`,` `,M(Cr,{text:`ultrathink`,nonShimmerColors:[n.colors.rainbow_red,n.colors.rainbow_orange,n.colors.rainbow_yellow,n.colors.rainbow_green,n.colors.rainbow_blue,n.colors.rainbow_indigo,n.colors.rainbow_violet],shimmerColors:[n.colors.rainbow_red_shimmer,n.colors.rainbow_orange_shimmer,n.colors.rainbow_yellow_shimmer,n.colors.rainbow_green_shimmer,n.colors.rainbow_blue_shimmer,n.colors.rainbow_indigo_shimmer,n.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),M(Q,{color:n.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[M(Q,{color:n.colors.planMode,children:`│ `}),N(Q,{color:n.colors.permission,children:[`Ready to code?`,` `]}),M(t,{children:`Here is Claude's plan:`}),N(Q,{color:n.colors.planMode,children:[` `,`│`]})]}),M(Q,{color:n.colors.permission,children:`╭─────────────────────────────────────────────╮`}),N(t,{children:[M(Q,{color:n.colors.permission,children:`│ `}),M(t,{bold:!0,children:`Permissions:`}),` `,N(Q,{backgroundColor:n.colors.permission,color:n.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,M(Q,{color:n.colors.permission,children:`│`})]}),M(t,{children:`> list the dir`}),N(t,{children:[M(Q,{color:n.colors.error,children:`●`}),M(t,{children:` Update(__init__.py)`})]}),N(t,{children:[M(t,{children:` ⎿ `}),M(Q,{color:n.colors.error,children:`User rejected update to __init__.py`})]}),N(t,{children:[` `,`1`,` `,N(Q,{backgroundColor:n.colors.diffRemovedDimmed,children:[`- import`,` `]}),M(Q,{backgroundColor:n.colors.diffRemovedWordDimmed,children:`os`})]}),N(t,{children:[` `,`2`,` `,N(Q,{backgroundColor:n.colors.diffAddedDimmed,children:[`+ import`,` `]}),M(Q,{backgroundColor:n.colors.diffAddedWordDimmed,children:`random`})]}),N(t,{children:[M(Q,{color:n.colors.success,children:`●`}),M(t,{children:` List(.)`})]}),N(t,{children:[M(t,{children:`●`}),M(t,{children:` The directory `}),M(Q,{color:n.colors.permission,children:`C:\\Users\\user`}),N(t,{children:[` `,`contains `,M(t,{bold:!0,children:`123`}),` files.`]})]}),N(t,{children:[M(Q,{color:n.colors.claude,children:`✻ Th`}),M(Q,{color:n.colors.claudeShimmer,children:`ink`}),M(Q,{color:n.colors.claude,children:`ing… `}),M(t,{children:`(esc to interrupt)`})]}),M(t,{children:M(Q,{color:n.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),M(t,{children:M(Q,{color:n.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),M(t,{children:M(Q,{color:n.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function Er({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?M(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?M(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):M(Q,{color:r,bold:n,children:e})}function Dr({initialValue:n,onColorChange:i,onExit:a,colorKey:o,theme:c}){let l=kr(n)||{h:0,s:50,l:50},u=Or(n)||{r:128,g:128,b:128},[f,p]=m(l),[h,g]=m(u),[_,v]=m(`hsl`),[y,b]=m(`h`),[x,S]=m(!1),[C,w]=m(!1);d(()=>{let e=kr(n),t=Or(n);e&&t&&(S(!0),p(e),g(t),S(!1))},[n]),d(()=>{!x&&C&&i(`rgb(${h.r},${h.g},${h.b})`)},[f,h,x,C]),d(()=>{w(!0)},[]);let T=e=>{if(Jn(e)){let t=Yn(e),n=kr(t),r=Or(t);n&&r&&(S(!0),p(n),g(r),S(!1))}};r((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){T(e);return}t.return||t.escape?a():t.ctrl&&e===`a`?(v(e=>e===`hsl`?`rgb`:`hsl`),b(e=>_===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?b(_===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?b(_===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?E(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&E(t.shift||t.ctrl||t.meta?10:1)});let E=e=>{S(!0),_===`hsl`?p(t=>{let n={...t};y===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):y===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):y===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=O(n.h,n.s,n.l);return g({r,g:i,b:a}),n}):g(t=>{let n={...t};return y===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):y===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):y===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),p(D(n.r,n.g,n.b)),n}),S(!1)},D=(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)}},O=(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)]},k=()=>{let e=[],n=[[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 r=0;r<40;r++){let i=r/39*(n.length-1),a=Math.floor(i),o=Math.ceil(i),s=i-a,[c,l,u]=n[a],[d,f,p]=n[o],m=Math.round(c+(d-c)*s),h=Math.round(l+(f-l)*s),g=Math.round(u+(p-u)*s);e.push(M(t,{backgroundColor:`rgb(${m},${h},${g})`,children:` `},r))}return e},A=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,r,f.l);e.push(M(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},ee=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,f.s,r);e.push(M(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},P=()=>{let[e,t,n]=O(f.h,f.s,f.l);return`rgb(${e},${t},${n})`},F=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},te=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${r},${h.g},${h.b})`,children:` `},n))}return e},I=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${h.r},${r},${h.b})`,children:` `},n))}return e},L=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(M(t,{backgroundColor:`rgb(${h.r},${h.g},${r})`,children:` `},n))}return e},R=(e,t)=>Math.round(e/t*39);return N(e,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[N(e,{flexDirection:`column`,children:[M(t,{bold:!0,children:`Color Picker`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),M(t,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),M(t,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),M(t,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),M(t,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),M(t,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),_===`hsl`?N(j,{children:[N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`h`?`yellow`:`white`,children:[y===`h`?`❯ `:` `,`Hue (`,f.h,`°):`]})}),M(e,{children:k().map((e,n)=>M(s,{children:n===R(f.h,360)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`s`?`yellow`:`white`,children:[y===`s`?`❯ `:` `,`Saturation (`,f.s,`%):`]})}),M(e,{children:A().map((e,n)=>M(s,{children:n===R(f.s,100)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`l`?`yellow`:`white`,children:[y===`l`?`❯ `:` `,`Lightness (`,f.l,`%):`]})}),M(e,{children:ee().map((e,n)=>M(s,{children:n===R(f.l,100)?M(t,{children:`|`}):e},n))})]})]}):N(j,{children:[N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`r`?`yellow`:`white`,children:[y===`r`?`❯ `:` `,`Red (`,h.r,`):`]})}),M(e,{children:te().map((e,n)=>M(s,{children:n===R(h.r,255)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`g`?`yellow`:`white`,children:[y===`g`?`❯ `:` `,`Green (`,h.g,`):`]})}),M(e,{children:I().map((e,n)=>M(s,{children:n===R(h.g,255)?M(t,{children:`|`}):e},n))})]}),N(e,{marginBottom:1,children:[M(e,{width:25,children:N(t,{color:y===`b`?`yellow`:`white`,children:[y===`b`?`❯ `:` `,`Blue (`,h.b,`):`]})}),M(e,{children:L().map((e,n)=>M(s,{children:n===R(h.b,255)?M(t,{children:`|`}):e},n))})]})]}),N(e,{marginBottom:1,children:[M(t,{children:`Current: `}),M(t,{backgroundColor:P(),children:` `})]}),N(e,{flexDirection:`row`,justifyContent:`space-between`,children:[N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`Hex `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:F(h.r,h.g,h.b)}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:F(h.r,h.g,h.b)}):M(t,{color:P(),bold:!0,children:F(h.r,h.g,h.b)})]}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`RGB `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):M(t,{color:P(),bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`})]}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:`HSL `}),o?.startsWith(`diff`)?M(t,{backgroundColor:P(),color:c?.colors?.text||`white`,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):o===`inverseText`?M(t,{color:P(),backgroundColor:c?.colors?.permission,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):M(t,{color:P(),bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`})]})]})]})}function Or(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 kr(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 Ar({onBack:n,themeId:i}){let{settings:{themes:a},updateSettings:o}=u($),[s,c]=m(i),d=a.find(e=>e.id===s)||a[0],[f,p]=m(`rgb`),[h,g]=m(0),[_,v]=m(null),[y,b]=m(null),[x,S]=m(``),[C,w]=m(``),T=l(e=>{o(t=>{let n=t.themes.findIndex(e=>e.id===s);n!==-1&&e(t.themes[n])})},[s,o]),E=e=>{if(h>=2&&Jn(e)){let t=Yn(e),n=D[h-2];T(e=>{e.colors[n]=t})}};r((e,t)=>{if(_===null&&y===null){if(e.length>1&&!t.ctrl&&!t.meta){E(e);return}if(t.escape)n();else if(t.ctrl&&e===`a`)p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(t.upArrow)g(e=>Math.max(0,e-1));else if(t.downArrow)g(e=>Math.min(D.length+1,e+1));else if(t.return)if(h===0)b(`name`),S(d.name),w(d.name);else if(h===1)b(`id`),S(d.id),w(d.id);else{let e=h-2,t=D[e],n=d.colors[t];v(e),S(n),w(n)}}else if(_!==null)t.ctrl&&e===`a`&&p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(y!==null)if(t.return){if(y===`id`){let e=s;c(x),o(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=x)})}else T(e=>{e.name=x});b(null),S(``),w(``)}else t.escape?(b(null),S(``),w(``)):t.backspace||t.delete?S(e=>e.slice(0,-1)):e&&S(t=>t+e)});let D=Object.keys(d.colors),O=(e,t)=>{let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)return e;let r=parseInt(n[1]),i=parseInt(n[2]),a=parseInt(n[3]);switch(t){case`hex`:{let e=e=>e.toString(16).padStart(2,`0`);return`#${e(r)}${e(i)}${e(a)}`}case`hsl`:{let e=r/255,t=i/255,n=a/255,o=Math.max(e,t,n),s=Math.min(e,t,n),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===e?((t-n)/c+(t<n?6:0))/6:o===t?((n-e)/c+2)/6:((e-t)/c+4)/6),`hsl(${Math.round(d*360)}, ${Math.round(u*100)}%, ${Math.round(l*100)}%)`}case`rgb`:default:return e}},k=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]||``,A=Math.max(...D.map(e=>e.length));return N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(X,{children:[`Editing theme “`,d.name,`” (`,d.id,`)`]})}),_===null&&y===null?N(j,{children:[N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`enter to edit theme name, id, or color`}),M(t,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),M(t,{dimColor:!0,children:`paste color from clipboard (when on color)`}),M(t,{dimColor:!0,children:`esc to go back`})]}),h<2?N(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[M(t,{bold:!0,children:h===0?`Theme Name`:`Theme ID`}),M(t,{children:h===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):N(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:d.colors[D[h-2]],flexDirection:`column`,paddingLeft:1,children:[M(Er,{colorKey:D[h-2],theme:d,bold:!0}),M(t,{children:k(D[h-2])})]}),N(e,{flexDirection:`column`,children:[N(e,{children:[M(t,{color:h===0?`yellow`:`white`,children:h===0?`❯ `:` `}),M(t,{bold:!0,children:`Name: `}),M(t,{children:d.name})]}),N(e,{marginBottom:1,children:[M(t,{color:h===1?`yellow`:`white`,children:h===1?`❯ `:` `}),M(t,{bold:!0,children:`ID: `}),M(t,{children:d.id})]}),(()=>{if(h<2)return N(j,{children:[D.slice(0,20).map((n,r)=>{let i=r+2;return N(e,{children:[M(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),M(e,{width:A+2,children:M(t,{children:M(Er,{colorKey:n,theme:d,bold:!0})})}),M(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),D.length>20&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let n=h-2,r=Math.max(0,n-10),i=Math.min(D.length,r+20),a=Math.max(0,i-20),o=D.slice(a,i);return N(j,{children:[a>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,a,` more above`]}),o.map((n,r)=>{let i=a+r+2;return N(e,{children:[M(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),M(e,{width:A+2,children:M(t,{children:M(Er,{colorKey:n,theme:d,bold:!0})})}),M(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),i<D.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-i,` more below`]})]})})()]})]}):y?N(e,{flexDirection:`column`,marginTop:1,children:[N(t,{children:[`Editing `,y===`name`?`theme name`:`theme ID`,`:`]}),M(e,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:M(t,{children:x})}),M(t,{dimColor:!0,children:`enter to save, esc to cancel`})]}):M(Dr,{initialValue:C,colorKey:D[_],theme:d,onColorChange:e=>{S(e),T(t=>{t.colors[D[_]]=e})},onExit:()=>{T(e=>{e.colors[D[_]]=x}),v(null),S(``),w(``)}})]}),M(e,{width:`50%`,children:M(Tr,{theme:d})})]})}function jr(e){return e.map(e=>`${e.name} (${e.id})`)}function Mr({onBack:n}){let{settings:{themes:i},updateSettings:a}=u($),[o,s]=m(0),[c,l]=m(null),[d,f]=m(!0),p=()=>{let e={colors:{...(i[0]||K.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};a(t=>{t.themes.push(e)}),l(e.id),f(!1)},h=e=>{i.length<=1||(a(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),o>=i.length-1&&s(Math.max(0,i.length-2)))},g=()=>{a(e=>{e.themes=[...K.themes]}),s(0)};if(r((e,t)=>{if(t.escape)n();else if(t.upArrow)s(e=>Math.max(0,e-1));else if(t.downArrow)s(e=>Math.min(i.length-1,e+1));else if(t.return){let e=i[o];e&&(l(e.id),f(!1))}else if(e===`n`)p();else if(e===`d`){let e=i[o];e&&h(e.id)}else t.ctrl&&e===`r`&&g()},{isActive:d}),c)return M(Ar,{themeId:c,onBack:()=>{l(null),f(!0)}});let _=jr(i),v=i.find(e=>_[o]?.includes(`(${e.id})`))||i[0];return i.length===0?M(e,{children:N(e,{flexDirection:`column`,width:`100%`,children:[M(X,{children:`Themes`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new theme`}),M(t,{dimColor:!0,children:`esc to go back`})]}),M(t,{children:`No themes available!`})]})}):N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(X,{children:`Themes`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new theme`}),M(t,{dimColor:!0,children:`d to delete a theme`}),M(t,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),M(t,{dimColor:!0,children:`enter to edit theme`}),M(t,{dimColor:!0,children:`esc to go back`})]}),M(e,{flexDirection:`column`,children:_.map((e,n)=>N(t,{color:o===n?`yellow`:void 0,children:[o===n?`❯ `:` `,e]},n))})]}),M(e,{width:`50%`,children:M(Tr,{theme:v})})]})}function Nr({onBack:n}){let{settings:{thinkingVerbs:{format:i,verbs:a},themes:o},updateSettings:s}=u($),c=[`format`,`verbs`],[l,d]=m(0),f=c[l],[p,h]=m(0),[g,_]=m(!1),[v,y]=m(``),[b,x]=m(!1),[S,C]=m(!1),[w,T]=m(i),E=Un(),D=(o.find(e=>e.id===E)||o.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return r((e,t)=>{if(S){t.return?(s(e=>{e.thinkingVerbs.format=w}),C(!1)):t.escape?(T(i),C(!1)):t.backspace||t.delete?T(e=>e.slice(0,-1)):e&&T(t=>t+e);return}if(g||b){t.return&&v.trim()?(b?(s(e=>{e.thinkingVerbs.verbs.push(v.trim())}),x(!1)):(s(e=>{e.thinkingVerbs.verbs[p]=v.trim()}),_(!1)),y(``)):t.escape?(y(``),_(!1),x(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&y(t=>t+e);return}t.escape?n():t.return?f===`format`&&(T(i),C(!0)):t.tab?t.shift?d(e=>e===0?c.length-1:e-1):d(e=>e===c.length-1?0:e+1):t.upArrow?f===`verbs`&&a.length>0&&h(e=>e>0?e-1:a.length-1):t.downArrow?f===`verbs`&&a.length>0&&h(e=>e<a.length-1?e+1:0):e===`e`&&f===`verbs`?a.length>0&&(y(a[p]),_(!0)):e===`d`&&f===`verbs`?a.length>1&&(s(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==p)}),p>=a.length-1&&h(Math.max(0,a.length-2))):e===`n`&&f===`verbs`?(x(!0),y(``)):t.ctrl&&e===`r`&&f===`verbs`&&(s(e=>{e.thinkingVerbs.verbs=[...K.thinkingVerbs.verbs]}),h(0))}),N(e,{children:[N(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,flexDirection:`column`,children:[M(X,{children:`Thinking Verbs`}),N(e,{flexDirection:`column`,children:[M(t,{dimColor:!0,children:f===`format`?`enter to edit format`:`changes auto-saved`}),M(t,{dimColor:!0,children:`esc to go back`}),M(t,{dimColor:!0,children:`tab to switch sections`})]})]}),M(e,{marginBottom:1,children:M(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:f===`format`?`yellow`:void 0,children:f===`format`?`❯ `:` `}),M(t,{bold:!0,color:f===`format`?`yellow`:void 0,children:`Format`})]}),f===`format`&&(S?N(t,{dimColor:!0,children:[` `,`enter to save`]}):N(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:S?`yellow`:`gray`,children:M(t,{children:S?w:i})})}),M(e,{children:N(t,{children:[M(t,{color:f===`verbs`?`yellow`:void 0,children:f===`verbs`?`❯ `:` `}),M(t,{bold:!0,color:f===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),f===`verbs`&&M(e,{flexDirection:`column`,children:N(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),M(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,p-4),n=Math.min(a.length,e+8),r=Math.max(0,n-8),i=a.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return N(t,{color:f===`verbs`&&i===p?`cyan`:void 0,children:[f===`verbs`&&i===p?`❯ `:` `,e]},i)}),n<a.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),b&&N(e,{alignItems:`center`,children:[M(t,{color:`yellow`,children:`❯ `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:v})})]}),g&&N(e,{marginTop:1,alignItems:`center`,children:[M(t,{children:`Editing: `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:v})})]})]})})]}),N(e,{width:`50%`,flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,children:`Preview`})}),M(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:N(t,{children:[N(t,{color:D,children:[`✻ `,i.replace(/\{\}/g,a[p]),` `]}),M(t,{children:`(esc to interrupt)`})]})})]})]})}const Pr=[{name:`Default`,phases:K.thinkingStyle.phases,reverseMirror:K.thinkingStyle.reverseMirror},{name:`Basic`,phases:[`|`,`/`,`-`,`\\`],reverseMirror:!1},{name:`Braille`,phases:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],reverseMirror:!1},{name:`Circle`,phases:[`◐`,`◓`,`◑`,`◒`],reverseMirror:!1},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Clock`,phases:[`🕛`,`🕐`,`🕑`,`🕒`,`🕓`,`🕔`,`🕕`,`🕖`,`🕗`,`🕘`,`🕙`,`🕚`],reverseMirror:!1},{name:`Globe`,phases:[`🌍`,`🌎`,`🌏`],reverseMirror:!1},{name:`Arc`,phases:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`],reverseMirror:!1},{name:`Triangle`,phases:[`◤`,`◥`,`◢`,`◣`],reverseMirror:!1},{name:`Bouncing`,phases:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`],reverseMirror:!1},{name:`Dots`,phases:[`.`,`..`,`...`],reverseMirror:!1},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1}];function Fr({onBack:n}){let{settings:{thinkingStyle:{phases:i,updateInterval:a,reverseMirror:o},themes:s},updateSettings:c}=u($),l=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[f,p]=m(0),h=l[f],[g,_]=m(0),[v,y]=m(0),[b,x]=m(!1),[S,C]=m(``),[w,T]=m(!1),[E,D]=m(!1),[O,k]=m(a.toString()),[A,ee]=m(0),P=Un(),F=(s.find(e=>e.id===P)||s.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;d(()=>{if(i.length>0){let e=o?[...i,...[...i].reverse().slice(1,-1)]:i,t=setInterval(()=>{ee(t=>(t+1)%e.length)},a);return()=>clearInterval(t)}},[i,a,o]),r((e,t)=>{if(E){if(t.return){let e=parseInt(O);!isNaN(e)&&e>0&&c(t=>{t.thinkingStyle.updateInterval=e}),D(!1)}else t.escape?(k(a.toString()),D(!1)):t.backspace||t.delete?k(e=>e.slice(0,-1)):e&&e.match(/^[0-9]$/)&&k(t=>t+e);return}if(b||w){if(t.return&&S.length){let e=w?[...i,S]:i.map((e,t)=>t===g?S:e);c(t=>{t.thinkingStyle.phases=e}),x(!1),C(``)}else t.escape?(C(``),x(!1),T(!1)):t.backspace||t.delete?C(e=>e.slice(0,-1)):e&&C(t=>t+e);return}if(t.escape)n();else if(t.return)if(h===`updateInterval`)k(a.toString()),D(!0);else if(h===`presets`){let e=Pr[v];c(t=>{t.thinkingStyle.phases=[...e.phases],t.thinkingStyle.reverseMirror=e.reverseMirror})}else h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(t.tab)t.shift?p(e=>e===0?l.length-1:e-1):p(e=>e===l.length-1?0:e+1);else if(t.upArrow)h===`phases`&&i.length>0?_(e=>e>0?e-1:i.length-1):h===`presets`&&y(e=>e>0?e-1:Pr.length-1);else if(t.downArrow)h===`phases`&&i.length>0?_(e=>e<i.length-1?e+1:0):h===`presets`&&y(e=>e<Pr.length-1?e+1:0);else if(e===` `)h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(e===`e`&&h===`phases`)i.length>0&&(C(i[g]),x(!0));else if(e===`a`&&h===`phases`)T(!0),C(``);else if(e===`d`&&h===`phases`)i.length>1&&(c(e=>{e.thinkingStyle.phases=i.filter((e,t)=>t!==g)}),g>=i.length&&_(Math.max(0,i.length-1)));else if(e===`w`&&h===`phases`){if(g>0){let e=[...i];[e[g-1],e[g]]=[e[g],e[g-1]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e-1)}}else if(e===`s`&&h===`phases`){if(g<i.length-1){let e=[...i];[e[g],e[g+1]]=[e[g+1],e[g]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e+1)}}else t.ctrl&&e===`r`&&(c(e=>{e.thinkingStyle=K.thinkingStyle}),_(0),y(0))});let te=o?`●`:`○`,I=(()=>o?[...i,...[...i].reverse().slice(1,-1)]:i)(),L=I.length>0?I[A]:`·`;return M(e,{children:N(e,{flexDirection:`column`,width:`100%`,children:[N(e,{flexDirection:`row`,width:`100%`,children:[N(e,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[M(X,{children:`Thinking style`}),N(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:[`enter to`,` `,h===`updateInterval`?`edit interval`:h===`presets`?`apply preset`:`save`]}),M(t,{dimColor:!0,children:`esc to go back`}),M(t,{dimColor:!0,children:`tab to switch sections`})]})]}),N(e,{width:`50%`,flexDirection:`column`,children:[M(e,{children:M(t,{bold:!0,children:`Preview`})}),N(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[M(e,{width:(L?.length??0)+1,children:M(t,{color:F,children:L})}),N(t,{children:[M(t,{color:F,children:`Thinking… `}),M(t,{children:`(esc to interrupt)`})]})]})]})]}),N(e,{flexDirection:`row`,gap:4,children:[N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:h===`reverseMirror`?`yellow`:void 0,children:h===`reverseMirror`?`❯ `:` `}),M(t,{bold:!0,color:h===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),h===`reverseMirror`&&N(t,{dimColor:!0,children:[` `,`space to toggle`]}),M(e,{marginLeft:2,marginBottom:1,children:N(t,{children:[te,` `,o?`Enabled`:`Disabled`]})})]}),N(e,{flexDirection:`column`,children:[N(t,{children:[M(t,{color:h===`updateInterval`?`yellow`:void 0,children:h===`updateInterval`?`❯ `:` `}),M(t,{bold:!0,color:h===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),h===`updateInterval`&&(E?N(t,{dimColor:!0,children:[` `,`enter to save`]}):N(t,{dimColor:!0,children:[` `,`enter to edit`]})),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:M(t,{children:E?O:a})})})]})]}),M(e,{children:N(t,{children:[M(t,{color:h===`phases`?`yellow`:void 0,children:h===`phases`?`❯ `:` `}),M(t,{bold:!0,color:h===`phases`?`yellow`:void 0,children:`Phases`})]})}),h===`phases`&&M(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),M(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,g-4),n=Math.min(i.length,e+8),r=Math.max(0,n-8),a=i.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return N(t,{color:h===`phases`&&i===g?`cyan`:void 0,children:[h===`phases`&&i===g?`❯ `:` `,e]},i)}),n<i.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),w&&N(e,{children:[M(t,{color:`yellow`,children:`❯ `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:S})})]}),b&&N(e,{marginTop:1,children:[M(t,{children:`Editing: `}),M(e,{borderStyle:`round`,borderColor:`yellow`,children:M(t,{children:S})})]})]})}),M(e,{children:N(t,{children:[M(t,{color:h===`presets`?`yellow`:void 0,children:h===`presets`?`❯ `:` `}),M(t,{bold:!0,color:h===`presets`?`yellow`:void 0,children:`Presets`})]})}),h===`presets`&&N(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,v-4),n=Math.min(Pr.length,e+8),r=Math.max(0,n-8),i=Pr.slice(r,n);return N(j,{children:[r>0&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return N(t,{color:h===`presets`&&i===v?`cyan`:void 0,children:[h===`presets`&&i===v?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<Pr.length&&N(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,Pr.length-n,` more below`]})]})})()})}),M(e,{marginTop:1,children:M(t,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function Ir(e,t){let n=p(!0);d(()=>{if(n.current){n.current=!1;return}return e()},t)}const Lr=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Rr=[{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 zr({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(!1),[c,l]=m(!1),[d,f]=m(!1),[p,h]=m(()=>i.userMessageDisplay.format),[g,_]=m(()=>String(i.userMessageDisplay.paddingX)),[v,y]=m(()=>String(i.userMessageDisplay.paddingY)),[b,x]=m(i.userMessageDisplay.fitBoxToContent),[S,C]=m(0),[w,T]=m(()=>[...i.userMessageDisplay.styling]),[E,D]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[O,k]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:i.userMessageDisplay.foregroundColor),[A,ee]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[j,P]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[F,te]=m(()=>Rr.findIndex(e=>e.value===i.userMessageDisplay.borderStyle)),[I,L]=m(()=>i.userMessageDisplay.borderColor),[R,ne]=m(null),[re,ie]=m(``),ae=Un(),z=i.themes?.find(e=>e.id===ae)||i.themes?.[0],[oe,se]=m(`text`),ce=[`format`,`styling`,`foreground`,`background`],le=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[ue,de]=m(0),[fe,pe]=m(0),B=oe===`text`?ce[ue]:le[fe],me=()=>{a(e=>{e.userMessageDisplay.format=p,e.userMessageDisplay.styling=[...w],e.userMessageDisplay.foregroundColor=E===`default`?`default`:O,e.userMessageDisplay.backgroundColor=A===`none`?null:A===`default`?`default`:j,e.userMessageDisplay.borderStyle=Rr[F].value,e.userMessageDisplay.borderColor=I,e.userMessageDisplay.paddingX=parseInt(g)||0,e.userMessageDisplay.paddingY=parseInt(v)||0,e.userMessageDisplay.fitBoxToContent=b})},he=()=>{h(K.userMessageDisplay.format),T([...K.userMessageDisplay.styling]),D(`default`),k(`rgb(255,255,255)`),ee(`none`),P(`rgb(0,0,0)`),te(Rr.findIndex(e=>e.value===K.userMessageDisplay.borderStyle)),L(K.userMessageDisplay.borderColor),_(String(K.userMessageDisplay.paddingX)),y(String(K.userMessageDisplay.paddingY)),x(K.userMessageDisplay.fitBoxToContent),a(e=>{e.userMessageDisplay={...K.userMessageDisplay}})};Ir(()=>{me()},[p,w,E,O,A,j,F,I,g,v,b]),r((e,t)=>{if(o){t.return?s(!1):t.escape?(h(i.userMessageDisplay.format),s(!1)):t.backspace||t.delete?h(e=>e.slice(0,-1)):e&&h(t=>t+e);return}if(c){t.return?l(!1):t.escape?(_(String(i.userMessageDisplay.paddingX)),l(!1)):t.backspace||t.delete?_(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&_(t=>t+e);return}if(d){t.return?f(!1):t.escape?(y(String(i.userMessageDisplay.paddingY)),f(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&y(t=>t+e);return}if(R===null){if(t.escape)n();else if(t.ctrl&&e===`r`)he();else if(t.leftArrow||t.rightArrow)se(e=>e===`text`?`border`:`text`);else if(t.tab)oe===`text`?t.shift?de(e=>e===0?ce.length-1:e-1):de(e=>e===ce.length-1?0:e+1):t.shift?pe(e=>e===0?le.length-1:e-1):pe(e=>e===le.length-1?0:e+1);else if(t.return)B===`format`?s(!0):B===`paddingX`?l(!0):B===`paddingY`?f(!0):B===`foreground`?E===`custom`&&(ie(O),ne(`foreground`)):B===`background`?A===`custom`&&(ie(j),ne(`background`)):B===`borderColor`&&(ie(I),ne(`border`));else if(t.upArrow)B===`styling`?C(e=>Math.max(0,e-1)):B===`borderStyle`?te(e=>e===0?Rr.length-1:e-1):B===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):B===`background`&&ee(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!j||j===``)&&P(`rgb(0,0,0)`),t});else if(t.downArrow)B===`styling`?C(e=>Math.min(Lr.length-1,e+1)):B===`borderStyle`?te(e=>e===Rr.length-1?0:e+1):B===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):B===`background`&&ee(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!j||j===``)&&P(`rgb(0,0,0)`),t});else if(e===` `)if(B===`styling`){let e=Lr[S].value;T(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else B===`fitBoxToContent`&&x(e=>!e)}});let ge=n=>{let r=E===`default`?z?.colors?.text:O,i=A===`none`?void 0:A===`default`?z?.colors?.userMessageBackground:j,a=Rr[F].value,o=parseInt(g)||0,s=parseInt(v)||0,c=M(t,{bold:w.includes(`bold`),italic:w.includes(`italic`),underline:w.includes(`underline`),strikethrough:w.includes(`strikethrough`),inverse:w.includes(`inverse`),color:r,backgroundColor:i,children:n});if(a===`topBottomSingle`||a===`topBottomDouble`||a===`topBottomBold`){let r=a===`topBottomSingle`?`─`:a===`topBottomDouble`?`═`:`━`,i=n.length+o*2,l=r.repeat(i);return N(e,{flexDirection:`column`,children:[M(t,{color:I,children:l}),s>0&&M(e,{height:s}),M(e,{paddingX:o,children:c}),s>0&&M(e,{height:s}),M(t,{color:I,children:l})]})}else if(a!==`none`||o>0||s>0||b){let t=o>0||s>0?M(e,{paddingX:o,paddingY:s,children:c}):c,n={};return a!==`none`&&(n.borderStyle=a,n.borderColor=I),b?n.alignSelf=`flex-start`:n.flexGrow=1,a===`none`?t:M(e,{...n,children:t})}else return c};return R?M(Dr,{initialValue:re,theme:z,onColorChange:e=>{R===`foreground`?k(e):R===`background`?P(e):R===`border`&&L(e)},onExit:()=>{ne(null),ie(``)}}):N(e,{flexDirection:`column`,children:[M(X,{children:`Customize how user messages are displayed`}),N(e,{flexDirection:`column`,marginBottom:1,children:[M(t,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),M(t,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),N(e,{flexDirection:`row`,gap:1,children:[N(e,{flexDirection:`column`,width:`50%`,borderStyle:oe===`text`?`round`:`single`,borderColor:oe===`text`?`yellow`:`gray`,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,color:oe===`text`?`yellow`:void 0,children:`Text & Styling`})}),M(e,{children:N(t,{color:B===`format`?`yellow`:void 0,bold:B===`format`,children:[B===`format`?`❯ `:` `,`Format String`]})}),B===`format`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:o?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),M(e,{marginLeft:2,marginBottom:1,children:M(e,{borderStyle:`round`,borderColor:o?`yellow`:`gray`,children:M(t,{children:p})})}),M(e,{children:N(t,{color:B===`styling`?`yellow`:void 0,bold:B===`styling`,children:[B===`styling`?`❯ `:` `,`Styling`]})}),B===`styling`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),M(e,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Lr.map((n,r)=>M(e,{children:N(t,{color:B===`styling`&&S===r?`cyan`:void 0,children:[B===`styling`&&S===r?`❯ `:` `,w.includes(n.value)?`●`:`○`,` `,n.label]})},n.value))}),N(e,{flexDirection:`row`,gap:1,marginBottom:1,children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(t,{color:B===`foreground`?`yellow`:void 0,bold:B===`foreground`,children:[B===`foreground`?`❯ `:` `,`Foreground`]})}),B===`foreground`&&M(e,{marginLeft:2,children:N(t,{dimColor:!0,children:[`up/down · `,E===`custom`?`enter`:``]})}),N(e,{marginLeft:2,flexDirection:`column`,children:[M(e,{children:N(t,{children:[E===`default`?`● `:`○ `,`Default`]})}),M(e,{children:N(t,{children:[E===`custom`?`● `:`○ `,`Custom`,E===`custom`&&`: `,E===`custom`&&M(t,{color:O,children:O})]})})]})]}),N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{children:N(t,{color:B===`background`?`yellow`:void 0,bold:B===`background`,children:[B===`background`?`❯ `:` `,`Background`]})}),B===`background`&&M(e,{marginLeft:2,children:N(t,{dimColor:!0,children:[`up/down · `,A===`custom`?`enter`:``]})}),N(e,{marginLeft:2,flexDirection:`column`,children:[M(e,{children:N(t,{children:[A===`default`?`● `:`○ `,`Default`]})}),M(e,{children:N(t,{children:[A===`none`?`● `:`○ `,`None`]})}),M(e,{children:N(t,{children:[A===`custom`?`● `:`○ `,`Custom`,A===`custom`&&`: `,A===`custom`&&M(t,{backgroundColor:j,children:j})]})})]})]})]})]}),N(e,{flexDirection:`column`,width:`50%`,borderStyle:oe===`border`?`round`:`single`,borderColor:oe===`border`?`yellow`:`gray`,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,color:oe===`border`?`yellow`:void 0,children:`Border & Padding`})}),M(e,{children:N(t,{color:B===`borderStyle`?`yellow`:void 0,bold:B===`borderStyle`,children:[B===`borderStyle`?`❯ `:` `,`Border Style`]})}),B===`borderStyle`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`up/down to navigate`})}),N(e,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[M(e,{flexDirection:`column`,width:`50%`,children:Rr.slice(0,6).map((n,r)=>M(e,{children:N(t,{color:B===`borderStyle`&&F===r?`cyan`:void 0,children:[B===`borderStyle`&&F===r?`❯ `:` `,F===r?`● `:`○ `,n.label]})},n.value))}),M(e,{flexDirection:`column`,width:`50%`,children:Rr.slice(6).map((n,r)=>{let i=r+6;return M(e,{children:N(t,{color:B===`borderStyle`&&F===i?`cyan`:void 0,children:[B===`borderStyle`&&F===i?`❯ `:` `,F===i?`● `:`○ `,n.label]})},n.value)})})]}),M(e,{children:N(t,{color:B===`borderColor`?`yellow`:void 0,bold:B===`borderColor`,children:[B===`borderColor`?`❯ `:` `,`Border Color`]})}),B===`borderColor`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`enter to pick color`})}),M(e,{marginLeft:2,marginBottom:1,children:M(t,{color:I,children:I})}),N(e,{flexDirection:`row`,gap:1,children:[N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`paddingX`?`yellow`:void 0,bold:B===`paddingX`,children:[B===`paddingX`?`❯ `:` `,`Padding X`]})}),B===`paddingX`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:c?`enter/esc`:`enter`})}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:c?`yellow`:`gray`,children:M(t,{children:g})})})]}),N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`paddingY`?`yellow`:void 0,bold:B===`paddingY`,children:[B===`paddingY`?`❯ `:` `,`Padding Y`]})}),B===`paddingY`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:d?`enter/esc`:`enter`})}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:d?`yellow`:`gray`,children:M(t,{children:v})})})]}),N(e,{flexDirection:`column`,width:`33%`,children:[M(e,{children:N(t,{color:B===`fitBoxToContent`?`yellow`:void 0,bold:B===`fitBoxToContent`,children:[B===`fitBoxToContent`?`❯ `:` `,b?`●`:`○`,` Fit box to content`]})}),B===`fitBoxToContent`&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`space`})})]})]})]})]}),N(e,{flexDirection:`column`,marginTop:1,paddingX:1,children:[M(e,{marginBottom:1,children:M(t,{bold:!0,children:`Preview`})}),N(e,{flexDirection:`row`,gap:2,children:[N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{marginBottom:1,children:M(t,{underline:!0,children:`Before (Claude Code default):`})}),M(e,{marginLeft:1,children:N(t,{backgroundColor:z?.colors?.userMessageBackground,color:z?.colors?.text,children:[` `,`> list the dir`,` `]})}),M(e,{marginLeft:1,marginTop:1,children:N(t,{children:[M(t,{color:z?.colors?.inactive||`#888888`,children:`●`}),M(t,{children:` The directory `}),M(t,{color:z?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),M(t,{children:` contains `}),M(t,{bold:!0,children:`123`}),M(t,{children:` files.`})]})})]}),N(e,{flexDirection:`column`,width:`50%`,children:[M(e,{marginBottom:1,children:M(t,{underline:!0,children:`After (Your customization):`})}),M(e,{marginLeft:1,flexDirection:`row`,children:(()=>ge(p.replace(/\{\}/g,`list the dir`)))()}),M(e,{marginLeft:1,marginTop:1,children:N(t,{children:[M(t,{color:z?.colors?.inactive||`#888888`,children:`●`}),M(t,{children:` The directory `}),M(t,{color:z?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),M(t,{children:` contains `}),M(t,{bold:!0,children:`123`}),M(t,{children:` files.`})]})})]})]})]})]})}function Br({onSubmit:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(0),c={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1},l=()=>{i.misc||={...c}},d=f(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>i.inputBox?.removeBorder??!1,toggle:()=>{a(e=>{e.inputBox||={removeBorder:!1},e.inputBox.removeBorder=!e.inputBox.removeBorder})}},{id:`showVersion`,title:`Show tweakcc version at startup`,description:`Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.`,getValue:()=>i.misc?.showTweakccVersion??!0,toggle:()=>{a(e=>{l(),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:()=>i.misc?.showPatchesApplied??!0,toggle:()=>{a(e=>{l(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>i.misc?.expandThinkingBlocks??!0,toggle:()=>{a(e=>{l(),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:()=>i.misc?.enableConversationTitle??!0,toggle:()=>{a(e=>{l(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>i.misc?.hideStartupBanner??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.hideCtrlGToEdit??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.hideStartupClawd??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.increaseFileReadLimit??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.suppressLineNumbers??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.suppressRateLimitOptions??!1,toggle:()=>{a(e=>{l(),e.misc.suppressRateLimitOptions=!e.misc.suppressRateLimitOptions})}}],[i,a]),p=d.length,h=p-1,g=f(()=>o<4?0:Math.min(o-4+1,p-4),[o,p]),_=d.slice(g,g+4),v=g>0,y=g+4<p;return r((e,t)=>{t.return||t.escape?n():t.upArrow?s(e=>Math.max(0,e-1)):t.downArrow?s(e=>Math.min(h,e+1)):e===` `&&d[o]?.toggle()}),N(e,{flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(X,{children:`Miscellaneous Settings`})}),M(e,{marginBottom:1,children:M(t,{dimColor:!0,children:`Various tweaks and customizations. Press space to toggle settings, enter to go back.`})}),v&&M(e,{children:N(t,{dimColor:!0,children:[` ↑ `,g,` more above`]})}),_.map((n,r)=>{let i=g+r===o,a=n.getValue()?`☑`:`☐`;return N(e,{flexDirection:`column`,children:[M(e,{children:N(t,{children:[M(t,{color:i?`cyan`:void 0,children:i?`❯ `:` `}),M(t,{bold:!0,color:i?`cyan`:void 0,children:n.title})]})}),M(e,{children:N(t,{dimColor:!0,children:[` `,n.description]})}),M(e,{marginLeft:4,marginBottom:1,children:N(t,{children:[a,` `,n.getValue()?`Enabled`:`Disabled`]})})]},n.id)}),y&&M(e,{children:N(t,{dimColor:!0,children:[` `,`↓ `,p-g-4,` more below`]})}),M(e,{marginTop:1,children:N(t,{dimColor:!0,children:[`Item `,o+1,` of `,p]})})]})}const Vr=[`Task`,`Bash`,`Glob`,`Grep`,`Read`,`Edit`,`Write`,`NotebookEdit`,`WebFetch`,`WebSearch`,`BashOutput`,`KillShell`,`TodoWrite`,`AskUserQuestion`,`Skill`,`SlashCommand`,`EnterPlanMode`,`ExitPlanMode`,`LSP`];function Hr({toolsetIndex:n,onBack:i}){let{settings:a,updateSettings:o}=u($),s=a.toolsets[n],[c,l]=m(s?.name||`New Toolset`),[f,p]=m(s?.allowedTools||[]),[h,g]=m(!1),[_,v]=m(0);d(()=>{s&&o(e=>{let t=e.toolsets[n].name;e.toolsets[n].name=c,e.toolsets[n].allowedTools=f,t!==c&&(e.defaultToolset===t&&(e.defaultToolset=c),e.planModeToolset===t&&(e.planModeToolset=c))})},[c,f]);let y=e=>f===`*`?!0:f.includes(e),b=e=>{e===`All`?p(`*`):e===`None`?p([]):f===`*`?p(Vr.filter(t=>t!==e)):f.includes(e)?p(f.filter(t=>t!==e)):p([...f,e])};if(r((e,t)=>{if(h){t.return?g(!1):t.escape?(l(s?.name||`New Toolset`),g(!1)):t.backspace||t.delete?l(e=>e.slice(0,-1)):e&&e.length===1&&l(t=>t+e);return}if(t.escape)i();else if(t.upArrow)v(e=>Math.max(0,e-1));else if(t.downArrow)v(e=>Math.min(Vr.length+1,e+1));else if(e===` `||t.return)if(_===0)b(`All`);else if(_===1)b(`None`);else{let e=Vr[_-2];e&&b(e)}else e===`n`&&g(!0)}),!s)return M(e,{flexDirection:`column`,children:M(t,{color:`red`,children:`Toolset not found`})});let x=f===`*`,S=Array.isArray(f)&&f.length===0;return N(e,{flexDirection:`column`,children:[M(X,{children:`Edit Toolset`}),M(e,{marginBottom:1,flexDirection:`column`,children:M(t,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{bold:!0,children:`Name:`}),M(e,{marginLeft:2,children:M(e,{borderStyle:`round`,borderColor:h?`yellow`:`gray`,children:M(t,{children:c})})}),h&&M(e,{marginLeft:2,children:M(t,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{bold:!0,children:`Allowed Tools:`}),M(e,{marginLeft:2,children:N(t,{color:_===0?`cyan`:void 0,children:[_===0?`❯ `:` `,x?`●`:`○`,` All`]})}),M(e,{marginLeft:2,children:N(t,{color:_===1?`cyan`:void 0,children:[_===1?`❯ `:` `,S?`●`:`○`,` None`]})}),Vr.map((n,r)=>{let i=r+2;return M(e,{marginLeft:2,children:N(t,{color:_===i?`cyan`:void 0,children:[_===i?`❯ `:` `,y(n)?`◉`:`○`,` `,n]})},n)})]}),M(e,{borderStyle:`round`,padding:1,marginTop:1,children:N(e,{flexDirection:`column`,children:[M(t,{bold:!0,children:`Summary:`}),N(t,{children:[`Name: `,M(t,{color:`cyan`,children:c})]}),N(t,{children:[`Tools:`,` `,f===`*`?M(t,{color:`green`,children:`All tools (*)`}):f.length===0?M(t,{color:`red`,children:`No tools ([])`}):N(t,{color:`yellow`,children:[f.length,` selected`]})]})]})})]})}function Ur({onBack:n}){let{settings:{toolsets:i,defaultToolset:a,planModeToolset:o,themes:s},updateSettings:c}=u($),l=Un(),d=s.find(e=>e.id===l)||s[0],f=K.themes[0],p=d?.colors.planMode||f.colors.planMode,h=d?.colors.autoAccept||f.colors.autoAccept,[g,_]=m(0),[v,y]=m(null),[b,x]=m(!0),S=()=>{let e={name:`New Toolset`,allowedTools:[]};c(t=>{t.toolsets.push(e)}),y(i.length),x(!1)},C=e=>{let t=i[e];c(n=>{n.toolsets.splice(e,1),n.defaultToolset===t.name&&(n.defaultToolset=null),n.planModeToolset===t.name&&(n.planModeToolset=null)}),g>=i.length-1&&_(Math.max(0,i.length-2))},w=e=>{let t=i[e];c(e=>{e.defaultToolset=t.name})},T=e=>{let t=i[e];c(e=>{e.planModeToolset=t.name})};if(r((e,t)=>{t.escape?n():t.upArrow?_(e=>Math.max(0,e-1)):t.downArrow?_(e=>Math.min(i.length-1,e+1)):t.return&&i.length>0?(y(g),x(!1)):e===`n`?S():e===`x`&&i.length>0?C(g):e===`d`&&i.length>0?w(g):e===`p`&&i.length>0&&T(g)},{isActive:b}),v!==null)return M(Hr,{toolsetIndex:v,onBack:()=>{y(null),x(!0)}});let E=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return N(e,{flexDirection:`column`,children:[M(X,{children:`Toolsets`}),N(e,{marginBottom:1,flexDirection:`column`,children:[M(t,{dimColor:!0,children:`n to create a new toolset`}),i.length>0&&M(t,{dimColor:!0,children:`d to set as default toolset`}),i.length>0&&M(t,{dimColor:!0,children:`p to set as plan mode toolset`}),i.length>0&&M(t,{dimColor:!0,children:`x to delete a toolset`}),i.length>0&&M(t,{dimColor:!0,children:`enter to edit toolset`}),M(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?M(t,{children:`No toolsets created yet. Press n to create one.`}):M(e,{flexDirection:`column`,children:i.map((n,r)=>{let i=n.name===a,s=n.name===o,c=g===r,l;return c&&(l=`yellow`),N(e,{flexDirection:`row`,children:[N(t,{color:l,children:[c?`❯ `:` `,n.name,` `]}),N(t,{color:l,children:[`(`,E(n),`)`]}),i&&M(t,{color:h,children:` ⏵⏵ accept edits`}),s&&M(t,{color:p,children:` ⏸ plan mode`})]},r)})})]})}function Wr({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(`plan`),[c,l]=m(!1),[d,f]=m(0),p=i.subagentModels||{plan:null,explore:null,generalPurpose:null},h=[{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.`}],g=[{label:`Default (Inherited)`,value:null},{label:`sonnet`,value:`sonnet`},{label:`haiku`,value:`haiku`},{label:`opus`,value:`opus`},{label:`sonnet[1m]`,value:`sonnet[1m]`}];return r((e,t)=>{if(c){if(t.escape)l(!1);else if(t.upArrow)f(e=>e>0?e-1:g.length-1);else if(t.downArrow)f(e=>e<g.length-1?e+1:0);else if(t.return){let e=g[d].value;a(t=>{t.subagentModels||={plan:null,explore:null,generalPurpose:null},t.subagentModels[o]=e}),l(!1)}}else if(t.escape)n();else if(t.upArrow){let e=h.findIndex(e=>e.id===o);s(h[e>0?e-1:h.length-1].id)}else if(t.downArrow){let e=h.findIndex(e=>e.id===o);s(h[e<h.length-1?e+1:0].id)}else if(e===` `||t.return){let e=p[o],t=g.findIndex(t=>t.value===e);f(t>=0?t:0),l(!0)}}),c?N(e,{flexDirection:`column`,children:[M(e,{marginBottom:1,children:N(X,{children:[`Select Model for`,` `,h.find(e=>e.id===o)?.title]})}),g.map((n,r)=>{let i=r===d;return M(e,{children:N(t,{color:i?`cyan`:void 0,children:[i?`❯ `:` `,n.label,n.value?N(t,{dimColor:!0,children:[` (`,n.value,`)`]}):null]})},r)})]}):N(e,{flexDirection:`column`,children:[M(e,{marginBottom:1,children:M(X,{children:`Subagent Model Settings`})}),M(e,{marginBottom:1,children:M(t,{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.`})}),h.map(n=>{let r=n.id===o,i=p[n.id],a=g.find(e=>e.value===i)?.label||i||`Default`;return N(e,{flexDirection:`column`,marginBottom:1,children:[M(e,{children:N(t,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,M(t,{bold:!0,children:n.title})]})}),M(e,{marginLeft:4,children:M(t,{dimColor:!0,children:n.description})}),M(e,{marginLeft:4,children:N(t,{children:[`Current: `,M(t,{color:`green`,children:a})]})})]},n.id)})]})}const $=c({settings:K,updateSettings:e=>{},changesApplied:!1,ccVersion:``});function Gr({startupCheckInfo:t,configMigrated:n}){let[i,a]=m({settings:K,changesApplied:!1,ccVersion:``,lastModified:``}),[o,s]=m(!1);d(()=>{(async()=>{let e=await ur();a(e),s(!e.hidePiebaldAnnouncement)})()},[]);let c=l(e=>{let t=JSON.parse(JSON.stringify(i.settings));e(t),a(e=>({...e,settings:t,changesApplied:!1})),dr(e=>{e.settings=t,e.changesApplied=!1})},[i.settings]),[u,f]=m(null),[p,h]=m(null);d(()=>{t.wasUpdated&&t.oldVersion&&(h({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
|
|
640
|
-
(However, your customization are still remembered in ${
|
|
641
|
-
Please reapply your changes below.`,type:`warning`}),c(()=>{}))},[]),r((e,t)=>{t.ctrl&&e===`c`&&process.exit(0),(e===`q`||t.escape)&&!u&&process.exit(0),e===`h`&&!u&&o&&(s(!1),
|
|
642
|
-
`)}function
|
|
639
|
+
`)))},br=async()=>{await b.mkdir(J,{recursive:!0}),await b.mkdir(_r,{recursive:!0});let e=w.join(J,`.gitignore`);try{await b.stat(e)}catch(t){t instanceof Error&&`code`in t&&t.code===`ENOENT`&&await b.writeFile(e,[`.DS_Store`,`prompt-data-cache`,`cli.js.backup`,`native-binary.backup`,`native-claudejs-orig.js`,`native-claudejs-patched.js`,`systemPromptAppliedHashes.json`,`systemPromptOriginalHashes.json`,`system-prompts/*.diff.html`].join(_)+_)}};let xr=null;const Sr=async()=>{let e={ccVersion:``,ccInstallationPath:null,lastModified:new Date().toISOString(),changesApplied:!0,settings:q};try{G(`Reading config at ${Y}`),yr();let t=await b.readFile(Y,`utf8`),n={...e,...JSON.parse(t)},r=n?.settings?.thinkingVerbs;return r?.punctuation&&(r.format=`{}`+r.punctuation,delete r.punctuation),n.settings=cr(n.settings,q),n.settings.inputPatternHighlighters&&(n.settings.inputPatternHighlighters=n.settings.inputPatternHighlighters.map(e=>cr(e,fr))),n.settings.toolsets&&(n.settings.toolsets=n.settings.toolsets.map(e=>cr(e,pr))),n.settings.themes&&(n.settings.themes=n.settings.themes.map(e=>cr(e,mr))),lr(n),ur(n),delete n.settings.launchText,await rt(_r)&&(n.changesApplied=!1),await wr(n),xr=n,n}catch(t){if(t instanceof Error&&`code`in t&&t.code===`ENOENT`)return e;throw t}},Cr=async e=>(G(`Updating config at ${Y}`),xr||=await Sr(),e(xr),xr.lastModified=new Date().toISOString(),await wr(xr),xr),wr=async e=>{try{e.lastModified=new Date().toISOString(),await br(),await b.writeFile(Y,JSON.stringify(e,null,2))}catch(e){throw console.error(`Error saving config:`,e),e}};var X=({children:e,...n})=>P(t,{bold:!0,backgroundColor:`#ffd500`,color:`#000`,...n,children:[` `,e,` `]});const Tr=[`\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 Er=()=>P(e,{flexDirection:`row`,height:10,alignItems:`center`,borderStyle:`bold`,borderBottom:!1,borderTop:!1,borderRight:!1,borderColor:`#ff8400`,marginBottom:1,children:[P(e,{marginBottom:1,paddingLeft:1,flexDirection:`column`,flexGrow:1,children:[N(t,{bold:!0,color:`#ff8400`,children:`Piebald is released!`}),N(t,{children:` `}),P(t,{children:[`We've released `,N(t,{bold:!0,children:`Piebald`}),`, the ultimate agentic AI developer experience.`]}),P(t,{children:[`Download it and try it out for free!`,` `,N(v,{url:`https://piebald.ai/`,fallback:!1,children:N(t,{color:`#ff8400`,children:`https://piebald.ai/`})})]}),N(t,{children:` `}),N(t,{dimColor:!0,color:`gray`,children:`press 'h' to hide`})]}),N(e,{width:22,flexShrink:0,flexDirection:`column`,alignItems:`center`,children:Tr.map((e,n)=>N(t,{children:e},n))})]});let Z=function(e){return e.APPLY_CHANGES=`*Apply customizations`,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.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 Dr({items:n,selectedIndex:i,onSelect:a,onSubmit:o}){return r((e,t)=>{t.upArrow?a(i>0?i-1:n.length-1):t.downArrow?a(i<n.length-1?i+1:0):t.return&&o(n[i].name)}),N(e,{flexDirection:`column`,children:n.map((n,r)=>N(e,{children:P(t,{children:[P(t,{bold:r===i,color:r===i?`cyan`:void 0,...r===i?n.selectedStyles??{}:n.styles??{},children:[r===i?`❯ `:` `,n.name]}),n.desc&&r===i&&P(t,{dimColor:!0,bold:!1,children:[` \x1B[0;2m`,`- `,n.desc]})]})},r))})}const Or=[{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.VIEW_SYSTEM_PROMPTS,desc:`Opens the system prompts directory where you can customize Claude Code's system prompts`}],kr=[{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 (${Y})`},{name:Z.OPEN_CLI,desc:`Opens Claude Code's cli.js file`},{name:Z.EXIT,desc:`Bye!`}];var Ar=({onSubmit:e})=>{let t=[...u($).changesApplied?[]:[{name:Z.APPLY_CHANGES,desc:`Required: Updates Claude Code in-place with your changes`,selectedStyles:{color:`green`}}],...Or,...kr],[n,r]=m(0);return N(Dr,{items:t,selectedIndex:n,onSelect:r,onSubmit:t=>e(t)})};const jr=()=>P(e,{flexDirection:`row`,children:[N(X,{children:`tweakcc`}),N(t,{children:` (by `}),N(v,{url:`https://piebald.ai`,fallback:!1,children:N(t,{color:`#ff8400`,bold:!0,children:`Piebald`})}),N(t,{children:`)`})]}),Mr=()=>N(e,{children:P(t,{color:`yellow`,children:[`⭐ `,N(t,{bold:!0,children:`Star the repo at `}),N(v,{url:`https://github.com/Piebald-AI/tweakcc`,fallback:!1,children:N(t,{bold:!0,color:`cyan`,children:`https://github.com/Piebald-AI/tweakcc`})}),N(t,{bold:!0,children:` if you find this useful!`}),` ⭐`]})}),Nr=({notification:n})=>N(e,{borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`bold`,borderColor:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,paddingLeft:1,flexDirection:`column`,children:N(t,{color:n.type===`success`?`green`:n.type===`error`?`red`:n.type===`info`?`blue`:`yellow`,children:n.message})}),Pr=({onSubmit:n,notification:r,configMigrated:i,showPiebaldAnnouncement:a})=>P(e,{flexDirection:`column`,gap:1,children:[i&&N(e,{children:N(t,{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."})}),N(jr,{}),N(e,{children:P(t,{children:[N(t,{bold:!0,children:`Customize your Claude Code installation.`}),` `,P(t,{dimColor:!0,children:[`Settings will be saved to `,J.replace(h.homedir(),`~`),`/config.json.`]})]})}),N(a?Er:Mr,{}),r&&N(Nr,{notification:r}),N(Ar,{onSubmit:n})]});function Q({color:e,backgroundColor:n,bold:r,dimColor:i,children:s}){let c=e?.startsWith(`ansi:`),l=n?.startsWith(`ansi:`);if(c||l){if(o.Children.toArray(s).some(e=>o.isValidElement(e)))return N(t,{children:s});let u=a;if(c){let t=e.slice(5);u=u[t]||u}if(l){let e=n.slice(5),t=e.startsWith(`bg`)?e:`bg${e.charAt(0).toUpperCase()}${e.slice(1)}`;u=u[t]||u}r&&(u=u.bold),i&&(u=u.dim);let d=o.Children.toArray(s).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``);return N(t,{children:u(d)})}return N(t,{color:e,backgroundColor:n,bold:r,dimColor:i,children:s})}function Fr({text:e,nonShimmerColors:n,shimmerColors:r,shimmerWidth:i=3,updateDuration:a=50,restartPoint:o=10}){let[s,c]=m(0);return d(()=>{let t=setInterval(()=>{c(t=>{let n=t+1;return n>=e.length+o?-i:n})},a);return()=>clearInterval(t)},[e.length,o,a]),n.length===r.length?N(t,{children:e.split(``).map((a,o)=>{let c=o>=s&&o<s+i&&s<e.length,l=o%n.length;return N(t,{color:c?r[l]:n[l],children:a},o)})}):(console.error(`UltrathinkRainbowShimmer: nonShimmerColors and shimmerColors must have the same length`),N(t,{children:e}))}const Ir=F.cwd();function Lr({theme:n}){let{ccVersion:r}=u($);return P(e,{flexDirection:`column`,paddingLeft:1,children:[N(e,{marginBottom:1,children:P(t,{bold:!0,children:[`Preview: `,n.name]})}),N(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,children:P(e,{flexDirection:`column`,children:[P(e,{flexDirection:`column`,children:[P(t,{children:[N(Q,{color:n.colors.clawd_body,children:` ▐`}),N(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`▛███▜`}),P(t,{children:[N(Q,{color:n.colors.clawd_body,children:`▌ `}),` `,N(t,{bold:!0,children:`Claude Code`}),` `,r?`v${r}`:`v2.0.14`]})]}),P(t,{children:[N(Q,{color:n.colors.clawd_body,children:`▝▜`}),N(t,{color:n.colors.clawd_body,backgroundColor:n.colors.clawd_background,children:`█████`}),N(Q,{color:n.colors.clawd_body,children:`▛▘`}),` `,Zn(),` · `,Xn()]}),P(Q,{color:n.colors.clawd_body,children:[` `,`▘▘ ▝▝`,` `,Ir]}),P(t,{children:[P(Q,{color:n.colors.success,children:[`Login successful. Press`,` `]}),N(Q,{bold:!0,color:n.colors.success,children:`Enter`}),P(Q,{color:n.colors.success,children:[` `,`to continue…`]})]})]}),N(t,{children:`╭─────────────────────────────────────────────╮`}),P(t,{children:[`│ 1 function greet() `,`{`,` `,`│`]}),P(t,{children:[`│ 2`,` `,N(Q,{backgroundColor:n.colors.diffRemoved,color:n.colors.text,children:`- console.log("`}),N(Q,{backgroundColor:n.colors.diffRemovedWord,children:`Hello, World!`}),N(Q,{backgroundColor:n.colors.diffRemoved,children:`");`}),` `,`│`]}),P(t,{children:[`│ 2`,` `,N(Q,{backgroundColor:n.colors.diffAdded,color:n.colors.text,children:`+ console.log("`}),N(Q,{backgroundColor:n.colors.diffAddedWord,children:`Hello, Claude!`}),N(Q,{backgroundColor:n.colors.diffAdded,children:`");`}),` `,`│`]}),N(Q,{color:n.colors.warning,children:`╭─────────────────────────────────────────────╮`}),P(Q,{color:n.colors.warning,children:[`│ Do you trust the files in this folder?`,` `,`│`]}),P(t,{children:[N(Q,{color:n.colors.warning,children:`│ `}),N(t,{dimColor:!0,children:`Enter to confirm · Esc to exit`}),P(Q,{color:n.colors.warning,children:[` `,`│`]})]}),N(Q,{color:n.colors.bashBorder,children:`───────────────────────────────────────────────`}),P(t,{children:[N(Q,{color:n.colors.bashBorder,children:`!`}),N(t,{children:` ls`})]}),N(Q,{color:n.colors.promptBorder,children:`───────────────────────────────────────────────`}),N(t,{children:P(t,{children:[`> list the dir`,` `,N(Fr,{text:`ultrathink`,nonShimmerColors:[n.colors.rainbow_red,n.colors.rainbow_orange,n.colors.rainbow_yellow,n.colors.rainbow_green,n.colors.rainbow_blue,n.colors.rainbow_indigo,n.colors.rainbow_violet],shimmerColors:[n.colors.rainbow_red_shimmer,n.colors.rainbow_orange_shimmer,n.colors.rainbow_yellow_shimmer,n.colors.rainbow_green_shimmer,n.colors.rainbow_blue_shimmer,n.colors.rainbow_indigo_shimmer,n.colors.rainbow_violet_shimmer],shimmerWidth:3,updateDuration:50,restartPoint:10})]})}),N(Q,{color:n.colors.planMode,children:`╭─────────────────────────────────────────────╮`}),P(t,{children:[N(Q,{color:n.colors.planMode,children:`│ `}),P(Q,{color:n.colors.permission,children:[`Ready to code?`,` `]}),N(t,{children:`Here is Claude's plan:`}),P(Q,{color:n.colors.planMode,children:[` `,`│`]})]}),N(Q,{color:n.colors.permission,children:`╭─────────────────────────────────────────────╮`}),P(t,{children:[N(Q,{color:n.colors.permission,children:`│ `}),N(t,{bold:!0,children:`Permissions:`}),` `,P(Q,{backgroundColor:n.colors.permission,color:n.colors.inverseText,bold:!0,children:[` `,`Allow`,` `]}),` `,`Deny`,` `,`Workspace`,` `,N(Q,{color:n.colors.permission,children:`│`})]}),N(t,{children:`> list the dir`}),P(t,{children:[N(Q,{color:n.colors.error,children:`●`}),N(t,{children:` Update(__init__.py)`})]}),P(t,{children:[N(t,{children:` ⎿ `}),N(Q,{color:n.colors.error,children:`User rejected update to __init__.py`})]}),P(t,{children:[` `,`1`,` `,P(Q,{backgroundColor:n.colors.diffRemovedDimmed,children:[`- import`,` `]}),N(Q,{backgroundColor:n.colors.diffRemovedWordDimmed,children:`os`})]}),P(t,{children:[` `,`2`,` `,P(Q,{backgroundColor:n.colors.diffAddedDimmed,children:[`+ import`,` `]}),N(Q,{backgroundColor:n.colors.diffAddedWordDimmed,children:`random`})]}),P(t,{children:[N(Q,{color:n.colors.success,children:`●`}),N(t,{children:` List(.)`})]}),P(t,{children:[N(t,{children:`●`}),N(t,{children:` The directory `}),N(Q,{color:n.colors.permission,children:`C:\\Users\\user`}),P(t,{children:[` `,`contains `,N(t,{bold:!0,children:`123`}),` files.`]})]}),P(t,{children:[N(Q,{color:n.colors.claude,children:`✻ Th`}),N(Q,{color:n.colors.claudeShimmer,children:`ink`}),N(Q,{color:n.colors.claude,children:`ing… `}),N(t,{children:`(esc to interrupt)`})]}),N(t,{children:N(Q,{color:n.colors.autoAccept,children:`⏵⏵ accept edits on (shift+tab to cycle)`})}),N(t,{children:N(Q,{color:n.colors.planMode,children:`⏸ plan mode on (shift+tab to cycle)`})}),N(t,{children:N(Q,{color:n.colors.ide,children:`◯ IDE connected ⧉ 44 lines selected`})})]})})]})}function Rr({colorKey:e,theme:t,bold:n=!1}){let r=t.colors[e];return e===`inverseText`?N(Q,{color:r,backgroundColor:t.colors.permission,bold:n,children:e}):e.startsWith(`diff`)?N(Q,{backgroundColor:r,bold:n,color:t.colors.text,children:e}):N(Q,{color:r,bold:n,children:e})}function zr({initialValue:n,onColorChange:i,onExit:a,colorKey:o,theme:c}){let l=Vr(n)||{h:0,s:50,l:50},u=Br(n)||{r:128,g:128,b:128},[f,p]=m(l),[h,g]=m(u),[_,v]=m(`hsl`),[y,b]=m(`h`),[x,S]=m(!1),[C,w]=m(!1);d(()=>{let e=Vr(n),t=Br(n);e&&t&&(S(!0),p(e),g(t),S(!1))},[n]),d(()=>{!x&&C&&i(`rgb(${h.r},${h.g},${h.b})`)},[f,h,x,C]),d(()=>{w(!0)},[]);let T=e=>{if(er(e)){let t=tr(e),n=Vr(t),r=Br(t);n&&r&&(S(!0),p(n),g(r),S(!1))}};r((e,t)=>{if(e.length>1&&!t.ctrl&&!t.meta){T(e);return}t.return||t.escape?a():t.ctrl&&e===`a`?(v(e=>e===`hsl`?`rgb`:`hsl`),b(e=>_===`hsl`?e===`h`?`r`:e===`s`?`g`:`b`:e===`r`?`h`:e===`g`?`s`:`l`)):t.upArrow?b(_===`hsl`?e=>e===`h`?`l`:e===`s`?`h`:`s`:e=>e===`r`?`b`:e===`g`?`r`:`g`):t.downArrow||t.tab?b(_===`hsl`?e=>e===`h`?`s`:e===`s`?`l`:`h`:e=>e===`r`?`g`:e===`g`?`b`:`r`):t.leftArrow?E(t.shift||t.ctrl||t.meta?-10:-1):t.rightArrow&&E(t.shift||t.ctrl||t.meta?10:1)});let E=e=>{S(!0),_===`hsl`?p(t=>{let n={...t};y===`h`?n.h=Math.max(0,Math.min(359,t.h+e)):y===`s`?n.s=Math.max(0,Math.min(100,t.s+e)):y===`l`&&(n.l=Math.max(0,Math.min(100,t.l+e)));let[r,i,a]=O(n.h,n.s,n.l);return g({r,g:i,b:a}),n}):g(t=>{let n={...t};return y===`r`?n.r=Math.max(0,Math.min(255,t.r+e)):y===`g`?n.g=Math.max(0,Math.min(255,t.g+e)):y===`b`&&(n.b=Math.max(0,Math.min(255,t.b+e))),p(D(n.r,n.g,n.b)),n}),S(!1)},D=(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)}},O=(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)]},k=()=>{let e=[],n=[[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 r=0;r<40;r++){let i=r/39*(n.length-1),a=Math.floor(i),o=Math.ceil(i),s=i-a,[c,l,u]=n[a],[d,f,p]=n[o],m=Math.round(c+(d-c)*s),h=Math.round(l+(f-l)*s),g=Math.round(u+(p-u)*s);e.push(N(t,{backgroundColor:`rgb(${m},${h},${g})`,children:` `},r))}return e},A=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,r,f.l);e.push(N(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},j=()=>{let e=[];for(let n=0;n<40;n++){let r=n/39*100,[i,a,o]=O(f.h,f.s,r);e.push(N(t,{backgroundColor:`rgb(${i},${a},${o})`,children:` `},n))}return e},F=()=>{let[e,t,n]=O(f.h,f.s,f.l);return`rgb(${e},${t},${n})`},I=(e,t,n)=>{let r=e=>e.toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},L=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(N(t,{backgroundColor:`rgb(${r},${h.g},${h.b})`,children:` `},n))}return e},R=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(N(t,{backgroundColor:`rgb(${h.r},${r},${h.b})`,children:` `},n))}return e},z=()=>{let e=[];for(let n=0;n<40;n++){let r=Math.round(n/39*255);e.push(N(t,{backgroundColor:`rgb(${h.r},${h.g},${r})`,children:` `},n))}return e},B=(e,t)=>Math.round(e/t*39);return P(e,{flexDirection:`column`,borderStyle:`single`,borderColor:`white`,padding:1,children:[P(e,{flexDirection:`column`,children:[N(t,{bold:!0,children:`Color Picker`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{color:`gray`,dimColor:!0,children:`←→ to adjust (shift/ctrl/cmd +10)`}),N(t,{color:`gray`,dimColor:!0,children:`↑↓ to change bar`}),N(t,{color:`gray`,dimColor:!0,children:`ctrl+a to switch rgb/hsl`}),N(t,{color:`gray`,dimColor:!0,children:`paste color from clipboard`}),N(t,{color:`gray`,dimColor:!0,children:`enter to exit (auto-saved)`}),N(t,{color:`gray`,dimColor:!0,children:`esc to save and exit`})]})]}),_===`hsl`?P(M,{children:[P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`h`?`yellow`:`white`,children:[y===`h`?`❯ `:` `,`Hue (`,f.h,`°):`]})}),N(e,{children:k().map((e,n)=>N(s,{children:n===B(f.h,360)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`s`?`yellow`:`white`,children:[y===`s`?`❯ `:` `,`Saturation (`,f.s,`%):`]})}),N(e,{children:A().map((e,n)=>N(s,{children:n===B(f.s,100)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`l`?`yellow`:`white`,children:[y===`l`?`❯ `:` `,`Lightness (`,f.l,`%):`]})}),N(e,{children:j().map((e,n)=>N(s,{children:n===B(f.l,100)?N(t,{children:`|`}):e},n))})]})]}):P(M,{children:[P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`r`?`yellow`:`white`,children:[y===`r`?`❯ `:` `,`Red (`,h.r,`):`]})}),N(e,{children:L().map((e,n)=>N(s,{children:n===B(h.r,255)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`g`?`yellow`:`white`,children:[y===`g`?`❯ `:` `,`Green (`,h.g,`):`]})}),N(e,{children:R().map((e,n)=>N(s,{children:n===B(h.g,255)?N(t,{children:`|`}):e},n))})]}),P(e,{marginBottom:1,children:[N(e,{width:25,children:P(t,{color:y===`b`?`yellow`:`white`,children:[y===`b`?`❯ `:` `,`Blue (`,h.b,`):`]})}),N(e,{children:z().map((e,n)=>N(s,{children:n===B(h.b,255)?N(t,{children:`|`}):e},n))})]})]}),P(e,{marginBottom:1,children:[N(t,{children:`Current: `}),N(t,{backgroundColor:F(),children:` `})]}),P(e,{flexDirection:`row`,justifyContent:`space-between`,children:[P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:`Hex `}),o?.startsWith(`diff`)?N(t,{backgroundColor:F(),color:c?.colors?.text||`white`,bold:!0,children:I(h.r,h.g,h.b)}):o===`inverseText`?N(t,{color:F(),backgroundColor:c?.colors?.permission,bold:!0,children:I(h.r,h.g,h.b)}):N(t,{color:F(),bold:!0,children:I(h.r,h.g,h.b)})]}),P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:`RGB `}),o?.startsWith(`diff`)?N(t,{backgroundColor:F(),color:c?.colors?.text||`white`,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):o===`inverseText`?N(t,{color:F(),backgroundColor:c?.colors?.permission,bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`}):N(t,{color:F(),bold:!0,children:`rgb(${h.r}, ${h.g}, ${h.b})`})]}),P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:`HSL `}),o?.startsWith(`diff`)?N(t,{backgroundColor:F(),color:c?.colors?.text||`white`,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):o===`inverseText`?N(t,{color:F(),backgroundColor:c?.colors?.permission,bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`}):N(t,{color:F(),bold:!0,children:`hsl(${f.h}, ${f.s}%, ${f.l}%)`})]})]})]})}function Br(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 Vr(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 Hr({onBack:n,themeId:i}){let{settings:{themes:a},updateSettings:o}=u($),[s,c]=m(i),d=a.find(e=>e.id===s)||a[0],[f,p]=m(`rgb`),[h,g]=m(0),[_,v]=m(null),[y,b]=m(null),[x,S]=m(``),[C,w]=m(``),T=l(e=>{o(t=>{let n=t.themes.findIndex(e=>e.id===s);n!==-1&&e(t.themes[n])})},[s,o]),E=e=>{if(h>=2&&er(e)){let t=tr(e),n=D[h-2];T(e=>{e.colors[n]=t})}};r((e,t)=>{if(_===null&&y===null){if(e.length>1&&!t.ctrl&&!t.meta){E(e);return}if(t.escape)n();else if(t.ctrl&&e===`a`)p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(t.upArrow)g(e=>Math.max(0,e-1));else if(t.downArrow)g(e=>Math.min(D.length+1,e+1));else if(t.return)if(h===0)b(`name`),S(d.name),w(d.name);else if(h===1)b(`id`),S(d.id),w(d.id);else{let e=h-2,t=D[e],n=d.colors[t];v(e),S(n),w(n)}}else if(_!==null)t.ctrl&&e===`a`&&p(e=>e===`rgb`?`hex`:e===`hex`?`hsl`:`rgb`);else if(y!==null)if(t.return){if(y===`id`){let e=s;c(x),o(t=>{let n=t.themes.findIndex(t=>t.id===e);n!==-1&&(t.themes[n].id=x)})}else T(e=>{e.name=x});b(null),S(``),w(``)}else t.escape?(b(null),S(``),w(``)):t.backspace||t.delete?S(e=>e.slice(0,-1)):e&&S(t=>t+e)});let D=Object.keys(d.colors),O=(e,t)=>{let n=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!n)return e;let r=parseInt(n[1]),i=parseInt(n[2]),a=parseInt(n[3]);switch(t){case`hex`:{let e=e=>e.toString(16).padStart(2,`0`);return`#${e(r)}${e(i)}${e(a)}`}case`hsl`:{let e=r/255,t=i/255,n=a/255,o=Math.max(e,t,n),s=Math.min(e,t,n),c=o-s,l=(o+s)/2,u=0;c!==0&&(u=l>.5?c/(2-o-s):c/(o+s));let d=0;return c!==0&&(d=o===e?((t-n)/c+(t<n?6:0))/6:o===t?((n-e)/c+2)/6:((e-t)/c+4)/6),`hsl(${Math.round(d*360)}, ${Math.round(u*100)}%, ${Math.round(l*100)}%)`}case`rgb`:default:return e}},k=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]||``,A=Math.max(...D.map(e=>e.length));return P(e,{children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{children:P(X,{children:[`Editing theme “`,d.name,`” (`,d.id,`)`]})}),_===null&&y===null?P(M,{children:[P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`enter to edit theme name, id, or color`}),N(t,{dimColor:!0,children:`ctrl+a to toggle rgb, hex, hsl`}),N(t,{dimColor:!0,children:`paste color from clipboard (when on color)`}),N(t,{dimColor:!0,children:`esc to go back`})]}),h<2?P(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:`yellow`,flexDirection:`column`,paddingLeft:1,children:[N(t,{bold:!0,children:h===0?`Theme Name`:`Theme ID`}),N(t,{children:h===0?`The display name for this theme`:"Unique identifier for this theme; used in `.claude.json` to select the theme."})]}):P(e,{marginBottom:1,borderStyle:`single`,borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:d.colors[D[h-2]],flexDirection:`column`,paddingLeft:1,children:[N(Rr,{colorKey:D[h-2],theme:d,bold:!0}),N(t,{children:k(D[h-2])})]}),P(e,{flexDirection:`column`,children:[P(e,{children:[N(t,{color:h===0?`yellow`:`white`,children:h===0?`❯ `:` `}),N(t,{bold:!0,children:`Name: `}),N(t,{children:d.name})]}),P(e,{marginBottom:1,children:[N(t,{color:h===1?`yellow`:`white`,children:h===1?`❯ `:` `}),N(t,{bold:!0,children:`ID: `}),N(t,{children:d.id})]}),(()=>{if(h<2)return P(M,{children:[D.slice(0,20).map((n,r)=>{let i=r+2;return P(e,{children:[N(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),N(e,{width:A+2,children:N(t,{children:N(Rr,{colorKey:n,theme:d,bold:!0})})}),N(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),D.length>20&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-20,` more below`]})]});let n=h-2,r=Math.max(0,n-10),i=Math.min(D.length,r+20),a=Math.max(0,i-20),o=D.slice(a,i);return P(M,{children:[a>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,a,` more above`]}),o.map((n,r)=>{let i=a+r+2;return P(e,{children:[N(t,{color:h===i?`yellow`:`white`,children:h===i?`❯ `:` `}),N(e,{width:A+2,children:N(t,{children:N(Rr,{colorKey:n,theme:d,bold:!0})})}),N(Q,{color:d.colors[n],children:O(d.colors[n],f)})]},n)}),i<D.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,D.length-i,` more below`]})]})})()]})]}):y?P(e,{flexDirection:`column`,marginTop:1,children:[P(t,{children:[`Editing `,y===`name`?`theme name`:`theme ID`,`:`]}),N(e,{borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:N(t,{children:x})}),N(t,{dimColor:!0,children:`enter to save, esc to cancel`})]}):N(zr,{initialValue:C,colorKey:D[_],theme:d,onColorChange:e=>{S(e),T(t=>{t.colors[D[_]]=e})},onExit:()=>{T(e=>{e.colors[D[_]]=x}),v(null),S(``),w(``)}})]}),N(e,{width:`50%`,children:N(Lr,{theme:d})})]})}function Ur(e){return e.map(e=>`${e.name} (${e.id})`)}function Wr({onBack:n}){let{settings:{themes:i},updateSettings:a}=u($),[o,s]=m(0),[c,l]=m(null),[d,f]=m(!0),p=()=>{let e={colors:{...(i[0]||q.themes[0]).colors},name:`New Custom Theme`,id:`custom-${Date.now()}`};a(t=>{t.themes.push(e)}),l(e.id),f(!1)},h=e=>{i.length<=1||(a(t=>{t.themes=t.themes.filter(t=>t.id!==e)}),o>=i.length-1&&s(Math.max(0,i.length-2)))},g=()=>{a(e=>{e.themes=[...q.themes]}),s(0)};if(r((e,t)=>{if(t.escape)n();else if(t.upArrow)s(e=>Math.max(0,e-1));else if(t.downArrow)s(e=>Math.min(i.length-1,e+1));else if(t.return){let e=i[o];e&&(l(e.id),f(!1))}else if(e===`n`)p();else if(e===`d`){let e=i[o];e&&h(e.id)}else t.ctrl&&e===`r`&&g()},{isActive:d}),c)return N(Hr,{themeId:c,onBack:()=>{l(null),f(!0)}});let _=Ur(i),v=i.find(e=>_[o]?.includes(`(${e.id})`))||i[0];return i.length===0?N(e,{children:P(e,{flexDirection:`column`,width:`100%`,children:[N(X,{children:`Themes`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new theme`}),N(t,{dimColor:!0,children:`esc to go back`})]}),N(t,{children:`No themes available!`})]})}):P(e,{children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(X,{children:`Themes`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new theme`}),N(t,{dimColor:!0,children:`d to delete a theme`}),N(t,{dimColor:!0,children:`ctrl+r to delete all themes and restore built-in`}),N(t,{dimColor:!0,children:`enter to edit theme`}),N(t,{dimColor:!0,children:`esc to go back`})]}),N(e,{flexDirection:`column`,children:_.map((e,n)=>P(t,{color:o===n?`yellow`:void 0,children:[o===n?`❯ `:` `,e]},n))})]}),N(e,{width:`50%`,children:N(Lr,{theme:v})})]})}function Gr({onBack:n}){let{settings:{thinkingVerbs:{format:i,verbs:a},themes:o},updateSettings:s}=u($),c=[`format`,`verbs`],[l,d]=m(0),f=c[l],[p,h]=m(0),[g,_]=m(!1),[v,y]=m(``),[b,x]=m(!1),[S,C]=m(!1),[w,T]=m(i),E=Yn(),D=(o.find(e=>e.id===E)||o.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;return r((e,t)=>{if(S){t.return?(s(e=>{e.thinkingVerbs.format=w}),C(!1)):t.escape?(T(i),C(!1)):t.backspace||t.delete?T(e=>e.slice(0,-1)):e&&T(t=>t+e);return}if(g||b){t.return&&v.trim()?(b?(s(e=>{e.thinkingVerbs.verbs.push(v.trim())}),x(!1)):(s(e=>{e.thinkingVerbs.verbs[p]=v.trim()}),_(!1)),y(``)):t.escape?(y(``),_(!1),x(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&y(t=>t+e);return}t.escape?n():t.return?f===`format`&&(T(i),C(!0)):t.tab?t.shift?d(e=>e===0?c.length-1:e-1):d(e=>e===c.length-1?0:e+1):t.upArrow?f===`verbs`&&a.length>0&&h(e=>e>0?e-1:a.length-1):t.downArrow?f===`verbs`&&a.length>0&&h(e=>e<a.length-1?e+1:0):e===`e`&&f===`verbs`?a.length>0&&(y(a[p]),_(!0)):e===`d`&&f===`verbs`?a.length>1&&(s(e=>{e.thinkingVerbs.verbs=e.thinkingVerbs.verbs.filter((e,t)=>t!==p)}),p>=a.length-1&&h(Math.max(0,a.length-2))):e===`n`&&f===`verbs`?(x(!0),y(``)):t.ctrl&&e===`r`&&f===`verbs`&&(s(e=>{e.thinkingVerbs.verbs=[...q.thinkingVerbs.verbs]}),h(0))}),P(e,{children:[P(e,{flexDirection:`column`,width:`50%`,children:[P(e,{marginBottom:1,flexDirection:`column`,children:[N(X,{children:`Thinking Verbs`}),P(e,{flexDirection:`column`,children:[N(t,{dimColor:!0,children:f===`format`?`enter to edit format`:`changes auto-saved`}),N(t,{dimColor:!0,children:`esc to go back`}),N(t,{dimColor:!0,children:`tab to switch sections`})]})]}),N(e,{marginBottom:1,children:N(t,{dimColor:!0,children:`Customize the verbs shown during generation and their format.`})}),P(e,{flexDirection:`column`,children:[P(t,{children:[N(t,{color:f===`format`?`yellow`:void 0,children:f===`format`?`❯ `:` `}),N(t,{bold:!0,color:f===`format`?`yellow`:void 0,children:`Format`})]}),f===`format`&&(S?P(t,{dimColor:!0,children:[` `,`enter to save`]}):P(t,{dimColor:!0,children:[` `,`enter to edit`]}))]}),N(e,{marginLeft:2,marginBottom:1,children:N(e,{borderStyle:`round`,borderColor:S?`yellow`:`gray`,children:N(t,{children:S?w:i})})}),N(e,{children:P(t,{children:[N(t,{color:f===`verbs`?`yellow`:void 0,children:f===`verbs`?`❯ `:` `}),N(t,{bold:!0,color:f===`verbs`?`yellow`:void 0,children:`Verbs`})]})}),f===`verbs`&&N(e,{flexDirection:`column`,children:P(t,{dimColor:!0,children:[` `,`e to edit · d to delete · n to add new · ctrl+r to reset`]})}),N(e,{marginLeft:2,marginBottom:1,children:P(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,p-4),n=Math.min(a.length,e+8),r=Math.max(0,n-8),i=a.slice(r,n);return P(M,{children:[r>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return P(t,{color:f===`verbs`&&i===p?`cyan`:void 0,children:[f===`verbs`&&i===p?`❯ `:` `,e]},i)}),n<a.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,a.length-n,` more below`]})]})})(),b&&P(e,{alignItems:`center`,children:[N(t,{color:`yellow`,children:`❯ `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:v})})]}),g&&P(e,{marginTop:1,alignItems:`center`,children:[N(t,{children:`Editing: `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:v})})]})]})})]}),P(e,{width:`50%`,flexDirection:`column`,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,children:`Preview`})}),N(e,{borderStyle:`single`,borderColor:`gray`,padding:1,flexDirection:`column`,children:P(t,{children:[P(t,{color:D,children:[`✻ `,i.replace(/\{\}/g,a[p]),` `]}),N(t,{children:`(esc to interrupt)`})]})})]})]})}const Kr=[{name:`Default`,phases:q.thinkingStyle.phases,reverseMirror:q.thinkingStyle.reverseMirror},{name:`Basic`,phases:[`|`,`/`,`-`,`\\`],reverseMirror:!1},{name:`Braille`,phases:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],reverseMirror:!1},{name:`Circle`,phases:[`◐`,`◓`,`◑`,`◒`],reverseMirror:!1},{name:`Wave`,phases:[`▁`,`▃`,`▄`,`▅`,`▆`,`▇`,`█`],reverseMirror:!0},{name:`Glow`,phases:[`░`,`▒`,`▓`,`█`],reverseMirror:!0},{name:`Partial block`,phases:[`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`,`█`],reverseMirror:!0},{name:`Clock`,phases:[`🕛`,`🕐`,`🕑`,`🕒`,`🕓`,`🕔`,`🕕`,`🕖`,`🕗`,`🕘`,`🕙`,`🕚`],reverseMirror:!1},{name:`Globe`,phases:[`🌍`,`🌎`,`🌏`],reverseMirror:!1},{name:`Arc`,phases:[`◜`,`◠`,`◝`,`◞`,`◡`,`◟`],reverseMirror:!1},{name:`Triangle`,phases:[`◤`,`◥`,`◢`,`◣`],reverseMirror:!1},{name:`Bouncing`,phases:[`⠁`,`⠂`,`⠄`,`⡀`,`⢀`,`⠠`,`⠐`,`⠈`],reverseMirror:!1},{name:`Dots`,phases:[`.`,`..`,`...`],reverseMirror:!1},{name:`Colors`,phases:[`🔴`,`🟠`,`🟡`,`🟢`,`🔵`,`🟣`],reverseMirror:!1}];function qr({onBack:n}){let{settings:{thinkingStyle:{phases:i,updateInterval:a,reverseMirror:o},themes:s},updateSettings:c}=u($),l=[`reverseMirror`,`updateInterval`,`phases`,`presets`],[f,p]=m(0),h=l[f],[g,_]=m(0),[v,y]=m(0),[b,x]=m(!1),[S,C]=m(``),[w,T]=m(!1),[E,D]=m(!1),[O,k]=m(a.toString()),[A,j]=m(0),F=Yn(),I=(s.find(e=>e.id===F)||s.find(e=>e.id===`dark`))?.colors.claude||`rgb(215,119,87)`;d(()=>{if(i.length>0){let e=o?[...i,...[...i].reverse().slice(1,-1)]:i,t=setInterval(()=>{j(t=>(t+1)%e.length)},a);return()=>clearInterval(t)}},[i,a,o]),r((e,t)=>{if(E){if(t.return){let e=parseInt(O);!isNaN(e)&&e>0&&c(t=>{t.thinkingStyle.updateInterval=e}),D(!1)}else t.escape?(k(a.toString()),D(!1)):t.backspace||t.delete?k(e=>e.slice(0,-1)):e&&e.match(/^[0-9]$/)&&k(t=>t+e);return}if(b||w){if(t.return&&S.length){let e=w?[...i,S]:i.map((e,t)=>t===g?S:e);c(t=>{t.thinkingStyle.phases=e}),x(!1),C(``)}else t.escape?(C(``),x(!1),T(!1)):t.backspace||t.delete?C(e=>e.slice(0,-1)):e&&C(t=>t+e);return}if(t.escape)n();else if(t.return)if(h===`updateInterval`)k(a.toString()),D(!0);else if(h===`presets`){let e=Kr[v];c(t=>{t.thinkingStyle.phases=[...e.phases],t.thinkingStyle.reverseMirror=e.reverseMirror})}else h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(t.tab)t.shift?p(e=>e===0?l.length-1:e-1):p(e=>e===l.length-1?0:e+1);else if(t.upArrow)h===`phases`&&i.length>0?_(e=>e>0?e-1:i.length-1):h===`presets`&&y(e=>e>0?e-1:Kr.length-1);else if(t.downArrow)h===`phases`&&i.length>0?_(e=>e<i.length-1?e+1:0):h===`presets`&&y(e=>e<Kr.length-1?e+1:0);else if(e===` `)h===`reverseMirror`&&c(e=>{e.thinkingStyle.reverseMirror=!e.thinkingStyle.reverseMirror});else if(e===`e`&&h===`phases`)i.length>0&&(C(i[g]),x(!0));else if(e===`a`&&h===`phases`)T(!0),C(``);else if(e===`d`&&h===`phases`)i.length>1&&(c(e=>{e.thinkingStyle.phases=i.filter((e,t)=>t!==g)}),g>=i.length&&_(Math.max(0,i.length-1)));else if(e===`w`&&h===`phases`){if(g>0){let e=[...i];[e[g-1],e[g]]=[e[g],e[g-1]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e-1)}}else if(e===`s`&&h===`phases`){if(g<i.length-1){let e=[...i];[e[g],e[g+1]]=[e[g+1],e[g]],c(t=>{t.thinkingStyle.phases=e}),_(e=>e+1)}}else t.ctrl&&e===`r`&&(c(e=>{e.thinkingStyle=q.thinkingStyle}),_(0),y(0))});let L=o?`●`:`○`,R=(()=>o?[...i,...[...i].reverse().slice(1,-1)]:i)(),z=R.length>0?R[A]:`·`;return N(e,{children:P(e,{flexDirection:`column`,width:`100%`,children:[P(e,{flexDirection:`row`,width:`100%`,children:[P(e,{marginBottom:1,flexDirection:`column`,width:`50%`,children:[N(X,{children:`Thinking style`}),P(e,{flexDirection:`column`,children:[P(t,{dimColor:!0,children:[`enter to`,` `,h===`updateInterval`?`edit interval`:h===`presets`?`apply preset`:`save`]}),N(t,{dimColor:!0,children:`esc to go back`}),N(t,{dimColor:!0,children:`tab to switch sections`})]})]}),P(e,{width:`50%`,flexDirection:`column`,children:[N(e,{children:N(t,{bold:!0,children:`Preview`})}),P(e,{borderStyle:`single`,borderColor:`gray`,paddingX:1,flexDirection:`row`,children:[N(e,{width:(z?.length??0)+1,children:N(t,{color:I,children:z})}),P(t,{children:[N(t,{color:I,children:`Thinking… `}),N(t,{children:`(esc to interrupt)`})]})]})]})]}),P(e,{flexDirection:`row`,gap:4,children:[P(e,{flexDirection:`column`,children:[P(t,{children:[N(t,{color:h===`reverseMirror`?`yellow`:void 0,children:h===`reverseMirror`?`❯ `:` `}),N(t,{bold:!0,color:h===`reverseMirror`?`yellow`:void 0,children:`Reverse-mirror phases`})]}),h===`reverseMirror`&&P(t,{dimColor:!0,children:[` `,`space to toggle`]}),N(e,{marginLeft:2,marginBottom:1,children:P(t,{children:[L,` `,o?`Enabled`:`Disabled`]})})]}),P(e,{flexDirection:`column`,children:[P(t,{children:[N(t,{color:h===`updateInterval`?`yellow`:void 0,children:h===`updateInterval`?`❯ `:` `}),N(t,{bold:!0,color:h===`updateInterval`?`yellow`:void 0,children:`Update interval (ms)`})]}),h===`updateInterval`&&(E?P(t,{dimColor:!0,children:[` `,`enter to save`]}):P(t,{dimColor:!0,children:[` `,`enter to edit`]})),N(e,{marginLeft:2,marginBottom:1,children:N(e,{borderStyle:`round`,borderColor:E?`yellow`:`gray`,children:N(t,{children:E?O:a})})})]})]}),N(e,{children:P(t,{children:[N(t,{color:h===`phases`?`yellow`:void 0,children:h===`phases`?`❯ `:` `}),N(t,{bold:!0,color:h===`phases`?`yellow`:void 0,children:`Phases`})]})}),h===`phases`&&N(e,{marginBottom:1,flexDirection:`column`,children:P(t,{dimColor:!0,children:[` `,`[e]dit`,` `,`[a]dd`,` `,`[d]elete`,` `,`[w]move up`,` `,`[s]move down`]})}),N(e,{marginLeft:2,marginBottom:1,children:P(e,{flexDirection:`column`,children:[(()=>{let e=Math.max(0,g-4),n=Math.min(i.length,e+8),r=Math.max(0,n-8),a=i.slice(r,n);return P(M,{children:[r>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),a.map((e,n)=>{let i=r+n;return P(t,{color:h===`phases`&&i===g?`cyan`:void 0,children:[h===`phases`&&i===g?`❯ `:` `,e]},i)}),n<i.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,i.length-n,` more below`]})]})})(),w&&P(e,{children:[N(t,{color:`yellow`,children:`❯ `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:S})})]}),b&&P(e,{marginTop:1,children:[N(t,{children:`Editing: `}),N(e,{borderStyle:`round`,borderColor:`yellow`,children:N(t,{children:S})})]})]})}),N(e,{children:P(t,{children:[N(t,{color:h===`presets`?`yellow`:void 0,children:h===`presets`?`❯ `:` `}),N(t,{bold:!0,color:h===`presets`?`yellow`:void 0,children:`Presets`})]})}),h===`presets`&&P(t,{dimColor:!0,children:[` `,`Selecting one will overwrite your choice of phases`]}),N(e,{marginLeft:2,marginBottom:1,children:N(e,{flexDirection:`column`,children:(()=>{let e=Math.max(0,v-4),n=Math.min(Kr.length,e+8),r=Math.max(0,n-8),i=Kr.slice(r,n);return P(M,{children:[r>0&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↑ `,r,` more above`]}),i.map((e,n)=>{let i=r+n;return P(t,{color:h===`presets`&&i===v?`cyan`:void 0,children:[h===`presets`&&i===v?`❯ `:` `,e.name,` `,e.phases.join(``)]},i)}),n<Kr.length&&P(t,{color:`gray`,dimColor:!0,children:[` `,`↓ `,Kr.length-n,` more below`]})]})})()})}),N(e,{marginTop:1,children:N(t,{dimColor:!0,children:`ctrl+r to reset all settings to default`})})]})})}function Jr(e,t){let n=p(!0);d(()=>{if(n.current){n.current=!1;return}return e()},t)}const Yr=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],Xr=[{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 Zr({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(!1),[c,l]=m(!1),[d,f]=m(!1),[p,h]=m(()=>i.userMessageDisplay.format),[g,_]=m(()=>String(i.userMessageDisplay.paddingX)),[v,y]=m(()=>String(i.userMessageDisplay.paddingY)),[b,x]=m(i.userMessageDisplay.fitBoxToContent),[S,C]=m(0),[w,T]=m(()=>[...i.userMessageDisplay.styling]),[E,D]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`default`:`custom`),[O,k]=m(()=>i.userMessageDisplay.foregroundColor===`default`?`rgb(255,255,255)`:i.userMessageDisplay.foregroundColor),[A,j]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null?`none`:e===`default`?`default`:`custom`}),[M,F]=m(()=>{let e=i.userMessageDisplay.backgroundColor;return e===null||e===`default`?`rgb(0,0,0)`:e}),[I,L]=m(()=>Xr.findIndex(e=>e.value===i.userMessageDisplay.borderStyle)),[R,z]=m(()=>i.userMessageDisplay.borderColor),[B,ee]=m(null),[te,ne]=m(``),re=Yn(),ie=i.themes?.find(e=>e.id===re)||i.themes?.[0],[ae,oe]=m(`text`),se=[`format`,`styling`,`foreground`,`background`],ce=[`borderStyle`,`borderColor`,`paddingX`,`paddingY`,`fitBoxToContent`],[le,ue]=m(0),[de,V]=m(0),H=ae===`text`?se[le]:ce[de],fe=()=>{a(e=>{e.userMessageDisplay.format=p,e.userMessageDisplay.styling=[...w],e.userMessageDisplay.foregroundColor=E===`default`?`default`:O,e.userMessageDisplay.backgroundColor=A===`none`?null:A===`default`?`default`:M,e.userMessageDisplay.borderStyle=Xr[I].value,e.userMessageDisplay.borderColor=R,e.userMessageDisplay.paddingX=parseInt(g)||0,e.userMessageDisplay.paddingY=parseInt(v)||0,e.userMessageDisplay.fitBoxToContent=b})},pe=()=>{h(q.userMessageDisplay.format),T([...q.userMessageDisplay.styling]),D(`default`),k(`rgb(255,255,255)`),j(`none`),F(`rgb(0,0,0)`),L(Xr.findIndex(e=>e.value===q.userMessageDisplay.borderStyle)),z(q.userMessageDisplay.borderColor),_(String(q.userMessageDisplay.paddingX)),y(String(q.userMessageDisplay.paddingY)),x(q.userMessageDisplay.fitBoxToContent),a(e=>{e.userMessageDisplay={...q.userMessageDisplay}})};Jr(()=>{fe()},[p,w,E,O,A,M,I,R,g,v,b]),r((e,t)=>{if(o){t.return?s(!1):t.escape?(h(i.userMessageDisplay.format),s(!1)):t.backspace||t.delete?h(e=>e.slice(0,-1)):e&&h(t=>t+e);return}if(c){t.return?l(!1):t.escape?(_(String(i.userMessageDisplay.paddingX)),l(!1)):t.backspace||t.delete?_(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&_(t=>t+e);return}if(d){t.return?f(!1):t.escape?(y(String(i.userMessageDisplay.paddingY)),f(!1)):t.backspace||t.delete?y(e=>e.slice(0,-1)):e&&/^\d$/.test(e)&&y(t=>t+e);return}if(B===null){if(t.escape)n();else if(t.ctrl&&e===`r`)pe();else if(t.leftArrow||t.rightArrow)oe(e=>e===`text`?`border`:`text`);else if(t.tab)ae===`text`?t.shift?ue(e=>e===0?se.length-1:e-1):ue(e=>e===se.length-1?0:e+1):t.shift?V(e=>e===0?ce.length-1:e-1):V(e=>e===ce.length-1?0:e+1);else if(t.return)H===`format`?s(!0):H===`paddingX`?l(!0):H===`paddingY`?f(!0):H===`foreground`?E===`custom`&&(ne(O),ee(`foreground`)):H===`background`?A===`custom`&&(ne(M),ee(`background`)):H===`borderColor`&&(ne(R),ee(`border`));else if(t.upArrow)H===`styling`?C(e=>Math.max(0,e-1)):H===`borderStyle`?L(e=>e===0?Xr.length-1:e-1):H===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):H===`background`&&j(e=>{let t=e===`default`?`custom`:e===`custom`?`none`:`default`;return t===`custom`&&(!M||M===``)&&F(`rgb(0,0,0)`),t});else if(t.downArrow)H===`styling`?C(e=>Math.min(Yr.length-1,e+1)):H===`borderStyle`?L(e=>e===Xr.length-1?0:e+1):H===`foreground`?D(e=>{let t=e===`default`?`custom`:`default`;return t===`custom`&&(!O||O===``)&&k(`rgb(255,255,255)`),t}):H===`background`&&j(e=>{let t=e===`default`?`none`:e===`none`?`custom`:`default`;return t===`custom`&&(!M||M===``)&&F(`rgb(0,0,0)`),t});else if(e===` `)if(H===`styling`){let e=Yr[S].value;T(w.indexOf(e)>=0?w.filter(t=>t!==e):[...w,e])}else H===`fitBoxToContent`&&x(e=>!e)}});let me=n=>{let r=E===`default`?ie?.colors?.text:O,i=A===`none`?void 0:A===`default`?ie?.colors?.userMessageBackground:M,a=Xr[I].value,o=parseInt(g)||0,s=parseInt(v)||0,c=N(t,{bold:w.includes(`bold`),italic:w.includes(`italic`),underline:w.includes(`underline`),strikethrough:w.includes(`strikethrough`),inverse:w.includes(`inverse`),color:r,backgroundColor:i,children:n});if(a===`topBottomSingle`||a===`topBottomDouble`||a===`topBottomBold`){let r=a===`topBottomSingle`?`─`:a===`topBottomDouble`?`═`:`━`,i=n.length+o*2,l=r.repeat(i);return P(e,{flexDirection:`column`,children:[N(t,{color:R,children:l}),s>0&&N(e,{height:s}),N(e,{paddingX:o,children:c}),s>0&&N(e,{height:s}),N(t,{color:R,children:l})]})}else if(a!==`none`||o>0||s>0||b){let t=o>0||s>0?N(e,{paddingX:o,paddingY:s,children:c}):c,n={};return a!==`none`&&(n.borderStyle=a,n.borderColor=R),b?n.alignSelf=`flex-start`:n.flexGrow=1,a===`none`?t:N(e,{...n,children:t})}else return c};return B?N(zr,{initialValue:te,theme:ie,onColorChange:e=>{B===`foreground`?k(e):B===`background`?F(e):B===`border`&&z(e)},onExit:()=>{ee(null),ne(``)}}):P(e,{flexDirection:`column`,children:[N(X,{children:`Customize how user messages are displayed`}),P(e,{flexDirection:`column`,marginBottom:1,children:[N(t,{dimColor:!0,children:`left/right arrows to switch columns · tab to navigate options`}),N(t,{dimColor:!0,children:`enter to edit · ctrl+r to reset · esc to go back`})]}),P(e,{flexDirection:`row`,gap:1,children:[P(e,{flexDirection:`column`,width:`50%`,borderStyle:ae===`text`?`round`:`single`,borderColor:ae===`text`?`yellow`:`gray`,paddingX:1,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,color:ae===`text`?`yellow`:void 0,children:`Text & Styling`})}),N(e,{children:P(t,{color:H===`format`?`yellow`:void 0,bold:H===`format`,children:[H===`format`?`❯ `:` `,`Format String`]})}),H===`format`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:o?`enter to save · esc to cancel`:`enter to edit · use {} as message placeholder`})}),N(e,{marginLeft:2,marginBottom:1,children:N(e,{borderStyle:`round`,borderColor:o?`yellow`:`gray`,children:N(t,{children:p})})}),N(e,{children:P(t,{color:H===`styling`?`yellow`:void 0,bold:H===`styling`,children:[H===`styling`?`❯ `:` `,`Styling`]})}),H===`styling`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`up/down to navigate · space to toggle`})}),N(e,{marginLeft:2,marginBottom:1,flexDirection:`column`,children:Yr.map((n,r)=>N(e,{children:P(t,{color:H===`styling`&&S===r?`cyan`:void 0,children:[H===`styling`&&S===r?`❯ `:` `,w.includes(n.value)?`●`:`○`,` `,n.label]})},n.value))}),P(e,{flexDirection:`row`,gap:1,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{children:P(t,{color:H===`foreground`?`yellow`:void 0,bold:H===`foreground`,children:[H===`foreground`?`❯ `:` `,`Foreground`]})}),H===`foreground`&&N(e,{marginLeft:2,children:P(t,{dimColor:!0,children:[`up/down · `,E===`custom`?`enter`:``]})}),P(e,{marginLeft:2,flexDirection:`column`,children:[N(e,{children:P(t,{children:[E===`default`?`● `:`○ `,`Default`]})}),N(e,{children:P(t,{children:[E===`custom`?`● `:`○ `,`Custom`,E===`custom`&&`: `,E===`custom`&&N(t,{color:O,children:O})]})})]})]}),P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{children:P(t,{color:H===`background`?`yellow`:void 0,bold:H===`background`,children:[H===`background`?`❯ `:` `,`Background`]})}),H===`background`&&N(e,{marginLeft:2,children:P(t,{dimColor:!0,children:[`up/down · `,A===`custom`?`enter`:``]})}),P(e,{marginLeft:2,flexDirection:`column`,children:[N(e,{children:P(t,{children:[A===`default`?`● `:`○ `,`Default`]})}),N(e,{children:P(t,{children:[A===`none`?`● `:`○ `,`None`]})}),N(e,{children:P(t,{children:[A===`custom`?`● `:`○ `,`Custom`,A===`custom`&&`: `,A===`custom`&&N(t,{backgroundColor:M,children:M})]})})]})]})]})]}),P(e,{flexDirection:`column`,width:`50%`,borderStyle:ae===`border`?`round`:`single`,borderColor:ae===`border`?`yellow`:`gray`,paddingX:1,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,color:ae===`border`?`yellow`:void 0,children:`Border & Padding`})}),N(e,{children:P(t,{color:H===`borderStyle`?`yellow`:void 0,bold:H===`borderStyle`,children:[H===`borderStyle`?`❯ `:` `,`Border Style`]})}),H===`borderStyle`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`up/down to navigate`})}),P(e,{marginLeft:2,marginBottom:1,flexDirection:`row`,children:[N(e,{flexDirection:`column`,width:`50%`,children:Xr.slice(0,6).map((n,r)=>N(e,{children:P(t,{color:H===`borderStyle`&&I===r?`cyan`:void 0,children:[H===`borderStyle`&&I===r?`❯ `:` `,I===r?`● `:`○ `,n.label]})},n.value))}),N(e,{flexDirection:`column`,width:`50%`,children:Xr.slice(6).map((n,r)=>{let i=r+6;return N(e,{children:P(t,{color:H===`borderStyle`&&I===i?`cyan`:void 0,children:[H===`borderStyle`&&I===i?`❯ `:` `,I===i?`● `:`○ `,n.label]})},n.value)})})]}),N(e,{children:P(t,{color:H===`borderColor`?`yellow`:void 0,bold:H===`borderColor`,children:[H===`borderColor`?`❯ `:` `,`Border Color`]})}),H===`borderColor`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`enter to pick color`})}),N(e,{marginLeft:2,marginBottom:1,children:N(t,{color:R,children:R})}),P(e,{flexDirection:`row`,gap:1,children:[P(e,{flexDirection:`column`,width:`33%`,children:[N(e,{children:P(t,{color:H===`paddingX`?`yellow`:void 0,bold:H===`paddingX`,children:[H===`paddingX`?`❯ `:` `,`Padding X`]})}),H===`paddingX`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:c?`enter/esc`:`enter`})}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:c?`yellow`:`gray`,children:N(t,{children:g})})})]}),P(e,{flexDirection:`column`,width:`33%`,children:[N(e,{children:P(t,{color:H===`paddingY`?`yellow`:void 0,bold:H===`paddingY`,children:[H===`paddingY`?`❯ `:` `,`Padding Y`]})}),H===`paddingY`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:d?`enter/esc`:`enter`})}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:d?`yellow`:`gray`,children:N(t,{children:v})})})]}),P(e,{flexDirection:`column`,width:`33%`,children:[N(e,{children:P(t,{color:H===`fitBoxToContent`?`yellow`:void 0,bold:H===`fitBoxToContent`,children:[H===`fitBoxToContent`?`❯ `:` `,b?`●`:`○`,` Fit box to content`]})}),H===`fitBoxToContent`&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`space`})})]})]})]})]}),P(e,{flexDirection:`column`,marginTop:1,paddingX:1,children:[N(e,{marginBottom:1,children:N(t,{bold:!0,children:`Preview`})}),P(e,{flexDirection:`row`,gap:2,children:[P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,children:N(t,{underline:!0,children:`Before (Claude Code default):`})}),N(e,{marginLeft:1,children:P(t,{backgroundColor:ie?.colors?.userMessageBackground,color:ie?.colors?.text,children:[` `,`> list the dir`,` `]})}),N(e,{marginLeft:1,marginTop:1,children:P(t,{children:[N(t,{color:ie?.colors?.inactive||`#888888`,children:`●`}),N(t,{children:` The directory `}),N(t,{color:ie?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),N(t,{children:` contains `}),N(t,{bold:!0,children:`123`}),N(t,{children:` files.`})]})})]}),P(e,{flexDirection:`column`,width:`50%`,children:[N(e,{marginBottom:1,children:N(t,{underline:!0,children:`After (Your customization):`})}),N(e,{marginLeft:1,flexDirection:`row`,children:(()=>me(p.replace(/\{\}/g,`list the dir`)))()}),N(e,{marginLeft:1,marginTop:1,children:P(t,{children:[N(t,{color:ie?.colors?.inactive||`#888888`,children:`●`}),N(t,{children:` The directory `}),N(t,{color:ie?.colors?.permission||`#00ff00`,children:`C:\\Users\\user`}),N(t,{children:` contains `}),N(t,{bold:!0,children:`123`}),N(t,{children:` files.`})]})})]})]})]})]})}const Qr=[{label:`bold`,value:`bold`},{label:`italic`,value:`italic`},{label:`underline`,value:`underline`},{label:`strikethrough`,value:`strikethrough`},{label:`inverse`,value:`inverse`}],$r=[[`name`,`regex`,`regexFlags`],[`format`,`styling`],[`foreground`,`background`],[`enabled`],[`testText`]];function ei({testText:e,regex:n,regexFlags:r,format:i,styling:a,foregroundColor:o,backgroundColor:s}){let c=[];try{let l=r.includes(`g`)?r:r+`g`,u=new RegExp(n,l),d=[...e.matchAll(u)];if(d.length===0)return N(t,{children:e});let f=0;return d.forEach((n,r)=>{let l=n.index,u=l+n[0].length;l>f&&c.push(N(t,{children:e.slice(f,l)},`plain-${r}`));let d=i.replace(/\{MATCH\}/g,n[0]);c.push(N(t,{bold:a.includes(`bold`),italic:a.includes(`italic`),underline:a.includes(`underline`),strikethrough:a.includes(`strikethrough`),inverse:a.includes(`inverse`),color:o,backgroundColor:s,children:d},`match-${r}`)),f=u}),f<e.length&&c.push(N(t,{children:e.slice(f)},`plain-end`)),N(M,{children:c})}catch{return N(t,{children:e})}}function ti({highlighterIndex:n,onBack:i}){let{settings:a,updateSettings:o}=u($),s=a.inputPatternHighlighters[n],c=Yn(),l=a.themes?.find(e=>e.id===c)||a.themes?.[0],[f,p]=m(s?.name||`New Highlighter`),[h,g]=m(s?.regex||``),[_,v]=m(s?.regexFlags||`g`),[y,b]=m(s?.format||`{MATCH}`),[x,S]=m(s?.styling||[]),[C,w]=m(s?.foregroundColor===null?`none`:`custom`),[T,E]=m(s?.foregroundColor||`rgb(255,0,255)`),[D,O]=m(s?.backgroundColor?`custom`:`none`),[k,A]=m(s?.backgroundColor||`rgb(0,0,0)`),[j,M]=m(s?.enabled??!0),[F,I]=m(a.inputPatternHighlightersTestText||`Type test text here to see highlighting`),[L,R]=m(`name`),[z,B]=m(!1),[ee,te]=m(0),[ne,re]=m(null),[ie,ae]=m(``),[oe,se]=m(null),[ce,le]=m(0),[ue,de]=m(0);if(d(()=>{let e=$r[ce];R(e[Math.min(ue,e.length-1)])},[ce,ue]),d(()=>{if(!h){se(null);return}try{new RegExp(h,_),se(null)}catch(e){se(e.message)}},[h,_]),d(()=>{n>=0&&o(e=>{e.inputPatternHighlighters[n]&&(e.inputPatternHighlighters[n]={name:f,regex:h,regexFlags:_,format:y,styling:x,foregroundColor:C===`custom`?T:null,backgroundColor:D===`custom`?k:null,enabled:j})})},[n,f,h,_,y,x,C,T,D,k,j]),d(()=>{o(e=>{e.inputPatternHighlightersTestText=F})},[F]),r((e,t)=>{if(z){t.return?B(!1):t.escape?(L===`name`&&p(s?.name||``),L===`regex`&&g(s?.regex||``),L===`regexFlags`&&v(s?.regexFlags||`g`),L===`format`&&b(s?.format||`{MATCH}`),L===`testText`&&I(a.inputPatternHighlightersTestText||`Type test text here to see highlighting`),B(!1)):t.backspace||t.delete?(L===`name`&&p(e=>e.slice(0,-1)),L===`regex`&&g(e=>e.slice(0,-1)),L===`regexFlags`&&v(e=>e.slice(0,-1)),L===`format`&&b(e=>e.slice(0,-1)),L===`testText`&&I(e=>e.slice(0,-1))):e&&e.length===1&&(L===`name`&&p(t=>t+e),L===`regex`&&g(t=>t+e),L===`regexFlags`&&v(t=>t+e),L===`format`&&b(t=>t+e),L===`testText`&&I(t=>t+e));return}if(ne===null){if(t.escape)i();else if(t.upArrow)L===`styling`&&ee>0?te(e=>e-1):le(e=>Math.max(0,e-1));else if(t.downArrow)L===`styling`&&ee<Qr.length-1?te(e=>e+1):le(e=>Math.min($r.length-1,e+1));else if(t.leftArrow)L===`foreground`?w(e=>e===`none`?`custom`:`none`):L===`background`?O(e=>e===`none`?`custom`:`none`):de(e=>Math.max(0,e-1));else if(t.rightArrow)if(L===`foreground`)w(e=>e===`none`?`custom`:`none`);else if(L===`background`)O(e=>e===`none`?`custom`:`none`);else{let e=$r[ce].length-1;de(t=>Math.min(e,t+1))}else if(t.tab){let e=$r.flat(),n=e.indexOf(L);if(t.shift){if(n>0){let t=e[n-1];for(let e=0;e<$r.length;e++){let n=$r[e].indexOf(t);if(n>=0){le(e),de(n);break}}}}else if(n<e.length-1){let t=e[n+1];for(let e=0;e<$r.length;e++){let n=$r[e].indexOf(t);if(n>=0){le(e),de(n);break}}}}else if(t.return)L===`name`||L===`regex`||L===`regexFlags`||L===`format`||L===`testText`?B(!0):L===`foreground`&&C===`custom`?(ae(T),re(`foreground`)):L===`background`&&D===`custom`&&(ae(k),re(`background`));else if(e===` `)if(L===`styling`){let e=Qr[ee].value;x.includes(e)?S(x.filter(t=>t!==e)):S([...x,e])}else L===`enabled`&&M(!j)}}),!s)return N(e,{flexDirection:`column`,children:N(t,{color:`red`,children:`Highlighter not found`})});if(ne)return N(zr,{initialValue:ie,theme:l,onColorChange:e=>{ne===`foreground`?E(e):ne===`background`&&A(e)},onExit:()=>{re(null),ae(``)}});let V=e=>L===e,H=e=>({color:V(e)?`yellow`:void 0,bold:V(e)});return P(e,{flexDirection:`column`,children:[N(X,{children:`Edit Highlighter`}),N(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:`arrows to navigate · enter to edit · space to toggle · esc to go back`})}),P(e,{flexDirection:`row`,gap:2,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`30%`,children:[P(t,{...H(`name`),children:[V(`name`)?`❯ `:` `,`Name`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`name`)?z?`green`:`yellow`:`gray`,children:N(t,{children:f||`(empty)`})})})]}),P(e,{flexDirection:`column`,width:`45%`,children:[P(t,{...H(`regex`),children:[V(`regex`)?`❯ `:` `,`Regex Pattern`]}),P(e,{marginLeft:2,flexDirection:`column`,children:[N(e,{borderStyle:`round`,borderColor:V(`regex`)?z?`green`:`yellow`:oe?`red`:`gray`,children:N(t,{children:h||`(empty)`})}),oe&&N(t,{color:`red`,children:oe})]})]}),P(e,{flexDirection:`column`,width:`20%`,children:[P(t,{...H(`regexFlags`),children:[V(`regexFlags`)?`❯ `:` `,`Flags`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`regexFlags`)?z?`green`:`yellow`:`gray`,children:N(t,{children:_||`g`})})})]})]}),P(e,{flexDirection:`row`,gap:2,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`50%`,children:[P(t,{...H(`format`),children:[V(`format`)?`❯ `:` `,`Format String`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`format`)?z?`green`:`yellow`:`gray`,children:N(t,{children:y||`{MATCH}`})})}),V(`format`)&&N(e,{marginLeft:2,children:P(t,{dimColor:!0,children:[`use `,`{MATCH}`,` as placeholder`]})})]}),P(e,{flexDirection:`column`,width:`45%`,children:[P(t,{...H(`styling`),children:[V(`styling`)?`❯ `:` `,`Styling`]}),N(e,{marginLeft:2,flexDirection:`column`,children:Qr.map((e,n)=>{let r=x.includes(e.value),i=V(`styling`)&&ee===n;return P(t,{color:i?`cyan`:void 0,children:[i?`❯ `:` `,r?`●`:`○`,` `,e.label]},e.value)})})]})]}),P(e,{flexDirection:`row`,gap:2,marginBottom:1,children:[P(e,{flexDirection:`column`,width:`48%`,children:[P(t,{...H(`foreground`),children:[V(`foreground`)?`❯ `:` `,`Foreground Color`]}),P(e,{marginLeft:2,flexDirection:`row`,gap:1,children:[P(t,{color:V(`foreground`)?`yellow`:void 0,children:[`[`,C===`none`?`●`:`○`,`] none`,` `,`[`,C===`custom`?`●`:`○`,`] custom`]}),C===`custom`&&N(e,{borderStyle:`round`,borderColor:V(`foreground`)?`yellow`:`gray`,children:N(t,{color:T,children:` ████ `})})]})]}),P(e,{flexDirection:`column`,width:`48%`,children:[P(t,{...H(`background`),children:[V(`background`)?`❯ `:` `,`Background Color`]}),P(e,{marginLeft:2,flexDirection:`row`,gap:1,children:[P(t,{color:V(`background`)?`yellow`:void 0,children:[`[`,D===`none`?`●`:`○`,`] none`,` `,`[`,D===`custom`?`●`:`○`,`] custom`]}),D===`custom`&&N(e,{borderStyle:`round`,borderColor:V(`background`)?`yellow`:`gray`,children:P(t,{backgroundColor:k,children:[` `,` `,` `]})})]})]})]}),N(e,{marginBottom:1,children:P(t,{...H(`enabled`),children:[V(`enabled`)?`❯ `:` `,`Enabled:`,` `,N(t,{color:j?`green`:`red`,children:j?`● Yes`:`○ No`})]})}),P(e,{flexDirection:`column`,marginBottom:1,children:[P(t,{...H(`testText`),children:[V(`testText`)?`❯ `:` `,`Test Text`]}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:V(`testText`)?z?`green`:`yellow`:`gray`,children:N(t,{children:F||`(empty)`})})})]}),N(e,{borderStyle:`round`,padding:1,children:P(e,{flexDirection:`column`,children:[N(t,{bold:!0,children:`Live Preview:`}),h?N(e,{marginTop:1,children:N(ei,{testText:F,regex:h,regexFlags:_,format:y,styling:x,foregroundColor:C===`custom`?T:void 0,backgroundColor:D===`custom`?k:void 0})}):N(t,{dimColor:!0,children:`Enter a regex pattern to see the preview`})]})})]})}function ni({onBack:n}){let{settings:{inputPatternHighlighters:i,themes:a},updateSettings:o}=u($),s=Yn(),c=a.find(e=>e.id===s)||a[0],l=q.themes[0],d=c?.colors.success||l.colors.success,f=c?.colors.error||l.colors.error,[p,h]=m(0),[g,_]=m(null),[v,y]=m(!0),b=()=>{let e={name:`New Highlighter`,regex:``,regexFlags:`g`,format:`{MATCH}`,styling:[],foregroundColor:`rgb(255,0,255)`,backgroundColor:null,enabled:!0};o(t=>{t.inputPatternHighlighters.push(e)}),_(i.length),y(!1)},x=e=>{o(t=>{t.inputPatternHighlighters.splice(e,1)}),p>=i.length-1&&h(Math.max(0,i.length-2))},S=e=>{o(t=>{t.inputPatternHighlighters[e].enabled=!t.inputPatternHighlighters[e].enabled})},C=e=>{e<=0||(o(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e-1,0,n)}),h(e-1))},w=e=>{e>=i.length-1||(o(t=>{let n=t.inputPatternHighlighters[e];t.inputPatternHighlighters.splice(e,1),t.inputPatternHighlighters.splice(e+1,0,n)}),h(e+1))};return r((e,t)=>{t.escape?n():t.upArrow?h(e=>Math.max(0,e-1)):t.downArrow&&i.length>0?h(e=>Math.min(i.length-1,e+1)):t.return&&i.length>0?(_(p),y(!1)):e===`n`?b():e===`x`&&i.length>0?x(p):e===` `&&i.length>0?S(p):e===`u`&&i.length>0&&p>0?C(p):e===`d`&&i.length>0&&p<i.length-1&&w(p)},{isActive:v}),g===null?P(e,{flexDirection:`column`,children:[N(X,{children:`Input Pattern Highlighters`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`Create custom highlighters for patterns in your input prompt.`}),N(t,{dimColor:!0,children:`Matched text will be styled and optionally reformatted.`})]}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new highlighter`}),i.length>0&&N(t,{dimColor:!0,children:`space to toggle enabled/disabled`}),i.length>0&&N(t,{dimColor:!0,children:`u/d to move highlighter up/down`}),i.length>0&&N(t,{dimColor:!0,children:`x to delete a highlighter`}),i.length>0&&N(t,{dimColor:!0,children:`enter to edit highlighter`}),N(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?N(t,{children:`No highlighters created yet. Press n to create one.`}):N(e,{flexDirection:`column`,children:i.map((n,r)=>{let i=p===r,a;return i&&(a=`yellow`),P(e,{flexDirection:`row`,children:[P(t,{color:a,children:[i?`❯ `:` `,n.enabled?`● `:`○ `,n.name,` `]}),N(t,{dimColor:!0,children:`(`}),n.regex?P(t,{dimColor:!0,children:[`/`,n.regex,`/`,n.regexFlags]}):N(t,{dimColor:!0,children:`(no regex)`}),n.styling.length>0&&N(M,{children:P(t,{color:a,dimColor:!n.enabled,children:[` `,`· `,n.styling.join(`, `)]})}),N(t,{dimColor:!0,children:`)`}),n.enabled?N(t,{color:d,children:` enabled`}):N(t,{color:f,children:` disabled`})]},r)})})]}):N(ti,{highlighterIndex:g,onBack:()=>{_(null),y(!0)}})}function ri({onSubmit:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(0),c={showTweakccVersion:!0,showPatchesApplied:!0,expandThinkingBlocks:!0,enableConversationTitle:!0,hideStartupBanner:!1,hideCtrlGToEdit:!1,hideStartupClawd:!1,increaseFileReadLimit:!1,suppressLineNumbers:!1,suppressRateLimitOptions:!1},l=()=>{i.misc||={...c}},d=f(()=>[{id:`removeBorder`,title:`Remove input box border`,description:`Removes the rounded border around the input box for a cleaner look.`,getValue:()=>i.inputBox?.removeBorder??!1,toggle:()=>{a(e=>{e.inputBox||={removeBorder:!1},e.inputBox.removeBorder=!e.inputBox.removeBorder})}},{id:`showVersion`,title:`Show tweakcc version at startup`,description:`Shows the blue "+ tweakcc v<VERSION>" message when starting Claude Code.`,getValue:()=>i.misc?.showTweakccVersion??!0,toggle:()=>{a(e=>{l(),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:()=>i.misc?.showPatchesApplied??!0,toggle:()=>{a(e=>{l(),e.misc.showPatchesApplied=!e.misc.showPatchesApplied})}},{id:`expandThinking`,title:`Expand thinking blocks`,description:`Makes thinking blocks always expanded by default instead of collapsed.`,getValue:()=>i.misc?.expandThinkingBlocks??!0,toggle:()=>{a(e=>{l(),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:()=>i.misc?.enableConversationTitle??!0,toggle:()=>{a(e=>{l(),e.misc.enableConversationTitle=!e.misc.enableConversationTitle})}},{id:`hideStartupBanner`,title:`Hide startup banner`,description:`Hides the startup banner message displayed before first prompt.`,getValue:()=>i.misc?.hideStartupBanner??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.hideCtrlGToEdit??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.hideStartupClawd??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.increaseFileReadLimit??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.suppressLineNumbers??!1,toggle:()=>{a(e=>{l(),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:()=>i.misc?.suppressRateLimitOptions??!1,toggle:()=>{a(e=>{l(),e.misc.suppressRateLimitOptions=!e.misc.suppressRateLimitOptions})}}],[i,a]),p=d.length,h=p-1,g=f(()=>o<4?0:Math.min(o-4+1,p-4),[o,p]),_=d.slice(g,g+4),v=g>0,y=g+4<p;return r((e,t)=>{t.return||t.escape?n():t.upArrow?s(e=>Math.max(0,e-1)):t.downArrow?s(e=>Math.min(h,e+1)):e===` `&&d[o]?.toggle()}),P(e,{flexDirection:`column`,children:[N(e,{marginBottom:1,children:N(X,{children:`Miscellaneous Settings`})}),N(e,{marginBottom:1,children:N(t,{dimColor:!0,children:`Various tweaks and customizations. Press space to toggle settings, enter to go back.`})}),v&&N(e,{children:P(t,{dimColor:!0,children:[` ↑ `,g,` more above`]})}),_.map((n,r)=>{let i=g+r===o,a=n.getValue()?`☑`:`☐`;return P(e,{flexDirection:`column`,children:[N(e,{children:P(t,{children:[N(t,{color:i?`cyan`:void 0,children:i?`❯ `:` `}),N(t,{bold:!0,color:i?`cyan`:void 0,children:n.title})]})}),N(e,{children:P(t,{dimColor:!0,children:[` `,n.description]})}),N(e,{marginLeft:4,marginBottom:1,children:P(t,{children:[a,` `,n.getValue()?`Enabled`:`Disabled`]})})]},n.id)}),y&&N(e,{children:P(t,{dimColor:!0,children:[` `,`↓ `,p-g-4,` more below`]})}),N(e,{marginTop:1,children:P(t,{dimColor:!0,children:[`Item `,o+1,` of `,p]})})]})}const ii=[`Task`,`Bash`,`Glob`,`Grep`,`Read`,`Edit`,`Write`,`NotebookEdit`,`WebFetch`,`WebSearch`,`BashOutput`,`KillShell`,`TodoWrite`,`AskUserQuestion`,`Skill`,`SlashCommand`,`EnterPlanMode`,`ExitPlanMode`,`LSP`];function ai({toolsetIndex:n,onBack:i}){let{settings:a,updateSettings:o}=u($),s=a.toolsets[n],[c,l]=m(s?.name||`New Toolset`),[f,p]=m(s?.allowedTools||[]),[h,g]=m(!1),[_,v]=m(0);d(()=>{s&&o(e=>{let t=e.toolsets[n].name;e.toolsets[n].name=c,e.toolsets[n].allowedTools=f,t!==c&&(e.defaultToolset===t&&(e.defaultToolset=c),e.planModeToolset===t&&(e.planModeToolset=c))})},[c,f]);let y=e=>f===`*`?!0:f.includes(e),b=e=>{e===`All`?p(`*`):e===`None`?p([]):f===`*`?p(ii.filter(t=>t!==e)):f.includes(e)?p(f.filter(t=>t!==e)):p([...f,e])};if(r((e,t)=>{if(h){t.return?g(!1):t.escape?(l(s?.name||`New Toolset`),g(!1)):t.backspace||t.delete?l(e=>e.slice(0,-1)):e&&e.length===1&&l(t=>t+e);return}if(t.escape)i();else if(t.upArrow)v(e=>Math.max(0,e-1));else if(t.downArrow)v(e=>Math.min(ii.length+1,e+1));else if(e===` `||t.return)if(_===0)b(`All`);else if(_===1)b(`None`);else{let e=ii[_-2];e&&b(e)}else e===`n`&&g(!0)}),!s)return N(e,{flexDirection:`column`,children:N(t,{color:`red`,children:`Toolset not found`})});let x=f===`*`,S=Array.isArray(f)&&f.length===0;return P(e,{flexDirection:`column`,children:[N(X,{children:`Edit Toolset`}),N(e,{marginBottom:1,flexDirection:`column`,children:N(t,{dimColor:!0,children:`n to edit name · space/enter to toggle · esc to go back`})}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{bold:!0,children:`Name:`}),N(e,{marginLeft:2,children:N(e,{borderStyle:`round`,borderColor:h?`yellow`:`gray`,children:N(t,{children:c})})}),h&&N(e,{marginLeft:2,children:N(t,{dimColor:!0,children:`enter to save · esc to cancel`})})]}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{bold:!0,children:`Allowed Tools:`}),N(e,{marginLeft:2,children:P(t,{color:_===0?`cyan`:void 0,children:[_===0?`❯ `:` `,x?`●`:`○`,` All`]})}),N(e,{marginLeft:2,children:P(t,{color:_===1?`cyan`:void 0,children:[_===1?`❯ `:` `,S?`●`:`○`,` None`]})}),ii.map((n,r)=>{let i=r+2;return N(e,{marginLeft:2,children:P(t,{color:_===i?`cyan`:void 0,children:[_===i?`❯ `:` `,y(n)?`◉`:`○`,` `,n]})},n)})]}),N(e,{borderStyle:`round`,padding:1,marginTop:1,children:P(e,{flexDirection:`column`,children:[N(t,{bold:!0,children:`Summary:`}),P(t,{children:[`Name: `,N(t,{color:`cyan`,children:c})]}),P(t,{children:[`Tools:`,` `,f===`*`?N(t,{color:`green`,children:`All tools (*)`}):f.length===0?N(t,{color:`red`,children:`No tools ([])`}):P(t,{color:`yellow`,children:[f.length,` selected`]})]})]})})]})}function oi({onBack:n}){let{settings:{toolsets:i,defaultToolset:a,planModeToolset:o,themes:s},updateSettings:c}=u($),l=Yn(),d=s.find(e=>e.id===l)||s[0],f=q.themes[0],p=d?.colors.planMode||f.colors.planMode,h=d?.colors.autoAccept||f.colors.autoAccept,[g,_]=m(0),[v,y]=m(null),[b,x]=m(!0),S=()=>{let e={name:`New Toolset`,allowedTools:[]};c(t=>{t.toolsets.push(e)}),y(i.length),x(!1)},C=e=>{let t=i[e];c(n=>{n.toolsets.splice(e,1),n.defaultToolset===t.name&&(n.defaultToolset=null),n.planModeToolset===t.name&&(n.planModeToolset=null)}),g>=i.length-1&&_(Math.max(0,i.length-2))},w=e=>{let t=i[e];c(e=>{e.defaultToolset=t.name})},T=e=>{let t=i[e];c(e=>{e.planModeToolset=t.name})};if(r((e,t)=>{t.escape?n():t.upArrow?_(e=>Math.max(0,e-1)):t.downArrow?_(e=>Math.min(i.length-1,e+1)):t.return&&i.length>0?(y(g),x(!1)):e===`n`?S():e===`x`&&i.length>0?C(g):e===`d`&&i.length>0?w(g):e===`p`&&i.length>0&&T(g)},{isActive:b}),v!==null)return N(ai,{toolsetIndex:v,onBack:()=>{y(null),x(!0)}});let E=e=>e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}`;return P(e,{flexDirection:`column`,children:[N(X,{children:`Toolsets`}),P(e,{marginBottom:1,flexDirection:`column`,children:[N(t,{dimColor:!0,children:`n to create a new toolset`}),i.length>0&&N(t,{dimColor:!0,children:`d to set as default toolset`}),i.length>0&&N(t,{dimColor:!0,children:`p to set as plan mode toolset`}),i.length>0&&N(t,{dimColor:!0,children:`x to delete a toolset`}),i.length>0&&N(t,{dimColor:!0,children:`enter to edit toolset`}),N(t,{dimColor:!0,children:`esc to go back`})]}),i.length===0?N(t,{children:`No toolsets created yet. Press n to create one.`}):N(e,{flexDirection:`column`,children:i.map((n,r)=>{let i=n.name===a,s=n.name===o,c=g===r,l;return c&&(l=`yellow`),P(e,{flexDirection:`row`,children:[P(t,{color:l,children:[c?`❯ `:` `,n.name,` `]}),P(t,{color:l,children:[`(`,E(n),`)`]}),i&&N(t,{color:h,children:` ⏵⏵ accept edits`}),s&&N(t,{color:p,children:` ⏸ plan mode`})]},r)})})]})}function si({onBack:n}){let{settings:i,updateSettings:a}=u($),[o,s]=m(`plan`),[c,l]=m(!1),[d,f]=m(0),p=i.subagentModels||{plan:null,explore:null,generalPurpose:null},h=[{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.`}],g=[{label:`Default (Inherited)`,value:null},{label:`sonnet`,value:`sonnet`},{label:`haiku`,value:`haiku`},{label:`opus`,value:`opus`},{label:`sonnet[1m]`,value:`sonnet[1m]`}];return r((e,t)=>{if(c){if(t.escape)l(!1);else if(t.upArrow)f(e=>e>0?e-1:g.length-1);else if(t.downArrow)f(e=>e<g.length-1?e+1:0);else if(t.return){let e=g[d].value;a(t=>{t.subagentModels||={plan:null,explore:null,generalPurpose:null},t.subagentModels[o]=e}),l(!1)}}else if(t.escape)n();else if(t.upArrow){let e=h.findIndex(e=>e.id===o);s(h[e>0?e-1:h.length-1].id)}else if(t.downArrow){let e=h.findIndex(e=>e.id===o);s(h[e<h.length-1?e+1:0].id)}else if(e===` `||t.return){let e=p[o],t=g.findIndex(t=>t.value===e);f(t>=0?t:0),l(!0)}}),c?P(e,{flexDirection:`column`,children:[N(e,{marginBottom:1,children:P(X,{children:[`Select Model for`,` `,h.find(e=>e.id===o)?.title]})}),g.map((n,r)=>{let i=r===d;return N(e,{children:P(t,{color:i?`cyan`:void 0,children:[i?`❯ `:` `,n.label,n.value?P(t,{dimColor:!0,children:[` (`,n.value,`)`]}):null]})},r)})]}):P(e,{flexDirection:`column`,children:[N(e,{marginBottom:1,children:N(X,{children:`Subagent Model Settings`})}),N(e,{marginBottom:1,children:N(t,{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.`})}),h.map(n=>{let r=n.id===o,i=p[n.id],a=g.find(e=>e.value===i)?.label||i||`Default`;return P(e,{flexDirection:`column`,marginBottom:1,children:[N(e,{children:P(t,{color:r?`cyan`:void 0,children:[r?`❯ `:` `,N(t,{bold:!0,children:n.title})]})}),N(e,{marginLeft:4,children:N(t,{dimColor:!0,children:n.description})}),N(e,{marginLeft:4,children:P(t,{children:[`Current: `,N(t,{color:`green`,children:a})]})})]},n.id)})]})}const $=c({settings:q,updateSettings:e=>{},changesApplied:!1,ccVersion:``});function ci({startupCheckInfo:t,configMigrated:n}){let[i,a]=m({settings:q,changesApplied:!1,ccVersion:``,lastModified:``}),[o,s]=m(!1);d(()=>{(async()=>{let e=await Sr();a(e),s(!e.hidePiebaldAnnouncement)})()},[]);let c=l(e=>{let t=JSON.parse(JSON.stringify(i.settings));e(t),a(e=>({...e,settings:t,changesApplied:!1})),Cr(e=>{e.settings=t,e.changesApplied=!1})},[i.settings]),[u,f]=m(null),[p,h]=m(null);d(()=>{t.wasUpdated&&t.oldVersion&&(h({message:`Your Claude Code installation was updated from ${t.oldVersion} to ${t.newVersion}, and the patching was likely overwritten
|
|
640
|
+
(However, your customization are still remembered in ${Y}.)
|
|
641
|
+
Please reapply your changes below.`,type:`warning`}),c(()=>{}))},[]),r((e,t)=>{t.ctrl&&e===`c`&&process.exit(0),(e===`q`||t.escape)&&!u&&process.exit(0),e===`h`&&!u&&o&&(s(!1),Cr(e=>{e.hidePiebaldAnnouncement=!0}))},{isActive:!u});let g=e=>{switch(h(null),e){case Z.APPLY_CHANGES:t.ccInstInfo&&(h({message:`Applying patches...`,type:`info`}),zn(i,t.ccInstInfo).then(e=>{a(e),h({message:`Customization patches applied successfully!`,type:`success`})}));break;case Z.THEMES:case Z.THINKING_VERBS:case Z.THINKING_STYLE:case Z.USER_MESSAGE_DISPLAY:case Z.INPUT_PATTERN_HIGHLIGHTERS:case Z.MISC:case Z.TOOLSETS:case Z.SUBAGENT_MODELS:f(e);break;case Z.VIEW_SYSTEM_PROMPTS:Qn(_r);break;case Z.RESTORE_ORIGINAL:t.ccInstInfo&&(t.ccInstInfo.nativeInstallationPath?Dn(t.ccInstInfo):En(t.ccInstInfo)).then(()=>{h({message:`Original Claude Code restored successfully!`,type:`success`}),c(()=>{})});break;case Z.OPEN_CONFIG:$n(Y);break;case Z.OPEN_CLI:t.ccInstInfo?.cliPath&&$n(t.ccInstInfo.cliPath);break;case Z.EXIT:process.exit(0)}},_=()=>{f(null)};return N($.Provider,{value:{settings:i.settings,updateSettings:c,changesApplied:i.changesApplied,ccVersion:t.ccInstInfo?.version||``},children:N(e,{flexDirection:`column`,children:u===null?N(Pr,{onSubmit:g,notification:p,configMigrated:n,showPiebaldAnnouncement:o}):u===Z.THEMES?N(Wr,{onBack:_}):u===Z.THINKING_VERBS?N(Gr,{onBack:_}):u===Z.THINKING_STYLE?N(qr,{onBack:_}):u===Z.USER_MESSAGE_DISPLAY?N(Zr,{onBack:_}):u===Z.INPUT_PATTERN_HIGHLIGHTERS?N(ni,{onBack:_}):u===Z.MISC?N(ri,{onSubmit:_}):u===Z.TOOLSETS?N(oi,{onBack:_}):u===Z.SUBAGENT_MODELS?N(si,{onBack:_}):null})})}const li=(()=>{let e=[],t=process.platform==`win32`?g.homedir().replace(/\\/g,`/`):g.homedir(),n=`node_modules/@anthropic-ai/claude-code`,r=(t,n=!1)=>{if(n)try{let n=R(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`)?G(`Permission denied accessing: ${t} (${n.code})`):G(`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(`${g.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),ui=(()=>{let e=process.platform===`win32`?g.homedir().replace(/\\/g,`/`):g.homedir(),t=[],n=(e,n=!1)=>{if(n)try{let n=R(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`)?G(`Permission denied accessing: ${e} (${n.code})`):G(`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]})};return n(`${e}/.local/bin/claude`),n(`${e}/.local/share/claude/versions/*`,!0),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 di=class extends Error{constructor(e){super(e),this.name=`InstallationDetectionError`}};let fi=null;async function pi(){return fi||=L.create(),fi}async function mi(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 G(`Failed to read file prefix:`,e),null}}async function hi(e){try{let t=await b.realpath(e);G(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await mi(t);if(!n)return G(`resolvePathToInstallationType: Could not read file prefix`),null;let r=await pi(),i=null;if(typeof r.detect==`function`&&(i=r.detect(n)||null),!i)return G(`resolvePathToInstallationType: WASMagic returned no mime type`),null;let a=i.toLowerCase();return G(`resolvePathToInstallationType: Detected mime type: ${a}`),a.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:a.startsWith(`text/`)?(G(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:t}}catch(e){return G(`resolvePathToInstallationType: Error:`,e),null}}async function gi(){try{let e=await I(`claude`);return G(`getClaudeFromPath: Found claude at ${e}`),e}catch{return G(`getClaudeFromPath: claude not found on PATH`),null}}function _i(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())G(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&G(`Extracted version ${a} (${i} occurrences)`),a||null}async function vi(e){let t=_i(await b.readFile(e,`utf8`));if(!t)throw Error(`No VERSION strings found in JS file: ${e}`);return t}async function yi(e){let t=await ee(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}`);let n=_i(t.toString(`utf8`));if(!n)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return n}function bi(e){let t=D.basename(e).match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function xi(e,t){let n=bi(e);return n?(G(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?vi(e):yi(e)}async function Si(){let e=[],t=new Set;for(let n of li){let r=D.join(n,`cli.js`);if(!t.has(r))try{if(await ir(r)){G(`collectCandidates: Found cli.js at ${r}`);let n=await vi(r);e.push({path:r,kind:`npm-based`,version:n}),t.add(r)}}catch(e){G(`collectCandidates: Error checking ${r}:`,e)}}for(let n of ui)if(!t.has(n))try{if(await ir(n)){G(`collectCandidates: Found native binary at ${n}`);let r=await xi(n,`native-binary`);e.push({path:n,kind:`native-binary`,version:r}),t.add(n)}}catch(e){G(`collectCandidates: Error checking ${n}:`,e)}return[...e].sort((e,t)=>or(e.version,t.version))}function Ci(e){return e.map(e=>` • ${e.path} (${e.kind}, v${e.version})`).join(`
|
|
642
|
+
`)}function wi(e){return` 2. Set ccInstallationPath in your config file (${Y}):
|
|
643
643
|
|
|
644
644
|
{
|
|
645
645
|
"ccInstallationPath": "${e}"
|
|
646
|
-
}`}function
|
|
646
|
+
}`}function Ti(e){return` 1. Set the TWEAKCC_CC_INSTALLATION_PATH environment variable:
|
|
647
647
|
|
|
648
|
-
export TWEAKCC_CC_INSTALLATION_PATH="${e}"`}function
|
|
648
|
+
export TWEAKCC_CC_INSTALLATION_PATH="${e}"`}function Ei(e){let t=e[0]?.path||`/path/to/claude`;return`Multiple Claude Code installations found.
|
|
649
649
|
|
|
650
650
|
Found installations:
|
|
651
|
-
${
|
|
651
|
+
${Ci(e)}
|
|
652
652
|
|
|
653
653
|
To specify which installation to use, either:
|
|
654
654
|
|
|
655
|
-
${
|
|
655
|
+
${Ti(t)}
|
|
656
656
|
|
|
657
|
-
${
|
|
657
|
+
${wi(t)}`}function Di(){return`Could not find Claude Code installation.
|
|
658
658
|
|
|
659
659
|
To fix this, either:
|
|
660
660
|
|
|
661
|
-
${
|
|
661
|
+
${Ti(`/path/to/claude`)}
|
|
662
662
|
|
|
663
|
-
${
|
|
663
|
+
${wi(`/path/to/claude`)}
|
|
664
664
|
|
|
665
665
|
3. Install Claude Code:
|
|
666
666
|
• npm install -g @anthropic-ai/claude-code
|
|
667
|
-
• Or download from https://claude.ai/download`}function
|
|
667
|
+
• Or download from https://claude.ai/download`}function Oi(e,t,n,r){return t===`npm-based`?{cliPath:e,version:n,source:r}:{nativeInstallationPath:e,version:n,source:r}}async function ki(e,t){let n=process.env.TWEAKCC_CC_INSTALLATION_PATH?.trim();if(n&&n.length>0){if(G(`Checking TWEAKCC_CC_INSTALLATION_PATH: ${n}`),!await ir(n))throw new di(`TWEAKCC_CC_INSTALLATION_PATH is set to '${n}' but file does not exist.`);let e=await hi(n);if(!e)throw new di(`Unable to detect installation type from TWEAKCC_CC_INSTALLATION_PATH value '${n}'.\nExpected a Claude Code cli.js file or native binary.`);let t=await xi(e.resolvedPath,e.kind);return Gn()&&e.kind===`npm-based`&&G(`SHA256 hash: ${await nr(e.resolvedPath)}`),G(`Using Claude Code from TWEAKCC_CC_INSTALLATION_PATH: ${e.resolvedPath} (${e.kind}, v${t})`),Oi(e.resolvedPath,e.kind,t,`env-var`)}if(e.ccInstallationPath){let t=e.ccInstallationPath;if(G(`Checking ccInstallationPath: ${t}`),!await ir(t))throw new di(`ccInstallationPath is set to '${t}' but file does not exist.`);let n=await hi(t);if(!n)throw new di(`Unable to detect installation type from configured ccInstallationPath '${t}'.\nExpected a Claude Code cli.js file or native binary.`);let r=await xi(n.resolvedPath,n.kind);return Gn()&&n.kind===`npm-based`&&G(`SHA256 hash: ${await nr(n.resolvedPath)}`),G(`Using Claude Code from ccInstallationPath: ${n.resolvedPath} (${n.kind}, v${r})`),Oi(n.resolvedPath,n.kind,r,`config`)}let r=await gi();if(r){G(`Checking claude on PATH: ${r}`);let e=await hi(r);if(!e)G(`Unable to detect installation type from 'claude' on PATH (${r}). Falling back to hardcoded search paths.`);else{let t=await xi(e.resolvedPath,e.kind);return Gn()&&e.kind===`npm-based`&&G(`SHA256 hash: ${await nr(e.resolvedPath)}`),G(`Using Claude Code from PATH: ${e.resolvedPath} (${e.kind}, v${t})`),Oi(e.resolvedPath,e.kind,t,`path`)}}G(`Collecting candidates from hardcoded search paths...`);let i=await Si();if(i.length===0){if(t.interactive)return null;throw new di(Di())}if(i.length===1){let e=i[0];return G(`Using single candidate: ${e.path} (${e.kind}, v${e.version})`),Oi(e.path,e.kind,e.version,`search-paths`)}if(!t.interactive)throw new di(Ei(i));return{version:``,source:`search-paths`,_pendingCandidates:i}}function Ai(e){return e._pendingCandidates||null}async function ji(e){return G(`Saving selected installation to config: ${e.path}`),await Cr(t=>{t.ccInstallationPath=e.path}),Oi(e.path,e.kind,e.version,`config`)}function Mi(){return Di()}async function Ni(e){let t=await Sr(),n=await ki(t,e);if(!n)return{startupCheckInfo:null,pendingCandidates:null};let r=Ai(n);return r?{startupCheckInfo:null,pendingCandidates:r}:{startupCheckInfo:await Pi(t,n),pendingCandidates:null}}async function Pi(e,t){if(!t)return null;if(t.version)try{Ot(await _t(t.version))}catch{}let n=t.version,r=e.ccVersion,i=!1;await ir(hr)||(G(`startupCheck: ${hr} not found; backing up cli.js`),await wn(t),i=!0);let a=!1;return t.nativeInstallationPath&&!await ir(gr)&&(G(`startupCheck: ${gr} not found; backing up native binary`),await Tn(t),a=!0),n===r?{wasUpdated:!1,oldVersion:null,newVersion:null,ccInstInfo:t}:(i||(G(`startupCheck: real version (${n}) != backed up version (${r}); backing up cli.js`),await b.unlink(hr),await wn(t)),t.nativeInstallationPath&&!a&&(G(`startupCheck: real version (${n}) != backed up version (${r}); backing up native binary`),await ir(gr)&&await b.unlink(gr),await Tn(t)),{wasUpdated:!0,oldVersion:r,newVersion:n,ccInstInfo:t})}function Fi({candidates:n,onSelect:i}){let[a,o]=m(0);return r((e,t)=>{t.escape?process.exit(0):t.upArrow?o(e=>e>0?e-1:n.length-1):t.downArrow?o(e=>e<n.length-1?e+1:0):t.return&&i(n[a])}),P(e,{flexDirection:`column`,children:[N(t,{bold:!0,color:`yellow`,children:`No claude executable was found in PATH, and multiple Claude Code installations were found. Please select one:`}),N(t,{children:` `}),n.map((n,r)=>P(e,{children:[P(t,{bold:r===a,color:r===a?`cyan`:void 0,children:[r===a?`❯ `:` `,n.path]}),P(t,{dimColor:!0,children:[` `,`(`,n.kind,`, v`,n.version,`)`]})]},n.path)),N(t,{children:` `}),P(t,{children:[`Your choice will be saved to`,` `,N(t,{color:`blue`,children:`ccInstallationPath`}),` in`,` `,P(t,{color:`blue`,children:[J.replace(h.homedir(),`~`),`/config.json`]}),`.`]}),N(t,{children:` `}),N(t,{dimColor:!0,children:`Use ↑↓ arrows to navigate, Enter to select, Esc to quit`})]})}const Ii=async()=>{let e=new i;e.name(`tweakcc`).description(`Command-line tool to customize your Claude Code theme colors, thinking verbs and more.`).version(`3.4.0`).option(`-d, --debug`,`enable debug mode`).option(`-v, --verbose`,`enable verbose debug mode (includes diffs)`).option(`-a, --apply`,`apply saved customizations without interactive UI`),e.parse();let t=e.opts();t.verbose?Jn():t.debug&&qn();let n=await dr();if(t.apply){await Li();return}await Ri(n)};async function Li(){console.log(`Applying saved customizations to Claude Code...`),console.log(`Configuration saved at: ${Y}`);let e=await Sr();(!e.settings||Object.keys(e.settings).length===0)&&(console.error(`No saved customizations found in `+Y),process.exit(1));try{let t=await Ni({interactive:!1});(!t.startupCheckInfo||!t.startupCheckInfo.ccInstInfo)&&(console.error(Mi()),process.exit(1));let{ccInstInfo:n}=t.startupCheckInfo;n.nativeInstallationPath?console.log(`Found Claude Code (native installation): ${n.nativeInstallationPath}`):console.log(`Found Claude Code at: ${n.cliPath}`),console.log(`Version: ${n.version}`),console.log(`Loading system prompts...`);let r=await bt(n.version);r.success||(console.log(a.red(`
|
|
668
668
|
✖ Error downloading system prompts:`)),console.log(a.red(` ${r.errorMessage}`)),console.log(a.yellow(`
|
|
669
|
-
⚠ System prompts not available - skipping system prompt customizations`))),console.log(`Applying customizations...`),await
|
|
669
|
+
⚠ System prompts not available - skipping system prompt customizations`))),console.log(`Applying customizations...`),await zn(e,n),console.log(`Customizations applied successfully!`),process.exit(0)}catch(e){throw e instanceof di&&(console.error(a.red(`Error: ${e.message}`)),process.exit(1)),e}}async function Ri(e){try{let t=await Ni({interactive:!0});if(t.pendingCandidates){await zi(t.pendingCandidates,e);return}t.startupCheckInfo||(console.error(a.red(Mi())),process.exit(1)),await Bi(t.startupCheckInfo,e)}catch(e){throw e instanceof di&&(console.error(a.red(`Error: ${e.message}`)),process.exit(1)),e}}async function zi(e,t){return new Promise((r,i)=>{let o=n(N(Fi,{candidates:e,onSelect:async e=>{try{let n=await ji(e),i=await Pi(await Sr(),n);i||(console.error(a.red(`Error: Failed to complete startup check after selection.`)),process.exit(1)),o.unmount(),await Bi(i,t),r()}catch(e){i(e)}}}))})}async function Bi(e,t){let r=await bt(e.ccInstInfo.version);r.success||(console.log(a.red(`
|
|
670
670
|
✖ Error downloading system prompts:`)),console.log(a.red(` ${r.errorMessage}`)),console.log(a.yellow(`⚠ System prompts not available - system prompt customizations will be skipped
|
|
671
|
-
`))),n(
|
|
671
|
+
`))),n(N(ci,{startupCheckInfo:e,configMigrated:t}))}Ii();export{Gn as n,G as t};
|