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

Function Fh_

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

Source from the content-addressed store, hash-verified

744`)+1;while(K!==0)this.onNewLine(this.offset+K),K=this.source.indexOf(`
745`,K)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(q){let K=q.items[q.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,K.value){let _="end"in K.value?K.value.end:void 0;if((Array.isArray(_)?_[_.length-1]:void 0)?.type==="comment")_?.push(this.sourceToken);else q.items.push({start:[this.sourceToken]})}else if(K.sep)K.sep.push(this.sourceToken);else K.start.push(this.sourceToken);return;case"space":case"comment":if(K.value)q.items.push({start:[this.sourceToken]});else if(K.sep)K.sep.push(this.sourceToken);else{if(this.atIndentedComment(K.start,q.indent)){let z=q.items[q.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,K.start),z.push(this.sourceToken),q.items.pop();return}}K.start.push(this.sourceToken)}return}if(this.indent>=q.indent){let _=!this.onKeyLine&&this.indent===q.indent,z=_&&(K.sep||K.explicitKey)&&this.type!=="seq-item-ind",Y=[];if(z&&K.sep&&!K.value){let $=[];for(let A=0;A<K.sep.length;++A){let O=K.sep[A];switch(O.type){case"newline":$.push(A);break;case"space":break;case"comment":if(O.indent>q.indent)$.length=0;break;default:$.length=0}}if($.length>=2)Y=K.sep.splice($[1])}switch(this.type){case"anchor":case"tag":if(z||K.value)Y.push(this.sourceToken),q.items.push({start:Y}),this.onKeyLine=!0;else if(K.sep)K.sep.push(this.sourceToken);else K.start.push(this.sourceToken);return;case"explicit-key-ind":if(!K.sep&&!K.explicitKey)K.start.push(this.sourceToken),K.explicitKey=!0;else if(z||K.value)Y.push(this.sourceToken),q.items.push({start:Y,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(K.explicitKey)if(!K.sep)if(q76(K.start,"newline"))Object.assign(K,{key:null,sep:[this.sourceToken]});else{let $=Xv6(K.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:null,sep:[this.sourceToken]}]})}else if(K.value)q.items.push({start:[],key:null,sep:[this.sourceToken]});else if(q76(K.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Y,key:null,sep:[this.sourceToken]}]});else if(Q44(K.key)&&!q76(K.sep,"newline")){let $=Xv6(K.start),A=K.key,O=K.sep;O.push(this.sourceToken),delete K.key,delete K.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:A,sep:O}]})}else if(Y.length>0)K.sep=K.sep.concat(Y,this.sourceToken);else K.sep.push(this.sourceToken);else if(!K.sep)Object.assign(K,{key:null,sep:[this.sourceToken]});else if(K.value||z)q.items.push({start:Y,key:null,sep:[this.sourceToken]});else if(q76(K.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else K.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let $=this.flowScalar(this.type);if(z||K.value)q.items.push({start:Y,key:$,sep:[]}),this.onKeyLine=!0;else if(K.sep)this.stack.push($);else Object.assign(K,{key:$,sep:[]}),this.onKeyLine=!0;return}default:{let $=this.startBlockValue(q);if($){if($.type==="block-seq"){if(!K.explicitKey&&K.sep&&!q76(K.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(_)q.items.push({start:Y});this.stack.push($);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(q){let K=q.items[q.items.length-1];switch(this.type){case"newline":if(K.value){let _="end"in K.value?K.value.end:void 0;if((Array.isArray(_)?_[_.length-1]:void 0)?.type==="comment")_?.push(this.sourceToken);else q.items.push({start:[this.sourceToken]})}else K.start.push(this.sourceToken);return;case"space":case"comment":if(K.value)q.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(K.start,q.indent)){let z=q.items[q.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,K.start),z.push(this.sourceToken),q.items.pop();return}}K.start.push(this.sourceToken)}return;case"anchor":case"tag":if(K.value||this.indent<=q.indent)break;K.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==q.indent)break;if(K.value||q76(K.start,"seq-item-ind"))q.items.push({start:[this.sourceToken]});else K.start.push(this.sourceToken);return}if(this.indent>q.indent){let _=this.startBlockValue(q);if(_){this.stack.push(_);return}}yield*this.pop(),yield*this.step()}*flowCollection(q){let K=q.items[q.items.length-1];if(this.type==="flow-error-end"){let _;do yield*this.pop(),_=this.peek(1);while(_&&_.type==="flow-collection")}else if(q.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!K||K.sep)q.items.push({start:[this.sourceToken]});else K.start.push(this.sourceToken);return;case"map-value-ind":if(!K||K.value)q.items.push({start:[],key:null,sep:[this.sourceToken]});else if(K.sep)K.sep.push(this.sourceToken);else Object.assign(K,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!K||K.value)q.items.push({start:[this.sourceToken]});else if(K.sep)K.sep.push(this.sourceToken);else K.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let z=this.flowScalar(this.type);if(!K||K.value)q.items.push({start:[],key:z,sep:[]});else if(K.sep)this.stack.push(z);else Object.assign(K,{key:z,sep:[]});return}case"flow-map-end":case"flow-seq-end":q.end.push(this.sourceToken);return}let _=this.startBlockValue(q);if(_)this.stack.push(_);else yield*this.pop(),yield*this.step()}else{let _=this.peek(2);if(_.type==="block-map"&&(this.type==="map-value-ind"&&_.indent===q.indent||this.type==="newline"&&!_.items[_.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&_.type!=="flow-collection"){let z=IG8(_),Y=Xv6(z);U44(q);let $=q.end.splice(1,q.end.length);$.push(this.sourceToken);let A={type:"block-map",offset:q.offset,indent:q.indent,items:[{start:Y,key:q,sep:$}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=A}else yield*this.lineEnd(q)}}flowScalar(q){if(this.onNewLine){let K=this.source.indexOf(`
746`)+1;while(K!==0)this.onNewLine(this.offset+K),K=this.source.indexOf(`
747`,K)+1}return{type:q,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(q){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let K=IG8(q),_=Xv6(K);return _.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:_,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let K=IG8(q),_=Xv6(K);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:_,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(q,K){if(this.type!=="comment")return!1;if(this.indent<=K)return!1;return q.every((_)=>_.type==="newline"||_.type==="space")}*documentEnd(q){if(this.type!=="doc-mode"){if(q.end)q.end.push(this.sourceToken);else q.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(q){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(q.end)q.end.push(this.sourceToken);else q.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}pR_.Parser=d44});var r44=m((nR_)=>{var c44=Oh1(),gR_=jn6(),Wn6=Hn6(),FR_=fR1(),UR_=uY(),QR_=fh1(),l44=Zh1();function n44(q){let K=q.prettyErrors!==!1;return{lineCounter:q.lineCounter||K&&new QR_.LineCounter||null,prettyErrors:K}}function dR_(q,K={}){let{lineCounter:_,prettyErrors:z}=n44(K),Y=new l44.Parser(_?.addNewLine),$=new c44.Composer(K),A=Array.from($.compose(Y.parse(q)));if(z&&_)for(let O of A)O.errors.forEach(Wn6.prettifyError(q,_)),O.warnings.forEach(Wn6.prettifyError(q,_));if(A.length>0)return A;return Object.assign([],{empty:!0},$.streamInfo())}function i44(q,K={}){let{lineCounter:_,prettyErrors:z}=n44(K),Y=new l44.Parser(_?.addNewLine),$=new c44.Composer(K),A=null;for(let O of $.compose(Y.parse(q),!0,q.length))if(!A)A=O;else if(A.options.logLevel!=="silent"){A.errors.push(new Wn6.YAMLParseError(O.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(z&&_)A.errors.forEach(Wn6.prettifyError(q,_)),A.warnings.forEach(Wn6.prettifyError(q,_));return A}function cR_(q,K,_){let z=void 0;if(typeof K==="function")z=K;else if(_===void 0&&K&&typeof K==="object")_=K;let Y=i44(q,_);if(!Y)return null;if(Y.warnings.forEach(($)=>FR_.warn(Y.options.logLevel,$)),Y.errors.length>0)if(Y.options.logLevel!=="silent")throw Y.errors[0];else Y.errors=[];return Y.toJS(Object.assign({reviver:z},_))}function lR_(q,K,_){let z=null;if(typeof K==="function"||Array.isArray(K))z=K;else if(_===void 0&&K)_=K;if(typeof _==="string")_=_.length;if(typeof _==="number"){let Y=Math.round(_);_=Y<1?void 0:Y>8?{indent:8}:{indent:Y}}if(q===void 0){let{keepUndefined:Y}=_??K??{};if(!Y)return}if(UR_.isDocument(q)&&!z)return q.toString(_);return new gR_.Document(q,z,_).toString(_)}nR_.parse=cR_;nR_.parseAllDocuments=dR_;nR_.parseDocument=i44;nR_.stringify=lR_});var a44=m((jh_)=>{var sR_=Oh1(),tR_=jn6(),eR_=lR1(),Gh1=Hn6(),qh_=rl6(),K76=uY(),Kh_=a16(),_h_=DX(),zh_=t16(),Yh_=e16(),$h_=bG8(),Ah_=Dh1(),Oh_=fh1(),wh_=Zh1(),uG8=r44(),o44=nl6();jh_.Composer=sR_.Composer;jh_.Document=tR_.Document;jh_.Schema=eR_.Schema;jh_.YAMLError=Gh1.YAMLError;jh_.YAMLParseError=Gh1.YAMLParseError;jh_.YAMLWarning=Gh1.YAMLWarning;jh_.Alias=qh_.Alias;jh_.isAlias=K76.isAlias;jh_.isCollection=K76.isCollection;jh_.isDocument=K76.isDocument;jh_.isMap=K76.isMap;jh_.isNode=K76.isNode;jh_.isPair=K76.isPair;jh_.isScalar=K76.isScalar;jh_.isSeq=K76.isSeq;jh_.Pair=Kh_.Pair;jh_.Scalar=_h_.Scalar;jh_.YAMLMap=zh_.YAMLMap;jh_.YAMLSeq=Yh_.YAMLSeq;jh_.CST=$h_;jh_.Lexer=Ah_.Lexer;jh_.LineCounter=Oh_.LineCounter;jh_.Parser=wh_.Parser;jh_.parse=uG8.parse;jh_.parseAllDocuments=uG8.parseAllDocuments;jh_.parseDocument=uG8.parseDocument;jh_.stringify=uG8.stringify;jh_.visit=o44.visit;jh_.visitAsync=o44.visitAsync});function Dn6(q){if(typeof Bun<"u")return Bun.YAML.parse(q);return a44().parse(q)}function Fh_(q){let K=q.split(`
748`),_=[];for(let z of K){let Y=z.match(/^([a-zA-Z_-]+):\s+(.+)$/);if(Y){let[,$,A]=Y;if(!$||!A){_.push(z);continue}if(A.startsWith('"')&&A.endsWith('"')||A.startsWith("'")&&A.endsWith("'")){_.push(z);continue}if(gh_.test(A)){let O=A.replace(/\\/g,"\\\\").replace(/"/g,"\\\"");_.push(`${$}: "${O}"`);continue}}_.push(z)}return _.join(`
749`)}function kH(q,K){let _=q.match(Th1);if(!_)return{frontmatter:{},content:q};let z=_[1]||"",Y=q.slice(_[0].length),$={};try{let A=Dn6(z);if(A&&typeof A==="object"&&!Array.isArray(A))$=A}catch{try{let A=Fh_(z),O=Dn6(A);if(O&&typeof O==="object"&&!Array.isArray(O))$=O}catch(A){let O=K?` in ${K}`:"";N(`Failed to parse YAML frontmatter${O}: ${A instanceof Error?A.message:A}`,{level:"warn"})}}return{frontmatter:$,content:Y}}function fn6(q){if(Array.isArray(q))return q.flatMap(fn6);if(typeof q!=="string")return[];let K=[],_="",z=0;for(let $=0;$<q.length;$++){let A=q[$];if(A==="{")z++,_+=A;else if(A==="}")z--,_+=A;else if(A===","&&z===0){let O=_.trim();if(O)K.push(O);_=""}else _+=A}let Y=_.trim();if(Y)K.push(Y);return K.filter(($)=>$.length>0).flatMap(($)=>t44($))}function t44(q){let K=q.match(/^([^{]*)\{([^}]+)\}(.*)$/);if(!K)return[q];let _=K[1]||"",z=K[2]||"",Y=K[3]||"",$=z.split(",").map((O)=>O.trim()),A=[];for(let O of $){let w=_+O+Y,j=t44(w);A.push(...j)}return A}function mG8(q){if(q===void 0||q===null)return;let K=typeof q==="number"?q:parseInt(String(q),10);if(Number.isInteger(K)&&K>0)return K;return}function Lu(q,K,_){if(q==null)return null;if(typeof q==="string")return q.trim()||null;if(typeof q==="number"||typeof q==="boolean")return String(q);let z=_?`${_}:${K}`:K??"unknown";return N(`Description invalid for ${z} - omitting`,{level:"warn"}),null}function Pv6(q){return q===!0||q==="true"}function pG8(q,K){if(q==null)return;let _=String(q).trim().toLowerCase();if(_==="")return;if(s44.includes(_))return _;N(`Frontmatter 'shell: ${q}' in ${K} is not recognized. Valid values: ${s44.join(", ")}. Falling back to bash.`,{level:"warn"});return}var gh_,Th1,s44;var rV=y(()=>{_8();gh_=/[{}[\]*&#!|>%@`]|: /;Th1=/^---\s*\n([\s\S]*?)---\s*\n?/;s44=["bash","powershell"]});import{execFile as Uh_,spawn as KK4}from"child_process";import{homedir as Qh_}from"os";import*as _76 from"path";import{fileURLToPath as dh_}from"url";function xA6(){let q=gG8();return{rgPath:q.command,rgArgs:q.args,argv0:q.argv0}}function nh_(q){return q.includes("os error 11")||q.includes("Resource temporarily unavailable")}function e44(q,K,_,z,Y=!1){let{rgPath:$,rgArgs:A,argv0:O}=xA6(),w=Y?["-j","1"]:[],j=[...A,...w,...q,K],H=Z1()==="wsl"?60000:20000,J=parseInt(process.env.CLAUDE_CODE_GLOB_TIMEOUT_SECONDS||"",10)||0,M=J>0?J*1000:H;if(O){let X=KK4($,j,{argv0:O,signal:_,windowsHide:!0}),P="",W="",D=!1,f=!1;X.stdout?.on("data",(v)=>{if(!D){if(P+=v.toString(),P.length>Zn6)P=P.slice(0,Zn6),D=!0}}),X.stderr?.on("data",(v)=>{if(!f){if(W+=v.toString(),W.length>Zn6)W=W.slice(0,Zn6),f=!0}});let G,Z=setTimeout(()=>{if(process.platform==="win32")X.kill();else X.kill("SIGTERM"),G=setTimeout((v)=>v.kill("SIGKILL"),5000,X)},M),T=!1;return X.on("close",(v,V)=>{if(T)return;if(T=!0,clearTimeout(Z),clearTimeout(G),v===0||v===1)z(null,P,W);else{let E=Error(`ripgrep exited with code ${v}`);E.code=v??void 0,E.signal=V??void 0,z(E,P,W)}}),X.on("error",(v)=>{if(T)return;T=!0,clearTimeout(Z),clearTimeout(G),z(v,P,W)}),X}return Uh_($,j,{maxBuffer:Zn6,signal:_,timeout:M,killSignal:process.platform==="win32"?void 0:"SIGKILL"},z)}async function ih_(q,K,_){await YK4();let{rgPath:z,rgArgs:Y,argv0:$}=xA6();return new Promise((A,O)=>{let w=KK4(z,[...Y,...q,K],{argv0:$,signal:_,windowsHide:!0,stdio:["ignore","pipe","ignore"]}),j=0;w.stdout?.on("data",(J)=>{j+=G$(J,`
750`)});let H=!1;w.on("close",(J)=>{if(H)return;if(H=!0,J===0||J===1)A(j);else O(Error(`rg --files exited ${J}`))}),w.on("error",(J)=>{if(H)return;H=!0,O(J)})})}async function LF(q,K,_){return await YK4(),rh_().catch((z)=>{H6(z)}),new Promise((z,Y)=>{let $=(A,O,w,j)=>{if(!A){z(O.trim().split(`
751`).map((W)=>W.replace(/\r$/,"")).filter(Boolean));return}if(A.code===1){z([]);return}if(["ENOENT","EACCES","EPERM"].includes(A.code)){Y(A);return}if(!j&&nh_(w)){N("rg EAGAIN error detected, retrying with single-threaded mode (-j 1)"),d("tengu_ripgrep_eagain_retry",{}),e44(q,K,_,(W,D,f)=>{$(W,D,f,!0)},!0);return}let J=O&&O.trim().length>0,M=A.signal==="SIGTERM"||A.signal==="SIGKILL"||A.code==="ABORT_ERR",X=A.code==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER",P=[];if(J){if(P=O.trim().split(`

Callers 1

kHFunction · 0.85

Calls 7

matchMethod · 0.45
pushMethod · 0.45
startsWithMethod · 0.45
endsWithMethod · 0.45
testMethod · 0.45
replaceMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected