tweakcc-fixed 2.7.26 → 2.7.28
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 +4 -4
- package/dist/{config-DavJt5YD.mjs → config-BEI9_PWQ.mjs} +5 -5
- package/dist/{content-tmuIYrP1.mjs → content-DhLuiI4m.mjs} +1 -1
- package/dist/identifierUnion-BgceXnlI.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/{nativeInstallation-JIix3X_a.mjs → nativeInstallation-DRr0xN5l.mjs} +1 -1
- package/package.json +1 -1
- package/dist/identifierUnion-Dhy0TLxP.mjs +0 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/tweakcc-fixed)
|
|
8
8
|
[](https://www.npmjs.com/package/tweakcc-fixed)
|
|
9
|
-
[](https://github.com/anthropics/claude-code)
|
|
10
10
|
[](#credit--license)
|
|
11
11
|
|
|
12
12
|
**[Install](#install) · [Customize](#what-you-can-customize) · [The fork](#what-this-fork-adds) · [How it works](#how-it-works)**
|
|
@@ -57,9 +57,9 @@ The biggest difference is coverage. Its extractor pulls over four times the prom
|
|
|
57
57
|
|
|
58
58
|
| | tweakcc-fixed | upstream |
|
|
59
59
|
| ---------------------------- | :-----------: | :-------: |
|
|
60
|
-
| Prompt sites (CC 2.1.
|
|
61
|
-
| Unique prompt IDs | **3,
|
|
62
|
-
| Patches | **
|
|
60
|
+
| Prompt sites (CC 2.1.233) | **4,061** | 670 |
|
|
61
|
+
| Unique prompt IDs | **3,779** | 670 |
|
|
62
|
+
| Patches | **61** | 45 |
|
|
63
63
|
| Overrides on native installs | **yes** | gated off |
|
|
64
64
|
|
|
65
65
|
That reach shows up in a few mechanisms the base doesn't have. The `<system-reminder>` injections that fire per turn — and never surface as named prompts — become editable: blank one out to drop it, or rewrite it. Each connected MCP server's instruction block can be dropped or rewritten the same way. And where upstream gates system-prompt overrides off for native installs, this fork applies them. It pairs with [lobotomized-claude-code](https://github.com/skrabe/lobotomized-claude-code), a set of per-model override packs tuned against exactly this extraction.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c,{createReadStream as l}from"node:fs";import*as u from"node:path";import d from"node:path";import*as f from"fs";import*as p from"path";import*as m from"os";import*as h from"child_process";import*as g from"crypto";import{spawnSync as _}from"node:child_process";import v from"gray-matter";import{fileURLToPath as y}from"node:url";import{Worker as b}from"node:worker_threads";import{diffWordsWithSpace as x}from"diff";import*as S from"node:crypto";let C=null;async function w(){if(C!==null)return C;try{return await import(`node-lief`),C=await import(`./nativeInstallation-
|
|
1
|
+
import{createRequire as e}from"node:module";import t from"chalk";import*as n from"node:os";import r,{EOL as i}from"node:os";import*as a from"node:fs/promises";import o from"node:fs/promises";import*as s from"node:fs";import c,{createReadStream as l}from"node:fs";import*as u from"node:path";import d from"node:path";import*as f from"fs";import*as p from"path";import*as m from"os";import*as h from"child_process";import*as g from"crypto";import{spawnSync as _}from"node:child_process";import v from"gray-matter";import{fileURLToPath as y}from"node:url";import{Worker as b}from"node:worker_threads";import{diffWordsWithSpace as x}from"diff";import*as S from"node:crypto";let C=null;async function w(){if(C!==null)return C;try{return await import(`node-lief`),C=await import(`./nativeInstallation-DRr0xN5l.mjs`),C}catch(e){return q(`Error loading native installation module: ${e instanceof Error?e.message:String(e)}`),e instanceof Error&&q(e),null}}async function T(e,t){let n=await w();return n?n.extractClaudeJsFromNativeInstallation(e,t):{data:null,clearBytecode:!1,error:`node-lief native module unavailable on this platform/runtime (cannot extract from native installs)`}}async function E(e,t,n,r){let i=await w();if(!i)throw Error("`repackNativeInstallation()` called but `node-lief` is not available. This is unexpected - `extractClaudeJsFromNativeInstallation()` should have been called first.");i.repackNativeInstallation(e,t,n,r)}async function D(e){let t=await w();return t?t.resolveNixBinaryWrapper(e):null}const O=`You are a difficulty router for an AI coding agent. Each turn you get a compact running SUMMARY of the session, a CONTEXT block (the model in use and the level you assigned last turn), the most recent exchange (the previous user message and the assistant reply), and the user NEW message. Do two things and output ONLY a JSON object with the keys level and summary - no prose, no code fence.
|
|
2
2
|
|
|
3
3
|
# level
|
|
4
4
|
Pick the integer effort level (0 = least effort, {MAX} = most) for the NEW message, judged IN CONTEXT of the summary, the context block, and the recent exchange:
|
|
@@ -53,7 +53,7 @@ No human input has been received since the last genuine user message in this con
|
|
|
53
53
|
{{content}}`,apply(e,t,n){let r=e.match(/([$\w]+)=`\$\{"\[SYSTEM NOTIFICATION - NOT USER INPUT\]"\}\nThis is an automated background-task event, NOT a message from the user\.\nDo NOT interpret this as user acknowledgement, confirmation, or response to any pending question\.\n[^`]*`/);if(r&&r.index!==void 0){let i=n?``:t.replace(/\$\{H\}/g,``),a=`${r[1]}=\`${i}\``,o=e.slice(0,r.index)+a+e.slice(r.index+r[0].length);return V(e,o,a,r.index,r.index+r[0].length),o}return P(e,/(case"task-notification":return|function [$\w]+\([$\w]+\)\{return)`\[SYSTEM NOTIFICATION - NOT USER INPUT\]\nThis is an automated background-task event, NOT a message from the user\.\nDo NOT interpret this as user acknowledgement, confirmation, or response to any pending question\.\n\n\$\{([$\w]+)\}`(;|\})/,e=>{let[,r,i,a]=e;return n?`${r}\`\${${i}}\`${a}`:`${r}\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\`${a}`},`task-notification-framing`,e=>/case"task-notification":return`\$\{[$\w]+\}`;/.test(e))}},{id:`user-sent-new-message`,name:`User-sent-new-message wrapper`,description:`Wraps a user message that arrives mid-turn. Carries the "This is how Claude Code surfaces messages the user sends mid-turn … Address the message above as you continue this turn" framing (reworded in CC 2.1.205 from the old imperative "IMPORTANT: … you MUST address … Do not ignore it"). Empty .md = no wrapping (just the message text).`,shadows:[`system-reminder-mid-turn-user-message-surfacing`],placeholders:{message:"${H}"},defaultBody:`The user sent a new message while you were working:
|
|
54
54
|
{{message}}
|
|
55
55
|
|
|
56
|
-
This is how Claude Code surfaces messages the user sends mid-turn — within the running turn, often alongside the next tool result, rather than as a separate conversation turn. Address the message above as you continue this turn.`,apply(e,t,n){return P(e,/((?:case"auto-continuation":)?case"human":case void 0:(?:default:)?)return`(?:The user sent a new message while you were working:\n|\$\{[$\w]+\})\$\{([$\w]+)\}\n\n(?:This is how Claude Code surfaces messages the user sends mid-turn \\u2014 within the running turn, often alongside the next tool result, rather than as a separate conversation turn\. Address the message above as you continue this turn\.|IMPORTANT: After completing your current task, you MUST address the user's message above\. Do not ignore it\.)`/,e=>{let[,r,i]=e;return n?`${r}return\`\${${i}}\``:`${r}return\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`user-sent-new-message`,e=>/(?:case"auto-continuation":)?case"human":case void 0:(?:default:)?return`\$\{[$\w]+\}`/.test(e))}},{id:`stop-hook-session-goal`,name:`Stop-hook session-goal reminder`,description:`Fires when /goal sets a session-scoped stop hook. Carries the "do not pause to ask" framing. Empty .md = silent goal activation (just the condition value used internally).`,placeholders:{condition:"${H}"},defaultBody:'A session-scoped Stop hook is now active with condition: "{{condition}}". Briefly acknowledge the goal, then immediately start (or continue) working toward it — treat the condition itself as your directive and do not pause to ask the user what to do. The hook will block stopping until the condition holds. It auto-clears once the condition is met — do not tell the user to run `/goal clear` after success; that\'s only for clearing a goal early.',apply(e,t,n){return P(e,/([$\w]+)=\(([$\w]+)\)=>`A session-scoped Stop hook is now active with condition: "\$\{\2\}"\. Briefly acknowledge the goal, then immediately start \(or continue\) working toward it[\s\S]*?after success; that's only for clearing a goal early\.`/,e=>{let[,r,i]=e;return n?`${r}=(${i})=>""`:`${r}=(${i})=>\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`stop-hook-session-goal`,e=>/[$\w]+=\([$\w]+\)=>""/.test(e))}},{id:`mcp-per-server-router`,name:`MCP per-server instruction router`,description:`Patches CC's MCP instruction assembly to consult ~/.tweakcc/system-reminders/mcp-<server-name>.md at runtime. Empty body in that file drops the server's block. Body containing {{server_instructions}} resolves to the server's pristine instructions. Custom body replaces. THIS .md does nothing on its own — it just enables per-server .md files. Empty body = disable this routing (servers use pristine instructions verbatim).`,placeholders:{},defaultBody:`This file is a marker that enables per-MCP-server overrides. Edit per-server content in mcp-<server-name>.md alongside this file. Leave this file with content (any content) to enable routing; empty it to disable.`,apply(e,t,n){if(n)return e;let r=e.match(/for\(let ([$\w]+) of ([$\w]+)\)if\(\1\.instructions\)([$\w]+)\.set\(\1\.name,`## \$\{\1\.name\}\n\$\{\1\.instructions\}`\);/);if(!r||r.index===void 0)return e.includes(`__tweakccMcpOverride`)?e:(console.error(`patch: reminder mcp-per-server-router: failed to find MCP assembly loop`),null);let[i,a,o,s]=r,c=`function __tweakccMcpOverride(_n,_d){try{let _f=require('fs'),_p=require('os').homedir()+'/.tweakcc/system-reminders/mcp-'+_n+'.md';let _r=_f.readFileSync(_p,'utf8');let _m=_r.match(/-->\\s*([\\s\\S]*?)\\s*\$/);if(!_m)return _d;let _b=_m[1].trim();if(_b==='')return null;return _b.replace(/\\{\\{server_instructions\\}\\}/g,_d||'')}catch{return _d}}for(let ${a} of ${o}){let _c=__tweakccMcpOverride(${a}.name,${a}.instructions);if(_c)${s}.set(${a}.name,\`## \${${a}.name}\n\${_c}\`)}`,l=e.slice(0,r.index)+c+e.slice(r.index+i.length);return V(e,l,c,r.index,r.index+i.length),l}}],bt=async()=>{let e=[u.join(n.homedir(),`.claude.json`),u.join(n.homedir(),`.claude`,`mcp.json`)];for(let t of e)try{let e=await a.readFile(t,`utf8`),n=JSON.parse(e);if(n.mcpServers&&typeof n.mcpServers==`object`)return Object.keys(n.mcpServers)}catch{}return[]},xt=async(e,t)=>{let n=[],r=e,i=await bt();for(let e of i)await pt(`mcp-${e}`,`MCP server: ${e}`,`Instructions block content for MCP server "${e}". {{server_instructions}} expands at runtime to the server's pristine instructions. Empty body drops the server's block from the model's context. Custom body replaces it.`,t,[`server_instructions`],`{{server_instructions}}`);for(let e of yt){let i=await pt(e.id,e.name,e.description,t,Object.keys(e.placeholders),e.defaultBody),a=await ft(e.id);if(!a){n.push({id:e.id,name:e.name,description:e.description,state:`default`,applied:!1,failed:!1,skipped:!0,details:`override file missing after ensure (unexpected)`});continue}let{result:o,errors:s}=mt(a.body,e.placeholders);if(s.length>0){n.push({id:e.id,name:e.name,description:e.description,state:`override`,applied:!1,failed:!0,skipped:!1,details:s.join(`; `)});continue}let c=e.apply(r,o,a.isSuppressed);if(c===null){n.push({id:e.id,name:e.name,description:e.description,state:a.isSuppressed?`suppressed`:`override`,applied:!1,failed:!0,skipped:!1,details:`patch function returned null`});continue}let l=c!==r;r=c;let u;u=a.isSuppressed?`suppressed`:a.body===e.defaultBody.trim()?`default`:`override`,n.push({id:e.id,name:e.name,description:e.description,state:u,applied:l,failed:!1,skipped:!1,details:i?`seeded default file`:void 0})}return{content:r,results:n}};let St=null;const Ct=async()=>{if(St)return St;let e=new Set,t=[Q,hc];for(let n of t){let t;try{t=await a.readdir(n)}catch{continue}if(Array.isArray(t))for(let r of t){if(!r.endsWith(`.md`))continue;let t;try{t=await a.readFile(p.join(n,r),`utf8`)}catch{continue}let i=v(t,{delimiters:[`<!--`,`-->`]}).data?.shadows;if(Array.isArray(i))for(let t of i)typeof t==`string`&&t&&e.add(t)}}for(let t of yt)if(Array.isArray(t.shadows))for(let n of t.shadows)typeof n==`string`&&n&&e.add(n);return St=e,e};let wt=null;const Tt=async()=>{if(wt)return wt;let e=new Set,t=qe();if(t){let n;try{n=await a.readdir(t)}catch{n=[]}for(let r of n)if(!(!r.startsWith(`prompts-`)||!r.endsWith(`.json`)))try{let n=await a.readFile(p.join(t,r),`utf8`),i=JSON.parse(n);for(let t of i.prompts??[])for(let n of Object.values(t.identifierMap??{}))n&&e.add(n)}catch{continue}}if(e.size===0)try{let t=await import(`./identifierUnion-
|
|
56
|
+
This is how Claude Code surfaces messages the user sends mid-turn — within the running turn, often alongside the next tool result, rather than as a separate conversation turn. Address the message above as you continue this turn.`,apply(e,t,n){return P(e,/((?:case"auto-continuation":)?case"human":case void 0:(?:default:)?)return`(?:The user sent a new message while you were working:\n|\$\{[$\w]+\})\$\{([$\w]+)\}\n\n(?:This is how Claude Code surfaces messages the user sends mid-turn \\u2014 within the running turn, often alongside the next tool result, rather than as a separate conversation turn\. Address the message above as you continue this turn\.|IMPORTANT: After completing your current task, you MUST address the user's message above\. Do not ignore it\.)`/,e=>{let[,r,i]=e;return n?`${r}return\`\${${i}}\``:`${r}return\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`user-sent-new-message`,e=>/(?:case"auto-continuation":)?case"human":case void 0:(?:default:)?return`\$\{[$\w]+\}`/.test(e))}},{id:`stop-hook-session-goal`,name:`Stop-hook session-goal reminder`,description:`Fires when /goal sets a session-scoped stop hook. Carries the "do not pause to ask" framing. Empty .md = silent goal activation (just the condition value used internally).`,placeholders:{condition:"${H}"},defaultBody:'A session-scoped Stop hook is now active with condition: "{{condition}}". Briefly acknowledge the goal, then immediately start (or continue) working toward it — treat the condition itself as your directive and do not pause to ask the user what to do. The hook will block stopping until the condition holds. It auto-clears once the condition is met — do not tell the user to run `/goal clear` after success; that\'s only for clearing a goal early.',apply(e,t,n){return P(e,/([$\w]+)=\(([$\w]+)\)=>`A session-scoped Stop hook is now active with condition: "\$\{\2\}"\. Briefly acknowledge the goal, then immediately start \(or continue\) working toward it[\s\S]*?after success; that's only for clearing a goal early\.`/,e=>{let[,r,i]=e;return n?`${r}=(${i})=>""`:`${r}=(${i})=>\`${t.replace(/\$\{H\}/g,`\${${i}}`)}\``},`stop-hook-session-goal`,e=>/[$\w]+=\([$\w]+\)=>""/.test(e))}},{id:`mcp-per-server-router`,name:`MCP per-server instruction router`,description:`Patches CC's MCP instruction assembly to consult ~/.tweakcc/system-reminders/mcp-<server-name>.md at runtime. Empty body in that file drops the server's block. Body containing {{server_instructions}} resolves to the server's pristine instructions. Custom body replaces. THIS .md does nothing on its own — it just enables per-server .md files. Empty body = disable this routing (servers use pristine instructions verbatim).`,placeholders:{},defaultBody:`This file is a marker that enables per-MCP-server overrides. Edit per-server content in mcp-<server-name>.md alongside this file. Leave this file with content (any content) to enable routing; empty it to disable.`,apply(e,t,n){if(n)return e;let r=e.match(/for\(let ([$\w]+) of ([$\w]+)\)if\(\1\.instructions\)([$\w]+)\.set\(\1\.name,`## \$\{\1\.name\}\n\$\{\1\.instructions\}`\);/);if(!r||r.index===void 0)return e.includes(`__tweakccMcpOverride`)?e:(console.error(`patch: reminder mcp-per-server-router: failed to find MCP assembly loop`),null);let[i,a,o,s]=r,c=`function __tweakccMcpOverride(_n,_d){try{let _f=require('fs'),_p=require('os').homedir()+'/.tweakcc/system-reminders/mcp-'+_n+'.md';let _r=_f.readFileSync(_p,'utf8');let _m=_r.match(/-->\\s*([\\s\\S]*?)\\s*\$/);if(!_m)return _d;let _b=_m[1].trim();if(_b==='')return null;return _b.replace(/\\{\\{server_instructions\\}\\}/g,_d||'')}catch{return _d}}for(let ${a} of ${o}){let _c=__tweakccMcpOverride(${a}.name,${a}.instructions);if(_c)${s}.set(${a}.name,\`## \${${a}.name}\n\${_c}\`)}`,l=e.slice(0,r.index)+c+e.slice(r.index+i.length);return V(e,l,c,r.index,r.index+i.length),l}}],bt=async()=>{let e=[u.join(n.homedir(),`.claude.json`),u.join(n.homedir(),`.claude`,`mcp.json`)];for(let t of e)try{let e=await a.readFile(t,`utf8`),n=JSON.parse(e);if(n.mcpServers&&typeof n.mcpServers==`object`)return Object.keys(n.mcpServers)}catch{}return[]},xt=async(e,t)=>{let n=[],r=e,i=await bt();for(let e of i)await pt(`mcp-${e}`,`MCP server: ${e}`,`Instructions block content for MCP server "${e}". {{server_instructions}} expands at runtime to the server's pristine instructions. Empty body drops the server's block from the model's context. Custom body replaces it.`,t,[`server_instructions`],`{{server_instructions}}`);for(let e of yt){let i=await pt(e.id,e.name,e.description,t,Object.keys(e.placeholders),e.defaultBody),a=await ft(e.id);if(!a){n.push({id:e.id,name:e.name,description:e.description,state:`default`,applied:!1,failed:!1,skipped:!0,details:`override file missing after ensure (unexpected)`});continue}let{result:o,errors:s}=mt(a.body,e.placeholders);if(s.length>0){n.push({id:e.id,name:e.name,description:e.description,state:`override`,applied:!1,failed:!0,skipped:!1,details:s.join(`; `)});continue}let c=e.apply(r,o,a.isSuppressed);if(c===null){n.push({id:e.id,name:e.name,description:e.description,state:a.isSuppressed?`suppressed`:`override`,applied:!1,failed:!0,skipped:!1,details:`patch function returned null`});continue}let l=c!==r;r=c;let u;u=a.isSuppressed?`suppressed`:a.body===e.defaultBody.trim()?`default`:`override`,n.push({id:e.id,name:e.name,description:e.description,state:u,applied:l,failed:!1,skipped:!1,details:i?`seeded default file`:void 0})}return{content:r,results:n}};let St=null;const Ct=async()=>{if(St)return St;let e=new Set,t=[Q,hc];for(let n of t){let t;try{t=await a.readdir(n)}catch{continue}if(Array.isArray(t))for(let r of t){if(!r.endsWith(`.md`))continue;let t;try{t=await a.readFile(p.join(n,r),`utf8`)}catch{continue}let i=v(t,{delimiters:[`<!--`,`-->`]}).data?.shadows;if(Array.isArray(i))for(let t of i)typeof t==`string`&&t&&e.add(t)}}for(let t of yt)if(Array.isArray(t.shadows))for(let n of t.shadows)typeof n==`string`&&n&&e.add(n);return St=e,e};let wt=null;const Tt=async()=>{if(wt)return wt;let e=new Set,t=qe();if(t){let n;try{n=await a.readdir(t)}catch{n=[]}for(let r of n)if(!(!r.startsWith(`prompts-`)||!r.endsWith(`.json`)))try{let n=await a.readFile(p.join(t,r),`utf8`),i=JSON.parse(n);for(let t of i.prompts??[])for(let n of Object.values(t.identifierMap??{}))n&&e.add(n)}catch{continue}}if(e.size===0)try{let t=await import(`./identifierUnion-BgceXnlI.mjs`);for(let n of t.IDENTIFIER_UNION)e.add(n)}catch{}return wt=e,e},Et=e=>{let t=v(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(`
|
|
57
57
|
`).length-1),{name:n||``,description:r||``,ccVersion:i||``,variables:a||[],content:t.content,contentLineOffset:o}},Dt=(e,t)=>v.stringify(``,t,{delimiters:[`<!--`,`-->`]}).replace(/\n$/,``)+(e.endsWith(`
|
|
58
58
|
`)?e:e+`
|
|
59
59
|
`),Ot=(e,t,n)=>{let r=t||F(e.pieces,e.identifiers,e.identifierMap),i=Object.keys(e.identifierMap).length>0?[...new Set(Object.values(e.identifierMap))]:void 0,a={name:e.name,description:e.description,ccVersion:e.version};if(i&&i.length>0&&(a.variables=i),n)for(let[e,t]of Object.entries(n))e in a||(a[e]=t);return Dt(r,a)},kt=async e=>{let t={};try{let n=jt(e),r=v(await a.readFile(n,`utf8`),{delimiters:[`<!--`,`-->`]}),i=new Set([`name`,`description`,`ccVersion`,`variables`]);for(let[e,n]of Object.entries(r.data))i.has(e)||(t[e]=n)}catch{}return t},F=(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},At=(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},jt=e=>p.join(Q,`${e}.md`),Mt=async e=>{try{return await a.access(jt(e)),!0}catch{return!1}},Nt=async e=>{let t=jt(e);return Et(await a.readFile(t,`utf-8`))},Pt=async(e,t)=>{let n=jt(e);await a.writeFile(n,t,`utf-8`)},Ft=async(e,t)=>{let n=jt(e),r=await a.readFile(n,`utf-8`),i=v(r,{delimiters:[`<!--`,`-->`]}),o=Object.keys(t).length>0?[...new Set(Object.values(t))]:void 0,s=new Set([`name`,`description`,`ccVersion`,`variables`]),c={name:i.data.name,description:i.data.description,ccVersion:i.data.ccVersion};o&&o.length>0&&(c.variables=o);for(let[e,t]of Object.entries(i.data))s.has(e)||(c[e]=t);let l=Dt(i.content,c);l!==r&&await Pt(e,l)},It=(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}},Lt=(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=It(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},Rt=async(e,t,n,r,i,o,s,c)=>{let l=n.split(`
|
|
@@ -427,7 +427,7 @@ if (toolsets.hasOwnProperty(currentToolset)) {
|
|
|
427
427
|
}
|
|
428
428
|
} else {
|
|
429
429
|
${o} = ${s};
|
|
430
|
-
}let `,u=a.index,d=u+a[0].length,f=e.slice(0,u)+l+e.slice(d);return V(e,f,l,u,d),f},ei=(e,t,n)=>{if(!Xr(e))return console.error(`patch: toolsets: computeToolsFilter: failed to find app state info`),null;let r=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),i=n?JSON.stringify(n):`undefined`,a=e.match(/([,;{])([$\w]+)=([$\w]+\.useCallback\()\(\)=>\{let ([$\w]+)=([$\w]+)\.getState\(\),([$\w]+)=([$\w]+)\.current
|
|
430
|
+
}let `,u=a.index,d=u+a[0].length,f=e.slice(0,u)+l+e.slice(d);return V(e,f,l,u,d),f},ei=(e,t,n)=>{if(!Xr(e))return console.error(`patch: toolsets: computeToolsFilter: failed to find app state info`),null;let r=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),i=n?JSON.stringify(n):`undefined`,a=e.match(/([,;{])([$\w]+)=([$\w]+\.useCallback\()\(\)=>\{let ([$\w]+)=([$\w]+)\.getState\(\),([$\w]+)=([$\w]+)\.current(?:,[$\w]+=[^;]{0,80})*;if\(\6!==null&&[\s\S]{0,600}?\)return \6\.result;[\s\S]{0,300}?let ([$\w]+)=[$\w]+\(\4\.toolPermissionContext,\4\.mcp\.tools(?:,\{skillTools:\4\.skillTools(?:,activeAgents:[^{}]*)?\})?\),([$\w]+)=[$\w]+\([$\w]+,\8,\4\.toolPermissionContext\.mode\),([$\w]+)=[$\w]+\([$\w]+\?[$\w]+\([$\w]+,(?:\9|[$\w]+\([$\w]+,\9,[^()]*\)),!1,!0\)\.resolvedTools:\9,\4\.toolPermissionContext\);return \7\.current=\{[\s\S]{0,600}?result:\10\},\10\},\[/);if(a&&a.index!==void 0){let t=a[0],n=a[4],o=a[6],s=a[10],c=`const __ts=${r},__tf=(t,s)=>{const n=s.toolset??${i};globalThis.__tweakcc_toolset={name:n,tools:__ts[n]};if(__ts.hasOwnProperty(n)){const a=__ts[n];if(a==="*")return t;return t.filter(d=>a.includes(d.name))}return t};`,l=t.indexOf(`()=>{`),u=`return ${o}.result;`,d=t.indexOf(u),f=`,${s}},[`;if(l===-1||d===-1||!t.endsWith(f))return console.error(`patch: toolsets: computeToolsFilter: memoized shape matched but landmarks missing`),null;let p=t.slice(0,t.length-f.length)+`,__tf(${s},${n})},[`;p=p.slice(0,d)+`return __tf(${o}.result,${n});`+p.slice(d+u.length),p=p.slice(0,l+5)+c+p.slice(l+5);let m=a.index,h=m+t.length,g=e.slice(0,m)+p+e.slice(h);return V(e,g,p,m,h),g}let o=e.match(/([$\w]+)=(?:([$\w]+\.useCallback\())?\(\)=>\{let ([$\w]+)=([$\w]+)\.getState\(\),([$\w]+)=([$\w]+)\(\3\.toolPermissionContext,\3\.mcp\.tools(?:,\{skillTools:\3\.skillTools\})?\),([$\w]+)=([$\w]+)\([$\w]+,\5,\3\.toolPermissionContext\.mode\);if\(!([$\w]+)\)return \7;return ([$\w]+)\(\9,\7,!1,!0\)\.resolvedTools\}/);if(!o||o.index===void 0)return console.error(`patch: toolsets: computeToolsFilter: failed to find computeTools pattern`),null;let s=o[1],c=o[2]||``,l=o[3],u=o[4],d=o[5],f=o[6],p=o[7],m=o[8],h=o[9],g=o[10],_=o[0].includes(`{skillTools:${l}.skillTools}`)?`,{skillTools:${l}.skillTools}`:``,v=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),y=n?JSON.stringify(n):`undefined`,b=o[0],x=b.match(RegExp(`${m.replace(/\$/g,`\\$`)}\\(([$\\w]+),${d.replace(/\$/g,`\\$`)},`));if(!x)return console.error(`patch: toolsets: computeToolsFilter: failed to extract init var from merge call`),null;let S=`${s}=${c}()=>{let ${l}=${u}.getState(),${d}=${f}(${l}.toolPermissionContext,${l}.mcp.tools${_}),${p}=${m}(${x[1]},${d},${l}.toolPermissionContext.mode);const __ts=${v},__tc=${l}.toolset??${y},__tf=(t)=>{globalThis.__tweakcc_toolset={name:__tc,tools:__ts[__tc]};if(__ts.hasOwnProperty(__tc)){const a=__ts[__tc];if(a==="*")return t;return t.filter(d=>a.includes(d.name))}return t};if(!${h})return __tf(${p});return __tf(${g}(${h},${p},!1,!0).resolvedTools)}`,C=o.index,w=C+b.length,T=e.slice(0,C)+S+e.slice(w);return V(e,T,S,C,w),T},ti=(e,t,n)=>{let r=JSON.stringify(Object.fromEntries(t.map(e=>[e.name,e.allowedTools===`*`?`*`:e.allowedTools]))),i=n?JSON.stringify(n):`undefined`,a=e.match(/let ([$\w]+)=([$\w]+)\(([$\w]+)\)([;,])(?=[\s\S]{0,2500}tools:\1,refreshTools:\(\)=>\2\(([$\w]+)\(\)\))/);if(!a||a.index===void 0)return console.error(`patch: toolsets: printToolsFilter: failed to find print tools initialization`),null;let o=a[1],s=a[2],c=a[3],l=a[4],u=a[5],d=`let ${o}=${s}(${c});const __tpts=${r},__tptf=(t,s)=>{const n=s.toolset??${i};globalThis.__tweakcc_toolset={name:n,tools:__tpts[n]};if(__tpts.hasOwnProperty(n)){const a=__tpts[n];if(a==="*")return t;return t.filter(d=>a.includes(d.name))}return t};${o}=__tptf(${o},${c});${l===`,`?`let `:``}`,f=e.slice(0,a.index)+d+e.slice(a.index+a[0].length);V(e,f,d,a.index,a.index+a[0].length);let p=RegExp(`refreshTools:\\(\\)=>${s.replace(/\$/g,`\\$`)}\\(${u.replace(/\$/g,`\\$`)}\\(\\)\\)`),m=f.match(p);if(!m||m.index===void 0)return console.error(`patch: toolsets: printToolsFilter: failed to find print refreshTools`),null;let h=`refreshTools:()=>{let s=${u}();return __tptf(${s}(s),s)}`,g=f;return f=f.slice(0,m.index)+h+f.slice(m.index+m[0].length),V(g,f,h,m.index,m.index+m[0].length),f},ni=(e,t,n)=>{let r=/`<tool_use_error>Error: No such tool available: \$\{([$\w.]+)\}(?:\$\{([$\w.]+)\})?<\/tool_use_error>`/g,i=e,a=0,o=`__tweakcc_toolErrorMsg`,s=`function ${o}(toolName,hint){hint=hint||"";var info=globalThis.__tweakcc_toolset;if(info&&info.tools&&info.tools!=="*"&&Array.isArray(info.tools)){return "<tool_use_error>Error: No such tool available: "+toolName+hint+". The active toolset is '"+info.name+"' which only includes: "+info.tools.join(", ")+". Do not attempt to use "+toolName+" again — it will fail. If the user switches toolsets via /toolset, you may retry.</tool_use_error>"}return "<tool_use_error>Error: No such tool available: "+toolName+hint+"</tool_use_error>"};`;if(i=i.replace(r,(e,t,n)=>(a++,n?`${o}(${t},${n})`:`${o}(${t})`)),a===0)return console.error(`patch: toolsets: toolsetAwareErrors: failed to find error pattern`),null;i=i.replace(/`Error: No such tool available: \$\{([$\w.]+)\}(?:\$\{([$\w.]+)\})?`/g,(e,t,n)=>`${n?`${o}(${t},${n})`:`${o}(${t})`}.replace(/<\\/?tool_use_error>/g,"")`);let c=i.indexOf(`
|
|
431
431
|
`,i.indexOf(`// Version:`));return c===-1?(console.error(`patch: toolsets: toolsetAwareErrors: failed to find insertion point for helper`),null):(i=i.slice(0,c+1)+s+i.slice(c+1),i)},ri=(e,t,n)=>{let r=Zr(e);if(r===null)return console.error(`patch: toolsets: failed to find slash command insertion point`),null;let i=hs(e);if(!i)return console.error(`patch: toolsets: failed to find React variable`),null;let a=Cs(e);if(!a)return console.error(`patch: toolsets: failed to find Box component`),null;let o=xs(e);if(!o)return console.error(`patch: toolsets: failed to find Text component`),null;let s=Jr(e);if(!s)return console.error(`patch: toolsets: failed to find Select component`),null;let c=Yr(e),l=Xr(e);if(!l)return console.error(`patch: toolsets: failed to find app state getter`),null;let u=us(e);if(!u)return console.error(`patch: toolsets: failed to find chalk variable`),null;let{appStateUseSelectorFn:d,appStateSetState:f}=l,p=JSON.stringify(t.map(e=>e.name)),m=JSON.stringify(t.map(e=>({label:e.name,value:e.name,description:e.allowedTools===`*`?`All tools`:e.allowedTools.length===0?`No tools`:`${e.allowedTools.length} tool${e.allowedTools.length===1?``:`s`}: ${e.allowedTools.join(`, `)}`}))),h=`const toolsetComp = ({ onExit, input }) => {
|
|
432
432
|
const currentToolset = ${d}(state => state.toolset) ?? ${n?JSON.stringify(n):`undefined`};
|
|
433
433
|
|
|
@@ -508,7 +508,7 @@ if (toolsets.hasOwnProperty(currentToolset)) {
|
|
|
508
508
|
userFacingName() {
|
|
509
509
|
return "toolset";
|
|
510
510
|
}
|
|
511
|
-
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},vi=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},yi=(e,t)=>{let n=vi(e);if(n===null)return null;let r=Xr(e);if(!r)return console.error(`patch: addCurrentToolsetAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateUseSelectorFn:i}=r,a=`const currentToolset = ${i}(state => state.toolset) ?? ${t?JSON.stringify(t):`undefined`};`,o=e.slice(0,n)+a+e.slice(n);return V(e,o,a,n,n),o},bi=e=>{let t=e.match(/if\(([$\w]+)\(\([$\w]+\)=>\(\{\.\.\.[$\w]+,toolPermissionContext.{0,200}?mode:([$\w]+)/);return!
|
|
511
|
+
}`):(console.error(`patch: toolsets: failed to find React variable`),null)},vi=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},yi=(e,t)=>{let n=vi(e);if(n===null)return null;let r=Xr(e);if(!r)return console.error(`patch: addCurrentToolsetAtToolChangeComponentScope: failed to get app state getter function`),null;let{appStateUseSelectorFn:i}=r,a=`const currentToolset = ${i}(state => state.toolset) ?? ${t?JSON.stringify(t):`undefined`};`,o=e.slice(0,n)+a+e.slice(n);return V(e,o,a,n,n),o},bi=e=>{let t=e.match(/return ([$\w]+)\(\([$\w]+\)=>\{let ([$\w]+)=[$\w]+\.toolPermissionContext\.mode;if\(\2===([$\w]+)\)return [$\w]+;let ([$\w]+)=[$\w]+\(\2,\3,[$\w]+\.toolPermissionContext\);return\{\.\.\.[$\w]+,toolPermissionContext:\{\.\.\.\4,mode:\3\}\}\}\)/);if(t&&t.index!==void 0)return{index:t.index,modeVar:t[3],setStateVar:t[1]};let n=e.match(/if\(([$\w]+)\(\([$\w]+\)=>\(\{\.\.\.[$\w]+,toolPermissionContext.{0,200}?mode:([$\w]+)/);return!n||n.index===void 0?(console.error(`patch: findModeChange: failed to find mode change location`),null):{index:n.index,modeVar:n[2],setStateVar:n[1]}},xi=(e,t,n)=>{let r=bi(e);if(!r)return null;let{index:i,modeVar:a,setStateVar:o}=r,s=`if(${a}==="plan"){${o}((prev)=>({...prev,toolset:${JSON.stringify(t)}}));}else{${o}((prev)=>({...prev,toolset:${JSON.stringify(n)}}));}`,c=e.slice(0,i)+s+e.slice(i);return V(e,c,s,i,i),c},Si=(e,t,n,r)=>{if(!t||t.length===0)return e;let i=e;if(i=Qr(i,n),!i)return console.error(`patch: toolsets: step 1 failed (writeToolsetFieldToAppState)`),null;if(i=$r(i,t,n),!i)return console.error(`patch: toolsets: step 2 failed (writeToolFetchingUseMemo)`),null;if(i=ei(i,t,n),!i)return console.error(`patch: toolsets: step 2b failed (writeComputeToolsFilter)`),null;if(i=ti(i,t,n),!i)return console.error(`patch: toolsets: step 2c failed (writePrintToolsFilter)`),null;let a=ni(i,t,n);if(a?i=a:console.error(`patch: toolsets: step 2d failed (writeToolsetAwareErrors) — continuing without friendlier errors`),i=ri(i,t,n),!i)return console.error(`patch: toolsets: step 3 failed (writeToolsetComponentDefinition)`),null;if(i=_i(i),!i)return console.error(`patch: toolsets: step 4 failed (writeSlashCommandDefinition)`),null;if(i=mi(i,n),!i)return console.error(`patch: toolsets: step 5 failed (insertShiftTabAppStateVar)`),null;if(i=hi(i),!i)return console.error(`patch: toolsets: step 6 failed (appendToolsetToModeDisplay)`),null;if(i=gi(i),!i)return console.error(`patch: toolsets: step 7 failed (appendToolsetToShortcutsDisplay)`),null;if(r&&n){if(i=yi(i,n),!i)return console.error(`patch: toolsets: step 8a failed (addCurrentToolsetAtToolChangeComponentScope)`),null;if(i=xi(i,r,n),!i)return console.error(`patch: toolsets: step 8b failed (writeModeChangeUpdateToolset)`),null}return i},Ci=/\{top:\["┌","─","┬","┐"\],middle:\["├","─","┼","┤"\],bottom:\["└","─","┴","┘"\]\}/,wi=/top:\["\\u250C","\\u2500","\\u252C","\\u2510"\],middle:\["\\u251C","\\u2500","\\u253C","\\u2524"\],bottom:\["\\u2514","\\u2500","\\u2534","\\u2518"\]/,Ti=/top: \["┌", "─", "┬", "┐"\],\s+middle: \["├", "─", "┼", "┤"\],\s+bottom: \["└", "─", "┴", "┘"\]/,Ei=/if\(([$\w]+)\.push\(\.\.\.([$\w]+)\(([$\w]+),!1\)\),([$\w]+)<([$\w]+)\.rows\.length-1\)([$\w]+)\.push\(([$\w]+)\("middle"\)\)/g,Di=/if\s*\(\s*\(\s*([$\w]+)\.push\(\.\.\.([$\w]+)\(([$\w]+)\s*,\s*!1\)\)\s*,\s*([$\w]+)\s*<\s*([$\w]+)\.rows\.length\s*-\s*1\s*\)\s*\)\s*([$\w]+)\.push\(([$\w]+)\("middle"\)\)\s*;?/g,Oi=/([$\w]+)\.push\(([$\w]+)\("top"\)\),/g,ki=/,([$\w]+)\.push\(([$\w]+)\("bottom"\)\),/g,Ai=/([$\w]+)\.push\(\s*([$\w]+)\(\s*"top"\s*\)\s*\)\s*,\s*/g,ji=/,\s*([$\w]+)\.push\(\s*([$\w]+)\(\s*"bottom"\s*\)\s*\)\s*,/g;function Mi(e){let t=e,n=!1,r=t;t=t.replace(Ei,`$1.push(...$2($3,!1))`),t!==r&&(n=!0);let i=t;return t=t.replace(Di,`$1.push(...$2($3,!1))`),t!==i&&(n=!0),{result:t,success:n}}function Ni(e){let t=e,n=!1,r=t;t=t.replace(Oi,``),t!==r&&(n=!0);let i=t;t=t.replace(Ai,``),t!==i&&(n=!0);let a=t;t=t.replace(ki,`,`),t!==a&&(n=!0);let o=t;return t=t.replace(ji,`,`),t!==o&&(n=!0),{result:t,success:n}}const Pi=(e,t)=>{if(t===`markdown`&&(t=`ascii`),t===`default`)return q(`Table format is "default", no patching needed`),null;let n=e,r=0;if(t===`ascii`){if(Ci.test(n)){let e=n;n=n.replace(Ci,`{top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]}`),n!==e&&(r++,q(`Patched table border definition object (minified format)`))}else if(wi.test(n)){let e=n;n=n.replace(wi,`top:["","","",""],middle:["|","-","|","|"],bottom:["","","",""]`),n!==e&&(r++,q(`Patched table border definition object (native Unicode format)`))}else if(Ti.test(n)){let e=n;n=n.replace(Ti,`top: ["", "", "", ""],
|
|
512
512
|
middle: ["|", "-", "|", "|"],bottom: ["", "", "", ""]`),n!==e&&(r++,q(`Patched table border definition object (spaced format)`))}else J(`Could not find table border definition pattern - CLI may have changed`);{let e=n,t=n.match(/function [$\w]+\([^)]*\)\{[\s\S]{0,1600}?let ([$\w]+)="(?:\\u2502|│)";[\s\S]{0,1600}?\1\+=" "\+[$\w]+\+" (?:\\u2502|│)"/);if(t&&t.index!==void 0){let e=t.index,r=e+t[0].length,i=n.slice(e,r).replace(/" \\u2502"/g,`" |"`).replace(/" │"/g,`" |"`);n=n.slice(0,e)+i+n.slice(r)}n!==e&&(r++,q(`Patched compact table vertical separators`))}{let e=n;n=n.replace(/"─"\.repeat\(/g,`"-".repeat(`),n=n.replace(/"\\u2500"\.repeat\(/g,`"-".repeat(`),n!==e&&(r++,q(`Patched horizontal separator characters`))}{let{result:e,success:t}=Mi(n);t&&(n=e,r++,q(`Removed inter-row separators`))}{let{result:e,success:t}=Ni(n);t&&(n=e,r++,q(`Removed top/bottom border pushes`))}}else if(t===`clean`){if(Ci.test(n)){let e=n;n=n.replace(Ci,`{top:["","","",""],middle:["├","─","┼","┤"],bottom:["","","",""]}`),n!==e&&(r++,q(`Patched table border definition for clean format (minified format)`))}else if(wi.test(n)){let e=n;n=n.replace(wi,`top:["","","",""],middle:["\\u251C","\\u2500","\\u253C","\\u2524"],bottom:["","","",""]`),n!==e&&(r++,q(`Patched table border definition for clean format (native Unicode format)`))}else if(Ti.test(n)){let e=n;n=n.replace(Ti,`top: ["", "", "", ""],
|
|
513
513
|
middle: ["├", "─", "┼", "┤"],
|
|
514
514
|
bottom: ["", "", "", ""]`),n!==e&&(r++,q(`Patched table border definition for clean format (spaced format)`))}else J(`Could not find table border definition pattern - CLI may have changed`);{let{result:e,success:t}=Mi(n);t&&(n=e,r++,q(`Removed inter-row separators`))}{let{result:e,success:t}=Ni(n);t&&(n=e,r++,q(`Removed top/bottom border pushes`))}}else if(t===`clean-top-bottom`){let{result:e,success:t}=Mi(n);t&&(n=e,r++,q(`Removed inter-row separators (keeping top/bottom borders)`))}else return console.error(`patch: tableFormat: failed to find handler for unknown format "${t}"`),q(`Unknown table format "${t}", skipping`),null;if(r===0)return console.error(`patch: tableFormat: failed to find any table-rendering patterns to patch for format "${t}" (border-definition object, vertical-border chars, horizontal separator, or inter-row separator)`),J(`No table format patches were applied - patterns may not have matched`),null;q(`[Table format patch: ${r} modifications for ${t} style]`);let i=Fi(e,n);if(i!==-1){let{oldEnd:t,newEnd:r}=Ii(e,n,i),a=n.slice(i,r);V(e,n,a,i,t)}return q(`Table format patch applied: ${r} changes, file size ${e.length} -> ${n.length}`),n};function Fi(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return e.length===t.length?-1:n}function Ii(e,t,n){let r=e.length-1,i=t.length-1;for(;r>=n&&i>=n&&e[r]===t[i];)r--,i--;return{oldEnd:r+1,newEnd:i+1}}const Li=e=>hs(e)?Br(e,`, {
|
|
@@ -738,7 +738,7 @@ ${t}({
|
|
|
738
738
|
return [{ type: "text", text: content }];
|
|
739
739
|
},
|
|
740
740
|
});
|
|
741
|
-
return`+s,u=r.index,d=u+i.length,f=e.slice(0,u)+l+e.slice(d);return V(e,f,l,u,d),f},ga=e=>{let t=xs(e);if(!t)return console.error(`patch: thinkingBlockStyling: failed to find Text component`),null;let n=e.match(/\{thinking:([$\w]+)\}.{0,400}(?:∴|\\u2234) Thinking.{0,700}(?:…|\\u2026).{0,200}\b[$\w]+(?:\.default)?\.createElement\(([$\w]+,null),\1\)/);if(!n||n.index===void 0)return console.error(`patch: thinkingBlockStyling: failed to find thinking label pattern`),null;let r=n[0].replace(n[2],`${t},{dimColor:true,italic:true}`),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return V(e,o,r,i,a),o},_a=e=>{let t=e.match(/![$\w]+\(process\.env\.MCP_CONNECTION_NONBLOCKING\)/);return!t||t.index===void 0?null:{startIndex:t.index,endIndex:t.index+t[0].length}},va=[/MCP_SERVER_CONNECTION_BATCH_SIZE\)\s*;\s*return\s*[$\w]+\s*>\s*0\s*\?\s*[$\w]+\s*:\s*(\d+)/g,/MCP_SERVER_CONNECTION_BATCH_SIZE\|\|"",10\)\s*;\s*return\s*[$\w]+\s*>\s*0\s*\?\s*[$\w]+\s*:\s*(\d+)/g,/MCP_SERVER_CONNECTION_BATCH_SIZE\|\|"",10\)\s*\|\|\s*(\d+)/g],ya=e=>{let t=[];for(let n of va){n.lastIndex=0;for(let r of e.matchAll(n)){if(r.index===void 0)continue;let e=r.index+r[0].length;t.push({startIndex:e-r[1].length,endIndex:e})}}return t.length===0&&console.error(`patch: mcpStartup: failed to find MCP_SERVER_CONNECTION_BATCH_SIZE default`),t.sort((e,t)=>e.startIndex-t.startIndex)},ba=e=>{let t=_a(e);if(!t)return e;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},xa=(e,t)=>{let n=ya(e);if(n.length===0)return null;let r=String(t),i=e;for(let e of[...n].reverse()){let t=i.slice(0,e.startIndex)+r+i.slice(e.endIndex);V(i,t,r,e.startIndex,e.endIndex),i=t}return i},Sa=(e,t=300,n=!1)=>{let r=e.match(/(,([$\w]+)=([$\w]+(?:\.default)?)\.useCallback.{0,1000}statusLineText.{0,200}?),([$\w]+)=([$\w.]+\(\(\)=>(\2\(([$\w]+)\)),300\)|[$\w]+\(\(\)=>\{\2\(\)\},300\)|[$\w]+\(\2,300\)|.{0,100}\{[$\w]+\.current=void 0,\2\(\)\},300\)\},\[\2\]\)|[$\w]+\.useCallback\(\(\)=>\{if\([$\w]+\.current!==void 0\)clearTimeout\([$\w]+\.current\);[$\w]+\.current=setTimeout\(\([$\w]+,[$\w]+\)=>\{[$\w]+\.current=void 0,[$\w]+\(\)\},300,[$\w]+,\2\)\},\[\2\]\)|\3\.useCallback\(\(\)=>\{.{0,200}setTimeout\(\([$\w]+,[$\w]+\)=>\{[$\w]+\.current=void 0,[$\w]+\(\)\},300,[$\w]+,\2\)\},\[\2\]\))/);if(!r||r.index===void 0)return console.error(`patch: statuslineUpdateThrottle: failed to find statusline update throttle pattern`),null;let i=r[1],a=r[2],o=r[3],s=r[4],c=r[6]??`${a}()`,l=r[7],u=Number(t),d=Number.isFinite(u)&&u>=0?Math.trunc(u):300,f=l?`${a}, ${l}`:a,p=a,m;m=n?l?i+`,argRef=${o}.useRef(${l}),unused1=${o}.useEffect(()=>{argRef.current=${l};},[${l}]),unused2=${o}.useEffect(()=>{const id=setInterval(()=>${a}(argRef.current),${d});return()=>clearInterval(id);},[${p}]),${s}=${o}.useCallback(()=>{},[])`:i+`,unused1=${o}.useEffect(()=>{const id=setInterval(()=>${c},${d});return()=>clearInterval(id);},[${p}]),${s}=${o}.useCallback(()=>{},[])`:i+`,lastCall=${o}.useRef(0),${s}=${o}.useCallback(()=>{let now=Date.now();if(now-lastCall.current>=${d}){lastCall.current=now;${c};}},[${f}])`;let h=r.index,g=h+r[0].length,_=e.slice(0,h)+m+e.slice(g);return V(e,_,m,h,g),_},Ca=e=>typeof e==`number`?e:e.threshold??1e3,wa=(e,t)=>{let n=e.match(/children:\[([$\w]+)," tokens"\][^]{0,80}?,"tokens"\)/);if(!n||n.index===void 0)return null;let r=n[1].replace(/\$/g,`\\$`),i=Math.max(0,n.index-4e3),a=e.slice(i,n.index+n[0].length),o=[...a.matchAll(RegExp(`(?<![$\\w])${r}=[$\\w]+\\(`,`g`))],s=RegExp(`(${r}=[$\\w]+\\()(${t})(\\)[^]{0,4000}?children:\\[${r}," tokens"\\])`,`y`),c=null;for(let e of o.reverse())if(s.lastIndex=e.index,c=s.exec(a),c)break;return c?{fullMatch:c[0],pre:c[1],partToWrap:c[2],post:c[3],startIndex:i+c.index}:null},Ta=(e,t)=>{let n=Ca(t),r,i,a,o,s,c=`[$\\w]+(?:\\?\\.[$\\w]+)*(?:\\([^()]*\\))?`,l=wa(e,c);if(l)({fullMatch:r,pre:i,partToWrap:a,post:o,startIndex:s}=l);else{let t=e.match(RegExp(`(([$\\w]+)=[$\\w]+\\()(${c})(\\),.{0,2000}key:"tokens".{0,200},\\2," tokens")`));if(t&&t.index!==void 0)[r,i,,a,o]=t,s=t.index;else{let t=e.match(RegExp(`(overrideMessage:.{0,10000},([$\\w]+)=[$\\w]+\\()(${c})(\\),.{0,1000}key:"tokens".{0,200},\\2," tokens")`));if(t&&t.index!==void 0)[r,i,,a,o]=t,s=t.index;else{let t=e.match(/(overrideMessage:.{0,10000},key:"tokens".{0,200}[$\w]+\()(Math\.round\(.+?\))(\))/);if(t&&t.index!==void 0)[r,i,a,o]=t,s=t.index;else return console.error(`patch: tokenCountRounding: cannot find token count pattern in any CC format`),null}}}let u=`${i}Math.round((${a})/${n})*${n}${o}`,d=s+r.length,f=e.slice(0,s)+u+e.slice(d);return V(e,f,u,s,d),f},Ea=(e,t)=>/CLAUDE\.md.{0,100}for\(let \w+ of \["AGENTS\.md"/.test(e)?(console.log(`patch: agentsMd: alternative MD file support already present natively - skipping`),e):Da(e,t)||Oa(e,t)||ka(e,t)||Aa(e,t)||ja(e,t),Da=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+),([$\w]+)=!1;(if\(\6\)\{[\s\S]*?\}else\{[\s\S]*?\})if\(\7===null\)\{([\s\S]*?\[CLAUDE\.md\] skipping[\s\S]*?return\{info:null,includePaths:\[\]\})\}return ([$\w]+)\(\7,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\12,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[7],l=n[8],u=n[9],d=n[10],f=n[11],p=n[12],m=n[13],h=`${r},didReroute){try{let ${c},${l}=!1;${u}if(${c}===null){if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${a}.slice(0,-9)+alt;try{let rerouteResult=await ${i}(altPath,${o},${s},void 0,true);if(rerouteResult.info)return rerouteResult}catch{}}}${d}}return ${f}(${c},${a},${o},${s})}catch(${p}){return ${m}(${p},${a}),{info:null,includePaths:[]}}}`,g=n.index,_=g+n[0].length,v=e.slice(0,g)+h+e.slice(_);return V(e,v,h,g,_),v},Oa=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=!1,([$\w]+)=await ([$\w]+)\(\6,\3,([$\w]+),\(([$\w]+)\)=>\{\8=\12\.isDirectory\(\)\}\);if\(\9===null\)\{([\s\S]*?\[CLAUDE\.md\] skipping[\s\S]*?return\{info:null,includePaths:\[\]\})\}return ([$\w]+)\(\9,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\15,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7],u=n[8],d=n[9],f=n[10],p=n[11],m=n[12],h=n[13],g=n[14],_=n[15],v=n[16],y=`${r},didReroute){try{let ${c}=${l}(),${u}=!1,${d}=await ${f}(${c},${a},${p},(${m})=>{${u}=${m}.isDirectory()});if(${d}===null){if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${a}.slice(0,-9)+alt;try{let rerouteResult=await ${i}(altPath,${o},${s},true);if(rerouteResult.info)return rerouteResult}catch{}}}${h}}return ${g}(${d},${a},${o},${s})}catch(${_}){return ${v}(${_},${a}),{info:null,includePaths:[]}}}`,b=n.index,x=b+n[0].length,S=e.slice(0,b)+y+e.slice(x);return V(e,S,y,b,x),S},ka=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=await ([$\w]+)\(\6,\3,([$\w]+)\);if\(\8===null\)return (([$\w]+)\(`\[CLAUDE\.md\] skipping[^`]*`\),\{info:null,includePaths:\[\]\});return ([$\w]+)\(\8,\3,\4,\5\)\}catch\(([$\w]+)\)\{return (([$\w]+)\(\14,\3\),\{info:null,includePaths:\[\]\})\}\}/);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7],u=n[8],d=n[9],f=n[10],p=n[11],m=n[13],h=n[14],g=n[15],_=`${r},didReroute){try{let ${c}=${l}(),${u}=await ${d}(${c},${a},${f});if(${u}===null){if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${a}.slice(0,-9)+alt;try{let rerouteResult=await ${i}(altPath,${o},${s},true);if(rerouteResult.info)return rerouteResult}catch{}}}return ${p};}return ${m}(${u},${a},${o},${s})}catch(${h}){return ${g}}}`,v=n.index,y=v+n[0].length,b=e.slice(0,v)+_+e.slice(y);return V(e,b,_,v,y),b},Aa=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=await ([$\w]+)\(\)\.readFile\(\3,\{encoding:"utf-8"\}\);return ([$\w]+)\(\6,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\9,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=n[10],m=`${i},didReroute){try{let ${l}=await ${u}().readFile(${o},{encoding:"utf-8"});return ${d}(${l},${o},${s},${c})}catch(${f}){if(!didReroute&&(${o}.endsWith("/CLAUDE.md")||${o}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${o}.slice(0,-9)+alt;try{let r=await ${a}(altPath,${s},${c},true);if(r.info)return r}catch{}}}return ${p}(${f},${o}),{info:null,includePaths:[]}}}`,h=n.index,g=h+r.length,_=e.slice(0,h)+m+e.slice(g);return V(e,_,m,h,g),_},ja=(e,t)=>{let n=e.match(/(function ([$\w]+)\(([$\w]+),([^)]+?))\)(?:.|\n){0,500}Skipping non-text file in @include/);if(!n||n.index===void 0)return console.error(`patch: agentsMd: failed to find CLAUDE.md reading function`),null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n.index,c=/([$\w]+(?:\(\))?)\.(?:readFileSync|existsSync|statSync)/,l=n[0].match(c),u=null;if(!l&&(u=e.slice(Math.max(0,s-5e3),s).match(c),!u))return console.error(`patch: agentsMd: failed to find fs expression in function or caller`),null;let d=l?l[1]:u?u[1]:`require("fs")`,f=JSON.stringify(t),p=s+r.length,m=e.slice(0,p)+`,didReroute`+e.slice(p);V(e,m,`,didReroute`,p,p);let h=m.slice(s),g=/\.isFile\(\)\)return null/,_=h.match(g)??h.match(/==="EISDIR"\)return null/);if(!_||_.index===void 0)return console.error(`patch: agentsMd: failed to find early return null for injection`),null;let v=!h.match(g),y=`if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${f}){let altPath=${a}.slice(0,-9)+alt;if(${d}.existsSync(altPath)&&${d}.statSync(altPath).isFile())return ${i}(altPath,${o},true);}}`,b=s+_.index,x=_[0],S=v?`==="EISDIR"){${y}return null;}`:`.isFile()){${y}return null;}`;return m=m.slice(0,b)+S+m.slice(b+x.length),V(e,m,S,b,b),m},Ma=(e,t)=>{let n=e.lastIndexOf(`function `,t);if(n===-1)return null;let r=e.indexOf(`{`,n);if(r===-1||r>t)return null;let i=0;for(let t=r;t<e.length;t++){let n=e[t];if(n===`{`)i++;else if(n===`}`&&(i--,i===0)){let n=e.slice(r,t+1),i=/return [$\w]+(?:\.default)?\.createElement/g,a,o=null;for(;(a=i.exec(n))!==null;)o=a;return o?r+o.index:null}}return null},Na=e=>{let t=[[/When ready, use \$\{([$\w]+)\} to present your plan for approval/g,(e,t)=>`When ready, use \${${t}} to exit plan mode. The plan will be approved automatically.`],[/Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval\./g,`Use this tool when you are in plan mode and have finished writing your plan to the plan file. Calling this tool exits plan mode and approves the plan automatically.`],[/This tool simply signals that you're done planning and ready for the user to review and approve/g,`This tool signals that you are done planning and that the plan should be approved automatically`],[/Once your plan is finalized, use THIS tool to request approval/g,`Once your plan is finalized, use THIS tool to approve the plan and proceed`],[/ExitPlanMode inherently requests user approval of your plan\./g,`ExitPlanMode inherently approves your plan and lets you proceed.`],[/Present your plan to the user for approval/g,`Exit plan mode; the plan will be approved automatically`],[/design an implementation approach for user approval/g,`design an implementation approach before automatic approval`],[/This tool REQUIRES user approval - they must consent to entering plan mode/g,`This tool enters plan mode; plan exit approval is handled automatically when auto-accept plan mode is enabled`],[/Claude has written up a plan and is ready to execute\. Would you like to proceed\?/g,`Claude has written up a plan and is ready to execute. The plan is approved automatically.`],[/Call `\$\{([$\w]+)\}` to present the plan for approval\./g,(e,t)=>`Call \`\${${t}}\` to exit plan mode; the plan will be approved automatically.`],[/## Phase 2: Spawn Workers \(After Plan Approval\)/g,`## Phase 2: Spawn Workers (After Automatic Plan Approval)`],[/Once the plan is approved, spawn/g,`After the plan is approved automatically, spawn`],[/searchHint:"present plan for approval and start coding \(plan mode only\)"/g,`searchHint:"approve plan and start coding (plan mode only)"`],[/async description\(\)\{return"Prompts the user to exit plan mode and start coding"\}/g,`async description(){return"Exits plan mode and starts coding"}`]],n=e;for(let[r,i]of t){let t=n;n=n.replace(r,i),n!==t&&V(e,n,String(i),0,0)}let r=`permissionUpdates:[{type:"setMode",mode:"acceptEdits",destination:"session"}]`,i=/kind:"permission_exit_plan_mode_v2",payload:([\s\S]{0,300}?),result:([\s\S]{0,180}?),default:\{behavior:"cancelled"\}/,a=n;n=n.replace(i,`kind:"permission_exit_plan_mode_v2",payload:$1,result:$2,default:{behavior:"allow",${r}}`),n!==a&&V(e,n,`permission_exit_plan_mode_v2 default allow`,0,0);let o=/async checkPermissions\(([$\w]+),([$\w]+)\)\{if\(([$\w]+)\(\)\)return\{behavior:"allow",updatedInput:\1\};return\{behavior:"ask",message:"Exit plan mode\?",updatedInput:\1\}\}/,s=n;return n=n.replace(o,`async checkPermissions($1,$2){return{behavior:"allow",updatedInput:$1,${r}}}`),n!==s&&V(e,n,`ExitPlanMode checkPermissions allow`,0,0),n},Pa=e=>{let t=e.indexOf(`title:"Ready to code?"`);if(t===-1)return console.error(`patch: autoAcceptPlanMode: failed to find "Ready to code?" title`),null;if(/[$\w]+(?:\.current)?\("yes-accept-edits(?:-keep-context)?"\);return null;return/.test(e))return e;let n=e.slice(t,t+3e3),r=n.match(/onChange:\([$\w]+\)=>([$\w]+)\([$\w]+\),onCancel/),i=n.match(/onChange:([$\w]+),onCancel/),a=n.match(/onChange:\([$\w]+\)=>void ([$\w]+)\.current\([$\w]+\),onCancel/),o;if(r)o=r[1];else if(i)o=i[1];else if(a)o=`${a[1]}.current`;else return console.error(`patch: autoAcceptPlanMode: failed to find onChange handler`),null;let s=e.match(/(\}\}\)\)\)\);)(return [$\w]+\.default\.createElement\([$\w]+\.default\.Fragment,null,[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:"Ready to code\?")/);if(s&&s.index!==void 0){let t=`${o}("yes-accept-edits-keep-context");return null;`,n=s[1]+t+s[2],r=s.index,i=r+s[0].length,a=e.slice(0,r)+n+e.slice(i);return V(e,a,n,r,i),Na(a)}let c=Math.max(0,t-2500),l=e.slice(c,t),u=l.match(/(return [$\w]+\.default\.createElement\([$\w]+,\{flexDirection:"column",tabIndex:0,autoFocus:!0.{0,200}[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:")$/);if(!u){let n=l.lastIndexOf(`return `);if(n===-1){let n=Ma(e,t);if(n===null)return console.error(`patch: autoAcceptPlanMode: failed to find return before "Ready to code?"`),null;let r=`${o}("yes-accept-edits-keep-context");return null;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),Na(i)}let r=c+n,i=`${o}("yes-accept-edits-keep-context");return null;`,a=e.slice(0,r)+i+e.slice(r);return V(e,a,i,r,r),Na(a)}let d=c+u.index,f=`${o}("yes-accept-edits-keep-context");return null;`,p=e.slice(0,d)+f+e.slice(d);return V(e,p,f,d,d),Na(p)},Fa=e=>{let t=e.match(/console\.error\("--dangerously-skip-permissions cannot be used with root\/sudo privileges for security reasons"\),process\.exit\(1\)/);if(!t||t.index===void 0)return e.includes(`root/sudo privileges`)?(console.error(`patch: allowBypassPermsInSudo: failed to find pattern`),null):e;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+`{}`+e.slice(r);return V(e,i,`{}`,n,r),i},Ia=[/Claude Code has switched from npm to native installer\. Run `claude install` or see https:\/\/docs\.anthropic\.com\/en\/docs\/claude-code\/getting-started for more options\./g,/installMethod is native, but directory [^"'`\n;]+/g,/installMethod is native, but claude command (?:is missing or invalid|not found) at [^"'`\n;]+/g,/Native installation exists but ~\/\.local\/bin is not in your PATH(?:\. Run: echo 'export PATH="\$HOME\/\.local\/bin:\$PATH"' >> [^"'`\n;]+ then open a new terminal or run: source [^"'`\n;]+)?/g,/Run: echo 'export PATH="\$HOME\/\.local\/bin:\$PATH"' >> [^"'`\n;]+ then open a new terminal or run: source [^"'`\n;]+/g],La=e=>{let t=e,n=!1,r=-1,i=-1;for(let e of Ia)t=t.replace(e,(e,t)=>(n||(r=t,i=t+e.length),n=!0,``));return n?(V(e,t,``,r,i),t):(console.warn(`patch: suppressNativeInstallerWarning: failed to find pattern`),null)},Ra=e=>{let t=e.split(`
|
|
741
|
+
return`+s,u=r.index,d=u+i.length,f=e.slice(0,u)+l+e.slice(d);return V(e,f,l,u,d),f},ga=e=>{let t=xs(e);if(!t)return console.error(`patch: thinkingBlockStyling: failed to find Text component`),null;let n=e.match(/\{thinking:([$\w]+)\}.{0,400}(?:∴|\\u2234) Thinking.{0,700}(?:…|\\u2026).{0,200}\b[$\w]+(?:\.default)?\.createElement\(([$\w]+,null),\1\)/);if(!n||n.index===void 0)return console.error(`patch: thinkingBlockStyling: failed to find thinking label pattern`),null;let r=n[0].replace(n[2],`${t},{dimColor:true,italic:true}`),i=n.index,a=i+n[0].length,o=e.slice(0,i)+r+e.slice(a);return V(e,o,r,i,a),o},_a=e=>{let t=e.match(/![$\w]+\(process\.env\.MCP_CONNECTION_NONBLOCKING\)/);return!t||t.index===void 0?null:{startIndex:t.index,endIndex:t.index+t[0].length}},va=[/MCP_SERVER_CONNECTION_BATCH_SIZE\)\s*;\s*return\s*[$\w]+\s*>\s*0\s*\?\s*[$\w]+\s*:\s*(\d+)/g,/MCP_SERVER_CONNECTION_BATCH_SIZE\|\|"",10\)\s*;\s*return\s*[$\w]+\s*>\s*0\s*\?\s*[$\w]+\s*:\s*(\d+)/g,/MCP_SERVER_CONNECTION_BATCH_SIZE\|\|"",10\)\s*\|\|\s*(\d+)/g],ya=e=>{let t=[];for(let n of va){n.lastIndex=0;for(let r of e.matchAll(n)){if(r.index===void 0)continue;let e=r.index+r[0].length;t.push({startIndex:e-r[1].length,endIndex:e})}}return t.length===0&&console.error(`patch: mcpStartup: failed to find MCP_SERVER_CONNECTION_BATCH_SIZE default`),t.sort((e,t)=>e.startIndex-t.startIndex)},ba=e=>{let t=_a(e);if(!t)return e;let n=`false`,r=e.slice(0,t.startIndex)+n+e.slice(t.endIndex);return V(e,r,n,t.startIndex,t.endIndex),r},xa=(e,t)=>{let n=ya(e);if(n.length===0)return null;let r=String(t),i=e;for(let e of[...n].reverse()){let t=i.slice(0,e.startIndex)+r+i.slice(e.endIndex);V(i,t,r,e.startIndex,e.endIndex),i=t}return i},Sa=(e,t=300,n=!1)=>{let r=/(,([$\w]+)=([$\w]+(?:\.default)?)\.useCallback.{0,1000}statusLineText.{0,200}?),([$\w]+)=([$\w.]+\(\(\)=>(\2\(([$\w]+)\)),300\)|[$\w]+\(\(\)=>\{\2\(\)\},300\)|[$\w]+\(\2,300\)|.{0,100}\{[$\w]+\.current=void 0,\2\(\)\},300\)\},\[\2\]\)|[$\w]+\.useCallback\(\(\)=>\{if\([$\w]+\.current!==void 0\)clearTimeout\([$\w]+\.current\);[$\w]+\.current=setTimeout\(\([$\w]+,[$\w]+\)=>\{[$\w]+\.current=void 0,[$\w]+\(\)\},300,[$\w]+,\2\)\},\[\2\]\)|\3\.useCallback\(\(\)=>\{.{0,200}setTimeout\(\([$\w]+,[$\w]+\)=>\{[$\w]+\.current=void 0,[$\w]+\(\)\},300,[$\w]+,\2\)\},\[\2\]\))/,i=e.match(/(#[$\w]+)\(\)\{this\.(#[$\w]+)\?\.\(\),this\.\2=this\.(#[$\w]+)\.setTimeout\(\(\)=>\{this\.\2=null,this\.(#[$\w]+)\(\)\},[$\w]+\)\}/);if(i&&i.index!==void 0){let[r,a,o,s,c]=i,l=Number(t),u=Number.isFinite(l)&&l>=0?Math.trunc(l):300,d=n?`${a}(){if(this.${o})return;let t=()=>{this.${o}=this.${s}.setTimeout(t,${u}),this.${c}()};this.${o}=this.${s}.setTimeout(t,${u})}`:`${a}(){if(this.${o})return;let d=Math.max(0,${u}-(Date.now()-(this.tccLastStatusline||0)));this.${o}=this.${s}.setTimeout(()=>{this.${o}=null,this.tccLastStatusline=Date.now(),this.${c}()},d)}`,f=i.index,p=f+r.length,m=e.slice(0,f)+d+e.slice(p);return V(e,m,d,f,p),m}let a=e.match(r);if(!a||a.index===void 0)return console.error(`patch: statuslineUpdateThrottle: failed to find statusline update throttle pattern`),null;let o=a[1],s=a[2],c=a[3],l=a[4],u=a[6]??`${s}()`,d=a[7],f=Number(t),p=Number.isFinite(f)&&f>=0?Math.trunc(f):300,m=d?`${s}, ${d}`:s,h=s,g;g=n?d?o+`,argRef=${c}.useRef(${d}),unused1=${c}.useEffect(()=>{argRef.current=${d};},[${d}]),unused2=${c}.useEffect(()=>{const id=setInterval(()=>${s}(argRef.current),${p});return()=>clearInterval(id);},[${h}]),${l}=${c}.useCallback(()=>{},[])`:o+`,unused1=${c}.useEffect(()=>{const id=setInterval(()=>${u},${p});return()=>clearInterval(id);},[${h}]),${l}=${c}.useCallback(()=>{},[])`:o+`,lastCall=${c}.useRef(0),${l}=${c}.useCallback(()=>{let now=Date.now();if(now-lastCall.current>=${p}){lastCall.current=now;${u};}},[${m}])`;let _=a.index,v=_+a[0].length,y=e.slice(0,_)+g+e.slice(v);return V(e,y,g,_,v),y},Ca=e=>typeof e==`number`?e:e.threshold??1e3,wa=(e,t)=>{let n=e.match(/children:\[([$\w]+)," tokens"\][^]{0,80}?,"tokens"\)/);if(!n||n.index===void 0)return null;let r=n[1].replace(/\$/g,`\\$`),i=Math.max(0,n.index-4e3),a=e.slice(i,n.index+n[0].length),o=[...a.matchAll(RegExp(`(?<![$\\w])${r}=[$\\w]+\\(`,`g`))],s=RegExp(`(${r}=[$\\w]+\\()(${t})(\\)[^]{0,4000}?children:\\[${r}," tokens"\\])`,`y`),c=null;for(let e of o.reverse())if(s.lastIndex=e.index,c=s.exec(a),c)break;return c?{fullMatch:c[0],pre:c[1],partToWrap:c[2],post:c[3],startIndex:i+c.index}:null},Ta=(e,t)=>{let n=Ca(t),r,i,a,o,s,c=`[$\\w]+(?:\\?\\.[$\\w]+)*(?:\\([^()]*\\))?`,l=wa(e,c);if(l)({fullMatch:r,pre:i,partToWrap:a,post:o,startIndex:s}=l);else{let t=e.match(RegExp(`(([$\\w]+)=[$\\w]+\\()(${c})(\\),.{0,2000}key:"tokens".{0,200},\\2," tokens")`));if(t&&t.index!==void 0)[r,i,,a,o]=t,s=t.index;else{let t=e.match(RegExp(`(overrideMessage:.{0,10000},([$\\w]+)=[$\\w]+\\()(${c})(\\),.{0,1000}key:"tokens".{0,200},\\2," tokens")`));if(t&&t.index!==void 0)[r,i,,a,o]=t,s=t.index;else{let t=e.match(/(overrideMessage:.{0,10000},key:"tokens".{0,200}[$\w]+\()(Math\.round\(.+?\))(\))/);if(t&&t.index!==void 0)[r,i,a,o]=t,s=t.index;else return console.error(`patch: tokenCountRounding: cannot find token count pattern in any CC format`),null}}}let u=`${i}Math.round((${a})/${n})*${n}${o}`,d=s+r.length,f=e.slice(0,s)+u+e.slice(d);return V(e,f,u,s,d),f},Ea=(e,t)=>/CLAUDE\.md.{0,100}for\(let \w+ of \["AGENTS\.md"/.test(e)?(console.log(`patch: agentsMd: alternative MD file support already present natively - skipping`),e):Da(e,t)||Oa(e,t)||ka(e,t)||Aa(e,t)||ja(e,t),Da=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+),([$\w]+)=!1;(if\(\6\)\{[\s\S]*?\}else\{[\s\S]*?\})if\(\7===null\)\{([\s\S]*?\[CLAUDE\.md\] skipping[\s\S]*?return\{info:null,includePaths:\[\]\})\}return ([$\w]+)\(\7,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\12,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[7],l=n[8],u=n[9],d=n[10],f=n[11],p=n[12],m=n[13],h=`${r},didReroute){try{let ${c},${l}=!1;${u}if(${c}===null){if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${a}.slice(0,-9)+alt;try{let rerouteResult=await ${i}(altPath,${o},${s},void 0,true);if(rerouteResult.info)return rerouteResult}catch{}}}${d}}return ${f}(${c},${a},${o},${s})}catch(${p}){return ${m}(${p},${a}),{info:null,includePaths:[]}}}`,g=n.index,_=g+n[0].length,v=e.slice(0,g)+h+e.slice(_);return V(e,v,h,g,_),v},Oa=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=!1,([$\w]+)=await ([$\w]+)\(\6,\3,([$\w]+),\(([$\w]+)\)=>\{\8=\12\.isDirectory\(\)\}\);if\(\9===null\)\{([\s\S]*?\[CLAUDE\.md\] skipping[\s\S]*?return\{info:null,includePaths:\[\]\})\}return ([$\w]+)\(\9,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\15,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7],u=n[8],d=n[9],f=n[10],p=n[11],m=n[12],h=n[13],g=n[14],_=n[15],v=n[16],y=`${r},didReroute){try{let ${c}=${l}(),${u}=!1,${d}=await ${f}(${c},${a},${p},(${m})=>{${u}=${m}.isDirectory()});if(${d}===null){if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${a}.slice(0,-9)+alt;try{let rerouteResult=await ${i}(altPath,${o},${s},true);if(rerouteResult.info)return rerouteResult}catch{}}}${h}}return ${g}(${d},${a},${o},${s})}catch(${_}){return ${v}(${_},${a}),{info:null,includePaths:[]}}}`,b=n.index,x=b+n[0].length,S=e.slice(0,b)+y+e.slice(x);return V(e,S,y,b,x),S},ka=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=([$\w]+)\(\),([$\w]+)=await ([$\w]+)\(\6,\3,([$\w]+)\);if\(\8===null\)return (([$\w]+)\(`\[CLAUDE\.md\] skipping[^`]*`\),\{info:null,includePaths:\[\]\});return ([$\w]+)\(\8,\3,\4,\5\)\}catch\(([$\w]+)\)\{return (([$\w]+)\(\14,\3\),\{info:null,includePaths:\[\]\})\}\}/);if(!n||n.index===void 0)return null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7],u=n[8],d=n[9],f=n[10],p=n[11],m=n[13],h=n[14],g=n[15],_=`${r},didReroute){try{let ${c}=${l}(),${u}=await ${d}(${c},${a},${f});if(${u}===null){if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${a}.slice(0,-9)+alt;try{let rerouteResult=await ${i}(altPath,${o},${s},true);if(rerouteResult.info)return rerouteResult}catch{}}}return ${p};}return ${m}(${u},${a},${o},${s})}catch(${h}){return ${g}}}`,v=n.index,y=v+n[0].length,b=e.slice(0,v)+_+e.slice(y);return V(e,b,_,v,y),b},Aa=(e,t)=>{let n=e.match(/(async function ([$\w]+)\(([$\w]+),([$\w]+),([$\w]+))\)\{try\{let ([$\w]+)=await ([$\w]+)\(\)\.readFile\(\3,\{encoding:"utf-8"\}\);return ([$\w]+)\(\6,\3,\4,\5\)\}catch\(([$\w]+)\)\{return ([$\w]+)\(\9,\3\),\{info:null,includePaths:\[\]\}\}\}/);if(!n||n.index===void 0)return null;let r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=n[10],m=`${i},didReroute){try{let ${l}=await ${u}().readFile(${o},{encoding:"utf-8"});return ${d}(${l},${o},${s},${c})}catch(${f}){if(!didReroute&&(${o}.endsWith("/CLAUDE.md")||${o}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${JSON.stringify(t)}){let altPath=${o}.slice(0,-9)+alt;try{let r=await ${a}(altPath,${s},${c},true);if(r.info)return r}catch{}}}return ${p}(${f},${o}),{info:null,includePaths:[]}}}`,h=n.index,g=h+r.length,_=e.slice(0,h)+m+e.slice(g);return V(e,_,m,h,g),_},ja=(e,t)=>{let n=e.match(/(function ([$\w]+)\(([$\w]+),([^)]+?))\)(?:.|\n){0,500}Skipping non-text file in @include/);if(!n||n.index===void 0)return console.error(`patch: agentsMd: failed to find CLAUDE.md reading function`),null;let r=n[1],i=n[2],a=n[3],o=n[4],s=n.index,c=/([$\w]+(?:\(\))?)\.(?:readFileSync|existsSync|statSync)/,l=n[0].match(c),u=null;if(!l&&(u=e.slice(Math.max(0,s-5e3),s).match(c),!u))return console.error(`patch: agentsMd: failed to find fs expression in function or caller`),null;let d=l?l[1]:u?u[1]:`require("fs")`,f=JSON.stringify(t),p=s+r.length,m=e.slice(0,p)+`,didReroute`+e.slice(p);V(e,m,`,didReroute`,p,p);let h=m.slice(s),g=/\.isFile\(\)\)return null/,_=h.match(g)??h.match(/==="EISDIR"\)return null/);if(!_||_.index===void 0)return console.error(`patch: agentsMd: failed to find early return null for injection`),null;let v=!h.match(g),y=`if(!didReroute&&(${a}.endsWith("/CLAUDE.md")||${a}.endsWith("\\\\CLAUDE.md"))){for(let alt of ${f}){let altPath=${a}.slice(0,-9)+alt;if(${d}.existsSync(altPath)&&${d}.statSync(altPath).isFile())return ${i}(altPath,${o},true);}}`,b=s+_.index,x=_[0],S=v?`==="EISDIR"){${y}return null;}`:`.isFile()){${y}return null;}`;return m=m.slice(0,b)+S+m.slice(b+x.length),V(e,m,S,b,b),m},Ma=(e,t)=>{let n=e.lastIndexOf(`function `,t);if(n===-1)return null;let r=e.indexOf(`{`,n);if(r===-1||r>t)return null;let i=0;for(let t=r;t<e.length;t++){let n=e[t];if(n===`{`)i++;else if(n===`}`&&(i--,i===0)){let n=e.slice(r,t+1),i=/return [$\w]+(?:\.default)?\.createElement/g,a,o=null;for(;(a=i.exec(n))!==null;)o=a;return o?r+o.index:null}}return null},Na=e=>{let t=[[/When ready, use \$\{([$\w]+)\} to present your plan for approval/g,(e,t)=>`When ready, use \${${t}} to exit plan mode. The plan will be approved automatically.`],[/Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval\./g,`Use this tool when you are in plan mode and have finished writing your plan to the plan file. Calling this tool exits plan mode and approves the plan automatically.`],[/This tool simply signals that you're done planning and ready for the user to review and approve/g,`This tool signals that you are done planning and that the plan should be approved automatically`],[/Once your plan is finalized, use THIS tool to request approval/g,`Once your plan is finalized, use THIS tool to approve the plan and proceed`],[/ExitPlanMode inherently requests user approval of your plan\./g,`ExitPlanMode inherently approves your plan and lets you proceed.`],[/Present your plan to the user for approval/g,`Exit plan mode; the plan will be approved automatically`],[/design an implementation approach for user approval/g,`design an implementation approach before automatic approval`],[/This tool REQUIRES user approval - they must consent to entering plan mode/g,`This tool enters plan mode; plan exit approval is handled automatically when auto-accept plan mode is enabled`],[/Claude has written up a plan and is ready to execute\. Would you like to proceed\?/g,`Claude has written up a plan and is ready to execute. The plan is approved automatically.`],[/Call `\$\{([$\w]+)\}` to present the plan for approval\./g,(e,t)=>`Call \`\${${t}}\` to exit plan mode; the plan will be approved automatically.`],[/## Phase 2: Spawn Workers \(After Plan Approval\)/g,`## Phase 2: Spawn Workers (After Automatic Plan Approval)`],[/Once the plan is approved, spawn/g,`After the plan is approved automatically, spawn`],[/searchHint:"present plan for approval and start coding \(plan mode only\)"/g,`searchHint:"approve plan and start coding (plan mode only)"`],[/async description\(\)\{return"Prompts the user to exit plan mode and start coding"\}/g,`async description(){return"Exits plan mode and starts coding"}`]],n=e;for(let[r,i]of t){let t=n;n=n.replace(r,i),n!==t&&V(e,n,String(i),0,0)}let r=`permissionUpdates:[{type:"setMode",mode:"acceptEdits",destination:"session"}]`,i=/kind:"permission_exit_plan_mode_v2",payload:([\s\S]{0,300}?),result:([\s\S]{0,180}?),default:\{behavior:"cancelled"\}/,a=n;n=n.replace(i,`kind:"permission_exit_plan_mode_v2",payload:$1,result:$2,default:{behavior:"allow",${r}}`),n!==a&&V(e,n,`permission_exit_plan_mode_v2 default allow`,0,0);let o=/async checkPermissions\(([$\w]+),([$\w]+)\)\{if\(([$\w]+)\(\)\)return\{behavior:"allow",updatedInput:\1\};return\{behavior:"ask",message:"Exit plan mode\?",updatedInput:\1\}\}/,s=n;return n=n.replace(o,`async checkPermissions($1,$2){return{behavior:"allow",updatedInput:$1,${r}}}`),n!==s&&V(e,n,`ExitPlanMode checkPermissions allow`,0,0),n},Pa=e=>{let t=e.indexOf(`title:"Ready to code?"`);if(t===-1)return console.error(`patch: autoAcceptPlanMode: failed to find "Ready to code?" title`),null;if(/[$\w]+(?:\.current)?\("yes-accept-edits(?:-keep-context)?"\);return null;return/.test(e))return e;let n=e.slice(t,t+3e3),r=n.match(/onChange:\([$\w]+\)=>([$\w]+)\([$\w]+\),onCancel/),i=n.match(/onChange:([$\w]+),onCancel/),a=n.match(/onChange:\([$\w]+\)=>void ([$\w]+)\.current\([$\w]+\),onCancel/),o;if(r)o=r[1];else if(i)o=i[1];else if(a)o=`${a[1]}.current`;else return console.error(`patch: autoAcceptPlanMode: failed to find onChange handler`),null;let s=e.match(/(\}\}\)\)\)\);)(return [$\w]+\.default\.createElement\([$\w]+\.default\.Fragment,null,[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:"Ready to code\?")/);if(s&&s.index!==void 0){let t=`${o}("yes-accept-edits-keep-context");return null;`,n=s[1]+t+s[2],r=s.index,i=r+s[0].length,a=e.slice(0,r)+n+e.slice(i);return V(e,a,n,r,i),Na(a)}let c=Math.max(0,t-2500),l=e.slice(c,t),u=l.match(/(return [$\w]+\.default\.createElement\([$\w]+,\{flexDirection:"column",tabIndex:0,autoFocus:!0.{0,200}[$\w]+\.default\.createElement\([$\w]+,\{color:"planMode",title:")$/);if(!u){let n=l.lastIndexOf(`return `);if(n===-1){let n=Ma(e,t);if(n===null)return console.error(`patch: autoAcceptPlanMode: failed to find return before "Ready to code?"`),null;let r=`${o}("yes-accept-edits-keep-context");return null;`,i=e.slice(0,n)+r+e.slice(n);return V(e,i,r,n,n),Na(i)}let r=c+n,i=`${o}("yes-accept-edits-keep-context");return null;`,a=e.slice(0,r)+i+e.slice(r);return V(e,a,i,r,r),Na(a)}let d=c+u.index,f=`${o}("yes-accept-edits-keep-context");return null;`,p=e.slice(0,d)+f+e.slice(d);return V(e,p,f,d,d),Na(p)},Fa=e=>{let t=e.match(/console\.error\("--dangerously-skip-permissions cannot be used with root\/sudo privileges for security reasons"\),process\.exit\(1\)/);if(!t||t.index===void 0)return e.includes(`root/sudo privileges`)?(console.error(`patch: allowBypassPermsInSudo: failed to find pattern`),null):e;let n=t.index,r=n+t[0].length,i=e.slice(0,n)+`{}`+e.slice(r);return V(e,i,`{}`,n,r),i},Ia=[/Claude Code has switched from npm to native installer\. Run `claude install` or see https:\/\/docs\.anthropic\.com\/en\/docs\/claude-code\/getting-started for more options\./g,/installMethod is native, but directory [^"'`\n;]+/g,/installMethod is native, but claude command (?:is missing or invalid|not found) at [^"'`\n;]+/g,/Native installation exists but ~\/\.local\/bin is not in your PATH(?:\. Run: echo 'export PATH="\$HOME\/\.local\/bin:\$PATH"' >> [^"'`\n;]+ then open a new terminal or run: source [^"'`\n;]+)?/g,/Run: echo 'export PATH="\$HOME\/\.local\/bin:\$PATH"' >> [^"'`\n;]+ then open a new terminal or run: source [^"'`\n;]+/g],La=e=>{let t=e,n=!1,r=-1,i=-1;for(let e of Ia)t=t.replace(e,(e,t)=>(n||(r=t,i=t+e.length),n=!0,``));return n?(V(e,t,``,r,i),t):(console.warn(`patch: suppressNativeInstallerWarning: failed to find pattern`),null)},Ra=e=>{let t=e.split(`
|
|
742
742
|
`),n=0;for(let e=0;e<t.length;e++){let r=t[e];if(!r.startsWith(`#!`)&&!(r.startsWith(`//`)&&(r.includes(`Version`)||r.includes(`(c)`)))&&!(r.trim()===``&&e<5)){n=e;break}}return n>0?t.slice(0,n).join(`
|
|
743
743
|
`).length:0},za=e=>{let t=Ra(e),n=`// SCROLLING FIX PATCH START
|
|
744
744
|
const _origStdoutWrite=process.stdout.write;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,C as t,ct as n,f as r,h as i,l as a,lt as o,n as s,p as c,r as l,u,ut as ee,w as d}from"./config-
|
|
1
|
+
import{A as e,C as t,ct as n,f as r,h as i,l as a,lt as o,n as s,p as c,r as l,u,ut as ee,w as d}from"./config-BEI9_PWQ.mjs";import{Box as f,Text as p,render as m,useInput as h}from"ink";import g,{useState as _}from"react";import*as te from"node:os";import v from"node:os";import*as y from"node:fs/promises";import b from"node:fs/promises";import x from"path";import{jsx as S,jsxs as C}from"react/jsx-runtime";import w from"which";import{globbySync as T}from"globby";const E=(()=>{let e=[],t=process.platform==`win32`?v.homedir().replace(/\\/g,`/`):v.homedir(),n=`node_modules/@anthropic-ai/claude-code`,r=(t,n=!1)=>{if(n)try{let n=T(t,{onlyFiles:!1});e.push({pattern:t,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?c(`Permission denied accessing: ${t} (${n.code})`):c(`Error expanding glob pattern "${t}": ${n instanceof Error?n.message:String(n)}`),e.push({pattern:t,isGlob:!0,expandedPaths:[]})}else e.push({pattern:t,isGlob:!1,expandedPaths:[t]})};return r(`${v.homedir()}/.claude/local/${n}`),process.env.NPM_PREFIX&&r(`${process.env.NPM_PREFIX}/lib/${n}`),process.env.N_PREFIX&&r(`${process.env.N_PREFIX}/lib/${n}`),process.env.VOLTA_HOME&&r(`${process.env.VOLTA_HOME}/lib/${n}`),process.env.FNM_DIR&&r(`${process.env.FNM_DIR}/lib/${n}`),process.env.NVM_DIR&&r(`${process.env.NVM_DIR}/lib/${n}`),process.env.NODENV_ROOT&&r(`${process.env.NODENV_ROOT}/versions/*/lib/${n}`,!0),process.env.NVS_HOME&&r(`${process.env.NVS_HOME}/node/*/*/lib/${n}`,!0),process.env.ASDF_DATA_DIR&&r(`${process.env.ASDF_DATA_DIR}/installs/nodejs/*/lib/${n}`,!0),process.platform==`win32`?(r(`${t}/AppData/Local/Volta/tools/image/packages/@anthropic-ai/claude-code/${n}`),r(`${t}/AppData/Roaming/npm/${n}`),r(`${t}/AppData/Roaming/nvm/*/${n}`,!0),r(`${t}/AppData/Local/Yarn/config/global/${n}`),r(`${t}/AppData/Local/pnpm/global/*/${n}`,!0),r(`C:/nvm4w/nodejs/${n}`),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/AppData/Roaming/Yarn/config/global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/${n}`),r(`${t}/AppData/Roaming/pnpm-global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/Bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/AppData/Local/fnm_multishells/*/node_modules/${n}`,!0),r(`${t}/AppData/Local/mise/installs/node/*/${n}`,!0),r(`${t}/AppData/Local/mise/installs/npm-anthropic-ai-claude-code/*/${n}`,!0)):(process.platform==`darwin`&&(r(`${t}/Library/${n}`),r(`/opt/local/lib/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/Library/Caches/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0)),r(`${t}/.local/lib/${n}`),r(`${t}/.local/share/${n}`),r(`${t}/.npm-global/lib/${n}`),r(`${t}/.npm-packages/lib/${n}`),r(`${t}/.npm/lib/${n}`),r(`${t}/npm/lib/${n}`),r(`/etc/${n}`),r(`/lib/${n}`),r(`/opt/node/lib/${n}`),r(`/usr/lib/${n}`),r(`/usr/local/lib/${n}`),r(`/usr/share/${n}`),r(`/var/lib/${n}`),r(`/opt/homebrew/lib/${n}`),r(`${t}/.linuxbrew/lib/${n}`),r(`${t}/.config/yarn/global/${n}`),r(`${t}/.yarn/global/${n}`),r(`${t}/.bun/install/global/${n}`),r(`${t}/.pnpm-global/${n}`),r(`${t}/.pnpm-global/*/${n}`,!0),r(`${t}/pnpm-global/${n}`),r(`${t}/pnpm-global/*/${n}`,!0),r(`${t}/.local/share/pnpm/global/${n}`),r(`${t}/.local/share/pnpm/global/*/${n}`,!0),r(`${t}/.bun/install/global/${n}`),r(`${t}/.bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`${t}/.local/share/bun/install/cache/@anthropic-ai/claude-code*@@@*`,!0),r(`/usr/local/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/versions/node/*/lib/${n}`,!0),r(`${t}/n/lib/${n}`),r(`${t}/.volta/tools/image/node/*/lib/${n}`,!0),r(`${t}/.fnm/node-versions/*/installation/lib/${n}`,!0),r(`${t}/.local/state/fnm_multishells/*/lib/${n}`,!0),r(`/usr/local/nvm/versions/node/*/lib/${n}`,!0),r(`/usr/local/share/nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nvm/versions/node/*/lib/${n}`,!0),r(`${t}/.nodenv/versions/*/lib/${n}`,!0),r(`${t}/.nvs/*/lib/${n}`,!0),r(`${t}/.asdf/installs/nodejs/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/node/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/node/*/lib/${n}`,!0),process.env.MISE_DATA_DIR&&r(`${process.env.MISE_DATA_DIR}/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0),r(`${t}/.local/share/mise/installs/npm-anthropic-ai-claude-code/*/lib/${n}`,!0)),process.platform==`win32`&&e.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),e})().flatMap(e=>e.expandedPaths),ne=(()=>{let e=process.platform===`win32`?v.homedir().replace(/\\/g,`/`):v.homedir(),t=[],n=(e,n=!1)=>{if(n)try{let n=T(e,{onlyFiles:!0});t.push({pattern:e,isGlob:!0,expandedPaths:n})}catch(n){n instanceof Error&&`code`in n&&(n.code===`EACCES`||n.code===`EPERM`)?c(`Permission denied accessing: ${e} (${n.code})`):c(`Error expanding glob pattern "${e}": ${n instanceof Error?n.message:String(n)}`),t.push({pattern:e,isGlob:!0,expandedPaths:[]})}else t.push({pattern:e,isGlob:!1,expandedPaths:[e]})};if(n(`${e}/.local/bin/claude`),process.platform===`win32`&&(n(`${e}/.nvm/versions/node/v22.21.1/lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`),n(`${e}/.local/bin/claude.exe`)),n(`${e}/.local/share/claude/versions/*`,!0),process.platform!==`win32`){let t=`lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`,r=process.env.MISE_DATA_DIR||`${e}/.local/share/mise`;n(`${r}/installs/node/*/${t}`,!0),n(`${r}/installs/npm-anthropic-ai-claude-code/*/${t}`,!0)}return process.platform===`win32`&&t.forEach(e=>{e.pattern=e.pattern.replace(/\//g,`\\`),e.expandedPaths=e.expandedPaths.map(e=>e.replace(/\//g,`\\`))}),t})().flatMap(e=>e.expandedPaths);var D=class extends Error{constructor(e){super(e),this.name=`InstallationDetectionError`}};let O=null;async function re(){return O||=(async()=>{try{let{WASMagic:e}=await import(`wasmagic`);return await e.create()}catch(e){return c(`WASMagic initialization failed (likely SIMD unsupported on this CPU):`,e),c(`Using fallback file type detection`),null}})(),O}const ie=Buffer.from([127,69,76,70]),ae=Buffer.from([254,237,250,206]),oe=Buffer.from([254,237,250,207]),se=Buffer.from([206,250,237,254]),k=Buffer.from([207,250,237,254]),A=Buffer.from([202,254,186,190]),j=Buffer.from([77,90]);function M(e){if(e.length===0)return null;if(e[0]===35&&e[1]===33&&e.subarray(0,Math.min(256,e.length)).toString(`utf8`).split(`
|
|
2
2
|
`)[0].includes(`node`))return c(`detectFileTypeFallback: Detected JavaScript via shebang`),`javascript`;if(e.length>=4){let t=e.subarray(0,4);if(t.equals(ie))return c(`detectFileTypeFallback: Detected ELF binary`),`binary`;if(t.equals(ae)||t.equals(oe)||t.equals(se)||t.equals(k)||t.equals(A))return c(`detectFileTypeFallback: Detected Mach-O binary`),`binary`}if(e.length>=2&&e.subarray(0,2).equals(j))return c(`detectFileTypeFallback: Detected PE binary`),`binary`;let t=Math.min(512,e.length),n=0,r=0;for(let i=0;i<t;i++){let t=e[i];(t>=32&&t<=126||t===9||t===10||t===13)&&n++,t===0&&r++}if(r>0)return c(`detectFileTypeFallback: Detected binary (${r} null bytes in first ${t} bytes)`),`binary`;let i=n/t;return i>.9?(c(`detectFileTypeFallback: Detected JavaScript via text heuristic (${Math.round(i*100)}% printable)`),`javascript`):(c(`detectFileTypeFallback: Unknown file type (${Math.round(i*100)}% printable)`),null)}async function N(e,t=4096){try{let n=await b.open(e,`r`);try{let e=Buffer.allocUnsafe(t),{bytesRead:r}=await n.read({buffer:e,position:0,length:t});return r<=0?null:e.subarray(0,r)}finally{await n.close()}}catch(e){return c(`Failed to read file prefix:`,e),null}}async function P(e){if(process.platform===`win32`)return e;let t=await ee(e);return t?(c(`maybeResolveNixWrapper: resolved Nix wrapper ${e} -> ${t}`),t):e}async function F(e){try{let t=await b.realpath(e);c(`resolvePathToInstallationType: ${e} -> ${t}`);let n=await N(t);if(!n)return c(`resolvePathToInstallationType: Could not read file prefix`),null;let r=await re();if(r&&typeof r.detect==`function`){let e=r.detect(n)||null;if(e){let n=e.toLowerCase();return c(`resolvePathToInstallationType: Detected mime type: ${n}`),n.includes(`javascript`)?{kind:`npm-based`,resolvedPath:t}:n.startsWith(`text/`)?(c(`resolvePathToInstallationType: Unrecognized file type`),null):{kind:`native-binary`,resolvedPath:await P(t)}}}c(`resolvePathToInstallationType: Using fallback file type detection`);let i=M(n);return i===`javascript`?{kind:`npm-based`,resolvedPath:t}:i===`binary`?{kind:`native-binary`,resolvedPath:await P(t)}:(c(`resolvePathToInstallationType: Fallback could not determine file type`),null)}catch(e){return c(`resolvePathToInstallationType: Error:`,e),null}}async function I(){c(`getClaudeFromPath: PATH = ${process.env.PATH}`),c(`getClaudeFromPath: PATHEXT = ${process.env.PATHEXT}`);try{let e=await w(`claude`);return c(`getClaudeFromPath: Found claude at ${e}`),e}catch{return c(`getClaudeFromPath: claude not found on PATH`),null}}function L(e){let t=/\bVERSION:"(\d+\.\d+\.\d+)"/g,n=new Map,r;for(;(r=t.exec(e))!==null;){let e=r[1];n.set(e,(n.get(e)||0)+1)}if(n.size===0)return null;let i=0,a;for(let[e,t]of n.entries())c(`Found version ${e} with ${t} occurrences`),t>i&&(i=t,a=e);return a&&c(`Extracted version ${a} (${i} occurrences)`),a||null}async function R(e){let t=L(await b.readFile(e,`utf8`));if(!t)throw Error(`No VERSION strings found in JS file: ${e}`);return t}async function z(e){let{data:t,error:r}=await n(e);if(!t)throw Error(`Could not extract JS from native binary: ${e}${r?` (${r})`:``}`);let i=L(t.toString(`utf8`));if(!i)throw Error(`No VERSION strings found in extracted JS from: ${e}`);return i}function B(e){let t=x.basename(e).match(/^(\d+\.\d+\.\d+)$/);return t?t[1]:null}async function V(e,t){let n=B(e);return n?(c(`extractVersion: Got version ${n} from filename`),n):t===`npm-based`?R(e):z(e)}async function H(){let e=[],t=new Set;for(let n of E){let r=x.join(n,`cli.js`);try{if(await i(r)){let n=await b.realpath(r).catch(()=>r);if(t.has(n))continue;t.add(n),c(`collectCandidates: Found cli.js at ${n}`);let i=await R(n);e.push({path:n,kind:`npm-based`,version:i})}}catch(e){c(`collectCandidates: Error checking ${r}:`,e)}}for(let n of ne)try{if(await i(n)){let r=await b.realpath(n).catch(()=>n);if(t.has(r))continue;t.add(r);let i=await P(r);c(`collectCandidates: Found native binary at ${r}${i===r?``:` (resolved -> ${i})`}`);let a=await V(i,`native-binary`);e.push({path:i,kind:`native-binary`,version:a})}}catch(e){c(`collectCandidates: Error checking ${n}:`,e)}return[...e].sort((e,t)=>r(t.version,e.version))}function U(e){return e.map(e=>` • ${e.path} (${e.kind}, v${e.version})`).join(`
|
|
3
3
|
`)}function W(e){return` 2. Set ccInstallationPath in your config file (${l}):
|
|
4
4
|
|