MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / getPath

Function getPath

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

Source from the content-addressed store, hash-verified

3026Human:`,"\n\nA:":`
3027
3028Assistant:`}});function Tu8(q){if(!q)return"Update";if(q.file_path?.startsWith(hA()))return"Updated plan";if(q.edits!=null)return"Update";if(q.old_string==="")return"Create";return"Update"}function Rs1(q){if(!q?.file_path)return null;return _3(q.file_path)}function U$K({file_path:q},{verbose:K}){if(!q)return null;if(q.startsWith(hA()))return"";return A$.createElement(x0,{filePath:q},K?q:_3(q))}function Q$K({filePath:q,structuredPatch:K,originalFile:_},z,{style:Y,verbose:$}){let A=q.startsWith(hA());return A$.createElement(Pu8,{filePath:q,structuredPatch:K,firstLine:_.split(`
3029`)[0]??null,fileContent:_,style:Y,verbose:$,previewHint:A?"/plan to preview":void 0})}function d$K(q,K){let{style:_,verbose:z}=K,Y=q.file_path,$=q.old_string??"",A=q.new_string??"",O=q.replace_all??!1;if("edits"in q&&q.edits!=null)return A$.createElement(yK6,{file_path:Y,operation:"update",firstLine:null,verbose:z});if($==="")return A$.createElement(yK6,{file_path:Y,operation:"write",content:A,firstLine:ce(A),verbose:z});return A$.createElement(Baz,{filePath:Y,oldString:$,newString:A,replaceAll:O,style:_,verbose:z})}function c$K(q,K){let{verbose:_}=K;if(!_&&typeof q==="string"&&o4(q,"tool_use_error")){let z=o4(q,"tool_use_error");if(z?.includes("File has not been read yet"))return A$.createElement(s8,null,A$.createElement(k,{dimColor:!0},"File must be read first"));if(z?.includes(uZ))return A$.createElement(s8,null,A$.createElement(k,{color:"error"},"File not found"));return A$.createElement(s8,null,A$.createElement(k,{color:"error"},"Error editing file"))}return A$.createElement(Y2,{result:q,verbose:_})}function Baz(q){let K=z6(16),{filePath:_,oldString:z,newString:Y,replaceAll:$,style:A,verbose:O}=q,w;if(K[0]!==_||K[1]!==Y||K[2]!==z||K[3]!==$)w=()=>Faz(_,z,Y,$),K[0]=_,K[1]=Y,K[2]=z,K[3]=$,K[4]=w;else w=K[4];let[j]=iL6.useState(w),H;if(K[5]!==_||K[6]!==O)H=A$.createElement(yK6,{file_path:_,operation:"update",firstLine:null,verbose:O}),K[5]=_,K[6]=O,K[7]=H;else H=K[7];let J;if(K[8]!==j||K[9]!==_||K[10]!==A||K[11]!==O)J=A$.createElement(gaz,{promise:j,filePath:_,style:A,verbose:O}),K[8]=j,K[9]=_,K[10]=A,K[11]=O,K[12]=J;else J=K[12];let M;if(K[13]!==H||K[14]!==J)M=A$.createElement(iL6.Suspense,{fallback:H},J),K[13]=H,K[14]=J,K[15]=M;else M=K[15];return M}function gaz(q){let K=z6(7),{promise:_,filePath:z,style:Y,verbose:$}=q,{patch:A,firstLine:O,fileContent:w}=iL6.use(_),j;if(K[0]!==w||K[1]!==z||K[2]!==O||K[3]!==A||K[4]!==Y||K[5]!==$)j=A$.createElement(yK6,{file_path:z,operation:"update",patch:A,firstLine:O,fileContent:w,style:Y,verbose:$}),K[0]=w,K[1]=z,K[2]=O,K[3]=A,K[4]=Y,K[5]=$,K[6]=j;else j=K[6];return j}async function Faz(q,K,_,z){try{let Y=await x$K(q,K,dL6);if(Y===null||Y.truncated||Y.content===""){let{patch:w}=_88({filePath:q,fileContents:K,oldString:K,newString:_});return{patch:w,firstLine:null,fileContent:void 0}}let $=Fj6(Y.content,K)||K,A=nL6(K,$,_),{patch:O}=_88({filePath:q,fileContents:Y.content,oldString:$,newString:A,replaceAll:z});return{patch:Ku8(O,Y.lineOffset-1),firstLine:Y.lineOffset===1?ce(Y.content):null,fileContent:Y.content}}catch(Y){return H6(Y),{patch:[],firstLine:null,fileContent:void 0}}}var A$,iL6;var hs1=y(()=>{q8();Gs1();gK();i1();bN();Ts1();YK6();s6();BQ();bK();E8();SJ();Zu8();Uj6();A$=O6(D6(),1),iL6=O6(D6(),1)});import{dirname as Uaz,isAbsolute as Ss1,sep as Qaz}from"path";function daz(q){try{let K=vB(q);return{content:K.content,fileExists:!0,encoding:K.encoding,lineEndings:K.lineEndings}}catch(K){if(_7(K))return{content:"",fileExists:!1,encoding:"utf8",lineEndings:"LF"};throw K}}var l$K=1073741824,UX;var LK6=y(()=>{k8();o1();Pj6();OL6();uQ();VV6();Ga();Bq();I7();_8();BQ();m8();y8();bK();oN();zu8();ZE();U7();e7();Au8();E8();dz();Tz();br();tYK();q$K();wu8();hs1();Uj6();UX=sq({name:X4,searchHint:"modify file contents in place",maxResultSizeChars:1e5,strict:!0,async description(){return"A tool for editing files"},async prompt(){return eYK()},userFacingName:Tu8,getToolUseSummary:Rs1,getActivityDescription(q){let K=Rs1(q);return K?`Editing ${K}`:"Editing file"},get inputSchema(){return Ou8()},get outputSchema(){return K$K()},toAutoClassifierInput(q){return`${q.file_path}: ${q.new_string}`},getPath(q){return q.file_path},backfillObservableInput(q){if(typeof q.file_path==="string")q.file_path=lq(q.file_path)},async preparePermissionMatcher({file_path:q}){return(K)=>lv(K,q)},async checkPermissions(q,K){let _=K.getAppState();return Qj6(UX,q,_.toolPermissionContext)},renderToolUseMessage:U$K,renderToolResultMessage:Q$K,renderToolUseRejectedMessage:d$K,renderToolUseErrorMessage:c$K,async validateInput(q,K){let{file_path:_,old_string:z,new_string:Y,replace_all:$=!1}=q,A=lq(_),O=$I8(A,Y);if(O)return{result:!1,message:O,errorCode:0};if(z===Y)return{result:!1,behavior:"ask",message:"No changes to make: old_string and new_string are exactly the same.",errorCode:1};let w=K.getAppState();if(VH(A,w.toolPermissionContext,"edit","deny")!==null)return{result:!1,behavior:"ask",message:"File is in a directory that is denied by your permission settings.",errorCode:2};if(A.startsWith("\\\\")||A.startsWith("//"))return{result:!0};let H=X8();try{let{size:f}=await H.stat(A);if(f>l$K)return{result:!1,behavior:"ask",message:`File is too large to edit (${m4(f)}). Maximum editable file size is ${m4(l$K)}.`,errorCode:10}}catch(f){if(!_7(f))throw f}let J;try{let f=await H.readFileBytes(A),G=f.length>=2&&f[0]===255&&f[1]===254?"utf16le":"utf8";J=f.toString(G).replaceAll(`\r
3030`,`
3031`)}catch(f){if(_7(f))J=null;else throw f}if(J===null){if(z==="")return{result:!0};let f=U$8(A),G=await pe(A),Z=`File does not exist. ${uZ} ${Z8()}.`;if(G)Z+=` Did you mean ${G}?`;else if(f)Z+=` Did you mean ${f}?`;return{result:!1,behavior:"ask",message:Z,errorCode:4}}if(z===""){if(J.trim()!=="")return{result:!1,behavior:"ask",message:"Cannot create new file - file already exists.",errorCode:3};return{result:!0}}if(A.endsWith(".ipynb"))return{result:!1,behavior:"ask",message:`File is a Jupyter Notebook. Use the ${nW} to edit this file.`,errorCode:5};let M=K.readFileState.get(A);if(!M||M.isPartialView)return{result:!1,behavior:"ask",message:"File has not been read yet. Read it first before writing to it.",meta:{isFilePathAbsolute:String(Ss1(_))},errorCode:6};if(M){if(ik(A)>M.timestamp)if(M.offset===void 0&&M.limit===void 0&&J===M.content);else return{result:!1,behavior:"ask",message:"File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.",errorCode:7}}let X=J,P=Fj6(X,z);if(!P)return{result:!1,behavior:"ask",message:`String to replace not found in file.

Callers 1

callFunction · 0.90

Calls 3

Z8Function · 0.85
lqFunction · 0.85
prFunction · 0.85

Tested by

no test coverage detected