MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / X$K

Function X$K

package/cli.js:2998–2998  ·  view source on GitHub ↗
(q,K)

Source from the content-addressed store, hash-verified

2996- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
2997- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
2998- The edit will FAIL if \`old_string\` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use \`replace_all\` to change every instance of \`old_string\`.
2999- Use \`replace_all\` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.`}var q$K=y(()=>{bK();IY()});var Ou8,Js1,Ms1,K$K;var wu8=y(()=>{x7();TK6();Ou8=B6(()=>L.strictObject({file_path:L.string().describe("The absolute path to the file to modify"),old_string:L.string().describe("The text to replace"),new_string:L.string().describe("The text to replace it with (must be different from old_string)"),replace_all:BX(L.boolean().default(!1).optional()).describe("Replace all occurrences of old_string (default false)")})),Js1=B6(()=>L.object({oldStart:L.number(),oldLines:L.number(),newStart:L.number(),newLines:L.number(),lines:L.array(L.string())})),Ms1=B6(()=>L.object({filename:L.string(),status:L.enum(["modified","added"]),additions:L.number(),deletions:L.number(),changes:L.number(),patch:L.string(),repository:L.string().nullable().optional().describe("GitHub owner/repo when available")})),K$K=B6(()=>L.object({filePath:L.string().describe("The file path that was edited"),oldString:L.string().describe("The original string that was replaced"),newString:L.string().describe("The new string that replaced it"),originalFile:L.string().describe("The original file contents before editing"),structuredPatch:L.array(Js1()).describe("Diff patch showing the changes"),userModified:L.boolean().describe("Whether the user modified the proposed changes"),replaceAll:L.boolean().describe("Whether all occurrences were replaced"),gitDiff:Ms1().optional()}))});import{extname as loz}from"path";function _$K(q,K,_){let z=JL7(_,K),Y=Bj6.get(z);if(Y!==void 0)return Bj6.delete(z),Bj6.set(z,Y),Y;let $=q.highlight(K,{language:_});if(Bj6.size>=noz){let A=Bj6.keys().next().value;if(A!==void 0)Bj6.delete(A)}return Bj6.set(z,$),$}function z$K(q){let K=z6(20),{code:_,filePath:z,dim:Y,skipColoring:$}=q,A=Y===void 0?!1:Y,O=$===void 0?!1:$,w;if(K[0]!==_)w=jl(_),K[0]=_,K[1]=w;else w=K[1];let j=w;if(O){let D;if(K[2]!==j)D=vb.default.createElement(B5,null,j),K[2]=j,K[3]=D;else D=K[3];let f;if(K[4]!==A||K[5]!==D)f=vb.default.createElement(k,{dimColor:A},D),K[4]=A,K[5]=D,K[6]=f;else f=K[6];return f}let H;if(K[7]!==z)H=loz(z).slice(1),K[7]=z,K[8]=H;else H=K[8];let J=H,M;if(K[9]!==j)M=vb.default.createElement(B5,null,j),K[9]=j,K[10]=M;else M=K[10];let X;if(K[11]!==j||K[12]!==J)X=vb.default.createElement(ioz,{codeWithSpaces:j,language:J}),K[11]=j,K[12]=J,K[13]=X;else X=K[13];let P;if(K[14]!==M||K[15]!==X)P=vb.default.createElement(vb.Suspense,{fallback:M},X),K[14]=M,K[15]=X,K[16]=P;else P=K[16];let W;if(K[17]!==A||K[18]!==P)W=vb.default.createElement(k,{dimColor:A},P),K[17]=A,K[18]=P,K[19]=W;else W=K[19];return W}function ioz(q){let K=z6(10),{codeWithSpaces:_,language:z}=q,Y;if(K[0]===Symbol.for("react.memo_cache_sentinel"))Y=Er(),K[0]=Y;else Y=K[0];let $=vb.use(Y),A;if(K[1]!==_||K[2]!==$||K[3]!==z){q:{if(!$){A=_;break q}let j="markdown";if(z)if($.supportsLanguage(z))j=z;else N(`Language not supported while highlighting code, falling back to markdown: ${z}`);try{A=_$K($,_,j)}catch(H){let J=H;if(J instanceof Error&&J.message.includes("Unknown language")){N(`Language not supported while highlighting code, falling back to markdown: ${J}`);let M;if(K[5]!==_||K[6]!==$)M=_$K($,_,"markdown"),K[5]=_,K[6]=$,K[7]=M;else M=K[7];A=M;break q}A=_}}K[1]=_,K[2]=$,K[3]=z,K[4]=A}else A=K[4];let O=A,w;if(K[8]!==O)w=vb.default.createElement(B5,null,O),K[8]=O,K[9]=w;else w=K[9];return w}var vb,noz=500,Bj6;var Y$K=y(()=>{q8();s6();sO6();_8();bK();vb=O6(D6(),1),Bj6=new Map});import{basename as roz,extname as ooz}from"path";function Ws1(){if(ju8)return ju8;let q=cr6();return ju8="default"in q&&q.default?q.default:q,ju8}function a4(q,K,_){return{r:q,g:K,b:_,a:255}}function iP(q){return{r:q,g:0,b:0,a:0}}function M$K(q){if(q.includes("ansi"))return"ansi";let K=process.env.COLORTERM??"";return K==="truecolor"||K==="24bit"?"truecolor":"color256"}function aoz(q,K,_){let z=(f)=>f<48?0:f<115?1:f<155?2:f<195?3:f<235?4:5,Y=z(q),$=z(K),A=z(_),O=16+36*Y+6*$+A,w=Math.round((q+K+_)/3);if(w<5)return 16;if(w>244&&Y===$&&$===A)return O;let j=Math.max(0,Math.min(23,Math.round((w-8)/10))),H=232+j,J=8+j*10,M=Ps1[Y],X=Ps1[$],P=Ps1[A],W=(q-M)**2+(K-X)**2+(_-P)**2;return(q-J)**2+(K-J)**2+(_-J)**2<W?H:O}function $$K(q,K,_){if(q.a===0){let Y=q.r;if(Y<8)return`\x1B[${(K?30:40)+Y}m`;if(Y<16)return`\x1B[${(K?90:100)+(Y-8)}m`;return`\x1B[${K?38:48};5;${Y}m`}if(q.a===1)return K?"\x1B[39m":"\x1B[49m";let z=K?38:48;if(_==="truecolor")return`\x1B[${z};2;${q.r};${q.g};${q.b}m`;return`\x1B[${z};5;${aoz(q.r,q.g,q.b)}m`}function soz(q,K,_,z){let Y=z?Xs1+Ds1:Xs1;for(let[$,A]of q){if(Y+=$$K($.foreground,!0,K),!_)Y+=$$K($.background,!1,K);Y+=A}return Y+Xs1}function toz(q){if(q.includes("ansi"))return"ansi";if(q.includes("dark"))return"Monokai Extended";return"GitHub"}function X$K(q,K){let _=q.includes("dark"),z=q.includes("ansi"),Y=q.includes("daltonized"),$=K==="truecolor";if(z)return{addLine:Ta,addWord:Ta,addDecoration:iP(10),deleteLine:Ta,deleteWord:Ta,deleteDecoration:iP(9),foreground:iP(7),background:Ta,scopes:qaz};if(_){let H=a4(248,248,242),J=a4(61,1,0),M=a4(92,2,0),X=a4(220,90,90);if(Y)return{addLine:$?a4(0,27,41):iP(17),addWord:$?a4(0,48,71):iP(24),addDecoration:a4(81,160,200),deleteLine:J,deleteWord:M,deleteDecoration:X,foreground:H,background:Ta,scopes:A$K};return{addLine:$?a4(2,40,0):iP(22),addWord:$?a4(4,71,0):iP(28),addDecoration:a4(80,200,80),deleteLine:J,deleteWord:M,deleteDecoration:X,foreground:H,background:Ta,scopes:A$K}}let A=a4(51,51,51),O=a4(255,220,220),w=a4(255,199,199),j=a4(207,34,46);if(Y)return{addLine:a4(219,237,255),addWord:a4(179,217,255),addDecoration:a4(36,87,138),deleteLine:O,deleteWord:w,deleteDecoration:j,foreground:A,background:Ta,scopes:O$K};return{addLine:a4(220,255,220),addWord:a4(178,255,178),addDecoration:a4(36,138,61),deleteLine:O,deleteWord:w,deleteDecoration:j,foreground:A,background:Ta,scopes:O$K}}function Hu8(q){return{foreground:q.foreground,background:q.background}}function Ju8(q,K){switch(q){case"+":return K.addLine;case"-":return K.deleteLine;case" ":return K.background}}function Kaz(q,K){switch(q){case"+":return K.addWord;case"-":return K.deleteWord;case" ":return K.background}}function P$K(q,K){switch(q){case"+":return K.addDecoration;case"-":return K.deleteDecoration;case" ":return K.foreground}}function W$K(q,K){let _=roz(q),z=ooz(q).slice(1),Y=_.split(".")[0]??"",$=w$K[_]??w$K[Y];if($&&Ws1().getLanguage($))return $;if(z){if(Ws1().getLanguage(z))return z}if(K){let A=K.startsWith("\uFEFF")?K.slice(1):K;if(A.startsWith("#!")){if(A.includes("bash")||A.includes("/sh"))return"bash";if(A.includes("python"))return"python";if(A.includes("node"))return"javascript";if(A.includes("ruby"))return"ruby";if(A.includes("perl"))return"perl"}if(A.startsWith("<?php"))return"php";if(A.startsWith("<?xml"))return"xml"}return null}function _az(q,K,_){if(!q)return _.foreground;if(q==="keyword"&&eoz.has(K.trim()))return _.scopes._storage??_.foreground;return _.scopes[q]??_.scopes[q.split(".")[0]]??_.foreground}function D$K(q,K,_,z){if(typeof q==="string"){let $=_az(_,q,K);z.push([{foreground:$,background:K.background},q]);return}let Y=q.scope??q.kind??_;for(let $ of q.children)D$K($,K,Y,z)}function zaz(q){return typeof q==="object"&&q!==null&&"rootNode"in q&&typeof q.rootNode==="object"&&q.rootNode!==null&&"children"in q.rootNode}function f$K(q,K,_){let z=K+`
3000`;if(!q.lang)return[[Hu8(_),z]];let Y;try{Y=Ws1().highlight(z,{language:q.lang,ignoreIllegals:!0})}catch{return[[Hu8(_),z]]}if(!zaz(Y.emitter)){if(!j$K)j$K=!0,H6(Error(`color-diff: hljs emitter shape mismatch (keys: ${Object.keys(Y.emitter).join(",")}). Syntax highlighting disabled.`));return[[Hu8(_),z]]}let $=[];return D$K(Y.emitter.rootNode,_,void 0,$),$}function H$K(q){let K=[],_=0;while(_<q.length){let z=q[_];if(/[\p{L}\p{N}_]/u.test(z)){let Y=_+1;while(Y<q.length&&/[\p{L}\p{N}_]/u.test(q[Y]))Y++;K.push(q.slice(_,Y)),_=Y}else if(/\s/.test(z)){let Y=_+1;while(Y<q.length&&/\s/.test(q[Y]))Y++;K.push(q.slice(_,Y)),_=Y}else{let $=q.codePointAt(_)>65535?2:1;K.push(q.slice(_,_+$)),_+=$}}return K}function $az(q){let K=[],_=0;while(_<q.length)if(q[_]==="-"){let z=_,Y=_;while(Y<q.length&&q[Y]==="-")Y++;let $=Y;while($<q.length&&q[$]==="+")$++;let A=Y-z,O=$-Y;if(A>0&&O>0){let w=Math.min(A,O);for(let j=0;j<w;j++)K.push([z+j,Y+j]);_=$}else _=Y}else _++;return K}function Aaz(q,K){let _=H$K(q),z=H$K(K),Y=px1(_,z),$=q.length+K.length,A=0,O=[],w=[],j=0,H=0;for(let J of Y){let M=J.value.reduce((X,P)=>X+P.length,0);if(J.removed)A+=M,O.push({start:j,end:j+M}),j+=M;else if(J.added)A+=M,w.push({start:H,end:H+M}),H+=M;else j+=M,H+=M}if($>0&&A/$>Yaz)return[[],[]];return[O,w]}function Z$K(q){q.lines=q.lines.map((K)=>K.flatMap(([_,z])=>z.split(`
3001`).filter((Y)=>Y.length>0).map((Y)=>[_,Y])))}function Oaz(q){return O1(q)}function G$K(q,K,_){let z=[];for(let Y of q.lines){let $=Y.slice(),A=[],O=0;while($.length>0){let[w,j]=$.shift(),H=O1(j);if(O+H<=K)A.push([w,j]),O+=H;else{let J=K-O,M=0,X=0;for(let P of j){let W=Oaz(P);if(X+W>J)break;X+=W,M+=P.length}if(M===0)if(O===0)M=j.codePointAt(0)>65535?2:1;else{z.push(A),$.unshift([w,j]),A=[],O=0;continue}A.push([w,j.slice(0,M)]),z.push(A),$.unshift([w,j.slice(M)]),A=[],O=0}}z.push(A)}if(q.lines=z,q.marker&&q.marker!==" "){let Y=Ju8(q.marker,_),$={foreground:_.foreground,background:Y};for(let A of q.lines){let O=A.reduce((w,[,j])=>w+O1(j),0);if(O<K)A.push([$," ".repeat(K-O)])}}}function T$K(q,K,_,z){let Y={foreground:q.marker?P$K(q.marker,K):K.foreground,background:q.marker?Ju8(q.marker,K):K.background},$=q.marker===null||q.marker===" ";for(let A=0;A<q.lines.length;A++){let O=A===0?` ${String(q.lineNumber).padStart(_)} `:" ".repeat(_+2),w=$&&!z?`${Ds1}${O}${J$K}`:O;q.lines[A].unshift([Y,w])}}function waz(q,K){if(!q.marker)return;let _={foreground:P$K(q.marker,K),background:Ju8(q.marker,K)};for(let z of q.lines)z.unshift([_,q.marker])}function jaz(q){for(let K of q.lines)if(K.length>0){K[0][1]=Ds1+K[0][1];let _=K.length-1;K[_][1]=K[_][1]+J$K}}function Haz(q,K,_){if(!q.marker)return;let z=Ju8(q.marker,K),Y=Kaz(q.marker,K),$=0,A=0;for(let O=0;O<q.lines.length;O++){let w=[];for(let[j,H]of q.lines[O]){let J=A,M=A+H.length;while($<_.length&&_[$].end<=J)$++;if($>=_.length){w.push([{...j,background:z},H]),A=M;continue}let X=H,P=J;while(X.length>0&&$<_.length){let W=_[$],D=P>=W.start&&P<W.end,f;if(D)f=Math.min(W.end,M);else if(W.start>P&&W.start<M)f=W.start;else f=M;let G=f-P,Z=X.slice(0,G);if(w.push([{...j,background:D?Y:z},Z]),X=X.slice(G),P=f,P>=W.end)$++}if(X.length>0)w.push([{...j,background:z},X]);A=M}q.lines[O]=w}}function v$K(q,K,_,z){return q.lines.map((Y)=>soz(Y,z,_,K))}function Jaz(q){let K=Math.max(0,q.oldStart+q.oldLines-1),_=Math.max(0,q.newStart+q.newLines-1);return Math.max(K,_)}function Maz(q){return q==="+"||q==="-"?q:" "}class fs1{hunk;filePath;firstLine;prefixContent;constructor(q,K,_,z){this.hunk=q,this.filePath=_,this.firstLine=K,this.prefixContent=z??null}render(q,K,_){let z=M$K(q),Y=X$K(q,z),A={lang:W$K(this.filePath,this.firstLine),stack:null};this.prefixContent;let O=String(Jaz(this.hunk)).length,w=this.hunk.oldStart,j=this.hunk.newStart,H=Math.max(1,K-O-2-1),J=this.hunk.lines.map((P)=>{let W=Maz(P.slice(0,1)),D=P.slice(1),f;switch(W){case"+":f=j++;break;case"-":f=w++;break;case" ":f=j,w++,j++;break}return{lineNumber:f,marker:W,code:D}}),M=J.map(()=>[]);if(!_){let P=J.map((W)=>W.marker);for(let[W,D]of $az(P)){let[f,G]=Aaz(J[W].code,J[D].code);M[W]=f,M[D]=G}}let X=[];for(let P=0;P<J.length;P++){let{lineNumber:W,marker:D,code:f}=J[P],G=D==="-"?[[Hu8(Y),f]]:f$K(A,f,Y),Z={marker:D,lineNumber:W,lines:[G]};if(Z$K(Z),Haz(Z,Y,M[P]),G$K(Z,H,Y),z==="ansi"&&D==="-")jaz(Z);waz(Z,Y),T$K(Z,Y,O,_),X.push(...v$K(Z,_,!1,z))}return X}}class Zs1{code;filePath;constructor(q,K){this.code=q,this.filePath=K}render(q,K,_){let z=M$K(q),Y=X$K(q,z),$=this.code.split(`

Callers 2

renderMethod · 0.85
renderMethod · 0.85

Calls 3

iPFunction · 0.85
a4Function · 0.85
includesMethod · 0.80

Tested by

no test coverage detected