@pickled-dev/cli 0.12.0 → 0.13.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 yZ=Object.create;var{getPrototypeOf:xZ,defineProperty:n4,getOwnPropertyNames:fZ}=Object;var kZ=Object.prototype.hasOwnProperty;function gZ($){return this[$]}var hZ,vZ,r4=($,X,Z)=>{var q=$!=null&&typeof $==="object";if(q){var z=X?hZ??=new WeakMap:vZ??=new WeakMap,G=z.get($);if(G)return G}Z=$!=null?yZ(xZ($)):{};let J=X||!$||!$.__esModule?n4(Z,"default",{value:$,enumerable:!0}):Z;for(let Q of fZ($))if(!kZ.call(J,Q))n4(J,Q,{get:gZ.bind($,Q),enumerable:!0});if(q)z.set($,J);return J};var K=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var Q0=import.meta.require;var _$=K((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=K((lZ)=>{var{InvalidArgumentError:pZ}=_$();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 cZ($){let X=$.name()+($.variadic===!0?"...":"");return $.required?"<"+X+">":"["+X+"]"}lZ.Argument=t4;lZ.humanReadableArgName=cZ});var c2=K((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((q)=>!q._hidden),Z=$._getHelpCommand();if(Z&&!Z._hidden)X.push(Z);if(this.sortSubcommands)X.sort((q,z)=>{return q.name().localeCompare(z.name())});return X}compareOptions($,X){let Z=(q)=>{return q.short?q.short.replace(/^-/,""):q.long.replace(/^--/,"")};return Z($).localeCompare(Z(X))}visibleOptions($){let X=$.options.filter((q)=>!q.hidden),Z=$._getHelpOption();if(Z&&!Z.hidden){let q=Z.short&&$._findOption(Z.short),z=Z.long&&$._findOption(Z.long);if(!q&&!z)X.push(Z);else if(Z.long&&!z)X.push($.createOption(Z.long,Z.description));else if(Z.short&&!q)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 q=Z.options.filter((z)=>!z.hidden);X.push(...q)}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,q)=>{return Math.max(Z,this.displayWidth(X.styleSubcommandTerm(X.subcommandTerm(q))))},0)}longestOptionTermLength($,X){return X.visibleOptions($).reduce((Z,q)=>{return Math.max(Z,this.displayWidth(X.styleOptionTerm(X.optionTerm(q))))},0)}longestGlobalOptionTermLength($,X){return X.visibleGlobalOptions($).reduce((Z,q)=>{return Math.max(Z,this.displayWidth(X.styleOptionTerm(X.optionTerm(q))))},0)}longestArgumentTermLength($,X){return X.visibleArguments($).reduce((Z,q)=>{return Math.max(Z,this.displayWidth(X.styleArgumentTerm(X.argumentTerm(q))))},0)}commandUsage($){let X=$._name;if($._aliases[0])X=X+"|"+$._aliases[0];let Z="";for(let q=$.parent;q;q=q.parent)Z=q.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 q=new Map;return $.forEach((z)=>{let G=Z(z);if(!q.has(G))q.set(G,[])}),X.forEach((z)=>{let G=Z(z);if(!q.has(G))q.set(G,[]);q.get(G).push(z)}),q}formatHelp($,X){let Z=X.padWidth($,X),q=X.helpWidth??80;function z(W,H){return X.formatItem(W,Z,H,X)}let G=[`${X.styleTitle("Usage:")} ${X.styleUsage(X.commandUsage($))}`,""],J=X.commandDescription($);if(J.length>0)G=G.concat([X.boxWrap(X.styleCommandDescription(J),q),""]);let Q=X.visibleArguments($).map((W)=>{return z(X.styleArgumentTerm(X.argumentTerm(W)),X.styleArgumentDescription(X.argumentDescription(W)))});if(G=G.concat(this.formatItemList("Arguments:",Q,X)),this.groupItems($.options,X.visibleOptions($),(W)=>W.helpGroupHeading??"Options:").forEach((W,H)=>{let V=W.map((w)=>{return z(X.styleOptionTerm(X.optionTerm(w)),X.styleOptionDescription(X.optionDescription(w)))});G=G.concat(this.formatItemList(H,V,X))}),X.showGlobalOptions){let W=X.visibleGlobalOptions($).map((H)=>{return z(X.styleOptionTerm(X.optionTerm(H)),X.styleOptionDescription(X.optionDescription(H)))});G=G.concat(this.formatItemList("Global Options:",W,X))}return this.groupItems($.commands,X.visibleCommands($),(W)=>W.helpGroup()||"Commands:").forEach((W,H)=>{let V=W.map((w)=>{return z(X.styleSubcommandTerm(X.subcommandTerm(w)),X.styleSubcommandDescription(X.subcommandDescription(w)))});G=G.concat(this.formatItemList(H,V,X))}),G.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,q){let G=" ".repeat(2);if(!Z)return G+$;let J=$.padEnd(X+$.length-q.displayWidth($)),Q=2,U=(this.helpWidth??80)-X-Q-2,W;if(U<this.minWidthToWrap||q.preformatted(Z))W=Z;else W=q.boxWrap(Z,U).replace(/\n/g,`
|
|
5
|
+
`+" ".repeat(X+Q));return G+J+" ".repeat(Q)+W.replace(/\n/g,`
|
|
6
|
+
${G}`)}boxWrap($,X){if(X<this.minWidthToWrap)return $;let Z=$.split(/\r\n|\n/),q=/[\s]*[^\s]+/g,z=[];return Z.forEach((G)=>{let J=G.match(q);if(J===null){z.push("");return}let Q=[J.shift()],Y=this.displayWidth(Q[0]);J.forEach((U)=>{let W=this.displayWidth(U);if(Y+W<=X){Q.push(U),Y+=W;return}z.push(Q.join(""));let H=U.trimStart();Q=[H],Y=this.displayWidth(H)}),z.push(Q.join(""))}),z.join(`
|
|
7
|
+
`)}}function $X($){let X=/\x1b\[\d*(;\d*)*m/g;return $.replace(X,"")}nZ.Help=e4;nZ.stripColor=$X});var l2=K(($6)=>{var{InvalidArgumentError:tZ}=_$();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 qX{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 q=this.negativeOptions.get(Z).presetArg,z=q!==void 0?q:!1;return X.negate===(z===$)}}function XX($){return $.split("-").reduce((X,Z)=>{return X+Z[0].toUpperCase()+Z.slice(1)})}function eZ($){let X,Z,q=/^-[^-]$/,z=/^--[^-]/,G=$.split(/[ |,]+/).concat("guard");if(q.test(G[0]))X=G.shift();if(z.test(G[0]))Z=G.shift();if(!X&&q.test(G[0]))X=G.shift();if(!X&&z.test(G[0]))X=Z,Z=G.shift();if(G[0].startsWith("-")){let J=G[0],Q=`option creation failed due to '${J}' in option flags '${$}'`;if(/^-[^-][^-]/.test(J))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(q.test(J))throw Error(`${Q}
|
|
11
|
+
- too many short flags`);if(z.test(J))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=qX});var zX=K((G6)=>{function q6($,X){if(Math.abs($.length-X.length)>3)return Math.max($.length,X.length);let Z=[];for(let q=0;q<=$.length;q++)Z[q]=[q];for(let q=0;q<=X.length;q++)Z[0][q]=q;for(let q=1;q<=X.length;q++)for(let z=1;z<=$.length;z++){let G=1;if($[z-1]===X[q-1])G=0;else G=1;if(Z[z][q]=Math.min(Z[z-1][q]+1,Z[z][q-1]+1,Z[z-1][q-1]+G),z>1&&q>1&&$[z-1]===X[q-2]&&$[z-2]===X[q-1])Z[z][q]=Math.min(Z[z][q],Z[z-2][q-2]+1)}return Z[$.length][X.length]}function z6($,X){if(!X||X.length===0)return"";X=Array.from(new Set(X));let Z=$.startsWith("--");if(Z)$=$.slice(2),X=X.map((J)=>J.slice(2));let q=[],z=3,G=0.4;if(X.forEach((J)=>{if(J.length<=1)return;let Q=q6($,J),Y=Math.max($.length,J.length);if((Y-Q)/Y>G){if(Q<z)z=Q,q=[J];else if(Q===z)q.push(J)}}),q.sort((J,Q)=>J.localeCompare(Q)),Z)q=q.map((J)=>`--${J}`);if(q.length>1)return`
|
|
14
|
+
(Did you mean one of ${q.join(", ")}?)`;if(q.length===1)return`
|
|
15
|
+
(Did you mean ${q[0]}?)`;return""}G6.suggestSimilar=z6});var YX=K((T6)=>{var Q6=Q0("events").EventEmitter,i2=Q0("child_process"),Y0=Q0("path"),w1=Q0("fs"),E=Q0("process"),{Argument:Y6,humanReadableArgName:U6}=T1(),{CommanderError:a2}=_$(),{Help:H6,stripColor:W6}=c2(),{Option:GX,DualOptions:V6}=l2(),{suggestSimilar:JX}=zX();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)=>E.stdout.write(X),writeErr:(X)=>E.stderr.write(X),outputError:(X,Z)=>Z(X),getOutHelpWidth:()=>E.stdout.isTTY?E.stdout.columns:void 0,getErrHelpWidth:()=>E.stderr.isTTY?E.stderr.columns:void 0,getOutHasColors:()=>s2()??(E.stdout.isTTY&&E.stdout.hasColors?.()),getErrHasColors:()=>s2()??(E.stderr.isTTY&&E.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 q=X,z=Z;if(typeof q==="object"&&q!==null)z=q,q=null;z=z||{};let[,G,J]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(G);if(q)Q.description(q),Q._executableHandler=!0;if(z.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(z.noHelp||z.hidden),Q._executableFile=z.executableFile||null,J)Q.arguments(J);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),q)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,q){let z=this.createArgument($,X);if(typeof Z==="function")z.default(q).argParser(Z);else z.default(Z);return this.addArgument(z),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]",[,q,z]=Z.match(/([^ ]+) *(.*)/),G=X??"display help for command",J=this.createCommand(q);if(J.helpOption(!1),z)J.arguments(z);if(G)J.description(G);if(this._addImplicitHelpCommand=!0,this._helpCommand=J,$||X)this._initCommandGroup(J);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));E.exit($)}action($){let X=(Z)=>{let q=this.registeredArguments.length,z=Z.slice(0,q);if(this._storeOptionsAsProperties)z[q]=this;else z[q]=this.opts();return z.push(this),$.apply(this,z)};return this._actionHandler=X,this}createOption($,X){return new GX($,X)}_callParseArg($,X,Z,q){try{return $.parseArg(X,Z)}catch(z){if(z.code==="commander.invalidArgument"){let G=`${q} ${z.message}`;this.error(G,{exitCode:z.exitCode,code:z.code})}throw z}}_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=(q)=>{return[q.name()].concat(q.aliases())},Z=X($).find((q)=>this._findCommand(q));if(Z){let q=X(this._findCommand(Z)).join("|"),z=X($).join("|");throw Error(`cannot add command '${z}' as already have command '${q}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let X=$.name(),Z=$.attributeName();if($.negate){let z=$.long.replace(/^--no-/,"--");if(!this._findOption(z))this.setOptionValueWithSource(Z,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(Z,$.defaultValue,"default");let q=(z,G,J)=>{if(z==null&&$.presetArg!==void 0)z=$.presetArg;let Q=this.getOptionValue(Z);if(z!==null&&$.parseArg)z=this._callParseArg($,z,Q,G);else if(z!==null&&$.variadic)z=$._collectValue(z,Q);if(z==null)if($.negate)z=!1;else if($.isBoolean()||$.optional)z=!0;else z="";this.setOptionValueWithSource(Z,z,J)};if(this.on("option:"+X,(z)=>{let G=`error: option '${$.flags}' argument '${z}' is invalid.`;q(z,G,"cli")}),$.envVar)this.on("optionEnv:"+X,(z)=>{let G=`error: option '${$.flags}' value '${z}' from env '${$.envVar}' is invalid.`;q(z,G,"env")});return this}_optionEx($,X,Z,q,z){if(typeof X==="object"&&X instanceof GX)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let G=this.createOption(X,Z);if(G.makeOptionMandatory(!!$.mandatory),typeof q==="function")G.default(z).argParser(q);else if(q instanceof RegExp){let J=q;q=(Q,Y)=>{let U=J.exec(Q);return U?U[0]:Y},G.default(z).argParser(q)}else G.default(q);return this.addOption(G)}option($,X,Z,q){return this._optionEx({},$,X,Z,q)}requiredOption($,X,Z,q){return this._optionEx({mandatory:!0},$,X,Z,q)}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(E.versions?.electron)X.from="electron";let q=E.execArgv??[];if(q.includes("-e")||q.includes("--eval")||q.includes("-p")||q.includes("--print"))X.from="eval"}if($===void 0)$=E.argv;this.rawArgs=$.slice();let Z;switch(X.from){case void 0:case"node":this._scriptPath=$[1],Z=$.slice(2);break;case"electron":if(E.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(w1.existsSync($))return;let q=X?`searched for local subcommand relative to directory '${X}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",z=`'${$}' 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
|
+
- ${q}`;throw Error(z)}_executeSubCommand($,X){X=X.slice();let Z=!1,q=[".js",".ts",".tsx",".mjs",".cjs"];function z(U,W){let H=Y0.resolve(U,W);if(w1.existsSync(H))return H;if(q.includes(Y0.extname(W)))return;let V=q.find((w)=>w1.existsSync(`${H}${w}`));if(V)return`${H}${V}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=$._executableFile||`${this._name}-${$._name}`,J=this._executableDir||"";if(this._scriptPath){let U;try{U=w1.realpathSync(this._scriptPath)}catch{U=this._scriptPath}J=Y0.resolve(Y0.dirname(U),J)}if(J){let U=z(J,G);if(!U&&!$._executableFile&&this._scriptPath){let W=Y0.basename(this._scriptPath,Y0.extname(this._scriptPath));if(W!==this._name)U=z(J,`${W}-${$._name}`)}G=U||G}Z=q.includes(Y0.extname(G));let Q;if(E.platform!=="win32")if(Z)X.unshift(G),X=QX(E.execArgv).concat(X),Q=i2.spawn(E.argv[0],X,{stdio:"inherit"});else Q=i2.spawn(G,X,{stdio:"inherit"});else this._checkForMissingExecutable(G,J,$._name),X.unshift(G),X=QX(E.execArgv).concat(X),Q=i2.spawn(E.execPath,X,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((W)=>{E.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)E.exit(U);else Y(new a2(U,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(U)=>{if(U.code==="ENOENT")this._checkForMissingExecutable(G,J,$._name);else if(U.code==="EACCES")throw Error(`'${G}' not executable`);if(!Y)E.exit(1);else{let W=new a2(1,"commander.executeSubCommandAsync","(error)");W.nestedError=U,Y(W)}}),this.runningCommand=Q}_dispatchSubcommand($,X,Z){let q=this._findCommand($);if(!q)this.help({error:!0});q._prepareForParse();let z;return z=this._chainOrCallSubCommandHook(z,q,"preSubcommand"),z=this._chainOrCall(z,()=>{if(q._executableHandler)this._executeSubCommand(q,X.concat(Z));else return q._parseCommand(X,Z)}),z}_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,q,z)=>{let G=q;if(q!==null&&Z.parseArg){let J=`error: command-argument value '${q}' is invalid for argument '${Z.name()}'.`;G=this._callParseArg(Z,q,z,J)}return G};this._checkNumberOfArguments();let X=[];this.registeredArguments.forEach((Z,q)=>{let z=Z.defaultValue;if(Z.variadic){if(q<this.args.length){if(z=this.args.slice(q),Z.parseArg)z=z.reduce((G,J)=>{return $(Z,J,G)},Z.defaultValue)}else if(z===void 0)z=[]}else if(q<this.args.length){if(z=this.args[q],Z.parseArg)z=$(Z,z,Z.defaultValue)}X[q]=z}),this.processedArgs=X}_chainOrCall($,X){if($?.then&&typeof $.then==="function")return $.then(()=>X());return X()}_chainOrCallHooks($,X){let Z=$,q=[];if(this._getCommandAndAncestors().reverse().filter((z)=>z._lifeCycleHooks[X]!==void 0).forEach((z)=>{z._lifeCycleHooks[X].forEach((G)=>{q.push({hookedCommand:z,callback:G})})}),X==="postAction")q.reverse();return q.forEach((z)=>{Z=this._chainOrCall(Z,()=>{return z.callback(z.hookedCommand,this)})}),Z}_chainOrCallSubCommandHook($,X,Z){let q=$;if(this._lifeCycleHooks[Z]!==void 0)this._lifeCycleHooks[Z].forEach((z)=>{q=this._chainOrCall(q,()=>{return z(this,X)})});return q}_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 q=()=>{if(Z.unknown.length>0)this.unknownOption(Z.unknown[0])},z=`command:${this.name()}`;if(this._actionHandler){q(),this._processArguments();let G;if(G=this._chainOrCallHooks(G,"preAction"),G=this._chainOrCall(G,()=>this._actionHandler(this.processedArgs)),this.parent)G=this._chainOrCall(G,()=>{this.parent.emit(z,$,X)});return G=this._chainOrCallHooks(G,"postAction"),G}if(this.parent?.listenerCount(z))q(),this._processArguments(),this.parent.emit(z,$,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 q(),this._processArguments()}else if(this.commands.length)q(),this.help({error:!0});else q(),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 q=Z.attributeName();if(this.getOptionValue(q)===void 0)return!1;return this.getOptionValueSource(q)!=="default"});$.filter((Z)=>Z.conflictsWith.length>0).forEach((Z)=>{let q=$.find((z)=>Z.conflictsWith.includes(z.attributeName()));if(q)this._conflictingOption(Z,q)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let X=[],Z=[],q=X;function z(U){return U.length>1&&U[0]==="-"}let G=(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)))},J=null,Q=null,Y=0;while(Y<$.length||Q){let U=Q??$[Y++];if(Q=null,U==="--"){if(q===Z)q.push(U);q.push(...$.slice(Y));break}if(J&&(!z(U)||G(U))){this.emit(`option:${J.name()}`,U);continue}if(J=null,z(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&&(!z($[Y])||G($[Y])))H=$[Y++];this.emit(`option:${W.name()}`,H)}else this.emit(`option:${W.name()}`);J=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(q===X&&z(U)&&!(this.commands.length===0&&G(U)))q=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){q.push(U,...$.slice(Y));break}q.push(U)}return{operands:X,unknown:Z}}opts(){if(this._storeOptionsAsProperties){let $={},X=this.options.length;for(let Z=0;Z<X;Z++){let q=this.options[Z].attributeName();$[q]=q===this._versionOptionName?this._version:this[q]}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||{},q=Z.exitCode||1,z=Z.code||"commander.error";this._exit(q,z,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in E.env){let X=$.attributeName();if(this.getOptionValue(X)===void 0||["default","config","env"].includes(this.getOptionValueSource(X)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,E.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((q)=>!X(q)).forEach((q)=>{this.setOptionValueWithSource(q,Z.implied[q],"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=(G)=>{let J=G.attributeName(),Q=this.getOptionValue(J),Y=this.options.find((W)=>W.negate&&J===W.attributeName()),U=this.options.find((W)=>!W.negate&&J===W.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return U||G},q=(G)=>{let J=Z(G),Q=J.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${J.envVar}'`;return`option '${J.flags}'`},z=`error: ${q($)} cannot be used with ${q(X)}`;this.error(z,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let X="";if($.startsWith("--")&&this._showSuggestionAfterError){let q=[],z=this;do{let G=z.createHelp().visibleOptions(z).filter((J)=>J.long).map((J)=>J.long);q=q.concat(G),z=z.parent}while(z&&!z._enablePositionalOptions);X=JX($,q)}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",z=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${X} argument${Z} but got ${$.length}.`;this.error(z,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],X="";if(this._showSuggestionAfterError){let q=[];this.createHelp().visibleCommands(this).forEach((z)=>{if(q.push(z.name()),z.alias())q.push(z.alias())}),X=JX($,q)}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 q=this.createOption(X,Z);return this._versionOptionName=q.attributeName(),this._registerOption(q),this.on("option:"+q.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 q=[Z.name()].concat(Z.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${q}'`)}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 q=X.formatHelp(this,X);if(Z.hasColors)return q;return this._outputConfiguration.stripColor(q)}_getOutputContext($){$=$||{};let X=!!$.error,Z,q,z;if(X)Z=(J)=>this._outputConfiguration.writeErr(J),q=this._outputConfiguration.getErrHasColors(),z=this._outputConfiguration.getErrHelpWidth();else Z=(J)=>this._outputConfiguration.writeOut(J),q=this._outputConfiguration.getOutHasColors(),z=this._outputConfiguration.getOutHelpWidth();return{error:X,write:(J)=>{if(!q)J=this._outputConfiguration.stripColor(J);return Z(J)},hasColors:q,helpWidth:z}}outputHelp($){let X;if(typeof $==="function")X=$,$=void 0;let Z=this._getOutputContext($),q={error:Z.error,write:Z.write,command:this};this._getCommandAndAncestors().reverse().forEach((G)=>G.emit("beforeAllHelp",q)),this.emit("beforeHelp",q);let z=this.helpInformation({error:Z.error});if(X){if(z=X(z),typeof z!=="string"&&!Buffer.isBuffer(z))throw Error("outputHelp callback must return a string or a Buffer")}if(Z.write(z),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",q),this._getCommandAndAncestors().forEach((G)=>G.emit("afterAllHelp",q))}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(E.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 q=`${$}Help`;return this.on(q,(z)=>{let G;if(typeof X==="function")G=X({error:z.error,command:z.command});else G=X;if(G)z.write(`${G}
|
|
28
|
+
`)}),this}_outputHelpIfRequested($){let X=this._getHelpOption();if(X&&$.find((q)=>X.is(q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function QX($){return $.map((X)=>{if(!X.startsWith("--inspect"))return X;let Z,q="127.0.0.1",z="9229",G;if((G=X.match(/^(--inspect(-brk)?)$/))!==null)Z=G[1];else if((G=X.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Z=G[1],/^\d+$/.test(G[3]))z=G[3];else q=G[3];else if((G=X.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Z=G[1],q=G[3],z=G[4];if(Z&&z!=="0")return`${Z}=${q}:${parseInt(z)+1}`;return X})}function s2(){if(E.env.NO_COLOR||E.env.FORCE_COLOR==="0"||E.env.FORCE_COLOR==="false")return!1;if(E.env.FORCE_COLOR||E.env.CLICOLOR_FORCE!==void 0)return!0;return}T6.Command=n2;T6.useColor=s2});var VX=K((D6)=>{var{Argument:UX}=T1(),{Command:r2}=YX(),{CommanderError:B6,InvalidArgumentError:HX}=_$(),{Help:K6}=c2(),{Option:WX}=l2();D6.program=new r2;D6.createCommand=($)=>new r2($);D6.createOption=($,X)=>new WX($,X);D6.createArgument=($,X)=>new UX($,X);D6.Command=r2;D6.Option=WX;D6.Argument=UX;D6.Help=K6;D6.CommanderError=B6;D6.InvalidArgumentError=HX;D6.InvalidOptionArgumentError=HX});var j=K((h6)=>{var $9=Symbol.for("yaml.alias"),LX=Symbol.for("yaml.document"),L1=Symbol.for("yaml.map"),BX=Symbol.for("yaml.pair"),X9=Symbol.for("yaml.scalar"),B1=Symbol.for("yaml.seq"),U0=Symbol.for("yaml.node.type"),C6=($)=>!!$&&typeof $==="object"&&$[U0]===$9,b6=($)=>!!$&&typeof $==="object"&&$[U0]===LX,y6=($)=>!!$&&typeof $==="object"&&$[U0]===L1,x6=($)=>!!$&&typeof $==="object"&&$[U0]===BX,KX=($)=>!!$&&typeof $==="object"&&$[U0]===X9,f6=($)=>!!$&&typeof $==="object"&&$[U0]===B1;function DX($){if($&&typeof $==="object")switch($[U0]){case L1:case B1:return!0}return!1}function k6($){if($&&typeof $==="object")switch($[U0]){case $9:case L1:case X9:case B1:return!0}return!1}var g6=($)=>(KX($)||DX($))&&!!$.anchor;h6.ALIAS=$9;h6.DOC=LX;h6.MAP=L1;h6.NODE_TYPE=U0;h6.PAIR=BX;h6.SCALAR=X9;h6.SEQ=B1;h6.hasAnchor=g6;h6.isAlias=C6;h6.isCollection=DX;h6.isDocument=b6;h6.isMap=y6;h6.isNode=k6;h6.isPair=x6;h6.isScalar=KX;h6.isSeq=f6});var F$=K((Xq)=>{var h=j(),c=Symbol("break visit"),_X=Symbol("skip children"),G0=Symbol("remove node");function K1($,X){let Z=FX(X);if(h.isDocument($)){if(l0(null,$.contents,Z,Object.freeze([$]))===G0)$.contents=null}else l0(null,$,Z,Object.freeze([]))}K1.BREAK=c;K1.SKIP=_X;K1.REMOVE=G0;function l0($,X,Z,q){let z=OX($,X,Z,q);if(h.isNode(z)||h.isPair(z))return MX($,q,z),l0($,z,Z,q);if(typeof z!=="symbol"){if(h.isCollection(X)){q=Object.freeze(q.concat(X));for(let G=0;G<X.items.length;++G){let J=l0(G,X.items[G],Z,q);if(typeof J==="number")G=J-1;else if(J===c)return c;else if(J===G0)X.items.splice(G,1),G-=1}}else if(h.isPair(X)){q=Object.freeze(q.concat(X));let G=l0("key",X.key,Z,q);if(G===c)return c;else if(G===G0)X.key=null;let J=l0("value",X.value,Z,q);if(J===c)return c;else if(J===G0)X.value=null}}return z}async function D1($,X){let Z=FX(X);if(h.isDocument($)){if(await i0(null,$.contents,Z,Object.freeze([$]))===G0)$.contents=null}else await i0(null,$,Z,Object.freeze([]))}D1.BREAK=c;D1.SKIP=_X;D1.REMOVE=G0;async function i0($,X,Z,q){let z=await OX($,X,Z,q);if(h.isNode(z)||h.isPair(z))return MX($,q,z),i0($,z,Z,q);if(typeof z!=="symbol"){if(h.isCollection(X)){q=Object.freeze(q.concat(X));for(let G=0;G<X.items.length;++G){let J=await i0(G,X.items[G],Z,q);if(typeof J==="number")G=J-1;else if(J===c)return c;else if(J===G0)X.items.splice(G,1),G-=1}}else if(h.isPair(X)){q=Object.freeze(q.concat(X));let G=await i0("key",X.key,Z,q);if(G===c)return c;else if(G===G0)X.key=null;let J=await i0("value",X.value,Z,q);if(J===c)return c;else if(J===G0)X.value=null}}return z}function FX($){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,q){if(typeof Z==="function")return Z($,X,q);if(h.isMap(X))return Z.Map?.($,X,q);if(h.isSeq(X))return Z.Seq?.($,X,q);if(h.isPair(X))return Z.Pair?.($,X,q);if(h.isScalar(X))return Z.Scalar?.($,X,q);if(h.isAlias(X))return Z.Alias?.($,X,q);return}function MX($,X,Z){let q=X[X.length-1];if(h.isCollection(q))q.items[$]=Z;else if(h.isPair(q))if($==="key")q.key=Z;else q.value=Z;else if(h.isDocument(q))q.contents=Z;else{let z=h.isAlias(q)?"alias":"scalar";throw Error(`Cannot replace node with ${z} parent`)}}Xq.visit=K1;Xq.visitAsync=D1});var Z9=K((Qq)=>{var IX=j(),zq=F$(),Gq={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Jq=($)=>$.replace(/[!,[\]{}]/g,(X)=>Gq[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]+/),q=Z.shift();switch(q){case"%TAG":{if(Z.length!==2){if(X(0,"%TAG directive should contain exactly two parts"),Z.length<2)return!1}let[z,G]=Z;return this.tags[z]=G,!0}case"%YAML":{if(this.yaml.explicit=!0,Z.length!==1)return X(0,"%YAML directive should contain exactly one part"),!1;let[z]=Z;if(z==="1.1"||z==="1.2")return this.yaml.version=z,!0;else{let G=/^\d+\.\d+$/.test(z);return X(6,`Unsupported YAML version ${z}`,G),!1}}default:return X(0,`Unknown directive ${q}`,!0),!1}}tagName($,X){if($==="!")return"!";if($[0]!=="!")return X(`Not a valid tag: ${$}`),null;if($[1]==="<"){let G=$.slice(2,-1);if(G==="!"||G==="!!")return X(`Verbatim tags aren't resolved, so ${$} is invalid.`),null;if($[$.length-1]!==">")X("Verbatim tags must end with a >");return G}let[,Z,q]=$.match(/^(.*!)([^!]*)$/s);if(!q)X(`The ${$} tag has no suffix`);let z=this.tags[Z];if(z)try{return z+decodeURIComponent(q)}catch(G){return X(String(G)),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+Jq($.substring(Z.length));return $[0]==="!"?$:`!<${$}>`}toString($){let X=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],Z=Object.entries(this.tags),q;if($&&Z.length>0&&IX.isNode($.contents)){let z={};zq.visit($.contents,(G,J)=>{if(IX.isNode(J)&&J.tag)z[J.tag]=!0}),q=Object.keys(z)}else q=[];for(let[z,G]of Z){if(z==="!!"&&G==="tag:yaml.org,2002:")continue;if(!$||q.some((J)=>J.startsWith(G)))X.push(`%TAG ${z} ${G}`)}return X.join(`
|
|
29
|
+
`)}}s.defaultYaml={explicit:!1,version:"1.2"};s.defaultTags={"!!":"tag:yaml.org,2002:"};Qq.Directives=s});var _1=K((Vq)=>{var RX=j(),Uq=F$();function Hq($){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 Uq.visit($,{Value(Z,q){if(q.anchor)X.add(q.anchor)}}),X}function NX($,X){for(let Z=1;;++Z){let q=`${$}${Z}`;if(!X.has(q))return q}}function Wq($,X){let Z=[],q=new Map,z=null;return{onAnchor:(G)=>{Z.push(G),z??(z=PX($));let J=NX(X,z);return z.add(J),J},setAnchors:()=>{for(let G of Z){let J=q.get(G);if(typeof J==="object"&&J.anchor&&(RX.isScalar(J.node)||RX.isCollection(J.node)))J.node.anchor=J.anchor;else{let Q=Error("Failed to resolve repeated object (this should not happen)");throw Q.source=G,Q}}},sourceObjects:q}}Vq.anchorIsValid=Hq;Vq.anchorNames=PX;Vq.createNodeAnchors=Wq;Vq.findNewAnchor=NX});var q9=K((Kq)=>{function O$($,X,Z,q){if(q&&typeof q==="object")if(Array.isArray(q))for(let z=0,G=q.length;z<G;++z){let J=q[z],Q=O$($,q,String(z),J);if(Q===void 0)delete q[z];else if(Q!==J)q[z]=Q}else if(q instanceof Map)for(let z of Array.from(q.keys())){let G=q.get(z),J=O$($,q,z,G);if(J===void 0)q.delete(z);else if(J!==G)q.set(z,J)}else if(q instanceof Set)for(let z of Array.from(q)){let G=O$($,q,z,z);if(G===void 0)q.delete(z);else if(G!==z)q.delete(z),q.add(G)}else for(let[z,G]of Object.entries(q)){let J=O$($,q,z,G);if(J===void 0)delete q[z];else if(J!==G)q[z]=J}return $.call(X,Z,q)}Kq.applyReviver=O$});var L0=K((Fq)=>{var _q=j();function AX($,X,Z){if(Array.isArray($))return $.map((q,z)=>AX(q,String(z),Z));if($&&typeof $.toJSON==="function"){if(!Z||!_q.hasAnchor($))return $.toJSON(X,Z);let q={aliasCount:0,count:1,res:void 0};Z.anchors.set($,q),Z.onCreate=(G)=>{q.res=G,delete Z.onCreate};let z=$.toJSON(X,Z);if(Z.onCreate)Z.onCreate(z);return z}if(typeof $==="bigint"&&!Z?.keep)return Number($);return $}Fq.toJS=AX});var F1=K((Rq)=>{var Mq=q9(),SX=j(),Iq=L0();class jX{constructor($){Object.defineProperty(this,SX.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:q,reviver:z}={}){if(!SX.isDocument($))throw TypeError("A document argument is required");let G={anchors:new Map,doc:$,keep:!0,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof Z==="number"?Z:100},J=Iq.toJS(this,"",G);if(typeof q==="function")for(let{count:Q,res:Y}of G.anchors.values())q(Y,Q);return typeof z==="function"?Mq.applyReviver(z,{"":J},"",J):J}}Rq.NodeBase=jX});var M$=K((Eq)=>{var Nq=_1(),Aq=F$(),a0=j(),Sq=F1(),jq=L0();class EX extends Sq.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=[],Aq.visit($,{Node:(z,G)=>{if(a0.isAlias(G)||a0.hasAnchor(G))Z.push(G)}}),X)X.aliasResolveCache=Z;let q=void 0;for(let z of Z){if(z===this)break;if(z.anchor===this.source)q=z}return q}toJSON($,X){if(!X)return{source:this.source};let{anchors:Z,doc:q,maxAliasCount:z}=X,G=this.resolve(q,X);if(!G){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(Q)}let J=Z.get(G);if(!J)jq.toJS(G,null,X),J=Z.get(G);if(J?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(z>=0){if(J.count+=1,J.aliasCount===0)J.aliasCount=O1(q,G,Z);if(J.count*J.aliasCount>z)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return J.res}toString($,X,Z){let q=`*${this.source}`;if($){if(Nq.anchorIsValid(this.source),$.options.verifyAliasOrder&&!$.anchors.has(this.source)){let z=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(z)}if($.implicitKey)return`${q} `}return q}}function O1($,X,Z){if(a0.isAlias(X)){let q=X.resolve($),z=Z&&q&&Z.get(q);return z?z.count*z.aliasCount:0}else if(a0.isCollection(X)){let q=0;for(let z of X.items){let G=O1($,z,Z);if(G>q)q=G}return q}else if(a0.isPair(X)){let q=O1($,X.key,Z),z=O1($,X.value,Z);return Math.max(q,z)}return 1}Eq.Alias=EX});var g=K((kq)=>{var bq=j(),yq=F1(),xq=L0(),fq=($)=>!$||typeof $!=="function"&&typeof $!=="object";class S0 extends yq.NodeBase{constructor($){super(bq.SCALAR);this.value=$}toJSON($,X){return X?.keep?this.value:xq.toJS(this.value,$,X)}toString(){return String(this.value)}}S0.BLOCK_FOLDED="BLOCK_FOLDED";S0.BLOCK_LITERAL="BLOCK_LITERAL";S0.PLAIN="PLAIN";S0.QUOTE_DOUBLE="QUOTE_DOUBLE";S0.QUOTE_SINGLE="QUOTE_SINGLE";kq.Scalar=S0;kq.isScalarValue=fq});var I$=K((pq)=>{var vq=M$(),j0=j(),CX=g(),uq="tag:yaml.org,2002:";function mq($,X,Z){if(X){let q=Z.filter((G)=>G.tag===X),z=q.find((G)=>!G.format)??q[0];if(!z)throw Error(`Tag ${X} not found`);return z}return Z.find((q)=>q.identify?.($)&&!q.format)}function dq($,X,Z){if(j0.isDocument($))$=$.contents;if(j0.isNode($))return $;if(j0.isPair($)){let H=Z.schema[j0.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:q,onAnchor:z,onTagObj:G,schema:J,sourceObjects:Q}=Z,Y=void 0;if(q&&$&&typeof $==="object")if(Y=Q.get($),Y)return Y.anchor??(Y.anchor=z($)),new vq.Alias(Y.anchor);else Y={anchor:null,node:null},Q.set($,Y);if(X?.startsWith("!!"))X=uq+X.slice(2);let U=mq($,X,J.tags);if(!U){if($&&typeof $.toJSON==="function")$=$.toJSON();if(!$||typeof $!=="object"){let H=new CX.Scalar($);if(Y)Y.node=H;return H}U=$ instanceof Map?J[j0.MAP]:(Symbol.iterator in Object($))?J[j0.SEQ]:J[j0.MAP]}if(G)G(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 CX.Scalar($);if(X)W.tag=X;else if(!U.default)W.tag=U.tag;if(Y)Y.node=W;return W}pq.createNode=dq});var M1=K((aq)=>{var lq=I$(),J0=j(),iq=F1();function z9($,X,Z){let q=Z;for(let z=X.length-1;z>=0;--z){let G=X[z];if(typeof G==="number"&&Number.isInteger(G)&&G>=0){let J=[];J[G]=q,q=J}else q=new Map([[G,q]])}return lq.createNode(q,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 yX extends iq.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)=>J0.isNode(Z)||J0.isPair(Z)?Z.clone($):Z),this.range)X.range=this.range.slice();return X}addIn($,X){if(bX($))this.add(X);else{let[Z,...q]=$,z=this.get(Z,!0);if(J0.isCollection(z))z.addIn(q,X);else if(z===void 0&&this.schema)this.set(Z,z9(this.schema,q,X));else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${q}`)}}deleteIn($){let[X,...Z]=$;if(Z.length===0)return this.delete(X);let q=this.get(X,!0);if(J0.isCollection(q))return q.deleteIn(Z);else throw Error(`Expected YAML collection at ${X}. Remaining path: ${Z}`)}getIn($,X){let[Z,...q]=$,z=this.get(Z,!0);if(q.length===0)return!X&&J0.isScalar(z)?z.value:z;else return J0.isCollection(z)?z.getIn(q,X):void 0}hasAllNullValues($){return this.items.every((X)=>{if(!J0.isPair(X))return!1;let Z=X.value;return Z==null||$&&J0.isScalar(Z)&&Z.value==null&&!Z.commentBefore&&!Z.comment&&!Z.tag})}hasIn($){let[X,...Z]=$;if(Z.length===0)return this.has(X);let q=this.get(X,!0);return J0.isCollection(q)?q.hasIn(Z):!1}setIn($,X){let[Z,...q]=$;if(q.length===0)this.set(Z,X);else{let z=this.get(Z,!0);if(J0.isCollection(z))z.setIn(q,X);else if(z===void 0&&this.schema)this.set(Z,z9(this.schema,q,X));else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${q}`)}}}aq.Collection=yX;aq.collectionFromPath=z9;aq.isEmptyPath=bX});var R$=K((eq)=>{var oq=($)=>$.replace(/^(?!$)(?: $)?/gm,"#");function G9($,X){if(/^\n+$/.test($))return $.substring(1);return X?$.replace(/^(?! *$)/gm,X):$}var tq=($,X,Z)=>$.endsWith(`
|
|
30
|
+
`)?G9(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
|
+
`+G9(Z,X):($.endsWith(" ")?"":" ")+Z;eq.indentComment=G9;eq.lineComment=tq;eq.stringifyComment=oq});var fX=K((zz)=>{function qz($,X,Z="flow",{indentAtStart:q,lineWidth:z=80,minContentWidth:G=20,onFold:J,onOverflow:Q}={}){if(!z||z<0)return $;if(z<G)G=0;let Y=Math.max(1+G,1+z-X.length);if($.length<=Y)return $;let U=[],W={},H=z-X.length;if(typeof q==="number")if(q>z-Math.max(2,G))U.push(0);else H=z-q;let V=void 0,w=void 0,B=!1,T=-1,L=-1,D=-1;if(Z==="block"){if(T=xX($,T,X.length),T!==-1)H=T+Y}for(let O;O=$[T+=1];){if(Z==="quoted"&&O==="\\"){switch(L=T,$[T+1]){case"x":T+=3;break;case"u":T+=5;break;case"U":T+=9;break;default:T+=1}D=T}if(O===`
|
|
33
|
+
`){if(Z==="block")T=xX($,T,X.length);H=T+X.length+Y,V=void 0}else{if(O===" "&&w&&w!==" "&&w!==`
|
|
34
|
+
`&&w!=="\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(w===" "||w==="\t")w=O,O=$[T+=1],B=!0;let I=T>D+1?T-2:L-1;if(W[I])return $;U.push(I),W[I]=!0,H=I+Y,V=void 0}else B=!0}w=O}if(B&&Q)Q();if(U.length===0)return $;if(J)J();let _=$.slice(0,U[0]);for(let O=0;O<U.length;++O){let I=U[O],R=U[O+1]||$.length;if(I===0)_=`
|
|
36
|
+
${X}${$.slice(0,R)}`;else{if(Z==="quoted"&&W[I])_+=`${$[I]}\\`;_+=`
|
|
37
|
+
${X}${$.slice(I+1,R)}`}}return _}function xX($,X,Z){let q=X,z=X+1,G=$[z];while(G===" "||G==="\t")if(X<z+Z)G=$[++X];else{do G=$[++X];while(G&&G!==`
|
|
38
|
+
`);q=X,z=X+1,G=$[z]}return q}zz.FOLD_BLOCK="block";zz.FOLD_FLOW="flow";zz.FOLD_QUOTED="quoted";zz.foldFlowLines=qz});var N$=K((Vz)=>{var $0=g(),B0=fX(),R1=($,X)=>({indentAtStart:X?$.indent.length:$.indentAtStart,lineWidth:$.options.lineWidth,minContentWidth:$.options.minContentWidth}),P1=($)=>/^(%|---|\.\.\.)/m.test($);function Uz($,X,Z){if(!X||X<0)return!1;let q=X-Z,z=$.length;if(z<=q)return!1;for(let G=0,J=0;G<z;++G)if($[G]===`
|
|
39
|
+
`){if(G-J>q)return!0;if(J=G+1,z-J<=q)return!1}return!0}function P$($,X){let Z=JSON.stringify($);if(X.options.doubleQuotedAsJSON)return Z;let{implicitKey:q}=X,z=X.options.doubleQuotedMinMultiLineLength,G=X.indent||(P1($)?" ":""),J="",Q=0;for(let Y=0,U=Z[Y];U;U=Z[++Y]){if(U===" "&&Z[Y+1]==="\\"&&Z[Y+2]==="n")J+=Z.slice(Q,Y)+"\\ ",Y+=1,Q=Y,U="\\";if(U==="\\")switch(Z[Y+1]){case"u":{J+=Z.slice(Q,Y);let W=Z.substr(Y+2,4);switch(W){case"0000":J+="\\0";break;case"0007":J+="\\a";break;case"000b":J+="\\v";break;case"001b":J+="\\e";break;case"0085":J+="\\N";break;case"00a0":J+="\\_";break;case"2028":J+="\\L";break;case"2029":J+="\\P";break;default:if(W.substr(0,2)==="00")J+="\\x"+W.substr(2);else J+=Z.substr(Y,6)}Y+=5,Q=Y+1}break;case"n":if(q||Z[Y+2]==='"'||Z.length<z)Y+=1;else{J+=Z.slice(Q,Y)+`
|
|
40
|
+
|
|
41
|
+
`;while(Z[Y+2]==="\\"&&Z[Y+3]==="n"&&Z[Y+4]!=='"')J+=`
|
|
42
|
+
`,Y+=2;if(J+=G,Z[Y+2]===" ")J+="\\";Y+=1,Q=Y+1}break;default:Y+=1}}return J=Q?J+Z.slice(Q):Z,q?J:B0.foldFlowLines(J,G,B0.FOLD_QUOTED,R1(X,!1))}function J9($,X){if(X.options.singleQuote===!1||X.implicitKey&&$.includes(`
|
|
43
|
+
`)||/[ \t]\n|\n[ \t]/.test($))return P$($,X);let Z=X.indent||(P1($)?" ":""),q="'"+$.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
44
|
+
${Z}`)+"'";return X.implicitKey?q:B0.foldFlowLines(q,Z,B0.FOLD_FLOW,R1(X,!1))}function s0($,X){let{singleQuote:Z}=X.options,q;if(Z===!1)q=P$;else{let z=$.includes('"'),G=$.includes("'");if(z&&!G)q=J9;else if(G&&!z)q=P$;else q=Z?J9:P$}return q($,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},q,z,G){let{blockQuote:J,commentString:Q,lineWidth:Y}=q.options;if(!J||/\n[\t ]+$/.test(Z))return s0(Z,q);let U=q.indent||(q.forceBlockIndent||P1(Z)?" ":""),W=J==="literal"?!0:J==="folded"||X===$0.Scalar.BLOCK_FOLDED?!1:X===$0.Scalar.BLOCK_LITERAL?!0:!Uz(Z,Y,U.length);if(!Z)return W?`|
|
|
48
48
|
`:`>
|
|
49
|
-
`;let
|
|
50
|
-
`&&
|
|
51
|
-
`);if(
|
|
52
|
-
`)
|
|
53
|
-
`)D=
|
|
54
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${U}`),
|
|
55
|
-
${U}${
|
|
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 w=Z.substring(V),B=w.indexOf(`
|
|
51
|
+
`);if(B===-1)H="-";else if(Z===w||B!==w.length-1){if(H="+",G)G()}else H="";if(w){if(Z=Z.slice(0,-w.length),w[w.length-1]===`
|
|
52
|
+
`)w=w.slice(0,-1);w=w.replace(Q9,`$&${U}`)}let T=!1,L,D=-1;for(L=0;L<Z.length;++L){let R=Z[L];if(R===" ")T=!0;else if(R===`
|
|
53
|
+
`)D=L;else break}let _=Z.substring(0,D<L?D+1:L);if(_)Z=Z.substring(_.length),_=_.replace(/\n+/g,`$&${U}`);let I=(T?U?"2":"1":"")+H;if($){if(I+=" "+Q($.replace(/ ?[\r\n]+/g," ")),z)z()}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,C=R1(q,!0);if(J!=="folded"&&X!==$0.Scalar.BLOCK_FOLDED)C.onOverflow=()=>{N=!0};let F=B0.foldFlowLines(`${_}${R}${w}`,U,B0.FOLD_BLOCK,C);if(!N)return`>${I}
|
|
55
|
+
${U}${F}`}return Z=Z.replace(/\n+/g,`$&${U}`),`|${I}
|
|
56
|
+
${U}${_}${Z}${w}`}function Hz($,X,Z,q){let{type:z,value:G}=$,{actualString:J,implicitKey:Q,indent:Y,indentStep:U,inFlow:W}=X;if(Q&&G.includes(`
|
|
57
|
+
`)||W&&/[[\]{},]/.test(G))return s0(G,X);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return Q||W||!G.includes(`
|
|
58
|
+
`)?s0(G,X):I1($,X,Z,q);if(!Q&&!W&&z!==$0.Scalar.PLAIN&&G.includes(`
|
|
59
|
+
`))return I1($,X,Z,q);if(P1(G)){if(Y==="")return X.forceBlockIndent=!0,I1($,X,Z,q);else if(Q&&Y===U)return s0(G,X)}let H=G.replace(/\n+/g,`$&
|
|
60
|
+
${Y}`);if(J){let V=(T)=>T.default&&T.tag!=="tag:yaml.org,2002:str"&&T.test?.test(H),{compat:w,tags:B}=X.doc.schema;if(B.some(V)||w?.some(V))return s0(G,X)}return Q?H:B0.foldFlowLines(H,Y,B0.FOLD_FLOW,R1(X,!1))}function Wz($,X,Z,q){let{implicitKey:z,inFlow:G}=X,J=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(J.value))Q=$0.Scalar.QUOTE_DOUBLE}let Y=(W)=>{switch(W){case $0.Scalar.BLOCK_FOLDED:case $0.Scalar.BLOCK_LITERAL:return z||G?s0(J.value,X):I1(J,X,Z,q);case $0.Scalar.QUOTE_DOUBLE:return P$(J.value,X);case $0.Scalar.QUOTE_SINGLE:return J9(J.value,X);case $0.Scalar.PLAIN:return Hz(J,X,Z,q);default:return null}},U=Y(Q);if(U===null){let{defaultKeyType:W,defaultStringType:H}=X.options,V=z&&W||H;if(U=Y(V),U===null)throw Error(`Unsupported default string type ${V}`)}return U}Vz.stringifyString=Wz});var A$=K((Oz)=>{var wz=_1(),K0=j(),Lz=R$(),Bz=N$();function Kz($,X){let Z=Object.assign({blockQuote:!0,commentString:Lz.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),q;switch(Z.collectionStyle){case"block":q=!1;break;case"flow":q=!0;break;default:q=null}return{anchors:new Set,doc:$,flowCollectionPadding:Z.flowCollectionPadding?" ":"",indent:"",indentStep:typeof Z.indent==="number"?" ".repeat(Z.indent):" ",inFlow:q,options:Z}}function Dz($,X){if(X.tag){let z=$.filter((G)=>G.tag===X.tag);if(z.length>0)return z.find((G)=>G.format===X.format)??z[0]}let Z=void 0,q;if(K0.isScalar(X)){q=X.value;let z=$.filter((G)=>G.identify?.(q));if(z.length>1){let G=z.filter((J)=>J.test);if(G.length>0)z=G}Z=z.find((G)=>G.format===X.format)??z.find((G)=>!G.format)}else q=X,Z=$.find((z)=>z.nodeClass&&q instanceof z.nodeClass);if(!Z){let z=q?.constructor?.name??(q===null?"null":typeof q);throw Error(`Tag not resolved for ${z} value`)}return Z}function _z($,X,{anchors:Z,doc:q}){if(!q.directives)return"";let z=[],G=(K0.isScalar($)||K0.isCollection($))&&$.anchor;if(G&&wz.anchorIsValid(G))Z.add(G),z.push(`&${G}`);let J=$.tag??(X.default?null:X.tag);if(J)z.push(q.directives.tagString(J));return z.join(" ")}function Fz($,X,Z,q){if(K0.isPair($))return $.toString(X,Z,q);if(K0.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 z=void 0,G=K0.isNode($)?$:X.doc.createNode($,{onTagObj:(Y)=>z=Y});z??(z=Dz(X.doc.schema.tags,G));let J=_z(G,z,X);if(J.length>0)X.indentAtStart=(X.indentAtStart??0)+J.length+1;let Q=typeof z.stringify==="function"?z.stringify(G,X,Z,q):K0.isScalar(G)?Bz.stringifyString(G,X,Z,q):G.toString(X,Z,q);if(!J)return Q;return K0.isScalar(G)||Q[0]==="{"||Q[0]==="["?`${J} ${Q}`:`${J}
|
|
61
|
+
${X.indent}${Q}`}Oz.createStringifyContext=Kz;Oz.stringify=Fz});var hX=K((Pz)=>{var H0=j(),kX=g(),gX=A$(),S$=R$();function Rz({key:$,value:X},Z,q,z){let{allNullValues:G,doc:J,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 w=!H&&(!$||V&&X==null&&!Z.inFlow||H0.isCollection($)||(H0.isScalar($)?$.type===kX.Scalar.BLOCK_FOLDED||$.type===kX.Scalar.BLOCK_LITERAL:typeof $==="object"));Z=Object.assign({},Z,{allNullValues:!1,implicitKey:!w&&(H||!G),indent:Q+Y});let B=!1,T=!1,L=gX.stringify($,Z,()=>B=!0,()=>T=!0);if(!w&&!Z.inFlow&&L.length>1024){if(H)throw Error("With simple keys, single line scalar must not span more than 1024 characters");w=!0}if(Z.inFlow){if(G||X==null){if(B&&q)q();return L===""?"?":w?`? ${L}`:L}}else if(G&&!H||X==null&&w){if(L=`? ${L}`,V&&!B)L+=S$.lineComment(L,Z.indent,U(V));else if(T&&z)z();return L}if(B)V=null;if(w){if(V)L+=S$.lineComment(L,Z.indent,U(V));L=`? ${L}
|
|
62
|
+
${Q}:`}else if(L=`${L}:`,V)L+=S$.lineComment(L,Z.indent,U(V));let D,_,O;if(H0.isNode(X))D=!!X.spaceBefore,_=X.commentBefore,O=X.comment;else if(D=!1,_=null,O=null,X&&typeof X==="object")X=J.createNode(X);if(Z.implicitKey=!1,!w&&!V&&H0.isScalar(X))Z.indentAtStart=L.length+1;if(T=!1,!W&&Y.length>=2&&!Z.inFlow&&!w&&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||D||_){if(N=D?`
|
|
63
|
+
`:"",_){let C=U(_);N+=`
|
|
64
|
+
${S$.indentComment(C,Z.indent)}`}if(R===""&&!Z.inFlow){if(N===`
|
|
65
|
+
`&&O)N=`
|
|
66
|
+
|
|
67
|
+
`}else N+=`
|
|
68
|
+
${Z.indent}`}else if(!w&&H0.isCollection(X)){let C=R[0],F=R.indexOf(`
|
|
69
|
+
`),y=F!==-1,a=Z.inFlow??X.flow??X.items.length===0;if(y||!a){let q0=!1;if(y&&(C==="&"||C==="!")){let k=R.indexOf(" ");if(C==="&"&&k!==-1&&k<F&&R[k+1]==="!")k=R.indexOf(" ",k+1);if(k===-1||F<k)q0=!0}if(!q0)N=`
|
|
70
|
+
${Z.indent}`}}else if(R===""||R[0]===`
|
|
71
|
+
`)N="";if(L+=N+R,Z.inFlow){if(I&&q)q()}else if(O&&!I)L+=S$.lineComment(L,Z.indent,U(O));else if(T&&z)z();return L}Pz.stringifyPair=Rz});var Y9=K((jz)=>{var vX=Q0("process");function Az($,...X){if($==="debug")console.log(...X)}function Sz($,X){if($==="debug"||$==="warn")if(typeof vX.emitWarning==="function")vX.emitWarning(X);else console.warn(X)}jz.debug=Az;jz.warn=Sz});var S1=K((yz)=>{var j$=j(),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},bz=($,X)=>(A1.identify(X)||j$.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=$&&j$.isAlias(Z)?Z.resolve($.doc):Z,j$.isSeq(Z))for(let q of Z.items)U9($,X,q);else if(Array.isArray(Z))for(let q of Z)U9($,X,q);else U9($,X,Z)}function U9($,X,Z){let q=$&&j$.isAlias(Z)?Z.resolve($.doc):Z;if(!j$.isMap(q))throw Error("Merge sources must be maps or map aliases");let z=q.toJSON(null,$,Map);for(let[G,J]of z)if(X instanceof Map){if(!X.has(G))X.set(G,J)}else if(X instanceof Set)X.add(G);else if(!Object.prototype.hasOwnProperty.call(X,G))Object.defineProperty(X,G,{value:J,writable:!0,enumerable:!0,configurable:!0});return X}yz.addMergeToJSMap=mX;yz.isMergeKey=bz;yz.merge=A1});var W9=K((mz)=>{var gz=Y9(),dX=S1(),hz=A$(),pX=j(),H9=L0();function vz($,X,{key:Z,value:q}){if(pX.isNode(Z)&&Z.addToJSMap)Z.addToJSMap($,X,q);else if(dX.isMergeKey($,Z))dX.addMergeToJSMap($,X,q);else{let z=H9.toJS(Z,"",$);if(X instanceof Map)X.set(z,H9.toJS(q,z,$));else if(X instanceof Set)X.add(z);else{let G=uz(Z,z,$),J=H9.toJS(q,G,$);if(G in X)Object.defineProperty(X,G,{value:J,writable:!0,enumerable:!0,configurable:!0});else X[G]=J}}return X}function uz($,X,Z){if(X===null)return"";if(typeof X!=="object")return String(X);if(pX.isNode($)&&Z?.doc){let q=hz.createStringifyContext(Z.doc,{});q.anchors=new Set;for(let G of Z.anchors.keys())q.anchors.add(G.anchor);q.inFlow=!0,q.inStringifyKey=!0;let z=$.toString(q);if(!Z.mapKeyWarned){let G=JSON.stringify(z);if(G.length>40)G=G.substring(0,36)+'..."';gz.warn(Z.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${G}. Set mapAsMap: true to use object keys.`),Z.mapKeyWarned=!0}return z}return JSON.stringify(X)}mz.addPairToJSMap=vz});var D0=K((iz)=>{var cX=I$(),pz=hX(),cz=W9(),j1=j();function lz($,X,Z){let q=cX.createNode($,void 0,Z),z=cX.createNode(X,void 0,Z);return new E1(q,z)}class E1{constructor($,X=null){Object.defineProperty(this,j1.NODE_TYPE,{value:j1.PAIR}),this.key=$,this.value=X}clone($){let{key:X,value:Z}=this;if(j1.isNode(X))X=X.clone($);if(j1.isNode(Z))Z=Z.clone($);return new E1(X,Z)}toJSON($,X){let Z=X?.mapAsMap?new Map:{};return cz.addPairToJSMap(X,Z,this)}toString($,X,Z){return $?.doc?pz.stringifyPair(this,$,X,Z):JSON.stringify(this)}}iz.Pair=E1;iz.createPair=lz});var V9=K((tz)=>{var E0=j(),lX=A$(),C1=R$();function nz($,X,Z){return(X.inFlow??$.flow?oz:rz)($,X,Z)}function rz({comment:$,items:X},Z,{blockItemPrefix:q,flowChars:z,itemIndent:G,onChompKeep:J,onComment:Q}){let{indent:Y,options:{commentString:U}}=Z,W=Object.assign({},Z,{indent:G,type:null}),H=!1,V=[];for(let B=0;B<X.length;++B){let T=X[B],L=null;if(E0.isNode(T)){if(!H&&T.spaceBefore)V.push("");if(b1(Z,V,T.commentBefore,H),T.comment)L=T.comment}else if(E0.isPair(T)){let _=E0.isNode(T.key)?T.key:null;if(_){if(!H&&_.spaceBefore)V.push("");b1(Z,V,_.commentBefore,H)}}H=!1;let D=lX.stringify(T,W,()=>L=null,()=>H=!0);if(L)D+=C1.lineComment(D,G,U(L));if(H&&L)H=!1;V.push(q+D)}let w;if(V.length===0)w=z.start+z.end;else{w=V[0];for(let B=1;B<V.length;++B){let T=V[B];w+=T?`
|
|
72
|
+
${Y}${T}`:`
|
|
73
|
+
`}}if($){if(w+=`
|
|
74
|
+
`+C1.indentComment(U($),Y),Q)Q()}else if(H&&J)J();return w}function oz({items:$},X,{flowChars:Z,itemIndent:q}){let{indent:z,indentStep:G,flowCollectionPadding:J,options:{commentString:Q}}=X;q+=G;let Y=Object.assign({},X,{indent:q,inFlow:!0,type:null}),U=!1,W=0,H=[];for(let B=0;B<$.length;++B){let T=$[B],L=null;if(E0.isNode(T)){if(T.spaceBefore)H.push("");if(b1(X,H,T.commentBefore,!1),T.comment)L=T.comment}else if(E0.isPair(T)){let _=E0.isNode(T.key)?T.key:null;if(_){if(_.spaceBefore)H.push("");if(b1(X,H,_.commentBefore,!1),_.comment)U=!0}let O=E0.isNode(T.value)?T.value:null;if(O){if(O.comment)L=O.comment;if(O.commentBefore)U=!0}else if(T.value==null&&_?.comment)L=_.comment}if(L)U=!0;let D=lX.stringify(T,Y,()=>L=null);if(B<$.length-1)D+=",";if(L)D+=C1.lineComment(D,q,Q(L));if(!U&&(H.length>W||D.includes(`
|
|
75
|
+
`)))U=!0;H.push(D),W=H.length}let{start:V,end:w}=Z;if(H.length===0)return V+w;else{if(!U){let B=H.reduce((T,L)=>T+L.length+2,2);U=X.options.lineWidth>0&&B>X.options.lineWidth}if(U){let B=V;for(let T of H)B+=T?`
|
|
76
|
+
${G}${z}${T}`:`
|
|
77
|
+
`;return`${B}
|
|
78
|
+
${z}${w}`}else return`${V}${J}${H.join(" ")}${J}${w}`}}function b1({indent:$,options:{commentString:X}},Z,q,z){if(q&&z)q=q.replace(/^\n+/,"");if(q){let G=C1.indentComment(X(q),$);Z.push(G.trimStart())}}tz.stringifyCollection=nz});var F0=K((z3)=>{var $3=V9(),X3=W9(),Z3=M1(),_0=j(),y1=D0(),q3=g();function E$($,X){let Z=_0.isScalar(X)?X.value:X;for(let q of $)if(_0.isPair(q)){if(q.key===X||q.key===Z)return q;if(_0.isScalar(q.key)&&q.key.value===Z)return q}return}class iX extends Z3.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor($){super(_0.MAP,$);this.items=[]}static from($,X,Z){let{keepUndefined:q,replacer:z}=Z,G=new this($),J=(Q,Y)=>{if(typeof z==="function")Y=z.call(X,Q,Y);else if(Array.isArray(z)&&!z.includes(Q))return;if(Y!==void 0||q)G.items.push(y1.createPair(Q,Y,Z))};if(X instanceof Map)for(let[Q,Y]of X)J(Q,Y);else if(X&&typeof X==="object")for(let Q of Object.keys(X))J(Q,X[Q]);if(typeof $.sortMapEntries==="function")G.items.sort($.sortMapEntries);return G}add($,X){let Z;if(_0.isPair($))Z=$;else if(!$||typeof $!=="object"||!("key"in $))Z=new y1.Pair($,$?.value);else Z=new y1.Pair($.key,$.value);let q=E$(this.items,Z.key),z=this.schema?.sortMapEntries;if(q){if(!X)throw Error(`Key ${Z.key} already set`);if(_0.isScalar(q.value)&&q3.isScalarValue(Z.value))q.value.value=Z.value;else q.value=Z.value}else if(z){let G=this.items.findIndex((J)=>z(Z,J)<0);if(G===-1)this.items.push(Z);else this.items.splice(G,0,Z)}else this.items.push(Z)}delete($){let X=E$(this.items,$);if(!X)return!1;return this.items.splice(this.items.indexOf(X),1).length>0}get($,X){let q=E$(this.items,$)?.value;return(!X&&_0.isScalar(q)?q.value:q)??void 0}has($){return!!E$(this.items,$)}set($,X){this.add(new y1.Pair($,X),!0)}toJSON($,X,Z){let q=Z?new Z:X?.mapAsMap?new Map:{};if(X?.onCreate)X.onCreate(q);for(let z of this.items)X3.addPairToJSMap(X,q,z);return q}toString($,X,Z){if(!$)return JSON.stringify(this);for(let q of this.items)if(!_0.isPair(q))throw Error(`Map items must all be pairs; found ${JSON.stringify(q)} instead`);if(!$.allNullValues&&this.hasAllNullValues(!1))$=Object.assign({},$,{allNullValues:!0});return $3.stringifyCollection(this,$,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:$.indent||"",onChompKeep:Z,onComment:X})}}z3.YAMLMap=iX;z3.findPair=E$});var n0=K((U3)=>{var Q3=j(),aX=F0(),Y3={collection:"map",default:!0,nodeClass:aX.YAMLMap,tag:"tag:yaml.org,2002:map",resolve($,X){if(!Q3.isMap($))X("Expected a mapping for this tag");return $},createNode:($,X,Z)=>aX.YAMLMap.from($,X,Z)};U3.map=Y3});var O0=K((B3)=>{var W3=I$(),V3=V9(),T3=M1(),f1=j(),w3=g(),L3=L0();class sX extends T3.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor($){super(f1.SEQ,$);this.items=[]}add($){this.items.push($)}delete($){let X=x1($);if(typeof X!=="number")return!1;return this.items.splice(X,1).length>0}get($,X){let Z=x1($);if(typeof Z!=="number")return;let q=this.items[Z];return!X&&f1.isScalar(q)?q.value:q}has($){let X=x1($);return typeof X==="number"&&X<this.items.length}set($,X){let Z=x1($);if(typeof Z!=="number")throw Error(`Expected a valid index, not ${$}.`);let q=this.items[Z];if(f1.isScalar(q)&&w3.isScalarValue(X))q.value=X;else this.items[Z]=X}toJSON($,X){let Z=[];if(X?.onCreate)X.onCreate(Z);let q=0;for(let z of this.items)Z.push(L3.toJS(z,String(q++),X));return Z}toString($,X,Z){if(!$)return JSON.stringify(this);return V3.stringifyCollection(this,$,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:($.indent||"")+" ",onChompKeep:Z,onComment:X})}static from($,X,Z){let{replacer:q}=Z,z=new this($);if(X&&Symbol.iterator in Object(X)){let G=0;for(let J of X){if(typeof q==="function"){let Q=X instanceof Set?J:String(G++);J=q.call(X,Q,J)}z.items.push(W3.createNode(J,void 0,Z))}}return z}}function x1($){let X=f1.isScalar($)?$.value:$;if(X&&typeof X==="string")X=Number(X);return typeof X==="number"&&Number.isInteger(X)&&X>=0?X:null}B3.YAMLSeq=sX});var r0=K((F3)=>{var D3=j(),nX=O0(),_3={collection:"seq",default:!0,nodeClass:nX.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve($,X){if(!D3.isSeq($))X("Expected a sequence for this tag");return $},createNode:($,X,Z)=>nX.YAMLSeq.from($,X,Z)};F3.seq=_3});var C$=K((R3)=>{var M3=N$(),I3={identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify($,X,Z,q){return X=Object.assign({actualString:!0},X),M3.stringifyString($,X,Z,q)}};R3.string=I3});var k1=K((N3)=>{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};N3.nullTag=oX});var T9=K((j3)=>{var S3=g(),tX={identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:($)=>new S3.Scalar($[0]==="t"||$[0]==="T"),stringify({source:$,value:X},Z){if($&&tX.test.test($)){let q=$[0]==="t"||$[0]==="T";if(X===q)return $}return X?Z.options.trueStr:Z.options.falseStr}};j3.boolTag=tX});var o0=K((b3)=>{function C3({format:$,minFractionDigits:X,tag:Z,value:q}){if(typeof q==="bigint")return String(q);let z=typeof q==="number"?q:Number(q);if(!isFinite(z))return isNaN(z)?".nan":z<0?"-.inf":".inf";let G=Object.is(q,-0)?"-0":JSON.stringify(q);if(!$&&X&&(!Z||Z==="tag:yaml.org,2002:float")&&/^\d/.test(G)){let J=G.indexOf(".");if(J<0)J=G.length,G+=".";let Q=X-(G.length-J-1);while(Q-- >0)G+="0"}return G}b3.stringifyNumber=C3});var L9=K((h3)=>{var x3=g(),w9=o0(),f3={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:w9.stringifyNumber},k3={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():w9.stringifyNumber($)}},g3={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve($){let X=new x3.Scalar(parseFloat($)),Z=$.indexOf(".");if(Z!==-1&&$[$.length-1]==="0")X.minFractionDigits=$.length-Z-1;return X},stringify:w9.stringifyNumber};h3.float=g3;h3.floatExp=k3;h3.floatNaN=f3});var K9=K((l3)=>{var eX=o0(),g1=($)=>typeof $==="bigint"||Number.isInteger($),B9=($,X,Z,{intAsBigInt:q})=>q?BigInt($):parseInt($.substring(X),Z);function $5($,X,Z){let{value:q}=$;if(g1(q)&&q>=0)return Z+q.toString(X);return eX.stringifyNumber($)}var d3={identify:($)=>g1($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:($,X,Z)=>B9($,2,8,Z),stringify:($)=>$5($,8,"0o")},p3={identify:g1,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:($,X,Z)=>B9($,0,10,Z),stringify:eX.stringifyNumber},c3={identify:($)=>g1($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:($,X,Z)=>B9($,2,16,Z),stringify:($)=>$5($,16,"0x")};l3.int=p3;l3.intHex=c3;l3.intOct=d3});var X5=K((X7)=>{var n3=n0(),r3=k1(),o3=r0(),t3=C$(),e3=T9(),D9=L9(),_9=K9(),$7=[n3.map,o3.seq,t3.string,r3.nullTag,e3.boolTag,_9.intOct,_9.int,_9.intHex,D9.floatNaN,D9.floatExp,D9.float];X7.schema=$7});var q5=K((U7)=>{var q7=g(),z7=n0(),G7=r0();function Z5($){return typeof $==="bigint"||Number.isInteger($)}var h1=({value:$})=>JSON.stringify($),J7=[{identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify:h1},{identify:($)=>$==null,createNode:()=>new q7.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}],Q7={default:!0,tag:"",test:/^/,resolve($,X){return X(`Unresolved plain scalar ${JSON.stringify($)}`),$}},Y7=[z7.map,G7.seq].concat(J7,Q7);U7.schema=Y7});var O9=K((T7)=>{var b$=Q0("buffer"),F9=g(),W7=N$(),V7={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,"")),q=new Uint8Array(Z.length);for(let z=0;z<Z.length;++z)q[z]=Z.charCodeAt(z);return q}else return X("This environment does not support reading binary tags; either Buffer or atob is required"),$},stringify({comment:$,type:X,value:Z},q,z,G){if(!Z)return"";let J=Z,Q;if(typeof b$.Buffer==="function")Q=J instanceof b$.Buffer?J.toString("base64"):b$.Buffer.from(J.buffer).toString("base64");else if(typeof btoa==="function"){let Y="";for(let U=0;U<J.length;++U)Y+=String.fromCharCode(J[U]);Q=btoa(Y)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(X??(X=F9.Scalar.BLOCK_LITERAL),X!==F9.Scalar.QUOTE_DOUBLE){let Y=Math.max(q.options.lineWidth-q.indent.length,q.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===F9.Scalar.BLOCK_LITERAL?`
|
|
79
|
+
`:" ")}return W7.stringifyString({comment:$,type:X,value:Q},q,z,G)}};T7.binary=V7});var u1=K((D7)=>{var v1=j(),M9=D0(),L7=g(),B7=O0();function z5($,X){if(v1.isSeq($))for(let Z=0;Z<$.items.length;++Z){let q=$.items[Z];if(v1.isPair(q))continue;else if(v1.isMap(q)){if(q.items.length>1)X("Each pair must have its own sequence indicator");let z=q.items[0]||new M9.Pair(new L7.Scalar(null));if(q.commentBefore)z.key.commentBefore=z.key.commentBefore?`${q.commentBefore}
|
|
80
|
+
${z.key.commentBefore}`:q.commentBefore;if(q.comment){let G=z.value??z.key;G.comment=G.comment?`${q.comment}
|
|
81
|
+
${G.comment}`:q.comment}q=z}$.items[Z]=v1.isPair(q)?q:new M9.Pair(q)}else X("Expected a sequence for this tag");return $}function G5($,X,Z){let{replacer:q}=Z,z=new B7.YAMLSeq($);z.tag="tag:yaml.org,2002:pairs";let G=0;if(X&&Symbol.iterator in Object(X))for(let J of X){if(typeof q==="function")J=q.call(X,String(G++),J);let Q,Y;if(Array.isArray(J))if(J.length===2)Q=J[0],Y=J[1];else throw TypeError(`Expected [key, value] tuple: ${J}`);else if(J&&J instanceof Object){let U=Object.keys(J);if(U.length===1)Q=U[0],Y=J[Q];else throw TypeError(`Expected tuple with one key, not ${U.length} keys`)}else Q=J;z.items.push(M9.createPair(Q,Y,Z))}return z}var K7={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:z5,createNode:G5};D7.createPairs=G5;D7.pairs=K7;D7.resolvePairs=z5});var R9=K((R7)=>{var J5=j(),I9=L0(),y$=F0(),M7=O0(),Q5=u1();class C0 extends M7.YAMLSeq{constructor(){super();this.add=y$.YAMLMap.prototype.add.bind(this),this.delete=y$.YAMLMap.prototype.delete.bind(this),this.get=y$.YAMLMap.prototype.get.bind(this),this.has=y$.YAMLMap.prototype.has.bind(this),this.set=y$.YAMLMap.prototype.set.bind(this),this.tag=C0.tag}toJSON($,X){if(!X)return super.toJSON($);let Z=new Map;if(X?.onCreate)X.onCreate(Z);for(let q of this.items){let z,G;if(J5.isPair(q))z=I9.toJS(q.key,"",X),G=I9.toJS(q.value,z,X);else z=I9.toJS(q,"",X);if(Z.has(z))throw Error("Ordered maps must not include duplicate keys");Z.set(z,G)}return Z}static from($,X,Z){let q=Q5.createPairs($,X,Z),z=new this;return z.items=q.items,z}}C0.tag="tag:yaml.org,2002:omap";var I7={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:C0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,X){let Z=Q5.resolvePairs($,X),q=[];for(let{key:z}of Z.items)if(J5.isScalar(z))if(q.includes(z.value))X(`Ordered maps must not include duplicate keys: ${z.value}`);else q.push(z.value);return Object.assign(new C0,Z)},createNode:($,X,Z)=>C0.from($,X,Z)};R7.YAMLOMap=C0;R7.omap=I7});var V5=K((A7)=>{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};A7.falseTag=W5;A7.trueTag=H5});var T5=K((x7)=>{var E7=g(),P9=o0(),C7={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},b7={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($)}},y7={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let X=new E7.Scalar(parseFloat($.replace(/_/g,""))),Z=$.indexOf(".");if(Z!==-1){let q=$.substring(Z+1).replace(/_/g,"");if(q[q.length-1]==="0")X.minFractionDigits=q.length}return X},stringify:P9.stringifyNumber};x7.float=y7;x7.floatExp=b7;x7.floatNaN=C7});var L5=K((d7)=>{var w5=o0(),x$=($)=>typeof $==="bigint"||Number.isInteger($);function m1($,X,Z,{intAsBigInt:q}){let z=$[0];if(z==="-"||z==="+")X+=1;if($=$.substring(X).replace(/_/g,""),q){switch(Z){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let J=BigInt($);return z==="-"?BigInt(-1)*J:J}let G=parseInt($,Z);return z==="-"?-1*G:G}function N9($,X,Z){let{value:q}=$;if(x$(q)){let z=q.toString(X);return q<0?"-"+Z+z.substr(1):Z+z}return w5.stringifyNumber($)}var h7={identify:x$,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")},v7={identify:x$,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")},u7={identify:x$,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,X,Z)=>m1($,0,10,Z),stringify:w5.stringifyNumber},m7={identify:x$,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")};d7.int=u7;d7.intBin=h7;d7.intHex=m7;d7.intOct=v7});var A9=K((s7)=>{var c1=j(),d1=D0(),p1=F0();class b0 extends p1.YAMLMap{constructor($){super($);this.tag=b0.tag}add($){let X;if(c1.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&&c1.isPair(Z)?c1.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:q}=Z,z=new this($);if(X&&Symbol.iterator in Object(X))for(let G of X){if(typeof q==="function")G=q.call(X,G,G);z.items.push(d1.createPair(G,null,Z))}return z}}b0.tag="tag:yaml.org,2002:set";var a7={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(c1.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 $}};s7.YAMLSet=b0;s7.set=a7});var j9=K(($G)=>{var o7=o0();function S9($,X){let Z=$[0],q=Z==="-"||Z==="+"?$.substring(1):$,z=(J)=>X?BigInt(J):Number(J),G=q.replace(/_/g,"").split(":").reduce((J,Q)=>J*z(60)+z(Q),z(0));return Z==="-"?z(-1)*G:G}function B5($){let{value:X}=$,Z=(J)=>J;if(typeof X==="bigint")Z=(J)=>BigInt(J);else if(isNaN(X)||!isFinite(X))return o7.stringifyNumber($);let q="";if(X<0)q="-",X*=Z(-1);let z=Z(60),G=[X%z];if(X<60)G.unshift(0);else if(X=(X-G[0])/z,G.unshift(X%z),X>=60)X=(X-G[0])/z,G.unshift(X);return q+G.map((J)=>String(J).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var t7={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})=>S9($,Z),stringify:B5},e7={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:($)=>S9($,!1),stringify:B5},K5={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(K5.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,Z,q,z,G,J,Q]=X.map(Number),Y=X[7]?Number((X[7]+"00").substr(1,3)):0,U=Date.UTC(Z,q-1,z,G||0,J||0,Q||0,Y),W=X[8];if(W&&W!=="Z"){let H=S9(W,!1);if(Math.abs(H)<30)H*=60;U-=60000*H}return new Date(U)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};$G.floatTime=e7;$G.intTime=t7;$G.timestamp=K5});var _5=K((wG)=>{var zG=n0(),GG=k1(),JG=r0(),QG=C$(),YG=O9(),D5=V5(),E9=T5(),l1=L5(),UG=S1(),HG=R9(),WG=u1(),VG=A9(),C9=j9(),TG=[zG.map,JG.seq,QG.string,GG.nullTag,D5.trueTag,D5.falseTag,l1.intBin,l1.intOct,l1.int,l1.intHex,E9.floatNaN,E9.floatExp,E9.float,YG.binary,UG.merge,HG.omap,WG.pairs,VG.set,C9.intTime,C9.floatTime,C9.timestamp];wG.schema=TG});var j5=K((IG)=>{var I5=n0(),BG=k1(),R5=r0(),KG=C$(),DG=T9(),b9=L9(),y9=K9(),_G=X5(),FG=q5(),P5=O9(),f$=S1(),N5=R9(),A5=u1(),F5=_5(),S5=A9(),i1=j9(),O5=new Map([["core",_G.schema],["failsafe",[I5.map,R5.seq,KG.string]],["json",FG.schema],["yaml11",F5.schema],["yaml-1.1",F5.schema]]),M5={binary:P5.binary,bool:DG.boolTag,float:b9.float,floatExp:b9.floatExp,floatNaN:b9.floatNaN,floatTime:i1.floatTime,int:y9.int,intHex:y9.intHex,intOct:y9.intOct,intTime:i1.intTime,map:I5.map,merge:f$.merge,null:BG.nullTag,omap:N5.omap,pairs:A5.pairs,seq:R5.seq,set:S5.set,timestamp:i1.timestamp},OG={"tag:yaml.org,2002:binary":P5.binary,"tag:yaml.org,2002:merge":f$.merge,"tag:yaml.org,2002:omap":N5.omap,"tag:yaml.org,2002:pairs":A5.pairs,"tag:yaml.org,2002:set":S5.set,"tag:yaml.org,2002:timestamp":i1.timestamp};function MG($,X,Z){let q=O5.get(X);if(q&&!$)return Z&&!q.includes(f$.merge)?q.concat(f$.merge):q.slice();let z=q;if(!z)if(Array.isArray($))z=[];else{let G=Array.from(O5.keys()).filter((J)=>J!=="yaml11").map((J)=>JSON.stringify(J)).join(", ");throw Error(`Unknown schema "${X}"; use one of ${G} or define customTags array`)}if(Array.isArray($))for(let G of $)z=z.concat(G);else if(typeof $==="function")z=$(z.slice());if(Z)z=z.concat(f$.merge);return z.reduce((G,J)=>{let Q=typeof J==="string"?M5[J]:J;if(!Q){let Y=JSON.stringify(J),U=Object.keys(M5).map((W)=>JSON.stringify(W)).join(", ");throw Error(`Unknown custom tag ${Y}; use one of ${U}`)}if(!G.includes(Q))G.push(Q);return G},[])}IG.coreKnownTags=OG;IG.getTags=MG});var k9=K((EG)=>{var x9=j(),NG=n0(),AG=r0(),SG=C$(),a1=j5(),jG=($,X)=>$.key<X.key?-1:$.key>X.key?1:0;class f9{constructor({compat:$,customTags:X,merge:Z,resolveKnownTags:q,schema:z,sortMapEntries:G,toStringDefaults:J}){this.compat=Array.isArray($)?a1.getTags($,"compat"):$?a1.getTags(null,$):null,this.name=typeof z==="string"&&z||"core",this.knownTags=q?a1.coreKnownTags:{},this.tags=a1.getTags(X,this.name,Z),this.toStringOptions=J??null,Object.defineProperty(this,x9.MAP,{value:NG.map}),Object.defineProperty(this,x9.SCALAR,{value:SG.string}),Object.defineProperty(this,x9.SEQ,{value:AG.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?jG:null}clone(){let $=Object.create(f9.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}EG.Schema=f9});var E5=K((xG)=>{var bG=j(),g9=A$(),k$=R$();function yG($,X){let Z=[],q=X.directives===!0;if(X.directives!==!1&&$.directives){let Y=$.directives.toString($);if(Y)Z.push(Y),q=!0;else if($.directives.docStart)q=!0}if(q)Z.push("---");let z=g9.createStringifyContext($,X),{commentString:G}=z.options;if($.commentBefore){if(Z.length!==1)Z.unshift("");let Y=G($.commentBefore);Z.unshift(k$.indentComment(Y,""))}let J=!1,Q=null;if($.contents){if(bG.isNode($.contents)){if($.contents.spaceBefore&&q)Z.push("");if($.contents.commentBefore){let W=G($.contents.commentBefore);Z.push(k$.indentComment(W,""))}z.forceBlockIndent=!!$.comment,Q=$.contents.comment}let Y=Q?void 0:()=>J=!0,U=g9.stringify($.contents,z,()=>Q=null,Y);if(Q)U+=k$.lineComment(U,"",G(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,z));if($.directives?.docEnd)if($.comment){let Y=G($.comment);if(Y.includes(`
|
|
82
|
+
`))Z.push("..."),Z.push(k$.indentComment(Y,""));else Z.push(`... ${Y}`)}else Z.push("...");else{let Y=$.comment;if(Y&&J)Y=Y.replace(/^\n+/,"");if(Y){if((!J||Q)&&Z[Z.length-1]!=="")Z.push("");Z.push(k$.indentComment(G(Y),""))}}return Z.join(`
|
|
83
83
|
`)+`
|
|
84
|
-
`}
|
|
85
|
-
`;Q
|
|
84
|
+
`}xG.stringifyDocument=yG});var g$=K((pG)=>{var kG=M$(),t0=M1(),n=j(),gG=D0(),hG=L0(),vG=k9(),uG=E5(),h9=_1(),mG=q9(),dG=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 q=null;if(typeof X==="function"||Array.isArray(X))q=X;else if(Z===void 0&&X)Z=X,X=void 0;let z=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},Z);this.options=z;let{version:G}=z;if(Z?._directives){if(this.directives=Z._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new v9.Directives({version:G});this.setSchema(G,Z),this.contents=$===void 0?null:this.createNode($,q,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 kG.Alias($.anchor)}createNode($,X,Z){let q=void 0;if(typeof X==="function")$=X.call({"":$},"",$),q=X;else if(Array.isArray(X)){let T=(D)=>typeof D==="number"||D instanceof String||D instanceof Number,L=X.filter(T).map(String);if(L.length>0)X=X.concat(L);q=X}else if(Z===void 0&&X)Z=X,X=void 0;let{aliasDuplicateObjects:z,anchorPrefix:G,flow:J,keepUndefined:Q,onTagObj:Y,tag:U}=Z??{},{onAnchor:W,setAnchors:H,sourceObjects:V}=h9.createNodeAnchors(this,G||"a"),w={aliasDuplicateObjects:z??!0,keepUndefined:Q??!1,onAnchor:W,onTagObj:Y,replacer:q,schema:this.schema,sourceObjects:V},B=dG.createNode($,U,w);if(J&&n.isCollection(B))B.flow=!0;return H(),B}createPair($,X,Z={}){let q=this.createNode($,null,Z),z=this.createNode(X,null,Z);return new gG.Pair(q,z)}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 q=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${q}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(Z)this.schema=new vG.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:q,onAnchor:z,reviver:G}={}){let J={anchors:new Map,doc:this,keep:!$,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof q==="number"?q:100},Q=hG.toJS(this.contents,X??"",J);if(typeof z==="function")for(let{count:Y,res:U}of J.anchors.values())z(U,Y);return typeof G==="function"?mG.applyReviver(G,{"":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 uG.stringifyDocument(this,$)}}function e0($){if(n.isCollection($))return!0;throw Error("Expected a YAML collection as document contents")}pG.Document=u9});var h$=K((iG)=>{class s1 extends Error{constructor($,X,Z,q){super();this.name=$,this.code=Z,this.message=q,this.pos=X}}class C5 extends s1{constructor($,X,Z){super("YAMLParseError",$,X,Z)}}class b5 extends s1{constructor($,X,Z){super("YAMLWarning",$,X,Z)}}var lG=($,X)=>(Z)=>{if(Z.pos[0]===-1)return;Z.linePos=Z.pos.map((Q)=>X.linePos(Q));let{line:q,col:z}=Z.linePos[0];Z.message+=` at line ${q}, column ${z}`;let G=z-1,J=$.substring(X.lineStarts[q-1],X.lineStarts[q]).replace(/[\n\r]+$/,"");if(G>=60&&J.length>80){let Q=Math.min(G-39,J.length-79);J="\u2026"+J.substring(Q),G-=Q-1}if(J.length>80)J=J.substring(0,79)+"\u2026";if(q>1&&/^ *$/.test(J.substring(0,G))){let Q=$.substring(X.lineStarts[q-2],X.lineStarts[q-1]);if(Q.length>80)Q=Q.substring(0,79)+`\u2026
|
|
85
|
+
`;J=Q+J}if(/[^ ]/.test(J)){let Q=1,Y=Z.linePos[1];if(Y?.line===q&&Y.col>z)Q=Math.max(1,Math.min(Y.col-z,80-G));let U=" ".repeat(G)+"^".repeat(Q);Z.message+=`:
|
|
86
86
|
|
|
87
|
-
${
|
|
87
|
+
${J}
|
|
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
|
-
`))
|
|
122
|
-
`||
|
|
123
|
-
`)break;if(
|
|
124
|
-
`)
|
|
125
|
-
`;
|
|
126
|
-
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function
|
|
89
|
+
`}};iG.YAMLError=s1;iG.YAMLParseError=C5;iG.YAMLWarning=b5;iG.prettifyError=lG});var v$=K((tG)=>{function oG($,{flow:X,indicator:Z,next:q,offset:z,onError:G,parentIndent:J,startOnNewline:Q}){let Y=!1,U=Q,W=Q,H="",V="",w=!1,B=!1,T=null,L=null,D=null,_=null,O=null,I=null,R=null;for(let F of $){if(B){if(F.type!=="space"&&F.type!=="newline"&&F.type!=="comma")G(F.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");B=!1}if(T){if(U&&F.type!=="comment"&&F.type!=="newline")G(T,"TAB_AS_INDENT","Tabs are not allowed as indentation");T=null}switch(F.type){case"space":if(!X&&(Z!=="doc-start"||q?.type!=="flow-collection")&&F.source.includes("\t"))T=F;W=!0;break;case"comment":{if(!W)G(F,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let y=F.source.substring(1)||" ";if(!H)H=y;else H+=V+y;V="",U=!1;break}case"newline":if(U){if(H)H+=F.source;else if(!I||Z!=="seq-item-ind")Y=!0}else V+=F.source;if(U=!0,w=!0,L||D)_=F;W=!0;break;case"anchor":if(L)G(F,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(F.source.endsWith(":"))G(F.offset+F.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);L=F,R??(R=F.offset),U=!1,W=!1,B=!0;break;case"tag":{if(D)G(F,"MULTIPLE_TAGS","A node can have at most one tag");D=F,R??(R=F.offset),U=!1,W=!1,B=!0;break}case Z:if(L||D)G(F,"BAD_PROP_ORDER",`Anchors and tags must be after the ${F.source} indicator`);if(I)G(F,"UNEXPECTED_TOKEN",`Unexpected ${F.source} in ${X??"collection"}`);I=F,U=Z==="seq-item-ind"||Z==="explicit-key-ind",W=!1;break;case"comma":if(X){if(O)G(F,"UNEXPECTED_TOKEN",`Unexpected , in ${X}`);O=F,U=!1,W=!1;break}default:G(F,"UNEXPECTED_TOKEN",`Unexpected ${F.type} token`),U=!1,W=!1}}let N=$[$.length-1],C=N?N.offset+N.source.length:z;if(B&&q&&q.type!=="space"&&q.type!=="newline"&&q.type!=="comma"&&(q.type!=="scalar"||q.source!==""))G(q.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(T&&(U&&T.indent<=J||q?.type==="block-map"||q?.type==="block-seq"))G(T,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:O,found:I,spaceBefore:Y,comment:H,hasNewline:w,anchor:L,tag:D,newlineAfterProp:_,end:C,start:R??C}}tG.resolveProps=oG});var n1=K(($J)=>{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}}$J.containsNewline=m9});var d9=K((zJ)=>{var ZJ=n1();function qJ($,X,Z){if(X?.type==="flow-collection"){let q=X.end[0];if(q.indent===$&&(q.source==="]"||q.source==="}")&&ZJ.containsNewline(X))Z(q,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}zJ.flowIndentCheck=qJ});var p9=K((QJ)=>{var y5=j();function JJ($,X,Z){let{uniqueKeys:q}=$.options;if(q===!1)return!1;let z=typeof q==="function"?q:(G,J)=>G===J||y5.isScalar(G)&&y5.isScalar(J)&&G.value===J.value;return X.some((G)=>z(G.key,Z))}QJ.mapIncludes=JJ});var h5=K((TJ)=>{var x5=D0(),UJ=F0(),f5=v$(),HJ=n1(),k5=d9(),WJ=p9(),g5="All mapping items must start at the same column";function VJ({composeNode:$,composeEmptyNode:X},Z,q,z,G){let Q=new(G?.nodeClass??UJ.YAMLMap)(Z.schema);if(Z.atRoot)Z.atRoot=!1;let Y=q.offset,U=null;for(let W of q.items){let{start:H,key:V,sep:w,value:B}=W,T=f5.resolveProps(H,{indicator:"explicit-key-ind",next:V??w?.[0],offset:Y,onError:z,parentIndent:q.indent,startOnNewline:!0}),L=!T.found;if(L){if(V){if(V.type==="block-seq")z(Y,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in V&&V.indent!==q.indent)z(Y,"BAD_INDENT",g5)}if(!T.anchor&&!T.tag&&!w){if(U=T.end,T.comment)if(Q.comment)Q.comment+=`
|
|
91
|
+
`+T.comment;else Q.comment=T.comment;continue}if(T.newlineAfterProp||HJ.containsNewline(V))z(V??H[H.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(T.found?.indent!==q.indent)z(Y,"BAD_INDENT",g5);Z.atKey=!0;let D=T.end,_=V?$(Z,V,T,z):X(Z,D,H,null,T,z);if(Z.schema.compat)k5.flowIndentCheck(q.indent,V,z);if(Z.atKey=!1,WJ.mapIncludes(Z,Q.items,_))z(D,"DUPLICATE_KEY","Map keys must be unique");let O=f5.resolveProps(w??[],{indicator:"map-value-ind",next:B,offset:_.range[2],onError:z,parentIndent:q.indent,startOnNewline:!V||V.type==="block-scalar"});if(Y=O.end,O.found){if(L){if(B?.type==="block-map"&&!O.hasNewline)z(Y,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(Z.options.strict&&T.start<O.found.offset-1024)z(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let I=B?$(Z,B,O,z):X(Z,Y,w,null,O,z);if(Z.schema.compat)k5.flowIndentCheck(q.indent,B,z);Y=I.range[2];let R=new x5.Pair(_,I);if(Z.options.keepSourceTokens)R.srcToken=W;Q.items.push(R)}else{if(L)z(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(O.comment)if(_.comment)_.comment+=`
|
|
92
|
+
`+O.comment;else _.comment=O.comment;let I=new x5.Pair(_);if(Z.options.keepSourceTokens)I.srcToken=W;Q.items.push(I)}}if(U&&U<Y)z(U,"IMPOSSIBLE","Map comment with trailing content");return Q.range=[q.offset,Y,U??Y],Q}TJ.resolveBlockMap=VJ});var v5=K((_J)=>{var LJ=O0(),BJ=v$(),KJ=d9();function DJ({composeNode:$,composeEmptyNode:X},Z,q,z,G){let Q=new(G?.nodeClass??LJ.YAMLSeq)(Z.schema);if(Z.atRoot)Z.atRoot=!1;if(Z.atKey)Z.atKey=!1;let Y=q.offset,U=null;for(let{start:W,value:H}of q.items){let V=BJ.resolveProps(W,{indicator:"seq-item-ind",next:H,offset:Y,onError:z,parentIndent:q.indent,startOnNewline:!0});if(!V.found)if(V.anchor||V.tag||H)if(H?.type==="block-seq")z(V.end,"BAD_INDENT","All sequence items must start at the same column");else z(Y,"MISSING_CHAR","Sequence item without - indicator");else{if(U=V.end,V.comment)Q.comment=V.comment;continue}let w=H?$(Z,H,V,z):X(Z,V.end,W,null,V,z);if(Z.schema.compat)KJ.flowIndentCheck(q.indent,H,z);Y=w.range[2],Q.items.push(w)}return Q.range=[q.offset,Y,U??Y],Q}_J.resolveBlockSeq=DJ});var $$=K((MJ)=>{function OJ($,X,Z,q){let z="";if($){let G=!1,J="";for(let Q of $){let{source:Y,type:U}=Q;switch(U){case"space":G=!0;break;case"comment":{if(Z&&!G)q(Q,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=Y.substring(1)||" ";if(!z)z=W;else z+=J+W;J="";break}case"newline":if(z)J+=Y;G=!0;break;default:q(Q,"UNEXPECTED_TOKEN",`Unexpected ${U} at node end`)}X+=Y.length}}return{comment:z,offset:X}}MJ.resolveEnd=OJ});var d5=K((CJ)=>{var RJ=j(),PJ=D0(),u5=F0(),NJ=O0(),AJ=$$(),m5=v$(),SJ=n1(),jJ=p9(),c9="Block collections are not allowed within flow collections",l9=($)=>$&&($.type==="block-map"||$.type==="block-seq");function EJ({composeNode:$,composeEmptyNode:X},Z,q,z,G){let J=q.start.source==="{",Q=J?"flow map":"flow sequence",U=new(G?.nodeClass??(J?u5.YAMLMap:NJ.YAMLSeq))(Z.schema);U.flow=!0;let W=Z.atRoot;if(W)Z.atRoot=!1;if(Z.atKey)Z.atKey=!1;let H=q.offset+q.start.source.length;for(let L=0;L<q.items.length;++L){let D=q.items[L],{start:_,key:O,sep:I,value:R}=D,N=m5.resolveProps(_,{flow:Q,indicator:"explicit-key-ind",next:O??I?.[0],offset:H,onError:z,parentIndent:q.indent,startOnNewline:!1});if(!N.found){if(!N.anchor&&!N.tag&&!I&&!R){if(L===0&&N.comma)z(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`);else if(L<q.items.length-1)z(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(!J&&Z.options.strict&&SJ.containsNewline(O))z(O,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(L===0){if(N.comma)z(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`)}else{if(!N.comma)z(N.start,"MISSING_CHAR",`Missing , between ${Q} items`);if(N.comment){let C="";$:for(let F of _)switch(F.type){case"comma":case"space":break;case"comment":C=F.source.substring(1);break $;default:break $}if(C){let F=U.items[U.items.length-1];if(RJ.isPair(F))F=F.value??F.key;if(F.comment)F.comment+=`
|
|
94
|
+
`+C;else F.comment=C;N.comment=N.comment.substring(C.length+1)}}}if(!J&&!I&&!N.found){let C=R?$(Z,R,N,z):X(Z,N.end,I,null,N,z);if(U.items.push(C),H=C.range[2],l9(R))z(C.range,"BLOCK_IN_FLOW",c9)}else{Z.atKey=!0;let C=N.end,F=O?$(Z,O,N,z):X(Z,C,_,null,N,z);if(l9(O))z(F.range,"BLOCK_IN_FLOW",c9);Z.atKey=!1;let y=m5.resolveProps(I??[],{flow:Q,indicator:"map-value-ind",next:R,offset:F.range[2],onError:z,parentIndent:q.indent,startOnNewline:!1});if(y.found){if(!J&&!N.found&&Z.options.strict){if(I)for(let k of I){if(k===y.found)break;if(k.type==="newline"){z(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(N.start<y.found.offset-1024)z(y.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]===":")z(R,"MISSING_CHAR",`Missing space after : in ${Q}`);else z(y.start,"MISSING_CHAR",`Missing , or : between ${Q} items`);let a=R?$(Z,R,y,z):y.found?X(Z,y.end,I,null,y,z):null;if(a){if(l9(R))z(a.range,"BLOCK_IN_FLOW",c9)}else if(y.comment)if(F.comment)F.comment+=`
|
|
95
|
+
`+y.comment;else F.comment=y.comment;let q0=new PJ.Pair(F,a);if(Z.options.keepSourceTokens)q0.srcToken=D;if(J){let k=U;if(jJ.mapIncludes(Z,k.items,F))z(C,"DUPLICATE_KEY","Map keys must be unique");k.items.push(q0)}else{let k=new u5.YAMLMap(Z.schema);k.flow=!0,k.items.push(q0);let V1=(a??F).range;k.range=[F.range[0],V1[1],V1[2]],U.items.push(k)}H=a?a.range[2]:y.end}}let V=J?"}":"]",[w,...B]=q.end,T=H;if(w?.source===V)T=w.offset+w.source.length;else{let L=Q[0].toUpperCase()+Q.substring(1),D=W?`${L} must end with a ${V}`:`${L} in block collection must be sufficiently indented and end with a ${V}`;if(z(H,W?"MISSING_CHAR":"BAD_INDENT",D),w&&w.source.length!==1)B.unshift(w)}if(B.length>0){let L=AJ.resolveEnd(B,T,Z.options.strict,z);if(L.comment)if(U.comment)U.comment+=`
|
|
96
|
+
`+L.comment;else U.comment=L.comment;U.range=[q.offset,T,L.offset]}else U.range=[q.offset,T,T];return U}CJ.resolveFlowCollection=EJ});var p5=K((mJ)=>{var yJ=j(),xJ=g(),fJ=F0(),kJ=O0(),gJ=h5(),hJ=v5(),vJ=d5();function i9($,X,Z,q,z,G){let J=Z.type==="block-map"?gJ.resolveBlockMap($,X,Z,q,G):Z.type==="block-seq"?hJ.resolveBlockSeq($,X,Z,q,G):vJ.resolveFlowCollection($,X,Z,q,G),Q=J.constructor;if(z==="!"||z===Q.tagName)return J.tag=Q.tagName,J;if(z)J.tag=z;return J}function uJ($,X,Z,q,z){let G=q.tag,J=!G?null:X.directives.tagName(G.source,(V)=>z(G,"TAG_RESOLVE_FAILED",V));if(Z.type==="block-seq"){let{anchor:V,newlineAfterProp:w}=q,B=V&&G?V.offset>G.offset?V:G:V??G;if(B&&(!w||w.offset<B.offset))z(B,"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(!G||!J||J==="!"||J===fJ.YAMLMap.tagName&&Q==="map"||J===kJ.YAMLSeq.tagName&&Q==="seq")return i9($,X,Z,z,J);let Y=X.schema.tags.find((V)=>V.tag===J&&V.collection===Q);if(!Y){let V=X.schema.knownTags[J];if(V?.collection===Q)X.schema.tags.push(Object.assign({},V,{default:!1})),Y=V;else{if(V)z(G,"BAD_COLLECTION_TYPE",`${V.tag} used for ${Q} collection, but expects ${V.collection??"scalar"}`,!0);else z(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${J}`,!0);return i9($,X,Z,z,J)}}let U=i9($,X,Z,z,J,Y),W=Y.resolve?.(U,(V)=>z(G,"TAG_RESOLVE_FAILED",V),X.options)??U,H=yJ.isNode(W)?W:new xJ.Scalar(W);if(H.range=U.range,H.tag=J,Y?.format)H.format=Y.format;return H}mJ.composeCollection=uJ});var s9=K((iJ)=>{var a9=g();function pJ($,X,Z){let q=X.offset,z=cJ(X,$.options.strict,Z);if(!z)return{value:"",type:null,comment:"",range:[q,q,q]};let G=z.mode===">"?a9.Scalar.BLOCK_FOLDED:a9.Scalar.BLOCK_LITERAL,J=X.source?lJ(X.source):[],Q=J.length;for(let T=J.length-1;T>=0;--T){let L=J[T][1];if(L===""||L==="\r")Q=T;else break}if(Q===0){let T=z.chomp==="+"&&J.length>0?`
|
|
97
|
+
`.repeat(Math.max(1,J.length-1)):"",L=q+z.length;if(X.source)L+=X.source.length;return{value:T,type:G,comment:z.comment,range:[q,L,L]}}let Y=X.indent+z.indent,U=X.offset+z.length,W=0;for(let T=0;T<Q;++T){let[L,D]=J[T];if(D===""||D==="\r"){if(z.indent===0&&L.length>Y)Y=L.length}else{if(L.length<Y)Z(U+L.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(z.indent===0)Y=L.length;if(W=T,Y===0&&!$.atRoot)Z(U,"BAD_INDENT","Block scalar values in collections must be indented");break}U+=L.length+D.length+1}for(let T=J.length-1;T>=Q;--T)if(J[T][0].length>Y)Q=T+1;let H="",V="",w=!1;for(let T=0;T<W;++T)H+=J[T][0].slice(Y)+`
|
|
98
|
+
`;for(let T=W;T<Q;++T){let[L,D]=J[T];U+=L.length+D.length+1;let _=D[D.length-1]==="\r";if(_)D=D.slice(0,-1);if(D&&L.length<Y){let I=`Block scalar lines must not be less indented than their ${z.indent?"explicit indentation indicator":"first line"}`;Z(U-D.length-(_?2:1),"BAD_INDENT",I),L=""}if(G===a9.Scalar.BLOCK_LITERAL)H+=V+L.slice(Y)+D,V=`
|
|
99
|
+
`;else if(L.length>Y||D[0]==="\t"){if(V===" ")V=`
|
|
100
|
+
`;else if(!w&&V===`
|
|
101
|
+
`)V=`
|
|
102
|
+
|
|
103
|
+
`;H+=V+L.slice(Y)+D,V=`
|
|
104
|
+
`,w=!0}else if(D==="")if(V===`
|
|
105
|
+
`)H+=`
|
|
106
|
+
`;else V=`
|
|
107
|
+
`;else H+=V+D,V=" ",w=!1}switch(z.chomp){case"-":break;case"+":for(let T=Q;T<J.length;++T)H+=`
|
|
108
|
+
`+J[T][0].slice(Y);if(H[H.length-1]!==`
|
|
109
|
+
`)H+=`
|
|
110
|
+
`;break;default:H+=`
|
|
111
|
+
`}let B=q+z.length+X.source.length;return{value:H,type:G,comment:z.comment,range:[q,B,B]}}function cJ({offset:$,props:X},Z,q){if(X[0].type!=="block-scalar-header")return q(X[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:z}=X[0],G=z[0],J=0,Q="",Y=-1;for(let V=1;V<z.length;++V){let w=z[V];if(!Q&&(w==="-"||w==="+"))Q=w;else{let B=Number(w);if(!J&&B)J=B;else if(Y===-1)Y=$+V}}if(Y!==-1)q(Y,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${z}`);let U=!1,W="",H=z.length;for(let V=1;V<X.length;++V){let w=X[V];switch(w.type){case"space":U=!0;case"newline":H+=w.source.length;break;case"comment":if(Z&&!U)q(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");H+=w.source.length,W=w.source.substring(1);break;case"error":q(w,"UNEXPECTED_TOKEN",w.message),H+=w.source.length;break;default:{let B=`Unexpected token in block scalar header: ${w.type}`;q(w,"UNEXPECTED_TOKEN",B);let T=w.source;if(T&&typeof T==="string")H+=T.length}}}return{mode:G,indent:J,chomp:Q,comment:W,length:H}}function lJ($){let X=$.split(/\n( *)/),Z=X[0],q=Z.match(/^( *)/),G=[q?.[1]?[q[1],Z.slice(q[1].length)]:["",Z]];for(let J=1;J<X.length;J+=2)G.push([X[J],X[J+1]]);return G}iJ.resolveBlockScalar=pJ});var r9=K((ZQ)=>{var n9=g(),sJ=$$();function nJ($,X,Z){let{offset:q,type:z,source:G,end:J}=$,Q,Y,U=(V,w,B)=>Z(q+V,w,B);switch(z){case"scalar":Q=n9.Scalar.PLAIN,Y=rJ(G,U);break;case"single-quoted-scalar":Q=n9.Scalar.QUOTE_SINGLE,Y=oJ(G,U);break;case"double-quoted-scalar":Q=n9.Scalar.QUOTE_DOUBLE,Y=tJ(G,U);break;default:return Z($,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${z}`),{value:"",type:null,comment:"",range:[q,q+G.length,q+G.length]}}let W=q+G.length,H=sJ.resolveEnd(J,W,X,Z);return{value:Y,type:Q,comment:H.comment,range:[q,W,H.offset]}}function rJ($,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 c5($)}function oJ($,X){if($[$.length-1]!=="'"||$.length===1)X($.length,"MISSING_CHAR","Missing closing 'quote");return c5($.slice(1,-1)).replace(/''/g,"'")}function c5($){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 q=X.exec($);if(!q)return $;let z=q[1],G=" ",J=X.lastIndex;Z.lastIndex=J;while(q=Z.exec($)){if(q[1]==="")if(G===`
|
|
114
|
+
`)z+=G;else G=`
|
|
115
|
+
`;else z+=G+q[1],G=" ";J=Z.lastIndex}let Q=/[ \t]*(.*)/sy;return Q.lastIndex=J,q=Q.exec($),z+G+(q?.[1]??"")}function tJ($,X){let Z="";for(let q=1;q<$.length-1;++q){let z=$[q];if(z==="\r"&&$[q+1]===`
|
|
116
|
+
`)continue;if(z===`
|
|
117
|
+
`){let{fold:G,offset:J}=eJ($,q);Z+=G,q=J}else if(z==="\\"){let G=$[++q],J=$Q[G];if(J)Z+=J;else if(G===`
|
|
118
|
+
`){G=$[q+1];while(G===" "||G==="\t")G=$[++q+1]}else if(G==="\r"&&$[q+1]===`
|
|
119
|
+
`){G=$[++q+1];while(G===" "||G==="\t")G=$[++q+1]}else if(G==="x"||G==="u"||G==="U"){let Q={x:2,u:4,U:8}[G];Z+=XQ($,q+1,Q,X),q+=Q}else{let Q=$.substr(q-1,2);X(q-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Z+=Q}}else if(z===" "||z==="\t"){let G=q,J=$[q+1];while(J===" "||J==="\t")J=$[++q+1];if(J!==`
|
|
120
|
+
`&&!(J==="\r"&&$[q+2]===`
|
|
121
|
+
`))Z+=q>G?$.slice(G,q+1):z}else Z+=z}if($[$.length-1]!=='"'||$.length===1)X($.length,"MISSING_CHAR",'Missing closing "quote');return Z}function eJ($,X){let Z="",q=$[X+1];while(q===" "||q==="\t"||q===`
|
|
122
|
+
`||q==="\r"){if(q==="\r"&&$[X+2]!==`
|
|
123
|
+
`)break;if(q===`
|
|
124
|
+
`)Z+=`
|
|
125
|
+
`;X+=1,q=$[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,q){let z=$.substr(X,Z),J=z.length===Z&&/^[0-9a-fA-F]+$/.test(z)?parseInt(z,16):NaN;if(isNaN(J)){let Q=$.substr(X-2,Z+2);return q(X-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Q}return String.fromCodePoint(J)}ZQ.resolveFlowScalar=nJ});var i5=K((UQ)=>{var y0=j(),l5=g(),zQ=s9(),GQ=r9();function JQ($,X,Z,q){let{value:z,type:G,comment:J,range:Q}=X.type==="block-scalar"?zQ.resolveBlockScalar($,X,q):GQ.resolveFlowScalar(X,$.options.strict,q),Y=Z?$.directives.tagName(Z.source,(H)=>q(Z,"TAG_RESOLVE_FAILED",H)):null,U;if($.options.stringKeys&&$.atKey)U=$.schema[y0.SCALAR];else if(Y)U=QQ($.schema,z,Y,Z,q);else if(X.type==="scalar")U=YQ($,z,X,q);else U=$.schema[y0.SCALAR];let W;try{let H=U.resolve(z,(V)=>q(Z??X,"TAG_RESOLVE_FAILED",V),$.options);W=y0.isScalar(H)?H:new l5.Scalar(H)}catch(H){let V=H instanceof Error?H.message:String(H);q(Z??X,"TAG_RESOLVE_FAILED",V),W=new l5.Scalar(z)}if(W.range=Q,W.source=z,G)W.type=G;if(Y)W.tag=Y;if(U.format)W.format=U.format;if(J)W.comment=J;return W}function QQ($,X,Z,q,z){if(Z==="!")return $[y0.SCALAR];let G=[];for(let Q of $.tags)if(!Q.collection&&Q.tag===Z)if(Q.default&&Q.test)G.push(Q);else return Q;for(let Q of G)if(Q.test?.test(X))return Q;let J=$.knownTags[Z];if(J&&!J.collection)return $.tags.push(Object.assign({},J,{default:!1,test:void 0})),J;return z(q,"TAG_RESOLVE_FAILED",`Unresolved tag: ${Z}`,Z!=="tag:yaml.org,2002:str"),$[y0.SCALAR]}function YQ({atKey:$,directives:X,schema:Z},q,z,G){let J=Z.tags.find((Q)=>(Q.default===!0||$&&Q.default==="key")&&Q.test?.test(q))||Z[y0.SCALAR];if(Z.compat){let Q=Z.compat.find((Y)=>Y.default&&Y.test?.test(q))??Z[y0.SCALAR];if(J.tag!==Q.tag){let Y=X.tagString(J.tag),U=X.tagString(Q.tag),W=`Value may be parsed as either ${Y} or ${U}`;G(z,"TAG_RESOLVE_FAILED",W,!0)}}return J}UQ.composeScalar=JQ});var a5=K((VQ)=>{function WQ($,X,Z){if(X){Z??(Z=X.length);for(let q=Z-1;q>=0;--q){let z=X[q];switch(z.type){case"space":case"comment":case"newline":$-=z.source.length;continue}z=X[++q];while(z?.type==="space")$+=z.source.length,z=X[++q];break}}return $}VQ.emptyScalarPosition=WQ});var r5=K((OQ)=>{var wQ=M$(),LQ=j(),BQ=p5(),s5=i5(),KQ=$$(),DQ=a5(),_Q={composeNode:n5,composeEmptyNode:o9};function n5($,X,Z,q){let z=$.atKey,{spaceBefore:G,comment:J,anchor:Q,tag:Y}=Z,U,W=!0;switch(X.type){case"alias":if(U=FQ($,X,q),Q||Y)q(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,q),Q)U.anchor=Q.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(U=BQ.composeCollection(_Q,$,X,Z,q),Q)U.anchor=Q.source.substring(1);break;default:{let H=X.type==="error"?X.message:`Unsupported token (type: ${X.type})`;q(X,"UNEXPECTED_TOKEN",H),U=o9($,X.offset,void 0,null,Z,q),W=!1}}if(Q&&U.anchor==="")q(Q,"BAD_ALIAS","Anchor cannot be an empty string");if(z&&$.options.stringKeys&&(!LQ.isScalar(U)||typeof U.value!=="string"||U.tag&&U.tag!=="tag:yaml.org,2002:str"))q(Y??X,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(G)U.spaceBefore=!0;if(J)if(X.type==="scalar"&&X.source==="")U.comment=J;else U.commentBefore=J;if($.options.keepSourceTokens&&W)U.srcToken=X;return U}function o9($,X,Z,q,{spaceBefore:z,comment:G,anchor:J,tag:Q,end:Y},U){let W={type:"scalar",offset:DQ.emptyScalarPosition(X,Z,q),indent:-1,source:""},H=s5.composeScalar($,W,Q,U);if(J){if(H.anchor=J.source.substring(1),H.anchor==="")U(J,"BAD_ALIAS","Anchor cannot be an empty string")}if(z)H.spaceBefore=!0;if(G)H.comment=G,H.range[2]=Y;return H}function FQ({options:$},{offset:X,source:Z,end:q},z){let G=new wQ.Alias(Z.substring(1));if(G.source==="")z(X,"BAD_ALIAS","Alias cannot be an empty string");if(G.source.endsWith(":"))z(X+Z.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let J=X+Z.length,Q=KQ.resolveEnd(q,J,$.strict,z);if(G.range=[X,J,Q.offset],Q.comment)G.comment=Q.comment;return G}OQ.composeEmptyNode=o9;OQ.composeNode=n5});var t5=K((SQ)=>{var RQ=g$(),o5=r5(),PQ=$$(),NQ=v$();function AQ($,X,{offset:Z,start:q,value:z,end:G},J){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(q,{indicator:"doc-start",next:z??G?.[0],offset:Z,onError:J,parentIndent:0,startOnNewline:!0});if(W.found){if(Y.directives.docStart=!0,z&&(z.type==="block-map"||z.type==="block-seq")&&!W.hasNewline)J(W.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}Y.contents=z?o5.composeNode(U,z,W,J):o5.composeEmptyNode(U,W.end,q,null,W,J);let H=Y.contents.range[2],V=PQ.resolveEnd(G,H,!1,J);if(V.comment)Y.comment=V.comment;return Y.range=[Z,H,V.offset],Y}SQ.composeDoc=AQ});var t9=K((fQ)=>{var EQ=Q0("process"),CQ=Z9(),bQ=g$(),u$=h$(),e5=j(),yQ=t5(),xQ=$$();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,q=!1;for(let z=0;z<$.length;++z){let G=$[z];switch(G[0]){case"#":X+=(X===""?"":q?`
|
|
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
|
+
`)+(G.substring(1)||" "),Z=!0,q=!1;break;case"%":if($[z+1]?.[0]!=="#")z+=1;Z=!1;break;default:if(!Z)q=!0;Z=!1}}return{comment:X,afterEmptyLine:q}}class X8{constructor($={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(X,Z,q,z)=>{let G=m$(X);if(z)this.warnings.push(new u$.YAMLWarning(G,Z,q));else this.errors.push(new u$.YAMLParseError(G,Z,q))},this.directives=new CQ.Directives({version:$.version||"1.2"}),this.options=$}decorate($,X){let{comment:Z,afterEmptyLine:q}=$8(this.prelude);if(Z){let z=$.contents;if(X)$.comment=$.comment?`${$.comment}
|
|
130
|
+
${Z}`:Z;else if(q||$.directives.docStart||!z)$.commentBefore=Z;else if(e5.isCollection(z)&&!z.flow&&z.items.length>0){let G=z.items[0];if(e5.isPair(G))G=G.key;let J=G.commentBefore;G.commentBefore=J?`${Z}
|
|
131
|
+
${J}`:Z}else{let G=z.commentBefore;z.commentBefore=G?`${Z}
|
|
132
|
+
${G}`: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 q of $)yield*this.next(q);yield*this.end(X,Z)}*next($){if(EQ.env.LOG_STREAM)console.dir($,{depth:null});switch($.type){case"directive":this.directives.add($.source,(X,Z,q)=>{let z=m$($);z[0]+=X,this.onError(z,"BAD_DIRECTIVE",Z,q)}),this.prelude.push($.source),this.atDirectives=!0;break;case"document":{let X=yQ.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=xQ.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),q=new bQ.Document(void 0,Z);if(this.atDirectives)this.onError(X,"MISSING_CHAR","Missing directives-end indicator line");q.range=[0,X,X],this.decorate(q,!1),yield q}}}fQ.Composer=X8});var z8=K((cQ)=>{var gQ=s9(),hQ=r9(),vQ=h$(),Z8=N$();function uQ($,X=!0,Z){if($){let q=(z,G,J)=>{let Q=typeof z==="number"?z:Array.isArray(z)?z[0]:z.offset;if(Z)Z(Q,G,J);else throw new vQ.YAMLParseError([Q,Q+1],G,J)};switch($.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return hQ.resolveFlowScalar($,X,q);case"block-scalar":return gQ.resolveBlockScalar({options:{strict:X}},$,q)}}return null}function mQ($,X){let{implicitKey:Z=!1,indent:q,inFlow:z=!1,offset:G=-1,type:J="PLAIN"}=X,Q=Z8.stringifyString({type:J,value:$},{implicitKey:Z,indent:q>0?" ".repeat(q):"",inFlow:z,options:{blockQuote:!0,lineWidth:-1}}),Y=X.end??[{type:"newline",offset:-1,indent:q,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:G,indent:q,source:W}];if(!q8(V,Y))V.push({type:"newline",offset:-1,indent:q,source:`
|
|
137
|
+
`});return{type:"block-scalar",offset:G,indent:q,props:V,source:H}}case'"':return{type:"double-quoted-scalar",offset:G,indent:q,source:Q,end:Y};case"'":return{type:"single-quoted-scalar",offset:G,indent:q,source:Q,end:Y};default:return{type:"scalar",offset:G,indent:q,source:Q,end:Y}}}function dQ($,X,Z={}){let{afterKey:q=!1,implicitKey:z=!1,inFlow:G=!1,type:J}=Z,Q="indent"in $?$.indent:null;if(q&&typeof Q==="number")Q+=2;if(!J)switch($.type){case"single-quoted-scalar":J="QUOTE_SINGLE";break;case"double-quoted-scalar":J="QUOTE_DOUBLE";break;case"block-scalar":{let U=$.props[0];if(U.type!=="block-scalar-header")throw Error("Invalid block scalar header");J=U.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:J="PLAIN"}let Y=Z8.stringifyString({type:J,value:X},{implicitKey:z||Q===null,indent:Q!==null&&Q>0?" ".repeat(Q):"",inFlow:G,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
|
+
`),q=X.substring(0,Z),z=X.substring(Z+1)+`
|
|
139
|
+
`;if($.type==="block-scalar"){let G=$.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=q,$.source=z}else{let{offset:G}=$,J="indent"in $?$.indent:-1,Q=[{type:"block-scalar-header",offset:G,indent:J,source:q}];if(!q8(Q,"end"in $?$.end:void 0))Q.push({type:"newline",offset:-1,indent:J,source:`
|
|
140
|
+
`});for(let Y of Object.keys($))if(Y!=="type"&&Y!=="offset")delete $[Y];Object.assign($,{type:"block-scalar",indent:J,props:Q,source:z})}}function q8($,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 q=$.props.slice(1),z=X.length;if($.props[0].type==="block-scalar-header")z-=$.props[0].source.length;for(let G of q)G.offset+=z;delete $.props,Object.assign($,{type:Z,source:X,end:q});break}case"block-map":case"block-seq":{let z={type:"newline",offset:$.offset+X.length,indent:$.indent,source:`
|
|
141
|
+
`};delete $.items,Object.assign($,{type:Z,source:X,end:[z]});break}default:{let q="indent"in $?$.indent:-1,z="end"in $&&Array.isArray($.end)?$.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys($))if(G!=="type"&&G!=="offset")delete $[G];Object.assign($,{type:Z,indent:q,source:X,end:z})}}}cQ.createScalarToken=mQ;cQ.resolveAsScalar=uQ;cQ.setScalarValue=dQ});var G8=K((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:q}){let z="";for(let G of $)z+=G.source;if(X)z+=o1(X);if(Z)for(let G of Z)z+=G.source;if(q)z+=o1(q);return z}nQ.stringify=sQ});var Y8=K((tQ)=>{var $4=Symbol("break visit"),oQ=Symbol("skip children"),J8=Symbol("remove item");function x0($,X){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};Q8(Object.freeze([]),$,X)}x0.BREAK=$4;x0.SKIP=oQ;x0.REMOVE=J8;x0.itemAtPath=($,X)=>{let Z=$;for(let[q,z]of X){let G=Z?.[q];if(G&&"items"in G)Z=G.items[z];else return}return Z};x0.parentCollection=($,X)=>{let Z=x0.itemAtPath($,X.slice(0,-1)),q=X[X.length-1][0],z=Z?.[q];if(z&&"items"in z)return z;throw Error("Parent collection not found")};function Q8($,X,Z){let q=Z(X,$);if(typeof q==="symbol")return q;for(let z of["key","value"]){let G=X[z];if(G&&"items"in G){for(let J=0;J<G.items.length;++J){let Q=Q8(Object.freeze($.concat([[z,J]])),G.items[J],Z);if(typeof Q==="number")J=Q-1;else if(Q===$4)return $4;else if(Q===J8)G.items.splice(J,1),J-=1}if(typeof q==="function"&&z==="key")q=q(X,$)}}return typeof q==="function"?q(X,$):q}tQ.visit=x0});var t1=K((JY)=>{var X4=z8(),$Y=G8(),XY=Y8(),Z4="\uFEFF",q4="\x02",z4="\x18",G4="\x1F",ZY=($)=>!!$&&("items"in $),qY=($)=>!!$&&($.type==="scalar"||$.type==="single-quoted-scalar"||$.type==="double-quoted-scalar"||$.type==="block-scalar");function zY($){switch($){case Z4:return"<BOM>";case q4:return"<DOC>";case z4:return"<FLOW_END>";case G4:return"<SCALAR>";default:return JSON.stringify($)}}function GY($){switch($){case Z4:return"byte-order-mark";case q4:return"doc-mode";case z4:return"flow-error-end";case G4: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}JY.createScalarToken=X4.createScalarToken;JY.resolveAsScalar=X4.resolveAsScalar;JY.setScalarValue=X4.setScalarValue;JY.stringify=$Y.stringify;JY.visit=XY.visit;JY.BOM=Z4;JY.DOCUMENT=q4;JY.FLOW_END=z4;JY.SCALAR=G4;JY.isCollection=ZY;JY.isScalar=qY;JY.prettyToken=zY;JY.tokenType=GY});var Q4=K((MY)=>{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"),FY=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),e1=new Set(",[]{}"),OY=new Set(` ,[]{}
|
|
145
|
+
\r `),J4=($)=>!$||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 q=this.buffer[Z+$+1];if(q===`
|
|
148
|
+
`||!q&&!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 z=$[Z-1];if(z===" "||z==="\t"){X=Z-1;break}else Z=$.indexOf("#",Z+1)}while(!0){let z=$[X-1];if(z===" "||z==="\t")X-=1;else break}let q=(yield*this.pushCount(X))+(yield*this.pushSpaces(!0));return yield*this.pushCount($.length-q),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(J4),"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 q=this.getLine();if(q===null)return this.setNext("flow");if(Z!==-1&&Z<this.indentNext&&q[0]!=="#"||Z===0&&(q.startsWith("---")||q.startsWith("..."))&&X0(q[3])){if(!(Z===this.indentNext-1&&this.flowLevel===1&&(q[0]==="]"||q[0]==="}")))return this.flowLevel=0,yield d$.FLOW_END,yield*this.parseLineStart()}let z=0;while(q[z]===",")z+=yield*this.pushCount(1),z+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(z+=yield*this.pushIndicators(),q[z]){case void 0:return"flow";case"#":return yield*this.pushCount(q.length-z),"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(J4),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let G=this.charAt(1);if(this.flowKey||X0(G)||G===",")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 z=0;while(this.buffer[X-1-z]==="\\")z+=1;if(z%2===0)break;X=this.buffer.indexOf('"',X+1)}let Z=this.buffer.substring(0,X),q=Z.indexOf(`
|
|
151
|
+
`,this.pos);if(q!==-1){while(q!==-1){let z=this.continueScalar(q+1);if(z===-1)break;q=Z.indexOf(`
|
|
152
|
+
`,z)}if(q!==-1)X=q-(Z[q-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 z=this.pos;Z=this.buffer[z];++z)switch(Z){case" ":X+=1;break;case`
|
|
153
|
+
`:$=z,X=0;break;case"\r":{let G=this.buffer[z+1];if(!G&&!this.atEnd)return this.setNext("block-scalar");if(G===`
|
|
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 z=this.continueScalar($+1);if(z===-1)break;$=this.buffer.indexOf(`
|
|
155
|
+
`,z)}while($!==-1);if($===-1){if(!this.atEnd)return this.setNext("block-scalar");$=this.buffer.length}}let q=$+1;Z=this.buffer[q];while(Z===" ")Z=this.buffer[++q];if(Z==="\t"){while(Z==="\t"||Z===" "||Z==="\r"||Z===`
|
|
156
|
+
`)Z=this.buffer[++q];$=q-1}else if(!this.blockScalarKeep)do{let z=$-1,G=this.buffer[z];if(G==="\r")G=this.buffer[--z];let J=z;while(G===" ")G=this.buffer[--z];if(G===`
|
|
157
|
+
`&&z>=this.pos&&z+1+X>J)$=z;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,q;while(q=this.buffer[++Z])if(q===":"){let z=this.buffer[Z+1];if(X0(z)||$&&e1.has(z))break;X=Z}else if(X0(q)){let z=this.buffer[Z+1];if(q==="\r")if(z===`
|
|
158
|
+
`)Z+=1,q=`
|
|
159
|
+
`,z=this.buffer[Z+1];else X=Z;if(z==="#"||$&&e1.has(z))break;if(q===`
|
|
160
|
+
`){let G=this.continueScalar(Z+1);if(G===-1)break;Z=Math.max(Z,G-2)}}else{if($&&e1.has(q))break;X=Z}if(!q&&!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(J4))+(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(FY.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 q=X-this.pos;if(q>0)yield this.buffer.substr(this.pos,q),this.pos=X;return q}*pushUntil($){let X=this.pos,Z=this.buffer[X];while(!$(Z))Z=this.buffer[++X];return yield*this.pushToIndex(X,!1)}}MY.Lexer=H8});var Y4=K((RY)=>{class W8{constructor(){this.lineStarts=[],this.addNewLine=($)=>this.lineStarts.push($),this.linePos=($)=>{let X=0,Z=this.lineStarts.length;while(X<Z){let z=X+Z>>1;if(this.lineStarts[z]<$)X=z+1;else Z=z}if(this.lineStarts[X]===$)return{line:X+1,col:1};if(X===0)return{line:0,col:$};let q=this.lineStarts[X-1];return{line:X,col:$-q+1}}}}RY.LineCounter=W8});var U4=K((SY)=>{var NY=Q0("process"),V8=t1(),AY=Q4();function M0($,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 L8($){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 w8($){if($.start.type==="flow-seq-start"){for(let X of $.items)if(X.sep&&!X.value&&!M0(X.start,"explicit-key-ind")&&!M0(X.sep,"map-value-ind")){if(X.key)X.value=X.key;if(delete X.key,L8(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 B8{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")w8(X);switch(Z.type){case"document":Z.value=X;break;case"block-scalar":Z.props.push(X);break;case"block-map":{let q=Z.items[Z.items.length-1];if(q.value){Z.items.push({start:[],key:X,sep:[]}),this.onKeyLine=!0;return}else if(q.sep)q.value=X;else{Object.assign(q,{key:X,sep:[]}),this.onKeyLine=!q.explicitKey;return}break}case"block-seq":{let q=Z.items[Z.items.length-1];if(q.value)Z.items.push({start:[],value:X});else q.value=X;break}case"flow-collection":{let q=Z.items[Z.items.length-1];if(!q||q.value)Z.items.push({start:[],key:X,sep:[]});else if(q.sep)q.value=X;else Object.assign(q,{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 q=X.items[X.items.length-1];if(q&&!q.sep&&!q.value&&q.start.length>0&&T8(q.start)===-1&&(X.indent===0||q.start.every((z)=>z.type!=="comment"||z.indent<X.indent))){if(Z.type==="document")Z.end=q.start;else Z.items.push({start:q.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),q;if($.end)q=$.end,q.push(this.sourceToken),delete $.end;else q=[this.sourceToken];let z={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:Z,key:$,sep:q}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=z}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 q=$.items[$.items.length-2]?.value?.end;if(Array.isArray(q)){Array.prototype.push.apply(q,X.start),q.push(this.sourceToken),$.items.pop();return}}X.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let Z=!this.onKeyLine&&this.indent===$.indent,q=Z&&(X.sep||X.explicitKey)&&this.type!=="seq-item-ind",z=[];if(q&&X.sep&&!X.value){let G=[];for(let J=0;J<X.sep.length;++J){let Q=X.sep[J];switch(Q.type){case"newline":G.push(J);break;case"space":break;case"comment":if(Q.indent>$.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)z=X.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(q||X.value)z.push(this.sourceToken),$.items.push({start:z}),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(q||X.value)z.push(this.sourceToken),$.items.push({start:z,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(M0(X.start,"newline"))Object.assign(X,{key:null,sep:[this.sourceToken]});else{let G=X$(X.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]})}else if(X.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(M0(X.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,key:null,sep:[this.sourceToken]}]});else if(L8(X.key)&&!M0(X.sep,"newline")){let G=X$(X.start),J=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:G,key:J,sep:Q}]})}else if(z.length>0)X.sep=X.sep.concat(z,this.sourceToken);else X.sep.push(this.sourceToken);else if(!X.sep)Object.assign(X,{key:null,sep:[this.sourceToken]});else if(X.value||q)$.items.push({start:z,key:null,sep:[this.sourceToken]});else if(M0(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 G=this.flowScalar(this.type);if(q||X.value)$.items.push({start:z,key:G,sep:[]}),this.onKeyLine=!0;else if(X.sep)this.stack.push(G);else Object.assign(X,{key:G,sep:[]}),this.onKeyLine=!0;return}default:{let G=this.startBlockValue($);if(G){if(G.type==="block-seq"){if(!X.explicitKey&&X.sep&&!M0(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:z});this.stack.push(G);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 q=$.items[$.items.length-2]?.value?.end;if(Array.isArray(q)){Array.prototype.push.apply(q,X.start),q.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||M0(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 q=this.flowScalar(this.type);if(!X||X.value)$.items.push({start:[],key:q,sep:[]});else if(X.sep)this.stack.push(q);else Object.assign(X,{key:q,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 q=$2(Z),z=X$(q);w8($);let G=$.end.splice(1,$.end.length);G.push(this.sourceToken);let J={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:z,key:$,sep:G}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=J}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()}}}SY.Parser=B8});var O8=K((gY)=>{var K8=t9(),EY=g$(),p$=h$(),CY=Y9(),bY=j(),yY=Y4(),D8=U4();function _8($){let X=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||X&&new yY.LineCounter||null,prettyErrors:X}}function xY($,X={}){let{lineCounter:Z,prettyErrors:q}=_8(X),z=new D8.Parser(Z?.addNewLine),G=new K8.Composer(X),J=Array.from(G.compose(z.parse($)));if(q&&Z)for(let Q of J)Q.errors.forEach(p$.prettifyError($,Z)),Q.warnings.forEach(p$.prettifyError($,Z));if(J.length>0)return J;return Object.assign([],{empty:!0},G.streamInfo())}function F8($,X={}){let{lineCounter:Z,prettyErrors:q}=_8(X),z=new D8.Parser(Z?.addNewLine),G=new K8.Composer(X),J=null;for(let Q of G.compose(z.parse($),!0,$.length))if(!J)J=Q;else if(J.options.logLevel!=="silent"){J.errors.push(new p$.YAMLParseError(Q.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(q&&Z)J.errors.forEach(p$.prettifyError($,Z)),J.warnings.forEach(p$.prettifyError($,Z));return J}function fY($,X,Z){let q=void 0;if(typeof X==="function")q=X;else if(Z===void 0&&X&&typeof X==="object")Z=X;let z=F8($,Z);if(!z)return null;if(z.warnings.forEach((G)=>CY.warn(z.options.logLevel,G)),z.errors.length>0)if(z.options.logLevel!=="silent")throw z.errors[0];else z.errors=[];return z.toJS(Object.assign({reviver:q},Z))}function kY($,X,Z){let q=null;if(typeof X==="function"||Array.isArray(X))q=X;else if(Z===void 0&&X)Z=X;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??X??{};if(!z)return}if(bY.isDocument($)&&!q)return $.toString(Z);return new EY.Document($,q,Z).toString(Z)}gY.parse=fY;gY.parseAllDocuments=xY;gY.parseDocument=F8;gY.stringify=kY});var I8=K(($U)=>{var dY=t9(),pY=g$(),cY=k9(),H4=h$(),lY=M$(),I0=j(),iY=D0(),aY=g(),sY=F0(),nY=O0(),rY=t1(),oY=Q4(),tY=Y4(),eY=U4(),X2=O8(),M8=F$();$U.Composer=dY.Composer;$U.Document=pY.Document;$U.Schema=cY.Schema;$U.YAMLError=H4.YAMLError;$U.YAMLParseError=H4.YAMLParseError;$U.YAMLWarning=H4.YAMLWarning;$U.Alias=lY.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=M8.visit;$U.visitAsync=M8.visitAsync});var TX=r4(VX(),1),{program:c0,createCommand:sW,createArgument:nW,createOption:rW,CommanderError:oW,InvalidArgumentError:tW,InvalidOptionArgumentError:eW,Command:$V,Argument:XV,Option:o2,Help:ZV}=TX.default;var wX={name:"@pickled-dev/cli",version:"0.12.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 z0={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 q;try{let z=await Z.text();q=R8.default.parse(z)}catch(z){throw Error(`Failed to parse pickled.yml: ${z}`)}return EU(q),q}function EU($){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,q]of Object.entries($.docs.sources))bU(Z,q);if($.targets)for(let[Z,q]of Object.entries($.targets)){if(q.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(q.provider==="codex-cli"){if(!q.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(q.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(q.category==="api"){if(!q.model)throw Error(`pickled.yml: target "${Z}" (api/${q.provider}) requires an explicit 'model' field. Pickled does not substitute a default; reproducible evals depend on pinning the model.`);let z=["allowedTools","disallowedTools","mcpServers","permissionMode","maxTurns","maxThinkingTokens","maxBudgetUsd"];for(let G of z)if(q[G]!==void 0)throw Error(`pickled.yml: target "${Z}" (api/${q.provider}) sets '${G}', which only applies to CLI/Agent SDK targets. Remove the field; API targets accept only model/temperature/maxTokens/threshold.`);if(q.workspaceContext!==void 0)throw Error(`pickled.yml: target "${Z}" (api/${q.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 q of Z.requiredSources)if(!X.has(q))throw Error(`pickled.yml: scenario "${Z.name}" references unknown source "${q}". Declared sources: ${[...X].join(", ")||"(none)"}`);fU(Z.name,Z.traps),CU(Z.name,Z.compareSurfaces,X)}}function CU($,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 q=0;q<X.length;q++){let z=X[q];if(!Array.isArray(z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${q}] must be an array of source ids`);if(z.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${q}] must be a non-empty list of source ids`);for(let G of z){if(typeof G!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${q}] entries must be string source ids`);if(!Z.has(G))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${q}] references unknown source "${G}". Declared sources: ${[...Z].join(", ")||"(none)"}`)}}}function bU($,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 q=Z.audit;if(q.traps!==void 0&&typeof q.traps!=="boolean")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean`);for(let z of Object.keys(q))if(z!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${z}"`)}for(let q of Object.keys(Z))if(q!=="path"&&q!=="audit")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${q}"`)}var yU=new Set(["g","y"]),xU=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 q of X){if(!q.id||typeof q.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(Z.has(q.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${q.id}"`);if(Z.add(q.id),!q.reason||typeof q.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" requires non-empty 'reason'`);if(q.auditSeverity!==void 0&&q.auditSeverity!=="warning"&&q.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" auditSeverity must be "warning" or "error"`);let z=typeof q.match==="string",G=typeof q.pattern==="string";if(z===G)throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" must set exactly one of 'match' or 'pattern'`);if(z){if(q.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" has empty 'match'`);if(q.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" sets 'flags' without 'pattern'`)}else{let J=q.pattern;if(typeof J!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" must set 'pattern'`);if(J==="")throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" has empty 'pattern'`);if(q.flags!==void 0){if(typeof q.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" has non-string 'flags'`);for(let Q of q.flags){if(yU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" uses forbidden regex flag "${Q}" (g and y are not allowed)`);if(!xU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${q.id}" uses unsupported regex flag "${Q}"`)}}try{new RegExp(J,q.flags??"")}catch(Q){throw Error(`pickled.yml: scenario "${$}" trap "${q.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 q=[...Z].sort().join(", ");throw Error(`Unknown target: "${X}". Available targets: ${q}`)}return{...$,matrix:{...$.matrix,target:[X]},scenarios:$.scenarios.filter((q)=>!q.target||q.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:q,findings:z}=$,G=[],J=z.filter((H)=>H.severity==="error").length,Q=z.filter((H)=>H.severity==="warning").length;if(G.push(`# Agent-context audit
|
|
167
|
+
`),G.push(`Target: \`${X.targetRepo}\``),G.push(`Budgets: root \u2264 ${X.budgets.rootLines} lines, nested warn at ${X.budgets.nestedWarnLines} lines.`),G.push(`Found ${Z.length} agent-doc files. ${J} error(s), ${Q} warning(s).
|
|
168
|
+
`),G.push(`## Inventory
|
|
169
|
+
`),Z.length===0)G.push(`No agent-doc files found.
|
|
170
|
+
`);else{G.push("| File | Lines | Kind | Notes |"),G.push("|---|---|---|---|");let H=[...Z].sort((V,w)=>w.lineCount-V.lineCount);for(let V of H){let w=!V.relPath.includes("/"),B=P8(V.lineCount,w,X),T=V.isSymlink?`symlink \u2192 ${V.symlinkTarget?.replace(`${X.targetRepo}/`,"")??"?"}`:"file";G.push(`| \`${V.relPath}\` | ${V.lineCount} | ${T} | ${B} |`)}G.push("")}if(G.push(`## AGENTS.md / CLAUDE.md pairs
|
|
171
|
+
`),q.length===0)G.push(`No pairs found.
|
|
172
|
+
`);else{G.push("| Directory | A | C | Class | Detail |"),G.push("|---|---|---|---|---|");for(let H of q)G.push(`| \`${H.dir||"(root)"}\` | ${H.agentsExists?"\u2713":"\xB7"} | ${H.claudeExists?"\u2713":"\xB7"} | ${H.classification} | ${H.detail} |`);G.push("")}let Y=Z.filter((H)=>!H.isSymlink&&H.brokenPathRefs.length+H.brokenImports.length>0);if(G.push(`## Broken references
|
|
173
|
+
`),Y.length===0)G.push(`None detected.
|
|
174
|
+
`);else for(let H of Y){if(G.push(`### \`${H.relPath}\`
|
|
175
|
+
`),H.brokenPathRefs.length>0){G.push("Broken path references:");for(let V of H.brokenPathRefs)G.push(` - \`${V}\``);G.push("")}if(H.brokenImports.length>0){G.push("Broken `@`-imports:");for(let V of H.brokenImports)G.push(` - \`${V}\``);G.push("")}}let U=Z.filter((H)=>!H.isSymlink&&H.unresolvedCommands.length>0);if(G.push(`## Unresolved package-manager commands (advisory)
|
|
176
|
+
`),G.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)G.push(`None flagged.
|
|
177
|
+
`);else for(let H of U){G.push(`### \`${H.relPath}\`
|
|
178
|
+
`);for(let V of H.unresolvedCommands)G.push(` - \`${V}\``);G.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(G.push(`## Section breakdown for files over budget
|
|
179
|
+
`),W.length===0)G.push(`All files within budget.
|
|
180
|
+
`);else for(let H of W){G.push(`### \`${H.relPath}\` (${H.lineCount} lines)
|
|
181
|
+
`),G.push(`Largest H2 sections (lines including any subsections):
|
|
182
|
+
`),G.push("| Section | Lines |"),G.push("|---|---|");for(let V of H.sections.slice(0,10))G.push(`| ${V.header} | ${V.lines} |`);G.push("")}if(G.push(`## Registered-source trap matches
|
|
183
|
+
`),G.push("Catches stale claims in `docs.sources` against declared traps. Sources with `audit.traps: false` are excluded.\n"),$.sourceTrapMatches.length===0)G.push(`None.
|
|
184
|
+
`);else{for(let H of $.sourceTrapMatches)G.push(`- **${H.sourceId}** (\`${H.sourcePath}:L${H.line}\`) \u2014 trap \`${H.trapId}\` matched \`${H.matched}\` (${H.severity})`),G.push(` - reason: ${H.trapReason}`),G.push(" - fix: remove the stale claim, retire the trap, or set `audit.traps: false` on the source");G.push("")}return G.join(`
|
|
185
|
+
`)}function q2($){return JSON.stringify($,null,2)}function z2($){let{config:X,files:Z,pairs:q,findings:z}=$,G=[],J=z.filter((H)=>H.severity==="error").length,Q=z.filter((H)=>H.severity==="warning").length;if(G.push("pickled audit"),G.push(`Target: ${X.targetRepo}`),G.push(`Budgets: root \u2264 ${X.budgets.rootLines} lines, nested warn at ${X.budgets.nestedWarnLines} lines.`),G.push(`Found: ${Z.length} agent-doc file(s) \xB7 ${J} error(s) \xB7 ${Q} warning(s)`),G.push(""),G.push("Inventory"),Z.length===0)G.push(" none");else{let H=[...Z].sort((w,B)=>B.lineCount-w.lineCount),V=Math.max(...H.map((w)=>w.relPath.length));for(let w of H){let B=!w.relPath.includes("/"),T=P8(w.lineCount,B,X),L=w.isSymlink?`symlink \u2192 ${w.symlinkTarget?.replace(`${X.targetRepo}/`,"")??"?"}`:"file",D=`${w.lineCount}`.padStart(4),_=w.relPath.padEnd(V),O=T?` (${T})`:"";G.push(` ${_} ${D} lines ${L}${O}`)}}if(G.push(""),G.push("AGENTS.md / CLAUDE.md pairs"),q.length===0)G.push(" none");else for(let H of q){let V=H.dir||"(root)";G.push(` ${V}: ${H.classification} \xB7 ${H.detail}`)}G.push("");let Y=Z.filter((H)=>!H.isSymlink&&H.brokenPathRefs.length+H.brokenImports.length>0);if(G.push("Broken references"),Y.length===0)G.push(" none");else for(let H of Y){G.push(` ${H.relPath}:`);for(let V of H.brokenPathRefs)G.push(` path: ${V}`);for(let V of H.brokenImports)G.push(` @-import: ${V}`)}G.push("");let U=Z.filter((H)=>!H.isSymlink&&H.unresolvedCommands.length>0);if(G.push("Unresolved package-manager commands (advisory)"),U.length===0)G.push(" none");else for(let H of U){G.push(` ${H.relPath}:`);for(let V of H.unresolvedCommands)G.push(` ${V}`)}G.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(G.push("Section breakdown for files over budget"),W.length===0)G.push(" all files within budget");else for(let H of W){G.push(` ${H.relPath} (${H.lineCount} lines):`);for(let V of H.sections.slice(0,10))G.push(` ${V.header.padEnd(40)} ${V.lines} lines`)}if(G.push(""),G.push("Registered-source trap matches"),$.sourceTrapMatches.length===0)G.push(" none");else for(let H of $.sourceTrapMatches){let V=H.severity==="error"?"error":"warning";G.push(` [${V}] ${H.sourceId} (${H.sourcePath}:L${H.line}): trap ${H.trapId} matched "${H.matched}"`),G.push(` reason: ${H.trapReason}`),G.push(" fix: remove the stale claim, retire the trap, or set audit.traps: false on the source")}return G.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 z$,lstatSync as E8,readFileSync as Q2,readlinkSync as pU,statSync as cU}from"fs";import{dirname as Y2,isAbsolute as lU,join as w4,relative as iU,resolve as L4}from"path";var{Glob:j8}=globalThis.Bun;var G2=["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/**"],q$={targetRepo:".",budgets:{rootLines:120,nestedWarnLines:200},ignore:G2,intentionalDifferentPairs:[],knownCommands:[]};function J2($){if(!$)return q$;return{targetRepo:$.targetRepo??q$.targetRepo,budgets:{rootLines:$.budgets?.rootLines??q$.budgets.rootLines,nestedWarnLines:$.budgets?.nestedWarnLines??q$.budgets.nestedWarnLines},ignore:$.ignore??G2,intentionalDifferentPairs:$.intentionalDifferentPairs??[],knownCommands:$.knownCommands??[]}}import{existsSync as uU}from"fs";import{join as mU}from"path";function f0($){let X=[],Z=[];for(let q of $.traps){let z=kU($.response,q);if(z)X.push(z);else Z.push(q.id)}return{fired:X,avoided:Z}}function kU($,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 q=new RegExp(X.pattern,X.flags??"").exec($);if(!q)return null;return{id:X.id,reason:X.reason,matched:q[0],snippet:N8($,q.index,q[0].length),index:q.index}}return null}function N8($,X,Z){let q=Math.max(0,X-40),z=Math.min($.length,X+Z+40),G=$.slice(q,z).replace(/\s+/g," ").trim();if(q>0)G=`...${G}`;if(z<$.length)G=`${G}...`;return G}import T4 from"path";function gU($){return $.startsWith("http://")||$.startsWith("https://")}async function hU($,X,Z){let q=await fetch(X);if(!q.ok)throw Error(`Failed to fetch source "${$}" from ${X}: ${q.status} ${q.statusText}`);let z=await q.text();return{id:$,source:X,content:z,name:new URL(X).hostname+new URL(X).pathname,type:"url",auditTraps:Z}}async function vU($,X,Z,q){let z=T4.isAbsolute(X)?X:T4.resolve(Z,X),G=Bun.file(z);if(!await G.exists())throw Error(`Source "${$}" not found at ${z}`);let J=await G.text();return{id:$,source:X,content:J,name:T4.basename(z),type:"file",auditTraps:q}}async function A8($,X,Z){let{path:q,auditTraps:z}=V4(X);if(gU(q))return hU($,q,z);return vU($,q,Z,z)}async function c$($,X){let Z=Object.entries($);return await Promise.all(Z.map(([z,G])=>A8(z,G,X)))}async function S8($){if(!uU(mU($,"pickled.yml")))return{matches:[],findings:[]};let X=await Z$($),Z=X.docs?.sources;if(!Z||Object.keys(Z).length===0)return{matches:[],findings:[]};let q={};for(let[U,W]of Object.entries(Z)){let H=typeof W==="string"?W:W.path;if(H.startsWith("http://")||H.startsWith("https://"))continue;q[U]=W}if(Object.keys(q).length===0)return{matches:[],findings:[]};let z=[],G=new Map;for(let U of X.scenarios)for(let W of U.traps??[])z.push(W),G.set(W,W.auditSeverity??"warning");if(z.length===0)return{matches:[],findings:[]};let J=await c$(q,$),Q=[],Y=[];for(let U of J){if(U.auditTraps===!1)continue;for(let W of z){let{fired:H}=f0({response:U.content,traps:[W]}),V=H[0];if(!V)continue;let w=dU(U.content,V.index),B=G.get(W)??"warning";Q.push({sourceId:U.id,sourcePath:U.source,trapId:V.id,trapReason:V.reason,matched:V.matched,snippet:V.snippet,line:w,severity:B}),Y.push({severity:B,category:"trap-source-match",file:U.source,message:`source [${U.id}] matches trap '${V.id}' ("${V.matched}"). ${V.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 dU($,X){let Z=1,q=Math.min(X,$.length);for(let z=0;z<q;z++)if($[z]===`
|
|
187
|
+
`)Z++;return Z}var aU=["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=J2($),Z=L4(X.targetRepo);if(!z$(Z))throw Error(`targetRepo does not exist: ${Z}`);let q=new Set;for(let U of aU){let W=new j8(U);for await(let H of W.scan({cwd:Z,dot:!0,onlyFiles:!1,followSymlinks:!1})){if(X.ignore.some((B)=>new j8(B).match(H)))continue;let V=w4(Z,H),w=E8(V);if(w.isFile()){q.add(H);continue}if(w.isSymbolicLink())try{if(cU(V).isFile())q.add(H)}catch{}}}let z=[];for(let U of[...q].sort())z.push(await sU(Z,U,w4(Z,U),X));let G=JH(z,X),J=QH(z,G,X),{matches:Q,findings:Y}=await S8(Z);return{config:X,files:z,pairs:G,findings:[...J,...Y],sourceTrapMatches:Q}}async function sU($,X,Z,q){let G=E8(Z).isSymbolicLink(),J=null,Q=X;if(G){let V=pU(Z),w=lU(V)?V:L4(Y2(Z),V);if(J=w,z$(w))Q=iU($,w)}let Y=G&&J&&z$(J)?J:Z,U=Q2(Y,"utf8"),W=(U.match(/\n/g)??[]).length,H=U.endsWith(`
|
|
188
|
+
`)?W:W+1;return{relPath:X,absPath:Z,isSymlink:G,symlinkTarget:J,realRelPath:Q,lineCount:H,brokenPathRefs:rU(U,$,X),brokenImports:tU(U,Y2(Z)),unresolvedCommands:ZH(U,$,q.knownCommands),sections:qH(U)}}function nU($){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 rU($,X,Z){let q=GH($),z=Y2(Z),G=nU(Z),J=new Set,Q=/`([^`\n]{2,200})`/g,Y;Y=Q.exec(q);while(Y!==null){let U=Y[1].trim().replace(/[#?].*$/,"");if(zH(U)&&!oU(X,U,z,G).found)J.add(U);Y=Q.exec(q)}return[...J].sort()}function oU($,X,Z,q){let z=[X];if(Z&&Z!==".")z.push(`${Z}/${X}`);if(q)z.push(`${q}/${X}`);z.push(`packages/${X}`,`apps/${X}`,`shared/${X}`);for(let G of z){let J=G.replace(/\/+/g,"/");if(z$(`${$}/${J}`))return{found:!0,resolvedAs:J}}return{found:!1}}function tU($,X){let Z=new Set,q=/@([\w./@~-]+\.md)/g,z;z=q.exec($);while(z!==null){let G=z[1];if(G.startsWith("~/")){z=q.exec($);continue}let J=G.startsWith("/")?G:L4(X,G);if(!z$(J))Z.add(G);z=q.exec($)}return[...Z].sort()}var eU=["bun","pnpm","npm","yarn"],$H=new Set(["install","add","remove","update","i","audit","list","ls","why","outdated","exec","run","create","init","x"]),XH={bun:new Set(["build","test","link","unlink","upgrade"])};function ZH($,X,Z){let q=new Set,z=w4(X,"package.json"),G=new Set;if(z$(z))try{let Q=JSON.parse(Q2(z,"utf8"));G=new Set(Object.keys(Q.scripts??{}))}catch{}let J=new Set(Z.map((Q)=>Q.trim()));for(let Q of eU){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(!G.has(W)&&!J.has(`${Q} ${W}`)&&!J.has(`${Q} run ${W}`)&&!$H.has(W)&&!XH[Q]?.has(W))q.add(`${Q} ${W}`);U=Y.exec($)}}return[...q].sort()}function qH($){let X=$.split(`
|
|
189
|
+
`),Z=[],q=null;if(X.forEach((z,G)=>{if(/^##\s+/.test(z)){if(q)Z.push({header:q.header,lines:G-q.start});q={header:z.replace(/^##\s+/,"").trim(),start:G}}}),q){let z=q;Z.push({header:z.header,lines:X.length-z.start})}return Z.sort((z,G)=>G.lines-z.lines)}function zH($){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 JH($,X){let Z=new Map;for(let G of $){let J=G.relPath.split("/").pop()??"";if(J!=="AGENTS.md"&&J!=="CLAUDE.md")continue;let Q=Y2(G.relPath),Y=Z.get(Q)??{};if(J==="AGENTS.md")Y.agents=G;if(J==="CLAUDE.md")Y.claude=G;Z.set(Q,Y)}let q=new Set(X.intentionalDifferentPairs),z=[];for(let[G,J]of Z){let Q=!!J.agents,Y=!!J.claude;if(!Q&&!Y)continue;if(!Q||!Y){z.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"single",detail:Q?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:U,claude:W}=J,H=`${U.relPath}:${W.relPath}`,V=`${W.relPath}:${U.relPath}`;if(q.has(H)||q.has(V)){z.push({dir:G,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 L=U.isSymlink?"CLAUDE.md":"AGENTS.md";z.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"linked",detail:`canonical: ${L}`});continue}let B=Q2(U.absPath,"utf8"),T=Q2(W.absPath,"utf8");if(B===T)z.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${U.lineCount}L), not symlinked`});else z.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`divergent (${U.lineCount}L vs ${W.lineCount}L), not in intentional-different allowlist`})}return z.sort((G,J)=>G.dir.localeCompare(J.dir)),z}function QH($,X,Z){let q=[];for(let z of $){if(z.isSymlink)continue;for(let Q of z.brokenImports)q.push({severity:"error",category:"broken-import",file:z.relPath,message:`broken @-import: ${Q}`});for(let Q of z.brokenPathRefs)q.push({severity:"error",category:"broken-path-ref",file:z.relPath,message:`broken path reference: ${Q}`});for(let Q of z.unresolvedCommands)q.push({severity:"warning",category:"unresolved-command",file:z.relPath,message:`unresolved command: ${Q}`});let G=!z.relPath.includes("/"),J=G?Z.budgets.rootLines:Z.budgets.nestedWarnLines;if(z.lineCount>J)q.push({severity:"warning",category:"over-budget",file:z.relPath,message:`${z.lineCount} lines exceeds ${G?"root":"nested"} budget of ${J}`})}for(let z of X)if(z.classification==="unexpected-duplicate"){let G=z.detail.startsWith("divergent")?"error":"warning";q.push({severity:G,category:G==="error"?"divergent-pair":"duplicate-pair",file:z.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${z.detail}`})}return q}function k0($){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 B4($){let X=YH($);if(X===null)return[];let Z=[],q=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,z=q.exec(X);while(z!==null)Z.push({id:z[1].trim(),note:z[2].trim()||void 0}),z=q.exec(X);return Z}function YH($){let Z=/^##\s+Sources\s*$/im.exec($);if(!Z)return null;let q=Z.index+Z[0].length,z=$.slice(q),G=/^##\s+/m.exec(z);return G?z.slice(0,G.index):z}function l$($){let X=B4($.response),Z=new Set(X.map((V)=>V.id)),q=new Set($.registeredIds),z=new Set($.requiredSources),G=[...Z],J=[...z].filter((V)=>!Z.has(V)),Q=[...Z].filter((V)=>!q.has(V)),Y=[...z],U,W,H;if(G.length===0)U="NO",W=0,H="No citations in response";else if(Q.length===G.length)U="NO",W=0,H=`All cited sources are unknown: ${Q.join(", ")}`;else if(J.length===0&&Q.length===0)U="YES",W=100,H=Y.length>0?`All required sources cited: ${Y.join(", ")}`:`Cited registered sources: ${G.join(", ")}`;else{U="PARTIAL";let V=Y.length>0?Y.length:1,w=Y.length-J.length,B=Y.length>0?w/V*100:60,T=Q.length*15;W=Math.max(0,Math.min(100,Math.round(B-T)));let L=[];if(J.length>0)L.push(`missing: ${J.join(", ")}`);if(Q.length>0)L.push(`unknown: ${Q.join(", ")}`);H=L.join("; ")}return{answerable:U,confidence:W,reason:H,citations:{cited:G,required:Y,missing:J,unknown:Q}}}var g0="0.40.1";var C8=!1,h0=void 0,K4=void 0,UH=void 0,HH=void 0,WH=void 0,b8=void 0,VH=void 0,H2=void 0,D4=void 0,y8=void 0,_4=void 0,W2=void 0,x8=void 0;function f8($,X={auto:!1}){if(C8)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}'\``);C8=X.auto,h0=$.kind,K4=$.fetch,UH=$.Request,HH=$.Response,WH=$.Headers,b8=$.FormData,VH=$.Blob,H2=$.File,D4=$.ReadableStream,y8=$.getMultipartRequestOptions,_4=$.getDefaultAgent,W2=$.fileFromPath,x8=$.isFsReadStream}class F4{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function k8({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,q,z,G;try{Z=fetch,q=Request,z=Response,G=Headers}catch(J){throw Error(`this environment is missing the following Web Fetch API type: ${J.message}. ${X}`)}return{kind:"web",fetch:Z,Request:q,Response:z,Headers:G,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(J,Q)=>({...Q,body:new F4(J)}),getDefaultAgent:(J)=>{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:(J)=>!1}}import{ReadStream as wH}from"fs";function g8(){let $=k8();function X(Z){return Z instanceof wH}return{...$,isFsReadStream:X}}var O4=()=>{if(!h0)f8(g8(),{auto:!0})};O4();class P extends Error{}class v extends P{constructor($,X,Z,q){super(`${v.makeMessage($,X,Z)}`);this.status=$,this.headers=q,this.request_id=q?.["request-id"],this.error=X}static makeMessage($,X,Z){let q=X?.message?typeof X.message==="string"?X.message:JSON.stringify(X.message):X?JSON.stringify(X):Z;if($&&q)return`${$} ${q}`;if($)return`${$} status code (no body)`;if(q)return q;return"(no status code or body)"}static generate($,X,Z,q){if(!$||!q)return new v0({message:Z,cause:F2(X)});let z=X;if($===400)return new V2($,z,Z,q);if($===401)return new T2($,z,Z,q);if($===403)return new w2($,z,Z,q);if($===404)return new L2($,z,Z,q);if($===409)return new B2($,z,Z,q);if($===422)return new K2($,z,Z,q);if($===429)return new D2($,z,Z,q);if($>=500)return new _2($,z,Z,q);return new v($,z,Z,q)}}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 w2 extends v{}class L2 extends v{}class B2 extends v{}class K2 extends v{}class D2 extends v{}class _2 extends v{}var O2=function($,X,Z,q,z){if(q==="m")throw TypeError("Private method is not writable");if(q==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return q==="a"?z.call($,Z):z?z.value=Z:X.set($,Z),Z},u0=function($,X,Z,q){if(Z==="a"&&!q)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?q:Z==="a"?q.call($):q?q.value:X.get($)},l;class R0{constructor(){l.set(this,void 0),this.buffer=new Uint8Array,O2(this,l,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 q=[],z;while((z=BH(this.buffer,u0(this,l,"f")))!=null){if(z.carriage&&u0(this,l,"f")==null){O2(this,l,z.index,"f");continue}if(u0(this,l,"f")!=null&&(z.index!==u0(this,l,"f")+1||z.carriage)){q.push(this.decodeText(this.buffer.slice(0,u0(this,l,"f")-1))),this.buffer=this.buffer.slice(u0(this,l,"f")),O2(this,l,null,"f");continue}let G=u0(this,l,"f")!==null?z.preceding-1:z.preceding,J=this.decodeText(this.buffer.slice(0,G));q.push(J),this.buffer=this.buffer.slice(z.index),O2(this,l,null,"f")}return q}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
|
+
`)}}l=new WeakMap;R0.NEWLINE_CHARS=new Set([`
|
|
191
|
+
`,"\r"]);R0.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function BH($,X){for(let z=X??0;z<$.length;z++){if($[z]===10)return{preceding:z,index:z+1,carriage:!1};if($[z]===13)return{preceding:z,index:z+1,carriage:!0}}return null}function h8($){for(let q=0;q<$.length-1;q++){if($[q]===10&&$[q+1]===10)return q+2;if($[q]===13&&$[q+1]===13)return q+2;if($[q]===13&&$[q+1]===10&&q+3<$.length&&$[q+2]===13&&$[q+3]===10)return q+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*q(){if(Z)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");Z=!0;let z=!1;try{for await(let G of KH($,X)){if(G.event==="completion")try{yield JSON.parse(G.data)}catch(J){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),J}if(G.event==="message_start"||G.event==="message_delta"||G.event==="message_stop"||G.event==="content_block_start"||G.event==="content_block_delta"||G.event==="content_block_stop")try{yield JSON.parse(G.data)}catch(J){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),J}if(G.event==="ping")continue;if(G.event==="error")throw v.generate(void 0,`SSE Error: ${G.data}`,G.data,M4($.headers))}z=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{if(!z)X.abort()}}return new i(q,X)}static fromReadableStream($,X){let Z=!1;async function*q(){let G=new R0,J=a$($);for await(let Q of J)for(let Y of G.decode(Q))yield Y;for(let Q of G.flush())yield Q}async function*z(){if(Z)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");Z=!0;let G=!1;try{for await(let J of q()){if(G)continue;if(J)yield JSON.parse(J)}G=!0}catch(J){if(J instanceof Error&&J.name==="AbortError")return;throw J}finally{if(!G)X.abort()}}return new i(z,X)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],X=[],Z=this.iterator(),q=(z)=>{return{next:()=>{if(z.length===0){let G=Z.next();$.push(G),X.push(G)}return z.shift()}}};return[new i(()=>q($),this.controller),new i(()=>q(X),this.controller)]}toReadableStream(){let $=this,X,Z=new TextEncoder;return new D4({async start(){X=$[Symbol.asyncIterator]()},async pull(q){try{let{value:z,done:G}=await X.next();if(G)return q.close();let J=Z.encode(JSON.stringify(z)+`
|
|
192
|
+
`);q.enqueue(J)}catch(z){q.error(z)}},async cancel(){await X.return?.()}})}}async function*KH($,X){if(!$.body)throw X.abort(),new P("Attempted to iterate over a response with no body");let Z=new v8,q=new R0,z=a$($.body);for await(let G of DH(z))for(let J of q.decode(G)){let Q=Z.decode(J);if(Q)yield Q}for(let G of q.flush()){let J=Z.decode(G);if(J)yield J}}async function*DH($){let X=new Uint8Array;for await(let Z of $){if(Z==null)continue;let q=Z instanceof ArrayBuffer?new Uint8Array(Z):typeof Z==="string"?new TextEncoder().encode(Z):Z,z=new Uint8Array(X.length+q.length);z.set(X),z.set(q,X.length),X=z;let G;while((G=h8(X))!==-1)yield X.slice(0,G),X=X.slice(G)}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 z={event:this.event,data:this.data.join(`
|
|
193
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],z}if(this.chunks.push($),$.startsWith(":"))return null;let[X,Z,q]=_H($,":");if(q.startsWith(" "))q=q.substring(1);if(X==="event")this.event=q;else if(X==="data")this.data.push(q);return null}}function _H($,X){let Z=$.indexOf(X);if(Z!==-1)return[$.substring(0,Z),X,$.substring(Z+X.length)];return[$,"",""]}var FH=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",OH=($)=>$!=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 $,OH($))return $;if(FH($)){let z=await $.blob();X||(X=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let G=s$(z)?[await z.arrayBuffer()]:[z];return new H2(G,X,Z)}let q=await MH($);if(X||(X=RH($)??"unknown_file"),!Z?.type){let z=q[0]?.type;if(typeof z==="string")Z={...Z,type:z}}return new H2(q,X,Z)}async function MH($){let X=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)X.push($);else if(s$($))X.push(await $.arrayBuffer());else if(PH($))for await(let Z of $)X.push(Z);else throw Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${IH($)}`);return X}function IH($){return`[${Object.getOwnPropertyNames($).map((Z)=>`"${Z}"`).join(", ")}]`}function RH($){return I4($.name)||I4($.filename)||I4($.path)?.split(/[\\/]/).pop()}var I4=($)=>{if(typeof $==="string")return $;if(typeof Buffer<"u"&&$ instanceof Buffer)return String($);return},PH=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",R4=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var AH=function($,X,Z,q,z){if(q==="m")throw TypeError("Private method is not writable");if(q==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return q==="a"?z.call($,Z):z?z.value=Z:X.set($,Z),Z},SH=function($,X,Z,q){if(Z==="a"&&!q)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?q:Z==="a"?q.call($):q?q.value:X.get($)},M2;O4();async function l8($){let{response:X}=$;if($.options.stream){if(G$("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 q=X.headers.get("content-type")?.split(";")[0]?.trim();if(q?.includes("application/json")||q?.endsWith("+json")){let J=await X.json();return G$("response",X.status,X.url,X.headers,J),i8(J,X)}let G=await X.text();return G$("response",X.status,X.url,X.headers,G),G}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=l8){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:q,fetch:z}){this.baseURL=$,this.maxRetries=P4("maxRetries",X),this.timeout=P4("timeout",Z),this.httpAgent=q,this.fetch=z??K4}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...bH(),...this.authHeaders($)}}validateHeaders($,X){}defaultIdempotencyKey(){return`stainless-node-retry-${gH()}`}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(q)=>{let z=q&&s$(q?.body)?new DataView(await q.body.arrayBuffer()):q?.body instanceof DataView?q.body:q?.body instanceof ArrayBuffer?new DataView(q.body):q&&ArrayBuffer.isView(q?.body)?new DataView(q.body.buffer):q?.body;return{method:$,path:X,...q,body:z}}))}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:q,path:z,query:G,headers:J={}}=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(z,G);if("timeout"in Z)P4("timeout",Z.timeout);Z.timeout=Z.timeout??this.timeout;let W=Z.httpAgent??this.httpAgent??_4(U),H=Z.timeout+1000;if(typeof W?.options?.timeout==="number"&&H>(W.options.timeout??0))W.options.timeout=H;if(this.idempotencyHeader&&q!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let V=this.buildHeaders({options:Z,headers:J,contentLength:Y,retryCount:X});return{req:{method:q,...Q&&{body:Q},headers:V,...W&&{agent:W},signal:Z.signal??null},url:U,timeout:Z.timeout}}buildHeaders({options:$,headers:X,contentLength:Z,retryCount:q}){let z={};if(Z)z["content-length"]=Z;let G=this.defaultHeaders($);if(c8(z,G),c8(z,X),R4($.body)&&h0!=="node")delete z["content-type"];if(I2(G,"x-stainless-retry-count")===void 0&&I2(X,"x-stainless-retry-count")===void 0)z["x-stainless-retry-count"]=String(q);if(I2(G,"x-stainless-timeout")===void 0&&I2(X,"x-stainless-timeout")===void 0&&$.timeout)z["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(z,X),z}_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,q){return v.generate($,X,Z,q)}request($,X=null){return new R2(this.makeRequest($,X))}async makeRequest($,X){let Z=await $,q=Z.maxRetries??this.maxRetries;if(X==null)X=q;await this.prepareOptions(Z);let{req:z,url:G,timeout:J}=this.buildRequest(Z,{retryCount:q-X});if(await this.prepareRequest(z,{url:G,options:Z}),G$("request",G,Z,z.headers),Z.signal?.aborted)throw new m;let Q=new AbortController,Y=await this.fetchWithTimeout(G,z,J,Q).catch(F2);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=M4(Y.headers);if(!Y.ok){if(X&&this.shouldRetry(Y)){let T=`retrying, ${X} attempts remaining`;return G$(`response (error; ${T})`,Y.status,G,U),this.retryRequest(Z,X,U)}let W=await Y.text().catch((T)=>F2(T).message),H=yH(W),V=H?void 0:W;throw G$(`response (error; ${X?"(error; no more retries left)":"(error; not retryable)"})`,Y.status,G,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):$)),q=this.defaultQuery();if(!s8(q))X={...q,...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,q){let{signal:z,...G}=X||{};if(z)z.addEventListener("abort",()=>q.abort());let J=setTimeout(()=>q.abort(),Z),Q={signal:q.signal,...G};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(J),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 q,z=Z?.["retry-after-ms"];if(z){let J=parseFloat(z);if(!Number.isNaN(J))q=J}let G=Z?.["retry-after"];if(G&&!q){let J=parseFloat(G);if(!Number.isNaN(J))q=J*1000;else q=Date.parse(G)-Date.now()}if(!(q&&0<=q&&q<60000)){let J=$.maxRetries??this.maxRetries;q=this.calculateDefaultRetryTimeoutMillis(X,J)}return await kH(q),this.makeRequest($,X-1)}calculateDefaultRetryTimeoutMillis($,X){let z=X-$,G=Math.min(0.5*Math.pow(2,z),8),J=1-Math.random()*0.25;return G*J*1000}getUserAgent(){return`${this.constructor.name}/JS ${g0}`}}class A4{constructor($,X,Z,q){M2.set(this,void 0),AH(this,M2,$,"f"),this.options=q,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[q,z]of Z)$.url.searchParams.set(q,z);X.query=void 0,X.path=$.url.toString()}return await SH(this,M2,"f").requestAPIList(this.constructor,X)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(M2=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(q)=>new Z($,q.response,await l8(q),q.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let X of $)yield X}}var M4=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(X,Z){let q=Z.toString();return X[q.toLowerCase()]||X[q]}})},jH={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(jH,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 $=CH();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 CH(){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 q=Z.exec(navigator.userAgent);if(q){let z=q[1]||0,G=q[2]||0,J=q[3]||0;return{browser:X,version:`${z}.${G}.${J}`}}}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,bH=()=>{return p8??(p8=EH())},yH=($)=>{try{return JSON.parse($)}catch(X){return}},xH=/^[a-z][a-z0-9+.-]*:/i,fH=($)=>{return xH.test($)},kH=($)=>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},F2=($)=>{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 c8($,X){for(let Z in X){if(!n8(X,Z))continue;let q=Z.toLowerCase();if(!q)continue;let z=X[Z];if(z===null)delete $[q];else if(z!==void 0)$[q]=z}}function G$($,...X){if(typeof process<"u"&&process?.env?.DEBUG==="true")console.log(`Anthropic:DEBUG:${$}`,...X)}var gH=()=>{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"},hH=($)=>{return typeof $?.get==="function"};var I2=($,X)=>{let Z=X.toLowerCase();if(hH($)){let q=X[0]?.toUpperCase()+X.substring(1).replace(/([^\w])(\w)/g,(z,G,J)=>G+J.toUpperCase());for(let z of[X,Z,X.toUpperCase(),q]){let G=$.get(z);if(G)return G}}for(let[q,z]of Object.entries($))if(q.toLowerCase()===Z){if(Array.isArray(z)){if(z.length<=1)return z[0];return console.warn(`Received ${z.length} entries for the ${X} header, using the first entry.`),z[0]}return z}return};class W0 extends A4{constructor($,X,Z,q){super($,X,Z,q);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 J$ 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{}J$.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,...q}=$;return this._client.post("/v1/messages/batches?beta=true",{body:q,...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:q}=X;return this._client.get(`/v1/messages/batches/${$}?beta=true`,{...Z,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}list($={},X){if(r($))return this.list({},$);let{betas:Z,...q}=$;return this._client.getAPIList("/v1/messages/batches?beta=true",r$,{query:q,...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:q}=X;return this._client.delete(`/v1/messages/batches/${$}?beta=true`,{...Z,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}cancel($,X={},Z){if(r(X))return this.cancel($,{},X);let{betas:q}=X;return this._client.post(`/v1/messages/batches/${$}/cancel?beta=true`,{...Z,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}async results($,X={},Z){if(r(X))return this.results($,{},X);let q=await this.retrieve($);if(!q.results_url)throw new P(`No batch \`results_url\`; Has it finished processing? ${q.processing_status} - ${q.id}`);let{betas:z}=X;return this._client.get(q.results_url,{...Z,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...Z?.headers},stream:!0,__binaryResponse:!0})._thenUnwrap((G,J)=>Q$.fromResponse(J.response,J.controller))}}class r$ extends W0{}Y$.BetaMessageBatchesPage=r$;var dH=($)=>{let X=0,Z=[];while(X<$.length){let q=$[X];if(q==="\\"){X++;continue}if(q==="{"){Z.push({type:"brace",value:"{"}),X++;continue}if(q==="}"){Z.push({type:"brace",value:"}"}),X++;continue}if(q==="["){Z.push({type:"paren",value:"["}),X++;continue}if(q==="]"){Z.push({type:"paren",value:"]"}),X++;continue}if(q===":"){Z.push({type:"separator",value:":"}),X++;continue}if(q===","){Z.push({type:"delimiter",value:","}),X++;continue}if(q==='"'){let Q="",Y=!1;q=$[++X];while(q!=='"'){if(X===$.length){Y=!0;break}if(q==="\\"){if(X++,X===$.length){Y=!0;break}Q+=q+$[X],q=$[++X]}else Q+=q,q=$[++X]}if(q=$[++X],!Y)Z.push({type:"string",value:Q});continue}if(q&&/\s/.test(q)){X++;continue}let G=/[0-9]/;if(q&&G.test(q)||q==="-"||q==="."){let Q="";if(q==="-")Q+=q,q=$[++X];while(q&&G.test(q)||q===".")Q+=q,q=$[++X];Z.push({type:"number",value:Q});continue}let J=/[a-z]/i;if(q&&J.test(q)){let Q="";while(q&&J.test(q)){if(X===$.length)break;Q+=q,q=$[++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 q=$[$.length-2];if(q?.type==="delimiter")return $=$.slice(0,$.length-1),U$($);else if(q?.type==="brace"&&q.value==="{")return $=$.slice(0,$.length-1),U$($);break;case"delimiter":return $=$.slice(0,$.length-1),U$($);break}return $},pH=($)=>{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(pH(U$(dH($)))));var d=function($,X,Z,q,z){if(q==="m")throw TypeError("Private method is not writable");if(q==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return q==="a"?z.call($,Z):z?z.value=Z:X.set($,Z),Z},A=function($,X,Z,q){if(Z==="a"&&!q)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?q:Z==="a"?q.call($):q?q.value:X.get($)},o,P0,o$,A2,t$,e$,S2,$1,V0,X1,j2,E2,H$,C2,b2,S4,o8,j4,E4,C4,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),S2.set(this,()=>{}),$1.set(this,()=>{}),V0.set(this,{}),X1.set(this,!1),j2.set(this,!1),E2.set(this,!1),H$.set(this,!1),C2.set(this,void 0),b2.set(this,void 0),j4.set(this,($)=>{if(d(this,j2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new m;if($ instanceof m)return d(this,E2,!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,S2,$,"f"),d(this,$1,X,"f")}),"f"),A(this,o$,"f").catch(()=>{}),A(this,e$,"f").catch(()=>{})}get response(){return A(this,C2,"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 q=new Z1;for(let z of X.messages)q._addMessageParam(z);return q._run(()=>q._createMessage($,{...X,stream:!0},{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"stream"}})),q}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},A(this,j4,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,X=!0){if(this.receivedMessages.push($),X)this._emit("message",$)}async _createMessage($,X,Z){let q=Z?.signal;if(q){if(q.aborted)this.controller.abort();q.addEventListener("abort",()=>this.controller.abort())}A(this,o,"m",E4).call(this);let{response:z,data:G}=await $.create({...X,stream:!0},{...Z,signal:this.controller.signal}).withResponse();this._connected(z);for await(let J of G)A(this,o,"m",C4).call(this,J);if(G.controller.signal?.aborted)throw new m;A(this,o,"m",b4).call(this)}_connected($){if(this.ended)return;d(this,C2,$,"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,j2,"f")}get aborted(){return A(this,E2,"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 q=Z.findIndex((z)=>z.listener===X);if(q>=0)Z.splice(q,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",S4).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,S2,"f").call(this);let Z=A(this,V0,"f")[$];if(Z)A(this,V0,"f")[$]=Z.filter((q)=>!q.once),Z.forEach(({listener:q})=>q(...X));if($==="abort"){let q=X[0];if(!A(this,H$,"f")&&!Z?.length)Promise.reject(q);A(this,t$,"f").call(this,q),A(this,$1,"f").call(this,q),this._emit("end");return}if($==="error"){let q=X[0];if(!A(this,H$,"f")&&!Z?.length)Promise.reject(q);A(this,t$,"f").call(this,q),A(this,$1,"f").call(this,q),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",A(this,o,"m",S4).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",E4).call(this),this._connected(null);let q=i.fromReadableStream($,this.controller);for await(let z of q)A(this,o,"m",C4).call(this,z);if(q.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,S2=new WeakMap,$1=new WeakMap,V0=new WeakMap,X1=new WeakMap,j2=new WeakMap,E2=new WeakMap,H$=new WeakMap,C2=new WeakMap,b2=new WeakMap,j4=new WeakMap,o=new WeakSet,S4=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(" ")},E4=function(){if(this.ended)return;d(this,P0,void 0,"f")},C4=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 q=Z.content.at(-1);switch(X.delta.type){case"text_delta":{if(q.type==="text")this._emit("text",X.delta.text,q.text||"");break}case"citations_delta":{if(q.type==="text")this._emit("citation",X.delta.citation,q.citations??[]);break}case"input_json_delta":{if(q.type==="tool_use"&&q.input)this._emit("inputJson",X.delta.partial_json,q.input);break}case"thinking_delta":{if(q.type==="thinking")this._emit("thinking",X.delta.thinking,q.thinking);break}case"signature_delta":{if(q.type==="thinking")this._emit("signature",q.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 q=Z.content.at(X.index);switch(X.delta.type){case"text_delta":{if(q?.type==="text")q.text+=X.delta.text;break}case"citations_delta":{if(q?.type==="text")q.citations??(q.citations=[]),q.citations.push(X.delta.citation);break}case"input_json_delta":{if(q?.type==="tool_use"){let z=q[e8]||"";if(z+=X.delta.partial_json,Object.defineProperty(q,e8,{value:z,enumerable:!1,writable:!0}),z)q.input=N2(z)}break}case"thinking_delta":{if(q?.type==="thinking")q.thinking+=X.delta.thinking;break}case"signature_delta":{if(q?.type==="thinking")q.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",(q)=>{let z=X.shift();if(z)z.resolve(q);else $.push(q)}),this.on("end",()=>{Z=!0;for(let q of X)q.resolve(void 0);X.length=0}),this.on("abort",(q)=>{Z=!0;for(let z of X)z.reject(q);X.length=0}),this.on("error",(q)=>{Z=!0;for(let z of X)z.reject(q);X.length=0}),{next:async()=>{if(!$.length){if(Z)return{value:void 0,done:!0};return new Promise((z,G)=>X.push({resolve:z,reject:G})).then((z)=>z?{value:z,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,...q}=$;if(q.model in XZ)console.warn(`The model '${q.model}' is deprecated and will reach end-of-life on ${XZ[q.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:q,timeout:this._client._options.timeout??(q.stream?600000:this._client._calculateNonstreamingTimeout(q.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,...q}=$;return this._client.post("/v1/messages/count_tokens?beta=true",{body:q,...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 J$(this._client),this.messages=new m0(this._client)}}T0.Models=J$;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",q1,{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((q,z)=>Q$.fromResponse(z.response,z.controller))}}class q1 extends W0{}V$.MessageBatchesPage=q1;var p=function($,X,Z,q,z){if(q==="m")throw TypeError("Private method is not writable");if(q==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!z:!X.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return q==="a"?z.call($,Z):z?z.value=Z:X.set($,Z),Z},S=function($,X,Z,q){if(Z==="a"&&!q)throw TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!q:!X.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return Z==="m"?q:Z==="a"?q.call($):q?q.value:X.get($)},t,N0,z1,y2,G1,J1,x2,Q1,w0,Y1,f2,k2,T$,g2,h2,y4,ZZ,x4,f4,k4,g4,qZ,zZ="__json_buf";class U1{constructor(){t.add(this),this.messages=[],this.receivedMessages=[],N0.set(this,void 0),this.controller=new AbortController,z1.set(this,void 0),y2.set(this,()=>{}),G1.set(this,()=>{}),J1.set(this,void 0),x2.set(this,()=>{}),Q1.set(this,()=>{}),w0.set(this,{}),Y1.set(this,!1),f2.set(this,!1),k2.set(this,!1),T$.set(this,!1),g2.set(this,void 0),h2.set(this,void 0),x4.set(this,($)=>{if(p(this,f2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new m;if($ instanceof m)return p(this,k2,!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,z1,new Promise(($,X)=>{p(this,y2,$,"f"),p(this,G1,X,"f")}),"f"),p(this,J1,new Promise(($,X)=>{p(this,x2,$,"f"),p(this,Q1,X,"f")}),"f"),S(this,z1,"f").catch(()=>{}),S(this,J1,"f").catch(()=>{})}get response(){return S(this,g2,"f")}get request_id(){return S(this,h2,"f")}async withResponse(){let $=await S(this,z1,"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 q=new U1;for(let z of X.messages)q._addMessageParam(z);return q._run(()=>q._createMessage($,{...X,stream:!0},{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"stream"}})),q}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},S(this,x4,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,X=!0){if(this.receivedMessages.push($),X)this._emit("message",$)}async _createMessage($,X,Z){let q=Z?.signal;if(q){if(q.aborted)this.controller.abort();q.addEventListener("abort",()=>this.controller.abort())}S(this,t,"m",f4).call(this);let{response:z,data:G}=await $.create({...X,stream:!0},{...Z,signal:this.controller.signal}).withResponse();this._connected(z);for await(let J of G)S(this,t,"m",k4).call(this,J);if(G.controller.signal?.aborted)throw new m;S(this,t,"m",g4).call(this)}_connected($){if(this.ended)return;p(this,g2,$,"f"),p(this,h2,$?.headers.get("request-id"),"f"),S(this,y2,"f").call(this,$),this._emit("connect")}get ended(){return S(this,Y1,"f")}get errored(){return S(this,f2,"f")}get aborted(){return S(this,k2,"f")}abort(){this.controller.abort()}on($,X){return(S(this,w0,"f")[$]||(S(this,w0,"f")[$]=[])).push({listener:X}),this}off($,X){let Z=S(this,w0,"f")[$];if(!Z)return this;let q=Z.findIndex((z)=>z.listener===X);if(q>=0)Z.splice(q,1);return this}once($,X){return(S(this,w0,"f")[$]||(S(this,w0,"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 S(this,J1,"f")}get currentMessage(){return S(this,N0,"f")}async finalMessage(){return await this.done(),S(this,t,"m",y4).call(this)}async finalText(){return await this.done(),S(this,t,"m",ZZ).call(this)}_emit($,...X){if(S(this,Y1,"f"))return;if($==="end")p(this,Y1,!0,"f"),S(this,x2,"f").call(this);let Z=S(this,w0,"f")[$];if(Z)S(this,w0,"f")[$]=Z.filter((q)=>!q.once),Z.forEach(({listener:q})=>q(...X));if($==="abort"){let q=X[0];if(!S(this,T$,"f")&&!Z?.length)Promise.reject(q);S(this,G1,"f").call(this,q),S(this,Q1,"f").call(this,q),this._emit("end");return}if($==="error"){let q=X[0];if(!S(this,T$,"f")&&!Z?.length)Promise.reject(q);S(this,G1,"f").call(this,q),S(this,Q1,"f").call(this,q),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",S(this,t,"m",y4).call(this))}async _fromReadableStream($,X){let Z=X?.signal;if(Z){if(Z.aborted)this.controller.abort();Z.addEventListener("abort",()=>this.controller.abort())}S(this,t,"m",f4).call(this),this._connected(null);let q=i.fromReadableStream($,this.controller);for await(let z of q)S(this,t,"m",k4).call(this,z);if(q.controller.signal?.aborted)throw new m;S(this,t,"m",g4).call(this)}[(N0=new WeakMap,z1=new WeakMap,y2=new WeakMap,G1=new WeakMap,J1=new WeakMap,x2=new WeakMap,Q1=new WeakMap,w0=new WeakMap,Y1=new WeakMap,f2=new WeakMap,k2=new WeakMap,T$=new WeakMap,g2=new WeakMap,h2=new WeakMap,x4=new WeakMap,t=new WeakSet,y4=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(" ")},f4=function(){if(this.ended)return;p(this,N0,void 0,"f")},k4=function(X){if(this.ended)return;let Z=S(this,t,"m",qZ).call(this,X);switch(this._emit("streamEvent",X,Z),X.type){case"content_block_delta":{let q=Z.content.at(-1);switch(X.delta.type){case"text_delta":{if(q.type==="text")this._emit("text",X.delta.text,q.text||"");break}case"citations_delta":{if(q.type==="text")this._emit("citation",X.delta.citation,q.citations??[]);break}case"input_json_delta":{if(q.type==="tool_use"&&q.input)this._emit("inputJson",X.delta.partial_json,q.input);break}case"thinking_delta":{if(q.type==="thinking")this._emit("thinking",X.delta.thinking,q.thinking);break}case"signature_delta":{if(q.type==="thinking")this._emit("signature",q.signature);break}default:GZ(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=S(this,N0,"f");if(!X)throw new P("request ended without sending any chunks");return p(this,N0,void 0,"f"),X},qZ=function(X){let Z=S(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 q=Z.content.at(X.index);switch(X.delta.type){case"text_delta":{if(q?.type==="text")q.text+=X.delta.text;break}case"citations_delta":{if(q?.type==="text")q.citations??(q.citations=[]),q.citations.push(X.delta.citation);break}case"input_json_delta":{if(q?.type==="tool_use"){let z=q[zZ]||"";if(z+=X.delta.partial_json,Object.defineProperty(q,zZ,{value:z,enumerable:!1,writable:!0}),z)q.input=N2(z)}break}case"thinking_delta":{if(q?.type==="thinking")q.thinking+=X.delta.thinking;break}case"signature_delta":{if(q?.type==="thinking")q.signature=X.delta.signature;break}default:GZ(X.delta)}return Z}case"content_block_stop":return Z}},Symbol.asyncIterator)](){let $=[],X=[],Z=!1;return this.on("streamEvent",(q)=>{let z=X.shift();if(z)z.resolve(q);else $.push(q)}),this.on("end",()=>{Z=!0;for(let q of X)q.resolve(void 0);X.length=0}),this.on("abort",(q)=>{Z=!0;for(let z of X)z.reject(q);X.length=0}),this.on("error",(q)=>{Z=!0;for(let z of X)z.reject(q);X.length=0}),{next:async()=>{if(!$.length){if(Z)return{value:void 0,done:!0};return new Promise((z,G)=>X.push({resolve:z,reject:G})).then((z)=>z?{value:z,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 GZ($){}class A0 extends u{constructor(){super(...arguments);this.batches=new V$(this._client)}create($,X){if($.model in JZ)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${JZ[$.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 JZ={"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=q1;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",w$,{query:$,...X})}}class w$ extends W0{}d0.ModelInfosPage=w$;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,...q}={}){let z={apiKey:X,authToken:Z,...q,baseURL:$||"https://api.anthropic.com"};if(!z.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:z.baseURL,timeout:z.timeout??600000,httpAgent:z.httpAgent,maxRetries:z.maxRetries,fetch:z.fetch});this.completions=new W$(this),this.messages=new A0(this),this.models=new d0(this),this.beta=new T0(this),this._options=z,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=L2;b.ConflictError=B2;b.RateLimitError=D2;b.BadRequestError=V2;b.AuthenticationError=T2;b.InternalServerError=_2;b.PermissionDeniedError=w2;b.UnprocessableEntityError=K2;b.toFile=u8;b.fileFromPath=W2;b.Completions=W$;b.Messages=A0;b.Models=d0;b.ModelInfosPage=w$;b.Beta=T0;var YZ=b;function L$($,X,Z){let q=X.length>0?X.map((J)=>`- ${J.id}: ${J.name} (${J.source})`).join(`
|
|
207
|
+
`):"(no sources provided)",z=X.map((J)=>`<source id="${J.id}">
|
|
208
|
+
${J.content.trimEnd()}
|
|
192
209
|
</source>`).join(`
|
|
193
210
|
|
|
194
|
-
`),
|
|
211
|
+
`),G=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
|
+
${q}
|
|
200
217
|
|
|
201
|
-
${
|
|
218
|
+
${z}
|
|
202
219
|
|
|
203
|
-
${
|
|
220
|
+
${G}
|
|
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:q,requiredSources:z}=X;if(!this.config.model)throw Error(`API target "${this.name}" missing 'model'. API targets must declare an explicit model.`);let G=L$(Z,q,z),Q=await this.clientFactory().messages.create({model:this.config.model,max_tokens:this.config.maxTokens??4096,temperature:this.config.temperature??0,system:G,messages:[{role:"user",content:$}]}),Y=sH(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 sH($){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 nH}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:q,context:z,docs:G,requiredSources:J}=X,Q=[],Y=[],U=L$(Z,G,J),W={cwd:q,model:this.config.model??"sonnet",systemPrompt:U,allowedTools:z?.allowedTools??this.config.allowedTools??t2,disallowedTools:z?.disallowedTools??this.config.disallowedTools??e2,permissionMode:this.config.permissionMode??"acceptEdits",maxTurns:this.config.maxTurns??10,maxThinkingTokens:this.config.maxThinkingTokens,maxBudgetUsd:this.config.maxBudgetUsd,mcpServers:z?.mcpServers??this.config.mcpServers,settingSources:[]},H=[],V="",w="";for await(let B of nH({prompt:$,options:W})){if(B.type==="assistant"){let T=B.message?.content;if(Array.isArray(T)){let L="";for(let D of T){if(D.type==="text")L+=D.text;if(D.type==="tool_use"){let _=D;if(!Q.includes(_.name))Q.push(_.name)}}if(L){let D=H.length===0?"initial":"intermediate";H.push({type:D,text:L}),V=L}}}if(B.type==="result"){let T=B;if(T.result)w=T.result}}if(H.length>0)H[H.length-1].type="final";return{response:w||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 rH}from"crypto";import{rm as oH}from"fs/promises";import{tmpdir as tH}from"os";import{join as eH}from"path";var $W="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??zW,this.readFileFn=Z.readFile??GW,this.binary=Z.binary??$W}async run($,X){let{tool:Z,cwd:q,docs:z,requiredSources:G}=X,J=this.config.model;if(!J)throw Error(`CodexCliTarget "${this.name}" requires an explicit model. Validation should have caught this at config load.`);let Y=`${L$(Z,z,G)}
|
|
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=eH(tH(),`pickled-codex-${rH()}.txt`),W=["--ask-for-approval","never","exec","--json","--sandbox","read-only","--ignore-user-config","--ignore-rules","--ephemeral","--skip-git-repo-check","--cd",q,"--model",J,"--output-last-message",U,"-"];try{let H=await this.spawnFn(this.binary,W,{cwd:q,stdin:Y}),{allResponses:V,toolsUsed:w}=XW(H.stdout);if(H.exitCode!==0)throw Error(`codex exec failed (exit ${H.exitCode}): ${H.stderr.trim()||"no stderr output"}`);let B="";try{B=(await this.readFileFn(U)).trim()}catch{B=V.length>0?V[V.length-1].text:""}if(V.length>0)V[V.length-1].type="final";return{response:B,allResponses:V,toolsUsed:w,sources:[],metadata:{model:J,category:this.category,provider:this.provider,target:this.name}}}finally{await oH(U,{force:!0})}}}function XW($){let X=[],Z=[];for(let q of $.split(`
|
|
236
|
+
`)){let z=q.trim();if(!z)continue;let G;try{G=JSON.parse(z)}catch{continue}let J=ZW(G);if(J){let Y=X.length===0?"initial":"intermediate";X.push({type:Y,text:J})}let Q=qW(G);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 zW=async($,X,Z)=>{let q=Bun.spawn([$,...X],{cwd:Z.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});q.stdin.write(Z.stdin),await q.stdin.end();let[z,G,J]=await Promise.all([new Response(q.stdout).text(),new Response(q.stderr).text(),q.exited]);return{exitCode:J,stdout:z,stderr:G}},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??z0;switch(Z.category){case"cli":return JW($,Z);case"api":return QW($,Z);case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${Z.category}`)}}function JW($,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 QW($,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 B$="default";function d4($,X){if(!$||$===B$)return{name:B$,config:z0};if(X?.[$])return{name:$,config:X[$]};return console.warn(`Target "${$}" not found, using default`),{name:B$,config:z0}}function UZ($,X){if(!$||$===B$)return{name:B$,config:{}};if(X?.[$])return{name:$,config:X[$]};return console.warn(`Context "${$}" not found, using default`),{name:B$,config:{}}}function YW($){let X=[],Z=$.matrix?.target??["default"],q=$.matrix?.context??["default"];for(let z of $.scenarios){let G=z.target?[z.target]:Z,J=z.context?[z.context]:q;for(let Q of G)for(let Y of J)X.push({scenario:z,targetName:Q,contextName:Y})}return X}async function p4($,X,Z={}){let{onProgress:q}=Z,z=[];if(X.scenarios.length===0)throw Error("No scenarios defined in config");let G=X.docs?.sources??{},J=[];if(Object.keys(G).length>0){q?.("Loading sources..."),J=await c$(G,$.path);for(let W of J)q?.(` [${W.id}] ${W.name}`);q?.("")}let Q=J.map((W)=>W.id),Y=YW(X),U="";for(let{scenario:W,targetName:H,contextName:V}of Y){let w=UW(H,V);if(W.name!==U){if(U)q?.("");q?.(`"${W.name}"`),U=W.name}try{let B=await HW(W,H,V,$,X,J,Q,Z);z.push(B);let T=w?w.padEnd(18):"";if(B.surfaces){q?.(` ${T} (compare-surfaces mode)`);for(let L of B.surfaces){let D=k0(L),_=` [${L.active.join(",")}]`.padEnd(22);q?.(`${_} ${D.icon} ${D.label} (${D.confidence}%)`)}}else{let L=k0({answerable:B.answerable??"NO",confidence:B.confidence??0,traps:B.traps??{fired:[],avoided:[]},error:B.error});q?.(` ${T} ${L.icon} ${L.label} (${L.confidence}%)`)}}catch(B){let T=H==="default"?z0:X.targets?.[H]??z0,L={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((_)=>_.id)},error:B instanceof Error?B.message:String(B),target:{target:H,category:T.category,provider:T.provider,model:T.model??"unknown"},context:{name:V}};z.push(L);let D=w?w.padEnd(18):"";q?.(` ${D} \u2717 Error`)}}return q?.(""),WW($,J,z)}function UW($,X){if($==="default"&&X==="default")return"";if(X==="default")return`[${$}]`;return`[${$}/${X}]`}async function HW($,X,Z,q,z,G,J,Q){let{config:Y}=d4(X,z.targets),{config:U}=UZ(Z,z.contexts),W=Q.targetFactory?Q.targetFactory(X,Y):m4(X,Y);if($.compareSurfaces&&$.compareSurfaces.length>0){let _=[],O;for(let I of $.compareSurfaces){let R=new Set(I),N=G.filter((p0)=>R.has(p0.id)),C=$.requiredSources.filter((p0)=>R.has(p0)),F=await W.run($.prompt,{tool:q,cwd:q.path,context:U,docs:N,requiredSources:C,onProgress:Q.onProgress}),y=l$({response:F.response,requiredSources:C,registeredIds:I}),a=f0({response:F.response,traps:$.traps??[]}),q0=a.fired.length>0,k=q0?"NO":y.answerable,V1=q0?0:y.confidence,bZ=q0?`Trap fired: ${a.fired.map((p0)=>`"${p0.id}" (${p0.reason})`).join("; ")}`:y.reason;_.push({active:I,answerable:k,confidence:V1,response:F.response,reason:bZ,citations:y.citations,traps:a,allResponses:F.allResponses}),O=F.metadata??O}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:_,target:O,context:{name:Z}}}let H=await W.run($.prompt,{tool:q,cwd:q.path,context:U,docs:G,requiredSources:$.requiredSources,onProgress:Q.onProgress}),V=l$({response:H.response,requiredSources:$.requiredSources,registeredIds:J}),w=f0({response:H.response,traps:$.traps??[]}),B=w.fired.length>0,T=B?"NO":V.answerable,L=B?0:V.confidence,D=B?`Trap fired: ${w.fired.map((_)=>`"${_.id}" (${_.reason})`).join("; ")}`:V.reason;return{scenario:$,answerable:T,confidence:L,response:H.response,reason:D,citations:V.citations,traps:w,target:H.metadata,context:{name:Z},toolsUsed:H.toolsUsed,sources:H.sources,allResponses:H.allResponses}}function WW($,X,Z){let q=[];for(let Q of Z){if(Q.surfaces){for(let Y of Q.surfaces)q.push({answerable:Y.answerable,confidence:Y.confidence});continue}if(Q.answerable!==null&&Q.confidence!==null)q.push({answerable:Q.answerable,confidence:Q.confidence})}let z=q.length,G=q.filter((Q)=>Q.answerable==="YES"||Q.answerable==="PARTIAL").length,J=z>0?Math.round(q.reduce((Q,Y)=>{if(Y.answerable==="YES")return Q+Y.confidence;if(Y.answerable==="PARTIAL")return Q+Y.confidence*0.5;return Q},0)/z):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:X,scenarios:Z,summary:{total:z,answered:G,unanswered:z-G,score:J}}}var HZ=($=0)=>(X)=>`\x1B[${X+$}m`,WZ=($=0)=>(X)=>`\x1B[${38+$};5;${X}m`,VZ=($=0)=>(X,Z,q)=>`\x1B[${38+$};2;${X};${Z};${q}m`,x={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]}},JB=Object.keys(x.modifier),VW=Object.keys(x.color),TW=Object.keys(x.bgColor),QB=[...VW,...TW];function wW(){let $=new Map;for(let[X,Z]of Object.entries(x)){for(let[q,z]of Object.entries(Z))x[q]={open:`\x1B[${z[0]}m`,close:`\x1B[${z[1]}m`},Z[q]=x[q],$.set(z[0],z[1]);Object.defineProperty(x,X,{value:Z,enumerable:!1})}return Object.defineProperty(x,"codes",{value:$,enumerable:!1}),x.color.close="\x1B[39m",x.bgColor.close="\x1B[49m",x.color.ansi=HZ(),x.color.ansi256=WZ(),x.color.ansi16m=VZ(),x.bgColor.ansi=HZ(10),x.bgColor.ansi256=WZ(10),x.bgColor.ansi16m=VZ(10),Object.defineProperties(x,{rgbToAnsi256:{value(X,Z,q){if(X===Z&&Z===q){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(q/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[q]=Z;if(q.length===3)q=[...q].map((G)=>G+G).join("");let z=Number.parseInt(q,16);return[z>>16&255,z>>8&255,z&255]},enumerable:!1},hexToAnsi256:{value:(X)=>x.rgbToAnsi256(...x.hexToRgb(X)),enumerable:!1},ansi256ToAnsi:{value(X){if(X<8)return 30+X;if(X<16)return 90+(X-8);let Z,q,z;if(X>=232)Z=((X-232)*10+8)/255,q=Z,z=Z;else{X-=16;let Q=X%36;Z=Math.floor(X/36)/5,q=Math.floor(Q/6)/5,z=Q%6/5}let G=Math.max(Z,q,z)*2;if(G===0)return 30;let J=30+(Math.round(z)<<2|Math.round(q)<<1|Math.round(Z));if(G===2)J+=60;return J},enumerable:!1},rgbToAnsi:{value:(X,Z,q)=>x.ansi256ToAnsi(x.rgbToAnsi256(X,Z,q)),enumerable:!1},hexToAnsi:{value:(X)=>x.ansi256ToAnsi(x.hexToAnsi256(X)),enumerable:!1}}),x}var LW=wW(),Z0=LW;import c4 from"process";import BW from"os";import TZ from"tty";function e($,X=globalThis.Deno?globalThis.Deno.args:c4.argv){let Z=$.startsWith("-")?"":$.length===1?"-":"--",q=X.indexOf(Z+$),z=X.indexOf("--");return q!==-1&&(z===-1||q<z)}var{env:f}=c4,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 KW(){if("FORCE_COLOR"in f){if(f.FORCE_COLOR==="true")return 1;if(f.FORCE_COLOR==="false")return 0;return f.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(f.FORCE_COLOR,10),3)}}function DW($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function _W($,{streamIsTTY:X,sniffFlags:Z=!0}={}){let q=KW();if(q!==void 0)v2=q;let z=Z?v2:q;if(z===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 f&&"AGENT_NAME"in f)return 1;if($&&!X&&z===void 0)return 0;let G=z||0;if(f.TERM==="dumb")return G;if(c4.platform==="win32"){let J=BW.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in f){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((J)=>(J in f)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((J)=>(J in f))||f.CI_NAME==="codeship")return 1;return G}if("TEAMCITY_VERSION"in f)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(f.TEAMCITY_VERSION)?1:0;if(f.COLORTERM==="truecolor")return 3;if(f.TERM==="xterm-kitty")return 3;if(f.TERM==="xterm-ghostty")return 3;if(f.TERM==="wezterm")return 3;if("TERM_PROGRAM"in f){let J=Number.parseInt((f.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(f.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(f.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(f.TERM))return 1;if("COLORTERM"in f)return 1;return G}function wZ($,X={}){let Z=_W($,{streamIsTTY:$&&$.isTTY,...X});return DW(Z)}var FW={stdout:wZ({isTTY:TZ.isatty(1)}),stderr:wZ({isTTY:TZ.isatty(2)})},LZ=FW;function BZ($,X,Z){let q=$.indexOf(X);if(q===-1)return $;let z=X.length,G=0,J="";do J+=$.slice(G,q)+X+Z,G=q+z,q=$.indexOf(X,G);while(q!==-1);return J+=$.slice(G),J}function KZ($,X,Z,q){let z=0,G="";do{let J=$[q-1]==="\r";G+=$.slice(z,J?q-1:q)+X+(J?`\r
|
|
220
237
|
`:`
|
|
221
|
-
`)+z
|
|
222
|
-
`,
|
|
223
|
-
`);if(
|
|
224
|
-
`)}function
|
|
225
|
-
`);let
|
|
226
|
-
`);else
|
|
238
|
+
`)+Z,z=q+1,q=$.indexOf(`
|
|
239
|
+
`,z)}while(q!==-1);return G+=$.slice(z),G}var{stdout:DZ,stderr:_Z}=LZ,l4=Symbol("GENERATOR"),K$=Symbol("STYLER"),H1=Symbol("IS_EMPTY"),FZ=["ansi","ansi","ansi256","ansi16m"],D$=Object.create(null),OW=($,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=DZ?DZ.level:0;$.level=X.level===void 0?Z:X.level};var MW=($)=>{let X=(...Z)=>Z.join(" ");return OW(X,$),Object.setPrototypeOf(X,W1.prototype),X};function W1($){return MW($)}Object.setPrototypeOf(W1.prototype,Function.prototype);for(let[$,X]of Object.entries(Z0))D$[$]={get(){let Z=u2(this,a4(X.open,X.close,this[K$]),this[H1]);return Object.defineProperty(this,$,{value:Z}),Z}};D$.visible={get(){let $=u2(this,this[K$],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var i4=($,X,Z,...q)=>{if($==="rgb"){if(X==="ansi16m")return Z0[Z].ansi16m(...q);if(X==="ansi256")return Z0[Z].ansi256(Z0.rgbToAnsi256(...q));return Z0[Z].ansi(Z0.rgbToAnsi(...q))}if($==="hex")return i4("rgb",X,Z,...Z0.hexToRgb(...q));return Z0[Z][$](...q)},IW=["rgb","hex","ansi256"];for(let $ of IW){D$[$]={get(){let{level:Z}=this;return function(...q){let z=a4(i4($,FZ[Z],"color",...q),Z0.color.close,this[K$]);return u2(this,z,this[H1])}}};let X="bg"+$[0].toUpperCase()+$.slice(1);D$[X]={get(){let{level:Z}=this;return function(...q){let z=a4(i4($,FZ[Z],"bgColor",...q),Z0.bgColor.close,this[K$]);return u2(this,z,this[H1])}}}}var RW=Object.defineProperties(()=>{},{...D$,level:{enumerable:!0,get(){return this[l4].level},set($){this[l4].level=$}}}),a4=($,X,Z)=>{let q,z;if(Z===void 0)q=$,z=X;else q=Z.openAll+$,z=X+Z.closeAll;return{open:$,close:X,openAll:q,closeAll:z,parent:Z}},u2=($,X,Z)=>{let q=(...z)=>PW(q,z.length===1?""+z[0]:z.join(" "));return Object.setPrototypeOf(q,RW),q[l4]=$,q[K$]=X,q[H1]=Z,q},PW=($,X)=>{if($.level<=0||!X)return $[H1]?"":X;let Z=$[K$];if(Z===void 0)return X;let{openAll:q,closeAll:z}=Z;if(X.includes("\x1B"))while(Z!==void 0)X=BZ(X,Z.close,Z.open),Z=Z.parent;let G=X.indexOf(`
|
|
240
|
+
`);if(G!==-1)X=KZ(X,z,q,G);return q+X+z};Object.defineProperties(W1.prototype,D$);var NW=W1(),KB=W1({level:_Z?_Z.level:0});var M=NW;var OZ="\u2500".repeat(55);function PZ($){if($==="success")return M.green;if($==="warning")return M.yellow;return M.red}function AW($){if($>=70)return M.green;if($>=50)return M.yellow;return M.red}function NZ($){if($.label==="Error")return $.label;return`${$.label} (${$.confidence}%)`}function SW($){let X=k0({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 jW($){let X=$.target?.target??"default",Z=$.context?.name??"default";if(X==="default"&&Z==="default")return"";if(Z==="default")return M.dim(`[${X}]`);return M.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(M.dim(`${X}error: ${$.error}`)),Z;if($.traps.fired.length>0)for(let q of $.traps.fired)Z.push(M.red(`${X}trap: ${q.id}`)),Z.push(M.dim(`${X}reason: ${q.reason}`)),Z.push(M.dim(`${X}match: "${q.matched}"`));else if($.reason&&$.answerable!=="YES")Z.push(M.dim(`${X}reason: ${$.reason}`));if($.citations.cited.length>0)Z.push(M.dim(`${X}cited: ${m2($.citations.cited)}`));if($.citations.missing.length>0)Z.push(M.dim(`${X}missing: ${m2($.citations.missing)}`));if($.citations.unknown.length>0)Z.push(M.dim(`${X}unknown: ${m2($.citations.unknown)}`));return Z}function MZ($,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:q}=SW($),z=jW($),G=`${X} ${Z}`;return z?`${z} ${q(G)}`:q(G)}function RZ($,X){if(!$.surfaces)return[];let Z=[];Z.push(`${X}${M.dim("Citations scoped to active surface (compare mode)")}`);for(let q of $.surfaces){let z=k0(q),G=PZ(z.tone),J=M.dim(`[${q.active.join(",")}]`),Q=`${G(z.icon)} ${G(NZ(z))}`;Z.push(`${X}${J} ${Q}`),Z.push(...AZ({traps:q.traps,reason:q.reason,answerable:q.answerable,citations:q.citations},`${X} `))}return Z}function CW($){let X=0,Z=0,q=0;for(let z of $){if(z.surfaces){for(let G of z.surfaces)X+=G.traps.fired.length,Z+=G.citations.missing.length,q+=G.citations.unknown.length;continue}if(z.traps)X+=z.traps.fired.length;if(z.citations)Z+=z.citations.missing.length,q+=z.citations.unknown.length}if(X>0&&Z+q>0)return"Review fired traps and citation gaps.";if(X>0)return"Review fired traps before trusting this surface.";if(Z+q>0)return"Review missing and unknown citations.";return"Citations hold. No declared traps fired."}function bW($,X){let Z=$.summary.score,z=`Overall: ${AW(Z)(`${Z}`)} / 100`;if(X===void 0||X<=0)return z;let J=Z>=X?M.green("run passes"):M.red("run fails");return`${z} \xB7 threshold ${X} \xB7 ${J}`}function SZ($,X={}){let{tool:Z,scenarios:q,summary:z}=$,G=q,J=[];if(J.push(M.bold("pickled check")),J.push(OZ),J.push(`Tool: ${M.cyan(Z.name)}`),$.docs.length>0)J.push(`Sources: ${M.dim(m2($.docs.map((Q)=>Q.id)))}`);else J.push(`Sources: ${M.dim("none registered")}`);if(J.push(`Scenarios: ${M.dim(String(z.total))}`),J.push(""),EW(G)){let Q=new Map;for(let Y of G){let U=Y.scenario.name;if(!Q.has(U))Q.set(U,[]);Q.get(U)?.push(Y)}for(let[Y,U]of Q){J.push(`Scenario: ${Y}`);for(let W of U)if(W.surfaces)J.push(...RZ(W," "));else J.push(` ${IZ(W)}`),J.push(...MZ(W," "));J.push("")}}else for(let Q of G){if(J.push(`Scenario: ${Q.scenario.name}`),Q.surfaces)J.push(...RZ(Q," "));else J.push(` ${IZ(Q)}`),J.push(...MZ(Q," "));J.push("")}return J.push(OZ),J.push(bW($,X.threshold)),J.push(M.dim(CW(q))),J.join(`
|
|
241
|
+
`)}function s4($,X={}){console.log(SZ($,X)),console.log()}function d2($,X={}){if(X.verbose)return JSON.stringify($,null,2);let Z={...$,docs:$.docs.map((q)=>({...q,content:""})),scenarios:$.scenarios.map((q)=>{let{allResponses:z,...G}=q;return G})};return JSON.stringify(Z,null,2)}function xW($){if($.format&&$.format!=="terminal")return $.format;if($.json)return"json";return $.format??"terminal"}async function jZ($,X){let{output:Z}=X,q=xW(X),z=yW.resolve($),G;try{G=await U2({targetRepo:z})}catch(H){console.error(M.red(H instanceof Error?H.message:H)),process.exit(1)}let J;if(q==="json")J=q2(G);else if(q==="markdown")J=Z2(G);else J=z2(G);if(Z)await Bun.write(Z,J);else await fW(`${J}
|
|
242
|
+
`);let Q=G.findings.filter((H)=>H.severity==="error").length,Y=G.findings.filter((H)=>H.severity==="warning").length;if(q!=="json"&&!Z)if(console.log(),Q===0&&Y===0)console.log(M.green("Audit clean. No issues found."));else{let H=Q>0?M.red:M.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($,(q)=>{if(q)Z(q);else X()})})}import kW from"path";async function EZ($,X){let{json:Z,output:q,verbose:z}=X,G=(V)=>!Z&&console.log(V),J=kW.resolve($),Q;try{Q=await Z$(J)}catch(V){console.error(M.red(V instanceof Error?V.message:V)),console.error(),console.error(M.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(B){console.error(M.red(B instanceof Error?B.message:String(B))),process.exit(1)}let w=V-Q.scenarios.length;if(w>0&&!Z)G(M.dim(`Skipping ${w} scenario(s) with explicit target != "${X.target}"`))}let Y={name:Q.tool.name,description:Q.tool.description,path:J};if(z){G(M.bold("pickled check")),G(""),G(M.dim(` Tool: ${Y.name}`)),G(M.dim(` Scenarios: ${Q.scenarios.length}`));for(let V of Q.scenarios)G(M.dim(` - ${V.name}`))}let U=await p4(Y,Q,{onProgress:z?(V)=>{if(!Z)G(M.dim(` ${V}`))}:void 0}),W=X.threshold?parseInt(X.threshold,10):Q.threshold??0,H=W>0&&U.summary.score<W;if(q)await Bun.write(q,d2(U,{verbose:z}));else if(Z)await gW(`${d2(U,{verbose:z})}
|
|
243
|
+
`);else s4(U,{threshold:W});if(H){if(Z||q)console.error(M.red(`Overall: ${U.summary.score} / 100 \xB7 threshold ${W} \xB7 run fails`)),console.error(M.dim("Review failed scenarios before trusting this surface."));process.exit(1)}}function gW($){return new Promise((X,Z)=>{process.stdout.write($,(q)=>{if(q)Z(q);else X()})})}import hW from"path";var vW=`# 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 CZ($){let Z=`${hW.resolve($)}/pickled.yml`;if(await Bun.file(Z).exists())console.error(M.red("pickled.yml already exists")),process.exit(1);await Bun.write(Z,vW),console.log(M.green("Created pickled.yml")),console.log(),console.log(M.dim("Next steps:")),console.log(M.dim(" 1. Edit pickled.yml: list your sources and scenarios")),console.log(M.dim(" 2. Run: pickled check")),console.log()}c0.name("pickled").description("Test what agents actually understand about your product").version(wX.version);c0.command("init").description("Create a pickled.yml config file").argument("[path]","Path to your project (default: current directory)",".").action(CZ);c0.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(jZ);c0.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(EZ);await c0.parseAsync();
|