@thegpvc/gp-foundry 0.2.10 → 0.2.12
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/agent-context/README.md +60 -9
- package/actions/agent-context/action.yml +22 -1
- package/actions/agent-context/dist/index.cjs +79 -45
- package/actions/config-loader/dist/index.cjs +1 -1
- package/actions/run-agent/README.md +9 -0
- package/actions/run-agent/action.yml +84 -0
- package/actions/sanitize-untrusted-input/README.md +24 -5
- package/actions/sanitize-untrusted-input/dist/index.cjs +30 -28
- package/actions/setup-agent/README.md +1 -0
- package/actions/setup-agent/action.yml +13 -1
- package/dist/cli/index.cjs +120 -111
- package/package.json +1 -1
- package/schema/config.schema.json +7 -1
- package/skill/reference/node-types.md +28 -2
- package/skill/templates/foundry.config.yaml +1 -0
- package/skill/templates/scope.yaml +2 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -1,138 +1,147 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(
|
|
4
|
-
`)}padWidth(e,
|
|
2
|
+
"use strict";var Xr=Object.create;var di=Object.defineProperty;var zr=Object.getOwnPropertyDescriptor;var Qr=Object.getOwnPropertyNames;var Zr=Object.getPrototypeOf,eo=Object.prototype.hasOwnProperty;var to=(i,e,t)=>()=>{if(t)throw t[0];try{return i&&(e=i(i=0)),e}catch(r){throw t=[r],r}};var Te=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var no=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qr(e))!eo.call(i,o)&&o!==t&&di(i,o,{get:()=>e[o],enumerable:!(r=zr(e,o))||r.enumerable});return i};var Nt=(i,e,t)=>(t=i!=null?Xr(Zr(i)):{},no(e||!i||!i.__esModule?di(t,"default",{value:i,enumerable:!0}):t,i));var io,W,H=to(()=>{"use strict";io=()=>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,W=io()});var lt=Te(an=>{"use strict";H();var It=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}},sn=class extends It{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};an.CommanderError=It;an.InvalidArgumentError=sn});var Ht=Te(cn=>{"use strict";H();var{InvalidArgumentError:ro}=lt(),ln=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 ro(`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 oo(i){let e=i.name()+(i.variadic===!0?"...":"");return i.required?"<"+e+">":"["+e+"]"}cn.Argument=ln;cn.humanReadableArgName=oo});var dn=Te(pi=>{"use strict";H();var{humanReadableArgName:so}=Ht(),un=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,a)=>o.name().localeCompare(a.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),a=r.long&&e._findOption(r.long);!o&&!a?t.push(r):r.long&&!a?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(a=>!a.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=>so(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,a=2,u=2;function p(v,b){if(b){let A=`${v.padEnd(r+u)}${b}`;return t.wrap(A,o-a,r+u)}return v}function s(v){return v.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(a))}let l=[`Usage: ${t.commandUsage(e)}`,""],d=t.commandDescription(e);d.length>0&&(l=l.concat([t.wrap(d,o,0),""]));let f=t.visibleArguments(e).map(v=>p(t.argumentTerm(v),t.argumentDescription(v)));f.length>0&&(l=l.concat(["Arguments:",s(f),""]));let _=t.visibleOptions(e).map(v=>p(t.optionTerm(v),t.optionDescription(v)));if(_.length>0&&(l=l.concat(["Options:",s(_),""])),this.showGlobalOptions){let v=t.visibleGlobalOptions(e).map(b=>p(t.optionTerm(b),t.optionDescription(b)));v.length>0&&(l=l.concat(["Global Options:",s(v),""]))}let g=t.visibleCommands(e).map(v=>p(t.subcommandTerm(v),t.subcommandDescription(v)));return g.length>0&&(l=l.concat(["Commands:",s(g),""])),l.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 a=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",u=new RegExp(`[\\n][${a}]+`);if(e.match(u))return e;let p=t-r;if(p<o)return e;let s=e.slice(0,r),l=e.slice(r).replace(`\r
|
|
5
5
|
`,`
|
|
6
|
-
`),
|
|
7
|
-
|.{1,${
|
|
8
|
-
`?"":(
|
|
9
|
-
`)}};
|
|
6
|
+
`),d=" ".repeat(r),_="\\s\u200B",g=new RegExp(`
|
|
7
|
+
|.{1,${p-1}}([${_}]|$)|[^${_}]+?([${_}]|$)`,"g"),v=l.match(g)||[];return s+v.map((b,A)=>b===`
|
|
8
|
+
`?"":(A>0?d:"")+b.trimEnd()).join(`
|
|
9
|
+
`)}};pi.Help=un});var mn=Te(hn=>{"use strict";H();var{InvalidArgumentError:ao}=lt(),pn=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=co(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 ao(`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 lo(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},fn=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,a=o!==void 0?o:!1;return t.negate===(a===e)}};function lo(i){return i.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function co(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}}hn.Option=pn;hn.DualOptions=fn});var hi=Te(fi=>{"use strict";H();function uo(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 a=1;i[o-1]===e[r-1]?a=0:a=1,t[o][r]=Math.min(t[o-1][r]+1,t[o][r-1]+1,t[o-1][r-1]+a),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 po(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(u=>u.slice(2)));let r=[],o=3,a=.4;return e.forEach(u=>{if(u.length<=1)return;let p=uo(i,u),s=Math.max(i.length,u.length);(s-p)/s>a&&(p<o?(o=p,r=[u]):p===o&&r.push(u))}),r.sort((u,p)=>u.localeCompare(p)),t&&(r=r.map(u=>`--${u}`)),r.length>1?`
|
|
10
10
|
(Did you mean one of ${r.join(", ")}?)`:r.length===1?`
|
|
11
|
-
(Did you mean ${r[0]}?)`:""}
|
|
12
|
-
- specify the name in Command constructor or using .name()`);return
|
|
13
|
-
Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(
|
|
14
|
-
- already used by option '${
|
|
11
|
+
(Did you mean ${r[0]}?)`:""}fi.suggestSimilar=po});var wi=Te(yi=>{"use strict";H();var fo=require("events").EventEmitter,gn=require("child_process"),ke=require("path"),bn=require("fs"),Q=require("process"),{Argument:ho,humanReadableArgName:mo}=Ht(),{CommanderError:yn}=lt(),{Help:go}=dn(),{Option:mi,DualOptions:bo}=mn(),{suggestSimilar:gi}=hi(),wn=class i extends fo{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=>Q.stdout.write(t),writeErr:t=>Q.stderr.write(t),getOutHelpWidth:()=>Q.stdout.isTTY?Q.stdout.columns:void 0,getErrHelpWidth:()=>Q.stderr.isTTY?Q.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,a=r;typeof o=="object"&&o!==null&&(a=o,o=null),a=a||{};let[,u,p]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(u);return o&&(s.description(o),s._executableHandler=!0),a.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(a.noHelp||a.hidden),s._executableFile=a.executableFile||null,p&&s.arguments(p),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),o?this:s}createCommand(e){return new i(e)}createHelp(){return Object.assign(new go,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 ho(e,t)}argument(e,t,r,o){let a=this.createArgument(e,t);return typeof r=="function"?a.default(o).argParser(r):a.default(r),this.addArgument(a),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(/([^ ]+) *(.*)/),a=t??"display help for command",u=this.createCommand(r);return u.helpOption(!1),o&&u.arguments(o),a&&u.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=u,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 yn(e,t,r)),Q.exit(e)}action(e){let t=r=>{let o=this.registeredArguments.length,a=r.slice(0,o);return this._storeOptionsAsProperties?a[o]=this:a[o]=this.opts(),a.push(this),e.apply(this,a)};return this._actionHandler=t,this}createOption(e,t){return new mi(e,t)}_callParseArg(e,t,r,o){try{return e.parseArg(t,r)}catch(a){if(a.code==="commander.invalidArgument"){let u=`${o} ${a.message}`;this.error(u,{exitCode:a.exitCode,code:a.code})}throw a}}_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("|"),a=t(e).join("|");throw new Error(`cannot add command '${a}' 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 a=e.long.replace(/^--no-/,"--");this._findOption(a)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let o=(a,u,p)=>{a==null&&e.presetArg!==void 0&&(a=e.presetArg);let s=this.getOptionValue(r);a!==null&&e.parseArg?a=this._callParseArg(e,a,s,u):a!==null&&e.variadic&&(a=e._concatValue(a,s)),a==null&&(e.negate?a=!1:e.isBoolean()||e.optional?a=!0:a=""),this.setOptionValueWithSource(r,a,p)};return this.on("option:"+t,a=>{let u=`error: option '${e.flags}' argument '${a}' is invalid.`;o(a,u,"cli")}),e.envVar&&this.on("optionEnv:"+t,a=>{let u=`error: option '${e.flags}' value '${a}' from env '${e.envVar}' is invalid.`;o(a,u,"env")}),this}_optionEx(e,t,r,o,a){if(typeof t=="object"&&t instanceof mi)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let u=this.createOption(t,r);if(u.makeOptionMandatory(!!e.mandatory),typeof o=="function")u.default(a).argParser(o);else if(o instanceof RegExp){let p=o;o=(s,l)=>{let d=p.exec(s);return d?d[0]:l},u.default(a).argParser(o)}else u.default(o);return this.addOption(u)}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){Q.versions?.electron&&(t.from="electron");let o=Q.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(t.from="eval")}e===void 0&&(e=Q.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":Q.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 a(d,f){let _=ke.resolve(d,f);if(bn.existsSync(_))return _;if(o.includes(ke.extname(f)))return;let g=o.find(v=>bn.existsSync(`${_}${v}`));if(g)return`${_}${g}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,p=this._executableDir||"";if(this._scriptPath){let d;try{d=bn.realpathSync(this._scriptPath)}catch{d=this._scriptPath}p=ke.resolve(ke.dirname(d),p)}if(p){let d=a(p,u);if(!d&&!e._executableFile&&this._scriptPath){let f=ke.basename(this._scriptPath,ke.extname(this._scriptPath));f!==this._name&&(d=a(p,`${f}-${e._name}`))}u=d||u}r=o.includes(ke.extname(u));let s;Q.platform!=="win32"?r?(t.unshift(u),t=bi(Q.execArgv).concat(t),s=gn.spawn(Q.argv[0],t,{stdio:"inherit"})):s=gn.spawn(u,t,{stdio:"inherit"}):(t.unshift(u),t=bi(Q.execArgv).concat(t),s=gn.spawn(Q.execPath,t,{stdio:"inherit"})),s.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{Q.on(f,()=>{s.killed===!1&&s.exitCode===null&&s.kill(f)})});let l=this._exitCallback;s.on("close",d=>{d=d??1,l?l(new yn(d,"commander.executeSubCommandAsync","(close)")):Q.exit(d)}),s.on("error",d=>{if(d.code==="ENOENT"){let f=p?`searched for local subcommand relative to directory '${p}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${u}' 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
|
+
- ${f}`;throw new Error(_)}else if(d.code==="EACCES")throw new Error(`'${u}' not executable`);if(!l)Q.exit(1);else{let f=new yn(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,l(f)}}),this.runningCommand=s}_dispatchSubcommand(e,t,r){let o=this._findCommand(e);o||this.help({error:!0});let a;return a=this._chainOrCallSubCommandHook(a,o,"preSubcommand"),a=this._chainOrCall(a,()=>{if(o._executableHandler)this._executeSubCommand(o,t.concat(r));else return o._parseCommand(t,r)}),a}_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,a)=>{let u=o;if(o!==null&&r.parseArg){let p=`error: command-argument value '${o}' is invalid for argument '${r.name()}'.`;u=this._callParseArg(r,o,a,p)}return u};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,o)=>{let a=r.defaultValue;r.variadic?o<this.args.length?(a=this.args.slice(o),r.parseArg&&(a=a.reduce((u,p)=>e(r,p,u),r.defaultValue))):a===void 0&&(a=[]):o<this.args.length&&(a=this.args[o],r.parseArg&&(a=e(r,a,r.defaultValue))),t[o]=a}),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(a=>a._lifeCycleHooks[t]!==void 0).forEach(a=>{a._lifeCycleHooks[t].forEach(u=>{o.push({hookedCommand:a,callback:u})})}),t==="postAction"&&o.reverse(),o.forEach(a=>{r=this._chainOrCall(r,()=>a.callback(a.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let o=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(a=>{o=this._chainOrCall(o,()=>a(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])},a=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let u;return u=this._chainOrCallHooks(u,"preAction"),u=this._chainOrCall(u,()=>this._actionHandler(this.processedArgs)),this.parent&&(u=this._chainOrCall(u,()=>{this.parent.emit(a,e,t)})),u=this._chainOrCallHooks(u,"postAction"),u}if(this.parent&&this.parent.listenerCount(a))o(),this._processArguments(),this.parent.emit(a,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(a=>r.conflictsWith.includes(a.attributeName()));o&&this._conflictingOption(r,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],o=t,a=e.slice();function u(s){return s.length>1&&s[0]==="-"}let p=null;for(;a.length;){let s=a.shift();if(s==="--"){o===r&&o.push(s),o.push(...a);break}if(p&&!u(s)){this.emit(`option:${p.name()}`,s);continue}if(p=null,u(s)){let l=this._findOption(s);if(l){if(l.required){let d=a.shift();d===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,d)}else if(l.optional){let d=null;a.length>0&&!u(a[0])&&(d=a.shift()),this.emit(`option:${l.name()}`,d)}else this.emit(`option:${l.name()}`);p=l.variadic?l:null;continue}}if(s.length>2&&s[0]==="-"&&s[1]!=="-"){let l=this._findOption(`-${s[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,s.slice(2)):(this.emit(`option:${l.name()}`),a.unshift(`-${s.slice(2)}`));continue}}if(/^--[^=]+=/.test(s)){let l=s.indexOf("="),d=this._findOption(s.slice(0,l));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,s.slice(l+1));continue}}if(u(s)&&(o=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(s)){t.push(s),a.length>0&&r.push(...a);break}else if(this._getHelpCommand()&&s===this._getHelpCommand().name()){t.push(s),a.length>0&&t.push(...a);break}else if(this._defaultCommandName){r.push(s),a.length>0&&r.push(...a);break}}if(this._passThroughOptions){o.push(s),a.length>0&&o.push(...a);break}o.push(s)}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 r=
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,
|
|
22
|
-
Expecting one of '${r.join("', '")}'`);let o=`${e}Help`;return this.on(o,
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`
|
|
27
|
-
`)})}function
|
|
28
|
-
`)})
|
|
20
|
+
`),this.outputHelp({error:!0}));let r=t||{},o=r.exitCode||1,a=r.code||"commander.error";this._exit(o,a,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Q.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()}`,Q.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new bo(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=u=>{let p=u.attributeName(),s=this.getOptionValue(p),l=this.options.find(f=>f.negate&&p===f.attributeName()),d=this.options.find(f=>!f.negate&&p===f.attributeName());return l&&(l.presetArg===void 0&&s===!1||l.presetArg!==void 0&&s===l.presetArg)?l:d||u},o=u=>{let p=r(u),s=p.attributeName();return this.getOptionValueSource(s)==="env"?`environment variable '${p.envVar}'`:`option '${p.flags}'`},a=`error: ${o(e)} cannot be used with ${o(t)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let o=[],a=this;do{let u=a.createHelp().visibleOptions(a).filter(p=>p.long).map(p=>p.long);o=o.concat(u),a=a.parent}while(a&&!a._enablePositionalOptions);t=gi(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",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(a=>{o.push(a.name()),a.alias()&&o.push(a.alias())}),t=gi(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=>mo(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=ke.basename(e,ke.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(a=>a.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(a=>a.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=Q.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,a=>{let u;typeof t=="function"?u=t({error:a.error,command:a.command}):u=t,u&&a.write(`${u}
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(o=>t.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function bi(i){return i.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",o="9229",a;return(a=e.match(/^(--inspect(-brk)?)$/))!==null?t=a[1]:(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=a[1],/^\d+$/.test(a[3])?o=a[3]:r=a[3]):(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=a[1],r=a[3],o=a[4]),t&&o!=="0"?`${t}=${r}:${parseInt(o)+1}`:e})}yi.Command=wn});var ki=Te(pe=>{"use strict";H();var{Argument:_i}=Ht(),{Command:_n}=wi(),{CommanderError:yo,InvalidArgumentError:Ai}=lt(),{Help:wo}=dn(),{Option:$i}=mn();pe.program=new _n;pe.createCommand=i=>new _n(i);pe.createOption=(i,e)=>new $i(i,e);pe.createArgument=(i,e)=>new _i(i,e);pe.Command=_n;pe.Option=$i;pe.Argument=_i;pe.Help=wo;pe.CommanderError=yo;pe.InvalidArgumentError=Ai;pe.InvalidOptionArgumentError=Ai});var Mt=Te((ia,An)=>{"use strict";H();var Ft=process||{},vi=Ft.argv||[],Pt=Ft.env||{},_o=!(Pt.NO_COLOR||vi.includes("--no-color"))&&(!!Pt.FORCE_COLOR||vi.includes("--color")||Ft.platform==="win32"||(Ft.stdout||{}).isTTY&&Pt.TERM!=="dumb"||!!Pt.CI),Ao=(i,e,t=i)=>r=>{let o=""+r,a=o.indexOf(e,i.length);return~a?i+$o(o,e,t,a)+e:i+o+e},$o=(i,e,t,r)=>{let o="",a=0;do o+=i.substring(a,r)+t,a=r+e.length,r=i.indexOf(e,a);while(~r);return o+i.substring(a)},xi=(i=_o)=>{let e=i?Ao:()=>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")}};An.exports=xi();An.exports.createColors=xi});H();H();var Ei=Nt(ki(),1),{program:Ws,createCommand:Vs,createArgument:Ys,createOption:Ks,CommanderError:Js,InvalidArgumentError:Xs,InvalidOptionArgumentError:zs,Command:Si,Argument:Qs,Option:Zs,Help:ea}=Ei.default;var J=Nt(Mt(),1),Jr=require("child_process"),Y=require("fs"),ne=require("path");H();H();H();var Ge=["analyst","issue-agent","producer","pr-review","pr-fix","scheduled-agent"];function Ci(i){return i.uses!==void 0}H();function ct(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"}}H();H();var $n=new Set(["type","role","prompt","policy","tools","context","name","output","gates","skip","select","authors","max_attempts","agent_attempts","schedule","timeout","environment","paths","commit","secrets","permissions","on_complete_label","cancel_in_progress","checkout","title","harness_ref","persist_credentials","repo_guides"]),kn=new Set(["on","when","do"]);function Oi(i,e){let t=(a,u)=>{let p=Array.from({length:u.length+1},(s,l)=>l);for(let s=1;s<=a.length;s++){let l=p[0];p[0]=s;for(let d=1;d<=u.length;d++){let f=p[d];p[d]=Math.min(p[d]+1,p[d-1]+1,l+(a[s-1]===u[d-1]?0:1)),l=f}}return p[u.length]},r,o=3;for(let a of e){let u=t(i.toLowerCase(),a);u<o&&([r,o]=[a,u])}return r}function En(i){let e=i.attrs.gates;if(e===void 0)return[];if(typeof e!="string")throw new Error(`node '${i.id}': gates= must be a string like "ci.yml" or "lint?90"`);let t=[];for(let r of e.split(",").map(o=>o.trim()).filter(Boolean)){let[o,...a]=r.split("?"),u=o.trim();if(!u)throw new Error(`node '${i.id}': gates= entry '${r}' names no workflow or check`);let p={name:u,kind:/\.ya?ml$/i.test(u)?"workflow":"check"};for(let s of a.map(l=>l.trim()))if(s==="info")p.info=!0;else if(/^[1-9]\d*$/.test(s)&&p.graceSeconds===void 0)p.graceSeconds=Number(s);else throw new Error(`node '${i.id}': gates= entry '${r}' has a bad '?${s}' suffix \u2014 expected '?<seconds>' (a whole number >= 1) and/or '?info', e.g. "${u}?90" or "${u}?info"`);t.push(p)}return t}function Ti(i){try{return En(i)}catch{return[]}}function Sn(i){let e=i.attrs.skip;if(e===void 0)return[];if(typeof e!="string"||!e.trim())throw new Error(`node '${i.id}': skip= must be a non-empty string like "draft,unchanged-diff"`);let t=[],r=new Set;for(let o of e.split(",").map(a=>a.trim()).filter(Boolean))if(!r.has(o))if(r.add(o),o==="draft"||o==="bot-author"||o==="unchanged-diff")t.push({kind:o});else if(o.startsWith("label:")&&o.slice(6).trim())t.push({kind:"label",label:o.slice(6).trim()});else throw new Error(`node '${i.id}': unknown skip= entry '${o}' \u2014 expected draft, bot-author, label:<key> or unchanged-diff`);if(!t.length)throw new Error(`node '${i.id}': skip= has no entries`);return t}function Fe(i){try{return Sn(i)}catch{return[]}}var ko=/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\[bot\])?$/;function Ri(i,e){let t=[];for(let r of i){let o=String(r).trim();if(!o)continue;if(!ko.test(o))throw new Error(`${e}: '${o}' is not a GitHub login`);let a=o.toLowerCase();t.includes(a)||t.push(a)}if(!t.length)throw new Error(`${e}: names no login \u2014 an empty allowlist would match nobody`);return t}function vn(i){return i.type==="pr-fix"||(i.type==="pr-review"||i.type==="analyst")&&Ee(i)}function xn(i,e){let t=i.attrs.authors;return t!==void 0?Ri(String(t).split(","),`node '${i.id}': authors=`):ut(e)}function ut(i){let e=i.repo?.authors;if(e!==void 0){if(!Array.isArray(e))throw new Error("repo.authors must be a list of GitHub logins");return Ri(e,"repo.authors")}}function We(i,e){if(vn(i))try{return xn(i,e)}catch{return[Cn]}}var Cn="no author matches a malformed allowlist";function Ni(i){let e=i.map(t=>`github.event.pull_request.user.login == '${t}'`);return e.length===1?e[0]:`(${e.join(" || ")})`}function Ee(i){return i.context==="pr-diff"||i.context==="pr-review"}function Ve(i){return i.attrs.select==="sweep"&&i.type==="pr-review"&&Ee(i)&&i.attrs.schedule!==void 0}function Ye(i,e){return(i.type==="pr-review"||i.type==="analyst")&&Ee(i)&&i.attrs.schedule===void 0&&(Fe(i).length>0||We(i,e)!==void 0)}function Ke(i){return Ve(i)?`${i.id}_select`:`${i.id}_guard`}function Dt(i){return`${i.id} #`}function On(i){return`gp-foundry/sweep-failed (${i.id})`}function Tn(i){return`gp-foundry/swept (${i.id})`}function Lt(i){return`<!-- gp-foundry:diff:${i.id}:`}var Ii="**Verdict:**";H();function Xe(i){return`\${{ secrets.${i} }}`}function Se(i,e){if(!e)return"";let t=i.specDir?.replace(/\/+$/,"");return t?`${t}/${e}`:e}function le(i){let e=ct(i.config);return e.mode==="app"?"${{ steps.app-token.outputs.token }}":e.mode==="pat"?Xe(e.tokenSecret??"AGENT_PAT"):"${{ github.token }}"}var Eo=new Set(["actions","checks","contents","deployments","issues","packages","pages","pull-requests","security-events","statuses","workflows"]);function jt(i,e){let t=ct(i.config);if(t.mode!=="app"||!t.appIdSecret||!t.appKeySecret)return;let r={"client-id":Xe(t.appIdSecret),"private-key":Xe(t.appKeySecret)};for(let[o,a]of Object.entries(e??{}))Eo.has(o)&&a!=="none"&&(r[`permission-${o}`]=a);return{uses:"actions/create-github-app-token@v3",id:"app-token",name:"Mint app token",with:r}}var Je=".gp-foundry/harness";function Ut(i,e=!1){return i.attrs.harness_ref==="head"?!1:e||i.type==="pr-fix"||(i.type==="pr-review"||i.type==="analyst")&&Ee(i)}function qt(i,e){let t=i.config.runtime?.mode==="vendored",r=i.specDir.replace(/\/+$/,""),o=[i.node.files.role,i.node.files.prompt,"agents/scope.yaml","agents/communication.md"].filter(d=>!!d).map(d=>r?`${r}/${d}`:d),a=new Set([".github/agent-setup"]);t&&a.add(".github/actions");for(let d of o){let f=d.includes("/")?d.slice(0,d.lastIndexOf("/")):"";f&&a.add(f)}let u=[...a].sort(),p=u.filter(d=>!u.some(f=>f!==d&&d.startsWith(`${f}/`))),s=[{uses:"actions/checkout@v5",name:"Checkout harness files (base ref)",with:{ref:e,path:Je,"fetch-depth":1,"sparse-checkout":p.join(`
|
|
24
|
+
`),token:le(i),"persist-credentials":!1}},ie({name:"Keep the harness copy out of the working tree",run:`mkdir -p .git/info
|
|
25
|
+
echo "/${Je.split("/")[0]}/" >> .git/info/exclude`})],l=t?d=>`./${Je}/.github/actions/${d}`:i.actionRef;return{ctx:{...i,specDir:r?`${Je}/${r}`:Je,harnessRoot:Je,actionRef:l},steps:s}}function Bt(i,e={}){let t={token:le(i)};return e.ref&&(t.ref=e.ref),e.persistCredentials===!1&&(t["persist-credentials"]=!1),i.node.attrs.checkout==="partial"?(t["fetch-depth"]=0,t.filter="blob:none"):e.fetchDepth!==void 0&&(t["fetch-depth"]=e.fetchDepth),{uses:"actions/checkout@v5",name:"Checkout",with:t}}function ze(i){return{uses:`${i?.harnessRoot?`./${i.harnessRoot}`:"."}/.github/agent-setup`,name:"Setup agent toolchain"}}function Hi(i){let e=i.attrs.persist_credentials;return typeof e=="boolean"?e:i.attrs.checkout==="partial"}function So(i){return i===void 0?!0:i.split(",").some(e=>{let t=e.trim();return t==="Bash"||/^Bash\(\s*gh\b/.test(t)})}function Pi(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 ie({name:"Configure git identity",env:{GIT_NAME:t,GIT_EMAIL:r},run:`git config user.name "$GIT_NAME"
|
|
26
|
+
git config user.email "$GIT_EMAIL"`})}function dt(i,e,t,r={}){let o={type:e,number:t,token:le(i)};r.checks&&(o["checks-token"]="${{ github.token }}");let a=i.config.identity?.bot_login;return a&&(o["trusted-authors"]=a,r.framing==="baseline"&&(o["trusted-framing"]="baseline")),{uses:i.actionRef("agent-context"),id:"ctx",name:"Fetch context",with:o}}function Qe(i,e){let t=i.node,r=i.config,o={"role-file":Se(i,t.files.role),model:r.agent.model,"comms-file":Se(i,"agents/communication.md"),"scope-path":Se(i,"agents/scope.yaml"),...r.agent.api_key_secret?{"anthropic-api-key":Xe(r.agent.api_key_secret)}:{"claude-code-oauth-token":Xe(r.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")}};So(i.roleTools?.(t.id))&&(o["github-token"]=le(i)),t.attrs.repo_guides===!1&&(o["repo-guides"]="false"),e.withContext&&(o["context-file"]="${{ steps.ctx.outputs.context-file }}"),r.agent.conventions&&(o.conventions=r.agent.conventions);let a=typeof t.attrs.secrets=="string"?t.attrs.secrets.split(",").map(l=>l.trim()).filter(Boolean):[],u=[...new Set([...r.agent.secrets??[],...a])];u.length&&(o["extra-env"]=u.map(l=>`${l}=${Xe(l)}`).join(`
|
|
27
|
+
`));let p=t.attrs.agent_attempts;p!==void 0&&(o["max-attempts"]=String(p));let s=t.files.prompt;return s&&(o["prompt-override-file"]=Se(i,s)),{uses:i.actionRef("run-agent"),name:"Run agent",with:o}}function ie(i){return{shell:"bash",...i}}function Gt(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 a=/^\s*([a-z](?:[a-z-]*[a-z])?)\s*:\s*(read|write|none)\s*$/.exec(o);if(!a)throw new Error(`node '${i.id}': bad permissions= entry '${o.trim()}' \u2014 expected '<scope>: read|write|none', e.g. "id-token: write"`);t[a[1]]=a[2]}return t}function Mi(i,e){let t;try{t=Gt(i)}catch{return e}return Object.keys(t).length?{...e,permissions:{...e.permissions,...t}}:e}var Me="${{ github.event.issue.number }}",Ze="${{ github.event.pull_request.number }}",Nn="${{ github.event.pull_request.head.sha }}",Fi="${{ github.event.pull_request.head.ref }}",In="${{ github.event.pull_request.base.ref }}";function Hn(i,e){try{return{...e,...Gt(i)}}catch{return e}}function Re(i,e){let t=i.attrs.timeout;return typeof t=="number"?t:e}var vo=10;function Wt(i){return Math.max(1,i-vo)}function Vt(i,e,t){let r=[],o=jt(i,t&&Hn(i.node,t));return o&&r.push(o),r.push(Bt(i,e)),r.push(Pi(i)),r}function Rn(i){let e=i,t=e.node,r=t.context??"issue",o=r==="pr-diff"||r==="pr-review",a=o?{contents:"read","pull-requests":"write",checks:"read"}:{contents:"read",issues:"write"},u=Ve(t),p=!u&&Ye(t,e.config),s=Ke(t),l=u?"${{ matrix.pr.number }}":Ze,d=u?"${{ matrix.pr.sha }}":Nn,f=[],_=jt(e,Hn(t,a));_&&f.push(_);let g=Hi(t);if(f.push(Bt(e,o?{ref:d,fetchDepth:0,persistCredentials:g}:{persistCredentials:g})),o&&Ut(t)){let U=qt(e,u?"${{ matrix.pr.base }}":In);f.push(...U.steps),e=U.ctx}let v=o?Ti(t):[],b=v.map(U=>U.name),A=b.map((U,ee)=>Co(`gate-${U}`,ee,b));v.forEach((U,ee)=>{f.push({uses:e.actionRef("wait-for-checks"),id:A[ee],name:`Wait for ${U.name}`,with:{sha:d,...U.kind==="workflow"?{"workflow-name":U.name,token:le(e)}:{"check-name":U.name,token:"${{ github.token }}"},...U.graceSeconds!==void 0?{"missing-grace-seconds":U.graceSeconds}:{}}})}),f.push(ze(e));let N=r==="pr-diff"?"pr-diff":r==="pr-review"?"pr-review":"issue";f.push(dt(e,N,o?l:Me,{framing:"baseline",checks:o})),v.length&&f.push(Oo(v,A));let F=Re(t,b.length?15+15*b.length:25),D=Qe(e,{withContext:!0});f.push(b.length?D:{...D,timeoutMinutes:Wt(F)});let L={jobId:t.id,name:t.id,permissions:a,timeoutMinutes:F,steps:f};return u?(L.needs=[s],L.displayName=`${Dt(t)}\${{ matrix.pr.number }}`,L.if=`needs.${s}.outputs.count != '0'`,L.strategy={"fail-fast":!1,matrix:{pr:`\${{ fromJSON(needs.${s}.outputs.prs) }}`}}):p&&(L.needs=[s],L.if=`needs.${s}.outputs.run == 'true'`,Fe(t).some(U=>U.kind==="unchanged-diff")&&f.push(xo(e,s))),L}function xo(i,e){return ie({name:"Stamp the review with the diff hash",if:`\${{ success() && needs.${e}.outputs.diff_hash != '' }}`,env:{GH_TOKEN:le(i),PR:Ze,HEAD_SHA:`\${{ needs.${e}.outputs.head_sha }}`,DIFF_HASH:`\${{ needs.${e}.outputs.diff_hash }}`,BOT_LOGIN:i.config.identity?.bot_login??"",MARKER_PREFIX:Lt(i.node)},run:["# Best-effort: a missing stamp only means the next event is reviewed again.",`ID=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`," .[] | select(.user.login == env.BOT_LOGIN and .commit_id == env.HEAD_SHA)",` | select((.body // "") | contains(env.MARKER_PREFIX) | not) | .id' 2>/dev/null | tail -n 1) || ID=""`,'if [ -z "$ID" ]; then',' echo "no unstamped review by $BOT_LOGIN on $HEAD_SHA \u2014 nothing to stamp"'," exit 0","fi",`BODY=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$ID" --jq '.body // ""') || exit 0`,'gh api --method PUT "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews/$ID" \\',` -f body="$(printf '%s\\n\\n%s%s -->' "$BODY" "$MARKER_PREFIX" "$DIFF_HASH")" >/dev/null \\`,' || echo "::warning::could not stamp review $ID with the diff hash"'].join(`
|
|
28
|
+
`)})}function Co(i,e,t){let r=u=>u.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),o=r(i)||`gate-${e+1}`;return t.filter((u,p)=>p!==e&&r(`gate-${u}`)===o).length>0?`${o}-${e+1}`:o}function Oo(i,e){let t={CONTEXT_FILE:"${{ steps.ctx.outputs.context-file }}"},r=["{",' echo ""',' echo "=== CI GATES ==="'],o=p=>` echo "$GATE_${p+1}_NAME: $GATE_${p+1}_RESULT"`;i.forEach((p,s)=>{t[`GATE_${s+1}_NAME`]=p.name,t[`GATE_${s+1}_RESULT`]=`\${{ steps.${e[s]}.outputs.conclusion }}`});let a=i.map((p,s)=>({g:p,i:s})).filter(({g:p})=>!p.info),u=i.map((p,s)=>({g:p,i:s})).filter(({g:p})=>p.info);return a.length&&(a.forEach(({i:p})=>r.push(o(p))),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."')),u.length&&(a.length&&r.push(' echo ""'),r.push(' echo "Informational checks (advisory \u2014 never blocking on their own):"'),u.forEach(({i:p})=>r.push(o(p))),r.push(' echo ""',` echo "'skipped', 'neutral' or 'timeout' here means the check did not run or had"`,' echo "nothing to report on this head \u2014 that is normal and is not a finding. A"',` echo "'failure' is input to weigh alongside your own review, not a verdict."`)),r.push('} >> "$CONTEXT_FILE"'),ie({name:"Record CI gate results in the context",env:t,run:r.join(`
|
|
29
|
+
`)})}function To(i){let e=i.node,t=i.config,r=Vt(i,void 0,{contents:"write","pull-requests":"write",issues:"write"});r.push(ie({id:"branch",name:"Create branch",env:{ISSUE_NUMBER:Me,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(`
|
|
30
|
+
`)}));let o=Re(e,35);return r.push(ze(i)),r.push(dt(i,"issue",Me)),r.push({...Qe(i,{withContext:!0}),timeoutMinutes:Wt(o)}),r.push({uses:i.actionRef("agent-fallback"),name:"Fallback: commit / push / PR",if:"${{ !cancelled() }}",with:{branch:"${{ steps.branch.outputs.branch }}",token:le(i),"agent-name":e.id,"base-branch":t.repo.base_branch,"issue-number":Me,"pr-title":"${{ github.event.issue.title }}","pr-body":`### \u{1F6E0}\uFE0F Auto-created (fallback)
|
|
29
31
|
|
|
30
32
|
The agent finished but didn't open a PR itself, so one was created automatically. See the commits and the linked issue for context.
|
|
31
33
|
|
|
32
|
-
Closes #${
|
|
33
|
-
`)}));let
|
|
34
|
-
`)})),{jobId:
|
|
35
|
-
`)})]}}function
|
|
36
|
-
`)})),r.push(
|
|
37
|
-
`)})),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":n.repo.base_branch,token:ce(i),"agent-name":e.id,"scope-path":Ae(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:xe(e,20),steps:r}}function mi(i,e,n){let r=i.node,o=[],s=Hn(i);s&&o.push(s),o.push(Pn(i,n?{ref:mt,fetchDepth:0}:void 0)),o.push(Ge()),o.push(sn(i,n?"pr-review":"issue",n?We:He)),r.files.role&&o.push(Ve(i,{withContext:!0}));let u=r.attrs.on_complete_label;if(typeof u=="string"&&u){let a=i.config.labels?.[u]??u;o.push(se({name:"Apply completion label",env:{GH_TOKEN:ce(i),NUM:n?We:He},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${a}'`}))}return fi(r,{jobId:r.id,name:r.id,needs:e,permissions:n?{contents:"read","pull-requests":"write",issues:"write"}:{contents:"read",issues:"write"},timeoutMinutes:xe(r,15),steps:o})}var ao={analyst:ft,"issue-agent":ft,"pr-review":ft,producer:eo,"pr-fix":no,"merge-gate":ro,"human-gate":oo,"scheduled-agent":so,start:()=>null,exit:()=>null};function gt(i,e,n){let r=ao[i.type];if(!r)return null;let o=r(n);return o&&fi(i,o)}I();var lo=new Set(qe);function Pe(i){let e=new Map(i.nodes.map(u=>[u.id,u])),n=new Map,r=new Map;for(let u of i.nodes)n.set(u.id,[]),r.set(u.id,[]);for(let u of i.edges)n.get(u.to)?.push(u),r.get(u.from)?.push(u);let o=new Map,s=new Set;for(let u of i.nodes){if(u.type!=="fan_in")continue;let a=n.get(u.id)??[];if(a.length<2)continue;let d=[],l,p=!0;for(let E of a){let k=e.get(E.from);if(!k||!lo.has(k.type)){p=!1;break}let x=n.get(k.id)??[],M=r.get(k.id)??[];if(x.length!==1||M.length!==1||M[0].to!==u.id){p=!1;break}let H=e.get(x[0].from);if(!H||H.type!=="parallel"){p=!1;break}if(x[0].on||x[0].when){p=!1;break}if(l===void 0)l=H.id;else if(l!==H.id){p=!1;break}d.push(k.id)}if(!p||l===void 0)continue;let m=n.get(l)??[],h=r.get(l)??[];if(m.length!==1||!m[0].on)continue;let $=new Set(d);if(!(!h.every(E=>$.has(E.to))||h.length!==d.length)){o.set(u.id,{parallelId:l,entryEdge:m[0],legIds:d,faninId:u.id}),s.add(l);for(let E of d)s.add(E)}}return{byFanin:o,memberIds:s}}var an=new Set(qe);function ln(i,e={}){let n=[],r=new Map(i.nodes.map(a=>[a.id,a])),o=Pe(i).memberIds;for(let a of i.nodes)a.declared||n.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(an.has(a.type)&&!a.files.role&&n.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{ht(a)}catch(d){n.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")&&n.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)&&n.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"}),an.has(a.type)||n.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"})}if(a.attrs.cancel_in_progress!==void 0&&(typeof a.attrs.cancel_in_progress!="boolean"&&n.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${a.id}' must be true or false, got ${JSON.stringify(a.attrs.cancel_in_progress)}`,where:{node:a.id,line:a.line}}),!an.has(a.type)||o.has(a.id)?n.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${a.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:a.id,line:a.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):a.attrs.cancel_in_progress===!0&&(a.type==="producer"||a.type==="pr-fix"||a.type==="scheduled-agent"&&a.attrs.commit!=="none")&&n.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${a.id}' (type ${a.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:a.id,line:a.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),a.attrs.checkout!==void 0&&(a.attrs.checkout!=="partial"?n.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${a.id}' must be "partial", got ${JSON.stringify(a.attrs.checkout)}`,where:{node:a.id,line:a.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(a.type==="start"||a.type==="exit"||a.type==="parallel"||a.type==="human-gate")&&n.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${a.id}' (type ${a.type}) is ignored \u2014 this node checks nothing out`,where:{node:a.id,line:a.line}})),a.attrs.gates!==void 0)try{dt(a)}catch(d){n.push({level:"error",code:"node.bad-gates",message:d.message,where:{node:a.id,line:a.line},hint:'comma-separated workflow files or check-run names, each with an optional ?<seconds> grace \u2014 e.g. gates="ci.yml, e2e (chromium)?90"'})}if(a.attrs.skip!==void 0){let d=[];try{d=pt(a)}catch(p){n.push({level:"error",code:"node.bad-skip",message:p.message,where:{node:a.id,line:a.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}(a.type==="pr-review"||a.type==="analyst")&&tn(a)&&a.attrs.schedule===void 0&&!o.has(a.id)||n.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${a.id}' is not supported here \u2014 it needs a standalone, event-driven pr-review/analyst node with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line},hint:a.attrs.select!==void 0||a.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':o.has(a.id)?"a diamond leg has no guard job of its own; put the review lane outside the diamond":'set context="pr-diff" on the node \u2014 skip= reads the pull request the event is about'}),d.some(p=>p.kind==="unchanged-diff")&&!i.config.identity?.bot_login&&n.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${a.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:a.id,line:a.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}a.attrs.select!==void 0&&(a.attrs.select!=="sweep"?n.push({level:"error",code:"node.bad-select",message:`select= on '${a.id}' must be "sweep", got ${JSON.stringify(a.attrs.select)}`,where:{node:a.id,line:a.line}}):a.type!=="pr-review"||!tn(a)||o.has(a.id)?n.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${a.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:a.id,line:a.line}}):a.attrs.schedule===void 0?n.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${a.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:a.id,line:a.line},hint:'e.g. schedule="*/15 * * * *"'}):i.config.identity?.bot_login||n.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${a.id}': identity.bot_login is unset, so ANY review carrying a '**Verdict:**' marker counts as the decision \u2014 a user can pre-empt the lane by posting one`,where:{node:a.id,line:a.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),a.type==="human-gate"&&a.attrs.environment===void 0&&n.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&&n.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 l=a.files[d];l&&!e.fileExists(l)&&n.push({level:"error",code:"file.missing",message:`node '${a.id}' references ${d}="${l}" which does not exist`,where:{node:a.id,line:a.line,file:l}})}if(e.roles){let a=new Map;for(let l of i.nodes)a.set(l.id,[]);for(let l of i.edges){let p=r.get(l.to);p&&a.get(l.from)?.push({node:p,edge:l})}let d=l=>(e.roles?.get(l.id)?.role??l.id).toLowerCase();for(let l of i.nodes){let p=e.roles.get(l.id);if(!p?.handoffs)continue;let m=a.get(l.id)??[],h=new Set(m.flatMap(E=>[E.node.id.toLowerCase(),d(E.node)])),$=new Set(p.handoffs.map(E=>String(E.to).toLowerCase()));for(let E of p.handoffs)h.has(String(E.to).toLowerCase())||n.push({level:"warning",code:"role.handoff-no-edge",message:`role '${p.role}' (node '${l.id}') declares a handoff to '${E.to}' but there is no matching out-edge`,where:{node:l.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:E,edge:k}of m)E.type==="exit"&&!k.when||!$.has(E.id.toLowerCase())&&!$.has(d(E))&&n.push({level:"warning",code:"role.edge-no-handoff",message:`node '${l.id}' has an out-edge to '${E.id}' not declared as a handoff in role '${p.role}'`,where:{node:l.id,edge:[l.id,E.id]},hint:"document the handoff in the role, or remove the edge"})}}let s=(a,d)=>{if(typeof a=="string"){let l=a.match(/<[A-Za-z][^<>]{0,80}>/);l&&n.push({level:"error",code:"config.placeholder",message:`config value ${d} still contains the placeholder ${l[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((l,p)=>s(l,`${d}[${p}]`));else if(a&&typeof a=="object")for(let[l,p]of Object.entries(a))s(p,d?`${d}.${l}`:l)};if(s(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let a=new Set,d=!1;for(let l of i.nodes)an.has(l.type)&&(d=!0,a.add("run-agent")),an.has(l.type)&&l.type!=="scheduled-agent"&&a.add("agent-context"),(l.type==="producer"||l.type==="scheduled-agent")&&a.add("agent-fallback"),l.type==="merge-gate"&&a.add("merge-gate"),l.type==="pr-review"&&l.attrs.gates!==void 0&&a.add("wait-for-checks");for(let l of a)e.fileExists(`actions/${l}/action.yml`)||n.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${l}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});d&&!e.fileExists("agent-setup/action.yml")&&n.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}=Pe(i);for(let l of i.nodes)if(l.type==="parallel"&&!d.has(l.id)&&n.push({level:"error",code:"diamond.malformed",message:`parallel '${l.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:l.id,line:l.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),l.type==="fan_in"){let p=a.get(l.id);if(!p)n.push({level:"error",code:"diamond.malformed",message:`fan_in '${l.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:l.id,line:l.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!l.files.role&&l.attrs.on_complete_label===void 0&&n.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${l.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:l.id,line:l.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let m=p.legIds.filter(h=>r.get(h)?.type==="pr-review");m.length&&n.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${l.id}' lanes [${m.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:l.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(nn(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&&n.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??""))&&n.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")||n.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"}),n}I();var co=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),gi=new Set(["start"]);function cn(i){let e=[],n=new Set(i.nodes.map(l=>l.id)),r=new Map(i.nodes.map(l=>[l.id,l])),o=new Map;for(let l of n)o.set(l,[]);for(let l of i.edges)n.has(l.from)&&n.has(l.to)&&o.get(l.from).push(l.to);let s=i.nodes.filter(l=>gi.has(l.type)||l.attrs.schedule!==void 0||l.type==="merge-gate"),u=new Set,a=s.map(l=>l.id);for(;a.length;){let l=a.pop();if(!u.has(l)){u.add(l);for(let p of o.get(l)??[])a.push(p)}}for(let l of i.nodes)!u.has(l.id)&&!gi.has(l.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${l.id}' is unreachable from any entry (start/scheduled) node`,where:{node:l.id,line:l.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let l of i.nodes)(o.get(l.id)??[]).length===0&&!co.has(l.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${l.id}' (type ${l.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:l.id,line:l.line},hint:"route it to a next node, or make it an exit"});for(let l of fo(n,o)){if(!(l.length>1||(o.get(l[0])??[]).includes(l[0])))continue;let m=new Set(l),h=[];for(let $ of l)for(let E of o.get($)??[])m.has(E)||h.push({from:$,to:E});h.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${l.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:l[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):h.some($=>po(uo(i,$.from,$.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${l.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:l[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let d=new Map;for(let l of i.edges){let p=`${l.on??""}|${l.when??""}`;d.has(l.from)||d.set(l.from,new Map);let m=d.get(l.from);m.has(p)||m.set(p,new Set),m.get(p).add(l.to)}for(let[l,p]of d)for(let[m,h]of p)h.size>1&&m!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${l}' has multiple edges with identical trigger/guard (${m}) to different targets: ${[...h].join(", ")}`,where:{node:l},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function uo(i,e,n){return i.edges.find(r=>r.from===e&&r.to===n)?.when}function po(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function fo(i,e){let n=0,r=new Map,o=new Map,s=new Set,u=[],a=[],d=l=>{r.set(l,n),o.set(l,n),n++,u.push(l),s.add(l);for(let p of e.get(l)??[])r.has(p)?s.has(p)&&o.set(l,Math.min(o.get(l),r.get(p))):(d(p),o.set(l,Math.min(o.get(l),o.get(p))));if(o.get(l)===r.get(l)){let p=[],m;do m=u.pop(),s.delete(m),p.push(m);while(m!==l);a.push(p.reverse())}};for(let l of i)r.has(l)||d(l);return a}I();var ho=new Set(qe),mo=new Set(["pr-review","pr-fix"]);function go(i,e){return e.labels?.[i]??i}function jn(i){return mo.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function bt(i,e,n){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.ready_for_review":return r("pull_request","ready_for_review");case"pull_request_review.submitted":return r("pull_request_review","submitted");case"push":if(jn(n))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function un(i,e){return i==="push"&&jn(e)?"pull_request.synchronize":i}function _i(i){let[e,n]=i.split(".");return n?`(github.event_name == '${e}' && github.event.action == '${n}')`:`github.event_name == '${e}'`}function bo(i,e,n){if(i.on){let o=i.on.split(",").map(u=>u.trim()).filter(Boolean),s=o.map(u=>un(u,e));return{events:o,guard:i.when?Dn(i.when,s,n):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[jn(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Dn(r,o,n)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Dn(r,o,n)}}}function Dn(i,e,n){if(i.startsWith("label=")){let o=`github.event.label.name == '${go(i.slice(6),n)}'`,s=yo(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=wo(n);return s?`${o} && ${s}`:o}}function yo(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 wo(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function bi(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function _o(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function yi(i,e,n){let r=_o(n),o=[...e].filter(bi);if(!r||o.length===0)return i;let s=[...e].filter(a=>!bi(a)),u=s.length?`(${s.map(_i).join(" || ")} || ${r})`:r;return i?`(${i}) && ${u}`:u}function wi(i,e){let n=i.attrs.cancel_in_progress;return typeof n=="boolean"&&ho.has(i.type)?n:e}function Ao(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":wi(i,!1)};let n=jn(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${n}`,"cancel-in-progress":wi(i,i.type==="issue-agent")}}function Ai(i){let e={},n=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=Pe(i);for(let s of i.nodes){if(s.type==="start"||s.type==="exit"||o.memberIds.has(s.id))continue;let u=o.byFanin.get(s.id);if(u){let E=u.entryEdge,k=n.get(u.legIds[0]),x={},M=(E.on??"").split(",").map(K=>K.trim()).filter(Boolean);for(let K of M)bt(x,K,k);let H={nodeId:s.id,triggers:x,dispatches:[]},F=new Set(M.map(K=>un(K,k))),L=yi(E.when?Dn(E.when,[...F],i.config):void 0,F,i.config);L&&(H.guard=L);let re=M.some(K=>un(K,k).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";H.concurrency={group:`${s.id}-${re}`,"cancel-in-progress":!1},e[s.id]=H;continue}if(s.type==="parallel"||s.type==="fan_in")continue;let a={},d=new Set,l=new Set,p=new Set,m=[];if(s.attrs.schedule!==void 0)a.schedule=[{cron:String(s.attrs.schedule)}],a.workflow_dispatch={};else{for(let E of r.get(s.id)??[]){let k=bo(E,s,i.config);if(k){for(let x of k.events)bt(a,x,s);for(let x of k.events)p.add(un(x,s));if(k.guard)d.add(k.guard);else for(let x of k.events)l.add(un(x,s))}}if(a.pull_request&&Ue(s)&&Ie(s).some(E=>E.kind==="draft")&&(bt(a,"pull_request.ready_for_review",s),p.add("pull_request.ready_for_review"),l.add("pull_request.ready_for_review")),d.size&&l.size)for(let E of l)d.add(_i(E))}for(let E of i.edges)E.from===s.id&&E.do&&m.push({toNode:E.to,when:E.when});let h=yi(d.size?[...d].join(" || "):void 0,p,i.config),$={nodeId:s.id,triggers:a,dispatches:m};h&&($.guard=h),Object.keys(a).length&&($.concurrency=Ao(s)),e[s.id]=$}return{perNode:e}}I();I();function ko(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ie={},Ln={},Ce={},ki;function dn(){if(ki)return Ce;ki=1;function i(u){return typeof u>"u"||u===null}function e(u){return typeof u=="object"&&u!==null}function n(u){return Array.isArray(u)?u:i(u)?[]:[u]}function r(u,a){if(a){let d=Object.keys(a);for(let l=0,p=d.length;l<p;l+=1){let m=d[l];u[m]=a[m]}}return u}function o(u,a){let d="";for(let l=0;l<a;l+=1)d+=u;return d}function s(u){return u===0&&Number.NEGATIVE_INFINITY===1/u}return Ce.isNothing=i,Ce.isObject=e,Ce.toArray=n,Ce.repeat=o,Ce.isNegativeZero=s,Ce.extend=r,Ce}var yt,Ei;function pn(){if(Ei)return yt;Ei=1;function i(n,r){let o="",s=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(o+='in "'+n.mark.name+'" '),o+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!r&&n.mark.snippet&&(o+=`
|
|
34
|
+
Closes #${Me}`}}),{jobId:e.id,name:e.id,permissions:{contents:"write","pull-requests":"write",issues:"write"},timeoutMinutes:o,steps:r}}function Ro(i){let e=i,t=e.node,r=Vt(e,{ref:Fi,fetchDepth:0},{contents:"write","pull-requests":"write",checks:"read"});if(Ut(t)){let l=qt(e,In);r.push(...l.steps),e=l.ctx}let o=typeof t.attrs.max_attempts=="number"?t.attrs.max_attempts:3,a=`<!-- gp-foundry:attempt:${t.id} -->`,u=e.config.labels?.["needs-human"]??"needs-human",p=e.config.identity?.bot_login??"";r.push(ie({id:"attempts",name:`Enforce attempt budget (max ${o})`,env:{GH_TOKEN:le(e),PR:Ze,MARKER:a,MAX:String(o),BOT_LOGIN:p},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 "${u}" 2>/dev/null || gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/labels" -f 'labels[]=${u}'`,` gh pr comment "$PR" --body "$(printf '## \u26D4 Attempt budget (${t.id})\\n\\nExhausted (%s/%s requested-changes rounds) \u2014 labeling \`${u}\` 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(`
|
|
35
|
+
`)}));let s="steps.attempts.outputs.exhausted != 'true'";return r.push({...ze(e),if:s}),r.push({...dt(e,"pr-review",Ze,{framing:"work-item",checks:!0}),if:s}),r.push({...Qe(e,{withContext:!0}),if:s,timeoutMinutes:Wt(Re(t,35))}),r.push(ie({name:"Commit and push fixes",if:`${s} && !cancelled()`,env:{BRANCH:Fi},run:["# Commit anything the agent left uncommitted...",'if [ -n "$(git status --porcelain)" ]; then'," git add -A",` git commit -m "agent fix: ${t.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(`
|
|
36
|
+
`)})),{jobId:t.id,name:t.id,permissions:{contents:"write","pull-requests":"write",checks:"read"},timeoutMinutes:Re(t,35),steps:r}}function Di(i){return`gp-foundry/human-approval (${String(i.attrs.environment??"production")})`}var No="github-actions";function Io(i){return`${Di(i)}@${No}`}function Ho(i){let e=i.node,t=Vt(i,{fetchDepth:0}),o=i.inEdges.map(a=>i.nodeById?.(a.from)).filter(a=>!!a&&a.type==="human-gate").map(Io);return t.push({uses:i.actionRef("merge-gate"),name:"Evaluate merge gate",with:{token:le(i),"checks-token":"${{ github.token }}","policy-path":Se(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:Re(e,10),steps:t}}function Po(i){let e=i.node,t=String(e.attrs.environment??"production");return{jobId:e.id,name:e.id,permissions:{checks:"write"},environment:t,steps:[ie({name:"Record the approval on the head commit",env:{GH_TOKEN:"${{ github.token }}",CHECK_NAME:Di(e),HEAD_SHA:Nn,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(`
|
|
37
|
+
`)})]}}function Fo(i){let e=i.node,t=i.config,r=Vt(i,{fetchDepth:0}),o=typeof e.attrs.commit=="string"?e.attrs.commit:"direct",a=typeof e.attrs.paths=="string"?e.attrs.paths:"";return o==="pr"&&r.push(ie({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(`
|
|
38
|
+
`)})),r.push(ze(i)),r.push({...Qe(i,{withContext:!1}),id:"agent",timeoutMinutes:Wt(Re(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:le(i),"agent-name":e.id,"scope-path":Se(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.`,...a?{"allowed-paths":a}:{}}}):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:le(i),"agent-name":e.id,"scope-path":Se(i,"agents/scope.yaml"),"commit-message":`chore(${e.id}): scheduled update`,...a?{"allowed-paths":a}:{}}}),r.push(ie({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(`
|
|
39
|
+
`)})),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:le(i),"agent-name":e.id,"scope-path":Se(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",...a?{"allowed-paths":a}:{}}})),{jobId:e.id,name:e.id,permissions:{contents:"write",issues:"write","pull-requests":"write",actions:"write"},timeoutMinutes:Re(e,20),steps:r}}function Li(i,e,t){let r=i,o=r.node,a=t?{contents:"read","pull-requests":"write",issues:"write",checks:"read"}:{contents:"read",issues:"write"},u=[],p=jt(r,Hn(o,a));if(p&&u.push(p),u.push(Bt(r,t?{ref:Nn,fetchDepth:0,persistCredentials:!1}:{persistCredentials:!1})),Ut(o,t)){let l=qt(r,In);u.push(...l.steps),r=l.ctx}u.push(ze(r)),u.push(dt(r,t?"pr-review":"issue",t?Ze:Me,{framing:"baseline",checks:t})),o.files.role&&u.push(Qe(r,{withContext:!0}));let s=o.attrs.on_complete_label;if(typeof s=="string"&&s){let l=r.config.labels?.[s]??s;u.push(ie({name:"Apply completion label",env:{GH_TOKEN:le(r),NUM:t?Ze:Me},run:`gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$NUM/labels" -f 'labels[]=${l}'`}))}return Mi(o,{jobId:o.id,name:o.id,needs:e,permissions:a,timeoutMinutes:Re(o,15),steps:u})}var Mo={analyst:Rn,"issue-agent":Rn,"pr-review":Rn,producer:To,"pr-fix":Ro,"merge-gate":Ho,"human-gate":Po,"scheduled-agent":Fo,start:()=>null,exit:()=>null};function Pn(i,e,t){let r=Mo[i.type];if(!r)return null;let o=r(t);return o&&Mi(i,o)}H();var Do=new Set(Ge);function De(i){let e=new Map(i.nodes.map(u=>[u.id,u])),t=new Map,r=new Map;for(let u of i.nodes)t.set(u.id,[]),r.set(u.id,[]);for(let u of i.edges)t.get(u.to)?.push(u),r.get(u.from)?.push(u);let o=new Map,a=new Set;for(let u of i.nodes){if(u.type!=="fan_in")continue;let p=t.get(u.id)??[];if(p.length<2)continue;let s=[],l,d=!0;for(let v of p){let b=e.get(v.from);if(!b||!Do.has(b.type)){d=!1;break}let A=t.get(b.id)??[],N=r.get(b.id)??[];if(A.length!==1||N.length!==1||N[0].to!==u.id){d=!1;break}let F=e.get(A[0].from);if(!F||F.type!=="parallel"){d=!1;break}if(A[0].on||A[0].when){d=!1;break}if(l===void 0)l=F.id;else if(l!==F.id){d=!1;break}s.push(b.id)}if(!d||l===void 0)continue;let f=t.get(l)??[],_=r.get(l)??[];if(f.length!==1||!f[0].on)continue;let g=new Set(s);if(!(!_.every(v=>g.has(v.to))||_.length!==s.length)){o.set(u.id,{parallelId:l,entryEdge:f[0],legIds:s,faninId:u.id}),a.add(l);for(let v of s)a.add(v)}}return{byFanin:o,memberIds:a}}var et=new Set(Ge);function pt(i,e={}){let t=[],r=new Map(i.nodes.map(s=>[s.id,s])),o=De(i).memberIds;for(let s of i.nodes)s.declared||t.push({level:"error",code:"node.undeclared",message:`node '${s.id}' is referenced in an edge but never declared`,where:{node:s.id,line:s.line},hint:`add a node statement, e.g. ${s.id} [type=...]`});let a=(s,l,d,f)=>{let _=Oi(s,l);t.push({level:"error",code:"attr.unknown",message:`unknown attribute '${s}=' on ${d} \u2014 it would be silently ignored`,where:f,hint:_?`did you mean '${_}='?`:"see reference/node-types.md for the attributes this version of gp-foundry understands"})};for(let s of i.nodes)for(let l of Object.keys(s.raw))$n.has(l)||a(l,$n,`node '${s.id}'`,{node:s.id,line:s.line});for(let s of i.edges)for(let l of Object.keys(s.raw))kn.has(l)||a(l,kn,`edge '${s.from} -> ${s.to}'`,{edge:[s.from,s.to],line:s.line});try{ut(i.config)}catch(s){t.push({level:"error",code:"config.bad-authors",message:s.message,hint:"repo.authors is a list of GitHub logins, e.g. authors: [dpup]"})}for(let s of i.nodes){if(s.attrs.authors!==void 0)if(!vn(s)||o.has(s.id))t.push({level:"error",code:"node.authors-unsupported",message:`authors= on '${s.id}' is not supported here \u2014 it binds a standalone pr-review / pr-fix node, or an analyst with context="pr-diff" or "pr-review"`,where:{node:s.id,line:s.line},hint:o.has(s.id)?"a diamond is bound by repo.authors in foundry.config.yaml":"to restrict every PR lane at once, set repo.authors in foundry.config.yaml"});else try{xn(s,i.config)}catch(g){t.push({level:"error",code:"node.bad-authors",message:g.message,where:{node:s.id,line:s.line},hint:'comma-separated GitHub logins, e.g. authors="dpup, octocat"'})}if(et.has(s.type)&&!s.files.role&&t.push({level:"error",code:"node.missing-role",message:`agent node '${s.id}' (type ${s.type}) needs a role="..." job description`,where:{node:s.id,line:s.line}}),s.attrs.permissions!==void 0){try{Gt(s)}catch(g){t.push({level:"error",code:"node.bad-permissions",message:g.message,where:{node:s.id,line:s.line},hint:`write scopes as '<scope>: read|write|none', comma-separated \u2014 e.g. permissions="id-token: write"`})}(s.type==="start"||s.type==="exit"||s.type==="parallel")&&t.push({level:"warning",code:"node.permissions-ignored",message:`permissions= on '${s.id}' (type ${s.type}) is ignored \u2014 this node emits no workflow job`,where:{node:s.id,line:s.line},hint:"move permissions= to the lane (job-emitting node) that needs the scope"})}if(s.attrs.agent_attempts!==void 0){let g=s.attrs.agent_attempts;(typeof g!="number"||!Number.isInteger(g)||g<1)&&t.push({level:"error",code:"node.bad-agent-attempts",message:`agent_attempts= on '${s.id}' must be a whole number >= 1, got ${JSON.stringify(g)}`,where:{node:s.id,line:s.line},hint:"1 disables retrying; omit the attr to use run-agent's default \u2014 e.g. agent_attempts=1"}),et.has(s.type)||t.push({level:"warning",code:"node.agent-attempts-ignored",message:`agent_attempts= on '${s.id}' (type ${s.type}) is ignored \u2014 this node runs no agent`,where:{node:s.id,line:s.line},hint:"move agent_attempts= to the agent lane whose retry budget you meant to change"})}let l=s.type!=="start"&&s.type!=="exit"&&s.type!=="parallel",d=s.type==="analyst"||s.type==="issue-agent"||s.type==="pr-review"||s.type==="fan_in",f=s.type==="pr-fix"||(s.type==="pr-review"||s.type==="analyst")&&Ee(s)||s.type==="fan_in",_=(g,v,b)=>{t.push({level:"error",code:g,message:v,where:{node:s.id,line:s.line},...b?{hint:b}:{}})};if(s.attrs.title!==void 0&&(typeof s.attrs.title!="string"||!s.attrs.title.trim()||s.attrs.title.includes("${{")?_("node.bad-title",`title= on '${s.id}' must be a plain, non-empty string, got ${JSON.stringify(s.attrs.title)}`):(!l||o.has(s.id))&&_("node.title-unsupported",`title= on '${s.id}' has no workflow to name \u2014 this node does not own one`,"set it on the node that owns the workflow (for a diamond, the fan_in)")),s.attrs.harness_ref!==void 0&&(s.attrs.harness_ref!=="base"&&s.attrs.harness_ref!=="head"?_("node.bad-harness-ref",`harness_ref= on '${s.id}' must be "base" or "head", got ${JSON.stringify(s.attrs.harness_ref)}`):f?s.attrs.harness_ref==="head"&&t.push({level:"warning",code:"node.harness-from-head",message:`harness_ref="head" on '${s.id}': its role, scope and setup composite are read from the PR under review, so a PR can rewrite the instructions it is judged by \u2014 and the setup step that runs with this job's secrets`,where:{node:s.id,line:s.line},hint:"omit harness_ref (the default is the base ref) unless you are testing a harness change in its own PR"}):_("node.harness-ref-unsupported",`harness_ref= on '${s.id}' does not apply \u2014 only a lane handed a pull request chooses between the base ref's harness files and the PR head's`)),s.attrs.persist_credentials!==void 0&&(typeof s.attrs.persist_credentials!="boolean"?_("node.bad-persist-credentials",`persist_credentials= on '${s.id}' must be true or false, got ${JSON.stringify(s.attrs.persist_credentials)}`):d?s.attrs.persist_credentials===!1&&s.attrs.checkout==="partial"&&_("node.partial-needs-credentials",`'${s.id}' sets checkout="partial" with persist_credentials=false \u2014 a blob-less clone fetches file contents on demand and cannot without the credential`,'drop checkout="partial" (a full clone needs no credential after checkout), or drop persist_credentials=false'):_("node.persist-credentials-unsupported",`persist_credentials= on '${s.id}' (type ${s.type}) does not apply \u2014 only read-and-advise lanes drop the checkout credential; a lane that pushes needs it`)),s.attrs.repo_guides!==void 0&&(typeof s.attrs.repo_guides!="boolean"?_("node.bad-repo-guides",`repo_guides= on '${s.id}' must be true or false, got ${JSON.stringify(s.attrs.repo_guides)}`):!et.has(s.type)&&s.type!=="fan_in"&&_("node.repo-guides-unsupported",`repo_guides= on '${s.id}' (type ${s.type}) does not apply \u2014 this node runs no agent`)),s.attrs.cancel_in_progress!==void 0&&(typeof s.attrs.cancel_in_progress!="boolean"&&t.push({level:"error",code:"node.bad-cancel-in-progress",message:`cancel_in_progress= on '${s.id}' must be true or false, got ${JSON.stringify(s.attrs.cancel_in_progress)}`,where:{node:s.id,line:s.line}}),!et.has(s.type)||o.has(s.id)?t.push({level:"warning",code:"node.cancel-in-progress-ignored",message:`cancel_in_progress= on '${s.id}' is ignored \u2014 it applies to an agent node that owns its own workflow`,where:{node:s.id,line:s.line},hint:"set it on a standalone agent lane (analyst, issue-agent, producer, pr-review, pr-fix, scheduled-agent)"}):s.attrs.cancel_in_progress===!0&&(s.type==="producer"||s.type==="pr-fix"||s.type==="scheduled-agent"&&s.attrs.commit!=="none")&&t.push({level:"warning",code:"node.cancel-in-progress-discards-work",message:`cancel_in_progress=true on '${s.id}' (type ${s.type}): a cancelled run skips the commit/push salvage, so whatever the agent had written but not yet pushed is lost`,where:{node:s.id,line:s.line},hint:"keep it for lanes where the newer event supersedes the older run's work; otherwise leave the default (queue)"})),s.attrs.checkout!==void 0&&(s.attrs.checkout!=="partial"?t.push({level:"error",code:"node.bad-checkout",message:`checkout= on '${s.id}' must be "partial", got ${JSON.stringify(s.attrs.checkout)}`,where:{node:s.id,line:s.line},hint:`checkout="partial" is a blob-less clone with full history; omit the attr for the lane's default checkout`}):(s.type==="start"||s.type==="exit"||s.type==="parallel"||s.type==="human-gate")&&t.push({level:"warning",code:"node.checkout-ignored",message:`checkout= on '${s.id}' (type ${s.type}) is ignored \u2014 this node checks nothing out`,where:{node:s.id,line:s.line}})),s.attrs.gates!==void 0)try{En(s)}catch(g){t.push({level:"error",code:"node.bad-gates",message:g.message,where:{node:s.id,line:s.line},hint:'comma-separated workflow files or check-run names, each with an optional ?<seconds> grace \u2014 e.g. gates="ci.yml, e2e (chromium)?90"'})}if(s.attrs.skip!==void 0){let g=[];try{g=Sn(s)}catch(b){t.push({level:"error",code:"node.bad-skip",message:b.message,where:{node:s.id,line:s.line},hint:'e.g. skip="draft,bot-author,label:no-agent-review,unchanged-diff"'})}(s.type==="pr-review"||s.type==="analyst")&&Ee(s)&&s.attrs.schedule===void 0&&!o.has(s.id)||t.push({level:"error",code:"node.skip-unsupported",message:`skip= on '${s.id}' is not supported here \u2014 it needs a standalone, event-driven pr-review/analyst node with context="pr-diff" or "pr-review"`,where:{node:s.id,line:s.line},hint:s.attrs.select!==void 0||s.attrs.schedule!==void 0?'a scheduled (select="sweep") lane picks its own PRs; skip= guards a lane that reacts to PR events':o.has(s.id)?"a diamond leg has no guard job of its own; put the review lane outside the diamond":'set context="pr-diff" on the node \u2014 skip= reads the pull request the event is about'}),g.some(b=>b.kind==="unchanged-diff")&&!i.config.identity?.bot_login&&t.push({level:"error",code:"node.skip-needs-bot-login",message:`skip="unchanged-diff" on '${s.id}' compares against the bot's last review, but identity.bot_login is unset`,where:{node:s.id,line:s.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the reviews"})}s.attrs.select!==void 0&&(s.attrs.select!=="sweep"?t.push({level:"error",code:"node.bad-select",message:`select= on '${s.id}' must be "sweep", got ${JSON.stringify(s.attrs.select)}`,where:{node:s.id,line:s.line}}):s.type!=="pr-review"||!Ee(s)||o.has(s.id)?t.push({level:"error",code:"node.select-unsupported",message:`select="sweep" on '${s.id}' needs a standalone pr-review node with context="pr-diff" or "pr-review"`,where:{node:s.id,line:s.line}}):s.attrs.schedule===void 0?t.push({level:"error",code:"node.sweep-no-schedule",message:`select="sweep" on '${s.id}' needs schedule="<cron>" \u2014 a sweep is driven by its schedule, not by PR events`,where:{node:s.id,line:s.line},hint:'e.g. schedule="*/15 * * * *"'}):i.config.identity?.bot_login||t.push({level:"warning",code:"node.sweep-no-bot-login",message:`select="sweep" on '${s.id}': identity.bot_login is unset, so ANY review carrying a '**Verdict:**' marker counts as the decision \u2014 a user can pre-empt the lane by posting one`,where:{node:s.id,line:s.line},hint:"set identity.bot_login in foundry.config.yaml to the login that posts the verdict"})),s.type==="human-gate"&&s.attrs.environment===void 0&&t.push({level:"error",code:"node.human-gate-no-environment",message:`human-gate '${s.id}' must set environment=<name> (maps to a protected GitHub Environment)`,where:{node:s.id,line:s.line}}),s.type==="merge-gate"&&!s.files.policy&&t.push({level:"warning",code:"node.merge-gate-no-policy",message:`merge-gate '${s.id}' has no policy="..."; default merge policy will be used`,where:{node:s.id,line:s.line}})}if(e.fileExists)for(let s of i.nodes)for(let l of["role","policy","prompt","tools"]){let d=s.files[l];d&&!e.fileExists(d)&&t.push({level:"error",code:"file.missing",message:`node '${s.id}' references ${l}="${d}" which does not exist`,where:{node:s.id,line:s.line,file:d}})}if(e.roles){let s=new Map;for(let d of i.nodes)s.set(d.id,[]);for(let d of i.edges){let f=r.get(d.to);f&&s.get(d.from)?.push({node:f,edge:d})}let l=d=>(e.roles?.get(d.id)?.role??d.id).toLowerCase();for(let d of i.nodes){let f=e.roles.get(d.id);if(!f?.handoffs)continue;let _=s.get(d.id)??[],g=new Set(_.flatMap(b=>[b.node.id.toLowerCase(),l(b.node)])),v=new Set(f.handoffs.map(b=>String(b.to).toLowerCase()));for(let b of f.handoffs)g.has(String(b.to).toLowerCase())||t.push({level:"warning",code:"role.handoff-no-edge",message:`role '${f.role}' (node '${d.id}') declares a handoff to '${b.to}' but there is no matching out-edge`,where:{node:d.id},hint:"add the edge, or remove the handoff so the job description matches the graph"});for(let{node:b,edge:A}of _)b.type==="exit"&&!A.when||!v.has(b.id.toLowerCase())&&!v.has(l(b))&&t.push({level:"warning",code:"role.edge-no-handoff",message:`node '${d.id}' has an out-edge to '${b.id}' not declared as a handoff in role '${f.role}'`,where:{node:d.id,edge:[d.id,b.id]},hint:"document the handoff in the role, or remove the edge"})}}let u=(s,l)=>{if(typeof s=="string"){let d=s.match(/<[A-Za-z][^<>]{0,80}>/);d&&t.push({level:"error",code:"config.placeholder",message:`config value ${l} still contains the placeholder ${d[0]} \u2014 fill it in foundry.config.yaml`,hint:"generated workflows would be broken until every <placeholder> is replaced"})}else if(Array.isArray(s))s.forEach((d,f)=>u(d,`${l}[${f}]`));else if(s&&typeof s=="object")for(let[d,f]of Object.entries(s))u(f,l?`${l}.${d}`:d)};if(u(i.config,""),e.fileExists&&(i.config.runtime?.mode??"pinned")==="vendored"){let s=new Set,l=!1;for(let d of i.nodes)et.has(d.type)&&(l=!0,s.add("run-agent")),et.has(d.type)&&d.type!=="scheduled-agent"&&s.add("agent-context"),(d.type==="producer"||d.type==="scheduled-agent")&&s.add("agent-fallback"),d.type==="merge-gate"&&s.add("merge-gate"),d.type==="pr-review"&&d.attrs.gates!==void 0&&s.add("wait-for-checks");for(let d of s)e.fileExists(`actions/${d}/action.yml`)||t.push({level:"warning",code:"runtime.action-not-vendored",message:`runtime.mode is 'vendored' but .github/actions/${d}/ is missing`,hint:"run `gp-foundry vendor` to copy the runtime actions into the repo"});l&&!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:s,memberIds:l}=De(i);for(let d of i.nodes)if(d.type==="parallel"&&!l.has(d.id)&&t.push({level:"error",code:"diamond.malformed",message:`parallel '${d.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:d.id,line:d.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"}),d.type==="fan_in"){let f=s.get(d.id);if(!f)t.push({level:"error",code:"diamond.malformed",message:`fan_in '${d.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:d.id,line:d.line},hint:"see reference/node-types.md \u2014 v1 supports clean parallel\u2192legs\u2192fan_in diamonds only"});else{!d.files.role&&d.attrs.on_complete_label===void 0&&t.push({level:"error",code:"diamond.unobservable-join",message:`fan_in '${d.id}' has neither a role nor on_complete_label \u2014 its completion would be unobservable`,where:{node:d.id,line:d.line},hint:'give it a role="..." (synthesize the lanes) and/or on_complete_label=<label> to cascade the next stage'});let _=f.legIds.filter(g=>r.get(g)?.type==="pr-review");_.length&&t.push({level:"warning",code:"diamond.lane-verdict-risk",message:`fan_in '${d.id}' lanes [${_.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:d.id},hint:"lane roles must post ANALYSES (plain comments); only the fan_in role posts the verdict"})}}}if(ct(i.config).mode==="github-token"){let s=i.edges.filter(l=>/^(pull_request\.opened|pull_request\.synchronize|push)/.test(l.on??"")||/^(label=|verdict=)/.test(l.when??""));s.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 ${s.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(s=>/^verdict=/.test(s.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(s=>s.type==="start"||s.attrs.schedule!==void 0||s.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}H();var Lo=new Set(["exit","merge-gate","human-gate","scheduled-agent","fan_in"]),ji=new Set(["start"]);function ft(i){let e=[],t=new Set(i.nodes.map(l=>l.id)),r=new Map(i.nodes.map(l=>[l.id,l])),o=new Map;for(let l of t)o.set(l,[]);for(let l of i.edges)t.has(l.from)&&t.has(l.to)&&o.get(l.from).push(l.to);let a=i.nodes.filter(l=>ji.has(l.type)||l.attrs.schedule!==void 0||l.type==="merge-gate"),u=new Set,p=a.map(l=>l.id);for(;p.length;){let l=p.pop();if(!u.has(l)){u.add(l);for(let d of o.get(l)??[])p.push(d)}}for(let l of i.nodes)!u.has(l.id)&&!ji.has(l.type)&&e.push({level:"warning",code:"graph.unreachable",message:`node '${l.id}' is unreachable from any entry (start/scheduled) node`,where:{node:l.id,line:l.line},hint:"add an incoming edge, a schedule=, or a start node that leads here"});for(let l of i.nodes)(o.get(l.id)??[]).length===0&&!Lo.has(l.type)&&e.push({level:"warning",code:"graph.dead-end",message:`node '${l.id}' (type ${l.type}) has no outgoing edge and is not a sink (exit/merge-gate/human-gate)`,where:{node:l.id,line:l.line},hint:"route it to a next node, or make it an exit"});for(let l of qo(t,o)){if(!(l.length>1||(o.get(l[0])??[]).includes(l[0])))continue;let f=new Set(l),_=[];for(let g of l)for(let v of o.get(g)??[])f.has(v)||_.push({from:g,to:v});_.length===0?e.push({level:"error",code:"graph.unbounded-loop",message:`cycle {${l.join(" \u2192 ")}} has no escape edge \u2014 this is a livelock`,where:{node:l[0]},hint:'add a bounded escape edge (e.g. when="attempts>=N" \u2192 needs-human/exit)'}):_.some(g=>Uo(jo(i,g.from,g.to)))||e.push({level:"warning",code:"graph.loop-escape-unbounded",message:`cycle {${l.join(" \u2192 ")}} escapes, but no escape guard looks bounded (no >=, attempts, max, count, limit)`,where:{node:l[0]},hint:"guard the escape with an explicit bound so the loop provably terminates"})}let s=new Map;for(let l of i.edges){let d=`${l.on??""}|${l.when??""}`;s.has(l.from)||s.set(l.from,new Map);let f=s.get(l.from);f.has(d)||f.set(d,new Set),f.get(d).add(l.to)}for(let[l,d]of s)for(let[f,_]of d)_.size>1&&f!=="|"&&e.push({level:"warning",code:"graph.ambiguous-routing",message:`node '${l}' has multiple edges with identical trigger/guard (${f}) to different targets: ${[..._].join(", ")}`,where:{node:l},hint:"distinguish the guards, or the transition is nondeterministic"});return e}function jo(i,e,t){return i.edges.find(r=>r.from===e&&r.to===t)?.when}function Uo(i){return i?/(>=|>|attempts|max|count|limit)/i.test(i):!1}function qo(i,e){let t=0,r=new Map,o=new Map,a=new Set,u=[],p=[],s=l=>{r.set(l,t),o.set(l,t),t++,u.push(l),a.add(l);for(let d of e.get(l)??[])r.has(d)?a.has(d)&&o.set(l,Math.min(o.get(l),r.get(d))):(s(d),o.set(l,Math.min(o.get(l),o.get(d))));if(o.get(l)===r.get(l)){let d=[],f;do f=u.pop(),a.delete(f),d.push(f);while(f!==l);p.push(d.reverse())}};for(let l of i)r.has(l)||s(l);return p}H();var Bo=new Set(Ge),Go=new Set(["pr-review","pr-fix"]);function Wo(i,e){return e.labels?.[i]??i}function Kt(i){return Go.has(i.type)||i.context==="pr-diff"||i.context==="pr-review"}function Fn(i,e,t){let r=(o,a)=>{i[o]??={},i[o].types??=[],i[o].types.includes(a)||i[o].types.push(a)};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.ready_for_review":return r("pull_request","ready_for_review");case"pull_request_review.submitted":return r("pull_request_review","submitted");case"push":if(Kt(t))return r("pull_request","synchronize");i.push??={};return;case"workflow_dispatch":i.workflow_dispatch??={};return;default:i[e]??={}}}function ht(i,e){return i==="push"&&Kt(e)?"pull_request.synchronize":i}function Wi(i){let[e,t]=i.split(".");return t?`(github.event_name == '${e}' && github.event.action == '${t}')`:`github.event_name == '${e}'`}function Vo(i,e,t){if(i.on){let o=i.on.split(",").map(u=>u.trim()).filter(Boolean),a=o.map(u=>ht(u,e));return{events:o,guard:i.when?Yt(i.when,a,t):void 0}}if(!i.when)return;let r=i.when;if(r.startsWith("label=")){let o=[Kt(e)?"pull_request.labeled":"issues.labeled"];return{events:o,guard:Yt(r,o,t)}}if(r.startsWith("verdict=")){let o=["pull_request_review.submitted"];return{events:o,guard:Yt(r,o,t)}}}function Yt(i,e,t){if(i.startsWith("label=")){let o=`github.event.label.name == '${Wo(i.slice(6),t)}'`,a=Yo(e);return a?`${o} && ${a}`: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}')`,a=Ko(t);return a?`${o} && ${a}`:o}}function Yo(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 Ko(i){let e=i.identity?.bot_login;return e?`github.event.review.user.login == '${e}'`:void 0}function Ui(i){return/^(pull_request|pull_request_review|pull_request_target)\b/.test(i)}function Jo(i){let e=i.repo?.branch_prefix;return e?`startsWith(github.event.pull_request.head.ref, '${e}')`:void 0}function qi(i,e,t){return Vi(i,e,Jo(t))}function Bi(i,e,t){return Vi(i,e,t?Ni(t):void 0)}function Vi(i,e,t){let r=[...e].filter(Ui);if(!t||r.length===0)return i;let o=[...e].filter(u=>!Ui(u)),a=o.length?`(${o.map(Wi).join(" || ")} || ${t})`:t;return i?`(${i}) && ${a}`:a}function Gi(i,e){let t=i.attrs.cancel_in_progress;return typeof t=="boolean"&&Bo.has(i.type)?t:e}function Xo(i){if(i.attrs.schedule!==void 0)return{group:i.id,"cancel-in-progress":Gi(i,!1)};let t=Kt(i)||i.type==="human-gate"?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";return{group:`${i.id}-${t}`,"cancel-in-progress":Gi(i,i.type==="issue-agent")}}function Yi(i){let e={},t=new Map(i.nodes.map(a=>[a.id,a])),r=new Map;for(let a of i.nodes)r.set(a.id,[]);for(let a of i.edges)r.get(a.to)?.push(a);let o=De(i);for(let a of i.nodes){if(a.type==="start"||a.type==="exit"||o.memberIds.has(a.id))continue;let u=o.byFanin.get(a.id);if(u){let v=u.entryEdge,b=t.get(u.legIds[0]),A={},N=(v.on??"").split(",").map(te=>te.trim()).filter(Boolean);for(let te of N)Fn(A,te,b);let F={nodeId:a.id,triggers:A,dispatches:[]},D=new Set(N.map(te=>ht(te,b))),L;try{L=ut(i.config)}catch{L=[Cn]}let U=Bi(qi(v.when?Yt(v.when,[...D],i.config):void 0,D,i.config),D,L);U&&(F.guard=U);let oe=N.some(te=>ht(te,b).startsWith("pull_request"))?"${{ github.event.pull_request.number }}":"${{ github.event.issue.number }}";F.concurrency={group:`${a.id}-${oe}`,"cancel-in-progress":!1},e[a.id]=F;continue}if(a.type==="parallel"||a.type==="fan_in")continue;let p={},s=new Set,l=new Set,d=new Set,f=[];if(a.attrs.schedule!==void 0)p.schedule=[{cron:String(a.attrs.schedule)}],p.workflow_dispatch={};else{for(let v of r.get(a.id)??[]){let b=Vo(v,a,i.config);if(b){for(let A of b.events)Fn(p,A,a);for(let A of b.events)d.add(ht(A,a));if(b.guard)s.add(b.guard);else for(let A of b.events)l.add(ht(A,a))}}if(p.pull_request&&Ye(a,i.config)&&Fe(a).some(v=>v.kind==="draft")&&(Fn(p,"pull_request.ready_for_review",a),d.add("pull_request.ready_for_review"),l.add("pull_request.ready_for_review")),s.size&&l.size)for(let v of l)s.add(Wi(v))}for(let v of i.edges)v.from===a.id&&v.do&&f.push({toNode:v.to,when:v.when});let _=Bi(qi(s.size?[...s].join(" || "):void 0,d,i.config),d,We(a,i.config)),g={nodeId:a.id,triggers:p,dispatches:f};_&&(g.guard=_),Object.keys(p).length&&(g.concurrency=Xo(a)),e[a.id]=g}return{perNode:e}}H();H();function zo(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var re={},Jt={},Ne={},Ki;function mt(){if(Ki)return Ne;Ki=1;function i(u){return typeof u>"u"||u===null}function e(u){return typeof u=="object"&&u!==null}function t(u){return Array.isArray(u)?u:i(u)?[]:[u]}function r(u,p){if(p){let s=Object.keys(p);for(let l=0,d=s.length;l<d;l+=1){let f=s[l];u[f]=p[f]}}return u}function o(u,p){let s="";for(let l=0;l<p;l+=1)s+=u;return s}function a(u){return u===0&&Number.NEGATIVE_INFINITY===1/u}return Ne.isNothing=i,Ne.isObject=e,Ne.toArray=t,Ne.repeat=o,Ne.isNegativeZero=a,Ne.extend=r,Ne}var Mn,Ji;function gt(){if(Ji)return Mn;Ji=1;function i(t,r){let o="",a=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+=`
|
|
38
40
|
|
|
39
|
-
`+
|
|
40
|
-
`+
|
|
41
|
-
`,
|
|
42
|
-
`;for(let
|
|
43
|
-
`}return
|
|
44
|
-
\r`;function
|
|
45
|
-
`;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
|
|
46
|
-
`,
|
|
47
|
-
`,
|
|
48
|
-
`);break}
|
|
49
|
-
`,
|
|
50
|
-
`,
|
|
51
|
-
`,
|
|
52
|
-
`,
|
|
53
|
-
`),
|
|
54
|
-
|
|
55
|
-
`&&(
|
|
56
|
-
`+i.repeat(" ",c.indent*
|
|
57
|
-
`,C
|
|
41
|
+
`+t.mark.snippet),a+" "+o):a}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)},Mn=e,Mn}var Dn,Xi;function Qo(){if(Xi)return Dn;Xi=1;let i=mt();function e(o,a,u,p,s){let l="",d="",f=Math.floor(s/2)-1;return p-a>f&&(l=" ... ",a=p-f+l.length),u-p>f&&(d=" ...",u=p+f-d.length),{str:l+o.slice(a,u).replace(/\t/g,"\u2192")+d,pos:p-a+l.length}}function t(o,a){return i.repeat(" ",a-o.length)+o}function r(o,a){if(a=Object.create(a||null),!o.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);let u=/\r?\n|\r|\0/g,p=[0],s=[],l,d=-1;for(;l=u.exec(o.buffer);)s.push(l.index),p.push(l.index+l[0].length),o.position<=l.index&&d<0&&(d=p.length-2);d<0&&(d=p.length-1);let f="",_=Math.min(o.line+a.linesAfter,s.length).toString().length,g=a.maxLength-(a.indent+_+3);for(let b=1;b<=a.linesBefore&&!(d-b<0);b++){let A=e(o.buffer,p[d-b],s[d-b],o.position-(p[d]-p[d-b]),g);f=i.repeat(" ",a.indent)+t((o.line-b+1).toString(),_)+" | "+A.str+`
|
|
42
|
+
`+f}let v=e(o.buffer,p[d],s[d],o.position,g);f+=i.repeat(" ",a.indent)+t((o.line+1).toString(),_)+" | "+v.str+`
|
|
43
|
+
`,f+=i.repeat("-",a.indent+_+3+v.pos)+`^
|
|
44
|
+
`;for(let b=1;b<=a.linesAfter&&!(d+b>=s.length);b++){let A=e(o.buffer,p[d+b],s[d+b],o.position-(p[d]-p[d+b]),g);f+=i.repeat(" ",a.indent)+t((o.line+b+1).toString(),_)+" | "+A.str+`
|
|
45
|
+
`}return f.replace(/\n$/,"")}return Dn=r,Dn}var Ln,zi;function ae(){if(zi)return Ln;zi=1;let i=gt(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],t=["scalar","sequence","mapping"];function r(a){let u={};return a!==null&&Object.keys(a).forEach(function(p){a[p].forEach(function(s){u[String(s)]=p})}),u}function o(a,u){if(u=u||{},Object.keys(u).forEach(function(p){if(e.indexOf(p)===-1)throw new i('Unknown option "'+p+'" is met in definition of "'+a+'" YAML type.')}),this.options=u,this.tag=a,this.kind=u.kind||null,this.resolve=u.resolve||function(){return!0},this.construct=u.construct||function(p){return p},this.instanceOf=u.instanceOf||null,this.predicate=u.predicate||null,this.represent=u.represent||null,this.representName=u.representName||null,this.defaultStyle=u.defaultStyle||null,this.multi=u.multi||!1,this.styleAliases=r(u.styleAliases||null),t.indexOf(this.kind)===-1)throw new i('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Ln=o,Ln}var jn,Qi;function wr(){if(Qi)return jn;Qi=1;let i=gt(),e=ae();function t(a,u){let p=[];return a[u].forEach(function(s){let l=p.length;p.forEach(function(d,f){d.tag===s.tag&&d.kind===s.kind&&d.multi===s.multi&&(l=f)}),p[l]=s}),p}function r(){let a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function u(p){p.multi?(a.multi[p.kind].push(p),a.multi.fallback.push(p)):a[p.kind][p.tag]=a.fallback[p.tag]=p}for(let p=0,s=arguments.length;p<s;p+=1)arguments[p].forEach(u);return a}function o(a){return this.extend(a)}return o.prototype.extend=function(u){let p=[],s=[];if(u instanceof e)s.push(u);else if(Array.isArray(u))s=s.concat(u);else if(u&&(Array.isArray(u.implicit)||Array.isArray(u.explicit)))u.implicit&&(p=p.concat(u.implicit)),u.explicit&&(s=s.concat(u.explicit));else throw new i("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");p.forEach(function(d){if(!(d instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(d.loadKind&&d.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(d.multi)throw new i("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),s.forEach(function(d){if(!(d instanceof e))throw new i("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let l=Object.create(o.prototype);return l.implicit=(this.implicit||[]).concat(p),l.explicit=(this.explicit||[]).concat(s),l.compiledImplicit=t(l,"implicit"),l.compiledExplicit=t(l,"explicit"),l.compiledTypeMap=r(l.compiledImplicit,l.compiledExplicit),l},jn=o,jn}var Un,Zi;function _r(){if(Zi)return Un;Zi=1;let i=ae();return Un=new i("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Un}var qn,er;function Ar(){if(er)return qn;er=1;let i=ae();return qn=new i("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),qn}var Bn,tr;function $r(){if(tr)return Bn;tr=1;let i=ae();return Bn=new i("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Bn}var Gn,nr;function kr(){if(nr)return Gn;nr=1;let i=wr();return Gn=new i({explicit:[_r(),Ar(),$r()]}),Gn}var Wn,ir;function Er(){if(ir)return Wn;ir=1;let i=ae();function e(o){if(o===null)return!0;let a=o.length;return a===1&&o==="~"||a===4&&(o==="null"||o==="Null"||o==="NULL")}function t(){return null}function r(o){return o===null}return Wn=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"}),Wn}var Vn,rr;function Sr(){if(rr)return Vn;rr=1;let i=ae();function e(o){if(o===null)return!1;let a=o.length;return a===4&&(o==="true"||o==="True"||o==="TRUE")||a===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 Vn=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"}),Vn}var Yn,or;function vr(){if(or)return Yn;or=1;let i=mt(),e=ae();function t(l){return l>=48&&l<=57||l>=65&&l<=70||l>=97&&l<=102}function r(l){return l>=48&&l<=55}function o(l){return l>=48&&l<=57}function a(l){if(l===null)return!1;let d=l.length,f=0,_=!1;if(!d)return!1;let g=l[f];if((g==="-"||g==="+")&&(g=l[++f]),g==="0"){if(f+1===d)return!0;if(g=l[++f],g==="b"){for(f++;f<d;f++){if(g=l[f],g!=="0"&&g!=="1")return!1;_=!0}return _&&isFinite(u(l))}if(g==="x"){for(f++;f<d;f++){if(!t(l.charCodeAt(f)))return!1;_=!0}return _&&isFinite(u(l))}if(g==="o"){for(f++;f<d;f++){if(!r(l.charCodeAt(f)))return!1;_=!0}return _&&isFinite(u(l))}}for(;f<d;f++){if(!o(l.charCodeAt(f)))return!1;_=!0}return _?isFinite(u(l)):!1}function u(l){let d=l,f=1,_=d[0];if((_==="-"||_==="+")&&(_==="-"&&(f=-1),d=d.slice(1),_=d[0]),d==="0")return 0;if(_==="0"){if(d[1]==="b")return f*parseInt(d.slice(2),2);if(d[1]==="x")return f*parseInt(d.slice(2),16);if(d[1]==="o")return f*parseInt(d.slice(2),8)}return f*parseInt(d,10)}function p(l){return u(l)}function s(l){return Object.prototype.toString.call(l)==="[object Number]"&&l%1===0&&!i.isNegativeZero(l)}return Yn=new e("tag:yaml.org,2002:int",{kind:"scalar",resolve:a,construct:p,predicate:s,represent:{binary:function(l){return l>=0?"0b"+l.toString(2):"-0b"+l.toString(2).slice(1)},octal:function(l){return l>=0?"0o"+l.toString(8):"-0o"+l.toString(8).slice(1)},decimal:function(l){return l.toString(10)},hexadecimal:function(l){return l>=0?"0x"+l.toString(16).toUpperCase():"-0x"+l.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Yn}var Kn,sr;function xr(){if(sr)return Kn;sr=1;let i=mt(),e=ae(),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(l){return l===null||!t.test(l)?!1:isFinite(parseFloat(l,10))?!0:r.test(l)}function a(l){let d=l.toLowerCase(),f=d[0]==="-"?-1:1;return"+-".indexOf(d[0])>=0&&(d=d.slice(1)),d===".inf"?f===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:d===".nan"?NaN:f*parseFloat(d,10)}let u=/^[-+]?[0-9]+e/;function p(l,d){if(isNaN(l))switch(d){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===l)switch(d){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===l)switch(d){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(i.isNegativeZero(l))return"-0.0";let f=l.toString(10);return u.test(f)?f.replace("e",".e"):f}function s(l){return Object.prototype.toString.call(l)==="[object Number]"&&(l%1!==0||i.isNegativeZero(l))}return Kn=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:a,predicate:s,represent:p,defaultStyle:"lowercase"}),Kn}var Jn,ar;function Cr(){return ar||(ar=1,Jn=kr().extend({implicit:[Er(),Sr(),vr(),xr()]})),Jn}var Xn,lr;function Or(){return lr||(lr=1,Xn=Cr()),Xn}var zn,cr;function Tr(){if(cr)return zn;cr=1;let i=ae(),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(u){return u===null?!1:e.exec(u)!==null||t.exec(u)!==null}function o(u){let p=0,s=null,l=e.exec(u);if(l===null&&(l=t.exec(u)),l===null)throw new Error("Date resolve error");let d=+l[1],f=+l[2]-1,_=+l[3];if(!l[4])return new Date(Date.UTC(d,f,_));let g=+l[4],v=+l[5],b=+l[6];if(l[7]){for(p=l[7].slice(0,3);p.length<3;)p+="0";p=+p}if(l[9]){let N=+l[10],F=+(l[11]||0);s=(N*60+F)*6e4,l[9]==="-"&&(s=-s)}let A=new Date(Date.UTC(d,f,_,g,v,b,p));return s&&A.setTime(A.getTime()-s),A}function a(u){return u.toISOString()}return zn=new i("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:a}),zn}var Qn,ur;function Rr(){if(ur)return Qn;ur=1;let i=ae();function e(t){return t==="<<"||t===null}return Qn=new i("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Qn}var Zn,dr;function Nr(){if(dr)return Zn;dr=1;let i=ae(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
46
|
+
\r`;function t(u){if(u===null)return!1;let p=0,s=u.length,l=e;for(let d=0;d<s;d++){let f=l.indexOf(u.charAt(d));if(!(f>64)){if(f<0)return!1;p+=6}}return p%8===0}function r(u){let p=u.replace(/[\r\n=]/g,""),s=p.length,l=e,d=0,f=[];for(let g=0;g<s;g++)g%4===0&&g&&(f.push(d>>16&255),f.push(d>>8&255),f.push(d&255)),d=d<<6|l.indexOf(p.charAt(g));let _=s%4*6;return _===0?(f.push(d>>16&255),f.push(d>>8&255),f.push(d&255)):_===18?(f.push(d>>10&255),f.push(d>>2&255)):_===12&&f.push(d>>4&255),new Uint8Array(f)}function o(u){let p="",s=0,l=u.length,d=e;for(let _=0;_<l;_++)_%3===0&&_&&(p+=d[s>>18&63],p+=d[s>>12&63],p+=d[s>>6&63],p+=d[s&63]),s=(s<<8)+u[_];let f=l%3;return f===0?(p+=d[s>>18&63],p+=d[s>>12&63],p+=d[s>>6&63],p+=d[s&63]):f===2?(p+=d[s>>10&63],p+=d[s>>4&63],p+=d[s<<2&63],p+=d[64]):f===1&&(p+=d[s>>2&63],p+=d[s<<4&63],p+=d[64],p+=d[64]),p}function a(u){return Object.prototype.toString.call(u)==="[object Uint8Array]"}return Zn=new i("tag:yaml.org,2002:binary",{kind:"scalar",resolve:t,construct:r,predicate:a,represent:o}),Zn}var ei,pr;function Ir(){if(pr)return ei;pr=1;let i=ae(),e=Object.prototype.hasOwnProperty,t=Object.prototype.toString;function r(a){if(a===null)return!0;let u=[],p=a;for(let s=0,l=p.length;s<l;s+=1){let d=p[s],f=!1;if(t.call(d)!=="[object Object]")return!1;let _;for(_ in d)if(e.call(d,_))if(!f)f=!0;else return!1;if(!f)return!1;if(u.indexOf(_)===-1)u.push(_);else return!1}return!0}function o(a){return a!==null?a:[]}return ei=new i("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),ei}var ti,fr;function Hr(){if(fr)return ti;fr=1;let i=ae(),e=Object.prototype.toString;function t(o){if(o===null)return!0;let a=o,u=new Array(a.length);for(let p=0,s=a.length;p<s;p+=1){let l=a[p];if(e.call(l)!=="[object Object]")return!1;let d=Object.keys(l);if(d.length!==1)return!1;u[p]=[d[0],l[d[0]]]}return!0}function r(o){if(o===null)return[];let a=o,u=new Array(a.length);for(let p=0,s=a.length;p<s;p+=1){let l=a[p],d=Object.keys(l);u[p]=[d[0],l[d[0]]]}return u}return ti=new i("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:t,construct:r}),ti}var ni,hr;function Pr(){if(hr)return ni;hr=1;let i=ae(),e=Object.prototype.hasOwnProperty;function t(o){if(o===null)return!0;let a=o;for(let u in a)if(e.call(a,u)&&a[u]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return ni=new i("tag:yaml.org,2002:set",{kind:"mapping",resolve:t,construct:r}),ni}var ii,mr;function oi(){return mr||(mr=1,ii=Or().extend({implicit:[Tr(),Rr()],explicit:[Nr(),Ir(),Hr(),Pr()]})),ii}var gr;function Zo(){if(gr)return Jt;gr=1;let i=mt(),e=gt(),t=Qo(),r=oi(),o=Object.prototype.hasOwnProperty,a=1,u=2,p=3,s=4,l=1,d=2,f=3,_=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,g=/[\x85\u2028\u2029]/,v=/[,\[\]{}]/,b=/^(?:!|!!|![0-9A-Za-z-]+!)$/,A=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function N(n){return Object.prototype.toString.call(n)}function F(n){return n===10||n===13}function D(n){return n===9||n===32}function L(n){return n===9||n===32||n===10||n===13}function U(n){return n===44||n===91||n===93||n===123||n===125}function ee(n){if(n>=48&&n<=57)return n-48;let h=n|32;return h>=97&&h<=102?h-97+10:-1}function oe(n){return n===120?2:n===117?4:n===85?8:0}function te(n){return n>=48&&n<=57?n-48:-1}function ce(n){switch(n){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
47
|
+
`;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 be(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}function me(n,h,w){h==="__proto__"?Object.defineProperty(n,h,{configurable:!0,enumerable:!0,writable:!0,value:w}):n[h]=w}let j=new Array(256),ue=new Array(256);for(let n=0;n<256;n++)j[n]=ce(n)?1:0,ue[n]=ce(n);function Z(n,h){this.input=n,this.filename=h.filename||null,this.schema=h.schema||r,this.onWarning=h.onWarning||null,this.legacy=h.legacy||!1,this.json=h.json||!1,this.listener=h.listener||null,this.maxDepth=typeof h.maxDepth=="number"?h.maxDepth:100,this.maxTotalMergeKeys=typeof h.maxTotalMergeKeys=="number"?h.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 se(n,h){let w={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return w.snippet=t(w),new e(h,w)}function I(n,h){throw se(n,h)}function je(n,h){n.onWarning&&n.onWarning.call(null,se(n,h))}function ye(n,h,w){let E=n.anchorMapTransactions;if(E.length!==0){let y=E[E.length-1];o.call(y,h)||(y[h]={existed:o.call(n.anchorMap,h),value:n.anchorMap[h]})}n.anchorMap[h]=w}function Zt(n){n.anchorMapTransactions.push(Object.create(null))}function Pe(n){let h=n.anchorMapTransactions.pop(),w=n.anchorMapTransactions;if(w.length===0)return;let E=w[w.length-1],y=Object.keys(h);for(let O=0,c=y.length;O<c;O+=1){let m=y[O];o.call(E,m)||(E[m]=h[m])}}function en(n){let h=n.anchorMapTransactions.pop(),w=Object.keys(h);for(let E=w.length-1;E>=0;E-=1){let y=h[w[E]];y.existed?n.anchorMap[w[E]]=y.value:delete n.anchorMap[w[E]]}}function rt(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 Ue(n,h){n.position=h.position,n.line=h.line,n.lineStart=h.lineStart,n.lineIndent=h.lineIndent,n.firstTabInLine=h.firstTabInLine,n.tag=h.tag,n.anchor=h.anchor,n.kind=h.kind,n.result=h.result}let $t={YAML:function(h,w,E){h.version!==null&&I(h,"duplication of %YAML directive"),E.length!==1&&I(h,"YAML directive accepts exactly one argument");let y=/^([0-9]+)\.([0-9]+)$/.exec(E[0]);y===null&&I(h,"ill-formed argument of the YAML directive");let O=parseInt(y[1],10),c=parseInt(y[2],10);O!==1&&I(h,"unacceptable YAML version of the document"),h.version=E[0],h.checkLineBreaks=c<2,c!==1&&c!==2&&je(h,"unsupported YAML version of the document")},TAG:function(h,w,E){let y;E.length!==2&&I(h,"TAG directive accepts exactly two arguments");let O=E[0];y=E[1],b.test(O)||I(h,"ill-formed tag handle (first argument) of the TAG directive"),o.call(h.tagMap,O)&&I(h,'there is a previously declared suffix for "'+O+'" tag handle'),A.test(y)||I(h,"ill-formed tag prefix (second argument) of the TAG directive");try{y=decodeURIComponent(y)}catch{I(h,"tag prefix is malformed: "+y)}h.tagMap[O]=y}};function de(n,h,w,E){if(h<w){let y=n.input.slice(h,w);if(E)for(let O=0,c=y.length;O<c;O+=1){let m=y.charCodeAt(O);m===9||m>=32&&m<=1114111||I(n,"expected valid JSON character")}else _.test(y)&&I(n,"the stream contains non-printable characters");n.result+=y}}function Oe(n,h,w,E){i.isObject(w)||I(n,"cannot merge mappings; the provided source object is unacceptable");let y=Object.keys(w);for(let O=0,c=y.length;O<c;O+=1){let m=y[O];n.maxTotalMergeKeys!==-1&&++n.totalMergeKeys>n.maxTotalMergeKeys&&I(n,"merge keys exceeded maxTotalMergeKeys ("+n.maxTotalMergeKeys+")"),o.call(h,m)||(me(h,m,w[m]),E[m]=!0)}}function we(n,h,w,E,y,O,c,m,x){if(Array.isArray(y)){y=Array.prototype.slice.call(y);for(let $=0,k=y.length;$<k;$+=1)Array.isArray(y[$])&&I(n,"nested arrays are not supported inside keys"),typeof y=="object"&&N(y[$])==="[object Object]"&&(y[$]="[object Object]")}if(typeof y=="object"&&N(y)==="[object Object]"&&(y="[object Object]"),y=String(y),h===null&&(h={}),E==="tag:yaml.org,2002:merge")if(Array.isArray(O))for(let $=0,k=O.length;$<k;$+=1)Oe(n,h,O[$],w);else Oe(n,h,O,w);else!n.json&&!o.call(w,y)&&o.call(h,y)&&(n.line=c||n.line,n.lineStart=m||n.lineStart,n.position=x||n.position,I(n,"duplicated mapping key")),me(h,y,O),delete w[y];return h}function qe(n){let h=n.input.charCodeAt(n.position);h===10?n.position++:h===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):I(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function z(n,h,w){let E=0,y=n.input.charCodeAt(n.position);for(;y!==0;){for(;D(y);)y===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),y=n.input.charCodeAt(++n.position);if(h&&y===35)do y=n.input.charCodeAt(++n.position);while(y!==10&&y!==13&&y!==0);if(F(y))for(qe(n),y=n.input.charCodeAt(n.position),E++,n.lineIndent=0;y===32;)n.lineIndent++,y=n.input.charCodeAt(++n.position);else break}return w!==-1&&E!==0&&n.lineIndent<w&&je(n,"deficient indentation"),E}function Be(n){let h=n.position,w=n.input.charCodeAt(h);return!!((w===45||w===46)&&w===n.input.charCodeAt(h+1)&&w===n.input.charCodeAt(h+2)&&(h+=3,w=n.input.charCodeAt(h),w===0||L(w)))}function _e(n,h){h===1?n.result+=" ":h>1&&(n.result+=i.repeat(`
|
|
48
|
+
`,h-1))}function kt(n,h,w){let E,y,O,c,m,x,$=n.kind,k=n.result,C=n.input.charCodeAt(n.position);if(L(C)||U(C)||C===35||C===38||C===42||C===33||C===124||C===62||C===39||C===34||C===37||C===64||C===96)return!1;if(C===63||C===45){let S=n.input.charCodeAt(n.position+1);if(L(S)||w&&U(S))return!1}for(n.kind="scalar",n.result="",E=y=n.position,O=!1;C!==0;){if(C===58){let S=n.input.charCodeAt(n.position+1);if(L(S)||w&&U(S))break}else if(C===35){let S=n.input.charCodeAt(n.position-1);if(L(S))break}else{if(n.position===n.lineStart&&Be(n)||w&&U(C))break;if(F(C))if(c=n.line,m=n.lineStart,x=n.lineIndent,z(n,!1,-1),n.lineIndent>=h){O=!0,C=n.input.charCodeAt(n.position);continue}else{n.position=y,n.line=c,n.lineStart=m,n.lineIndent=x;break}}O&&(de(n,E,y,!1),_e(n,n.line-c),E=y=n.position,O=!1),D(C)||(y=n.position+1),C=n.input.charCodeAt(++n.position)}return de(n,E,y,!1),n.result?!0:(n.kind=$,n.result=k,!1)}function Et(n,h){let w,E,y=n.input.charCodeAt(n.position);if(y!==39)return!1;for(n.kind="scalar",n.result="",n.position++,w=E=n.position;(y=n.input.charCodeAt(n.position))!==0;)if(y===39)if(de(n,w,n.position,!0),y=n.input.charCodeAt(++n.position),y===39)w=n.position,n.position++,E=n.position;else return!0;else F(y)?(de(n,w,E,!0),_e(n,z(n,!1,h)),w=E=n.position):n.position===n.lineStart&&Be(n)?I(n,"unexpected end of the document within a single quoted scalar"):(n.position++,D(y)||(E=n.position));I(n,"unexpected end of the stream within a single quoted scalar")}function ot(n,h){let w,E,y,O=n.input.charCodeAt(n.position);if(O!==34)return!1;for(n.kind="scalar",n.result="",n.position++,w=E=n.position;(O=n.input.charCodeAt(n.position))!==0;){if(O===34)return de(n,w,n.position,!0),n.position++,!0;if(O===92){if(de(n,w,n.position,!0),O=n.input.charCodeAt(++n.position),F(O))z(n,!1,h);else if(O<256&&j[O])n.result+=ue[O],n.position++;else if((y=oe(O))>0){let c=y,m=0;for(;c>0;c--)O=n.input.charCodeAt(++n.position),(y=ee(O))>=0?m=(m<<4)+y:I(n,"expected hexadecimal character");n.result+=be(m),n.position++}else I(n,"unknown escape sequence");w=E=n.position}else F(O)?(de(n,w,E,!0),_e(n,z(n,!1,h)),w=E=n.position):n.position===n.lineStart&&Be(n)?I(n,"unexpected end of the document within a double quoted scalar"):(n.position++,D(O)||(E=n.position))}I(n,"unexpected end of the stream within a double quoted scalar")}function St(n,h){let w=!0,E,y,O,c=n.tag,m,x=n.anchor,$,k,C,S,R=Object.create(null),T,P,M,q=n.input.charCodeAt(n.position);if(q===91)$=93,S=!1,m=[];else if(q===123)$=125,S=!0,m={};else return!1;for(n.anchor!==null&&ye(n,n.anchor,m),q=n.input.charCodeAt(++n.position);q!==0;){if(z(n,!0,h),q=n.input.charCodeAt(n.position),q===$)return n.position++,n.tag=c,n.anchor=x,n.kind=S?"mapping":"sequence",n.result=m,!0;if(w?q===44&&I(n,"expected the node content, but found ','"):I(n,"missed comma between flow collection entries"),P=T=M=null,k=C=!1,q===63){let K=n.input.charCodeAt(n.position+1);L(K)&&(k=C=!0,n.position++,z(n,!0,h))}E=n.line,y=n.lineStart,O=n.position,$e(n,h,a,!1,!0),P=n.tag,T=n.result,z(n,!0,h),q=n.input.charCodeAt(n.position),(C||n.line===E)&&q===58&&(k=!0,q=n.input.charCodeAt(++n.position),z(n,!0,h),$e(n,h,a,!1,!0),M=n.result),S?we(n,m,R,P,T,M,E,y,O):k?m.push(we(n,null,R,P,T,M,E,y,O)):m.push(T),z(n,!0,h),q=n.input.charCodeAt(n.position),q===44?(w=!0,q=n.input.charCodeAt(++n.position)):w=!1}I(n,"unexpected end of the stream within a flow collection")}function vt(n,h){let w,E=l,y=!1,O=!1,c=h,m=0,x=!1,$,k=n.input.charCodeAt(n.position);if(k===124)w=!1;else if(k===62)w=!0;else return!1;for(n.kind="scalar",n.result="";k!==0;)if(k=n.input.charCodeAt(++n.position),k===43||k===45)l===E?E=k===43?f:d:I(n,"repeat of a chomping mode identifier");else if(($=te(k))>=0)$===0?I(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):O?I(n,"repeat of an indentation width identifier"):(c=h+$-1,O=!0);else break;if(D(k)){do k=n.input.charCodeAt(++n.position);while(D(k));if(k===35)do k=n.input.charCodeAt(++n.position);while(!F(k)&&k!==0)}for(;k!==0;){for(qe(n),n.lineIndent=0,k=n.input.charCodeAt(n.position);(!O||n.lineIndent<c)&&k===32;)n.lineIndent++,k=n.input.charCodeAt(++n.position);if(!O&&n.lineIndent>c&&(c=n.lineIndent),F(k)){m++;continue}if(!O&&c===0&&I(n,"missing indentation for block scalar"),n.lineIndent<c){E===f?n.result+=i.repeat(`
|
|
49
|
+
`,y?1+m:m):E===l&&y&&(n.result+=`
|
|
50
|
+
`);break}w?D(k)?(x=!0,n.result+=i.repeat(`
|
|
51
|
+
`,y?1+m:m)):x?(x=!1,n.result+=i.repeat(`
|
|
52
|
+
`,m+1)):m===0?y&&(n.result+=" "):n.result+=i.repeat(`
|
|
53
|
+
`,m):n.result+=i.repeat(`
|
|
54
|
+
`,y?1+m:m),y=!0,O=!0,m=0;let C=n.position;for(;!F(k)&&k!==0;)k=n.input.charCodeAt(++n.position);de(n,C,n.position,!1)}return!0}function Ae(n,h){let w=n.tag,E=n.anchor,y=[],O=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&ye(n,n.anchor,y);let c=n.input.charCodeAt(n.position);for(;c!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,I(n,"tab characters must not be used in indentation")),c===45);){let m=n.input.charCodeAt(n.position+1);if(!L(m))break;if(O=!0,n.position++,z(n,!0,-1)&&n.lineIndent<=h){y.push(null),c=n.input.charCodeAt(n.position);continue}let x=n.line;if($e(n,h,p,!1,!0),y.push(n.result),z(n,!0,-1),c=n.input.charCodeAt(n.position),(n.line===x||n.lineIndent>h)&&c!==0)I(n,"bad indentation of a sequence entry");else if(n.lineIndent<h)break}return O?(n.tag=w,n.anchor=E,n.kind="sequence",n.result=y,!0):!1}function xt(n,h,w){let E,y,O,c,m=n.tag,x=n.anchor,$={},k=Object.create(null),C=null,S=null,R=null,T=!1,P=!1;if(n.firstTabInLine!==-1)return!1;n.anchor!==null&&ye(n,n.anchor,$);let M=n.input.charCodeAt(n.position);for(;M!==0;){!T&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,I(n,"tab characters must not be used in indentation"));let q=n.input.charCodeAt(n.position+1),K=n.line;if((M===63||M===58)&&L(q))M===63?(T&&(we(n,$,k,C,S,null,y,O,c),C=S=R=null),P=!0,T=!0,E=!0):T?(T=!1,E=!0):I(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(y=n.line,O=n.lineStart,c=n.position,!$e(n,w,u,!1,!0))break;if(n.line===K){for(M=n.input.charCodeAt(n.position);D(M);)M=n.input.charCodeAt(++n.position);if(M===58)M=n.input.charCodeAt(++n.position),L(M)||I(n,"a whitespace character is expected after the key-value separator within a block mapping"),T&&(we(n,$,k,C,S,null,y,O,c),C=S=R=null),P=!0,T=!1,E=!1,C=n.tag,S=n.result;else if(P)I(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=m,n.anchor=x,!0}else if(P)I(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=m,n.anchor=x,!0}if((n.line===K||n.lineIndent>h)&&(T&&(y=n.line,O=n.lineStart,c=n.position),$e(n,h,s,!0,E)&&(T?S=n.result:R=n.result),T||(we(n,$,k,C,S,R,y,O,c),C=S=R=null),z(n,!0,-1),M=n.input.charCodeAt(n.position)),(n.line===K||n.lineIndent>h)&&M!==0)I(n,"bad indentation of a mapping entry");else if(n.lineIndent<h)break}return T&&we(n,$,k,C,S,null,y,O,c),P&&(n.tag=m,n.anchor=x,n.kind="mapping",n.result=$),P}function tn(n){let h=!1,w=!1,E,y,O=n.input.charCodeAt(n.position);if(O!==33)return!1;n.tag!==null&&I(n,"duplication of a tag property"),O=n.input.charCodeAt(++n.position),O===60?(h=!0,O=n.input.charCodeAt(++n.position)):O===33?(w=!0,E="!!",O=n.input.charCodeAt(++n.position)):E="!";let c=n.position;if(h){do O=n.input.charCodeAt(++n.position);while(O!==0&&O!==62);n.position<n.length?(y=n.input.slice(c,n.position),O=n.input.charCodeAt(++n.position)):I(n,"unexpected end of the stream within a verbatim tag")}else{for(;O!==0&&!L(O);)O===33&&(w?I(n,"tag suffix cannot contain exclamation marks"):(E=n.input.slice(c-1,n.position+1),b.test(E)||I(n,"named tag handle cannot contain such characters"),w=!0,c=n.position+1)),O=n.input.charCodeAt(++n.position);y=n.input.slice(c,n.position),v.test(y)&&I(n,"tag suffix cannot contain flow indicator characters")}y&&!A.test(y)&&I(n,"tag name cannot contain such characters: "+y);try{y=decodeURIComponent(y)}catch{I(n,"tag name is malformed: "+y)}return h?n.tag=y:o.call(n.tagMap,E)?n.tag=n.tagMap[E]+y:E==="!"?n.tag="!"+y:E==="!!"?n.tag="tag:yaml.org,2002:"+y:I(n,'undeclared tag handle "'+E+'"'),!0}function Ct(n){let h=n.input.charCodeAt(n.position);if(h!==38)return!1;n.anchor!==null&&I(n,"duplication of an anchor property"),h=n.input.charCodeAt(++n.position);let w=n.position;for(;h!==0&&!L(h)&&!U(h);)h=n.input.charCodeAt(++n.position);return n.position===w&&I(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(w,n.position),!0}function Ot(n){let h=n.input.charCodeAt(n.position);if(h!==42)return!1;h=n.input.charCodeAt(++n.position);let w=n.position;for(;h!==0&&!L(h)&&!U(h);)h=n.input.charCodeAt(++n.position);n.position===w&&I(n,"name of an alias node must contain at least one character");let E=n.input.slice(w,n.position);return o.call(n.anchorMap,E)||I(n,'unidentified alias "'+E+'"'),n.result=n.anchorMap[E],z(n,!0,-1),!0}function nn(n,h,w,E){let y=rt(n);return Zt(n),Ue(n,h),n.tag=null,n.anchor=null,n.kind=null,n.result=null,xt(n,w,E)&&n.kind==="mapping"?(Pe(n),!0):(en(n),Ue(n,y),!1)}function $e(n,h,w,E,y){let O,c,m=1,x=!1,$=!1,k=null,C,S,R;n.depth>=n.maxDepth&&I(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=c=s===w||p===w;if(E&&z(n,!0,-1)&&(x=!0,n.lineIndent>h?m=1:n.lineIndent===h?m=0:n.lineIndent<h&&(m=-1)),m===1)for(;;){let P=n.input.charCodeAt(n.position),M=rt(n);if(x&&(P===33&&n.tag!==null||P===38&&n.anchor!==null)||!tn(n)&&!Ct(n))break;k===null&&(k=M),z(n,!0,-1)?(x=!0,c=T,n.lineIndent>h?m=1:n.lineIndent===h?m=0:n.lineIndent<h&&(m=-1)):c=!1}if(c&&(c=x||y),m===1||s===w)if(a===w||u===w?S=h:S=h+1,R=n.position-n.lineStart,m===1)if(c&&(Ae(n,R)||xt(n,R,S))||St(n,S))$=!0;else{let P=n.input.charCodeAt(n.position);k!==null&&T&&!c&&P!==124&&P!==62&&nn(n,k,k.position-k.lineStart,S)||O&&vt(n,S)||Et(n,S)||ot(n,S)?$=!0:Ot(n)?($=!0,(n.tag!==null||n.anchor!==null)&&I(n,"alias node should not have any properties")):kt(n,S,a===w)&&($=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&ye(n,n.anchor,n.result)}else m===0&&($=c&&Ae(n,R));if(n.tag===null)n.anchor!==null&&ye(n,n.anchor,n.result);else if(n.tag==="?"){n.result!==null&&n.kind!=="scalar"&&I(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"');for(let P=0,M=n.implicitTypes.length;P<M;P+=1)if(C=n.implicitTypes[P],C.resolve(n.result)){n.result=C.construct(n.result),n.tag=C.tag,n.anchor!==null&&ye(n,n.anchor,n.result);break}}else if(n.tag!=="!"){if(o.call(n.typeMap[n.kind||"fallback"],n.tag))C=n.typeMap[n.kind||"fallback"][n.tag];else{C=null;let P=n.typeMap.multi[n.kind||"fallback"];for(let M=0,q=P.length;M<q;M+=1)if(n.tag.slice(0,P[M].tag.length)===P[M].tag){C=P[M];break}}C||I(n,"unknown tag !<"+n.tag+">"),n.result!==null&&C.kind!==n.kind&&I(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+C.kind+'", not "'+n.kind+'"'),C.resolve(n.result,n.tag)?(n.result=C.construct(n.result,n.tag),n.anchor!==null&&ye(n,n.anchor,n.result)):I(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||$}function rn(n){let h=n.position,w=!1,E;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(E=n.input.charCodeAt(n.position))!==0&&(z(n,!0,-1),E=n.input.charCodeAt(n.position),!(n.lineIndent>0||E!==37));){w=!0,E=n.input.charCodeAt(++n.position);let y=n.position;for(;E!==0&&!L(E);)E=n.input.charCodeAt(++n.position);let O=n.input.slice(y,n.position),c=[];for(O.length<1&&I(n,"directive name must not be less than one character in length");E!==0;){for(;D(E);)E=n.input.charCodeAt(++n.position);if(E===35){do E=n.input.charCodeAt(++n.position);while(E!==0&&!F(E));break}if(F(E))break;for(y=n.position;E!==0&&!L(E);)E=n.input.charCodeAt(++n.position);c.push(n.input.slice(y,n.position))}E!==0&&qe(n),o.call($t,O)?$t[O](n,O,c):je(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)):w&&I(n,"directives end mark is expected"),$e(n,n.lineIndent-1,s,!1,!0),z(n,!0,-1),n.checkLineBreaks&&g.test(n.input.slice(h,n.position))&&je(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&Be(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,z(n,!0,-1));return}n.position<n.length-1&&I(n,"end of the stream or a document separator is expected")}function Tt(n,h){n=String(n),h=h||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
|
|
55
|
+
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));let w=new Z(n,h),E=n.indexOf("\0");for(E!==-1&&(w.position=E,I(w,"null byte is not allowed in input")),w.input+="\0";w.input.charCodeAt(w.position)===32;)w.lineIndent+=1,w.position+=1;for(;w.position<w.length-1;)rn(w);return w.documents}function Rt(n,h,w){h!==null&&typeof h=="object"&&typeof w>"u"&&(w=h,h=null);let E=Tt(n,w);if(typeof h!="function")return E;for(let y=0,O=E.length;y<O;y+=1)h(E[y])}function on(n,h){let w=Tt(n,h);if(w.length!==0){if(w.length===1)return w[0];throw new e("expected a single document in the stream, but found more")}}return Jt.loadAll=Rt,Jt.load=on,Jt}var ri={},br;function es(){if(br)return ri;br=1;let i=mt(),e=gt(),t=oi(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,a=65279,u=9,p=10,s=13,l=32,d=33,f=34,_=35,g=37,v=38,b=39,A=42,N=44,F=45,D=58,L=61,U=62,ee=63,oe=64,te=91,ce=93,be=96,me=123,j=124,ue=125,Z={};Z[0]="\\0",Z[7]="\\a",Z[8]="\\b",Z[9]="\\t",Z[10]="\\n",Z[11]="\\v",Z[12]="\\f",Z[13]="\\r",Z[27]="\\e",Z[34]='\\"',Z[92]="\\\\",Z[133]="\\N",Z[160]="\\_",Z[8232]="\\L",Z[8233]="\\P";let se=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],I=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function je(c,m){if(m===null)return{};let x={},$=Object.keys(m);for(let k=0,C=$.length;k<C;k+=1){let S=$[k],R=String(m[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let T=c.compiledTypeMap.fallback[S];T&&o.call(T.styleAliases,R)&&(R=T.styleAliases[R]),x[S]=R}return x}function ye(c){let m,x,$=c.toString(16).toUpperCase();if(c<=255)m="x",x=2;else if(c<=65535)m="u",x=4;else if(c<=4294967295)m="U",x=8;else throw new e("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+m+i.repeat("0",x-$.length)+$}let Zt=1,Pe=2;function en(c){this.schema=c.schema||t,this.indent=Math.max(1,c.indent||2),this.noArrayIndent=c.noArrayIndent||!1,this.skipInvalid=c.skipInvalid||!1,this.flowLevel=i.isNothing(c.flowLevel)?-1:c.flowLevel,this.styleMap=je(this.schema,c.styles||null),this.sortKeys=c.sortKeys||!1,this.lineWidth=c.lineWidth||80,this.noRefs=c.noRefs||!1,this.noCompatMode=c.noCompatMode||!1,this.condenseFlow=c.condenseFlow||!1,this.quotingType=c.quotingType==='"'?Pe:Zt,this.forceQuotes=c.forceQuotes||!1,this.replacer=typeof c.replacer=="function"?c.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function rt(c,m){let x=i.repeat(" ",m),$=0,k="",C=c.length;for(;$<C;){let S,R=c.indexOf(`
|
|
56
|
+
`,$);R===-1?(S=c.slice($),$=C):(S=c.slice($,R+1),$=R+1),S.length&&S!==`
|
|
57
|
+
`&&(k+=x),k+=S}return k}function Ue(c,m){return`
|
|
58
|
+
`+i.repeat(" ",c.indent*m)}function $t(c,m){for(let x=0,$=c.implicitTypes.length;x<$;x+=1)if(c.implicitTypes[x].resolve(m))return!0;return!1}function de(c){return c===l||c===u}function Oe(c){return c>=32&&c<=126||c>=161&&c<=55295&&c!==8232&&c!==8233||c>=57344&&c<=65533&&c!==a||c>=65536&&c<=1114111}function we(c){return Oe(c)&&c!==a&&c!==s&&c!==p}function qe(c,m,x){let $=we(c),k=$&&!de(c);return(x?$:$&&c!==N&&c!==te&&c!==ce&&c!==me&&c!==ue)&&c!==_&&!(m===D&&!k)||we(m)&&!de(m)&&c===_||m===D&&k}function z(c){return Oe(c)&&c!==a&&!de(c)&&c!==F&&c!==ee&&c!==D&&c!==N&&c!==te&&c!==ce&&c!==me&&c!==ue&&c!==_&&c!==v&&c!==A&&c!==d&&c!==j&&c!==L&&c!==U&&c!==b&&c!==f&&c!==g&&c!==oe&&c!==be}function Be(c){return!de(c)&&c!==D}function _e(c,m){let x=c.charCodeAt(m),$;return x>=55296&&x<=56319&&m+1<c.length&&($=c.charCodeAt(m+1),$>=56320&&$<=57343)?(x-55296)*1024+$-56320+65536:x}function kt(c){return/^\n* /.test(c)}let Et=1,ot=2,St=3,vt=4,Ae=5;function xt(c,m,x,$,k,C,S,R){let T,P=0,M=null,q=!1,K=!1,ui=$!==-1,st=-1,at=z(_e(c,0))&&Be(_e(c,c.length-1));if(m||S)for(T=0;T<c.length;P>=65536?T+=2:T++){if(P=_e(c,T),!Oe(P))return Ae;at=at&&qe(P,M,R),M=P}else{for(T=0;T<c.length;P>=65536?T+=2:T++){if(P=_e(c,T),P===p)q=!0,ui&&(K=K||T-st-1>$&&c[st+1]!==" ",st=T);else if(!Oe(P))return Ae;at=at&&qe(P,M,R),M=P}K=K||ui&&T-st-1>$&&c[st+1]!==" "}return!q&&!K?at&&!S&&!k(c)?Et:C===Pe?Ae:ot:x>9&&kt(c)?Ae:S?C===Pe?Ae:ot:K?vt:St}function tn(c,m,x,$,k){c.dump=(function(){if(m.length===0)return c.quotingType===Pe?'""':"''";if(!c.noCompatMode&&(se.indexOf(m)!==-1||I.test(m)))return c.quotingType===Pe?'"'+m+'"':"'"+m+"'";let C=c.indent*Math.max(1,x),S=c.lineWidth===-1?-1:Math.max(Math.min(c.lineWidth,40),c.lineWidth-C),R=$||c.flowLevel>-1&&x>=c.flowLevel;function T(P){return $t(c,P)}switch(xt(m,R,c.indent,S,T,c.quotingType,c.forceQuotes&&!$,k)){case Et:return m;case ot:return"'"+m.replace(/'/g,"''")+"'";case St:return"|"+Ct(m,c.indent)+Ot(rt(m,C));case vt:return">"+Ct(m,c.indent)+Ot(rt(nn(m,S),C));case Ae:return'"'+rn(m)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function Ct(c,m){let x=kt(c)?String(m):"",$=c[c.length-1]===`
|
|
59
|
+
`,C=$&&(c[c.length-2]===`
|
|
58
60
|
`||c===`
|
|
59
|
-
`)?"+"
|
|
60
|
-
`}function
|
|
61
|
-
`?c.slice(0,-1):c}function
|
|
62
|
-
`);return R=R!==-1?R:c.length,
|
|
63
|
-
`||c[0]===" ",C,S;for(;S=
|
|
64
|
-
`:"")
|
|
65
|
-
`+c.slice(
|
|
66
|
-
`,c.length-
|
|
67
|
-
`+c.slice(S+1):T+=c.slice(
|
|
68
|
-
`:""}return
|
|
69
|
-
`)})]}}function
|
|
70
|
-
`);return{jobId:
|
|
71
|
-
`)}]}}
|
|
61
|
+
`)?"+":$?"":"-";return x+C+`
|
|
62
|
+
`}function Ot(c){return c[c.length-1]===`
|
|
63
|
+
`?c.slice(0,-1):c}function nn(c,m){let x=/(\n+)([^\n]*)/g,$=(function(){let R=c.indexOf(`
|
|
64
|
+
`);return R=R!==-1?R:c.length,x.lastIndex=R,$e(c.slice(0,R),m)})(),k=c[0]===`
|
|
65
|
+
`||c[0]===" ",C,S;for(;S=x.exec(c);){let R=S[1],T=S[2];C=T[0]===" ",$+=R+(!k&&!C&&T!==""?`
|
|
66
|
+
`:"")+$e(T,m),k=C}return $}function $e(c,m){if(c===""||c[0]===" ")return c;let x=/ [^ ]/g,$,k=0,C,S=0,R=0,T="";for(;$=x.exec(c);)R=$.index,R-k>m&&(C=S>k?S:R,T+=`
|
|
67
|
+
`+c.slice(k,C),k=C+1),S=R;return T+=`
|
|
68
|
+
`,c.length-k>m&&S>k?T+=c.slice(k,S)+`
|
|
69
|
+
`+c.slice(S+1):T+=c.slice(k),T.slice(1)}function rn(c){let m="",x=0;for(let $=0;$<c.length;x>=65536?$+=2:$++){x=_e(c,$);let k=Z[x];!k&&Oe(x)?(m+=c[$],x>=65536&&(m+=c[$+1])):m+=k||ye(x)}return m}function Tt(c,m,x){let $="",k=c.tag;for(let C=0,S=x.length;C<S;C+=1){let R=x[C];c.replacer&&(R=c.replacer.call(x,String(C),R)),(w(c,m,R,!1,!1)||typeof R>"u"&&w(c,m,null,!1,!1))&&($!==""&&($+=","+(c.condenseFlow?"":" ")),$+=c.dump)}c.tag=k,c.dump="["+$+"]"}function Rt(c,m,x,$){let k="",C=c.tag;for(let S=0,R=x.length;S<R;S+=1){let T=x[S];c.replacer&&(T=c.replacer.call(x,String(S),T)),(w(c,m+1,T,!0,!0,!1,!0)||typeof T>"u"&&w(c,m+1,null,!0,!0,!1,!0))&&((!$||k!=="")&&(k+=Ue(c,m)),c.dump&&p===c.dump.charCodeAt(0)?k+="-":k+="- ",k+=c.dump)}c.tag=C,c.dump=k||"[]"}function on(c,m,x){let $="",k=c.tag,C=Object.keys(x);for(let S=0,R=C.length;S<R;S+=1){let T="";$!==""&&(T+=", "),c.condenseFlow&&(T+='"');let P=C[S],M=x[P];c.replacer&&(M=c.replacer.call(x,P,M)),w(c,m,P,!1,!1)&&(c.dump.length>1024&&(T+="? "),T+=c.dump+(c.condenseFlow?'"':"")+":"+(c.condenseFlow?"":" "),w(c,m,M,!1,!1)&&(T+=c.dump,$+=T))}c.tag=k,c.dump="{"+$+"}"}function n(c,m,x,$){let k="",C=c.tag,S=Object.keys(x);if(c.sortKeys===!0)S.sort();else if(typeof c.sortKeys=="function")S.sort(c.sortKeys);else if(c.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let R=0,T=S.length;R<T;R+=1){let P="";(!$||k!=="")&&(P+=Ue(c,m));let M=S[R],q=x[M];if(c.replacer&&(q=c.replacer.call(x,M,q)),!w(c,m+1,M,!0,!0,!0))continue;let K=c.tag!==null&&c.tag!=="?"||c.dump&&c.dump.length>1024;K&&(c.dump&&p===c.dump.charCodeAt(0)?P+="?":P+="? "),P+=c.dump,K&&(P+=Ue(c,m)),w(c,m+1,q,!0,K)&&(c.dump&&p===c.dump.charCodeAt(0)?P+=":":P+=": ",P+=c.dump,k+=P)}c.tag=C,c.dump=k||"{}"}function h(c,m,x){let $=x?c.explicitTypes:c.implicitTypes;for(let k=0,C=$.length;k<C;k+=1){let S=$[k];if((S.instanceOf||S.predicate)&&(!S.instanceOf||typeof m=="object"&&m instanceof S.instanceOf)&&(!S.predicate||S.predicate(m))){if(x?S.multi&&S.representName?c.tag=S.representName(m):c.tag=S.tag:c.tag="?",S.represent){let R=c.styleMap[S.tag]||S.defaultStyle,T;if(r.call(S.represent)==="[object Function]")T=S.represent(m,R);else if(o.call(S.represent,R))T=S.represent[R](m,R);else throw new e("!<"+S.tag+'> tag resolver accepts not "'+R+'" style');c.dump=T}return!0}}return!1}function w(c,m,x,$,k,C,S){c.tag=null,c.dump=x,h(c,x,!1)||h(c,x,!0);let R=r.call(c.dump),T=$;$&&($=c.flowLevel<0||c.flowLevel>m);let P=R==="[object Object]"||R==="[object Array]",M,q;if(P&&(M=c.duplicates.indexOf(x),q=M!==-1),(c.tag!==null&&c.tag!=="?"||q||c.indent!==2&&m>0)&&(k=!1),q&&c.usedDuplicates[M])c.dump="*ref_"+M;else{if(P&&q&&!c.usedDuplicates[M]&&(c.usedDuplicates[M]=!0),R==="[object Object]")$&&Object.keys(c.dump).length!==0?(n(c,m,c.dump,k),q&&(c.dump="&ref_"+M+c.dump)):(on(c,m,c.dump),q&&(c.dump="&ref_"+M+" "+c.dump));else if(R==="[object Array]")$&&c.dump.length!==0?(c.noArrayIndent&&!S&&m>0?Rt(c,m-1,c.dump,k):Rt(c,m,c.dump,k),q&&(c.dump="&ref_"+M+c.dump)):(Tt(c,m,c.dump),q&&(c.dump="&ref_"+M+" "+c.dump));else if(R==="[object String]")c.tag!=="?"&&tn(c,c.dump,m,C,T);else{if(R==="[object Undefined]")return!1;if(c.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+R)}if(c.tag!==null&&c.tag!=="?"){let K=encodeURI(c.tag[0]==="!"?c.tag.slice(1):c.tag).replace(/!/g,"%21");c.tag[0]==="!"?K="!"+K:K.slice(0,18)==="tag:yaml.org,2002:"?K="!!"+K.slice(18):K="!<"+K+">",c.dump=K+" "+c.dump}}return!0}function E(c,m){let x=[],$=[];y(c,x,$);let k=$.length;for(let C=0;C<k;C+=1)m.duplicates.push(x[$[C]]);m.usedDuplicates=new Array(k)}function y(c,m,x){if(c!==null&&typeof c=="object"){let $=m.indexOf(c);if($!==-1)x.indexOf($)===-1&&x.push($);else if(m.push(c),Array.isArray(c))for(let k=0,C=c.length;k<C;k+=1)y(c[k],m,x);else{let k=Object.keys(c);for(let C=0,S=k.length;C<S;C+=1)y(c[k[C]],m,x)}}}function O(c,m){m=m||{};let x=new en(m);x.noRefs||E(c,x);let $=c;return x.replacer&&($=x.replacer.call({"":$},"",$)),w(x,0,$,!0,!0)?x.dump+`
|
|
70
|
+
`:""}return ri.dump=O,ri}var yr;function ts(){if(yr)return re;yr=1;let i=Zo(),e=es();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 re.Type=ae(),re.Schema=wr(),re.FAILSAFE_SCHEMA=kr(),re.JSON_SCHEMA=Cr(),re.CORE_SCHEMA=Or(),re.DEFAULT_SCHEMA=oi(),re.load=i.load,re.loadAll=i.loadAll,re.dump=e.dump,re.YAMLException=gt(),re.types={binary:Nr(),float:xr(),map:$r(),null:Er(),pairs:Hr(),set:Pr(),timestamp:Tr(),bool:Sr(),int:vr(),merge:Rr(),omap:Ir(),seq:Ar(),str:_r()},re.safeLoad=t("safeLoad","load"),re.safeLoadAll=t("safeLoadAll","loadAll"),re.safeDump=t("safeDump","dump"),re}var ns=ts(),ve=zo(ns),{Type:Fa,Schema:Ma,FAILSAFE_SCHEMA:Da,JSON_SCHEMA:La,CORE_SCHEMA:ja,DEFAULT_SCHEMA:Ua,load:qa,loadAll:Ba,dump:Ga,YAMLException:Wa,types:Va,safeLoad:Ya,safeLoadAll:Ka,safeDump:Ja}=ve;H();var is="${{ github.event.pull_request.number }}",rs=10,Fr=3,os=600;function Mr(i){return Ve(i.node)?ls(i):Ye(i.node,i.config)?as(i):null}function Dr(i){return Ve(i.node)?cs(i):null}var ss="github-actions";function as(i){let e=i.node,t=Fe(e),r=We(e,i.config),o={GH_TOKEN:"${{ github.token }}",PR:is,NODE:e.id,BOT_LOGIN:i.config.identity?.bot_login??""};r&&(o.AUTHORS=r.join(","));let a=["# Decide whether this lane should run for the PR. The skip= reads fail OPEN:","# a lane that runs once too often costs a run, one that is wrongly skipped","# costs a review nobody knows is missing. The author allowlist is the one","# exception and fails CLOSED \u2014 it says whose PRs the lane may touch at all.",'RUN=true; REASON=""; HEAD_SHA=""; DIFF_HASH=""',"finish() {",' { echo "run=$RUN"; echo "reason=$REASON"; echo "head_sha=$HEAD_SHA"; echo "diff_hash=$DIFF_HASH"; } >> "$GITHUB_OUTPUT"',' if [ "$RUN" = "true" ]; then echo "Running $NODE."; else echo "::notice::Skipping $NODE: $REASON"; fi'," exit 0","}",'skip() { RUN=false; REASON="$1"; finish; }',"","# Live PR state, not the event payload: the run may have queued for a while.",'PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" 2>/dev/null) || PR_JSON=""','if [ -z "$PR_JSON" ]; then',...r?[' skip "could not read PR #$PR to verify its author"']:[' echo "::warning::could not read PR #$PR \u2014 not skipping"'," finish"],"fi",`HEAD_SHA=$(jq -r '.head.sha // ""' <<< "$PR_JSON")`];r&&a.push("","# authors: only these logins' PRs (case-insensitive). The job-level `if:`","# already turned everyone else away from the event payload; this is the","# same test against the PR as it is now, and anything but a match skips.",`if ! jq -e '(.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a)' <<< "$PR_JSON" >/dev/null; then`,` skip "the author $(jq -r '.user.login // "?"' <<< "$PR_JSON") is not in the allowlist"`,"fi");let u=0;for(let p of t)if(a.push(""),p.kind==="draft")a.push("# draft",`if [ "$(jq -r '.draft' <<< "$PR_JSON")" = "true" ]; then skip "the PR is a draft"; fi`);else if(p.kind==="bot-author")a.push("# bot-author: a PR opened by a bot (dependabot, renovate, \u2026). The harness's","# own bot is exempt \u2014 its PRs are the ones this lane exists to review.",`AUTHOR=$(jq -r '.user.login // ""' <<< "$PR_JSON")`,`AUTHOR_TYPE=$(jq -r '.user.type // ""' <<< "$PR_JSON")`,'if [ "$AUTHOR" != "$BOT_LOGIN" ]; then',' case "$AUTHOR_TYPE:$AUTHOR" in',' Bot:*|*"[bot]") skip "authored by the bot $AUTHOR" ;;'," esac","fi");else if(p.kind==="label"){u+=1;let s=`SKIP_LABEL_${u}`;o[s]=i.config.labels?.[p.label]??p.label,a.push(`# label:${p.label}`,`if jq -e --arg l "$${s}" 'any(.labels[]?; .name == $l)' <<< "$PR_JSON" >/dev/null; then`,` skip "the PR carries the label $${s}"`,"fi")}else o.MARKER_PREFIX=Lt(e),o.EVENT_ACTION="${{ github.event.action }}",a.push("# unchanged-diff: hash the PR's merge-base diff and compare it with the hash","# stamped into this bot's last review. Blob ids and hunk positions are","# dropped first, so a rebase or a merge from the base branch that leaves the","# change itself untouched hashes the same. Only a push (synchronize) is","# ever skipped this way: a label, a ready-for-review or a re-request is",'# someone asking for a review, and "nothing changed" is no answer to that.',`BASE_SHA=$(jq -r '.base.sha // ""' <<< "$PR_JSON")`,'if [ -n "$HEAD_SHA" ] && [ -n "$BASE_SHA" ] \\',' && DIFF=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA" -H "Accept: application/vnd.github.diff" 2>/dev/null) \\',' && [ -n "$DIFF" ]; then',` DIFF_HASH=$(printf '%s\\n' "$DIFF" \\`," | sed -E -e '/^index [0-9a-f]+\\.\\.[0-9a-f]+/d' -e 's/^@@ -[0-9,]+ \\+[0-9,]+ @@/@@/' \\"," | sha256sum | cut -d' ' -f1)",` LAST=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR/reviews" --paginate --jq '`,' .[] | select(.user.login == env.BOT_LOGIN) | (.body // "")',` | select(contains(env.MARKER_PREFIX)) | split(env.MARKER_PREFIX) | last | .[0:64]' 2>/dev/null | tail -n 1) || LAST=""`,' if [ "$EVENT_ACTION" = "synchronize" ] && [ -n "$LAST" ] && [ "$LAST" = "$DIFF_HASH" ]; then',' skip "the diff is unchanged since the last review"'," fi","else",' echo "::warning::could not hash the diff of PR #$PR \u2014 not skipping on unchanged-diff"',"fi");return a.push("","finish"),{jobId:Ke(e),name:`${e.id} skip guard`,displayName:`${e.id} guard`,permissions:{contents:"read","pull-requests":"read"},timeoutMinutes:5,outputs:{run:"${{ steps.decide.outputs.run }}",reason:"${{ steps.decide.outputs.reason }}",head_sha:"${{ steps.decide.outputs.head_sha }}",diff_hash:"${{ steps.decide.outputs.diff_hash }}"},steps:[ie({id:"decide",name:"Decide whether to run",env:o,run:a.join(`
|
|
71
|
+
`)})]}}function ls(i){let e=i.node,t=We(e,i.config),r=["# Pick the PR heads that are ready for a decision. Selection is a pure","# function of repo state \u2014 no agent, no randomness \u2014 and every read fails","# CLOSED: a head whose state cannot be read is left for the next sweep.","#",`# candidate open, not a draft, on a harness branch${t?", by an allowlisted author":""}`,"# reviews in no review is still being waited on (no pending review request)","# checks in every check-run on the head is completed, no commit status","# pending \u2014 and at least one check-run exists, unless the PR has","# been quiet for $SETTLE_SECONDS s (a repo with no CI still gets swept)","# undecided no verdict review on this exact head yet, and no earlier","# sweep has already run the lane on it (the swept check)","# not spent fewer than $MAX_FAILURES failed lane runs on this head",`LIST=$(gh api "repos/$GITHUB_REPOSITORY/pulls?state=open&sort=created&direction=asc&per_page=100" --paginate --jq '`," .[] | select(.draft | not)"," | select(.head.ref | startswith(env.PREFIX))",...t?[' | select((.user.login // "" | ascii_downcase) as $a | env.AUTHORS | split(",") | index($a))']:[],` | "\\(.number) \\(.head.sha) \\((.requested_reviewers | length) + (.requested_teams | length)) \\(now - (.updated_at | fromdateiso8601) | floor) \\(.base.ref)"') || {`,' echo "::error::could not list open pull requests"'," exit 1","}","SELECTED='[]'","while read -r NUM SHA REQUESTED QUIET BASE; do",' [ -n "$NUM" ] || continue',' if [ "$REQUESTED" != "0" ]; then echo "#$NUM: $REQUESTED review request(s) outstanding"; continue; fi'," # One read of the head's check-runs answers four questions: how many exist,"," # how many are still running, has the lane already run here, how often has it failed.",` CHECKS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`," .check_runs | [ length,",' ([.[] | select(.status != "completed")] | length),'," ([.[] | select(.name == env.SWEPT_CHECK and .app.slug == env.MARK_APP)] | length),"," ([.[] | select(.name == env.FAILED_CHECK and .app.slug == env.MARK_APP)] | length) ] | @tsv' \\",` | awk '{t+=$1; r+=$2; s+=$3; f+=$4} END {print t+0, r+0, s+0, f+0}') || { echo "#$NUM: could not read check-runs"; continue; }`,' read -r TOTAL RUNNING SWEPT FAILURES <<< "$CHECKS"',' if [ "$RUNNING" != "0" ]; then echo "#$NUM: $RUNNING check-run(s) still running"; continue; fi',' if [ "$TOTAL" = "0" ] && [ "$QUIET" -lt "$SETTLE_SECONDS" ]; then',' echo "#$NUM: no check-run on $SHA yet and the PR changed ${QUIET}s ago \u2014 waiting for CI to register"'," continue"," fi"," # The lane's own record that it ran here. A role that posts nothing (a"," # shadow run, an abstention) leaves no verdict, and without this the same"," # head would be handed to the agent again on every tick, forever.",' if [ "$SWEPT" != "0" ]; then echo "#$NUM: already swept at $SHA"; continue; fi'," # \u2026and a lane that keeps FAILING on a head is not retried forever either.",' if [ "$FAILURES" -ge "$MAX_FAILURES" ]; then echo "#$NUM: gave up on $SHA after $FAILURES failed runs"; continue; fi',` STATUS=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/status" --jq '`,` if .total_count == 0 then "none" else .state end') || { echo "#$NUM: could not read commit status"; continue; }`,' if [ "$STATUS" = "pending" ]; then echo "#$NUM: a commit status is pending"; continue; fi',` DECIDED=$(SHA="$SHA" gh api "repos/$GITHUB_REPOSITORY/pulls/$NUM/reviews?per_page=100" --paginate --jq '`," [ .[] | select(.commit_id == env.SHA)",' | select(env.BOT_LOGIN == "" or .user.login == env.BOT_LOGIN)',` | select((.body // "") | contains(env.VERDICT_MARKER)) ] | length' | awk '{s+=$1} END {print s+0}') || { echo "#$NUM: could not read reviews"; continue; }`,' if [ "$DECIDED" != "0" ]; then echo "#$NUM: already decided at $SHA"; continue; fi',' echo "#$NUM: selected at $SHA"',` SELECTED=$(jq -c --argjson n "$NUM" --arg s "$SHA" --arg b "$BASE" '. + [{number: $n, sha: $s, base: $b}]' <<< "$SELECTED")`,` if [ "$(jq 'length' <<< "$SELECTED")" -ge "$LIMIT" ]; then`,' echo "limit of $LIMIT reached \u2014 the rest wait for the next sweep"'," break"," fi",'done <<< "$LIST"',`{ echo "prs=$SELECTED"; echo "count=$(jq 'length' <<< "$SELECTED")"; } >> "$GITHUB_OUTPUT"`].join(`
|
|
72
|
+
`);return{jobId:Ke(e),name:`${e.id} sweep select`,displayName:`${e.id} select`,permissions:{contents:"read","pull-requests":"read",checks:"read",statuses:"read"},timeoutMinutes:10,outputs:{prs:"${{ steps.select.outputs.prs }}",count:"${{ steps.select.outputs.count }}"},steps:[ie({id:"select",name:"Select pull requests ready for a decision",env:{GH_TOKEN:"${{ github.token }}",PREFIX:i.config.repo.branch_prefix,BOT_LOGIN:i.config.identity?.bot_login??"",VERDICT_MARKER:Ii,SWEPT_CHECK:Tn(e),FAILED_CHECK:On(e),MARK_APP:ss,LIMIT:String(rs),MAX_FAILURES:String(Fr),SETTLE_SECONDS:String(os),...t?{AUTHORS:t.join(",")}:{}},run:r})]}}function cs(i){let e=i.node,t=Ke(e);return{jobId:`${e.id}_mark`,name:`${e.id} sweep mark`,displayName:`${e.id} mark`,needs:[t,e.id],if:`\${{ always() && needs.${t}.result == 'success' && needs.${t}.outputs.count != '0' }}`,permissions:{checks:"write",actions:"read"},timeoutMinutes:5,steps:[ie({name:"Mark the heads this sweep covered",env:{GH_TOKEN:"${{ github.token }}",PRS:`\${{ needs.${t}.outputs.prs }}`,NODE:e.id,JOB_PREFIX:Dt(e),SWEPT_CHECK:Tn(e),FAILED_CHECK:On(e),MAX_FAILURES:String(Fr),RUN_ID:"${{ github.run_id }}",RUN_ATTEMPT:"${{ github.run_attempt }}"},run:[`JOBS=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/attempts/$RUN_ATTEMPT/jobs?per_page=100" --paginate --jq '`,` .jobs[] | [(.conclusion // "none"), .name] | @tsv') || {`,` echo "::error::could not read this run's jobs \u2014 no head marked, so the next sweep will repeat them"`," exit 1","}","publish() { # <check name> <sha> <title> <summary>",' gh api --method POST "repos/$GITHUB_REPOSITORY/check-runs" \\',' -f name="$1" -f head_sha="$2" -f status=completed -f conclusion=neutral \\',' -f "output[title]=$3" -f "output[summary]=$4" >/dev/null',"}","FAILED=0","while read -r NUM SHA; do",' [ -n "$NUM" ] || continue',` RESULT=$(awk -F'\\t' -v n="$JOB_PREFIX$NUM" '$2 == n {print $1}' <<< "$JOBS" | tail -n 1)`,' case "$RESULT" in'," success)",' if publish "$SWEPT_CHECK" "$SHA" "Swept by $NODE" "The $NODE lane ran on $SHA. This is a record that it ran, not a verdict."; then',' echo "#$NUM: marked $SHA"'," else",' echo "::error::#$NUM: could not publish the swept check on $SHA \u2014 the next sweep will repeat it"'," FAILED=1"," fi ;;"," failure|timed_out)"," # One check-run per failed attempt; the selector counts them and stops at $MAX_FAILURES.",` PRIOR=$(gh api "repos/$GITHUB_REPOSITORY/commits/$SHA/check-runs?per_page=100" --paginate --jq '`," [.check_runs[] | select(.name == env.FAILED_CHECK)] | length' 2>/dev/null | awk '{s+=$1} END {print s+0}') || PRIOR=0"," N=$((PRIOR + 1))",' if [ "$N" -ge "$MAX_FAILURES" ]; then',' TITLE="$NODE gave up after $N failed runs"',' SUMMARY="The $NODE lane failed $N times on $SHA and will not be run on this head again. Push a new commit, or re-run the lane by hand, to try again."'," else",' TITLE="$NODE run $N of $MAX_FAILURES failed"',' SUMMARY="The $NODE lane failed on $SHA. The next sweep retries it; after $MAX_FAILURES failures it stops."'," fi",' if publish "$FAILED_CHECK" "$SHA" "$TITLE" "$SUMMARY"; then',' echo "#$NUM: lane $RESULT \u2014 recorded failed run $N of $MAX_FAILURES on $SHA"'," else",' echo "::error::#$NUM: could not record the failed run on $SHA \u2014 its retries are not being counted"'," FAILED=1"," fi ;;"," *)",' echo "#$NUM: lane did not finish (${RESULT:-no job}) \u2014 left for the next sweep, not counted as a failure" ;;'," esac",`done < <(jq -r '.[] | "\\(.number) \\(.sha)"' <<< "$PRS")`,'exit "$FAILED"'].join(`
|
|
73
|
+
`)})]}}H();var Lr=[" /^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 si="# GENERATED FROM harness.dot \u2014 DO NOT EDIT.",us=`${si}
|
|
74
|
+
# Edit harness.dot / roles / foundry.config.yaml and run \`gp-foundry build\`.
|
|
75
|
+
`;function ds(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 ps(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),Ci(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 jr(i){return String(i.attrs.title??i.attrs.name??i.id)}function fs(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 '",...Lr,` ' "$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(`
|
|
76
|
+
`)}]}}}}function hs(i){return i.nodes.some(e=>e.type==="producer"||e.type==="pr-fix"||e.type==="scheduled-agent"&&e.attrs.commit!=="none")}function Ur(i,e,t="",r={}){let o=[],a=ds(i.config),u=new Map(i.nodes.map(g=>[g.id,g])),p=new Map,s=new Map;for(let g of i.nodes)p.set(g.id,[]),s.set(g.id,[]);for(let g of i.edges)p.get(g.from)?.push(g),s.get(g.to)?.push(g);let l=g=>({config:i.config,node:g,outEdges:p.get(g.id)??[],inEdges:s.get(g.id)??[],actionRef:a,nodeById:v=>u.get(v),specDir:t,roleTools:r.roleTools}),d=(g,v)=>{let b={};g.displayName&&(b.name=g.displayName),b["runs-on"]="ubuntu-latest";let A=g.if??v;return A&&(b.if=A),g.environment&&(b.environment=g.environment),g.permissions&&Object.keys(g.permissions).length&&(b.permissions=g.permissions),g.timeoutMinutes&&(b["timeout-minutes"]=g.timeoutMinutes),g.needs?.length&&(b.needs=g.needs),g.outputs&&Object.keys(g.outputs).length&&(b.outputs=g.outputs),g.strategy&&(b.strategy=g.strategy),b.steps=g.steps.map(ps),b},f=(g,v)=>{let b=ve.dump(v,{lineWidth:-1,noRefs:!0,quotingType:'"'});o.push({path:`.github/workflows/${g}.yml`,contents:us+b,generated:!0})},_=De(i);hs(i)&&f("immutable-guard",fs(i.config,t));for(let g of i.nodes){if(_.memberIds.has(g.id))continue;let v=e.perNode[g.id];if(!v||Object.keys(v.triggers).length===0)continue;let b=_.byFanin.get(g.id);if(b){let L={};for(let oe of b.legIds){let{skip:te,select:ce,...be}=u.get(oe).attrs,me={...u.get(oe),attrs:be},j=Pn(me,i,l(me));j&&(L[j.jobId]=d(j,v.guard))}let U=JSON.stringify(v.triggers).includes('"pull_request"'),ee=Li(l(g),b.legIds,U);L[ee.jobId]=d(ee),f(g.id,{name:jr(g),on:v.triggers,...v.concurrency?{concurrency:v.concurrency}:{},permissions:{contents:"read"},jobs:L});continue}let A=Pn(g,i,l(g));if(!A)continue;let N=Mr(l(g)),F=N?{[N.jobId]:d(N,v.guard),[A.jobId]:d(A)}:{[A.jobId]:d(A,v.guard)},D=Dr(l(g));D&&(F[D.jobId]=d(D)),f(g.id,{name:jr(g),on:v.triggers,...v.concurrency?{concurrency:v.concurrency}:{},permissions:{contents:"read"},jobs:F})}return o}H();function ms(i){return Object.entries(i).map(([e,t])=>{if(e==="schedule"&&Array.isArray(t))return`schedule: ${t.map(o=>`\`${o.cron??"?"}\``).join(", ")}`;let r=t?.types;return r?.length?`${e}: ${r.join(", ")}`:e}).join(" \xB7 ")}function gs(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 bs(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 Xt(i,e){let t=["```mermaid","flowchart TD"];for(let o of i.nodes){let[a,u]=gs(o);t.push(` ${o.id}${a}"${bs(o)}"${u}`)}for(let o of i.edges){let a=[o.on,o.when].filter(Boolean).join(" \xB7 ");t.push(a?` ${o.from} -->|"${a}"| ${o.to}`:` ${o.from} --> ${o.to}`)}t.push("```","");let r=Object.values(e?.perNode??{}).filter(o=>Object.keys(o.triggers).length);if(r.length){t.push("## Triggers","","| Workflow | Runs on |","|----------|---------|");for(let o of r)t.push(`| \`${o.nodeId}\` | ${ms(o.triggers)} |`);t.push("")}return`<!-- GENERATED FROM harness.dot \u2014 DO NOT EDIT. Run \`gp-foundry build\`. -->
|
|
72
77
|
|
|
73
78
|
# ${i.config?.name&&i.config.name!=="harness"?i.config.name:i.name} \u2014 agent harness
|
|
74
79
|
|
|
75
|
-
${
|
|
76
|
-
`)}`}
|
|
77
|
-
`){r++,o++;continue}if(u===" "||u===" "||u==="\r"){o++;continue}if(u==="/"&&
|
|
78
|
-
`;)o++;continue}if(u==="/"&&
|
|
79
|
-
`&&r++,o++;o+=2;continue}if(u==="-"&&
|
|
80
|
-
`&&r++,
|
|
81
|
-
`)}function
|
|
82
|
-
`),e.hint&&process.stderr.write(` ${
|
|
83
|
-
`)}}function
|
|
84
|
-
`),
|
|
85
|
-
`)}function
|
|
80
|
+
${t.join(`
|
|
81
|
+
`)}`}H();var ys=/^---\r?\n([\s\S]*?)\r?\n---/;function zt(i){let e=ys.exec(i);if(e)try{let t=ve.load(e[1]);if(t&&typeof t=="object")return t}catch{return}}H();var ws=new Set(["start","exit","analyst","issue-agent","producer","pr-review","pr-fix","merge-gate","human-gate","scheduled-agent","parallel","fan_in"]),_s=new Set(["role","prompt","policy","tools"]);function As(i){let e=[],t=[],r=1,o=0,a=i;for(;o<a.length;){let u=a[o];if(u===`
|
|
82
|
+
`){r++,o++;continue}if(u===" "||u===" "||u==="\r"){o++;continue}if(u==="/"&&a[o+1]==="/"){for(;o<a.length&&a[o]!==`
|
|
83
|
+
`;)o++;continue}if(u==="/"&&a[o+1]==="*"){for(o+=2;o<a.length&&!(a[o]==="*"&&a[o+1]==="/");)a[o]===`
|
|
84
|
+
`&&r++,o++;o+=2;continue}if(u==="-"&&a[o+1]===">"){e.push({kind:"arrow",value:"->",line:r}),o+=2;continue}if(u==="{"){e.push({kind:"lbrace",value:u,line:r}),o++;continue}if(u==="}"){e.push({kind:"rbrace",value:u,line:r}),o++;continue}if(u==="["){e.push({kind:"lbrack",value:u,line:r}),o++;continue}if(u==="]"){e.push({kind:"rbrack",value:u,line:r}),o++;continue}if(u==="="){e.push({kind:"eq",value:u,line:r}),o++;continue}if(u===","){e.push({kind:"comma",value:u,line:r}),o++;continue}if(u===";"){e.push({kind:"semi",value:u,line:r}),o++;continue}if(u==='"'){let p=o+1,s="";for(;p<a.length&&a[p]!=='"';){if(a[p]==="\\"&&p+1<a.length){s+=a[p+1],p+=2;continue}a[p]===`
|
|
85
|
+
`&&r++,s+=a[p],p++}p>=a.length&&t.push({message:"unterminated string",line:r}),e.push({kind:"id",value:s,line:r}),o=p+1;continue}if(/[A-Za-z0-9_]/.test(u)){let p=o,s="";for(;p<a.length&&/[A-Za-z0-9_.\-]/.test(a[p]);)s+=a[p],p++;e.push({kind:"id",value:s,line:r}),o=p;continue}t.push({message:`unexpected character '${u}'`,line:r}),o++}return{toks:e,errors:t}}function $s(i){return i==="true"?!0:i==="false"?!1:/^-?\d+$/.test(i)?Number(i):i}function bt(i){let{toks:e,errors:t}=As(i),r=[],o=[],a=new Map,u="harness",p=0,s=()=>e[p],l=()=>e[p++],d=(b,A)=>t.push({message:b,line:A});s()?.kind==="id"&&s()?.value==="digraph"?(l(),s()?.kind==="id"&&s()?.value!==void 0&&(u=l().value),s()?.kind==="lbrace"?l():d("expected '{' after digraph header",s()?.line)):d("expected 'digraph' keyword",s()?.line);function f(){let b={};if(s()?.kind!=="lbrack")return{attrs:b};let A=l().line;for(;s()&&s().kind!=="rbrack";){let N=l();if(!N||N.kind!=="id"){d("expected attribute name",N?.line);break}if(s()?.kind!=="eq"){d(`expected '=' after attribute '${N.value}'`,N.line);break}l();let F=l();if(!F||F.kind!=="id"){d(`expected value for attribute '${N.value}'`,F?.line);break}b[N.value]=F.value,s()?.kind==="comma"&&l()}return s()?.kind==="rbrack"?l():d("unterminated attribute list '['",A),{attrs:b,line:A}}function _(b,A){let N=a.get(b);return N||(N={id:b,type:"analyst",attrs:{},files:{},raw:{},line:A},a.set(b,N),r.push(N)),N}function g(b,A,N){b.declared=!0,b.raw={...b.raw,...A},N!==void 0&&(b.line=b.line??N);for(let[F,D]of Object.entries(A))F==="type"?(ws.has(D)||d(`unknown node type '${D}' on node '${b.id}'`,N),b.type=D):F==="context"?b.context=D:_s.has(F)?b.files[F]=D:b.attrs[F]=$s(D)}let v=0;for(;s()&&s().kind!=="rbrace"&&!(v++>1e5);){let b=s();if(b.kind==="semi"){l();continue}if(b.kind!=="id"){d(`unexpected token '${b.value}'`,b.line),l();continue}let A=l();if(s()?.kind==="arrow"){let N=[{id:A.value,line:A.line}];for(;s()?.kind==="arrow";){l();let L=l();if(!L||L.kind!=="id"){d("expected node id after '->'",L?.line);break}N.push({id:L.value,line:L.line})}let{attrs:F,line:D}=f();for(let L=0;L+1<N.length;L++){let U=N[L],ee=N[L+1];_(U.id,U.line),_(ee.id,ee.line);let oe={from:U.id,to:ee.id,raw:{...F},line:D??U.line};F.on!==void 0&&(oe.on=F.on),F.when!==void 0&&(oe.when=F.when),F.do!==void 0&&(oe.do=F.do),o.push(oe)}}else{let{attrs:N,line:F}=f(),D=_(A.value,A.line);g(D,N,F??A.line)}s()?.kind==="semi"&&l()}return s()?.kind==="rbrace"&&l(),{name:u,nodes:r,edges:o,errors:t}}H();var yt=require("fs");var tt={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 Qt(i){if(!i||!(0,yt.existsSync)(i))return structuredClone(tt);let e=ve.load((0,yt.readFileSync)(i,"utf8"))??{};return{...tt,...e,identity:{...tt.identity,...e.identity??{}},agent:{...tt.agent,...e.agent??{}},repo:{...tt.repo,...e.repo??{}},labels:{...tt.labels,...e.labels??{}}}}function ge(i,e){let t=bt((0,yt.readFileSync)(i,"utf8")),r=Qt(e);return{harness:{name:t.name,nodes:t.nodes,edges:t.edges,config:r,sourcePath:i},parseErrors:t.errors}}function nt(i,e={},t={}){let r=[...pt(i,e),...ft(i)],o=p=>{let s=i.nodes.find(f=>f.id===p)?.files.role,l=s&&e.readFile?e.readFile(s):void 0;if(l===void 0)return;let d=zt(l)?.tools;return typeof d=="string"?d:void 0},a=Yi(i),u=Ur(i,a,t.specDir??"",{roleTools:o});return u.push({path:".github/HARNESS.md",contents:Xt(i,a),generated:!0}),{files:u,diagnostics:r}}function wt(i){return i.some(e=>e.level==="error")}H();var xe=require("fs"),fe=require("path"),qr=require("url"),Le=Nt(Mt(),1);function _t(i,e){let t=(0,fe.join)(i,".github","workflows");if(!(0,xe.existsSync)(t))return[];let r=new Set(e.map(o=>o.path));return(0,xe.readdirSync)(t).filter(o=>/\.ya?ml$/.test(o)).map(o=>`.github/workflows/${o}`).filter(o=>!r.has(o)).filter(o=>(0,xe.readFileSync)((0,fe.join)(i,o),"utf8").startsWith(si)).sort()}function he(i){return(0,qr.fileURLToPath)(new URL(`../../${i}`,W))}function X(i){process.stdout.write(JSON.stringify(i,null,2)+`
|
|
86
|
+
`)}function ai(i){for(let e of i){let t=e.level==="error"?Le.default.red("error"):e.level==="warning"?Le.default.yellow("warn"):Le.default.blue("info"),r=e.where?.node?Le.default.dim(` [${e.where.node}]`):"";process.stderr.write(`${t} ${Le.default.dim(e.code)}${r} ${e.message}
|
|
87
|
+
`),e.hint&&process.stderr.write(` ${Le.default.dim("hint: "+e.hint)}
|
|
88
|
+
`)}}function Ce(i){let e=(0,fe.resolve)(i.dot??".github/harness.dot"),t=(0,fe.dirname)(e),r=i.config?(0,fe.resolve)(i.config):void 0;if(!r){for(let a of[(0,fe.join)(t,"foundry.config.yaml"),(0,fe.join)(t,"agents/foundry.config.yaml")])if((0,xe.existsSync)(a)){r=a;break}}let o=t.endsWith(".github")?(0,fe.dirname)(t):t;return{dot:e,config:r,base:t,root:o}}function At(i){return e=>{let t=(0,fe.join)(i,e);try{return(0,xe.existsSync)(t)?(0,xe.readFileSync)(t,"utf8"):void 0}catch{return}}}H();var li=require("child_process"),B=require("fs"),V=require("path");var G=Nt(Mt(),1);var ci=require("path");function it(i,e={}){try{return{ok:!0,out:(0,li.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 Ie(i,e){let t=it(i,{cwd:e});if(!t.ok)return null;try{return JSON.parse(t.out)}catch{return null}}function Vr(){let i=he("actions");return(0,B.readdirSync)(i,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(0,B.existsSync)((0,V.join)(i,e.name,"action.yml"))).map(e=>e.name)}function Yr(i){let e=Qt(i),t=new Map([["build","ready to implement"],["plan","needs design first"]]),r=[];for(let[o,a]of t)r.push({name:e.labels?.[o]??o,description:a,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 Br(i){let e={ok:G.default.green("\u2713"),warn:G.default.yellow("!"),fail:G.default.red("\u2717"),skip:G.default.dim("-")};for(let t of i)process.stdout.write(`${e[t.status]} ${t.name.padEnd(28)} ${t.detail}
|
|
89
|
+
`),t.hint&&t.status!=="ok"&&process.stdout.write(` ${G.default.dim("hint: "+t.hint)}
|
|
90
|
+
`)}function ks(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,V.dirname)(i.sourcePath??""),a=(0,V.join)(e,o,r.files.policy);if(!(0,B.existsSync)(a))return!0;try{let u=ve.load((0,B.readFileSync)(a,"utf8"));return(u?.require_ci??u?.requireCi)!==!1}catch{return!0}})}function Gr(i){let e=[];for(let r of Vr()){let o=he(`actions/${r}`),a=(0,V.join)(i,".github/actions",r);(0,B.mkdirSync)(a,{recursive:!0}),(0,B.cpSync)((0,V.join)(o,"action.yml"),(0,V.join)(a,"action.yml")),(0,B.existsSync)((0,V.join)(o,"dist"))&&(0,B.cpSync)((0,V.join)(o,"dist"),(0,V.join)(a,"dist"),{recursive:!0}),e.push(`.github/actions/${r}/`)}let t=(0,V.join)(i,".github/agent-setup/action.yml");return(0,B.existsSync)(t)||((0,B.mkdirSync)((0,V.dirname)(t),{recursive:!0}),(0,B.writeFileSync)(t,(0,B.readFileSync)(he("skill/templates/agent-setup.yml"),"utf8")),e.push(".github/agent-setup/action.yml")),e}function Es(i){(0,B.mkdirSync)(i,{recursive:!0}),(0,B.cpSync)(he("skill/SKILL.md"),(0,V.join)(i,"SKILL.md")),(0,B.cpSync)(he("skill/reference"),(0,V.join)(i,"reference"),{recursive:!0}),(0,B.cpSync)(he("skill/templates"),(0,V.join)(i,"templates"),{recursive:!0})}function Wr(i){let e=[],{dot:t,config:r,base:o,root:a}=Ce(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:u,parseErrors:p}=ge(t,r),s=j=>(0,B.existsSync)((0,V.join)(o,j)),l=(0,ci.relative)(a,o).replace(/\\/g,"/"),{files:d,diagnostics:f}=nt(u,{fileExists:s,readFile:At(o)},{specDir:l}),_=f.filter(j=>j.level==="error").length+p.length,g=f.filter(j=>j.level==="warning");e.push(_?{name:"validate",status:"fail",detail:`${_} error(s)`,hint:"run `gp-foundry validate` for details"}:{name:"validate",status:g.length?"warn":"ok",detail:g.length?`${g.length} warning(s): ${g.map(j=>j.code).join(", ")}`:"no diagnostics"});let v=d.filter(j=>{let ue=(0,V.join)(a,j.path);return((0,B.existsSync)(ue)?(0,B.readFileSync)(ue,"utf8"):null)!==j.contents}),b=_t(a,d),A=[...v.map(j=>j.path),...b.map(j=>`${j} (stale)`)];if(e.push(A.length?{name:"workflows in sync",status:"fail",detail:`${A.length} file(s) out of sync: ${A.slice(0,3).join(", ")}${A.length>3?", \u2026":""}`,hint:"run `gp-foundry build`"}:{name:"workflows in sync",status:"ok",detail:`${d.length} generated files match`}),(u.config.runtime?.mode??"pinned")==="vendored"){let j=Vr().filter(ue=>!(0,B.existsSync)((0,V.join)(a,".github/actions",ue,"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,V.join)(a,".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`)"}),!it(["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 F=Ie(["repo","view","--json","nameWithOwner,defaultBranchRef"],a);if(!F)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:F.nameWithOwner});let D=F.defaultBranchRef?.name;D&&e.push(D===u.config.repo.base_branch?{name:"base branch",status:"ok",detail:D}:{name:"base branch",status:"fail",detail:`config says '${u.config.repo.base_branch}' but the repo default is '${D}'`,hint:"fix repo.base_branch in foundry.config.yaml and re-run `gp-foundry up`"});let L=new Set((Ie(["label","list","--json","name","--limit","1000"],a)??[]).map(j=>j.name)),U=Yr(r).map(j=>j.name),ee=U.filter(j=>!L.has(j));e.push(ee.length?{name:"labels",status:"fail",detail:`missing: ${ee.join(", ")}`,hint:"run `gp-foundry up` to create them"}:{name:"labels",status:"ok",detail:U.join(", ")});let oe=new Set((Ie(["secret","list","--json","name"],a)??[]).map(j=>j.name)),te=[u.config.agent.api_key_secret||(u.config.agent.oauth_token_secret??"CLAUDE_CODE_OAUTH_TOKEN")],ce=u.config.auth;ce?.mode==="pat"&&ce.token_secret&&te.push(ce.token_secret),ce?.mode==="app"&&te.push(ce.app_id_secret??"APP_ID",ce.app_key_secret??"APP_PRIVATE_KEY");let be=te.filter(j=>!oe.has(j));if(e.push(be.length?{name:"secrets",status:"fail",detail:`missing: ${be.join(", ")}`,hint:`gh secret set ${be[0]}`}:{name:"secrets",status:"ok",detail:te.join(", ")}),ks(u,a)){let ue=d.filter(se=>/\/workflows\/.*\.yml$/.test(se.path)&&se.contents.includes("actions/merge-gate")).map(se=>(0,V.join)(a,se.path)).filter(se=>(0,B.existsSync)(se)).map(se=>(0,B.readFileSync)(se,"utf8")),Z=ue.filter(se=>!se.includes("checks-token"));ue.length&&Z.length&&e.push({name:"merge gate ci read",status:"fail",detail:`${Z.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 me=it(["--version"]);try{let j=(0,li.execFileSync)("git",["status","--porcelain",".github"],{cwd:a,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 Ss(i){let{dot:e,config:t,root:r}=Ce(i);if(!it(["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=Ie(["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:a}=ge(e,t),u=a.config.repo.branch_prefix,p=Date.now(),s=A=>Math.round((p-Date.parse(A))/36e5),l={};for(let A of["plan","build","needs-human"]){let N=A==="needs-human"?"needs-human":a.config.labels?.[A]??A,F=Ie(["issue","list","--label",N,"--state","open","--json","number,title,createdAt","--limit","50"],r)??[];l[N]=F.map(D=>({number:D.number,title:D.title,ageHours:s(D.createdAt)}))}let f=(Ie(["pr","list","--state","open","--json","number,title,labels,mergeable,headRefName,body,updatedAt","--limit","50"],r)??[]).filter(A=>A.headRefName.startsWith(u)),_=[],g=new Set;for(let A of f)for(let N of A.body?.matchAll(/[Cc]loses #(\d+)/g)??[])g.add(Number(N[1]));let v=a.config.labels?.build??"build";for(let A of l[v]??[])!g.has(A.number)&&A.ageHours>=2&&_.push({kind:"issue-no-pr",number:A.number,title:A.title,detail:`labeled ${v} ${A.ageHours}h ago, no open PR closes it`});for(let A of f)A.updatedAt&&s(A.updatedAt)>=4&&_.push({kind:"pr-idle",number:A.number,title:A.title,detail:`no activity for ${s(A.updatedAt)}h`});let b=(Ie(["run","list","--status","failure","--limit","15","--json","name,url,createdAt,conclusion"],r)??[]).filter(A=>s(A.createdAt)<=24).map(A=>({workflow:A.name,url:A.url,ageHours:s(A.createdAt)}));return{repo:o.nameWithOwner,lanes:l,prs:f.map(A=>({number:A.number,title:A.title,labels:A.labels.map(N=>N.name),mergeable:A.mergeable,headRefName:A.headRefName})),stalled:_,recentFailures:b}}function Kr(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=Gr(e.dir);if(e.json)return X({written:t});for(let r of t)process.stdout.write(G.default.green(`vendored ${r}
|
|
86
91
|
`));process.stdout.write(G.default.dim(`commit .github/actions/ \u2014 the generated workflows reference these local paths
|
|
87
|
-
`))}),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
|
|
92
|
+
`))}),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,V.join)(t,".claude/skills/gp-foundry"):(0,V.join)(e.dir,".claude/skills/gp-foundry");if(Es(r),e.json)return X({installed:r});process.stdout.write(G.default.green(`installed skill \u2192 ${r}
|
|
88
93
|
`)),process.stdout.write(G.default.dim(`In Claude Code, type /gp-foundry (or just ask: "set up an agent pipeline for this repo").
|
|
89
94
|
The skill interviews you Socratically, drafts harness.dot + roles, and drives this CLI.
|
|
90
|
-
`))}),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:
|
|
95
|
+
`))}),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}=Wr(e);e.json?X({ok:!r,checks:t}):(Br(t),process.stdout.write(r?G.default.red(`
|
|
91
96
|
not ready \u2014 fix the \u2717 items above
|
|
92
97
|
`):G.default.green(`
|
|
93
98
|
factory is ready
|
|
94
|
-
`))),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
|
|
95
|
-
`)),
|
|
96
|
-
`))),process.exit(1)),e.json)return
|
|
97
|
-
${
|
|
99
|
+
`))),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=Ss(e);if("error"in t&&(e.json?X(t):(process.stderr.write(G.default.red(t.error+`
|
|
100
|
+
`)),t.hint&&process.stderr.write(G.default.dim("hint: "+t.hint+`
|
|
101
|
+
`))),process.exit(1)),e.json)return X(t);process.stdout.write(G.default.bold(`
|
|
102
|
+
${t.repo} \u2014 factory status
|
|
98
103
|
|
|
99
|
-
`));for(let[r,o]of Object.entries(
|
|
100
|
-
`));for(let
|
|
104
|
+
`));for(let[r,o]of Object.entries(t.lanes)){process.stdout.write(G.default.cyan(`${r} (${o.length})
|
|
105
|
+
`));for(let a of o.slice(0,10))process.stdout.write(` #${a.number} ${a.title} ${G.default.dim(`(${a.ageHours}h)`)}
|
|
101
106
|
`)}process.stdout.write(G.default.cyan(`
|
|
102
|
-
agent PRs (${
|
|
103
|
-
`));for(let r of
|
|
104
|
-
`);if(
|
|
105
|
-
stalled (${
|
|
106
|
-
`));for(let r of
|
|
107
|
-
`)}if(
|
|
108
|
-
failed runs, last 24h (${
|
|
109
|
-
`));for(let r of
|
|
110
|
-
`)}!
|
|
107
|
+
agent PRs (${t.prs.length})
|
|
108
|
+
`));for(let r of t.prs)process.stdout.write(` #${r.number} ${r.title} ${G.default.dim(r.mergeable??"")} ${r.labels.length?G.default.yellow(r.labels.join(",")):""}
|
|
109
|
+
`);if(t.stalled.length){process.stdout.write(G.default.red(`
|
|
110
|
+
stalled (${t.stalled.length})
|
|
111
|
+
`));for(let r of t.stalled)process.stdout.write(` #${r.number} ${r.title} \u2014 ${r.detail}
|
|
112
|
+
`)}if(t.recentFailures.length){process.stdout.write(G.default.red(`
|
|
113
|
+
failed runs, last 24h (${t.recentFailures.length})
|
|
114
|
+
`));for(let r of t.recentFailures.slice(0,10))process.stdout.write(` ${r.workflow} ${G.default.dim(`${r.ageHours}h ago`)} ${r.url}
|
|
115
|
+
`)}!t.stalled.length&&!t.recentFailures.length&&process.stdout.write(G.default.green(`
|
|
111
116
|
no stalled work, no recent failures
|
|
112
|
-
`))}),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:
|
|
113
|
-
`))}else u.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(G.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:
|
|
114
|
-
`)));let
|
|
115
|
-
`));let
|
|
116
|
-
`),
|
|
117
|
+
`))}),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:a}=Ce(e),u={};if(it(["auth","status"]).ok&&Ie(["repo","view","--json","nameWithOwner"],a)){let A=[];for(let N of Yr(r))it(["label","create",N.name,"--color",N.color,"--description",N.description],{cwd:a}).ok&&A.push(N.name);u.labels=A,e.json||process.stdout.write(G.default.green(`labels ensured (created: ${A.length?A.join(", "):"none \u2014 already present"})
|
|
118
|
+
`))}else u.labels="skipped (gh unavailable or no GitHub repo)",e.json||process.stdout.write(G.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:p}=ge(t,r);(p.config.runtime?.mode??"pinned")==="vendored"&&(u.vendored=Gr(a),e.json||process.stdout.write(G.default.green(`vendored ${u.vendored.length} runtime action(s)
|
|
119
|
+
`)));let s=A=>(0,B.existsSync)((0,V.join)(o,A)),l=(0,ci.relative)(a,o).replace(/\\/g,"/"),{files:d,diagnostics:f}=nt(p,{fileExists:s,readFile:At(o)},{specDir:l});wt(f)&&(e.json?X({ok:!1,diagnostics:f}):process.stderr.write(G.default.red("build errors \u2014 run `gp-foundry validate` for details\n")),process.exit(1));for(let A of d){let N=(0,V.join)(a,A.path);(0,B.mkdirSync)((0,V.dirname)(N),{recursive:!0}),(0,B.writeFileSync)(N,A.contents)}u.wrote=d.map(A=>A.path);let _=_t(a,d);for(let A of _)(0,B.rmSync)((0,V.join)(a,A));u.removed=_,_.length&&!e.json&&process.stdout.write(G.default.yellow(`removed ${_.length} stale generated workflow(s): ${_.join(", ")}
|
|
120
|
+
`));let g=d.filter(A=>A.path.startsWith(".github/workflows/")).length;e.json||process.stdout.write(G.default.green(`built ${g} workflows + HARNESS.md
|
|
121
|
+
`));let{checks:v,failed:b}=Wr(e);if(u.checks=v,u.ok=!b,e.json)return X(u);process.stdout.write(`
|
|
122
|
+
`),Br(v),process.stdout.write(b?G.default.yellow(`
|
|
117
123
|
almost there \u2014 fix the \u2717 items above, commit .github/, push, then file an issue
|
|
118
124
|
`):G.default.green(`
|
|
119
125
|
factory is up \u2014 commit .github/, push, then file an issue to watch it run
|
|
120
|
-
`)),process.exit(
|
|
121
|
-
`));for(let
|
|
122
|
-
`));process.stdout.write(["",
|
|
123
|
-
`))});
|
|
124
|
-
`)),process.exit(1));let{harness:
|
|
125
|
-
`));process.exit(1)}let
|
|
126
|
-
`));
|
|
127
|
-
`));
|
|
128
|
-
`))
|
|
129
|
-
`)
|
|
130
|
-
`)
|
|
131
|
-
`)
|
|
132
|
-
`))
|
|
133
|
-
`))
|
|
134
|
-
`)),
|
|
135
|
-
`)
|
|
136
|
-
`))
|
|
137
|
-
`)),process.exit(1))
|
|
138
|
-
`)});
|
|
126
|
+
`)),process.exit(b?1:0)})}var He=new Si,vs=JSON.parse((0,Y.readFileSync)(he("package.json"),"utf8")).version;He.name("gp-foundry").description("Compile a DOT harness spec into GitHub Actions.").version(vs);function xs(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 a=zt((0,Y.readFileSync)(o,"utf8"));a&&t.set(r.id,a)}}return t}var Cs=[["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"]];He.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=(p,s)=>{let l=(0,ne.join)(e,p);if((0,Y.existsSync)(l)&&!i.force){r.push(p);return}(0,Y.mkdirSync)((0,ne.dirname)(l),{recursive:!0}),(0,Y.writeFileSync)(l,s),t.push(p)},a="main";try{let p=(0,Jr.execFileSync)("git",["symbolic-ref","--short","HEAD"],{cwd:e,encoding:"utf8"}).trim();p&&(a=p)}catch{}for(let[p,s]of Cs){let l=(0,Y.readFileSync)(he(p),"utf8");s.endsWith("foundry.config.yaml")&&a!=="main"&&(l=l.replace(/^(\s*base_branch:\s*)main\b/m,`$1${a}`)),o(s,l)}let u=(0,ne.join)(e,".github/harness.dot");if((0,Y.existsSync)(u))for(let p of bt((0,Y.readFileSync)(u,"utf8")).nodes){if(!p.files.role)continue;let s=p.files.role.replace(/^.*\//,"").replace(/\.md$/,""),l=he(`roles/software/${s}.md`),d=(0,Y.existsSync)(l)?l:he("skill/templates/role.md");o((0,ne.join)(".github",p.files.role),(0,Y.readFileSync)(d,"utf8"))}if(i.json)return X({written:t,skipped:r});for(let p of t)process.stdout.write(J.default.green(`created ${p}
|
|
127
|
+
`));for(let p of r)process.stderr.write(J.default.yellow(`skipped ${p} (exists; --force to overwrite)
|
|
128
|
+
`));process.stdout.write(["",J.default.bold("Next steps \u2014 dark factory in 4 moves:"),` 1. ${J.default.cyan("gp-foundry up")} vendor actions, create labels, build workflows, run checks`,` 2. set two secrets: ${J.default.cyan("gh secret set CLAUDE_CODE_OAUTH_TOKEN")} (agent auth)`,` ${J.default.cyan("gh secret set AGENT_PAT")} (fine-grained PAT: contents/PRs/issues RW)`,` 3. commit + push ${J.default.cyan(".github/")}`," 4. file an issue \u2192 the \u{1F575}\uFE0F scout triages it and the factory takes it from there","",J.default.dim("Tune later: .github/harness.dot (topology) \xB7 agents/roles/*.md (behavior) \xB7 agents/policy/merge.yaml (merge rules)"),""].join(`
|
|
129
|
+
`))});He.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}=Ce(i);(0,Y.existsSync)(e)||(i.json?X({error:`no harness.dot at ${e}`}):process.stderr.write(J.default.red(`no harness.dot at ${e}
|
|
130
|
+
`)),process.exit(1));let{harness:a,parseErrors:u}=ge(e,t);if(u.length){if(i.json)X({parseErrors:u});else for(let g of u)process.stderr.write(J.default.red(`parse: ${g.message}${g.line?` (line ${g.line})`:""}
|
|
131
|
+
`));process.exit(1)}let p=(0,ne.resolve)(i.out??o),s=(0,ne.relative)(p,r).replace(/\\/g,"/"),l=g=>(0,Y.existsSync)((0,ne.join)(r,g)),{files:d,diagnostics:f}=nt(a,{fileExists:l,readFile:At(r)},{specDir:s});i.json||ai(f);let _=_t(p,d);if(i.check){let g=d.filter(b=>{let A=(0,ne.join)(p,b.path);return((0,Y.existsSync)(A)?(0,Y.readFileSync)(A,"utf8"):null)!==b.contents}),v=g.length===0&&_.length===0;if(i.json)X({upToDate:v,drift:g.map(b=>b.path),stale:_,diagnostics:f});else if(v)process.stdout.write(J.default.green(`up to date
|
|
132
|
+
`));else{for(let b of g)process.stderr.write(J.default.yellow(`drift: ${b.path}
|
|
133
|
+
`));for(let b of _)process.stderr.write(J.default.yellow(`stale: ${b} (no longer generated)
|
|
134
|
+
`));process.stderr.write(J.default.red("generated files are out of date \u2014 run `gp-foundry build`\n"))}process.exit(v?0:1)}if(wt(f)&&!i.force&&(i.json?X({ok:!1,diagnostics:f,wrote:[]}):process.stderr.write(J.default.red(`errors present \u2014 not writing (use --force to override)
|
|
135
|
+
`)),process.exit(1)),i.dryRun){if(i.json)X({diagnostics:f,files:d,stale:_});else{for(let g of d)process.stdout.write(J.default.cyan(`--- ${g.path}
|
|
136
|
+
`)+g.contents+`
|
|
137
|
+
`);for(let g of _)process.stdout.write(J.default.yellow(`would remove ${g} (no longer generated)
|
|
138
|
+
`))}return}for(let g of d){let v=(0,ne.join)(p,g.path);(0,Y.mkdirSync)((0,ne.dirname)(v),{recursive:!0}),(0,Y.writeFileSync)(v,g.contents),i.json||process.stdout.write(J.default.green(`wrote ${g.path}
|
|
139
|
+
`))}for(let g of _)(0,Y.rmSync)((0,ne.join)(p,g)),i.json||process.stdout.write(J.default.yellow(`removed ${g} (no longer generated)
|
|
140
|
+
`));i.json&&X({ok:!wt(f),diagnostics:f,wrote:d.map(g=>g.path),removed:_})});He.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}=Ce(i);(0,Y.existsSync)(e)||(i.json?X({ok:!1,error:`no harness.dot at ${e}`}):process.stderr.write(J.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
141
|
+
`)),process.exit(1));let{harness:o,parseErrors:a}=ge(e,t),u=d=>(0,Y.existsSync)((0,ne.join)(r,d)),p=xs(o,r),s=[...pt(o,{fileExists:u,roles:p}),...ft(o)],l=s.some(d=>d.level==="error")||a.length>0;if(i.json)X({ok:!l,parseErrors:a,diagnostics:s});else{for(let d of a)process.stderr.write(J.default.red(`parse: ${d.message}
|
|
142
|
+
`));ai(s)}process.exit(l?1:0)});He.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}=Ce(i);(0,Y.existsSync)(e)||(i.json?X({error:`no harness.dot at ${e}`}):process.stderr.write(J.default.red(`no harness.dot at ${e} \u2014 run \`gp-foundry init\` first
|
|
143
|
+
`)),process.exit(1));let{harness:t}=ge(e);i.json?X({name:t.name,nodes:t.nodes,edges:t.edges}):process.stdout.write(Xt(t)+`
|
|
144
|
+
`)});He.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}=Ce(e);(0,Y.existsSync)(t)||(e.json?X({error:`no harness.dot at ${t}`}):process.stderr.write(J.default.red(`no harness.dot at ${t} \u2014 run \`gp-foundry init\` first
|
|
145
|
+
`)),process.exit(1));let{harness:o}=ge(t,r),{files:a}=nt(o),u=a.find(p=>p.path.endsWith(`/${i}.yml`))??a.find(p=>p.path.startsWith(".github/workflows/")&&new RegExp(`^ ${i}:`,"m").test(p.contents));u||(e.json?X({error:`no generated workflow for node '${i}'`}):process.stderr.write(J.default.red(`no generated workflow for node '${i}'
|
|
146
|
+
`)),process.exit(1)),e.json?X({node:i,path:u.path,contents:u.contents}):process.stdout.write(u.contents+`
|
|
147
|
+
`)});Kr(He);He.parseAsync(process.argv);
|