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

Function xd

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

Source from the content-addressed store, hash-verified

7946`),this.outputHelp({error:!0});let _=K||{},z=_.exitCode||1,Y=_.code||"commander.error";this._exit(z,Y,q)}_parseOptionsEnv(){this.options.forEach((q)=>{if(q.envVar&&q.envVar in pJ.env){let K=q.attributeName();if(this.getOptionValue(K)===void 0||["default","config","env"].includes(this.getOptionValueSource(K)))if(q.required||q.optional)this.emit(`optionEnv:${q.name()}`,pJ.env[q.envVar]);else this.emit(`optionEnv:${q.name()}`)}})}_parseOptionsImplied(){let q=new lbY(this.options),K=(_)=>{return this.getOptionValue(_)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(_))};this.options.filter((_)=>_.implied!==void 0&&K(_.attributeName())&&q.valueFromOption(this.getOptionValue(_.attributeName()),_)).forEach((_)=>{Object.keys(_.implied).filter((z)=>!K(z)).forEach((z)=>{this.setOptionValueWithSource(z,_.implied[z],"implied")})})}missingArgument(q){let K=`error: missing required argument '${q}'`;this.error(K,{code:"commander.missingArgument"})}optionMissingArgument(q){let K=`error: option '${q.flags}' argument missing`;this.error(K,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(q){let K=`error: required option '${q.flags}' not specified`;this.error(K,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(q,K){let _=($)=>{let A=$.attributeName(),O=this.getOptionValue(A),w=this.options.find((H)=>H.negate&&A===H.attributeName()),j=this.options.find((H)=>!H.negate&&A===H.attributeName());if(w&&(w.presetArg===void 0&&O===!1||w.presetArg!==void 0&&O===w.presetArg))return w;return j||$},z=($)=>{let A=_($),O=A.attributeName();if(this.getOptionValueSource(O)==="env")return`environment variable '${A.envVar}'`;return`option '${A.flags}'`},Y=`error: ${z(q)} cannot be used with ${z(K)}`;this.error(Y,{code:"commander.conflictingOption"})}unknownOption(q){if(this._allowUnknownOption)return;let K="";if(q.startsWith("--")&&this._showSuggestionAfterError){let z=[],Y=this;do{let $=Y.createHelp().visibleOptions(Y).filter((A)=>A.long).map((A)=>A.long);z=z.concat($),Y=Y.parent}while(Y&&!Y._enablePositionalOptions);K=nFK(q,z)}let _=`error: unknown option '${q}'${K}`;this.error(_,{code:"commander.unknownOption"})}_excessArguments(q){if(this._allowExcessArguments)return;let K=this.registeredArguments.length,_=K===1?"":"s",Y=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${K} argument${_} but got ${q.length}.`;this.error(Y,{code:"commander.excessArguments"})}unknownCommand(){let q=this.args[0],K="";if(this._showSuggestionAfterError){let z=[];this.createHelp().visibleCommands(this).forEach((Y)=>{if(z.push(Y.name()),Y.alias())z.push(Y.alias())}),K=nFK(q,z)}let _=`error: unknown command '${q}'${K}`;this.error(_,{code:"commander.unknownCommand"})}version(q,K,_){if(q===void 0)return this._version;this._version=q,K=K||"-V, --version",_=_||"output the version number";let z=this.createOption(K,_);return this._versionOptionName=z.attributeName(),this._registerOption(z),this.on("option:"+z.name(),()=>{this._outputConfiguration.writeOut(`${q}
7947`),this._exit(0,"commander.version",q)}),this}description(q,K){if(q===void 0&&K===void 0)return this._description;if(this._description=q,K)this._argsDescription=K;return this}summary(q){if(q===void 0)return this._summary;return this._summary=q,this}alias(q){if(q===void 0)return this._aliases[0];let K=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)K=this.commands[this.commands.length-1];if(q===K._name)throw Error("Command alias can't be the same as its name");let _=this.parent?._findCommand(q);if(_){let z=[_.name()].concat(_.aliases()).join("|");throw Error(`cannot add alias '${q}' to command '${this.name()}' as already have command '${z}'`)}return K._aliases.push(q),this}aliases(q){if(q===void 0)return this._aliases;return q.forEach((K)=>this.alias(K)),this}usage(q){if(q===void 0){if(this._usage)return this._usage;let K=this.registeredArguments.map((_)=>{return dbY(_)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?K:[]).join(" ")}return this._usage=q,this}name(q){if(q===void 0)return this._name;return this._name=q,this}nameFromFilename(q){return this._name=hs.basename(q,hs.extname(q)),this}executableDir(q){if(q===void 0)return this._executableDir;return this._executableDir=q,this}helpInformation(q){let K=this.createHelp();if(K.helpWidth===void 0)K.helpWidth=q&&q.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return K.formatHelp(this,K)}_getHelpContext(q){q=q||{};let K={error:!!q.error},_;if(K.error)_=(z)=>this._outputConfiguration.writeErr(z);else _=(z)=>this._outputConfiguration.writeOut(z);return K.write=q.write||_,K.command=this,K}outputHelp(q){let K;if(typeof q==="function")K=q,q=void 0;let _=this._getHelpContext(q);this._getCommandAndAncestors().reverse().forEach((Y)=>Y.emit("beforeAllHelp",_)),this.emit("beforeHelp",_);let z=this.helpInformation(_);if(K){if(z=K(z),typeof z!=="string"&&!Buffer.isBuffer(z))throw Error("outputHelp callback must return a string or a Buffer")}if(_.write(z),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",_),this._getCommandAndAncestors().forEach((Y)=>Y.emit("afterAllHelp",_))}helpOption(q,K){if(typeof q==="boolean"){if(q)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return q=q??"-h, --help",K=K??"display help for command",this._helpOption=this.createOption(q,K),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(q){return this._helpOption=q,this}help(q){this.outputHelp(q);let K=pJ.exitCode||0;if(K===0&&q&&typeof q!=="function"&&q.error)K=1;this._exit(K,"commander.help","(outputHelp)")}addHelpText(q,K){let _=["beforeAll","before","after","afterAll"];if(!_.includes(q))throw Error(`Unexpected value for position to addHelpText.
7948Expecting one of '${_.join("', '")}'`);let z=`${q}Help`;return this.on(z,(Y)=>{let $;if(typeof K==="function")$=K({error:Y.error,command:Y.command});else $=K;if($)Y.write(`${$}
7949`)}),this}_outputHelpIfRequested(q){let K=this._getHelpOption();if(K&&q.find((z)=>K.is(z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function iFK(q){return q.map((K)=>{if(!K.startsWith("--inspect"))return K;let _,z="127.0.0.1",Y="9229",$;if(($=K.match(/^(--inspect(-brk)?)$/))!==null)_=$[1];else if(($=K.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(_=$[1],/^\d+$/.test($[3]))Y=$[3];else z=$[3];else if(($=K.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)_=$[1],z=$[3],Y=$[4];if(_&&Y!=="0")return`${_}=${z}:${parseInt(Y)+1}`;return K})}nbY.Command=r_7});var tFK=m((abY)=>{var{Argument:oFK}=iQ8(),{Command:o_7}=rFK(),{CommanderError:rbY,InvalidArgumentError:aFK}=eq8(),{Help:obY}=d_7(),{Option:sFK}=c_7();abY.program=new o_7;abY.createCommand=(q)=>new o_7(q);abY.createOption=(q,K)=>new sFK(q,K);abY.createArgument=(q,K)=>new oFK(q,K);abY.Command=o_7;abY.Option=sFK;abY.Argument=oFK;abY.Help=obY;abY.CommanderError=rbY;abY.InvalidArgumentError=aFK;abY.InvalidOptionArgumentError=aFK});var qUK=m((kR,eFK)=>{var hp=tFK();kR=eFK.exports={};kR.program=new hp.Command;kR.Argument=hp.Argument;kR.Command=hp.Command;kR.CommanderError=hp.CommanderError;kR.Help=hp.Help;kR.InvalidArgumentError=hp.InvalidArgumentError;kR.InvalidOptionArgumentError=hp.InvalidArgumentError;kR.Option=hp.Option;kR.createCommand=(q)=>new hp.Command(q);kR.createOption=(q,K)=>new hp.Option(q,K);kR.createArgument=(q,K)=>new hp.Argument(q,K)});var KUK,le2,ne2,ie2,re2,oe2,_UK,ae2,zUK,se2,G3,te2;var a_7=y(()=>{KUK=O6(qUK(),1),{program:le2,createCommand:ne2,createArgument:ie2,createOption:re2,CommanderError:oe2,InvalidArgumentError:_UK,InvalidOptionArgumentError:ae2,Command:zUK,Argument:se2,Option:G3,Help:te2}=KUK.default});function $UK(){if(YUK)return;if(YUK=!0,i6(process.env.CLAUDE_CODE_USE_BEDROCK)||i6(process.env.CLAUDE_CODE_USE_VERTEX)||i6(process.env.CLAUDE_CODE_USE_FOUNDRY))return;if(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ANTHROPIC_UNIX_SOCKET||process.env.CLAUDE_CODE_CLIENT_CERT||process.env.CLAUDE_CODE_CLIENT_KEY)return;let q=process.env.ANTHROPIC_BASE_URL||u7().BASE_API_URL;fetch(q,{method:"HEAD",signal:AbortSignal.timeout(1e4)}).catch(()=>{})}var YUK=!1;var AUK=y(()=>{H3();m8()});function OUK(){if(process.env.NODE_EXTRA_CA_CERTS)return;let q=wxY();if(q)process.env.NODE_EXTRA_CA_CERTS=q,N(`CA certs: Applied NODE_EXTRA_CA_CERTS from config to process.env: ${q}`)}function wxY(){try{let K=j8()?.env,z=v1("userSettings")?.env;N(`CA certs: Config fallback - globalEnv keys: ${K?Object.keys(K).join(","):"none"}, settingsEnv keys: ${z?Object.keys(z).join(","):"none"}`);let Y=z?.NODE_EXTRA_CA_CERTS||K?.NODE_EXTRA_CA_CERTS;if(Y)N(`CA certs: Found NODE_EXTRA_CA_CERTS in config/settings: ${Y}`);return Y}catch(q){N(`CA certs: Config fallback failed: ${q}`,{level:"error"});return}}var wUK=y(()=>{V1();_8();U1()});function jxY(q){if(!q||!process.env.ANTHROPIC_UNIX_SOCKET)return q||{};let{ANTHROPIC_UNIX_SOCKET:K,ANTHROPIC_BASE_URL:_,ANTHROPIC_API_KEY:z,ANTHROPIC_AUTH_TOKEN:Y,CLAUDE_CODE_OAUTH_TOKEN:$,...A}=q;return A}function HxY(q){if(!q)return{};if(!i6(process.env.CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST))return q;let K={};for(let[_,z]of Object.entries(q))if(!nx4(_))K[_]=z;return K}function JxY(q){if(!q||!rQ8)return q||{};let K={};for(let[_,z]of Object.entries(q))if(!rQ8.has(_))K[_]=z;return K}function rS6(q){return JxY(HxY(jxY(q)))}function jUK(){if(rQ8===void 0)rQ8=process.env.CLAUDE_CODE_ENTRYPOINT==="claude-desktop"?new Set(Object.keys(process.env)):null;Object.assign(process.env,rS6(j8().env));for(let K of MxY){if(K==="policySettings")continue;if(!$J(K))continue;Object.assign(process.env,rS6(v1(K)?.env))}Pm(),Object.assign(process.env,rS6(v1("policySettings")?.env));let q=rS6(Z7()?.env);for(let[K,_]of Object.entries(q))if(iN6.has(K.toUpperCase()))process.env[K]=_}function xd(){Object.assign(process.env,rS6(j8().env)),Object.assign(process.env,rS6(Z7()?.env)),_C7(),rF7(),l1q(),Zj8()}var rQ8,MxY;var q48=y(()=>{lF1();Lp6();V1();m8();lL8();PI();qv();kO();U1();MxY=["userSettings","flagSettings","policySettings"]});import{createServer as XxY}from"node:net";function t_7(q){let K=q.length,_=[],z=K;while(z>127)_.push(z&127|128),z>>>=7;_.push(z);let Y=new Uint8Array(1+_.length+K);return Y[0]=10,Y.set(_,1),Y.set(q,1+_.length),Y}function WxY(q){if(q.length===0)return new Uint8Array(0);if(q[0]!==10)return null;let K=0,_=0,z=1;while(z<q.length){let Y=q[z];if(K|=(Y&127)<<_,z++,(Y&128)===0)break;if(_+=7,_>28)return null}if(z+K>q.length)return null;return q.subarray(z,z+K)}function JUK(){return{connectBuf:Buffer.alloc(0),pending:[],wsOpen:!1,established:!1,closed:!1}}async function MUK(q){let K="Basic "+Buffer.from(`${q.sessionId}:${q.token}`).toString("base64"),_=`Bearer ${q.token}`,z=typeof Bun<"u"?DxY(q.wsUrl,K,_):await fxY(q.wsUrl,K,_);return N(`[upstreamproxy] relay listening on 127.0.0.1:${z.port}`),z}function DxY(q,K,_){let z=Bun.listen({hostname:"127.0.0.1",port:0,socket:{open(Y){Y.data={...JUK(),writeBuf:[]}},data(Y,$){let A=Y.data;XUK({write:(w)=>{let j=typeof w==="string"?Buffer.from(w,"utf8"):w;if(A.writeBuf.length>0){A.writeBuf.push(j);return}let H=Y.write(j);if(H<j.length)A.writeBuf.push(j.subarray(H))},end:()=>Y.end()},A,$,q,K,_)},drain(Y){let $=Y.data;while($.writeBuf.length>0){let A=$.writeBuf[0],O=Y.write(A);if(O<A.length){$.writeBuf[0]=A.subarray(O);return}$.writeBuf.shift()}},close(Y){oS6(Y.data)},error(Y,$){N(`[upstreamproxy] client socket error: ${$.message}`),oS6(Y.data)}}});return{port:z.port,stop:()=>z.stop(!0)}}async function fxY(q,K,_){s_7=(await Promise.resolve().then(() => (W96(),MI6))).default;let z=new WeakMap,Y=XxY(($)=>{let A=JUK();z.set($,A);let O={write:(w)=>{$.write(typeof w==="string"?w:Buffer.from(w))},end:()=>$.end()};$.on("data",(w)=>XUK(O,A,w,q,K,_)),$.on("close",()=>oS6(z.get($))),$.on("error",(w)=>{N(`[upstreamproxy] client socket error: ${w.message}`),oS6(z.get($))})});return new Promise(($,A)=>{Y.once("error",A),Y.listen(0,"127.0.0.1",()=>{let O=Y.address();if(O===null||typeof O==="string"){A(Error("upstreamproxy: server has no TCP address"));return}$({port:O.port,stop:()=>Y.close()})})})}function XUK(q,K,_,z,Y,$){if(!K.ws){K.connectBuf=Buffer.concat([K.connectBuf,_]);let A=K.connectBuf.indexOf(`\r
7950\r
7951`);if(A===-1){if(K.connectBuf.length>8192)q.write(`HTTP/1.1 400 Bad Request\r

Callers 4

oQ8Function · 0.85
SsFunction · 0.85
reKFunction · 0.85
fsYFunction · 0.85

Calls 7

rS6Function · 0.85
j8Function · 0.85
_C7Function · 0.85
rF7Function · 0.85
l1qFunction · 0.85
Zj8Function · 0.85
assignMethod · 0.45

Tested by

no test coverage detected