@thegpvc/gp-foundry 0.2.7 → 0.2.9
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/actions/merge-gate/dist/index.cjs +26 -26
- package/actions/run-agent/README.md +54 -9
- package/actions/run-agent/action.yml +116 -13
- package/dist/cli/index.cjs +90 -89
- package/package.json +1 -1
- package/skill/reference/node-types.md +3 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -1,134 +1,135 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(s))}let c=[`Usage: ${t.commandUsage(e)}`,""],
|
|
4
|
-
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,
|
|
2
|
+
"use strict";var pr=Object.create;var Mt=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var br=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&(e=i(i=0)),e}catch(r){throw t=[r],r}};var Ee=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var yr=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of hr(e))!gr.call(i,o)&&o!==t&&Mt(i,o,{get:()=>e[o],enumerable:!(r=fr(e,o))||r.enumerable});return i};var _n=(i,e,t)=>(t=i!=null?pr(mr(i)):{},yr(e||!i||!i.__esModule?Mt(t,"default",{value:i,enumerable:!0}):t,i));var wr,V,I=br(()=>{"use strict";wr=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,V=wr()});var Je=Ee(Gn=>{"use strict";I();var An=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},Vn=class extends An{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Gn.CommanderError=An;Gn.InvalidArgumentError=Vn});var kn=Ee(Yn=>{"use strict";I();var{InvalidArgumentError:_r}=Je(),Wn=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new _r(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ar(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}Yn.Argument=Wn;Yn.humanReadableArgName=Ar});var Jn=Ee(Ft=>{"use strict";I();var{humanReadableArgName:kr}=kn(),Kn=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(o=>!o._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((o,s)=>o.name().localeCompare(s.name())),t}compareOptions(e,t){let r=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(o=>!o.hidden),r=e._getHelpOption();if(r&&!r.hidden){let o=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!o&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!o&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let o=r.options.filter(s=>!s.hidden);t.push(...o)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(r=>kr(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,o)=>Math.max(r,t.subcommandTerm(o).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,o)=>Math.max(r,t.optionTerm(o).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,o)=>Math.max(r,t.argumentTerm(o).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let o=e.parent;o;o=o.parent)r=o.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),o=t.helpWidth||80,s=2,a=2;function d($,S){if(S){let v=`${$.padEnd(r+a)}${S}`;return t.wrap(v,o-s,r+a)}return $}function u($){return $.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(s))}let c=[`Usage: ${t.commandUsage(e)}`,""],p=t.commandDescription(e);p.length>0&&(c=c.concat([t.wrap(p,o,0),""]));let m=t.visibleArguments(e).map($=>d(t.argumentTerm($),t.argumentDescription($)));m.length>0&&(c=c.concat(["Arguments:",u(m),""]));let g=t.visibleOptions(e).map($=>d(t.optionTerm($),t.optionDescription($)));if(g.length>0&&(c=c.concat(["Options:",u(g),""])),this.showGlobalOptions){let $=t.visibleGlobalOptions(e).map(S=>d(t.optionTerm(S),t.optionDescription(S)));$.length>0&&(c=c.concat(["Global Options:",u($),""]))}let k=t.visibleCommands(e).map($=>d(t.subcommandTerm($),t.subcommandDescription($)));return k.length>0&&(c=c.concat(["Commands:",u(k),""])),c.join(`
|
|
4
|
+
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,r,o=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",a=new RegExp(`[\\n][${s}]+`);if(e.match(a))return e;let d=t-r;if(d<o)return e;let u=e.slice(0,r),c=e.slice(r).replace(`\r
|
|
5
5
|
`,`
|
|
6
|
-
`),
|
|
7
|
-
|.{1,${d-1}}([${g}]|$)|[^${g}]+?([${g}]|$)`,"g"),$=c.match(k)||[];return u+$.map((
|
|
8
|
-
`?"":(v>0?
|
|
9
|
-
`)}};Ft.Help=
|
|
10
|
-
(Did you mean one of ${
|
|
11
|
-
(Did you mean ${
|
|
12
|
-
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new $r(e,t)}argument(e,t,
|
|
13
|
-
Expecting one of '${
|
|
14
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=o=>[o.name()].concat(o.aliases()),
|
|
6
|
+
`),p=" ".repeat(r),g="\\s\u200B",k=new RegExp(`
|
|
7
|
+
|.{1,${d-1}}([${g}]|$)|[^${g}]+?([${g}]|$)`,"g"),$=c.match(k)||[];return u+$.map((S,v)=>S===`
|
|
8
|
+
`?"":(v>0?p:"")+S.trimEnd()).join(`
|
|
9
|
+
`)}};Ft.Help=Kn});var Zn=Ee(Qn=>{"use strict";I();var{InvalidArgumentError:xr}=Je(),zn=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=Er(e);this.short=r.shortFlag,this.long=r.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}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new xr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Cr(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Xn=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let o=this.negativeOptions.get(r).presetArg,s=o!==void 0?o:!1;return t.negate===(s===e)}};function Cr(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Er(i){let e,t,r=i.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}Qn.Option=zn;Qn.DualOptions=Xn});var Lt=Ee(jt=>{"use strict";I();function Sr(i,e){if(Math.abs(i.length-e.length)>3)return Math.max(i.length,e.length);let t=[];for(let r=0;r<=i.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=i.length;o++){let s=1;i[o-1]===e[r-1]?s=0:s=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+s),o>1&&r>1&&i[o-1]===e[r-2]&&i[o-2]===e[r-1]&&(t[o][r]=Math.min(t[o][r],t[o-2][r-2]+1))}return t[i.length][e.length]}function vr(i,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=i.startsWith("--");t&&(i=i.slice(2),e=e.map(a=>a.slice(2)));let r=[],o=3,s=.4;return e.forEach(a=>{if(a.length<=1)return;let d=Sr(i,a),u=Math.max(i.length,a.length);(u-d)/u>s&&(d<o?(o=d,r=[a]):d===o&&r.push(a))}),r.sort((a,d)=>a.localeCompare(d)),t&&(r=r.map(a=>`--${a}`)),r.length>1?`
|
|
10
|
+
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
11
|
+
(Did you mean ${r[0]}?)`:""}jt.suggestSimilar=vr});var Vt=Ee(Ut=>{"use strict";I();var Or=require("events").EventEmitter,et=require("child_process"),ye=require("path"),nt=require("fs"),X=require("process"),{Argument:$r,humanReadableArgName:Tr}=kn(),{CommanderError:tt}=Je(),{Help:Nr}=Jn(),{Option:Dt,DualOptions:Rr}=Zn(),{suggestSimilar:qt}=Lt(),it=class i extends Or{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",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._outputConfiguration={writeOut:t=>X.stdout.write(t),writeErr:t=>X.stderr.write(t),getOutHelpWidth:()=>X.stdout.isTTY?X.stdout.columns:void 0,getErrHelpWidth:()=>X.stderr.isTTY?X.stderr.columns:void 0,outputError:(t,r)=>r(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let o=t,s=r;typeof o=="object"&&o!==null&&(s=o,o=null),s=s||{};let[,a,d]=e.match(/([^ ]+) *(.*)/),u=this.createCommand(a);return o&&(u.description(o),u._executableHandler=!0),s.isDefault&&(this._defaultCommandName=u._name),u._hidden=!!(s.noHelp||s.hidden),u._executableFile=s.executableFile||null,d&&u.arguments(d),this._registerCommand(u),u.parent=this,u.copyInheritedSettings(this),o?this:u}createCommand(e){return new i(e)}createHelp(){return Object.assign(new Nr,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
|
+
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new $r(e,t)}argument(e,t,r,o){let s=this.createArgument(e,t);return typeof r=="function"?s.default(o).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,r,o]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",a=this.createCommand(r);return a.helpOption(!1),o&&a.arguments(o),s&&a.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=a,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
|
+
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new tt(e,t,r)),X.exit(e)}action(e){let t=r=>{let o=this.registeredArguments.length,s=r.slice(0,o);return this._storeOptionsAsProperties?s[o]=this:s[o]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Dt(e,t)}_callParseArg(e,t,r,o){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let a=`${o} ${s.message}`;this.error(a,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
|
|
14
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=o=>[o.name()].concat(o.aliases()),r=t(e).find(o=>this._findCommand(o));if(r){let o=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${o}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let o=(s,a,d)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let u=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,u,a):s!==null&&e.variadic&&(s=e._concatValue(s,u)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,d)};return this.on("option:"+t,s=>{let a=`error: option '${e.flags}' argument '${s}' is invalid.`;o(s,a,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let a=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;o(s,a,"env")}),this}_optionEx(e,t,r,o,s){if(typeof t=="object"&&t instanceof Dt)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let a=this.createOption(t,r);if(a.makeOptionMandatory(!!e.mandatory),typeof o=="function")a.default(s).argParser(o);else if(o instanceof RegExp){let d=o;o=(u,c)=>{let p=d.exec(u);return p?p[0]:c},a.default(s).argParser(o)}else a.default(o);return this.addOption(a)}option(e,t,r,o){return this._optionEx({},e,t,r,o)}requiredOption(e,t,r,o){return this._optionEx({mandatory:!0},e,t,r,o)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){X.versions?.electron&&(t.from="electron");let o=X.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(t.from="eval")}e===void 0&&(e=X.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":X.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function s(p,m){let g=ye.resolve(p,m);if(nt.existsSync(g))return g;if(o.includes(ye.extname(m)))return;let k=o.find($=>nt.existsSync(`${g}${$}`));if(k)return`${g}${k}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||"";if(this._scriptPath){let p;try{p=nt.realpathSync(this._scriptPath)}catch{p=this._scriptPath}d=ye.resolve(ye.dirname(p),d)}if(d){let p=s(d,a);if(!p&&!e._executableFile&&this._scriptPath){let m=ye.basename(this._scriptPath,ye.extname(this._scriptPath));m!==this._name&&(p=s(d,`${m}-${e._name}`))}a=p||a}r=o.includes(ye.extname(a));let u;X.platform!=="win32"?r?(t.unshift(a),t=Bt(X.execArgv).concat(t),u=et.spawn(X.argv[0],t,{stdio:"inherit"})):u=et.spawn(a,t,{stdio:"inherit"}):(t.unshift(a),t=Bt(X.execArgv).concat(t),u=et.spawn(X.execPath,t,{stdio:"inherit"})),u.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(m=>{X.on(m,()=>{u.killed===!1&&u.exitCode===null&&u.kill(m)})});let c=this._exitCallback;u.on("close",p=>{p=p??1,c?c(new tt(p,"commander.executeSubCommandAsync","(close)")):X.exit(p)}),u.on("error",p=>{if(p.code==="ENOENT"){let m=d?`searched for local subcommand relative to directory '${d}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",g=`'${a}' does not exist
|
|
15
15
|
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${
|
|
17
|
+
- ${m}`;throw new Error(g)}else if(p.code==="EACCES")throw new Error(`'${a}' not executable`);if(!c)X.exit(1);else{let m=new tt(1,"commander.executeSubCommandAsync","(error)");m.nestedError=p,c(m)}}),this.runningCommand=u}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,o,"preSubcommand"),s=this._chainOrCall(s,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(r,o,s)=>{let a=o;if(o!==null&&r.parseArg){let d=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;a=this._callParseArg(r,o,s,d)}return a};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,o)=>{let s=r.defaultValue;r.variadic?o<this.args.length?(s=this.args.slice(o),r.parseArg&&(s=s.reduce((a,d)=>e(r,d,a),r.defaultValue))):s===void 0&&(s=[]):o<this.args.length&&(s=this.args[o],r.parseArg&&(s=e(r,s,r.defaultValue))),t[o]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,o=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(a=>{o.push({hookedCommand:s,callback:a})})}),t==="postAction"&&o.reverse(),o.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{o=this._chainOrCall(o,()=>s(this,t))}),o}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let a;return a=this._chainOrCallHooks(a,"preAction"),a=this._chainOrCall(a,()=>this._actionHandler(this.processedArgs)),this.parent&&(a=this._chainOrCall(a,()=>{this.parent.emit(s,e,t)})),a=this._chainOrCallHooks(a,"postAction"),a}if(this.parent&&this.parent.listenerCount(s))o(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(r=>{let o=r.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let o=e.find(s=>r.conflictsWith.includes(s.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],o=t,s=e.slice();function a(u){return u.length>1&&u[0]==="-"}let d=null;for(;s.length;){let u=s.shift();if(u==="--"){o===r&&o.push(u),o.push(...s);break}if(d&&!a(u)){this.emit(`option:${d.name()}`,u);continue}if(d=null,a(u)){let c=this._findOption(u);if(c){if(c.required){let p=s.shift();p===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,p)}else if(c.optional){let p=null;s.length>0&&!a(s[0])&&(p=s.shift()),this.emit(`option:${c.name()}`,p)}else this.emit(`option:${c.name()}`);d=c.variadic?c:null;continue}}if(u.length>2&&u[0]==="-"&&u[1]!=="-"){let c=this._findOption(`-${u[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,u.slice(2)):(this.emit(`option:${c.name()}`),s.unshift(`-${u.slice(2)}`));continue}}if(/^--[^=]+=/.test(u)){let c=u.indexOf("="),p=this._findOption(u.slice(0,c));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,u.slice(c+1));continue}}if(a(u)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(u)){t.push(u),s.length>0&&r.push(...s);break}else if(this._getHelpCommand()&&u===this._getHelpCommand().name()){t.push(u),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){r.push(u),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){o.push(u),s.length>0&&o.push(...s);break}o.push(u)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let o=this.options[r].attributeName();e[o]=o===this._versionOptionName?this._version:this[o]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
20
|
-
`),this.outputHelp({error:!0}));let
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let
|
|
22
|
-
Expecting one of '${
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Bt(
|
|
24
|
-
git config user.email "$GIT_EMAIL"`})}function Qe(
|
|
25
|
-
`));let d=t.files.prompt;return
|
|
26
|
-
`)})}function qr(
|
|
27
|
-
`)}));let o=Se(e,
|
|
20
|
+
`),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,s=r.code||"commander.error";this._exit(o,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in X.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,X.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Rr(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(o=>!t(o)).forEach(o=>{this.setOptionValueWithSource(o,r.implied[o],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=a=>{let d=a.attributeName(),u=this.getOptionValue(d),c=this.options.find(m=>m.negate&&d===m.attributeName()),p=this.options.find(m=>!m.negate&&d===m.attributeName());return c&&(c.presetArg===void 0&&u===!1||c.presetArg!==void 0&&u===c.presetArg)?c:p||a},o=a=>{let d=r(a),u=d.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${d.envVar}'`:`option '${d.flags}'`},s=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],s=this;do{let a=s.createHelp().visibleOptions(s).filter(d=>d.long).map(d=>d.long);o=o.concat(a),s=s.parent}while(s&&!s._enablePositionalOptions);t=qt(e,o)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(s=>{o.push(s.name()),s.alias()&&o.push(s.alias())}),t=qt(e,o)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let o=this.createOption(t,r);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
21
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let o=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${o}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(r=>Tr(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=ye.basename(e,ye.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},r;return t.error?r=o=>this._outputConfiguration.writeErr(o):r=o=>this._outputConfiguration.writeOut(o),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let o=this.helpInformation(r);if(t&&(o=t(o),typeof o!="string"&&!Buffer.isBuffer(o)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(o),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=X.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
22
|
+
Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,s=>{let a;typeof t=="function"?a=t({error:s.error,command:s.command}):a=t,a&&s.write(`${a}
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Bt(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?o=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],o=s[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}Ut.Command=it});var Kt=Ee(le=>{"use strict";I();var{Argument:Gt}=kn(),{Command:rt}=Vt(),{CommanderError:Hr,InvalidArgumentError:Wt}=Je(),{Help:Ir}=Jn(),{Option:Yt}=Zn();le.program=new rt;le.createCommand=i=>new rt(i);le.createOption=(i,e)=>new Yt(i,e);le.createArgument=(i,e)=>new Gt(i,e);le.Command=rt;le.Option=Yt;le.Argument=Gt;le.Help=Ir;le.CommanderError=Hr;le.InvalidArgumentError=Wt;le.InvalidOptionArgumentError=Wt});var En=Ee((os,ot)=>{"use strict";I();var Cn=process||{},Xt=Cn.argv||[],xn=Cn.env||{},Pr=!(xn.NO_COLOR||Xt.includes("--no-color"))&&(!!xn.FORCE_COLOR||Xt.includes("--color")||Cn.platform==="win32"||(Cn.stdout||{}).isTTY&&xn.TERM!=="dumb"||!!xn.CI),Mr=(i,e,t=i)=>r=>{let o=""+r,s=o.indexOf(e,i.length);return~s?i+Fr(o,e,t,s)+e:i+o+e},Fr=(i,e,t,r)=>{let o="",s=0;do o+=i.substring(s,r)+t,s=r+e.length,r=i.indexOf(e,s);while(~r);return o+i.substring(s)},Qt=(i=Pr)=>{let e=i?Mr:()=>String;return{isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};ot.exports=Qt();ot.exports.createColors=Qt});I();I();var Jt=_n(Kt(),1),{program:Yo,createCommand:Ko,createArgument:Jo,createOption:zo,CommanderError:Xo,InvalidArgumentError:Qo,InvalidOptionArgumentError:Zo,Command:zt,Argument:es,Option:ns,Help:ts}=Jt.default;var Q=_n(En(),1),dr=require("child_process"),Y=require("fs"),ne=require("path");I();I();I();var Sn=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function Zt(i){return i.uses!==void 0}I();function ze(i){let e=i.auth;return e?.mode?{mode:e.mode,appIdSecret:e.app_id_secret??i.identity.app_id_secret,appKeySecret:e.app_key_secret??i.identity.app_key_secret,tokenSecret:e.token_secret}:i.identity.app_id_secret&&i.identity.app_key_secret?{mode:"app",appIdSecret:i.identity.app_id_secret,appKeySecret:i.identity.app_key_secret}:{mode:"github-token"}}I();I();function Xe(i){return`\${{ secrets.${i} }}`}function we(i,e){if(!e)return"";let t=i.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function ce(i){let e=ze(i.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Xe(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}function vn(i){let e=ze(i.config);if(!(e.mode!=="app"||!e.appIdSecret||!e.appKeySecret))return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:{"app-id":Xe(e.appIdSecret),"private-key":Xe(e.appKeySecret)}}}function On(i,e={}){let t={token:ce(i)};return e.ref&&(t.ref=e.ref),e.fetchDepth!==void 0&&(t["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:t}}function Le(){return{uses:"./.github/agent-setup",name:"Setup agent toolchain"}}function ei(i){let e=i.config.identity,t=e.git_name??e.bot_login??"gp-foundry agent",r=e.git_email??`${e.bot_login??"gp-foundry-agent"}@users.noreply.github.com`;return de({name:"Configure git identity",env:{GIT_NAME:t,GIT_EMAIL:r},run:`git config user.name "$GIT_NAME"
|
|
24
|
+
git config user.email "$GIT_EMAIL"`})}function Qe(i,e,t){let r={type:e,number:t,token:ce(i)},o=i.config.identity?.bot_login;return o&&(r["trusted-authors"]=o),{uses:i.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:r}}function De(i,e){let t=i.node,r=i.config,o={"role-file":we(i,t.files.role),model:r.agent.model,"comms-file":we(i,"agents/communication.md"),"scope-path":we(i,"agents/scope.yaml"),"claude-code-oauth-token":Xe(r.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN"),"github-token":ce(i)};e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),r.agent.conventions&&(o.conventions=r.agent.conventions);let s=typeof t.attrs.secrets=="string"?t.attrs.secrets.split(",").map(c=>c.trim()).filter(Boolean):[],a=[...new Set([...r.agent.secrets??[],...s])];a.length&&(o["extra-env"]=a.map(c=>`${c}=${Xe(c)}`).join(`
|
|
25
|
+
`));let d=t.attrs.agent_attempts;d!==void 0&&(o["max-attempts"]=String(d));let u=t.files.prompt;return u&&(o["prompt-override-file"]=we(i,u)),{uses:i.actionRef("run-agent"),name:"Run agent",with:o}}function de(i){return{shell:"bash",...i}}function at(i){let e=i.attrs.permissions;if(e===void 0)return{};if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': permissions= must be a non-empty string like "id-token: write"`);let t={},r=e.split(",").filter(o=>o.trim());if(!r.length)throw new Error(`node '${i.id}': permissions= has no entries \u2014 expected e.g. "id-token: write"`);for(let o of r){let s=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!s)throw new Error(`node '${i.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[s[1]]=s[2]}return t}function ti(i,e){let t;try{t=at(i)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var He="${{ github.event.issue.number }}",Ze="${{ github.event.pull_request.number }}",$n="${{ github.event.pull_request.head.sha }}",ni="${{ github.event.pull_request.head.ref }}";function Se(i,e){let t=i.attrs.timeout;return typeof t=="number"?t:e}var jr=10;function Tn(i){return Math.max(1,i-jr)}function Nn(i,e){let t=[],r=vn(i);return r&&t.push(r),t.push(On(i,e)),t.push(ei(i)),t}function st(i){let e=i.node,t=e.context??"issue",r=t==="pr-diff"||t==="pr-review",o=r?{contents:"read","pull-requests":"write"}:{contents:"read",issues:"write"},s=[],a=vn(i);a&&s.push(a),s.push(On(i,r?{ref:$n,fetchDepth:0}:void 0));let d=typeof e.attrs.gates=="string"?e.attrs.gates:void 0,u=r&&d?d.split(",").map(k=>k.trim()).filter(Boolean):[],c=u.map((k,$)=>Lr(`gate-${k}`,$,u));u.forEach((k,$)=>{s.push({uses:i.actionRef("wait-for-checks"),id:c[$],name:`Wait for ${k}`,with:{sha:$n,"workflow-name":k,token:ce(i)}})}),s.push(Le());let p=t==="pr-diff"?"pr-diff":t==="pr-review"?"pr-review":"issue";s.push(Qe(i,p,r?Ze:He)),u.length&&s.push(Dr(u,c));let m=Se(e,u.length?15+15*u.length:25),g=De(i,{withContext:!0});return s.push(u.length?g:{...g,timeoutMinutes:Tn(m)}),{jobId:e.id,name:e.id,permissions:o,timeoutMinutes:m,steps:s}}function Lr(i,e,t){let r=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=r(i)||`gate-${e+1}`;return t.filter((a,d)=>d!==e&&r(`gate-${a}`)===o).length>0?`${o}-${e+1}`:o}function Dr(i,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},r=["{",' echo ""',' echo "=== CI GATES ==="'];return i.forEach((o,s)=>{t[`GATE_${s+1}_NAME`]=o,t[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`,r.push(` echo "$GATE_${s+1}_NAME: $GATE_${s+1}_RESULT"`)}),r.push(' echo ""',` echo "A gate whose result is not 'success' is a blocking finding: say which one"`,` echo "failed and request changes. 'timeout' or 'skipped' means CI never gave an"`,' echo "answer \u2014 treat it as unverified, not as a pass."','} >> "$CONTEXT_FILE"'),de({name:"Record CI gate results in the context",env:t,run:r.join(`
|
|
26
|
+
`)})}function qr(i){let e=i.node,t=i.config,r=Nn(i);r.push(de({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:He,ISSUE_TITLE:"${{ github.event.issue.title }}",PREFIX:t.repo.branch_prefix},run:[`SLUG=$(printf '%s' "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | cut -c1-50 | sed 's/-$//')`,'BRANCH="$PREFIX$ISSUE_NUMBER-$SLUG"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
27
|
+
`)}));let o=Se(e,35);return r.push(Le()),r.push(Qe(i,"issue",He)),r.push({...De(i,{withContext:!0}),timeoutMinutes:Tn(o)}),r.push({uses:i.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:ce(i),"agent-name":e.id,"base-branch":t.repo.base_branch,"issue-number":He,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
|
|
28
28
|
|
|
29
29
|
The agent finished but didn't open a PR itself, so one was created automatically. See the commits and the linked issue for context.
|
|
30
30
|
|
|
31
|
-
Closes #${
|
|
32
|
-
`)}));let d="steps.attempts.outputs.exhausted != 'true'";return t.push({...Le(),if:d}),t.push({...Qe(
|
|
33
|
-
`)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:Se(e,
|
|
34
|
-
`)})]}}function Yr(
|
|
35
|
-
`)})),i.push(Le()),i.push({...De(r,{withContext:!1}),timeoutMinutes:st(Se(e,15))}),o==="pr"?i.push({uses:r.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":t.repo.base_branch,token:ue(r),"agent-name":e.id,"scope-path":Ee(r,"agents/scope.yaml"),"pr-title":`${e.id}: scheduled update`,"pr-body":`Scheduled output from the \`${e.id}\` lane \u2014 review and merge like any agent PR.`,...s?{"allowed-paths":s}:{}}}):o==="direct"&&i.push({uses:r.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:t.repo.base_branch,"base-branch":t.repo.base_branch,token:ue(r),"agent-name":e.id,"scope-path":Ee(r,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...s?{"allowed-paths":s}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Se(e,15),steps:i}}function ri(r,e,t){let i=r.node,o=[],s=Sn(r);s&&o.push(s),o.push(vn(r,t?{ref:On,fetchDepth:0}:void 0)),o.push(Le()),o.push(Qe(r,t?"pr-review":"issue",t?Ze:Re)),i.files.role&&o.push(De(r,{withContext:!0}));let a=i.attrs.on_complete_label;if(typeof a=="string"&&a){let d=r.config.labels?.[a]??a;o.push(ye({name:"Apply completion label",env:{GH_TOKEN:ue(r),NUM:t?Ze:Re},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${d}'`}))}return ti(i,{jobId:i.id,name:i.id,needs:e,permissions:t?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:Se(i,15),steps:o})}var Kr={analyst:rt,"issue-agent":rt,"pr-review":rt,producer:qr,"pr-fix":Br,"merge-gate":Gr,"human-gate":Wr,"scheduled-agent":Yr,start:()=>null,exit:()=>null};function at(r,e,t){let i=Kr[r.type];if(!i)return null;let o=i(t);return o&&ti(r,o)}I();var Jr=new Set(En);function qe(r){let e=new Map(r.nodes.map(a=>[a.id,a])),t=new Map,i=new Map;for(let a of r.nodes)t.set(a.id,[]),i.set(a.id,[]);for(let a of r.edges)t.get(a.to)?.push(a),i.get(a.from)?.push(a);let o=new Map,s=new Set;for(let a of r.nodes){if(a.type!=="fan_in")continue;let d=t.get(a.id)??[];if(d.length<2)continue;let u=[],c,f=!0;for(let $ of d){let E=e.get($.from);if(!E||!Jr.has(E.type)){f=!1;break}let v=t.get(E.id)??[],P=i.get(E.id)??[];if(v.length!==1||P.length!==1||P[0].to!==a.id){f=!1;break}let F=e.get(v[0].from);if(!F||F.type!=="parallel"){f=!1;break}if(v[0].on||v[0].when){f=!1;break}if(c===void 0)c=F.id;else if(c!==F.id){f=!1;break}u.push(E.id)}if(!f||c===void 0)continue;let h=t.get(c)??[],g=i.get(c)??[];if(h.length!==1||!h[0].on)continue;let k=new Set(u);if(!(!g.every($=>k.has($.to))||g.length!==u.length)){o.set(a.id,{parallelId:c,entryEdge:h[0],legIds:u,faninId:a.id}),s.add(c);for(let $ of u)s.add($)}}return{byFanin:o,memberIds:s}}var lt=new Set(En);function en(r,e={}){let t=[],i=new Map(r.nodes.map(a=>[a.id,a]));for(let a of r.nodes)a.declared||t.push({level:"error",code:"node.undeclared",message:`node '${a.id}' is referenced in an edge but never declared`,where:{node:a.id,line:a.line},hint:`add a node statement, e.g. ${a.id} [type=...]`});for(let a of r.nodes){if(lt.has(a.type)&&!a.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${a.id}' (type ${a.type}) needs a role="..." job description`,where:{node:a.id,line:a.line}}),a.attrs.permissions!==void 0){try{ot(a)}catch(d){t.push({level:"error",code:"node.bad-permissions",message:d.message,where:{node:a.id,line:a.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(a.type==="start"||a.type==="exit"||a.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${a.id}' (type ${a.type}) is ignored \u2014 this node emits no workflow job`,where:{node:a.id,line:a.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}a.type==="human-gate"&&a.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${a.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:a.id,line:a.line}}),a.type==="merge-gate"&&!a.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${a.id}' has no policy="..."; default merge policy will be used`,where:{node:a.id,line:a.line}})}if(e.fileExists)for(let a of r.nodes)for(let d of["role","policy","prompt","tools"]){let u=a.files[d];u&&!e.fileExists(u)&&t.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${d}="${u}" which does not exist`,where:{node:a.id,line:a.line,file:u}})}if(e.roles){let a=new Map;for(let u of r.nodes)a.set(u.id,[]);for(let u of r.edges){let c=i.get(u.to);c&&a.get(u.from)?.push({node:c,edge:u})}let d=u=>(e.roles?.get(u.id)?.role??u.id).toLowerCase();for(let u of r.nodes){let c=e.roles.get(u.id);if(!c?.handoffs)continue;let f=a.get(u.id)??[],h=new Set(f.flatMap(k=>[k.node.id.toLowerCase(),d(k.node)])),g=new Set(c.handoffs.map(k=>String(k.to).toLowerCase()));for(let k of c.handoffs)h.has(String(k.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${c.role}' (node '${u.id}') declares a handoff to '${k.to}' but there is no matching out-edge`,where:{node:u.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:k,edge:$}of f)k.type==="exit"&&!$.when||!g.has(k.id.toLowerCase())&&!g.has(d(k))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${u.id}' has an out-edge to '${k.id}' not declared as a handoff in role '${c.role}'`,where:{node:u.id,edge:[u.id,k.id]},hint:"document the handoff in the role, or remove the edge"})}}let o=(a,d)=>{if(typeof a=="string"){let u=a.match(/<[A-Za-z][^<>]{0,80}>/);u&&t.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${u[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(a))a.forEach((u,c)=>o(u,`${d}[${c}]`));else if(a&&typeof a=="object")for(let[u,c]of Object.entries(a))o(c,d?`${d}.${u}`:u)};if(o(r.config,""),e.fileExists&&(r.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,d=!1;for(let u of r.nodes)lt.has(u.type)&&(d=!0,a.add("run-agent")),lt.has(u.type)&&u.type!=="scheduled-agent"&&a.add("agent-context"),(u.type==="producer"||u.type==="scheduled-agent")&&a.add("agent-fallback"),u.type==="merge-gate"&&a.add("merge-gate"),u.type==="pr-review"&&u.attrs.gates!==void 0&&a.add("wait-for-checks");for(let u of a)e.fileExists(`actions/${u}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${u}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&t.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:a,memberIds:d}=qe(r);for(let u of r.nodes)if(u.type==="parallel"&&!d.has(u.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${u.id}' is not part of a clean diamond (need: exactly one in-edge carrying on=, \u22652 bare out-edges to agent legs that each flow into one fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),u.type==="fan_in"){let c=a.get(u.id);if(!c)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${u.id}' is not the join of a clean diamond (need \u22652 legs, each with exactly one in-edge from a shared parallel and one out-edge into this fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!u.files.role&&u.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${u.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:u.id,line:u.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let f=c.legIds.filter(h=>i.get(h)?.type==="pr-review");f.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${u.id}' lanes [${f.join(", ")}] are pr-review typed \u2014 if a lane role posts a '**Verdict:**' review, the merge gate acts on ONE lane's opinion and the join is bypassed`,where:{node:u.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(ze(r.config).mode==="github-token"){let a=r.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));a.length&&t.push({level:r.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${a.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!r.config.identity?.bot_login&&r.edges.some(a=>/^verdict=/.test(a.when??""))&&t.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),r.nodes.some(a=>a.type==="start"||a.attrs.schedule!==void 0||a.type==="merge-gate")||t.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),t}I();var zr=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),oi=new Set(["start"]);function nn(r){let e=[],t=new Set(r.nodes.map(c=>c.id)),i=new Map(r.nodes.map(c=>[c.id,c])),o=new Map;for(let c of t)o.set(c,[]);for(let c of r.edges)t.has(c.from)&&t.has(c.to)&&o.get(c.from).push(c.to);let s=r.nodes.filter(c=>oi.has(c.type)||c.attrs.schedule!==void 0||c.type==="merge-gate"),a=new Set,d=s.map(c=>c.id);for(;d.length;){let c=d.pop();if(!a.has(c)){a.add(c);for(let f of o.get(c)??[])d.push(f)}}for(let c of r.nodes)!a.has(c.id)&&!oi.has(c.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${c.id}' is unreachable from any entry (start/scheduled) node`,where:{node:c.id,line:c.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let c of r.nodes)(o.get(c.id)??[]).length===0&&!zr.has(c.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${c.id}' (type ${c.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:c.id,line:c.line},hint:"route it to a next node, or make it an exit"});for(let c of Zr(t,o)){if(!(c.length>1||(o.get(c[0])??[]).includes(c[0])))continue;let h=new Set(c),g=[];for(let k of c)for(let $ of o.get(k)??[])h.has($)||g.push({from:k,to:$});g.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${c.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:c[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):g.some(k=>Qr(Xr(r,k.from,k.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${c.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:c[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let u=new Map;for(let c of r.edges){let f=`${c.on??""}|${c.when??""}`;u.has(c.from)||u.set(c.from,new Map);let h=u.get(c.from);h.has(f)||h.set(f,new Set),h.get(f).add(c.to)}for(let[c,f]of u)for(let[h,g]of f)g.size>1&&h!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${c}' has multiple edges with identical trigger/guard (${h}) to different targets: ${[...g].join(", ")}`,where:{node:c},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Xr(r,e,t){return r.edges.find(i=>i.from===e&&i.to===t)?.when}function Qr(r){return r?/(>=|>|attempts|max|count|limit)/i.test(r):!1}function Zr(r,e){let t=0,i=new Map,o=new Map,s=new Set,a=[],d=[],u=c=>{i.set(c,t),o.set(c,t),t++,a.push(c),s.add(c);for(let f of e.get(c)??[])i.has(f)?s.has(f)&&o.set(c,Math.min(o.get(c),i.get(f))):(u(f),o.set(c,Math.min(o.get(c),o.get(f))));if(o.get(c)===i.get(c)){let f=[],h;do h=a.pop(),s.delete(h),f.push(h);while(h!==c);d.push(f.reverse())}};for(let c of r)i.has(c)||u(c);return d}I();var eo=new Set(["pr-review","pr-fix"]);function no(r,e){return e.labels?.[r]??r}function Hn(r){return eo.has(r.type)||r.context==="pr-diff"||r.context==="pr-review"}function si(r,e,t){let i=(o,s)=>{r[o]??={},r[o].types??=[],r[o].types.includes(s)||r[o].types.push(s)};switch(e){case"issues.opened":return i("issues","opened");case"issues.labeled":return i("issues","labeled");case"issue_comment.created":return i("issue_comment","created");case"pull_request.opened":return i("pull_request","opened");case"pull_request.synchronize":return i("pull_request","synchronize");case"pull_request.labeled":return i("pull_request","labeled");case"pull_request.closed":return i("pull_request","closed");case"pull_request_review.submitted":return i("pull_request_review","submitted");case"push":if(Hn(t))return i("pull_request","synchronize");r.push??={};return;case"workflow_dispatch":r.workflow_dispatch??={};return;default:r[e]??={}}}function Tn(r,e){return r==="push"&&Hn(e)?"pull_request.synchronize":r}function ci(r){let[e,t]=r.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function to(r,e,t){if(r.on)return{events:r.on.split(",").map(s=>s.trim()).filter(Boolean),guard:r.when?Nn(r.when,e,t):void 0};if(!r.when)return;let i=r.when;if(i.startsWith("label="))return{events:[Hn(e)?"pull_request.labeled":"issues.labeled"],guard:Nn(i,e,t)};if(i.startsWith("verdict="))return{events:["pull_request_review.submitted"],guard:Nn(i,e,t)}}function Nn(r,e,t){if(r.startsWith("label="))return`github.event.label.name == '${no(r.slice(6),t)}'`;let i=r==="verdict=approve"?"APPROVE":r==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(i){let o=`contains(github.event.review.body, '**Verdict:** ${i}')`,s=io(t);return s?`${o} && ${s}`:o}}function io(r){let e=r.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function ai(r){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(r)}function ro(r){let e=r.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function li(r,e,t){let i=ro(t),o=[...e].filter(ai);if(!i||o.length===0)return r;let s=[...e].filter(d=>!ai(d)),a=s.length?`(${s.map(ci).join(" || ")} || ${i})`:i;return r?`(${r}) && ${a}`:a}function oo(r){if(r.attrs.schedule!==void 0)return{group:r.id,"cancel-in-progress":!1};let t=Hn(r)||r.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${r.id}-${t}`,"cancel-in-progress":r.type==="issue-agent"}}function ui(r){let e={},t=new Map(r.nodes.map(s=>[s.id,s])),i=new Map;for(let s of r.nodes)i.set(s.id,[]);for(let s of r.edges)i.get(s.to)?.push(s);let o=qe(r);for(let s of r.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let a=o.byFanin.get(s.id);if(a){let $=a.entryEdge,E=t.get(a.legIds[0]),v={},P=($.on??"").split(",").map(K=>K.trim()).filter(Boolean);for(let K of P)si(v,K,E);let F={nodeId:s.id,triggers:v,dispatches:[]},L=new Set(P.map(K=>Tn(K,E))),D=li($.when?Nn($.when,E,r.config):void 0,L,r.config);D&&(F.guard=D);let oe=P.some(K=>Tn(K,E).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";F.concurrency={group:`${s.id}-${oe}`,"cancel-in-progress":!1},e[s.id]=F;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let d={},u=new Set,c=new Set,f=new Set,h=[];if(s.attrs.schedule!==void 0)d.schedule=[{cron:String(s.attrs.schedule)}],d.workflow_dispatch={};else{for(let $ of i.get(s.id)??[]){let E=to($,s,r.config);if(E){for(let v of E.events)si(d,v,s);for(let v of E.events)f.add(Tn(v,s));if(E.guard)u.add(E.guard);else for(let v of E.events)c.add(Tn(v,s))}}if(u.size&&c.size)for(let $ of c)u.add(ci($))}for(let $ of r.edges)$.from===s.id&&$.do&&h.push({toNode:$.to,when:$.when});let g=li(u.size?[...u].join(" || "):void 0,f,r.config),k={nodeId:s.id,triggers:d,dispatches:h};g&&(k.guard=g),Object.keys(d).length&&(k.concurrency=oo(s)),e[s.id]=k}return{perNode:e}}I();I();function so(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ie={},Rn={},ve={},di;function tn(){if(di)return ve;di=1;function r(a){return typeof a>"u"||a===null}function e(a){return typeof a=="object"&&a!==null}function t(a){return Array.isArray(a)?a:r(a)?[]:[a]}function i(a,d){if(d){let u=Object.keys(d);for(let c=0,f=u.length;c<f;c+=1){let h=u[c];a[h]=d[h]}}return a}function o(a,d){let u="";for(let c=0;c<d;c+=1)u+=a;return u}function s(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}return ve.isNothing=r,ve.isObject=e,ve.toArray=t,ve.repeat=o,ve.isNegativeZero=s,ve.extend=i,ve}var ct,fi;function rn(){if(fi)return ct;fi=1;function r(t,i){let o="",s=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(o+='in "'+t.mark.name+'" '),o+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!i&&t.mark.snippet&&(o+=`
|
|
31
|
+
Closes #${He}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:r}}function Br(i){let e=i.node,t=Nn(i,{ref:ni,fetchDepth:0}),r=typeof e.attrs.max_attempts=="number"?e.attrs.max_attempts:3,o=`<!-- gp-foundry:attempt:${e.id} -->`,s=i.config.labels?.["needs-human"]??"needs-human",a=i.config.identity?.bot_login??"";t.push(de({id:"attempts",name:`Enforce attempt budget (max ${r})`,env:{GH_TOKEN:ce(i),PR:Ze,MARKER:o,MAX:String(r),BOT_LOGIN:a},run:["# One request-changes verdict = one attempt. The jq filter reads the bot","# login from the environment (never interpolated into the script), and an","# empty BOT_LOGIN counts any reviewer's request-changes.","# (--paginate emits one count per page, so the counts are summed.)",`COUNT=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," [ .[]",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',' | select(.state == "CHANGES_REQUESTED" or ((.body // "") | test("Verdict.*REQUEST_CHANGES")))'," ] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}')",'[ -n "$COUNT" ] || COUNT=0','echo "attempts so far: $COUNT / $MAX"','if [ "$COUNT" -gt "$MAX" ]; then',` gh pr edit "$PR" --add-label "${s}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${s}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${e.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${s}\` and stopping. A human should take this over.\\n\\n%s' "$COUNT" "$MAX" "$MARKER")"`,' echo "exhausted=true" >> "$GITHUB_OUTPUT"',"else",` gh pr comment "$PR" --body "$(printf '%s attempt %s of %s' "$MARKER" "$COUNT" "$MAX")" >/dev/null`,' echo "exhausted=false" >> "$GITHUB_OUTPUT"',"fi"].join(`
|
|
32
|
+
`)}));let d="steps.attempts.outputs.exhausted != 'true'";return t.push({...Le(),if:d}),t.push({...Qe(i,"pr-review",Ze),if:d}),t.push({...De(i,{withContext:!0}),if:d,timeoutMinutes:Tn(Se(e,35))}),t.push(de({name:"Commit and push fixes",if:`${d} && !cancelled()`,env:{BRANCH:ni},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${e.id}"`,"fi","# ...then push if HEAD is ahead of the remote (the agent may have committed itself).",'git fetch origin "$BRANCH" --quiet 2>/dev/null || true','if [ "$(git rev-parse HEAD)" != "$(git rev-parse "origin/$BRANCH" 2>/dev/null || echo none)" ]; then',' git push origin "HEAD:$BRANCH"',' echo "pushed fix to $BRANCH"',"else",' echo "no changes to push"',"fi"].join(`
|
|
33
|
+
`)})),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write"},timeoutMinutes:Se(e,35),steps:t}}function ii(i){return`gp-foundry/human-approval (${String(i.attrs.environment??"production")})`}var Ur="github-actions";function Vr(i){return`${ii(i)}@${Ur}`}function Gr(i){let e=i.node,t=Nn(i,{fetchDepth:0}),o=i.inEdges.map(s=>i.nodeById?.(s.from)).filter(s=>!!s&&s.type==="human-gate").map(Vr);return t.push({uses:i.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:ce(i),"checks-token":"${{ github.token }}","policy-path":we(i,e.files.policy),"base-branch":i.config.repo.base_branch,"branch-prefix":i.config.repo.branch_prefix,...i.config.identity?.bot_login?{"bot-login":i.config.identity.bot_login}:{},...o.length?{"required-checks":o.join(",")}:{}}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write",checks:"read"},timeoutMinutes:Se(e,10),steps:t}}function Wr(i){let e=i.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[de({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:ii(e),HEAD_SHA:$n,ENVIRONMENT:t},run:['if ! gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$CHECK_NAME" \\',' -f head_sha="$HEAD_SHA" \\'," -f status=completed \\"," -f conclusion=success \\"," -f 'output[title]=Approved' \\",' -f "output[summary]=Environment \\"$ENVIRONMENT\\" was approved by a human for $HEAD_SHA."; then',' echo "::error::Approved for $ENVIRONMENT, but publishing the approval check failed."',' echo "::error::The merge gate requires \\"$CHECK_NAME\\" on $HEAD_SHA, so this PR will not merge until it is published."'," exit 1","fi",'echo "Approved for $ENVIRONMENT."'].join(`
|
|
34
|
+
`)})]}}function Yr(i){let e=i.node,t=i.config,r=Nn(i,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",s=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&r.push(de({id:"branch",name:"Create branch",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}"},run:['BRANCH="$PREFIX$NODE-$RUN_ID"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
35
|
+
`)})),r.push(Le()),r.push({...De(i,{withContext:!1}),id:"agent",timeoutMinutes:Tn(Se(e,20))}),o==="pr"?r.push({uses:i.actionRef("agent-fallback"),name:"Commit, push branch, open PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}","base-branch":t.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":we(i,"agents/scope.yaml"),"pr-title":`${e.id}: scheduled update`,"pr-body":`Scheduled output from the \`${e.id}\` lane \u2014 review and merge like any agent PR.`,...s?{"allowed-paths":s}:{}}}):o==="direct"&&(r.push({uses:i.actionRef("agent-fallback"),name:"Strip protected paths, commit, push",with:{branch:t.repo.base_branch,"base-branch":t.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":we(i,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...s?{"allowed-paths":s}:{}}}),r.push(de({id:"recovery",name:"Create recovery branch",if:"${{ !cancelled() && steps.agent.outcome == 'failure' }}",env:{PREFIX:t.repo.branch_prefix,NODE:e.id,RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:['BRANCH="$PREFIX$NODE-recovery-$RUN_ID-$RUN_ATTEMPT"','git checkout -b "$BRANCH"','echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"'].join(`
|
|
36
|
+
`)})),r.push({uses:i.actionRef("agent-fallback"),name:"Preserve failed agent output for review",if:"${{ !cancelled() && steps.agent.outcome == 'failure' && steps.recovery.outcome == 'success' }}",with:{branch:"${{ steps.recovery.outputs.branch }}","base-branch":t.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":we(i,"agents/scope.yaml"),"pr-title":`${e.id}: recover incomplete scheduled output`,"pr-body":`Partial output from a failed \`${e.id}\` run. Review for completeness before merging. Run: \${{ github.server_url }}/\${{ github.repository }}/actions/runs/\${{ github.run_id }}`,"pr-label":i.config.labels?.["needs-human"]??"needs-human",...s?{"allowed-paths":s}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Se(e,20),steps:r}}function ri(i,e,t){let r=i.node,o=[],s=vn(i);s&&o.push(s),o.push(On(i,t?{ref:$n,fetchDepth:0}:void 0)),o.push(Le()),o.push(Qe(i,t?"pr-review":"issue",t?Ze:He)),r.files.role&&o.push(De(i,{withContext:!0}));let a=r.attrs.on_complete_label;if(typeof a=="string"&&a){let d=i.config.labels?.[a]??a;o.push(de({name:"Apply completion label",env:{GH_TOKEN:ce(i),NUM:t?Ze:He},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${d}'`}))}return ti(r,{jobId:r.id,name:r.id,needs:e,permissions:t?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:Se(r,15),steps:o})}var Kr={analyst:st,"issue-agent":st,"pr-review":st,producer:qr,"pr-fix":Br,"merge-gate":Gr,"human-gate":Wr,"scheduled-agent":Yr,start:()=>null,exit:()=>null};function lt(i,e,t){let r=Kr[i.type];if(!r)return null;let o=r(t);return o&&ti(i,o)}I();var Jr=new Set(Sn);function qe(i){let e=new Map(i.nodes.map(a=>[a.id,a])),t=new Map,r=new Map;for(let a of i.nodes)t.set(a.id,[]),r.set(a.id,[]);for(let a of i.edges)t.get(a.to)?.push(a),r.get(a.from)?.push(a);let o=new Map,s=new Set;for(let a of i.nodes){if(a.type!=="fan_in")continue;let d=t.get(a.id)??[];if(d.length<2)continue;let u=[],c,p=!0;for(let $ of d){let S=e.get($.from);if(!S||!Jr.has(S.type)){p=!1;break}let v=t.get(S.id)??[],P=r.get(S.id)??[];if(v.length!==1||P.length!==1||P[0].to!==a.id){p=!1;break}let F=e.get(v[0].from);if(!F||F.type!=="parallel"){p=!1;break}if(v[0].on||v[0].when){p=!1;break}if(c===void 0)c=F.id;else if(c!==F.id){p=!1;break}u.push(S.id)}if(!p||c===void 0)continue;let m=t.get(c)??[],g=r.get(c)??[];if(m.length!==1||!m[0].on)continue;let k=new Set(u);if(!(!g.every($=>k.has($.to))||g.length!==u.length)){o.set(a.id,{parallelId:c,entryEdge:m[0],legIds:u,faninId:a.id}),s.add(c);for(let $ of u)s.add($)}}return{byFanin:o,memberIds:s}}var Rn=new Set(Sn);function en(i,e={}){let t=[],r=new Map(i.nodes.map(a=>[a.id,a]));for(let a of i.nodes)a.declared||t.push({level:"error",code:"node.undeclared",message:`node '${a.id}' is referenced in an edge but never declared`,where:{node:a.id,line:a.line},hint:`add a node statement, e.g. ${a.id} [type=...]`});for(let a of i.nodes){if(Rn.has(a.type)&&!a.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${a.id}' (type ${a.type}) needs a role="..." job description`,where:{node:a.id,line:a.line}}),a.attrs.permissions!==void 0){try{at(a)}catch(d){t.push({level:"error",code:"node.bad-permissions",message:d.message,where:{node:a.id,line:a.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(a.type==="start"||a.type==="exit"||a.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${a.id}' (type ${a.type}) is ignored \u2014 this node emits no workflow job`,where:{node:a.id,line:a.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(a.attrs.agent_attempts!==void 0){let d=a.attrs.agent_attempts;(typeof d!="number"||!Number.isInteger(d)||d<1)&&t.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${a.id}' must be a whole number >= 1, got ${JSON.stringify(d)}`,where:{node:a.id,line:a.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),Rn.has(a.type)||t.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${a.id}' (type ${a.type}) is ignored \u2014 this node runs no agent`,where:{node:a.id,line:a.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}a.type==="human-gate"&&a.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${a.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:a.id,line:a.line}}),a.type==="merge-gate"&&!a.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${a.id}' has no policy="..."; default merge policy will be used`,where:{node:a.id,line:a.line}})}if(e.fileExists)for(let a of i.nodes)for(let d of["role","policy","prompt","tools"]){let u=a.files[d];u&&!e.fileExists(u)&&t.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${d}="${u}" which does not exist`,where:{node:a.id,line:a.line,file:u}})}if(e.roles){let a=new Map;for(let u of i.nodes)a.set(u.id,[]);for(let u of i.edges){let c=r.get(u.to);c&&a.get(u.from)?.push({node:c,edge:u})}let d=u=>(e.roles?.get(u.id)?.role??u.id).toLowerCase();for(let u of i.nodes){let c=e.roles.get(u.id);if(!c?.handoffs)continue;let p=a.get(u.id)??[],m=new Set(p.flatMap(k=>[k.node.id.toLowerCase(),d(k.node)])),g=new Set(c.handoffs.map(k=>String(k.to).toLowerCase()));for(let k of c.handoffs)m.has(String(k.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${c.role}' (node '${u.id}') declares a handoff to '${k.to}' but there is no matching out-edge`,where:{node:u.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:k,edge:$}of p)k.type==="exit"&&!$.when||!g.has(k.id.toLowerCase())&&!g.has(d(k))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${u.id}' has an out-edge to '${k.id}' not declared as a handoff in role '${c.role}'`,where:{node:u.id,edge:[u.id,k.id]},hint:"document the handoff in the role, or remove the edge"})}}let o=(a,d)=>{if(typeof a=="string"){let u=a.match(/<[A-Za-z][^<>]{0,80}>/);u&&t.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${u[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(a))a.forEach((u,c)=>o(u,`${d}[${c}]`));else if(a&&typeof a=="object")for(let[u,c]of Object.entries(a))o(c,d?`${d}.${u}`:u)};if(o(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,d=!1;for(let u of i.nodes)Rn.has(u.type)&&(d=!0,a.add("run-agent")),Rn.has(u.type)&&u.type!=="scheduled-agent"&&a.add("agent-context"),(u.type==="producer"||u.type==="scheduled-agent")&&a.add("agent-fallback"),u.type==="merge-gate"&&a.add("merge-gate"),u.type==="pr-review"&&u.attrs.gates!==void 0&&a.add("wait-for-checks");for(let u of a)e.fileExists(`actions/${u}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${u}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&t.push({level:"warning",code:"runtime.agent-setup-missing",message:"generated agent jobs use ./.github/agent-setup, which does not exist",hint:"run `gp-foundry vendor` (or `gp-foundry init`) to scaffold the agent-setup shim"})}{let{byFanin:a,memberIds:d}=qe(i);for(let u of i.nodes)if(u.type==="parallel"&&!d.has(u.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${u.id}' is not part of a clean diamond (need: exactly one in-edge carrying on=, \u22652 bare out-edges to agent legs that each flow into one fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),u.type==="fan_in"){let c=a.get(u.id);if(!c)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${u.id}' is not the join of a clean diamond (need \u22652 legs, each with exactly one in-edge from a shared parallel and one out-edge into this fan_in)`,where:{node:u.id,line:u.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!u.files.role&&u.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${u.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:u.id,line:u.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let p=c.legIds.filter(m=>r.get(m)?.type==="pr-review");p.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${u.id}' lanes [${p.join(", ")}] are pr-review typed \u2014 if a lane role posts a '**Verdict:**' review, the merge gate acts on ONE lane's opinion and the join is bypassed`,where:{node:u.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(ze(i.config).mode==="github-token"){let a=i.edges.filter(d=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(d.on??"")||/^(label=|verdict=)/.test(d.when??""));a.length&&t.push({level:i.config.auth?.mode==="github-token"?"error":"warning",code:"auth.github-token-no-cascade",message:`auth mode 'github-token': commits/PRs made with GITHUB_TOKEN do not trigger other workflows, so ${a.length} event-cascade edge(s) (pull_request.opened/synchronize/push) will not fire and the harness will stall`,hint:"use auth.mode 'app' or 'pat' (a fine-grained PAT secret), or drive those stages via explicit dispatch"})}return!i.config.identity?.bot_login&&i.edges.some(a=>/^verdict=/.test(a.when??""))&&t.push({level:"warning",code:"auth.no-bot-login",message:"identity.bot_login is unset, so verdict-triggered workflows (fixer, human-gate) guard only on the verdict marker \u2014 any user who can review the PR can fire them",hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"}),i.nodes.some(a=>a.type==="start"||a.attrs.schedule!==void 0||a.type==="merge-gate")||t.push({level:"warning",code:"graph.no-entry",message:"harness has no entry node (a start node or a scheduled node) \u2014 nothing will trigger it"}),t}I();var zr=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),oi=new Set(["start"]);function nn(i){let e=[],t=new Set(i.nodes.map(c=>c.id)),r=new Map(i.nodes.map(c=>[c.id,c])),o=new Map;for(let c of t)o.set(c,[]);for(let c of i.edges)t.has(c.from)&&t.has(c.to)&&o.get(c.from).push(c.to);let s=i.nodes.filter(c=>oi.has(c.type)||c.attrs.schedule!==void 0||c.type==="merge-gate"),a=new Set,d=s.map(c=>c.id);for(;d.length;){let c=d.pop();if(!a.has(c)){a.add(c);for(let p of o.get(c)??[])d.push(p)}}for(let c of i.nodes)!a.has(c.id)&&!oi.has(c.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${c.id}' is unreachable from any entry (start/scheduled) node`,where:{node:c.id,line:c.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let c of i.nodes)(o.get(c.id)??[]).length===0&&!zr.has(c.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${c.id}' (type ${c.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:c.id,line:c.line},hint:"route it to a next node, or make it an exit"});for(let c of Zr(t,o)){if(!(c.length>1||(o.get(c[0])??[]).includes(c[0])))continue;let m=new Set(c),g=[];for(let k of c)for(let $ of o.get(k)??[])m.has($)||g.push({from:k,to:$});g.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${c.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:c[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):g.some(k=>Qr(Xr(i,k.from,k.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${c.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:c[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let u=new Map;for(let c of i.edges){let p=`${c.on??""}|${c.when??""}`;u.has(c.from)||u.set(c.from,new Map);let m=u.get(c.from);m.has(p)||m.set(p,new Set),m.get(p).add(c.to)}for(let[c,p]of u)for(let[m,g]of p)g.size>1&&m!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${c}' has multiple edges with identical trigger/guard (${m}) to different targets: ${[...g].join(", ")}`,where:{node:c},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function Xr(i,e,t){return i.edges.find(r=>r.from===e&&r.to===t)?.when}function Qr(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function Zr(i,e){let t=0,r=new Map,o=new Map,s=new Set,a=[],d=[],u=c=>{r.set(c,t),o.set(c,t),t++,a.push(c),s.add(c);for(let p of e.get(c)??[])r.has(p)?s.has(p)&&o.set(c,Math.min(o.get(c),r.get(p))):(u(p),o.set(c,Math.min(o.get(c),o.get(p))));if(o.get(c)===r.get(c)){let p=[],m;do m=a.pop(),s.delete(m),p.push(m);while(m!==c);d.push(p.reverse())}};for(let c of i)r.has(c)||u(c);return d}I();var eo=new Set(["pr-review","pr-fix"]);function no(i,e){return e.labels?.[i]??i}function In(i){return eo.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function si(i,e,t){let r=(o,s)=>{i[o]??={},i[o].types??=[],i[o].types.includes(s)||i[o].types.push(s)};switch(e){case"issues.opened":return r("issues","opened");case"issues.labeled":return r("issues","labeled");case"issue_comment.created":return r("issue_comment","created");case"pull_request.opened":return r("pull_request","opened");case"pull_request.synchronize":return r("pull_request","synchronize");case"pull_request.labeled":return r("pull_request","labeled");case"pull_request.closed":return r("pull_request","closed");case"pull_request_review.submitted":return r("pull_request_review","submitted");case"push":if(In(t))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function tn(i,e){return i==="push"&&In(e)?"pull_request.synchronize":i}function ci(i){let[e,t]=i.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function to(i,e,t){if(i.on){let o=i.on.split(",").map(a=>a.trim()).filter(Boolean),s=o.map(a=>tn(a,e));return{events:o,guard:i.when?Hn(i.when,s,t):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[In(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Hn(r,o,t)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Hn(r,o,t)}}}function Hn(i,e,t){if(i.startsWith("label=")){let o=`github.event.label.name == '${no(i.slice(6),t)}'`,s=io(e);return s?`${o} && ${s}`:o}let r=i==="verdict=approve"?"APPROVE":i==="verdict=request_changes"?"REQUEST_CHANGES":void 0;if(r){let o=`contains(github.event.review.body, '**Verdict:** ${r}')`,s=ro(t);return s?`${o} && ${s}`:o}}function io(i){if(i.length&&i.every(e=>e.split(".")[0]==="issues"))return"github.event.issue.state == 'open'";if(i.length&&i.every(e=>e.split(".")[0]==="pull_request"))return"github.event.pull_request.state == 'open'"}function ro(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function ai(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function oo(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function li(i,e,t){let r=oo(t),o=[...e].filter(ai);if(!r||o.length===0)return i;let s=[...e].filter(d=>!ai(d)),a=s.length?`(${s.map(ci).join(" || ")} || ${r})`:r;return i?`(${i}) && ${a}`:a}function so(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":!1};let t=In(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${t}`,"cancel-in-progress":i.type==="issue-agent"}}function ui(i){let e={},t=new Map(i.nodes.map(s=>[s.id,s])),r=new Map;for(let s of i.nodes)r.set(s.id,[]);for(let s of i.edges)r.get(s.to)?.push(s);let o=qe(i);for(let s of i.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let a=o.byFanin.get(s.id);if(a){let $=a.entryEdge,S=t.get(a.legIds[0]),v={},P=($.on??"").split(",").map(K=>K.trim()).filter(Boolean);for(let K of P)si(v,K,S);let F={nodeId:s.id,triggers:v,dispatches:[]},L=new Set(P.map(K=>tn(K,S))),D=li($.when?Hn($.when,[...L],i.config):void 0,L,i.config);D&&(F.guard=D);let oe=P.some(K=>tn(K,S).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";F.concurrency={group:`${s.id}-${oe}`,"cancel-in-progress":!1},e[s.id]=F;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let d={},u=new Set,c=new Set,p=new Set,m=[];if(s.attrs.schedule!==void 0)d.schedule=[{cron:String(s.attrs.schedule)}],d.workflow_dispatch={};else{for(let $ of r.get(s.id)??[]){let S=to($,s,i.config);if(S){for(let v of S.events)si(d,v,s);for(let v of S.events)p.add(tn(v,s));if(S.guard)u.add(S.guard);else for(let v of S.events)c.add(tn(v,s))}}if(u.size&&c.size)for(let $ of c)u.add(ci($))}for(let $ of i.edges)$.from===s.id&&$.do&&m.push({toNode:$.to,when:$.when});let g=li(u.size?[...u].join(" || "):void 0,p,i.config),k={nodeId:s.id,triggers:d,dispatches:m};g&&(k.guard=g),Object.keys(d).length&&(k.concurrency=so(s)),e[s.id]=k}return{perNode:e}}I();I();function ao(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ie={},Pn={},ve={},di;function rn(){if(di)return ve;di=1;function i(a){return typeof a>"u"||a===null}function e(a){return typeof a=="object"&&a!==null}function t(a){return Array.isArray(a)?a:i(a)?[]:[a]}function r(a,d){if(d){let u=Object.keys(d);for(let c=0,p=u.length;c<p;c+=1){let m=u[c];a[m]=d[m]}}return a}function o(a,d){let u="";for(let c=0;c<d;c+=1)u+=a;return u}function s(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}return ve.isNothing=i,ve.isObject=e,ve.toArray=t,ve.repeat=o,ve.isNegativeZero=s,ve.extend=r,ve}var ct,pi;function on(){if(pi)return ct;pi=1;function i(t,r){let o="",s=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(o+='in "'+t.mark.name+'" '),o+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!r&&t.mark.snippet&&(o+=`
|
|
36
37
|
|
|
37
|
-
`+t.mark.snippet),s+" "+o):s}function e(t,
|
|
38
|
-
`+
|
|
39
|
-
`,
|
|
40
|
-
`;for(let
|
|
41
|
-
`}return
|
|
42
|
-
\r`;function t(a){if(a===null)return!1;let d=0,u=a.length,c=e;for(let
|
|
43
|
-
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function j(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}function se(n,
|
|
44
|
-
`,
|
|
45
|
-
`,b?1+
|
|
46
|
-
`);break}y?L(_)?(C=!0,n.result+=
|
|
47
|
-
`,b?1+
|
|
48
|
-
`,
|
|
49
|
-
`,
|
|
50
|
-
`,b?1+
|
|
51
|
-
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));let y=new ee(n,
|
|
52
|
-
`,w);N===-1?(x=l.slice(w),w=
|
|
53
|
-
`&&(_+=C),_+=x}return _}function Me(l,
|
|
54
|
-
`+
|
|
55
|
-
`,
|
|
38
|
+
`+t.mark.snippet),s+" "+o):s}function e(t,r){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=r,this.message=i(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+i(this,r)},ct=e,ct}var ut,fi;function lo(){if(fi)return ut;fi=1;let i=rn();function e(o,s,a,d,u){let c="",p="",m=Math.floor(u/2)-1;return d-s>m&&(c=" ... ",s=d-m+c.length),a-d>m&&(p=" ...",a=d+m-p.length),{str:c+o.slice(s,a).replace(/\t/g,"\u2192")+p,pos:d-s+c.length}}function t(o,s){return i.repeat(" ",s-o.length)+o}function r(o,s){if(s=Object.create(s||null),!o.buffer)return null;s.maxLength||(s.maxLength=79),typeof s.indent!="number"&&(s.indent=1),typeof s.linesBefore!="number"&&(s.linesBefore=3),typeof s.linesAfter!="number"&&(s.linesAfter=2);let a=/\r?\n|\r|\0/g,d=[0],u=[],c,p=-1;for(;c=a.exec(o.buffer);)u.push(c.index),d.push(c.index+c[0].length),o.position<=c.index&&p<0&&(p=d.length-2);p<0&&(p=d.length-1);let m="",g=Math.min(o.line+s.linesAfter,u.length).toString().length,k=s.maxLength-(s.indent+g+3);for(let S=1;S<=s.linesBefore&&!(p-S<0);S++){let v=e(o.buffer,d[p-S],u[p-S],o.position-(d[p]-d[p-S]),k);m=i.repeat(" ",s.indent)+t((o.line-S+1).toString(),g)+" | "+v.str+`
|
|
39
|
+
`+m}let $=e(o.buffer,d[p],u[p],o.position,k);m+=i.repeat(" ",s.indent)+t((o.line+1).toString(),g)+" | "+$.str+`
|
|
40
|
+
`,m+=i.repeat("-",s.indent+g+3+$.pos)+`^
|
|
41
|
+
`;for(let S=1;S<=s.linesAfter&&!(p+S>=u.length);S++){let v=e(o.buffer,d[p+S],u[p+S],o.position-(d[p]-d[p+S]),k);m+=i.repeat(" ",s.indent)+t((o.line+S+1).toString(),g)+" | "+v.str+`
|
|
42
|
+
`}return m.replace(/\n$/,"")}return ut=r,ut}var dt,hi;function re(){if(hi)return dt;hi=1;let i=on(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],t=["scalar","sequence","mapping"];function r(s){let a={};return s!==null&&Object.keys(s).forEach(function(d){s[d].forEach(function(u){a[String(u)]=d})}),a}function o(s,a){if(a=a||{},Object.keys(a).forEach(function(d){if(e.indexOf(d)===-1)throw new i('Unknown option "'+d+'" is met in definition of "'+s+'" YAML type.')}),this.options=a,this.tag=s,this.kind=a.kind||null,this.resolve=a.resolve||function(){return!0},this.construct=a.construct||function(d){return d},this.instanceOf=a.instanceOf||null,this.predicate=a.predicate||null,this.represent=a.represent||null,this.representName=a.representName||null,this.defaultStyle=a.defaultStyle||null,this.multi=a.multi||!1,this.styleAliases=r(a.styleAliases||null),t.indexOf(this.kind)===-1)throw new i('Unknown kind "'+this.kind+'" is specified for "'+s+'" YAML type.')}return dt=o,dt}var pt,mi;function Mi(){if(mi)return pt;mi=1;let i=on(),e=re();function t(s,a){let d=[];return s[a].forEach(function(u){let c=d.length;d.forEach(function(p,m){p.tag===u.tag&&p.kind===u.kind&&p.multi===u.multi&&(c=m)}),d[c]=u}),d}function r(){let s={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function a(d){d.multi?(s.multi[d.kind].push(d),s.multi.fallback.push(d)):s[d.kind][d.tag]=s.fallback[d.tag]=d}for(let d=0,u=arguments.length;d<u;d+=1)arguments[d].forEach(a);return s}function o(s){return this.extend(s)}return o.prototype.extend=function(a){let d=[],u=[];if(a instanceof e)u.push(a);else if(Array.isArray(a))u=u.concat(a);else if(a&&(Array.isArray(a.implicit)||Array.isArray(a.explicit)))a.implicit&&(d=d.concat(a.implicit)),a.explicit&&(u=u.concat(a.explicit));else throw new i("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");d.forEach(function(p){if(!(p instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(p.loadKind&&p.loadKind!=="scalar")throw new i("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(p.multi)throw new i("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),u.forEach(function(p){if(!(p instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let c=Object.create(o.prototype);return c.implicit=(this.implicit||[]).concat(d),c.explicit=(this.explicit||[]).concat(u),c.compiledImplicit=t(c,"implicit"),c.compiledExplicit=t(c,"explicit"),c.compiledTypeMap=r(c.compiledImplicit,c.compiledExplicit),c},pt=o,pt}var ft,gi;function Fi(){if(gi)return ft;gi=1;let i=re();return ft=new i("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),ft}var ht,bi;function ji(){if(bi)return ht;bi=1;let i=re();return ht=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),ht}var mt,yi;function Li(){if(yi)return mt;yi=1;let i=re();return mt=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),mt}var gt,wi;function Di(){if(wi)return gt;wi=1;let i=Mi();return gt=new i({explicit:[Fi(),ji(),Li()]}),gt}var bt,_i;function qi(){if(_i)return bt;_i=1;let i=re();function e(o){if(o===null)return!0;let s=o.length;return s===1&&o==="~"||s===4&&(o==="null"||o==="Null"||o==="NULL")}function t(){return null}function r(o){return o===null}return bt=new i("tag:yaml.org,2002:null",{kind:"scalar",resolve:e,construct:t,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),bt}var yt,Ai;function Bi(){if(Ai)return yt;Ai=1;let i=re();function e(o){if(o===null)return!1;let s=o.length;return s===4&&(o==="true"||o==="True"||o==="TRUE")||s===5&&(o==="false"||o==="False"||o==="FALSE")}function t(o){return o==="true"||o==="True"||o==="TRUE"}function r(o){return Object.prototype.toString.call(o)==="[object Boolean]"}return yt=new i("tag:yaml.org,2002:bool",{kind:"scalar",resolve:e,construct:t,predicate:r,represent:{lowercase:function(o){return o?"true":"false"},uppercase:function(o){return o?"TRUE":"FALSE"},camelcase:function(o){return o?"True":"False"}},defaultStyle:"lowercase"}),yt}var wt,ki;function Ui(){if(ki)return wt;ki=1;let i=rn(),e=re();function t(c){return c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102}function r(c){return c>=48&&c<=55}function o(c){return c>=48&&c<=57}function s(c){if(c===null)return!1;let p=c.length,m=0,g=!1;if(!p)return!1;let k=c[m];if((k==="-"||k==="+")&&(k=c[++m]),k==="0"){if(m+1===p)return!0;if(k=c[++m],k==="b"){for(m++;m<p;m++){if(k=c[m],k!=="0"&&k!=="1")return!1;g=!0}return g&&isFinite(a(c))}if(k==="x"){for(m++;m<p;m++){if(!t(c.charCodeAt(m)))return!1;g=!0}return g&&isFinite(a(c))}if(k==="o"){for(m++;m<p;m++){if(!r(c.charCodeAt(m)))return!1;g=!0}return g&&isFinite(a(c))}}for(;m<p;m++){if(!o(c.charCodeAt(m)))return!1;g=!0}return g?isFinite(a(c)):!1}function a(c){let p=c,m=1,g=p[0];if((g==="-"||g==="+")&&(g==="-"&&(m=-1),p=p.slice(1),g=p[0]),p==="0")return 0;if(g==="0"){if(p[1]==="b")return m*parseInt(p.slice(2),2);if(p[1]==="x")return m*parseInt(p.slice(2),16);if(p[1]==="o")return m*parseInt(p.slice(2),8)}return m*parseInt(p,10)}function d(c){return a(c)}function u(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!i.isNegativeZero(c)}return wt=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:s,construct:d,predicate:u,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),wt}var _t,xi;function Vi(){if(xi)return _t;xi=1;let i=rn(),e=re(),t=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function o(c){return c===null||!t.test(c)?!1:isFinite(parseFloat(c,10))?!0:r.test(c)}function s(c){let p=c.toLowerCase(),m=p[0]==="-"?-1:1;return"+-".indexOf(p[0])>=0&&(p=p.slice(1)),p===".inf"?m===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:p===".nan"?NaN:m*parseFloat(p,10)}let a=/^[-+]?[0-9]+e/;function d(c,p){if(isNaN(c))switch(p){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(p){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(p){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(c))return"-0.0";let m=c.toString(10);return a.test(m)?m.replace("e",".e"):m}function u(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||i.isNegativeZero(c))}return _t=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:s,predicate:u,represent:d,defaultStyle:"lowercase"}),_t}var At,Ci;function Gi(){return Ci||(Ci=1,At=Di().extend({implicit:[qi(),Bi(),Ui(),Vi()]})),At}var kt,Ei;function Wi(){return Ei||(Ei=1,kt=Gi()),kt}var xt,Si;function Yi(){if(Si)return xt;Si=1;let i=re(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(a){return a===null?!1:e.exec(a)!==null||t.exec(a)!==null}function o(a){let d=0,u=null,c=e.exec(a);if(c===null&&(c=t.exec(a)),c===null)throw new Error("Date resolve error");let p=+c[1],m=+c[2]-1,g=+c[3];if(!c[4])return new Date(Date.UTC(p,m,g));let k=+c[4],$=+c[5],S=+c[6];if(c[7]){for(d=c[7].slice(0,3);d.length<3;)d+="0";d=+d}if(c[9]){let P=+c[10],F=+(c[11]||0);u=(P*60+F)*6e4,c[9]==="-"&&(u=-u)}let v=new Date(Date.UTC(p,m,g,k,$,S,d));return u&&v.setTime(v.getTime()-u),v}function s(a){return a.toISOString()}return xt=new i("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:s}),xt}var Ct,vi;function Ki(){if(vi)return Ct;vi=1;let i=re();function e(t){return t==="<<"||t===null}return Ct=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Ct}var Et,Oi;function Ji(){if(Oi)return Et;Oi=1;let i=re(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
43
|
+
\r`;function t(a){if(a===null)return!1;let d=0,u=a.length,c=e;for(let p=0;p<u;p++){let m=c.indexOf(a.charAt(p));if(!(m>64)){if(m<0)return!1;d+=6}}return d%8===0}function r(a){let d=a.replace(/[\r\n=]/g,""),u=d.length,c=e,p=0,m=[];for(let k=0;k<u;k++)k%4===0&&k&&(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)),p=p<<6|c.indexOf(d.charAt(k));let g=u%4*6;return g===0?(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)):g===18?(m.push(p>>10&255),m.push(p>>2&255)):g===12&&m.push(p>>4&255),new Uint8Array(m)}function o(a){let d="",u=0,c=a.length,p=e;for(let g=0;g<c;g++)g%3===0&&g&&(d+=p[u>>18&63],d+=p[u>>12&63],d+=p[u>>6&63],d+=p[u&63]),u=(u<<8)+a[g];let m=c%3;return m===0?(d+=p[u>>18&63],d+=p[u>>12&63],d+=p[u>>6&63],d+=p[u&63]):m===2?(d+=p[u>>10&63],d+=p[u>>4&63],d+=p[u<<2&63],d+=p[64]):m===1&&(d+=p[u>>2&63],d+=p[u<<4&63],d+=p[64],d+=p[64]),d}function s(a){return Object.prototype.toString.call(a)==="[object Uint8Array]"}return Et=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:t,construct:r,predicate:s,represent:o}),Et}var St,$i;function zi(){if($i)return St;$i=1;let i=re(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function r(s){if(s===null)return!0;let a=[],d=s;for(let u=0,c=d.length;u<c;u+=1){let p=d[u],m=!1;if(t.call(p)!=="[object Object]")return!1;let g;for(g in p)if(e.call(p,g))if(!m)m=!0;else return!1;if(!m)return!1;if(a.indexOf(g)===-1)a.push(g);else return!1}return!0}function o(s){return s!==null?s:[]}return St=new i("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),St}var vt,Ti;function Xi(){if(Ti)return vt;Ti=1;let i=re(),e=Object.prototype.toString;function t(o){if(o===null)return!0;let s=o,a=new Array(s.length);for(let d=0,u=s.length;d<u;d+=1){let c=s[d];if(e.call(c)!=="[object Object]")return!1;let p=Object.keys(c);if(p.length!==1)return!1;a[d]=[p[0],c[p[0]]]}return!0}function r(o){if(o===null)return[];let s=o,a=new Array(s.length);for(let d=0,u=s.length;d<u;d+=1){let c=s[d],p=Object.keys(c);a[d]=[p[0],c[p[0]]]}return a}return vt=new i("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:t,construct:r}),vt}var Ot,Ni;function Qi(){if(Ni)return Ot;Ni=1;let i=re(),e=Object.prototype.hasOwnProperty;function t(o){if(o===null)return!0;let s=o;for(let a in s)if(e.call(s,a)&&s[a]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return Ot=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:t,construct:r}),Ot}var $t,Ri;function Nt(){return Ri||(Ri=1,$t=Wi().extend({implicit:[Yi(),Ki()],explicit:[Ji(),zi(),Xi(),Qi()]})),$t}var Hi;function co(){if(Hi)return Pn;Hi=1;let i=rn(),e=on(),t=lo(),r=Nt(),o=Object.prototype.hasOwnProperty,s=1,a=2,d=3,u=4,c=1,p=2,m=3,g=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,k=/[\x85\u2028\u2029]/,$=/[,\[\]{}]/,S=/^(?:!|!!|![0-9A-Za-z-]+!)$/,v=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function P(n){return Object.prototype.toString.call(n)}function F(n){return n===10||n===13}function L(n){return n===9||n===32}function D(n){return n===9||n===32||n===10||n===13}function Z(n){return n===44||n===91||n===93||n===123||n===125}function oe(n){if(n>=48&&n<=57)return n-48;let f=n|32;return f>=97&&f<=102?f-97+10:-1}function K(n){return n===120?2:n===117?4:n===85?8:0}function xe(n){return n>=48&&n<=57?n-48:-1}function Te(n){switch(n){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
44
|
+
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function j(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}function se(n,f,y){f==="__proto__"?Object.defineProperty(n,f,{configurable:!0,enumerable:!0,writable:!0,value:y}):n[f]=y}let Ne=new Array(256),te=new Array(256);for(let n=0;n<256;n++)Ne[n]=Te(n)?1:0,te[n]=Te(n);function ee(n,f){this.input=n,this.filename=f.filename||null,this.schema=f.schema||r,this.onWarning=f.onWarning||null,this.legacy=f.legacy||!1,this.json=f.json||!1,this.listener=f.listener||null,this.maxDepth=typeof f.maxDepth=="number"?f.maxDepth:100,this.maxTotalMergeKeys=typeof f.maxTotalMergeKeys=="number"?f.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function cn(n,f){let y={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return y.snippet=t(y),new e(f,y)}function R(n,f){throw cn(n,f)}function Pe(n,f){n.onWarning&&n.onWarning.call(null,cn(n,f))}function fe(n,f,y){let A=n.anchorMapTransactions;if(A.length!==0){let b=A[A.length-1];o.call(b,f)||(b[f]={existed:o.call(n.anchorMap,f),value:n.anchorMap[f]})}n.anchorMap[f]=y}function jn(n){n.anchorMapTransactions.push(Object.create(null))}function Re(n){let f=n.anchorMapTransactions.pop(),y=n.anchorMapTransactions;if(y.length===0)return;let A=y[y.length-1],b=Object.keys(f);for(let O=0,l=b.length;O<l;O+=1){let h=b[O];o.call(A,h)||(A[h]=f[h])}}function Ln(n){let f=n.anchorMapTransactions.pop(),y=Object.keys(f);for(let A=y.length-1;A>=0;A-=1){let b=f[y[A]];b.existed?n.anchorMap[y[A]]=b.value:delete n.anchorMap[y[A]]}}function Ge(n){return{position:n.position,line:n.line,lineStart:n.lineStart,lineIndent:n.lineIndent,firstTabInLine:n.firstTabInLine,tag:n.tag,anchor:n.anchor,kind:n.kind,result:n.result}}function Me(n,f){n.position=f.position,n.line=f.line,n.lineStart=f.lineStart,n.lineIndent=f.lineIndent,n.firstTabInLine=f.firstTabInLine,n.tag=f.tag,n.anchor=f.anchor,n.kind=f.kind,n.result=f.result}let un={YAML:function(f,y,A){f.version!==null&&R(f,"duplication of %YAML directive"),A.length!==1&&R(f,"YAML directive accepts exactly one argument");let b=/^([0-9]+)\.([0-9]+)$/.exec(A[0]);b===null&&R(f,"ill-formed argument of the YAML directive");let O=parseInt(b[1],10),l=parseInt(b[2],10);O!==1&&R(f,"unacceptable YAML version of the document"),f.version=A[0],f.checkLineBreaks=l<2,l!==1&&l!==2&&Pe(f,"unsupported YAML version of the document")},TAG:function(f,y,A){let b;A.length!==2&&R(f,"TAG directive accepts exactly two arguments");let O=A[0];b=A[1],S.test(O)||R(f,"ill-formed tag handle (first argument) of the TAG directive"),o.call(f.tagMap,O)&&R(f,'there is a previously declared suffix for "'+O+'" tag handle'),v.test(b)||R(f,"ill-formed tag prefix (second argument) of the TAG directive");try{b=decodeURIComponent(b)}catch{R(f,"tag prefix is malformed: "+b)}f.tagMap[O]=b}};function ae(n,f,y,A){if(f<y){let b=n.input.slice(f,y);if(A)for(let O=0,l=b.length;O<l;O+=1){let h=b.charCodeAt(O);h===9||h>=32&&h<=1114111||R(n,"expected valid JSON character")}else g.test(b)&&R(n,"the stream contains non-printable characters");n.result+=b}}function Ce(n,f,y,A){i.isObject(y)||R(n,"cannot merge mappings; the provided source object is unacceptable");let b=Object.keys(y);for(let O=0,l=b.length;O<l;O+=1){let h=b[O];n.maxTotalMergeKeys!==-1&&++n.totalMergeKeys>n.maxTotalMergeKeys&&R(n,"merge keys exceeded maxTotalMergeKeys ("+n.maxTotalMergeKeys+")"),o.call(f,h)||(se(f,h,y[h]),A[h]=!0)}}function he(n,f,y,A,b,O,l,h,C){if(Array.isArray(b)){b=Array.prototype.slice.call(b);for(let w=0,_=b.length;w<_;w+=1)Array.isArray(b[w])&&R(n,"nested arrays are not supported inside keys"),typeof b=="object"&&P(b[w])==="[object Object]"&&(b[w]="[object Object]")}if(typeof b=="object"&&P(b)==="[object Object]"&&(b="[object Object]"),b=String(b),f===null&&(f={}),A==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(let w=0,_=O.length;w<_;w+=1)Ce(n,f,O[w],y);else Ce(n,f,O,y);else!n.json&&!o.call(y,b)&&o.call(f,b)&&(n.line=l||n.line,n.lineStart=h||n.lineStart,n.position=C||n.position,R(n,"duplicated mapping key")),se(f,b,O),delete y[b];return f}function Fe(n){let f=n.input.charCodeAt(n.position);f===10?n.position++:f===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):R(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function z(n,f,y){let A=0,b=n.input.charCodeAt(n.position);for(;b!==0;){for(;L(b);)b===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),b=n.input.charCodeAt(++n.position);if(f&&b===35)do b=n.input.charCodeAt(++n.position);while(b!==10&&b!==13&&b!==0);if(F(b))for(Fe(n),b=n.input.charCodeAt(n.position),A++,n.lineIndent=0;b===32;)n.lineIndent++,b=n.input.charCodeAt(++n.position);else break}return y!==-1&&A!==0&&n.lineIndent<y&&Pe(n,"deficient indentation"),A}function je(n){let f=n.position,y=n.input.charCodeAt(f);return!!((y===45||y===46)&&y===n.input.charCodeAt(f+1)&&y===n.input.charCodeAt(f+2)&&(f+=3,y=n.input.charCodeAt(f),y===0||D(y)))}function me(n,f){f===1?n.result+=" ":f>1&&(n.result+=i.repeat(`
|
|
45
|
+
`,f-1))}function dn(n,f,y){let A,b,O,l,h,C,w=n.kind,_=n.result,E=n.input.charCodeAt(n.position);if(D(E)||Z(E)||E===35||E===38||E===42||E===33||E===124||E===62||E===39||E===34||E===37||E===64||E===96)return!1;if(E===63||E===45){let x=n.input.charCodeAt(n.position+1);if(D(x)||y&&Z(x))return!1}for(n.kind="scalar",n.result="",A=b=n.position,O=!1;E!==0;){if(E===58){let x=n.input.charCodeAt(n.position+1);if(D(x)||y&&Z(x))break}else if(E===35){let x=n.input.charCodeAt(n.position-1);if(D(x))break}else{if(n.position===n.lineStart&&je(n)||y&&Z(E))break;if(F(E))if(l=n.line,h=n.lineStart,C=n.lineIndent,z(n,!1,-1),n.lineIndent>=f){O=!0,E=n.input.charCodeAt(n.position);continue}else{n.position=b,n.line=l,n.lineStart=h,n.lineIndent=C;break}}O&&(ae(n,A,b,!1),me(n,n.line-l),A=b=n.position,O=!1),L(E)||(b=n.position+1),E=n.input.charCodeAt(++n.position)}return ae(n,A,b,!1),n.result?!0:(n.kind=w,n.result=_,!1)}function pn(n,f){let y,A,b=n.input.charCodeAt(n.position);if(b!==39)return!1;for(n.kind="scalar",n.result="",n.position++,y=A=n.position;(b=n.input.charCodeAt(n.position))!==0;)if(b===39)if(ae(n,y,n.position,!0),b=n.input.charCodeAt(++n.position),b===39)y=n.position,n.position++,A=n.position;else return!0;else F(b)?(ae(n,y,A,!0),me(n,z(n,!1,f)),y=A=n.position):n.position===n.lineStart&&je(n)?R(n,"unexpected end of the document within a single quoted scalar"):(n.position++,L(b)||(A=n.position));R(n,"unexpected end of the stream within a single quoted scalar")}function We(n,f){let y,A,b,O=n.input.charCodeAt(n.position);if(O!==34)return!1;for(n.kind="scalar",n.result="",n.position++,y=A=n.position;(O=n.input.charCodeAt(n.position))!==0;){if(O===34)return ae(n,y,n.position,!0),n.position++,!0;if(O===92){if(ae(n,y,n.position,!0),O=n.input.charCodeAt(++n.position),F(O))z(n,!1,f);else if(O<256&&Ne[O])n.result+=te[O],n.position++;else if((b=K(O))>0){let l=b,h=0;for(;l>0;l--)O=n.input.charCodeAt(++n.position),(b=oe(O))>=0?h=(h<<4)+b:R(n,"expected hexadecimal character");n.result+=j(h),n.position++}else R(n,"unknown escape sequence");y=A=n.position}else F(O)?(ae(n,y,A,!0),me(n,z(n,!1,f)),y=A=n.position):n.position===n.lineStart&&je(n)?R(n,"unexpected end of the document within a double quoted scalar"):(n.position++,L(O)||(A=n.position))}R(n,"unexpected end of the stream within a double quoted scalar")}function fn(n,f){let y=!0,A,b,O,l=n.tag,h,C=n.anchor,w,_,E,x,N=Object.create(null),T,H,M,q=n.input.charCodeAt(n.position);if(q===91)w=93,x=!1,h=[];else if(q===123)w=125,x=!0,h={};else return!1;for(n.anchor!==null&&fe(n,n.anchor,h),q=n.input.charCodeAt(++n.position);q!==0;){if(z(n,!0,f),q=n.input.charCodeAt(n.position),q===w)return n.position++,n.tag=l,n.anchor=C,n.kind=x?"mapping":"sequence",n.result=h,!0;if(y?q===44&&R(n,"expected the node content, but found ','"):R(n,"missed comma between flow collection entries"),H=T=M=null,_=E=!1,q===63){let W=n.input.charCodeAt(n.position+1);D(W)&&(_=E=!0,n.position++,z(n,!0,f))}A=n.line,b=n.lineStart,O=n.position,be(n,f,s,!1,!0),H=n.tag,T=n.result,z(n,!0,f),q=n.input.charCodeAt(n.position),(E||n.line===A)&&q===58&&(_=!0,q=n.input.charCodeAt(++n.position),z(n,!0,f),be(n,f,s,!1,!0),M=n.result),x?he(n,h,N,H,T,M,A,b,O):_?h.push(he(n,null,N,H,T,M,A,b,O)):h.push(T),z(n,!0,f),q=n.input.charCodeAt(n.position),q===44?(y=!0,q=n.input.charCodeAt(++n.position)):y=!1}R(n,"unexpected end of the stream within a flow collection")}function hn(n,f){let y,A=c,b=!1,O=!1,l=f,h=0,C=!1,w,_=n.input.charCodeAt(n.position);if(_===124)y=!1;else if(_===62)y=!0;else return!1;for(n.kind="scalar",n.result="";_!==0;)if(_=n.input.charCodeAt(++n.position),_===43||_===45)c===A?A=_===43?m:p:R(n,"repeat of a chomping mode identifier");else if((w=xe(_))>=0)w===0?R(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?R(n,"repeat of an indentation width identifier"):(l=f+w-1,O=!0);else break;if(L(_)){do _=n.input.charCodeAt(++n.position);while(L(_));if(_===35)do _=n.input.charCodeAt(++n.position);while(!F(_)&&_!==0)}for(;_!==0;){for(Fe(n),n.lineIndent=0,_=n.input.charCodeAt(n.position);(!O||n.lineIndent<l)&&_===32;)n.lineIndent++,_=n.input.charCodeAt(++n.position);if(!O&&n.lineIndent>l&&(l=n.lineIndent),F(_)){h++;continue}if(!O&&l===0&&R(n,"missing indentation for block scalar"),n.lineIndent<l){A===m?n.result+=i.repeat(`
|
|
46
|
+
`,b?1+h:h):A===c&&b&&(n.result+=`
|
|
47
|
+
`);break}y?L(_)?(C=!0,n.result+=i.repeat(`
|
|
48
|
+
`,b?1+h:h)):C?(C=!1,n.result+=i.repeat(`
|
|
49
|
+
`,h+1)):h===0?b&&(n.result+=" "):n.result+=i.repeat(`
|
|
50
|
+
`,h):n.result+=i.repeat(`
|
|
51
|
+
`,b?1+h:h),b=!0,O=!0,h=0;let E=n.position;for(;!F(_)&&_!==0;)_=n.input.charCodeAt(++n.position);ae(n,E,n.position,!1)}return!0}function ge(n,f){let y=n.tag,A=n.anchor,b=[],O=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&fe(n,n.anchor,b);let l=n.input.charCodeAt(n.position);for(;l!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,R(n,"tab characters must not be used in indentation")),l===45);){let h=n.input.charCodeAt(n.position+1);if(!D(h))break;if(O=!0,n.position++,z(n,!0,-1)&&n.lineIndent<=f){b.push(null),l=n.input.charCodeAt(n.position);continue}let C=n.line;if(be(n,f,d,!1,!0),b.push(n.result),z(n,!0,-1),l=n.input.charCodeAt(n.position),(n.line===C||n.lineIndent>f)&&l!==0)R(n,"bad indentation of a sequence entry");else if(n.lineIndent<f)break}return O?(n.tag=y,n.anchor=A,n.kind="sequence",n.result=b,!0):!1}function mn(n,f,y){let A,b,O,l,h=n.tag,C=n.anchor,w={},_=Object.create(null),E=null,x=null,N=null,T=!1,H=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&fe(n,n.anchor,w);let M=n.input.charCodeAt(n.position);for(;M!==0;){!T&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,R(n,"tab characters must not be used in indentation"));let q=n.input.charCodeAt(n.position+1),W=n.line;if((M===63||M===58)&&D(q))M===63?(T&&(he(n,w,_,E,x,null,b,O,l),E=x=N=null),H=!0,T=!0,A=!0):T?(T=!1,A=!0):R(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,M=q;else{if(b=n.line,O=n.lineStart,l=n.position,!be(n,y,a,!1,!0))break;if(n.line===W){for(M=n.input.charCodeAt(n.position);L(M);)M=n.input.charCodeAt(++n.position);if(M===58)M=n.input.charCodeAt(++n.position),D(M)||R(n,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(he(n,w,_,E,x,null,b,O,l),E=x=N=null),H=!0,T=!1,A=!1,E=n.tag,x=n.result;else if(H)R(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=h,n.anchor=C,!0}else if(H)R(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=h,n.anchor=C,!0}if((n.line===W||n.lineIndent>f)&&(T&&(b=n.line,O=n.lineStart,l=n.position),be(n,f,u,!0,A)&&(T?x=n.result:N=n.result),T||(he(n,w,_,E,x,N,b,O,l),E=x=N=null),z(n,!0,-1),M=n.input.charCodeAt(n.position)),(n.line===W||n.lineIndent>f)&&M!==0)R(n,"bad indentation of a mapping entry");else if(n.lineIndent<f)break}return T&&he(n,w,_,E,x,null,b,O,l),H&&(n.tag=h,n.anchor=C,n.kind="mapping",n.result=w),H}function Dn(n){let f=!1,y=!1,A,b,O=n.input.charCodeAt(n.position);if(O!==33)return!1;n.tag!==null&&R(n,"duplication of a tag property"),O=n.input.charCodeAt(++n.position),O===60?(f=!0,O=n.input.charCodeAt(++n.position)):O===33?(y=!0,A="!!",O=n.input.charCodeAt(++n.position)):A="!";let l=n.position;if(f){do O=n.input.charCodeAt(++n.position);while(O!==0&&O!==62);n.position<n.length?(b=n.input.slice(l,n.position),O=n.input.charCodeAt(++n.position)):R(n,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!D(O);)O===33&&(y?R(n,"tag suffix cannot contain exclamation marks"):(A=n.input.slice(l-1,n.position+1),S.test(A)||R(n,"named tag handle cannot contain such characters"),y=!0,l=n.position+1)),O=n.input.charCodeAt(++n.position);b=n.input.slice(l,n.position),$.test(b)&&R(n,"tag suffix cannot contain flow indicator characters")}b&&!v.test(b)&&R(n,"tag name cannot contain such characters: "+b);try{b=decodeURIComponent(b)}catch{R(n,"tag name is malformed: "+b)}return f?n.tag=b:o.call(n.tagMap,A)?n.tag=n.tagMap[A]+b:A==="!"?n.tag="!"+b:A==="!!"?n.tag="tag:yaml.org,2002:"+b:R(n,'undeclared tag handle "'+A+'"'),!0}function gn(n){let f=n.input.charCodeAt(n.position);if(f!==38)return!1;n.anchor!==null&&R(n,"duplication of an anchor property"),f=n.input.charCodeAt(++n.position);let y=n.position;for(;f!==0&&!D(f)&&!Z(f);)f=n.input.charCodeAt(++n.position);return n.position===y&&R(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(y,n.position),!0}function bn(n){let f=n.input.charCodeAt(n.position);if(f!==42)return!1;f=n.input.charCodeAt(++n.position);let y=n.position;for(;f!==0&&!D(f)&&!Z(f);)f=n.input.charCodeAt(++n.position);n.position===y&&R(n,"name of an alias node must contain at least one character");let A=n.input.slice(y,n.position);return o.call(n.anchorMap,A)||R(n,'unidentified alias "'+A+'"'),n.result=n.anchorMap[A],z(n,!0,-1),!0}function qn(n,f,y,A){let b=Ge(n);return jn(n),Me(n,f),n.tag=null,n.anchor=null,n.kind=null,n.result=null,mn(n,y,A)&&n.kind==="mapping"?(Re(n),!0):(Ln(n),Me(n,b),!1)}function be(n,f,y,A,b){let O,l,h=1,C=!1,w=!1,_=null,E,x,N;n.depth>=n.maxDepth&&R(n,"nesting exceeded maxDepth ("+n.maxDepth+")"),n.depth+=1,n.listener!==null&&n.listener("open",n),n.tag=null,n.anchor=null,n.kind=null,n.result=null;let T=O=l=u===y||d===y;if(A&&z(n,!0,-1)&&(C=!0,n.lineIndent>f?h=1:n.lineIndent===f?h=0:n.lineIndent<f&&(h=-1)),h===1)for(;;){let H=n.input.charCodeAt(n.position),M=Ge(n);if(C&&(H===33&&n.tag!==null||H===38&&n.anchor!==null)||!Dn(n)&&!gn(n))break;_===null&&(_=M),z(n,!0,-1)?(C=!0,l=T,n.lineIndent>f?h=1:n.lineIndent===f?h=0:n.lineIndent<f&&(h=-1)):l=!1}if(l&&(l=C||b),h===1||u===y)if(s===y||a===y?x=f:x=f+1,N=n.position-n.lineStart,h===1)if(l&&(ge(n,N)||mn(n,N,x))||fn(n,x))w=!0;else{let H=n.input.charCodeAt(n.position);_!==null&&T&&!l&&H!==124&&H!==62&&qn(n,_,_.position-_.lineStart,x)||O&&hn(n,x)||pn(n,x)||We(n,x)?w=!0:bn(n)?(w=!0,(n.tag!==null||n.anchor!==null)&&R(n,"alias node should not have any properties")):dn(n,x,s===y)&&(w=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&fe(n,n.anchor,n.result)}else h===0&&(w=l&&ge(n,N));if(n.tag===null)n.anchor!==null&&fe(n,n.anchor,n.result);else if(n.tag==="?"){n.result!==null&&n.kind!=="scalar"&&R(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"');for(let H=0,M=n.implicitTypes.length;H<M;H+=1)if(E=n.implicitTypes[H],E.resolve(n.result)){n.result=E.construct(n.result),n.tag=E.tag,n.anchor!==null&&fe(n,n.anchor,n.result);break}}else if(n.tag!=="!"){if(o.call(n.typeMap[n.kind||"fallback"],n.tag))E=n.typeMap[n.kind||"fallback"][n.tag];else{E=null;let H=n.typeMap.multi[n.kind||"fallback"];for(let M=0,q=H.length;M<q;M+=1)if(n.tag.slice(0,H[M].tag.length)===H[M].tag){E=H[M];break}}E||R(n,"unknown tag !<"+n.tag+">"),n.result!==null&&E.kind!==n.kind&&R(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+E.kind+'", not "'+n.kind+'"'),E.resolve(n.result,n.tag)?(n.result=E.construct(n.result,n.tag),n.anchor!==null&&fe(n,n.anchor,n.result)):R(n,"cannot resolve a node with !<"+n.tag+"> explicit tag")}return n.listener!==null&&n.listener("close",n),n.depth-=1,n.tag!==null||n.anchor!==null||w}function Bn(n){let f=n.position,y=!1,A;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(A=n.input.charCodeAt(n.position))!==0&&(z(n,!0,-1),A=n.input.charCodeAt(n.position),!(n.lineIndent>0||A!==37));){y=!0,A=n.input.charCodeAt(++n.position);let b=n.position;for(;A!==0&&!D(A);)A=n.input.charCodeAt(++n.position);let O=n.input.slice(b,n.position),l=[];for(O.length<1&&R(n,"directive name must not be less than one character in length");A!==0;){for(;L(A);)A=n.input.charCodeAt(++n.position);if(A===35){do A=n.input.charCodeAt(++n.position);while(A!==0&&!F(A));break}if(F(A))break;for(b=n.position;A!==0&&!D(A);)A=n.input.charCodeAt(++n.position);l.push(n.input.slice(b,n.position))}A!==0&&Fe(n),o.call(un,O)?un[O](n,O,l):Pe(n,'unknown document directive "'+O+'"')}if(z(n,!0,-1),n.lineIndent===0&&n.input.charCodeAt(n.position)===45&&n.input.charCodeAt(n.position+1)===45&&n.input.charCodeAt(n.position+2)===45?(n.position+=3,z(n,!0,-1)):y&&R(n,"directives end mark is expected"),be(n,n.lineIndent-1,u,!1,!0),z(n,!0,-1),n.checkLineBreaks&&k.test(n.input.slice(f,n.position))&&Pe(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&je(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,z(n,!0,-1));return}n.position<n.length-1&&R(n,"end of the stream or a document separator is expected")}function yn(n,f){n=String(n),f=f||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
|
|
52
|
+
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));let y=new ee(n,f),A=n.indexOf("\0");for(A!==-1&&(y.position=A,R(y,"null byte is not allowed in input")),y.input+="\0";y.input.charCodeAt(y.position)===32;)y.lineIndent+=1,y.position+=1;for(;y.position<y.length-1;)Bn(y);return y.documents}function wn(n,f,y){f!==null&&typeof f=="object"&&typeof y>"u"&&(y=f,f=null);let A=yn(n,y);if(typeof f!="function")return A;for(let b=0,O=A.length;b<O;b+=1)f(A[b])}function Un(n,f){let y=yn(n,f);if(y.length!==0){if(y.length===1)return y[0];throw new e("expected a single document in the stream, but found more")}}return Pn.loadAll=wn,Pn.load=Un,Pn}var Tt={},Ii;function uo(){if(Ii)return Tt;Ii=1;let i=rn(),e=on(),t=Nt(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,a=9,d=10,u=13,c=32,p=33,m=34,g=35,k=37,$=38,S=39,v=42,P=44,F=45,L=58,D=61,Z=62,oe=63,K=64,xe=91,Te=93,j=96,se=123,Ne=124,te=125,ee={};ee[0]="\\0",ee[7]="\\a",ee[8]="\\b",ee[9]="\\t",ee[10]="\\n",ee[11]="\\v",ee[12]="\\f",ee[13]="\\r",ee[27]="\\e",ee[34]='\\"',ee[92]="\\\\",ee[133]="\\N",ee[160]="\\_",ee[8232]="\\L",ee[8233]="\\P";let cn=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],R=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Pe(l,h){if(h===null)return{};let C={},w=Object.keys(h);for(let _=0,E=w.length;_<E;_+=1){let x=w[_],N=String(h[x]);x.slice(0,2)==="!!"&&(x="tag:yaml.org,2002:"+x.slice(2));let T=l.compiledTypeMap.fallback[x];T&&o.call(T.styleAliases,N)&&(N=T.styleAliases[N]),C[x]=N}return C}function fe(l){let h,C,w=l.toString(16).toUpperCase();if(l<=255)h="x",C=2;else if(l<=65535)h="u",C=4;else if(l<=4294967295)h="U",C=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+h+i.repeat("0",C-w.length)+w}let jn=1,Re=2;function Ln(l){this.schema=l.schema||t,this.indent=Math.max(1,l.indent||2),this.noArrayIndent=l.noArrayIndent||!1,this.skipInvalid=l.skipInvalid||!1,this.flowLevel=i.isNothing(l.flowLevel)?-1:l.flowLevel,this.styleMap=Pe(this.schema,l.styles||null),this.sortKeys=l.sortKeys||!1,this.lineWidth=l.lineWidth||80,this.noRefs=l.noRefs||!1,this.noCompatMode=l.noCompatMode||!1,this.condenseFlow=l.condenseFlow||!1,this.quotingType=l.quotingType==='"'?Re:jn,this.forceQuotes=l.forceQuotes||!1,this.replacer=typeof l.replacer=="function"?l.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Ge(l,h){let C=i.repeat(" ",h),w=0,_="",E=l.length;for(;w<E;){let x,N=l.indexOf(`
|
|
53
|
+
`,w);N===-1?(x=l.slice(w),w=E):(x=l.slice(w,N+1),w=N+1),x.length&&x!==`
|
|
54
|
+
`&&(_+=C),_+=x}return _}function Me(l,h){return`
|
|
55
|
+
`+i.repeat(" ",l.indent*h)}function un(l,h){for(let C=0,w=l.implicitTypes.length;C<w;C+=1)if(l.implicitTypes[C].resolve(h))return!0;return!1}function ae(l){return l===c||l===a}function Ce(l){return l>=32&&l<=126||l>=161&&l<=55295&&l!==8232&&l!==8233||l>=57344&&l<=65533&&l!==s||l>=65536&&l<=1114111}function he(l){return Ce(l)&&l!==s&&l!==u&&l!==d}function Fe(l,h,C){let w=he(l),_=w&&!ae(l);return(C?w:w&&l!==P&&l!==xe&&l!==Te&&l!==se&&l!==te)&&l!==g&&!(h===L&&!_)||he(h)&&!ae(h)&&l===g||h===L&&_}function z(l){return Ce(l)&&l!==s&&!ae(l)&&l!==F&&l!==oe&&l!==L&&l!==P&&l!==xe&&l!==Te&&l!==se&&l!==te&&l!==g&&l!==$&&l!==v&&l!==p&&l!==Ne&&l!==D&&l!==Z&&l!==S&&l!==m&&l!==k&&l!==K&&l!==j}function je(l){return!ae(l)&&l!==L}function me(l,h){let C=l.charCodeAt(h),w;return C>=55296&&C<=56319&&h+1<l.length&&(w=l.charCodeAt(h+1),w>=56320&&w<=57343)?(C-55296)*1024+w-56320+65536:C}function dn(l){return/^\n* /.test(l)}let pn=1,We=2,fn=3,hn=4,ge=5;function mn(l,h,C,w,_,E,x,N){let T,H=0,M=null,q=!1,W=!1,Pt=w!==-1,Ye=-1,Ke=z(me(l,0))&&je(me(l,l.length-1));if(h||x)for(T=0;T<l.length;H>=65536?T+=2:T++){if(H=me(l,T),!Ce(H))return ge;Ke=Ke&&Fe(H,M,N),M=H}else{for(T=0;T<l.length;H>=65536?T+=2:T++){if(H=me(l,T),H===d)q=!0,Pt&&(W=W||T-Ye-1>w&&l[Ye+1]!==" ",Ye=T);else if(!Ce(H))return ge;Ke=Ke&&Fe(H,M,N),M=H}W=W||Pt&&T-Ye-1>w&&l[Ye+1]!==" "}return!q&&!W?Ke&&!x&&!_(l)?pn:E===Re?ge:We:C>9&&dn(l)?ge:x?E===Re?ge:We:W?hn:fn}function Dn(l,h,C,w,_){l.dump=(function(){if(h.length===0)return l.quotingType===Re?'""':"''";if(!l.noCompatMode&&(cn.indexOf(h)!==-1||R.test(h)))return l.quotingType===Re?'"'+h+'"':"'"+h+"'";let E=l.indent*Math.max(1,C),x=l.lineWidth===-1?-1:Math.max(Math.min(l.lineWidth,40),l.lineWidth-E),N=w||l.flowLevel>-1&&C>=l.flowLevel;function T(H){return un(l,H)}switch(mn(h,N,l.indent,x,T,l.quotingType,l.forceQuotes&&!w,_)){case pn:return h;case We:return"'"+h.replace(/'/g,"''")+"'";case fn:return"|"+gn(h,l.indent)+bn(Ge(h,E));case hn:return">"+gn(h,l.indent)+bn(Ge(qn(h,x),E));case ge:return'"'+Bn(h)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function gn(l,h){let C=dn(l)?String(h):"",w=l[l.length-1]===`
|
|
56
|
+
`,E=w&&(l[l.length-2]===`
|
|
56
57
|
`||l===`
|
|
57
|
-
`)?"+":w?"":"-";return C+
|
|
58
|
-
`}function
|
|
59
|
-
`?l.slice(0,-1):l}function
|
|
60
|
-
`);return N=N!==-1?N:l.length,C.lastIndex=N,
|
|
61
|
-
`||l[0]===" ",
|
|
62
|
-
`:"")+
|
|
63
|
-
`+l.slice(_,
|
|
64
|
-
`,l.length-_>
|
|
65
|
-
`+l.slice(x+1):T+=l.slice(_),T.slice(1)}function
|
|
66
|
-
`:""}return Tt.dump=O,Tt}var Pi;function
|
|
67
|
-
`)}]}}}}function nr(
|
|
58
|
+
`)?"+":w?"":"-";return C+E+`
|
|
59
|
+
`}function bn(l){return l[l.length-1]===`
|
|
60
|
+
`?l.slice(0,-1):l}function qn(l,h){let C=/(\n+)([^\n]*)/g,w=(function(){let N=l.indexOf(`
|
|
61
|
+
`);return N=N!==-1?N:l.length,C.lastIndex=N,be(l.slice(0,N),h)})(),_=l[0]===`
|
|
62
|
+
`||l[0]===" ",E,x;for(;x=C.exec(l);){let N=x[1],T=x[2];E=T[0]===" ",w+=N+(!_&&!E&&T!==""?`
|
|
63
|
+
`:"")+be(T,h),_=E}return w}function be(l,h){if(l===""||l[0]===" ")return l;let C=/ [^ ]/g,w,_=0,E,x=0,N=0,T="";for(;w=C.exec(l);)N=w.index,N-_>h&&(E=x>_?x:N,T+=`
|
|
64
|
+
`+l.slice(_,E),_=E+1),x=N;return T+=`
|
|
65
|
+
`,l.length-_>h&&x>_?T+=l.slice(_,x)+`
|
|
66
|
+
`+l.slice(x+1):T+=l.slice(_),T.slice(1)}function Bn(l){let h="",C=0;for(let w=0;w<l.length;C>=65536?w+=2:w++){C=me(l,w);let _=ee[C];!_&&Ce(C)?(h+=l[w],C>=65536&&(h+=l[w+1])):h+=_||fe(C)}return h}function yn(l,h,C){let w="",_=l.tag;for(let E=0,x=C.length;E<x;E+=1){let N=C[E];l.replacer&&(N=l.replacer.call(C,String(E),N)),(y(l,h,N,!1,!1)||typeof N>"u"&&y(l,h,null,!1,!1))&&(w!==""&&(w+=","+(l.condenseFlow?"":" ")),w+=l.dump)}l.tag=_,l.dump="["+w+"]"}function wn(l,h,C,w){let _="",E=l.tag;for(let x=0,N=C.length;x<N;x+=1){let T=C[x];l.replacer&&(T=l.replacer.call(C,String(x),T)),(y(l,h+1,T,!0,!0,!1,!0)||typeof T>"u"&&y(l,h+1,null,!0,!0,!1,!0))&&((!w||_!=="")&&(_+=Me(l,h)),l.dump&&d===l.dump.charCodeAt(0)?_+="-":_+="- ",_+=l.dump)}l.tag=E,l.dump=_||"[]"}function Un(l,h,C){let w="",_=l.tag,E=Object.keys(C);for(let x=0,N=E.length;x<N;x+=1){let T="";w!==""&&(T+=", "),l.condenseFlow&&(T+='"');let H=E[x],M=C[H];l.replacer&&(M=l.replacer.call(C,H,M)),y(l,h,H,!1,!1)&&(l.dump.length>1024&&(T+="? "),T+=l.dump+(l.condenseFlow?'"':"")+":"+(l.condenseFlow?"":" "),y(l,h,M,!1,!1)&&(T+=l.dump,w+=T))}l.tag=_,l.dump="{"+w+"}"}function n(l,h,C,w){let _="",E=l.tag,x=Object.keys(C);if(l.sortKeys===!0)x.sort();else if(typeof l.sortKeys=="function")x.sort(l.sortKeys);else if(l.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let N=0,T=x.length;N<T;N+=1){let H="";(!w||_!=="")&&(H+=Me(l,h));let M=x[N],q=C[M];if(l.replacer&&(q=l.replacer.call(C,M,q)),!y(l,h+1,M,!0,!0,!0))continue;let W=l.tag!==null&&l.tag!=="?"||l.dump&&l.dump.length>1024;W&&(l.dump&&d===l.dump.charCodeAt(0)?H+="?":H+="? "),H+=l.dump,W&&(H+=Me(l,h)),y(l,h+1,q,!0,W)&&(l.dump&&d===l.dump.charCodeAt(0)?H+=":":H+=": ",H+=l.dump,_+=H)}l.tag=E,l.dump=_||"{}"}function f(l,h,C){let w=C?l.explicitTypes:l.implicitTypes;for(let _=0,E=w.length;_<E;_+=1){let x=w[_];if((x.instanceOf||x.predicate)&&(!x.instanceOf||typeof h=="object"&&h instanceof x.instanceOf)&&(!x.predicate||x.predicate(h))){if(C?x.multi&&x.representName?l.tag=x.representName(h):l.tag=x.tag:l.tag="?",x.represent){let N=l.styleMap[x.tag]||x.defaultStyle,T;if(r.call(x.represent)==="[object Function]")T=x.represent(h,N);else if(o.call(x.represent,N))T=x.represent[N](h,N);else throw new e("!<"+x.tag+'> tag resolver accepts not "'+N+'" style');l.dump=T}return!0}}return!1}function y(l,h,C,w,_,E,x){l.tag=null,l.dump=C,f(l,C,!1)||f(l,C,!0);let N=r.call(l.dump),T=w;w&&(w=l.flowLevel<0||l.flowLevel>h);let H=N==="[object Object]"||N==="[object Array]",M,q;if(H&&(M=l.duplicates.indexOf(C),q=M!==-1),(l.tag!==null&&l.tag!=="?"||q||l.indent!==2&&h>0)&&(_=!1),q&&l.usedDuplicates[M])l.dump="*ref_"+M;else{if(H&&q&&!l.usedDuplicates[M]&&(l.usedDuplicates[M]=!0),N==="[object Object]")w&&Object.keys(l.dump).length!==0?(n(l,h,l.dump,_),q&&(l.dump="&ref_"+M+l.dump)):(Un(l,h,l.dump),q&&(l.dump="&ref_"+M+" "+l.dump));else if(N==="[object Array]")w&&l.dump.length!==0?(l.noArrayIndent&&!x&&h>0?wn(l,h-1,l.dump,_):wn(l,h,l.dump,_),q&&(l.dump="&ref_"+M+l.dump)):(yn(l,h,l.dump),q&&(l.dump="&ref_"+M+" "+l.dump));else if(N==="[object String]")l.tag!=="?"&&Dn(l,l.dump,h,E,T);else{if(N==="[object Undefined]")return!1;if(l.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+N)}if(l.tag!==null&&l.tag!=="?"){let W=encodeURI(l.tag[0]==="!"?l.tag.slice(1):l.tag).replace(/!/g,"%21");l.tag[0]==="!"?W="!"+W:W.slice(0,18)==="tag:yaml.org,2002:"?W="!!"+W.slice(18):W="!<"+W+">",l.dump=W+" "+l.dump}}return!0}function A(l,h){let C=[],w=[];b(l,C,w);let _=w.length;for(let E=0;E<_;E+=1)h.duplicates.push(C[w[E]]);h.usedDuplicates=new Array(_)}function b(l,h,C){if(l!==null&&typeof l=="object"){let w=h.indexOf(l);if(w!==-1)C.indexOf(w)===-1&&C.push(w);else if(h.push(l),Array.isArray(l))for(let _=0,E=l.length;_<E;_+=1)b(l[_],h,C);else{let _=Object.keys(l);for(let E=0,x=_.length;E<x;E+=1)b(l[_[E]],h,C)}}}function O(l,h){h=h||{};let C=new Ln(h);C.noRefs||A(l,C);let w=l;return C.replacer&&(w=C.replacer.call({"":w},"",w)),y(C,0,w,!0,!0)?C.dump+`
|
|
67
|
+
`:""}return Tt.dump=O,Tt}var Pi;function po(){if(Pi)return ie;Pi=1;let i=co(),e=uo();function t(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return ie.Type=re(),ie.Schema=Mi(),ie.FAILSAFE_SCHEMA=Di(),ie.JSON_SCHEMA=Gi(),ie.CORE_SCHEMA=Wi(),ie.DEFAULT_SCHEMA=Nt(),ie.load=i.load,ie.loadAll=i.loadAll,ie.dump=e.dump,ie.YAMLException=on(),ie.types={binary:Ji(),float:Vi(),map:Li(),null:qi(),pairs:Xi(),set:Qi(),timestamp:Yi(),bool:Bi(),int:Ui(),merge:Ki(),omap:zi(),seq:ji(),str:Fi()},ie.safeLoad=t("safeLoad","load"),ie.safeLoadAll=t("safeLoadAll","loadAll"),ie.safeDump=t("safeDump","dump"),ie}var fo=po(),_e=ao(fo),{Type:Ns,Schema:Rs,FAILSAFE_SCHEMA:Hs,JSON_SCHEMA:Is,CORE_SCHEMA:Ps,DEFAULT_SCHEMA:Ms,load:Fs,loadAll:js,dump:Ls,YAMLException:Ds,types:qs,safeLoad:Bs,safeLoadAll:Us,safeDump:Vs}=_e;I();var Zi=[" /^immutable_paths[[:space:]]*:/ { grab=1; next }"," grab {",' # A new top-level key (no leading whitespace, ends with ":") ends the list.'," if ($0 ~ /^[^[:space:]#][^:]*:/) { grab=0; next }",' # List item: " - some/path"'," if ($0 ~ /^[[:space:]]*-[[:space:]]*/) {"," line=$0",' sub(/^[[:space:]]*-[[:space:]]*/, "", line) # drop the "- " marker',' sub(/[[:space:]]*#.*$/, "", line) # drop trailing comment',' gsub(/^[[:space:]]+|[[:space:]]+$/, "", line) # trim',` gsub(/^["'\\'']|["'\\'']$/, "", line) # drop surrounding quotes`,' if (line != "") print line'," }"," }"];var ho="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.\n# Edit harness.dot / roles / foundry.config.yaml and run `gp-foundry build`.\n";function mo(i){let e=i.runtime??{};if(e.mode==="vendored")return o=>`./.github/actions/${o}`;let t=e.owner_repo??"thegpvc/gp-foundry",r=e.ref??"v1";return o=>`${t}/actions/${o}@${r}`}function go(i){let e={};return i.name&&(e.name=i.name),i.id&&(e.id=i.id),i.if&&(e.if=i.if),i.timeoutMinutes&&(e["timeout-minutes"]=i.timeoutMinutes),Zt(i)?(e.uses=i.uses,i.with&&Object.keys(i.with).length&&(e.with=i.with)):(i.shell&&(e.shell=i.shell),i.env&&Object.keys(i.env).length&&(e.env=i.env),e.run=i.run),e}function er(i){return String(i.attrs.name??i.id)}function bo(i,e){let t=e?`${e.replace(/\/+$/,"")}/agents/scope.yaml`:"agents/scope.yaml";return{name:"immutable-paths guard",on:{pull_request:{types:["opened","synchronize","reopened"]}},permissions:{contents:"read"},jobs:{"immutable-paths":{"runs-on":"ubuntu-latest",if:`startsWith(github.event.pull_request.head.ref, '${i.repo.branch_prefix}')`,"timeout-minutes":5,steps:[{name:"Checkout",uses:"actions/checkout@v5",with:{"fetch-depth":0}},{name:"Fail if the PR touches an immutable path",shell:"bash",env:{SCOPE_PATH:t,BASE_SHA:"${{ github.event.pull_request.base.sha }}",HEAD_SHA:"${{ github.event.pull_request.head.sha }}"},run:["# The immutable_paths list, read without a YAML parser. This scan is","# shared with the agent-fallback composite (src/shared/immutable-paths.ts);","# a test fails if the two copies drift.",'PATHS=""','HAS_KEY=""','if [ -f "$SCOPE_PATH" ]; then',` grep -q '^immutable_paths[[:space:]]*:' "$SCOPE_PATH" && HAS_KEY=1`," PATHS=$(awk '",...Zi,` ' "$SCOPE_PATH")`,"fi",'if [ -z "$PATHS" ]; then'," # An absent key falls back to the workflows directory. A key that IS"," # present but yields nothing means the scan could not read it (e.g. a"," # flow-style list) \u2014 silently guarding a different set of paths than"," # the file names is how a green check comes to mean nothing.",' if [ -n "$HAS_KEY" ]; then',' echo "::error::$SCOPE_PATH declares immutable_paths but none could be read."',` echo "Write it as a block list, one '- path/' entry per line; this guard"`,' echo "refuses to run against a list it cannot parse."'," exit 1"," fi",' PATHS=".github/workflows/"',"fi","","# Three-dot: compare against the MERGE BASE, so edits that landed on the","# base branch after this PR forked are not blamed on the PR. --no-renames","# keeps a rename visible as a delete of the protected path, which is","# exactly the move this guard must catch.",'VIOLATIONS=""',"while IFS= read -r P; do",' [ -z "$P" ] && continue',' # A git pathspec, not a substring: "$P" anchors at the repo root and'," # understands the glob forms scope.yaml is written in.",' HITS=$(git diff --no-renames --name-only "$BASE_SHA...$HEAD_SHA" -- "$P" || true)',` [ -n "$HITS" ] && VIOLATIONS="$VIOLATIONS$HITS"$'\\n'`,'done <<< "$PATHS"',"",`if [ -n "$(printf '%s' "$VIOLATIONS" | tr -d '[:space:]')" ]; then`,' echo "::error::This branch changes paths scope.yaml marks immutable:"',` printf '%s\\n' "$VIOLATIONS" | sed '/^$/d' | sort -u | sed 's/^/ - /'`,' echo "Agents must never modify these. If the change is intentional, a human"',' echo "should make it on their own branch."'," exit 1","fi",'echo "No immutable paths touched."'].join(`
|
|
68
|
+
`)}]}}}}function nr(i,e,t=""){let r=[],o=mo(i.config),s=new Map(i.nodes.map(g=>[g.id,g])),a=new Map,d=new Map;for(let g of i.nodes)a.set(g.id,[]),d.set(g.id,[]);for(let g of i.edges)a.get(g.from)?.push(g),d.get(g.to)?.push(g);let u=g=>({config:i.config,node:g,outEdges:a.get(g.id)??[],inEdges:d.get(g.id)??[],actionRef:o,nodeById:k=>s.get(k),specDir:t}),c=(g,k)=>{let $={"runs-on":"ubuntu-latest"},S=g.if??k;return S&&($.if=S),g.environment&&($.environment=g.environment),g.permissions&&Object.keys(g.permissions).length&&($.permissions=g.permissions),g.timeoutMinutes&&($["timeout-minutes"]=g.timeoutMinutes),g.needs?.length&&($.needs=g.needs),g.strategy&&($.strategy=g.strategy),$.steps=g.steps.map(go),$},p=(g,k)=>{let $=_e.dump(k,{lineWidth:-1,noRefs:!0,quotingType:'"'});r.push({path:`.github/workflows/${g}.yml`,contents:ho+$,generated:!0})},m=qe(i);p("immutable-guard",bo(i.config,t));for(let g of i.nodes){if(m.memberIds.has(g.id))continue;let k=e.perNode[g.id];if(!k||Object.keys(k.triggers).length===0)continue;let $=m.byFanin.get(g.id);if($){let v={};for(let L of $.legIds){let D=s.get(L),Z=lt(D,i,u(D));Z&&(v[Z.jobId]=c(Z,k.guard))}let P=JSON.stringify(k.triggers).includes('"pull_request"'),F=ri(u(g),$.legIds,P);v[F.jobId]=c(F),p(g.id,{name:er(g),on:k.triggers,...k.concurrency?{concurrency:k.concurrency}:{},permissions:{contents:"read"},jobs:v});continue}let S=lt(g,i,u(g));S&&p(g.id,{name:er(g),on:k.triggers,...k.concurrency?{concurrency:k.concurrency}:{},permissions:{contents:"read"},jobs:{[S.jobId]:c(S,k.guard)}})}return r}I();function yo(i){switch(i.type){case"start":case"exit":return["([","])"];case"human-gate":return["{{","}}"];case"merge-gate":return["[/","/]"];case"parallel":case"fan_in":return["[[","]]"];default:return["[","]"]}}function wo(i){let e=i.files.role?.replace(/^.*\//,"").replace(/\.md$/,""),t=e&&e!==i.id?`${e} \xB7 ${i.type}`:i.type;return`${i.id}<br/><small>${t}</small>`}function Mn(i){let e=["```mermaid","flowchart TD"];for(let t of i.nodes){let[r,o]=yo(t);e.push(` ${t.id}${r}"${wo(t)}"${o}`)}for(let t of i.edges){let r=[t.on,t.when].filter(Boolean).join(" \xB7 ");e.push(r?` ${t.from} -->|"${r}"| ${t.to}`:` ${t.from} --> ${t.to}`)}return e.push("```",""),`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
|
|
68
69
|
|
|
69
|
-
# ${
|
|
70
|
+
# ${i.config?.name&&i.config.name!=="harness"?i.config.name:i.name} \u2014 agent harness
|
|
70
71
|
|
|
71
72
|
${e.join(`
|
|
72
|
-
`)}`}I();var
|
|
73
|
-
`){
|
|
73
|
+
`)}`}I();var _o=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),Ao=new Set(["role","prompt","policy","tools"]);function ko(i){let e=[],t=[],r=1,o=0,s=i;for(;o<s.length;){let a=s[o];if(a===`
|
|
74
|
+
`){r++,o++;continue}if(a===" "||a===" "||a==="\r"){o++;continue}if(a==="/"&&s[o+1]==="/"){for(;o<s.length&&s[o]!==`
|
|
74
75
|
`;)o++;continue}if(a==="/"&&s[o+1]==="*"){for(o+=2;o<s.length&&!(s[o]==="*"&&s[o+1]==="/");)s[o]===`
|
|
75
|
-
`&&
|
|
76
|
-
`&&
|
|
77
|
-
`)}function
|
|
76
|
+
`&&r++,o++;o+=2;continue}if(a==="-"&&s[o+1]===">"){e.push({kind:"arrow",value:"->",line:r}),o+=2;continue}if(a==="{"){e.push({kind:"lbrace",value:a,line:r}),o++;continue}if(a==="}"){e.push({kind:"rbrace",value:a,line:r}),o++;continue}if(a==="["){e.push({kind:"lbrack",value:a,line:r}),o++;continue}if(a==="]"){e.push({kind:"rbrack",value:a,line:r}),o++;continue}if(a==="="){e.push({kind:"eq",value:a,line:r}),o++;continue}if(a===","){e.push({kind:"comma",value:a,line:r}),o++;continue}if(a===";"){e.push({kind:"semi",value:a,line:r}),o++;continue}if(a==='"'){let d=o+1,u="";for(;d<s.length&&s[d]!=='"';){if(s[d]==="\\"&&d+1<s.length){u+=s[d+1],d+=2;continue}s[d]===`
|
|
77
|
+
`&&r++,u+=s[d],d++}d>=s.length&&t.push({message:"unterminated string",line:r}),e.push({kind:"id",value:u,line:r}),o=d+1;continue}if(/[A-Za-z0-9_]/.test(a)){let d=o,u="";for(;d<s.length&&/[A-Za-z0-9_.\-]/.test(s[d]);)u+=s[d],d++;e.push({kind:"id",value:u,line:r}),o=d;continue}t.push({message:`unexpected character '${a}'`,line:r}),o++}return{toks:e,errors:t}}function xo(i){return i==="true"?!0:i==="false"?!1:/^-?\d+$/.test(i)?Number(i):i}function sn(i){let{toks:e,errors:t}=ko(i),r=[],o=[],s=new Map,a="harness",d=0,u=()=>e[d],c=()=>e[d++],p=(S,v)=>t.push({message:S,line:v});u()?.kind==="id"&&u()?.value==="digraph"?(c(),u()?.kind==="id"&&u()?.value!==void 0&&(a=c().value),u()?.kind==="lbrace"?c():p("expected '{' after digraph header",u()?.line)):p("expected 'digraph' keyword",u()?.line);function m(){let S={};if(u()?.kind!=="lbrack")return{attrs:S};let v=c().line;for(;u()&&u().kind!=="rbrack";){let P=c();if(!P||P.kind!=="id"){p("expected attribute name",P?.line);break}if(u()?.kind!=="eq"){p(`expected '=' after attribute '${P.value}'`,P.line);break}c();let F=c();if(!F||F.kind!=="id"){p(`expected value for attribute '${P.value}'`,F?.line);break}S[P.value]=F.value,u()?.kind==="comma"&&c()}return u()?.kind==="rbrack"?c():p("unterminated attribute list '['",v),{attrs:S,line:v}}function g(S,v){let P=s.get(S);return P||(P={id:S,type:"analyst",attrs:{},files:{},raw:{},line:v},s.set(S,P),r.push(P)),P}function k(S,v,P){S.declared=!0,S.raw={...S.raw,...v},P!==void 0&&(S.line=S.line??P);for(let[F,L]of Object.entries(v))F==="type"?(_o.has(L)||p(`unknown node type '${L}' on node '${S.id}'`,P),S.type=L):F==="context"?S.context=L:Ao.has(F)?S.files[F]=L:S.attrs[F]=xo(L)}let $=0;for(;u()&&u().kind!=="rbrace"&&!($++>1e5);){let S=u();if(S.kind==="semi"){c();continue}if(S.kind!=="id"){p(`unexpected token '${S.value}'`,S.line),c();continue}let v=c();if(u()?.kind==="arrow"){let P=[{id:v.value,line:v.line}];for(;u()?.kind==="arrow";){c();let D=c();if(!D||D.kind!=="id"){p("expected node id after '->'",D?.line);break}P.push({id:D.value,line:D.line})}let{attrs:F,line:L}=m();for(let D=0;D+1<P.length;D++){let Z=P[D],oe=P[D+1];g(Z.id,Z.line),g(oe.id,oe.line);let K={from:Z.id,to:oe.id,raw:{...F},line:L??Z.line};F.on!==void 0&&(K.on=F.on),F.when!==void 0&&(K.when=F.when),F.do!==void 0&&(K.do=F.do),o.push(K)}}else{let{attrs:P,line:F}=m(),L=g(v.value,v.line);k(L,P,F??v.line)}u()?.kind==="semi"&&c()}return u()?.kind==="rbrace"&&c(),{name:a,nodes:r,edges:o,errors:t}}I();var an=require("fs");var Be={name:"harness",identity:{},agent:{cli:"claude",model:"claude-opus-4-8",oauth_token_secret:"CLAUDE_CODE_OAUTH_TOKEN"},repo:{base_branch:"main",branch_prefix:"agent/"},labels:{}};function Fn(i){if(!i||!(0,an.existsSync)(i))return structuredClone(Be);let e=_e.load((0,an.readFileSync)(i,"utf8"))??{};return{...Be,...e,identity:{...Be.identity,...e.identity??{}},agent:{...Be.agent,...e.agent??{}},repo:{...Be.repo,...e.repo??{}},labels:{...Be.labels,...e.labels??{}}}}function pe(i,e){let t=sn((0,an.readFileSync)(i,"utf8")),r=Fn(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:r,sourcePath:i},parseErrors:t.errors}}function Ue(i,e={},t={}){let r=[...en(i,e),...nn(i)],o=nr(i,ui(i),t.specDir??"");return o.push({path:".github/HARNESS.md",contents:Mn(i),generated:!0}),{files:o,diagnostics:r}}function ln(i){return i.some(e=>e.level==="error")}I();var Co=/^---\r?\n([\s\S]*?)\r?\n---/;function tr(i){let e=Co.exec(i);if(e)try{let t=_e.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}I();var ir=require("fs"),Ae=require("path"),rr=require("url"),Ie=_n(En(),1);function ue(i){return(0,rr.fileURLToPath)(new URL(`../../${i}`,V))}function J(i){process.stdout.write(JSON.stringify(i,null,2)+`
|
|
78
|
+
`)}function Rt(i){for(let e of i){let t=e.level==="error"?Ie.default.red("error"):e.level==="warning"?Ie.default.yellow("warn"):Ie.default.blue("info"),r=e.where?.node?Ie.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${Ie.default.dim(e.code)}${r} ${e.message}
|
|
78
79
|
`),e.hint&&process.stderr.write(` ${Ie.default.dim("hint: "+e.hint)}
|
|
79
|
-
`)}}function
|
|
80
|
+
`)}}function ke(i){let e=(0,Ae.resolve)(i.dot??".github/harness.dot"),t=(0,Ae.dirname)(e),r=i.config?(0,Ae.resolve)(i.config):void 0;if(!r){for(let s of[(0,Ae.join)(t,"foundry.config.yaml"),(0,Ae.join)(t,"agents/foundry.config.yaml")])if((0,ir.existsSync)(s)){r=s;break}}let o=t.endsWith(".github")?(0,Ae.dirname)(t):t;return{dot:e,config:r,base:t,root:o}}I();var Ht=require("child_process"),B=require("fs"),G=require("path");var U=_n(En(),1);var It=require("path");function Ve(i,e={}){try{return{ok:!0,out:(0,Ht.execFileSync)("gh",i,{encoding:"utf8",stdio:["ignore","pipe","pipe"],cwd:e.cwd}).trim()}}catch(t){return{ok:!1,out:t.stderr?.toString().trim()??String(t.message)}}}function Oe(i,e){let t=Ve(i,{cwd:e});if(!t.ok)return null;try{return JSON.parse(t.out)}catch{return null}}function lr(){let i=ue("actions");return(0,B.readdirSync)(i,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,B.existsSync)((0,G.join)(i,e.name,"action.yml"))).map(e=>e.name)}function cr(i){let e=Fn(i),t=new Map([["build","ready to implement"],["plan","needs design first"]]),r=[];for(let[o,s]of t)r.push({name:e.labels?.[o]??o,description:s,color:o==="build"?"0e8a16":"5319e7"});return r.push({name:"needs-human",description:"agents are blocked; a human should take over",color:"b60205"}),r.push({name:"needs-rebase",description:"PR conflicts with base; the janitor sweep rebases it",color:"d93f0b"}),r}function or(i){let e={ok:U.default.green("\u2713"),warn:U.default.yellow("!"),fail:U.default.red("\u2717"),skip:U.default.dim("-")};for(let t of i)process.stdout.write(`${e[t.status]} ${t.name.padEnd(28)} ${t.detail}
|
|
80
81
|
`),t.hint&&t.status!=="ok"&&process.stdout.write(` ${U.default.dim("hint: "+t.hint)}
|
|
81
|
-
`)}function
|
|
82
|
+
`)}function Eo(i,e){let t=i.nodes.filter(r=>r.type==="merge-gate");return t.length===0?!1:t.some(r=>{if(!r.files.policy)return!0;let o=(0,G.dirname)(i.sourcePath??""),s=(0,G.join)(e,o,r.files.policy);if(!(0,B.existsSync)(s))return!0;try{let a=_e.load((0,B.readFileSync)(s,"utf8"));return(a?.require_ci??a?.requireCi)!==!1}catch{return!0}})}function sr(i){let e=[];for(let r of lr()){let o=ue(`actions/${r}`),s=(0,G.join)(i,".github/actions",r);(0,B.mkdirSync)(s,{recursive:!0}),(0,B.cpSync)((0,G.join)(o,"action.yml"),(0,G.join)(s,"action.yml")),(0,B.existsSync)((0,G.join)(o,"dist"))&&(0,B.cpSync)((0,G.join)(o,"dist"),(0,G.join)(s,"dist"),{recursive:!0}),e.push(`.github/actions/${r}/`)}let t=(0,G.join)(i,".github/agent-setup/action.yml");return(0,B.existsSync)(t)||((0,B.mkdirSync)((0,G.dirname)(t),{recursive:!0}),(0,B.writeFileSync)(t,(0,B.readFileSync)(ue("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function So(i){(0,B.mkdirSync)(i,{recursive:!0}),(0,B.cpSync)(ue("skill/SKILL.md"),(0,G.join)(i,"SKILL.md")),(0,B.cpSync)(ue("skill/reference"),(0,G.join)(i,"reference"),{recursive:!0}),(0,B.cpSync)(ue("skill/templates"),(0,G.join)(i,"templates"),{recursive:!0})}function ar(i){let e=[],{dot:t,config:r,base:o,root:s}=ke(i);if(!(0,B.existsSync)(t))return e.push({name:"harness",status:"fail",detail:`no harness.dot at ${t}`,hint:"run `gp-foundry init`"}),{checks:e,failed:!0};let{harness:a,parseErrors:d}=pe(t,r),u=j=>(0,B.existsSync)((0,G.join)(o,j)),c=(0,It.relative)(s,o).replace(/\\/g,"/"),{files:p,diagnostics:m}=Ue(a,{fileExists:u},{specDir:c}),g=m.filter(j=>j.level==="error").length+d.length,k=m.filter(j=>j.level==="warning");e.push(g?{name:"validate",status:"fail",detail:`${g} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:k.length?"warn":"ok",detail:k.length?`${k.length} warning(s): ${k.map(j=>j.code).join(", ")}`:"no diagnostics"});let $=p.filter(j=>{let se=(0,G.join)(s,j.path);return((0,B.existsSync)(se)?(0,B.readFileSync)(se,"utf8"):null)!==j.contents});if(e.push($.length?{name:"workflows in sync",status:"fail",detail:`${$.length} file(s) drifted: ${$.slice(0,3).map(j=>j.path).join(", ")}${$.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${p.length} generated files match`}),(a.config.runtime?.mode??"pinned")==="vendored"){let j=lr().filter(se=>!(0,B.existsSync)((0,G.join)(s,".github/actions",se,"action.yml")));e.push(j.length?{name:"vendored actions",status:"fail",detail:`missing: ${j.join(", ")}`,hint:"run `gp-foundry vendor`"}:{name:"vendored actions",status:"ok",detail:"all runtime actions vendored"})}if(e.push((0,B.existsSync)((0,G.join)(s,".github/agent-setup/action.yml"))?{name:"agent-setup shim",status:"ok",detail:".github/agent-setup/action.yml present"}:{name:"agent-setup shim",status:"fail",detail:"missing \u2014 every agent job needs it",hint:"run `gp-foundry vendor` (or `init`)"}),!Ve(["auth","status"]).ok)return e.push({name:"gh cli",status:"skip",detail:"gh missing or unauthenticated \u2014 skipping repo checks",hint:"install GitHub CLI and `gh auth login`"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"gh cli",status:"ok",detail:"authenticated"});let v=Oe(["repo","view","--json","nameWithOwner,defaultBranchRef"],s);if(!v)return e.push({name:"github repo",status:"skip",detail:"not a GitHub repo (or no remote) \u2014 skipping labels/secrets checks",hint:"create it with `gh repo create`, then re-run `gp-foundry up` to create labels"}),{checks:e,failed:e.some(j=>j.status==="fail")};e.push({name:"github repo",status:"ok",detail:v.nameWithOwner});let P=v.defaultBranchRef?.name;P&&e.push(P===a.config.repo.base_branch?{name:"base branch",status:"ok",detail:P}:{name:"base branch",status:"fail",detail:`config says '${a.config.repo.base_branch}' but the repo default is '${P}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let F=new Set((Oe(["label","list","--json","name","--limit","1000"],s)??[]).map(j=>j.name)),L=cr(r).map(j=>j.name),D=L.filter(j=>!F.has(j));e.push(D.length?{name:"labels",status:"fail",detail:`missing: ${D.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:L.join(", ")});let Z=new Set((Oe(["secret","list","--json","name"],s)??[]).map(j=>j.name)),oe=[a.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN"],K=a.config.auth;K?.mode==="pat"&&K.token_secret&&oe.push(K.token_secret),K?.mode==="app"&&oe.push(K.app_id_secret??"APP_ID",K.app_key_secret??"APP_PRIVATE_KEY");let xe=oe.filter(j=>!Z.has(j));if(e.push(xe.length?{name:"secrets",status:"fail",detail:`missing: ${xe.join(", ")}`,hint:`gh secret set ${xe[0]}`}:{name:"secrets",status:"ok",detail:oe.join(", ")}),Eo(a,s)){let se=p.filter(te=>/\/workflows\/.*\.yml$/.test(te.path)&&te.contents.includes("actions/merge-gate")).map(te=>(0,G.join)(s,te.path)).filter(te=>(0,B.existsSync)(te)).map(te=>(0,B.readFileSync)(te,"utf8")),Ne=se.filter(te=>!te.includes("checks-token"));se.length&&Ne.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${Ne.length} merge-gate workflow(s) read check-runs with the harness token`,hint:"a fine-grained PAT cannot be granted the Checks permission, so that read 403s and nothing merges \u2014 run `gp-foundry build` to pass GITHUB_TOKEN instead, then commit"})}let Te=Ve(["--version"]);try{let j=(0,Ht.execFileSync)("git",["status","--porcelain",".github"],{cwd:s,encoding:"utf8"}).trim();e.push(j?{name:"committed",status:"warn",detail:".github/ has uncommitted changes",hint:"commit + push so GitHub picks them up"}:{name:"committed",status:"ok",detail:".github/ clean"})}catch{e.push({name:"committed",status:"skip",detail:"not a git repo"})}return{checks:e,failed:e.some(j=>j.status==="fail")}}function vo(i){let{dot:e,config:t,root:r}=ke(i);if(!Ve(["auth","status"]).ok)return{error:"gh missing or unauthenticated \u2014 status needs the GitHub CLI",hint:"install the GitHub CLI and run `gh auth login`"};let o=Oe(["repo","view","--json","nameWithOwner"],r);if(!o)return{error:"not a GitHub repo (or no remote)",hint:"create it with `gh repo create`, push, then re-run `gp-foundry status`"};let{harness:s}=pe(e,t),a=s.config.repo.branch_prefix,d=Date.now(),u=v=>Math.round((d-Date.parse(v))/36e5),c={};for(let v of["plan","build","needs-human"]){let P=v==="needs-human"?"needs-human":s.config.labels?.[v]??v,F=Oe(["issue","list","--label",P,"--state","open","--json","number,title,createdAt","--limit","50"],r)??[];c[P]=F.map(L=>({number:L.number,title:L.title,ageHours:u(L.createdAt)}))}let m=(Oe(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],r)??[]).filter(v=>v.headRefName.startsWith(a)),g=[],k=new Set;for(let v of m)for(let P of v.body?.matchAll(/[Cc]loses #(\d+)/g)??[])k.add(Number(P[1]));let $=s.config.labels?.build??"build";for(let v of c[$]??[])!k.has(v.number)&&v.ageHours>=2&&g.push({kind:"issue-no-pr",number:v.number,title:v.title,detail:`labeled ${$} ${v.ageHours}h ago, no open PR closes it`});for(let v of m)v.updatedAt&&u(v.updatedAt)>=4&&g.push({kind:"pr-idle",number:v.number,title:v.title,detail:`no activity for ${u(v.updatedAt)}h`});let S=(Oe(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],r)??[]).filter(v=>u(v.createdAt)<=24).map(v=>({workflow:v.name,url:v.url,ageHours:u(v.createdAt)}));return{repo:o.nameWithOwner,lanes:c,prs:m.map(v=>({number:v.number,title:v.title,labels:v.labels.map(P=>P.name),mergeable:v.mergeable,headRefName:v.headRefName})),stalled:g,recentFailures:S}}function ur(i){i.command("vendor").description("Copy the runtime-core actions into .github/actions/ (self-contained repo)").option("--dir <path>","target repo root",".").option("--json","machine-readable output").action(e=>{let t=sr(e.dir);if(e.json)return J({written:t});for(let r of t)process.stdout.write(U.default.green(`vendored ${r}
|
|
82
83
|
`));process.stdout.write(U.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
|
|
83
|
-
`))}),
|
|
84
|
+
`))}),i.command("skill").description("Install the Claude skill (Socratic setup) into .claude/skills/gp-foundry/").option("--user","install for all projects (~/.claude/skills/) instead of this repo").option("--dir <path>","target repo root (project mode)",".").option("--json","machine-readable output").action(e=>{let t=process.env.HOME??process.env.USERPROFILE??".",r=e.user?(0,G.join)(t,".claude/skills/gp-foundry"):(0,G.join)(e.dir,".claude/skills/gp-foundry");if(So(r),e.json)return J({installed:r});process.stdout.write(U.default.green(`installed skill \u2192 ${r}
|
|
84
85
|
`)),process.stdout.write(U.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
|
|
85
86
|
The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
|
|
86
|
-
`))}),
|
|
87
|
+
`))}),i.command("doctor").description("Preflight the factory: config, drift, vendored actions, gh auth, labels, secrets").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{checks:t,failed:r}=ar(e);e.json?J({ok:!r,checks:t}):(or(t),process.stdout.write(r?U.default.red(`
|
|
87
88
|
not ready \u2014 fix the \u2717 items above
|
|
88
89
|
`):U.default.green(`
|
|
89
90
|
factory is ready
|
|
90
|
-
`))),process.exit(
|
|
91
|
+
`))),process.exit(r?1:0)}),i.command("status").description("Factory dashboard: work in flight, stalled items, recent failures").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let t=vo(e);if("error"in t&&(e.json?J(t):(process.stderr.write(U.default.red(t.error+`
|
|
91
92
|
`)),t.hint&&process.stderr.write(U.default.dim("hint: "+t.hint+`
|
|
92
93
|
`))),process.exit(1)),e.json)return J(t);process.stdout.write(U.default.bold(`
|
|
93
94
|
${t.repo} \u2014 factory status
|
|
94
95
|
|
|
95
|
-
`));for(let[
|
|
96
|
+
`));for(let[r,o]of Object.entries(t.lanes)){process.stdout.write(U.default.cyan(`${r} (${o.length})
|
|
96
97
|
`));for(let s of o.slice(0,10))process.stdout.write(` #${s.number} ${s.title} ${U.default.dim(`(${s.ageHours}h)`)}
|
|
97
98
|
`)}process.stdout.write(U.default.cyan(`
|
|
98
99
|
agent PRs (${t.prs.length})
|
|
99
|
-
`));for(let
|
|
100
|
+
`));for(let r of t.prs)process.stdout.write(` #${r.number} ${r.title} ${U.default.dim(r.mergeable??"")} ${r.labels.length?U.default.yellow(r.labels.join(",")):""}
|
|
100
101
|
`);if(t.stalled.length){process.stdout.write(U.default.red(`
|
|
101
102
|
stalled (${t.stalled.length})
|
|
102
|
-
`));for(let
|
|
103
|
+
`));for(let r of t.stalled)process.stdout.write(` #${r.number} ${r.title} \u2014 ${r.detail}
|
|
103
104
|
`)}if(t.recentFailures.length){process.stdout.write(U.default.red(`
|
|
104
105
|
failed runs, last 24h (${t.recentFailures.length})
|
|
105
|
-
`));for(let
|
|
106
|
+
`));for(let r of t.recentFailures.slice(0,10))process.stdout.write(` ${r.workflow} ${U.default.dim(`${r.ageHours}h ago`)} ${r.url}
|
|
106
107
|
`)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(U.default.green(`
|
|
107
108
|
no stalled work, no recent failures
|
|
108
|
-
`))}),
|
|
109
|
-
`))}else a.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(U.default.yellow("skipped label creation (gh unavailable or no GitHub repo yet) \u2014 re-run `gp-foundry up` once the repo exists\n"));let{harness:d}=
|
|
110
|
-
`)));let u=
|
|
109
|
+
`))}),i.command("up").description("Bring the factory up: create labels, vendor actions, build workflows, run doctor").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(e=>{let{dot:t,config:r,base:o,root:s}=ke(e),a={};if(Ve(["auth","status"]).ok&&Oe(["repo","view","--json","nameWithOwner"],s)){let S=[];for(let v of cr(r))Ve(["label","create",v.name,"--color",v.color,"--description",v.description],{cwd:s}).ok&&S.push(v.name);a.labels=S,e.json||process.stdout.write(U.default.green(`labels ensured (created: ${S.length?S.join(", "):"none \u2014 already present"})
|
|
110
|
+
`))}else a.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(U.default.yellow("skipped label creation (gh unavailable or no GitHub repo yet) \u2014 re-run `gp-foundry up` once the repo exists\n"));let{harness:d}=pe(t,r);(d.config.runtime?.mode??"pinned")==="vendored"&&(a.vendored=sr(s),e.json||process.stdout.write(U.default.green(`vendored ${a.vendored.length} runtime action(s)
|
|
111
|
+
`)));let u=S=>(0,B.existsSync)((0,G.join)(o,S)),c=(0,It.relative)(s,o).replace(/\\/g,"/"),{files:p,diagnostics:m}=Ue(d,{fileExists:u},{specDir:c});ln(m)&&(e.json?J({ok:!1,diagnostics:m}):process.stderr.write(U.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let S of p){let v=(0,G.join)(s,S.path);(0,B.mkdirSync)((0,G.dirname)(v),{recursive:!0}),(0,B.writeFileSync)(v,S.contents)}a.wrote=p.map(S=>S.path);let g=p.filter(S=>S.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(U.default.green(`built ${g} workflows + HARNESS.md
|
|
111
112
|
`));let{checks:k,failed:$}=ar(e);if(a.checks=k,a.ok=!$,e.json)return J(a);process.stdout.write(`
|
|
112
113
|
`),or(k),process.stdout.write($?U.default.yellow(`
|
|
113
114
|
almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
|
|
114
115
|
`):U.default.green(`
|
|
115
116
|
factory is up \u2014 commit .github/, push, then file an issue to watch it run
|
|
116
|
-
`)),process.exit($?1:0)})}var $e=new zt,
|
|
117
|
-
`));for(let d of
|
|
117
|
+
`)),process.exit($?1:0)})}var $e=new zt,Oo=JSON.parse((0,Y.readFileSync)(ue("package.json"),"utf8")).version;$e.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(Oo);function $o(i,e){let t=new Map;for(let r of i.nodes){if(!r.files.role)continue;let o=(0,ne.join)(e,r.files.role);if((0,Y.existsSync)(o)){let s=tr((0,Y.readFileSync)(o,"utf8"));s&&t.set(r.id,s)}}return t}var To=[["skill/templates/harness.dot",".github/harness.dot"],["skill/templates/foundry.config.yaml",".github/agents/foundry.config.yaml"],["skill/templates/scope.yaml",".github/agents/scope.yaml"],["skill/templates/policy-merge.yaml",".github/agents/policy/merge.yaml"],["skill/templates/communication.md",".github/agents/communication.md"],["skill/templates/agent-setup.yml",".github/agent-setup/action.yml"]];$e.command("init").description("Scaffold a starter harness (harness.dot + config + roles + scope + policy) into a repo").option("--dir <path>","target repo root",".").option("--force","overwrite existing files").option("--json","machine-readable output").action(i=>{let e=(0,ne.resolve)(i.dir),t=[],r=[],o=(d,u)=>{let c=(0,ne.join)(e,d);if((0,Y.existsSync)(c)&&!i.force){r.push(d);return}(0,Y.mkdirSync)((0,ne.dirname)(c),{recursive:!0}),(0,Y.writeFileSync)(c,u),t.push(d)},s="main";try{let d=(0,dr.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();d&&(s=d)}catch{}for(let[d,u]of To){let c=(0,Y.readFileSync)(ue(d),"utf8");u.endsWith("foundry.config.yaml")&&s!=="main"&&(c=c.replace(/^(\s*base_branch:\s*)main\b/m,`$1${s}`)),o(u,c)}let a=(0,ne.join)(e,".github/harness.dot");if((0,Y.existsSync)(a))for(let d of sn((0,Y.readFileSync)(a,"utf8")).nodes){if(!d.files.role)continue;let u=d.files.role.replace(/^.*\//,"").replace(/\.md$/,""),c=ue(`roles/software/${u}.md`),p=(0,Y.existsSync)(c)?c:ue("skill/templates/role.md");o((0,ne.join)(".github",d.files.role),(0,Y.readFileSync)(p,"utf8"))}if(i.json)return J({written:t,skipped:r});for(let d of t)process.stdout.write(Q.default.green(`created ${d}
|
|
118
|
+
`));for(let d of r)process.stderr.write(Q.default.yellow(`skipped ${d} (exists; --force to overwrite)
|
|
118
119
|
`));process.stdout.write(["",Q.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${Q.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${Q.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${Q.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${Q.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",Q.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
|
|
119
|
-
`))});$e.command("build").description("Compile harness.dot \u2192 .github/workflows/*.yml (+ HARNESS.md)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--out <dir>","output repo root (default: dir of harness.dot)").option("--check","verify generated files are in sync; exit 1 on drift").option("--dry-run","print what would be written; do not write").option("--force","write even if there are error diagnostics").option("--json","machine-readable output").action(
|
|
120
|
-
`)),process.exit(1));let{harness:s,parseErrors:a}=
|
|
121
|
-
`));process.exit(1)}let d=(0,ne.resolve)(
|
|
120
|
+
`))});$e.command("build").description("Compile harness.dot \u2192 .github/workflows/*.yml (+ HARNESS.md)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--out <dir>","output repo root (default: dir of harness.dot)").option("--check","verify generated files are in sync; exit 1 on drift").option("--dry-run","print what would be written; do not write").option("--force","write even if there are error diagnostics").option("--json","machine-readable output").action(i=>{let{dot:e,config:t,base:r,root:o}=ke(i);(0,Y.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e}
|
|
121
|
+
`)),process.exit(1));let{harness:s,parseErrors:a}=pe(e,t);if(a.length){if(i.json)J({parseErrors:a});else for(let g of a)process.stderr.write(Q.default.red(`parse: ${g.message}${g.line?` (line ${g.line})`:""}
|
|
122
|
+
`));process.exit(1)}let d=(0,ne.resolve)(i.out??o),u=(0,ne.relative)(d,r).replace(/\\/g,"/"),c=g=>(0,Y.existsSync)((0,ne.join)(r,g)),{files:p,diagnostics:m}=Ue(s,{fileExists:c},{specDir:u});if(i.json||Rt(m),i.check){let g=p.filter(k=>{let $=(0,ne.join)(d,k.path);return((0,Y.existsSync)($)?(0,Y.readFileSync)($,"utf8"):null)!==k.contents});if(i.json)J({upToDate:g.length===0,drift:g.map(k=>k.path),diagnostics:m});else if(g.length){for(let k of g)process.stderr.write(Q.default.yellow(`drift: ${k.path}
|
|
122
123
|
`));process.stderr.write(Q.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}else process.stdout.write(Q.default.green(`up to date
|
|
123
|
-
`));process.exit(g.length?1:0)}if(
|
|
124
|
-
`)),process.exit(1)),
|
|
124
|
+
`));process.exit(g.length?1:0)}if(ln(m)&&!i.force&&(i.json?J({ok:!1,diagnostics:m,wrote:[]}):process.stderr.write(Q.default.red(`errors present \u2014 not writing (use --force to override)
|
|
125
|
+
`)),process.exit(1)),i.dryRun){if(i.json)J({diagnostics:m,files:p});else for(let g of p)process.stdout.write(Q.default.cyan(`--- ${g.path}
|
|
125
126
|
`)+g.contents+`
|
|
126
|
-
`);return}for(let g of
|
|
127
|
-
`))}
|
|
128
|
-
`)),process.exit(1));let{harness:o,parseErrors:s}=
|
|
129
|
-
`));
|
|
130
|
-
`)),process.exit(1));let{harness:t}=
|
|
131
|
-
`)});$e.command("explain <node>").description("Show the workflow a single node compiles to").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action((
|
|
132
|
-
`)),process.exit(1));let{harness:o}=
|
|
133
|
-
`)),process.exit(1)),e.json?J({node:
|
|
127
|
+
`);return}for(let g of p){let k=(0,ne.join)(d,g.path);(0,Y.mkdirSync)((0,ne.dirname)(k),{recursive:!0}),(0,Y.writeFileSync)(k,g.contents),i.json||process.stdout.write(Q.default.green(`wrote ${g.path}
|
|
128
|
+
`))}i.json&&J({ok:!ln(m),diagnostics:m,wrote:p.map(g=>g.path)})});$e.command("validate").description("Validate the harness (structural + files + role handoffs + topology)").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action(i=>{let{dot:e,config:t,base:r}=ke(i);(0,Y.existsSync)(e)||(i.json?J({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
129
|
+
`)),process.exit(1));let{harness:o,parseErrors:s}=pe(e,t),a=p=>(0,Y.existsSync)((0,ne.join)(r,p)),d=$o(o,r),u=[...en(o,{fileExists:a,roles:d}),...nn(o)],c=u.some(p=>p.level==="error")||s.length>0;if(i.json)J({ok:!c,parseErrors:s,diagnostics:u});else{for(let p of s)process.stderr.write(Q.default.red(`parse: ${p.message}
|
|
130
|
+
`));Rt(u)}process.exit(c?1:0)});$e.command("graph").description("Print the harness topology (Mermaid, or --json for the IR)").option("--dot <path>","path to harness.dot").option("--json","output the parsed nodes/edges as JSON").action(i=>{let{dot:e}=ke(i);(0,Y.existsSync)(e)||(i.json?J({error:`no harness.dot at ${e}`}):process.stderr.write(Q.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
131
|
+
`)),process.exit(1));let{harness:t}=pe(e);i.json?J({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(Mn(t)+`
|
|
132
|
+
`)});$e.command("explain <node>").description("Show the workflow a single node compiles to").option("--dot <path>","path to harness.dot").option("--config <path>","path to foundry.config.yaml").option("--json","machine-readable output").action((i,e)=>{let{dot:t,config:r}=ke(e);(0,Y.existsSync)(t)||(e.json?J({error:`no harness.dot at ${t}`}):process.stderr.write(Q.default.red(`no harness.dot at ${t} \u2014 run \`gp-foundry init\` first
|
|
133
|
+
`)),process.exit(1));let{harness:o}=pe(t,r),{files:s}=Ue(o),a=s.find(d=>d.path.endsWith(`/${i}.yml`))??s.find(d=>d.path.startsWith(".github/workflows/")&&new RegExp(`^ ${i}:`,"m").test(d.contents));a||(e.json?J({error:`no generated workflow for node '${i}'`}):process.stderr.write(Q.default.red(`no generated workflow for node '${i}'
|
|
134
|
+
`)),process.exit(1)),e.json?J({node:i,path:a.path,contents:a.contents}):process.stdout.write(a.contents+`
|
|
134
135
|
`)});ur($e);$e.parseAsync(process.argv);
|