@pickled-dev/cli 0.12.0 → 0.14.0
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 +34 -0
- package/dist/index.js +204 -187
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,206 +1,223 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`)}displayWidth($){return
|
|
5
|
-
`+" ".repeat(
|
|
6
|
-
${
|
|
7
|
-
`)}}function
|
|
3
|
+
var xZ=Object.create;var{getPrototypeOf:yZ,defineProperty:n4,getOwnPropertyNames:kZ}=Object;var fZ=Object.prototype.hasOwnProperty;function gZ($){return this[$]}var hZ,vZ,r4=($,X,Z)=>{var z=$!=null&&typeof $==="object";if(z){var q=X?hZ??=new WeakMap:vZ??=new WeakMap,J=q.get($);if(J)return J}Z=$!=null?xZ(yZ($)):{};let G=X||!$||!$.__esModule?n4(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of kZ($))if(!fZ.call(G,Q))n4(G,Q,{get:gZ.bind($,Q),enumerable:!0});if(z)q.set($,G);return G};var D=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var Q0=import.meta.require;var F$=D((uZ)=>{class p2 extends Error{constructor($,X,Z){super(Z);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=X,this.exitCode=$,this.nestedError=void 0}}class o4 extends p2{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}uZ.CommanderError=p2;uZ.InvalidArgumentError=o4});var T1=D((cZ)=>{var{InvalidArgumentError:pZ}=F$();class t4{constructor($,X){switch(this.description=X||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,X){if(X===this.defaultValue||!Array.isArray(X))return[$];return X.push($),X}default($,X){return this.defaultValue=$,this.defaultValueDescription=X,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(X,Z)=>{if(!this.argChoices.includes(X))throw new pZ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(X,Z);return X},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function lZ($){let X=$.name()+($.variadic===!0?"...":"");return $.required?"<"+X+">":"["+X+"]"}cZ.Argument=t4;cZ.humanReadableArgName=lZ});var l2=D((nZ)=>{var{humanReadableArgName:sZ}=T1();class e4{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let X=$.commands.filter((z)=>!z._hidden),Z=$._getHelpCommand();if(Z&&!Z._hidden)X.push(Z);if(this.sortSubcommands)X.sort((z,q)=>{return z.name().localeCompare(q.name())});return X}compareOptions($,X){let Z=(z)=>{return z.short?z.short.replace(/^-/,""):z.long.replace(/^--/,"")};return Z($).localeCompare(Z(X))}visibleOptions($){let X=$.options.filter((z)=>!z.hidden),Z=$._getHelpOption();if(Z&&!Z.hidden){let z=Z.short&&$._findOption(Z.short),q=Z.long&&$._findOption(Z.long);if(!z&&!q)X.push(Z);else if(Z.long&&!q)X.push($.createOption(Z.long,Z.description));else if(Z.short&&!z)X.push($.createOption(Z.short,Z.description))}if(this.sortOptions)X.sort(this.compareOptions);return X}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let X=[];for(let Z=$.parent;Z;Z=Z.parent){let z=Z.options.filter((q)=>!q.hidden);X.push(...z)}if(this.sortOptions)X.sort(this.compareOptions);return X}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((X)=>{X.description=X.description||$._argsDescription[X.name()]||""});if($.registeredArguments.find((X)=>X.description))return $.registeredArguments;return[]}subcommandTerm($){let X=$.registeredArguments.map((Z)=>sZ(Z)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(X?" "+X:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,X){return X.visibleCommands($).reduce((Z,z)=>{return Math.max(Z,this.displayWidth(X.styleSubcommandTerm(X.subcommandTerm(z))))},0)}longestOptionTermLength($,X){return X.visibleOptions($).reduce((Z,z)=>{return Math.max(Z,this.displayWidth(X.styleOptionTerm(X.optionTerm(z))))},0)}longestGlobalOptionTermLength($,X){return X.visibleGlobalOptions($).reduce((Z,z)=>{return Math.max(Z,this.displayWidth(X.styleOptionTerm(X.optionTerm(z))))},0)}longestArgumentTermLength($,X){return X.visibleArguments($).reduce((Z,z)=>{return Math.max(Z,this.displayWidth(X.styleArgumentTerm(X.argumentTerm(z))))},0)}commandUsage($){let X=$._name;if($._aliases[0])X=X+"|"+$._aliases[0];let Z="";for(let z=$.parent;z;z=z.parent)Z=z.name()+" "+Z;return Z+X+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let X=[];if($.argChoices)X.push(`choices: ${$.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")X.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)X.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)X.push(`env: ${$.envVar}`);if(X.length>0){let Z=`(${X.join(", ")})`;if($.description)return`${$.description} ${Z}`;return Z}return $.description}argumentDescription($){let X=[];if($.argChoices)X.push(`choices: ${$.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if($.defaultValue!==void 0)X.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(X.length>0){let Z=`(${X.join(", ")})`;if($.description)return`${$.description} ${Z}`;return Z}return $.description}formatItemList($,X,Z){if(X.length===0)return[];return[Z.styleTitle($),...X,""]}groupItems($,X,Z){let z=new Map;return $.forEach((q)=>{let J=Z(q);if(!z.has(J))z.set(J,[])}),X.forEach((q)=>{let J=Z(q);if(!z.has(J))z.set(J,[]);z.get(J).push(q)}),z}formatHelp($,X){let Z=X.padWidth($,X),z=X.helpWidth??80;function q(W,H){return X.formatItem(W,Z,H,X)}let J=[`${X.styleTitle("Usage:")} ${X.styleUsage(X.commandUsage($))}`,""],G=X.commandDescription($);if(G.length>0)J=J.concat([X.boxWrap(X.styleCommandDescription(G),z),""]);let Q=X.visibleArguments($).map((W)=>{return q(X.styleArgumentTerm(X.argumentTerm(W)),X.styleArgumentDescription(X.argumentDescription(W)))});if(J=J.concat(this.formatItemList("Arguments:",Q,X)),this.groupItems($.options,X.visibleOptions($),(W)=>W.helpGroupHeading??"Options:").forEach((W,H)=>{let V=W.map((B)=>{return q(X.styleOptionTerm(X.optionTerm(B)),X.styleOptionDescription(X.optionDescription(B)))});J=J.concat(this.formatItemList(H,V,X))}),X.showGlobalOptions){let W=X.visibleGlobalOptions($).map((H)=>{return q(X.styleOptionTerm(X.optionTerm(H)),X.styleOptionDescription(X.optionDescription(H)))});J=J.concat(this.formatItemList("Global Options:",W,X))}return this.groupItems($.commands,X.visibleCommands($),(W)=>W.helpGroup()||"Commands:").forEach((W,H)=>{let V=W.map((B)=>{return q(X.styleSubcommandTerm(X.subcommandTerm(B)),X.styleSubcommandDescription(X.subcommandDescription(B)))});J=J.concat(this.formatItemList(H,V,X))}),J.join(`
|
|
4
|
+
`)}displayWidth($){return $X($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((X)=>{if(X==="[options]")return this.styleOptionText(X);if(X==="[command]")return this.styleSubcommandText(X);if(X[0]==="["||X[0]==="<")return this.styleArgumentText(X);return this.styleCommandText(X)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((X)=>{if(X==="[options]")return this.styleOptionText(X);if(X[0]==="["||X[0]==="<")return this.styleArgumentText(X);return this.styleSubcommandText(X)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,X){return Math.max(X.longestOptionTermLength($,X),X.longestGlobalOptionTermLength($,X),X.longestSubcommandTermLength($,X),X.longestArgumentTermLength($,X))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,X,Z,z){let J=" ".repeat(2);if(!Z)return J+$;let G=$.padEnd(X+$.length-z.displayWidth($)),Q=2,U=(this.helpWidth??80)-X-Q-2,W;if(U<this.minWidthToWrap||z.preformatted(Z))W=Z;else W=z.boxWrap(Z,U).replace(/\n/g,`
|
|
5
|
+
`+" ".repeat(X+Q));return J+G+" ".repeat(Q)+W.replace(/\n/g,`
|
|
6
|
+
${J}`)}boxWrap($,X){if(X<this.minWidthToWrap)return $;let Z=$.split(/\r\n|\n/),z=/[\s]*[^\s]+/g,q=[];return Z.forEach((J)=>{let G=J.match(z);if(G===null){q.push("");return}let Q=[G.shift()],Y=this.displayWidth(Q[0]);G.forEach((U)=>{let W=this.displayWidth(U);if(Y+W<=X){Q.push(U),Y+=W;return}q.push(Q.join(""));let H=U.trimStart();Q=[H],Y=this.displayWidth(H)}),q.push(Q.join(""))}),q.join(`
|
|
7
|
+
`)}}function $X($){let X=/\x1b\[\d*(;\d*)*m/g;return $.replace(X,"")}nZ.Help=e4;nZ.stripColor=$X});var c2=D(($6)=>{var{InvalidArgumentError:tZ}=F$();class ZX{constructor($,X){this.flags=$,this.description=X||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let Z=eZ($);if(this.short=Z.shortFlag,this.long=Z.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,X){return this.defaultValue=$,this.defaultValueDescription=X,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let X=$;if(typeof $==="string")X={[$]:!0};return this.implied=Object.assign(this.implied||{},X),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,X){if(X===this.defaultValue||!Array.isArray(X))return[$];return X.push($),X}choices($){return this.argChoices=$.slice(),this.parseArg=(X,Z)=>{if(!this.argChoices.includes(X))throw new tZ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(X,Z);return X},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return XX(this.name().replace(/^no-/,""));return XX(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class zX{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((X)=>{if(X.negate)this.negativeOptions.set(X.attributeName(),X);else this.positiveOptions.set(X.attributeName(),X)}),this.negativeOptions.forEach((X,Z)=>{if(this.positiveOptions.has(Z))this.dualOptions.add(Z)})}valueFromOption($,X){let Z=X.attributeName();if(!this.dualOptions.has(Z))return!0;let z=this.negativeOptions.get(Z).presetArg,q=z!==void 0?z:!1;return X.negate===(q===$)}}function XX($){return $.split("-").reduce((X,Z)=>{return X+Z[0].toUpperCase()+Z.slice(1)})}function eZ($){let X,Z,z=/^-[^-]$/,q=/^--[^-]/,J=$.split(/[ |,]+/).concat("guard");if(z.test(J[0]))X=J.shift();if(q.test(J[0]))Z=J.shift();if(!X&&z.test(J[0]))X=J.shift();if(!X&&q.test(J[0]))X=Z,Z=J.shift();if(J[0].startsWith("-")){let G=J[0],Q=`option creation failed due to '${G}' in option flags '${$}'`;if(/^-[^-][^-]/.test(G))throw Error(`${Q}
|
|
8
8
|
- a short flag is a single dash and a single character
|
|
9
9
|
- either use a single dash and a single character (for a short flag)
|
|
10
|
-
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(
|
|
11
|
-
- too many short flags`);if(
|
|
12
|
-
- too many long flags`);throw Error(`${
|
|
13
|
-
- unrecognised flag format`)}if(
|
|
14
|
-
(Did you mean one of ${
|
|
15
|
-
(Did you mean ${
|
|
16
|
-
- specify the name in Command constructor or using .name()`);if(
|
|
17
|
-
Expecting one of '${
|
|
18
|
-
- already used by option '${
|
|
19
|
-
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,
|
|
20
|
-
- if '${
|
|
10
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(z.test(G))throw Error(`${Q}
|
|
11
|
+
- too many short flags`);if(q.test(G))throw Error(`${Q}
|
|
12
|
+
- too many long flags`);throw Error(`${Q}
|
|
13
|
+
- unrecognised flag format`)}if(X===void 0&&Z===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:X,longFlag:Z}}$6.Option=ZX;$6.DualOptions=zX});var qX=D((J6)=>{function z6($,X){if(Math.abs($.length-X.length)>3)return Math.max($.length,X.length);let Z=[];for(let z=0;z<=$.length;z++)Z[z]=[z];for(let z=0;z<=X.length;z++)Z[0][z]=z;for(let z=1;z<=X.length;z++)for(let q=1;q<=$.length;q++){let J=1;if($[q-1]===X[z-1])J=0;else J=1;if(Z[q][z]=Math.min(Z[q-1][z]+1,Z[q][z-1]+1,Z[q-1][z-1]+J),q>1&&z>1&&$[q-1]===X[z-2]&&$[q-2]===X[z-1])Z[q][z]=Math.min(Z[q][z],Z[q-2][z-2]+1)}return Z[$.length][X.length]}function q6($,X){if(!X||X.length===0)return"";X=Array.from(new Set(X));let Z=$.startsWith("--");if(Z)$=$.slice(2),X=X.map((G)=>G.slice(2));let z=[],q=3,J=0.4;if(X.forEach((G)=>{if(G.length<=1)return;let Q=z6($,G),Y=Math.max($.length,G.length);if((Y-Q)/Y>J){if(Q<q)q=Q,z=[G];else if(Q===q)z.push(G)}}),z.sort((G,Q)=>G.localeCompare(Q)),Z)z=z.map((G)=>`--${G}`);if(z.length>1)return`
|
|
14
|
+
(Did you mean one of ${z.join(", ")}?)`;if(z.length===1)return`
|
|
15
|
+
(Did you mean ${z[0]}?)`;return""}J6.suggestSimilar=q6});var YX=D((T6)=>{var Q6=Q0("events").EventEmitter,i2=Q0("child_process"),Y0=Q0("path"),B1=Q0("fs"),C=Q0("process"),{Argument:Y6,humanReadableArgName:U6}=T1(),{CommanderError:a2}=F$(),{Help:H6,stripColor:W6}=l2(),{Option:JX,DualOptions:V6}=c2(),{suggestSimilar:GX}=qX();class n2 extends Q6{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(X)=>C.stdout.write(X),writeErr:(X)=>C.stderr.write(X),outputError:(X,Z)=>Z(X),getOutHelpWidth:()=>C.stdout.isTTY?C.stdout.columns:void 0,getErrHelpWidth:()=>C.stderr.isTTY?C.stderr.columns:void 0,getOutHasColors:()=>s2()??(C.stdout.isTTY&&C.stdout.hasColors?.()),getErrHasColors:()=>s2()??(C.stderr.isTTY&&C.stderr.hasColors?.()),stripColor:(X)=>W6(X)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let X=this;X;X=X.parent)$.push(X);return $}command($,X,Z){let z=X,q=Z;if(typeof z==="object"&&z!==null)q=z,z=null;q=q||{};let[,J,G]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(J);if(z)Q.description(z),Q._executableHandler=!0;if(q.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(q.noHelp||q.hidden),Q._executableFile=q.executableFile||null,G)Q.arguments(G);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),z)return this;return Q}createCommand($){return new n2($)}createHelp(){return Object.assign(new H6,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,X){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
16
|
+
- specify the name in Command constructor or using .name()`);if(X=X||{},X.isDefault)this._defaultCommandName=$._name;if(X.noHelp||X.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,X){return new Y6($,X)}argument($,X,Z,z){let q=this.createArgument($,X);if(typeof Z==="function")q.default(z).argParser(Z);else q.default(Z);return this.addArgument(q),this}arguments($){return $.trim().split(/ +/).forEach((X)=>{this.argument(X)}),this}addArgument($){let X=this.registeredArguments.slice(-1)[0];if(X?.variadic)throw Error(`only the last argument can be variadic '${X.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,X){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let Z=$??"help [command]",[,z,q]=Z.match(/([^ ]+) *(.*)/),J=X??"display help for command",G=this.createCommand(z);if(G.helpOption(!1),q)G.arguments(q);if(J)G.description(J);if(this._addImplicitHelpCommand=!0,this._helpCommand=G,$||X)this._initCommandGroup(G);return this}addHelpCommand($,X){if(typeof $!=="object")return this.helpCommand($,X),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,X){let Z=["preSubcommand","preAction","postAction"];if(!Z.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
17
|
+
Expecting one of '${Z.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(X);else this._lifeCycleHooks[$]=[X];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(X)=>{if(X.code!=="commander.executeSubCommandAsync")throw X};return this}_exit($,X,Z){if(this._exitCallback)this._exitCallback(new a2($,X,Z));C.exit($)}action($){let X=(Z)=>{let z=this.registeredArguments.length,q=Z.slice(0,z);if(this._storeOptionsAsProperties)q[z]=this;else q[z]=this.opts();return q.push(this),$.apply(this,q)};return this._actionHandler=X,this}createOption($,X){return new JX($,X)}_callParseArg($,X,Z,z){try{return $.parseArg(X,Z)}catch(q){if(q.code==="commander.invalidArgument"){let J=`${z} ${q.message}`;this.error(J,{exitCode:q.exitCode,code:q.code})}throw q}}_registerOption($){let X=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(X){let Z=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${Z}'
|
|
18
|
+
- already used by option '${X.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let X=(z)=>{return[z.name()].concat(z.aliases())},Z=X($).find((z)=>this._findCommand(z));if(Z){let z=X(this._findCommand(Z)).join("|"),q=X($).join("|");throw Error(`cannot add command '${q}' as already have command '${z}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let X=$.name(),Z=$.attributeName();if($.negate){let q=$.long.replace(/^--no-/,"--");if(!this._findOption(q))this.setOptionValueWithSource(Z,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(Z,$.defaultValue,"default");let z=(q,J,G)=>{if(q==null&&$.presetArg!==void 0)q=$.presetArg;let Q=this.getOptionValue(Z);if(q!==null&&$.parseArg)q=this._callParseArg($,q,Q,J);else if(q!==null&&$.variadic)q=$._collectValue(q,Q);if(q==null)if($.negate)q=!1;else if($.isBoolean()||$.optional)q=!0;else q="";this.setOptionValueWithSource(Z,q,G)};if(this.on("option:"+X,(q)=>{let J=`error: option '${$.flags}' argument '${q}' is invalid.`;z(q,J,"cli")}),$.envVar)this.on("optionEnv:"+X,(q)=>{let J=`error: option '${$.flags}' value '${q}' from env '${$.envVar}' is invalid.`;z(q,J,"env")});return this}_optionEx($,X,Z,z,q){if(typeof X==="object"&&X instanceof JX)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let J=this.createOption(X,Z);if(J.makeOptionMandatory(!!$.mandatory),typeof z==="function")J.default(q).argParser(z);else if(z instanceof RegExp){let G=z;z=(Q,Y)=>{let U=G.exec(Q);return U?U[0]:Y},J.default(q).argParser(z)}else J.default(z);return this.addOption(J)}option($,X,Z,z){return this._optionEx({},$,X,Z,z)}requiredOption($,X,Z,z){return this._optionEx({mandatory:!0},$,X,Z,z)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,X){return this.setOptionValueWithSource($,X,void 0)}setOptionValueWithSource($,X,Z){if(this._storeOptionsAsProperties)this[$]=X;else this._optionValues[$]=X;return this._optionValueSources[$]=Z,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let X;return this._getCommandAndAncestors().forEach((Z)=>{if(Z.getOptionValueSource($)!==void 0)X=Z.getOptionValueSource($)}),X}_prepareUserArgs($,X){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(X=X||{},$===void 0&&X.from===void 0){if(C.versions?.electron)X.from="electron";let z=C.execArgv??[];if(z.includes("-e")||z.includes("--eval")||z.includes("-p")||z.includes("--print"))X.from="eval"}if($===void 0)$=C.argv;this.rawArgs=$.slice();let Z;switch(X.from){case void 0:case"node":this._scriptPath=$[1],Z=$.slice(2);break;case"electron":if(C.defaultApp)this._scriptPath=$[1],Z=$.slice(2);else Z=$.slice(1);break;case"user":Z=$.slice(0);break;case"eval":Z=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${X.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",Z}parse($,X){this._prepareForParse();let Z=this._prepareUserArgs($,X);return this._parseCommand([],Z),this}async parseAsync($,X){this._prepareForParse();let Z=this._prepareUserArgs($,X);return await this._parseCommand([],Z),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
19
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,X,Z){if(B1.existsSync($))return;let z=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",q=`'${$}' does not exist
|
|
20
|
+
- if '${Z}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
21
21
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
22
|
-
- ${
|
|
22
|
+
- ${z}`;throw Error(q)}_executeSubCommand($,X){X=X.slice();let Z=!1,z=[".js",".ts",".tsx",".mjs",".cjs"];function q(U,W){let H=Y0.resolve(U,W);if(B1.existsSync(H))return H;if(z.includes(Y0.extname(W)))return;let V=z.find((B)=>B1.existsSync(`${H}${B}`));if(V)return`${H}${V}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let J=$._executableFile||`${this._name}-${$._name}`,G=this._executableDir||"";if(this._scriptPath){let U;try{U=B1.realpathSync(this._scriptPath)}catch{U=this._scriptPath}G=Y0.resolve(Y0.dirname(U),G)}if(G){let U=q(G,J);if(!U&&!$._executableFile&&this._scriptPath){let W=Y0.basename(this._scriptPath,Y0.extname(this._scriptPath));if(W!==this._name)U=q(G,`${W}-${$._name}`)}J=U||J}Z=z.includes(Y0.extname(J));let Q;if(C.platform!=="win32")if(Z)X.unshift(J),X=QX(C.execArgv).concat(X),Q=i2.spawn(C.argv[0],X,{stdio:"inherit"});else Q=i2.spawn(J,X,{stdio:"inherit"});else this._checkForMissingExecutable(J,G,$._name),X.unshift(J),X=QX(C.execArgv).concat(X),Q=i2.spawn(C.execPath,X,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((W)=>{C.on(W,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(W)})});let Y=this._exitCallback;Q.on("close",(U)=>{if(U=U??1,!Y)C.exit(U);else Y(new a2(U,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(U)=>{if(U.code==="ENOENT")this._checkForMissingExecutable(J,G,$._name);else if(U.code==="EACCES")throw Error(`'${J}' not executable`);if(!Y)C.exit(1);else{let W=new a2(1,"commander.executeSubCommandAsync","(error)");W.nestedError=U,Y(W)}}),this.runningCommand=Q}_dispatchSubcommand($,X,Z){let z=this._findCommand($);if(!z)this.help({error:!0});z._prepareForParse();let q;return q=this._chainOrCallSubCommandHook(q,z,"preSubcommand"),q=this._chainOrCall(q,()=>{if(z._executableHandler)this._executeSubCommand(z,X.concat(Z));else return z._parseCommand(X,Z)}),q}_dispatchHelpCommand($){if(!$)this.help();let X=this._findCommand($);if(X&&!X._executableHandler)X.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,X)=>{if($.required&&this.args[X]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(Z,z,q)=>{let J=z;if(z!==null&&Z.parseArg){let G=`error: command-argument value '${z}' is invalid for argument '${Z.name()}'.`;J=this._callParseArg(Z,z,q,G)}return J};this._checkNumberOfArguments();let X=[];this.registeredArguments.forEach((Z,z)=>{let q=Z.defaultValue;if(Z.variadic){if(z<this.args.length){if(q=this.args.slice(z),Z.parseArg)q=q.reduce((J,G)=>{return $(Z,G,J)},Z.defaultValue)}else if(q===void 0)q=[]}else if(z<this.args.length){if(q=this.args[z],Z.parseArg)q=$(Z,q,Z.defaultValue)}X[z]=q}),this.processedArgs=X}_chainOrCall($,X){if($?.then&&typeof $.then==="function")return $.then(()=>X());return X()}_chainOrCallHooks($,X){let Z=$,z=[];if(this._getCommandAndAncestors().reverse().filter((q)=>q._lifeCycleHooks[X]!==void 0).forEach((q)=>{q._lifeCycleHooks[X].forEach((J)=>{z.push({hookedCommand:q,callback:J})})}),X==="postAction")z.reverse();return z.forEach((q)=>{Z=this._chainOrCall(Z,()=>{return q.callback(q.hookedCommand,this)})}),Z}_chainOrCallSubCommandHook($,X,Z){let z=$;if(this._lifeCycleHooks[Z]!==void 0)this._lifeCycleHooks[Z].forEach((q)=>{z=this._chainOrCall(z,()=>{return q(this,X)})});return z}_parseCommand($,X){let Z=this.parseOptions(X);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(Z.operands),X=Z.unknown,this.args=$.concat(X),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),X);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(X),this._dispatchSubcommand(this._defaultCommandName,$,X);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(Z.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=()=>{if(Z.unknown.length>0)this.unknownOption(Z.unknown[0])},q=`command:${this.name()}`;if(this._actionHandler){z(),this._processArguments();let J;if(J=this._chainOrCallHooks(J,"preAction"),J=this._chainOrCall(J,()=>this._actionHandler(this.processedArgs)),this.parent)J=this._chainOrCall(J,()=>{this.parent.emit(q,$,X)});return J=this._chainOrCallHooks(J,"postAction"),J}if(this.parent?.listenerCount(q))z(),this._processArguments(),this.parent.emit(q,$,X);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,X);if(this.listenerCount("command:*"))this.emit("command:*",$,X);else if(this.commands.length)this.unknownCommand();else z(),this._processArguments()}else if(this.commands.length)z(),this.help({error:!0});else z(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((X)=>X._name===$||X._aliases.includes($))}_findOption($){return this.options.find((X)=>X.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((X)=>{if(X.mandatory&&$.getOptionValue(X.attributeName())===void 0)$.missingMandatoryOptionValue(X)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((Z)=>{let z=Z.attributeName();if(this.getOptionValue(z)===void 0)return!1;return this.getOptionValueSource(z)!=="default"});$.filter((Z)=>Z.conflictsWith.length>0).forEach((Z)=>{let z=$.find((q)=>Z.conflictsWith.includes(q.attributeName()));if(z)this._conflictingOption(Z,z)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let X=[],Z=[],z=X;function q(U){return U.length>1&&U[0]==="-"}let J=(U)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(U))return!1;return!this._getCommandAndAncestors().some((W)=>W.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},G=null,Q=null,Y=0;while(Y<$.length||Q){let U=Q??$[Y++];if(Q=null,U==="--"){if(z===Z)z.push(U);z.push(...$.slice(Y));break}if(G&&(!q(U)||J(U))){this.emit(`option:${G.name()}`,U);continue}if(G=null,q(U)){let W=this._findOption(U);if(W){if(W.required){let H=$[Y++];if(H===void 0)this.optionMissingArgument(W);this.emit(`option:${W.name()}`,H)}else if(W.optional){let H=null;if(Y<$.length&&(!q($[Y])||J($[Y])))H=$[Y++];this.emit(`option:${W.name()}`,H)}else this.emit(`option:${W.name()}`);G=W.variadic?W:null;continue}}if(U.length>2&&U[0]==="-"&&U[1]!=="-"){let W=this._findOption(`-${U[1]}`);if(W){if(W.required||W.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${W.name()}`,U.slice(2));else this.emit(`option:${W.name()}`),Q=`-${U.slice(2)}`;continue}}if(/^--[^=]+=/.test(U)){let W=U.indexOf("="),H=this._findOption(U.slice(0,W));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,U.slice(W+1));continue}}if(z===X&&q(U)&&!(this.commands.length===0&&J(U)))z=Z;if((this._enablePositionalOptions||this._passThroughOptions)&&X.length===0&&Z.length===0){if(this._findCommand(U)){X.push(U),Z.push(...$.slice(Y));break}else if(this._getHelpCommand()&&U===this._getHelpCommand().name()){X.push(U,...$.slice(Y));break}else if(this._defaultCommandName){Z.push(U,...$.slice(Y));break}}if(this._passThroughOptions){z.push(U,...$.slice(Y));break}z.push(U)}return{operands:X,unknown:Z}}opts(){if(this._storeOptionsAsProperties){let $={},X=this.options.length;for(let Z=0;Z<X;Z++){let z=this.options[Z].attributeName();$[z]=z===this._versionOptionName?this._version:this[z]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,X)=>Object.assign($,X.opts()),{})}error($,X){if(this._outputConfiguration.outputError(`${$}
|
|
23
23
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
24
24
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
25
|
-
`),this.outputHelp({error:!0});let
|
|
26
|
-
`),this._exit(0,"commander.version",$)}),this}description($,
|
|
27
|
-
Expecting one of '${
|
|
28
|
-
`)}),this}_outputHelpIfRequested($){let
|
|
29
|
-
`)}}
|
|
30
|
-
`)?
|
|
25
|
+
`),this.outputHelp({error:!0});let Z=X||{},z=Z.exitCode||1,q=Z.code||"commander.error";this._exit(z,q,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in C.env){let X=$.attributeName();if(this.getOptionValue(X)===void 0||["default","config","env"].includes(this.getOptionValueSource(X)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,C.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new V6(this.options),X=(Z)=>{return this.getOptionValue(Z)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(Z))};this.options.filter((Z)=>Z.implied!==void 0&&X(Z.attributeName())&&$.valueFromOption(this.getOptionValue(Z.attributeName()),Z)).forEach((Z)=>{Object.keys(Z.implied).filter((z)=>!X(z)).forEach((z)=>{this.setOptionValueWithSource(z,Z.implied[z],"implied")})})}missingArgument($){let X=`error: missing required argument '${$}'`;this.error(X,{code:"commander.missingArgument"})}optionMissingArgument($){let X=`error: option '${$.flags}' argument missing`;this.error(X,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let X=`error: required option '${$.flags}' not specified`;this.error(X,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,X){let Z=(J)=>{let G=J.attributeName(),Q=this.getOptionValue(G),Y=this.options.find((W)=>W.negate&&G===W.attributeName()),U=this.options.find((W)=>!W.negate&&G===W.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return U||J},z=(J)=>{let G=Z(J),Q=G.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${G.envVar}'`;return`option '${G.flags}'`},q=`error: ${z($)} cannot be used with ${z(X)}`;this.error(q,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let X="";if($.startsWith("--")&&this._showSuggestionAfterError){let z=[],q=this;do{let J=q.createHelp().visibleOptions(q).filter((G)=>G.long).map((G)=>G.long);z=z.concat(J),q=q.parent}while(q&&!q._enablePositionalOptions);X=GX($,z)}let Z=`error: unknown option '${$}'${X}`;this.error(Z,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let X=this.registeredArguments.length,Z=X===1?"":"s",q=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${X} argument${Z} but got ${$.length}.`;this.error(q,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],X="";if(this._showSuggestionAfterError){let z=[];this.createHelp().visibleCommands(this).forEach((q)=>{if(z.push(q.name()),q.alias())z.push(q.alias())}),X=GX($,z)}let Z=`error: unknown command '${$}'${X}`;this.error(Z,{code:"commander.unknownCommand"})}version($,X,Z){if($===void 0)return this._version;this._version=$,X=X||"-V, --version",Z=Z||"output the version number";let z=this.createOption(X,Z);return this._versionOptionName=z.attributeName(),this._registerOption(z),this.on("option:"+z.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
26
|
+
`),this._exit(0,"commander.version",$)}),this}description($,X){if($===void 0&&X===void 0)return this._description;if(this._description=$,X)this._argsDescription=X;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let X=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)X=this.commands[this.commands.length-1];if($===X._name)throw Error("Command alias can't be the same as its name");let Z=this.parent?._findCommand($);if(Z){let z=[Z.name()].concat(Z.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${z}'`)}return X._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((X)=>this.alias(X)),this}usage($){if($===void 0){if(this._usage)return this._usage;let X=this.registeredArguments.map((Z)=>{return U6(Z)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?X:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=Y0.basename($,Y0.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let X=this.createHelp(),Z=this._getOutputContext($);X.prepareContext({error:Z.error,helpWidth:Z.helpWidth,outputHasColors:Z.hasColors});let z=X.formatHelp(this,X);if(Z.hasColors)return z;return this._outputConfiguration.stripColor(z)}_getOutputContext($){$=$||{};let X=!!$.error,Z,z,q;if(X)Z=(G)=>this._outputConfiguration.writeErr(G),z=this._outputConfiguration.getErrHasColors(),q=this._outputConfiguration.getErrHelpWidth();else Z=(G)=>this._outputConfiguration.writeOut(G),z=this._outputConfiguration.getOutHasColors(),q=this._outputConfiguration.getOutHelpWidth();return{error:X,write:(G)=>{if(!z)G=this._outputConfiguration.stripColor(G);return Z(G)},hasColors:z,helpWidth:q}}outputHelp($){let X;if(typeof $==="function")X=$,$=void 0;let Z=this._getOutputContext($),z={error:Z.error,write:Z.write,command:this};this._getCommandAndAncestors().reverse().forEach((J)=>J.emit("beforeAllHelp",z)),this.emit("beforeHelp",z);let q=this.helpInformation({error:Z.error});if(X){if(q=X(q),typeof q!=="string"&&!Buffer.isBuffer(q))throw Error("outputHelp callback must return a string or a Buffer")}if(Z.write(q),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",z),this._getCommandAndAncestors().forEach((J)=>J.emit("afterAllHelp",z))}helpOption($,X){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",X??"display help for command"),$||X)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let X=Number(C.exitCode??0);if(X===0&&$&&typeof $!=="function"&&$.error)X=1;this._exit(X,"commander.help","(outputHelp)")}addHelpText($,X){let Z=["beforeAll","before","after","afterAll"];if(!Z.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
27
|
+
Expecting one of '${Z.join("', '")}'`);let z=`${$}Help`;return this.on(z,(q)=>{let J;if(typeof X==="function")J=X({error:q.error,command:q.command});else J=X;if(J)q.write(`${J}
|
|
28
|
+
`)}),this}_outputHelpIfRequested($){let X=this._getHelpOption();if(X&&$.find((z)=>X.is(z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function QX($){return $.map((X)=>{if(!X.startsWith("--inspect"))return X;let Z,z="127.0.0.1",q="9229",J;if((J=X.match(/^(--inspect(-brk)?)$/))!==null)Z=J[1];else if((J=X.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Z=J[1],/^\d+$/.test(J[3]))q=J[3];else z=J[3];else if((J=X.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Z=J[1],z=J[3],q=J[4];if(Z&&q!=="0")return`${Z}=${z}:${parseInt(q)+1}`;return X})}function s2(){if(C.env.NO_COLOR||C.env.FORCE_COLOR==="0"||C.env.FORCE_COLOR==="false")return!1;if(C.env.FORCE_COLOR||C.env.CLICOLOR_FORCE!==void 0)return!0;return}T6.Command=n2;T6.useColor=s2});var VX=D((_6)=>{var{Argument:UX}=T1(),{Command:r2}=YX(),{CommanderError:L6,InvalidArgumentError:HX}=F$(),{Help:D6}=l2(),{Option:WX}=c2();_6.program=new r2;_6.createCommand=($)=>new r2($);_6.createOption=($,X)=>new WX($,X);_6.createArgument=($,X)=>new UX($,X);_6.Command=r2;_6.Option=WX;_6.Argument=UX;_6.Help=D6;_6.CommanderError=L6;_6.InvalidArgumentError=HX;_6.InvalidOptionArgumentError=HX});var S=D((h6)=>{var $9=Symbol.for("yaml.alias"),KX=Symbol.for("yaml.document"),K1=Symbol.for("yaml.map"),LX=Symbol.for("yaml.pair"),X9=Symbol.for("yaml.scalar"),L1=Symbol.for("yaml.seq"),U0=Symbol.for("yaml.node.type"),E6=($)=>!!$&&typeof $==="object"&&$[U0]===$9,b6=($)=>!!$&&typeof $==="object"&&$[U0]===KX,x6=($)=>!!$&&typeof $==="object"&&$[U0]===K1,y6=($)=>!!$&&typeof $==="object"&&$[U0]===LX,DX=($)=>!!$&&typeof $==="object"&&$[U0]===X9,k6=($)=>!!$&&typeof $==="object"&&$[U0]===L1;function _X($){if($&&typeof $==="object")switch($[U0]){case K1:case L1:return!0}return!1}function f6($){if($&&typeof $==="object")switch($[U0]){case $9:case K1:case X9:case L1:return!0}return!1}var g6=($)=>(DX($)||_X($))&&!!$.anchor;h6.ALIAS=$9;h6.DOC=KX;h6.MAP=K1;h6.NODE_TYPE=U0;h6.PAIR=LX;h6.SCALAR=X9;h6.SEQ=L1;h6.hasAnchor=g6;h6.isAlias=E6;h6.isCollection=_X;h6.isDocument=b6;h6.isMap=x6;h6.isNode=f6;h6.isPair=y6;h6.isScalar=DX;h6.isSeq=k6});var M$=D((Xz)=>{var h=S(),l=Symbol("break visit"),FX=Symbol("skip children"),J0=Symbol("remove node");function D1($,X){let Z=MX(X);if(h.isDocument($)){if(c0(null,$.contents,Z,Object.freeze([$]))===J0)$.contents=null}else c0(null,$,Z,Object.freeze([]))}D1.BREAK=l;D1.SKIP=FX;D1.REMOVE=J0;function c0($,X,Z,z){let q=OX($,X,Z,z);if(h.isNode(q)||h.isPair(q))return wX($,z,q),c0($,q,Z,z);if(typeof q!=="symbol"){if(h.isCollection(X)){z=Object.freeze(z.concat(X));for(let J=0;J<X.items.length;++J){let G=c0(J,X.items[J],Z,z);if(typeof G==="number")J=G-1;else if(G===l)return l;else if(G===J0)X.items.splice(J,1),J-=1}}else if(h.isPair(X)){z=Object.freeze(z.concat(X));let J=c0("key",X.key,Z,z);if(J===l)return l;else if(J===J0)X.key=null;let G=c0("value",X.value,Z,z);if(G===l)return l;else if(G===J0)X.value=null}}return q}async function _1($,X){let Z=MX(X);if(h.isDocument($)){if(await i0(null,$.contents,Z,Object.freeze([$]))===J0)$.contents=null}else await i0(null,$,Z,Object.freeze([]))}_1.BREAK=l;_1.SKIP=FX;_1.REMOVE=J0;async function i0($,X,Z,z){let q=await OX($,X,Z,z);if(h.isNode(q)||h.isPair(q))return wX($,z,q),i0($,q,Z,z);if(typeof q!=="symbol"){if(h.isCollection(X)){z=Object.freeze(z.concat(X));for(let J=0;J<X.items.length;++J){let G=await i0(J,X.items[J],Z,z);if(typeof G==="number")J=G-1;else if(G===l)return l;else if(G===J0)X.items.splice(J,1),J-=1}}else if(h.isPair(X)){z=Object.freeze(z.concat(X));let J=await i0("key",X.key,Z,z);if(J===l)return l;else if(J===J0)X.key=null;let G=await i0("value",X.value,Z,z);if(G===l)return l;else if(G===J0)X.value=null}}return q}function MX($){if(typeof $==="object"&&($.Collection||$.Node||$.Value))return Object.assign({Alias:$.Node,Map:$.Node,Scalar:$.Node,Seq:$.Node},$.Value&&{Map:$.Value,Scalar:$.Value,Seq:$.Value},$.Collection&&{Map:$.Collection,Seq:$.Collection},$);return $}function OX($,X,Z,z){if(typeof Z==="function")return Z($,X,z);if(h.isMap(X))return Z.Map?.($,X,z);if(h.isSeq(X))return Z.Seq?.($,X,z);if(h.isPair(X))return Z.Pair?.($,X,z);if(h.isScalar(X))return Z.Scalar?.($,X,z);if(h.isAlias(X))return Z.Alias?.($,X,z);return}function wX($,X,Z){let z=X[X.length-1];if(h.isCollection(z))z.items[$]=Z;else if(h.isPair(z))if($==="key")z.key=Z;else z.value=Z;else if(h.isDocument(z))z.contents=Z;else{let q=h.isAlias(z)?"alias":"scalar";throw Error(`Cannot replace node with ${q} parent`)}}Xz.visit=D1;Xz.visitAsync=_1});var Z9=D((Qz)=>{var IX=S(),qz=M$(),Jz={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Gz=($)=>$.replace(/[!,[\]{}]/g,(X)=>Jz[X]);class s{constructor($,X){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,$),this.tags=Object.assign({},s.defaultTags,X)}clone(){let $=new s(this.yaml,this.tags);return $.docStart=this.docStart,$}atDocument(){let $=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return $}add($,X){if(this.atNextDocument)this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1;let Z=$.trim().split(/[ \t]+/),z=Z.shift();switch(z){case"%TAG":{if(Z.length!==2){if(X(0,"%TAG directive should contain exactly two parts"),Z.length<2)return!1}let[q,J]=Z;return this.tags[q]=J,!0}case"%YAML":{if(this.yaml.explicit=!0,Z.length!==1)return X(0,"%YAML directive should contain exactly one part"),!1;let[q]=Z;if(q==="1.1"||q==="1.2")return this.yaml.version=q,!0;else{let J=/^\d+\.\d+$/.test(q);return X(6,`Unsupported YAML version ${q}`,J),!1}}default:return X(0,`Unknown directive ${z}`,!0),!1}}tagName($,X){if($==="!")return"!";if($[0]!=="!")return X(`Not a valid tag: ${$}`),null;if($[1]==="<"){let J=$.slice(2,-1);if(J==="!"||J==="!!")return X(`Verbatim tags aren't resolved, so ${$} is invalid.`),null;if($[$.length-1]!==">")X("Verbatim tags must end with a >");return J}let[,Z,z]=$.match(/^(.*!)([^!]*)$/s);if(!z)X(`The ${$} tag has no suffix`);let q=this.tags[Z];if(q)try{return q+decodeURIComponent(z)}catch(J){return X(String(J)),null}if(Z==="!")return $;return X(`Could not resolve tag: ${$}`),null}tagString($){for(let[X,Z]of Object.entries(this.tags))if($.startsWith(Z))return X+Gz($.substring(Z.length));return $[0]==="!"?$:`!<${$}>`}toString($){let X=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],Z=Object.entries(this.tags),z;if($&&Z.length>0&&IX.isNode($.contents)){let q={};qz.visit($.contents,(J,G)=>{if(IX.isNode(G)&&G.tag)q[G.tag]=!0}),z=Object.keys(q)}else z=[];for(let[q,J]of Z){if(q==="!!"&&J==="tag:yaml.org,2002:")continue;if(!$||z.some((G)=>G.startsWith(J)))X.push(`%TAG ${q} ${J}`)}return X.join(`
|
|
29
|
+
`)}}s.defaultYaml={explicit:!1,version:"1.2"};s.defaultTags={"!!":"tag:yaml.org,2002:"};Qz.Directives=s});var F1=D((Vz)=>{var RX=S(),Uz=M$();function Hz($){if(/[\x00-\x19\s,[\]{}]/.test($)){let Z=`Anchor must not contain whitespace or control characters: ${JSON.stringify($)}`;throw Error(Z)}return!0}function PX($){let X=new Set;return Uz.visit($,{Value(Z,z){if(z.anchor)X.add(z.anchor)}}),X}function NX($,X){for(let Z=1;;++Z){let z=`${$}${Z}`;if(!X.has(z))return z}}function Wz($,X){let Z=[],z=new Map,q=null;return{onAnchor:(J)=>{Z.push(J),q??(q=PX($));let G=NX(X,q);return q.add(G),G},setAnchors:()=>{for(let J of Z){let G=z.get(J);if(typeof G==="object"&&G.anchor&&(RX.isScalar(G.node)||RX.isCollection(G.node)))G.node.anchor=G.anchor;else{let Q=Error("Failed to resolve repeated object (this should not happen)");throw Q.source=J,Q}}},sourceObjects:z}}Vz.anchorIsValid=Hz;Vz.anchorNames=PX;Vz.createNodeAnchors=Wz;Vz.findNewAnchor=NX});var z9=D((Dz)=>{function O$($,X,Z,z){if(z&&typeof z==="object")if(Array.isArray(z))for(let q=0,J=z.length;q<J;++q){let G=z[q],Q=O$($,z,String(q),G);if(Q===void 0)delete z[q];else if(Q!==G)z[q]=Q}else if(z instanceof Map)for(let q of Array.from(z.keys())){let J=z.get(q),G=O$($,z,q,J);if(G===void 0)z.delete(q);else if(G!==J)z.set(q,G)}else if(z instanceof Set)for(let q of Array.from(z)){let J=O$($,z,q,q);if(J===void 0)z.delete(q);else if(J!==q)z.delete(q),z.add(J)}else for(let[q,J]of Object.entries(z)){let G=O$($,z,q,J);if(G===void 0)delete z[q];else if(G!==J)z[q]=G}return $.call(X,Z,z)}Dz.applyReviver=O$});var K0=D((Mz)=>{var Fz=S();function AX($,X,Z){if(Array.isArray($))return $.map((z,q)=>AX(z,String(q),Z));if($&&typeof $.toJSON==="function"){if(!Z||!Fz.hasAnchor($))return $.toJSON(X,Z);let z={aliasCount:0,count:1,res:void 0};Z.anchors.set($,z),Z.onCreate=(J)=>{z.res=J,delete Z.onCreate};let q=$.toJSON(X,Z);if(Z.onCreate)Z.onCreate(q);return q}if(typeof $==="bigint"&&!Z?.keep)return Number($);return $}Mz.toJS=AX});var M1=D((Rz)=>{var wz=z9(),jX=S(),Iz=K0();class SX{constructor($){Object.defineProperty(this,jX.NODE_TYPE,{value:$})}clone(){let $=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)$.range=this.range.slice();return $}toJS($,{mapAsMap:X,maxAliasCount:Z,onAnchor:z,reviver:q}={}){if(!jX.isDocument($))throw TypeError("A document argument is required");let J={anchors:new Map,doc:$,keep:!0,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof Z==="number"?Z:100},G=Iz.toJS(this,"",J);if(typeof z==="function")for(let{count:Q,res:Y}of J.anchors.values())z(Y,Q);return typeof q==="function"?wz.applyReviver(q,{"":G},"",G):G}}Rz.NodeBase=SX});var w$=D((Cz)=>{var Nz=F1(),Az=M$(),a0=S(),jz=M1(),Sz=K0();class CX extends jz.NodeBase{constructor($){super(a0.ALIAS);this.source=$,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve($,X){let Z;if(X?.aliasResolveCache)Z=X.aliasResolveCache;else if(Z=[],Az.visit($,{Node:(q,J)=>{if(a0.isAlias(J)||a0.hasAnchor(J))Z.push(J)}}),X)X.aliasResolveCache=Z;let z=void 0;for(let q of Z){if(q===this)break;if(q.anchor===this.source)z=q}return z}toJSON($,X){if(!X)return{source:this.source};let{anchors:Z,doc:z,maxAliasCount:q}=X,J=this.resolve(z,X);if(!J){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(Q)}let G=Z.get(J);if(!G)Sz.toJS(J,null,X),G=Z.get(J);if(G?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(q>=0){if(G.count+=1,G.aliasCount===0)G.aliasCount=O1(z,J,Z);if(G.count*G.aliasCount>q)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return G.res}toString($,X,Z){let z=`*${this.source}`;if($){if(Nz.anchorIsValid(this.source),$.options.verifyAliasOrder&&!$.anchors.has(this.source)){let q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(q)}if($.implicitKey)return`${z} `}return z}}function O1($,X,Z){if(a0.isAlias(X)){let z=X.resolve($),q=Z&&z&&Z.get(z);return q?q.count*q.aliasCount:0}else if(a0.isCollection(X)){let z=0;for(let q of X.items){let J=O1($,q,Z);if(J>z)z=J}return z}else if(a0.isPair(X)){let z=O1($,X.key,Z),q=O1($,X.value,Z);return Math.max(z,q)}return 1}Cz.Alias=CX});var g=D((fz)=>{var bz=S(),xz=M1(),yz=K0(),kz=($)=>!$||typeof $!=="function"&&typeof $!=="object";class j0 extends xz.NodeBase{constructor($){super(bz.SCALAR);this.value=$}toJSON($,X){return X?.keep?this.value:yz.toJS(this.value,$,X)}toString(){return String(this.value)}}j0.BLOCK_FOLDED="BLOCK_FOLDED";j0.BLOCK_LITERAL="BLOCK_LITERAL";j0.PLAIN="PLAIN";j0.QUOTE_DOUBLE="QUOTE_DOUBLE";j0.QUOTE_SINGLE="QUOTE_SINGLE";fz.Scalar=j0;fz.isScalarValue=kz});var I$=D((pz)=>{var vz=w$(),S0=S(),EX=g(),uz="tag:yaml.org,2002:";function mz($,X,Z){if(X){let z=Z.filter((J)=>J.tag===X),q=z.find((J)=>!J.format)??z[0];if(!q)throw Error(`Tag ${X} not found`);return q}return Z.find((z)=>z.identify?.($)&&!z.format)}function dz($,X,Z){if(S0.isDocument($))$=$.contents;if(S0.isNode($))return $;if(S0.isPair($)){let H=Z.schema[S0.MAP].createNode?.(Z.schema,null,Z);return H.items.push($),H}if($ instanceof String||$ instanceof Number||$ instanceof Boolean||typeof BigInt<"u"&&$ instanceof BigInt)$=$.valueOf();let{aliasDuplicateObjects:z,onAnchor:q,onTagObj:J,schema:G,sourceObjects:Q}=Z,Y=void 0;if(z&&$&&typeof $==="object")if(Y=Q.get($),Y)return Y.anchor??(Y.anchor=q($)),new vz.Alias(Y.anchor);else Y={anchor:null,node:null},Q.set($,Y);if(X?.startsWith("!!"))X=uz+X.slice(2);let U=mz($,X,G.tags);if(!U){if($&&typeof $.toJSON==="function")$=$.toJSON();if(!$||typeof $!=="object"){let H=new EX.Scalar($);if(Y)Y.node=H;return H}U=$ instanceof Map?G[S0.MAP]:(Symbol.iterator in Object($))?G[S0.SEQ]:G[S0.MAP]}if(J)J(U),delete Z.onTagObj;let W=U?.createNode?U.createNode(Z.schema,$,Z):typeof U?.nodeClass?.from==="function"?U.nodeClass.from(Z.schema,$,Z):new EX.Scalar($);if(X)W.tag=X;else if(!U.default)W.tag=U.tag;if(Y)Y.node=W;return W}pz.createNode=dz});var w1=D((az)=>{var cz=I$(),G0=S(),iz=M1();function q9($,X,Z){let z=Z;for(let q=X.length-1;q>=0;--q){let J=X[q];if(typeof J==="number"&&Number.isInteger(J)&&J>=0){let G=[];G[J]=z,z=G}else z=new Map([[J,z]])}return cz.createNode(z,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:$,sourceObjects:new Map})}var bX=($)=>$==null||typeof $==="object"&&!!$[Symbol.iterator]().next().done;class xX extends iz.NodeBase{constructor($,X){super($);Object.defineProperty(this,"schema",{value:X,configurable:!0,enumerable:!1,writable:!0})}clone($){let X=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if($)X.schema=$;if(X.items=X.items.map((Z)=>G0.isNode(Z)||G0.isPair(Z)?Z.clone($):Z),this.range)X.range=this.range.slice();return X}addIn($,X){if(bX($))this.add(X);else{let[Z,...z]=$,q=this.get(Z,!0);if(G0.isCollection(q))q.addIn(z,X);else if(q===void 0&&this.schema)this.set(Z,q9(this.schema,z,X));else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${z}`)}}deleteIn($){let[X,...Z]=$;if(Z.length===0)return this.delete(X);let z=this.get(X,!0);if(G0.isCollection(z))return z.deleteIn(Z);else throw Error(`Expected YAML collection at ${X}. Remaining path: ${Z}`)}getIn($,X){let[Z,...z]=$,q=this.get(Z,!0);if(z.length===0)return!X&&G0.isScalar(q)?q.value:q;else return G0.isCollection(q)?q.getIn(z,X):void 0}hasAllNullValues($){return this.items.every((X)=>{if(!G0.isPair(X))return!1;let Z=X.value;return Z==null||$&&G0.isScalar(Z)&&Z.value==null&&!Z.commentBefore&&!Z.comment&&!Z.tag})}hasIn($){let[X,...Z]=$;if(Z.length===0)return this.has(X);let z=this.get(X,!0);return G0.isCollection(z)?z.hasIn(Z):!1}setIn($,X){let[Z,...z]=$;if(z.length===0)this.set(Z,X);else{let q=this.get(Z,!0);if(G0.isCollection(q))q.setIn(z,X);else if(q===void 0&&this.schema)this.set(Z,q9(this.schema,z,X));else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${z}`)}}}az.Collection=xX;az.collectionFromPath=q9;az.isEmptyPath=bX});var R$=D((ez)=>{var oz=($)=>$.replace(/^(?!$)(?: $)?/gm,"#");function J9($,X){if(/^\n+$/.test($))return $.substring(1);return X?$.replace(/^(?! *$)/gm,X):$}var tz=($,X,Z)=>$.endsWith(`
|
|
30
|
+
`)?J9(Z,X):Z.includes(`
|
|
31
31
|
`)?`
|
|
32
|
-
`+
|
|
33
|
-
`){if(
|
|
34
|
-
`&&
|
|
35
|
-
`&&
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
`);X
|
|
39
|
-
`){if(
|
|
40
|
-
|
|
41
|
-
`;while(
|
|
42
|
-
`,
|
|
43
|
-
`)||/[ \t]\n|\n[ \t]/.test($))return
|
|
44
|
-
${
|
|
32
|
+
`+J9(Z,X):($.endsWith(" ")?"":" ")+Z;ez.indentComment=J9;ez.lineComment=tz;ez.stringifyComment=oz});var kX=D((q3)=>{function z3($,X,Z="flow",{indentAtStart:z,lineWidth:q=80,minContentWidth:J=20,onFold:G,onOverflow:Q}={}){if(!q||q<0)return $;if(q<J)J=0;let Y=Math.max(1+J,1+q-X.length);if($.length<=Y)return $;let U=[],W={},H=q-X.length;if(typeof z==="number")if(z>q-Math.max(2,J))U.push(0);else H=q-z;let V=void 0,B=void 0,L=!1,T=-1,K=-1,_=-1;if(Z==="block"){if(T=yX($,T,X.length),T!==-1)H=T+Y}for(let O;O=$[T+=1];){if(Z==="quoted"&&O==="\\"){switch(K=T,$[T+1]){case"x":T+=3;break;case"u":T+=5;break;case"U":T+=9;break;default:T+=1}_=T}if(O===`
|
|
33
|
+
`){if(Z==="block")T=yX($,T,X.length);H=T+X.length+Y,V=void 0}else{if(O===" "&&B&&B!==" "&&B!==`
|
|
34
|
+
`&&B!=="\t"){let I=$[T+1];if(I&&I!==" "&&I!==`
|
|
35
|
+
`&&I!=="\t")V=T}if(T>=H)if(V)U.push(V),H=V+Y,V=void 0;else if(Z==="quoted"){while(B===" "||B==="\t")B=O,O=$[T+=1],L=!0;let I=T>_+1?T-2:K-1;if(W[I])return $;U.push(I),W[I]=!0,H=I+Y,V=void 0}else L=!0}B=O}if(L&&Q)Q();if(U.length===0)return $;if(G)G();let F=$.slice(0,U[0]);for(let O=0;O<U.length;++O){let I=U[O],R=U[O+1]||$.length;if(I===0)F=`
|
|
36
|
+
${X}${$.slice(0,R)}`;else{if(Z==="quoted"&&W[I])F+=`${$[I]}\\`;F+=`
|
|
37
|
+
${X}${$.slice(I+1,R)}`}}return F}function yX($,X,Z){let z=X,q=X+1,J=$[q];while(J===" "||J==="\t")if(X<q+Z)J=$[++X];else{do J=$[++X];while(J&&J!==`
|
|
38
|
+
`);z=X,q=X+1,J=$[q]}return z}q3.FOLD_BLOCK="block";q3.FOLD_FLOW="flow";q3.FOLD_QUOTED="quoted";q3.foldFlowLines=z3});var N$=D((V3)=>{var $0=g(),L0=kX(),R1=($,X)=>({indentAtStart:X?$.indent.length:$.indentAtStart,lineWidth:$.options.lineWidth,minContentWidth:$.options.minContentWidth}),P1=($)=>/^(%|---|\.\.\.)/m.test($);function U3($,X,Z){if(!X||X<0)return!1;let z=X-Z,q=$.length;if(q<=z)return!1;for(let J=0,G=0;J<q;++J)if($[J]===`
|
|
39
|
+
`){if(J-G>z)return!0;if(G=J+1,q-G<=z)return!1}return!0}function P$($,X){let Z=JSON.stringify($);if(X.options.doubleQuotedAsJSON)return Z;let{implicitKey:z}=X,q=X.options.doubleQuotedMinMultiLineLength,J=X.indent||(P1($)?" ":""),G="",Q=0;for(let Y=0,U=Z[Y];U;U=Z[++Y]){if(U===" "&&Z[Y+1]==="\\"&&Z[Y+2]==="n")G+=Z.slice(Q,Y)+"\\ ",Y+=1,Q=Y,U="\\";if(U==="\\")switch(Z[Y+1]){case"u":{G+=Z.slice(Q,Y);let W=Z.substr(Y+2,4);switch(W){case"0000":G+="\\0";break;case"0007":G+="\\a";break;case"000b":G+="\\v";break;case"001b":G+="\\e";break;case"0085":G+="\\N";break;case"00a0":G+="\\_";break;case"2028":G+="\\L";break;case"2029":G+="\\P";break;default:if(W.substr(0,2)==="00")G+="\\x"+W.substr(2);else G+=Z.substr(Y,6)}Y+=5,Q=Y+1}break;case"n":if(z||Z[Y+2]==='"'||Z.length<q)Y+=1;else{G+=Z.slice(Q,Y)+`
|
|
40
|
+
|
|
41
|
+
`;while(Z[Y+2]==="\\"&&Z[Y+3]==="n"&&Z[Y+4]!=='"')G+=`
|
|
42
|
+
`,Y+=2;if(G+=J,Z[Y+2]===" ")G+="\\";Y+=1,Q=Y+1}break;default:Y+=1}}return G=Q?G+Z.slice(Q):Z,z?G:L0.foldFlowLines(G,J,L0.FOLD_QUOTED,R1(X,!1))}function G9($,X){if(X.options.singleQuote===!1||X.implicitKey&&$.includes(`
|
|
43
|
+
`)||/[ \t]\n|\n[ \t]/.test($))return P$($,X);let Z=X.indent||(P1($)?" ":""),z="'"+$.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
44
|
+
${Z}`)+"'";return X.implicitKey?z:L0.foldFlowLines(z,Z,L0.FOLD_FLOW,R1(X,!1))}function s0($,X){let{singleQuote:Z}=X.options,z;if(Z===!1)z=P$;else{let q=$.includes('"'),J=$.includes("'");if(q&&!J)z=G9;else if(J&&!q)z=P$;else z=Z?G9:P$}return z($,X)}var Q9;try{Q9=new RegExp(`(^|(?<!
|
|
45
45
|
))
|
|
46
46
|
+(?!
|
|
47
|
-
|$)`,"g")}catch{
|
|
47
|
+
|$)`,"g")}catch{Q9=/\n+(?!\n|$)/g}function I1({comment:$,type:X,value:Z},z,q,J){let{blockQuote:G,commentString:Q,lineWidth:Y}=z.options;if(!G||/\n[\t ]+$/.test(Z))return s0(Z,z);let U=z.indent||(z.forceBlockIndent||P1(Z)?" ":""),W=G==="literal"?!0:G==="folded"||X===$0.Scalar.BLOCK_FOLDED?!1:X===$0.Scalar.BLOCK_LITERAL?!0:!U3(Z,Y,U.length);if(!Z)return W?`|
|
|
48
48
|
`:`>
|
|
49
|
-
`;let
|
|
50
|
-
`&&
|
|
51
|
-
`);if(
|
|
52
|
-
`)
|
|
53
|
-
`)
|
|
54
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${U}`),
|
|
55
|
-
${U}${M}`}return
|
|
56
|
-
${U}${
|
|
57
|
-
`)||
|
|
58
|
-
`)?
|
|
59
|
-
`))return
|
|
60
|
-
${
|
|
61
|
-
${
|
|
62
|
-
${
|
|
63
|
-
`:"",
|
|
64
|
-
${
|
|
65
|
-
`&&
|
|
66
|
-
|
|
67
|
-
`}else
|
|
68
|
-
${
|
|
69
|
-
`),
|
|
70
|
-
${
|
|
71
|
-
`)
|
|
72
|
-
${
|
|
73
|
-
`}}if($){if(
|
|
74
|
-
`+
|
|
75
|
-
`)))U=!0;
|
|
76
|
-
${
|
|
77
|
-
`;return`${
|
|
78
|
-
${
|
|
79
|
-
`:" ")}return
|
|
80
|
-
${
|
|
81
|
-
${H.comment}`:X.comment}X=Z}$.items[z]=x$.isPair(X)?X:new cq.Pair(X)}else q("Expected a sequence for this tag");return $}function Q9($,q,z){let{replacer:X}=z,Z=new vZ.YAMLSeq($);Z.tag="tag:yaml.org,2002:pairs";let H=0;if(q&&Symbol.iterator in Object(q))for(let Q of q){if(typeof X==="function")Q=X.call(q,String(H++),Q);let J,G;if(Array.isArray(Q))if(Q.length===2)J=Q[0],G=Q[1];else throw TypeError(`Expected [key, value] tuple: ${Q}`);else if(Q&&Q instanceof Object){let U=Object.keys(Q);if(U.length===1)J=U[0],G=Q[J];else throw TypeError(`Expected tuple with one key, not ${U.length} keys`)}else J=Q;Z.items.push(cq.createPair(J,G,z))}return Z}var uZ={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:H9,createNode:Q9};mZ.createPairs=Q9;mZ.pairs=uZ;mZ.resolvePairs=H9});var aq=I((aZ)=>{var J9=A(),iq=o(),s0=z0(),cZ=X0(),U9=h$();class G0 extends cZ.YAMLSeq{constructor(){super();this.add=s0.YAMLMap.prototype.add.bind(this),this.delete=s0.YAMLMap.prototype.delete.bind(this),this.get=s0.YAMLMap.prototype.get.bind(this),this.has=s0.YAMLMap.prototype.has.bind(this),this.set=s0.YAMLMap.prototype.set.bind(this),this.tag=G0.tag}toJSON($,q){if(!q)return super.toJSON($);let z=new Map;if(q?.onCreate)q.onCreate(z);for(let X of this.items){let Z,H;if(J9.isPair(X))Z=iq.toJS(X.key,"",q),H=iq.toJS(X.value,Z,q);else Z=iq.toJS(X,"",q);if(z.has(Z))throw Error("Ordered maps must not include duplicate keys");z.set(Z,H)}return z}static from($,q,z){let X=U9.createPairs($,q,z),Z=new this;return Z.items=X.items,Z}}G0.tag="tag:yaml.org,2002:omap";var iZ={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:G0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,q){let z=U9.resolvePairs($,q),X=[];for(let{key:Z}of z.items)if(J9.isScalar(Z))if(X.includes(Z.value))q(`Ordered maps must not include duplicate keys: ${Z.value}`);else X.push(Z.value);return Object.assign(new G0,z)},createNode:($,q,z)=>G0.from($,q,z)};aZ.YAMLOMap=G0;aZ.omap=iZ});var T9=I((nZ)=>{var G9=y();function Y9({value:$,source:q},z){if(q&&($?B9:W9).test.test(q))return q;return $?z.options.trueStr:z.options.falseStr}var B9={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new G9.Scalar(!0),stringify:Y9},W9={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new G9.Scalar(!1),stringify:Y9};nZ.falseTag=W9;nZ.trueTag=B9});var L9=I((X6)=>{var eZ=y(),sq=K0(),$6={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:sq.stringifyNumber},q6={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($.replace(/_/g,"")),stringify($){let q=Number($.value);return isFinite(q)?q.toExponential():sq.stringifyNumber($)}},z6={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let q=new eZ.Scalar(parseFloat($.replace(/_/g,""))),z=$.indexOf(".");if(z!==-1){let X=$.substring(z+1).replace(/_/g,"");if(X[X.length-1]==="0")q.minFractionDigits=X.length}return q},stringify:sq.stringifyNumber};X6.float=z6;X6.floatExp=q6;X6.floatNaN=$6});var _9=I((B6)=>{var V9=K0(),r0=($)=>typeof $==="bigint"||Number.isInteger($);function g$($,q,z,{intAsBigInt:X}){let Z=$[0];if(Z==="-"||Z==="+")q+=1;if($=$.substring(q).replace(/_/g,""),X){switch(z){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let Q=BigInt($);return Z==="-"?BigInt(-1)*Q:Q}let H=parseInt($,z);return Z==="-"?-1*H:H}function rq($,q,z){let{value:X}=$;if(r0(X)){let Z=X.toString(q);return X<0?"-"+z+Z.substr(1):z+Z}return V9.stringifyNumber($)}var J6={identify:r0,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,q,z)=>g$($,2,2,z),stringify:($)=>rq($,2,"0b")},U6={identify:r0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,q,z)=>g$($,1,8,z),stringify:($)=>rq($,8,"0")},G6={identify:r0,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,q,z)=>g$($,0,10,z),stringify:V9.stringifyNumber},Y6={identify:r0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,q,z)=>g$($,2,16,z),stringify:($)=>rq($,16,"0x")};B6.int=G6;B6.intBin=J6;B6.intHex=Y6;B6.intOct=U6});var nq=I((I6)=>{var m$=A(),v$=$0(),u$=z0();class Y0 extends u$.YAMLMap{constructor($){super($);this.tag=Y0.tag}add($){let q;if(m$.isPair($))q=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)q=new v$.Pair($.key,null);else q=new v$.Pair($,null);if(!u$.findPair(this.items,q.key))this.items.push(q)}get($,q){let z=u$.findPair(this.items,$);return!q&&m$.isPair(z)?m$.isScalar(z.key)?z.key.value:z.key:z}set($,q){if(typeof q!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof q}`);let z=u$.findPair(this.items,$);if(z&&!q)this.items.splice(this.items.indexOf(z),1);else if(!z&&q)this.items.push(new v$.Pair($))}toJSON($,q){return super.toJSON($,q,Set)}toString($,q,z){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),q,z);else throw Error("Set items must all have null values")}static from($,q,z){let{replacer:X}=z,Z=new this($);if(q&&Symbol.iterator in Object(q))for(let H of q){if(typeof X==="function")H=X.call(q,H,H);Z.items.push(v$.createPair(H,null,z))}return Z}}Y0.tag="tag:yaml.org,2002:set";var _6={collection:"map",identify:($)=>$ instanceof Set,nodeClass:Y0,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,q,z)=>Y0.from($,q,z),resolve($,q){if(m$.isMap($))if($.hasAllNullValues(!0))return Object.assign(new Y0,$);else q("Set items must all have null values");else q("Expected a mapping for this tag");return $}};I6.YAMLSet=Y0;I6.set=_6});var tq=I((K6)=>{var M6=K0();function oq($,q){let z=$[0],X=z==="-"||z==="+"?$.substring(1):$,Z=(Q)=>q?BigInt(Q):Number(Q),H=X.replace(/_/g,"").split(":").reduce((Q,J)=>Q*Z(60)+Z(J),Z(0));return z==="-"?Z(-1)*H:H}function I9($){let{value:q}=$,z=(Q)=>Q;if(typeof q==="bigint")z=(Q)=>BigInt(Q);else if(isNaN(q)||!isFinite(q))return M6.stringifyNumber($);let X="";if(q<0)X="-",q*=z(-1);let Z=z(60),H=[q%Z];if(q<60)H.unshift(0);else if(q=(q-H[0])/Z,H.unshift(q%Z),q>=60)q=(q-H[0])/Z,H.unshift(q);return X+H.map((Q)=>String(Q).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var w6={identify:($)=>typeof $==="bigint"||Number.isInteger($),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:($,q,{intAsBigInt:z})=>oq($,z),stringify:I9},P6={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:($)=>oq($,!1),stringify:I9},D9={identify:($)=>$ instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve($){let q=$.match(D9.test);if(!q)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,z,X,Z,H,Q,J]=q.map(Number),G=q[7]?Number((q[7]+"00").substr(1,3)):0,U=Date.UTC(z,X-1,Z,H||0,Q||0,J||0,G),B=q[8];if(B&&B!=="Z"){let Y=oq(B,!1);if(Math.abs(Y)<30)Y*=60;U-=60000*Y}return new Date(U)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};K6.floatTime=P6;K6.intTime=w6;K6.timestamp=D9});var M9=I((h6)=>{var j6=w0(),S6=y$(),N6=P0(),E6=i0(),b6=lq(),R9=T9(),eq=L9(),d$=_9(),C6=F$(),y6=aq(),f6=h$(),k6=nq(),$1=tq(),x6=[j6.map,N6.seq,E6.string,S6.nullTag,R9.trueTag,R9.falseTag,d$.intBin,d$.intOct,d$.int,d$.intHex,eq.floatNaN,eq.floatExp,eq.float,b6.binary,C6.merge,y6.omap,f6.pairs,k6.set,$1.intTime,$1.floatTime,$1.timestamp];h6.schema=x6});var E9=I((i6)=>{var O9=w0(),v6=y$(),F9=P0(),u6=i0(),m6=xq(),q1=gq(),z1=uq(),d6=z9(),p6=Z9(),A9=lq(),n0=F$(),j9=aq(),S9=h$(),w9=M9(),N9=nq(),p$=tq(),P9=new Map([["core",d6.schema],["failsafe",[O9.map,F9.seq,u6.string]],["json",p6.schema],["yaml11",w9.schema],["yaml-1.1",w9.schema]]),K9={binary:A9.binary,bool:m6.boolTag,float:q1.float,floatExp:q1.floatExp,floatNaN:q1.floatNaN,floatTime:p$.floatTime,int:z1.int,intHex:z1.intHex,intOct:z1.intOct,intTime:p$.intTime,map:O9.map,merge:n0.merge,null:v6.nullTag,omap:j9.omap,pairs:S9.pairs,seq:F9.seq,set:N9.set,timestamp:p$.timestamp},l6={"tag:yaml.org,2002:binary":A9.binary,"tag:yaml.org,2002:merge":n0.merge,"tag:yaml.org,2002:omap":j9.omap,"tag:yaml.org,2002:pairs":S9.pairs,"tag:yaml.org,2002:set":N9.set,"tag:yaml.org,2002:timestamp":p$.timestamp};function c6($,q,z){let X=P9.get(q);if(X&&!$)return z&&!X.includes(n0.merge)?X.concat(n0.merge):X.slice();let Z=X;if(!Z)if(Array.isArray($))Z=[];else{let H=Array.from(P9.keys()).filter((Q)=>Q!=="yaml11").map((Q)=>JSON.stringify(Q)).join(", ");throw Error(`Unknown schema "${q}"; use one of ${H} or define customTags array`)}if(Array.isArray($))for(let H of $)Z=Z.concat(H);else if(typeof $==="function")Z=$(Z.slice());if(z)Z=Z.concat(n0.merge);return Z.reduce((H,Q)=>{let J=typeof Q==="string"?K9[Q]:Q;if(!J){let G=JSON.stringify(Q),U=Object.keys(K9).map((B)=>JSON.stringify(B)).join(", ");throw Error(`Unknown custom tag ${G}; use one of ${U}`)}if(!H.includes(J))H.push(J);return H},[])}i6.coreKnownTags=l6;i6.getTags=c6});var H1=I((e6)=>{var X1=A(),r6=w0(),n6=P0(),o6=i0(),l$=E9(),t6=($,q)=>$.key<q.key?-1:$.key>q.key?1:0;class Z1{constructor({compat:$,customTags:q,merge:z,resolveKnownTags:X,schema:Z,sortMapEntries:H,toStringDefaults:Q}){this.compat=Array.isArray($)?l$.getTags($,"compat"):$?l$.getTags(null,$):null,this.name=typeof Z==="string"&&Z||"core",this.knownTags=X?l$.coreKnownTags:{},this.tags=l$.getTags(q,this.name,z),this.toStringOptions=Q??null,Object.defineProperty(this,X1.MAP,{value:r6.map}),Object.defineProperty(this,X1.SCALAR,{value:o6.string}),Object.defineProperty(this,X1.SEQ,{value:n6.seq}),this.sortMapEntries=typeof H==="function"?H:H===!0?t6:null}clone(){let $=Object.create(Z1.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}e6.Schema=Z1});var b9=I((XH)=>{var qH=A(),Q1=d0(),o0=v0();function zH($,q){let z=[],X=q.directives===!0;if(q.directives!==!1&&$.directives){let G=$.directives.toString($);if(G)z.push(G),X=!0;else if($.directives.docStart)X=!0}if(X)z.push("---");let Z=Q1.createStringifyContext($,q),{commentString:H}=Z.options;if($.commentBefore){if(z.length!==1)z.unshift("");let G=H($.commentBefore);z.unshift(o0.indentComment(G,""))}let Q=!1,J=null;if($.contents){if(qH.isNode($.contents)){if($.contents.spaceBefore&&X)z.push("");if($.contents.commentBefore){let B=H($.contents.commentBefore);z.push(o0.indentComment(B,""))}Z.forceBlockIndent=!!$.comment,J=$.contents.comment}let G=J?void 0:()=>Q=!0,U=Q1.stringify($.contents,Z,()=>J=null,G);if(J)U+=o0.lineComment(U,"",H(J));if((U[0]==="|"||U[0]===">")&&z[z.length-1]==="---")z[z.length-1]=`--- ${U}`;else z.push(U)}else z.push(Q1.stringify($.contents,Z));if($.directives?.docEnd)if($.comment){let G=H($.comment);if(G.includes(`
|
|
82
|
-
`))
|
|
49
|
+
`;let H,V;for(V=Z.length;V>0;--V){let R=Z[V-1];if(R!==`
|
|
50
|
+
`&&R!=="\t"&&R!==" ")break}let B=Z.substring(V),L=B.indexOf(`
|
|
51
|
+
`);if(L===-1)H="-";else if(Z===B||L!==B.length-1){if(H="+",J)J()}else H="";if(B){if(Z=Z.slice(0,-B.length),B[B.length-1]===`
|
|
52
|
+
`)B=B.slice(0,-1);B=B.replace(Q9,`$&${U}`)}let T=!1,K,_=-1;for(K=0;K<Z.length;++K){let R=Z[K];if(R===" ")T=!0;else if(R===`
|
|
53
|
+
`)_=K;else break}let F=Z.substring(0,_<K?_+1:K);if(F)Z=Z.substring(F.length),F=F.replace(/\n+/g,`$&${U}`);let I=(T?U?"2":"1":"")+H;if($){if(I+=" "+Q($.replace(/ ?[\r\n]+/g," ")),q)q()}if(!W){let R=Z.replace(/\n+/g,`
|
|
54
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${U}`),N=!1,E=R1(z,!0);if(G!=="folded"&&X!==$0.Scalar.BLOCK_FOLDED)E.onOverflow=()=>{N=!0};let M=L0.foldFlowLines(`${F}${R}${B}`,U,L0.FOLD_BLOCK,E);if(!N)return`>${I}
|
|
55
|
+
${U}${M}`}return Z=Z.replace(/\n+/g,`$&${U}`),`|${I}
|
|
56
|
+
${U}${F}${Z}${B}`}function H3($,X,Z,z){let{type:q,value:J}=$,{actualString:G,implicitKey:Q,indent:Y,indentStep:U,inFlow:W}=X;if(Q&&J.includes(`
|
|
57
|
+
`)||W&&/[[\]{},]/.test(J))return s0(J,X);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(J))return Q||W||!J.includes(`
|
|
58
|
+
`)?s0(J,X):I1($,X,Z,z);if(!Q&&!W&&q!==$0.Scalar.PLAIN&&J.includes(`
|
|
59
|
+
`))return I1($,X,Z,z);if(P1(J)){if(Y==="")return X.forceBlockIndent=!0,I1($,X,Z,z);else if(Q&&Y===U)return s0(J,X)}let H=J.replace(/\n+/g,`$&
|
|
60
|
+
${Y}`);if(G){let V=(T)=>T.default&&T.tag!=="tag:yaml.org,2002:str"&&T.test?.test(H),{compat:B,tags:L}=X.doc.schema;if(L.some(V)||B?.some(V))return s0(J,X)}return Q?H:L0.foldFlowLines(H,Y,L0.FOLD_FLOW,R1(X,!1))}function W3($,X,Z,z){let{implicitKey:q,inFlow:J}=X,G=typeof $.value==="string"?$:Object.assign({},$,{value:String($.value)}),{type:Q}=$;if(Q!==$0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(G.value))Q=$0.Scalar.QUOTE_DOUBLE}let Y=(W)=>{switch(W){case $0.Scalar.BLOCK_FOLDED:case $0.Scalar.BLOCK_LITERAL:return q||J?s0(G.value,X):I1(G,X,Z,z);case $0.Scalar.QUOTE_DOUBLE:return P$(G.value,X);case $0.Scalar.QUOTE_SINGLE:return G9(G.value,X);case $0.Scalar.PLAIN:return H3(G,X,Z,z);default:return null}},U=Y(Q);if(U===null){let{defaultKeyType:W,defaultStringType:H}=X.options,V=q&&W||H;if(U=Y(V),U===null)throw Error(`Unsupported default string type ${V}`)}return U}V3.stringifyString=W3});var A$=D((O3)=>{var B3=F1(),D0=S(),K3=R$(),L3=N$();function D3($,X){let Z=Object.assign({blockQuote:!0,commentString:K3.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},$.schema.toStringOptions,X),z;switch(Z.collectionStyle){case"block":z=!1;break;case"flow":z=!0;break;default:z=null}return{anchors:new Set,doc:$,flowCollectionPadding:Z.flowCollectionPadding?" ":"",indent:"",indentStep:typeof Z.indent==="number"?" ".repeat(Z.indent):" ",inFlow:z,options:Z}}function _3($,X){if(X.tag){let q=$.filter((J)=>J.tag===X.tag);if(q.length>0)return q.find((J)=>J.format===X.format)??q[0]}let Z=void 0,z;if(D0.isScalar(X)){z=X.value;let q=$.filter((J)=>J.identify?.(z));if(q.length>1){let J=q.filter((G)=>G.test);if(J.length>0)q=J}Z=q.find((J)=>J.format===X.format)??q.find((J)=>!J.format)}else z=X,Z=$.find((q)=>q.nodeClass&&z instanceof q.nodeClass);if(!Z){let q=z?.constructor?.name??(z===null?"null":typeof z);throw Error(`Tag not resolved for ${q} value`)}return Z}function F3($,X,{anchors:Z,doc:z}){if(!z.directives)return"";let q=[],J=(D0.isScalar($)||D0.isCollection($))&&$.anchor;if(J&&B3.anchorIsValid(J))Z.add(J),q.push(`&${J}`);let G=$.tag??(X.default?null:X.tag);if(G)q.push(z.directives.tagString(G));return q.join(" ")}function M3($,X,Z,z){if(D0.isPair($))return $.toString(X,Z,z);if(D0.isAlias($)){if(X.doc.directives)return $.toString(X);if(X.resolvedAliases?.has($))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(X.resolvedAliases)X.resolvedAliases.add($);else X.resolvedAliases=new Set([$]);$=$.resolve(X.doc)}}let q=void 0,J=D0.isNode($)?$:X.doc.createNode($,{onTagObj:(Y)=>q=Y});q??(q=_3(X.doc.schema.tags,J));let G=F3(J,q,X);if(G.length>0)X.indentAtStart=(X.indentAtStart??0)+G.length+1;let Q=typeof q.stringify==="function"?q.stringify(J,X,Z,z):D0.isScalar(J)?L3.stringifyString(J,X,Z,z):J.toString(X,Z,z);if(!G)return Q;return D0.isScalar(J)||Q[0]==="{"||Q[0]==="["?`${G} ${Q}`:`${G}
|
|
61
|
+
${X.indent}${Q}`}O3.createStringifyContext=D3;O3.stringify=M3});var hX=D((P3)=>{var H0=S(),fX=g(),gX=A$(),j$=R$();function R3({key:$,value:X},Z,z,q){let{allNullValues:J,doc:G,indent:Q,indentStep:Y,options:{commentString:U,indentSeq:W,simpleKeys:H}}=Z,V=H0.isNode($)&&$.comment||null;if(H){if(V)throw Error("With simple keys, key nodes cannot have comments");if(H0.isCollection($)||!H0.isNode($)&&typeof $==="object")throw Error("With simple keys, collection cannot be used as a key value")}let B=!H&&(!$||V&&X==null&&!Z.inFlow||H0.isCollection($)||(H0.isScalar($)?$.type===fX.Scalar.BLOCK_FOLDED||$.type===fX.Scalar.BLOCK_LITERAL:typeof $==="object"));Z=Object.assign({},Z,{allNullValues:!1,implicitKey:!B&&(H||!J),indent:Q+Y});let L=!1,T=!1,K=gX.stringify($,Z,()=>L=!0,()=>T=!0);if(!B&&!Z.inFlow&&K.length>1024){if(H)throw Error("With simple keys, single line scalar must not span more than 1024 characters");B=!0}if(Z.inFlow){if(J||X==null){if(L&&z)z();return K===""?"?":B?`? ${K}`:K}}else if(J&&!H||X==null&&B){if(K=`? ${K}`,V&&!L)K+=j$.lineComment(K,Z.indent,U(V));else if(T&&q)q();return K}if(L)V=null;if(B){if(V)K+=j$.lineComment(K,Z.indent,U(V));K=`? ${K}
|
|
62
|
+
${Q}:`}else if(K=`${K}:`,V)K+=j$.lineComment(K,Z.indent,U(V));let _,F,O;if(H0.isNode(X))_=!!X.spaceBefore,F=X.commentBefore,O=X.comment;else if(_=!1,F=null,O=null,X&&typeof X==="object")X=G.createNode(X);if(Z.implicitKey=!1,!B&&!V&&H0.isScalar(X))Z.indentAtStart=K.length+1;if(T=!1,!W&&Y.length>=2&&!Z.inFlow&&!B&&H0.isSeq(X)&&!X.flow&&!X.tag&&!X.anchor)Z.indent=Z.indent.substring(2);let I=!1,R=gX.stringify(X,Z,()=>I=!0,()=>T=!0),N=" ";if(V||_||F){if(N=_?`
|
|
63
|
+
`:"",F){let E=U(F);N+=`
|
|
64
|
+
${j$.indentComment(E,Z.indent)}`}if(R===""&&!Z.inFlow){if(N===`
|
|
65
|
+
`&&O)N=`
|
|
66
|
+
|
|
67
|
+
`}else N+=`
|
|
68
|
+
${Z.indent}`}else if(!B&&H0.isCollection(X)){let E=R[0],M=R.indexOf(`
|
|
69
|
+
`),x=M!==-1,a=Z.inFlow??X.flow??X.items.length===0;if(x||!a){let z0=!1;if(x&&(E==="&"||E==="!")){let f=R.indexOf(" ");if(E==="&"&&f!==-1&&f<M&&R[f+1]==="!")f=R.indexOf(" ",f+1);if(f===-1||M<f)z0=!0}if(!z0)N=`
|
|
70
|
+
${Z.indent}`}}else if(R===""||R[0]===`
|
|
71
|
+
`)N="";if(K+=N+R,Z.inFlow){if(I&&z)z()}else if(O&&!I)K+=j$.lineComment(K,Z.indent,U(O));else if(T&&q)q();return K}P3.stringifyPair=R3});var Y9=D((S3)=>{var vX=Q0("process");function A3($,...X){if($==="debug")console.log(...X)}function j3($,X){if($==="debug"||$==="warn")if(typeof vX.emitWarning==="function")vX.emitWarning(X);else console.warn(X)}S3.debug=A3;S3.warn=j3});var j1=D((x3)=>{var S$=S(),uX=g(),N1="<<",A1={identify:($)=>$===N1||typeof $==="symbol"&&$.description===N1,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new uX.Scalar(Symbol(N1)),{addToJSMap:mX}),stringify:()=>N1},b3=($,X)=>(A1.identify(X)||S$.isScalar(X)&&(!X.type||X.type===uX.Scalar.PLAIN)&&A1.identify(X.value))&&$?.doc.schema.tags.some((Z)=>Z.tag===A1.tag&&Z.default);function mX($,X,Z){if(Z=$&&S$.isAlias(Z)?Z.resolve($.doc):Z,S$.isSeq(Z))for(let z of Z.items)U9($,X,z);else if(Array.isArray(Z))for(let z of Z)U9($,X,z);else U9($,X,Z)}function U9($,X,Z){let z=$&&S$.isAlias(Z)?Z.resolve($.doc):Z;if(!S$.isMap(z))throw Error("Merge sources must be maps or map aliases");let q=z.toJSON(null,$,Map);for(let[J,G]of q)if(X instanceof Map){if(!X.has(J))X.set(J,G)}else if(X instanceof Set)X.add(J);else if(!Object.prototype.hasOwnProperty.call(X,J))Object.defineProperty(X,J,{value:G,writable:!0,enumerable:!0,configurable:!0});return X}x3.addMergeToJSMap=mX;x3.isMergeKey=b3;x3.merge=A1});var W9=D((m3)=>{var g3=Y9(),dX=j1(),h3=A$(),pX=S(),H9=K0();function v3($,X,{key:Z,value:z}){if(pX.isNode(Z)&&Z.addToJSMap)Z.addToJSMap($,X,z);else if(dX.isMergeKey($,Z))dX.addMergeToJSMap($,X,z);else{let q=H9.toJS(Z,"",$);if(X instanceof Map)X.set(q,H9.toJS(z,q,$));else if(X instanceof Set)X.add(q);else{let J=u3(Z,q,$),G=H9.toJS(z,J,$);if(J in X)Object.defineProperty(X,J,{value:G,writable:!0,enumerable:!0,configurable:!0});else X[J]=G}}return X}function u3($,X,Z){if(X===null)return"";if(typeof X!=="object")return String(X);if(pX.isNode($)&&Z?.doc){let z=h3.createStringifyContext(Z.doc,{});z.anchors=new Set;for(let J of Z.anchors.keys())z.anchors.add(J.anchor);z.inFlow=!0,z.inStringifyKey=!0;let q=$.toString(z);if(!Z.mapKeyWarned){let J=JSON.stringify(q);if(J.length>40)J=J.substring(0,36)+'..."';g3.warn(Z.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${J}. Set mapAsMap: true to use object keys.`),Z.mapKeyWarned=!0}return q}return JSON.stringify(X)}m3.addPairToJSMap=v3});var _0=D((i3)=>{var lX=I$(),p3=hX(),l3=W9(),S1=S();function c3($,X,Z){let z=lX.createNode($,void 0,Z),q=lX.createNode(X,void 0,Z);return new C1(z,q)}class C1{constructor($,X=null){Object.defineProperty(this,S1.NODE_TYPE,{value:S1.PAIR}),this.key=$,this.value=X}clone($){let{key:X,value:Z}=this;if(S1.isNode(X))X=X.clone($);if(S1.isNode(Z))Z=Z.clone($);return new C1(X,Z)}toJSON($,X){let Z=X?.mapAsMap?new Map:{};return l3.addPairToJSMap(X,Z,this)}toString($,X,Z){return $?.doc?p3.stringifyPair(this,$,X,Z):JSON.stringify(this)}}i3.Pair=C1;i3.createPair=c3});var V9=D((t3)=>{var C0=S(),cX=A$(),E1=R$();function n3($,X,Z){return(X.inFlow??$.flow?o3:r3)($,X,Z)}function r3({comment:$,items:X},Z,{blockItemPrefix:z,flowChars:q,itemIndent:J,onChompKeep:G,onComment:Q}){let{indent:Y,options:{commentString:U}}=Z,W=Object.assign({},Z,{indent:J,type:null}),H=!1,V=[];for(let L=0;L<X.length;++L){let T=X[L],K=null;if(C0.isNode(T)){if(!H&&T.spaceBefore)V.push("");if(b1(Z,V,T.commentBefore,H),T.comment)K=T.comment}else if(C0.isPair(T)){let F=C0.isNode(T.key)?T.key:null;if(F){if(!H&&F.spaceBefore)V.push("");b1(Z,V,F.commentBefore,H)}}H=!1;let _=cX.stringify(T,W,()=>K=null,()=>H=!0);if(K)_+=E1.lineComment(_,J,U(K));if(H&&K)H=!1;V.push(z+_)}let B;if(V.length===0)B=q.start+q.end;else{B=V[0];for(let L=1;L<V.length;++L){let T=V[L];B+=T?`
|
|
72
|
+
${Y}${T}`:`
|
|
73
|
+
`}}if($){if(B+=`
|
|
74
|
+
`+E1.indentComment(U($),Y),Q)Q()}else if(H&&G)G();return B}function o3({items:$},X,{flowChars:Z,itemIndent:z}){let{indent:q,indentStep:J,flowCollectionPadding:G,options:{commentString:Q}}=X;z+=J;let Y=Object.assign({},X,{indent:z,inFlow:!0,type:null}),U=!1,W=0,H=[];for(let L=0;L<$.length;++L){let T=$[L],K=null;if(C0.isNode(T)){if(T.spaceBefore)H.push("");if(b1(X,H,T.commentBefore,!1),T.comment)K=T.comment}else if(C0.isPair(T)){let F=C0.isNode(T.key)?T.key:null;if(F){if(F.spaceBefore)H.push("");if(b1(X,H,F.commentBefore,!1),F.comment)U=!0}let O=C0.isNode(T.value)?T.value:null;if(O){if(O.comment)K=O.comment;if(O.commentBefore)U=!0}else if(T.value==null&&F?.comment)K=F.comment}if(K)U=!0;let _=cX.stringify(T,Y,()=>K=null);if(L<$.length-1)_+=",";if(K)_+=E1.lineComment(_,z,Q(K));if(!U&&(H.length>W||_.includes(`
|
|
75
|
+
`)))U=!0;H.push(_),W=H.length}let{start:V,end:B}=Z;if(H.length===0)return V+B;else{if(!U){let L=H.reduce((T,K)=>T+K.length+2,2);U=X.options.lineWidth>0&&L>X.options.lineWidth}if(U){let L=V;for(let T of H)L+=T?`
|
|
76
|
+
${J}${q}${T}`:`
|
|
77
|
+
`;return`${L}
|
|
78
|
+
${q}${B}`}else return`${V}${G}${H.join(" ")}${G}${B}`}}function b1({indent:$,options:{commentString:X}},Z,z,q){if(z&&q)z=z.replace(/^\n+/,"");if(z){let J=E1.indentComment(X(z),$);Z.push(J.trimStart())}}t3.stringifyCollection=n3});var M0=D((q7)=>{var $7=V9(),X7=W9(),Z7=w1(),F0=S(),x1=_0(),z7=g();function C$($,X){let Z=F0.isScalar(X)?X.value:X;for(let z of $)if(F0.isPair(z)){if(z.key===X||z.key===Z)return z;if(F0.isScalar(z.key)&&z.key.value===Z)return z}return}class iX extends Z7.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor($){super(F0.MAP,$);this.items=[]}static from($,X,Z){let{keepUndefined:z,replacer:q}=Z,J=new this($),G=(Q,Y)=>{if(typeof q==="function")Y=q.call(X,Q,Y);else if(Array.isArray(q)&&!q.includes(Q))return;if(Y!==void 0||z)J.items.push(x1.createPair(Q,Y,Z))};if(X instanceof Map)for(let[Q,Y]of X)G(Q,Y);else if(X&&typeof X==="object")for(let Q of Object.keys(X))G(Q,X[Q]);if(typeof $.sortMapEntries==="function")J.items.sort($.sortMapEntries);return J}add($,X){let Z;if(F0.isPair($))Z=$;else if(!$||typeof $!=="object"||!("key"in $))Z=new x1.Pair($,$?.value);else Z=new x1.Pair($.key,$.value);let z=C$(this.items,Z.key),q=this.schema?.sortMapEntries;if(z){if(!X)throw Error(`Key ${Z.key} already set`);if(F0.isScalar(z.value)&&z7.isScalarValue(Z.value))z.value.value=Z.value;else z.value=Z.value}else if(q){let J=this.items.findIndex((G)=>q(Z,G)<0);if(J===-1)this.items.push(Z);else this.items.splice(J,0,Z)}else this.items.push(Z)}delete($){let X=C$(this.items,$);if(!X)return!1;return this.items.splice(this.items.indexOf(X),1).length>0}get($,X){let z=C$(this.items,$)?.value;return(!X&&F0.isScalar(z)?z.value:z)??void 0}has($){return!!C$(this.items,$)}set($,X){this.add(new x1.Pair($,X),!0)}toJSON($,X,Z){let z=Z?new Z:X?.mapAsMap?new Map:{};if(X?.onCreate)X.onCreate(z);for(let q of this.items)X7.addPairToJSMap(X,z,q);return z}toString($,X,Z){if(!$)return JSON.stringify(this);for(let z of this.items)if(!F0.isPair(z))throw Error(`Map items must all be pairs; found ${JSON.stringify(z)} instead`);if(!$.allNullValues&&this.hasAllNullValues(!1))$=Object.assign({},$,{allNullValues:!0});return $7.stringifyCollection(this,$,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:$.indent||"",onChompKeep:Z,onComment:X})}}q7.YAMLMap=iX;q7.findPair=C$});var n0=D((U7)=>{var Q7=S(),aX=M0(),Y7={collection:"map",default:!0,nodeClass:aX.YAMLMap,tag:"tag:yaml.org,2002:map",resolve($,X){if(!Q7.isMap($))X("Expected a mapping for this tag");return $},createNode:($,X,Z)=>aX.YAMLMap.from($,X,Z)};U7.map=Y7});var O0=D((L7)=>{var W7=I$(),V7=V9(),T7=w1(),k1=S(),B7=g(),K7=K0();class sX extends T7.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor($){super(k1.SEQ,$);this.items=[]}add($){this.items.push($)}delete($){let X=y1($);if(typeof X!=="number")return!1;return this.items.splice(X,1).length>0}get($,X){let Z=y1($);if(typeof Z!=="number")return;let z=this.items[Z];return!X&&k1.isScalar(z)?z.value:z}has($){let X=y1($);return typeof X==="number"&&X<this.items.length}set($,X){let Z=y1($);if(typeof Z!=="number")throw Error(`Expected a valid index, not ${$}.`);let z=this.items[Z];if(k1.isScalar(z)&&B7.isScalarValue(X))z.value=X;else this.items[Z]=X}toJSON($,X){let Z=[];if(X?.onCreate)X.onCreate(Z);let z=0;for(let q of this.items)Z.push(K7.toJS(q,String(z++),X));return Z}toString($,X,Z){if(!$)return JSON.stringify(this);return V7.stringifyCollection(this,$,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:($.indent||"")+" ",onChompKeep:Z,onComment:X})}static from($,X,Z){let{replacer:z}=Z,q=new this($);if(X&&Symbol.iterator in Object(X)){let J=0;for(let G of X){if(typeof z==="function"){let Q=X instanceof Set?G:String(J++);G=z.call(X,Q,G)}q.items.push(W7.createNode(G,void 0,Z))}}return q}}function y1($){let X=k1.isScalar($)?$.value:$;if(X&&typeof X==="string")X=Number(X);return typeof X==="number"&&Number.isInteger(X)&&X>=0?X:null}L7.YAMLSeq=sX});var r0=D((M7)=>{var _7=S(),nX=O0(),F7={collection:"seq",default:!0,nodeClass:nX.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve($,X){if(!_7.isSeq($))X("Expected a sequence for this tag");return $},createNode:($,X,Z)=>nX.YAMLSeq.from($,X,Z)};M7.seq=F7});var E$=D((R7)=>{var w7=N$(),I7={identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify($,X,Z,z){return X=Object.assign({actualString:!0},X),w7.stringifyString($,X,Z,z)}};R7.string=I7});var f1=D((N7)=>{var rX=g(),oX={identify:($)=>$==null,createNode:()=>new rX.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new rX.Scalar(null),stringify:({source:$},X)=>typeof $==="string"&&oX.test.test($)?$:X.options.nullStr};N7.nullTag=oX});var T9=D((S7)=>{var j7=g(),tX={identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:($)=>new j7.Scalar($[0]==="t"||$[0]==="T"),stringify({source:$,value:X},Z){if($&&tX.test.test($)){let z=$[0]==="t"||$[0]==="T";if(X===z)return $}return X?Z.options.trueStr:Z.options.falseStr}};S7.boolTag=tX});var o0=D((b7)=>{function E7({format:$,minFractionDigits:X,tag:Z,value:z}){if(typeof z==="bigint")return String(z);let q=typeof z==="number"?z:Number(z);if(!isFinite(q))return isNaN(q)?".nan":q<0?"-.inf":".inf";let J=Object.is(z,-0)?"-0":JSON.stringify(z);if(!$&&X&&(!Z||Z==="tag:yaml.org,2002:float")&&/^\d/.test(J)){let G=J.indexOf(".");if(G<0)G=J.length,J+=".";let Q=X-(J.length-G-1);while(Q-- >0)J+="0"}return J}b7.stringifyNumber=E7});var K9=D((h7)=>{var y7=g(),B9=o0(),k7={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:B9.stringifyNumber},f7={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($),stringify($){let X=Number($.value);return isFinite(X)?X.toExponential():B9.stringifyNumber($)}},g7={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve($){let X=new y7.Scalar(parseFloat($)),Z=$.indexOf(".");if(Z!==-1&&$[$.length-1]==="0")X.minFractionDigits=$.length-Z-1;return X},stringify:B9.stringifyNumber};h7.float=g7;h7.floatExp=f7;h7.floatNaN=k7});var D9=D((c7)=>{var eX=o0(),g1=($)=>typeof $==="bigint"||Number.isInteger($),L9=($,X,Z,{intAsBigInt:z})=>z?BigInt($):parseInt($.substring(X),Z);function $5($,X,Z){let{value:z}=$;if(g1(z)&&z>=0)return Z+z.toString(X);return eX.stringifyNumber($)}var d7={identify:($)=>g1($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:($,X,Z)=>L9($,2,8,Z),stringify:($)=>$5($,8,"0o")},p7={identify:g1,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:($,X,Z)=>L9($,0,10,Z),stringify:eX.stringifyNumber},l7={identify:($)=>g1($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:($,X,Z)=>L9($,2,16,Z),stringify:($)=>$5($,16,"0x")};c7.int=p7;c7.intHex=l7;c7.intOct=d7});var X5=D((Xq)=>{var n7=n0(),r7=f1(),o7=r0(),t7=E$(),e7=T9(),_9=K9(),F9=D9(),$q=[n7.map,o7.seq,t7.string,r7.nullTag,e7.boolTag,F9.intOct,F9.int,F9.intHex,_9.floatNaN,_9.floatExp,_9.float];Xq.schema=$q});var z5=D((Uq)=>{var zq=g(),qq=n0(),Jq=r0();function Z5($){return typeof $==="bigint"||Number.isInteger($)}var h1=({value:$})=>JSON.stringify($),Gq=[{identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify:h1},{identify:($)=>$==null,createNode:()=>new zq.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:h1},{identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:($)=>$==="true",stringify:h1},{identify:Z5,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:($,X,{intAsBigInt:Z})=>Z?BigInt($):parseInt($,10),stringify:({value:$})=>Z5($)?$.toString():JSON.stringify($)},{identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:($)=>parseFloat($),stringify:h1}],Qq={default:!0,tag:"",test:/^/,resolve($,X){return X(`Unresolved plain scalar ${JSON.stringify($)}`),$}},Yq=[qq.map,Jq.seq].concat(Gq,Qq);Uq.schema=Yq});var O9=D((Tq)=>{var b$=Q0("buffer"),M9=g(),Wq=N$(),Vq={identify:($)=>$ instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve($,X){if(typeof b$.Buffer==="function")return b$.Buffer.from($,"base64");else if(typeof atob==="function"){let Z=atob($.replace(/[\n\r]/g,"")),z=new Uint8Array(Z.length);for(let q=0;q<Z.length;++q)z[q]=Z.charCodeAt(q);return z}else return X("This environment does not support reading binary tags; either Buffer or atob is required"),$},stringify({comment:$,type:X,value:Z},z,q,J){if(!Z)return"";let G=Z,Q;if(typeof b$.Buffer==="function")Q=G instanceof b$.Buffer?G.toString("base64"):b$.Buffer.from(G.buffer).toString("base64");else if(typeof btoa==="function"){let Y="";for(let U=0;U<G.length;++U)Y+=String.fromCharCode(G[U]);Q=btoa(Y)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(X??(X=M9.Scalar.BLOCK_LITERAL),X!==M9.Scalar.QUOTE_DOUBLE){let Y=Math.max(z.options.lineWidth-z.indent.length,z.options.minContentWidth),U=Math.ceil(Q.length/Y),W=Array(U);for(let H=0,V=0;H<U;++H,V+=Y)W[H]=Q.substr(V,Y);Q=W.join(X===M9.Scalar.BLOCK_LITERAL?`
|
|
79
|
+
`:" ")}return Wq.stringifyString({comment:$,type:X,value:Q},z,q,J)}};Tq.binary=Vq});var u1=D((_q)=>{var v1=S(),w9=_0(),Kq=g(),Lq=O0();function q5($,X){if(v1.isSeq($))for(let Z=0;Z<$.items.length;++Z){let z=$.items[Z];if(v1.isPair(z))continue;else if(v1.isMap(z)){if(z.items.length>1)X("Each pair must have its own sequence indicator");let q=z.items[0]||new w9.Pair(new Kq.Scalar(null));if(z.commentBefore)q.key.commentBefore=q.key.commentBefore?`${z.commentBefore}
|
|
80
|
+
${q.key.commentBefore}`:z.commentBefore;if(z.comment){let J=q.value??q.key;J.comment=J.comment?`${z.comment}
|
|
81
|
+
${J.comment}`:z.comment}z=q}$.items[Z]=v1.isPair(z)?z:new w9.Pair(z)}else X("Expected a sequence for this tag");return $}function J5($,X,Z){let{replacer:z}=Z,q=new Lq.YAMLSeq($);q.tag="tag:yaml.org,2002:pairs";let J=0;if(X&&Symbol.iterator in Object(X))for(let G of X){if(typeof z==="function")G=z.call(X,String(J++),G);let Q,Y;if(Array.isArray(G))if(G.length===2)Q=G[0],Y=G[1];else throw TypeError(`Expected [key, value] tuple: ${G}`);else if(G&&G instanceof Object){let U=Object.keys(G);if(U.length===1)Q=U[0],Y=G[Q];else throw TypeError(`Expected tuple with one key, not ${U.length} keys`)}else Q=G;q.items.push(w9.createPair(Q,Y,Z))}return q}var Dq={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:q5,createNode:J5};_q.createPairs=J5;_q.pairs=Dq;_q.resolvePairs=q5});var R9=D((Rq)=>{var G5=S(),I9=K0(),x$=M0(),wq=O0(),Q5=u1();class E0 extends wq.YAMLSeq{constructor(){super();this.add=x$.YAMLMap.prototype.add.bind(this),this.delete=x$.YAMLMap.prototype.delete.bind(this),this.get=x$.YAMLMap.prototype.get.bind(this),this.has=x$.YAMLMap.prototype.has.bind(this),this.set=x$.YAMLMap.prototype.set.bind(this),this.tag=E0.tag}toJSON($,X){if(!X)return super.toJSON($);let Z=new Map;if(X?.onCreate)X.onCreate(Z);for(let z of this.items){let q,J;if(G5.isPair(z))q=I9.toJS(z.key,"",X),J=I9.toJS(z.value,q,X);else q=I9.toJS(z,"",X);if(Z.has(q))throw Error("Ordered maps must not include duplicate keys");Z.set(q,J)}return Z}static from($,X,Z){let z=Q5.createPairs($,X,Z),q=new this;return q.items=z.items,q}}E0.tag="tag:yaml.org,2002:omap";var Iq={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:E0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,X){let Z=Q5.resolvePairs($,X),z=[];for(let{key:q}of Z.items)if(G5.isScalar(q))if(z.includes(q.value))X(`Ordered maps must not include duplicate keys: ${q.value}`);else z.push(q.value);return Object.assign(new E0,Z)},createNode:($,X,Z)=>E0.from($,X,Z)};Rq.YAMLOMap=E0;Rq.omap=Iq});var V5=D((Aq)=>{var Y5=g();function U5({value:$,source:X},Z){if(X&&($?H5:W5).test.test(X))return X;return $?Z.options.trueStr:Z.options.falseStr}var H5={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Y5.Scalar(!0),stringify:U5},W5={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Y5.Scalar(!1),stringify:U5};Aq.falseTag=W5;Aq.trueTag=H5});var T5=D((yq)=>{var Cq=g(),P9=o0(),Eq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:P9.stringifyNumber},bq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($.replace(/_/g,"")),stringify($){let X=Number($.value);return isFinite(X)?X.toExponential():P9.stringifyNumber($)}},xq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let X=new Cq.Scalar(parseFloat($.replace(/_/g,""))),Z=$.indexOf(".");if(Z!==-1){let z=$.substring(Z+1).replace(/_/g,"");if(z[z.length-1]==="0")X.minFractionDigits=z.length}return X},stringify:P9.stringifyNumber};yq.float=xq;yq.floatExp=bq;yq.floatNaN=Eq});var K5=D((dq)=>{var B5=o0(),y$=($)=>typeof $==="bigint"||Number.isInteger($);function m1($,X,Z,{intAsBigInt:z}){let q=$[0];if(q==="-"||q==="+")X+=1;if($=$.substring(X).replace(/_/g,""),z){switch(Z){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let G=BigInt($);return q==="-"?BigInt(-1)*G:G}let J=parseInt($,Z);return q==="-"?-1*J:J}function N9($,X,Z){let{value:z}=$;if(y$(z)){let q=z.toString(X);return z<0?"-"+Z+q.substr(1):Z+q}return B5.stringifyNumber($)}var hq={identify:y$,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,X,Z)=>m1($,2,2,Z),stringify:($)=>N9($,2,"0b")},vq={identify:y$,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,X,Z)=>m1($,1,8,Z),stringify:($)=>N9($,8,"0")},uq={identify:y$,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,X,Z)=>m1($,0,10,Z),stringify:B5.stringifyNumber},mq={identify:y$,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,X,Z)=>m1($,2,16,Z),stringify:($)=>N9($,16,"0x")};dq.int=uq;dq.intBin=hq;dq.intHex=mq;dq.intOct=vq});var A9=D((sq)=>{var l1=S(),d1=_0(),p1=M0();class b0 extends p1.YAMLMap{constructor($){super($);this.tag=b0.tag}add($){let X;if(l1.isPair($))X=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)X=new d1.Pair($.key,null);else X=new d1.Pair($,null);if(!p1.findPair(this.items,X.key))this.items.push(X)}get($,X){let Z=p1.findPair(this.items,$);return!X&&l1.isPair(Z)?l1.isScalar(Z.key)?Z.key.value:Z.key:Z}set($,X){if(typeof X!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof X}`);let Z=p1.findPair(this.items,$);if(Z&&!X)this.items.splice(this.items.indexOf(Z),1);else if(!Z&&X)this.items.push(new d1.Pair($))}toJSON($,X){return super.toJSON($,X,Set)}toString($,X,Z){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),X,Z);else throw Error("Set items must all have null values")}static from($,X,Z){let{replacer:z}=Z,q=new this($);if(X&&Symbol.iterator in Object(X))for(let J of X){if(typeof z==="function")J=z.call(X,J,J);q.items.push(d1.createPair(J,null,Z))}return q}}b0.tag="tag:yaml.org,2002:set";var aq={collection:"map",identify:($)=>$ instanceof Set,nodeClass:b0,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,X,Z)=>b0.from($,X,Z),resolve($,X){if(l1.isMap($))if($.hasAllNullValues(!0))return Object.assign(new b0,$);else X("Set items must all have null values");else X("Expected a mapping for this tag");return $}};sq.YAMLSet=b0;sq.set=aq});var S9=D(($J)=>{var oq=o0();function j9($,X){let Z=$[0],z=Z==="-"||Z==="+"?$.substring(1):$,q=(G)=>X?BigInt(G):Number(G),J=z.replace(/_/g,"").split(":").reduce((G,Q)=>G*q(60)+q(Q),q(0));return Z==="-"?q(-1)*J:J}function L5($){let{value:X}=$,Z=(G)=>G;if(typeof X==="bigint")Z=(G)=>BigInt(G);else if(isNaN(X)||!isFinite(X))return oq.stringifyNumber($);let z="";if(X<0)z="-",X*=Z(-1);let q=Z(60),J=[X%q];if(X<60)J.unshift(0);else if(X=(X-J[0])/q,J.unshift(X%q),X>=60)X=(X-J[0])/q,J.unshift(X);return z+J.map((G)=>String(G).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var tq={identify:($)=>typeof $==="bigint"||Number.isInteger($),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:($,X,{intAsBigInt:Z})=>j9($,Z),stringify:L5},eq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:($)=>j9($,!1),stringify:L5},D5={identify:($)=>$ instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve($){let X=$.match(D5.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,Z,z,q,J,G,Q]=X.map(Number),Y=X[7]?Number((X[7]+"00").substr(1,3)):0,U=Date.UTC(Z,z-1,q,J||0,G||0,Q||0,Y),W=X[8];if(W&&W!=="Z"){let H=j9(W,!1);if(Math.abs(H)<30)H*=60;U-=60000*H}return new Date(U)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};$J.floatTime=eq;$J.intTime=tq;$J.timestamp=D5});var F5=D((BJ)=>{var qJ=n0(),JJ=f1(),GJ=r0(),QJ=E$(),YJ=O9(),_5=V5(),C9=T5(),c1=K5(),UJ=j1(),HJ=R9(),WJ=u1(),VJ=A9(),E9=S9(),TJ=[qJ.map,GJ.seq,QJ.string,JJ.nullTag,_5.trueTag,_5.falseTag,c1.intBin,c1.intOct,c1.int,c1.intHex,C9.floatNaN,C9.floatExp,C9.float,YJ.binary,UJ.merge,HJ.omap,WJ.pairs,VJ.set,E9.intTime,E9.floatTime,E9.timestamp];BJ.schema=TJ});var S5=D((IJ)=>{var I5=n0(),LJ=f1(),R5=r0(),DJ=E$(),_J=T9(),b9=K9(),x9=D9(),FJ=X5(),MJ=z5(),P5=O9(),k$=j1(),N5=R9(),A5=u1(),M5=F5(),j5=A9(),i1=S9(),O5=new Map([["core",FJ.schema],["failsafe",[I5.map,R5.seq,DJ.string]],["json",MJ.schema],["yaml11",M5.schema],["yaml-1.1",M5.schema]]),w5={binary:P5.binary,bool:_J.boolTag,float:b9.float,floatExp:b9.floatExp,floatNaN:b9.floatNaN,floatTime:i1.floatTime,int:x9.int,intHex:x9.intHex,intOct:x9.intOct,intTime:i1.intTime,map:I5.map,merge:k$.merge,null:LJ.nullTag,omap:N5.omap,pairs:A5.pairs,seq:R5.seq,set:j5.set,timestamp:i1.timestamp},OJ={"tag:yaml.org,2002:binary":P5.binary,"tag:yaml.org,2002:merge":k$.merge,"tag:yaml.org,2002:omap":N5.omap,"tag:yaml.org,2002:pairs":A5.pairs,"tag:yaml.org,2002:set":j5.set,"tag:yaml.org,2002:timestamp":i1.timestamp};function wJ($,X,Z){let z=O5.get(X);if(z&&!$)return Z&&!z.includes(k$.merge)?z.concat(k$.merge):z.slice();let q=z;if(!q)if(Array.isArray($))q=[];else{let J=Array.from(O5.keys()).filter((G)=>G!=="yaml11").map((G)=>JSON.stringify(G)).join(", ");throw Error(`Unknown schema "${X}"; use one of ${J} or define customTags array`)}if(Array.isArray($))for(let J of $)q=q.concat(J);else if(typeof $==="function")q=$(q.slice());if(Z)q=q.concat(k$.merge);return q.reduce((J,G)=>{let Q=typeof G==="string"?w5[G]:G;if(!Q){let Y=JSON.stringify(G),U=Object.keys(w5).map((W)=>JSON.stringify(W)).join(", ");throw Error(`Unknown custom tag ${Y}; use one of ${U}`)}if(!J.includes(Q))J.push(Q);return J},[])}IJ.coreKnownTags=OJ;IJ.getTags=wJ});var f9=D((CJ)=>{var y9=S(),NJ=n0(),AJ=r0(),jJ=E$(),a1=S5(),SJ=($,X)=>$.key<X.key?-1:$.key>X.key?1:0;class k9{constructor({compat:$,customTags:X,merge:Z,resolveKnownTags:z,schema:q,sortMapEntries:J,toStringDefaults:G}){this.compat=Array.isArray($)?a1.getTags($,"compat"):$?a1.getTags(null,$):null,this.name=typeof q==="string"&&q||"core",this.knownTags=z?a1.coreKnownTags:{},this.tags=a1.getTags(X,this.name,Z),this.toStringOptions=G??null,Object.defineProperty(this,y9.MAP,{value:NJ.map}),Object.defineProperty(this,y9.SCALAR,{value:jJ.string}),Object.defineProperty(this,y9.SEQ,{value:AJ.seq}),this.sortMapEntries=typeof J==="function"?J:J===!0?SJ:null}clone(){let $=Object.create(k9.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}CJ.Schema=k9});var C5=D((yJ)=>{var bJ=S(),g9=A$(),f$=R$();function xJ($,X){let Z=[],z=X.directives===!0;if(X.directives!==!1&&$.directives){let Y=$.directives.toString($);if(Y)Z.push(Y),z=!0;else if($.directives.docStart)z=!0}if(z)Z.push("---");let q=g9.createStringifyContext($,X),{commentString:J}=q.options;if($.commentBefore){if(Z.length!==1)Z.unshift("");let Y=J($.commentBefore);Z.unshift(f$.indentComment(Y,""))}let G=!1,Q=null;if($.contents){if(bJ.isNode($.contents)){if($.contents.spaceBefore&&z)Z.push("");if($.contents.commentBefore){let W=J($.contents.commentBefore);Z.push(f$.indentComment(W,""))}q.forceBlockIndent=!!$.comment,Q=$.contents.comment}let Y=Q?void 0:()=>G=!0,U=g9.stringify($.contents,q,()=>Q=null,Y);if(Q)U+=f$.lineComment(U,"",J(Q));if((U[0]==="|"||U[0]===">")&&Z[Z.length-1]==="---")Z[Z.length-1]=`--- ${U}`;else Z.push(U)}else Z.push(g9.stringify($.contents,q));if($.directives?.docEnd)if($.comment){let Y=J($.comment);if(Y.includes(`
|
|
82
|
+
`))Z.push("..."),Z.push(f$.indentComment(Y,""));else Z.push(`... ${Y}`)}else Z.push("...");else{let Y=$.comment;if(Y&&G)Y=Y.replace(/^\n+/,"");if(Y){if((!G||Q)&&Z[Z.length-1]!=="")Z.push("");Z.push(f$.indentComment(J(Y),""))}}return Z.join(`
|
|
83
83
|
`)+`
|
|
84
|
-
`}
|
|
85
|
-
`;Q
|
|
84
|
+
`}yJ.stringifyDocument=xJ});var g$=D((pJ)=>{var fJ=w$(),t0=w1(),n=S(),gJ=_0(),hJ=K0(),vJ=f9(),uJ=C5(),h9=F1(),mJ=z9(),dJ=I$(),v9=Z9();class u9{constructor($,X,Z){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,n.NODE_TYPE,{value:n.DOC});let z=null;if(typeof X==="function"||Array.isArray(X))z=X;else if(Z===void 0&&X)Z=X,X=void 0;let q=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},Z);this.options=q;let{version:J}=q;if(Z?._directives){if(this.directives=Z._directives.atDocument(),this.directives.yaml.explicit)J=this.directives.yaml.version}else this.directives=new v9.Directives({version:J});this.setSchema(J,Z),this.contents=$===void 0?null:this.createNode($,z,Z)}clone(){let $=Object.create(u9.prototype,{[n.NODE_TYPE]:{value:n.DOC}});if($.commentBefore=this.commentBefore,$.comment=this.comment,$.errors=this.errors.slice(),$.warnings=this.warnings.slice(),$.options=Object.assign({},this.options),this.directives)$.directives=this.directives.clone();if($.schema=this.schema.clone(),$.contents=n.isNode(this.contents)?this.contents.clone($.schema):this.contents,this.range)$.range=this.range.slice();return $}add($){if(e0(this.contents))this.contents.add($)}addIn($,X){if(e0(this.contents))this.contents.addIn($,X)}createAlias($,X){if(!$.anchor){let Z=h9.anchorNames(this);$.anchor=!X||Z.has(X)?h9.findNewAnchor(X||"a",Z):X}return new fJ.Alias($.anchor)}createNode($,X,Z){let z=void 0;if(typeof X==="function")$=X.call({"":$},"",$),z=X;else if(Array.isArray(X)){let T=(_)=>typeof _==="number"||_ instanceof String||_ instanceof Number,K=X.filter(T).map(String);if(K.length>0)X=X.concat(K);z=X}else if(Z===void 0&&X)Z=X,X=void 0;let{aliasDuplicateObjects:q,anchorPrefix:J,flow:G,keepUndefined:Q,onTagObj:Y,tag:U}=Z??{},{onAnchor:W,setAnchors:H,sourceObjects:V}=h9.createNodeAnchors(this,J||"a"),B={aliasDuplicateObjects:q??!0,keepUndefined:Q??!1,onAnchor:W,onTagObj:Y,replacer:z,schema:this.schema,sourceObjects:V},L=dJ.createNode($,U,B);if(G&&n.isCollection(L))L.flow=!0;return H(),L}createPair($,X,Z={}){let z=this.createNode($,null,Z),q=this.createNode(X,null,Z);return new gJ.Pair(z,q)}delete($){return e0(this.contents)?this.contents.delete($):!1}deleteIn($){if(t0.isEmptyPath($)){if(this.contents==null)return!1;return this.contents=null,!0}return e0(this.contents)?this.contents.deleteIn($):!1}get($,X){return n.isCollection(this.contents)?this.contents.get($,X):void 0}getIn($,X){if(t0.isEmptyPath($))return!X&&n.isScalar(this.contents)?this.contents.value:this.contents;return n.isCollection(this.contents)?this.contents.getIn($,X):void 0}has($){return n.isCollection(this.contents)?this.contents.has($):!1}hasIn($){if(t0.isEmptyPath($))return this.contents!==void 0;return n.isCollection(this.contents)?this.contents.hasIn($):!1}set($,X){if(this.contents==null)this.contents=t0.collectionFromPath(this.schema,[$],X);else if(e0(this.contents))this.contents.set($,X)}setIn($,X){if(t0.isEmptyPath($))this.contents=X;else if(this.contents==null)this.contents=t0.collectionFromPath(this.schema,Array.from($),X);else if(e0(this.contents))this.contents.setIn($,X)}setSchema($,X={}){if(typeof $==="number")$=String($);let Z;switch($){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new v9.Directives({version:"1.1"});Z={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=$;else this.directives=new v9.Directives({version:$});Z={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;Z=null;break;default:{let z=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${z}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(Z)this.schema=new vJ.Schema(Object.assign(Z,X));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:$,jsonArg:X,mapAsMap:Z,maxAliasCount:z,onAnchor:q,reviver:J}={}){let G={anchors:new Map,doc:this,keep:!$,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof z==="number"?z:100},Q=hJ.toJS(this.contents,X??"",G);if(typeof q==="function")for(let{count:Y,res:U}of G.anchors.values())q(U,Y);return typeof J==="function"?mJ.applyReviver(J,{"":Q},"",Q):Q}toJSON($,X){return this.toJS({json:!0,jsonArg:$,mapAsMap:!1,onAnchor:X})}toString($={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in $&&(!Number.isInteger($.indent)||Number($.indent)<=0)){let X=JSON.stringify($.indent);throw Error(`"indent" option must be a positive integer, not ${X}`)}return uJ.stringifyDocument(this,$)}}function e0($){if(n.isCollection($))return!0;throw Error("Expected a YAML collection as document contents")}pJ.Document=u9});var h$=D((iJ)=>{class s1 extends Error{constructor($,X,Z,z){super();this.name=$,this.code=Z,this.message=z,this.pos=X}}class E5 extends s1{constructor($,X,Z){super("YAMLParseError",$,X,Z)}}class b5 extends s1{constructor($,X,Z){super("YAMLWarning",$,X,Z)}}var cJ=($,X)=>(Z)=>{if(Z.pos[0]===-1)return;Z.linePos=Z.pos.map((Q)=>X.linePos(Q));let{line:z,col:q}=Z.linePos[0];Z.message+=` at line ${z}, column ${q}`;let J=q-1,G=$.substring(X.lineStarts[z-1],X.lineStarts[z]).replace(/[\n\r]+$/,"");if(J>=60&&G.length>80){let Q=Math.min(J-39,G.length-79);G="\u2026"+G.substring(Q),J-=Q-1}if(G.length>80)G=G.substring(0,79)+"\u2026";if(z>1&&/^ *$/.test(G.substring(0,J))){let Q=$.substring(X.lineStarts[z-2],X.lineStarts[z-1]);if(Q.length>80)Q=Q.substring(0,79)+`\u2026
|
|
85
|
+
`;G=Q+G}if(/[^ ]/.test(G)){let Q=1,Y=Z.linePos[1];if(Y?.line===z&&Y.col>q)Q=Math.max(1,Math.min(Y.col-q,80-J));let U=" ".repeat(J)+"^".repeat(Q);Z.message+=`:
|
|
86
86
|
|
|
87
|
-
${
|
|
87
|
+
${G}
|
|
88
88
|
${U}
|
|
89
|
-
`}};
|
|
90
|
-
`))return!0;if($.end){for(let
|
|
91
|
-
`+T.comment;else
|
|
92
|
-
`+
|
|
93
|
-
`+
|
|
94
|
-
`+
|
|
95
|
-
`+
|
|
96
|
-
`+
|
|
97
|
-
`.repeat(Math.max(1,
|
|
98
|
-
`;for(let T=
|
|
99
|
-
`;else if(
|
|
100
|
-
`;else if(!
|
|
101
|
-
`)
|
|
102
|
-
|
|
103
|
-
`;
|
|
104
|
-
`,
|
|
105
|
-
`)
|
|
106
|
-
`;else
|
|
107
|
-
`;else
|
|
108
|
-
`+
|
|
109
|
-
`)
|
|
110
|
-
`;break;default:
|
|
111
|
-
`}let
|
|
112
|
-
`,"sy"),
|
|
113
|
-
`,"sy")}catch{
|
|
114
|
-
`)
|
|
115
|
-
`;else
|
|
116
|
-
`)continue;if(
|
|
117
|
-
`){let{fold:
|
|
118
|
-
`){
|
|
119
|
-
`){
|
|
120
|
-
`&&!(
|
|
121
|
-
`))z
|
|
122
|
-
`||
|
|
123
|
-
`)break;if(
|
|
124
|
-
`)
|
|
125
|
-
`;
|
|
126
|
-
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function
|
|
89
|
+
`}};iJ.YAMLError=s1;iJ.YAMLParseError=E5;iJ.YAMLWarning=b5;iJ.prettifyError=cJ});var v$=D((tJ)=>{function oJ($,{flow:X,indicator:Z,next:z,offset:q,onError:J,parentIndent:G,startOnNewline:Q}){let Y=!1,U=Q,W=Q,H="",V="",B=!1,L=!1,T=null,K=null,_=null,F=null,O=null,I=null,R=null;for(let M of $){if(L){if(M.type!=="space"&&M.type!=="newline"&&M.type!=="comma")J(M.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");L=!1}if(T){if(U&&M.type!=="comment"&&M.type!=="newline")J(T,"TAB_AS_INDENT","Tabs are not allowed as indentation");T=null}switch(M.type){case"space":if(!X&&(Z!=="doc-start"||z?.type!=="flow-collection")&&M.source.includes("\t"))T=M;W=!0;break;case"comment":{if(!W)J(M,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let x=M.source.substring(1)||" ";if(!H)H=x;else H+=V+x;V="",U=!1;break}case"newline":if(U){if(H)H+=M.source;else if(!I||Z!=="seq-item-ind")Y=!0}else V+=M.source;if(U=!0,B=!0,K||_)F=M;W=!0;break;case"anchor":if(K)J(M,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(M.source.endsWith(":"))J(M.offset+M.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);K=M,R??(R=M.offset),U=!1,W=!1,L=!0;break;case"tag":{if(_)J(M,"MULTIPLE_TAGS","A node can have at most one tag");_=M,R??(R=M.offset),U=!1,W=!1,L=!0;break}case Z:if(K||_)J(M,"BAD_PROP_ORDER",`Anchors and tags must be after the ${M.source} indicator`);if(I)J(M,"UNEXPECTED_TOKEN",`Unexpected ${M.source} in ${X??"collection"}`);I=M,U=Z==="seq-item-ind"||Z==="explicit-key-ind",W=!1;break;case"comma":if(X){if(O)J(M,"UNEXPECTED_TOKEN",`Unexpected , in ${X}`);O=M,U=!1,W=!1;break}default:J(M,"UNEXPECTED_TOKEN",`Unexpected ${M.type} token`),U=!1,W=!1}}let N=$[$.length-1],E=N?N.offset+N.source.length:q;if(L&&z&&z.type!=="space"&&z.type!=="newline"&&z.type!=="comma"&&(z.type!=="scalar"||z.source!==""))J(z.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(T&&(U&&T.indent<=G||z?.type==="block-map"||z?.type==="block-seq"))J(T,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:O,found:I,spaceBefore:Y,comment:H,hasNewline:B,anchor:K,tag:_,newlineAfterProp:F,end:E,start:R??E}}tJ.resolveProps=oJ});var n1=D(($G)=>{function m9($){if(!$)return null;switch($.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if($.source.includes(`
|
|
90
|
+
`))return!0;if($.end){for(let X of $.end)if(X.type==="newline")return!0}return!1;case"flow-collection":for(let X of $.items){for(let Z of X.start)if(Z.type==="newline")return!0;if(X.sep){for(let Z of X.sep)if(Z.type==="newline")return!0}if(m9(X.key)||m9(X.value))return!0}return!1;default:return!0}}$G.containsNewline=m9});var d9=D((qG)=>{var ZG=n1();function zG($,X,Z){if(X?.type==="flow-collection"){let z=X.end[0];if(z.indent===$&&(z.source==="]"||z.source==="}")&&ZG.containsNewline(X))Z(z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}qG.flowIndentCheck=zG});var p9=D((QG)=>{var x5=S();function GG($,X,Z){let{uniqueKeys:z}=$.options;if(z===!1)return!1;let q=typeof z==="function"?z:(J,G)=>J===G||x5.isScalar(J)&&x5.isScalar(G)&&J.value===G.value;return X.some((J)=>q(J.key,Z))}QG.mapIncludes=GG});var h5=D((TG)=>{var y5=_0(),UG=M0(),k5=v$(),HG=n1(),f5=d9(),WG=p9(),g5="All mapping items must start at the same column";function VG({composeNode:$,composeEmptyNode:X},Z,z,q,J){let Q=new(J?.nodeClass??UG.YAMLMap)(Z.schema);if(Z.atRoot)Z.atRoot=!1;let Y=z.offset,U=null;for(let W of z.items){let{start:H,key:V,sep:B,value:L}=W,T=k5.resolveProps(H,{indicator:"explicit-key-ind",next:V??B?.[0],offset:Y,onError:q,parentIndent:z.indent,startOnNewline:!0}),K=!T.found;if(K){if(V){if(V.type==="block-seq")q(Y,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in V&&V.indent!==z.indent)q(Y,"BAD_INDENT",g5)}if(!T.anchor&&!T.tag&&!B){if(U=T.end,T.comment)if(Q.comment)Q.comment+=`
|
|
91
|
+
`+T.comment;else Q.comment=T.comment;continue}if(T.newlineAfterProp||HG.containsNewline(V))q(V??H[H.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(T.found?.indent!==z.indent)q(Y,"BAD_INDENT",g5);Z.atKey=!0;let _=T.end,F=V?$(Z,V,T,q):X(Z,_,H,null,T,q);if(Z.schema.compat)f5.flowIndentCheck(z.indent,V,q);if(Z.atKey=!1,WG.mapIncludes(Z,Q.items,F))q(_,"DUPLICATE_KEY","Map keys must be unique");let O=k5.resolveProps(B??[],{indicator:"map-value-ind",next:L,offset:F.range[2],onError:q,parentIndent:z.indent,startOnNewline:!V||V.type==="block-scalar"});if(Y=O.end,O.found){if(K){if(L?.type==="block-map"&&!O.hasNewline)q(Y,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(Z.options.strict&&T.start<O.found.offset-1024)q(F.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let I=L?$(Z,L,O,q):X(Z,Y,B,null,O,q);if(Z.schema.compat)f5.flowIndentCheck(z.indent,L,q);Y=I.range[2];let R=new y5.Pair(F,I);if(Z.options.keepSourceTokens)R.srcToken=W;Q.items.push(R)}else{if(K)q(F.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(O.comment)if(F.comment)F.comment+=`
|
|
92
|
+
`+O.comment;else F.comment=O.comment;let I=new y5.Pair(F);if(Z.options.keepSourceTokens)I.srcToken=W;Q.items.push(I)}}if(U&&U<Y)q(U,"IMPOSSIBLE","Map comment with trailing content");return Q.range=[z.offset,Y,U??Y],Q}TG.resolveBlockMap=VG});var v5=D((FG)=>{var KG=O0(),LG=v$(),DG=d9();function _G({composeNode:$,composeEmptyNode:X},Z,z,q,J){let Q=new(J?.nodeClass??KG.YAMLSeq)(Z.schema);if(Z.atRoot)Z.atRoot=!1;if(Z.atKey)Z.atKey=!1;let Y=z.offset,U=null;for(let{start:W,value:H}of z.items){let V=LG.resolveProps(W,{indicator:"seq-item-ind",next:H,offset:Y,onError:q,parentIndent:z.indent,startOnNewline:!0});if(!V.found)if(V.anchor||V.tag||H)if(H?.type==="block-seq")q(V.end,"BAD_INDENT","All sequence items must start at the same column");else q(Y,"MISSING_CHAR","Sequence item without - indicator");else{if(U=V.end,V.comment)Q.comment=V.comment;continue}let B=H?$(Z,H,V,q):X(Z,V.end,W,null,V,q);if(Z.schema.compat)DG.flowIndentCheck(z.indent,H,q);Y=B.range[2],Q.items.push(B)}return Q.range=[z.offset,Y,U??Y],Q}FG.resolveBlockSeq=_G});var $$=D((wG)=>{function OG($,X,Z,z){let q="";if($){let J=!1,G="";for(let Q of $){let{source:Y,type:U}=Q;switch(U){case"space":J=!0;break;case"comment":{if(Z&&!J)z(Q,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=Y.substring(1)||" ";if(!q)q=W;else q+=G+W;G="";break}case"newline":if(q)G+=Y;J=!0;break;default:z(Q,"UNEXPECTED_TOKEN",`Unexpected ${U} at node end`)}X+=Y.length}}return{comment:q,offset:X}}wG.resolveEnd=OG});var d5=D((EG)=>{var RG=S(),PG=_0(),u5=M0(),NG=O0(),AG=$$(),m5=v$(),jG=n1(),SG=p9(),l9="Block collections are not allowed within flow collections",c9=($)=>$&&($.type==="block-map"||$.type==="block-seq");function CG({composeNode:$,composeEmptyNode:X},Z,z,q,J){let G=z.start.source==="{",Q=G?"flow map":"flow sequence",U=new(J?.nodeClass??(G?u5.YAMLMap:NG.YAMLSeq))(Z.schema);U.flow=!0;let W=Z.atRoot;if(W)Z.atRoot=!1;if(Z.atKey)Z.atKey=!1;let H=z.offset+z.start.source.length;for(let K=0;K<z.items.length;++K){let _=z.items[K],{start:F,key:O,sep:I,value:R}=_,N=m5.resolveProps(F,{flow:Q,indicator:"explicit-key-ind",next:O??I?.[0],offset:H,onError:q,parentIndent:z.indent,startOnNewline:!1});if(!N.found){if(!N.anchor&&!N.tag&&!I&&!R){if(K===0&&N.comma)q(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`);else if(K<z.items.length-1)q(N.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${Q}`);if(N.comment)if(U.comment)U.comment+=`
|
|
93
|
+
`+N.comment;else U.comment=N.comment;H=N.end;continue}if(!G&&Z.options.strict&&jG.containsNewline(O))q(O,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(K===0){if(N.comma)q(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`)}else{if(!N.comma)q(N.start,"MISSING_CHAR",`Missing , between ${Q} items`);if(N.comment){let E="";$:for(let M of F)switch(M.type){case"comma":case"space":break;case"comment":E=M.source.substring(1);break $;default:break $}if(E){let M=U.items[U.items.length-1];if(RG.isPair(M))M=M.value??M.key;if(M.comment)M.comment+=`
|
|
94
|
+
`+E;else M.comment=E;N.comment=N.comment.substring(E.length+1)}}}if(!G&&!I&&!N.found){let E=R?$(Z,R,N,q):X(Z,N.end,I,null,N,q);if(U.items.push(E),H=E.range[2],c9(R))q(E.range,"BLOCK_IN_FLOW",l9)}else{Z.atKey=!0;let E=N.end,M=O?$(Z,O,N,q):X(Z,E,F,null,N,q);if(c9(O))q(M.range,"BLOCK_IN_FLOW",l9);Z.atKey=!1;let x=m5.resolveProps(I??[],{flow:Q,indicator:"map-value-ind",next:R,offset:M.range[2],onError:q,parentIndent:z.indent,startOnNewline:!1});if(x.found){if(!G&&!N.found&&Z.options.strict){if(I)for(let f of I){if(f===x.found)break;if(f.type==="newline"){q(f,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(N.start<x.found.offset-1024)q(x.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(R)if("source"in R&&R.source?.[0]===":")q(R,"MISSING_CHAR",`Missing space after : in ${Q}`);else q(x.start,"MISSING_CHAR",`Missing , or : between ${Q} items`);let a=R?$(Z,R,x,q):x.found?X(Z,x.end,I,null,x,q):null;if(a){if(c9(R))q(a.range,"BLOCK_IN_FLOW",l9)}else if(x.comment)if(M.comment)M.comment+=`
|
|
95
|
+
`+x.comment;else M.comment=x.comment;let z0=new PG.Pair(M,a);if(Z.options.keepSourceTokens)z0.srcToken=_;if(G){let f=U;if(SG.mapIncludes(Z,f.items,M))q(E,"DUPLICATE_KEY","Map keys must be unique");f.items.push(z0)}else{let f=new u5.YAMLMap(Z.schema);f.flow=!0,f.items.push(z0);let V1=(a??M).range;f.range=[M.range[0],V1[1],V1[2]],U.items.push(f)}H=a?a.range[2]:x.end}}let V=G?"}":"]",[B,...L]=z.end,T=H;if(B?.source===V)T=B.offset+B.source.length;else{let K=Q[0].toUpperCase()+Q.substring(1),_=W?`${K} must end with a ${V}`:`${K} in block collection must be sufficiently indented and end with a ${V}`;if(q(H,W?"MISSING_CHAR":"BAD_INDENT",_),B&&B.source.length!==1)L.unshift(B)}if(L.length>0){let K=AG.resolveEnd(L,T,Z.options.strict,q);if(K.comment)if(U.comment)U.comment+=`
|
|
96
|
+
`+K.comment;else U.comment=K.comment;U.range=[z.offset,T,K.offset]}else U.range=[z.offset,T,T];return U}EG.resolveFlowCollection=CG});var p5=D((mG)=>{var xG=S(),yG=g(),kG=M0(),fG=O0(),gG=h5(),hG=v5(),vG=d5();function i9($,X,Z,z,q,J){let G=Z.type==="block-map"?gG.resolveBlockMap($,X,Z,z,J):Z.type==="block-seq"?hG.resolveBlockSeq($,X,Z,z,J):vG.resolveFlowCollection($,X,Z,z,J),Q=G.constructor;if(q==="!"||q===Q.tagName)return G.tag=Q.tagName,G;if(q)G.tag=q;return G}function uG($,X,Z,z,q){let J=z.tag,G=!J?null:X.directives.tagName(J.source,(V)=>q(J,"TAG_RESOLVE_FAILED",V));if(Z.type==="block-seq"){let{anchor:V,newlineAfterProp:B}=z,L=V&&J?V.offset>J.offset?V:J:V??J;if(L&&(!B||B.offset<L.offset))q(L,"MISSING_CHAR","Missing newline after block sequence props")}let Q=Z.type==="block-map"?"map":Z.type==="block-seq"?"seq":Z.start.source==="{"?"map":"seq";if(!J||!G||G==="!"||G===kG.YAMLMap.tagName&&Q==="map"||G===fG.YAMLSeq.tagName&&Q==="seq")return i9($,X,Z,q,G);let Y=X.schema.tags.find((V)=>V.tag===G&&V.collection===Q);if(!Y){let V=X.schema.knownTags[G];if(V?.collection===Q)X.schema.tags.push(Object.assign({},V,{default:!1})),Y=V;else{if(V)q(J,"BAD_COLLECTION_TYPE",`${V.tag} used for ${Q} collection, but expects ${V.collection??"scalar"}`,!0);else q(J,"TAG_RESOLVE_FAILED",`Unresolved tag: ${G}`,!0);return i9($,X,Z,q,G)}}let U=i9($,X,Z,q,G,Y),W=Y.resolve?.(U,(V)=>q(J,"TAG_RESOLVE_FAILED",V),X.options)??U,H=xG.isNode(W)?W:new yG.Scalar(W);if(H.range=U.range,H.tag=G,Y?.format)H.format=Y.format;return H}mG.composeCollection=uG});var s9=D((iG)=>{var a9=g();function pG($,X,Z){let z=X.offset,q=lG(X,$.options.strict,Z);if(!q)return{value:"",type:null,comment:"",range:[z,z,z]};let J=q.mode===">"?a9.Scalar.BLOCK_FOLDED:a9.Scalar.BLOCK_LITERAL,G=X.source?cG(X.source):[],Q=G.length;for(let T=G.length-1;T>=0;--T){let K=G[T][1];if(K===""||K==="\r")Q=T;else break}if(Q===0){let T=q.chomp==="+"&&G.length>0?`
|
|
97
|
+
`.repeat(Math.max(1,G.length-1)):"",K=z+q.length;if(X.source)K+=X.source.length;return{value:T,type:J,comment:q.comment,range:[z,K,K]}}let Y=X.indent+q.indent,U=X.offset+q.length,W=0;for(let T=0;T<Q;++T){let[K,_]=G[T];if(_===""||_==="\r"){if(q.indent===0&&K.length>Y)Y=K.length}else{if(K.length<Y)Z(U+K.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(q.indent===0)Y=K.length;if(W=T,Y===0&&!$.atRoot)Z(U,"BAD_INDENT","Block scalar values in collections must be indented");break}U+=K.length+_.length+1}for(let T=G.length-1;T>=Q;--T)if(G[T][0].length>Y)Q=T+1;let H="",V="",B=!1;for(let T=0;T<W;++T)H+=G[T][0].slice(Y)+`
|
|
98
|
+
`;for(let T=W;T<Q;++T){let[K,_]=G[T];U+=K.length+_.length+1;let F=_[_.length-1]==="\r";if(F)_=_.slice(0,-1);if(_&&K.length<Y){let I=`Block scalar lines must not be less indented than their ${q.indent?"explicit indentation indicator":"first line"}`;Z(U-_.length-(F?2:1),"BAD_INDENT",I),K=""}if(J===a9.Scalar.BLOCK_LITERAL)H+=V+K.slice(Y)+_,V=`
|
|
99
|
+
`;else if(K.length>Y||_[0]==="\t"){if(V===" ")V=`
|
|
100
|
+
`;else if(!B&&V===`
|
|
101
|
+
`)V=`
|
|
102
|
+
|
|
103
|
+
`;H+=V+K.slice(Y)+_,V=`
|
|
104
|
+
`,B=!0}else if(_==="")if(V===`
|
|
105
|
+
`)H+=`
|
|
106
|
+
`;else V=`
|
|
107
|
+
`;else H+=V+_,V=" ",B=!1}switch(q.chomp){case"-":break;case"+":for(let T=Q;T<G.length;++T)H+=`
|
|
108
|
+
`+G[T][0].slice(Y);if(H[H.length-1]!==`
|
|
109
|
+
`)H+=`
|
|
110
|
+
`;break;default:H+=`
|
|
111
|
+
`}let L=z+q.length+X.source.length;return{value:H,type:J,comment:q.comment,range:[z,L,L]}}function lG({offset:$,props:X},Z,z){if(X[0].type!=="block-scalar-header")return z(X[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:q}=X[0],J=q[0],G=0,Q="",Y=-1;for(let V=1;V<q.length;++V){let B=q[V];if(!Q&&(B==="-"||B==="+"))Q=B;else{let L=Number(B);if(!G&&L)G=L;else if(Y===-1)Y=$+V}}if(Y!==-1)z(Y,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${q}`);let U=!1,W="",H=q.length;for(let V=1;V<X.length;++V){let B=X[V];switch(B.type){case"space":U=!0;case"newline":H+=B.source.length;break;case"comment":if(Z&&!U)z(B,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");H+=B.source.length,W=B.source.substring(1);break;case"error":z(B,"UNEXPECTED_TOKEN",B.message),H+=B.source.length;break;default:{let L=`Unexpected token in block scalar header: ${B.type}`;z(B,"UNEXPECTED_TOKEN",L);let T=B.source;if(T&&typeof T==="string")H+=T.length}}}return{mode:J,indent:G,chomp:Q,comment:W,length:H}}function cG($){let X=$.split(/\n( *)/),Z=X[0],z=Z.match(/^( *)/),J=[z?.[1]?[z[1],Z.slice(z[1].length)]:["",Z]];for(let G=1;G<X.length;G+=2)J.push([X[G],X[G+1]]);return J}iG.resolveBlockScalar=pG});var r9=D((ZQ)=>{var n9=g(),sG=$$();function nG($,X,Z){let{offset:z,type:q,source:J,end:G}=$,Q,Y,U=(V,B,L)=>Z(z+V,B,L);switch(q){case"scalar":Q=n9.Scalar.PLAIN,Y=rG(J,U);break;case"single-quoted-scalar":Q=n9.Scalar.QUOTE_SINGLE,Y=oG(J,U);break;case"double-quoted-scalar":Q=n9.Scalar.QUOTE_DOUBLE,Y=tG(J,U);break;default:return Z($,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${q}`),{value:"",type:null,comment:"",range:[z,z+J.length,z+J.length]}}let W=z+J.length,H=sG.resolveEnd(G,W,X,Z);return{value:Y,type:Q,comment:H.comment,range:[z,W,H.offset]}}function rG($,X){let Z="";switch($[0]){case"\t":Z="a tab character";break;case",":Z="flow indicator character ,";break;case"%":Z="directive indicator character %";break;case"|":case">":{Z=`block scalar indicator ${$[0]}`;break}case"@":case"`":{Z=`reserved character ${$[0]}`;break}}if(Z)X(0,"BAD_SCALAR_START",`Plain value cannot start with ${Z}`);return l5($)}function oG($,X){if($[$.length-1]!=="'"||$.length===1)X($.length,"MISSING_CHAR","Missing closing 'quote");return l5($.slice(1,-1)).replace(/''/g,"'")}function l5($){let X,Z;try{X=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
112
|
+
`,"sy"),Z=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
113
|
+
`,"sy")}catch{X=/(.*?)[ \t]*\r?\n/sy,Z=/[ \t]*(.*?)[ \t]*\r?\n/sy}let z=X.exec($);if(!z)return $;let q=z[1],J=" ",G=X.lastIndex;Z.lastIndex=G;while(z=Z.exec($)){if(z[1]==="")if(J===`
|
|
114
|
+
`)q+=J;else J=`
|
|
115
|
+
`;else q+=J+z[1],J=" ";G=Z.lastIndex}let Q=/[ \t]*(.*)/sy;return Q.lastIndex=G,z=Q.exec($),q+J+(z?.[1]??"")}function tG($,X){let Z="";for(let z=1;z<$.length-1;++z){let q=$[z];if(q==="\r"&&$[z+1]===`
|
|
116
|
+
`)continue;if(q===`
|
|
117
|
+
`){let{fold:J,offset:G}=eG($,z);Z+=J,z=G}else if(q==="\\"){let J=$[++z],G=$Q[J];if(G)Z+=G;else if(J===`
|
|
118
|
+
`){J=$[z+1];while(J===" "||J==="\t")J=$[++z+1]}else if(J==="\r"&&$[z+1]===`
|
|
119
|
+
`){J=$[++z+1];while(J===" "||J==="\t")J=$[++z+1]}else if(J==="x"||J==="u"||J==="U"){let Q={x:2,u:4,U:8}[J];Z+=XQ($,z+1,Q,X),z+=Q}else{let Q=$.substr(z-1,2);X(z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Z+=Q}}else if(q===" "||q==="\t"){let J=z,G=$[z+1];while(G===" "||G==="\t")G=$[++z+1];if(G!==`
|
|
120
|
+
`&&!(G==="\r"&&$[z+2]===`
|
|
121
|
+
`))Z+=z>J?$.slice(J,z+1):q}else Z+=q}if($[$.length-1]!=='"'||$.length===1)X($.length,"MISSING_CHAR",'Missing closing "quote');return Z}function eG($,X){let Z="",z=$[X+1];while(z===" "||z==="\t"||z===`
|
|
122
|
+
`||z==="\r"){if(z==="\r"&&$[X+2]!==`
|
|
123
|
+
`)break;if(z===`
|
|
124
|
+
`)Z+=`
|
|
125
|
+
`;X+=1,z=$[X+1]}if(!Z)Z=" ";return{fold:Z,offset:X}}var $Q={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
126
|
+
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function XQ($,X,Z,z){let q=$.substr(X,Z),G=q.length===Z&&/^[0-9a-fA-F]+$/.test(q)?parseInt(q,16):NaN;if(isNaN(G)){let Q=$.substr(X-2,Z+2);return z(X-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Q}return String.fromCodePoint(G)}ZQ.resolveFlowScalar=nG});var i5=D((UQ)=>{var x0=S(),c5=g(),qQ=s9(),JQ=r9();function GQ($,X,Z,z){let{value:q,type:J,comment:G,range:Q}=X.type==="block-scalar"?qQ.resolveBlockScalar($,X,z):JQ.resolveFlowScalar(X,$.options.strict,z),Y=Z?$.directives.tagName(Z.source,(H)=>z(Z,"TAG_RESOLVE_FAILED",H)):null,U;if($.options.stringKeys&&$.atKey)U=$.schema[x0.SCALAR];else if(Y)U=QQ($.schema,q,Y,Z,z);else if(X.type==="scalar")U=YQ($,q,X,z);else U=$.schema[x0.SCALAR];let W;try{let H=U.resolve(q,(V)=>z(Z??X,"TAG_RESOLVE_FAILED",V),$.options);W=x0.isScalar(H)?H:new c5.Scalar(H)}catch(H){let V=H instanceof Error?H.message:String(H);z(Z??X,"TAG_RESOLVE_FAILED",V),W=new c5.Scalar(q)}if(W.range=Q,W.source=q,J)W.type=J;if(Y)W.tag=Y;if(U.format)W.format=U.format;if(G)W.comment=G;return W}function QQ($,X,Z,z,q){if(Z==="!")return $[x0.SCALAR];let J=[];for(let Q of $.tags)if(!Q.collection&&Q.tag===Z)if(Q.default&&Q.test)J.push(Q);else return Q;for(let Q of J)if(Q.test?.test(X))return Q;let G=$.knownTags[Z];if(G&&!G.collection)return $.tags.push(Object.assign({},G,{default:!1,test:void 0})),G;return q(z,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Z}`,Z!=="tag:yaml.org,2002:str"),$[x0.SCALAR]}function YQ({atKey:$,directives:X,schema:Z},z,q,J){let G=Z.tags.find((Q)=>(Q.default===!0||$&&Q.default==="key")&&Q.test?.test(z))||Z[x0.SCALAR];if(Z.compat){let Q=Z.compat.find((Y)=>Y.default&&Y.test?.test(z))??Z[x0.SCALAR];if(G.tag!==Q.tag){let Y=X.tagString(G.tag),U=X.tagString(Q.tag),W=`Value may be parsed as either ${Y} or ${U}`;J(q,"TAG_RESOLVE_FAILED",W,!0)}}return G}UQ.composeScalar=GQ});var a5=D((VQ)=>{function WQ($,X,Z){if(X){Z??(Z=X.length);for(let z=Z-1;z>=0;--z){let q=X[z];switch(q.type){case"space":case"comment":case"newline":$-=q.source.length;continue}q=X[++z];while(q?.type==="space")$+=q.source.length,q=X[++z];break}}return $}VQ.emptyScalarPosition=WQ});var r5=D((OQ)=>{var BQ=w$(),KQ=S(),LQ=p5(),s5=i5(),DQ=$$(),_Q=a5(),FQ={composeNode:n5,composeEmptyNode:o9};function n5($,X,Z,z){let q=$.atKey,{spaceBefore:J,comment:G,anchor:Q,tag:Y}=Z,U,W=!0;switch(X.type){case"alias":if(U=MQ($,X,z),Q||Y)z(X,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(U=s5.composeScalar($,X,Y,z),Q)U.anchor=Q.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(U=LQ.composeCollection(FQ,$,X,Z,z),Q)U.anchor=Q.source.substring(1);break;default:{let H=X.type==="error"?X.message:`Unsupported token (type: ${X.type})`;z(X,"UNEXPECTED_TOKEN",H),U=o9($,X.offset,void 0,null,Z,z),W=!1}}if(Q&&U.anchor==="")z(Q,"BAD_ALIAS","Anchor cannot be an empty string");if(q&&$.options.stringKeys&&(!KQ.isScalar(U)||typeof U.value!=="string"||U.tag&&U.tag!=="tag:yaml.org,2002:str"))z(Y??X,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(J)U.spaceBefore=!0;if(G)if(X.type==="scalar"&&X.source==="")U.comment=G;else U.commentBefore=G;if($.options.keepSourceTokens&&W)U.srcToken=X;return U}function o9($,X,Z,z,{spaceBefore:q,comment:J,anchor:G,tag:Q,end:Y},U){let W={type:"scalar",offset:_Q.emptyScalarPosition(X,Z,z),indent:-1,source:""},H=s5.composeScalar($,W,Q,U);if(G){if(H.anchor=G.source.substring(1),H.anchor==="")U(G,"BAD_ALIAS","Anchor cannot be an empty string")}if(q)H.spaceBefore=!0;if(J)H.comment=J,H.range[2]=Y;return H}function MQ({options:$},{offset:X,source:Z,end:z},q){let J=new BQ.Alias(Z.substring(1));if(J.source==="")q(X,"BAD_ALIAS","Alias cannot be an empty string");if(J.source.endsWith(":"))q(X+Z.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let G=X+Z.length,Q=DQ.resolveEnd(z,G,$.strict,q);if(J.range=[X,G,Q.offset],Q.comment)J.comment=Q.comment;return J}OQ.composeEmptyNode=o9;OQ.composeNode=n5});var t5=D((jQ)=>{var RQ=g$(),o5=r5(),PQ=$$(),NQ=v$();function AQ($,X,{offset:Z,start:z,value:q,end:J},G){let Q=Object.assign({_directives:X},$),Y=new RQ.Document(void 0,Q),U={atKey:!1,atRoot:!0,directives:Y.directives,options:Y.options,schema:Y.schema},W=NQ.resolveProps(z,{indicator:"doc-start",next:q??J?.[0],offset:Z,onError:G,parentIndent:0,startOnNewline:!0});if(W.found){if(Y.directives.docStart=!0,q&&(q.type==="block-map"||q.type==="block-seq")&&!W.hasNewline)G(W.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}Y.contents=q?o5.composeNode(U,q,W,G):o5.composeEmptyNode(U,W.end,z,null,W,G);let H=Y.contents.range[2],V=PQ.resolveEnd(J,H,!1,G);if(V.comment)Y.comment=V.comment;return Y.range=[Z,H,V.offset],Y}jQ.composeDoc=AQ});var t9=D((kQ)=>{var CQ=Q0("process"),EQ=Z9(),bQ=g$(),u$=h$(),e5=S(),xQ=t5(),yQ=$$();function m$($){if(typeof $==="number")return[$,$+1];if(Array.isArray($))return $.length===2?$:[$[0],$[1]];let{offset:X,source:Z}=$;return[X,X+(typeof Z==="string"?Z.length:1)]}function $8($){let X="",Z=!1,z=!1;for(let q=0;q<$.length;++q){let J=$[q];switch(J[0]){case"#":X+=(X===""?"":z?`
|
|
127
127
|
|
|
128
128
|
`:`
|
|
129
|
-
`)+(
|
|
130
|
-
${
|
|
131
|
-
${
|
|
132
|
-
${
|
|
133
|
-
${
|
|
134
|
-
`}];switch(
|
|
135
|
-
`),
|
|
136
|
-
`,
|
|
137
|
-
`});return{type:"block-scalar",offset:
|
|
138
|
-
`),X
|
|
139
|
-
`;if($.type==="block-scalar"){let
|
|
140
|
-
`});for(let
|
|
141
|
-
`};delete $.items,Object.assign($,{type:
|
|
129
|
+
`)+(J.substring(1)||" "),Z=!0,z=!1;break;case"%":if($[q+1]?.[0]!=="#")q+=1;Z=!1;break;default:if(!Z)z=!0;Z=!1}}return{comment:X,afterEmptyLine:z}}class X8{constructor($={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(X,Z,z,q)=>{let J=m$(X);if(q)this.warnings.push(new u$.YAMLWarning(J,Z,z));else this.errors.push(new u$.YAMLParseError(J,Z,z))},this.directives=new EQ.Directives({version:$.version||"1.2"}),this.options=$}decorate($,X){let{comment:Z,afterEmptyLine:z}=$8(this.prelude);if(Z){let q=$.contents;if(X)$.comment=$.comment?`${$.comment}
|
|
130
|
+
${Z}`:Z;else if(z||$.directives.docStart||!q)$.commentBefore=Z;else if(e5.isCollection(q)&&!q.flow&&q.items.length>0){let J=q.items[0];if(e5.isPair(J))J=J.key;let G=J.commentBefore;J.commentBefore=G?`${Z}
|
|
131
|
+
${G}`:Z}else{let J=q.commentBefore;q.commentBefore=J?`${Z}
|
|
132
|
+
${J}`:Z}}if(X)Array.prototype.push.apply($.errors,this.errors),Array.prototype.push.apply($.warnings,this.warnings);else $.errors=this.errors,$.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:$8(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose($,X=!1,Z=-1){for(let z of $)yield*this.next(z);yield*this.end(X,Z)}*next($){if(CQ.env.LOG_STREAM)console.dir($,{depth:null});switch($.type){case"directive":this.directives.add($.source,(X,Z,z)=>{let q=m$($);q[0]+=X,this.onError(q,"BAD_DIRECTIVE",Z,z)}),this.prelude.push($.source),this.atDirectives=!0;break;case"document":{let X=xQ.composeDoc(this.options,this.directives,$,this.onError);if(this.atDirectives&&!X.directives.docStart)this.onError($,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(X,!1),this.doc)yield this.doc;this.doc=X,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push($.source);break;case"error":{let X=$.source?`${$.message}: ${JSON.stringify($.source)}`:$.message,Z=new u$.YAMLParseError(m$($),"UNEXPECTED_TOKEN",X);if(this.atDirectives||!this.doc)this.errors.push(Z);else this.doc.errors.push(Z);break}case"doc-end":{if(!this.doc){this.errors.push(new u$.YAMLParseError(m$($),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let X=yQ.resolveEnd($.end,$.offset+$.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),X.comment){let Z=this.doc.comment;this.doc.comment=Z?`${Z}
|
|
133
|
+
${X.comment}`:X.comment}this.doc.range[2]=X.offset;break}default:this.errors.push(new u$.YAMLParseError(m$($),"UNEXPECTED_TOKEN",`Unsupported token ${$.type}`))}}*end($=!1,X=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if($){let Z=Object.assign({_directives:this.directives},this.options),z=new bQ.Document(void 0,Z);if(this.atDirectives)this.onError(X,"MISSING_CHAR","Missing directives-end indicator line");z.range=[0,X,X],this.decorate(z,!1),yield z}}}kQ.Composer=X8});var q8=D((lQ)=>{var gQ=s9(),hQ=r9(),vQ=h$(),Z8=N$();function uQ($,X=!0,Z){if($){let z=(q,J,G)=>{let Q=typeof q==="number"?q:Array.isArray(q)?q[0]:q.offset;if(Z)Z(Q,J,G);else throw new vQ.YAMLParseError([Q,Q+1],J,G)};switch($.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return hQ.resolveFlowScalar($,X,z);case"block-scalar":return gQ.resolveBlockScalar({options:{strict:X}},$,z)}}return null}function mQ($,X){let{implicitKey:Z=!1,indent:z,inFlow:q=!1,offset:J=-1,type:G="PLAIN"}=X,Q=Z8.stringifyString({type:G,value:$},{implicitKey:Z,indent:z>0?" ".repeat(z):"",inFlow:q,options:{blockQuote:!0,lineWidth:-1}}),Y=X.end??[{type:"newline",offset:-1,indent:z,source:`
|
|
134
|
+
`}];switch(Q[0]){case"|":case">":{let U=Q.indexOf(`
|
|
135
|
+
`),W=Q.substring(0,U),H=Q.substring(U+1)+`
|
|
136
|
+
`,V=[{type:"block-scalar-header",offset:J,indent:z,source:W}];if(!z8(V,Y))V.push({type:"newline",offset:-1,indent:z,source:`
|
|
137
|
+
`});return{type:"block-scalar",offset:J,indent:z,props:V,source:H}}case'"':return{type:"double-quoted-scalar",offset:J,indent:z,source:Q,end:Y};case"'":return{type:"single-quoted-scalar",offset:J,indent:z,source:Q,end:Y};default:return{type:"scalar",offset:J,indent:z,source:Q,end:Y}}}function dQ($,X,Z={}){let{afterKey:z=!1,implicitKey:q=!1,inFlow:J=!1,type:G}=Z,Q="indent"in $?$.indent:null;if(z&&typeof Q==="number")Q+=2;if(!G)switch($.type){case"single-quoted-scalar":G="QUOTE_SINGLE";break;case"double-quoted-scalar":G="QUOTE_DOUBLE";break;case"block-scalar":{let U=$.props[0];if(U.type!=="block-scalar-header")throw Error("Invalid block scalar header");G=U.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:G="PLAIN"}let Y=Z8.stringifyString({type:G,value:X},{implicitKey:q||Q===null,indent:Q!==null&&Q>0?" ".repeat(Q):"",inFlow:J,options:{blockQuote:!0,lineWidth:-1}});switch(Y[0]){case"|":case">":pQ($,Y);break;case'"':e9($,Y,"double-quoted-scalar");break;case"'":e9($,Y,"single-quoted-scalar");break;default:e9($,Y,"scalar")}}function pQ($,X){let Z=X.indexOf(`
|
|
138
|
+
`),z=X.substring(0,Z),q=X.substring(Z+1)+`
|
|
139
|
+
`;if($.type==="block-scalar"){let J=$.props[0];if(J.type!=="block-scalar-header")throw Error("Invalid block scalar header");J.source=z,$.source=q}else{let{offset:J}=$,G="indent"in $?$.indent:-1,Q=[{type:"block-scalar-header",offset:J,indent:G,source:z}];if(!z8(Q,"end"in $?$.end:void 0))Q.push({type:"newline",offset:-1,indent:G,source:`
|
|
140
|
+
`});for(let Y of Object.keys($))if(Y!=="type"&&Y!=="offset")delete $[Y];Object.assign($,{type:"block-scalar",indent:G,props:Q,source:q})}}function z8($,X){if(X)for(let Z of X)switch(Z.type){case"space":case"comment":$.push(Z);break;case"newline":return $.push(Z),!0}return!1}function e9($,X,Z){switch($.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":$.type=Z,$.source=X;break;case"block-scalar":{let z=$.props.slice(1),q=X.length;if($.props[0].type==="block-scalar-header")q-=$.props[0].source.length;for(let J of z)J.offset+=q;delete $.props,Object.assign($,{type:Z,source:X,end:z});break}case"block-map":case"block-seq":{let q={type:"newline",offset:$.offset+X.length,indent:$.indent,source:`
|
|
141
|
+
`};delete $.items,Object.assign($,{type:Z,source:X,end:[q]});break}default:{let z="indent"in $?$.indent:-1,q="end"in $&&Array.isArray($.end)?$.end.filter((J)=>J.type==="space"||J.type==="comment"||J.type==="newline"):[];for(let J of Object.keys($))if(J!=="type"&&J!=="offset")delete $[J];Object.assign($,{type:Z,indent:z,source:X,end:q})}}}lQ.createScalarToken=mQ;lQ.resolveAsScalar=uQ;lQ.setScalarValue=dQ});var J8=D((nQ)=>{var sQ=($)=>("type"in $)?o1($):r1($);function o1($){switch($.type){case"block-scalar":{let X="";for(let Z of $.props)X+=o1(Z);return X+$.source}case"block-map":case"block-seq":{let X="";for(let Z of $.items)X+=r1(Z);return X}case"flow-collection":{let X=$.start.source;for(let Z of $.items)X+=r1(Z);for(let Z of $.end)X+=Z.source;return X}case"document":{let X=r1($);if($.end)for(let Z of $.end)X+=Z.source;return X}default:{let X=$.source;if("end"in $&&$.end)for(let Z of $.end)X+=Z.source;return X}}}function r1({start:$,key:X,sep:Z,value:z}){let q="";for(let J of $)q+=J.source;if(X)q+=o1(X);if(Z)for(let J of Z)q+=J.source;if(z)q+=o1(z);return q}nQ.stringify=sQ});var Y8=D((tQ)=>{var $4=Symbol("break visit"),oQ=Symbol("skip children"),G8=Symbol("remove item");function y0($,X){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};Q8(Object.freeze([]),$,X)}y0.BREAK=$4;y0.SKIP=oQ;y0.REMOVE=G8;y0.itemAtPath=($,X)=>{let Z=$;for(let[z,q]of X){let J=Z?.[z];if(J&&"items"in J)Z=J.items[q];else return}return Z};y0.parentCollection=($,X)=>{let Z=y0.itemAtPath($,X.slice(0,-1)),z=X[X.length-1][0],q=Z?.[z];if(q&&"items"in q)return q;throw Error("Parent collection not found")};function Q8($,X,Z){let z=Z(X,$);if(typeof z==="symbol")return z;for(let q of["key","value"]){let J=X[q];if(J&&"items"in J){for(let G=0;G<J.items.length;++G){let Q=Q8(Object.freeze($.concat([[q,G]])),J.items[G],Z);if(typeof Q==="number")G=Q-1;else if(Q===$4)return $4;else if(Q===G8)J.items.splice(G,1),G-=1}if(typeof z==="function"&&q==="key")z=z(X,$)}}return typeof z==="function"?z(X,$):z}tQ.visit=y0});var t1=D((GY)=>{var X4=q8(),$Y=J8(),XY=Y8(),Z4="\uFEFF",z4="\x02",q4="\x18",J4="\x1F",ZY=($)=>!!$&&("items"in $),zY=($)=>!!$&&($.type==="scalar"||$.type==="single-quoted-scalar"||$.type==="double-quoted-scalar"||$.type==="block-scalar");function qY($){switch($){case Z4:return"<BOM>";case z4:return"<DOC>";case q4:return"<FLOW_END>";case J4:return"<SCALAR>";default:return JSON.stringify($)}}function JY($){switch($){case Z4:return"byte-order-mark";case z4:return"doc-mode";case q4:return"flow-error-end";case J4:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
142
142
|
`:case`\r
|
|
143
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch($[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}
|
|
144
|
-
`:case"\r":case"\t":return!0;default:return!1}}var
|
|
145
|
-
\r `),
|
|
146
|
-
`)return!0;if(
|
|
147
|
-
`;return!1}charAt($){return this.buffer[this.pos+$]}continueScalar($){let
|
|
148
|
-
`||!
|
|
149
|
-
`||
|
|
150
|
-
`,this.pos),this.lineEndPos=$;if($===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[$-1]==="\r")$-=1;return this.buffer.substring(this.pos,$)}hasChars($){return this.pos+$<=this.buffer.length}setNext($){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=$,null}peek($){return this.buffer.substr(this.pos,$)}*parseNext($){switch($){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let $=this.getLine();if($===null)return this.setNext("stream");if($[0]===
|
|
151
|
-
`,this.pos);if(
|
|
152
|
-
`,
|
|
153
|
-
`:$=
|
|
154
|
-
`)break}default:break $}if(!
|
|
155
|
-
`,
|
|
156
|
-
`)
|
|
157
|
-
`&&
|
|
158
|
-
`)
|
|
159
|
-
`,
|
|
160
|
-
`){let
|
|
143
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch($[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}GY.createScalarToken=X4.createScalarToken;GY.resolveAsScalar=X4.resolveAsScalar;GY.setScalarValue=X4.setScalarValue;GY.stringify=$Y.stringify;GY.visit=XY.visit;GY.BOM=Z4;GY.DOCUMENT=z4;GY.FLOW_END=q4;GY.SCALAR=J4;GY.isCollection=ZY;GY.isScalar=zY;GY.prettyToken=qY;GY.tokenType=JY});var Q4=D((wY)=>{var d$=t1();function X0($){switch($){case void 0:case" ":case`
|
|
144
|
+
`:case"\r":case"\t":return!0;default:return!1}}var U8=new Set("0123456789ABCDEFabcdef"),MY=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),e1=new Set(",[]{}"),OY=new Set(` ,[]{}
|
|
145
|
+
\r `),G4=($)=>!$||OY.has($);class H8{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex($,X=!1){if($){if(typeof $!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+$:$,this.lineEndPos=null}this.atEnd=!X;let Z=this.next??"stream";while(Z&&(X||this.hasChars(1)))Z=yield*this.parseNext(Z)}atLineEnd(){let $=this.pos,X=this.buffer[$];while(X===" "||X==="\t")X=this.buffer[++$];if(!X||X==="#"||X===`
|
|
146
|
+
`)return!0;if(X==="\r")return this.buffer[$+1]===`
|
|
147
|
+
`;return!1}charAt($){return this.buffer[this.pos+$]}continueScalar($){let X=this.buffer[$];if(this.indentNext>0){let Z=0;while(X===" ")X=this.buffer[++Z+$];if(X==="\r"){let z=this.buffer[Z+$+1];if(z===`
|
|
148
|
+
`||!z&&!this.atEnd)return $+Z+1}return X===`
|
|
149
|
+
`||Z>=this.indentNext||!X&&!this.atEnd?$+Z:-1}if(X==="-"||X==="."){let Z=this.buffer.substr($,3);if((Z==="---"||Z==="...")&&X0(this.buffer[$+3]))return-1}return $}getLine(){let $=this.lineEndPos;if(typeof $!=="number"||$!==-1&&$<this.pos)$=this.buffer.indexOf(`
|
|
150
|
+
`,this.pos),this.lineEndPos=$;if($===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[$-1]==="\r")$-=1;return this.buffer.substring(this.pos,$)}hasChars($){return this.pos+$<=this.buffer.length}setNext($){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=$,null}peek($){return this.buffer.substr(this.pos,$)}*parseNext($){switch($){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let $=this.getLine();if($===null)return this.setNext("stream");if($[0]===d$.BOM)yield*this.pushCount(1),$=$.substring(1);if($[0]==="%"){let X=$.length,Z=$.indexOf("#");while(Z!==-1){let q=$[Z-1];if(q===" "||q==="\t"){X=Z-1;break}else Z=$.indexOf("#",Z+1)}while(!0){let q=$[X-1];if(q===" "||q==="\t")X-=1;else break}let z=(yield*this.pushCount(X))+(yield*this.pushSpaces(!0));return yield*this.pushCount($.length-z),this.pushNewline(),"stream"}if(this.atLineEnd()){let X=yield*this.pushSpaces(!0);return yield*this.pushCount($.length-X),yield*this.pushNewline(),"stream"}return yield d$.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let $=this.charAt(0);if(!$&&!this.atEnd)return this.setNext("line-start");if($==="-"||$==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let X=this.peek(3);if((X==="---"||X==="...")&&X0(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,X==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!X0(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[$,X]=this.peek(2);if(!X&&!this.atEnd)return this.setNext("block-start");if(($==="-"||$==="?"||$===":")&&X0(X)){let Z=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=Z,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let $=this.getLine();if($===null)return this.setNext("doc");let X=yield*this.pushIndicators();switch($[X]){case"#":yield*this.pushCount($.length-X);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(G4),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return X+=yield*this.parseBlockScalarHeader(),X+=yield*this.pushSpaces(!0),yield*this.pushCount($.length-X),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let $,X,Z=-1;do{if($=yield*this.pushNewline(),$>0)X=yield*this.pushSpaces(!1),this.indentValue=Z=X;else X=0;X+=yield*this.pushSpaces(!0)}while($+X>0);let z=this.getLine();if(z===null)return this.setNext("flow");if(Z!==-1&&Z<this.indentNext&&z[0]!=="#"||Z===0&&(z.startsWith("---")||z.startsWith("..."))&&X0(z[3])){if(!(Z===this.indentNext-1&&this.flowLevel===1&&(z[0]==="]"||z[0]==="}")))return this.flowLevel=0,yield d$.FLOW_END,yield*this.parseLineStart()}let q=0;while(z[q]===",")q+=yield*this.pushCount(1),q+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(q+=yield*this.pushIndicators(),z[q]){case void 0:return"flow";case"#":return yield*this.pushCount(z.length-q),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(G4),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let J=this.charAt(1);if(this.flowKey||X0(J)||J===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let $=this.charAt(0),X=this.buffer.indexOf($,this.pos+1);if($==="'")while(X!==-1&&this.buffer[X+1]==="'")X=this.buffer.indexOf("'",X+2);else while(X!==-1){let q=0;while(this.buffer[X-1-q]==="\\")q+=1;if(q%2===0)break;X=this.buffer.indexOf('"',X+1)}let Z=this.buffer.substring(0,X),z=Z.indexOf(`
|
|
151
|
+
`,this.pos);if(z!==-1){while(z!==-1){let q=this.continueScalar(z+1);if(q===-1)break;z=Z.indexOf(`
|
|
152
|
+
`,q)}if(z!==-1)X=z-(Z[z-1]==="\r"?2:1)}if(X===-1){if(!this.atEnd)return this.setNext("quoted-scalar");X=this.buffer.length}return yield*this.pushToIndex(X+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let $=this.pos;while(!0){let X=this.buffer[++$];if(X==="+")this.blockScalarKeep=!0;else if(X>"0"&&X<="9")this.blockScalarIndent=Number(X)-1;else if(X!=="-")break}return yield*this.pushUntil((X)=>X0(X)||X==="#")}*parseBlockScalar(){let $=this.pos-1,X=0,Z;$:for(let q=this.pos;Z=this.buffer[q];++q)switch(Z){case" ":X+=1;break;case`
|
|
153
|
+
`:$=q,X=0;break;case"\r":{let J=this.buffer[q+1];if(!J&&!this.atEnd)return this.setNext("block-scalar");if(J===`
|
|
154
|
+
`)break}default:break $}if(!Z&&!this.atEnd)return this.setNext("block-scalar");if(X>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=X;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let q=this.continueScalar($+1);if(q===-1)break;$=this.buffer.indexOf(`
|
|
155
|
+
`,q)}while($!==-1);if($===-1){if(!this.atEnd)return this.setNext("block-scalar");$=this.buffer.length}}let z=$+1;Z=this.buffer[z];while(Z===" ")Z=this.buffer[++z];if(Z==="\t"){while(Z==="\t"||Z===" "||Z==="\r"||Z===`
|
|
156
|
+
`)Z=this.buffer[++z];$=z-1}else if(!this.blockScalarKeep)do{let q=$-1,J=this.buffer[q];if(J==="\r")J=this.buffer[--q];let G=q;while(J===" ")J=this.buffer[--q];if(J===`
|
|
157
|
+
`&&q>=this.pos&&q+1+X>G)$=q;else break}while(!0);return yield d$.SCALAR,yield*this.pushToIndex($+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let $=this.flowLevel>0,X=this.pos-1,Z=this.pos-1,z;while(z=this.buffer[++Z])if(z===":"){let q=this.buffer[Z+1];if(X0(q)||$&&e1.has(q))break;X=Z}else if(X0(z)){let q=this.buffer[Z+1];if(z==="\r")if(q===`
|
|
158
|
+
`)Z+=1,z=`
|
|
159
|
+
`,q=this.buffer[Z+1];else X=Z;if(q==="#"||$&&e1.has(q))break;if(z===`
|
|
160
|
+
`){let J=this.continueScalar(Z+1);if(J===-1)break;Z=Math.max(Z,J-2)}}else{if($&&e1.has(z))break;X=Z}if(!z&&!this.atEnd)return this.setNext("plain-scalar");return yield d$.SCALAR,yield*this.pushToIndex(X+1,!0),$?"flow":"doc"}*pushCount($){if($>0)return yield this.buffer.substr(this.pos,$),this.pos+=$,$;return 0}*pushToIndex($,X){let Z=this.buffer.slice(this.pos,$);if(Z)return yield Z,this.pos+=Z.length,Z.length;else if(X)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(G4))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let $=this.flowLevel>0,X=this.charAt(1);if(X0(X)||$&&e1.has(X)){if(!$)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let $=this.pos+2,X=this.buffer[$];while(!X0(X)&&X!==">")X=this.buffer[++$];return yield*this.pushToIndex(X===">"?$+1:$,!1)}else{let $=this.pos+1,X=this.buffer[$];while(X)if(MY.has(X))X=this.buffer[++$];else if(X==="%"&&U8.has(this.buffer[$+1])&&U8.has(this.buffer[$+2]))X=this.buffer[$+=3];else break;return yield*this.pushToIndex($,!1)}}*pushNewline(){let $=this.buffer[this.pos];if($===`
|
|
161
161
|
`)return yield*this.pushCount(1);else if($==="\r"&&this.charAt(1)===`
|
|
162
|
-
`)return yield*this.pushCount(2);else return 0}*pushSpaces($){let
|
|
163
|
-
`)+1;while(
|
|
164
|
-
`,
|
|
165
|
-
`)+1;while(
|
|
166
|
-
`,q)+1}return{type:$,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue($){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 q=o$($),z=j0(q);return z.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let q=o$($),z=j0(q);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,q){if(this.type!=="comment")return!1;if(this.indent<=q)return!1;return $.every((z)=>z.type==="newline"||z.type==="space")}*documentEnd($){if(this.type!=="doc-mode"){if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd($){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($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}oQ.Parser=I4});var P4=I((Q7)=>{var D4=w1(),eQ=t0(),Z$=e0(),$7=bq(),q7=A(),z7=b1(),R4=C1();function M4($){let q=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||q&&new z7.LineCounter||null,prettyErrors:q}}function X7($,q={}){let{lineCounter:z,prettyErrors:X}=M4(q),Z=new R4.Parser(z?.addNewLine),H=new D4.Composer(q),Q=Array.from(H.compose(Z.parse($)));if(X&&z)for(let J of Q)J.errors.forEach(Z$.prettifyError($,z)),J.warnings.forEach(Z$.prettifyError($,z));if(Q.length>0)return Q;return Object.assign([],{empty:!0},H.streamInfo())}function w4($,q={}){let{lineCounter:z,prettyErrors:X}=M4(q),Z=new R4.Parser(z?.addNewLine),H=new D4.Composer(q),Q=null;for(let J of H.compose(Z.parse($),!0,$.length))if(!Q)Q=J;else if(Q.options.logLevel!=="silent"){Q.errors.push(new Z$.YAMLParseError(J.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(X&&z)Q.errors.forEach(Z$.prettifyError($,z)),Q.warnings.forEach(Z$.prettifyError($,z));return Q}function Z7($,q,z){let X=void 0;if(typeof q==="function")X=q;else if(z===void 0&&q&&typeof q==="object")z=q;let Z=w4($,z);if(!Z)return null;if(Z.warnings.forEach((H)=>$7.warn(Z.options.logLevel,H)),Z.errors.length>0)if(Z.options.logLevel!=="silent")throw Z.errors[0];else Z.errors=[];return Z.toJS(Object.assign({reviver:X},z))}function H7($,q,z){let X=null;if(typeof q==="function"||Array.isArray(q))X=q;else if(z===void 0&&q)z=q;if(typeof z==="string")z=z.length;if(typeof z==="number"){let Z=Math.round(z);z=Z<1?void 0:Z>8?{indent:8}:{indent:Z}}if($===void 0){let{keepUndefined:Z}=z??q??{};if(!Z)return}if(q7.isDocument($)&&!X)return $.toString(z);return new eQ.Document($,X,z).toString(z)}Q7.parse=Z7;Q7.parseAllDocuments=X7;Q7.parseDocument=w4;Q7.stringify=H7});var O4=I((K7)=>{var B7=w1(),W7=t0(),T7=H1(),y1=e0(),L7=h0(),H0=A(),V7=$0(),_7=y(),I7=z0(),D7=X0(),R7=r$(),M7=E1(),w7=b1(),P7=C1(),t$=P4(),K4=k0();K7.Composer=B7.Composer;K7.Document=W7.Document;K7.Schema=T7.Schema;K7.YAMLError=y1.YAMLError;K7.YAMLParseError=y1.YAMLParseError;K7.YAMLWarning=y1.YAMLWarning;K7.Alias=L7.Alias;K7.isAlias=H0.isAlias;K7.isCollection=H0.isCollection;K7.isDocument=H0.isDocument;K7.isMap=H0.isMap;K7.isNode=H0.isNode;K7.isPair=H0.isPair;K7.isScalar=H0.isScalar;K7.isSeq=H0.isSeq;K7.Pair=V7.Pair;K7.Scalar=_7.Scalar;K7.YAMLMap=I7.YAMLMap;K7.YAMLSeq=D7.YAMLSeq;K7.CST=R7;K7.Lexer=M7.Lexer;K7.LineCounter=w7.LineCounter;K7.Parser=P7.Parser;K7.parse=t$.parse;K7.parseAllDocuments=t$.parseAllDocuments;K7.parseDocument=t$.parseDocument;K7.stringify=t$.stringify;K7.visit=K4.visit;K7.visitAsync=K4.visitAsync});var L2=o1(T2(),1),{program:_0,createCommand:EU,createArgument:bU,createOption:CU,CommanderError:yU,InvalidArgumentError:fU,InvalidOptionArgumentError:kU,Command:xU,Argument:hU,Option:Mq,Help:gU}=L2.default;var V2={name:"@pickled-dev/cli",version:"0.11.0",description:"Test what agents actually understand about your product",module:"dist/index.js",type:"module",bin:{pickled:"./dist/index.js"},files:["dist"],scripts:{dev:"bun run ./src/index.ts",build:"bun build ./src/index.ts --outdir ./dist --target bun --minify --external @anthropic-ai/claude-agent-sdk",release:"semantic-release"},dependencies:{commander:"^14.0.2",chalk:"^5.6.2","@anthropic-ai/claude-agent-sdk":"^0.3.0"},devDependencies:{"@pickled-dev/config":"workspace:*","@pickled-dev/core":"workspace:*","semantic-release":"^25.0.2","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/exec":"^7.1.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","semantic-release-ai-notes":"^0.3.0"}};import VU from"path";var l={category:"cli",provider:"claude-code",model:"sonnet"},wq=["Read","Glob","Grep","Bash"],Pq=["Edit","MultiEdit","Write","NotebookEdit"];var F4=o1(O4(),1);async function S0($){let q=`${$}/pickled.yml`,z=Bun.file(q);if(!await z.exists())throw Error(`pickled.yml not found in ${$}`);let X;try{let Z=await z.text();X=F4.default.parse(Z)}catch(Z){throw Error(`Failed to parse pickled.yml: ${Z}`)}return e7(X),X}function e7($){if(!$.tool?.name)throw Error("pickled.yml: 'tool.name' is required");if(!Array.isArray($.scenarios)||$.scenarios.length===0)throw Error("pickled.yml: 'scenarios' must be a non-empty array");if($.docs?.sources)for(let[z,X]of Object.entries($.docs.sources))qJ(z,X);if($.targets)for(let[z,X]of Object.entries($.targets)){if(X.systemPrompt!==void 0)throw Error(`pickled.yml: target "${z}" sets 'systemPrompt', which bypasses the citation contract. Remove it; custom prompts are not supported in citation mode.`);if(X.provider==="codex-cli"){if(!X.model)throw Error(`pickled.yml: target "${z}" (codex-cli) requires an explicit 'model' field. Codex's default model can change without notice; pin it for reproducible evals.`);if(X.maxTurns!==void 0)throw Error(`pickled.yml: target "${z}" (codex-cli) sets 'maxTurns', but the codex CLI does not support a turn cap. Remove the field.`)}}let q=new Set(Object.keys($.docs?.sources??{}));for(let z of $.scenarios){if(!z.name||!z.prompt)throw Error("pickled.yml: every scenario needs 'name' and 'prompt'");if(!Array.isArray(z.requiredSources))throw Error(`pickled.yml: scenario "${z.name}" is missing 'requiredSources' (use [] to allow any citation)`);for(let X of z.requiredSources)if(!q.has(X))throw Error(`pickled.yml: scenario "${z.name}" references unknown source "${X}". Declared sources: ${[...q].join(", ")||"(none)"}`);ZJ(z.name,z.traps),$J(z.name,z.compareSurfaces,q)}}function $J($,q,z){if(q===void 0)return;if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" compareSurfaces must be an array of source-id lists`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces cannot be empty (use a non-empty list of surfaces, or remove the field)`);for(let X=0;X<q.length;X++){let Z=q[X];if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${X}] must be an array of source ids`);if(Z.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${X}] must be a non-empty list of source ids`);for(let H of Z){if(typeof H!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${X}] entries must be string source ids`);if(!z.has(H))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${X}] references unknown source "${H}". Declared sources: ${[...z].join(", ")||"(none)"}`)}}}function qJ($,q){if(typeof q==="string"){if(q.length===0)throw Error(`pickled.yml: docs.sources["${$}"] string form must be a non-empty file path or URL`);return}if(!q||typeof q!=="object")throw Error(`pickled.yml: docs.sources["${$}"] must be a string (path/URL) or an object with a 'path' field`);let z=q;if(typeof z.path!=="string"||z.path.length===0)throw Error(`pickled.yml: docs.sources["${$}"] object form requires a non-empty 'path' field`);if(z.audit!==void 0){if(typeof z.audit!=="object"||z.audit===null)throw Error(`pickled.yml: docs.sources["${$}"].audit must be an object`);let X=z.audit;if(X.traps!==void 0&&typeof X.traps!=="boolean")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean`);for(let Z of Object.keys(X))if(Z!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${Z}"`)}for(let X of Object.keys(z))if(X!=="path"&&X!=="audit")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${X}"`)}var zJ=new Set(["g","y"]),XJ=new Set(["i","m","s","u","v"]);function ZJ($,q){if(q===void 0)return;if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" has non-array 'traps'`);let z=new Set;for(let X of q){if(!X.id||typeof X.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(z.has(X.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${X.id}"`);if(z.add(X.id),!X.reason||typeof X.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" requires non-empty 'reason'`);if(X.auditSeverity!==void 0&&X.auditSeverity!=="warning"&&X.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" auditSeverity must be "warning" or "error"`);let Z=typeof X.match==="string",H=typeof X.pattern==="string";if(Z===H)throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" must set exactly one of 'match' or 'pattern'`);if(Z){if(X.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" has empty 'match'`);if(X.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" sets 'flags' without 'pattern'`)}else{let Q=X.pattern;if(typeof Q!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" must set 'pattern'`);if(Q==="")throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" has empty 'pattern'`);if(X.flags!==void 0){if(typeof X.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" has non-string 'flags'`);for(let J of X.flags){if(zJ.has(J))throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" uses forbidden regex flag "${J}" (g and y are not allowed)`);if(!XJ.has(J))throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" uses unsupported regex flag "${J}"`)}}try{new RegExp(Q,X.flags??"")}catch(J){throw Error(`pickled.yml: scenario "${$}" trap "${X.id}" has invalid regex pattern: ${J instanceof Error?J.message:J}`)}}}}function f1($,q){let z=new Set([...Object.keys($.targets??{}),"default"]);if(!z.has(q)){let X=[...z].sort().join(", ");throw Error(`Unknown target: "${q}". Available targets: ${X}`)}return{...$,matrix:{...$.matrix,target:[q]},scenarios:$.scenarios.filter((X)=>!X.target||X.target===q)}}function k1($){if(typeof $==="string")return{path:$,auditTraps:!0};return{path:$.path,auditTraps:$.audit?.traps??!0}}function e$($){let{config:q,files:z,pairs:X,findings:Z}=$,H=[],Q=Z.filter((Y)=>Y.severity==="error").length,J=Z.filter((Y)=>Y.severity==="warning").length;if(H.push(`# Agent-context audit
|
|
167
|
-
`),
|
|
168
|
-
`),
|
|
169
|
-
`),
|
|
170
|
-
`);else{
|
|
171
|
-
`),
|
|
172
|
-
`);else{
|
|
173
|
-
`),
|
|
174
|
-
`);else for(let
|
|
175
|
-
`),
|
|
176
|
-
`),
|
|
177
|
-
`);else for(let
|
|
178
|
-
`);for(let
|
|
179
|
-
`),
|
|
180
|
-
`);else for(let
|
|
181
|
-
`),
|
|
182
|
-
`),
|
|
183
|
-
`),
|
|
184
|
-
`);else{for(let
|
|
185
|
-
`)}function
|
|
186
|
-
`)}function
|
|
187
|
-
`)
|
|
188
|
-
`)?
|
|
189
|
-
`),z=[],X=null;if(q.forEach((Z,H)=>{if(/^##\s+/.test(Z)){if(X)z.push({header:X.header,lines:H-X.start});X={header:Z.replace(/^##\s+/,"").trim(),start:H}}}),X){let Z=X;z.push({header:Z.header,lines:q.length-Z.start})}return z.sort((Z,H)=>H.lines-Z.lines)}function jJ($){if($.length===0||$.length>160)return!1;if(!$.includes("/"))return!1;if(/\s/.test($))return!1;if(/^https?:\/\//.test($))return!1;if(/[*?{}[\]<>]/.test($))return!1;if($.startsWith("@"))return!1;if($.startsWith("~/"))return!1;if(/^[a-z]+:\/\//i.test($))return!1;if(/^cdn\./.test($)||/^unpkg\./.test($)||/^npm\./.test($))return!1;if(/^\/[a-z]/.test($)&&/(?:icon|image|img|asset|file|path)/i.test($))return!1;if(/^(cd|pnpm|npm|yarn|bun|node|git|ls|cat|grep|find|sed|awk|mkdir|rm|mv|cp|echo|export|source|sudo|brew|docker|curl|wget)\b/.test($))return!1;return/[a-zA-Z0-9_.-]\/[a-zA-Z0-9_.-]/.test($)}function SJ($){return $.replace(/```[\s\S]*?```/g,"")}function NJ($,q){let z=new Map;for(let H of $){let Q=H.relPath.split("/").pop()??"";if(Q!=="AGENTS.md"&&Q!=="CLAUDE.md")continue;let J=Hq(H.relPath),G=z.get(J)??{};if(Q==="AGENTS.md")G.agents=H;if(Q==="CLAUDE.md")G.claude=H;z.set(J,G)}let X=new Set(q.intentionalDifferentPairs),Z=[];for(let[H,Q]of z){let J=!!Q.agents,G=!!Q.claude;if(!J&&!G)continue;if(!J||!G){Z.push({dir:H,agentsExists:J,claudeExists:G,classification:"single",detail:J?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:U,claude:B}=Q,Y=`${U.relPath}:${B.relPath}`,W=`${B.relPath}:${U.relPath}`;if(X.has(Y)||X.has(W)){Z.push({dir:H,agentsExists:J,claudeExists:G,classification:"intentional-different",detail:`allowlisted: ${U.lineCount}L vs ${B.lineCount}L`});continue}if(U.isSymlink&&U.symlinkTarget===B.absPath||B.isSymlink&&B.symlinkTarget===U.absPath){let V=U.isSymlink?"CLAUDE.md":"AGENTS.md";Z.push({dir:H,agentsExists:J,claudeExists:G,classification:"linked",detail:`canonical: ${V}`});continue}let _=Zq(U.absPath,"utf8"),T=Zq(B.absPath,"utf8");if(_===T)Z.push({dir:H,agentsExists:J,claudeExists:G,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${U.lineCount}L), not symlinked`});else Z.push({dir:H,agentsExists:J,claudeExists:G,classification:"unexpected-duplicate",detail:`divergent (${U.lineCount}L vs ${B.lineCount}L), not in intentional-different allowlist`})}return Z.sort((H,Q)=>H.dir.localeCompare(Q.dir)),Z}function EJ($,q,z){let X=[];for(let Z of $){if(Z.isSymlink)continue;for(let J of Z.brokenImports)X.push({severity:"error",category:"broken-import",file:Z.relPath,message:`broken @-import: ${J}`});for(let J of Z.brokenPathRefs)X.push({severity:"error",category:"broken-path-ref",file:Z.relPath,message:`broken path reference: ${J}`});for(let J of Z.unresolvedCommands)X.push({severity:"warning",category:"unresolved-command",file:Z.relPath,message:`unresolved command: ${J}`});let H=!Z.relPath.includes("/"),Q=H?z.budgets.rootLines:z.budgets.nestedWarnLines;if(Z.lineCount>Q)X.push({severity:"warning",category:"over-budget",file:Z.relPath,message:`${Z.lineCount} lines exceeds ${H?"root":"nested"} budget of ${Q}`})}for(let Z of q)if(Z.classification==="unexpected-duplicate"){let H=Z.detail.startsWith("divergent")?"error":"warning";X.push({severity:H,category:H==="error"?"divergent-pair":"duplicate-pair",file:Z.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${Z.detail}`})}return X}function L0($){let q=$.confidence;if($.error)return{icon:"\u2717",label:"Error",confidence:q,tone:"error"};if($.traps.fired.length>0)return{icon:"\u2717",label:"Trap fired",confidence:q,tone:"error"};if($.answerable==="YES")return{icon:"\u2713",label:q>=90?"Well grounded":"Grounded",confidence:q,tone:"success"};if($.answerable==="PARTIAL")return{icon:"\u26A0",label:"Partially grounded",confidence:q,tone:"warning"};return{icon:"\u2717",label:"Ungrounded",confidence:q,tone:"error"}}function v1($){let q=bJ($);if(q===null)return[];let z=[],X=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,Z=X.exec(q);while(Z!==null)z.push({id:Z[1].trim(),note:Z[2].trim()||void 0}),Z=X.exec(q);return z}function bJ($){let z=/^##\s+Sources\s*$/im.exec($);if(!z)return null;let X=z.index+z[0].length,Z=$.slice(X),H=/^##\s+/m.exec(Z);return H?Z.slice(0,H.index):Z}function Q$($){let q=v1($.response),z=new Set(q.map((W)=>W.id)),X=new Set($.registeredIds),Z=new Set($.requiredSources),H=[...z],Q=[...Z].filter((W)=>!z.has(W)),J=[...z].filter((W)=>!X.has(W)),G=[...Z],U,B,Y;if(H.length===0)U="NO",B=0,Y="No citations in response";else if(J.length===H.length)U="NO",B=0,Y=`All cited sources are unknown: ${J.join(", ")}`;else if(Q.length===0&&J.length===0)U="YES",B=100,Y=G.length>0?`All required sources cited: ${G.join(", ")}`:`Cited registered sources: ${H.join(", ")}`;else{U="PARTIAL";let W=G.length>0?G.length:1,L=G.length-Q.length,_=G.length>0?L/W*100:60,T=J.length*15;B=Math.max(0,Math.min(100,Math.round(_-T)));let V=[];if(Q.length>0)V.push(`missing: ${Q.join(", ")}`);if(J.length>0)V.push(`unknown: ${J.join(", ")}`);Y=V.join("; ")}return{answerable:U,confidence:B,reason:Y,citations:{cited:H,required:G,missing:Q,unknown:J}}}import{query as CJ}from"@anthropic-ai/claude-agent-sdk";function Jq($,q,z){let X=q.length>0?q.map((Q)=>`- ${Q.id}: ${Q.name} (${Q.source})`).join(`
|
|
190
|
-
`)
|
|
191
|
-
${Q.
|
|
162
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces($){let X=this.pos-1,Z;do Z=this.buffer[++X];while(Z===" "||$&&Z==="\t");let z=X-this.pos;if(z>0)yield this.buffer.substr(this.pos,z),this.pos=X;return z}*pushUntil($){let X=this.pos,Z=this.buffer[X];while(!$(Z))Z=this.buffer[++X];return yield*this.pushToIndex(X,!1)}}wY.Lexer=H8});var Y4=D((RY)=>{class W8{constructor(){this.lineStarts=[],this.addNewLine=($)=>this.lineStarts.push($),this.linePos=($)=>{let X=0,Z=this.lineStarts.length;while(X<Z){let q=X+Z>>1;if(this.lineStarts[q]<$)X=q+1;else Z=q}if(this.lineStarts[X]===$)return{line:X+1,col:1};if(X===0)return{line:0,col:$};let z=this.lineStarts[X-1];return{line:X,col:$-z+1}}}}RY.LineCounter=W8});var U4=D((jY)=>{var NY=Q0("process"),V8=t1(),AY=Q4();function w0($,X){for(let Z=0;Z<$.length;++Z)if($[Z].type===X)return!0;return!1}function T8($){for(let X=0;X<$.length;++X)switch($[X].type){case"space":case"comment":case"newline":break;default:return X}return-1}function K8($){switch($?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function $2($){switch($.type){case"document":return $.start;case"block-map":{let X=$.items[$.items.length-1];return X.sep??X.start}case"block-seq":return $.items[$.items.length-1].start;default:return[]}}function X$($){if($.length===0)return[];let X=$.length;$:while(--X>=0)switch($[X].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break $}while($[++X]?.type==="space");return $.splice(X,$.length)}function B8($){if($.start.type==="flow-seq-start"){for(let X of $.items)if(X.sep&&!X.value&&!w0(X.start,"explicit-key-ind")&&!w0(X.sep,"map-value-ind")){if(X.key)X.value=X.key;if(delete X.key,K8(X.value))if(X.value.end)Array.prototype.push.apply(X.value.end,X.sep);else X.value.end=X.sep;else Array.prototype.push.apply(X.start,X.sep);delete X.sep}}}class L8{constructor($){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new AY.Lexer,this.onNewLine=$}*parse($,X=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let Z of this.lexer.lex($,X))yield*this.next(Z);if(!X)yield*this.end()}*next($){if(this.source=$,NY.env.LOG_TOKENS)console.log("|",V8.prettyToken($));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=$.length;return}let X=V8.tokenType($);if(!X){let Z=`Not a YAML token: ${$}`;yield*this.pop({type:"error",offset:this.offset,message:Z,source:$}),this.offset+=$.length}else if(X==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=X,yield*this.step(),X){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+$.length);break;case"space":if(this.atNewLine&&$[0]===" ")this.indent+=$.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=$.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=$.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let $=this.peek(1);if(this.type==="doc-end"&&$?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!$)return yield*this.stream();switch($.type){case"document":return yield*this.document($);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar($);case"block-scalar":return yield*this.blockScalar($);case"block-map":return yield*this.blockMap($);case"block-seq":return yield*this.blockSequence($);case"flow-collection":return yield*this.flowCollection($);case"doc-end":return yield*this.documentEnd($)}yield*this.pop()}peek($){return this.stack[this.stack.length-$]}*pop($){let X=$??this.stack.pop();if(!X)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield X;else{let Z=this.peek(1);if(X.type==="block-scalar")X.indent="indent"in Z?Z.indent:0;else if(X.type==="flow-collection"&&Z.type==="document")X.indent=0;if(X.type==="flow-collection")B8(X);switch(Z.type){case"document":Z.value=X;break;case"block-scalar":Z.props.push(X);break;case"block-map":{let z=Z.items[Z.items.length-1];if(z.value){Z.items.push({start:[],key:X,sep:[]}),this.onKeyLine=!0;return}else if(z.sep)z.value=X;else{Object.assign(z,{key:X,sep:[]}),this.onKeyLine=!z.explicitKey;return}break}case"block-seq":{let z=Z.items[Z.items.length-1];if(z.value)Z.items.push({start:[],value:X});else z.value=X;break}case"flow-collection":{let z=Z.items[Z.items.length-1];if(!z||z.value)Z.items.push({start:[],key:X,sep:[]});else if(z.sep)z.value=X;else Object.assign(z,{key:X,sep:[]});return}default:yield*this.pop(),yield*this.pop(X)}if((Z.type==="document"||Z.type==="block-map"||Z.type==="block-seq")&&(X.type==="block-map"||X.type==="block-seq")){let z=X.items[X.items.length-1];if(z&&!z.sep&&!z.value&&z.start.length>0&&T8(z.start)===-1&&(X.indent===0||z.start.every((q)=>q.type!=="comment"||q.indent<X.indent))){if(Z.type==="document")Z.end=z.start;else Z.items.push({start:z.start});X.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let $={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")$.start.push(this.sourceToken);this.stack.push($);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document($){if($.value)return yield*this.lineEnd($);switch(this.type){case"doc-start":{if(T8($.start)!==-1)yield*this.pop(),yield*this.step();else $.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":$.start.push(this.sourceToken);return}let X=this.startBlockValue($);if(X)this.stack.push(X);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar($){if(this.type==="map-value-ind"){let X=$2(this.peek(2)),Z=X$(X),z;if($.end)z=$.end,z.push(this.sourceToken),delete $.end;else z=[this.sourceToken];let q={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:Z,key:$,sep:z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=q}else yield*this.lineEnd($)}*blockScalar($){switch(this.type){case"space":case"comment":case"newline":$.props.push(this.sourceToken);return;case"scalar":if($.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let X=this.source.indexOf(`
|
|
163
|
+
`)+1;while(X!==0)this.onNewLine(this.offset+X),X=this.source.indexOf(`
|
|
164
|
+
`,X)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap($){let X=$.items[$.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,X.value){let Z="end"in X.value?X.value.end:void 0;if((Array.isArray(Z)?Z[Z.length-1]:void 0)?.type==="comment")Z?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)$.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else{if(this.atIndentedComment(X.start,$.indent)){let z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,X.start),z.push(this.sourceToken),$.items.pop();return}}X.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let Z=!this.onKeyLine&&this.indent===$.indent,z=Z&&(X.sep||X.explicitKey)&&this.type!=="seq-item-ind",q=[];if(z&&X.sep&&!X.value){let J=[];for(let G=0;G<X.sep.length;++G){let Q=X.sep[G];switch(Q.type){case"newline":J.push(G);break;case"space":break;case"comment":if(Q.indent>$.indent)J.length=0;break;default:J.length=0}}if(J.length>=2)q=X.sep.splice(J[1])}switch(this.type){case"anchor":case"tag":if(z||X.value)q.push(this.sourceToken),$.items.push({start:q}),this.onKeyLine=!0;else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"explicit-key-ind":if(!X.sep&&!X.explicitKey)X.start.push(this.sourceToken),X.explicitKey=!0;else if(z||X.value)q.push(this.sourceToken),$.items.push({start:q,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(X.explicitKey)if(!X.sep)if(w0(X.start,"newline"))Object.assign(X,{key:null,sep:[this.sourceToken]});else{let J=X$(X.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:J,key:null,sep:[this.sourceToken]}]})}else if(X.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(w0(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]});else if(K8(X.key)&&!w0(X.sep,"newline")){let J=X$(X.start),G=X.key,Q=X.sep;Q.push(this.sourceToken),delete X.key,delete X.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:J,key:G,sep:Q}]})}else if(q.length>0)X.sep=X.sep.concat(q,this.sourceToken);else X.sep.push(this.sourceToken);else if(!X.sep)Object.assign(X,{key:null,sep:[this.sourceToken]});else if(X.value||z)$.items.push({start:q,key:null,sep:[this.sourceToken]});else if(w0(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else X.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let J=this.flowScalar(this.type);if(z||X.value)$.items.push({start:q,key:J,sep:[]}),this.onKeyLine=!0;else if(X.sep)this.stack.push(J);else Object.assign(X,{key:J,sep:[]}),this.onKeyLine=!0;return}default:{let J=this.startBlockValue($);if(J){if(J.type==="block-seq"){if(!X.explicitKey&&X.sep&&!w0(X.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(Z)$.items.push({start:q});this.stack.push(J);return}}}}yield*this.pop(),yield*this.step()}*blockSequence($){let X=$.items[$.items.length-1];switch(this.type){case"newline":if(X.value){let Z="end"in X.value?X.value.end:void 0;if((Array.isArray(Z)?Z[Z.length-1]:void 0)?.type==="comment")Z?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else X.start.push(this.sourceToken);return;case"space":case"comment":if(X.value)$.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(X.start,$.indent)){let z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,X.start),z.push(this.sourceToken),$.items.pop();return}}X.start.push(this.sourceToken)}return;case"anchor":case"tag":if(X.value||this.indent<=$.indent)break;X.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==$.indent)break;if(X.value||w0(X.start,"seq-item-ind"))$.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return}if(this.indent>$.indent){let Z=this.startBlockValue($);if(Z){this.stack.push(Z);return}}yield*this.pop(),yield*this.step()}*flowCollection($){let X=$.items[$.items.length-1];if(this.type==="flow-error-end"){let Z;do yield*this.pop(),Z=this.peek(1);while(Z?.type==="flow-collection")}else if($.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!X||X.sep)$.items.push({start:[this.sourceToken]});else X.start.push(this.sourceToken);return;case"map-value-ind":if(!X||X.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else Object.assign(X,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!X||X.value)$.items.push({start:[this.sourceToken]});else if(X.sep)X.sep.push(this.sourceToken);else X.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let z=this.flowScalar(this.type);if(!X||X.value)$.items.push({start:[],key:z,sep:[]});else if(X.sep)this.stack.push(z);else Object.assign(X,{key:z,sep:[]});return}case"flow-map-end":case"flow-seq-end":$.end.push(this.sourceToken);return}let Z=this.startBlockValue($);if(Z)this.stack.push(Z);else yield*this.pop(),yield*this.step()}else{let Z=this.peek(2);if(Z.type==="block-map"&&(this.type==="map-value-ind"&&Z.indent===$.indent||this.type==="newline"&&!Z.items[Z.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&Z.type!=="flow-collection"){let z=$2(Z),q=X$(z);B8($);let J=$.end.splice(1,$.end.length);J.push(this.sourceToken);let G={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:q,key:$,sep:J}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=G}else yield*this.lineEnd($)}}flowScalar($){if(this.onNewLine){let X=this.source.indexOf(`
|
|
165
|
+
`)+1;while(X!==0)this.onNewLine(this.offset+X),X=this.source.indexOf(`
|
|
166
|
+
`,X)+1}return{type:$,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue($){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 X=$2($),Z=X$(X);return Z.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Z,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let X=$2($),Z=X$(X);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Z,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,X){if(this.type!=="comment")return!1;if(this.indent<=X)return!1;return $.every((Z)=>Z.type==="newline"||Z.type==="space")}*documentEnd($){if(this.type!=="doc-mode"){if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd($){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($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}jY.Parser=L8});var O8=D((gY)=>{var D8=t9(),CY=g$(),p$=h$(),EY=Y9(),bY=S(),xY=Y4(),_8=U4();function F8($){let X=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||X&&new xY.LineCounter||null,prettyErrors:X}}function yY($,X={}){let{lineCounter:Z,prettyErrors:z}=F8(X),q=new _8.Parser(Z?.addNewLine),J=new D8.Composer(X),G=Array.from(J.compose(q.parse($)));if(z&&Z)for(let Q of G)Q.errors.forEach(p$.prettifyError($,Z)),Q.warnings.forEach(p$.prettifyError($,Z));if(G.length>0)return G;return Object.assign([],{empty:!0},J.streamInfo())}function M8($,X={}){let{lineCounter:Z,prettyErrors:z}=F8(X),q=new _8.Parser(Z?.addNewLine),J=new D8.Composer(X),G=null;for(let Q of J.compose(q.parse($),!0,$.length))if(!G)G=Q;else if(G.options.logLevel!=="silent"){G.errors.push(new p$.YAMLParseError(Q.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(z&&Z)G.errors.forEach(p$.prettifyError($,Z)),G.warnings.forEach(p$.prettifyError($,Z));return G}function kY($,X,Z){let z=void 0;if(typeof X==="function")z=X;else if(Z===void 0&&X&&typeof X==="object")Z=X;let q=M8($,Z);if(!q)return null;if(q.warnings.forEach((J)=>EY.warn(q.options.logLevel,J)),q.errors.length>0)if(q.options.logLevel!=="silent")throw q.errors[0];else q.errors=[];return q.toJS(Object.assign({reviver:z},Z))}function fY($,X,Z){let z=null;if(typeof X==="function"||Array.isArray(X))z=X;else if(Z===void 0&&X)Z=X;if(typeof Z==="string")Z=Z.length;if(typeof Z==="number"){let q=Math.round(Z);Z=q<1?void 0:q>8?{indent:8}:{indent:q}}if($===void 0){let{keepUndefined:q}=Z??X??{};if(!q)return}if(bY.isDocument($)&&!z)return $.toString(Z);return new CY.Document($,z,Z).toString(Z)}gY.parse=kY;gY.parseAllDocuments=yY;gY.parseDocument=M8;gY.stringify=fY});var I8=D(($U)=>{var dY=t9(),pY=g$(),lY=f9(),H4=h$(),cY=w$(),I0=S(),iY=_0(),aY=g(),sY=M0(),nY=O0(),rY=t1(),oY=Q4(),tY=Y4(),eY=U4(),X2=O8(),w8=M$();$U.Composer=dY.Composer;$U.Document=pY.Document;$U.Schema=lY.Schema;$U.YAMLError=H4.YAMLError;$U.YAMLParseError=H4.YAMLParseError;$U.YAMLWarning=H4.YAMLWarning;$U.Alias=cY.Alias;$U.isAlias=I0.isAlias;$U.isCollection=I0.isCollection;$U.isDocument=I0.isDocument;$U.isMap=I0.isMap;$U.isNode=I0.isNode;$U.isPair=I0.isPair;$U.isScalar=I0.isScalar;$U.isSeq=I0.isSeq;$U.Pair=iY.Pair;$U.Scalar=aY.Scalar;$U.YAMLMap=sY.YAMLMap;$U.YAMLSeq=nY.YAMLSeq;$U.CST=rY;$U.Lexer=oY.Lexer;$U.LineCounter=tY.LineCounter;$U.Parser=eY.Parser;$U.parse=X2.parse;$U.parseAllDocuments=X2.parseAllDocuments;$U.parseDocument=X2.parseDocument;$U.stringify=X2.stringify;$U.visit=w8.visit;$U.visitAsync=w8.visitAsync});var TX=r4(VX(),1),{program:l0,createCommand:nW,createArgument:rW,createOption:oW,CommanderError:tW,InvalidArgumentError:eW,InvalidOptionArgumentError:$V,Command:XV,Argument:ZV,Option:o2,Help:zV}=TX.default;var BX={name:"@pickled-dev/cli",version:"0.13.0",description:"Test what agents actually understand about your product",module:"dist/index.js",type:"module",bin:{pickled:"./dist/index.js"},files:["dist"],scripts:{dev:"bun run ./src/index.ts",build:"bun build ./src/index.ts --outdir ./dist --target bun --minify --external @anthropic-ai/claude-agent-sdk",release:"semantic-release"},dependencies:{commander:"^14.0.2",chalk:"^5.6.2","@anthropic-ai/claude-agent-sdk":"^0.3.0"},devDependencies:{"@pickled-dev/config":"workspace:*","@pickled-dev/core":"workspace:*","semantic-release":"^25.0.2","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/exec":"^7.1.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","semantic-release-ai-notes":"^0.3.0"}};import yW from"path";var q0={category:"cli",provider:"claude-code",model:"sonnet"},t2=["Read","Glob","Grep","Bash"],e2=["Edit","MultiEdit","Write","NotebookEdit"];var R8=r4(I8(),1);async function Z$($){let X=`${$}/pickled.yml`,Z=Bun.file(X);if(!await Z.exists())throw Error(`pickled.yml not found in ${$}`);let z;try{let q=await Z.text();z=R8.default.parse(q)}catch(q){throw Error(`Failed to parse pickled.yml: ${q}`)}return CU(z),z}function CU($){if(!$.tool?.name)throw Error("pickled.yml: 'tool.name' is required");if(!Array.isArray($.scenarios)||$.scenarios.length===0)throw Error("pickled.yml: 'scenarios' must be a non-empty array");if($.docs?.sources)for(let[Z,z]of Object.entries($.docs.sources))xU(Z,z);if($.targets)for(let[Z,z]of Object.entries($.targets)){if(z.systemPrompt!==void 0)throw Error(`pickled.yml: target "${Z}" sets 'systemPrompt', which bypasses the citation contract. Remove it; custom prompts are not supported in citation mode.`);if(z.provider==="codex-cli"){if(!z.model)throw Error(`pickled.yml: target "${Z}" (codex-cli) requires an explicit 'model' field. Codex's default model can change without notice; pin it for reproducible evals.`);if(z.maxTurns!==void 0)throw Error(`pickled.yml: target "${Z}" (codex-cli) sets 'maxTurns', but the codex CLI does not support a turn cap. Remove the field.`)}if(z.category==="api"){if(!z.model)throw Error(`pickled.yml: target "${Z}" (api/${z.provider}) requires an explicit 'model' field. Pickled does not substitute a default; reproducible evals depend on pinning the model.`);let q=["allowedTools","disallowedTools","mcpServers","permissionMode","maxTurns","maxThinkingTokens","maxBudgetUsd"];for(let J of q)if(z[J]!==void 0)throw Error(`pickled.yml: target "${Z}" (api/${z.provider}) sets '${J}', which only applies to CLI/Agent SDK targets. Remove the field; API targets accept only model/temperature/maxTokens/threshold.`);if(z.workspaceContext!==void 0)throw Error(`pickled.yml: target "${Z}" (api/${z.provider}) sets 'workspaceContext', which only applies to IDE targets. Remove the field.`)}}let X=new Set(Object.keys($.docs?.sources??{}));for(let Z of $.scenarios){if(!Z.name||!Z.prompt)throw Error("pickled.yml: every scenario needs 'name' and 'prompt'");if(!Array.isArray(Z.requiredSources))throw Error(`pickled.yml: scenario "${Z.name}" is missing 'requiredSources' (use [] to allow any citation)`);for(let z of Z.requiredSources)if(!X.has(z))throw Error(`pickled.yml: scenario "${Z.name}" references unknown source "${z}". Declared sources: ${[...X].join(", ")||"(none)"}`);fU(Z.name,Z.traps),bU(Z.name,Z.compareSurfaces,X)}EU($)}function EU($){if(!$.docs?.sources)return;let X=[];for(let[z,q]of Object.entries($.docs.sources)){if(typeof q==="string")continue;let J=q.audit?.traps;if(Array.isArray(J))X.push({id:z,list:J})}if(X.length===0)return;let Z=new Map;for(let z of $.scenarios)for(let q of z.traps??[]){let J=Z.get(q.id);if(J!==void 0)throw Error(`pickled.yml: trap id "${q.id}" is declared in both scenario "${J}" and scenario "${z.name}". Globally unique trap ids are required when any source uses list-form audit.traps suppression. Rename one of the traps.`);Z.set(q.id,z.name)}for(let{id:z,list:q}of X)for(let J of q)if(!Z.has(J)){let G=[...Z.keys()].join(", ")||"(none)";throw Error(`pickled.yml: docs.sources["${z}"].audit.traps lists unknown trap id "${J}". Declared trap ids: ${G}`)}}function bU($,X,Z){if(X===void 0)return;if(!Array.isArray(X))throw Error(`pickled.yml: scenario "${$}" compareSurfaces must be an array of source-id lists`);if(X.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces cannot be empty (use a non-empty list of surfaces, or remove the field)`);for(let z=0;z<X.length;z++){let q=X[z];if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be an array of source ids`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be a non-empty list of source ids`);for(let J of q){if(typeof J!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] entries must be string source ids`);if(!Z.has(J))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] references unknown source "${J}". Declared sources: ${[...Z].join(", ")||"(none)"}`)}}}function xU($,X){if(typeof X==="string"){if(X.length===0)throw Error(`pickled.yml: docs.sources["${$}"] string form must be a non-empty file path or URL`);return}if(!X||typeof X!=="object")throw Error(`pickled.yml: docs.sources["${$}"] must be a string (path/URL) or an object with a 'path' field`);let Z=X;if(typeof Z.path!=="string"||Z.path.length===0)throw Error(`pickled.yml: docs.sources["${$}"] object form requires a non-empty 'path' field`);if(Z.audit!==void 0){if(typeof Z.audit!=="object"||Z.audit===null)throw Error(`pickled.yml: docs.sources["${$}"].audit must be an object`);let z=Z.audit;if(z.traps!==void 0){let q=z.traps;if(typeof q==="boolean");else if(Array.isArray(q)){if(q.length===0)throw Error(`pickled.yml: docs.sources["${$}"].audit.traps cannot be an empty array; use true (scan all) or false (skip all) instead`);for(let J=0;J<q.length;J++)if(typeof q[J]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps[${J}] must be a string trap id`)}else throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean or an array of trap ids`)}for(let q of Object.keys(z))if(q!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${q}"`)}for(let z of Object.keys(Z))if(z!=="path"&&z!=="audit")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${z}"`)}var yU=new Set(["g","y"]),kU=new Set(["i","m","s","u","v"]);function fU($,X){if(X===void 0)return;if(!Array.isArray(X))throw Error(`pickled.yml: scenario "${$}" has non-array 'traps'`);let Z=new Set;for(let z of X){if(!z.id||typeof z.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(Z.has(z.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${z.id}"`);if(Z.add(z.id),!z.reason||typeof z.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" requires non-empty 'reason'`);if(z.auditSeverity!==void 0&&z.auditSeverity!=="warning"&&z.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" auditSeverity must be "warning" or "error"`);let q=typeof z.match==="string",J=typeof z.pattern==="string";if(q===J)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set exactly one of 'match' or 'pattern'`);if(q){if(z.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'match'`);if(z.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" sets 'flags' without 'pattern'`)}else{let G=z.pattern;if(typeof G!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set 'pattern'`);if(G==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'pattern'`);if(z.flags!==void 0){if(typeof z.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has non-string 'flags'`);for(let Q of z.flags){if(yU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses forbidden regex flag "${Q}" (g and y are not allowed)`);if(!kU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses unsupported regex flag "${Q}"`)}}try{new RegExp(G,z.flags??"")}catch(Q){throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has invalid regex pattern: ${Q instanceof Error?Q.message:Q}`)}}}}function W4($,X){let Z=new Set([...Object.keys($.targets??{}),"default"]);if(!Z.has(X)){let z=[...Z].sort().join(", ");throw Error(`Unknown target: "${X}". Available targets: ${z}`)}return{...$,matrix:{...$.matrix,target:[X]},scenarios:$.scenarios.filter((z)=>!z.target||z.target===X)}}function V4($){if(typeof $==="string")return{path:$,auditTraps:!0};return{path:$.path,auditTraps:$.audit?.traps??!0}}function Z2($){let{config:X,files:Z,pairs:z,findings:q}=$,J=[],G=q.filter((H)=>H.severity==="error").length,Q=q.filter((H)=>H.severity==="warning").length;if(J.push(`# Agent-context audit
|
|
167
|
+
`),J.push(`Target: \`${X.targetRepo}\``),J.push(`Budgets: root \u2264 ${X.budgets.rootLines} lines, nested warn at ${X.budgets.nestedWarnLines} lines.`),J.push(`Found ${Z.length} agent-doc files. ${G} error(s), ${Q} warning(s).
|
|
168
|
+
`),J.push(`## Inventory
|
|
169
|
+
`),Z.length===0)J.push(`No agent-doc files found.
|
|
170
|
+
`);else{J.push("| File | Lines | Kind | Notes |"),J.push("|---|---|---|---|");let H=[...Z].sort((V,B)=>B.lineCount-V.lineCount);for(let V of H){let B=!V.relPath.includes("/"),L=P8(V.lineCount,B,X),T=V.isSymlink?`symlink \u2192 ${V.symlinkTarget?.replace(`${X.targetRepo}/`,"")??"?"}`:"file";J.push(`| \`${V.relPath}\` | ${V.lineCount} | ${T} | ${L} |`)}J.push("")}if(J.push(`## AGENTS.md / CLAUDE.md pairs
|
|
171
|
+
`),z.length===0)J.push(`No pairs found.
|
|
172
|
+
`);else{J.push("| Directory | A | C | Class | Detail |"),J.push("|---|---|---|---|---|");for(let H of z)J.push(`| \`${H.dir||"(root)"}\` | ${H.agentsExists?"\u2713":"\xB7"} | ${H.claudeExists?"\u2713":"\xB7"} | ${H.classification} | ${H.detail} |`);J.push("")}let Y=Z.filter((H)=>!H.isSymlink&&H.brokenPathRefs.length+H.brokenImports.length>0);if(J.push(`## Broken references
|
|
173
|
+
`),Y.length===0)J.push(`None detected.
|
|
174
|
+
`);else for(let H of Y){if(J.push(`### \`${H.relPath}\`
|
|
175
|
+
`),H.brokenPathRefs.length>0){J.push("Broken path references:");for(let V of H.brokenPathRefs)J.push(` - \`${V}\``);J.push("")}if(H.brokenImports.length>0){J.push("Broken `@`-imports:");for(let V of H.brokenImports)J.push(` - \`${V}\``);J.push("")}}let U=Z.filter((H)=>!H.isSymlink&&H.unresolvedCommands.length>0);if(J.push(`## Unresolved package-manager commands (advisory)
|
|
176
|
+
`),J.push("Looks like a script command in markdown that did not match anything in the target `package.json` `scripts` or the `knownCommands` allowlist. Workspace-filtered commands check against root scripts, so false positives are expected. Review, do not fail CI on this.\n"),U.length===0)J.push(`None flagged.
|
|
177
|
+
`);else for(let H of U){J.push(`### \`${H.relPath}\`
|
|
178
|
+
`);for(let V of H.unresolvedCommands)J.push(` - \`${V}\``);J.push("")}let W=Z.filter((H)=>{if(H.isSymlink)return!1;return!H.relPath.includes("/")?H.lineCount>X.budgets.rootLines:H.lineCount>X.budgets.nestedWarnLines});if(J.push(`## Section breakdown for files over budget
|
|
179
|
+
`),W.length===0)J.push(`All files within budget.
|
|
180
|
+
`);else for(let H of W){J.push(`### \`${H.relPath}\` (${H.lineCount} lines)
|
|
181
|
+
`),J.push(`Largest H2 sections (lines including any subsections):
|
|
182
|
+
`),J.push("| Section | Lines |"),J.push("|---|---|");for(let V of H.sections.slice(0,10))J.push(`| ${V.header} | ${V.lines} |`);J.push("")}if(J.push(`## Registered-source trap matches
|
|
183
|
+
`),J.push("Catches stale claims in `docs.sources` against declared traps. Sources with `audit.traps: false` are excluded.\n"),$.sourceTrapMatches.length===0)J.push(`None.
|
|
184
|
+
`);else{for(let H of $.sourceTrapMatches)J.push(`- **${H.sourceId}** (\`${H.sourcePath}:L${H.line}\`) \u2014 trap \`${H.trapId}\` matched \`${H.matched}\` (${H.severity})`),J.push(` - reason: ${H.trapReason}`),J.push(" - fix: remove the stale claim, retire the trap, or set `audit.traps: false` on the source");J.push("")}return J.join(`
|
|
185
|
+
`)}function z2($){return JSON.stringify($,null,2)}function q2($){let{config:X,files:Z,pairs:z,findings:q}=$,J=[],G=q.filter((H)=>H.severity==="error").length,Q=q.filter((H)=>H.severity==="warning").length;if(J.push("pickled audit"),J.push(`Target: ${X.targetRepo}`),J.push(`Budgets: root \u2264 ${X.budgets.rootLines} lines, nested warn at ${X.budgets.nestedWarnLines} lines.`),J.push(`Found: ${Z.length} agent-doc file(s) \xB7 ${G} error(s) \xB7 ${Q} warning(s)`),J.push(""),J.push("Inventory"),Z.length===0)J.push(" none");else{let H=[...Z].sort((B,L)=>L.lineCount-B.lineCount),V=Math.max(...H.map((B)=>B.relPath.length));for(let B of H){let L=!B.relPath.includes("/"),T=P8(B.lineCount,L,X),K=B.isSymlink?`symlink \u2192 ${B.symlinkTarget?.replace(`${X.targetRepo}/`,"")??"?"}`:"file",_=`${B.lineCount}`.padStart(4),F=B.relPath.padEnd(V),O=T?` (${T})`:"";J.push(` ${F} ${_} lines ${K}${O}`)}}if(J.push(""),J.push("AGENTS.md / CLAUDE.md pairs"),z.length===0)J.push(" none");else for(let H of z){let V=H.dir||"(root)";J.push(` ${V}: ${H.classification} \xB7 ${H.detail}`)}J.push("");let Y=Z.filter((H)=>!H.isSymlink&&H.brokenPathRefs.length+H.brokenImports.length>0);if(J.push("Broken references"),Y.length===0)J.push(" none");else for(let H of Y){J.push(` ${H.relPath}:`);for(let V of H.brokenPathRefs)J.push(` path: ${V}`);for(let V of H.brokenImports)J.push(` @-import: ${V}`)}J.push("");let U=Z.filter((H)=>!H.isSymlink&&H.unresolvedCommands.length>0);if(J.push("Unresolved package-manager commands (advisory)"),U.length===0)J.push(" none");else for(let H of U){J.push(` ${H.relPath}:`);for(let V of H.unresolvedCommands)J.push(` ${V}`)}J.push("");let W=Z.filter((H)=>{if(H.isSymlink)return!1;return!H.relPath.includes("/")?H.lineCount>X.budgets.rootLines:H.lineCount>X.budgets.nestedWarnLines});if(J.push("Section breakdown for files over budget"),W.length===0)J.push(" all files within budget");else for(let H of W){J.push(` ${H.relPath} (${H.lineCount} lines):`);for(let V of H.sections.slice(0,10))J.push(` ${V.header.padEnd(40)} ${V.lines} lines`)}if(J.push(""),J.push("Registered-source trap matches"),$.sourceTrapMatches.length===0)J.push(" none");else for(let H of $.sourceTrapMatches){let V=H.severity==="error"?"error":"warning";J.push(` [${V}] ${H.sourceId} (${H.sourcePath}:L${H.line}): trap ${H.trapId} matched "${H.matched}"`),J.push(` reason: ${H.trapReason}`),J.push(" fix: remove the stale claim, retire the trap, or set audit.traps: false on the source")}return J.join(`
|
|
186
|
+
`)}function P8($,X,Z){if(X&&$>Z.budgets.rootLines)return`over root budget (${$} > ${Z.budgets.rootLines})`;if(!X&&$>Z.budgets.nestedWarnLines)return`over nested-warn (${$} > ${Z.budgets.nestedWarnLines})`;return""}import{existsSync as q$,lstatSync as C8,readFileSync as Q2,readlinkSync as lU,statSync as cU}from"fs";import{dirname as Y2,isAbsolute as iU,join as B4,relative as aU,resolve as K4}from"path";var{Glob:S8}=globalThis.Bun;var J2=["node_modules/**","**/node_modules/**",".git/**","**/.git/**","dist/**","**/dist/**","build/**","**/build/**",".next/**","**/.next/**",".turbo/**","**/.turbo/**",".cache/**","**/.cache/**",".runs/**","**/.runs/**","coverage/**","**/coverage/**","**/__fixtures__/**","**/tests/**/fixture/**","**/tests/**/fixtures/**","**/test/**/fixture/**","**/test/**/fixtures/**"],z$={targetRepo:".",budgets:{rootLines:120,nestedWarnLines:200},ignore:J2,intentionalDifferentPairs:[],knownCommands:[]};function G2($){if(!$)return z$;return{targetRepo:$.targetRepo??z$.targetRepo,budgets:{rootLines:$.budgets?.rootLines??z$.budgets.rootLines,nestedWarnLines:$.budgets?.nestedWarnLines??z$.budgets.nestedWarnLines},ignore:$.ignore??J2,intentionalDifferentPairs:$.intentionalDifferentPairs??[],knownCommands:$.knownCommands??[]}}import{existsSync as mU}from"fs";import{join as dU}from"path";function k0($){let X=[],Z=[];for(let z of $.traps){let q=gU($.response,z);if(q)X.push(q);else Z.push(z.id)}return{fired:X,avoided:Z}}function gU($,X){if(X.match!==void 0){let Z=$.indexOf(X.match);if(Z===-1)return null;return{id:X.id,reason:X.reason,matched:X.match,snippet:N8($,Z,X.match.length),index:Z}}if(X.pattern!==void 0){let z=new RegExp(X.pattern,X.flags??"").exec($);if(!z)return null;return{id:X.id,reason:X.reason,matched:z[0],snippet:N8($,z.index,z[0].length),index:z.index}}return null}function N8($,X,Z){let z=Math.max(0,X-40),q=Math.min($.length,X+Z+40),J=$.slice(z,q).replace(/\s+/g," ").trim();if(z>0)J=`...${J}`;if(q<$.length)J=`${J}...`;return J}import T4 from"path";function hU($){return $.startsWith("http://")||$.startsWith("https://")}async function vU($,X,Z){let z=await fetch(X);if(!z.ok)throw Error(`Failed to fetch source "${$}" from ${X}: ${z.status} ${z.statusText}`);let q=await z.text();return{id:$,source:X,content:q,name:new URL(X).hostname+new URL(X).pathname,type:"url",auditTraps:Z}}async function uU($,X,Z,z){let q=T4.isAbsolute(X)?X:T4.resolve(Z,X),J=Bun.file(q);if(!await J.exists())throw Error(`Source "${$}" not found at ${q}`);let G=await J.text();return{id:$,source:X,content:G,name:T4.basename(q),type:"file",auditTraps:z}}async function A8($,X,Z){let{path:z,auditTraps:q}=V4(X);if(hU(z))return vU($,z,q);return uU($,z,Z,q)}async function l$($,X){let Z=Object.entries($);return await Promise.all(Z.map(([q,J])=>A8(q,J,X)))}async function j8($){if(!mU(dU($,"pickled.yml")))return{matches:[],findings:[]};let X=await Z$($),Z=X.docs?.sources;if(!Z||Object.keys(Z).length===0)return{matches:[],findings:[]};let z={};for(let[U,W]of Object.entries(Z)){let H=typeof W==="string"?W:W.path;if(H.startsWith("http://")||H.startsWith("https://"))continue;z[U]=W}if(Object.keys(z).length===0)return{matches:[],findings:[]};let q=[],J=new Map;for(let U of X.scenarios)for(let W of U.traps??[])q.push(W),J.set(W,W.auditSeverity??"warning");if(q.length===0)return{matches:[],findings:[]};let G=await l$(z,$),Q=[],Y=[];for(let U of G){let W=U.auditTraps;if(W===!1)continue;let H=Array.isArray(W)?new Set(W):null;for(let V of q){if(H?.has(V.id))continue;let{fired:B}=k0({response:U.content,traps:[V]}),L=B[0];if(!L)continue;let T=pU(U.content,L.index),K=J.get(V)??"warning";Q.push({sourceId:U.id,sourcePath:U.source,trapId:L.id,trapReason:L.reason,matched:L.matched,snippet:L.snippet,line:T,severity:K}),Y.push({severity:K,category:"trap-source-match",file:U.source,message:`source [${U.id}] matches trap '${L.id}' ("${L.matched}"). ${L.reason} Fix: remove the stale claim from the source, retire the trap if no longer relevant, or set audit.traps: false on the source if it is deliberately stale or test-only.`})}}return{matches:Q,findings:Y}}function pU($,X){let Z=1,z=Math.min(X,$.length);for(let q=0;q<z;q++)if($[q]===`
|
|
187
|
+
`)Z++;return Z}var sU=["AGENTS.md","CLAUDE.md","CLAUDE.local.md","llms.txt","llms-full.txt",".claude/CLAUDE.md",".claude/rules/*.md","**/AGENTS.md","**/CLAUDE.md","**/CLAUDE.local.md","**/llms.txt","**/llms-full.txt","**/.claude/CLAUDE.md","**/.claude/rules/*.md"];async function U2($){let X=G2($),Z=K4(X.targetRepo);if(!q$(Z))throw Error(`targetRepo does not exist: ${Z}`);let z=new Set;for(let U of sU){let W=new S8(U);for await(let H of W.scan({cwd:Z,dot:!0,onlyFiles:!1,followSymlinks:!1})){if(X.ignore.some((L)=>new S8(L).match(H)))continue;let V=B4(Z,H),B=C8(V);if(B.isFile()){z.add(H);continue}if(B.isSymbolicLink())try{if(cU(V).isFile())z.add(H)}catch{}}}let q=[];for(let U of[...z].sort())q.push(await nU(Z,U,B4(Z,U),X));let J=QH(q,X),G=YH(q,J,X),{matches:Q,findings:Y}=await j8(Z);return{config:X,files:q,pairs:J,findings:[...G,...Y],sourceTrapMatches:Q}}async function nU($,X,Z,z){let J=C8(Z).isSymbolicLink(),G=null,Q=X;if(J){let V=lU(Z),B=iU(V)?V:K4(Y2(Z),V);if(G=B,q$(B))Q=aU($,B)}let Y=J&&G&&q$(G)?G:Z,U=Q2(Y,"utf8"),W=(U.match(/\n/g)??[]).length,H=U.endsWith(`
|
|
188
|
+
`)?W:W+1;return{relPath:X,absPath:Z,isSymlink:J,symlinkTarget:G,realRelPath:Q,lineCount:H,brokenPathRefs:oU(U,$,X),brokenImports:eU(U,Y2(Z)),unresolvedCommands:zH(U,$,z.knownCommands),sections:qH(U)}}function rU($){let X=$.split("/");if(X.length<2)return null;if(X[0]==="packages"||X[0]==="apps"||X[0]==="shared")return`${X[0]}/${X[1]}`;if(X[0]==="tests")return X.slice(0,2).join("/");return null}function oU($,X,Z){let z=GH($),q=Y2(Z),J=rU(Z),G=new Set,Q=/`([^`\n]{2,200})`/g,Y;Y=Q.exec(z);while(Y!==null){let U=Y[1].trim().replace(/[#?].*$/,"");if(JH(U)&&!tU(X,U,q,J).found)G.add(U);Y=Q.exec(z)}return[...G].sort()}function tU($,X,Z,z){let q=[X];if(Z&&Z!==".")q.push(`${Z}/${X}`);if(z)q.push(`${z}/${X}`);q.push(`packages/${X}`,`apps/${X}`,`shared/${X}`);for(let J of q){let G=J.replace(/\/+/g,"/");if(q$(`${$}/${G}`))return{found:!0,resolvedAs:G}}return{found:!1}}function eU($,X){let Z=new Set,z=/@([\w./@~-]+\.md)/g,q;q=z.exec($);while(q!==null){let J=q[1];if(J.startsWith("~/")){q=z.exec($);continue}let G=J.startsWith("/")?J:K4(X,J);if(!q$(G))Z.add(J);q=z.exec($)}return[...Z].sort()}var $H=["bun","pnpm","npm","yarn"],XH=new Set(["install","add","remove","update","i","audit","list","ls","why","outdated","exec","run","create","init","x"]),ZH={bun:new Set(["build","test","link","unlink","upgrade"])};function zH($,X,Z){let z=new Set,q=B4(X,"package.json"),J=new Set;if(q$(q))try{let Q=JSON.parse(Q2(q,"utf8"));J=new Set(Object.keys(Q.scripts??{}))}catch{}let G=new Set(Z.map((Q)=>Q.trim()));for(let Q of $H){let Y=new RegExp(`\\b${Q}\\s+(?:run\\s+|--filter\\s+\\S+\\s+(?:run\\s+)?)?([a-zA-Z][\\w:.\\-]*)`,"g"),U;U=Y.exec($);while(U!==null){let W=U[1];if(!J.has(W)&&!G.has(`${Q} ${W}`)&&!G.has(`${Q} run ${W}`)&&!XH.has(W)&&!ZH[Q]?.has(W))z.add(`${Q} ${W}`);U=Y.exec($)}}return[...z].sort()}function qH($){let X=$.split(`
|
|
189
|
+
`),Z=[],z=null;if(X.forEach((q,J)=>{if(/^##\s+/.test(q)){if(z)Z.push({header:z.header,lines:J-z.start});z={header:q.replace(/^##\s+/,"").trim(),start:J}}}),z){let q=z;Z.push({header:q.header,lines:X.length-q.start})}return Z.sort((q,J)=>J.lines-q.lines)}function JH($){if($.length===0||$.length>160)return!1;if(!$.includes("/"))return!1;if(/\s/.test($))return!1;if(/^https?:\/\//.test($))return!1;if(/[*?{}[\]<>]/.test($))return!1;if($.startsWith("@"))return!1;if($.startsWith("~/"))return!1;if(/^[a-z]+:\/\//i.test($))return!1;if(/^cdn\./.test($)||/^unpkg\./.test($)||/^npm\./.test($))return!1;if(/^\/[a-z]/.test($)&&/(?:icon|image|img|asset|file|path)/i.test($))return!1;if(/^(cd|pnpm|npm|yarn|bun|node|git|ls|cat|grep|find|sed|awk|mkdir|rm|mv|cp|echo|export|source|sudo|brew|docker|curl|wget)\b/.test($))return!1;return/[a-zA-Z0-9_.-]\/[a-zA-Z0-9_.-]/.test($)}function GH($){return $.replace(/```[\s\S]*?```/g,"")}function QH($,X){let Z=new Map;for(let J of $){let G=J.relPath.split("/").pop()??"";if(G!=="AGENTS.md"&&G!=="CLAUDE.md")continue;let Q=Y2(J.relPath),Y=Z.get(Q)??{};if(G==="AGENTS.md")Y.agents=J;if(G==="CLAUDE.md")Y.claude=J;Z.set(Q,Y)}let z=new Set(X.intentionalDifferentPairs),q=[];for(let[J,G]of Z){let Q=!!G.agents,Y=!!G.claude;if(!Q&&!Y)continue;if(!Q||!Y){q.push({dir:J,agentsExists:Q,claudeExists:Y,classification:"single",detail:Q?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:U,claude:W}=G,H=`${U.relPath}:${W.relPath}`,V=`${W.relPath}:${U.relPath}`;if(z.has(H)||z.has(V)){q.push({dir:J,agentsExists:Q,claudeExists:Y,classification:"intentional-different",detail:`allowlisted: ${U.lineCount}L vs ${W.lineCount}L`});continue}if(U.isSymlink&&U.symlinkTarget===W.absPath||W.isSymlink&&W.symlinkTarget===U.absPath){let K=U.isSymlink?"CLAUDE.md":"AGENTS.md";q.push({dir:J,agentsExists:Q,claudeExists:Y,classification:"linked",detail:`canonical: ${K}`});continue}let L=Q2(U.absPath,"utf8"),T=Q2(W.absPath,"utf8");if(L===T)q.push({dir:J,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${U.lineCount}L), not symlinked`});else q.push({dir:J,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`divergent (${U.lineCount}L vs ${W.lineCount}L), not in intentional-different allowlist`})}return q.sort((J,G)=>J.dir.localeCompare(G.dir)),q}function YH($,X,Z){let z=[];for(let q of $){if(q.isSymlink)continue;for(let Q of q.brokenImports)z.push({severity:"error",category:"broken-import",file:q.relPath,message:`broken @-import: ${Q}`});for(let Q of q.brokenPathRefs)z.push({severity:"error",category:"broken-path-ref",file:q.relPath,message:`broken path reference: ${Q}`});for(let Q of q.unresolvedCommands)z.push({severity:"warning",category:"unresolved-command",file:q.relPath,message:`unresolved command: ${Q}`});let J=!q.relPath.includes("/"),G=J?Z.budgets.rootLines:Z.budgets.nestedWarnLines;if(q.lineCount>G)z.push({severity:"warning",category:"over-budget",file:q.relPath,message:`${q.lineCount} lines exceeds ${J?"root":"nested"} budget of ${G}`})}for(let q of X)if(q.classification==="unexpected-duplicate"){let J=q.detail.startsWith("divergent")?"error":"warning";z.push({severity:J,category:J==="error"?"divergent-pair":"duplicate-pair",file:q.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${q.detail}`})}return z}function f0($){let X=$.confidence;if($.error)return{icon:"\u2717",label:"Error",confidence:X,tone:"error"};if($.traps.fired.length>0)return{icon:"\u2717",label:"Trap fired",confidence:X,tone:"error"};if($.answerable==="YES")return{icon:"\u2713",label:X>=90?"Well grounded":"Grounded",confidence:X,tone:"success"};if($.answerable==="PARTIAL")return{icon:"\u26A0",label:"Partially grounded",confidence:X,tone:"warning"};return{icon:"\u2717",label:"Ungrounded",confidence:X,tone:"error"}}function L4($){let X=UH($);if(X===null)return[];let Z=[],z=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,q=z.exec(X);while(q!==null)Z.push({id:q[1].trim(),note:q[2].trim()||void 0}),q=z.exec(X);return Z}function UH($){let Z=/^##\s+Sources\s*$/im.exec($);if(!Z)return null;let z=Z.index+Z[0].length,q=$.slice(z),J=/^##\s+/m.exec(q);return J?q.slice(0,J.index):q}function c$($){let X=L4($.response),Z=new Set(X.map((V)=>V.id)),z=new Set($.registeredIds),q=new Set($.requiredSources),J=[...Z],G=[...q].filter((V)=>!Z.has(V)),Q=[...Z].filter((V)=>!z.has(V)),Y=[...q],U,W,H;if(J.length===0)U="NO",W=0,H="No citations in response";else if(Q.length===J.length)U="NO",W=0,H=`All cited sources are unknown: ${Q.join(", ")}`;else if(G.length===0&&Q.length===0)U="YES",W=100,H=Y.length>0?`All required sources cited: ${Y.join(", ")}`:`Cited registered sources: ${J.join(", ")}`;else{U="PARTIAL";let V=Y.length>0?Y.length:1,B=Y.length-G.length,L=Y.length>0?B/V*100:60,T=Q.length*15;W=Math.max(0,Math.min(100,Math.round(L-T)));let K=[];if(G.length>0)K.push(`missing: ${G.join(", ")}`);if(Q.length>0)K.push(`unknown: ${Q.join(", ")}`);H=K.join("; ")}return{answerable:U,confidence:W,reason:H,citations:{cited:J,required:Y,missing:G,unknown:Q}}}var g0="0.40.1";var E8=!1,h0=void 0,D4=void 0,HH=void 0,WH=void 0,VH=void 0,b8=void 0,TH=void 0,H2=void 0,_4=void 0,x8=void 0,F4=void 0,W2=void 0,y8=void 0;function k8($,X={auto:!1}){if(E8)throw Error(`you must \`import '@anthropic-ai/sdk/shims/${$.kind}'\` before importing anything else from @anthropic-ai/sdk`);if(h0)throw Error(`can't \`import '@anthropic-ai/sdk/shims/${$.kind}'\` after \`import '@anthropic-ai/sdk/shims/${h0}'\``);E8=X.auto,h0=$.kind,D4=$.fetch,HH=$.Request,WH=$.Response,VH=$.Headers,b8=$.FormData,TH=$.Blob,H2=$.File,_4=$.ReadableStream,x8=$.getMultipartRequestOptions,F4=$.getDefaultAgent,W2=$.fileFromPath,y8=$.isFsReadStream}class M4{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function f8({manuallyImported:$}={}){let X=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from '@anthropic-ai/sdk'`:\n- `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)\n- `import '@anthropic-ai/sdk/shims/web'` (otherwise)\n",Z,z,q,J;try{Z=fetch,z=Request,q=Response,J=Headers}catch(G){throw Error(`this environment is missing the following Web Fetch API type: ${G.message}. ${X}`)}return{kind:"web",fetch:Z,Request:z,Response:q,Headers:J,FormData:typeof FormData<"u"?FormData:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${X}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${X}`)}},File:typeof File<"u"?File:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${X}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${X}`)}},getMultipartRequestOptions:async(G,Q)=>({...Q,body:new M4(G)}),getDefaultAgent:(G)=>{return},fileFromPath:()=>{throw Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads")},isFsReadStream:(G)=>!1}}import{ReadStream as KH}from"fs";function g8(){let $=f8();function X(Z){return Z instanceof KH}return{...$,isFsReadStream:X}}var O4=()=>{if(!h0)k8(g8(),{auto:!0})};O4();class P extends Error{}class v extends P{constructor($,X,Z,z){super(`${v.makeMessage($,X,Z)}`);this.status=$,this.headers=z,this.request_id=z?.["request-id"],this.error=X}static makeMessage($,X,Z){let z=X?.message?typeof X.message==="string"?X.message:JSON.stringify(X.message):X?JSON.stringify(X):Z;if($&&z)return`${$} ${z}`;if($)return`${$} status code (no body)`;if(z)return z;return"(no status code or body)"}static generate($,X,Z,z){if(!$||!z)return new v0({message:Z,cause:M2(X)});let q=X;if($===400)return new V2($,q,Z,z);if($===401)return new T2($,q,Z,z);if($===403)return new B2($,q,Z,z);if($===404)return new K2($,q,Z,z);if($===409)return new L2($,q,Z,z);if($===422)return new D2($,q,Z,z);if($===429)return new _2($,q,Z,z);if($>=500)return new F2($,q,Z,z);return new v($,q,Z,z)}}class m extends v{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class v0 extends v{constructor({message:$,cause:X}){super(void 0,void 0,$||"Connection error.",void 0);if(X)this.cause=X}}class i$ extends v0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class V2 extends v{}class T2 extends v{}class B2 extends v{}class K2 extends v{}class L2 extends v{}class D2 extends v{}class _2 extends v{}class F2 extends v{}var O2=function($,X,Z,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,Z):q?q.value=Z:X.set($,Z),Z},u0=function($,X,Z,z){if(Z==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?z:Z==="a"?z.call($):z?z.value:X.get($)},c;class R0{constructor(){c.set(this,void 0),this.buffer=new Uint8Array,O2(this,c,null,"f")}decode($){if($==null)return[];let X=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,Z=new Uint8Array(this.buffer.length+X.length);Z.set(this.buffer),Z.set(X,this.buffer.length),this.buffer=Z;let z=[],q;while((q=DH(this.buffer,u0(this,c,"f")))!=null){if(q.carriage&&u0(this,c,"f")==null){O2(this,c,q.index,"f");continue}if(u0(this,c,"f")!=null&&(q.index!==u0(this,c,"f")+1||q.carriage)){z.push(this.decodeText(this.buffer.slice(0,u0(this,c,"f")-1))),this.buffer=this.buffer.slice(u0(this,c,"f")),O2(this,c,null,"f");continue}let J=u0(this,c,"f")!==null?q.preceding-1:q.preceding,G=this.decodeText(this.buffer.slice(0,J));z.push(G),this.buffer=this.buffer.slice(q.index),O2(this,c,null,"f")}return z}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer<"u"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new P(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new P(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new P("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
190
|
+
`)}}c=new WeakMap;R0.NEWLINE_CHARS=new Set([`
|
|
191
|
+
`,"\r"]);R0.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function DH($,X){for(let q=X??0;q<$.length;q++){if($[q]===10)return{preceding:q,index:q+1,carriage:!1};if($[q]===13)return{preceding:q,index:q+1,carriage:!0}}return null}function h8($){for(let z=0;z<$.length-1;z++){if($[z]===10&&$[z+1]===10)return z+2;if($[z]===13&&$[z+1]===13)return z+2;if($[z]===13&&$[z+1]===10&&z+3<$.length&&$[z+2]===13&&$[z+3]===10)return z+4}return-1}function a$($){if($[Symbol.asyncIterator])return $;let X=$.getReader();return{async next(){try{let Z=await X.read();if(Z?.done)X.releaseLock();return Z}catch(Z){throw X.releaseLock(),Z}},async return(){let Z=X.cancel();return X.releaseLock(),await Z,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class i{constructor($,X){this.iterator=$,this.controller=X}static fromSSEResponse($,X){let Z=!1;async function*z(){if(Z)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");Z=!0;let q=!1;try{for await(let J of _H($,X)){if(J.event==="completion")try{yield JSON.parse(J.data)}catch(G){throw console.error("Could not parse message into JSON:",J.data),console.error("From chunk:",J.raw),G}if(J.event==="message_start"||J.event==="message_delta"||J.event==="message_stop"||J.event==="content_block_start"||J.event==="content_block_delta"||J.event==="content_block_stop")try{yield JSON.parse(J.data)}catch(G){throw console.error("Could not parse message into JSON:",J.data),console.error("From chunk:",J.raw),G}if(J.event==="ping")continue;if(J.event==="error")throw v.generate(void 0,`SSE Error: ${J.data}`,J.data,w4($.headers))}q=!0}catch(J){if(J instanceof Error&&J.name==="AbortError")return;throw J}finally{if(!q)X.abort()}}return new i(z,X)}static fromReadableStream($,X){let Z=!1;async function*z(){let J=new R0,G=a$($);for await(let Q of G)for(let Y of J.decode(Q))yield Y;for(let Q of J.flush())yield Q}async function*q(){if(Z)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");Z=!0;let J=!1;try{for await(let G of z()){if(J)continue;if(G)yield JSON.parse(G)}J=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{if(!J)X.abort()}}return new i(q,X)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],X=[],Z=this.iterator(),z=(q)=>{return{next:()=>{if(q.length===0){let J=Z.next();$.push(J),X.push(J)}return q.shift()}}};return[new i(()=>z($),this.controller),new i(()=>z(X),this.controller)]}toReadableStream(){let $=this,X,Z=new TextEncoder;return new _4({async start(){X=$[Symbol.asyncIterator]()},async pull(z){try{let{value:q,done:J}=await X.next();if(J)return z.close();let G=Z.encode(JSON.stringify(q)+`
|
|
192
|
+
`);z.enqueue(G)}catch(q){z.error(q)}},async cancel(){await X.return?.()}})}}async function*_H($,X){if(!$.body)throw X.abort(),new P("Attempted to iterate over a response with no body");let Z=new v8,z=new R0,q=a$($.body);for await(let J of FH(q))for(let G of z.decode(J)){let Q=Z.decode(G);if(Q)yield Q}for(let J of z.flush()){let G=Z.decode(J);if(G)yield G}}async function*FH($){let X=new Uint8Array;for await(let Z of $){if(Z==null)continue;let z=Z instanceof ArrayBuffer?new Uint8Array(Z):typeof Z==="string"?new TextEncoder().encode(Z):Z,q=new Uint8Array(X.length+z.length);q.set(X),q.set(z,X.length),X=q;let J;while((J=h8(X))!==-1)yield X.slice(0,J),X=X.slice(J)}if(X.length>0)yield X}class v8{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let q={event:this.event,data:this.data.join(`
|
|
193
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],q}if(this.chunks.push($),$.startsWith(":"))return null;let[X,Z,z]=MH($,":");if(z.startsWith(" "))z=z.substring(1);if(X==="event")this.event=z;else if(X==="data")this.data.push(z);return null}}function MH($,X){let Z=$.indexOf(X);if(Z!==-1)return[$.substring(0,Z),X,$.substring(Z+X.length)];return[$,"",""]}var OH=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",wH=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&s$($),s$=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function";async function u8($,X,Z){if($=await $,wH($))return $;if(OH($)){let q=await $.blob();X||(X=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let J=s$(q)?[await q.arrayBuffer()]:[q];return new H2(J,X,Z)}let z=await IH($);if(X||(X=PH($)??"unknown_file"),!Z?.type){let q=z[0]?.type;if(typeof q==="string")Z={...Z,type:q}}return new H2(z,X,Z)}async function IH($){let X=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)X.push($);else if(s$($))X.push(await $.arrayBuffer());else if(NH($))for await(let Z of $)X.push(Z);else throw Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${RH($)}`);return X}function RH($){return`[${Object.getOwnPropertyNames($).map((Z)=>`"${Z}"`).join(", ")}]`}function PH($){return I4($.name)||I4($.filename)||I4($.path)?.split(/[\\/]/).pop()}var I4=($)=>{if(typeof $==="string")return $;if(typeof Buffer<"u"&&$ instanceof Buffer)return String($);return},NH=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",R4=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var jH=function($,X,Z,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,Z):q?q.value=Z:X.set($,Z),Z},SH=function($,X,Z,z){if(Z==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?z:Z==="a"?z.call($):z?z.value:X.get($)},w2;O4();async function c8($){let{response:X}=$;if($.options.stream){if(J$("response",X.status,X.url,X.headers,X.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(X,$.controller);return i.fromSSEResponse(X,$.controller)}if(X.status===204)return null;if($.options.__binaryResponse)return X;let z=X.headers.get("content-type")?.split(";")[0]?.trim();if(z?.includes("application/json")||z?.endsWith("+json")){let G=await X.json();return J$("response",X.status,X.url,X.headers,G),i8(G,X)}let J=await X.text();return J$("response",X.status,X.url,X.headers,J),J}function i8($,X){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:X.headers.get("request-id"),enumerable:!1})}class R2 extends Promise{constructor($,X=c8){super((Z)=>{Z(null)});this.responsePromise=$,this.parseResponse=X}_thenUnwrap($){return new R2(this.responsePromise,async(X)=>i8($(await this.parseResponse(X),X),X.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,X]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:X,request_id:X.headers.get("request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(this.parseResponse);return this.parsedPromise}then($,X){return this.parse().then($,X)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class N4{constructor({baseURL:$,maxRetries:X=2,timeout:Z=600000,httpAgent:z,fetch:q}){this.baseURL=$,this.maxRetries=P4("maxRetries",X),this.timeout=P4("timeout",Z),this.httpAgent=z,this.fetch=q??D4}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...xH(),...this.authHeaders($)}}validateHeaders($,X){}defaultIdempotencyKey(){return`stainless-node-retry-${hH()}`}get($,X){return this.methodRequest("get",$,X)}post($,X){return this.methodRequest("post",$,X)}patch($,X){return this.methodRequest("patch",$,X)}put($,X){return this.methodRequest("put",$,X)}delete($,X){return this.methodRequest("delete",$,X)}methodRequest($,X,Z){return this.request(Promise.resolve(Z).then(async(z)=>{let q=z&&s$(z?.body)?new DataView(await z.body.arrayBuffer()):z?.body instanceof DataView?z.body:z?.body instanceof ArrayBuffer?new DataView(z.body):z&&ArrayBuffer.isView(z?.body)?new DataView(z.body.buffer):z?.body;return{method:$,path:X,...z,body:q}}))}getAPIList($,X,Z){return this.requestAPIList(X,{method:"get",path:$,...Z})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer<"u")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:X=0}={}){let Z={...$},{method:z,path:q,query:J,headers:G={}}=Z,Q=ArrayBuffer.isView(Z.body)||Z.__binaryRequest&&typeof Z.body==="string"?Z.body:R4(Z.body)?Z.body.body:Z.body?JSON.stringify(Z.body,null,2):null,Y=this.calculateContentLength(Q),U=this.buildURL(q,J);if("timeout"in Z)P4("timeout",Z.timeout);Z.timeout=Z.timeout??this.timeout;let W=Z.httpAgent??this.httpAgent??F4(U),H=Z.timeout+1000;if(typeof W?.options?.timeout==="number"&&H>(W.options.timeout??0))W.options.timeout=H;if(this.idempotencyHeader&&z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=$.idempotencyKey}let V=this.buildHeaders({options:Z,headers:G,contentLength:Y,retryCount:X});return{req:{method:z,...Q&&{body:Q},headers:V,...W&&{agent:W},signal:Z.signal??null},url:U,timeout:Z.timeout}}buildHeaders({options:$,headers:X,contentLength:Z,retryCount:z}){let q={};if(Z)q["content-length"]=Z;let J=this.defaultHeaders($);if(l8(q,J),l8(q,X),R4($.body)&&h0!=="node")delete q["content-type"];if(I2(J,"x-stainless-retry-count")===void 0&&I2(X,"x-stainless-retry-count")===void 0)q["x-stainless-retry-count"]=String(z);if(I2(J,"x-stainless-timeout")===void 0&&I2(X,"x-stainless-timeout")===void 0&&$.timeout)q["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(q,X),q}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new P("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:X,options:Z}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((X)=>[...X])):{...$}}makeStatusError($,X,Z,z){return v.generate($,X,Z,z)}request($,X=null){return new R2(this.makeRequest($,X))}async makeRequest($,X){let Z=await $,z=Z.maxRetries??this.maxRetries;if(X==null)X=z;await this.prepareOptions(Z);let{req:q,url:J,timeout:G}=this.buildRequest(Z,{retryCount:z-X});if(await this.prepareRequest(q,{url:J,options:Z}),J$("request",J,Z,q.headers),Z.signal?.aborted)throw new m;let Q=new AbortController,Y=await this.fetchWithTimeout(J,q,G,Q).catch(M2);if(Y instanceof Error){if(Z.signal?.aborted)throw new m;if(X)return this.retryRequest(Z,X);if(Y.name==="AbortError")throw new i$;throw new v0({cause:Y})}let U=w4(Y.headers);if(!Y.ok){if(X&&this.shouldRetry(Y)){let T=`retrying, ${X} attempts remaining`;return J$(`response (error; ${T})`,Y.status,J,U),this.retryRequest(Z,X,U)}let W=await Y.text().catch((T)=>M2(T).message),H=yH(W),V=H?void 0:W;throw J$(`response (error; ${X?"(error; no more retries left)":"(error; not retryable)"})`,Y.status,J,U,V),this.makeStatusError(Y.status,H,V,U)}return{response:Y,options:Z,controller:Q}}requestAPIList($,X){let Z=this.makeRequest(X,null);return new a8(this,Z,$)}buildURL($,X){let Z=fH($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),z=this.defaultQuery();if(!s8(z))X={...z,...X};if(typeof X==="object"&&X&&!Array.isArray(X))Z.search=this.stringifyQuery(X);return Z.toString()}stringifyQuery($){return Object.entries($).filter(([X,Z])=>typeof Z<"u").map(([X,Z])=>{if(typeof Z==="string"||typeof Z==="number"||typeof Z==="boolean")return`${encodeURIComponent(X)}=${encodeURIComponent(Z)}`;if(Z===null)return`${encodeURIComponent(X)}=`;throw new P(`Cannot stringify type ${typeof Z}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout($,X,Z,z){let{signal:q,...J}=X||{};if(q)q.addEventListener("abort",()=>z.abort());let G=setTimeout(()=>z.abort(),Z),Q={signal:z.signal,...J};if(Q.method)Q.method=Q.method.toUpperCase();let Y=60000,U=setTimeout(()=>{if(Q&&Q?.agent?.sockets){for(let W of Object.values(Q?.agent?.sockets).flat())if(W?.setKeepAlive)W.setKeepAlive(!0,Y)}},Y);return this.fetch.call(void 0,$,Q).finally(()=>{clearTimeout(G),clearTimeout(U)})}shouldRetry($){let X=$.headers.get("x-should-retry");if(X==="true")return!0;if(X==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,X,Z){let z,q=Z?.["retry-after-ms"];if(q){let G=parseFloat(q);if(!Number.isNaN(G))z=G}let J=Z?.["retry-after"];if(J&&!z){let G=parseFloat(J);if(!Number.isNaN(G))z=G*1000;else z=Date.parse(J)-Date.now()}if(!(z&&0<=z&&z<60000)){let G=$.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(X,G)}return await gH(z),this.makeRequest($,X-1)}calculateDefaultRetryTimeoutMillis($,X){let q=X-$,J=Math.min(0.5*Math.pow(2,q),8),G=1-Math.random()*0.25;return J*G*1000}getUserAgent(){return`${this.constructor.name}/JS ${g0}`}}class A4{constructor($,X,Z,z){w2.set(this,void 0),jH(this,w2,$,"f"),this.options=z,this.response=X,this.body=Z}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new P("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let X={...this.options};if("params"in $&&typeof X.query==="object")X.query={...X.query,...$.params};else if("url"in $){let Z=[...Object.entries(X.query||{}),...$.url.searchParams.entries()];for(let[z,q]of Z)$.url.searchParams.set(z,q);X.query=void 0,X.path=$.url.toString()}return await SH(this,w2,"f").requestAPIList(this.constructor,X)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(w2=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let X of $.getPaginatedItems())yield X}}class a8 extends R2{constructor($,X,Z){super(X,async(z)=>new Z($,z.response,await c8(z),z.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let X of $)yield X}}var w4=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(X,Z){let z=Z.toString();return X[z.toLowerCase()]||X[z]}})},CH={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},r=($)=>{return typeof $==="object"&&$!==null&&!s8($)&&Object.keys($).every((X)=>n8(CH,X))},EH=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":g0,"X-Stainless-OS":d8(Deno.build.os),"X-Stainless-Arch":m8(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":g0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":g0,"X-Stainless-OS":d8(process.platform),"X-Stainless-Arch":m8(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=bH();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":g0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":g0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function bH(){if(typeof navigator>"u"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:X,pattern:Z}of $){let z=Z.exec(navigator.userAgent);if(z){let q=z[1]||0,J=z[2]||0,G=z[3]||0;return{browser:X,version:`${q}.${J}.${G}`}}}return null}var m8=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},d8=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},p8,xH=()=>{return p8??(p8=EH())},yH=($)=>{try{return JSON.parse($)}catch(X){return}},kH=/^[a-z][a-z0-9+.-]*:/i,fH=($)=>{return kH.test($)},gH=($)=>new Promise((X)=>setTimeout(X,$)),P4=($,X)=>{if(typeof X!=="number"||!Number.isInteger(X))throw new P(`${$} must be an integer`);if(X<0)throw new P(`${$} must be a positive integer`);return X},M2=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return Error(JSON.stringify($))}catch{}return Error(String($))};var P2=($)=>{if(typeof process<"u")return process.env?.[$]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.($)?.trim();return};function s8($){if(!$)return!0;for(let X in $)return!1;return!0}function n8($,X){return Object.prototype.hasOwnProperty.call($,X)}function l8($,X){for(let Z in X){if(!n8(X,Z))continue;let z=Z.toLowerCase();if(!z)continue;let q=X[Z];if(q===null)delete $[z];else if(q!==void 0)$[z]=q}}function J$($,...X){if(typeof process<"u"&&process?.env?.DEBUG==="true")console.log(`Anthropic:DEBUG:${$}`,...X)}var hH=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let X=Math.random()*16|0;return($==="x"?X:X&3|8).toString(16)})},r8=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},vH=($)=>{return typeof $?.get==="function"};var I2=($,X)=>{let Z=X.toLowerCase();if(vH($)){let z=X[0]?.toUpperCase()+X.substring(1).replace(/([^\w])(\w)/g,(q,J,G)=>J+G.toUpperCase());for(let q of[X,Z,X.toUpperCase(),z]){let J=$.get(q);if(J)return J}}for(let[z,q]of Object.entries($))if(z.toLowerCase()===Z){if(Array.isArray(q)){if(q.length<=1)return q[0];return console.warn(`Received ${q.length} entries for the ${X} header, using the first entry.`),q[0]}return q}return};class W0 extends A4{constructor($,X,Z,z){super($,X,Z,z);this.data=Z.data||[],this.has_more=Z.has_more||!1,this.first_id=Z.first_id||null,this.last_id=Z.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let X=Object.fromEntries($.url.searchParams);if(!Object.keys(X).length)return null;return X}nextPageInfo(){if(this.options.query?.before_id){let X=this.first_id;if(!X)return null;return{params:{before_id:X}}}let $=this.last_id;if(!$)return null;return{params:{after_id:$}}}}class u{constructor($){this._client=$}}class G$ extends u{retrieve($,X){return this._client.get(`/v1/models/${$}?beta=true`,X)}list($={},X){if(r($))return this.list({},$);return this._client.getAPIList("/v1/models?beta=true",n$,{query:$,...X})}}class n$ extends W0{}G$.BetaModelInfosPage=n$;class Q${constructor($,X){this.iterator=$,this.controller=X}async*decoder(){let $=new R0;for await(let X of this.iterator)for(let Z of $.decode(X))yield JSON.parse(Z);for(let X of $.flush())yield JSON.parse(X)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,X){if(!$.body)throw X.abort(),new P("Attempted to iterate over a response with no body");return new Q$(a$($.body),X)}}class Y$ extends u{create($,X){let{betas:Z,...z}=$;return this._client.post("/v1/messages/batches?beta=true",{body:z,...X,headers:{"anthropic-beta":[...Z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}retrieve($,X={},Z){if(r(X))return this.retrieve($,{},X);let{betas:z}=X;return this._client.get(`/v1/messages/batches/${$}?beta=true`,{...Z,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}list($={},X){if(r($))return this.list({},$);let{betas:Z,...z}=$;return this._client.getAPIList("/v1/messages/batches?beta=true",r$,{query:z,...X,headers:{"anthropic-beta":[...Z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}delete($,X={},Z){if(r(X))return this.delete($,{},X);let{betas:z}=X;return this._client.delete(`/v1/messages/batches/${$}?beta=true`,{...Z,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}cancel($,X={},Z){if(r(X))return this.cancel($,{},X);let{betas:z}=X;return this._client.post(`/v1/messages/batches/${$}/cancel?beta=true`,{...Z,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}async results($,X={},Z){if(r(X))return this.results($,{},X);let z=await this.retrieve($);if(!z.results_url)throw new P(`No batch \`results_url\`; Has it finished processing? ${z.processing_status} - ${z.id}`);let{betas:q}=X;return this._client.get(z.results_url,{...Z,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...Z?.headers},stream:!0,__binaryResponse:!0})._thenUnwrap((J,G)=>Q$.fromResponse(G.response,G.controller))}}class r$ extends W0{}Y$.BetaMessageBatchesPage=r$;var pH=($)=>{let X=0,Z=[];while(X<$.length){let z=$[X];if(z==="\\"){X++;continue}if(z==="{"){Z.push({type:"brace",value:"{"}),X++;continue}if(z==="}"){Z.push({type:"brace",value:"}"}),X++;continue}if(z==="["){Z.push({type:"paren",value:"["}),X++;continue}if(z==="]"){Z.push({type:"paren",value:"]"}),X++;continue}if(z===":"){Z.push({type:"separator",value:":"}),X++;continue}if(z===","){Z.push({type:"delimiter",value:","}),X++;continue}if(z==='"'){let Q="",Y=!1;z=$[++X];while(z!=='"'){if(X===$.length){Y=!0;break}if(z==="\\"){if(X++,X===$.length){Y=!0;break}Q+=z+$[X],z=$[++X]}else Q+=z,z=$[++X]}if(z=$[++X],!Y)Z.push({type:"string",value:Q});continue}if(z&&/\s/.test(z)){X++;continue}let J=/[0-9]/;if(z&&J.test(z)||z==="-"||z==="."){let Q="";if(z==="-")Q+=z,z=$[++X];while(z&&J.test(z)||z===".")Q+=z,z=$[++X];Z.push({type:"number",value:Q});continue}let G=/[a-z]/i;if(z&&G.test(z)){let Q="";while(z&&G.test(z)){if(X===$.length)break;Q+=z,z=$[++X]}if(Q=="true"||Q=="false"||Q==="null")Z.push({type:"name",value:Q});else{X++;continue}continue}X++}return Z},U$=($)=>{if($.length===0)return $;let X=$[$.length-1];switch(X.type){case"separator":return $=$.slice(0,$.length-1),U$($);break;case"number":let Z=X.value[X.value.length-1];if(Z==="."||Z==="-")return $=$.slice(0,$.length-1),U$($);case"string":let z=$[$.length-2];if(z?.type==="delimiter")return $=$.slice(0,$.length-1),U$($);else if(z?.type==="brace"&&z.value==="{")return $=$.slice(0,$.length-1),U$($);break;case"delimiter":return $=$.slice(0,$.length-1),U$($);break}return $},lH=($)=>{let X=[];if($.map((Z)=>{if(Z.type==="brace")if(Z.value==="{")X.push("}");else X.splice(X.lastIndexOf("}"),1);if(Z.type==="paren")if(Z.value==="[")X.push("]");else X.splice(X.lastIndexOf("]"),1)}),X.length>0)X.reverse().map((Z)=>{if(Z==="}")$.push({type:"brace",value:"}"});else if(Z==="]")$.push({type:"paren",value:"]"})});return $},cH=($)=>{let X="";return $.map((Z)=>{switch(Z.type){case"string":X+='"'+Z.value+'"';break;default:X+=Z.value;break}}),X},N2=($)=>JSON.parse(cH(lH(U$(pH($)))));var d=function($,X,Z,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,Z):q?q.value=Z:X.set($,Z),Z},A=function($,X,Z,z){if(Z==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?z:Z==="a"?z.call($):z?z.value:X.get($)},o,P0,o$,A2,t$,e$,j2,$1,V0,X1,S2,C2,H$,E2,b2,j4,o8,S4,C4,E4,b4,t8,e8="__json_buf";class Z1{constructor(){o.add(this),this.messages=[],this.receivedMessages=[],P0.set(this,void 0),this.controller=new AbortController,o$.set(this,void 0),A2.set(this,()=>{}),t$.set(this,()=>{}),e$.set(this,void 0),j2.set(this,()=>{}),$1.set(this,()=>{}),V0.set(this,{}),X1.set(this,!1),S2.set(this,!1),C2.set(this,!1),H$.set(this,!1),E2.set(this,void 0),b2.set(this,void 0),S4.set(this,($)=>{if(d(this,S2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new m;if($ instanceof m)return d(this,C2,!0,"f"),this._emit("abort",$);if($ instanceof P)return this._emit("error",$);if($ instanceof Error){let X=new P($.message);return X.cause=$,this._emit("error",X)}return this._emit("error",new P(String($)))}),d(this,o$,new Promise(($,X)=>{d(this,A2,$,"f"),d(this,t$,X,"f")}),"f"),d(this,e$,new Promise(($,X)=>{d(this,j2,$,"f"),d(this,$1,X,"f")}),"f"),A(this,o$,"f").catch(()=>{}),A(this,e$,"f").catch(()=>{})}get response(){return A(this,E2,"f")}get request_id(){return A(this,b2,"f")}async withResponse(){let $=await A(this,o$,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let X=new Z1;return X._run(()=>X._fromReadableStream($)),X}static createMessage($,X,Z){let z=new Z1;for(let q of X.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...X,stream:!0},{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},A(this,S4,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,X=!0){if(this.receivedMessages.push($),X)this._emit("message",$)}async _createMessage($,X,Z){let z=Z?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}A(this,o,"m",C4).call(this);let{response:q,data:J}=await $.create({...X,stream:!0},{...Z,signal:this.controller.signal}).withResponse();this._connected(q);for await(let G of J)A(this,o,"m",E4).call(this,G);if(J.controller.signal?.aborted)throw new m;A(this,o,"m",b4).call(this)}_connected($){if(this.ended)return;d(this,E2,$,"f"),d(this,b2,$?.headers.get("request-id"),"f"),A(this,A2,"f").call(this,$),this._emit("connect")}get ended(){return A(this,X1,"f")}get errored(){return A(this,S2,"f")}get aborted(){return A(this,C2,"f")}abort(){this.controller.abort()}on($,X){return(A(this,V0,"f")[$]||(A(this,V0,"f")[$]=[])).push({listener:X}),this}off($,X){let Z=A(this,V0,"f")[$];if(!Z)return this;let z=Z.findIndex((q)=>q.listener===X);if(z>=0)Z.splice(z,1);return this}once($,X){return(A(this,V0,"f")[$]||(A(this,V0,"f")[$]=[])).push({listener:X,once:!0}),this}emitted($){return new Promise((X,Z)=>{if(d(this,H$,!0,"f"),$!=="error")this.once("error",Z);this.once($,X)})}async done(){d(this,H$,!0,"f"),await A(this,e$,"f")}get currentMessage(){return A(this,P0,"f")}async finalMessage(){return await this.done(),A(this,o,"m",j4).call(this)}async finalText(){return await this.done(),A(this,o,"m",o8).call(this)}_emit($,...X){if(A(this,X1,"f"))return;if($==="end")d(this,X1,!0,"f"),A(this,j2,"f").call(this);let Z=A(this,V0,"f")[$];if(Z)A(this,V0,"f")[$]=Z.filter((z)=>!z.once),Z.forEach(({listener:z})=>z(...X));if($==="abort"){let z=X[0];if(!A(this,H$,"f")&&!Z?.length)Promise.reject(z);A(this,t$,"f").call(this,z),A(this,$1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=X[0];if(!A(this,H$,"f")&&!Z?.length)Promise.reject(z);A(this,t$,"f").call(this,z),A(this,$1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",A(this,o,"m",j4).call(this))}async _fromReadableStream($,X){let Z=X?.signal;if(Z){if(Z.aborted)this.controller.abort();Z.addEventListener("abort",()=>this.controller.abort())}A(this,o,"m",C4).call(this),this._connected(null);let z=i.fromReadableStream($,this.controller);for await(let q of z)A(this,o,"m",E4).call(this,q);if(z.controller.signal?.aborted)throw new m;A(this,o,"m",b4).call(this)}[(P0=new WeakMap,o$=new WeakMap,A2=new WeakMap,t$=new WeakMap,e$=new WeakMap,j2=new WeakMap,$1=new WeakMap,V0=new WeakMap,X1=new WeakMap,S2=new WeakMap,C2=new WeakMap,H$=new WeakMap,E2=new WeakMap,b2=new WeakMap,S4=new WeakMap,o=new WeakSet,j4=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},o8=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");let X=this.receivedMessages.at(-1).content.filter((Z)=>Z.type==="text").map((Z)=>Z.text);if(X.length===0)throw new P("stream ended without producing a content block with type=text");return X.join(" ")},C4=function(){if(this.ended)return;d(this,P0,void 0,"f")},E4=function(X){if(this.ended)return;let Z=A(this,o,"m",t8).call(this,X);switch(this._emit("streamEvent",X,Z),X.type){case"content_block_delta":{let z=Z.content.at(-1);switch(X.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",X.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",X.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",X.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",X.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:$Z(X.delta)}break}case"message_stop":{this._addMessageParam(Z),this._addMessage(Z,!0);break}case"content_block_stop":{this._emit("contentBlock",Z.content.at(-1));break}case"message_start":{d(this,P0,Z,"f");break}case"content_block_start":case"message_delta":break}},b4=function(){if(this.ended)throw new P("stream has ended, this shouldn't happen");let X=A(this,P0,"f");if(!X)throw new P("request ended without sending any chunks");return d(this,P0,void 0,"f"),X},t8=function(X){let Z=A(this,P0,"f");if(X.type==="message_start"){if(Z)throw new P(`Unexpected event order, got ${X.type} before receiving "message_stop"`);return X.message}if(!Z)throw new P(`Unexpected event order, got ${X.type} before "message_start"`);switch(X.type){case"message_stop":return Z;case"message_delta":return Z.stop_reason=X.delta.stop_reason,Z.stop_sequence=X.delta.stop_sequence,Z.usage.output_tokens=X.usage.output_tokens,Z;case"content_block_start":return Z.content.push(X.content_block),Z;case"content_block_delta":{let z=Z.content.at(X.index);switch(X.delta.type){case"text_delta":{if(z?.type==="text")z.text+=X.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(X.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[e8]||"";if(q+=X.delta.partial_json,Object.defineProperty(z,e8,{value:q,enumerable:!1,writable:!0}),q)z.input=N2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=X.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=X.delta.signature;break}default:$Z(X.delta)}return Z}case"content_block_stop":return Z}},Symbol.asyncIterator)](){let $=[],X=[],Z=!1;return this.on("streamEvent",(z)=>{let q=X.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{Z=!0;for(let z of X)z.resolve(void 0);X.length=0}),this.on("abort",(z)=>{Z=!0;for(let q of X)q.reject(z);X.length=0}),this.on("error",(z)=>{Z=!0;for(let q of X)q.reject(z);X.length=0}),{next:async()=>{if(!$.length){if(Z)return{value:void 0,done:!0};return new Promise((q,J)=>X.push({resolve:q,reject:J})).then((q)=>q?{value:q,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new i(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function $Z($){}var XZ={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};class m0 extends u{constructor(){super(...arguments);this.batches=new Y$(this._client)}create($,X){let{betas:Z,...z}=$;if(z.model in XZ)console.warn(`The model '${z.model}' is deprecated and will reach end-of-life on ${XZ[z.model]}
|
|
194
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages?beta=true",{body:z,timeout:this._client._options.timeout??(z.stream?600000:this._client._calculateNonstreamingTimeout(z.max_tokens)),...X,headers:{...Z?.toString()!=null?{"anthropic-beta":Z?.toString()}:void 0,...X?.headers},stream:$.stream??!1})}stream($,X){return Z1.createMessage(this,$,X)}countTokens($,X){let{betas:Z,...z}=$;return this._client.post("/v1/messages/count_tokens?beta=true",{body:z,...X,headers:{"anthropic-beta":[...Z??[],"token-counting-2024-11-01"].toString(),...X?.headers}})}}m0.Batches=Y$;m0.BetaMessageBatchesPage=r$;class T0 extends u{constructor(){super(...arguments);this.models=new G$(this._client),this.messages=new m0(this._client)}}T0.Models=G$;T0.BetaModelInfosPage=n$;T0.Messages=m0;class W$ extends u{create($,X){return this._client.post("/v1/complete",{body:$,timeout:this._client._options.timeout??600000,...X,stream:$.stream??!1})}}class V$ extends u{create($,X){return this._client.post("/v1/messages/batches",{body:$,...X})}retrieve($,X){return this._client.get(`/v1/messages/batches/${$}`,X)}list($={},X){if(r($))return this.list({},$);return this._client.getAPIList("/v1/messages/batches",z1,{query:$,...X})}delete($,X){return this._client.delete(`/v1/messages/batches/${$}`,X)}cancel($,X){return this._client.post(`/v1/messages/batches/${$}/cancel`,X)}async results($,X){let Z=await this.retrieve($);if(!Z.results_url)throw new P(`No batch \`results_url\`; Has it finished processing? ${Z.processing_status} - ${Z.id}`);return this._client.get(Z.results_url,{...X,headers:{Accept:"application/binary",...X?.headers},__binaryResponse:!0})._thenUnwrap((z,q)=>Q$.fromResponse(q.response,q.controller))}}class z1 extends W0{}V$.MessageBatchesPage=z1;var p=function($,X,Z,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,Z):q?q.value=Z:X.set($,Z),Z},j=function($,X,Z,z){if(Z==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?z:Z==="a"?z.call($):z?z.value:X.get($)},t,N0,q1,x2,J1,G1,y2,Q1,B0,Y1,k2,f2,T$,g2,h2,x4,ZZ,y4,k4,f4,g4,zZ,qZ="__json_buf";class U1{constructor(){t.add(this),this.messages=[],this.receivedMessages=[],N0.set(this,void 0),this.controller=new AbortController,q1.set(this,void 0),x2.set(this,()=>{}),J1.set(this,()=>{}),G1.set(this,void 0),y2.set(this,()=>{}),Q1.set(this,()=>{}),B0.set(this,{}),Y1.set(this,!1),k2.set(this,!1),f2.set(this,!1),T$.set(this,!1),g2.set(this,void 0),h2.set(this,void 0),y4.set(this,($)=>{if(p(this,k2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new m;if($ instanceof m)return p(this,f2,!0,"f"),this._emit("abort",$);if($ instanceof P)return this._emit("error",$);if($ instanceof Error){let X=new P($.message);return X.cause=$,this._emit("error",X)}return this._emit("error",new P(String($)))}),p(this,q1,new Promise(($,X)=>{p(this,x2,$,"f"),p(this,J1,X,"f")}),"f"),p(this,G1,new Promise(($,X)=>{p(this,y2,$,"f"),p(this,Q1,X,"f")}),"f"),j(this,q1,"f").catch(()=>{}),j(this,G1,"f").catch(()=>{})}get response(){return j(this,g2,"f")}get request_id(){return j(this,h2,"f")}async withResponse(){let $=await j(this,q1,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let X=new U1;return X._run(()=>X._fromReadableStream($)),X}static createMessage($,X,Z){let z=new U1;for(let q of X.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...X,stream:!0},{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},j(this,y4,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,X=!0){if(this.receivedMessages.push($),X)this._emit("message",$)}async _createMessage($,X,Z){let z=Z?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}j(this,t,"m",k4).call(this);let{response:q,data:J}=await $.create({...X,stream:!0},{...Z,signal:this.controller.signal}).withResponse();this._connected(q);for await(let G of J)j(this,t,"m",f4).call(this,G);if(J.controller.signal?.aborted)throw new m;j(this,t,"m",g4).call(this)}_connected($){if(this.ended)return;p(this,g2,$,"f"),p(this,h2,$?.headers.get("request-id"),"f"),j(this,x2,"f").call(this,$),this._emit("connect")}get ended(){return j(this,Y1,"f")}get errored(){return j(this,k2,"f")}get aborted(){return j(this,f2,"f")}abort(){this.controller.abort()}on($,X){return(j(this,B0,"f")[$]||(j(this,B0,"f")[$]=[])).push({listener:X}),this}off($,X){let Z=j(this,B0,"f")[$];if(!Z)return this;let z=Z.findIndex((q)=>q.listener===X);if(z>=0)Z.splice(z,1);return this}once($,X){return(j(this,B0,"f")[$]||(j(this,B0,"f")[$]=[])).push({listener:X,once:!0}),this}emitted($){return new Promise((X,Z)=>{if(p(this,T$,!0,"f"),$!=="error")this.once("error",Z);this.once($,X)})}async done(){p(this,T$,!0,"f"),await j(this,G1,"f")}get currentMessage(){return j(this,N0,"f")}async finalMessage(){return await this.done(),j(this,t,"m",x4).call(this)}async finalText(){return await this.done(),j(this,t,"m",ZZ).call(this)}_emit($,...X){if(j(this,Y1,"f"))return;if($==="end")p(this,Y1,!0,"f"),j(this,y2,"f").call(this);let Z=j(this,B0,"f")[$];if(Z)j(this,B0,"f")[$]=Z.filter((z)=>!z.once),Z.forEach(({listener:z})=>z(...X));if($==="abort"){let z=X[0];if(!j(this,T$,"f")&&!Z?.length)Promise.reject(z);j(this,J1,"f").call(this,z),j(this,Q1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=X[0];if(!j(this,T$,"f")&&!Z?.length)Promise.reject(z);j(this,J1,"f").call(this,z),j(this,Q1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",j(this,t,"m",x4).call(this))}async _fromReadableStream($,X){let Z=X?.signal;if(Z){if(Z.aborted)this.controller.abort();Z.addEventListener("abort",()=>this.controller.abort())}j(this,t,"m",k4).call(this),this._connected(null);let z=i.fromReadableStream($,this.controller);for await(let q of z)j(this,t,"m",f4).call(this,q);if(z.controller.signal?.aborted)throw new m;j(this,t,"m",g4).call(this)}[(N0=new WeakMap,q1=new WeakMap,x2=new WeakMap,J1=new WeakMap,G1=new WeakMap,y2=new WeakMap,Q1=new WeakMap,B0=new WeakMap,Y1=new WeakMap,k2=new WeakMap,f2=new WeakMap,T$=new WeakMap,g2=new WeakMap,h2=new WeakMap,y4=new WeakMap,t=new WeakSet,x4=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},ZZ=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");let X=this.receivedMessages.at(-1).content.filter((Z)=>Z.type==="text").map((Z)=>Z.text);if(X.length===0)throw new P("stream ended without producing a content block with type=text");return X.join(" ")},k4=function(){if(this.ended)return;p(this,N0,void 0,"f")},f4=function(X){if(this.ended)return;let Z=j(this,t,"m",zZ).call(this,X);switch(this._emit("streamEvent",X,Z),X.type){case"content_block_delta":{let z=Z.content.at(-1);switch(X.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",X.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",X.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",X.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",X.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:JZ(X.delta)}break}case"message_stop":{this._addMessageParam(Z),this._addMessage(Z,!0);break}case"content_block_stop":{this._emit("contentBlock",Z.content.at(-1));break}case"message_start":{p(this,N0,Z,"f");break}case"content_block_start":case"message_delta":break}},g4=function(){if(this.ended)throw new P("stream has ended, this shouldn't happen");let X=j(this,N0,"f");if(!X)throw new P("request ended without sending any chunks");return p(this,N0,void 0,"f"),X},zZ=function(X){let Z=j(this,N0,"f");if(X.type==="message_start"){if(Z)throw new P(`Unexpected event order, got ${X.type} before receiving "message_stop"`);return X.message}if(!Z)throw new P(`Unexpected event order, got ${X.type} before "message_start"`);switch(X.type){case"message_stop":return Z;case"message_delta":return Z.stop_reason=X.delta.stop_reason,Z.stop_sequence=X.delta.stop_sequence,Z.usage.output_tokens=X.usage.output_tokens,Z;case"content_block_start":return Z.content.push(X.content_block),Z;case"content_block_delta":{let z=Z.content.at(X.index);switch(X.delta.type){case"text_delta":{if(z?.type==="text")z.text+=X.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(X.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[qZ]||"";if(q+=X.delta.partial_json,Object.defineProperty(z,qZ,{value:q,enumerable:!1,writable:!0}),q)z.input=N2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=X.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=X.delta.signature;break}default:JZ(X.delta)}return Z}case"content_block_stop":return Z}},Symbol.asyncIterator)](){let $=[],X=[],Z=!1;return this.on("streamEvent",(z)=>{let q=X.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{Z=!0;for(let z of X)z.resolve(void 0);X.length=0}),this.on("abort",(z)=>{Z=!0;for(let q of X)q.reject(z);X.length=0}),this.on("error",(z)=>{Z=!0;for(let q of X)q.reject(z);X.length=0}),{next:async()=>{if(!$.length){if(Z)return{value:void 0,done:!0};return new Promise((q,J)=>X.push({resolve:q,reject:J})).then((q)=>q?{value:q,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new i(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function JZ($){}class A0 extends u{constructor(){super(...arguments);this.batches=new V$(this._client)}create($,X){if($.model in GZ)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${GZ[$.model]}
|
|
195
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages",{body:$,timeout:this._client._options.timeout??($.stream?600000:this._client._calculateNonstreamingTimeout($.max_tokens)),...X,stream:$.stream??!1})}stream($,X){return U1.createMessage(this,$,X)}countTokens($,X){return this._client.post("/v1/messages/count_tokens",{body:$,...X})}}var GZ={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};A0.Batches=V$;A0.MessageBatchesPage=z1;class d0 extends u{retrieve($,X){return this._client.get(`/v1/models/${$}`,X)}list($={},X){if(r($))return this.list({},$);return this._client.getAPIList("/v1/models",B$,{query:$,...X})}}class B$ extends W0{}d0.ModelInfosPage=B$;var QZ;class b extends N4{constructor({baseURL:$=P2("ANTHROPIC_BASE_URL"),apiKey:X=P2("ANTHROPIC_API_KEY")??null,authToken:Z=P2("ANTHROPIC_AUTH_TOKEN")??null,...z}={}){let q={apiKey:X,authToken:Z,...z,baseURL:$||"https://api.anthropic.com"};if(!q.dangerouslyAllowBrowser&&r8())throw new P(`It looks like you're running in a browser-like environment.
|
|
196
|
+
|
|
197
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
198
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
199
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
200
|
+
|
|
201
|
+
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
202
|
+
`);super({baseURL:q.baseURL,timeout:q.timeout??600000,httpAgent:q.httpAgent,maxRetries:q.maxRetries,fetch:q.fetch});this.completions=new W$(this),this.messages=new A0(this),this.models=new d0(this),this.beta=new T0(this),this._options=q,this.apiKey=X,this.authToken=Z}defaultQuery(){return this._options.defaultQuery}defaultHeaders($){return{...super.defaultHeaders($),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01",...this._options.defaultHeaders}}validateHeaders($,X){if(this.apiKey&&$["x-api-key"])return;if(X["x-api-key"]===null)return;if(this.authToken&&$.authorization)return;if(X.authorization===null)return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}authHeaders($){return{...this.apiKeyAuth($),...this.bearerAuth($)}}apiKeyAuth($){if(this.apiKey==null)return{};return{"X-Api-Key":this.apiKey}}bearerAuth($){if(this.authToken==null)return{};return{Authorization:`Bearer ${this.authToken}`}}}QZ=b;b.Anthropic=QZ;b.HUMAN_PROMPT=`
|
|
203
|
+
|
|
204
|
+
Human:`;b.AI_PROMPT=`
|
|
205
|
+
|
|
206
|
+
Assistant:`;b.DEFAULT_TIMEOUT=600000;b.AnthropicError=P;b.APIError=v;b.APIConnectionError=v0;b.APIConnectionTimeoutError=i$;b.APIUserAbortError=m;b.NotFoundError=K2;b.ConflictError=L2;b.RateLimitError=_2;b.BadRequestError=V2;b.AuthenticationError=T2;b.InternalServerError=F2;b.PermissionDeniedError=B2;b.UnprocessableEntityError=D2;b.toFile=u8;b.fileFromPath=W2;b.Completions=W$;b.Messages=A0;b.Models=d0;b.ModelInfosPage=B$;b.Beta=T0;var YZ=b;function K$($,X,Z){let z=X.length>0?X.map((G)=>`- ${G.id}: ${G.name} (${G.source})`).join(`
|
|
207
|
+
`):"(no sources provided)",q=X.map((G)=>`<source id="${G.id}">
|
|
208
|
+
${G.content.trimEnd()}
|
|
192
209
|
</source>`).join(`
|
|
193
210
|
|
|
194
|
-
`),
|
|
211
|
+
`),J=Z.length>0?`The scenario REQUIRES citations from: ${Z.join(", ")}.`:"No specific source is required, but every claim must cite a registered source.";return`You are answering a question about the tool "${$.name}": ${$.description}.
|
|
195
212
|
|
|
196
213
|
Answer using ONLY information from the provided sources below. Do not draw on general knowledge.
|
|
197
214
|
|
|
198
215
|
Available sources:
|
|
199
|
-
${
|
|
216
|
+
${z}
|
|
200
217
|
|
|
201
|
-
${
|
|
218
|
+
${q}
|
|
202
219
|
|
|
203
|
-
${
|
|
220
|
+
${J}
|
|
204
221
|
|
|
205
222
|
End your response with a "## Sources" section that lists every source you actually used. Use this exact format:
|
|
206
223
|
|
|
@@ -211,19 +228,19 @@ End your response with a "## Sources" section that lists every source you actual
|
|
|
211
228
|
Rules:
|
|
212
229
|
- Only cite IDs that appear in the inventory above. Do not invent IDs.
|
|
213
230
|
- If you cannot answer from the provided sources, say so explicitly and write an empty "## Sources" section (just the heading, no bullets).
|
|
214
|
-
- The "## Sources" heading must be the last heading in your response.`}class
|
|
231
|
+
- The "## Sources" heading must be the last heading in your response.`}class h4{category="api";provider="anthropic";name;config;clientFactory;constructor($,X,Z){this.name=$,this.config=X,this.clientFactory=Z??(()=>new YZ)}async run($,X){let{tool:Z,docs:z,requiredSources:q}=X;if(!this.config.model)throw Error(`API target "${this.name}" missing 'model'. API targets must declare an explicit model.`);let J=K$(Z,z,q),Q=await this.clientFactory().messages.create({model:this.config.model,max_tokens:this.config.maxTokens??4096,temperature:this.config.temperature??0,system:J,messages:[{role:"user",content:$}]}),Y=nH(Q.content);return{response:Y,allResponses:Y?[{type:"final",text:Y}]:[],toolsUsed:[],sources:[],metadata:{model:this.config.model,category:this.category,provider:this.provider,target:this.name}}}}function nH($){if(!Array.isArray($))return"";let X=[];for(let Z of $)if(Z.type==="text"&&typeof Z.text==="string")X.push(Z.text);return X.join("")}import{query as rH}from"@anthropic-ai/claude-agent-sdk";class v4{category="cli";provider="claude-code";name;config;constructor($,X){this.name=$,this.config=X}async run($,X){let{tool:Z,cwd:z,context:q,docs:J,requiredSources:G}=X,Q=[],Y=[],U=K$(Z,J,G),W={cwd:z,model:this.config.model??"sonnet",systemPrompt:U,allowedTools:q?.allowedTools??this.config.allowedTools??t2,disallowedTools:q?.disallowedTools??this.config.disallowedTools??e2,permissionMode:this.config.permissionMode??"acceptEdits",maxTurns:this.config.maxTurns??10,maxThinkingTokens:this.config.maxThinkingTokens,maxBudgetUsd:this.config.maxBudgetUsd,mcpServers:q?.mcpServers??this.config.mcpServers,settingSources:[]},H=[],V="",B="";for await(let L of rH({prompt:$,options:W})){if(L.type==="assistant"){let T=L.message?.content;if(Array.isArray(T)){let K="";for(let _ of T){if(_.type==="text")K+=_.text;if(_.type==="tool_use"){let F=_;if(!Q.includes(F.name))Q.push(F.name)}}if(K){let _=H.length===0?"initial":"intermediate";H.push({type:_,text:K}),V=K}}}if(L.type==="result"){let T=L;if(T.result)B=T.result}}if(H.length>0)H[H.length-1].type="final";return{response:B||V,allResponses:H,toolsUsed:Q,sources:Y,metadata:{model:this.config.model??"sonnet",category:this.category,provider:this.provider,target:this.name}}}}import{randomUUID as oH}from"crypto";import{rm as tH}from"fs/promises";import{tmpdir as eH}from"os";import{join as $W}from"path";var XW="codex";class u4{category="cli";provider="codex-cli";name;config;spawnFn;readFileFn;binary;constructor($,X,Z={}){this.name=$,this.config=X,this.spawnFn=Z.spawn??JW,this.readFileFn=Z.readFile??GW,this.binary=Z.binary??XW}async run($,X){let{tool:Z,cwd:z,docs:q,requiredSources:J}=X,G=this.config.model;if(!G)throw Error(`CodexCliTarget "${this.name}" requires an explicit model. Validation should have caught this at config load.`);let Y=`${K$(Z,q,J)}
|
|
215
232
|
|
|
216
233
|
---
|
|
217
234
|
|
|
218
|
-
${$}`,U
|
|
219
|
-
`)){let Z=X.trim();if(!Z)continue;let H;try{H=JSON.parse(Z)}catch{continue}let Q=vJ(H);if(Q){let G=q.length===0?"initial":"intermediate";q.push({type:G,text:Q})}let J=uJ(H);if(J&&!z.includes(J))z.push(J)}return{allResponses:q,toolsUsed:z}}function vJ($){if(!$||typeof $!=="object")return null;let q=$;if(typeof q.message==="string")return q.message;if(typeof q.content==="string")return q.content;if(typeof q.type==="string"&&(q.type==="assistant_message"||q.type==="agent_message")&&typeof q.text==="string")return q.text;if(q.type==="message"&&typeof q.text==="string")return q.text;return null}function uJ($){if(!$||typeof $!=="object")return null;let q=$;if(typeof q.tool==="string")return q.tool;if(typeof q.type==="string"&&(q.type==="tool_call"||q.type==="function_call")&&typeof q.name==="string")return q.name;return null}var mJ=async($,q,z)=>{let X=Bun.spawn([$,...q],{cwd:z.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});X.stdin.write(z.stdin),await X.stdin.end();let[Z,H,Q]=await Promise.all([new Response(X.stdout).text(),new Response(X.stderr).text(),X.exited]);return{exitCode:Q,stdout:Z,stderr:H}},dJ=async($)=>{let q=Bun.file($);if(!await q.exists())throw Error(`Last-message file not found: ${$}`);return q.text()};function d1($,q){let z=q??l;switch(z.category){case"cli":return pJ($,z);case"api":throw Error("API targets not yet implemented. Coming soon!");case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${z.category}`)}}function pJ($,q){switch(q.provider){case"claude-code":return new u1($,q);case"codex-cli":return new m1($,q);case"gemini-cli":throw Error("Gemini CLI target not yet implemented. Coming soon!");case"amazon-q":throw Error("Amazon Q target not yet implemented. Coming soon!");default:throw Error(`Unknown CLI provider: ${q.provider}`)}}var b0="default";function p1($,q){if(!$||$===b0)return{name:b0,config:l};if(q?.[$])return{name:$,config:q[$]};return console.warn(`Target "${$}" not found, using default`),{name:b0,config:l}}function C4($,q){if(!$||$===b0)return{name:b0,config:{}};if(q?.[$])return{name:$,config:q[$]};return console.warn(`Context "${$}" not found, using default`),{name:b0,config:{}}}function lJ($){let q=[],z=$.matrix?.target??["default"],X=$.matrix?.context??["default"];for(let Z of $.scenarios){let H=Z.target?[Z.target]:z,Q=Z.context?[Z.context]:X;for(let J of H)for(let G of Q)q.push({scenario:Z,targetName:J,contextName:G})}return q}async function l1($,q,z={}){let{onProgress:X}=z,Z=[];if(q.scenarios.length===0)throw Error("No scenarios defined in config");let H=q.docs?.sources??{},Q=[];if(Object.keys(H).length>0){X?.("Loading sources..."),Q=await H$(H,$.path);for(let B of Q)X?.(` [${B.id}] ${B.name}`);X?.("")}let J=Q.map((B)=>B.id),G=lJ(q),U="";for(let{scenario:B,targetName:Y,contextName:W}of G){let L=cJ(Y,W);if(B.name!==U){if(U)X?.("");X?.(`"${B.name}"`),U=B.name}try{let _=await iJ(B,Y,W,$,q,Q,J,z);Z.push(_);let T=L?L.padEnd(18):"";if(_.surfaces){X?.(` ${T} (compare-surfaces mode)`);for(let V of _.surfaces){let D=L0(V),R=` [${V.active.join(",")}]`.padEnd(22);X?.(`${R} ${D.icon} ${D.label} (${D.confidence}%)`)}}else{let V=L0({answerable:_.answerable??"NO",confidence:_.confidence??0,traps:_.traps??{fired:[],avoided:[]},error:_.error});X?.(` ${T} ${V.icon} ${V.label} (${V.confidence}%)`)}}catch(_){let T=Y==="default"?l:q.targets?.[Y]??l,V={scenario:B,answerable:"NO",confidence:0,response:"",reason:"Error during run",citations:{cited:[],required:B.requiredSources,missing:B.requiredSources,unknown:[]},traps:{fired:[],avoided:(B.traps??[]).map((R)=>R.id)},error:_ instanceof Error?_.message:String(_),target:{target:Y,category:T.category,provider:T.provider,model:T.model??"unknown"},context:{name:W}};Z.push(V);let D=L?L.padEnd(18):"";X?.(` ${D} \u2717 Error`)}}return X?.(""),aJ($,Q,Z)}function cJ($,q){if($==="default"&&q==="default")return"";if(q==="default")return`[${$}]`;return`[${$}/${q}]`}async function iJ($,q,z,X,Z,H,Q,J){let{config:G}=p1(q,Z.targets),{config:U}=C4(z,Z.contexts),B=J.targetFactory?J.targetFactory(q,G):d1(q,G);if($.compareSurfaces&&$.compareSurfaces.length>0){let R=[],w;for(let K of $.compareSurfaces){let O=new Set(K),F=H.filter((V0)=>O.has(V0.id)),S=$.requiredSources.filter((V0)=>O.has(V0)),M=await B.run($.prompt,{tool:X,cwd:X.path,context:U,docs:F,requiredSources:S,onProgress:J.onProgress}),N=Q$({response:M.response,requiredSources:S,registeredIds:K}),x=T0({response:M.response,traps:$.traps??[]}),p=x.fired.length>0,C=p?"NO":N.answerable,G$=p?0:N.confidence,q5=p?`Trap fired: ${x.fired.map((V0)=>`"${V0.id}" (${V0.reason})`).join("; ")}`:N.reason;R.push({active:K,answerable:C,confidence:G$,response:M.response,reason:q5,citations:N.citations,traps:x,allResponses:M.allResponses}),w=M.metadata??w}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:R,target:w,context:{name:z}}}let Y=await B.run($.prompt,{tool:X,cwd:X.path,context:U,docs:H,requiredSources:$.requiredSources,onProgress:J.onProgress}),W=Q$({response:Y.response,requiredSources:$.requiredSources,registeredIds:Q}),L=T0({response:Y.response,traps:$.traps??[]}),_=L.fired.length>0,T=_?"NO":W.answerable,V=_?0:W.confidence,D=_?`Trap fired: ${L.fired.map((R)=>`"${R.id}" (${R.reason})`).join("; ")}`:W.reason;return{scenario:$,answerable:T,confidence:V,response:Y.response,reason:D,citations:W.citations,traps:L,target:Y.metadata,context:{name:z},toolsUsed:Y.toolsUsed,sources:Y.sources,allResponses:Y.allResponses}}function aJ($,q,z){let X=[];for(let J of z){if(J.surfaces){for(let G of J.surfaces)X.push({answerable:G.answerable,confidence:G.confidence});continue}if(J.answerable!==null&&J.confidence!==null)X.push({answerable:J.answerable,confidence:J.confidence})}let Z=X.length,H=X.filter((J)=>J.answerable==="YES"||J.answerable==="PARTIAL").length,Q=Z>0?Math.round(X.reduce((J,G)=>{if(G.answerable==="YES")return J+G.confidence;if(G.answerable==="PARTIAL")return J+G.confidence*0.5;return J},0)/Z):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:q,scenarios:z,summary:{total:Z,answered:H,unanswered:Z-H,score:Q}}}var y4=($=0)=>(q)=>`\x1B[${q+$}m`,f4=($=0)=>(q)=>`\x1B[${38+$};5;${q}m`,k4=($=0)=>(q,z,X)=>`\x1B[${38+$};2;${q};${z};${X}m`,E={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},UB=Object.keys(E.modifier),sJ=Object.keys(E.color),rJ=Object.keys(E.bgColor),GB=[...sJ,...rJ];function nJ(){let $=new Map;for(let[q,z]of Object.entries(E)){for(let[X,Z]of Object.entries(z))E[X]={open:`\x1B[${Z[0]}m`,close:`\x1B[${Z[1]}m`},z[X]=E[X],$.set(Z[0],Z[1]);Object.defineProperty(E,q,{value:z,enumerable:!1})}return Object.defineProperty(E,"codes",{value:$,enumerable:!1}),E.color.close="\x1B[39m",E.bgColor.close="\x1B[49m",E.color.ansi=y4(),E.color.ansi256=f4(),E.color.ansi16m=k4(),E.bgColor.ansi=y4(10),E.bgColor.ansi256=f4(10),E.bgColor.ansi16m=k4(10),Object.defineProperties(E,{rgbToAnsi256:{value(q,z,X){if(q===z&&z===X){if(q<8)return 16;if(q>248)return 231;return Math.round((q-8)/247*24)+232}return 16+36*Math.round(q/255*5)+6*Math.round(z/255*5)+Math.round(X/255*5)},enumerable:!1},hexToRgb:{value(q){let z=/[a-f\d]{6}|[a-f\d]{3}/i.exec(q.toString(16));if(!z)return[0,0,0];let[X]=z;if(X.length===3)X=[...X].map((H)=>H+H).join("");let Z=Number.parseInt(X,16);return[Z>>16&255,Z>>8&255,Z&255]},enumerable:!1},hexToAnsi256:{value:(q)=>E.rgbToAnsi256(...E.hexToRgb(q)),enumerable:!1},ansi256ToAnsi:{value(q){if(q<8)return 30+q;if(q<16)return 90+(q-8);let z,X,Z;if(q>=232)z=((q-232)*10+8)/255,X=z,Z=z;else{q-=16;let J=q%36;z=Math.floor(q/36)/5,X=Math.floor(J/6)/5,Z=J%6/5}let H=Math.max(z,X,Z)*2;if(H===0)return 30;let Q=30+(Math.round(Z)<<2|Math.round(X)<<1|Math.round(z));if(H===2)Q+=60;return Q},enumerable:!1},rgbToAnsi:{value:(q,z,X)=>E.ansi256ToAnsi(E.rgbToAnsi256(q,z,X)),enumerable:!1},hexToAnsi:{value:(q)=>E.ansi256ToAnsi(E.hexToAnsi256(q)),enumerable:!1}}),E}var oJ=nJ(),d=oJ;import c1 from"process";import tJ from"os";import x4 from"tty";function v($,q=globalThis.Deno?globalThis.Deno.args:c1.argv){let z=$.startsWith("-")?"":$.length===1?"-":"--",X=q.indexOf(z+$),Z=q.indexOf("--");return X!==-1&&(Z===-1||X<Z)}var{env:b}=c1,Uq;if(v("no-color")||v("no-colors")||v("color=false")||v("color=never"))Uq=0;else if(v("color")||v("colors")||v("color=true")||v("color=always"))Uq=1;function eJ(){if("FORCE_COLOR"in b){if(b.FORCE_COLOR==="true")return 1;if(b.FORCE_COLOR==="false")return 0;return b.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(b.FORCE_COLOR,10),3)}}function $U($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function qU($,{streamIsTTY:q,sniffFlags:z=!0}={}){let X=eJ();if(X!==void 0)Uq=X;let Z=z?Uq:X;if(Z===0)return 0;if(z){if(v("color=16m")||v("color=full")||v("color=truecolor"))return 3;if(v("color=256"))return 2}if("TF_BUILD"in b&&"AGENT_NAME"in b)return 1;if($&&!q&&Z===void 0)return 0;let H=Z||0;if(b.TERM==="dumb")return H;if(c1.platform==="win32"){let Q=tJ.release().split(".");if(Number(Q[0])>=10&&Number(Q[2])>=10586)return Number(Q[2])>=14931?3:2;return 1}if("CI"in b){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((Q)=>(Q in b)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((Q)=>(Q in b))||b.CI_NAME==="codeship")return 1;return H}if("TEAMCITY_VERSION"in b)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(b.TEAMCITY_VERSION)?1:0;if(b.COLORTERM==="truecolor")return 3;if(b.TERM==="xterm-kitty")return 3;if(b.TERM==="xterm-ghostty")return 3;if(b.TERM==="wezterm")return 3;if("TERM_PROGRAM"in b){let Q=Number.parseInt((b.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(b.TERM_PROGRAM){case"iTerm.app":return Q>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(b.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(b.TERM))return 1;if("COLORTERM"in b)return 1;return H}function h4($,q={}){let z=qU($,{streamIsTTY:$&&$.isTTY,...q});return $U(z)}var zU={stdout:h4({isTTY:x4.isatty(1)}),stderr:h4({isTTY:x4.isatty(2)})},g4=zU;function v4($,q,z){let X=$.indexOf(q);if(X===-1)return $;let Z=q.length,H=0,Q="";do Q+=$.slice(H,X)+q+z,H=X+Z,X=$.indexOf(q,H);while(X!==-1);return Q+=$.slice(H),Q}function u4($,q,z,X){let Z=0,H="";do{let Q=$[X-1]==="\r";H+=$.slice(Z,Q?X-1:X)+q+(Q?`\r
|
|
235
|
+
${$}`,U=$W(eH(),`pickled-codex-${oH()}.txt`),W=["--ask-for-approval","never","exec","--json","--sandbox","read-only","--ignore-user-config","--ignore-rules","--ephemeral","--skip-git-repo-check","--cd",z,"--model",G,"--output-last-message",U,"-"];try{let H=await this.spawnFn(this.binary,W,{cwd:z,stdin:Y}),{allResponses:V,toolsUsed:B}=ZW(H.stdout);if(H.exitCode!==0)throw Error(`codex exec failed (exit ${H.exitCode}): ${H.stderr.trim()||"no stderr output"}`);let L="";try{L=(await this.readFileFn(U)).trim()}catch{L=V.length>0?V[V.length-1].text:""}if(V.length>0)V[V.length-1].type="final";return{response:L,allResponses:V,toolsUsed:B,sources:[],metadata:{model:G,category:this.category,provider:this.provider,target:this.name}}}finally{await tH(U,{force:!0})}}}function ZW($){let X=[],Z=[];for(let z of $.split(`
|
|
236
|
+
`)){let q=z.trim();if(!q)continue;let J;try{J=JSON.parse(q)}catch{continue}let G=zW(J);if(G){let Y=X.length===0?"initial":"intermediate";X.push({type:Y,text:G})}let Q=qW(J);if(Q&&!Z.includes(Q))Z.push(Q)}return{allResponses:X,toolsUsed:Z}}function zW($){if(!$||typeof $!=="object")return null;let X=$;if(typeof X.message==="string")return X.message;if(typeof X.content==="string")return X.content;if(typeof X.type==="string"&&(X.type==="assistant_message"||X.type==="agent_message")&&typeof X.text==="string")return X.text;if(X.type==="message"&&typeof X.text==="string")return X.text;return null}function qW($){if(!$||typeof $!=="object")return null;let X=$;if(typeof X.tool==="string")return X.tool;if(typeof X.type==="string"&&(X.type==="tool_call"||X.type==="function_call")&&typeof X.name==="string")return X.name;return null}var JW=async($,X,Z)=>{let z=Bun.spawn([$,...X],{cwd:Z.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});z.stdin.write(Z.stdin),await z.stdin.end();let[q,J,G]=await Promise.all([new Response(z.stdout).text(),new Response(z.stderr).text(),z.exited]);return{exitCode:G,stdout:q,stderr:J}},GW=async($)=>{let X=Bun.file($);if(!await X.exists())throw Error(`Last-message file not found: ${$}`);return X.text()};function m4($,X){let Z=X??q0;switch(Z.category){case"cli":return QW($,Z);case"api":return YW($,Z);case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${Z.category}`)}}function QW($,X){switch(X.provider){case"claude-code":return new v4($,X);case"codex-cli":return new u4($,X);case"gemini-cli":throw Error("Gemini CLI target not yet implemented. Coming soon!");case"amazon-q":throw Error("Amazon Q target not yet implemented. Coming soon!");default:throw Error(`Unknown CLI provider: ${X.provider}`)}}function YW($,X){switch(X.provider){case"anthropic":return new h4($,X);case"openai":throw Error("OpenAI API target not yet implemented. Coming soon!");case"google":throw Error("Google API target not yet implemented. Coming soon!");default:throw Error(`Unknown API provider: ${X.provider}`)}}var L$="default";function d4($,X){if(!$||$===L$)return{name:L$,config:q0};if(X?.[$])return{name:$,config:X[$]};return console.warn(`Target "${$}" not found, using default`),{name:L$,config:q0}}function UZ($,X){if(!$||$===L$)return{name:L$,config:{}};if(X?.[$])return{name:$,config:X[$]};return console.warn(`Context "${$}" not found, using default`),{name:L$,config:{}}}function UW($){let X=[],Z=$.matrix?.target??["default"],z=$.matrix?.context??["default"];for(let q of $.scenarios){let J=q.target?[q.target]:Z,G=q.context?[q.context]:z;for(let Q of J)for(let Y of G)X.push({scenario:q,targetName:Q,contextName:Y})}return X}async function p4($,X,Z={}){let{onProgress:z}=Z,q=[];if(X.scenarios.length===0)throw Error("No scenarios defined in config");let J=X.docs?.sources??{},G=[];if(Object.keys(J).length>0){z?.("Loading sources..."),G=await l$(J,$.path);for(let W of G)z?.(` [${W.id}] ${W.name}`);z?.("")}let Q=G.map((W)=>W.id),Y=UW(X),U="";for(let{scenario:W,targetName:H,contextName:V}of Y){let B=HW(H,V);if(W.name!==U){if(U)z?.("");z?.(`"${W.name}"`),U=W.name}try{let L=await WW(W,H,V,$,X,G,Q,Z);q.push(L);let T=B?B.padEnd(18):"";if(L.surfaces){z?.(` ${T} (compare-surfaces mode)`);for(let K of L.surfaces){let _=f0(K),F=` [${K.active.join(",")}]`.padEnd(22);z?.(`${F} ${_.icon} ${_.label} (${_.confidence}%)`)}}else{let K=f0({answerable:L.answerable??"NO",confidence:L.confidence??0,traps:L.traps??{fired:[],avoided:[]},error:L.error});z?.(` ${T} ${K.icon} ${K.label} (${K.confidence}%)`)}}catch(L){let T=H==="default"?q0:X.targets?.[H]??q0,K={scenario:W,answerable:"NO",confidence:0,response:"",reason:"Error during run",citations:{cited:[],required:W.requiredSources,missing:W.requiredSources,unknown:[]},traps:{fired:[],avoided:(W.traps??[]).map((F)=>F.id)},error:L instanceof Error?L.message:String(L),target:{target:H,category:T.category,provider:T.provider,model:T.model??"unknown"},context:{name:V}};q.push(K);let _=B?B.padEnd(18):"";z?.(` ${_} \u2717 Error`)}}return z?.(""),VW($,G,q)}function HW($,X){if($==="default"&&X==="default")return"";if(X==="default")return`[${$}]`;return`[${$}/${X}]`}async function WW($,X,Z,z,q,J,G,Q){let{config:Y}=d4(X,q.targets),{config:U}=UZ(Z,q.contexts),W=Q.targetFactory?Q.targetFactory(X,Y):m4(X,Y);if($.compareSurfaces&&$.compareSurfaces.length>0){let F=[],O;for(let I of $.compareSurfaces){let R=new Set(I),N=J.filter((p0)=>R.has(p0.id)),E=$.requiredSources.filter((p0)=>R.has(p0)),M=await W.run($.prompt,{tool:z,cwd:z.path,context:U,docs:N,requiredSources:E,onProgress:Q.onProgress}),x=c$({response:M.response,requiredSources:E,registeredIds:I}),a=k0({response:M.response,traps:$.traps??[]}),z0=a.fired.length>0,f=z0?"NO":x.answerable,V1=z0?0:x.confidence,bZ=z0?`Trap fired: ${a.fired.map((p0)=>`"${p0.id}" (${p0.reason})`).join("; ")}`:x.reason;F.push({active:I,answerable:f,confidence:V1,response:M.response,reason:bZ,citations:x.citations,traps:a,allResponses:M.allResponses}),O=M.metadata??O}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:F,target:O,context:{name:Z}}}let H=await W.run($.prompt,{tool:z,cwd:z.path,context:U,docs:J,requiredSources:$.requiredSources,onProgress:Q.onProgress}),V=c$({response:H.response,requiredSources:$.requiredSources,registeredIds:G}),B=k0({response:H.response,traps:$.traps??[]}),L=B.fired.length>0,T=L?"NO":V.answerable,K=L?0:V.confidence,_=L?`Trap fired: ${B.fired.map((F)=>`"${F.id}" (${F.reason})`).join("; ")}`:V.reason;return{scenario:$,answerable:T,confidence:K,response:H.response,reason:_,citations:V.citations,traps:B,target:H.metadata,context:{name:Z},toolsUsed:H.toolsUsed,sources:H.sources,allResponses:H.allResponses}}function VW($,X,Z){let z=[];for(let Q of Z){if(Q.surfaces){for(let Y of Q.surfaces)z.push({answerable:Y.answerable,confidence:Y.confidence});continue}if(Q.answerable!==null&&Q.confidence!==null)z.push({answerable:Q.answerable,confidence:Q.confidence})}let q=z.length,J=z.filter((Q)=>Q.answerable==="YES"||Q.answerable==="PARTIAL").length,G=q>0?Math.round(z.reduce((Q,Y)=>{if(Y.answerable==="YES")return Q+Y.confidence;if(Y.answerable==="PARTIAL")return Q+Y.confidence*0.5;return Q},0)/q):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:X,scenarios:Z,summary:{total:q,answered:J,unanswered:q-J,score:G}}}var HZ=($=0)=>(X)=>`\x1B[${X+$}m`,WZ=($=0)=>(X)=>`\x1B[${38+$};5;${X}m`,VZ=($=0)=>(X,Z,z)=>`\x1B[${38+$};2;${X};${Z};${z}m`,y={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},QL=Object.keys(y.modifier),TW=Object.keys(y.color),BW=Object.keys(y.bgColor),YL=[...TW,...BW];function KW(){let $=new Map;for(let[X,Z]of Object.entries(y)){for(let[z,q]of Object.entries(Z))y[z]={open:`\x1B[${q[0]}m`,close:`\x1B[${q[1]}m`},Z[z]=y[z],$.set(q[0],q[1]);Object.defineProperty(y,X,{value:Z,enumerable:!1})}return Object.defineProperty(y,"codes",{value:$,enumerable:!1}),y.color.close="\x1B[39m",y.bgColor.close="\x1B[49m",y.color.ansi=HZ(),y.color.ansi256=WZ(),y.color.ansi16m=VZ(),y.bgColor.ansi=HZ(10),y.bgColor.ansi256=WZ(10),y.bgColor.ansi16m=VZ(10),Object.defineProperties(y,{rgbToAnsi256:{value(X,Z,z){if(X===Z&&Z===z){if(X<8)return 16;if(X>248)return 231;return Math.round((X-8)/247*24)+232}return 16+36*Math.round(X/255*5)+6*Math.round(Z/255*5)+Math.round(z/255*5)},enumerable:!1},hexToRgb:{value(X){let Z=/[a-f\d]{6}|[a-f\d]{3}/i.exec(X.toString(16));if(!Z)return[0,0,0];let[z]=Z;if(z.length===3)z=[...z].map((J)=>J+J).join("");let q=Number.parseInt(z,16);return[q>>16&255,q>>8&255,q&255]},enumerable:!1},hexToAnsi256:{value:(X)=>y.rgbToAnsi256(...y.hexToRgb(X)),enumerable:!1},ansi256ToAnsi:{value(X){if(X<8)return 30+X;if(X<16)return 90+(X-8);let Z,z,q;if(X>=232)Z=((X-232)*10+8)/255,z=Z,q=Z;else{X-=16;let Q=X%36;Z=Math.floor(X/36)/5,z=Math.floor(Q/6)/5,q=Q%6/5}let J=Math.max(Z,z,q)*2;if(J===0)return 30;let G=30+(Math.round(q)<<2|Math.round(z)<<1|Math.round(Z));if(J===2)G+=60;return G},enumerable:!1},rgbToAnsi:{value:(X,Z,z)=>y.ansi256ToAnsi(y.rgbToAnsi256(X,Z,z)),enumerable:!1},hexToAnsi:{value:(X)=>y.ansi256ToAnsi(y.hexToAnsi256(X)),enumerable:!1}}),y}var LW=KW(),Z0=LW;import l4 from"process";import DW from"os";import TZ from"tty";function e($,X=globalThis.Deno?globalThis.Deno.args:l4.argv){let Z=$.startsWith("-")?"":$.length===1?"-":"--",z=X.indexOf(Z+$),q=X.indexOf("--");return z!==-1&&(q===-1||z<q)}var{env:k}=l4,v2;if(e("no-color")||e("no-colors")||e("color=false")||e("color=never"))v2=0;else if(e("color")||e("colors")||e("color=true")||e("color=always"))v2=1;function _W(){if("FORCE_COLOR"in k){if(k.FORCE_COLOR==="true")return 1;if(k.FORCE_COLOR==="false")return 0;return k.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(k.FORCE_COLOR,10),3)}}function FW($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function MW($,{streamIsTTY:X,sniffFlags:Z=!0}={}){let z=_W();if(z!==void 0)v2=z;let q=Z?v2:z;if(q===0)return 0;if(Z){if(e("color=16m")||e("color=full")||e("color=truecolor"))return 3;if(e("color=256"))return 2}if("TF_BUILD"in k&&"AGENT_NAME"in k)return 1;if($&&!X&&q===void 0)return 0;let J=q||0;if(k.TERM==="dumb")return J;if(l4.platform==="win32"){let G=DW.release().split(".");if(Number(G[0])>=10&&Number(G[2])>=10586)return Number(G[2])>=14931?3:2;return 1}if("CI"in k){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((G)=>(G in k)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((G)=>(G in k))||k.CI_NAME==="codeship")return 1;return J}if("TEAMCITY_VERSION"in k)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(k.TEAMCITY_VERSION)?1:0;if(k.COLORTERM==="truecolor")return 3;if(k.TERM==="xterm-kitty")return 3;if(k.TERM==="xterm-ghostty")return 3;if(k.TERM==="wezterm")return 3;if("TERM_PROGRAM"in k){let G=Number.parseInt((k.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(k.TERM_PROGRAM){case"iTerm.app":return G>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(k.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(k.TERM))return 1;if("COLORTERM"in k)return 1;return J}function BZ($,X={}){let Z=MW($,{streamIsTTY:$&&$.isTTY,...X});return FW(Z)}var OW={stdout:BZ({isTTY:TZ.isatty(1)}),stderr:BZ({isTTY:TZ.isatty(2)})},KZ=OW;function LZ($,X,Z){let z=$.indexOf(X);if(z===-1)return $;let q=X.length,J=0,G="";do G+=$.slice(J,z)+X+Z,J=z+q,z=$.indexOf(X,J);while(z!==-1);return G+=$.slice(J),G}function DZ($,X,Z,z){let q=0,J="";do{let G=$[z-1]==="\r";J+=$.slice(q,G?z-1:z)+X+(G?`\r
|
|
220
237
|
`:`
|
|
221
|
-
`)+
|
|
222
|
-
`,
|
|
223
|
-
`);if(
|
|
224
|
-
`)}function
|
|
225
|
-
`);let J
|
|
226
|
-
`);else
|
|
238
|
+
`)+Z,q=z+1,z=$.indexOf(`
|
|
239
|
+
`,q)}while(z!==-1);return J+=$.slice(q),J}var{stdout:_Z,stderr:FZ}=KZ,c4=Symbol("GENERATOR"),D$=Symbol("STYLER"),H1=Symbol("IS_EMPTY"),MZ=["ansi","ansi","ansi256","ansi16m"],_$=Object.create(null),wW=($,X={})=>{if(X.level&&!(Number.isInteger(X.level)&&X.level>=0&&X.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let Z=_Z?_Z.level:0;$.level=X.level===void 0?Z:X.level};var IW=($)=>{let X=(...Z)=>Z.join(" ");return wW(X,$),Object.setPrototypeOf(X,W1.prototype),X};function W1($){return IW($)}Object.setPrototypeOf(W1.prototype,Function.prototype);for(let[$,X]of Object.entries(Z0))_$[$]={get(){let Z=u2(this,a4(X.open,X.close,this[D$]),this[H1]);return Object.defineProperty(this,$,{value:Z}),Z}};_$.visible={get(){let $=u2(this,this[D$],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var i4=($,X,Z,...z)=>{if($==="rgb"){if(X==="ansi16m")return Z0[Z].ansi16m(...z);if(X==="ansi256")return Z0[Z].ansi256(Z0.rgbToAnsi256(...z));return Z0[Z].ansi(Z0.rgbToAnsi(...z))}if($==="hex")return i4("rgb",X,Z,...Z0.hexToRgb(...z));return Z0[Z][$](...z)},RW=["rgb","hex","ansi256"];for(let $ of RW){_$[$]={get(){let{level:Z}=this;return function(...z){let q=a4(i4($,MZ[Z],"color",...z),Z0.color.close,this[D$]);return u2(this,q,this[H1])}}};let X="bg"+$[0].toUpperCase()+$.slice(1);_$[X]={get(){let{level:Z}=this;return function(...z){let q=a4(i4($,MZ[Z],"bgColor",...z),Z0.bgColor.close,this[D$]);return u2(this,q,this[H1])}}}}var PW=Object.defineProperties(()=>{},{..._$,level:{enumerable:!0,get(){return this[c4].level},set($){this[c4].level=$}}}),a4=($,X,Z)=>{let z,q;if(Z===void 0)z=$,q=X;else z=Z.openAll+$,q=X+Z.closeAll;return{open:$,close:X,openAll:z,closeAll:q,parent:Z}},u2=($,X,Z)=>{let z=(...q)=>NW(z,q.length===1?""+q[0]:q.join(" "));return Object.setPrototypeOf(z,PW),z[c4]=$,z[D$]=X,z[H1]=Z,z},NW=($,X)=>{if($.level<=0||!X)return $[H1]?"":X;let Z=$[D$];if(Z===void 0)return X;let{openAll:z,closeAll:q}=Z;if(X.includes("\x1B"))while(Z!==void 0)X=LZ(X,Z.close,Z.open),Z=Z.parent;let J=X.indexOf(`
|
|
240
|
+
`);if(J!==-1)X=DZ(X,q,z,J);return z+X+q};Object.defineProperties(W1.prototype,_$);var AW=W1(),_L=W1({level:FZ?FZ.level:0});var w=AW;var OZ="\u2500".repeat(55);function PZ($){if($==="success")return w.green;if($==="warning")return w.yellow;return w.red}function jW($){if($>=70)return w.green;if($>=50)return w.yellow;return w.red}function NZ($){if($.label==="Error")return $.label;return`${$.label} (${$.confidence}%)`}function SW($){let X=f0({answerable:$.answerable??"NO",confidence:$.confidence??0,traps:$.traps??{fired:[],avoided:[]},error:$.error}),Z=PZ(X.tone);return{icon:Z(X.icon),status:NZ(X),color:Z}}function CW($){let X=$.target?.target??"default",Z=$.context?.name??"default";if(X==="default"&&Z==="default")return"";if(Z==="default")return w.dim(`[${X}]`);return w.dim(`[${X}/${Z}]`)}function EW($){let X=$.map((Z)=>Z.scenario.name);return new Set(X).size!==X.length}function m2($){return $.map((X)=>`[${X}]`).join(", ")}function AZ($,X){let Z=[];if($.error)return Z.push(w.dim(`${X}error: ${$.error}`)),Z;if($.traps.fired.length>0)for(let z of $.traps.fired)Z.push(w.red(`${X}trap: ${z.id}`)),Z.push(w.dim(`${X}reason: ${z.reason}`)),Z.push(w.dim(`${X}match: "${z.matched}"`));else if($.reason&&$.answerable!=="YES")Z.push(w.dim(`${X}reason: ${$.reason}`));if($.citations.cited.length>0)Z.push(w.dim(`${X}cited: ${m2($.citations.cited)}`));if($.citations.missing.length>0)Z.push(w.dim(`${X}missing: ${m2($.citations.missing)}`));if($.citations.unknown.length>0)Z.push(w.dim(`${X}unknown: ${m2($.citations.unknown)}`));return Z}function wZ($,X){if(!$.traps||!$.citations)return[];return AZ({error:$.error,traps:$.traps,reason:$.reason??"",answerable:$.answerable??"NO",citations:$.citations},X)}function IZ($){let{icon:X,status:Z,color:z}=SW($),q=CW($),J=`${X} ${Z}`;return q?`${q} ${z(J)}`:z(J)}function RZ($,X){if(!$.surfaces)return[];let Z=[];Z.push(`${X}${w.dim("Citations scoped to active surface (compare mode)")}`);for(let z of $.surfaces){let q=f0(z),J=PZ(q.tone),G=w.dim(`[${z.active.join(",")}]`),Q=`${J(q.icon)} ${J(NZ(q))}`;Z.push(`${X}${G} ${Q}`),Z.push(...AZ({traps:z.traps,reason:z.reason,answerable:z.answerable,citations:z.citations},`${X} `))}return Z}function bW($){let X=0,Z=0,z=0;for(let q of $){if(q.surfaces){for(let J of q.surfaces)X+=J.traps.fired.length,Z+=J.citations.missing.length,z+=J.citations.unknown.length;continue}if(q.traps)X+=q.traps.fired.length;if(q.citations)Z+=q.citations.missing.length,z+=q.citations.unknown.length}if(X>0&&Z+z>0)return"Review fired traps and citation gaps.";if(X>0)return"Review fired traps before trusting this surface.";if(Z+z>0)return"Review missing and unknown citations.";return"Citations hold. No declared traps fired."}function xW($,X){let Z=$.summary.score,q=`Overall: ${jW(Z)(`${Z}`)} / 100`;if(X===void 0||X<=0)return q;let G=Z>=X?w.green("run passes"):w.red("run fails");return`${q} \xB7 threshold ${X} \xB7 ${G}`}function jZ($,X={}){let{tool:Z,scenarios:z,summary:q}=$,J=z,G=[];if(G.push(w.bold("pickled check")),G.push(OZ),G.push(`Tool: ${w.cyan(Z.name)}`),$.docs.length>0)G.push(`Sources: ${w.dim(m2($.docs.map((Q)=>Q.id)))}`);else G.push(`Sources: ${w.dim("none registered")}`);if(G.push(`Scenarios: ${w.dim(String(q.total))}`),G.push(""),EW(J)){let Q=new Map;for(let Y of J){let U=Y.scenario.name;if(!Q.has(U))Q.set(U,[]);Q.get(U)?.push(Y)}for(let[Y,U]of Q){G.push(`Scenario: ${Y}`);for(let W of U)if(W.surfaces)G.push(...RZ(W," "));else G.push(` ${IZ(W)}`),G.push(...wZ(W," "));G.push("")}}else for(let Q of J){if(G.push(`Scenario: ${Q.scenario.name}`),Q.surfaces)G.push(...RZ(Q," "));else G.push(` ${IZ(Q)}`),G.push(...wZ(Q," "));G.push("")}return G.push(OZ),G.push(xW($,X.threshold)),G.push(w.dim(bW(z))),G.join(`
|
|
241
|
+
`)}function s4($,X={}){console.log(jZ($,X)),console.log()}function d2($,X={}){if(X.verbose)return JSON.stringify($,null,2);let Z={...$,docs:$.docs.map((z)=>({...z,content:""})),scenarios:$.scenarios.map((z)=>{let{allResponses:q,...J}=z;return J})};return JSON.stringify(Z,null,2)}function kW($){if($.format&&$.format!=="terminal")return $.format;if($.json)return"json";return $.format??"terminal"}async function SZ($,X){let{output:Z}=X,z=kW(X),q=yW.resolve($),J;try{J=await U2({targetRepo:q})}catch(H){console.error(w.red(H instanceof Error?H.message:H)),process.exit(1)}let G;if(z==="json")G=z2(J);else if(z==="markdown")G=Z2(J);else G=q2(J);if(Z)await Bun.write(Z,G);else await fW(`${G}
|
|
242
|
+
`);let Q=J.findings.filter((H)=>H.severity==="error").length,Y=J.findings.filter((H)=>H.severity==="warning").length;if(z!=="json"&&!Z)if(console.log(),Q===0&&Y===0)console.log(w.green("Audit clean. No issues found."));else{let H=Q>0?w.red:w.yellow;console.log(H(`Audit found ${Q} error(s), ${Y} warning(s).`))}if((X.failOn??"error")==="warning"?Q+Y>0:Q>0)process.exit(1)}function fW($){return new Promise((X,Z)=>{process.stdout.write($,(z)=>{if(z)Z(z);else X()})})}import gW from"path";async function CZ($,X){let{json:Z,output:z,verbose:q}=X,J=(V)=>!Z&&console.log(V),G=gW.resolve($),Q;try{Q=await Z$(G)}catch(V){console.error(w.red(V instanceof Error?V.message:V)),console.error(),console.error(w.dim("Run `pickled init` to create a config file")),process.exit(1)}if(X.target){let V=Q.scenarios.length;try{Q=W4(Q,X.target)}catch(L){console.error(w.red(L instanceof Error?L.message:String(L))),process.exit(1)}let B=V-Q.scenarios.length;if(B>0&&!Z)J(w.dim(`Skipping ${B} scenario(s) with explicit target != "${X.target}"`))}let Y={name:Q.tool.name,description:Q.tool.description,path:G};if(q){J(w.bold("pickled check")),J(""),J(w.dim(` Tool: ${Y.name}`)),J(w.dim(` Scenarios: ${Q.scenarios.length}`));for(let V of Q.scenarios)J(w.dim(` - ${V.name}`))}let U=await p4(Y,Q,{onProgress:q?(V)=>{if(!Z)J(w.dim(` ${V}`))}:void 0}),W=X.threshold?parseInt(X.threshold,10):Q.threshold??0,H=W>0&&U.summary.score<W;if(z)await Bun.write(z,d2(U,{verbose:q}));else if(Z)await hW(`${d2(U,{verbose:q})}
|
|
243
|
+
`);else s4(U,{threshold:W});if(H){if(Z||z)console.error(w.red(`Overall: ${U.summary.score} / 100 \xB7 threshold ${W} \xB7 run fails`)),console.error(w.dim("Review failed scenarios before trusting this surface."));process.exit(1)}}function hW($){return new Promise((X,Z)=>{process.stdout.write($,(z)=>{if(z)Z(z);else X()})})}import vW from"path";var uW=`# pickled.yml - Agent legibility check for your product
|
|
227
244
|
|
|
228
245
|
tool:
|
|
229
246
|
name: "your-product"
|
|
@@ -245,4 +262,4 @@ scenarios:
|
|
|
245
262
|
|
|
246
263
|
# Optional: fail CI if score falls below threshold
|
|
247
264
|
# threshold: 80
|
|
248
|
-
`;async function
|
|
265
|
+
`;async function EZ($){let Z=`${vW.resolve($)}/pickled.yml`;if(await Bun.file(Z).exists())console.error(w.red("pickled.yml already exists")),process.exit(1);await Bun.write(Z,uW),console.log(w.green("Created pickled.yml")),console.log(),console.log(w.dim("Next steps:")),console.log(w.dim(" 1. Edit pickled.yml: list your sources and scenarios")),console.log(w.dim(" 2. Run: pickled check")),console.log()}l0.name("pickled").description("Test what agents actually understand about your product").version(BX.version);l0.command("init").description("Create a pickled.yml config file").argument("[path]","Path to your project (default: current directory)",".").action(EZ);l0.command("audit").description("Static scan of agent-context files (CLAUDE.md, AGENTS.md, llms.txt). No LLM calls.").argument("[path]","Path to your project (default: current directory)",".").addOption(new o2("--format <name>","Output format").choices(["terminal","markdown","json"]).default("terminal")).option("--json","Shorthand for --format json").option("-o, --output <file>","Save report to file").addOption(new o2("--fail-on <level>","Exit non-zero on this severity or higher").choices(["error","warning"]).default("error")).action(SZ);l0.command("check").description("Run agent scenarios against registered sources").argument("[path]","Path to your project (default: current directory)",".").option("--json","Output as JSON").option("-o, --output <file>","Save report to file").option("-v, --verbose","Show detailed progress").option("-t, --threshold <percent>","Minimum score % to pass (overrides config)").option("--target <name>","Run only the named target (overrides matrix.target)").action(CZ);await l0.parseAsync();
|